diff --git a/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowUtils.ts b/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowUtils.ts index a25b3a73..13238089 100644 --- a/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowUtils.ts +++ b/apps/web/src/modules/create-proposal/components/TransactionForm/Escrow/EscrowUtils.ts @@ -1,5 +1,5 @@ import { decode, encode } from 'bs58' -import { Address, Hex, encodeAbiParameters } from 'viem' +import { Address, Hex, encodeAbiParameters, toBytes, toHex } from 'viem' import { create } from 'zustand' import { createJSONStorage, persist } from 'zustand/middleware' @@ -7,8 +7,11 @@ import { CHAIN_ID } from 'src/typings' import { EscrowFormState, EscrowFormValues } from './EscrowForm.schema' -const KLEROS_ARBITRATION_PROVIDER = +const ESCROW_KLEROS_ARBITRATION_PROVIDER = '0x18542245cA523DFF96AF766047fE9423E0BED3C0' as Address +const ESCROW_RESOLVER_TYPE = 0 +const ESCROW_REQUIRE_VERIFICATION = true +const ESCROW_TYPE = toHex(toBytes('updatable', { size: 32 })) export function convertIpfsCidV0ToByte32(cid: string) { return `0x${Buffer.from(decode(cid).slice(2)).toString('hex')}` @@ -26,21 +29,21 @@ function getWrappedTokenAddress(chainId: number | string): Address { chainId = Number(chainId) switch (chainId) { case CHAIN_ID.ETHEREUM: - return '0xb4cdef4aa610c046864467592fae456a58d3443a' as Address + return '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2' as Address case CHAIN_ID.OPTIMISM: - return '0xdafeb89f713e25a02e4ec21a18e3757d7a76d19e' as Address + return '0x4200000000000000000000000000000000000006' as Address case CHAIN_ID.BASE: - return '0xf4640751e7363a0572d4ba93a9b049b956b33c17' as Address + return '0x4200000000000000000000000000000000000006' as Address case CHAIN_ID.ZORA: - return '0x0325e1b676c4cf59e0b690a05e0181be862193d4' as Address + return '0x4200000000000000000000000000000000000006' as Address case CHAIN_ID.SEPOLIA: - return '0x9c1E057B37605B7f6ed6f4c8E2826C3d84ddC08D' as Address + return '0xfFf9976782d46CC05630D1f6eBAb18b2324d6B14' as Address case CHAIN_ID.OPTIMISM_SEPOLIA: - return '0xe0986c3bdab537fbeb7c94d0c5ef961d6d8bf63a' as Address + return '0x4200000000000000000000000000000000000006' as Address case CHAIN_ID.BASE_SEPOLIA: - return '0x3add1d027116a5406ced10411945cf2d4d9ed68e' as Address + return '0x4200000000000000000000000000000000000006' as Address case CHAIN_ID.ZORA_SEPOLIA: - return '0x851e59a39571e599954702f0e4996bf838d9c863' as Address + return '0x4200000000000000000000000000000000000006' as Address default: throw new Error(`Unsupported chain ID: ${chainId}`) } @@ -49,15 +52,22 @@ function getWrappedTokenAddress(chainId: number | string): Address { function getEscrowBundler(chainId: number | string): Address { chainId = Number(chainId) switch (chainId) { - // @notice: update these when deployed - // case 1: // mainnet - // return '0xe0D0d4927Af5cEed02146e3905bA016301194D43' as Address - // case 10: // optimism - // return '0xe0D0d4927Af5cEed02146e3905bA016301194D43' as Address - case 11155111: // sepolia - return '0x8F9999B2d5C8DC0Eea10753E76c225843ffFc4b3' as Address - // case 8453: // base - // return '0xe0D0d4927Af5cEed02146e3905bA016301194D43' as Address + case CHAIN_ID.ETHEREUM: + return '0xb4cdef4aa610c046864467592fae456a58d3443a' as Address + case CHAIN_ID.OPTIMISM: + return '0xdafeb89f713e25a02e4ec21a18e3757d7a76d19e' as Address + case CHAIN_ID.BASE: + return '0xf4640751e7363a0572d4ba93a9b049b956b33c17' as Address + case CHAIN_ID.ZORA: + return '0x0325e1b676c4cf59e0b690a05e0181be862193d4' as Address + case CHAIN_ID.SEPOLIA: + return '0x9c1E057B37605B7f6ed6f4c8E2826C3d84ddC08D' as Address + case CHAIN_ID.OPTIMISM_SEPOLIA: + return '0xe0986c3bdab537fbeb7c94d0c5ef961d6d8bf63a' as Address + case CHAIN_ID.BASE_SEPOLIA: + return '0x3add1d027116a5406ced10411945cf2d4d9ed68e' as Address + case CHAIN_ID.ZORA_SEPOLIA: + return '0x851e59a39571e599954702f0e4996bf838d9c863' as Address default: throw new Error(`Unsupported chain ID: ${chainId}`) } @@ -74,17 +84,29 @@ function createEscrowData( // encode abi parameters to create escrowData const encodedParams = encodeAbiParameters( - ['address', 'address', 'address', 'uint256', 'bytes32', 'address', 'address'].map( - (type) => ({ type }) - ), + [ + 'address', + 'address', + 'uint8', + 'address', + 'uint256', + 'bytes32', + 'address', + 'address', + 'bool', + 'bytes32', + ].map((type) => ({ type })), [ values.clientAddress, - KLEROS_ARBITRATION_PROVIDER, + ESCROW_KLEROS_ARBITRATION_PROVIDER, + ESCROW_RESOLVER_TYPE, warappedTokenAddress, terminationTime, ipfsBytesCid, values.recipientAddress, values.recipientAddress, + ESCROW_REQUIRE_VERIFICATION, + ESCROW_TYPE, ] ) @@ -161,7 +183,7 @@ const useEscrowFormStore = create( export { createEscrowData, getEscrowBundler, - KLEROS_ARBITRATION_PROVIDER, + ESCROW_KLEROS_ARBITRATION_PROVIDER, deployEscrowAbi, useEscrowFormStore, }