@interest-protocol/xswap-sdk 1.0.1 → 1.0.3
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/dist/constants.d.ts +17 -15
- package/dist/constants.d.ts.map +1 -1
- package/dist/enclave-client.d.ts.map +1 -1
- package/dist/index.js +81 -96
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +81 -97
- package/dist/index.mjs.map +1 -1
- package/dist/schemas.d.ts +1 -6
- package/dist/schemas.d.ts.map +1 -1
- package/dist/utils.d.ts +0 -28
- package/dist/utils.d.ts.map +1 -1
- package/dist/xswap.d.ts +8 -7
- package/dist/xswap.d.ts.map +1 -1
- package/dist/xswap.types.d.ts +7 -3
- package/dist/xswap.types.d.ts.map +1 -1
- package/package.json +57 -54
package/dist/constants.d.ts
CHANGED
|
@@ -1,19 +1,20 @@
|
|
|
1
1
|
import type { WalletConfig } from './xswap.types';
|
|
2
|
-
export declare const
|
|
3
|
-
export declare const
|
|
4
|
-
export declare const
|
|
5
|
-
export declare const
|
|
2
|
+
export declare const ORIGINAL_PACKAGE_ID = "0xb188334e53f795fe12f0b516716d5b0b8024ddf51482df23525fd599c875edfa";
|
|
3
|
+
export declare const MAINNET_PACKAGE_ID = "0xb188334e53f795fe12f0b516716d5b0b8024ddf51482df23525fd599c875edfa";
|
|
4
|
+
export declare const ENCLAVE_CAP_OBJECT_ID = "0xe0f1b062c6ce742b8659e59ca29f8ebed7a926c292b4f8fc479ed82c04997abf";
|
|
5
|
+
export declare const ENCLAVE_OBJECT_ID = "0x73ed1600688bde2ffaaf8669ed0292809ae86c6945f076daa369c093060f7f04";
|
|
6
|
+
export declare const ENCLAVE_INITIAL_SHARED_VERSION = "788631979";
|
|
6
7
|
export declare const ENCLAVE_SHARED_OBJECT_DATA: {
|
|
7
|
-
readonly objectId: "
|
|
8
|
-
readonly initialSharedVersion: "
|
|
8
|
+
readonly objectId: "0x73ed1600688bde2ffaaf8669ed0292809ae86c6945f076daa369c093060f7f04";
|
|
9
|
+
readonly initialSharedVersion: "788631979";
|
|
9
10
|
};
|
|
10
|
-
export declare const ADMIN_CAP_OBJECT_ID = "
|
|
11
|
-
export declare const UPGRADE_CAP_OBJECT_ID = "
|
|
12
|
-
export declare const XSWAP_OBJECT_ID = "
|
|
13
|
-
export declare const XSWAP_INITIAL_SHARED_VERSION = "
|
|
11
|
+
export declare const ADMIN_CAP_OBJECT_ID = "0xbab05412dc7b3eeb9ae441d73c86f1f3442b49cf6ca4f34c5ca59c3c0dded688";
|
|
12
|
+
export declare const UPGRADE_CAP_OBJECT_ID = "0xa4e1aaf8a79289e097ffb3f7ac3ea7882fddf81329596fc25645b1e3d68dd1fc";
|
|
13
|
+
export declare const XSWAP_OBJECT_ID = "0xcbc04da0c892ca1f9d170976e84ff45dc6ae3439f01cbc93b3f06855c6c3e8a7";
|
|
14
|
+
export declare const XSWAP_INITIAL_SHARED_VERSION = "788588232";
|
|
14
15
|
export declare const XSWAP_SHARED_OBJECT_DATA: {
|
|
15
|
-
readonly objectId: "
|
|
16
|
-
readonly initialSharedVersion: "
|
|
16
|
+
readonly objectId: "0xcbc04da0c892ca1f9d170976e84ff45dc6ae3439f01cbc93b3f06855c6c3e8a7";
|
|
17
|
+
readonly initialSharedVersion: "788588232";
|
|
17
18
|
};
|
|
18
19
|
export declare const DWALLET_COORDINATOR_OBJECT_ID = "0x5ea59bce034008a006425df777da925633ef384ce25761657ea89e2a08ec75f3";
|
|
19
20
|
export declare const DWALLET_COORDINATOR_INITIAL_SHARED_VERSION = "595876492";
|
|
@@ -44,7 +45,8 @@ export declare const Functions: {
|
|
|
44
45
|
readonly Unpause: "unpause";
|
|
45
46
|
readonly AddWallet: "add_wallet";
|
|
46
47
|
readonly MintPresign: "mint_presign";
|
|
47
|
-
readonly
|
|
48
|
+
readonly TakePresign: "take_presign";
|
|
49
|
+
readonly SetRequestFee: "set_request_fee";
|
|
48
50
|
readonly CollectFees: "collect_fees";
|
|
49
51
|
readonly NewRequestParams: "new_request_params";
|
|
50
52
|
readonly NewSettleParams: "new_settle_params";
|
|
@@ -76,8 +78,8 @@ export declare const WalletKey: Record<typeof ChainId.Solana | typeof ChainId.Su
|
|
|
76
78
|
export declare const DWalletAddress: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
|
|
77
79
|
export declare const DWalletId: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
|
|
78
80
|
export declare const XCoreWalletId: Record<typeof ChainId.Solana | typeof ChainId.Sui, string>;
|
|
79
|
-
export declare const XCORE_PACKAGE_ID = "
|
|
80
|
-
export declare const PRESIGN_CAP_TYPE = "
|
|
81
|
+
export declare const XCORE_PACKAGE_ID = "0x1f9ded5e071cc9cb59dc1c4a0249e5674b82af44241092a0f40fc7a9bf6ea251";
|
|
82
|
+
export declare const PRESIGN_CAP_TYPE = "0x1f9ded5e071cc9cb59dc1c4a0249e5674b82af44241092a0f40fc7a9bf6ea251::presign_cap::PresignCap<0xb188334e53f795fe12f0b516716d5b0b8024ddf51482df23525fd599c875edfa::xswap::Witness>";
|
|
81
83
|
export declare const PCR_LENGTH = 48;
|
|
82
84
|
export declare const EMPTY_PCR: Uint8Array<ArrayBuffer>;
|
|
83
85
|
export declare const SOLANA_WALLET_CONFIG: WalletConfig;
|
package/dist/constants.d.ts.map
CHANGED
|
@@ -1 +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,qBA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,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;
|
|
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;IA8BlE,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"}
|
package/dist/index.js
CHANGED
|
@@ -3,18 +3,19 @@
|
|
|
3
3
|
var invariant = require('tiny-invariant');
|
|
4
4
|
var zod = require('zod');
|
|
5
5
|
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const
|
|
9
|
-
const
|
|
6
|
+
const ORIGINAL_PACKAGE_ID = '0xb188334e53f795fe12f0b516716d5b0b8024ddf51482df23525fd599c875edfa';
|
|
7
|
+
const MAINNET_PACKAGE_ID = '0xb188334e53f795fe12f0b516716d5b0b8024ddf51482df23525fd599c875edfa';
|
|
8
|
+
const ENCLAVE_CAP_OBJECT_ID = '0xe0f1b062c6ce742b8659e59ca29f8ebed7a926c292b4f8fc479ed82c04997abf';
|
|
9
|
+
const ENCLAVE_OBJECT_ID = '0x73ed1600688bde2ffaaf8669ed0292809ae86c6945f076daa369c093060f7f04';
|
|
10
|
+
const ENCLAVE_INITIAL_SHARED_VERSION = '788631979';
|
|
10
11
|
const ENCLAVE_SHARED_OBJECT_DATA = {
|
|
11
12
|
objectId: ENCLAVE_OBJECT_ID,
|
|
12
13
|
initialSharedVersion: ENCLAVE_INITIAL_SHARED_VERSION,
|
|
13
14
|
};
|
|
14
|
-
const ADMIN_CAP_OBJECT_ID = '
|
|
15
|
-
const UPGRADE_CAP_OBJECT_ID = '
|
|
16
|
-
const XSWAP_OBJECT_ID = '
|
|
17
|
-
const XSWAP_INITIAL_SHARED_VERSION = '
|
|
15
|
+
const ADMIN_CAP_OBJECT_ID = '0xbab05412dc7b3eeb9ae441d73c86f1f3442b49cf6ca4f34c5ca59c3c0dded688';
|
|
16
|
+
const UPGRADE_CAP_OBJECT_ID = '0xa4e1aaf8a79289e097ffb3f7ac3ea7882fddf81329596fc25645b1e3d68dd1fc';
|
|
17
|
+
const XSWAP_OBJECT_ID = '0xcbc04da0c892ca1f9d170976e84ff45dc6ae3439f01cbc93b3f06855c6c3e8a7';
|
|
18
|
+
const XSWAP_INITIAL_SHARED_VERSION = '788588232';
|
|
18
19
|
const XSWAP_SHARED_OBJECT_DATA = {
|
|
19
20
|
objectId: XSWAP_OBJECT_ID,
|
|
20
21
|
initialSharedVersion: XSWAP_INITIAL_SHARED_VERSION,
|
|
@@ -29,8 +30,8 @@ const Modules = {
|
|
|
29
30
|
XSwap: 'xswap',
|
|
30
31
|
Structs: 'structs',
|
|
31
32
|
};
|
|
32
|
-
const WITNESS_TYPE = `${
|
|
33
|
-
const XSWAP_TYPE = `${
|
|
33
|
+
const WITNESS_TYPE = `${ORIGINAL_PACKAGE_ID}::${Modules.XSwap}::Witness`;
|
|
34
|
+
const XSWAP_TYPE = `${ORIGINAL_PACKAGE_ID}::${Modules.XSwap}::XSWAP`;
|
|
34
35
|
const Functions = {
|
|
35
36
|
InitApp: 'init_app',
|
|
36
37
|
NewRequest: 'new_request',
|
|
@@ -48,7 +49,8 @@ const Functions = {
|
|
|
48
49
|
Unpause: 'unpause',
|
|
49
50
|
AddWallet: 'add_wallet',
|
|
50
51
|
MintPresign: 'mint_presign',
|
|
51
|
-
|
|
52
|
+
TakePresign: 'take_presign',
|
|
53
|
+
SetRequestFee: 'set_request_fee',
|
|
52
54
|
CollectFees: 'collect_fees',
|
|
53
55
|
NewRequestParams: 'new_request_params',
|
|
54
56
|
NewSettleParams: 'new_settle_params',
|
|
@@ -78,19 +80,19 @@ const WalletKey = {
|
|
|
78
80
|
[ChainId.Solana]: 0n,
|
|
79
81
|
};
|
|
80
82
|
const DWalletAddress = {
|
|
81
|
-
[ChainId.Sui]: '
|
|
82
|
-
[ChainId.Solana]: '
|
|
83
|
+
[ChainId.Sui]: '0x0d6d396862af7cd10d235069fee9580545e7fc0a9e74cf7a92ec1a6a1996313b',
|
|
84
|
+
[ChainId.Solana]: 'HmBJM5kjvCRE4iBd4kakGFRoaAyUfkq9xivMZgVzqGGC',
|
|
83
85
|
};
|
|
84
86
|
const DWalletId = {
|
|
85
|
-
[ChainId.Sui]: '
|
|
86
|
-
[ChainId.Solana]: '
|
|
87
|
+
[ChainId.Sui]: '0x66b32816bff596b27b7ae99ec2e0bc69e63035a0e087006fe4937b6b09e30b95',
|
|
88
|
+
[ChainId.Solana]: '0x3ca05691123a358e6793946ba38595d0925c68b656efe91ad08bbee430bfb26b',
|
|
87
89
|
};
|
|
88
90
|
const XCoreWalletId = {
|
|
89
|
-
[ChainId.Sui]: '
|
|
90
|
-
[ChainId.Solana]: '
|
|
91
|
+
[ChainId.Sui]: '0xb15f12512da8f21d853dcb549e2029f49e0a5dd0f56e88fc7b45d91d703ace0f',
|
|
92
|
+
[ChainId.Solana]: '0xc1b88839208b334cefbe141304a70fc51364069f7051a6b6b86fd0c3e9816144',
|
|
91
93
|
};
|
|
92
|
-
const XCORE_PACKAGE_ID = '
|
|
93
|
-
const PRESIGN_CAP_TYPE = `${XCORE_PACKAGE_ID}::presign_cap::PresignCap
|
|
94
|
+
const XCORE_PACKAGE_ID = '0x1f9ded5e071cc9cb59dc1c4a0249e5674b82af44241092a0f40fc7a9bf6ea251';
|
|
95
|
+
const PRESIGN_CAP_TYPE = `${XCORE_PACKAGE_ID}::presign_cap::PresignCap<${ORIGINAL_PACKAGE_ID}::xswap::Witness>`;
|
|
94
96
|
const PCR_LENGTH = 48;
|
|
95
97
|
const EMPTY_PCR = new Uint8Array(PCR_LENGTH).fill(0);
|
|
96
98
|
const SOLANA_WALLET_CONFIG = {
|
|
@@ -2750,11 +2752,6 @@ const WithdrawRequestProofRawSchema = zod.z.object({
|
|
|
2750
2752
|
tx_bytes: numberArray,
|
|
2751
2753
|
});
|
|
2752
2754
|
const PresignCapFieldsRawSchema = zod.z.object({
|
|
2753
|
-
app_type_name: zod.z.object({
|
|
2754
|
-
fields: zod.z.object({
|
|
2755
|
-
name: zod.z.string(),
|
|
2756
|
-
}),
|
|
2757
|
-
}),
|
|
2758
2755
|
wallet_key: zod.z.string(),
|
|
2759
2756
|
cap: zod.z.object({
|
|
2760
2757
|
fields: zod.z.object({
|
|
@@ -2765,7 +2762,7 @@ const PresignCapFieldsRawSchema = zod.z.object({
|
|
|
2765
2762
|
const PresignSessionFieldsRawSchema = zod.z.object({
|
|
2766
2763
|
state: zod.z.object({
|
|
2767
2764
|
fields: zod.z.object({
|
|
2768
|
-
presign: numberArray,
|
|
2765
|
+
presign: numberArray.optional(),
|
|
2769
2766
|
}),
|
|
2770
2767
|
}),
|
|
2771
2768
|
});
|
|
@@ -6224,44 +6221,16 @@ const parseU256LittleEndian = (bytes) => {
|
|
|
6224
6221
|
}
|
|
6225
6222
|
return result;
|
|
6226
6223
|
};
|
|
6227
|
-
/**
|
|
6228
|
-
* Extract the ed25519 public key from a dWallet's public_output.
|
|
6229
|
-
*
|
|
6230
|
-
* The public_output format is: [count, length, ...pubkey]
|
|
6231
|
-
* - Byte 0: count (typically 1)
|
|
6232
|
-
* - Byte 1: key length (32 for ed25519)
|
|
6233
|
-
* - Bytes 2-33: the 32-byte public key
|
|
6234
|
-
*/
|
|
6235
6224
|
const extractEd25519PublicKey = (publicOutput) => {
|
|
6236
6225
|
const keyLength = publicOutput[1];
|
|
6237
6226
|
invariant(keyLength === ED25519_PUBKEY_LENGTH, `Expected ed25519 key length ${ED25519_PUBKEY_LENGTH}, got ${keyLength}`);
|
|
6238
6227
|
return publicOutput.slice(2, 2 + ED25519_PUBKEY_LENGTH);
|
|
6239
6228
|
};
|
|
6240
|
-
/**
|
|
6241
|
-
* Extract the compressed secp256k1 public key from a dWallet's public_output.
|
|
6242
|
-
*
|
|
6243
|
-
* The public_output format is: [count, length, ...compressed_pubkey]
|
|
6244
|
-
* - Byte 0: count (typically 1)
|
|
6245
|
-
* - Byte 1: key length (33 for secp256k1 compressed)
|
|
6246
|
-
* - Bytes 2-34: the 33-byte compressed public key
|
|
6247
|
-
*/
|
|
6248
6229
|
const extractSecp256k1PublicKey = (publicOutput) => {
|
|
6249
6230
|
const keyLength = publicOutput[1];
|
|
6250
6231
|
invariant(keyLength === SECP256K1_COMPRESSED_PUBKEY_LENGTH, `Expected secp256k1 compressed key length ${SECP256K1_COMPRESSED_PUBKEY_LENGTH}, got ${keyLength}`);
|
|
6251
6232
|
return publicOutput.slice(2, 2 + SECP256K1_COMPRESSED_PUBKEY_LENGTH);
|
|
6252
6233
|
};
|
|
6253
|
-
/**
|
|
6254
|
-
* Serialize a secp256k1 signature for Sui transaction execution.
|
|
6255
|
-
*
|
|
6256
|
-
* Sui signature format: [flag byte] + [64-byte signature] + [33-byte compressed pubkey]
|
|
6257
|
-
* - Flag byte 0x01 indicates secp256k1
|
|
6258
|
-
* - Signature is 64 bytes (r || s)
|
|
6259
|
-
* - Public key is 33 bytes (compressed secp256k1)
|
|
6260
|
-
*
|
|
6261
|
-
* @param signature - 64-byte secp256k1 signature from IKA dWallet signing
|
|
6262
|
-
* @param publicKey - 33-byte compressed secp256k1 public key
|
|
6263
|
-
* @returns Serialized signature ready for Sui executeTransactionBlock
|
|
6264
|
-
*/
|
|
6265
6234
|
const serializeSuiSecp256k1Signature = (signature, publicKey) => {
|
|
6266
6235
|
invariant(signature.length === SECP256K1_SIGNATURE_LENGTH, `Expected signature length ${SECP256K1_SIGNATURE_LENGTH}, got ${signature.length}`);
|
|
6267
6236
|
invariant(publicKey.length === SECP256K1_COMPRESSED_PUBKEY_LENGTH, `Expected public key length ${SECP256K1_COMPRESSED_PUBKEY_LENGTH}, got ${publicKey.length}`);
|
|
@@ -6277,7 +6246,7 @@ const TxBytesKind = {
|
|
|
6277
6246
|
SuiTransaction: 'sui_transaction',
|
|
6278
6247
|
};
|
|
6279
6248
|
|
|
6280
|
-
var _XSwap_suiClient, _XSwap_packageId, _XSwap_xswapSharedObjectData, _XSwap_xcoreSharedObjectData, _XSwap_registrySharedObjectData, _XSwap_dwalletCoordinatorSharedObjectData, _XSwap_enclaveSharedObjectData;
|
|
6249
|
+
var _XSwap_suiClient, _XSwap_packageId, _XSwap_originalPackageId, _XSwap_xswapSharedObjectData, _XSwap_xcoreSharedObjectData, _XSwap_registrySharedObjectData, _XSwap_dwalletCoordinatorSharedObjectData, _XSwap_enclaveSharedObjectData;
|
|
6281
6250
|
const bcsBytes = suiBcs.vector(suiBcs.u8());
|
|
6282
6251
|
class XSwap {
|
|
6283
6252
|
static parseTxBytes(sourceChain, txBytes) {
|
|
@@ -6338,9 +6307,10 @@ class XSwap {
|
|
|
6338
6307
|
static parseWithdrawProof(raw) {
|
|
6339
6308
|
return XSwap.parseWithdrawRequestProof(raw);
|
|
6340
6309
|
}
|
|
6341
|
-
constructor({ suiClient, packageId, xswapSharedObjectData, xcoreSharedObjectData, registrySharedObjectData, dwalletCoordinatorSharedObjectData, enclaveSharedObjectData, }) {
|
|
6310
|
+
constructor({ suiClient, packageId, originalPackageId, xswapSharedObjectData, xcoreSharedObjectData, registrySharedObjectData, dwalletCoordinatorSharedObjectData, enclaveSharedObjectData, }) {
|
|
6342
6311
|
_XSwap_suiClient.set(this, void 0);
|
|
6343
6312
|
_XSwap_packageId.set(this, void 0);
|
|
6313
|
+
_XSwap_originalPackageId.set(this, void 0);
|
|
6344
6314
|
_XSwap_xswapSharedObjectData.set(this, void 0);
|
|
6345
6315
|
_XSwap_xcoreSharedObjectData.set(this, void 0);
|
|
6346
6316
|
_XSwap_registrySharedObjectData.set(this, void 0);
|
|
@@ -6348,13 +6318,13 @@ class XSwap {
|
|
|
6348
6318
|
_XSwap_enclaveSharedObjectData.set(this, void 0);
|
|
6349
6319
|
__classPrivateFieldSet(this, _XSwap_suiClient, suiClient, "f");
|
|
6350
6320
|
__classPrivateFieldSet(this, _XSwap_packageId, packageId ?? MAINNET_PACKAGE_ID, "f");
|
|
6321
|
+
__classPrivateFieldSet(this, _XSwap_originalPackageId, originalPackageId ?? ORIGINAL_PACKAGE_ID, "f");
|
|
6351
6322
|
__classPrivateFieldSet(this, _XSwap_xswapSharedObjectData, xswapSharedObjectData, "f");
|
|
6352
6323
|
__classPrivateFieldSet(this, _XSwap_xcoreSharedObjectData, xcoreSharedObjectData, "f");
|
|
6353
6324
|
__classPrivateFieldSet(this, _XSwap_registrySharedObjectData, registrySharedObjectData, "f");
|
|
6354
6325
|
__classPrivateFieldSet(this, _XSwap_dwalletCoordinatorSharedObjectData, dwalletCoordinatorSharedObjectData, "f");
|
|
6355
6326
|
__classPrivateFieldSet(this, _XSwap_enclaveSharedObjectData, enclaveSharedObjectData, "f");
|
|
6356
6327
|
}
|
|
6357
|
-
// === Params Builders ===
|
|
6358
6328
|
newRequestParams(tx, params) {
|
|
6359
6329
|
return tx.moveCall({
|
|
6360
6330
|
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.Structs}::${Functions.NewRequestParams}`,
|
|
@@ -6407,7 +6377,6 @@ class XSwap {
|
|
|
6407
6377
|
],
|
|
6408
6378
|
});
|
|
6409
6379
|
}
|
|
6410
|
-
// === Transaction Builders ===
|
|
6411
6380
|
initApp({ tx = new Transaction() } = {}) {
|
|
6412
6381
|
tx.moveCall({
|
|
6413
6382
|
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.InitApp}`,
|
|
@@ -6415,7 +6384,7 @@ class XSwap {
|
|
|
6415
6384
|
});
|
|
6416
6385
|
return tx;
|
|
6417
6386
|
}
|
|
6418
|
-
newRequest({ tx = new Transaction(), params }) {
|
|
6387
|
+
newRequest({ tx = new Transaction(), params, fee }) {
|
|
6419
6388
|
const requestParams = this.newRequestParams(tx, params);
|
|
6420
6389
|
const result = tx.moveCall({
|
|
6421
6390
|
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.NewRequest}`,
|
|
@@ -6426,6 +6395,7 @@ class XSwap {
|
|
|
6426
6395
|
this.immutableRegistryRef(tx),
|
|
6427
6396
|
this.immutableEnclaveRef(tx),
|
|
6428
6397
|
requestParams,
|
|
6398
|
+
fee,
|
|
6429
6399
|
],
|
|
6430
6400
|
});
|
|
6431
6401
|
return { tx, result };
|
|
@@ -6450,11 +6420,11 @@ class XSwap {
|
|
|
6450
6420
|
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.SettleRequest}`,
|
|
6451
6421
|
arguments: [
|
|
6452
6422
|
this.mutableXSwapRef(tx),
|
|
6453
|
-
tx.object.clock(),
|
|
6454
6423
|
this.mutableXCoreRef(tx),
|
|
6455
6424
|
this.mutableDwalletCoordinatorRef(tx),
|
|
6456
|
-
this.immutableRegistryRef(tx),
|
|
6457
6425
|
requestRef,
|
|
6426
|
+
tx.object.clock(),
|
|
6427
|
+
this.immutableRegistryRef(tx),
|
|
6458
6428
|
this.immutableEnclaveRef(tx),
|
|
6459
6429
|
tx.object(presignCapId),
|
|
6460
6430
|
settleParams,
|
|
@@ -6497,20 +6467,31 @@ class XSwap {
|
|
|
6497
6467
|
});
|
|
6498
6468
|
return { tx, result };
|
|
6499
6469
|
}
|
|
6500
|
-
mintPresign({ tx = new Transaction(), walletKey
|
|
6501
|
-
|
|
6470
|
+
mintPresign({ tx = new Transaction(), walletKey }) {
|
|
6471
|
+
tx.moveCall({
|
|
6502
6472
|
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.MintPresign}`,
|
|
6503
6473
|
arguments: [
|
|
6504
6474
|
this.mutableXSwapRef(tx),
|
|
6505
6475
|
this.mutableXCoreRef(tx),
|
|
6506
6476
|
this.mutableDwalletCoordinatorRef(tx),
|
|
6507
|
-
fee,
|
|
6508
6477
|
tx.pure.u64(walletKey),
|
|
6509
6478
|
],
|
|
6510
6479
|
});
|
|
6480
|
+
return tx;
|
|
6481
|
+
}
|
|
6482
|
+
takePresign({ tx = new Transaction(), walletKey, fee }) {
|
|
6483
|
+
const result = tx.moveCall({
|
|
6484
|
+
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.TakePresign}`,
|
|
6485
|
+
arguments: [
|
|
6486
|
+
this.mutableXSwapRef(tx),
|
|
6487
|
+
this.mutableXCoreRef(tx),
|
|
6488
|
+
this.mutableDwalletCoordinatorRef(tx),
|
|
6489
|
+
tx.pure.u64(walletKey),
|
|
6490
|
+
fee,
|
|
6491
|
+
],
|
|
6492
|
+
});
|
|
6511
6493
|
return { tx, result };
|
|
6512
6494
|
}
|
|
6513
|
-
// === Manager ===
|
|
6514
6495
|
addManager({ tx = new Transaction(), manager }) {
|
|
6515
6496
|
tx.moveCall({
|
|
6516
6497
|
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.AddManager}`,
|
|
@@ -6525,10 +6506,9 @@ class XSwap {
|
|
|
6525
6506
|
});
|
|
6526
6507
|
return tx;
|
|
6527
6508
|
}
|
|
6528
|
-
|
|
6529
|
-
setPresignFee({ tx = new Transaction(), adminCapId, fee }) {
|
|
6509
|
+
setRequestFee({ tx = new Transaction(), adminCapId, fee }) {
|
|
6530
6510
|
tx.moveCall({
|
|
6531
|
-
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.
|
|
6511
|
+
target: `${__classPrivateFieldGet(this, _XSwap_packageId, "f")}::${Modules.XSwap}::${Functions.SetRequestFee}`,
|
|
6532
6512
|
arguments: [this.mutableXSwapRef(tx), tx.object(adminCapId), tx.pure.u64(fee)],
|
|
6533
6513
|
});
|
|
6534
6514
|
return tx;
|
|
@@ -6622,7 +6602,6 @@ class XSwap {
|
|
|
6622
6602
|
});
|
|
6623
6603
|
return tx;
|
|
6624
6604
|
}
|
|
6625
|
-
// === Getters ===
|
|
6626
6605
|
async getRequest({ requestId }) {
|
|
6627
6606
|
const [obj, dynamicFields] = await Promise.all([
|
|
6628
6607
|
__classPrivateFieldGet(this, _XSwap_suiClient, "f").getObject({
|
|
@@ -6639,7 +6618,7 @@ class XSwap {
|
|
|
6639
6618
|
return XSwap.parseRequestFields(fields, txBytes);
|
|
6640
6619
|
}
|
|
6641
6620
|
async resolveTxBytes(dynamicFieldsData, sourceChain) {
|
|
6642
|
-
const txBytesField = dynamicFieldsData.find((field) => field.name.type === `${__classPrivateFieldGet(this,
|
|
6621
|
+
const txBytesField = dynamicFieldsData.find((field) => field.name.type === `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.XSwap}::TxBytesKey`);
|
|
6643
6622
|
if (!txBytesField) {
|
|
6644
6623
|
return null;
|
|
6645
6624
|
}
|
|
@@ -6682,13 +6661,13 @@ class XSwap {
|
|
|
6682
6661
|
txBytes,
|
|
6683
6662
|
};
|
|
6684
6663
|
}
|
|
6685
|
-
async getFirstPresign({ owner, walletKey,
|
|
6686
|
-
const caps = await this.getPresignCaps({ owner, walletKey
|
|
6664
|
+
async getFirstPresign({ owner, walletKey, }) {
|
|
6665
|
+
const caps = await this.getPresignCaps({ owner, walletKey });
|
|
6687
6666
|
const first = caps[0];
|
|
6688
|
-
invariant(first, `getFirstPresign: no PresignCap found for owner ${owner} with walletKey ${walletKey}
|
|
6667
|
+
invariant(first, `getFirstPresign: no PresignCap found for owner ${owner} with walletKey ${walletKey}`);
|
|
6689
6668
|
return first;
|
|
6690
6669
|
}
|
|
6691
|
-
async getPresignCaps({ owner, walletKey,
|
|
6670
|
+
async getPresignCaps({ owner, walletKey, }) {
|
|
6692
6671
|
const ownedObjects = await __classPrivateFieldGet(this, _XSwap_suiClient, "f").getOwnedObjects({
|
|
6693
6672
|
owner,
|
|
6694
6673
|
filter: { StructType: PRESIGN_CAP_TYPE },
|
|
@@ -6699,14 +6678,9 @@ class XSwap {
|
|
|
6699
6678
|
invariant(obj.data?.content?.dataType === 'moveObject', `getPresignCaps: unexpected content type for ${obj.data?.objectId}`);
|
|
6700
6679
|
const fields = PresignCapFieldsRawSchema.parse(obj.data.content.fields);
|
|
6701
6680
|
const objWalletKey = BigInt(fields.wallet_key);
|
|
6702
|
-
const objAppTypeName = fields.app_type_name.fields.name;
|
|
6703
6681
|
if (walletKey !== undefined && objWalletKey !== walletKey) {
|
|
6704
6682
|
continue;
|
|
6705
6683
|
}
|
|
6706
|
-
if (appTypeName !== undefined &&
|
|
6707
|
-
normalizeStructTag(objAppTypeName) !== normalizeStructTag(appTypeName)) {
|
|
6708
|
-
continue;
|
|
6709
|
-
}
|
|
6710
6684
|
const presignSessionId = fields.cap.fields.presign_id;
|
|
6711
6685
|
const sessionObj = await __classPrivateFieldGet(this, _XSwap_suiClient, "f").getObject({
|
|
6712
6686
|
id: presignSessionId,
|
|
@@ -6714,6 +6688,8 @@ class XSwap {
|
|
|
6714
6688
|
});
|
|
6715
6689
|
invariant(sessionObj.data?.content?.dataType === 'moveObject', `getPresignCaps: failed to fetch presign session ${presignSessionId}`);
|
|
6716
6690
|
const sessionFields = PresignSessionFieldsRawSchema.parse(sessionObj.data.content.fields);
|
|
6691
|
+
if (!sessionFields.state.fields.presign)
|
|
6692
|
+
continue;
|
|
6717
6693
|
results.push({
|
|
6718
6694
|
presignCapId: obj.data.objectId,
|
|
6719
6695
|
presign: new Uint8Array(sessionFields.state.fields.presign),
|
|
@@ -6754,24 +6730,22 @@ class XSwap {
|
|
|
6754
6730
|
const [rawBytes] = result.results[0].returnValues[0];
|
|
6755
6731
|
return suiBcs.bool().parse(new Uint8Array(rawBytes));
|
|
6756
6732
|
}
|
|
6757
|
-
// === Events ===
|
|
6758
6733
|
getEventTypes() {
|
|
6759
6734
|
return {
|
|
6760
|
-
requestCreated: `${__classPrivateFieldGet(this,
|
|
6761
|
-
requestSettled: `${__classPrivateFieldGet(this,
|
|
6762
|
-
requestCancelled: `${__classPrivateFieldGet(this,
|
|
6763
|
-
requestExpired: `${__classPrivateFieldGet(this,
|
|
6764
|
-
requestWithdrawn: `${__classPrivateFieldGet(this,
|
|
6765
|
-
chainAdded: `${__classPrivateFieldGet(this,
|
|
6766
|
-
chainRemoved: `${__classPrivateFieldGet(this,
|
|
6767
|
-
paused: `${__classPrivateFieldGet(this,
|
|
6768
|
-
unpaused: `${__classPrivateFieldGet(this,
|
|
6769
|
-
solverAdded: `${__classPrivateFieldGet(this,
|
|
6770
|
-
solverRemoved: `${__classPrivateFieldGet(this,
|
|
6771
|
-
walletAdded: `${__classPrivateFieldGet(this,
|
|
6735
|
+
requestCreated: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::RequestCreated`,
|
|
6736
|
+
requestSettled: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::RequestSettled`,
|
|
6737
|
+
requestCancelled: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::RequestCancelled`,
|
|
6738
|
+
requestExpired: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::RequestExpired`,
|
|
6739
|
+
requestWithdrawn: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::RequestWithdrawn`,
|
|
6740
|
+
chainAdded: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::ChainAdded`,
|
|
6741
|
+
chainRemoved: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::ChainRemoved`,
|
|
6742
|
+
paused: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::Paused`,
|
|
6743
|
+
unpaused: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::Unpaused`,
|
|
6744
|
+
solverAdded: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::SolverAdded`,
|
|
6745
|
+
solverRemoved: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::SolverRemoved`,
|
|
6746
|
+
walletAdded: `${__classPrivateFieldGet(this, _XSwap_originalPackageId, "f")}::${Modules.Structs}::WalletAdded`,
|
|
6772
6747
|
};
|
|
6773
6748
|
}
|
|
6774
|
-
// === Helpers ===
|
|
6775
6749
|
immutableXSwapRef(tx) {
|
|
6776
6750
|
return tx.sharedObjectRef({
|
|
6777
6751
|
objectId: __classPrivateFieldGet(this, _XSwap_xswapSharedObjectData, "f").objectId,
|
|
@@ -6839,9 +6813,19 @@ class XSwap {
|
|
|
6839
6813
|
return __classPrivateFieldGet(this, _XSwap_suiClient, "f");
|
|
6840
6814
|
}
|
|
6841
6815
|
}
|
|
6842
|
-
_XSwap_suiClient = new WeakMap(), _XSwap_packageId = new WeakMap(), _XSwap_xswapSharedObjectData = new WeakMap(), _XSwap_xcoreSharedObjectData = new WeakMap(), _XSwap_registrySharedObjectData = new WeakMap(), _XSwap_dwalletCoordinatorSharedObjectData = new WeakMap(), _XSwap_enclaveSharedObjectData = new WeakMap();
|
|
6816
|
+
_XSwap_suiClient = new WeakMap(), _XSwap_packageId = new WeakMap(), _XSwap_originalPackageId = new WeakMap(), _XSwap_xswapSharedObjectData = new WeakMap(), _XSwap_xcoreSharedObjectData = new WeakMap(), _XSwap_registrySharedObjectData = new WeakMap(), _XSwap_dwalletCoordinatorSharedObjectData = new WeakMap(), _XSwap_enclaveSharedObjectData = new WeakMap();
|
|
6843
6817
|
|
|
6844
6818
|
var _EnclaveClient_instances, _EnclaveClient_baseUrl, _EnclaveClient_apiKey, _EnclaveClient_fetchFromEnclave, _EnclaveClient_validateDigest;
|
|
6819
|
+
const TEXT_DECODER = new TextDecoder();
|
|
6820
|
+
const TEXT_ENCODER = new TextEncoder();
|
|
6821
|
+
const encodeTokenForEnclave = (tokenBytes, chainId) => {
|
|
6822
|
+
if (chainId === ChainId.Sui) {
|
|
6823
|
+
const structTag = TEXT_DECODER.decode(tokenBytes);
|
|
6824
|
+
const normalized = normalizeStructTag(structTag);
|
|
6825
|
+
return toHex(TEXT_ENCODER.encode(normalized)).replace(/^0x/, '');
|
|
6826
|
+
}
|
|
6827
|
+
return toHex(tokenBytes).replace(/^0x/, '');
|
|
6828
|
+
};
|
|
6845
6829
|
class EnclaveClient {
|
|
6846
6830
|
constructor({ baseUrl, apiKey }) {
|
|
6847
6831
|
_EnclaveClient_instances.add(this);
|
|
@@ -6870,9 +6854,9 @@ class EnclaveClient {
|
|
|
6870
6854
|
source_chain: args.sourceChain,
|
|
6871
6855
|
destination_chain: args.destinationChain,
|
|
6872
6856
|
destination_address: toHex(args.destinationAddress).replace(/^0x/, ''),
|
|
6873
|
-
destination_token:
|
|
6857
|
+
destination_token: encodeTokenForEnclave(args.destinationToken, args.destinationChain),
|
|
6874
6858
|
solver_recipient: args.solverRecipient.replace(/^0x/, ''),
|
|
6875
|
-
source_token:
|
|
6859
|
+
source_token: encodeTokenForEnclave(args.sourceToken, args.sourceChain),
|
|
6876
6860
|
source_amount: args.sourceAmount.toString(),
|
|
6877
6861
|
nonce_account: nonceAccount,
|
|
6878
6862
|
sui_gas_price_multiplier: suiGasPriceMultiplier,
|
|
@@ -6885,7 +6869,7 @@ class EnclaveClient {
|
|
|
6885
6869
|
const raw = await __classPrivateFieldGet(this, _EnclaveClient_instances, "m", _EnclaveClient_fetchFromEnclave).call(this, '/withdraw_request', {
|
|
6886
6870
|
chain_id: args.chainId,
|
|
6887
6871
|
user: toHex(args.user).replace(/^0x/, ''),
|
|
6888
|
-
token:
|
|
6872
|
+
token: encodeTokenForEnclave(args.token, args.chainId),
|
|
6889
6873
|
amount: args.amount.toString(),
|
|
6890
6874
|
recipient: toHex(args.recipient).replace(/^0x/, ''),
|
|
6891
6875
|
nonce_account: nonceAccount,
|
|
@@ -6947,6 +6931,7 @@ exports.Functions = Functions;
|
|
|
6947
6931
|
exports.Intent = Intent$1;
|
|
6948
6932
|
exports.MAINNET_PACKAGE_ID = MAINNET_PACKAGE_ID;
|
|
6949
6933
|
exports.Modules = Modules;
|
|
6934
|
+
exports.ORIGINAL_PACKAGE_ID = ORIGINAL_PACKAGE_ID;
|
|
6950
6935
|
exports.PCR_LENGTH = PCR_LENGTH;
|
|
6951
6936
|
exports.PRESIGN_CAP_TYPE = PRESIGN_CAP_TYPE;
|
|
6952
6937
|
exports.RequestStatus = RequestStatus;
|