@ledgerhq/coin-sui 0.7.1-nightly.1 → 0.8.0-nightly.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/.turbo/turbo-build.log +1 -1
- package/.unimportedrc.json +2 -1
- package/CHANGELOG.md +24 -0
- package/lib/api/index.d.ts +2 -3
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integration.test.d.ts +1 -0
- package/lib/api/index.integration.test.js +98 -105
- package/lib/api/index.integration.test.js.map +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/bridge/buildTransaction.d.ts.map +1 -1
- package/lib/bridge/buildTransaction.js +11 -2
- package/lib/bridge/buildTransaction.js.map +1 -1
- package/lib/bridge/buildTransaction.test.js +0 -2
- package/lib/bridge/buildTransaction.test.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -4
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.js +6 -2
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +1 -2
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getBalance.d.ts +1 -2
- package/lib/logic/getBalance.d.ts.map +1 -1
- package/lib/logic/getBalance.js.map +1 -1
- package/lib/logic/getBlock.d.ts +1 -2
- package/lib/logic/getBlock.d.ts.map +1 -1
- package/lib/logic/getBlock.js.map +1 -1
- package/lib/logic/listOperations.d.ts +1 -2
- package/lib/logic/listOperations.d.ts.map +1 -1
- package/lib/logic/listOperations.js.map +1 -1
- package/lib/logic/listOperations.test.js.map +1 -1
- package/lib/network/sdk.d.ts +7 -8
- package/lib/network/sdk.d.ts.map +1 -1
- package/lib/network/sdk.integration.test.d.ts +1 -0
- package/lib/network/sdk.integration.test.js +212 -224
- package/lib/network/sdk.integration.test.js.map +1 -1
- package/lib/network/sdk.js +1 -1
- package/lib/network/sdk.js.map +1 -1
- package/lib/network/sdk.test.js +4 -4
- package/lib/network/sdk.test.js.map +1 -1
- package/lib-es/api/index.d.ts +2 -3
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integration.test.d.ts +1 -0
- package/lib-es/api/index.integration.test.js +97 -106
- package/lib-es/api/index.integration.test.js.map +1 -1
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
- package/lib-es/bridge/buildTransaction.js +11 -2
- package/lib-es/bridge/buildTransaction.js.map +1 -1
- package/lib-es/bridge/buildTransaction.test.js +0 -2
- package/lib-es/bridge/buildTransaction.test.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -4
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.js +6 -2
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +1 -2
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getBalance.d.ts +1 -2
- package/lib-es/logic/getBalance.d.ts.map +1 -1
- package/lib-es/logic/getBalance.js.map +1 -1
- package/lib-es/logic/getBlock.d.ts +1 -2
- package/lib-es/logic/getBlock.d.ts.map +1 -1
- package/lib-es/logic/getBlock.js.map +1 -1
- package/lib-es/logic/listOperations.d.ts +1 -2
- package/lib-es/logic/listOperations.d.ts.map +1 -1
- package/lib-es/logic/listOperations.js.map +1 -1
- package/lib-es/logic/listOperations.test.js.map +1 -1
- package/lib-es/network/sdk.d.ts +7 -8
- package/lib-es/network/sdk.d.ts.map +1 -1
- package/lib-es/network/sdk.integration.test.d.ts +1 -0
- package/lib-es/network/sdk.integration.test.js +208 -225
- package/lib-es/network/sdk.integration.test.js.map +1 -1
- package/lib-es/network/sdk.js +1 -1
- package/lib-es/network/sdk.js.map +1 -1
- package/lib-es/network/sdk.test.js +4 -4
- package/lib-es/network/sdk.test.js.map +1 -1
- package/package.json +6 -8
- package/src/api/index.integration.test.ts +115 -123
- package/src/api/index.ts +5 -9
- package/src/bridge/buildTransaction.test.ts +0 -2
- package/src/bridge/buildTransaction.ts +12 -2
- package/src/logic/craftTransaction.ts +7 -4
- package/src/logic/estimateFees.ts +1 -2
- package/src/logic/getBalance.ts +1 -2
- package/src/logic/getBlock.ts +1 -2
- package/src/logic/listOperations.test.ts +1 -2
- package/src/logic/listOperations.ts +1 -2
- package/src/network/sdk.integration.test.ts +238 -244
- package/src/network/sdk.test.ts +4 -4
- package/src/network/sdk.ts +8 -13
- package/lib/api/types.d.ts +0 -6
- package/lib/api/types.d.ts.map +0 -1
- package/lib/api/types.js +0 -3
- package/lib/api/types.js.map +0 -1
- package/lib-es/api/types.d.ts +0 -6
- package/lib-es/api/types.d.ts.map +0 -1
- package/lib-es/api/types.js +0 -2
- package/lib-es/api/types.js.map +0 -1
- package/src/api/types.ts +0 -7
package/lib/network/sdk.d.ts
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Checkpoint, ExecuteTransactionBlockParams, PaginatedTransactionResponse, SuiClient, SuiTransactionBlockResponse, TransactionBlockData, QueryTransactionBlocksParams, BalanceChange } from "@mysten/sui/client";
|
|
2
2
|
import { BigNumber } from "bignumber.js";
|
|
3
|
-
import type { Block, BlockInfo, BlockTransaction, BlockOperation, Operation as Op } from "@ledgerhq/coin-framework/api/index";
|
|
3
|
+
import type { Block, BlockInfo, BlockTransaction, BlockOperation, Operation as Op, AssetInfo } from "@ledgerhq/coin-framework/api/index";
|
|
4
4
|
import type { Operation, OperationType } from "@ledgerhq/types-live";
|
|
5
5
|
import type { Transaction as TransactionType } from "../types";
|
|
6
6
|
import type { CreateExtrinsicArg } from "../logic/craftTransaction";
|
|
7
|
-
import { SuiAsset } from "../api/types";
|
|
8
7
|
type AsyncApiFunction<T> = (api: SuiClient) => Promise<T>;
|
|
9
8
|
export declare const TRANSACTIONS_LIMIT_PER_QUERY = 50;
|
|
10
9
|
export declare const TRANSACTIONS_LIMIT = 300;
|
|
@@ -72,7 +71,7 @@ export declare const getOperationCoinType: (transaction: SuiTransactionBlockResp
|
|
|
72
71
|
* Map the Sui history transaction to a Ledger Live Operation
|
|
73
72
|
*/
|
|
74
73
|
export declare function transactionToOperation(accountId: string, address: string, transaction: SuiTransactionBlockResponse): Operation;
|
|
75
|
-
export declare function transactionToOp(address: string, transaction: SuiTransactionBlockResponse): Op
|
|
74
|
+
export declare function transactionToOp(address: string, transaction: SuiTransactionBlockResponse): Op;
|
|
76
75
|
/**
|
|
77
76
|
* Convert a SUI RPC checkpoint info to a {@link BlockInfo}.
|
|
78
77
|
*
|
|
@@ -89,19 +88,19 @@ export declare function toBlockInfo(checkpoint: Checkpoint): BlockInfo;
|
|
|
89
88
|
*
|
|
90
89
|
* @param transaction SUI RPC transaction block response
|
|
91
90
|
*/
|
|
92
|
-
export declare function toBlockTransaction(transaction: SuiTransactionBlockResponse): BlockTransaction
|
|
91
|
+
export declare function toBlockTransaction(transaction: SuiTransactionBlockResponse): BlockTransaction;
|
|
93
92
|
/**
|
|
94
93
|
* Convert a SUI RPC transaction balance change to a {@link BlockOperation}.
|
|
95
94
|
*
|
|
96
95
|
* @param change balance change
|
|
97
96
|
*/
|
|
98
|
-
export declare function toBlockOperation(change: BalanceChange): BlockOperation
|
|
97
|
+
export declare function toBlockOperation(change: BalanceChange): BlockOperation[];
|
|
99
98
|
/**
|
|
100
99
|
* Convert a SUI coin type to a {@link SuiAsset}.
|
|
101
100
|
*
|
|
102
101
|
* @param coinType coin type, as returned from SUI RPC
|
|
103
102
|
*/
|
|
104
|
-
export declare function toSuiAsset(coinType: string):
|
|
103
|
+
export declare function toSuiAsset(coinType: string): AssetInfo;
|
|
105
104
|
export declare const getLastBlock: () => Promise<{
|
|
106
105
|
digest: string;
|
|
107
106
|
sequenceNumber: string;
|
|
@@ -115,7 +114,7 @@ export declare const filterOperations: (operationList1: SuiTransactionBlockRespo
|
|
|
115
114
|
/**
|
|
116
115
|
* Fetch operations for Alpaca
|
|
117
116
|
*/
|
|
118
|
-
export declare const getListOperations: (addr: string, cursor?: QueryTransactionBlocksParams["cursor"], withApiImpl?: typeof withApi) => Promise<Op
|
|
117
|
+
export declare const getListOperations: (addr: string, cursor?: QueryTransactionBlocksParams["cursor"], withApiImpl?: typeof withApi) => Promise<Op[]>;
|
|
119
118
|
/**
|
|
120
119
|
* Get a checkpoint (a.k.a, a block) metadata.
|
|
121
120
|
*
|
|
@@ -135,7 +134,7 @@ export declare const getBlockInfo: (id: string) => Promise<BlockInfo>;
|
|
|
135
134
|
* @param id the checkpoint digest or sequence number (as a string)
|
|
136
135
|
* @see {@link getBlockInfo}
|
|
137
136
|
*/
|
|
138
|
-
export declare const getBlock: (id: string) => Promise<Block
|
|
137
|
+
export declare const getBlock: (id: string) => Promise<Block>;
|
|
139
138
|
export declare const paymentInfo: (sender: string, fakeTransaction: TransactionType) => Promise<{
|
|
140
139
|
gasBudget: string;
|
|
141
140
|
totalGasUsed: bigint;
|
package/lib/network/sdk.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/network/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,6BAA6B,EAC7B,4BAA4B,EAE5B,SAAS,EACT,2BAA2B,EAC3B,oBAAoB,EAGpB,4BAA4B,EAC5B,aAAa,EAEd,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AACzC,OAAO,KAAK,EACV,KAAK,EACL,SAAS,EACT,gBAAgB,EAChB,cAAc,EACd,SAAS,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"sdk.d.ts","sourceRoot":"","sources":["../../src/network/sdk.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,UAAU,EACV,6BAA6B,EAC7B,4BAA4B,EAE5B,SAAS,EACT,2BAA2B,EAC3B,oBAAoB,EAGpB,4BAA4B,EAC5B,aAAa,EAEd,MA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M,yBAAyB,WAAkB;IACtD,GAAG,EAAE,SAAS,CAAC;IACf,OAAO,EAAE,MAAM,EAAE,CAAC;CACnB,KAAG,QAAQ,2BAA2B,EAAE,CAcxC,CAAC"}
|
|
@@ -1,228 +1,216 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
+
const config_1 = __importDefault(require("../config"));
|
|
8
|
+
const sdk_1 = require("./sdk");
|
|
9
|
+
const client_1 = require("@mysten/sui/client");
|
|
10
|
+
describe("SUI SDK Integration tests", () => {
|
|
11
|
+
beforeAll(() => {
|
|
12
|
+
config_1.default.setCoinConfig(() => ({
|
|
13
|
+
status: {
|
|
14
|
+
type: "active",
|
|
15
|
+
},
|
|
16
|
+
node: {
|
|
17
|
+
url: (0, client_1.getFullnodeUrl)("mainnet"),
|
|
18
|
+
},
|
|
19
|
+
}));
|
|
20
|
+
});
|
|
21
|
+
describe("getOperations", () => {
|
|
22
|
+
describe("Account 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164", () => {
|
|
23
|
+
// https://suiscan.xyz/mainnet/account/0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164/activity
|
|
24
|
+
// 5 as of 14/05/2025
|
|
25
|
+
const IN_OPERATIONS_COUNT = 2;
|
|
26
|
+
const OUT_OPERATIONS_COUNT = 3;
|
|
27
|
+
const TOTAL_OPERATIONS_COUNT = IN_OPERATIONS_COUNT + OUT_OPERATIONS_COUNT;
|
|
28
|
+
let operations;
|
|
29
|
+
const testingAccount = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
|
|
30
|
+
beforeAll(async () => {
|
|
31
|
+
operations = await (0, sdk_1.getOperations)("mockAccoundId", testingAccount);
|
|
32
|
+
});
|
|
33
|
+
describe("List", () => {
|
|
34
|
+
it("should fetch operations successfully", async () => {
|
|
35
|
+
expect(Array.isArray(operations)).toBeDefined();
|
|
36
|
+
});
|
|
37
|
+
it("should fetch all operations", async () => {
|
|
38
|
+
expect(operations.length).toBeGreaterThanOrEqual(TOTAL_OPERATIONS_COUNT);
|
|
39
|
+
});
|
|
40
|
+
it("should return the first operation at index 0 and the last at the end", async () => {
|
|
41
|
+
const oldestTxHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
|
|
42
|
+
const newestTxHash = "2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7";
|
|
43
|
+
expect(operations[operations.length - TOTAL_OPERATIONS_COUNT].hash).toEqual(newestTxHash);
|
|
44
|
+
expect(operations[operations.length - 1].hash).toEqual(oldestTxHash);
|
|
45
|
+
});
|
|
46
|
+
});
|
|
47
|
+
describe("Transaction types", () => {
|
|
48
|
+
it("should return correct IN/OUT operations numbers", async () => {
|
|
49
|
+
const inOps = operations.filter(op => op.type === "IN");
|
|
50
|
+
const outOps = operations.filter(op => op.type === "OUT");
|
|
51
|
+
expect(inOps.length).toBeGreaterThanOrEqual(IN_OPERATIONS_COUNT);
|
|
52
|
+
expect(outOps.length).toBeGreaterThanOrEqual(OUT_OPERATIONS_COUNT);
|
|
53
|
+
});
|
|
54
|
+
describe("SUI operations", () => {
|
|
55
|
+
it("should return SUI IN operations correctly", () => {
|
|
56
|
+
// https://suiscan.xyz/mainnet/tx/rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg
|
|
57
|
+
// Send 0.15 SUI to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
58
|
+
const txHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
|
|
59
|
+
const operation = operations.find(op => op.hash === txHash);
|
|
60
|
+
expect(operation).toMatchObject({
|
|
61
|
+
type: "IN",
|
|
62
|
+
value: (0, bignumber_js_1.default)("150000000"),
|
|
63
|
+
senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
64
|
+
recipients: [testingAccount],
|
|
65
|
+
extra: { coinType: "0x2::sui::SUI" },
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
it("should return SUI OUT operations correctly", () => {
|
|
69
|
+
// https://suiscan.xyz/mainnet/tx/CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW
|
|
70
|
+
// Get 0.052 SUI from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
71
|
+
const txHash = "CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW";
|
|
72
|
+
const operation = operations.find(op => op.hash === txHash);
|
|
73
|
+
expect(operation).toMatchObject({
|
|
74
|
+
type: "OUT",
|
|
75
|
+
value: (0, bignumber_js_1.default)("51747880"),
|
|
76
|
+
recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
77
|
+
senders: [testingAccount],
|
|
78
|
+
extra: { coinType: "0x2::sui::SUI" },
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
describe("SUI tokens operations", () => {
|
|
83
|
+
it("should return SUI tokens IN operations correctly", () => {
|
|
84
|
+
// https://suiscan.xyz/mainnet/tx/B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY
|
|
85
|
+
// Send 0.59 USDT to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
86
|
+
const txHash = "B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY";
|
|
87
|
+
const operation = operations.find(op => op.hash === txHash);
|
|
88
|
+
expect(operation).toMatchObject({
|
|
89
|
+
type: "IN",
|
|
90
|
+
value: (0, bignumber_js_1.default)("592557"),
|
|
91
|
+
senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
92
|
+
recipients: [testingAccount],
|
|
93
|
+
extra: {
|
|
94
|
+
coinType: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
|
|
95
|
+
},
|
|
96
|
+
});
|
|
97
|
+
});
|
|
98
|
+
it("should return SUI tokens OUT operations correctly", () => {
|
|
99
|
+
// https://suiscan.xyz/mainnet/tx/2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7
|
|
100
|
+
// Get 0.59 USDT from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
101
|
+
const txHash = "2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7";
|
|
102
|
+
const operation = operations.find(op => op.hash === txHash);
|
|
103
|
+
expect(operation).toMatchObject({
|
|
104
|
+
type: "OUT",
|
|
105
|
+
value: (0, bignumber_js_1.default)("592557"),
|
|
106
|
+
recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
107
|
+
senders: [testingAccount],
|
|
108
|
+
extra: {
|
|
109
|
+
coinType: "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
|
|
110
|
+
},
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
});
|
|
117
|
+
describe("getBalance", () => {
|
|
118
|
+
test("getAccountBalances should return account balance", async () => {
|
|
119
|
+
const address = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
|
|
120
|
+
const balance = await (0, sdk_1.getAccountBalances)(address);
|
|
121
|
+
expect(balance[0]).toHaveProperty("blockHeight");
|
|
122
|
+
expect(balance[0]).toHaveProperty("balance");
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
describe("createTransaction", () => {
|
|
126
|
+
test("createTransaction should build a transaction", async () => {
|
|
127
|
+
const address = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
|
|
128
|
+
const transaction = {
|
|
129
|
+
mode: "send",
|
|
130
|
+
family: "sui",
|
|
131
|
+
coinType: sdk_1.DEFAULT_COIN_TYPE,
|
|
132
|
+
amount: new bignumber_js_1.default(100),
|
|
133
|
+
recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
|
|
134
|
+
errors: {},
|
|
135
|
+
};
|
|
136
|
+
const tx = await (0, sdk_1.createTransaction)(address, transaction);
|
|
137
|
+
expect(tx).toBeInstanceOf(Uint8Array);
|
|
138
|
+
});
|
|
139
|
+
});
|
|
140
|
+
describe("paymentInfo", () => {
|
|
141
|
+
test("paymentInfo should return gas budget and fees", async () => {
|
|
142
|
+
const sender = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
|
|
143
|
+
const fakeTransaction = {
|
|
144
|
+
mode: "send",
|
|
145
|
+
family: "sui",
|
|
146
|
+
coinType: sdk_1.DEFAULT_COIN_TYPE,
|
|
147
|
+
amount: new bignumber_js_1.default(100),
|
|
148
|
+
recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
|
|
149
|
+
errors: {},
|
|
150
|
+
};
|
|
151
|
+
const info = await (0, sdk_1.paymentInfo)(sender, fakeTransaction);
|
|
152
|
+
expect(info).toHaveProperty("gasBudget");
|
|
153
|
+
expect(info).toHaveProperty("totalGasUsed");
|
|
154
|
+
expect(info).toHaveProperty("fees");
|
|
155
|
+
});
|
|
156
|
+
});
|
|
157
|
+
describe("getCheckpoint", () => {
|
|
158
|
+
test("getCheckpoint", async () => {
|
|
159
|
+
const checkpointById = await (0, sdk_1.getCheckpoint)("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
160
|
+
const checkpointBySequenceNumber = await (0, sdk_1.getCheckpoint)("164167623");
|
|
161
|
+
expect(checkpointById.epoch).toEqual("814");
|
|
162
|
+
expect(checkpointById.sequenceNumber).toEqual("164167623");
|
|
163
|
+
expect(checkpointById.timestampMs).toEqual("1751696298663");
|
|
164
|
+
expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
165
|
+
expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
|
|
166
|
+
expect(checkpointById.transactions.length).toEqual(19);
|
|
167
|
+
expect(checkpointById.digest).toEqual(checkpointBySequenceNumber.digest);
|
|
168
|
+
});
|
|
169
|
+
/*
|
|
170
|
+
test("getCheckpointWithTransactions", async () => {
|
|
171
|
+
const { checkpoint: checkpointById, transactions: checkpointByIdTransactions } =
|
|
172
|
+
await getCheckpointWithTransactions("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
173
|
+
const {
|
|
174
|
+
checkpoint: checkpointBySequenceNumber,
|
|
175
|
+
transactions: checkpointBySequenceNumberTransactions,
|
|
176
|
+
} = await getCheckpointWithTransactions("164167623");
|
|
177
|
+
expect(checkpointById.epoch).toEqual("814");
|
|
178
|
+
expect(checkpointById.sequenceNumber).toEqual("164167623");
|
|
179
|
+
expect(checkpointById.timestampMs).toEqual("1751696298663");
|
|
180
|
+
expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
181
|
+
expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
|
|
182
|
+
expect(checkpointById.transactions.length).toEqual(19);
|
|
183
|
+
expect(checkpointById).toEqual(checkpointBySequenceNumber);
|
|
184
|
+
expect(checkpointByIdTransactions.length).toEqual(19);
|
|
185
|
+
expect(checkpointBySequenceNumberTransactions.length).toEqual(19);
|
|
186
|
+
expect(checkpointByIdTransactions).toEqual(checkpointBySequenceNumberTransactions);
|
|
187
|
+
});
|
|
188
|
+
*/
|
|
189
|
+
});
|
|
190
|
+
describe("getBlockInfo", () => {
|
|
191
|
+
test("getBlockInfo should get block info by id or sequence number", async () => {
|
|
192
|
+
const blockById = await (0, sdk_1.getBlockInfo)("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
193
|
+
const blockBySequenceNumber = await (0, sdk_1.getBlockInfo)("164167623");
|
|
194
|
+
expect(blockById.height).toEqual(164167623);
|
|
195
|
+
expect(blockById.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
196
|
+
expect(blockById.time).toEqual(new Date(1751696298663));
|
|
197
|
+
expect(blockById.parent?.height).toEqual(164167622);
|
|
198
|
+
// expect(blockById.parent?.hash).toEqual("TODO");
|
|
199
|
+
expect(blockById).toEqual(blockBySequenceNumber);
|
|
200
|
+
});
|
|
201
|
+
});
|
|
202
|
+
describe("getBlock", () => {
|
|
203
|
+
test("getBlock should get block by id or sequence number", async () => {
|
|
204
|
+
const blockById = await (0, sdk_1.getBlock)("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
205
|
+
const blockBySequenceNumber = await (0, sdk_1.getBlock)("164167623");
|
|
206
|
+
expect(blockById.info.height).toEqual(164167623);
|
|
207
|
+
expect(blockById.info.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
208
|
+
expect(blockById.info.time).toEqual(new Date(1751696298663));
|
|
209
|
+
expect(blockById.info.parent?.height).toEqual(164167622);
|
|
210
|
+
// expect(blockById.info.parent?.hash).toEqual("TODO");
|
|
211
|
+
expect(blockById.transactions.length).toEqual(19);
|
|
212
|
+
expect(blockById).toEqual(blockBySequenceNumber);
|
|
213
|
+
});
|
|
6
214
|
});
|
|
7
215
|
});
|
|
8
|
-
// import BigNumber from "bignumber.js";
|
|
9
|
-
// import type { Operation } from "@ledgerhq/types-live";
|
|
10
|
-
// import { getEnv } from "@ledgerhq/live-env";
|
|
11
|
-
// import coinConfig from "../config";
|
|
12
|
-
// import {
|
|
13
|
-
// createTransaction,
|
|
14
|
-
// DEFAULT_COIN_TYPE,
|
|
15
|
-
// getAccountBalances,
|
|
16
|
-
// getOperations,
|
|
17
|
-
// getCheckpoint,
|
|
18
|
-
// getCheckpointWithTransactions,
|
|
19
|
-
// paymentInfo,
|
|
20
|
-
// } from "./sdk";
|
|
21
|
-
// describe("SUI SDK Integration tests", () => {
|
|
22
|
-
// beforeAll(() => {
|
|
23
|
-
// coinConfig.setCoinConfig(() => ({
|
|
24
|
-
// status: {
|
|
25
|
-
// type: "active",
|
|
26
|
-
// },
|
|
27
|
-
// node: {
|
|
28
|
-
// url: getEnv("API_SUI_NODE_PROXY"),
|
|
29
|
-
// },
|
|
30
|
-
// }));
|
|
31
|
-
// });
|
|
32
|
-
// describe("getOperations", () => {
|
|
33
|
-
// describe("Account 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164", () => {
|
|
34
|
-
// // https://suiscan.xyz/mainnet/account/0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164/activity
|
|
35
|
-
// // 5 as of 14/05/2025
|
|
36
|
-
// const IN_OPERATIONS_COUNT = 2;
|
|
37
|
-
// const OUT_OPERATIONS_COUNT = 3;
|
|
38
|
-
// const TOTAL_OPERATIONS_COUNT = IN_OPERATIONS_COUNT + OUT_OPERATIONS_COUNT;
|
|
39
|
-
// let operations: Operation[];
|
|
40
|
-
// const testingAccount = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
|
|
41
|
-
// beforeAll(async () => {
|
|
42
|
-
// operations = await getOperations("mockAccoundId", testingAccount);
|
|
43
|
-
// });
|
|
44
|
-
// describe("List", () => {
|
|
45
|
-
// it("should fetch operations successfully", async () => {
|
|
46
|
-
// expect(Array.isArray(operations)).toBeDefined();
|
|
47
|
-
// });
|
|
48
|
-
// it("should fetch all operations", async () => {
|
|
49
|
-
// expect(operations.length).toBeGreaterThanOrEqual(TOTAL_OPERATIONS_COUNT);
|
|
50
|
-
// });
|
|
51
|
-
// it("should return the first operation at index 0 and the last at the end", async () => {
|
|
52
|
-
// const oldestTxHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
|
|
53
|
-
// const newestTxHash = "2jXqsRSZNHZm4uEfpFxJE7A7RoZxWPZeANfBP4qGWkPR";
|
|
54
|
-
// expect(operations[operations.length - TOTAL_OPERATIONS_COUNT].hash).toEqual(newestTxHash);
|
|
55
|
-
// expect(operations[operations.length - 1].hash).toEqual(oldestTxHash);
|
|
56
|
-
// });
|
|
57
|
-
// });
|
|
58
|
-
// describe("Transaction types", () => {
|
|
59
|
-
// it("should return correct IN/OUT operations numbers", async () => {
|
|
60
|
-
// const inOps = operations.filter(op => op.type === "IN");
|
|
61
|
-
// const outOps = operations.filter(op => op.type === "OUT");
|
|
62
|
-
// expect(inOps.length).toBeGreaterThanOrEqual(IN_OPERATIONS_COUNT);
|
|
63
|
-
// expect(outOps.length).toBeGreaterThanOrEqual(OUT_OPERATIONS_COUNT);
|
|
64
|
-
// });
|
|
65
|
-
// describe("SUI operations", () => {
|
|
66
|
-
// it("should return SUI IN operations correctly", () => {
|
|
67
|
-
// // https://suiscan.xyz/mainnet/tx/rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg
|
|
68
|
-
// // Send 0.15 SUI to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
69
|
-
// const txHash = "rkTA5Tn9dgrWPnHgj2WK7rVnk5t9jC3ViPcHU9dewDg";
|
|
70
|
-
// const operation = operations.find(op => op.hash === txHash);
|
|
71
|
-
// expect(operation).toMatchObject({
|
|
72
|
-
// type: "IN",
|
|
73
|
-
// value: BigNumber("150000000"),
|
|
74
|
-
// senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
75
|
-
// recipients: [testingAccount],
|
|
76
|
-
// extra: { coinType: "0x2::sui::SUI" },
|
|
77
|
-
// });
|
|
78
|
-
// });
|
|
79
|
-
// it("should return SUI OUT operations correctly", () => {
|
|
80
|
-
// // https://suiscan.xyz/mainnet/tx/CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW
|
|
81
|
-
// // Get 0.052 SUI from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
82
|
-
// const txHash = "CnVCqFLDv9iJc3DPU2WGpJdZUjqFPhyEVJ5BAigEj9VW";
|
|
83
|
-
// const operation = operations.find(op => op.hash === txHash);
|
|
84
|
-
// expect(operation).toMatchObject({
|
|
85
|
-
// type: "OUT",
|
|
86
|
-
// value: BigNumber("51747880"),
|
|
87
|
-
// recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
88
|
-
// senders: [testingAccount],
|
|
89
|
-
// extra: { coinType: "0x2::sui::SUI" },
|
|
90
|
-
// });
|
|
91
|
-
// });
|
|
92
|
-
// });
|
|
93
|
-
// describe("SUI tokens operations", () => {
|
|
94
|
-
// it("should return SUI tokens IN operations correctly", () => {
|
|
95
|
-
// // https://suiscan.xyz/mainnet/tx/B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY
|
|
96
|
-
// // Send 0.59 USDT to 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
97
|
-
// const txHash = "B7x8pACzpoFSQ5rmA5T3Q91Q48CroFuerXf62KLaY5TY";
|
|
98
|
-
// const operation = operations.find(op => op.hash === txHash);
|
|
99
|
-
// expect(operation).toMatchObject({
|
|
100
|
-
// type: "IN",
|
|
101
|
-
// value: BigNumber("592557"),
|
|
102
|
-
// senders: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
103
|
-
// recipients: [testingAccount],
|
|
104
|
-
// extra: {
|
|
105
|
-
// coinType:
|
|
106
|
-
// "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
|
|
107
|
-
// },
|
|
108
|
-
// });
|
|
109
|
-
// });
|
|
110
|
-
// it("should return SUI tokens OUT operations correctly", () => {
|
|
111
|
-
// // https://suiscan.xyz/mainnet/tx/2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7
|
|
112
|
-
// // Get 0.59 USDT from 0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164
|
|
113
|
-
// const txHash = "2GjCnxe8wRqzG4Nr1pad6QAZzCxP8qJY4ioAaVaHvhF7";
|
|
114
|
-
// const operation = operations.find(op => op.hash === txHash);
|
|
115
|
-
// expect(operation).toMatchObject({
|
|
116
|
-
// type: "OUT",
|
|
117
|
-
// value: BigNumber("592557"),
|
|
118
|
-
// recipients: ["0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0"],
|
|
119
|
-
// senders: [testingAccount],
|
|
120
|
-
// extra: {
|
|
121
|
-
// coinType:
|
|
122
|
-
// "0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT",
|
|
123
|
-
// },
|
|
124
|
-
// });
|
|
125
|
-
// });
|
|
126
|
-
// });
|
|
127
|
-
// });
|
|
128
|
-
// });
|
|
129
|
-
// });
|
|
130
|
-
// describe("getBalance", () => {
|
|
131
|
-
// test("getAccountBalances should return account balance", async () => {
|
|
132
|
-
// const address = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
|
|
133
|
-
// const balance = await getAccountBalances(address);
|
|
134
|
-
// expect(balance[0]).toHaveProperty("blockHeight");
|
|
135
|
-
// expect(balance[0]).toHaveProperty("balance");
|
|
136
|
-
// });
|
|
137
|
-
// });
|
|
138
|
-
// describe("createTransaction", () => {
|
|
139
|
-
// test("createTransaction should build a transaction", async () => {
|
|
140
|
-
// const address = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
|
|
141
|
-
// const transaction = {
|
|
142
|
-
// mode: "send" as const,
|
|
143
|
-
// family: "sui" as const,
|
|
144
|
-
// coinType: DEFAULT_COIN_TYPE,
|
|
145
|
-
// amount: new BigNumber(100),
|
|
146
|
-
// recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
|
|
147
|
-
// errors: {},
|
|
148
|
-
// };
|
|
149
|
-
// const tx = await createTransaction(address, transaction);
|
|
150
|
-
// expect(tx).toBeInstanceOf(Uint8Array);
|
|
151
|
-
// });
|
|
152
|
-
// });
|
|
153
|
-
// describe("paymentInfo", () => {
|
|
154
|
-
// test("paymentInfo should return gas budget and fees", async () => {
|
|
155
|
-
// const sender = "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0";
|
|
156
|
-
// const fakeTransaction = {
|
|
157
|
-
// mode: "send" as const,
|
|
158
|
-
// family: "sui" as const,
|
|
159
|
-
// coinType: DEFAULT_COIN_TYPE,
|
|
160
|
-
// amount: new BigNumber(100),
|
|
161
|
-
// recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
|
|
162
|
-
// errors: {},
|
|
163
|
-
// };
|
|
164
|
-
// const info = await paymentInfo(sender, fakeTransaction);
|
|
165
|
-
// expect(info).toHaveProperty("gasBudget");
|
|
166
|
-
// expect(info).toHaveProperty("totalGasUsed");
|
|
167
|
-
// expect(info).toHaveProperty("fees");
|
|
168
|
-
// });
|
|
169
|
-
// });
|
|
170
|
-
// });
|
|
171
|
-
// describe("getCheckpoint", () => {
|
|
172
|
-
// test("getCheckpoint", async () => {
|
|
173
|
-
// const checkpointById = await getCheckpoint("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
174
|
-
// const checkpointBySequenceNumber = await getCheckpoint("164167623");
|
|
175
|
-
// expect(checkpointById.epoch).toEqual("814");
|
|
176
|
-
// expect(checkpointById.sequenceNumber).toEqual("164167623");
|
|
177
|
-
// expect(checkpointById.timestampMs).toEqual("1751696298663");
|
|
178
|
-
// expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
179
|
-
// expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
|
|
180
|
-
// expect(checkpointById.transactions.length).toEqual(19);
|
|
181
|
-
// expect(checkpointById).toEqual(checkpointBySequenceNumber);
|
|
182
|
-
// });
|
|
183
|
-
// test("getCheckpointWithTransactions", async () => {
|
|
184
|
-
// const { checkpoint: checkpointById, transactions: checkpointByIdTransactions } =
|
|
185
|
-
// await getCheckpointWithTransactions("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
186
|
-
// const {
|
|
187
|
-
// checkpoint: checkpointBySequenceNumber,
|
|
188
|
-
// transactions: checkpointBySequenceNumberTransactions,
|
|
189
|
-
// } = await getCheckpointWithTransactions("164167623");
|
|
190
|
-
// expect(checkpointById.epoch).toEqual("814");
|
|
191
|
-
// expect(checkpointById.sequenceNumber).toEqual("164167623");
|
|
192
|
-
// expect(checkpointById.timestampMs).toEqual("1751696298663");
|
|
193
|
-
// expect(checkpointById.digest).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
194
|
-
// expect(checkpointById.previousDigest).toEqual("6VKtVnpxstb968SzSrgYJ7zy5LXgFB6PnNHSJsT8Wr4E");
|
|
195
|
-
// expect(checkpointById.transactions.length).toEqual(19);
|
|
196
|
-
// expect(checkpointById).toEqual(checkpointBySequenceNumber);
|
|
197
|
-
// expect(checkpointByIdTransactions.length).toEqual(19);
|
|
198
|
-
// expect(checkpointBySequenceNumberTransactions.length).toEqual(19);
|
|
199
|
-
// expect(checkpointByIdTransactions).toEqual(checkpointBySequenceNumberTransactions);
|
|
200
|
-
// });
|
|
201
|
-
// });
|
|
202
|
-
// describe("getBlockInfo", () => {
|
|
203
|
-
// test("getBlockInfo should get block info by id or sequence number", async () => {
|
|
204
|
-
// const blockById = await getBlockInfo("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
205
|
-
// const blockBySequenceNumber = await getBlockInfo("164167623");
|
|
206
|
-
// expect(blockById.height).toEqual(164167623);
|
|
207
|
-
// expect(blockById.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
208
|
-
// expect(blockById.time).toEqual(new Date(1751696298663));
|
|
209
|
-
// expect(blockById.parent?.height).toEqual(164167622);
|
|
210
|
-
// expect(blockById.parent?.hash).toEqual("TODO");
|
|
211
|
-
// expect(blockById).toEqual(blockBySequenceNumber);
|
|
212
|
-
// });
|
|
213
|
-
// });
|
|
214
|
-
// describe("getBlock", () => {
|
|
215
|
-
// test("getBlock should get block by id or sequence number", async () => {
|
|
216
|
-
// const blockById = await getBlock("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
217
|
-
// const blockBySequenceNumber = await getBlock("164167623");
|
|
218
|
-
// expect(blockById.info.height).toEqual(164167623);
|
|
219
|
-
// expect(blockById.info.hash).toEqual("3Q4zW4ieWnNgKLEq6kvVfP35PX2tBDUJERTWYyyz4eyS");
|
|
220
|
-
// expect(blockById.info.time).toEqual(new Date(1751696298663));
|
|
221
|
-
// expect(blockById.info.parent?.height).toEqual(164167622);
|
|
222
|
-
// expect(blockById.info.parent?.hash).toEqual("TODO");
|
|
223
|
-
// expect(blockById.transactions.length).toEqual(19);
|
|
224
|
-
// expect(blockById).toEqual(blockBySequenceNumber);
|
|
225
|
-
// });
|
|
226
|
-
// });
|
|
227
|
-
// });
|
|
228
216
|
//# sourceMappingURL=sdk.integration.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sdk.integration.test.js","sourceRoot":"","sources":["../../src/network/sdk.integration.test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"sdk.integration.test.js","sourceRoot":"","sources":["../../src/network/sdk.integration.test.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AAErC,uDAAmC;AACnC,+BASe;AACf,+CAAoD;AAEpD,QAAQ,CAAC,2BAA2B,EAAE,GAAG,EAAE;IACzC,SAAS,CAAC,GAAG,EAAE;QACb,gBAAU,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC;YAC9B,MAAM,EAAE;gBACN,IAAI,EAAE,QAAQ;aACf;YACD,IAAI,EAAE;gBACJ,GAAG,EAAE,IAAA,uBAAc,EAAC,SAAS,CAAC;aAC/B;SACF,CAAC,CAAC,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC7B,QAAQ,CAAC,4EAA4E,EAAE,GAAG,EAAE;YAC1F,kHAAkH;YAElH,qBAAqB;YACrB,MAAM,mBAAmB,GAAG,CAAC,CAAC;YAC9B,MAAM,oBAAoB,GAAG,CAAC,CAAC;YAC/B,MAAM,sBAAsB,GAAG,mBAAmB,GAAG,oBAAoB,CAAC;YAE1E,IAAI,UAAuB,CAAC;YAE5B,MAAM,cAAc,GAAG,oEAAoE,CAAC;YAE5F,SAAS,CAAC,KAAK,IAAI,EAAE;gBACnB,UAAU,GAAG,MAAM,IAAA,mBAAa,EAAC,eAAe,EAAE,cAAc,CAAC,CAAC;YACpE,CAAC,CAAC,CA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AC,IAAI,CAAC,IAAI,CAAC,CAAC,OAAO,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,CAAC,CAAC;YAC7D,MAAM,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,OAAO,CAAC,SAAS,CAAC,CAAC;YACzD,uDAAuD;YACvD,MAAM,CAAC,SAAS,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;YAClD,MAAM,CAAC,SAAS,CAAC,CAAC,OAAO,CAAC,qBAAqB,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
package/lib/network/sdk.js
CHANGED
|
@@ -291,7 +291,7 @@ function toSuiAsset(coinType) {
|
|
|
291
291
|
case exports.DEFAULT_COIN_TYPE:
|
|
292
292
|
return { type: "native" };
|
|
293
293
|
default:
|
|
294
|
-
return { type: "token", coinType };
|
|
294
|
+
return { type: "token", assetReference: coinType };
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
exports.toSuiAsset = toSuiAsset;
|