@relay-protocol/settlement-sdk 0.0.74 → 0.0.76
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -20,7 +20,7 @@ export type WithdrawalAddressParams = {
|
|
|
20
20
|
/**
|
|
21
21
|
* Compute deterministic withdrawal address
|
|
22
22
|
*
|
|
23
|
-
* @param depository the depository contract holding the funds on origin chain
|
|
23
|
+
* @param depository the depository contract holding the funds on origin chain (as string)
|
|
24
24
|
* @param depositoryChainId the chain id of the depository contract currently holding the funds
|
|
25
25
|
* @param currency the id of the currency as expressed on origin chain (string)
|
|
26
26
|
* @param recipient the address that will receive the withdrawn funds on destination chain
|
|
@@ -38,6 +38,7 @@ export type WithdrawalAddressRequest = Omit<WithdrawalAddressParams, "depository
|
|
|
38
38
|
};
|
|
39
39
|
export type WithdrawalInitiationMessage = {
|
|
40
40
|
data: WithdrawalAddressRequest & {
|
|
41
|
+
expectedAmount: string;
|
|
41
42
|
settlementChainId: string;
|
|
42
43
|
signature: string;
|
|
43
44
|
};
|
|
@@ -47,6 +48,7 @@ export type WithdrawalInitiationMessage = {
|
|
|
47
48
|
};
|
|
48
49
|
export type WithdrawalInitiatedMessage = {
|
|
49
50
|
data: WithdrawalAddressRequest & {
|
|
51
|
+
expectedAmount: string;
|
|
50
52
|
settlementChainId: string;
|
|
51
53
|
};
|
|
52
54
|
result: {
|
|
@@ -54,52 +56,3 @@ export type WithdrawalInitiatedMessage = {
|
|
|
54
56
|
withdrawalAddress: string;
|
|
55
57
|
};
|
|
56
58
|
};
|
|
57
|
-
export type OnChainWithdrawalQuery = {
|
|
58
|
-
data: {
|
|
59
|
-
chainId: string;
|
|
60
|
-
payloadId: string;
|
|
61
|
-
payloadParams: SubmitWithdrawRequest;
|
|
62
|
-
};
|
|
63
|
-
result: {
|
|
64
|
-
encodedData: string;
|
|
65
|
-
signature?: string;
|
|
66
|
-
signer?: string;
|
|
67
|
-
};
|
|
68
|
-
};
|
|
69
|
-
export type OnchainWithdrawalRequest = {
|
|
70
|
-
data: {
|
|
71
|
-
chainId: string;
|
|
72
|
-
currency: string;
|
|
73
|
-
amount: string;
|
|
74
|
-
recipient: string;
|
|
75
|
-
spender: string;
|
|
76
|
-
nonce: string;
|
|
77
|
-
additionalData?: {
|
|
78
|
-
"hyperliquid-vm"?: {
|
|
79
|
-
currencyHyperliquidSymbol: string;
|
|
80
|
-
};
|
|
81
|
-
};
|
|
82
|
-
signature: string;
|
|
83
|
-
owner: string;
|
|
84
|
-
ownerChainId: string;
|
|
85
|
-
};
|
|
86
|
-
result: {
|
|
87
|
-
id: string;
|
|
88
|
-
encodedData: string;
|
|
89
|
-
payloadId: string;
|
|
90
|
-
submitWithdrawalRequestParams: SubmitWithdrawRequest;
|
|
91
|
-
signer: string;
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
export type OnchainWithdrawalSignatureRequest = {
|
|
95
|
-
data: {
|
|
96
|
-
chainId: string;
|
|
97
|
-
payloadId: string;
|
|
98
|
-
payloadParams: SubmitWithdrawRequest;
|
|
99
|
-
};
|
|
100
|
-
result: {
|
|
101
|
-
encodedData: string;
|
|
102
|
-
signer: string;
|
|
103
|
-
signature?: string;
|
|
104
|
-
};
|
|
105
|
-
};
|
|
@@ -5,27 +5,38 @@ exports.getWithdrawalAddress = getWithdrawalAddress;
|
|
|
5
5
|
exports.computeWithdrawerBalanceMessage = computeWithdrawerBalanceMessage;
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
7
|
const getSubmitWithdrawRequestHash = (request) => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
]
|
|
22
|
-
|
|
8
|
+
// EIP712 type from RelayAllocator
|
|
9
|
+
const PAYLOAD_TYPEHASH = (0, viem_1.keccak256)("SubmitWithdrawRequest(uint256 chainId,string depository,string currency,uint256 amount,address spender,string receiver,bytes data,bytes32 nonce)");
|
|
10
|
+
// Create EIP712 digest
|
|
11
|
+
const digest = (0, viem_1.keccak256)((0, viem_1.encodePacked)([
|
|
12
|
+
"bytes32",
|
|
13
|
+
"uint256",
|
|
14
|
+
"bytes32",
|
|
15
|
+
"bytes32",
|
|
16
|
+
"uint256",
|
|
17
|
+
"address",
|
|
18
|
+
"bytes32",
|
|
19
|
+
"bytes32",
|
|
20
|
+
"bytes32",
|
|
21
|
+
], [
|
|
22
|
+
PAYLOAD_TYPEHASH,
|
|
23
|
+
BigInt(request.chainId),
|
|
24
|
+
(0, viem_1.keccak256)(request.depository),
|
|
25
|
+
(0, viem_1.keccak256)(request.currency),
|
|
26
|
+
BigInt(request.amount),
|
|
27
|
+
request.spender,
|
|
28
|
+
(0, viem_1.keccak256)(request.receiver),
|
|
29
|
+
(0, viem_1.keccak256)(request.data),
|
|
30
|
+
request.nonce,
|
|
31
|
+
]));
|
|
32
|
+
// The withdrawal address is the digest itself (as a hex string)
|
|
33
|
+
return digest;
|
|
23
34
|
};
|
|
24
35
|
exports.getSubmitWithdrawRequestHash = getSubmitWithdrawRequestHash;
|
|
25
36
|
/**
|
|
26
37
|
* Compute deterministic withdrawal address
|
|
27
38
|
*
|
|
28
|
-
* @param depository the depository contract holding the funds on origin chain
|
|
39
|
+
* @param depository the depository contract holding the funds on origin chain (as string)
|
|
29
40
|
* @param depositoryChainId the chain id of the depository contract currently holding the funds
|
|
30
41
|
* @param currency the id of the currency as expressed on origin chain (string)
|
|
31
42
|
* @param recipient the address that will receive the withdrawn funds on destination chain
|
|
@@ -37,7 +48,7 @@ exports.getSubmitWithdrawRequestHash = getSubmitWithdrawRequestHash;
|
|
|
37
48
|
function getWithdrawalAddress(withdrawalParams) {
|
|
38
49
|
// pack and hash data
|
|
39
50
|
const nonce = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string"], [withdrawalParams.withdrawalNonce]));
|
|
40
|
-
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["
|
|
51
|
+
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "uint256", "string", "address", "address", "bytes32"], [
|
|
41
52
|
withdrawalParams.depository,
|
|
42
53
|
withdrawalParams.depositoryChainId,
|
|
43
54
|
withdrawalParams.currency,
|