From 3ea9e2acb7d98d34c7c4bee898ff48d7a6c97352 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 13:23:01 +0100 Subject: [PATCH 01/16] withdrawal address --- .../{allocator.ts => withdrawal-execution.ts} | 54 +++++++++++++++++-- test/withdrawal-execution.test.ts | 21 ++++++++ 2 files changed, 72 insertions(+), 3 deletions(-) rename src/messages/v2.2/{allocator.ts => withdrawal-execution.ts} (50%) create mode 100644 test/withdrawal-execution.test.ts diff --git a/src/messages/v2.2/allocator.ts b/src/messages/v2.2/withdrawal-execution.ts similarity index 50% rename from src/messages/v2.2/allocator.ts rename to src/messages/v2.2/withdrawal-execution.ts index 5d0bc40..f728f93 100644 --- a/src/messages/v2.2/allocator.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -51,8 +51,56 @@ export const getSubmitWithdrawRequestHash = ( return digest; }; -export function getWithdrawalAddress(request: SubmitWithdrawRequest): string { - const withdrawalHash = getSubmitWithdrawRequestHash(request); - const withdrawalAddress = withdrawalHash.slice(2).slice(-40); +export interface WithdrawalAddressParams { + depositoryAddress: string; + depositoryChainId: bigint; + tokenId: bigint; + recipientAddress: string; + amount: bigint; + blockNumber: bigint; + withdrawalNonce?: number; +} + +/** + * Compute deterministic withdrawal address + * + * @param depositoryAddress the depository contract holding the funds on origin chain + * @param depositoryChainId the hub chain id of the depository contract currently holding the funds + * @param tokenId the token id on the hub + * @param recipientAddress the address that will receive the withdrawn funds + * @param amount the balance to withdraw + * @param blockNumber block number when the Oracle witnessed the balance + * @param withdrawalNonce (optional) nonce to prevent collisions for similar withdrawals in the same block + * @returns withdrawal address (in lower case) + */ +export function getWithdrawalAddress( + withdrawalParams: WithdrawalAddressParams +): string { + // pack and hash data + const hash = keccak256( + encodePacked( + [ + "address", + "uint256", + "uint256", + "address", + "uint256", + "uint256", + "uint256", + ], + [ + withdrawalParams.depositoryAddress as `0x${string}`, + withdrawalParams.depositoryChainId, + withdrawalParams.tokenId, + withdrawalParams.recipientAddress as `0x${string}`, + withdrawalParams.amount, + withdrawalParams.blockNumber, + BigInt(withdrawalParams.withdrawalNonce || 0), + ] + ) + ); + + // get 40 bytes for an address + const withdrawalAddress = hash.slice(2).slice(-40).toLowerCase(); return `0x${withdrawalAddress}` as `0x${string}`; } diff --git a/test/withdrawal-execution.test.ts b/test/withdrawal-execution.test.ts new file mode 100644 index 0000000..5247b3d --- /dev/null +++ b/test/withdrawal-execution.test.ts @@ -0,0 +1,21 @@ +import { describe, it, expect } from "vitest"; +import { getWithdrawalAddress } from "../src/messages/v2.2/withdrawal-execution"; +import { getAddress } from "viem"; + +describe("getWithdrawalAddress", () => { + it("should return a valid withdrawal address", () => { + const params = { + depositoryAddress: "0x1234567890123456789012345678901234567890", + depositoryChainId: 1n, + tokenId: 100n, + recipientAddress: "0x9876543210987654321098765432109876543210", + amount: 1000n, + blockNumber: 12345n, + }; + + const address = getWithdrawalAddress(params); + expect(address).toMatch(/^0x[0-9a-f]{40}$/i); + expect(address).toBeTruthy(); + expect(getAddress(address).toLowerCase()).toMatch(address); + }); +}); From bfd91f3d83a3df25092d586574dd0832a2518b8f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 13:28:29 +0100 Subject: [PATCH 02/16] add oracle messages types --- src/messages/v2.2/withdrawal-execution.ts | 30 ++++++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index f728f93..6fa2762 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -57,8 +57,6 @@ export interface WithdrawalAddressParams { tokenId: bigint; recipientAddress: string; amount: bigint; - blockNumber: bigint; - withdrawalNonce?: number; } /** @@ -67,14 +65,17 @@ export interface WithdrawalAddressParams { * @param depositoryAddress the depository contract holding the funds on origin chain * @param depositoryChainId the hub chain id of the depository contract currently holding the funds * @param tokenId the token id on the hub - * @param recipientAddress the address that will receive the withdrawn funds + * @param recipientAddress the address that will receive the withdrawn funds on destination chain * @param amount the balance to withdraw * @param blockNumber block number when the Oracle witnessed the balance * @param withdrawalNonce (optional) nonce to prevent collisions for similar withdrawals in the same block * @returns withdrawal address (in lower case) */ export function getWithdrawalAddress( - withdrawalParams: WithdrawalAddressParams + withdrawalParams: WithdrawalAddressParams & { + blockNumber: bigint; + withdrawalNonce?: number; + } ): string { // pack and hash data const hash = keccak256( @@ -104,3 +105,24 @@ export function getWithdrawalAddress( const withdrawalAddress = hash.slice(2).slice(-40).toLowerCase(); return `0x${withdrawalAddress}` as `0x${string}`; } + +// types for oracle routes +export type WithdrawalInitiationMessage = { + data: { + hubChainId: string; + withdrawalAddressParams: WithdrawalAddressParams; + }; + result: { + withdrawalAddress: string; + }; +}; + +export type WithdrawalInitiatedMessage = { + data: { + hubChainId: string; + withdrawalAddressParams: WithdrawalAddressParams; + }; + result: { + proofOfWithdrawalAddressBalance: string; + }; +}; From 97450de9ff812fbed054916925c0eb8ba5db855a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 13:31:46 +0100 Subject: [PATCH 03/16] add to index --- src/index.ts | 10 ++++++++-- src/messages/v2.2/withdrawal-execution.ts | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index cb17687..5d65690 100644 --- a/src/index.ts +++ b/src/index.ts @@ -64,7 +64,10 @@ import { SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, -} from "./messages/v2.2/allocator"; + WithdrawalAddressParams, + WithdrawalInitiationMessage, + WithdrawalInitiatedMessage, +} from "./messages/v2.2/withdrawal-execution"; export { // Order @@ -126,8 +129,11 @@ export { encodeAction, decodeAction, - // Allocator + // Onchain withdrawals SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, + WithdrawalAddressParams, + WithdrawalInitiationMessage, + WithdrawalInitiatedMessage, }; diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index 6fa2762..b66bc5f 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -57,6 +57,7 @@ export interface WithdrawalAddressParams { tokenId: bigint; recipientAddress: string; amount: bigint; + withdrawalNonce?: number; } /** @@ -74,7 +75,6 @@ export interface WithdrawalAddressParams { export function getWithdrawalAddress( withdrawalParams: WithdrawalAddressParams & { blockNumber: bigint; - withdrawalNonce?: number; } ): string { // pack and hash data From 3f97b4c2d0b019127f599f31a23ecabb8b5f141e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 14:20:00 +0100 Subject: [PATCH 04/16] use currency --- src/messages/v2.2/withdrawal-execution.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index b66bc5f..0756fec 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -54,7 +54,7 @@ export const getSubmitWithdrawRequestHash = ( export interface WithdrawalAddressParams { depositoryAddress: string; depositoryChainId: bigint; - tokenId: bigint; + currency: string; recipientAddress: string; amount: bigint; withdrawalNonce?: number; @@ -65,7 +65,7 @@ export interface WithdrawalAddressParams { * * @param depositoryAddress the depository contract holding the funds on origin chain * @param depositoryChainId the hub chain id of the depository contract currently holding the funds - * @param tokenId the token id on the hub + * @param currency the id of the currency as expressed on origin chain (string) * @param recipientAddress the address that will receive the withdrawn funds on destination chain * @param amount the balance to withdraw * @param blockNumber block number when the Oracle witnessed the balance @@ -83,7 +83,7 @@ export function getWithdrawalAddress( [ "address", "uint256", - "uint256", + "string", "address", "uint256", "uint256", @@ -92,7 +92,7 @@ export function getWithdrawalAddress( [ withdrawalParams.depositoryAddress as `0x${string}`, withdrawalParams.depositoryChainId, - withdrawalParams.tokenId, + withdrawalParams.currency, withdrawalParams.recipientAddress as `0x${string}`, withdrawalParams.amount, withdrawalParams.blockNumber, From 69a7387f51df0b096a04a35564632bf8f4bf9a3e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 14:28:11 +0100 Subject: [PATCH 05/16] pass lug in oracle messages --- src/messages/v2.2/withdrawal-execution.ts | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index 0756fec..31bf7bd 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -64,7 +64,7 @@ export interface WithdrawalAddressParams { * Compute deterministic withdrawal address * * @param depositoryAddress the depository contract holding the funds on origin chain - * @param depositoryChainId the hub chain id of the depository contract currently holding the funds + * @param depositoryChainId the chain id of the depository contract currently holding the funds * @param currency the id of the currency as expressed on origin chain (string) * @param recipientAddress the address that will receive the withdrawn funds on destination chain * @param amount the balance to withdraw @@ -106,22 +106,22 @@ export function getWithdrawalAddress( return `0x${withdrawalAddress}` as `0x${string}`; } +// here we replace the hub chain id by a slug (e.g. 'base') +export type WithdrawalAddressRequest = Omit< + WithdrawalAddressParams, + "depositoryChainId" +> & { depositoryChainSlug: string }; + // types for oracle routes export type WithdrawalInitiationMessage = { - data: { - hubChainId: string; - withdrawalAddressParams: WithdrawalAddressParams; - }; + data: WithdrawalAddressRequest & { hubChainId: string }; result: { withdrawalAddress: string; }; }; export type WithdrawalInitiatedMessage = { - data: { - hubChainId: string; - withdrawalAddressParams: WithdrawalAddressParams; - }; + data: WithdrawalAddressRequest & { hubChainId: string }; result: { proofOfWithdrawalAddressBalance: string; }; From 9d8e72266ba3c1007dcd4a5abe2ceb68006deccc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 14:28:31 +0100 Subject: [PATCH 06/16] update comment --- src/messages/v2.2/withdrawal-execution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index 31bf7bd..f9c725c 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -106,7 +106,7 @@ export function getWithdrawalAddress( return `0x${withdrawalAddress}` as `0x${string}`; } -// here we replace the hub chain id by a slug (e.g. 'base') +// for oracle requests, we replace the hub chain id by a slug (e.g. 'base') export type WithdrawalAddressRequest = Omit< WithdrawalAddressParams, "depositoryChainId" From 1cd4b72914620f2b1ae7d25e5ab59b31b63e36ea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 14:38:58 +0100 Subject: [PATCH 07/16] better names --- src/messages/v2.2/withdrawal-execution.ts | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index f9c725c..8d3bf0f 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -110,18 +110,21 @@ export function getWithdrawalAddress( export type WithdrawalAddressRequest = Omit< WithdrawalAddressParams, "depositoryChainId" -> & { depositoryChainSlug: string }; +> & { + depositoryChainSlug: string; +}; // types for oracle routes export type WithdrawalInitiationMessage = { - data: WithdrawalAddressRequest & { hubChainId: string }; + data: WithdrawalAddressRequest & { settlementChainId: string }; result: { + owner: string; // current owner of balance on settlement chain withdrawalAddress: string; }; }; export type WithdrawalInitiatedMessage = { - data: WithdrawalAddressRequest & { hubChainId: string }; + data: WithdrawalAddressRequest & { settlementChainId: string }; result: { proofOfWithdrawalAddressBalance: string; }; From 003a188ec477aaec82177f33e2bbbcad5441c6a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 14:40:36 +0100 Subject: [PATCH 08/16] add owner --- src/messages/v2.2/withdrawal-execution.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index 8d3bf0f..704fd94 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -56,6 +56,7 @@ export interface WithdrawalAddressParams { depositoryChainId: bigint; currency: string; recipientAddress: string; + owner: string; amount: bigint; withdrawalNonce?: number; } @@ -67,6 +68,7 @@ export interface WithdrawalAddressParams { * @param depositoryChainId the chain id of the depository contract currently holding the funds * @param currency the id of the currency as expressed on origin chain (string) * @param recipientAddress the address that will receive the withdrawn funds on destination chain + * @param owner the address that owns the balance before the withdrawal is initiated * @param amount the balance to withdraw * @param blockNumber block number when the Oracle witnessed the balance * @param withdrawalNonce (optional) nonce to prevent collisions for similar withdrawals in the same block @@ -85,6 +87,7 @@ export function getWithdrawalAddress( "uint256", "string", "address", + "address", "uint256", "uint256", "uint256", @@ -94,6 +97,7 @@ export function getWithdrawalAddress( withdrawalParams.depositoryChainId, withdrawalParams.currency, withdrawalParams.recipientAddress as `0x${string}`, + withdrawalParams.owner as `0x${string}`, withdrawalParams.amount, withdrawalParams.blockNumber, BigInt(withdrawalParams.withdrawalNonce || 0), @@ -118,7 +122,6 @@ export type WithdrawalAddressRequest = Omit< export type WithdrawalInitiationMessage = { data: WithdrawalAddressRequest & { settlementChainId: string }; result: { - owner: string; // current owner of balance on settlement chain withdrawalAddress: string; }; }; From 3a51f9fba3200559e343252ee8966a9ac6dc9624 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 14:57:06 +0100 Subject: [PATCH 09/16] pass only address --- src/messages/v2.2/withdrawal-execution.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index 704fd94..e7c5d07 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -127,7 +127,7 @@ export type WithdrawalInitiationMessage = { }; export type WithdrawalInitiatedMessage = { - data: WithdrawalAddressRequest & { settlementChainId: string }; + data: { withdrawalAddress: string; settlementChainId: string }; result: { proofOfWithdrawalAddressBalance: string; }; From 4ebc1be5410bfe147af6aff9b9c28e4c64abbf0e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 14:57:48 +0100 Subject: [PATCH 10/16] return blockNumber --- src/messages/v2.2/withdrawal-execution.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index e7c5d07..af8bed0 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -123,6 +123,7 @@ export type WithdrawalInitiationMessage = { data: WithdrawalAddressRequest & { settlementChainId: string }; result: { withdrawalAddress: string; + blockNumber: string; }; }; From 1c50f32ee6596bffcaeb4407a378c63d88c6e77e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 15:01:02 +0100 Subject: [PATCH 11/16] pass blocknumber and params --- src/messages/v2.2/withdrawal-execution.ts | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index af8bed0..0a7005c 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -128,7 +128,10 @@ export type WithdrawalInitiationMessage = { }; export type WithdrawalInitiatedMessage = { - data: { withdrawalAddress: string; settlementChainId: string }; + data: WithdrawalAddressRequest & { + blockNumber: string; + settlementChainId: string; + }; result: { proofOfWithdrawalAddressBalance: string; }; From 96c969829afd861365bc822dcd2da3be9ad31c43 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 15:13:59 +0100 Subject: [PATCH 12/16] replace block number by nonce --- src/messages/v2.2/withdrawal-execution.ts | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index 0a7005c..cbc9828 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -58,7 +58,7 @@ export interface WithdrawalAddressParams { recipientAddress: string; owner: string; amount: bigint; - withdrawalNonce?: number; + withdrawalNonce: number; } /** @@ -70,8 +70,7 @@ export interface WithdrawalAddressParams { * @param recipientAddress the address that will receive the withdrawn funds on destination chain * @param owner the address that owns the balance before the withdrawal is initiated * @param amount the balance to withdraw - * @param blockNumber block number when the Oracle witnessed the balance - * @param withdrawalNonce (optional) nonce to prevent collisions for similar withdrawals in the same block + * @param withdrawalNonce nonce to prevent collisions for similar withdrawals * @returns withdrawal address (in lower case) */ export function getWithdrawalAddress( @@ -90,7 +89,6 @@ export function getWithdrawalAddress( "address", "uint256", "uint256", - "uint256", ], [ withdrawalParams.depositoryAddress as `0x${string}`, @@ -99,8 +97,7 @@ export function getWithdrawalAddress( withdrawalParams.recipientAddress as `0x${string}`, withdrawalParams.owner as `0x${string}`, withdrawalParams.amount, - withdrawalParams.blockNumber, - BigInt(withdrawalParams.withdrawalNonce || 0), + BigInt(withdrawalParams.withdrawalNonce), ] ) ); @@ -123,13 +120,11 @@ export type WithdrawalInitiationMessage = { data: WithdrawalAddressRequest & { settlementChainId: string }; result: { withdrawalAddress: string; - blockNumber: string; }; }; export type WithdrawalInitiatedMessage = { data: WithdrawalAddressRequest & { - blockNumber: string; settlementChainId: string; }; result: { From 8075bf276c663a62b1f59d8c38bff9c1e369a7ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 15:22:58 +0100 Subject: [PATCH 13/16] nonce in params --- src/messages/v2.2/withdrawal-execution.ts | 13 +++++++------ test/withdrawal-execution.test.ts | 5 +++-- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index cbc9828..433ea54 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -58,7 +58,7 @@ export interface WithdrawalAddressParams { recipientAddress: string; owner: string; amount: bigint; - withdrawalNonce: number; + withdrawalNonce: string; } /** @@ -74,11 +74,12 @@ export interface WithdrawalAddressParams { * @returns withdrawal address (in lower case) */ export function getWithdrawalAddress( - withdrawalParams: WithdrawalAddressParams & { - blockNumber: bigint; - } + withdrawalParams: WithdrawalAddressParams ): string { // pack and hash data + const nonce = keccak256( + encodePacked(["string"], [withdrawalParams.withdrawalNonce]) + ); const hash = keccak256( encodePacked( [ @@ -88,7 +89,7 @@ export function getWithdrawalAddress( "address", "address", "uint256", - "uint256", + "bytes32", ], [ withdrawalParams.depositoryAddress as `0x${string}`, @@ -97,7 +98,7 @@ export function getWithdrawalAddress( withdrawalParams.recipientAddress as `0x${string}`, withdrawalParams.owner as `0x${string}`, withdrawalParams.amount, - BigInt(withdrawalParams.withdrawalNonce), + nonce, ] ) ); diff --git a/test/withdrawal-execution.test.ts b/test/withdrawal-execution.test.ts index 5247b3d..93f9fde 100644 --- a/test/withdrawal-execution.test.ts +++ b/test/withdrawal-execution.test.ts @@ -7,10 +7,11 @@ describe("getWithdrawalAddress", () => { const params = { depositoryAddress: "0x1234567890123456789012345678901234567890", depositoryChainId: 1n, - tokenId: 100n, + currency: "10340230", recipientAddress: "0x9876543210987654321098765432109876543210", + owner: "0x9876543210987654321098765432109876543210", amount: 1000n, - blockNumber: 12345n, + withdrawalNonce: "haha", }; const address = getWithdrawalAddress(params); From f61c42102b1c45dcb27132a45d9967344937dd74 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 19:36:02 +0100 Subject: [PATCH 14/16] pass amount as string to oracle service --- src/messages/v2.2/withdrawal-execution.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index 433ea54..ad11321 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -109,11 +109,13 @@ export function getWithdrawalAddress( } // for oracle requests, we replace the hub chain id by a slug (e.g. 'base') +// and we pass the amount as a string export type WithdrawalAddressRequest = Omit< WithdrawalAddressParams, - "depositoryChainId" + "depositoryChainId" | "amount" > & { depositoryChainSlug: string; + amount: string; }; // types for oracle routes From e9eec8681eb2c6cbd88a856136f2e66f4a1d3900 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Sat, 13 Dec 2025 19:36:22 +0100 Subject: [PATCH 15/16] bump version --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7d9e340..681fefa 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@reservoir0x/relay-protocol-sdk", - "version": "0.0.60", + "version": "0.0.61", "description": "Relay protocol SDK", "main": "dist/index.js", "types": "dist/index.d.ts", From d8c7a8b328c3e8e09e7680709dd1966163d8aa49 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20Renaud?= Date: Mon, 15 Dec 2025 11:49:14 +0100 Subject: [PATCH 16/16] update type --- src/messages/v2.2/execution.ts | 5 +++++ src/messages/v2.2/withdrawal-execution.ts | 7 ++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/messages/v2.2/execution.ts b/src/messages/v2.2/execution.ts index 2b3a85a..b923e4e 100644 --- a/src/messages/v2.2/execution.ts +++ b/src/messages/v2.2/execution.ts @@ -31,6 +31,11 @@ export type ExecutionMessage = { metadata?: ExecutionMessageMetadata[]; }; +export type ExecutionMetadata = Omit< + ExecutionMessageMetadata, + "oracleContract" | "oracleChainId" +>; + export const getExecutionMessageId = (message: ExecutionMessage) => { return hashStruct({ types: { diff --git a/src/messages/v2.2/withdrawal-execution.ts b/src/messages/v2.2/withdrawal-execution.ts index ad11321..41ca64c 100644 --- a/src/messages/v2.2/withdrawal-execution.ts +++ b/src/messages/v2.2/withdrawal-execution.ts @@ -51,15 +51,15 @@ export const getSubmitWithdrawRequestHash = ( return digest; }; -export interface WithdrawalAddressParams { +export type WithdrawalAddressParams = { depositoryAddress: string; depositoryChainId: bigint; currency: string; - recipientAddress: string; owner: string; + recipientAddress: string; amount: bigint; withdrawalNonce: string; -} +}; /** * Compute deterministic withdrawal address @@ -132,5 +132,6 @@ export type WithdrawalInitiatedMessage = { }; result: { proofOfWithdrawalAddressBalance: string; + withdrawalAddress: string; }; };