@relay-protocol/settlement-sdk 0.0.79 → 0.0.81
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/hub/hub-utils.d.ts
CHANGED
|
@@ -1,17 +1,18 @@
|
|
|
1
|
+
import { Address, Hex } from "viem";
|
|
1
2
|
import { VmType } from "../utils";
|
|
2
3
|
export interface TokenIdComponents {
|
|
3
4
|
family: VmType;
|
|
4
|
-
chainId:
|
|
5
|
+
chainId: string;
|
|
5
6
|
address: string;
|
|
6
7
|
}
|
|
7
8
|
export interface VirtualAddressComponents {
|
|
8
9
|
family: VmType;
|
|
9
|
-
chainId:
|
|
10
|
+
chainId: string;
|
|
10
11
|
address: string;
|
|
11
12
|
}
|
|
12
13
|
export type TokenId = bigint;
|
|
13
|
-
export type VirtualAddress =
|
|
14
|
-
export declare const
|
|
14
|
+
export type VirtualAddress = Address;
|
|
15
|
+
export declare const arrayToHex: (arr: Uint8Array) => Hex;
|
|
15
16
|
/**
|
|
16
17
|
* Generates a virtual Ethereum address from token components
|
|
17
18
|
* @param components The token components (family, chainId, address)
|
package/dist/hub/hub-utils.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.arrayToHex = void 0;
|
|
4
4
|
exports.generateAddress = generateAddress;
|
|
5
5
|
exports.generateTokenId = generateTokenId;
|
|
6
6
|
const viem_1 = require("viem");
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
};
|
|
11
|
-
exports.getCheckSummedAddress = getCheckSummedAddress;
|
|
7
|
+
const utils_1 = require("../utils");
|
|
8
|
+
const arrayToHex = (arr) => `0x${Buffer.from(arr).toString("hex")}`;
|
|
9
|
+
exports.arrayToHex = arrayToHex;
|
|
12
10
|
/**
|
|
13
11
|
* Generates a virtual Ethereum address from token components
|
|
14
12
|
* @param components The token components (family, chainId, address)
|
|
@@ -19,7 +17,7 @@ exports.getCheckSummedAddress = getCheckSummedAddress;
|
|
|
19
17
|
*/
|
|
20
18
|
function generateAddress(components) {
|
|
21
19
|
const { chainId, address, family } = components;
|
|
22
|
-
const addressHash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "
|
|
20
|
+
const addressHash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "bytes"], [chainId, (0, exports.arrayToHex)((0, utils_1.encodeAddress)(address, family))]));
|
|
23
21
|
const addressBytes = addressHash.slice(2).slice(-40);
|
|
24
22
|
return (0, viem_1.getAddress)("0x" + addressBytes);
|
|
25
23
|
}
|
|
@@ -30,6 +28,6 @@ function generateAddress(components) {
|
|
|
30
28
|
*/
|
|
31
29
|
function generateTokenId(components) {
|
|
32
30
|
const { family, chainId, address } = components;
|
|
33
|
-
const packedData = (0, viem_1.encodePacked)(["string", "
|
|
31
|
+
const packedData = (0, viem_1.encodePacked)(["string", "bytes"], [chainId, (0, exports.arrayToHex)((0, utils_1.encodeAddress)(address, family))]);
|
|
34
32
|
return BigInt((0, viem_1.keccak256)(packedData));
|
|
35
33
|
}
|
package/dist/index.d.ts
CHANGED
|
@@ -6,6 +6,6 @@ import { SolverFillMessage, SolverFillStatus, getSolverFillMessageId } from "./m
|
|
|
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
8
|
import { SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, WithdrawalAddressParams, WithdrawalInitiationMessage, WithdrawalInitiatedMessage, WithdrawalAddressRequest, computeWithdrawerBalanceMessage, OnChainWithdrawalQuery, OnchainWithdrawalSignatureRequest, OnchainWithdrawalRequest } from "./messages/v2.2/withdrawal-execution";
|
|
9
|
-
import { TokenIdComponents, VirtualAddressComponents, TokenId, VirtualAddress,
|
|
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,
|
|
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, WithdrawalAddressParams, WithdrawalInitiationMessage, WithdrawalInitiatedMessage, WithdrawalAddressRequest, computeWithdrawerBalanceMessage, OnChainWithdrawalQuery, OnchainWithdrawalSignatureRequest, OnchainWithdrawalRequest, 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.computeWithdrawerBalanceMessage = exports.getWithdrawalAddress = exports.getSubmitWithdrawRequestHash = exports.generateTokenId = exports.generateAddress = exports.
|
|
3
|
+
exports.computeWithdrawerBalanceMessage = 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; } });
|
|
@@ -41,6 +41,5 @@ Object.defineProperty(exports, "getSubmitWithdrawRequestHash", { enumerable: tru
|
|
|
41
41
|
Object.defineProperty(exports, "getWithdrawalAddress", { enumerable: true, get: function () { return withdrawal_execution_1.getWithdrawalAddress; } });
|
|
42
42
|
Object.defineProperty(exports, "computeWithdrawerBalanceMessage", { enumerable: true, get: function () { return withdrawal_execution_1.computeWithdrawerBalanceMessage; } });
|
|
43
43
|
const hub_utils_1 = require("./hub/hub-utils");
|
|
44
|
-
Object.defineProperty(exports, "getCheckSummedAddress", { enumerable: true, get: function () { return hub_utils_1.getCheckSummedAddress; } });
|
|
45
44
|
Object.defineProperty(exports, "generateAddress", { enumerable: true, get: function () { return hub_utils_1.generateAddress; } });
|
|
46
45
|
Object.defineProperty(exports, "generateTokenId", { enumerable: true, get: function () { return hub_utils_1.generateTokenId; } });
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { VmType } from "../../utils";
|
|
1
2
|
export interface SubmitWithdrawRequest {
|
|
2
3
|
chainId: string;
|
|
3
4
|
depository: string;
|
|
@@ -11,7 +12,7 @@ export interface SubmitWithdrawRequest {
|
|
|
11
12
|
export declare const getSubmitWithdrawRequestHash: (request: SubmitWithdrawRequest) => `0x${string}`;
|
|
12
13
|
export type WithdrawalAddressParams = {
|
|
13
14
|
depository: string;
|
|
14
|
-
depositoryChainId:
|
|
15
|
+
depositoryChainId: string;
|
|
15
16
|
currency: string;
|
|
16
17
|
recipient: string;
|
|
17
18
|
withdrawerAlias: string;
|
|
@@ -29,7 +30,16 @@ export type WithdrawalAddressParams = {
|
|
|
29
30
|
* @param withdrawalNonce nonce to prevent collisions for similar withdrawals
|
|
30
31
|
* @returns withdrawal address (in lower case)
|
|
31
32
|
*/
|
|
32
|
-
export declare function getWithdrawalAddress(withdrawalParams: WithdrawalAddressParams
|
|
33
|
+
export declare function getWithdrawalAddress(withdrawalParams: WithdrawalAddressParams & {
|
|
34
|
+
depositoryVmType: VmType;
|
|
35
|
+
}): string;
|
|
36
|
+
export declare function getOrderAddress(data: {
|
|
37
|
+
depositChainVmType: VmType;
|
|
38
|
+
depositChainId: string;
|
|
39
|
+
depositor: string;
|
|
40
|
+
depositTimestamp: bigint;
|
|
41
|
+
depositId: string;
|
|
42
|
+
}): string;
|
|
33
43
|
export declare function computeWithdrawerBalanceMessage(withdrawerAlias: string, amount: bigint, withdrawalNonce: string): `0x${string}`;
|
|
34
44
|
export type WithdrawalAddressRequest = Omit<WithdrawalAddressParams, "depositoryChainId" | "amount" | "depository" | "withdrawerAlias"> & {
|
|
35
45
|
withdrawer: string;
|
|
@@ -2,8 +2,11 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSubmitWithdrawRequestHash = void 0;
|
|
4
4
|
exports.getWithdrawalAddress = getWithdrawalAddress;
|
|
5
|
+
exports.getOrderAddress = getOrderAddress;
|
|
5
6
|
exports.computeWithdrawerBalanceMessage = computeWithdrawerBalanceMessage;
|
|
6
7
|
const viem_1 = require("viem");
|
|
8
|
+
const hub_utils_1 = require("../../hub/hub-utils");
|
|
9
|
+
const utils_1 = require("../../utils");
|
|
7
10
|
const getSubmitWithdrawRequestHash = (request) => {
|
|
8
11
|
const encoded = (0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)([
|
|
9
12
|
"(uint256 chainId, string depository, string currency, uint256 amount, address spender, string receiver, bytes data, bytes32 nonce)",
|
|
@@ -35,20 +38,28 @@ exports.getSubmitWithdrawRequestHash = getSubmitWithdrawRequestHash;
|
|
|
35
38
|
* @returns withdrawal address (in lower case)
|
|
36
39
|
*/
|
|
37
40
|
function getWithdrawalAddress(withdrawalParams) {
|
|
38
|
-
|
|
39
|
-
const nonce = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string"], [withdrawalParams.withdrawalNonce]));
|
|
40
|
-
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "uint256", "string", "string", "address", "bytes32"], [
|
|
41
|
-
withdrawalParams.depository,
|
|
41
|
+
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "bytes", "bytes", "bytes", "address", "bytes32"], [
|
|
42
42
|
withdrawalParams.depositoryChainId,
|
|
43
|
-
withdrawalParams.
|
|
44
|
-
withdrawalParams.
|
|
43
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(withdrawalParams.depository, withdrawalParams.depositoryVmType)),
|
|
44
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(withdrawalParams.currency, withdrawalParams.depositoryVmType)),
|
|
45
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(withdrawalParams.recipient, withdrawalParams.depositoryVmType)),
|
|
45
46
|
withdrawalParams.withdrawerAlias,
|
|
46
|
-
|
|
47
|
+
`0x${BigInt(withdrawalParams.withdrawalNonce).toString(16).padStart(64, "0")}`,
|
|
47
48
|
]));
|
|
48
49
|
// get 40 bytes for an address
|
|
49
50
|
const withdrawalAddress = hash.slice(2).slice(-40).toLowerCase();
|
|
50
51
|
return `0x${withdrawalAddress}`;
|
|
51
52
|
}
|
|
53
|
+
function getOrderAddress(data) {
|
|
54
|
+
const hash = (0, viem_1.keccak256)((0, viem_1.encodePacked)(["string", "bytes", "uint256", "bytes32"], [
|
|
55
|
+
data.depositChainId,
|
|
56
|
+
(0, hub_utils_1.arrayToHex)((0, utils_1.encodeAddress)(data.depositor, data.depositChainVmType)),
|
|
57
|
+
BigInt(data.depositTimestamp),
|
|
58
|
+
data.depositId,
|
|
59
|
+
]));
|
|
60
|
+
const orderAddress = hash.slice(2).slice(-40);
|
|
61
|
+
return `0x${orderAddress}`;
|
|
62
|
+
}
|
|
52
63
|
// compute a message about withdrawer balance
|
|
53
64
|
// to be signed as auth proof for the oracle
|
|
54
65
|
function computeWithdrawerBalanceMessage(withdrawerAlias, amount, withdrawalNonce) {
|