@relay-protocol/settlement-sdk 0.0.91 → 0.0.92

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.
@@ -28,15 +28,15 @@ const getDepositoryDepositMessageId = (message, chainsConfig) => {
28
28
  data: {
29
29
  data: {
30
30
  chainId: message.data.chainId,
31
- transactionId: (0, utils_1.encodeTransactionId)(message.data.transactionId, vmType(message.data.chainId)),
31
+ transactionId: (0, utils_1.encodeTransactionIdToHex)(message.data.transactionId, vmType(message.data.chainId)),
32
32
  },
33
33
  result: {
34
- onchainId: (0, viem_1.bytesToHex)((0, utils_1.encodeBytes)(message.result.onchainId)),
35
- depository: (0, utils_1.encodeAddress)(message.result.depository, vmType(message.data.chainId)),
36
- depositId: (0, viem_1.bytesToHex)((0, utils_1.encodeBytes)(message.result.depositId)),
37
- depositor: (0, utils_1.encodeAddress)(message.result.depositor, vmType(message.data.chainId)),
38
- currency: (0, utils_1.encodeAddress)(message.result.currency, vmType(message.data.chainId)),
39
- amount: message.result.amount,
34
+ onchainId: (0, utils_1.encodeBytesToHex)(message.result.onchainId),
35
+ depository: (0, utils_1.encodeAddressToHex)(message.result.depository, vmType(message.data.chainId)),
36
+ depositId: (0, utils_1.encodeBytesToHex)(message.result.depositId),
37
+ depositor: (0, utils_1.encodeAddressToHex)(message.result.depositor, vmType(message.data.chainId)),
38
+ currency: (0, utils_1.encodeAddressToHex)(message.result.currency, vmType(message.data.chainId)),
39
+ amount: BigInt(message.result.amount),
40
40
  },
41
41
  },
42
42
  });
@@ -72,11 +72,11 @@ const getDepositoryWithdrawalMessageId = (message, chainsConfig) => {
72
72
  data: {
73
73
  data: {
74
74
  chainId: message.data.chainId,
75
- withdrawal: (0, utils_1.encodeBytes)(message.data.withdrawal),
75
+ withdrawal: (0, utils_1.encodeBytesToHex)(message.data.withdrawal),
76
76
  },
77
77
  result: {
78
- withdrawalId: (0, viem_1.bytesToHex)((0, utils_1.encodeBytes)(message.result.withdrawalId)),
79
- depository: (0, utils_1.encodeAddress)(message.result.depository, vmType(message.data.chainId)),
78
+ withdrawalId: (0, utils_1.encodeBytesToHex)(message.result.withdrawalId),
79
+ depository: (0, utils_1.encodeAddressToHex)(message.result.depository, vmType(message.data.chainId)),
80
80
  status: message.result.status,
81
81
  },
82
82
  },
@@ -385,9 +385,14 @@ const getDecodedWithdrawalId = (decodedWithdrawal) => {
385
385
  },
386
386
  primaryType: "CallRequest",
387
387
  data: {
388
- calls: decodedWithdrawal.withdrawal.calls,
389
- nonce: decodedWithdrawal.withdrawal.nonce,
390
- expiration: decodedWithdrawal.withdrawal.expiration,
388
+ calls: decodedWithdrawal.withdrawal.calls.map((c) => ({
389
+ to: c.to,
390
+ data: c.data,
391
+ value: BigInt(c.value),
392
+ allowFailure: c.allowFailure,
393
+ })),
394
+ nonce: BigInt(decodedWithdrawal.withdrawal.nonce),
395
+ expiration: BigInt(decodedWithdrawal.withdrawal.expiration),
391
396
  },
392
397
  });
393
398
  }
@@ -473,7 +478,7 @@ const getDecodedWithdrawalId = (decodedWithdrawal) => {
473
478
  hyperliquidChain: parameters.hyperliquidChain,
474
479
  destination: parameters.destination,
475
480
  amount: parameters.amount,
476
- time: parameters.time,
481
+ time: BigInt(parameters.time),
477
482
  },
478
483
  });
479
484
  }
@@ -500,7 +505,7 @@ const getDecodedWithdrawalId = (decodedWithdrawal) => {
500
505
  token: parameters.token,
501
506
  amount: parameters.amount,
502
507
  fromSubAccount: parameters.fromSubAccount,
503
- nonce: parameters.nonce,
508
+ nonce: BigInt(parameters.nonce),
504
509
  },
505
510
  });
506
511
  }
@@ -37,23 +37,24 @@ const getSolverFillMessageId = (message, chainsConfig) => {
37
37
  FillEntry: [{ name: "transactionId", type: "bytes" }],
38
38
  },
