@relay-protocol/settlement-sdk 0.0.64 → 0.0.67

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/README.md CHANGED
@@ -1,3 +1,109 @@
1
- ## Relay protocol SDK
1
+ # Relay Settlement SDK
2
2
 
3
- > #### SDK for the Relay protocol
3
+ TypeScript SDK for encoding/decoding and passing messages accross the Relay Settlement Protocol.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @relay-protocol/settlement-sdk
9
+ # or
10
+ yarn add @relay-protocol/settlement-sdk
11
+ ```
12
+
13
+ ## Usage
14
+
15
+ ### Orders
16
+
17
+ ```typescript
18
+ import {
19
+ encodeOrderCall,
20
+ decodeOrderCall,
21
+ getOrderId,
22
+ } from "@relay-protocol/settlement-sdk"
23
+
24
+ // Encode an order call
25
+ const encoded = encodeOrderCall({
26
+ vmType: "ethereum-vm",
27
+ call: {
28
+ to: "0x...",
29
+ data: "0x...",
30
+ value: "1000000000000000000",
31
+ },
32
+ })
33
+
34
+ // Decode an order call
35
+ const decoded = decodeOrderCall(encoded, "ethereum-vm")
36
+
37
+ // Get order ID
38
+ const orderId = getOrderId(order, chainsConfig)
39
+ ```
40
+
41
+ ### Address Encoding
42
+
43
+ ```typescript
44
+ import {
45
+ encodeAddress,
46
+ decodeAddress,
47
+ VmType,
48
+ } from "@relay-protocol/settlement-sdk"
49
+
50
+ // Encode address for a specific VM type
51
+ const encoded = encodeAddress("bc1q...", "bitcoin-vm")
52
+ const decoded = decodeAddress(encoded, "bitcoin-vm")
53
+ ```
54
+
55
+ ### Hub Contract utils
56
+
57
+ ```typescript
58
+ import {
59
+ generateAddress,
60
+ generateTokenId,
61
+ } from "@relay-protocol/settlement-sdk"
62
+
63
+ // Generate virtual address
64
+ const virtualAddress = generateAddress({
65
+ family: "ethereum-vm",
66
+ chainId: 1n,
67
+ address: "0x...",
68
+ })
69
+
70
+ // Generate token ID
71
+ const tokenId = generateTokenId({
72
+ family: "ethereum-vm",
73
+ chainId: 1n,
74
+ address: "0x...",
75
+ })
76
+ ```
77
+
78
+ ### Depository Contracts utils
79
+
80
+ ```typescript
81
+ import {
82
+ encodeWithdrawal,
83
+ decodeWithdrawal,
84
+ getDepositoryDepositMessageId,
85
+ getExecutionMessageId,
86
+ } from "@relay-protocol/settlement-sdk"
87
+
88
+ // Encode/decode withdrawal messages
89
+ const encoded = encodeWithdrawal(withdrawal, vmType)
90
+ const decoded = decodeWithdrawal(encoded, vmType)
91
+
92
+ // Get message IDs
93
+ const depositId = getDepositoryDepositMessageId(message)
94
+ const executionId = getExecutionMessageId(message)
95
+ ```
96
+
97
+ ## Supported VM Types
98
+
99
+ - `bitcoin-vm`
100
+ - `ethereum-vm`
101
+ - `solana-vm`
102
+ - `sui-vm`
103
+ - `hyperliquid-vm`
104
+ - `tron-vm`
105
+ - `lighter-vm`
106
+
107
+ ## API Reference
108
+
109
+ See the [TypeScript definitions](./dist/index.d.ts) for complete API documentation.
package/dist/index.d.ts CHANGED
@@ -7,4 +7,5 @@ import { ActionType, ExecutionMessage, ExecutionMessageMetadata, getExecutionMes
7
7
  import { VmType, decodeAddress, decodeTransactionId, encodeAddress, encodeBytes, encodeTransactionId, getVmTypeNativeCurrency } from "./utils";
8
8
  import { SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, WithdrawalAddressParams, WithdrawalInitiationMessage, WithdrawalInitiatedMessage, WithdrawalAddressRequest } from "./messages/v2.2/withdrawal-execution";
9
9
  import { TokenIdComponents, VirtualAddressComponents, TokenId, VirtualAddress, getCheckSummedAddress, generateAddress, generateTokenId } from "./hub/hub-utils";
10
- 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, getCheckSummedAddress, generateAddress, generateTokenId, SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, WithdrawalAddressParams, WithdrawalInitiationMessage, WithdrawalInitiatedMessage, WithdrawalAddressRequest, };
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, getCheckSummedAddress, generateAddress, generateTokenId, SubmitWithdrawRequest, getSubmitWithdrawRequestHash, getWithdrawalAddress, WithdrawalAddressParams, WithdrawalInitiationMessage, WithdrawalInitiatedMessage, WithdrawalAddressRequest, NetworkConfigs, ProtocolContracts, NetworkConfig, };
@@ -10,10 +10,10 @@ export interface SubmitWithdrawRequest {
10
10
  }
11
11
  export declare const getSubmitWithdrawRequestHash: (request: SubmitWithdrawRequest) => `0x${string}`;
12
12
  export type WithdrawalAddressParams = {
13
- depositoryAddress: string;
13
+ depository: string;
14
14
  depositoryChainId: bigint;
15
15
  currency: string;
16
- recipientAddress: string;
16
+ recipient: string;
17
17
  withdrawerAlias: string;
18
18
  amount: bigint;
19
19
  withdrawalNonce: string;
@@ -21,10 +21,10 @@ export type WithdrawalAddressParams = {
21
21
  /**
22
22
  * Compute deterministic withdrawal address
23
23
  *
24
- * @param depositoryAddress the depository contract holding the funds on origin chain
24
+ * @param depository the depository contract holding the funds on origin chain
25
25
  * @param depositoryChainId the chain id of the depository contract currently holding the funds
26
26
  * @param currency the id of the currency as expressed on origin chain (string)
27
- * @param recipientAddress the address that will receive the withdrawn funds on destination chain
27
+ * @param recipient the address that will receive the withdrawn funds on destination chain
28
28
  * @param withdrawerAlias the address that owns the balance on the settlement chain
29
29
  * before the withdrawal is initiated
30
30
  * @param amount the balance to withdraw
@@ -32,8 +32,8 @@ export type WithdrawalAddressParams = {
32
32
  * @returns withdrawal address (in lower case)
33
33
  */
34
34
  export declare function getWithdrawalAddress(withdrawalParams: WithdrawalAddressParams): string;
35
- export type WithdrawalAddressRequest = Omit<WithdrawalAddressParams, "depositoryChainId" | "amount"> & {
36
- depositoryChainSlug: string;
35
+ export type WithdrawalAddressRequest = Omit<WithdrawalAddressParams, "depositoryChainId" | "amount" | "depository"> & {
36
+ chainId: string;
37
37
  amount: string;
38
38
  };
39
39
  export type WithdrawalInitiationMessage = {
@@ -35,10 +35,10 @@ exports.getSubmitWithdrawRequestHash = getSubmitWithdrawRequestHash;
35
35
  /**
36
36
  * Compute deterministic withdrawal address
37
37
  *
38
- * @param depositoryAddress the depository contract holding the funds on origin chain
38
+ * @param depository the depository contract holding the funds on origin chain
39
39
  * @param depositoryChainId the chain id of the depository contract currently holding the funds
40
40
  * @param currency the id of the currency as expressed on origin chain (string)
41
- * @param recipientAddress the address that will receive the withdrawn funds on destination chain
41
+ * @param recipient the address that will receive the withdrawn funds on destination chain
42
42
  * @param withdrawerAlias the address that owns the balance on the settlement chain
43
43
  * before the withdrawal is initiated
44
44
  * @param amount the balance to withdraw
@@ -57,10 +57,10 @@ function getWithdrawalAddress(withdrawalParams) {
57
57
  "uint256",
58
58
  "bytes32",
59
59
  ], [
60
- withdrawalParams.depositoryAddress,
60
+ withdrawalParams.depository,
61
61
  withdrawalParams.depositoryChainId,
62
62
  withdrawalParams.currency,
63
- withdrawalParams.recipientAddress,
63
+ withdrawalParams.recipient,
64
64
  withdrawalParams.withdrawerAlias,
65
65
  withdrawalParams.amount,
66
66
  nonce,
@@ -0,0 +1,48 @@
1
+ import { VmType } from "./utils";
2
+ export interface ProtocolContracts {
3
+ depository?: string;
4
+ oracle?: string;
5
+ allocator?: string;
6
+ multisigSigner?: string;
7
+ }
8
+ export interface NetworkConfig {
9
+ chainId: bigint;
10
+ name: string;
11
+ family: VmType;
12
+ slug: string;
13
+ earliestBlock?: number;
14
+ isTestnet: boolean;
15
+ assets?: NetworkAssets;
16
+ rpc: [string, ...string[]];
17
+ explorerApiUrl?: string;
18
+ blockExplorer?: {
19
+ chainId: number;
20
+ network: string;
21
+ urls: {
22
+ apiURL: string;
23
+ browserURL: string;
24
+ };
25
+ apiKey?: string;
26
+ };
27
+ nativeCurrency?: {
28
+ decimals: number;
29
+ name: string;
30
+ symbol: string;
31
+ };
32
+ near?: {
33
+ rpc: string;
34
+ signer: string;
35
+ };
36
+ hubChainId?: string;
37
+ contracts?: {
38
+ dev?: ProtocolContracts;
39
+ prod?: ProtocolContracts;
40
+ };
41
+ }
42
+ interface NetworkAssets {
43
+ [asset: string]: string;
44
+ }
45
+ export interface NetworkConfigs {
46
+ [networkId: string]: NetworkConfig;
47
+ }
48
+ export {};
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@relay-protocol/settlement-sdk",
3
- "version": "0.0.64",
3
+ "version": "0.0.67",
4
4
  "description": "Relay protocol SDK",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",