Skip to content
This repository was archived by the owner on Oct 21, 2026. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
23 changes: 12 additions & 11 deletions src/builder/derive.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
]),
);
Expand All @@ -32,15 +33,15 @@ 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(
[{ type: "address" }, { type: "bytes32" }],
[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 });
};
2 changes: 1 addition & 1 deletion src/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -162,7 +162,7 @@ export class RelayClient {
return deriveDepositWallet(
address,
config.DepositWalletFactory,
config.DepositWalletImplementation,
config.DepositWalletBeacon,
);
}

Expand Down
8 changes: 5 additions & 3 deletions src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
export interface DepositWalletContractConfig {
DepositWalletFactory: string;
DepositWalletBeacon: string;
DepositWalletImplementation: string;
}

Expand All @@ -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 = {
Expand All @@ -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 => {
Expand Down
6 changes: 3 additions & 3 deletions tests/signatures/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,19 +36,19 @@ 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 () => {
const signer = createAbstractSigner(chainId, wallet);
const walletAddress = deriveDepositWallet(
owner,
config.DepositWalletFactory,
config.DepositWalletImplementation,
config.DepositWalletBeacon,
);
const request = await buildDepositWalletBatchRequest(
signer,
Expand Down
Loading