39
39
  primaryType: "SolverFill",
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
40
41
  data: {
41
42
  data: {
42
43
  order: (0, order_1.normalizeOrder)(message.data.order, chainsConfig),
43
- orderSignature: (0, utils_1.encodeBytes)(message.data.orderSignature),
44
+ orderSignature: (0, utils_1.encodeBytesToHex)(message.data.orderSignature),
44
45
  inputs: message.data.inputs.map((input) => ({
45
- transactionId: (0, utils_1.encodeTransactionId)(input.transactionId, vmType(message.data.order.inputs[input.inputIndex].payment.chainId)),
46
- onchainId: (0, viem_1.bytesToHex)((0, utils_1.encodeBytes)(input.onchainId)),
46
+ transactionId: (0, utils_1.encodeTransactionIdToHex)(input.transactionId, vmType(message.data.order.inputs[input.inputIndex].payment.chainId)),
47
+ onchainId: (0, utils_1.encodeBytesToHex)(input.onchainId),
47
48
  inputIndex: input.inputIndex,
48
49
  })),
49
50
  fill: {
50
- transactionId: (0, utils_1.encodeTransactionId)(message.data.fill.transactionId, vmType(message.data.order.output.chainId)),
51
+ transactionId: (0, utils_1.encodeTransactionIdToHex)(message.data.fill.transactionId, vmType(message.data.order.output.chainId)),
51
52
  },
52
53
  },
53
54
  result: {
54
- orderId: (0, viem_1.bytesToHex)((0, utils_1.encodeBytes)(message.result.orderId)),
55
+ orderId: (0, utils_1.encodeBytesToHex)(message.result.orderId),
55
56
  status: message.result.status,
56
- totalWeightedInputPaymentBpsDiff: message.result.totalWeightedInputPaymentBpsDiff,
57
+ totalWeightedInputPaymentBpsDiff: BigInt(message.result.totalWeightedInputPaymentBpsDiff),
57
58
  },
58
59
  },
59
60
  });
@@ -41,25 +41,26 @@ const getSolverRefundMessageId = (message, chainsConfig) => {
41
41
  ],
42
42
  },
43
43
  primaryType: "SolverRefund",
44
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
44
45
  data: {
45
46
  data: {
46
47
  order: (0, order_1.normalizeOrder)(message.data.order, chainsConfig),
47
- orderSignature: (0, utils_1.encodeBytes)(message.data.orderSignature),
48
+ orderSignature: (0, utils_1.encodeBytesToHex)(message.data.orderSignature),
48
49
  inputs: message.data.inputs.map((input) => ({
49
- transactionId: (0, utils_1.encodeTransactionId)(input.transactionId, vmType(message.data.order.inputs[input.inputIndex].payment.chainId)),
50
- onchainId: (0, viem_1.bytesToHex)((0, utils_1.encodeBytes)(input.onchainId)),
50
+ transactionId: (0, utils_1.encodeTransactionIdToHex)(input.transactionId, vmType(message.data.order.inputs[input.inputIndex].payment.chainId)),
51
+ onchainId: (0, utils_1.encodeBytesToHex)(input.onchainId),
51
52
  inputIndex: input.inputIndex,
52
53
  })),
53
54
  refunds: message.data.refunds.map((refund) => ({
54
- transactionId: (0, utils_1.encodeTransactionId)(refund.transactionId, vmType(message.data.order.inputs[refund.inputIndex].refunds[refund.refundIndex].chainId)),
55
+ transactionId: (0, utils_1.encodeTransactionIdToHex)(refund.transactionId, vmType(message.data.order.inputs[refund.inputIndex].refunds[refund.refundIndex].chainId)),
55
56
  inputIndex: refund.inputIndex,
56
57
  refundIndex: refund.refundIndex,
57
58
  })),
58
59
  },
59
60
  result: {
60
- orderId: (0, viem_1.bytesToHex)((0, utils_1.encodeBytes)(message.result.orderId)),
61
+ orderId: (0, utils_1.encodeBytesToHex)(message.result.orderId),
61
62
  status: message.result.status,
62
- totalWeightedInputPaymentBpsDiff: message.result.totalWeightedInputPaymentBpsDiff,
63
+ totalWeightedInputPaymentBpsDiff: BigInt(message.result.totalWeightedInputPaymentBpsDiff),
63
64
  },
64
65
  },
65
66
  });
