@interest-protocol/xswap-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,73 @@
1
+ # @lattice/xswap-sdk
2
+
3
+ SDK for cross-chain atomic swaps via XSwap protocol.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ bun install
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { XSwap, ChainId, DWalletAddress } from '@lattice/xswap-sdk';
15
+
16
+ const xswap = new XSwap({
17
+ suiClient,
18
+ packageId: XSWAP_PACKAGE_ID,
19
+ xswapSharedObjectData,
20
+ xcoreSharedObjectData,
21
+ registrySharedObjectData,
22
+ });
23
+
24
+ // Create a new swap request
25
+ const tx = xswap.newRequest({
26
+ depositProof,
27
+ sourceChain: ChainId.Solana,
28
+ destinationChain: ChainId.Sui,
29
+ destinationAddress: userSuiAddress,
30
+ minDestinationAmount: 1000000n,
31
+ });
32
+
33
+ // Settle a request (solver)
34
+ const tx = xswap.settleRequest({
35
+ requestId,
36
+ settleProof,
37
+ });
38
+
39
+ // Withdraw funds after settlement
40
+ const tx = xswap.withdrawRequest({
41
+ requestId,
42
+ withdrawProof,
43
+ presignCapId,
44
+ });
45
+ ```
46
+
47
+ ## Proof Parsers
48
+
49
+ ```typescript
50
+ // Parse enclave proofs
51
+ const depositProof = XSwap.parseNewRequestProof(raw);
52
+ const settleProof = XSwap.parseSettleProof(raw);
53
+ const withdrawProof = XSwap.parseWithdrawProof(raw);
54
+ ```
55
+
56
+ ## Wallet Keys
57
+
58
+ | Chain | Wallet Key |
59
+ |-------|------------|
60
+ | Solana | 0 |
61
+ | Sui | 1 |
62
+
63
+ ## Development
64
+
65
+ ```bash
66
+ bun run build # Build package
67
+ bun run test # Run tests
68
+ bun run lint # Run linter
69
+ ```
70
+
71
+ ## Documentation
72
+
73
+ See [../CLAUDE.md](../CLAUDE.md) for SDK architecture patterns.
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=utils.test.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.test.d.ts","sourceRoot":"","sources":["../../src/__tests__/utils.test.ts"],"names":[],"mappings":""}
@@ -0,0 +1,85 @@
1
+ import type { WalletConfig } from './xswap.types';
2
+ export declare const MAINNET_PACKAGE_ID = "0x90db0c50c4e1de33ce47efad1b66268697e3cc7c6e078408b73706b9800e8029";
3
+ export declare const ENCLAVE_CAP_OBJECT_ID = "0x77603cae7a47a0b626849a693881ce388b06cfe4064e078593e59dd9c30dcb73";
4
+ export declare const ENCLAVE_OBJECT_ID = "0x6a3114a47361653001fdaf82c2bd8a2fe05e1f1a04f00ccc0761663827b1362f";
5
+ export declare const ENCLAVE_INITIAL_SHARED_VERSION = "782601414";
6
+ export declare const ENCLAVE_SHARED_OBJECT_DATA: {
7
+ readonly objectId: "0x6a3114a47361653001fdaf82c2bd8a2fe05e1f1a04f00ccc0761663827b1362f";
8
+ readonly initialSharedVersion: "782601414";
9
+ };
10
+ export declare const ADMIN_CAP_OBJECT_ID = "0xf7ab8d9fe74d1879ca16c4e789c10e06db91aa16de432c62dc979c8c7a7c4ae6";
11
+ export declare const UPGRADE_CAP_OBJECT_ID = "0xb8b11297b8d15f2a654eb9825f0ef78a4d231af3cfd289ac6182a64e59690124";
12
+ export declare const XSWAP_OBJECT_ID = "0xf1c5200b411c1ddc496a442bf4bfdf656072dde47338fa6cd5f6ef9e896a4250";
13
+ export declare const XSWAP_INITIAL_SHARED_VERSION = "781617911";
14
+ export declare const XSWAP_SHARED_OBJECT_DATA: {
15
+ readonly objectId: "0xf1c5200b411c1ddc496a442bf4bfdf656072dde47338fa6cd5f6ef9e896a4250";
16
+ readonly initialSharedVersion: "781617911";
17
+ };
18
+ export declare const DWALLET_COORDINATOR_OBJECT_ID = "0x5ea59bce034008a006425df777da925633ef384ce25761657ea89e2a08ec75f3";
19
+ export declare const DWALLET_COORDINATOR_INITIAL_SHARED_VERSION = "595876492";
20
+ export declare const DWALLET_COORDINATOR_SHARED_OBJECT_DATA: {
21
+ readonly objectId: "0x5ea59bce034008a006425df777da925633ef384ce25761657ea89e2a08ec75f3";
22
+ readonly initialSharedVersion: "595876492";
23
+ };
24
+ export declare const Modules: {
25
+ readonly XSwap: "xswap";
26
+ readonly Structs: "structs";
27
+ };
28
+ export declare const WITNESS_TYPE: string;
29
+ export declare const XSWAP_TYPE: string;
30
+ export declare const Functions: {
31
+ readonly InitApp: "init_app";
32
+ readonly NewRequest: "new_request";
33
+ readonly ShareRequest: "share_request";
34
+ readonly SettleRequest: "settle_request";
35
+ readonly CancelRequest: "cancel_request";
36
+ readonly ExpireRequest: "expire_request";
37
+ readonly WithdrawRequest: "withdraw_request";
38
+ readonly AddSolver: "add_solver";
39
+ readonly RemoveSolver: "remove_solver";
40
+ readonly AddChain: "add_chain";
41
+ readonly RemoveChain: "remove_chain";
42
+ readonly SetMinConfirmations: "set_min_confirmations";
43
+ readonly Pause: "pause";
44
+ readonly Unpause: "unpause";
45
+ readonly AddWallet: "add_wallet";
46
+ readonly MintPresign: "mint_presign";
47
+ readonly SetPresignFee: "set_presign_fee";
48
+ readonly CollectFees: "collect_fees";
49
+ readonly NewRequestParams: "new_request_params";
50
+ readonly NewSettleParams: "new_settle_params";
51
+ readonly NewWithdrawRequestParams: "new_withdraw_request_params";
52
+ readonly DigestConsumed: "digest_consumed";
53
+ readonly AddManager: "add_manager";
54
+ readonly RemoveManager: "remove_manager";
55
+ };
56
+ export declare const ChainId: {
57
+ readonly Solana: 1;
58
+ readonly Evm: 2;
59
+ readonly Sui: 3;
60
+ };
61
+ export type ChainId = (typeof ChainId)[keyof typeof ChainId];
62
+ export declare const Intent: {
63
+ readonly NewRequest: 0;
64
+ readonly Settle: 1;
65
+ readonly WithdrawRequest: 4;
66
+ };
67
+ export type Intent = (typeof Intent)[keyof typeof Intent];
68
+ export declare const RequestStatus: {
69
+ readonly Open: 0;
70
+ readonly Settled: 1;
71
+ readonly Cancelled: 2;
72
+ readonly Expired: 3;
73
+ };
74
+ export type RequestStatus = (typeof RequestStatus)[keyof typeof RequestStatus];
75
+ export declare const WalletKey: Record<typeof ChainId.Solana | typeof ChainId.Sui, bigint>;
76
+ export declare const DWalletAddress: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
77
+ export declare const DWalletId: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
78
+ export declare const XCoreWalletId: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
79
+ export declare const XCORE_PACKAGE_ID = "0x0966345c144f5c8daec0560b2d8ed054ed704db5d0d75fb29801aca7ac88977d";
80
+ export declare const PRESIGN_CAP_TYPE = "0x0966345c144f5c8daec0560b2d8ed054ed704db5d0d75fb29801aca7ac88977d::presign_cap::PresignCap";
81
+ export declare const PCR_LENGTH = 48;
82
+ export declare const EMPTY_PCR: Uint8Array<ArrayBuffer>;
83
+ export declare const SOLANA_WALLET_CONFIG: WalletConfig;
84
+ export declare const SUI_WALLET_CONFIG: WalletConfig;
85
+ //# 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,eAAe,CAAC;AAElD,eAAO,MAAM,kBAAkB,uEACyC,CAAC;AAEzE,eAAO,MAAM,qBAAqB,uEACsC,CAAC;AAEzE,eAAO,MAAM,iBAAiB,uEAC0C,CAAC;AAEzE,eAAO,MAAM,8BAA8B,cAAc,CAAC;AAE1D,eAAO,MAAM,0BAA0B;;;CAG7B,CAAC;AAEX,eAAO,MAAM,mBAAmB,uEACwC,CAAC;AAEzE,eAAO,MAAM,qBAAqB,uEACsC,CAAC;AAEzE,eAAO,MAAM,eAAe,uEAAuE,CAAC;AAEpG,eAAO,MAAM,4BAA4B,cAAc,CAAC;AAExD,eAAO,MAAM,wBAAwB;;;CAG3B,CAAC;AAEX,eAA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,MAAM,gBAAgB,gGAAiD,CAAC;AAE/E,eAAO,MAAM,UAAU,KAAK,CAAC;AAC7B,eAAO,MAAM,SAAS,yBAAqC,CAAC;AAE5D,eAAO,MAAM,oBAAoB,EAAE,YAKlC,CAAC;AAEF,eAAO,MAAM,iBAAiB,EAAE,YAK/B,CAAC"}
@@ -0,0 +1,13 @@
1
+ import type { EnclaveClientConstructorArgs, FetchNewRequestProofArgs, FetchRequestProofArgs, FetchSettleProofArgs, FetchWithdrawProofArgs, FetchWithdrawRequestProofArgs, NewRequestProof, RequestProof, SettleProof, WithdrawProof, WithdrawRequestProof } from './xswap.types';
2
+ export declare class EnclaveClient {
3
+ #private;
4
+ constructor({ baseUrl, apiKey }: EnclaveClientConstructorArgs);
5
+ fetchNewRequestProof({ digest, chainId, }: FetchNewRequestProofArgs): Promise<NewRequestProof>;
6
+ fetchRequestProof(args: FetchRequestProofArgs): Promise<RequestProof>;
7
+ fetchSettleProof(args: FetchSettleProofArgs): Promise<SettleProof>;
8
+ fetchWithdrawRequestProof(args: FetchWithdrawRequestProofArgs): Promise<WithdrawRequestProof>;
9
+ fetchWithdrawProof(args: FetchWithdrawProofArgs): Promise<WithdrawProof>;
10
+ healthCheck(): Promise<boolean>;
11
+ static getWalletKeyForChain(chainId: number): bigint;
12
+ }
13
+ //# sourceMappingURL=enclave-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"enclave-client.d.ts","sourceRoot":"","sources":["../src/enclave-client.ts"],"names":[],"mappings":"AAWA,OAAO,KAAK,EACR,4BAA4B,EAC5B,wBAAwB,EACxB,qBAAqB,EACrB,oBAAoB,EACpB,sBAAsB,EACtB,6BAA6B,EAC7B,eAAe,EACf,YAAY,EACZ,WAAW,EACX,aAAa,EACb,oBAAoB,EACvB,MAAM,eAAe,CAAC;AAEvB,qBAAa,aAAa;;gBAIV,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,4BAA4B;IAuCvD,oBAAoB,CAAC,EACvB,MAAM,EACN,OAAO,GACV,EAAE,wBAAwB,GAAG,OAAO,CAAC,eAAe,CAAC;IAehD,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,OAAO,CAAC,YAAY,CAAC;IAIrE,gBAAgB,CAAC,IAAI,EAAE,oBAAoB,GAAG,OAAO,CAAC,WAAW,CAAC;IA2BlE,yBAAyB,CAC3B,IAAI,EAAE,6BAA6B,GACpC,OAAO,CAAC,oBAAoB,CAAC;IAsB1B,kBAAkB,CAAC,IAAI,EAAE,sBAAsB,GAAG,OAAO,CAAC,aAAa,CAAC;IAIxE,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAKrC,MAAM,CAAC,oBAAoB,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM;CAKvD"}
@@ -0,0 +1,6 @@
1
+ export * from './constants';
2
+ export * from './enclave-client';
3
+ export * from './utils';
4
+ export * from './xswap';
5
+ export * from './xswap.types';
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,kBAAkB,CAAC;AACjC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC"}