@interest-protocol/xbridge-sdk 1.0.0

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 ADDED
@@ -0,0 +1,110 @@
1
+ # @lattice/xbridge-sdk
2
+
3
+ SDK for cross-chain token bridge (inbound and outbound).
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun install
9
+ ```
10
+
11
+ ## Architecture
12
+
13
+ XBridge uses two separate contracts:
14
+
15
+ | Class | Direction | Description |
16
+ |-------|-----------|-------------|
17
+ | `XBridgeInbound` | Foreign → Sui | Mint wrapped tokens on Sui |
18
+ | `XBridgeOutbound` | Sui → Foreign | Lock native tokens on Sui |
19
+
20
+ ## Usage
21
+
22
+ ### Inbound (Foreign → Sui)
23
+
24
+ ```typescript
25
+ import { XBridgeInbound, ChainId } from '@lattice/xbridge-sdk';
26
+
27
+ const inbound = new XBridgeInbound({
28
+ suiClient,
29
+ packageId: INBOUND_PACKAGE_ID,
30
+ xbridgeInboundSharedObjectData,
31
+ xcoreSharedObjectData,
32
+ });
33
+
34
+ // Create mint request
35
+ const tx = inbound.newMintRequest({
36
+ sourceChain: ChainId.Solana,
37
+ digest,
38
+ amount: 1000000n,
39
+ fee,
40
+ coinType: '0x...::wsol::WSOL',
41
+ });
42
+
43
+ // Vote on mint request (validator)
44
+ const tx = inbound.voteMintRequest({
45
+ requestId,
46
+ voteProof,
47
+ coinType,
48
+ });
49
+ ```
50
+
51
+ ### Outbound (Sui → Foreign)
52
+
53
+ ```typescript
54
+ import { XBridgeOutbound, ChainId } from '@lattice/xbridge-sdk';
55
+
56
+ const outbound = new XBridgeOutbound({
57
+ suiClient,
58
+ packageId: OUTBOUND_PACKAGE_ID,
59
+ xbridgeOutboundSharedObjectData,
60
+ xcoreSharedObjectData,
61
+ });
62
+
63
+ // Create lock request
64
+ const tx = outbound.newLockRequest({
65
+ targetChain: ChainId.Solana,
66
+ recipient,
67
+ amount: 1000000n,
68
+ coin,
69
+ fee,
70
+ coinType: '0x2::sui::SUI',
71
+ });
72
+
73
+ // Vote on lock request (validator)
74
+ const tx = outbound.voteLockRequest({
75
+ requestId,
76
+ voteProof,
77
+ coinType,
78
+ });
79
+ ```
80
+
81
+ ## Wallet Keys
82
+
83
+ **IMPORTANT**: XBridge uses different wallet keys than XSwap.
84
+
85
+ | Chain | Wallet Key |
86
+ |-------|------------|
87
+ | Solana | 2 |
88
+ | Sui | 3 |
89
+
90
+ ## Enclave Intents
91
+
92
+ | Intent | Value | Use Case |
93
+ |--------|-------|----------|
94
+ | Vote | 2 | Vote on mint/burn requests |
95
+ | Cancel | 3 | Cancel mint request |
96
+ | VoteLock | 6 | Vote on lock requests |
97
+ | VoteUnlock | 7 | Vote on unlock requests |
98
+ | CancelUnlock | 8 | Cancel unlock request |
99
+
100
+ ## Development
101
+
102
+ ```bash
103
+ bun run build # Build package
104
+ bun run test # Run tests
105
+ bun run lint # Run linter
106
+ ```
107
+
108
+ ## Documentation
109
+
110
+ See [../CLAUDE.md](../CLAUDE.md) for SDK architecture patterns.
@@ -0,0 +1,171 @@
1
+ import type { WalletConfig } from './xbridge.types';
2
+ export declare const ORIGINAL_PACKAGE_ID = "0xb39fe0c60c140063923a723f4e0e5bc008d1593ae3c6a71aa89fed5dc3546c15";
3
+ export declare const MAINNET_PACKAGE_ID = "0xb39fe0c60c140063923a723f4e0e5bc008d1593ae3c6a71aa89fed5dc3546c15";
4
+ export declare const XBRIDGE_CONFIG_OBJECT_ID = "0x57c21dcb22f860504b160b5abf523b43c20398d9a7c675b46ba558bd530c79ee";
5
+ export declare const XBRIDGE_CONFIG_INITIAL_SHARED_VERSION = "782601350";
6
+ export declare const XBRIDGE_CONFIG_SHARED_OBJECT_DATA: {
7
+ readonly objectId: "0x57c21dcb22f860504b160b5abf523b43c20398d9a7c675b46ba558bd530c79ee";
8
+ readonly initialSharedVersion: "782601350";
9
+ };
10
+ export declare const XBRIDGE_INBOUND_OBJECT_ID = "0x4edfb48ff61c6722722d00949125b10ff3df263492339546ae75b94a276cb746";
11
+ export declare const XBRIDGE_INBOUND_INITIAL_SHARED_VERSION = "782601350";
12
+ export declare const XBRIDGE_INBOUND_SHARED_OBJECT_DATA: {
13
+ readonly objectId: "0x4edfb48ff61c6722722d00949125b10ff3df263492339546ae75b94a276cb746";
14
+ readonly initialSharedVersion: "782601350";
15
+ };
16
+ export declare const XBRIDGE_OUTBOUND_OBJECT_ID = "0xc7b3eec085c1920a0da6d4907883454c43e45facdbce614599d5722b70ba45dd";
17
+ export declare const XBRIDGE_OUTBOUND_INITIAL_SHARED_VERSION = "782601350";
18
+ export declare const XBRIDGE_OUTBOUND_SHARED_OBJECT_DATA: {
19
+ readonly objectId: "0xc7b3eec085c1920a0da6d4907883454c43e45facdbce614599d5722b70ba45dd";
20
+ readonly initialSharedVersion: "782601350";
21
+ };
22
+ export declare const ADMIN_CAP_OBJECT_ID = "0x2e29bc107f05fc340b124e8c4b174a7c661df5aea9dd98e546fcb27742608b61";
23
+ export declare const UPGRADE_CAP_OBJECT_ID = "0xe200edca09e4bd0c55ae3c3c65f52a5619ad5376292a966f62dcb72def60883b";
24
+ export declare const DWALLET_COORDINATOR_OBJECT_ID = "0x5ea59bce034008a006425df777da925633ef384ce25761657ea89e2a08ec75f3";
25
+ export declare const DWALLET_COORDINATOR_INITIAL_SHARED_VERSION = "595876492";
26
+ export declare const DWALLET_COORDINATOR_SHARED_OBJECT_DATA: {
27
+ readonly objectId: "0x5ea59bce034008a006425df777da925633ef384ce25761657ea89e2a08ec75f3";
28
+ readonly initialSharedVersion: "595876492";
29
+ };
30
+ export declare const ConfigModule: "config";
31
+ export declare const InboundModules: {
32
+ readonly Inbound: "inbound";
33
+ readonly Structs: "structs";
34
+ readonly Auth: "auth";
35
+ };
36
+ export declare const OutboundModules: {
37
+ readonly Outbound: "outbound";
38
+ readonly Structs: "structs";
39
+ readonly Auth: "auth";
40
+ };
41
+ export declare const ChainTokenModule: "chain_token";
42
+ export declare const ChainTokenFunctions: {
43
+ readonly NewSolana: "new_solana";
44
+ readonly NewEvm: "new_evm";
45
+ readonly NewSui: "new_sui";
46
+ };
47
+ export declare const ChainExecuteDataModule: "chain_execute_data";
48
+ export declare const ChainExecuteDataFunctions: {
49
+ readonly NewSolana: "new_solana";
50
+ readonly NewEvm: "new_evm";
51
+ readonly NewSui: "new_sui";
52
+ };
53
+ export declare const ConfigFunctions: {
54
+ readonly InitApp: "init_app";
55
+ readonly MintPresign: "mint_presign";
56
+ readonly AddWallet: "add_wallet";
57
+ readonly AddValidator: "add_validator";
58
+ readonly RemoveValidator: "remove_validator";
59
+ readonly SetMinVotes: "set_min_votes";
60
+ readonly SetMintFee: "set_mint_fee";
61
+ readonly SetBurnFee: "set_burn_fee";
62
+ readonly SetLockFee: "set_lock_fee";
63
+ readonly SetUnlockFee: "set_unlock_fee";
64
+ readonly SetPresignFee: "set_presign_fee";
65
+ readonly SetExpectedPcrs: "set_expected_pcrs";
66
+ readonly CollectFees: "collect_fees";
67
+ readonly Pause: "pause";
68
+ readonly Unpause: "unpause";
69
+ readonly AddWatchtower: "add_watchtower";
70
+ readonly RemoveWatchtower: "remove_watchtower";
71
+ };
72
+ export declare const InboundFunctions: {
73
+ readonly InitApp: "init_app";
74
+ readonly NewMintRequest: "new_mint_request";
75
+ readonly SetMintDigest: "set_mint_digest";
76
+ readonly VoteMintRequest: "vote_mint_request";
77
+ readonly ExecuteMintRequest: "execute_mint_request";
78
+ readonly CancelMintRequest: "cancel_mint_request";
79
+ readonly NewBurnRequest: "new_burn_request";
80
+ readonly VoteBurnRequest: "vote_burn_request";
81
+ readonly ExecuteBurnRequest: "execute_burn_request";
82
+ readonly CancelBurnRequest: "cancel_burn_request";
83
+ readonly MintPresign: "mint_presign";
84
+ readonly AddToken: "add_token";
85
+ readonly AddWallet: "add_wallet";
86
+ readonly AddChain: "add_chain";
87
+ readonly RemoveChain: "remove_chain";
88
+ readonly AddValidator: "add_validator";
89
+ readonly RemoveValidator: "remove_validator";
90
+ readonly SetMintFee: "set_mint_fee";
91
+ readonly SetBurnFee: "set_burn_fee";
92
+ readonly SetPresignFee: "set_presign_fee";
93
+ readonly SetExpectedPcrs: "set_expected_pcrs";
94
+ readonly SetMinVotes: "set_min_votes";
95
+ readonly SetMaxSupply: "set_max_supply";
96
+ readonly SetRateLimit: "set_rate_limit";
97
+ readonly CollectFees: "collect_fees";
98
+ readonly Pause: "pause";
99
+ readonly Unpause: "unpause";
100
+ readonly DigestConsumed: "digest_consumed";
101
+ readonly TotalSupply: "total_supply";
102
+ readonly AvailableMintSupply: "available_mint_supply";
103
+ };
104
+ export declare const OutboundFunctions: {
105
+ readonly InitApp: "init_app";
106
+ readonly NewLockRequest: "new_lock_request";
107
+ readonly VoteLockRequest: "vote_lock_request";
108
+ readonly ExecuteLockRequest: "execute_lock_request";
109
+ readonly CancelLockRequest: "cancel_lock_request";
110
+ readonly NewUnlockRequest: "new_unlock_request";
111
+ readonly SetUnlockDigest: "set_unlock_digest";
112
+ readonly VoteUnlockRequest: "vote_unlock_request";
113
+ readonly ExecuteUnlockRequest: "execute_unlock_request";
114
+ readonly CancelUnlockRequest: "cancel_unlock_request";
115
+ readonly MintPresign: "mint_presign";
116
+ readonly RegisterToken: "register_token";
117
+ readonly SetMaxLock: "set_max_lock";
118
+ readonly AddWallet: "add_wallet";
119
+ readonly AddChain: "add_chain";
120
+ readonly RemoveChain: "remove_chain";
121
+ readonly AddValidator: "add_validator";
122
+ readonly RemoveValidator: "remove_validator";
123
+ readonly SetLockFee: "set_lock_fee";
124
+ readonly SetUnlockFee: "set_unlock_fee";
125
+ readonly SetPresignFee: "set_presign_fee";
126
+ readonly SetExpectedPcrs: "set_expected_pcrs";
127
+ readonly SetMinVotes: "set_min_votes";
128
+ readonly SetRateLimit: "set_rate_limit";
129
+ readonly CollectFees: "collect_fees";
130
+ readonly Pause: "pause";
131
+ readonly Unpause: "unpause";
132
+ readonly DigestConsumed: "digest_consumed";
133
+ readonly LockedBalance: "locked_balance";
134
+ };
135
+ export declare const ChainId: {
136
+ readonly Solana: 1;
137
+ readonly Evm: 2;
138
+ readonly Sui: 3;
139
+ };
140
+ export type ChainId = (typeof ChainId)[keyof typeof ChainId];
141
+ export declare const Intent: {
142
+ readonly Vote: 2;
143
+ readonly Cancel: 3;
144
+ readonly VoteLock: 6;
145
+ readonly VoteUnlock: 7;
146
+ readonly CancelUnlock: 8;
147
+ };
148
+ export type Intent = (typeof Intent)[keyof typeof Intent];
149
+ export declare const RequestStatus: {
150
+ readonly Pending: 0;
151
+ readonly Completed: 1;
152
+ readonly Failed: 2;
153
+ };
154
+ export type RequestStatus = (typeof RequestStatus)[keyof typeof RequestStatus];
155
+ export declare const WalletKey: Record<typeof ChainId.Solana | typeof ChainId.Sui, bigint>;
156
+ export declare const DWalletAddress: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
157
+ export declare const DWalletId: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
158
+ export declare const XCoreWalletId: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
159
+ export declare const XCORE_PACKAGE_ID = "0x0966345c144f5c8daec0560b2d8ed054ed704db5d0d75fb29801aca7ac88977d";
160
+ export declare const TOKENS_PACKAGE_ID = "0x6ca737ee1a09538b3a1335d75f676300c88db1440086f77eb33c46ecf8c67b12";
161
+ export declare const WRAPPED_SOL_OTW = "0x6ca737ee1a09538b3a1335d75f676300c88db1440086f77eb33c46ecf8c67b12::tokens::WrappedSol";
162
+ export declare const WRAPPED_SUI_OTW = "0x6ca737ee1a09538b3a1335d75f676300c88db1440086f77eb33c46ecf8c67b12::tokens::WrappedSui";
163
+ export declare const WRAPPED_SOL_TYPE = "0xb39fe0c60c140063923a723f4e0e5bc008d1593ae3c6a71aa89fed5dc3546c15::inbound::XToken<0x6ca737ee1a09538b3a1335d75f676300c88db1440086f77eb33c46ecf8c67b12::tokens::WrappedSol>";
164
+ export declare const WRAPPED_SUI_TYPE = "0xb39fe0c60c140063923a723f4e0e5bc008d1593ae3c6a71aa89fed5dc3546c15::inbound::XToken<0x6ca737ee1a09538b3a1335d75f676300c88db1440086f77eb33c46ecf8c67b12::tokens::WrappedSui>";
165
+ export declare const PRESIGN_CAP_TYPE = "0x0966345c144f5c8daec0560b2d8ed054ed704db5d0d75fb29801aca7ac88977d::presign_cap::PresignCap";
166
+ export declare const WITNESS_TYPE = "0xb39fe0c60c140063923a723f4e0e5bc008d1593ae3c6a71aa89fed5dc3546c15::auth::Witness";
167
+ export declare const PCR_LENGTH = 48;
168
+ export declare const EMPTY_PCR: Uint8Array<ArrayBuffer>;
169
+ export declare const SOLANA_WALLET_CONFIG: WalletConfig;
170
+ export declare const SUI_WALLET_CONFIG: WalletConfig;
171
+ //# sourceMappingURL=constants.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAC;AAEpD,eAAO,MAAM,mBAAmB,uEACwC,CAAC;AAEzE,eAAO,MAAM,kBAAkB,uEACyC,CAAC;AAEzE,eAAO,MAAM,wBAAwB,uEACmC,CAAC;AACzE,eAAO,MAAM,qCAAqC,cAAc,CAAC;AAEjE,eAAO,MAAM,iCAAiC;;;CAGpC,CAAC;AAEX,eAAO,MAAM,yBAAyB,uEACkC,CAAC;AACzE,eAAO,MAAM,sCAAsC,cAAc,CAAC;AAElE,eAAO,MAAM,kCAAkC;;;CAGrC,CAAC;AAEX,eAAO,MAAM,0BAA0B,uEACiC,CAAC;AACzE,eAAO,MAAM,uCAAuC,cAAc,CAAC;AAEnE,eAAO,MAAM,mCAAmC;;;CAGtC,CAAC;AAEX,eAAO,MAAM,mBAAmB,uEACwC,CAAC;AAEzE,eAAO,MAAM,qBAAqB,uEACsC,CAAC;AAEzE,eAAO,MAAM,6BAA6B,uEAC8B,CAAC;AAEzE,eAAO,MAAM,0CAA0C,cAAc,CAAC;AAEtE,eAAO,MAAM,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AAO,CAAC,MAAM,GAAG,OAAO,OAAO,CAAC,GAAG,EAAE,MAAM,CAGvE,CAAC;AAEX,eAAO,MAAM,aAAa,EAAE,MAAM,CAAC,OAAO,OAAO,CAAC,MAAM,GAAG,OAAO,OAAO,CAAC,GAAG,EAAE,MAAM,CAG3E,CAAC;AAEX,eAAO,MAAM,gBAAgB,uEAC2C,CAAC;AAEzE,eAAO,MAAM,iBAAiB,uEAC0C,CAAC;AAEzE,eAAO,MAAM,eAAe,2FAA6C,CAAC;AAC1E,eAAO,MAAM,eAAe,2FAA6C,CAAC;AAE1E,eAAO,MAAM,gBAAgB,gLAAgE,CAAC;AAC9F,eAAO,MAAM,gBAAgB,gLAAgE,CAAC;AAE9F,eAAO,MAAM,gBAAgB,gGAAiD,CAAC;AAE/E,eAAO,MAAM,YAAY,sFAA0C,CAAC;AAEpE,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,SAAS,yBAAqC,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,YAMlC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAM/B,CAAC"}
@@ -0,0 +1,6 @@
1
+ export * from './constants';
2
+ export * from './utils';
3
+ export * from './xbridge.types';
4
+ export * from './xbridge-inbound';
5
+ export * from './xbridge-outbound';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC;AAClC,cAAc,oBAAoB,CAAC"}