diff --git a/package-lock.json b/package-lock.json index 3206f63..998caeb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@kuestcom/builder-relayer-client", - "version": "2.0.5", + "version": "2.0.6", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@kuestcom/builder-relayer-client", - "version": "2.0.5", + "version": "2.0.6", "dependencies": { "@kuestcom/builder-signing-sdk": "^2.0.2", "axios": "^1.16.1", diff --git a/package.json b/package.json index 338652b..2d73c38 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@kuestcom/builder-relayer-client", "description": "Wallet-only client for Kuest relayers", - "version": "2.0.5", + "version": "2.0.6", "main": "dist/index.js", "types": "dist/index.d.ts", "files": [ diff --git a/src/builder/derive.ts b/src/builder/derive.ts index d0d45a5..769612f 100644 --- a/src/builder/derive.ts +++ b/src/builder/derive.ts @@ -9,21 +9,22 @@ import { toHex, } from "viem"; -const ERC1967_CONST1: Hex = "0xcc3735a920a3ca505d382bbc545af43d6000803e6038573d6000fd5b3d6000f3"; -const ERC1967_CONST2: Hex = "0x5155f3363d3d373d3d363d7f360894a13ba1a3210667c828492db98dca3e2076"; -const ERC1967_PREFIX = 0x61003d3d8160233d3973n; +const ERC1967_BEACON_CONST1: Hex = "0x60195155f3363d3d373d3d363d602036600436635c60da"; +const ERC1967_BEACON_CONST2: Hex = "0x1b60e01b36527fa3f0ad74e5423aebfd80d3ef4346578335a9a72aeaee59ff6c"; +const ERC1967_BEACON_CONST3: Hex = "0xb3582b35133d50545afa5036515af43d6000803e604d573d6000fd5b3d6000f3"; +const ERC1967_BEACON_PREFIX = 0x6100523d8160233d3973n; -function initCodeHashERC1967(implementation: Address, args: Hex): Hex { +function initCodeHashERC1967BeaconProxy(beacon: Address, args: Hex): Hex { const n = BigInt((args.length - 2) / 2); - const combined = ERC1967_PREFIX + (n << 56n); + const combined = ERC1967_BEACON_PREFIX + (n << 56n); return keccak256( concat([ toHex(combined, { size: 10 }), - implementation as Hex, - "0x6009", - ERC1967_CONST2, - ERC1967_CONST1, + beacon as Hex, + ERC1967_BEACON_CONST1, + ERC1967_BEACON_CONST2, + ERC1967_BEACON_CONST3, args, ]), ); @@ -32,7 +33,7 @@ function initCodeHashERC1967(implementation: Address, args: Hex): Hex { export const deriveDepositWallet = ( owner: string, factory: string, - implementation: string, + beacon: string, ): string => { const walletId = pad(owner as Hex, { dir: "left", size: 32 }); const args = encodeAbiParameters( @@ -40,7 +41,7 @@ export const deriveDepositWallet = ( [factory as Address, walletId], ); const salt = keccak256(args); - const bytecodeHash = initCodeHashERC1967(implementation as Address, args); + const bytecodeHash = initCodeHashERC1967BeaconProxy(beacon as Address, args); return getCreate2Address({ from: factory as Hex, salt, bytecodeHash }); }; diff --git a/src/client.ts b/src/client.ts index 258362f..943f1df 100644 --- a/src/client.ts +++ b/src/client.ts @@ -162,7 +162,7 @@ export class RelayClient { return deriveDepositWallet( address, config.DepositWalletFactory, - config.DepositWalletImplementation, + config.DepositWalletBeacon, ); } diff --git a/src/config/index.ts b/src/config/index.ts index 5954563..de77559 100644 --- a/src/config/index.ts +++ b/src/config/index.ts @@ -1,5 +1,6 @@ export interface DepositWalletContractConfig { DepositWalletFactory: string; + DepositWalletBeacon: string; DepositWalletImplementation: string; } @@ -8,8 +9,9 @@ export interface ContractConfig { } const DEPOSIT_WALLET_CONFIG: DepositWalletContractConfig = { - DepositWalletFactory: "0x3DaBe8f032833CE42CC26d9149660E6f596759C5", - DepositWalletImplementation: "0xFB2f5D822Ecb062dE63a7B830C5e83C994698851", + DepositWalletFactory: "0x2CcdC6C5dDcd895aFcCD259F291de9b618A5cA6c", + DepositWalletBeacon: "0x74a618eBdd62Ff8579A8FE94f5B888d7623b9C35", + DepositWalletImplementation: "0xf9dFAe108bF7d7aaa9E6D8c1aB281c6285BAF86c", }; const AMOY: ContractConfig = { @@ -23,7 +25,7 @@ const POLYGON: ContractConfig = { export function isDepositWalletContractConfigValid( config: DepositWalletContractConfig, ): boolean { - return !!config.DepositWalletFactory && !!config.DepositWalletImplementation; + return !!config.DepositWalletFactory && !!config.DepositWalletBeacon; } export const getContractConfig = (chainId: number): ContractConfig => { diff --git a/tests/signatures/index.test.ts b/tests/signatures/index.test.ts index f916015..7d8073d 100644 --- a/tests/signatures/index.test.ts +++ b/tests/signatures/index.test.ts @@ -36,11 +36,11 @@ describe("deposit wallet relayer requests", () => { const address = deriveDepositWallet( owner, config.DepositWalletFactory, - config.DepositWalletImplementation, + config.DepositWalletBeacon, ); expect(address).match(/^0x[0-9a-fA-F]{40}$/); - expect(address).equal("0x053258Cfb6124a089363F89dA04b2eFa39b34e2d"); + expect(address).equal("0xF3ab66D34F0B14C9a4f8564Ec8baaBBf51ad0Fd6"); }); it("signs wallet batch requests", async () => { @@ -48,7 +48,7 @@ describe("deposit wallet relayer requests", () => { const walletAddress = deriveDepositWallet( owner, config.DepositWalletFactory, - config.DepositWalletImplementation, + config.DepositWalletBeacon, ); const request = await buildDepositWalletBatchRequest( signer,