@@ -78,36 +78,36 @@ export declare const normalizeOrder: (order: Order, chainsConfig: ChainIdToVmTyp
78
78
  inputs: {
79
79
  payment: {
80
80
  chainId: string;
81
- currency: Uint8Array<ArrayBufferLike>;
81
+ currency: `0x${string}`;
82
82
  amount: string;
83
83
  weight: string;
84
84
  };
85
85
  refunds: {
86
86
  chainId: string;
87
- recipient: Uint8Array<ArrayBufferLike>;
88
- currency: Uint8Array<ArrayBufferLike>;
87
+ recipient: `0x${string}`;
88
+ currency: `0x${string}`;
89
89
  minimumAmount: string;
90
90
  deadline: number;
91
- extraData: import("viem").ByteArray;
91
+ extraData: `0x${string}`;
92
92
  }[];
93
93
  }[];
94
94
  output: {
95
95
  chainId: string;
96
96
  payments: {
97
- recipient: Uint8Array<ArrayBufferLike>;
98
- currency: Uint8Array<ArrayBufferLike>;
97
+ recipient: `0x${string}`;
98
+ currency: `0x${string}`;
99
99
  minimumAmount: string;
100
100
  expectedAmount: string;
101
101
  }[];
102
- calls: import("viem").ByteArray[];
102
+ calls: `0x${string}`[];
103
103
  deadline: number;
104
- extraData: import("viem").ByteArray;
104
+ extraData: `0x${string}`;
105
105
  };
106
106
  fees: {
107
107
  recipientChainId: string;
108
- recipient: Uint8Array<ArrayBufferLike>;
108
+ recipient: `0x${string}`;
109
109
  currencyChainId: string;
110
- currency: Uint8Array<ArrayBufferLike>;
110
+ currency: `0x${string}`;
111
111
  amount: string;
112
112
  }[];
113
113
  };
@@ -96,36 +96,36 @@ const normalizeOrder = (order, chainsConfig) => {
96
96
  inputs: order.inputs.map((input) => ({
97
97
  payment: {
98
98
  chainId: input.payment.chainId,
99
- currency: (0, utils_1.encodeAddress)(input.payment.currency, vmType(input.payment.chainId)),
99
+ currency: (0, utils_1.encodeAddressToHex)(input.payment.currency, vmType(input.payment.chainId)),
100
100
  amount: input.payment.amount,
101
101
  weight: input.payment.weight,
102
102
  },
103
103
  refunds: input.refunds.map((refund) => ({
104
104
  chainId: refund.chainId,
105
- recipient: (0, utils_1.encodeAddress)(refund.recipient, vmType(refund.chainId)),
106
- currency: (0, utils_1.encodeAddress)(refund.currency, vmType(refund.chainId)),
105
+ recipient: (0, utils_1.encodeAddressToHex)(refund.recipient, vmType(refund.chainId)),
106
+ currency: (0, utils_1.encodeAddressToHex)(refund.currency, vmType(refund.chainId)),
107
107
  minimumAmount: refund.minimumAmount,
108
108
  deadline: refund.deadline,
109
- extraData: (0, utils_1.encodeBytes)(refund.extraData),
109
+ extraData: (0, utils_1.encodeBytesToHex)(refund.extraData),
110
110
  })),
111
111
  })),
112
112
  output: {
113
113
  chainId: order.output.chainId,
114
114
  payments: order.output.payments.map((payment) => ({
115
- recipient: (0, utils_1.encodeAddress)(payment.recipient, vmType(order.output.chainId)),
116
- currency: (0, utils_1.encodeAddress)(payment.currency, vmType(order.output.chainId)),
115
+ recipient: (0, utils_1.encodeAddressToHex)(payment.recipient, vmType(order.output.chainId)),
116
+ currency: (0, utils_1.encodeAddressToHex)(payment.currency, vmType(order.output.chainId)),
117
117
  minimumAmount: payment.minimumAmount,
118
118
  expectedAmount: payment.expectedAmount,
119
119
  })),
120
- calls: order.output.calls.map(utils_1.encodeBytes),
120
+ calls: order.output.calls.map(utils_1.encodeBytesToHex),
121
121
  deadline: order.output.deadline,
122
- extraData: (0, utils_1.encodeBytes)(order.output.extraData),
122
+ extraData: (0, utils_1.encodeBytesToHex)(order.output.extraData),
123
123
  },
124
124
  fees: order.fees.map((fee) => ({
125
125
  recipientChainId: fee.recipientChainId,
126
- recipient: (0, utils_1.encodeAddress)(fee.recipient, vmType(fee.recipientChainId)),
126
+ recipient: (0, utils_1.encodeAddressToHex)(fee.recipient, vmType(fee.recipientChainId)),
127
127
  currencyChainId: fee.currencyChainId,
128
- currency: (0, utils_1.encodeAddress)(fee.currency, vmType(fee.currencyChainId)),
128
+ currency: (0, utils_1.encodeAddressToHex)(fee.currency, vmType(fee.currencyChainId)),
129
129
  amount: fee.amount,
130
130
  })),
131
131
  };
