@relay-protocol/settlement-sdk 0.0.64 → 0.0.66
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 +108 -2
- package/dist/index.d.ts +2 -1
- package/dist/messages/v2.2/withdrawal-execution.d.ts +2 -2
- package/dist/networks.d.ts +48 -0
- package/dist/networks.js +2 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,3 +1,109 @@
|
|
|
1
|
-
|
|
1
|
+
# Relay Settlement SDK
|
|
2
2
|
|
|
3
|
-
|
|
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
|
-
|
|
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, };
|
|
@@ -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
|
-
|
|
35
|
+
export type WithdrawalAddressRequest = Omit<WithdrawalAddressParams, "depositoryChainId" | "amount" | "depositoryAddress"> & {
|
|
36
|
+
chainId: string;
|
|
37
37
|
amount: string;
|
|
38
38
|
};
|
|
39
39
|
export type WithdrawalInitiationMessage = {
|
|
@@ -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 {};
|
package/dist/networks.js
ADDED