@ledgerhq/coin-sui 0.15.0 → 0.16.0-nightly.1
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/CHANGELOG.md +22 -0
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.integration.test.js +1 -0
- package/lib/api/index.integration.test.js.map +1 -1
- package/lib/api/index.js +10 -2
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.js +1 -1
- package/lib/api/index.test.js.map +1 -1
- package/lib/bridge/buildTransaction.d.ts.map +1 -1
- package/lib/bridge/buildTransaction.js +1 -0
- package/lib/bridge/buildTransaction.js.map +1 -1
- package/lib/bridge/buildTransaction.test.js +2 -0
- package/lib/bridge/buildTransaction.test.js.map +1 -1
- package/lib/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib/bridge/getFeesForTransaction.js +4 -0
- package/lib/bridge/getFeesForTransaction.js.map +1 -1
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +3 -0
- package/lib/bridge/index.js.map +1 -1
- package/lib/logic/craftTransaction.d.ts +1 -1
- package/lib/logic/craftTransaction.d.ts.map +1 -1
- package/lib/logic/craftTransaction.integration.test.js +42 -0
- package/lib/logic/craftTransaction.integration.test.js.map +1 -1
- package/lib/logic/craftTransaction.js +3 -4
- package/lib/logic/craftTransaction.js.map +1 -1
- package/lib/logic/craftTransaction.test.js +19 -5
- package/lib/logic/craftTransaction.test.js.map +1 -1
- package/lib/logic/estimateFees.integration.test.js +4 -1
- package/lib/logic/estimateFees.integration.test.js.map +1 -1
- package/lib/logic/estimateFees.test.js +2 -0
- package/lib/logic/estimateFees.test.js.map +1 -1
- package/lib/network/index.d.ts +1 -1
- package/lib/network/sdk.d.ts +8 -4
- package/lib/network/sdk.d.ts.map +1 -1
- package/lib/network/sdk.integration.test.js +2 -2
- package/lib/network/sdk.integration.test.js.map +1 -1
- package/lib/network/sdk.js +78 -31
- package/lib/network/sdk.js.map +1 -1
- package/lib/network/sdk.test.js +148 -333
- package/lib/network/sdk.test.js.map +1 -1
- package/lib/types/model.d.ts +3 -0
- package/lib/types/model.d.ts.map +1 -1
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.integration.test.js +1 -0
- package/lib-es/api/index.integration.test.js.map +1 -1
- package/lib-es/api/index.js +10 -2
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.js +1 -1
- package/lib-es/api/index.test.js.map +1 -1
- package/lib-es/bridge/buildTransaction.d.ts.map +1 -1
- package/lib-es/bridge/buildTransaction.js +1 -0
- package/lib-es/bridge/buildTransaction.js.map +1 -1
- package/lib-es/bridge/buildTransaction.test.js +2 -0
- package/lib-es/bridge/buildTransaction.test.js.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.d.ts.map +1 -1
- package/lib-es/bridge/getFeesForTransaction.js +4 -0
- package/lib-es/bridge/getFeesForTransaction.js.map +1 -1
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +3 -0
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/logic/craftTransaction.d.ts +1 -1
- package/lib-es/logic/craftTransaction.d.ts.map +1 -1
- package/lib-es/logic/craftTransaction.integration.test.js +42 -0
- package/lib-es/logic/craftTransaction.integration.test.js.map +1 -1
- package/lib-es/logic/craftTransaction.js +3 -4
- package/lib-es/logic/craftTransaction.js.map +1 -1
- package/lib-es/logic/craftTransaction.test.js +19 -5
- package/lib-es/logic/craftTransaction.test.js.map +1 -1
- package/lib-es/logic/estimateFees.integration.test.js +4 -1
- package/lib-es/logic/estimateFees.integration.test.js.map +1 -1
- package/lib-es/logic/estimateFees.test.js +2 -0
- package/lib-es/logic/estimateFees.test.js.map +1 -1
- package/lib-es/network/index.d.ts +1 -1
- package/lib-es/network/sdk.d.ts +8 -4
- package/lib-es/network/sdk.d.ts.map +1 -1
- package/lib-es/network/sdk.integration.test.js +2 -2
- package/lib-es/network/sdk.integration.test.js.map +1 -1
- package/lib-es/network/sdk.js +75 -29
- package/lib-es/network/sdk.js.map +1 -1
- package/lib-es/network/sdk.test.js +148 -333
- package/lib-es/network/sdk.test.js.map +1 -1
- package/lib-es/types/model.d.ts +3 -0
- package/lib-es/types/model.d.ts.map +1 -1
- package/package.json +7 -7
- package/src/api/index.integration.test.ts +1 -0
- package/src/api/index.test.ts +1 -1
- package/src/api/index.ts +15 -2
- package/src/bridge/buildTransaction.test.ts +2 -0
- package/src/bridge/buildTransaction.ts +1 -0
- package/src/bridge/getFeesForTransaction.ts +4 -0
- package/src/bridge/index.ts +3 -0
- package/src/logic/craftTransaction.integration.test.ts +52 -0
- package/src/logic/craftTransaction.test.ts +55 -25
- package/src/logic/craftTransaction.ts +25 -20
- package/src/logic/estimateFees.integration.test.ts +4 -1
- package/src/logic/estimateFees.test.ts +2 -0
- package/src/network/sdk.integration.test.ts +2 -2
- package/src/network/sdk.test.ts +210 -369
- package/src/network/sdk.ts +114 -36
- package/src/types/model.ts +4 -0
- package/index.d.ts +0 -0
|
@@ -10,7 +10,7 @@ describe("craftTransaction", () => {
|
|
|
10
10
|
|
|
11
11
|
beforeEach(() => {
|
|
12
12
|
jest.clearAllMocks();
|
|
13
|
-
mockCreateTransaction.mockResolvedValue(mockUnsignedTx);
|
|
13
|
+
mockCreateTransaction.mockResolvedValue({ unsigned: mockUnsignedTx });
|
|
14
14
|
});
|
|
15
15
|
|
|
16
16
|
it("should create a transaction with correct parameters", async () => {
|
|
@@ -18,8 +18,10 @@ describe("craftTransaction", () => {
|
|
|
18
18
|
const amount = BigInt("1000000000");
|
|
19
19
|
const recipient = "0x456";
|
|
20
20
|
const type = "send";
|
|
21
|
+
const intentType = "transaction";
|
|
21
22
|
|
|
22
23
|
const result = await craftTransaction({
|
|
24
|
+
intentType,
|
|
23
25
|
sender,
|
|
24
26
|
amount,
|
|
25
27
|
recipient,
|
|
@@ -27,12 +29,17 @@ describe("craftTransaction", () => {
|
|
|
27
29
|
asset: { type: "native" },
|
|
28
30
|
});
|
|
29
31
|
|
|
30
|
-
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
32
|
+
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
33
|
+
sender,
|
|
34
|
+
{
|
|
35
|
+
intentType,
|
|
36
|
+
amount: new BigNumber(amount.toString()),
|
|
37
|
+
recipient,
|
|
38
|
+
mode: type,
|
|
39
|
+
coinType: "0x2::sui::SUI",
|
|
40
|
+
},
|
|
41
|
+
false,
|
|
42
|
+
);
|
|
36
43
|
expect(result).toEqual({ unsigned: mockUnsignedTx });
|
|
37
44
|
});
|
|
38
45
|
|
|
@@ -41,8 +48,10 @@ describe("craftTransaction", () => {
|
|
|
41
48
|
const amount = BigInt("500000000");
|
|
42
49
|
const recipient = "0x456";
|
|
43
50
|
const type = "send";
|
|
51
|
+
const intentType = "transaction";
|
|
44
52
|
|
|
45
53
|
const result = await craftTransaction({
|
|
54
|
+
intentType,
|
|
46
55
|
sender,
|
|
47
56
|
amount,
|
|
48
57
|
recipient,
|
|
@@ -50,12 +59,17 @@ describe("craftTransaction", () => {
|
|
|
50
59
|
asset: { type: "native" },
|
|
51
60
|
});
|
|
52
61
|
|
|
53
|
-
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
62
|
+
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
63
|
+
sender,
|
|
64
|
+
{
|
|
65
|
+
intentType,
|
|
66
|
+
amount: new BigNumber(amount.toString()),
|
|
67
|
+
recipient,
|
|
68
|
+
mode: type,
|
|
69
|
+
coinType: "0x2::sui::SUI",
|
|
70
|
+
},
|
|
71
|
+
false,
|
|
72
|
+
);
|
|
59
73
|
expect(result).toEqual({ unsigned: mockUnsignedTx });
|
|
60
74
|
});
|
|
61
75
|
|
|
@@ -64,8 +78,10 @@ describe("craftTransaction", () => {
|
|
|
64
78
|
const amount = BigInt("0");
|
|
65
79
|
const recipient = "0x456";
|
|
66
80
|
const type = "send";
|
|
81
|
+
const intentType = "transaction";
|
|
67
82
|
|
|
68
83
|
const result = await craftTransaction({
|
|
84
|
+
intentType,
|
|
69
85
|
sender,
|
|
70
86
|
amount,
|
|
71
87
|
recipient,
|
|
@@ -73,12 +89,17 @@ describe("craftTransaction", () => {
|
|
|
73
89
|
asset: { type: "native" },
|
|
74
90
|
});
|
|
75
91
|
|
|
76
|
-
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
92
|
+
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
93
|
+
sender,
|
|
94
|
+
{
|
|
95
|
+
intentType,
|
|
96
|
+
amount: new BigNumber(amount.toString()),
|
|
97
|
+
recipient,
|
|
98
|
+
mode: type,
|
|
99
|
+
coinType: "0x2::sui::SUI",
|
|
100
|
+
},
|
|
101
|
+
false,
|
|
102
|
+
);
|
|
82
103
|
expect(result).toEqual({ unsigned: mockUnsignedTx });
|
|
83
104
|
});
|
|
84
105
|
|
|
@@ -87,8 +108,10 @@ describe("craftTransaction", () => {
|
|
|
87
108
|
const amount = BigInt("1000000000000000000"); // 1 SUI (assuming 9 decimals)
|
|
88
109
|
const recipient = "0x456";
|
|
89
110
|
const type = "send";
|
|
111
|
+
const intentType = "transaction";
|
|
90
112
|
|
|
91
113
|
const result = await craftTransaction({
|
|
114
|
+
intentType,
|
|
92
115
|
sender,
|
|
93
116
|
amount,
|
|
94
117
|
recipient,
|
|
@@ -96,12 +119,17 @@ describe("craftTransaction", () => {
|
|
|
96
119
|
asset: { type: "native" },
|
|
97
120
|
});
|
|
98
121
|
|
|
99
|
-
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
122
|
+
expect(mockCreateTransaction).toHaveBeenCalledWith(
|
|
123
|
+
sender,
|
|
124
|
+
{
|
|
125
|
+
intentType,
|
|
126
|
+
amount: new BigNumber(amount.toString()),
|
|
127
|
+
recipient,
|
|
128
|
+
mode: type,
|
|
129
|
+
coinType: "0x2::sui::SUI",
|
|
130
|
+
},
|
|
131
|
+
false,
|
|
132
|
+
);
|
|
105
133
|
expect(result).toEqual({ unsigned: mockUnsignedTx });
|
|
106
134
|
});
|
|
107
135
|
|
|
@@ -113,9 +141,11 @@ describe("craftTransaction", () => {
|
|
|
113
141
|
const amount = BigInt("1000000000");
|
|
114
142
|
const recipient = "0x456";
|
|
115
143
|
const type = "send";
|
|
144
|
+
const intentType = "transaction";
|
|
116
145
|
|
|
117
146
|
await expect(
|
|
118
147
|
craftTransaction({
|
|
148
|
+
intentType,
|
|
119
149
|
sender,
|
|
120
150
|
amount,
|
|
121
151
|
recipient,
|
|
@@ -4,28 +4,33 @@ import type { SuiTransactionMode, CoreTransaction } from "../types";
|
|
|
4
4
|
import suiAPI from "../network";
|
|
5
5
|
import { DEFAULT_COIN_TYPE } from "../network/sdk";
|
|
6
6
|
|
|
7
|
-
export async function craftTransaction(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
7
|
+
export async function craftTransaction(
|
|
8
|
+
{
|
|
9
|
+
amount,
|
|
10
|
+
asset,
|
|
11
|
+
recipient,
|
|
12
|
+
sender,
|
|
13
|
+
type,
|
|
14
|
+
...extra
|
|
15
|
+
}: TransactionIntent & {
|
|
16
|
+
useAllAmount?: boolean;
|
|
17
|
+
stakedSuiId?: string;
|
|
18
|
+
},
|
|
19
|
+
withObjects: boolean = false,
|
|
20
|
+
): Promise<CoreTransaction> {
|
|
18
21
|
let coinType = DEFAULT_COIN_TYPE;
|
|
19
22
|
if (asset.type === "token" && asset.assetReference) {
|
|
20
23
|
coinType = asset.assetReference;
|
|
21
24
|
}
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
25
|
+
return suiAPI.createTransaction(
|
|
26
|
+
sender,
|
|
27
|
+
{
|
|
28
|
+
amount: BigNumber(amount.toString()),
|
|
29
|
+
coinType,
|
|
30
|
+
mode: type as SuiTransactionMode,
|
|
31
|
+
recipient,
|
|
32
|
+
...extra,
|
|
33
|
+
},
|
|
34
|
+
withObjects,
|
|
35
|
+
);
|
|
31
36
|
}
|
|
@@ -3,7 +3,7 @@ import { getFullnodeUrl } from "@mysten/sui/client";
|
|
|
3
3
|
import coinConfig from "../config";
|
|
4
4
|
import { estimateFees } from "./estimateFees";
|
|
5
5
|
|
|
6
|
-
const SENDER = "
|
|
6
|
+
const SENDER = "0xad79719ac7edb44f6e253f1f771e8291e281a6aaf1e4789b52bf85336f525e8e";
|
|
7
7
|
const RECIPIENT = "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164";
|
|
8
8
|
|
|
9
9
|
describe("estimateFees", () => {
|
|
@@ -20,6 +20,7 @@ describe("estimateFees", () => {
|
|
|
20
20
|
|
|
21
21
|
it("should estimate fees for native SUI transaction", async () => {
|
|
22
22
|
const transactionIntent: TransactionIntent = {
|
|
23
|
+
intentType: "transaction",
|
|
23
24
|
sender: SENDER,
|
|
24
25
|
recipient: RECIPIENT,
|
|
25
26
|
amount: BigInt(1000),
|
|
@@ -39,6 +40,7 @@ describe("estimateFees", () => {
|
|
|
39
40
|
"0x375f70cf2ae4c00bf37117d0c85a2c71545e6ee05c4a5c7d282cd66a4504b068::usdt::USDT";
|
|
40
41
|
|
|
41
42
|
const transactionIntent: TransactionIntent = {
|
|
43
|
+
intentType: "transaction",
|
|
42
44
|
sender: SENDER,
|
|
43
45
|
recipient: RECIPIENT,
|
|
44
46
|
amount: BigInt(1000),
|
|
@@ -58,6 +60,7 @@ describe("estimateFees", () => {
|
|
|
58
60
|
|
|
59
61
|
it("should handle concurrent fee estimations", async () => {
|
|
60
62
|
const transactionIntent: TransactionIntent = {
|
|
63
|
+
intentType: "transaction",
|
|
61
64
|
sender: SENDER,
|
|
62
65
|
recipient: RECIPIENT,
|
|
63
66
|
amount: BigInt(1000),
|
|
@@ -23,6 +23,7 @@ describe("estimateFees", () => {
|
|
|
23
23
|
});
|
|
24
24
|
|
|
25
25
|
const transactionIntent = {
|
|
26
|
+
intentType: "transaction" as const,
|
|
26
27
|
sender: "0x123",
|
|
27
28
|
recipient: "0x456",
|
|
28
29
|
amount: BigInt("1000000000"),
|
|
@@ -50,6 +51,7 @@ describe("estimateFees", () => {
|
|
|
50
51
|
});
|
|
51
52
|
|
|
52
53
|
const transactionIntent = {
|
|
54
|
+
intentType: "transaction" as const,
|
|
53
55
|
sender: "0x123",
|
|
54
56
|
recipient: "0x456",
|
|
55
57
|
amount: BigInt("0"),
|
|
@@ -155,14 +155,14 @@ describe("SUI SDK Integration tests", () => {
|
|
|
155
155
|
recipient: "0x33444cf803c690db96527cec67e3c9ab512596f4ba2d4eace43f0b4f716e0164",
|
|
156
156
|
errors: {},
|
|
157
157
|
};
|
|
158
|
-
const tx = await createTransaction(address, transaction);
|
|
158
|
+
const { unsigned: tx } = await createTransaction(address, transaction);
|
|
159
159
|
expect(tx).toBeInstanceOf(Uint8Array);
|
|
160
160
|
});
|
|
161
161
|
});
|
|
162
162
|
|
|
163
163
|
describe("paymentInfo", () => {
|
|
164
164
|
test("paymentInfo should return gas budget and fees", async () => {
|
|
165
|
-
const sender = "
|
|
165
|
+
const sender = "0xad79719ac7edb44f6e253f1f771e8291e281a6aaf1e4789b52bf85336f525e8e";
|
|
166
166
|
const fakeTransaction = {
|
|
167
167
|
mode: "send" as const,
|
|
168
168
|
family: "sui" as const,
|