@relay-protocol/settlement-sdk 0.0.87 → 0.0.88
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.
package/dist/index.d.ts
CHANGED
|
@@ -5,7 +5,7 @@ import { SolverRefundMessage, SolverRefundStatus, getSolverRefundMessageId } fro
|
|
|
5
5
|
import { SolverFillMessage, SolverFillStatus, getSolverFillMessageId } from "./messages/v2.1/solver-fill";
|
|
6
6
|
import { ActionType, ExecutionMessage, ExecutionMessageMetadata, getExecutionMessageId, encodeAction, decodeAction } from "./messages/v2.2/execution";
|
|
7
7
|
import { VmType, decodeAddress, decodeTransactionId, encodeAddress, encodeBytes, encodeTransactionId, getVmTypeNativeCurrency } from "./utils";
|
|
8
|
-
import {
|
|
8
|
+
import { SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, getOrderAddress, WithdrawalAddressParams, WithdrawalInitiationMessage, WithdrawalInitiatedMessage, WithdrawalAddressRequest, computeWithdrawerBalanceMessage, OnChainWithdrawalQuery, OnchainWithdrawalSignatureRequest, OnchainWithdrawalRequest, SubmitWithdrawRequestV2, DenormalizedSubmitWithdrawRequestV2, getSubmitWithdrawRequestHashV2, WithdrawalAddressParamsV2, getWithdrawalAddressV2, OrderAddressParamsV2, getOrderAddressV2, normalizePayloadParamsV2 } from "./messages/v2.2/withdrawal-execution";
|
|
9
9
|
import { TokenIdComponents, VirtualAddressComponents, TokenId, VirtualAddress, generateAddress, generateTokenId } from "./hub/hub-utils";
|
|
10
10
|
import type { NetworkConfig, NetworkConfigs, ProtocolContracts } from "./networks";
|
|
11
|
-
export { Order, encodeOrderCall, decodeOrderCall, encodeOrderExtraData, decodeOrderExtraData, getOrderId, VmType, decodeAddress, decodeTransactionId, encodeAddress, encodeBytes, encodeTransactionId, getVmTypeNativeCurrency, DepositoryDepositMessage, getDepositoryDepositMessageId, DecodedBitcoinVmWithdrawal, DecodedEthereumVmWithdrawal, DecodedSolanaVmWithdrawal, DecodedSuiVmWithdrawal, DecodedHyperliquidVmWithdrawal, DepositoryWithdrawalMessage, DepositoryWithdrawalStatus, getDepositoryWithdrawalMessageId, encodeWithdrawal, decodeWithdrawal, getDecodedWithdrawalId, getDecodedWithdrawalCurrency, getDecodedWithdrawalAmount, getDecodedWithdrawalRecipient, SolverRefundMessage, SolverRefundStatus, getSolverRefundMessageId, SolverFillMessage, SolverFillStatus, getSolverFillMessageId, ExecutionMessage, ExecutionMessageMetadata, ActionType, getExecutionMessageId, encodeAction, decodeAction, TokenIdComponents, VirtualAddressComponents, TokenId, VirtualAddress, generateAddress, generateTokenId,
|
|
11
|
+
export { Order, encodeOrderCall, decodeOrderCall, encodeOrderExtraData, decodeOrderExtraData, getOrderId, VmType, decodeAddress, decodeTransactionId, encodeAddress, encodeBytes, encodeTransactionId, getVmTypeNativeCurrency, DepositoryDepositMessage, getDepositoryDepositMessageId, DecodedBitcoinVmWithdrawal, DecodedEthereumVmWithdrawal, DecodedSolanaVmWithdrawal, DecodedSuiVmWithdrawal, DecodedHyperliquidVmWithdrawal, DepositoryWithdrawalMessage, DepositoryWithdrawalStatus, getDepositoryWithdrawalMessageId, encodeWithdrawal, decodeWithdrawal, getDecodedWithdrawalId, getDecodedWithdrawalCurrency, getDecodedWithdrawalAmount, getDecodedWithdrawalRecipient, SolverRefundMessage, SolverRefundStatus, getSolverRefundMessageId, SolverFillMessage, SolverFillStatus, getSolverFillMessageId, ExecutionMessage, ExecutionMessageMetadata, ActionType, getExecutionMessageId, encodeAction, decodeAction, TokenIdComponents, VirtualAddressComponents, TokenId, VirtualAddress, generateAddress, generateTokenId, SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, getOrderAddress, WithdrawalAddressParams, WithdrawalInitiationMessage, WithdrawalInitiatedMessage, WithdrawalAddressRequest, computeWithdrawerBalanceMessage, OnChainWithdrawalQuery, OnchainWithdrawalSignatureRequest, OnchainWithdrawalRequest, SubmitWithdrawRequestV2, DenormalizedSubmitWithdrawRequestV2, getSubmitWithdrawRequestHashV2, WithdrawalAddressParamsV2, getWithdrawalAddressV2, OrderAddressParamsV2, getOrderAddressV2, normalizePayloadParamsV2, NetworkConfigs, ProtocolContracts, NetworkConfig, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.normalizePayloadParamsV2 = exports.getOrderAddressV2 = exports.getWithdrawalAddressV2 = exports.getSubmitWithdrawRequestHashV2 = exports.computeWithdrawerBalanceMessage = exports.getOrderAddress = exports.getWithdrawalAddress = exports.getSubmitWithdrawRequestHash = exports.generateTokenId = exports.generateAddress = exports.decodeAction = exports.encodeAction = exports.getExecutionMessageId = exports.ActionType = exports.getSolverFillMessageId = exports.SolverFillStatus = exports.getSolverRefundMessageId = exports.SolverRefundStatus = exports.getDecodedWithdrawalRecipient = exports.getDecodedWithdrawalAmount = exports.getDecodedWithdrawalCurrency = exports.getDecodedWithdrawalId = exports.decodeWithdrawal = exports.encodeWithdrawal = exports.getDepositoryWithdrawalMessageId = exports.DepositoryWithdrawalStatus = exports.getDepositoryDepositMessageId = exports.getVmTypeNativeCurrency = exports.encodeTransactionId = exports.encodeBytes = exports.encodeAddress = exports.decodeTransactionId = exports.decodeAddress = exports.getOrderId = exports.decodeOrderExtraData = exports.encodeOrderExtraData = exports.decodeOrderCall = exports.encodeOrderCall = void 0;
|
|
4
4
|
const order_1 = require("./order");
|
|
5
5
|
Object.defineProperty(exports, "encodeOrderCall", { enumerable: true, get: function () { return order_1.encodeOrderCall; } });
|
|
6
6
|
Object.defineProperty(exports, "decodeOrderCall", { enumerable: true, get: function () { return order_1.decodeOrderCall; } });
|
|
@@ -40,7 +40,11 @@ const withdrawal_execution_1 = require("./messages/v2.2/withdrawal-execution");
|
|
|
40
40
|
Object.defineProperty(exports, "getSubmitWithdrawRequestHash", { enumerable: true, get: function () { return withdrawal_execution_1.getSubmitWithdrawRequestHash; } });
|
|
41
41
|
Object.defineProperty(exports, "getWithdrawalAddress", { enumerable: true, get: function () { return withdrawal_execution_1.getWithdrawalAddress; } });
|
|
42
42
|
Object.defineProperty(exports, "getOrderAddress", { enumerable: true, get: function () { return withdrawal_execution_1.getOrderAddress; } });
|
|
43
|
-
Object.defineProperty(exports, "
|
|
43
|
+
Object.defineProperty(exports, "computeWithdrawerBalanceMessage", { enumerable: true, get: function () { return withdrawal_execution_1.computeWithdrawerBalanceMessage; } });
|
|
44
|
+
Object.defineProperty(exports, "getSubmitWithdrawRequestHashV2", { enumerable: true, get: function () { return withdrawal_execution_1.getSubmitWithdrawRequestHashV2; } });
|
|
45
|
+
Object.defineProperty(exports, "getWithdrawalAddressV2", { enumerable: true, get: function () { return withdrawal_execution_1.getWithdrawalAddressV2; } });
|
|
46
|
+
Object.defineProperty(exports, "getOrderAddressV2", { enumerable: true, get: function () { return withdrawal_execution_1.getOrderAddressV2; } });
|
|
47
|
+
Object.defineProperty(exports, "normalizePayloadParamsV2", { enumerable: true, get: function () { return withdrawal_execution_1.normalizePayloadParamsV2; } });
|
|
44
48
|
const hub_utils_1 = require("./hub/hub-utils");
|
|
45
49
|
Object.defineProperty(exports, "generateAddress", { enumerable: true, get: function () { return hub_utils_1.generateAddress; } });
|
|
46
50
|
Object.defineProperty(exports, "generateTokenId", { enumerable: true, get: function () { return hub_utils_1.generateTokenId; } });
|
|
@@ -1,6 +1,120 @@
|
|
|
1
1
|
import { Address } from "viem";
|
|
2
2
|
import { VmType } from "../../utils";
|
|
3
3
|
export interface SubmitWithdrawRequest {
|
|
4
|
+
chainId: string;
|
|
5
|
+
depository: string;
|
|
6
|
+
currency: string;
|
|
7
|
+
amount: string;
|
|
8
|
+
spender: string;
|
|
9
|
+
receiver: string;
|
|
10
|
+
data: string;
|
|
11
|
+
nonce: string;
|
|
12
|
+
}
|
|
13
|
+
export declare const getSubmitWithdrawRequestHash: (request: SubmitWithdrawRequest) => `0x${string}`;
|
|
14
|
+
export type WithdrawalAddressParams = {
|
|
15
|
+
depository: string;
|
|
16
|
+
depositoryChainId: string;
|
|
17
|
+
currency: string;
|
|
18
|
+
recipient: string;
|
|
19
|
+
withdrawerAlias: string;
|
|
20
|
+
withdrawalNonce: string;
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Compute deterministic withdrawal address
|
|
24
|
+
*
|
|
25
|
+
* @param depository the depository contract holding the funds on origin chain (as string)
|
|
26
|
+
* @param depositoryChainId the chain id of the depository contract currently holding the funds
|
|
27
|
+
* @param currency the id of the currency as expressed on origin chain (string)
|
|
28
|
+
* @param recipient the address that will receive the withdrawn funds on destination chain
|
|
29
|
+
* @param withdrawerAlias the address that owns the balance on the settlement chain
|
|
30
|
+
* before the withdrawal is initiated
|
|
31
|
+
* @param withdrawalNonce nonce to prevent collisions for similar withdrawals
|
|
32
|
+
* @returns withdrawal address (in lower case)
|
|
33
|
+
*/
|
|
34
|
+
export declare function getWithdrawalAddress(withdrawalParams: WithdrawalAddressParams & {
|
|
35
|
+
depositoryVmType: VmType;
|
|
36
|
+
}): string;
|
|
37
|
+
export declare function getOrderAddress(data: {
|
|
38
|
+
depositChainVmType: VmType;
|
|
39
|
+
depositChainId: string;
|
|
40
|
+
depositor: string;
|
|
41
|
+
depositTimestamp: bigint;
|
|
42
|
+
depositId: string;
|
|
43
|
+
}): string;
|
|
44
|
+
export declare function computeWithdrawerBalanceMessage(withdrawerAlias: string, amount: bigint, withdrawalNonce: string): `0x${string}`;
|
|
45
|
+
export type WithdrawalAddressRequest = Omit<WithdrawalAddressParams, "depositoryChainId" | "amount" | "depository" | "withdrawerAlias"> & {
|
|
46
|
+
withdrawer: string;
|
|
47
|
+
withdrawerChainId: string;
|
|
48
|
+
chainId: string;
|
|
49
|
+
};
|
|
50
|
+
export type WithdrawalInitiationMessage = {
|
|
51
|
+
data: WithdrawalAddressRequest & {
|
|
52
|
+
expectedAmount: string;
|
|
53
|
+
settlementChainId: string;
|
|
54
|
+
signature: string;
|
|
55
|
+
};
|
|
56
|
+
result: {
|
|
57
|
+
withdrawalAddress: string;
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
export type WithdrawalInitiatedMessage = {
|
|
61
|
+
data: WithdrawalAddressRequest & {
|
|
62
|
+
expectedAmount: string;
|
|
63
|
+
settlementChainId: string;
|
|
64
|
+
};
|
|
65
|
+
result: {
|
|
66
|
+
proofOfWithdrawalAddressBalance: string;
|
|
67
|
+
withdrawalAddress: string;
|
|
68
|
+
};
|
|
69
|
+
};
|
|
70
|
+
export type OnChainWithdrawalQuery = {
|
|
71
|
+
data: {
|
|
72
|
+
chainId: string;
|
|
73
|
+
payloadId: string;
|
|
74
|
+
payloadParams: SubmitWithdrawRequest;
|
|
75
|
+
};
|
|
76
|
+
result: {
|
|
77
|
+
encodedData: string;
|
|
78
|
+
signature?: string;
|
|
79
|
+
signer?: string;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
export type OnchainWithdrawalRequest = {
|
|
83
|
+
data: {
|
|
84
|
+
chainId: string;
|
|
85
|
+
currency: string;
|
|
86
|
+
amount: string;
|
|
87
|
+
recipient: string;
|
|
88
|
+
spender: string;
|
|
89
|
+
nonce: string;
|
|
90
|
+
additionalData?: {
|
|
91
|
+
"hyperliquid-vm"?: {
|
|
92
|
+
currencyHyperliquidSymbol: string;
|
|
93
|
+
};
|
|
94
|
+
};
|
|
95
|
+
signature: string;
|
|
96
|
+
owner: string;
|
|
97
|
+
ownerChainId: string;
|
|
98
|
+
};
|
|
99
|
+
result: {
|
|
100
|
+
id: string;
|
|
101
|
+
encodedData: string;
|
|
102
|
+
payloadId: string;
|
|
103
|
+
submitWithdrawalRequestParams: SubmitWithdrawRequest;
|
|
104
|
+
signer: string;
|
|
105
|
+
};
|
|
106
|
+
};
|
|
107
|
+
export type OnchainWithdrawalSignatureRequest = {
|
|
108
|
+
data: {
|
|
109
|
+
chainId: string;
|
|
110
|
+
payloadId: string;
|
|
111
|
+
payloadParams: SubmitWithdrawRequest;
|
|
112
|
+
};
|
|
113
|
+
result: {
|
|
114
|
+
message: string;
|
|
115
|
+
};
|
|
116
|
+
};
|
|
117
|
+
export interface SubmitWithdrawRequestV2 {
|
|
4
118
|
chainId: string;
|
|
5
119
|
depository: string;
|
|
6
120
|
currency: string;
|
|
@@ -10,7 +124,7 @@ export interface SubmitWithdrawRequest {
|
|
|
10
124
|
nonce: string;
|
|
11
125
|
data: string;
|
|
12
126
|
}
|
|
13
|
-
export type
|
|
127
|
+
export type DenormalizedSubmitWithdrawRequestV2 = Omit<SubmitWithdrawRequestV2, "data"> & {
|
|
14
128
|
additionalData?: {
|
|
15
129
|
"bitcoin-vm"?: {
|
|
16
130
|
allocatorUtxos: {
|
|
@@ -26,8 +140,8 @@ export type DenormalizedSubmitWithdrawRequest = Omit<SubmitWithdrawRequest, "dat
|
|
|
26
140
|
};
|
|
27
141
|
};
|
|
28
142
|
};
|
|
29
|
-
export declare const
|
|
30
|
-
export type
|
|
143
|
+
export declare const getSubmitWithdrawRequestHashV2: (request: SubmitWithdrawRequestV2) => `0x${string}`;
|
|
144
|
+
export type WithdrawalAddressParamsV2 = {
|
|
31
145
|
vmType: VmType;
|
|
32
146
|
chainId: string;
|
|
33
147
|
depository: string;
|
|
@@ -36,28 +150,15 @@ export type WithdrawalAddressParams = {
|
|
|
36
150
|
ownerAlias: string;
|
|
37
151
|
nonce: string;
|
|
38
152
|
};
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
*
|
|
42
|
-
* @param vmType the vm type of the depository chain
|
|
43
|
-
* @param chainId the chain id of the depository contract currently holding the funds
|
|
44
|
-
* @param depository the depository contract holding the funds on origin chain (as string)
|
|
45
|
-
* @param currency the id of the currency as expressed on origin chain (string)
|
|
46
|
-
* @param recipient the address that will receive the withdrawn funds on destination chain
|
|
47
|
-
* @param ownerAlias the address that owns the balance on the settlement chain before the withdrawal is initiated
|
|
48
|
-
* @param nonce nonce to prevent collisions for similar withdrawals
|
|
49
|
-
* @returns withdrawal address (in lower case)
|
|
50
|
-
*/
|
|
51
|
-
export declare function getWithdrawalAddress(withdrawalParams: WithdrawalAddressParams): Address;
|
|
52
|
-
export type OrderAddressParams = {
|
|
153
|
+
export declare function getWithdrawalAddressV2(withdrawalParams: WithdrawalAddressParamsV2): Address;
|
|
154
|
+
export type OrderAddressParamsV2 = {
|
|
53
155
|
vmType: VmType;
|
|
54
156
|
chainId: string;
|
|
55
157
|
depositor: string;
|
|
56
158
|
timestamp: bigint;
|
|
57
159
|
depositId: string;
|
|
58
160
|
};
|
|
59
|
-
export declare function
|
|
60
|
-
export declare function
|
|
61
|
-
export declare function normalizePayloadParams(request: DenormalizedSubmitWithdrawRequest & {
|
|
161
|
+
export declare function getOrderAddressV2(orderParams: OrderAddressParamsV2): Address;
|
|
162
|
+
export declare function normalizePayloadParamsV2(request: DenormalizedSubmitWithdrawRequestV2 & {
|
|
62
163
|
vmType: VmType;
|
|
63
|
-
}):
|
|
164
|
+
}): SubmitWithdrawRequestV2;
|
|
@@ -36,11 +36,13 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
36
36
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
37
|
};
|
|
38
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
exports.getSubmitWithdrawRequestHash = void 0;
|
|
39
|
+
exports.getSubmitWithdrawRequestHashV2 = exports.getSubmitWithdrawRequestHash = void 0;
|
|
40
40
|
exports.getWithdrawalAddress = getWithdrawalAddress;
|
|
41
41
|
exports.getOrderAddress = getOrderAddress;
|
|
42
|
-
exports.
|
|
43
|
-
exports.
|
|
42
|
+
exports.computeWithdrawerBalanceMessage = computeWithdrawerBalanceMessage;
|
|
43
|
+
exports.getWithdrawalAddressV2 = getWithdrawalAddressV2;
|
|
44
|
+
exports.getOrderAddressV2 = getOrderAddressV2;
|
|
45
|
+
exports.normalizePayloadParamsV2 = normalizePayloadParamsV2;
|
|
44
46
|
const web3_js_1 = require("@solana/web3.js");
|
|
45
47
|
const bitcoin = __importStar(require("bitcoinjs-lib"));
|
|
46
48
|
const tronweb_1 = __importDefault(require("tronweb"));
|
|
@@ -57,7 +59,7 @@ const getSubmitWithdrawRequestHash = (request) => {
|
|
|
57
59
|
currency: request.currency,
|
|
58
60
|
amount: BigInt(request.amount),
|
|
59
61
|
spender: request.spender,
|
|
60
|
-
receiver: request.
|
|
62
|
+
receiver: request.receiver,
|
|
61
63
|
data: request.data,
|
|
62
64
|
nonce: request.nonce,
|
|
63
65
|
},
|
|
@@ -68,16 +70,66 @@ exports.getSubmitWithdrawRequestHash = getSubmitWithdrawRequestHash;
|
|
|
68
70
|
/**
|
|
69
71
|
* Compute deterministic withdrawal address
|
|
70
72
|
*
|
|
71
|
-
* @param vmType the vm type of the depository chain
|
|
72
|
-
* @param chainId the chain id of the depository contract currently holding the funds
|
|
73
73
|
* @param depository the depository contract holding the funds on origin chain (as string)
|
|
74
|
+
* @param depositoryChainId the chain id of the depository contract currently holding the funds
|
|
74
75
|
* @param currency the id of the currency as expressed on origin chain (string)
|
|
75
76
|
* @param recipient the address that will receive the withdrawn funds on destination chain
|
|
76
|
-
* @param
|
|
77
|
-
*
|
|
77
|
+
* @param withdrawerAlias the address that owns the balance on the settlement chain
|
|
78
|
+
* before the withdrawal is initiated
|
|
79
|
+
* @param withdrawalNonce nonce to prevent collisions for similar withdrawals
|
|
78
80
|
* @returns withdrawal address (in lower case)
|
|
79
81
|
*/
|
|
80
82
|
function getWithdrawalAddress(withdrawalParams) {
|
|
83
|
+
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "bytes", "bytes", "bytes", "address", "bytes32"], [
|
|
84
|
+
withdrawalParams.depositoryChainId,
|
|
85
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(withdrawalParams.depository, withdrawalParams.depositoryVmType)),
|
|
86
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(withdrawalParams.currency, withdrawalParams.depositoryVmType)),
|
|
87
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(withdrawalParams.recipient, withdrawalParams.depositoryVmType)),
|
|
88
|
+
withdrawalParams.withdrawerAlias,
|
|
89
|
+
`0x${BigInt(withdrawalParams.withdrawalNonce).toString(16).padStart(64, "0")}`,
|
|
90
|
+
]));
|
|
91
|
+
// get 40 bytes for an address
|
|
92
|
+
const withdrawalAddress = hash.slice(2).slice(-40).toLowerCase();
|
|
93
|
+
return `0x${withdrawalAddress}`;
|
|
94
|
+
}
|
|
95
|
+
function getOrderAddress(data) {
|
|
96
|
+
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "bytes", "uint256", "bytes32"], [
|
|
97
|
+
data.depositChainId,
|
|
98
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(data.depositor, data.depositChainVmType)),
|
|
99
|
+
BigInt(data.depositTimestamp),
|
|
100
|
+
data.depositId,
|
|
101
|
+
]));
|
|
102
|
+
const orderAddress = hash.slice(2).slice(-40);
|
|
103
|
+
return `0x${orderAddress}`;
|
|
104
|
+
}
|
|
105
|
+
// compute a message about withdrawer balance
|
|
106
|
+
// to be signed as auth proof for the oracle
|
|
107
|
+
function computeWithdrawerBalanceMessage(withdrawerAlias, amount, withdrawalNonce) {
|
|
108
|
+
return (0, viem_1.keccak256)((0, viem_1.encodePacked)(["address", "uint256", "bytes32"], [
|
|
109
|
+
withdrawerAlias,
|
|
110
|
+
BigInt(amount),
|
|
111
|
+
withdrawalNonce,
|
|
112
|
+
]));
|
|
113
|
+
}
|
|
114
|
+
const getSubmitWithdrawRequestHashV2 = (request) => {
|
|
115
|
+
const encoded = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)([
|
|
116
|
+
"(uint256 chainId, string depository, string currency, uint256 amount, address spender, string receiver, bytes data, bytes32 nonce)",
|
|
117
|
+
]), [
|
|
118
|
+
{
|
|
119
|
+
chainId: BigInt(request.chainId),
|
|
120
|
+
depository: request.depository,
|
|
121
|
+
currency: request.currency,
|
|
122
|
+
amount: BigInt(request.amount),
|
|
123
|
+
spender: request.spender,
|
|
124
|
+
receiver: request.recipient,
|
|
125
|
+
data: request.data,
|
|
126
|
+
nonce: request.nonce,
|
|
127
|
+
},
|
|
128
|
+
]);
|
|
129
|
+
return (0, viem_1.keccak256)(encoded);
|
|
130
|
+
};
|
|
131
|
+
exports.getSubmitWithdrawRequestHashV2 = getSubmitWithdrawRequestHashV2;
|
|
132
|
+
function getWithdrawalAddressV2(withdrawalParams) {
|
|
81
133
|
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "bytes", "bytes", "bytes", "address", "bytes32"], [
|
|
82
134
|
withdrawalParams.chainId,
|
|
83
135
|
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(withdrawalParams.depository, withdrawalParams.vmType)),
|
|
@@ -90,7 +142,7 @@ function getWithdrawalAddress(withdrawalParams) {
|
|
|
90
142
|
const withdrawalAddress = hash.slice(2).slice(-40).toLowerCase();
|
|
91
143
|
return `0x${withdrawalAddress}`;
|
|
92
144
|
}
|
|
93
|
-
function
|
|
145
|
+
function getOrderAddressV2(orderParams) {
|
|
94
146
|
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "bytes", "uint256", "bytes32"], [
|
|
95
147
|
orderParams.chainId,
|
|
96
148
|
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(orderParams.depositor, orderParams.vmType)),
|
|
@@ -101,14 +153,7 @@ function getOrderAddress(orderParams) {
|
|
|
101
153
|
const orderAddress = hash.slice(2).slice(-40);
|
|
102
154
|
return `0x${orderAddress}`;
|
|
103
155
|
}
|
|
104
|
-
function
|
|
105
|
-
return (0, viem_1.keccak256)((0, viem_1.encodePacked)(["address", "uint256", "bytes32"], [
|
|
106
|
-
withdrawerAlias,
|
|
107
|
-
BigInt(amount),
|
|
108
|
-
withdrawalNonce,
|
|
109
|
-
]));
|
|
110
|
-
}
|
|
111
|
-
function normalizePayloadParams(request) {
|
|
156
|
+
function normalizePayloadParamsV2(request) {
|
|
112
157
|
const defaultParams = {
|
|
113
158
|
chainId: request.chainId,
|
|
114
159
|
depository: request.depository,
|