@ledgerhq/coin-sui 0.16.0 → 0.17.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/.unimportedrc.json +2 -1
- package/CHANGELOG.md +22 -0
- package/lib/api/index.d.ts.map +1 -1
- package/lib/api/index.js +1 -0
- package/lib/api/index.js.map +1 -1
- package/lib/logic/estimateFees.d.ts +4 -1
- package/lib/logic/estimateFees.d.ts.map +1 -1
- package/lib/logic/estimateFees.js +2 -1
- package/lib/logic/estimateFees.js.map +1 -1
- package/lib/logic/getValidators.d.ts +3 -0
- package/lib/logic/getValidators.d.ts.map +1 -0
- package/lib/logic/getValidators.js +24 -0
- package/lib/logic/getValidators.js.map +1 -0
- package/lib/logic/index.d.ts +1 -0
- package/lib/logic/index.d.ts.map +1 -1
- package/lib/logic/index.js +3 -1
- package/lib/logic/index.js.map +1 -1
- package/lib/network/index.d.ts +3 -2
- package/lib/network/index.d.ts.map +1 -1
- package/lib/network/index.js +3 -1
- package/lib/network/index.js.map +1 -1
- package/lib/network/sdk.d.ts +4 -1
- package/lib/network/sdk.d.ts.map +1 -1
- package/lib/network/sdk.js +54 -23
- package/lib/network/sdk.js.map +1 -1
- package/lib/{bridge/bridge.integration.test.d.ts → test/bridge.dataset.d.ts} +1 -1
- package/lib/test/bridge.dataset.d.ts.map +1 -0
- package/lib/{bridge/bridge.integration.test.js → test/bridge.dataset.js} +2 -2
- package/lib/test/bridge.dataset.js.map +1 -0
- package/lib-es/api/index.d.ts.map +1 -1
- package/lib-es/api/index.js +2 -1
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/logic/estimateFees.d.ts +4 -1
- package/lib-es/logic/estimateFees.d.ts.map +1 -1
- package/lib-es/logic/estimateFees.js +2 -1
- package/lib-es/logic/estimateFees.js.map +1 -1
- package/lib-es/logic/getValidators.d.ts +3 -0
- package/lib-es/logic/getValidators.d.ts.map +1 -0
- package/lib-es/logic/getValidators.js +20 -0
- package/lib-es/logic/getValidators.js.map +1 -0
- package/lib-es/logic/index.d.ts +1 -0
- package/lib-es/logic/index.d.ts.map +1 -1
- package/lib-es/logic/index.js +1 -0
- package/lib-es/logic/index.js.map +1 -1
- package/lib-es/network/index.d.ts +3 -2
- package/lib-es/network/index.d.ts.map +1 -1
- package/lib-es/network/index.js +3 -2
- package/lib-es/network/index.js.map +1 -1
- package/lib-es/network/sdk.d.ts +4 -1
- package/lib-es/network/sdk.d.ts.map +1 -1
- package/lib-es/network/sdk.js +52 -22
- package/lib-es/network/sdk.js.map +1 -1
- package/lib-es/{bridge/bridge.integration.test.d.ts → test/bridge.dataset.d.ts} +1 -1
- package/lib-es/test/bridge.dataset.d.ts.map +1 -0
- package/lib-es/{bridge/bridge.integration.test.js → test/bridge.dataset.js} +2 -2
- package/lib-es/test/bridge.dataset.js.map +1 -0
- package/package.json +5 -9
- package/src/api/index.integration.test.ts +80 -7
- package/src/api/index.ts +2 -0
- package/src/logic/estimateFees.test.ts +22 -16
- package/src/logic/estimateFees.ts +6 -1
- package/src/logic/getValidators.test.ts +92 -0
- package/src/logic/getValidators.ts +23 -0
- package/src/logic/index.ts +1 -0
- package/src/network/index.ts +3 -0
- package/src/network/sdk.test.ts +134 -60
- package/src/network/sdk.ts +58 -23
- package/src/{bridge/bridge.integration.test.ts → test/bridge.dataset.ts} +1 -1
- package/lib/api/index.integration.test.d.ts +0 -2
- package/lib/api/index.integration.test.d.ts.map +0 -1
- package/lib/api/index.integration.test.js +0 -173
- package/lib/api/index.integration.test.js.map +0 -1
- package/lib/api/index.test.d.ts +0 -2
- package/lib/api/index.test.d.ts.map +0 -1
- package/lib/api/index.test.js +0 -173
- package/lib/api/index.test.js.map +0 -1
- package/lib/bridge/bridge.integration.test.d.ts.map +0 -1
- package/lib/bridge/bridge.integration.test.js.map +0 -1
- package/lib/bridge/broadcast.test.d.ts +0 -2
- package/lib/bridge/broadcast.test.d.ts.map +0 -1
- package/lib/bridge/broadcast.test.js +0 -48
- package/lib/bridge/broadcast.test.js.map +0 -1
- package/lib/bridge/buildOptimisticOperation.test.d.ts +0 -2
- package/lib/bridge/buildOptimisticOperation.test.d.ts.map +0 -1
- package/lib/bridge/buildOptimisticOperation.test.js +0 -52
- package/lib/bridge/buildOptimisticOperation.test.js.map +0 -1
- package/lib/bridge/buildTransaction.integration.test.d.ts +0 -2
- package/lib/bridge/buildTransaction.integration.test.d.ts.map +0 -1
- package/lib/bridge/buildTransaction.integration.test.js +0 -72
- package/lib/bridge/buildTransaction.integration.test.js.map +0 -1
- package/lib/bridge/buildTransaction.test.d.ts +0 -2
- package/lib/bridge/buildTransaction.test.d.ts.map +0 -1
- package/lib/bridge/buildTransaction.test.js +0 -231
- package/lib/bridge/buildTransaction.test.js.map +0 -1
- package/lib/bridge/estimateMaxSpendable.test.d.ts +0 -2
- package/lib/bridge/estimateMaxSpendable.test.d.ts.map +0 -1
- package/lib/bridge/estimateMaxSpendable.test.js +0 -52
- package/lib/bridge/estimateMaxSpendable.test.js.map +0 -1
- package/lib/bridge/formatters.test.d.ts +0 -2
- package/lib/bridge/formatters.test.d.ts.map +0 -1
- package/lib/bridge/formatters.test.js +0 -18
- package/lib/bridge/formatters.test.js.map +0 -1
- package/lib/bridge/getFeesForTransaction.test.d.ts +0 -2
- package/lib/bridge/getFeesForTransaction.test.d.ts.map +0 -1
- package/lib/bridge/getFeesForTransaction.test.js +0 -35
- package/lib/bridge/getFeesForTransaction.test.js.map +0 -1
- package/lib/bridge/getTransactionStatus.test.d.ts +0 -2
- package/lib/bridge/getTransactionStatus.test.d.ts.map +0 -1
- package/lib/bridge/getTransactionStatus.test.js +0 -69
- package/lib/bridge/getTransactionStatus.test.js.map +0 -1
- package/lib/bridge/index.test.d.ts +0 -2
- package/lib/bridge/index.test.d.ts.map +0 -1
- package/lib/bridge/index.test.js +0 -265
- package/lib/bridge/index.test.js.map +0 -1
- package/lib/bridge/preload.test.d.ts +0 -2
- package/lib/bridge/preload.test.d.ts.map +0 -1
- package/lib/bridge/preload.test.js +0 -52
- package/lib/bridge/preload.test.js.map +0 -1
- package/lib/bridge/prepareTransaction.test.d.ts +0 -2
- package/lib/bridge/prepareTransaction.test.d.ts.map +0 -1
- package/lib/bridge/prepareTransaction.test.js +0 -97
- package/lib/bridge/prepareTransaction.test.js.map +0 -1
- package/lib/bridge/serialization.test.d.ts +0 -2
- package/lib/bridge/serialization.test.d.ts.map +0 -1
- package/lib/bridge/serialization.test.js +0 -131
- package/lib/bridge/serialization.test.js.map +0 -1
- package/lib/bridge/signOperation.integration.test.d.ts +0 -2
- package/lib/bridge/signOperation.integration.test.d.ts.map +0 -1
- package/lib/bridge/signOperation.integration.test.js +0 -80
- package/lib/bridge/signOperation.integration.test.js.map +0 -1
- package/lib/bridge/signOperation.test.d.ts +0 -2
- package/lib/bridge/signOperation.test.d.ts.map +0 -1
- package/lib/bridge/signOperation.test.js +0 -445
- package/lib/bridge/signOperation.test.js.map +0 -1
- package/lib/bridge/synchronisation.test.d.ts +0 -2
- package/lib/bridge/synchronisation.test.d.ts.map +0 -1
- package/lib/bridge/synchronisation.test.js +0 -505
- package/lib/bridge/synchronisation.test.js.map +0 -1
- package/lib/bridge/transaction.test.d.ts +0 -2
- package/lib/bridge/transaction.test.d.ts.map +0 -1
- package/lib/bridge/transaction.test.js +0 -68
- package/lib/bridge/transaction.test.js.map +0 -1
- package/lib/logic/broadcast.test.d.ts +0 -2
- package/lib/logic/broadcast.test.d.ts.map +0 -1
- package/lib/logic/broadcast.test.js +0 -62
- package/lib/logic/broadcast.test.js.map +0 -1
- package/lib/logic/combine.test.d.ts +0 -2
- package/lib/logic/combine.test.d.ts.map +0 -1
- package/lib/logic/combine.test.js +0 -37
- package/lib/logic/combine.test.js.map +0 -1
- package/lib/logic/craftTransaction.integration.test.d.ts +0 -2
- package/lib/logic/craftTransaction.integration.test.d.ts.map +0 -1
- package/lib/logic/craftTransaction.integration.test.js +0 -98
- package/lib/logic/craftTransaction.integration.test.js.map +0 -1
- package/lib/logic/craftTransaction.test.d.ts +0 -2
- package/lib/logic/craftTransaction.test.d.ts.map +0 -1
- package/lib/logic/craftTransaction.test.js +0 -127
- package/lib/logic/craftTransaction.test.js.map +0 -1
- package/lib/logic/estimateFees.integration.test.d.ts +0 -2
- package/lib/logic/estimateFees.integration.test.d.ts.map +0 -1
- package/lib/logic/estimateFees.integration.test.js +0 -82
- package/lib/logic/estimateFees.integration.test.js.map +0 -1
- package/lib/logic/estimateFees.test.d.ts +0 -2
- package/lib/logic/estimateFees.test.d.ts.map +0 -1
- package/lib/logic/estimateFees.test.js +0 -70
- package/lib/logic/estimateFees.test.js.map +0 -1
- package/lib/logic/getBalance.integration.test.d.ts +0 -2
- package/lib/logic/getBalance.integration.test.d.ts.map +0 -1
- package/lib/logic/getBalance.integration.test.js +0 -56
- package/lib/logic/getBalance.integration.test.js.map +0 -1
- package/lib/logic/getBalance.test.d.ts +0 -2
- package/lib/logic/getBalance.test.d.ts.map +0 -1
- package/lib/logic/getBalance.test.js +0 -64
- package/lib/logic/getBalance.test.js.map +0 -1
- package/lib/logic/lastBlock.test.d.ts +0 -2
- package/lib/logic/lastBlock.test.d.ts.map +0 -1
- package/lib/logic/lastBlock.test.js +0 -27
- package/lib/logic/lastBlock.test.js.map +0 -1
- package/lib/logic/listOperations.test.d.ts +0 -2
- package/lib/logic/listOperations.test.d.ts.map +0 -1
- package/lib/logic/listOperations.test.js +0 -79
- package/lib/logic/listOperations.test.js.map +0 -1
- package/lib/network/sdk.integration.test.d.ts +0 -2
- package/lib/network/sdk.integration.test.d.ts.map +0 -1
- package/lib/network/sdk.integration.test.js +0 -215
- package/lib/network/sdk.integration.test.js.map +0 -1
- package/lib/network/sdk.test.d.ts +0 -2
- package/lib/network/sdk.test.d.ts.map +0 -1
- package/lib/network/sdk.test.js +0 -1784
- package/lib/network/sdk.test.js.map +0 -1
- package/lib/signer/getAddress.test.d.ts +0 -2
- package/lib/signer/getAddress.test.d.ts.map +0 -1
- package/lib/signer/getAddress.test.js +0 -106
- package/lib/signer/getAddress.test.js.map +0 -1
- package/lib/test/config.test.d.ts +0 -2
- package/lib/test/config.test.d.ts.map +0 -1
- package/lib/test/config.test.js +0 -44
- package/lib/test/config.test.js.map +0 -1
- package/lib-es/api/index.integration.test.d.ts +0 -2
- package/lib-es/api/index.integration.test.d.ts.map +0 -1
- package/lib-es/api/index.integration.test.js +0 -171
- package/lib-es/api/index.integration.test.js.map +0 -1
- package/lib-es/api/index.test.d.ts +0 -2
- package/lib-es/api/index.test.d.ts.map +0 -1
- package/lib-es/api/index.test.js +0 -148
- package/lib-es/api/index.test.js.map +0 -1
- package/lib-es/bridge/bridge.integration.test.d.ts.map +0 -1
- package/lib-es/bridge/bridge.integration.test.js.map +0 -1
- package/lib-es/bridge/broadcast.test.d.ts +0 -2
- package/lib-es/bridge/broadcast.test.d.ts.map +0 -1
- package/lib-es/bridge/broadcast.test.js +0 -46
- package/lib-es/bridge/broadcast.test.js.map +0 -1
- package/lib-es/bridge/buildOptimisticOperation.test.d.ts +0 -2
- package/lib-es/bridge/buildOptimisticOperation.test.d.ts.map +0 -1
- package/lib-es/bridge/buildOptimisticOperation.test.js +0 -47
- package/lib-es/bridge/buildOptimisticOperation.test.js.map +0 -1
- package/lib-es/bridge/buildTransaction.integration.test.d.ts +0 -2
- package/lib-es/bridge/buildTransaction.integration.test.d.ts.map +0 -1
- package/lib-es/bridge/buildTransaction.integration.test.js +0 -67
- package/lib-es/bridge/buildTransaction.integration.test.js.map +0 -1
- package/lib-es/bridge/buildTransaction.test.d.ts +0 -2
- package/lib-es/bridge/buildTransaction.test.d.ts.map +0 -1
- package/lib-es/bridge/buildTransaction.test.js +0 -229
- package/lib-es/bridge/buildTransaction.test.js.map +0 -1
- package/lib-es/bridge/estimateMaxSpendable.test.d.ts +0 -2
- package/lib-es/bridge/estimateMaxSpendable.test.d.ts.map +0 -1
- package/lib-es/bridge/estimateMaxSpendable.test.js +0 -50
- package/lib-es/bridge/estimateMaxSpendable.test.js.map +0 -1
- package/lib-es/bridge/formatters.test.d.ts +0 -2
- package/lib-es/bridge/formatters.test.d.ts.map +0 -1
- package/lib-es/bridge/formatters.test.js +0 -16
- package/lib-es/bridge/formatters.test.js.map +0 -1
- package/lib-es/bridge/getFeesForTransaction.test.d.ts +0 -2
- package/lib-es/bridge/getFeesForTransaction.test.d.ts.map +0 -1
- package/lib-es/bridge/getFeesForTransaction.test.js +0 -30
- package/lib-es/bridge/getFeesForTransaction.test.js.map +0 -1
- package/lib-es/bridge/getTransactionStatus.test.d.ts +0 -2
- package/lib-es/bridge/getTransactionStatus.test.d.ts.map +0 -1
- package/lib-es/bridge/getTransactionStatus.test.js +0 -64
- package/lib-es/bridge/getTransactionStatus.test.js.map +0 -1
- package/lib-es/bridge/index.test.d.ts +0 -2
- package/lib-es/bridge/index.test.d.ts.map +0 -1
- package/lib-es/bridge/index.test.js +0 -260
- package/lib-es/bridge/index.test.js.map +0 -1
- package/lib-es/bridge/preload.test.d.ts +0 -2
- package/lib-es/bridge/preload.test.d.ts.map +0 -1
- package/lib-es/bridge/preload.test.js +0 -50
- package/lib-es/bridge/preload.test.js.map +0 -1
- package/lib-es/bridge/prepareTransaction.test.d.ts +0 -2
- package/lib-es/bridge/prepareTransaction.test.d.ts.map +0 -1
- package/lib-es/bridge/prepareTransaction.test.js +0 -92
- package/lib-es/bridge/prepareTransaction.test.js.map +0 -1
- package/lib-es/bridge/serialization.test.d.ts +0 -2
- package/lib-es/bridge/serialization.test.d.ts.map +0 -1
- package/lib-es/bridge/serialization.test.js +0 -126
- package/lib-es/bridge/serialization.test.js.map +0 -1
- package/lib-es/bridge/signOperation.integration.test.d.ts +0 -2
- package/lib-es/bridge/signOperation.integration.test.d.ts.map +0 -1
- package/lib-es/bridge/signOperation.integration.test.js +0 -75
- package/lib-es/bridge/signOperation.integration.test.js.map +0 -1
- package/lib-es/bridge/signOperation.test.d.ts +0 -2
- package/lib-es/bridge/signOperation.test.d.ts.map +0 -1
- package/lib-es/bridge/signOperation.test.js +0 -440
- package/lib-es/bridge/signOperation.test.js.map +0 -1
- package/lib-es/bridge/synchronisation.test.d.ts +0 -2
- package/lib-es/bridge/synchronisation.test.d.ts.map +0 -1
- package/lib-es/bridge/synchronisation.test.js +0 -477
- package/lib-es/bridge/synchronisation.test.js.map +0 -1
- package/lib-es/bridge/transaction.test.d.ts +0 -2
- package/lib-es/bridge/transaction.test.d.ts.map +0 -1
- package/lib-es/bridge/transaction.test.js +0 -66
- package/lib-es/bridge/transaction.test.js.map +0 -1
- package/lib-es/logic/broadcast.test.d.ts +0 -2
- package/lib-es/logic/broadcast.test.d.ts.map +0 -1
- package/lib-es/logic/broadcast.test.js +0 -57
- package/lib-es/logic/broadcast.test.js.map +0 -1
- package/lib-es/logic/combine.test.d.ts +0 -2
- package/lib-es/logic/combine.test.d.ts.map +0 -1
- package/lib-es/logic/combine.test.js +0 -35
- package/lib-es/logic/combine.test.js.map +0 -1
- package/lib-es/logic/craftTransaction.integration.test.d.ts +0 -2
- package/lib-es/logic/craftTransaction.integration.test.d.ts.map +0 -1
- package/lib-es/logic/craftTransaction.integration.test.js +0 -93
- package/lib-es/logic/craftTransaction.integration.test.js.map +0 -1
- package/lib-es/logic/craftTransaction.test.d.ts +0 -2
- package/lib-es/logic/craftTransaction.test.d.ts.map +0 -1
- package/lib-es/logic/craftTransaction.test.js +0 -122
- package/lib-es/logic/craftTransaction.test.js.map +0 -1
- package/lib-es/logic/estimateFees.integration.test.d.ts +0 -2
- package/lib-es/logic/estimateFees.integration.test.d.ts.map +0 -1
- package/lib-es/logic/estimateFees.integration.test.js +0 -77
- package/lib-es/logic/estimateFees.integration.test.js.map +0 -1
- package/lib-es/logic/estimateFees.test.d.ts +0 -2
- package/lib-es/logic/estimateFees.test.d.ts.map +0 -1
- package/lib-es/logic/estimateFees.test.js +0 -65
- package/lib-es/logic/estimateFees.test.js.map +0 -1
- package/lib-es/logic/getBalance.integration.test.d.ts +0 -2
- package/lib-es/logic/getBalance.integration.test.d.ts.map +0 -1
- package/lib-es/logic/getBalance.integration.test.js +0 -51
- package/lib-es/logic/getBalance.integration.test.js.map +0 -1
- package/lib-es/logic/getBalance.test.d.ts +0 -2
- package/lib-es/logic/getBalance.test.d.ts.map +0 -1
- package/lib-es/logic/getBalance.test.js +0 -62
- package/lib-es/logic/getBalance.test.js.map +0 -1
- package/lib-es/logic/lastBlock.test.d.ts +0 -2
- package/lib-es/logic/lastBlock.test.d.ts.map +0 -1
- package/lib-es/logic/lastBlock.test.js +0 -25
- package/lib-es/logic/lastBlock.test.js.map +0 -1
- package/lib-es/logic/listOperations.test.d.ts +0 -2
- package/lib-es/logic/listOperations.test.d.ts.map +0 -1
- package/lib-es/logic/listOperations.test.js +0 -77
- package/lib-es/logic/listOperations.test.js.map +0 -1
- package/lib-es/network/sdk.integration.test.d.ts +0 -2
- package/lib-es/network/sdk.integration.test.d.ts.map +0 -1
- package/lib-es/network/sdk.integration.test.js +0 -210
- package/lib-es/network/sdk.integration.test.js.map +0 -1
- package/lib-es/network/sdk.test.d.ts +0 -2
- package/lib-es/network/sdk.test.d.ts.map +0 -1
- package/lib-es/network/sdk.test.js +0 -1756
- package/lib-es/network/sdk.test.js.map +0 -1
- package/lib-es/signer/getAddress.test.d.ts +0 -2
- package/lib-es/signer/getAddress.test.d.ts.map +0 -1
- package/lib-es/signer/getAddress.test.js +0 -101
- package/lib-es/signer/getAddress.test.js.map +0 -1
- package/lib-es/test/config.test.d.ts +0 -2
- package/lib-es/test/config.test.d.ts.map +0 -1
- package/lib-es/test/config.test.js +0 -39
- package/lib-es/test/config.test.js.map +0 -1
|
@@ -93,6 +93,24 @@ describe("Sui Api", () => {
|
|
|
93
93
|
});
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
+
describe("listOperations (staking)", () => {
|
|
97
|
+
let txs: Operation[];
|
|
98
|
+
|
|
99
|
+
beforeAll(async () => {
|
|
100
|
+
[txs] = await module.listOperations(
|
|
101
|
+
"0x13d73cab19d2cf14e39289b122ed93fb0f9edd00e4c829e0cefb1f0611c54a8f",
|
|
102
|
+
{ minHeight: 0, order: "asc" },
|
|
103
|
+
);
|
|
104
|
+
});
|
|
105
|
+
|
|
106
|
+
it("should map undelegate operations when it's not the first move call", async () => {
|
|
107
|
+
const tx1 = txs.find(t => t.id === "4UtCqCH3oNEdaprZR9UjaMGg6HgLn3V3q3FEcvs5vieM");
|
|
108
|
+
expect(tx1?.type).toBe("UNDELEGATE");
|
|
109
|
+
const tx2 = txs.find(t => t.id === "JEGnHCx2mtpDin216kbUBXm7V5rdMSPSUmgYbP3yxTEf");
|
|
110
|
+
expect(tx2?.type).toBe("UNDELEGATE");
|
|
111
|
+
});
|
|
112
|
+
});
|
|
113
|
+
|
|
96
114
|
describe("listOperations", () => {
|
|
97
115
|
let txs: Operation[];
|
|
98
116
|
|
|
@@ -182,13 +200,68 @@ describe("Sui Api", () => {
|
|
|
182
200
|
|
|
183
201
|
describe("getBlock", () => {
|
|
184
202
|
test("getBlock should get block by id or sequence number", async () => {
|
|
185
|
-
const block = await module.getBlock(
|
|
186
|
-
expect(block.info.height).toEqual(
|
|
187
|
-
expect(block.info.hash).toEqual("
|
|
188
|
-
expect(block.info.time).toEqual(new Date(
|
|
189
|
-
expect(block.info.parent?.height).toEqual(
|
|
190
|
-
expect(block.info.parent?.hash).toEqual("
|
|
191
|
-
expect(block.transactions.length).toEqual(
|
|
203
|
+
const block = await module.getBlock(195177985);
|
|
204
|
+
expect(block.info.height).toEqual(195177985);
|
|
205
|
+
expect(block.info.hash).toEqual("AzoHwjcCXkeiWoBVyWwZcE171zjxochFmcr9eQoNQyYn");
|
|
206
|
+
expect(block.info.time).toEqual(new Date(1759138080141));
|
|
207
|
+
expect(block.info.parent?.height).toEqual(195177984);
|
|
208
|
+
expect(block.info.parent?.hash).toEqual("A15NYkPDyKLZS4Swik7AY2mnLxwFET4kyNV6ChZ8tVJP");
|
|
209
|
+
expect(block.transactions.length).toEqual(12);
|
|
210
|
+
const tx = block.transactions[9];
|
|
211
|
+
const senderOp = tx.operations[0];
|
|
212
|
+
const receipientOp = tx.operations[1];
|
|
213
|
+
expect(tx.hash).toEqual("J3ddkv4TRqr4LviCbA3JyJCji5Kg5BcaBTkd6nMY5WXN");
|
|
214
|
+
expect(tx.operations.length).toEqual(2);
|
|
215
|
+
expect(senderOp.address).toEqual(
|
|
216
|
+
"0x2c814ceb68d1cb7168207b16754b1cf57e735685c4e5d87c4f50906edcc57c1c",
|
|
217
|
+
);
|
|
218
|
+
expect(senderOp.peer).toEqual(
|
|
219
|
+
"0xb37b298c9164c28c8aaf989a49416e3c323b67bc2b96a54501b524419ebb4ead",
|
|
220
|
+
);
|
|
221
|
+
expect(senderOp.amount).toEqual(BigInt(-5));
|
|
222
|
+
expect(receipientOp.address).toEqual(
|
|
223
|
+
"0xb37b298c9164c28c8aaf989a49416e3c323b67bc2b96a54501b524419ebb4ead",
|
|
224
|
+
);
|
|
225
|
+
expect(receipientOp.peer).toEqual(
|
|
226
|
+
"0x2c814ceb68d1cb7168207b16754b1cf57e735685c4e5d87c4f50906edcc57c1c",
|
|
227
|
+
);
|
|
228
|
+
expect(receipientOp.amount).toEqual(BigInt(5));
|
|
229
|
+
});
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
describe("getValidators", () => {
|
|
233
|
+
it("returns at least a hundred validators with expected fields", async () => {
|
|
234
|
+
const page = await module.getValidators();
|
|
235
|
+
|
|
236
|
+
expect(Array.isArray(page.items)).toBeTruthy();
|
|
237
|
+
expect(page.items.length).toBeGreaterThanOrEqual(100);
|
|
238
|
+
|
|
239
|
+
const v = page.items[0];
|
|
240
|
+
expect(v).toHaveProperty("address");
|
|
241
|
+
expect(v).toHaveProperty("name");
|
|
242
|
+
expect(v).toHaveProperty("description");
|
|
243
|
+
expect(v).toHaveProperty("url");
|
|
244
|
+
expect(v).toHaveProperty("logo");
|
|
245
|
+
expect(v).toHaveProperty("balance");
|
|
246
|
+
expect(v).toHaveProperty("commissionRate");
|
|
247
|
+
expect(v).toHaveProperty("apy");
|
|
248
|
+
|
|
249
|
+
// values should not be empty
|
|
250
|
+
expect(typeof v.address).toBe("string");
|
|
251
|
+
expect(v.address.length).toBeGreaterThan(0);
|
|
252
|
+
expect(typeof v.name).toBe("string");
|
|
253
|
+
expect(v.name.length).toBeGreaterThan(0);
|
|
254
|
+
expect(typeof v.description).toBe("string");
|
|
255
|
+
expect((v.description as string).length).toBeGreaterThan(0);
|
|
256
|
+
expect(typeof v.url).toBe("string");
|
|
257
|
+
expect((v.url as string).length).toBeGreaterThan(0);
|
|
258
|
+
expect(typeof v.logo).toBe("string");
|
|
259
|
+
expect((v.logo as string).length).toBeGreaterThan(0);
|
|
260
|
+
expect(typeof v.balance === "bigint").toBeTruthy();
|
|
261
|
+
expect(v.balance as bigint).toBeGreaterThanOrEqual(0n);
|
|
262
|
+
expect(typeof v.commissionRate).toBe("string");
|
|
263
|
+
expect((v.commissionRate as string).length).toBeGreaterThan(0);
|
|
264
|
+
expect(typeof v.apy).toBe("number");
|
|
192
265
|
});
|
|
193
266
|
});
|
|
194
267
|
|
package/src/api/index.ts
CHANGED
|
@@ -11,6 +11,7 @@ import {
|
|
|
11
11
|
craftTransaction,
|
|
12
12
|
getStakes,
|
|
13
13
|
getRewards,
|
|
14
|
+
getValidators as logicGetValidators,
|
|
14
15
|
} from "../logic";
|
|
15
16
|
import {
|
|
16
17
|
AlpacaApi,
|
|
@@ -42,6 +43,7 @@ export function createApi(config: SuiConfig): AlpacaApi {
|
|
|
42
43
|
listOperations: logicListOperations,
|
|
43
44
|
getStakes,
|
|
44
45
|
getRewards,
|
|
46
|
+
getValidators: logicGetValidators,
|
|
45
47
|
};
|
|
46
48
|
}
|
|
47
49
|
|
|
@@ -33,14 +33,17 @@ describe("estimateFees", () => {
|
|
|
33
33
|
|
|
34
34
|
const result = await estimateFees(transactionIntent);
|
|
35
35
|
|
|
36
|
-
expect(suiAPI.paymentInfo).toHaveBeenCalledWith(
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
36
|
+
expect(suiAPI.paymentInfo).toHaveBeenCalledWith(
|
|
37
|
+
transactionIntent.sender,
|
|
38
|
+
expect.objectContaining({
|
|
39
|
+
recipient: transactionIntent.recipient,
|
|
40
|
+
amount: BigNumber(transactionIntent.amount.toString()),
|
|
41
|
+
coinType: "0x2::sui::SUI",
|
|
42
|
+
errors: {},
|
|
43
|
+
family: "sui",
|
|
44
|
+
mode: "send",
|
|
45
|
+
}),
|
|
46
|
+
);
|
|
44
47
|
expect(result).toBe(BigInt(mockGasBudget));
|
|
45
48
|
});
|
|
46
49
|
|
|
@@ -61,14 +64,17 @@ describe("estimateFees", () => {
|
|
|
61
64
|
|
|
62
65
|
const result = await estimateFees(transactionIntent);
|
|
63
66
|
|
|
64
|
-
expect(suiAPI.paymentInfo).toHaveBeenCalledWith(
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
67
|
+
expect(suiAPI.paymentInfo).toHaveBeenCalledWith(
|
|
68
|
+
transactionIntent.sender,
|
|
69
|
+
expect.objectContaining({
|
|
70
|
+
recipient: transactionIntent.recipient,
|
|
71
|
+
amount: BigNumber("0"),
|
|
72
|
+
coinType: "0x2::sui::SUI",
|
|
73
|
+
errors: {},
|
|
74
|
+
family: "sui",
|
|
75
|
+
mode: "send",
|
|
76
|
+
}),
|
|
77
|
+
);
|
|
72
78
|
expect(result).toBe(BigInt(mockGasBudget));
|
|
73
79
|
});
|
|
74
80
|
});
|
|
@@ -9,7 +9,11 @@ export async function estimateFees({
|
|
|
9
9
|
sender,
|
|
10
10
|
asset,
|
|
11
11
|
type,
|
|
12
|
-
|
|
12
|
+
...extra
|
|
13
|
+
}: TransactionIntent & {
|
|
14
|
+
useAllAmount?: boolean;
|
|
15
|
+
stakedSuiId?: string;
|
|
16
|
+
}): Promise<bigint> {
|
|
13
17
|
let coinType = DEFAULT_COIN_TYPE;
|
|
14
18
|
if (asset.type === "token" && asset.assetReference) {
|
|
15
19
|
coinType = asset.assetReference;
|
|
@@ -35,6 +39,7 @@ export async function estimateFees({
|
|
|
35
39
|
amount: BigNumber(amount.toString()),
|
|
36
40
|
errors: {},
|
|
37
41
|
coinType,
|
|
42
|
+
...extra,
|
|
38
43
|
});
|
|
39
44
|
return BigInt(gasBudget);
|
|
40
45
|
}
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import * as network from "../network";
|
|
2
|
+
import { getValidators } from "./getValidators";
|
|
3
|
+
|
|
4
|
+
type NetworkValidator = {
|
|
5
|
+
suiAddress: string;
|
|
6
|
+
name: string;
|
|
7
|
+
description: string;
|
|
8
|
+
projectUrl: string;
|
|
9
|
+
imageUrl: string;
|
|
10
|
+
stakingPoolSuiBalance: string;
|
|
11
|
+
commissionRate: string;
|
|
12
|
+
apy: number;
|
|
13
|
+
};
|
|
14
|
+
|
|
15
|
+
jest.mock("../network", () => ({
|
|
16
|
+
getValidators: jest.fn(),
|
|
17
|
+
}));
|
|
18
|
+
|
|
19
|
+
const mockedGetValidators = jest.mocked(network.getValidators);
|
|
20
|
+
|
|
21
|
+
describe("logic/getValidators", () => {
|
|
22
|
+
afterEach(() => {
|
|
23
|
+
jest.restoreAllMocks();
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it("maps network validators to generic Validator and returns single page", async () => {
|
|
27
|
+
const networkValidators: NetworkValidator[] = [
|
|
28
|
+
{
|
|
29
|
+
suiAddress: "0xabc",
|
|
30
|
+
name: "Validator A",
|
|
31
|
+
description: "desc",
|
|
32
|
+
projectUrl: "https://example.com",
|
|
33
|
+
imageUrl: "https://example.com/logo.png",
|
|
34
|
+
stakingPoolSuiBalance: "1234567890",
|
|
35
|
+
commissionRate: "0.1",
|
|
36
|
+
apy: 0.08,
|
|
37
|
+
},
|
|
38
|
+
{
|
|
39
|
+
suiAddress: "0xdef",
|
|
40
|
+
name: "Validator B",
|
|
41
|
+
description: "",
|
|
42
|
+
projectUrl: "",
|
|
43
|
+
imageUrl: "",
|
|
44
|
+
stakingPoolSuiBalance: "0",
|
|
45
|
+
commissionRate: "0",
|
|
46
|
+
apy: 0,
|
|
47
|
+
},
|
|
48
|
+
];
|
|
49
|
+
|
|
50
|
+
mockedGetValidators.mockResolvedValueOnce(
|
|
51
|
+
networkValidators as unknown as ReturnType<typeof network.getValidators>,
|
|
52
|
+
);
|
|
53
|
+
|
|
54
|
+
const page = await getValidators();
|
|
55
|
+
|
|
56
|
+
expect(page.next).toBeUndefined();
|
|
57
|
+
expect(page.items).toHaveLength(2);
|
|
58
|
+
|
|
59
|
+
const [a, b] = page.items;
|
|
60
|
+
expect(a).toEqual({
|
|
61
|
+
address: "0xabc",
|
|
62
|
+
name: "Validator A",
|
|
63
|
+
description: "desc",
|
|
64
|
+
url: "https://example.com",
|
|
65
|
+
logo: "https://example.com/logo.png",
|
|
66
|
+
balance: BigInt("1234567890"),
|
|
67
|
+
commissionRate: "0.1",
|
|
68
|
+
apy: 0.08,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(b).toEqual({
|
|
72
|
+
address: "0xdef",
|
|
73
|
+
name: "Validator B",
|
|
74
|
+
description: "",
|
|
75
|
+
url: "",
|
|
76
|
+
logo: "",
|
|
77
|
+
balance: 0n,
|
|
78
|
+
commissionRate: "0",
|
|
79
|
+
apy: 0,
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
|
|
83
|
+
it("handles empty network response", async () => {
|
|
84
|
+
mockedGetValidators.mockResolvedValueOnce(
|
|
85
|
+
[] as unknown as ReturnType<typeof network.getValidators>,
|
|
86
|
+
);
|
|
87
|
+
|
|
88
|
+
const page = await getValidators();
|
|
89
|
+
expect(page.items).toEqual([]);
|
|
90
|
+
expect(page.next).toBeUndefined();
|
|
91
|
+
});
|
|
92
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { type Page, type Validator } from "@ledgerhq/coin-framework/api/index";
|
|
2
|
+
import { getValidators as getValidatorsFromNetwork } from "../network";
|
|
3
|
+
|
|
4
|
+
export async function getValidators(_cursor?: string): Promise<Page<Validator>> {
|
|
5
|
+
const validators = await getValidatorsFromNetwork();
|
|
6
|
+
|
|
7
|
+
const items: Validator[] = validators.map(v => ({
|
|
8
|
+
address: v.suiAddress,
|
|
9
|
+
name: v.name,
|
|
10
|
+
description: v.description,
|
|
11
|
+
url: v.projectUrl,
|
|
12
|
+
logo: v.imageUrl,
|
|
13
|
+
balance: BigInt(v.stakingPoolSuiBalance),
|
|
14
|
+
commissionRate: v.commissionRate,
|
|
15
|
+
apy: v.apy,
|
|
16
|
+
}));
|
|
17
|
+
|
|
18
|
+
return {
|
|
19
|
+
items,
|
|
20
|
+
// there is no underlying pagination, so undefined token
|
|
21
|
+
next: undefined,
|
|
22
|
+
};
|
|
23
|
+
}
|
package/src/logic/index.ts
CHANGED
package/src/network/index.ts
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
createTransaction,
|
|
10
10
|
executeTransactionBlock,
|
|
11
11
|
getStakes,
|
|
12
|
+
getValidators,
|
|
12
13
|
} from "./sdk";
|
|
13
14
|
|
|
14
15
|
export {
|
|
@@ -22,6 +23,7 @@ export {
|
|
|
22
23
|
createTransaction,
|
|
23
24
|
executeTransactionBlock,
|
|
24
25
|
getStakes,
|
|
26
|
+
getValidators,
|
|
25
27
|
};
|
|
26
28
|
|
|
27
29
|
export default {
|
|
@@ -35,4 +37,5 @@ export default {
|
|
|
35
37
|
createTransaction,
|
|
36
38
|
executeTransactionBlock,
|
|
37
39
|
getStakes,
|
|
40
|
+
getValidators,
|
|
38
41
|
};
|
package/src/network/sdk.test.ts
CHANGED
|
@@ -3,8 +3,12 @@ import coinConfig from "../config";
|
|
|
3
3
|
|
|
4
4
|
import { BigNumber } from "bignumber.js";
|
|
5
5
|
import { SuiClient } from "@mysten/sui/client";
|
|
6
|
-
import type {
|
|
7
|
-
|
|
6
|
+
import type {
|
|
7
|
+
TransactionBlockData,
|
|
8
|
+
SuiTransactionBlockResponse,
|
|
9
|
+
SuiTransactionBlockKind,
|
|
10
|
+
} from "@mysten/sui/client";
|
|
11
|
+
import assert, { fail } from "assert";
|
|
8
12
|
|
|
9
13
|
// Mock SUI client for tests
|
|
10
14
|
jest.mock("@mysten/sui/client", () => {
|
|
@@ -232,7 +236,6 @@ function mockStakingTx(address: string, amount: string) {
|
|
|
232
236
|
|
|
233
237
|
// amount must be a positive number
|
|
234
238
|
function mockUnstakingTx(address: string, amount: string) {
|
|
235
|
-
assert(new BigNumber(amount).gte(0), "amount must be a positive number");
|
|
236
239
|
return {
|
|
237
240
|
digest: "undelegate_tx_digest_456",
|
|
238
241
|
transaction: {
|
|
@@ -609,17 +612,48 @@ describe("SDK Functions", () => {
|
|
|
609
612
|
|
|
610
613
|
describe("Staking Operations", () => {
|
|
611
614
|
describe("Operation Type Detection", () => {
|
|
615
|
+
const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
|
|
612
616
|
test("getOperationType should return DELEGATE for staking transaction", () => {
|
|
613
|
-
const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
|
|
614
617
|
expect(sdk.getOperationType(address, mockStakingTx(address, "-1000000000"))).toBe("DELEGATE");
|
|
615
618
|
});
|
|
616
619
|
|
|
617
620
|
test("getOperationType should return UNDELEGATE for unstaking transaction", () => {
|
|
618
|
-
const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
|
|
619
621
|
expect(sdk.getOperationType(address, mockUnstakingTx(address, "1000000000"))).toBe(
|
|
620
622
|
"UNDELEGATE",
|
|
621
623
|
);
|
|
622
624
|
});
|
|
625
|
+
|
|
626
|
+
function prependOtherMoveCall(block: SuiTransactionBlockKind) {
|
|
627
|
+
if (block?.kind === "ProgrammableTransaction") {
|
|
628
|
+
block.transactions.unshift({
|
|
629
|
+
MoveCall: {
|
|
630
|
+
function: "other_function",
|
|
631
|
+
module: "module",
|
|
632
|
+
package: "package",
|
|
633
|
+
},
|
|
634
|
+
});
|
|
635
|
+
}
|
|
636
|
+
}
|
|
637
|
+
|
|
638
|
+
test("getOperationType should return UNDELEGATE when it's not the first MoveCall ", () => {
|
|
639
|
+
const tx = mockUnstakingTx(address, "1000");
|
|
640
|
+
if (tx.transaction) {
|
|
641
|
+
prependOtherMoveCall(tx.transaction.data.transaction);
|
|
642
|
+
expect(sdk.getOperationType(address, tx)).toBe("UNDELEGATE");
|
|
643
|
+
} else {
|
|
644
|
+
fail("can't prepare fixture");
|
|
645
|
+
}
|
|
646
|
+
});
|
|
647
|
+
|
|
648
|
+
test("getOperationType should return DELEGATE when it's not the first MoveCall ", () => {
|
|
649
|
+
const tx = mockStakingTx(address, "-1000");
|
|
650
|
+
if (tx.transaction) {
|
|
651
|
+
prependOtherMoveCall(tx.transaction.data.transaction);
|
|
652
|
+
expect(sdk.getOperationType(address, tx)).toBe("DELEGATE");
|
|
653
|
+
} else {
|
|
654
|
+
fail("can't prepare fixture");
|
|
655
|
+
}
|
|
656
|
+
});
|
|
623
657
|
});
|
|
624
658
|
|
|
625
659
|
describe("Operation Amount Calculation", () => {
|
|
@@ -661,17 +695,20 @@ describe("Staking Operations", () => {
|
|
|
661
695
|
}
|
|
662
696
|
|
|
663
697
|
test("alpaca getOperationAmount should calculate staking amount", () =>
|
|
664
|
-
expect(alpacaOperationAmount(mockStakingTx(address, "-
|
|
698
|
+
expect(alpacaOperationAmount(mockStakingTx(address, "-1001050000"))).toEqual(
|
|
665
699
|
new BigNumber("1000000000"),
|
|
666
700
|
));
|
|
667
701
|
|
|
702
|
+
// 1000 unstaked & 1050000 gas fees = -1049000 balance change
|
|
668
703
|
test("alpaca getOperationAmount should calculate unstaking amount of 1000", () =>
|
|
669
|
-
expect(alpacaOperationAmount(mockUnstakingTx(address, "
|
|
704
|
+
expect(alpacaOperationAmount(mockUnstakingTx(address, "-1049000"))).toEqual(
|
|
670
705
|
new BigNumber("1000"),
|
|
671
706
|
));
|
|
672
707
|
|
|
673
708
|
test("alpaca getOperationAmount should calculate unstaking amount of 0", () =>
|
|
674
|
-
expect(alpacaOperationAmount(mockUnstakingTx(address, "
|
|
709
|
+
expect(alpacaOperationAmount(mockUnstakingTx(address, "-1050000"))).toEqual(
|
|
710
|
+
new BigNumber("0"),
|
|
711
|
+
));
|
|
675
712
|
|
|
676
713
|
test("alpaca getOperationAmount should calculate amount correctly for SUI", () =>
|
|
677
714
|
expect(alpacaOperationAmount(mockTransaction)).toEqual(new BigNumber("9998990120")));
|
|
@@ -824,7 +861,7 @@ describe("Staking Operations", () => {
|
|
|
824
861
|
test("transactionToOp should map staking transaction correctly", () => {
|
|
825
862
|
const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
|
|
826
863
|
|
|
827
|
-
const operation = sdk.alpacaTransactionToOp(address, mockStakingTx(address, "-
|
|
864
|
+
const operation = sdk.alpacaTransactionToOp(address, mockStakingTx(address, "-1001050000"));
|
|
828
865
|
|
|
829
866
|
expect(operation.id).toEqual("delegate_tx_digest_123");
|
|
830
867
|
expect(operation.type).toEqual("DELEGATE");
|
|
@@ -838,7 +875,7 @@ describe("Staking Operations", () => {
|
|
|
838
875
|
test("transactionToOp should map unstaking transaction correctly", () => {
|
|
839
876
|
const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
|
|
840
877
|
|
|
841
|
-
const operation = sdk.alpacaTransactionToOp(address, mockUnstakingTx(address, "
|
|
878
|
+
const operation = sdk.alpacaTransactionToOp(address, mockUnstakingTx(address, "998950000"));
|
|
842
879
|
|
|
843
880
|
expect(operation.id).toEqual("undelegate_tx_digest_456");
|
|
844
881
|
expect(operation.type).toEqual("UNDELEGATE");
|
|
@@ -1737,17 +1774,22 @@ describe("filterOperations", () => {
|
|
|
1737
1774
|
describe("conversion methods", () => {
|
|
1738
1775
|
test("toBlockOperation should map native transfers correctly", () => {
|
|
1739
1776
|
expect(
|
|
1740
|
-
sdk.toBlockOperation(
|
|
1741
|
-
|
|
1742
|
-
|
|
1777
|
+
sdk.toBlockOperation(
|
|
1778
|
+
mockTransaction,
|
|
1779
|
+
{
|
|
1780
|
+
owner: {
|
|
1781
|
+
AddressOwner: "0x65449f57946938c84c5127",
|
|
1782
|
+
},
|
|
1783
|
+
coinType: sdk.DEFAULT_COIN_TYPE,
|
|
1784
|
+
amount: "-10000000000",
|
|
1743
1785
|
},
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
}),
|
|
1786
|
+
BigNumber(0),
|
|
1787
|
+
),
|
|
1747
1788
|
).toEqual([
|
|
1748
1789
|
{
|
|
1749
1790
|
type: "transfer",
|
|
1750
1791
|
address: "0x65449f57946938c84c5127",
|
|
1792
|
+
peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
|
|
1751
1793
|
amount: -10000000000n,
|
|
1752
1794
|
asset: { type: "native" },
|
|
1753
1795
|
},
|
|
@@ -1756,68 +1798,89 @@ describe("filterOperations", () => {
|
|
|
1756
1798
|
|
|
1757
1799
|
test("toBlockOperation should ignore transfers from shared owner", () => {
|
|
1758
1800
|
expect(
|
|
1759
|
-
sdk.toBlockOperation(
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1801
|
+
sdk.toBlockOperation(
|
|
1802
|
+
mockTransaction,
|
|
1803
|
+
{
|
|
1804
|
+
owner: {
|
|
1805
|
+
Shared: {
|
|
1806
|
+
initial_shared_version: "0",
|
|
1807
|
+
},
|
|
1763
1808
|
},
|
|
1809
|
+
coinType: sdk.DEFAULT_COIN_TYPE,
|
|
1810
|
+
amount: "-10000000000",
|
|
1764
1811
|
},
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
}),
|
|
1812
|
+
BigNumber(0),
|
|
1813
|
+
),
|
|
1768
1814
|
).toEqual([]);
|
|
1769
1815
|
});
|
|
1770
1816
|
|
|
1771
1817
|
test("toBlockOperation should ignore transfers from object owner", () => {
|
|
1772
1818
|
expect(
|
|
1773
|
-
sdk.toBlockOperation(
|
|
1774
|
-
|
|
1775
|
-
|
|
1819
|
+
sdk.toBlockOperation(
|
|
1820
|
+
mockTransaction,
|
|
1821
|
+
{
|
|
1822
|
+
owner: {
|
|
1823
|
+
ObjectOwner: "test",
|
|
1824
|
+
},
|
|
1825
|
+
coinType: sdk.DEFAULT_COIN_TYPE,
|
|
1826
|
+
amount: "-10000000000",
|
|
1776
1827
|
},
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
}),
|
|
1828
|
+
BigNumber(0),
|
|
1829
|
+
),
|
|
1780
1830
|
).toEqual([]);
|
|
1781
1831
|
});
|
|
1782
1832
|
|
|
1783
1833
|
test("toBlockOperation should ignore transfers from immutable owner", () => {
|
|
1784
1834
|
expect(
|
|
1785
|
-
sdk.toBlockOperation(
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1835
|
+
sdk.toBlockOperation(
|
|
1836
|
+
mockTransaction,
|
|
1837
|
+
{
|
|
1838
|
+
owner: "Immutable",
|
|
1839
|
+
coinType: sdk.DEFAULT_COIN_TYPE,
|
|
1840
|
+
amount: "-10000000000",
|
|
1841
|
+
},
|
|
1842
|
+
BigNumber(0),
|
|
1843
|
+
),
|
|
1790
1844
|
).toEqual([]);
|
|
1791
1845
|
});
|
|
1792
1846
|
|
|
1793
1847
|
test("toBlockOperation should ignore transfers from consensus owner", () => {
|
|
1794
1848
|
expect(
|
|
1795
|
-
sdk.toBlockOperation(
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1849
|
+
sdk.toBlockOperation(
|
|
1850
|
+
mockTransaction,
|
|
1851
|
+
{
|
|
1852
|
+
owner: {
|
|
1853
|
+
ConsensusAddressOwner: {
|
|
1854
|
+
owner: "test",
|
|
1855
|
+
start_version: "1",
|
|
1856
|
+
},
|
|
1800
1857
|
},
|
|
1858
|
+
coinType: sdk.DEFAULT_COIN_TYPE,
|
|
1859
|
+
amount: "-10000000000",
|
|
1801
1860
|
},
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
}),
|
|
1861
|
+
BigNumber(0),
|
|
1862
|
+
),
|
|
1805
1863
|
).toEqual([]);
|
|
1806
1864
|
});
|
|
1807
1865
|
|
|
1808
1866
|
test("toBlockOperation should map token transfers correctly", () => {
|
|
1809
1867
|
expect(
|
|
1810
|
-
sdk.toBlockOperation(
|
|
1811
|
-
|
|
1812
|
-
|
|
1868
|
+
sdk.toBlockOperation(
|
|
1869
|
+
mockTransaction,
|
|
1870
|
+
{
|
|
1871
|
+
owner: {
|
|
1872
|
+
AddressOwner: "0x65449f57946938c84c5127",
|
|
1873
|
+
},
|
|
1874
|
+
coinType: "0x168da5bf1f48dafc111b0a488fa454aca95e0b5e::usdc::USDC",
|
|
1875
|
+
amount: "8824",
|
|
1813
1876
|
},
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
}),
|
|
1877
|
+
BigNumber(0),
|
|
1878
|
+
),
|
|
1817
1879
|
).toEqual([
|
|
1818
1880
|
{
|
|
1819
1881
|
type: "transfer",
|
|
1820
1882
|
address: "0x65449f57946938c84c5127",
|
|
1883
|
+
peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
|
|
1821
1884
|
amount: 8824n,
|
|
1822
1885
|
asset: {
|
|
1823
1886
|
type: "token",
|
|
@@ -1830,18 +1893,22 @@ describe("filterOperations", () => {
|
|
|
1830
1893
|
test("toBlockOperation should map staking operations correctly", () => {
|
|
1831
1894
|
const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
|
|
1832
1895
|
expect(
|
|
1833
|
-
sdk.toBlockOperation(
|
|
1834
|
-
|
|
1835
|
-
|
|
1836
|
-
|
|
1837
|
-
|
|
1896
|
+
sdk.toBlockOperation(
|
|
1897
|
+
mockStakingTx(address, "-1000000000"),
|
|
1898
|
+
{
|
|
1899
|
+
owner: { AddressOwner: address },
|
|
1900
|
+
coinType: sdk.DEFAULT_COIN_TYPE,
|
|
1901
|
+
amount: "-10000000000",
|
|
1902
|
+
},
|
|
1903
|
+
BigNumber(0),
|
|
1904
|
+
),
|
|
1838
1905
|
).toEqual([
|
|
1839
1906
|
{
|
|
1840
1907
|
type: "other",
|
|
1841
1908
|
operationType: "DELEGATE",
|
|
1842
1909
|
address: address,
|
|
1843
1910
|
asset: { type: "native" },
|
|
1844
|
-
amount: 10000000000n,
|
|
1911
|
+
amount: -10000000000n,
|
|
1845
1912
|
},
|
|
1846
1913
|
]);
|
|
1847
1914
|
});
|
|
@@ -1849,11 +1916,15 @@ describe("filterOperations", () => {
|
|
|
1849
1916
|
test("toBlockOperation should map unstaking operations correctly", () => {
|
|
1850
1917
|
const address = "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24";
|
|
1851
1918
|
expect(
|
|
1852
|
-
sdk.toBlockOperation(
|
|
1853
|
-
|
|
1854
|
-
|
|
1855
|
-
|
|
1856
|
-
|
|
1919
|
+
sdk.toBlockOperation(
|
|
1920
|
+
mockUnstakingTx(address, "1000000000"),
|
|
1921
|
+
{
|
|
1922
|
+
owner: { AddressOwner: address },
|
|
1923
|
+
coinType: sdk.DEFAULT_COIN_TYPE,
|
|
1924
|
+
amount: "10000000000",
|
|
1925
|
+
},
|
|
1926
|
+
BigNumber(0),
|
|
1927
|
+
),
|
|
1857
1928
|
).toEqual([
|
|
1858
1929
|
{
|
|
1859
1930
|
type: "other",
|
|
@@ -1909,18 +1980,21 @@ describe("filterOperations", () => {
|
|
|
1909
1980
|
operations: [
|
|
1910
1981
|
{
|
|
1911
1982
|
address: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
|
|
1912
|
-
|
|
1983
|
+
peer: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
|
|
1984
|
+
amount: -9998990120n,
|
|
1913
1985
|
asset: { type: "native" },
|
|
1914
1986
|
type: "transfer",
|
|
1915
1987
|
},
|
|
1916
1988
|
{
|
|
1917
1989
|
address: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
|
|
1990
|
+
peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
|
|
1918
1991
|
amount: 9998990120n,
|
|
1919
1992
|
asset: { type: "native" },
|
|
1920
1993
|
type: "transfer",
|
|
1921
1994
|
},
|
|
1922
1995
|
{
|
|
1923
1996
|
address: "0x6e143fe0a8ca010a86580dafac44298e5b1b7d73efc345356a59a15f0d7824f0",
|
|
1997
|
+
peer: "0x65449f57946938c84c512732f1d69405d1fce417d9c9894696ddf4522f479e24",
|
|
1924
1998
|
amount: 500000n,
|
|
1925
1999
|
asset: { type: "token", assetReference: "0x123::test::TOKEN" },
|
|
1926
2000
|
type: "transfer",
|