@ledgerhq/coin-sui 0.7.0-nightly.7 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +43 -37
- package/lib/api/index.js +1 -1
- package/lib/api/index.js.map +1 -1
- package/lib/api/index.test.d.ts +2 -0
- package/lib/api/index.test.d.ts.map +1 -0
- package/lib/api/index.test.js +136 -0
- package/lib/api/index.test.js.map +1 -0
- package/lib/bridge/buildTransaction.test.d.ts +2 -0
- package/lib/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib/bridge/buildTransaction.test.js +324 -0
- package/lib/bridge/buildTransaction.test.js.map +1 -0
- package/lib/bridge/index.test.d.ts +2 -0
- package/lib/bridge/index.test.d.ts.map +1 -0
- package/lib/bridge/index.test.js +265 -0
- package/lib/bridge/index.test.js.map +1 -0
- package/lib/bridge/preload.test.d.ts +2 -0
- package/lib/bridge/preload.test.d.ts.map +1 -0
- package/lib/bridge/preload.test.js +256 -0
- package/lib/bridge/preload.test.js.map +1 -0
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +0 -13
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/bridge/signOperation.test.d.ts +2 -0
- package/lib/bridge/signOperation.test.d.ts.map +1 -0
- package/lib/bridge/signOperation.test.js +445 -0
- package/lib/bridge/signOperation.test.js.map +1 -0
- package/lib/network/sdk.d.ts +13 -6
- package/lib/network/sdk.d.ts.map +1 -1
- package/lib/network/sdk.js +101 -41
- package/lib/network/sdk.js.map +1 -1
- package/lib/network/sdk.test.js +640 -71
- package/lib/network/sdk.test.js.map +1 -1
- package/lib-es/api/index.js +1 -1
- package/lib-es/api/index.js.map +1 -1
- package/lib-es/api/index.test.d.ts +2 -0
- package/lib-es/api/index.test.d.ts.map +1 -0
- package/lib-es/api/index.test.js +111 -0
- package/lib-es/api/index.test.js.map +1 -0
- package/lib-es/bridge/buildTransaction.test.d.ts +2 -0
- package/lib-es/bridge/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/bridge/buildTransaction.test.js +322 -0
- package/lib-es/bridge/buildTransaction.test.js.map +1 -0
- package/lib-es/bridge/index.test.d.ts +2 -0
- package/lib-es/bridge/index.test.d.ts.map +1 -0
- package/lib-es/bridge/index.test.js +260 -0
- package/lib-es/bridge/index.test.js.map +1 -0
- package/lib-es/bridge/preload.test.d.ts +2 -0
- package/lib-es/bridge/preload.test.d.ts.map +1 -0
- package/lib-es/bridge/preload.test.js +254 -0
- package/lib-es/bridge/preload.test.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +0 -13
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/bridge/signOperation.test.d.ts +2 -0
- package/lib-es/bridge/signOperation.test.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.test.js +440 -0
- package/lib-es/bridge/signOperation.test.js.map +1 -0
- package/lib-es/network/sdk.d.ts +13 -6
- package/lib-es/network/sdk.d.ts.map +1 -1
- package/lib-es/network/sdk.js +100 -41
- package/lib-es/network/sdk.js.map +1 -1
- package/lib-es/network/sdk.test.js +617 -71
- package/lib-es/network/sdk.test.js.map +1 -1
- package/package.json +7 -7
- package/src/api/index.test.ts +127 -0
- package/src/api/index.ts +1 -1
- package/src/bridge/buildTransaction.test.ts +406 -0
- package/src/bridge/index.test.ts +319 -0
- package/src/bridge/preload.test.ts +333 -0
- package/src/bridge/signOperation.test.ts +507 -0
- package/src/bridge/signOperation.ts +0 -16
- package/src/network/sdk.test.ts +745 -99
- package/src/network/sdk.ts +131 -54
package/.turbo/turbo-build.log
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
|
|
2
|
-
> @ledgerhq/coin-sui@0.7.0
|
|
2
|
+
> @ledgerhq/coin-sui@0.7.0 build /home/runner/work/ledger-live/ledger-live/libs/coin-modules/coin-sui
|
|
3
3
|
> tsc --outDir lib --module commonjs --moduleResolution node10 && tsc -m ES6 --outDir lib-es
|
|
4
4
|
|
package/CHANGELOG.md
CHANGED
|
@@ -1,72 +1,78 @@
|
|
|
1
1
|
# @ledgerhq/coin-sui
|
|
2
2
|
|
|
3
|
-
## 0.7.0
|
|
3
|
+
## 0.7.0
|
|
4
4
|
|
|
5
|
-
###
|
|
6
|
-
|
|
7
|
-
- Updated dependencies [[`6ece1b8`](https://github.com/LedgerHQ/ledger-live/commit/6ece1b80ed05f9dab6541702e40a43b51887f958), [`63cdeb1`](https://github.com/LedgerHQ/ledger-live/commit/63cdeb1ea20fe0c16b623546ce00f3fe26b7ec80)]:
|
|
8
|
-
- @ledgerhq/cryptoassets@13.22.0-nightly.2
|
|
9
|
-
- @ledgerhq/coin-framework@5.6.0-nightly.6
|
|
10
|
-
|
|
11
|
-
## 0.7.0-nightly.6
|
|
5
|
+
### Minor Changes
|
|
12
6
|
|
|
13
|
-
|
|
7
|
+
- [#10938](https://github.com/LedgerHQ/ledger-live/pull/10938) [`17e039b`](https://github.com/LedgerHQ/ledger-live/commit/17e039b0c7487dda4a68f6a0fe493b4cf5fd265b) Thanks [@semeano](https://github.com/semeano)! - Add client version to HTTP headers
|
|
14
8
|
|
|
15
|
-
-
|
|
16
|
-
- @ledgerhq/cryptoassets@13.22.0-nightly.1
|
|
17
|
-
- @ledgerhq/coin-framework@5.6.0-nightly.5
|
|
9
|
+
- [#10901](https://github.com/LedgerHQ/ledger-live/pull/10901) [`6385b56`](https://github.com/LedgerHQ/ledger-live/commit/6385b564624bdcc0d12e96a9730d1baa3849ed56) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - sui: fixed send token issue
|
|
18
10
|
|
|
19
|
-
|
|
11
|
+
- [#11019](https://github.com/LedgerHQ/ledger-live/pull/11019) [`948dcc4`](https://github.com/LedgerHQ/ledger-live/commit/948dcc4e8de83985d8dbeb0af5538a5ff25c80d2) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - Fix sui swap device disconnected error
|
|
20
12
|
|
|
21
|
-
|
|
13
|
+
- [#11019](https://github.com/LedgerHQ/ledger-live/pull/11019) [`0318e2b`](https://github.com/LedgerHQ/ledger-live/commit/0318e2bee721ec12156be9f12530743a4c169396) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - fix: sui pending operation sync
|
|
22
14
|
|
|
23
|
-
- [#
|
|
15
|
+
- [#10844](https://github.com/LedgerHQ/ledger-live/pull/10844) [`f72b7ae`](https://github.com/LedgerHQ/ledger-live/commit/f72b7ae31d2329028f6ef86e89f67e563500e23b) Thanks [@estrauser-ledger](https://github.com/estrauser-ledger)! - Coin:SUI listOperation uses minHeight parameter
|
|
24
16
|
|
|
25
|
-
|
|
17
|
+
- [#11019](https://github.com/LedgerHQ/ledger-live/pull/11019) [`d56a4ba`](https://github.com/LedgerHQ/ledger-live/commit/d56a4ba6ae09a2e90fc9034a04b62e490d5ef4e6) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - fix: alpaca operation sync and time
|
|
26
18
|
|
|
27
19
|
### Patch Changes
|
|
28
20
|
|
|
29
|
-
- Updated dependencies [[`20406e5`](https://github.com/LedgerHQ/ledger-live/commit/20406e52b4167289fced610c6ca9824a6d68cdac)]:
|
|
30
|
-
- @ledgerhq/
|
|
31
|
-
- @ledgerhq/
|
|
32
|
-
- @ledgerhq/coin-framework@5.
|
|
33
|
-
- @ledgerhq/live
|
|
34
|
-
- @ledgerhq/
|
|
21
|
+
- Updated dependencies [[`17e039b`](https://github.com/LedgerHQ/ledger-live/commit/17e039b0c7487dda4a68f6a0fe493b4cf5fd265b), [`6ece1b8`](https://github.com/LedgerHQ/ledger-live/commit/6ece1b80ed05f9dab6541702e40a43b51887f958), [`bb7e311`](https://github.com/LedgerHQ/ledger-live/commit/bb7e31139763b9fd943bf237d2c6260d6aef24ab), [`0e32a4e`](https://github.com/LedgerHQ/ledger-live/commit/0e32a4e5482ad2d3002483632770a2d7981b7a5a), [`9fd5b54`](https://github.com/LedgerHQ/ledger-live/commit/9fd5b5449f1d15fc559e966e9d71e2ad6573547c), [`63cdeb1`](https://github.com/LedgerHQ/ledger-live/commit/63cdeb1ea20fe0c16b623546ce00f3fe26b7ec80), [`20406e5`](https://github.com/LedgerHQ/ledger-live/commit/20406e52b4167289fced610c6ca9824a6d68cdac)]:
|
|
22
|
+
- @ledgerhq/live-env@2.12.0
|
|
23
|
+
- @ledgerhq/cryptoassets@13.22.0
|
|
24
|
+
- @ledgerhq/coin-framework@5.7.0
|
|
25
|
+
- @ledgerhq/types-live@6.78.0
|
|
26
|
+
- @ledgerhq/errors@6.23.0
|
|
27
|
+
- @ledgerhq/live-network@2.0.13
|
|
35
28
|
- @ledgerhq/hw-app-sui@1.2.0
|
|
36
29
|
|
|
37
|
-
## 0.7.0-
|
|
30
|
+
## 0.7.0-next.1
|
|
38
31
|
|
|
39
|
-
###
|
|
32
|
+
### Minor Changes
|
|
33
|
+
|
|
34
|
+
- [#11019](https://github.com/LedgerHQ/ledger-live/pull/11019) [`948dcc4`](https://github.com/LedgerHQ/ledger-live/commit/948dcc4e8de83985d8dbeb0af5538a5ff25c80d2) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - Fix sui swap device disconnected error
|
|
35
|
+
|
|
36
|
+
- [#11019](https://github.com/LedgerHQ/ledger-live/pull/11019) [`0318e2b`](https://github.com/LedgerHQ/ledger-live/commit/0318e2bee721ec12156be9f12530743a4c169396) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - fix: sui pending operation sync
|
|
40
37
|
|
|
41
|
-
-
|
|
42
|
-
- @ledgerhq/coin-framework@5.6.0-nightly.3
|
|
38
|
+
- [#11019](https://github.com/LedgerHQ/ledger-live/pull/11019) [`d56a4ba`](https://github.com/LedgerHQ/ledger-live/commit/d56a4ba6ae09a2e90fc9034a04b62e490d5ef4e6) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - fix: alpaca operation sync and time
|
|
43
39
|
|
|
44
|
-
## 0.7.0-
|
|
40
|
+
## 0.7.0-next.0
|
|
45
41
|
|
|
46
42
|
### Minor Changes
|
|
47
43
|
|
|
44
|
+
- [#10938](https://github.com/LedgerHQ/ledger-live/pull/10938) [`17e039b`](https://github.com/LedgerHQ/ledger-live/commit/17e039b0c7487dda4a68f6a0fe493b4cf5fd265b) Thanks [@semeano](https://github.com/semeano)! - Add client version to HTTP headers
|
|
45
|
+
|
|
46
|
+
- [#10901](https://github.com/LedgerHQ/ledger-live/pull/10901) [`6385b56`](https://github.com/LedgerHQ/ledger-live/commit/6385b564624bdcc0d12e96a9730d1baa3849ed56) Thanks [@jccguimaraes](https://github.com/jccguimaraes)! - sui: fixed send token issue
|
|
47
|
+
|
|
48
48
|
- [#10844](https://github.com/LedgerHQ/ledger-live/pull/10844) [`f72b7ae`](https://github.com/LedgerHQ/ledger-live/commit/f72b7ae31d2329028f6ef86e89f67e563500e23b) Thanks [@estrauser-ledger](https://github.com/estrauser-ledger)! - Coin:SUI listOperation uses minHeight parameter
|
|
49
49
|
|
|
50
50
|
### Patch Changes
|
|
51
51
|
|
|
52
|
-
- Updated dependencies [[`0e32a4e`](https://github.com/LedgerHQ/ledger-live/commit/0e32a4e5482ad2d3002483632770a2d7981b7a5a)]:
|
|
53
|
-
- @ledgerhq/
|
|
54
|
-
- @ledgerhq/
|
|
52
|
+
- Updated dependencies [[`17e039b`](https://github.com/LedgerHQ/ledger-live/commit/17e039b0c7487dda4a68f6a0fe493b4cf5fd265b), [`6ece1b8`](https://github.com/LedgerHQ/ledger-live/commit/6ece1b80ed05f9dab6541702e40a43b51887f958), [`bb7e311`](https://github.com/LedgerHQ/ledger-live/commit/bb7e31139763b9fd943bf237d2c6260d6aef24ab), [`0e32a4e`](https://github.com/LedgerHQ/ledger-live/commit/0e32a4e5482ad2d3002483632770a2d7981b7a5a), [`9fd5b54`](https://github.com/LedgerHQ/ledger-live/commit/9fd5b5449f1d15fc559e966e9d71e2ad6573547c), [`63cdeb1`](https://github.com/LedgerHQ/ledger-live/commit/63cdeb1ea20fe0c16b623546ce00f3fe26b7ec80), [`20406e5`](https://github.com/LedgerHQ/ledger-live/commit/20406e52b4167289fced610c6ca9824a6d68cdac)]:
|
|
53
|
+
- @ledgerhq/live-env@2.12.0-next.0
|
|
54
|
+
- @ledgerhq/cryptoassets@13.22.0-next.0
|
|
55
|
+
- @ledgerhq/coin-framework@5.7.0-next.0
|
|
56
|
+
- @ledgerhq/types-live@6.78.0-next.0
|
|
57
|
+
- @ledgerhq/errors@6.23.0-next.0
|
|
58
|
+
- @ledgerhq/live-network@2.0.13-next.0
|
|
59
|
+
- @ledgerhq/hw-app-sui@1.2.0
|
|
55
60
|
|
|
56
|
-
## 0.6.1
|
|
61
|
+
## 0.6.1
|
|
57
62
|
|
|
58
63
|
### Patch Changes
|
|
59
64
|
|
|
60
|
-
- Updated dependencies [[`90b023d`](https://github.com/LedgerHQ/ledger-live/commit/90b023d9a6db34fef865abf96ab31a5e0bcef42a), [`2f38d03`](https://github.com/LedgerHQ/ledger-live/commit/2f38d032ec8e8481e4ff3b37f33aa4eb3872b542)]:
|
|
61
|
-
- @ledgerhq/
|
|
65
|
+
- Updated dependencies [[`d053a79`](https://github.com/LedgerHQ/ledger-live/commit/d053a7969ac7976ea6d10955c3cfa47621be1b32), [`90b023d`](https://github.com/LedgerHQ/ledger-live/commit/90b023d9a6db34fef865abf96ab31a5e0bcef42a), [`2f38d03`](https://github.com/LedgerHQ/ledger-live/commit/2f38d032ec8e8481e4ff3b37f33aa4eb3872b542), [`0232f73`](https://github.com/LedgerHQ/ledger-live/commit/0232f73efa73eb3a16c306f25dd110e12b9c1fb7)]:
|
|
66
|
+
- @ledgerhq/types-live@6.77.0
|
|
67
|
+
- @ledgerhq/coin-framework@5.6.0
|
|
62
68
|
|
|
63
|
-
## 0.6.1-
|
|
69
|
+
## 0.6.1-next.0
|
|
64
70
|
|
|
65
71
|
### Patch Changes
|
|
66
72
|
|
|
67
|
-
- Updated dependencies [[`d053a79`](https://github.com/LedgerHQ/ledger-live/commit/d053a7969ac7976ea6d10955c3cfa47621be1b32)]:
|
|
68
|
-
- @ledgerhq/types-live@6.77.0-
|
|
69
|
-
- @ledgerhq/coin-framework@5.
|
|
73
|
+
- Updated dependencies [[`d053a79`](https://github.com/LedgerHQ/ledger-live/commit/d053a7969ac7976ea6d10955c3cfa47621be1b32), [`90b023d`](https://github.com/LedgerHQ/ledger-live/commit/90b023d9a6db34fef865abf96ab31a5e0bcef42a), [`2f38d03`](https://github.com/LedgerHQ/ledger-live/commit/2f38d032ec8e8481e4ff3b37f33aa4eb3872b542), [`0232f73`](https://github.com/LedgerHQ/ledger-live/commit/0232f73efa73eb3a16c306f25dd110e12b9c1fb7)]:
|
|
74
|
+
- @ledgerhq/types-live@6.77.0-next.0
|
|
75
|
+
- @ledgerhq/coin-framework@5.6.0-next.0
|
|
70
76
|
|
|
71
77
|
## 0.6.0
|
|
72
78
|
|
package/lib/api/index.js
CHANGED
|
@@ -41,7 +41,7 @@ async function operationsFromHeight(address, minHeight) {
|
|
|
41
41
|
? { minHeight: minHeight, cursor: state.apiNextCursor }
|
|
42
42
|
: { minHeight: minHeight };
|
|
43
43
|
const [operations, nextCursor] = await (0, logic_1.listOperations)(address, option);
|
|
44
|
-
const opsFromHeight = operations.filter(op => op.tx.block.height
|
|
44
|
+
const opsFromHeight = operations.filter(op => op.tx.block.height > minHeight);
|
|
45
45
|
state.accumulator.push(...opsFromHeight);
|
|
46
46
|
state.apiNextCursor = nextCursor;
|
|
47
47
|
// The API makes 2 calls "IN" and "OUT" so even if we started filtering a few elements, we may still have more txs to fetch on one of the two calls.
|
package/lib/api/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":";;;;;;AAAA,uDAAuD;AACvD,oCAQkB;AAUlB,SAAgB,SAAS,CAAC,MAAiB;IACzC,gBAAU,CAAC,aAAa,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,GAAG,MAAM,EAA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,oBAAoB,CACjC,OAAe,EACf,SAAiB;IAEjB,MAAM,KAAK,GAAoB;QAC7B,WAAW,EAAE,SAAS;QACtB,kBAAkB,EAAE,IAAI;QACxB,WAAW,EAAE,EAAE;KAChB,CAAC;IAEF,OAAO,KAAK,CAAC,kBAAkB,EAAE,CAAC;QAChC,MAAM,MAAM,GAAG,KAAK,CAAC,aAAa;YAChC,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,aAAa,EAAE;YACvD,CAAC,CAAC,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;QAC7B,MAAM,CAAC,UAAU,EAAE,UAAU,CAAC,GAAG,MAAM,IAAA,sBAAc,EAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QACvE,MAAM,aAAa,GAAG,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;QAC9E,KAAK,CAAC,WAAW,CAAC,IAAI,CAAC,GAAG,aAAa,CAAC,CAAC;QACzC,KAAK,CAAC,aAAa,GAAG,UAAU,CAAC;QACjC,oJAAoJ;QACpJ,gDAAgD;QAChD,KAAK,CAAC,kBAAkB,GAAG,UAAU,KAAK,EAAE,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,CAAC;IAC3E,CAAC;IAED,OAAO,CAAC,KAAK,CAAC,WAAW,EAAE,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,KAAK,CAAC,aAAa,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;AAC7E,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.d.ts","sourceRoot":"","sources":["../../src/api/index.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
+
if (mod && mod.__esModule) return mod;
|
|
20
|
+
var result = {};
|
|
21
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
+
__setModuleDefault(result, mod);
|
|
23
|
+
return result;
|
|
24
|
+
};
|
|
25
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
+
const index_1 = require("./index");
|
|
27
|
+
const logic = __importStar(require("../logic"));
|
|
28
|
+
jest.mock("../logic");
|
|
29
|
+
jest.mock("../config", () => ({
|
|
30
|
+
__esModule: true,
|
|
31
|
+
default: {
|
|
32
|
+
setCoinConfig: jest.fn(),
|
|
33
|
+
getCoinConfig: jest.fn(),
|
|
34
|
+
},
|
|
35
|
+
}));
|
|
36
|
+
const mockConfig = {
|
|
37
|
+
node: { url: "http://localhost:1234" },
|
|
38
|
+
status: { type: "active" },
|
|
39
|
+
};
|
|
40
|
+
describe("api/index", () => {
|
|
41
|
+
let api;
|
|
42
|
+
beforeEach(() => {
|
|
43
|
+
jest.clearAllMocks();
|
|
44
|
+
api = (0, index_1.createApi)(mockConfig);
|
|
45
|
+
});
|
|
46
|
+
it("should set coin config and return API object", () => {
|
|
47
|
+
expect(typeof api).toBe("object");
|
|
48
|
+
expect(Object.keys(api)).toEqual(expect.arrayContaining([
|
|
49
|
+
"broadcast",
|
|
50
|
+
"combine",
|
|
51
|
+
"craftTransaction",
|
|
52
|
+
"estimateFees",
|
|
53
|
+
"getBalance",
|
|
54
|
+
"lastBlock",
|
|
55
|
+
"listOperations",
|
|
56
|
+
]));
|
|
57
|
+
});
|
|
58
|
+
it("should call broadcast from logic", async () => {
|
|
59
|
+
const mockBroadcast = jest.spyOn(logic, "broadcast").mockResolvedValue("broadcasted");
|
|
60
|
+
const result = await api.broadcast("tx");
|
|
61
|
+
expect(mockBroadcast).toHaveBeenCalledWith("tx");
|
|
62
|
+
expect(result).toBe("broadcasted");
|
|
63
|
+
});
|
|
64
|
+
it("should call combine from logic", async () => {
|
|
65
|
+
const mockCombine = jest.spyOn(logic, "combine").mockReturnValue("combined-tx");
|
|
66
|
+
const arg1 = "txstring";
|
|
67
|
+
const arg2 = "sigstring";
|
|
68
|
+
const result = api.combine(arg1, arg2);
|
|
69
|
+
expect(mockCombine).toHaveBeenCalledWith(arg1, arg2);
|
|
70
|
+
expect(result).toBe("combined-tx");
|
|
71
|
+
});
|
|
72
|
+
it("should call craftTransaction via craft wrapper and return hex string", async () => {
|
|
73
|
+
const unsigned = Buffer.from("unsignedTx");
|
|
74
|
+
jest.spyOn(logic, "craftTransaction").mockResolvedValue({ unsigned });
|
|
75
|
+
const txIntent = { foo: "bar" };
|
|
76
|
+
const result = await api.craftTransaction(txIntent);
|
|
77
|
+
expect(result).toBe(unsigned.toString("hex"));
|
|
78
|
+
expect(logic.craftTransaction).toHaveBeenCalledWith(txIntent);
|
|
79
|
+
});
|
|
80
|
+
it("should call estimateFees via estimate wrapper and return FeeEstimation", async () => {
|
|
81
|
+
jest.spyOn(logic, "estimateFees").mockResolvedValue(123n);
|
|
82
|
+
const txIntent = { foo: "bar" };
|
|
83
|
+
const result = await api.estimateFees(txIntent);
|
|
84
|
+
expect(result).toEqual({ value: 123n });
|
|
85
|
+
expect(logic.estimateFees).toHaveBeenCalledWith(txIntent);
|
|
86
|
+
});
|
|
87
|
+
it("should call getBalance from logic", async () => {
|
|
88
|
+
const mockGetBalance = jest
|
|
89
|
+
.spyOn(logic, "getBalance")
|
|
90
|
+
.mockResolvedValue([{ value: 42n, asset: { type: "native" } }]);
|
|
91
|
+
const result = await api.getBalance("address");
|
|
92
|
+
expect(mockGetBalance).toHaveBeenCalledWith("address");
|
|
93
|
+
expect(result).toEqual([{ value: 42n, asset: { type: "native" } }]);
|
|
94
|
+
});
|
|
95
|
+
it("should call lastBlock from logic", async () => {
|
|
96
|
+
const mockLastBlock = jest
|
|
97
|
+
.spyOn(logic, "lastBlock")
|
|
98
|
+
.mockResolvedValue({ hash: "h", height: 1, time: new Date() });
|
|
99
|
+
const result = await api.lastBlock();
|
|
100
|
+
expect(mockLastBlock).toHaveBeenCalled();
|
|
101
|
+
expect(result).toHaveProperty("hash");
|
|
102
|
+
expect(result).toHaveProperty("height");
|
|
103
|
+
expect(result).toHaveProperty("time");
|
|
104
|
+
});
|
|
105
|
+
it("should call listOperations from logic", async () => {
|
|
106
|
+
const minimalOperation = {
|
|
107
|
+
id: "op1",
|
|
108
|
+
type: "IN",
|
|
109
|
+
senders: ["sender1"],
|
|
110
|
+
recipients: ["recipient1"],
|
|
111
|
+
value: 1n,
|
|
112
|
+
asset: { type: "native" },
|
|
113
|
+
tx: {
|
|
114
|
+
hash: "hash1",
|
|
115
|
+
block: { height: 1 },
|
|
116
|
+
fees: 1n,
|
|
117
|
+
date: new Date(),
|
|
118
|
+
},
|
|
119
|
+
};
|
|
120
|
+
const mockListOperations = jest
|
|
121
|
+
.spyOn(logic, "listOperations")
|
|
122
|
+
.mockResolvedValue([[minimalOperation], ""]); // Return empty string for cursor
|
|
123
|
+
const result = await api.listOperations("address", { minHeight: 0 });
|
|
124
|
+
expect(mockListOperations).toHaveBeenCalledWith("address", { minHeight: 0 });
|
|
125
|
+
expect(result).toEqual([[minimalOperation], ""]);
|
|
126
|
+
});
|
|
127
|
+
it("should throw if craftTransaction throws", async () => {
|
|
128
|
+
jest.spyOn(logic, "craftTransaction").mockRejectedValue(new Error("fail"));
|
|
129
|
+
await expect(api.craftTransaction({})).rejects.toThrow("fail");
|
|
130
|
+
});
|
|
131
|
+
it("should throw if estimateFees throws", async () => {
|
|
132
|
+
jest.spyOn(logic, "estimateFees").mockRejectedValue(new Error("fail"));
|
|
133
|
+
await expect(api.estimateFees({})).rejects.toThrow("fail");
|
|
134
|
+
});
|
|
135
|
+
});
|
|
136
|
+
//# sourceMappingURL=index.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.test.js","sourceRoot":"","sources":["../../src/api/index.test.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mCAAoC;AACpC,gDAAkC;AAGlC,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;AACtB,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,GAAG,EAAE,CAAC,CAAC;IAC5B,UAAU,EAAE,IAAI;IAChB,OAAO,EAAE;QACP,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;QACxB,aAAa,EAAE,IAAI,CAAC,EAAE,EAAE;KACzB;CACF,CAAC,CAAC,CAAC;AAEJ,MAAM,UAAU,GAAkB;IAChC,IAAI,EAAE,EAAE,GAAG,EAAE,uBAAuB,EAAE;IACtC,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE;CAC3B,CAAC;AAEF,QAAQ,CAAC,WAAW,EAAE,GAAG,EAAE;IACzB,IAAI,GAAiC,CAAC;IAEtC,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,aAAa,EAAE,CAAC;QACrB,GAAG,GAAG,IAAA,iBAAS,EAAC,UAAU,CAAC,CAAC;IAC9B,CAAC,CAAC,CAAC;IAEH,EAAE,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,OAAO,CAAC,MAAM,CAAC,CAAC;IACpE,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTransaction.test.d.ts","sourceRoot":"","sources":["../../src/bridge/buildTransaction.test.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,324 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
4
|
+
const buildTransaction_1 = require("./buildTransaction");
|
|
5
|
+
// Mock the craftTransaction function
|
|
6
|
+
jest.mock("../logic", () => ({
|
|
7
|
+
craftTransaction: jest.fn(),
|
|
8
|
+
}));
|
|
9
|
+
const logic_1 = require("../logic");
|
|
10
|
+
describe("buildTransaction", () => {
|
|
11
|
+
const mockAccount = {
|
|
12
|
+
id: "test-account-id",
|
|
13
|
+
name: "Test Account",
|
|
14
|
+
address: "0x1234567890abcdef",
|
|
15
|
+
freshAddress: "0x1234567890abcdef",
|
|
16
|
+
freshAddressPath: "m/44'/784'/0'/0'/0'",
|
|
17
|
+
currency: {
|
|
18
|
+
id: "sui",
|
|
19
|
+
name: "Sui",
|
|
20
|
+
family: "sui",
|
|
21
|
+
units: [],
|
|
22
|
+
type: "CryptoCurrency",
|
|
23
|
+
},
|
|
24
|
+
balance: new bignumber_js_1.BigNumber("1000000000"),
|
|
25
|
+
spendableBalance: new bignumber_js_1.BigNumber("1000000000"),
|
|
26
|
+
blockHeight: 1000,
|
|
27
|
+
lastSyncDate: new Date(),
|
|
28
|
+
operations: [],
|
|
29
|
+
pendingOperations: [],
|
|
30
|
+
unit: {
|
|
31
|
+
name: "SUI",
|
|
32
|
+
code: "SUI",
|
|
33
|
+
magnitude: 9,
|
|
34
|
+
},
|
|
35
|
+
type: "Account",
|
|
36
|
+
};
|
|
37
|
+
const mockTransaction = {
|
|
38
|
+
id: "test-transaction-id",
|
|
39
|
+
family: "sui",
|
|
40
|
+
mode: "send",
|
|
41
|
+
coinType: "0x2::sui::SUI",
|
|
42
|
+
amount: new bignumber_js_1.BigNumber("100000000"),
|
|
43
|
+
recipient: "0xabcdef1234567890",
|
|
44
|
+
fees: new bignumber_js_1.BigNumber("1000000"),
|
|
45
|
+
errors: {},
|
|
46
|
+
warnings: {},
|
|
47
|
+
useAllAmount: false,
|
|
48
|
+
estimatedFees: new bignumber_js_1.BigNumber("1000000"),
|
|
49
|
+
feeStrategy: "medium",
|
|
50
|
+
networkInfo: {
|
|
51
|
+
family: "sui",
|
|
52
|
+
fees: new bignumber_js_1.BigNumber("1000000"),
|
|
53
|
+
},
|
|
54
|
+
};
|
|
55
|
+
beforeEach(() => {
|
|
56
|
+
jest.clearAllMocks();
|
|
57
|
+
logic_1.craftTransaction.mockResolvedValue({
|
|
58
|
+
unsigned: new Uint8Array([1, 2, 3, 4, 5]),
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
describe("buildTransaction", () => {
|
|
62
|
+
it("should call craftTransaction with correct parameters", async () => {
|
|
63
|
+
// WHEN
|
|
64
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, mockTransaction);
|
|
65
|
+
// THEN
|
|
66
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith({
|
|
67
|
+
sender: mockAccount.freshAddress,
|
|
68
|
+
recipient: mockTransaction.recipient,
|
|
69
|
+
type: mockTransaction.mode,
|
|
70
|
+
coinType: "0x2::sui::SUI",
|
|
71
|
+
amount: BigInt(mockTransaction.amount.toString()),
|
|
72
|
+
asset: { type: "native" },
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
it("should return the result from craftTransaction", async () => {
|
|
76
|
+
const expectedResult = {
|
|
77
|
+
unsigned: new Uint8Array([1, 2, 3, 4, 5]),
|
|
78
|
+
};
|
|
79
|
+
// WHEN
|
|
80
|
+
const result = await (0, buildTransaction_1.buildTransaction)(mockAccount, mockTransaction);
|
|
81
|
+
// THEN
|
|
82
|
+
expect(result).toEqual(expectedResult);
|
|
83
|
+
expect(result.unsigned).toBeInstanceOf(Uint8Array);
|
|
84
|
+
});
|
|
85
|
+
it("should handle BigNumber amount conversion correctly", async () => {
|
|
86
|
+
const transactionWithLargeAmount = {
|
|
87
|
+
...mockTransaction,
|
|
88
|
+
amount: new bignumber_js_1.BigNumber("999999999999999999"),
|
|
89
|
+
};
|
|
90
|
+
// WHEN
|
|
91
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, transactionWithLargeAmount);
|
|
92
|
+
// THEN
|
|
93
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
94
|
+
amount: BigInt("999999999999999999"),
|
|
95
|
+
}));
|
|
96
|
+
});
|
|
97
|
+
it("should handle zero amount", async () => {
|
|
98
|
+
const transactionWithZeroAmount = {
|
|
99
|
+
...mockTransaction,
|
|
100
|
+
amount: new bignumber_js_1.BigNumber("0"),
|
|
101
|
+
};
|
|
102
|
+
// WHEN
|
|
103
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, transactionWithZeroAmount);
|
|
104
|
+
// THEN
|
|
105
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
106
|
+
amount: BigInt("0"),
|
|
107
|
+
}));
|
|
108
|
+
});
|
|
109
|
+
it("should handle different transaction modes", async () => {
|
|
110
|
+
const transactionWithDifferentMode = {
|
|
111
|
+
...mockTransaction,
|
|
112
|
+
mode: "send",
|
|
113
|
+
};
|
|
114
|
+
// WHEN
|
|
115
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, transactionWithDifferentMode);
|
|
116
|
+
// THEN
|
|
117
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
118
|
+
type: "send",
|
|
119
|
+
}));
|
|
120
|
+
});
|
|
121
|
+
it("should handle different recipient addresses", async () => {
|
|
122
|
+
const transactionWithDifferentRecipient = {
|
|
123
|
+
...mockTransaction,
|
|
124
|
+
recipient: "0x9876543210fedcba",
|
|
125
|
+
};
|
|
126
|
+
// WHEN
|
|
127
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, transactionWithDifferentRecipient);
|
|
128
|
+
// THEN
|
|
129
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
130
|
+
recipient: "0x9876543210fedcba",
|
|
131
|
+
}));
|
|
132
|
+
});
|
|
133
|
+
it("should handle different account addresses", async () => {
|
|
134
|
+
const accountWithDifferentAddress = {
|
|
135
|
+
...mockAccount,
|
|
136
|
+
freshAddress: "0xabcdef1234567890",
|
|
137
|
+
};
|
|
138
|
+
// WHEN
|
|
139
|
+
await (0, buildTransaction_1.buildTransaction)(accountWithDifferentAddress, mockTransaction);
|
|
140
|
+
// THEN
|
|
141
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
142
|
+
sender: "0xabcdef1234567890",
|
|
143
|
+
}));
|
|
144
|
+
});
|
|
145
|
+
it("should propagate errors from craftTransaction", async () => {
|
|
146
|
+
const error = new Error("Transaction creation failed");
|
|
147
|
+
logic_1.craftTransaction.mockRejectedValue(error);
|
|
148
|
+
// WHEN & THEN
|
|
149
|
+
await expect((0, buildTransaction_1.buildTransaction)(mockAccount, mockTransaction)).rejects.toThrow("Transaction creation failed");
|
|
150
|
+
});
|
|
151
|
+
it("should handle craftTransaction returning null", async () => {
|
|
152
|
+
logic_1.craftTransaction.mockResolvedValue(null);
|
|
153
|
+
// WHEN
|
|
154
|
+
const result = await (0, buildTransaction_1.buildTransaction)(mockAccount, mockTransaction);
|
|
155
|
+
// THEN
|
|
156
|
+
expect(result).toBeNull();
|
|
157
|
+
});
|
|
158
|
+
it("should handle craftTransaction returning undefined", async () => {
|
|
159
|
+
logic_1.craftTransaction.mockResolvedValue(undefined);
|
|
160
|
+
// WHEN
|
|
161
|
+
const result = await (0, buildTransaction_1.buildTransaction)(mockAccount, mockTransaction);
|
|
162
|
+
// THEN
|
|
163
|
+
expect(result).toBeUndefined();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
describe("extractExtrinsicArg", () => {
|
|
167
|
+
it("should extract correct fields from transaction", () => {
|
|
168
|
+
const transaction = {
|
|
169
|
+
...mockTransaction,
|
|
170
|
+
useAllAmount: true,
|
|
171
|
+
};
|
|
172
|
+
// WHEN
|
|
173
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
174
|
+
// THEN
|
|
175
|
+
expect(result).toEqual({
|
|
176
|
+
mode: "send",
|
|
177
|
+
coinType: "0x2::sui::SUI",
|
|
178
|
+
amount: new bignumber_js_1.BigNumber("100000000"),
|
|
179
|
+
recipient: "0xabcdef1234567890",
|
|
180
|
+
useAllAmount: true,
|
|
181
|
+
});
|
|
182
|
+
});
|
|
183
|
+
it("should handle transaction without useAllAmount", () => {
|
|
184
|
+
const transaction = {
|
|
185
|
+
...mockTransaction,
|
|
186
|
+
useAllAmount: false,
|
|
187
|
+
};
|
|
188
|
+
// WHEN
|
|
189
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
190
|
+
// THEN
|
|
191
|
+
expect(result).toEqual({
|
|
192
|
+
mode: "send",
|
|
193
|
+
coinType: "0x2::sui::SUI",
|
|
194
|
+
amount: new bignumber_js_1.BigNumber("100000000"),
|
|
195
|
+
recipient: "0xabcdef1234567890",
|
|
196
|
+
useAllAmount: false,
|
|
197
|
+
});
|
|
198
|
+
});
|
|
199
|
+
it("should handle transaction with undefined useAllAmount", () => {
|
|
200
|
+
const transaction = {
|
|
201
|
+
...mockTransaction,
|
|
202
|
+
useAllAmount: undefined,
|
|
203
|
+
};
|
|
204
|
+
// WHEN
|
|
205
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
206
|
+
// THEN
|
|
207
|
+
expect(result).toEqual({
|
|
208
|
+
mode: "send",
|
|
209
|
+
coinType: "0x2::sui::SUI",
|
|
210
|
+
amount: new bignumber_js_1.BigNumber("100000000"),
|
|
211
|
+
recipient: "0xabcdef1234567890",
|
|
212
|
+
useAllAmount: undefined,
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
it("should handle different transaction modes", () => {
|
|
216
|
+
const transaction = {
|
|
217
|
+
...mockTransaction,
|
|
218
|
+
mode: "send",
|
|
219
|
+
};
|
|
220
|
+
// WHEN
|
|
221
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
222
|
+
// THEN
|
|
223
|
+
expect(result.mode).toBe("send");
|
|
224
|
+
});
|
|
225
|
+
it("should handle different amounts", () => {
|
|
226
|
+
const transaction = {
|
|
227
|
+
...mockTransaction,
|
|
228
|
+
amount: new bignumber_js_1.BigNumber("500000000"),
|
|
229
|
+
};
|
|
230
|
+
// WHEN
|
|
231
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
232
|
+
// THEN
|
|
233
|
+
expect(result.amount).toEqual(new bignumber_js_1.BigNumber("500000000"));
|
|
234
|
+
});
|
|
235
|
+
it("should handle different recipients", () => {
|
|
236
|
+
const transaction = {
|
|
237
|
+
...mockTransaction,
|
|
238
|
+
recipient: "0x9876543210fedcba",
|
|
239
|
+
};
|
|
240
|
+
// WHEN
|
|
241
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
242
|
+
// THEN
|
|
243
|
+
expect(result.recipient).toBe("0x9876543210fedcba");
|
|
244
|
+
});
|
|
245
|
+
it("should not include other transaction fields", () => {
|
|
246
|
+
const transaction = {
|
|
247
|
+
...mockTransaction,
|
|
248
|
+
fees: new bignumber_js_1.BigNumber("1000000"),
|
|
249
|
+
errors: { someError: new Error("test") },
|
|
250
|
+
};
|
|
251
|
+
// WHEN
|
|
252
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
253
|
+
// THEN
|
|
254
|
+
expect(result).not.toHaveProperty("fees");
|
|
255
|
+
expect(result).not.toHaveProperty("errors");
|
|
256
|
+
expect(result).not.toHaveProperty("family");
|
|
257
|
+
expect(result).not.toHaveProperty("id");
|
|
258
|
+
});
|
|
259
|
+
it("should handle zero amount", () => {
|
|
260
|
+
const transaction = {
|
|
261
|
+
...mockTransaction,
|
|
262
|
+
amount: new bignumber_js_1.BigNumber("0"),
|
|
263
|
+
};
|
|
264
|
+
// WHEN
|
|
265
|
+
const result = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
266
|
+
// THEN
|
|
267
|
+
expect(result.amount).toEqual(new bignumber_js_1.BigNumber("0"));
|
|
268
|
+
});
|
|
269
|
+
});
|
|
270
|
+
describe("Integration between extractExtrinsicArg and buildTransaction", () => {
|
|
271
|
+
it("should work together correctly", async () => {
|
|
272
|
+
const transaction = {
|
|
273
|
+
...mockTransaction,
|
|
274
|
+
useAllAmount: true,
|
|
275
|
+
};
|
|
276
|
+
// Extract extrinsic arg
|
|
277
|
+
const extrinsicArg = (0, buildTransaction_1.extractExtrinsicArg)(transaction);
|
|
278
|
+
// Build transaction
|
|
279
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, transaction);
|
|
280
|
+
// Verify that the extracted arg contains the expected fields
|
|
281
|
+
expect(extrinsicArg).toHaveProperty("mode", "send");
|
|
282
|
+
expect(extrinsicArg).toHaveProperty("amount");
|
|
283
|
+
expect(extrinsicArg).toHaveProperty("recipient");
|
|
284
|
+
expect(extrinsicArg).toHaveProperty("useAllAmount", true);
|
|
285
|
+
// Verify that buildTransaction was called with correct parameters
|
|
286
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith({
|
|
287
|
+
sender: mockAccount.freshAddress,
|
|
288
|
+
recipient: transaction.recipient,
|
|
289
|
+
type: transaction.mode,
|
|
290
|
+
coinType: "0x2::sui::SUI",
|
|
291
|
+
amount: BigInt(transaction.amount.toString()),
|
|
292
|
+
asset: { type: "native" },
|
|
293
|
+
});
|
|
294
|
+
});
|
|
295
|
+
});
|
|
296
|
+
describe("Edge Cases", () => {
|
|
297
|
+
it("should handle empty recipient string", async () => {
|
|
298
|
+
const transactionWithEmptyRecipient = {
|
|
299
|
+
...mockTransaction,
|
|
300
|
+
recipient: "",
|
|
301
|
+
};
|
|
302
|
+
// WHEN
|
|
303
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, transactionWithEmptyRecipient);
|
|
304
|
+
// THEN
|
|
305
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
306
|
+
recipient: "",
|
|
307
|
+
}));
|
|
308
|
+
});
|
|
309
|
+
it("should handle very long recipient addresses", async () => {
|
|
310
|
+
const longAddress = "0x" + "a".repeat(100);
|
|
311
|
+
const transactionWithLongRecipient = {
|
|
312
|
+
...mockTransaction,
|
|
313
|
+
recipient: longAddress,
|
|
314
|
+
};
|
|
315
|
+
// WHEN
|
|
316
|
+
await (0, buildTransaction_1.buildTransaction)(mockAccount, transactionWithLongRecipient);
|
|
317
|
+
// THEN
|
|
318
|
+
expect(logic_1.craftTransaction).toHaveBeenCalledWith(expect.objectContaining({
|
|
319
|
+
recipient: longAddress,
|
|
320
|
+
}));
|
|
321
|
+
});
|
|
322
|
+
});
|
|
323
|
+
});
|
|
324
|
+
//# sourceMappingURL=buildTransaction.test.js.map
|