package/dist/utils.d.ts CHANGED
@@ -1,9 +1,13 @@
1
+ import { Hex } from "viem";
1
2
  export type VmType = "bitcoin-vm" | "ethereum-vm" | "hyperliquid-vm" | "solana-vm" | "sui-vm" | "ton-vm" | "tron-vm" | "lighter-vm";
2
3
  export type ChainIdToVmType = Record<string, VmType>;
3
4
  export declare const getChainVmType: (chainId: string, chainsConfig: ChainIdToVmType) => VmType;
4
5
  export declare const getVmTypeNativeCurrency: (vmType: VmType) => "bc1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqmql8k8" | "0x0000000000000000000000000000000000000000" | "0x00000000000000000000000000000000" | "11111111111111111111111111111111" | "T9yD14Nj9j7xAB4dbGeiX9h8unkKHxuWwb" | "0";
6
+ export declare const encodeBytesToHex: (bytes: string) => `0x${string}`;
5
7
  export declare const encodeBytes: (bytes: string) => import("viem").ByteArray;
8
+ export declare const encodeAddressToHex: (address: string, vmType: VmType) => Hex;
6
9
  export declare const encodeAddress: (address: string, vmType: VmType) => Uint8Array;
7
10
  export declare const decodeAddress: (address: Uint8Array, vmType: VmType) => string;
11
+ export declare const encodeTransactionIdToHex: (transactionId: string, vmType: VmType) => Hex;
8
12
  export declare const encodeTransactionId: (transactionId: string, vmType: VmType) => Uint8Array;
9
13
  export declare const decodeTransactionId: (transactionId: Uint8Array, vmType: VmType) => string;
package/dist/utils.js CHANGED
@@ -36,7 +36,7 @@ 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.decodeTransactionId = exports.encodeTransactionId = exports.decodeAddress = exports.encodeAddress = exports.encodeBytes = exports.getVmTypeNativeCurrency = exports.getChainVmType = void 0;
39
+ exports.decodeTransactionId = exports.encodeTransactionId = exports.encodeTransactionIdToHex = exports.decodeAddress = exports.encodeAddress = exports.encodeAddressToHex = exports.encodeBytes = exports.encodeBytesToHex = exports.getVmTypeNativeCurrency = exports.getChainVmType = void 0;
40
40
  const viem_1 = require("viem");
41
41
  const bech32_1 = require("bech32");
42
42
  const bitcoin = __importStar(require("bitcoinjs-lib"));
@@ -69,10 +69,19 @@ const getVmTypeNativeCurrency = (vmType) => {
69
69
  }
70
70
  };
71
71
  exports.getVmTypeNativeCurrency = getVmTypeNativeCurrency;
72
+ const _toHexString = (arr) => {
73
+ return `0x${Buffer.from(arr).toString("hex")}`;
74
+ };
72
75
  // Bytes encoding
76
+ const encodeBytesToHex = (bytes) => _toHexString((0, exports.encodeBytes)(bytes));
77
+ exports.encodeBytesToHex = encodeBytesToHex;
73
78
  const encodeBytes = (bytes) => (0, viem_1.hexToBytes)(bytes);
74
79
  exports.encodeBytes = encodeBytes;
75
80
  // Address encoding
81
+ const encodeAddressToHex = (address, vmType) => {
82
+ return _toHexString((0, exports.encodeAddress)(address, vmType));
83
+ };
84
+ exports.encodeAddressToHex = encodeAddressToHex;
76
85
  const encodeAddress = (address, vmType) => {
77
86
  switch (vmType) {
78
87
  case "bitcoin-vm": {
@@ -195,6 +204,10 @@ const decodeAddress = (address, vmType) => {
195
204
  };
196
205
  exports.decodeAddress = decodeAddress;
197
206
  // Transaction encoding
207
+ const encodeTransactionIdToHex = (transactionId, vmType) => {
208
+ return _toHexString((0, exports.encodeTransactionId)(transactionId, vmType));
209
+ };
210
+ exports.encodeTransactionIdToHex = encodeTransactionIdToHex;
198
211
  const encodeTransactionId = (transactionId, vmType) => {
199
212
  switch (vmType) {
200
213
  case "bitcoin-vm": {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relay-protocol/settlement-sdk",
3
- "version": "0.0.91",
3
+ "version": "0.0.92",
4
4
  "description": "Relay protocol SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -28,7 +28,7 @@
28
28
  "bs58": "^6.0.0",
29
29
  "js-sha256": "^0.11.0",
30
30
  "tronweb": "^6.0.4",
31
- "viem": "^2.26.3"
31
+ "viem": "2.47.6"
32
32
  },
33
33
  "files": [
34
34
  "dist/**/*"