1
1
import { decode , encode } from 'bs58'
2
- import { Address , Hex , encodeAbiParameters } from 'viem'
2
+ import { Address , Hex , encodeAbiParameters , toBytes , toHex } from 'viem'
3
3
import { create } from 'zustand'
4
4
import { createJSONStorage , persist } from 'zustand/middleware'
5
5
6
+ import { CHAIN_ID } from 'src/typings'
7
+
6
8
import { EscrowFormState , EscrowFormValues } from './EscrowForm.schema'
7
9
8
- const KLEROS_ARBITRATION_PROVIDER =
10
+ const ESCROW_KLEROS_ARBITRATION_PROVIDER =
9
11
'0x18542245cA523DFF96AF766047fE9423E0BED3C0' as Address
12
+ const ESCROW_RESOLVER_TYPE = 0
13
+ const ESCROW_REQUIRE_VERIFICATION = true
14
+ const ESCROW_TYPE = toHex ( toBytes ( 'updatable' , { size : 32 } ) )
10
15
11
16
export function convertIpfsCidV0ToByte32 ( cid : string ) {
12
17
return `0x${ Buffer . from ( decode ( cid ) . slice ( 2 ) ) . toString ( 'hex' ) } `
@@ -23,13 +28,21 @@ export function convertByte32ToIpfsCidV0(str: Hex) {
23
28
function getWrappedTokenAddress ( chainId : number | string ) : Address {
24
29
chainId = Number ( chainId )
25
30
switch ( chainId ) {
26
- case 1 : // mainnet
31
+ case CHAIN_ID . ETHEREUM :
27
32
return '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' as Address
28
- case 10 : // optimism
33
+ case CHAIN_ID . OPTIMISM :
34
+ return '0x4200000000000000000000000000000000000006' as Address
35
+ case CHAIN_ID . BASE :
36
+ return '0x4200000000000000000000000000000000000006' as Address
37
+ case CHAIN_ID . ZORA :
29
38
return '0x4200000000000000000000000000000000000006' as Address
30
- case 11155111 : // sepolia
39
+ case CHAIN_ID . SEPOLIA :
31
40
return '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14' as Address
32
- case 8453 : // base
41
+ case CHAIN_ID . OPTIMISM_SEPOLIA :
42
+ return '0x4200000000000000000000000000000000000006' as Address
43
+ case CHAIN_ID . BASE_SEPOLIA :
44
+ return '0x4200000000000000000000000000000000000006' as Address
45
+ case CHAIN_ID . ZORA_SEPOLIA :
33
46
return '0x4200000000000000000000000000000000000006' as Address
34
47
default :
35
48
throw new Error ( `Unsupported chain ID: ${ chainId } ` )
@@ -39,15 +52,22 @@ function getWrappedTokenAddress(chainId: number | string): Address {
39
52
function getEscrowBundler ( chainId : number | string ) : Address {
40
53
chainId = Number ( chainId )
41
54
switch ( chainId ) {
42
- // @notice : update these when deployed
43
- // case 1: // mainnet
44
- // return '0xe0D0d4927Af5cEed02146e3905bA016301194D43' as Address
45
- // case 10: // optimism
46
- // return '0xe0D0d4927Af5cEed02146e3905bA016301194D43' as Address
47
- case 11155111 : // sepolia
48
- return '0x8F9999B2d5C8DC0Eea10753E76c225843ffFc4b3' as Address
49
- // case 8453: // base
50
- // return '0xe0D0d4927Af5cEed02146e3905bA016301194D43' as Address
55
+ case CHAIN_ID . ETHEREUM :
56
+ return '0xb4cdef4aa610c046864467592fae456a58d3443a' as Address
57
+ case CHAIN_ID . OPTIMISM :
58
+ return '0xdafeb89f713e25a02e4ec21a18e3757d7a76d19e' as Address
59
+ case CHAIN_ID . BASE :
60
+ return '0xf4640751e7363a0572d4ba93a9b049b956b33c17' as Address
61
+ case CHAIN_ID . ZORA :
62
+ return '0x0325e1b676c4cf59e0b690a05e0181be862193d4' as Address
63
+ case CHAIN_ID . SEPOLIA :
64
+ return '0x9c1E057B37605B7f6ed6f4c8E2826C3d84ddC08D' as Address
65
+ case CHAIN_ID . OPTIMISM_SEPOLIA :
66
+ return '0xe0986c3bdab537fbeb7c94d0c5ef961d6d8bf63a' as Address
67
+ case CHAIN_ID . BASE_SEPOLIA :
68
+ return '0x3add1d027116a5406ced10411945cf2d4d9ed68e' as Address
69
+ case CHAIN_ID . ZORA_SEPOLIA :
70
+ return '0x851e59a39571e599954702f0e4996bf838d9c863' as Address
51
71
default :
52
72
throw new Error ( `Unsupported chain ID: ${ chainId } ` )
53
73
}
@@ -64,17 +84,29 @@ function createEscrowData(
64
84
65
85
// encode abi parameters to create escrowData
66
86
const encodedParams = encodeAbiParameters (
67
- [ 'address' , 'address' , 'address' , 'uint256' , 'bytes32' , 'address' , 'address' ] . map (
68
- ( type ) => ( { type } )
69
- ) ,
87
+ [
88
+ 'address' ,
89
+ 'address' ,
90
+ 'uint8' ,
91
+ 'address' ,
92
+ 'uint256' ,
93
+ 'bytes32' ,
94
+ 'address' ,
95
+ 'address' ,
96
+ 'bool' ,
97
+ 'bytes32' ,
98
+ ] . map ( ( type ) => ( { type } ) ) ,
70
99
[
71
100
values . clientAddress ,
72
- KLEROS_ARBITRATION_PROVIDER ,
101
+ ESCROW_KLEROS_ARBITRATION_PROVIDER ,
102
+ ESCROW_RESOLVER_TYPE ,
73
103
warappedTokenAddress ,
74
104
terminationTime ,
75
105
ipfsBytesCid ,
76
106
values . recipientAddress ,
77
107
values . recipientAddress ,
108
+ ESCROW_REQUIRE_VERIFICATION ,
109
+ ESCROW_TYPE ,
78
110
]
79
111
)
80
112
@@ -151,7 +183,7 @@ const useEscrowFormStore = create(
151
183
export {
152
184
createEscrowData ,
153
185
getEscrowBundler ,
154
- KLEROS_ARBITRATION_PROVIDER ,
186
+ ESCROW_KLEROS_ARBITRATION_PROVIDER ,
155
187
deployEscrowAbi ,
156
188
useEscrowFormStore ,
157
189
}
0 commit comments