@ledgerhq/coin-canton 0.10.0-nightly.20251120023735 → 0.10.0-nightly.20251121023744
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/CHANGELOG.md +9 -7
- package/lib/bridge/serialization.d.ts +2 -0
- package/lib/bridge/serialization.d.ts.map +1 -1
- package/lib/bridge/serialization.js +1 -0
- package/lib/bridge/serialization.js.map +1 -1
- package/lib/bridge/sync.d.ts.map +1 -1
- package/lib/bridge/sync.js +10 -4
- package/lib/bridge/sync.js.map +1 -1
- package/lib/helpers.d.ts +10 -0
- package/lib/helpers.d.ts.map +1 -0
- package/lib/helpers.js +26 -0
- package/lib/helpers.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +5 -1
- package/lib/index.js.map +1 -1
- package/lib-es/bridge/serialization.d.ts +2 -0
- package/lib-es/bridge/serialization.d.ts.map +1 -1
- package/lib-es/bridge/serialization.js +1 -1
- package/lib-es/bridge/serialization.js.map +1 -1
- package/lib-es/bridge/sync.d.ts.map +1 -1
- package/lib-es/bridge/sync.js +11 -5
- package/lib-es/bridge/sync.js.map +1 -1
- package/lib-es/helpers.d.ts +10 -0
- package/lib-es/helpers.d.ts.map +1 -0
- package/lib-es/helpers.js +22 -0
- package/lib-es/helpers.js.map +1 -0
- package/lib-es/index.d.ts +2 -0
- package/lib-es/index.d.ts.map +1 -1
- package/lib-es/index.js +2 -0
- package/lib-es/index.js.map +1 -1
- package/package.json +6 -6
- package/src/bridge/serialization.ts +1 -1
- package/src/bridge/sync.ts +11 -5
- package/src/helpers.test.ts +361 -0
- package/src/helpers.ts +31 -0
- package/src/index.ts +2 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,23 +1,25 @@
|
|
|
1
1
|
# @ledgerhq/coin-canton
|
|
2
2
|
|
|
3
|
-
## 0.10.0-nightly.
|
|
3
|
+
## 0.10.0-nightly.20251121023744
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
7
7
|
- [#12402](https://github.com/LedgerHQ/ledger-live/pull/12402) [`544721d`](https://github.com/LedgerHQ/ledger-live/commit/544721d198454526ef83516619d59c881ba34eb9) Thanks [@qperrot](https://github.com/qperrot)! - Fix transactionSequenceNumber type
|
|
8
8
|
|
|
9
|
+
- [#12894](https://github.com/LedgerHQ/ledger-live/pull/12894) [`364d4ed`](https://github.com/LedgerHQ/ledger-live/commit/364d4ed5099087eea580399b4e8e6a83aa761f16) Thanks [@jonezque](https://github.com/jonezque)! - feat: canton updated logic to check if account is empty or not
|
|
10
|
+
|
|
9
11
|
- [#12745](https://github.com/LedgerHQ/ledger-live/pull/12745) [`aadcec6`](https://github.com/LedgerHQ/ledger-live/commit/aadcec66847b800f79452ba1df09149e0a1cb9e8) Thanks [@jonezque](https://github.com/jonezque)! - feat: pending offers to show, accept, cancel for canton network
|
|
10
12
|
|
|
11
13
|
- [#12604](https://github.com/LedgerHQ/ledger-live/pull/12604) [`eb5a17e`](https://github.com/LedgerHQ/ledger-live/commit/eb5a17e4db336eaa871eaeb52ffa5248e0f78bec) Thanks [@jnicoulaud-ledger](https://github.com/jnicoulaud-ledger)! - coin-modules/alpaca: add transaction status to operations
|
|
12
14
|
|
|
13
15
|
### Patch Changes
|
|
14
16
|
|
|
15
|
-
- Updated dependencies [[`74a340b`](https://github.com/LedgerHQ/ledger-live/commit/74a340b258589c9c37476103029eb036b930616c), [`a6bc24e`](https://github.com/LedgerHQ/ledger-live/commit/a6bc24ee988b98bf82f807ac5ce731ba79813901), [`b69c97d`](https://github.com/LedgerHQ/ledger-live/commit/b69c97d979ba97154c9abfda6abfc2a36becee4f), [`544721d`](https://github.com/LedgerHQ/ledger-live/commit/544721d198454526ef83516619d59c881ba34eb9), [`fe81926`](https://github.com/LedgerHQ/ledger-live/commit/fe81926afeb2df8e917e6bd1e4cbab13f09647fd), [`1c6f5f5`](https://github.com/LedgerHQ/ledger-live/commit/1c6f5f5843349b1955f7ca466f98cbe4ffcdaddf), [`b4a4e16`](https://github.com/LedgerHQ/ledger-live/commit/b4a4e160aae6fd64f944ab25633f6931dc4358d3), [`d5d838a`](https://github.com/LedgerHQ/ledger-live/commit/d5d838a23e00edd53293843781c559c41db4e854), [`9f61dcf`](https://github.com/LedgerHQ/ledger-live/commit/9f61dcf6163fd66657e5be732c28bea623a40515), [`903ea9c`](https://github.com/LedgerHQ/ledger-live/commit/903ea9cdacf704a0119de2803a4f409b775391a5), [`938b970`](https://github.com/LedgerHQ/ledger-live/commit/938b970e15118dc706c759a3bec27dc01c3dd268), [`c40e9da`](https://github.com/LedgerHQ/ledger-live/commit/c40e9da68452fe9827b9435ff2d162291186be73), [`02ef98f`](https://github.com/LedgerHQ/ledger-live/commit/02ef98faeb13c182ef255e06a43c39abeb55ecc7), [`c0b5b9f`](https://github.com/LedgerHQ/ledger-live/commit/c0b5b9f4cdcb2ea3e15419cbf3d1a14f725c3e6a), [`6d0c6b2`](https://github.com/LedgerHQ/ledger-live/commit/6d0c6b2eda60049d8eebda5de2c54e8f0be7d009), [`70049be`](https://github.com/LedgerHQ/ledger-live/commit/70049bed0cd0a8c7a9e4947a63af82061dad46c0), [`0d33751`](https://github.com/LedgerHQ/ledger-live/commit/0d33751bb2ae599d0d26ce6a8efdbe01757f12fb), [`5b41dd5`](https://github.com/LedgerHQ/ledger-live/commit/5b41dd56e024a5d03ba0e49084113c04887395db), [`aadcec6`](https://github.com/LedgerHQ/ledger-live/commit/aadcec66847b800f79452ba1df09149e0a1cb9e8), [`eb5a17e`](https://github.com/LedgerHQ/ledger-live/commit/eb5a17e4db336eaa871eaeb52ffa5248e0f78bec), [`ed8532b`](https://github.com/LedgerHQ/ledger-live/commit/ed8532bad754ca2b5f1788c6e92f4646b775ec79), [`9659a34`](https://github.com/LedgerHQ/ledger-live/commit/9659a34d9998d5c4dff8618bf6cef7d16403680d), [`c70f6a8`](https://github.com/LedgerHQ/ledger-live/commit/c70f6a8370056b6fd8f236205471359d6f9b846f)]:
|
|
16
|
-
- @ledgerhq/types-live@6.89.0-nightly.
|
|
17
|
-
- @ledgerhq/cryptoassets@13.33.0-nightly.
|
|
18
|
-
- @ledgerhq/coin-framework@6.9.0-nightly.
|
|
19
|
-
- @ledgerhq/live-env@2.21.0-nightly.
|
|
20
|
-
- @ledgerhq/live-network@2.1.1-nightly.
|
|
17
|
+
- Updated dependencies [[`74a340b`](https://github.com/LedgerHQ/ledger-live/commit/74a340b258589c9c37476103029eb036b930616c), [`a6bc24e`](https://github.com/LedgerHQ/ledger-live/commit/a6bc24ee988b98bf82f807ac5ce731ba79813901), [`b69c97d`](https://github.com/LedgerHQ/ledger-live/commit/b69c97d979ba97154c9abfda6abfc2a36becee4f), [`544721d`](https://github.com/LedgerHQ/ledger-live/commit/544721d198454526ef83516619d59c881ba34eb9), [`fe81926`](https://github.com/LedgerHQ/ledger-live/commit/fe81926afeb2df8e917e6bd1e4cbab13f09647fd), [`1c6f5f5`](https://github.com/LedgerHQ/ledger-live/commit/1c6f5f5843349b1955f7ca466f98cbe4ffcdaddf), [`b4a4e16`](https://github.com/LedgerHQ/ledger-live/commit/b4a4e160aae6fd64f944ab25633f6931dc4358d3), [`927ae64`](https://github.com/LedgerHQ/ledger-live/commit/927ae64db0bb04af54e25623655a001a68e0f2d3), [`d5d838a`](https://github.com/LedgerHQ/ledger-live/commit/d5d838a23e00edd53293843781c559c41db4e854), [`9f61dcf`](https://github.com/LedgerHQ/ledger-live/commit/9f61dcf6163fd66657e5be732c28bea623a40515), [`903ea9c`](https://github.com/LedgerHQ/ledger-live/commit/903ea9cdacf704a0119de2803a4f409b775391a5), [`938b970`](https://github.com/LedgerHQ/ledger-live/commit/938b970e15118dc706c759a3bec27dc01c3dd268), [`c40e9da`](https://github.com/LedgerHQ/ledger-live/commit/c40e9da68452fe9827b9435ff2d162291186be73), [`02ef98f`](https://github.com/LedgerHQ/ledger-live/commit/02ef98faeb13c182ef255e06a43c39abeb55ecc7), [`c0b5b9f`](https://github.com/LedgerHQ/ledger-live/commit/c0b5b9f4cdcb2ea3e15419cbf3d1a14f725c3e6a), [`6d0c6b2`](https://github.com/LedgerHQ/ledger-live/commit/6d0c6b2eda60049d8eebda5de2c54e8f0be7d009), [`70049be`](https://github.com/LedgerHQ/ledger-live/commit/70049bed0cd0a8c7a9e4947a63af82061dad46c0), [`0d33751`](https://github.com/LedgerHQ/ledger-live/commit/0d33751bb2ae599d0d26ce6a8efdbe01757f12fb), [`5b41dd5`](https://github.com/LedgerHQ/ledger-live/commit/5b41dd56e024a5d03ba0e49084113c04887395db), [`aadcec6`](https://github.com/LedgerHQ/ledger-live/commit/aadcec66847b800f79452ba1df09149e0a1cb9e8), [`eb5a17e`](https://github.com/LedgerHQ/ledger-live/commit/eb5a17e4db336eaa871eaeb52ffa5248e0f78bec), [`ed8532b`](https://github.com/LedgerHQ/ledger-live/commit/ed8532bad754ca2b5f1788c6e92f4646b775ec79), [`9659a34`](https://github.com/LedgerHQ/ledger-live/commit/9659a34d9998d5c4dff8618bf6cef7d16403680d), [`c70f6a8`](https://github.com/LedgerHQ/ledger-live/commit/c70f6a8370056b6fd8f236205471359d6f9b846f)]:
|
|
18
|
+
- @ledgerhq/types-live@6.89.0-nightly.20251121023744
|
|
19
|
+
- @ledgerhq/cryptoassets@13.33.0-nightly.20251121023744
|
|
20
|
+
- @ledgerhq/coin-framework@6.9.0-nightly.20251121023744
|
|
21
|
+
- @ledgerhq/live-env@2.21.0-nightly.20251121023744
|
|
22
|
+
- @ledgerhq/live-network@2.1.1-nightly.20251121023744
|
|
21
23
|
|
|
22
24
|
## 0.9.0
|
|
23
25
|
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Account, AccountRaw } from "@ledgerhq/types-live";
|
|
2
|
+
import { type CantonAccount } from "../types";
|
|
3
|
+
export declare function isCantonAccount(account: Account): account is CantonAccount;
|
|
2
4
|
export declare function assignToAccountRaw(account: Account, accountRaw: AccountRaw): void;
|
|
3
5
|
export declare function assignFromAccountRaw(accountRaw: AccountRaw, account: Account): void;
|
|
4
6
|
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,UAAU,CAAC;AAElB,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,aAAa,CAE1E;AAqBD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAMjF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAMnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":";;
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":";;AAQA,0CAEC;AAqBD,gDAMC;AAED,oDAMC;AArCD,SAAgB,eAAe,CAAC,OAAgB;IAC9C,OAAO,iBAAiB,IAAI,OAAO,CAAC;AACtC,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAsB;IAChD,OAAO,iBAAiB,IAAI,UAAU,CAAC;AACzC,CAAC;AAED,SAAS,cAAc,CAAC,CAAkB;IACxC,MAAM,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,GAAG,CAAC,CAAC;IAC7D,OAAO;QACL,oBAAoB;QACpB,wBAAwB;KACzB,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAqB;IAC7C,OAAO;QACL,oBAAoB,EAAE,CAAC,CAAC,oBAAoB;QAC5C,wBAAwB,EAAE,CAAC,CAAC,wBAAwB;KACrD,CAAC;AACJ,CAAC;AAED,SAAgB,kBAAkB,CAAC,OAAgB,EAAE,UAAsB;IACzE,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/D,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,UAAU,CAAC,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;AACH,CAAC;AAED,SAAgB,oBAAoB,CAAC,UAAsB,EAAE,OAAgB;IAC3E,IAAI,kBAAkB,CAAC,UAAU,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/D,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC;YAC/B,OAAO,CAAC,eAAe,GAAG,gBAAgB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;AACH,CAAC"}
|
package/lib/bridge/sync.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,2CAA2C,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAUhE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,2CAA2C,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAUhE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAmEvD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,GACzC,eAAe,CAAC,aAAa,CAAC,CA2GhC"}
|
package/lib/bridge/sync.js
CHANGED
|
@@ -13,6 +13,7 @@ const getBalance_1 = require("../common-logic/account/getBalance");
|
|
|
13
13
|
const config_1 = __importDefault(require("../config"));
|
|
14
14
|
const signer_1 = __importDefault(require("../signer"));
|
|
15
15
|
const onboard_1 = require("./onboard");
|
|
16
|
+
const helpers_1 = require("../helpers");
|
|
16
17
|
const txInfoToOperationAdapter = (accountId, partyId) => (txInfo) => {
|
|
17
18
|
const { transaction_hash, uid, block: { height, hash }, senders, recipients, transaction_timestamp, fee: { value: fee }, transfers: [{ value: transferValue, details }], } = txInfo;
|
|
18
19
|
let type = "UNKNOWN";
|
|
@@ -111,10 +112,15 @@ function makeGetAccountShape(signerContext) {
|
|
|
111
112
|
const newOperations = filterOperations(transactionData.operations, accountId, xpubOrAddress);
|
|
112
113
|
operations = (0, jsHelpers_1.mergeOps)(oldOperations, newOperations);
|
|
113
114
|
}
|
|
114
|
-
const
|
|
115
|
-
|
|
116
|
-
:
|
|
117
|
-
|
|
115
|
+
const used = !(0, helpers_1.isCantonAccountEmpty)({
|
|
116
|
+
operationsCount: operations.length,
|
|
117
|
+
balance: totalBalance,
|
|
118
|
+
subAccounts: initialAccount?.subAccounts ?? [],
|
|
119
|
+
cantonResources: {
|
|
120
|
+
instrumentUtxoCounts,
|
|
121
|
+
pendingTransferProposals,
|
|
122
|
+
},
|
|
123
|
+
});
|
|
118
124
|
const blockHeight = await (0, gateway_1.getLedgerEnd)(currency);
|
|
119
125
|
const creationDate = operations.length > 0
|
|
120
126
|
? new Date(Math.min(...operations.map(op => op.date.getTime())))
|
package/lib/bridge/sync.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":";;;;;
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":";;;;;AAkFA,kDA6GC;AA/LD,gEAAqC;AAErC,kEAAyE;AACzE,yEAAsF;AACtF,kEAAuE;AAEvE,gDAK4B;AAC5B,mEAAoF;AACpF,uDAAmC;AACnC,uDAAiC;AAEjC,uCAA+C;AAC/C,wCAAkD;AAElD,MAAM,wBAAwB,GAC5B,CAAC,SAAiB,EAAE,OAAe,EAAE,EAAE,CACvC,CAAC,MAAqB,EAAa,EAAE;IACnC,MAAM,EACJ,gBAAgB,EAChB,GAAG,EACH,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,EAAE,EACvB,OAAO,EACP,UAAU,EACV,qBAAqB,EACrB,GAAG,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,EACnB,SAAS,EAAE,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,OAAO,EAAE,CAAC,GAC/C,GAAG,MAAM,CAAC;IACX,IAAI,IAAI,GAAkB,SAAS,CAAC;IACpC,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,IAAI,aAAa,KAAK,GAAG,EAAE,CAAC;QACpD,IAAI,GAAG,MAAM,CAAC;IAChB,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,MAAM,EAAE,CAAC;QAClC,IAAI,GAAG,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,IAAI,CAAC;IAClD,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACrC,IAAI,GAAG,IAAI,CAAC;IACd,CAAC;SAAM,IAAI,MAAM,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACxC,IAAI,GAAG,cAAc,CAAC;IACxB,CAAC;IACD,IAAI,KAAK,GAAG,IAAI,sBAAS,CAAC,aAAa,CAAC,CAAC;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AAS,EAAE,aAAa,CAAC,CAAC;YAC7F,UAAU,GAAG,IAAA,oBAAQ,EAAC,aAAa,EAAE,aAAa,CAAC,CAAC;QACtD,CAAC;QAED,MAAM,IAAI,GAAG,CAAC,IAAA,8BAAoB,EAAC;YACjC,eAAe,EAAE,UAAU,CAAC,MAAM;YAClC,OAAO,EAAE,YAAY;YACrB,WAAW,EAAE,cAAc,EAAE,WAAW,IAAI,EAAE;YAC9C,eAAe,EAAE;gBACf,oBAAoB;gBACpB,wBAAwB;aACzB;SACF,CAAC,CAAC;QAEH,MAAM,WAAW,GAAG,MAAM,IAAA,sBAAY,EAAC,QAAQ,CAAC,CAAC;QAEjD,MAAM,YAAY,GAChB,UAAU,CAAC,MAAM,GAAG,CAAC;YACnB,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;YAChE,CAAC,CAAC,IAAI,IAAI,EAAE,CAAC;QAEjB,MAAM,KAAK,GAAG;YACZ,EAAE,EAAE,SAAS;YACb,IAAI,EAAE,SAAkB;YACxB,OAAO,EAAE,YAAY;YACrB,WAAW;YACX,YAAY;YACZ,YAAY,EAAE,IAAI,IAAI,EAAE;YACxB,YAAY,EAAE,OAAO;YACrB,cAAc,EAAE,OAAO;YACvB,UAAU;YACV,eAAe,EAAE,UAAU,CAAC,MAAM;YAClC,gBAAgB;YAChB,IAAI,EAAE,aAAa;YACnB,IAAI;YACJ,eAAe,EAAE;gBACf,oBAAoB;gBACpB,wBAAwB;aACzB;SACF,CAAC;QAEF,OAAO,KAAK,CAAC;IACf,CAAC,CAAC;AACJ,CAAC"}
|
package/lib/helpers.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import { CantonAccount } from "./types";
|
|
3
|
+
export declare function isCantonAccountEmpty(account: Pick<CantonAccount, "operationsCount" | "balance" | "subAccounts" | "cantonResources">): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Check if a Canton account is empty (has no operations, no balance, and no pending transfer proposals)
|
|
6
|
+
* @param account - The account to check (must be a Canton account)
|
|
7
|
+
* @returns true if the account is empty, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export declare function isAccountEmpty(account: AccountLike): boolean;
|
|
10
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,iBAAiB,GAAG,SAAS,GAAG,aAAa,GAAG,iBAAiB,CAAC,GAC9F,OAAO,CAOT;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAU5D"}
|
package/lib/helpers.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.isCantonAccountEmpty = isCantonAccountEmpty;
|
|
4
|
+
exports.isAccountEmpty = isAccountEmpty;
|
|
5
|
+
const serialization_1 = require("./bridge/serialization");
|
|
6
|
+
function isCantonAccountEmpty(account) {
|
|
7
|
+
return (account.operationsCount === 0 &&
|
|
8
|
+
account.balance.isZero() &&
|
|
9
|
+
!account.subAccounts?.length &&
|
|
10
|
+
!account.cantonResources?.pendingTransferProposals?.length);
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Check if a Canton account is empty (has no operations, no balance, and no pending transfer proposals)
|
|
14
|
+
* @param account - The account to check (must be a Canton account)
|
|
15
|
+
* @returns true if the account is empty, false otherwise
|
|
16
|
+
*/
|
|
17
|
+
function isAccountEmpty(account) {
|
|
18
|
+
if (account.type !== "Account") {
|
|
19
|
+
return false;
|
|
20
|
+
}
|
|
21
|
+
if (!(0, serialization_1.isCantonAccount)(account)) {
|
|
22
|
+
return false;
|
|
23
|
+
}
|
|
24
|
+
return isCantonAccountEmpty(account);
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":";;AAIA,oDASC;AAOD,wCAUC;AA7BD,0DAAyD;AAGzD,SAAgB,oBAAoB,CAClC,OAA+F;IAE/F,OAAO,CACL,OAAO,CAAC,eAAe,KAAK,CAAC;QAC7B,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE;QACxB,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM;QAC5B,CAAC,OAAO,CAAC,eAAe,EAAE,wBAAwB,EAAE,MAAM,CAC3D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,SAAgB,cAAc,CAAC,OAAoB;IACjD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,IAAA,+BAAe,EAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC"}
|
package/lib/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export { createBridges } from "./bridge/index";
|
|
3
3
|
export type { CantonCoinConfig } from "./config";
|
|
4
|
+
export { isAccountEmpty } from "./helpers";
|
|
5
|
+
export { isCantonAccount } from "./bridge/serialization";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
|
package/lib/index.js
CHANGED
|
@@ -14,8 +14,12 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.createBridges = void 0;
|
|
17
|
+
exports.isCantonAccount = exports.isAccountEmpty = exports.createBridges = void 0;
|
|
18
18
|
__exportStar(require("./types"), exports);
|
|
19
19
|
var index_1 = require("./bridge/index");
|
|
20
20
|
Object.defineProperty(exports, "createBridges", { enumerable: true, get: function () { return index_1.createBridges; } });
|
|
21
|
+
var helpers_1 = require("./helpers");
|
|
22
|
+
Object.defineProperty(exports, "isAccountEmpty", { enumerable: true, get: function () { return helpers_1.isAccountEmpty; } });
|
|
23
|
+
var serialization_1 = require("./bridge/serialization");
|
|
24
|
+
Object.defineProperty(exports, "isCantonAccount", { enumerable: true, get: function () { return serialization_1.isCantonAccount; } });
|
|
21
25
|
//# sourceMappingURL=index.js.map
|
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AAExB,wCAA+C;AAAtC,sGAAA,aAAa,OAAA"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAwB;AAExB,wCAA+C;AAAtC,sGAAA,aAAa,OAAA;AAEtB,qCAA2C;AAAlC,yGAAA,cAAc,OAAA;AACvB,wDAAyD;AAAhD,gHAAA,eAAe,OAAA"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { Account, AccountRaw } from "@ledgerhq/types-live";
|
|
2
|
+
import { type CantonAccount } from "../types";
|
|
3
|
+
export declare function isCantonAccount(account: Account): account is CantonAccount;
|
|
2
4
|
export declare function assignToAccountRaw(account: Account, accountRaw: AccountRaw): void;
|
|
3
5
|
export declare function assignFromAccountRaw(accountRaw: AccountRaw, account: Account): void;
|
|
4
6
|
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAChE,OAAO,EACL,KAAK,aAAa,EAInB,MAAM,UAAU,CAAC;AAElB,wBAAgB,eAAe,CAAC,OAAO,EAAE,OAAO,GAAG,OAAO,IAAI,aAAa,CAE1E;AAqBD,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAMjF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAMnF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAQA,
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../src/bridge/serialization.ts"],"names":[],"mappings":"AAQA,MAAM,UAAU,eAAe,CAAC,OAAgB;IAC9C,OAAO,iBAAiB,IAAI,OAAO,CAAC;AACtC,CAAC;AAED,SAAS,kBAAkB,CAAC,UAAsB;IAChD,OAAO,iBAAiB,IAAI,UAAU,CAAC;AACzC,CAAC;AAED,SAAS,cAAc,CAAC,CAAkB;IACxC,MAAM,EAAE,oBAAoB,EAAE,wBAAwB,EAAE,GAAG,CAAC,CAAC;IAC7D,OAAO;QACL,oBAAoB;QACpB,wBAAwB;KACzB,CAAC;AACJ,CAAC;AAED,SAAS,gBAAgB,CAAC,CAAqB;IAC7C,OAAO;QACL,oBAAoB,EAAE,CAAC,CAAC,oBAAoB;QAC5C,wBAAwB,EAAE,CAAC,CAAC,wBAAwB;KACrD,CAAC;AACJ,CAAC;AAED,MAAM,UAAU,kBAAkB,CAAC,OAAgB,EAAE,UAAsB;IACzE,IAAI,eAAe,CAAC,OAAO,CAAC,IAAI,kBAAkB,CAAC,UAAU,CAAC,EAAE,CAAC;QAC/D,IAAI,OAAO,CAAC,eAAe,EAAE,CAAC;YAC5B,UAAU,CAAC,eAAe,GAAG,cAAc,CAAC,OAAO,CAAC,eAAe,CAAC,CAAC;QACvE,CAAC;IACH,CAAC;AACH,CAAC;AAED,MAAM,UAAU,oBAAoB,CAAC,UAAsB,EAAE,OAAgB;IAC3E,IAAI,kBAAkB,CAAC,UAAU,CAAC,IAAI,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;QAC/D,IAAI,UAAU,CAAC,eAAe,EAAE,CAAC;YAC/B,OAAO,CAAC,eAAe,GAAG,gBAAgB,CAAC,UAAU,CAAC,eAAe,CAAC,CAAC;QACzE,CAAC;IACH,CAAC;AACH,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,2CAA2C,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAUhE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;
|
|
1
|
+
{"version":3,"file":"sync.d.ts","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,eAAe,EAAY,MAAM,2CAA2C,CAAC;AAEtF,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAUhE,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,UAAU,CAAC;AAmEvD,wBAAgB,mBAAmB,CACjC,aAAa,EAAE,aAAa,CAAC,YAAY,CAAC,GACzC,eAAe,CAAC,aAAa,CAAC,CA2GhC"}
|
package/lib-es/bridge/sync.js
CHANGED
|
@@ -6,7 +6,8 @@ import { getLedgerEnd, getOperations, getPendingTransferProposals, } from "../ne
|
|
|
6
6
|
import { getBalance } from "../common-logic/account/getBalance";
|
|
7
7
|
import coinConfig from "../config";
|
|
8
8
|
import resolver from "../signer";
|
|
9
|
-
import { isAccountOnboarded
|
|
9
|
+
import { isAccountOnboarded } from "./onboard";
|
|
10
|
+
import { isCantonAccountEmpty } from "../helpers";
|
|
10
11
|
const txInfoToOperationAdapter = (accountId, partyId) => (txInfo) => {
|
|
11
12
|
const { transaction_hash, uid, block: { height, hash }, senders, recipients, transaction_timestamp, fee: { value: fee }, transfers: [{ value: transferValue, details }], } = txInfo;
|
|
12
13
|
let type = "UNKNOWN";
|
|
@@ -105,10 +106,15 @@ export function makeGetAccountShape(signerContext) {
|
|
|
105
106
|
const newOperations = filterOperations(transactionData.operations, accountId, xpubOrAddress);
|
|
106
107
|
operations = mergeOps(oldOperations, newOperations);
|
|
107
108
|
}
|
|
108
|
-
const
|
|
109
|
-
|
|
110
|
-
:
|
|
111
|
-
|
|
109
|
+
const used = !isCantonAccountEmpty({
|
|
110
|
+
operationsCount: operations.length,
|
|
111
|
+
balance: totalBalance,
|
|
112
|
+
subAccounts: initialAccount?.subAccounts ?? [],
|
|
113
|
+
cantonResources: {
|
|
114
|
+
instrumentUtxoCounts,
|
|
115
|
+
pendingTransferProposals,
|
|
116
|
+
},
|
|
117
|
+
});
|
|
112
118
|
const blockHeight = await getLedgerEnd(currency);
|
|
113
119
|
const creationDate = operations.length > 0
|
|
114
120
|
? new Date(Math.min(...operations.map(op => op.date.getTime())))
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAmB,QAAQ,EAAE,MAAM,2CAA2C,CAAC;AACtF,OAAO,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAEvE,OAAO,EACL,YAAY,EACZ,aAAa,EAEb,2BAA2B,GAC5B,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,UAAU,EAAsB,MAAM,oCAAoC,CAAC;AACpF,OAAO,UAAU,MAAM,WAAW,CAAC;AACnC,OAAO,QAAQ,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"sync.js","sourceRoot":"","sources":["../../src/bridge/sync.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAErC,OAAO,EAAE,eAAe,EAAE,MAAM,wCAAwC,CAAC;AACzE,OAAO,EAAmB,QAAQ,EAA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export declare function isCantonAccountEmpty(account: Pick<CantonAccount, "operationsCount" | "balance" | "subAccounts" | "cantonResources">): boolean;
|
|
4
|
+
/**
|
|
5
|
+
* Check if a Canton account is empty (has no operations, no balance, and no pending transfer proposals)
|
|
6
|
+
* @param account - The account to check (must be a Canton account)
|
|
7
|
+
* @returns true if the account is empty, false otherwise
|
|
8
|
+
*/
|
|
9
|
+
export declare function isAccountEmpty(account: AccountLike): boolean;
|
|
10
|
+
//# sourceMappingURL=helpers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.d.ts","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAExD,OAAO,EAAE,aAAa,EAAE,MAAM,SAAS,CAAC;AAExC,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,IAAI,CAAC,aAAa,EAAE,iBAAiB,GAAG,SAAS,GAAG,aAAa,GAAG,iBAAiB,CAAC,GAC9F,OAAO,CAOT;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,OAAO,EAAE,WAAW,GAAG,OAAO,CAU5D"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { isCantonAccount } from "./bridge/serialization";
|
|
2
|
+
export function isCantonAccountEmpty(account) {
|
|
3
|
+
return (account.operationsCount === 0 &&
|
|
4
|
+
account.balance.isZero() &&
|
|
5
|
+
!account.subAccounts?.length &&
|
|
6
|
+
!account.cantonResources?.pendingTransferProposals?.length);
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Check if a Canton account is empty (has no operations, no balance, and no pending transfer proposals)
|
|
10
|
+
* @param account - The account to check (must be a Canton account)
|
|
11
|
+
* @returns true if the account is empty, false otherwise
|
|
12
|
+
*/
|
|
13
|
+
export function isAccountEmpty(account) {
|
|
14
|
+
if (account.type !== "Account") {
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
17
|
+
if (!isCantonAccount(account)) {
|
|
18
|
+
return false;
|
|
19
|
+
}
|
|
20
|
+
return isCantonAccountEmpty(account);
|
|
21
|
+
}
|
|
22
|
+
//# sourceMappingURL=helpers.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../src/helpers.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AAGzD,MAAM,UAAU,oBAAoB,CAClC,OAA+F;IAE/F,OAAO,CACL,OAAO,CAAC,eAAe,KAAK,CAAC;QAC7B,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE;QACxB,CAAC,OAAO,CAAC,WAAW,EAAE,MAAM;QAC5B,CAAC,OAAO,CAAC,eAAe,EAAE,wBAAwB,EAAE,MAAM,CAC3D,CAAC;AACJ,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,cAAc,CAAC,OAAoB;IACjD,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QAC/B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,IAAI,CAAC,eAAe,CAAC,OAAO,CAAC,EAAE,CAAC;QAC9B,OAAO,KAAK,CAAC;IACf,CAAC;IAED,OAAO,oBAAoB,CAAC,OAAO,CAAC,CAAC;AACvC,CAAC"}
|
package/lib-es/index.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export { createBridges } from "./bridge/index";
|
|
3
3
|
export type { CantonCoinConfig } from "./config";
|
|
4
|
+
export { isAccountEmpty } from "./helpers";
|
|
5
|
+
export { isCantonAccount } from "./bridge/serialization";
|
|
4
6
|
//# sourceMappingURL=index.d.ts.map
|
package/lib-es/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACjD,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
|
package/lib-es/index.js
CHANGED
package/lib-es/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AAExB,OAAO,EAAE,aAAa,EAAE,MAAM,gBAAgB,CAAC;AAE/C,OAAO,EAAE,cAAc,EAAE,MAAM,WAAW,CAAC;AAC3C,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-canton",
|
|
3
|
-
"version": "0.10.0-nightly.
|
|
3
|
+
"version": "0.10.0-nightly.20251121023744",
|
|
4
4
|
"description": "Canton coin integration",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"Ledger",
|
|
@@ -102,14 +102,14 @@
|
|
|
102
102
|
"invariant": "^2.2.4",
|
|
103
103
|
"protobufjs": "7.5.4",
|
|
104
104
|
"rxjs": "^7.8.1",
|
|
105
|
-
"@ledgerhq/coin-framework": "^6.9.0-nightly.
|
|
106
|
-
"@ledgerhq/cryptoassets": "^13.33.0-nightly.
|
|
105
|
+
"@ledgerhq/coin-framework": "^6.9.0-nightly.20251121023744",
|
|
106
|
+
"@ledgerhq/cryptoassets": "^13.33.0-nightly.20251121023744",
|
|
107
107
|
"@ledgerhq/devices": "8.7.0",
|
|
108
108
|
"@ledgerhq/errors": "^6.27.0",
|
|
109
|
-
"@ledgerhq/live-env": "^2.21.0-nightly.
|
|
110
|
-
"@ledgerhq/live-network": "^2.1.1-nightly.
|
|
109
|
+
"@ledgerhq/live-env": "^2.21.0-nightly.20251121023744",
|
|
110
|
+
"@ledgerhq/live-network": "^2.1.1-nightly.20251121023744",
|
|
111
111
|
"@ledgerhq/logs": "^6.13.0",
|
|
112
|
-
"@ledgerhq/types-live": "^6.89.0-nightly.
|
|
112
|
+
"@ledgerhq/types-live": "^6.89.0-nightly.20251121023744"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@types/invariant": "^2.2.37",
|
package/src/bridge/sync.ts
CHANGED
|
@@ -14,7 +14,8 @@ import { getBalance, type CantonBalance } from "../common-logic/account/getBalan
|
|
|
14
14
|
import coinConfig from "../config";
|
|
15
15
|
import resolver from "../signer";
|
|
16
16
|
import { CantonAccount, CantonSigner } from "../types";
|
|
17
|
-
import { isAccountOnboarded
|
|
17
|
+
import { isAccountOnboarded } from "./onboard";
|
|
18
|
+
import { isCantonAccountEmpty } from "../helpers";
|
|
18
19
|
|
|
19
20
|
const txInfoToOperationAdapter =
|
|
20
21
|
(accountId: string, partyId: string) =>
|
|
@@ -149,10 +150,15 @@ export function makeGetAccountShape(
|
|
|
149
150
|
operations = mergeOps(oldOperations, newOperations);
|
|
150
151
|
}
|
|
151
152
|
|
|
152
|
-
const
|
|
153
|
-
|
|
154
|
-
:
|
|
155
|
-
|
|
153
|
+
const used = !isCantonAccountEmpty({
|
|
154
|
+
operationsCount: operations.length,
|
|
155
|
+
balance: totalBalance,
|
|
156
|
+
subAccounts: initialAccount?.subAccounts ?? [],
|
|
157
|
+
cantonResources: {
|
|
158
|
+
instrumentUtxoCounts,
|
|
159
|
+
pendingTransferProposals,
|
|
160
|
+
},
|
|
161
|
+
});
|
|
156
162
|
|
|
157
163
|
const blockHeight = await getLedgerEnd(currency);
|
|
158
164
|
|
|
@@ -0,0 +1,361 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { TokenAccount } from "@ledgerhq/types-live";
|
|
3
|
+
import { isAccountEmpty } from "./helpers";
|
|
4
|
+
import { CantonAccount } from "./types";
|
|
5
|
+
import { createMockAccount } from "./test/fixtures";
|
|
6
|
+
|
|
7
|
+
describe("isAccountEmpty", () => {
|
|
8
|
+
const createCantonAccount = (overrides: Partial<CantonAccount> = {}): CantonAccount => {
|
|
9
|
+
const baseAccount = createMockAccount(overrides);
|
|
10
|
+
return {
|
|
11
|
+
...baseAccount,
|
|
12
|
+
cantonResources: {
|
|
13
|
+
instrumentUtxoCounts: {},
|
|
14
|
+
pendingTransferProposals: [],
|
|
15
|
+
...overrides.cantonResources,
|
|
16
|
+
},
|
|
17
|
+
};
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
describe("when account is not of type Account", () => {
|
|
21
|
+
it("should return false for TokenAccount", () => {
|
|
22
|
+
const tokenAccount: TokenAccount = {
|
|
23
|
+
type: "TokenAccount",
|
|
24
|
+
id: "token-account-id",
|
|
25
|
+
parentId: "parent-account-id",
|
|
26
|
+
token: {
|
|
27
|
+
type: "TokenCurrency",
|
|
28
|
+
id: "token-id",
|
|
29
|
+
contractAddress: "0x123",
|
|
30
|
+
name: "Test Token",
|
|
31
|
+
ticker: "TEST",
|
|
32
|
+
decimals: 18,
|
|
33
|
+
parentCurrency: {
|
|
34
|
+
id: "ethereum",
|
|
35
|
+
type: "CryptoCurrency",
|
|
36
|
+
name: "Ethereum",
|
|
37
|
+
ticker: "ETH",
|
|
38
|
+
family: "evm",
|
|
39
|
+
units: [],
|
|
40
|
+
explorerViews: [],
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
balance: new BigNumber(0),
|
|
44
|
+
spendableBalance: new BigNumber(0),
|
|
45
|
+
operationsCount: 0,
|
|
46
|
+
operations: [],
|
|
47
|
+
pendingOperations: [],
|
|
48
|
+
balanceHistoryCache: {
|
|
49
|
+
HOUR: { latestDate: null, balances: [] },
|
|
50
|
+
DAY: { latestDate: null, balances: [] },
|
|
51
|
+
WEEK: { latestDate: null, balances: [] },
|
|
52
|
+
},
|
|
53
|
+
swapHistory: [],
|
|
54
|
+
creationDate: new Date(),
|
|
55
|
+
balanceHistory: [],
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
expect(isAccountEmpty(tokenAccount)).toBe(false);
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
describe("when account is not a Canton account", () => {
|
|
63
|
+
it("should return false for non-Canton account", () => {
|
|
64
|
+
const nonCantonAccount = createMockAccount({
|
|
65
|
+
currency: {
|
|
66
|
+
...createMockAccount().currency,
|
|
67
|
+
family: "ethereum",
|
|
68
|
+
},
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
expect(isAccountEmpty(nonCantonAccount)).toBe(false);
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
describe("when account is a Canton account", () => {
|
|
76
|
+
it("should return true for empty account (zero operations, zero balance, no subAccounts, no pending proposals)", () => {
|
|
77
|
+
const emptyAccount = createCantonAccount({
|
|
78
|
+
operationsCount: 0,
|
|
79
|
+
balance: new BigNumber(0),
|
|
80
|
+
subAccounts: [],
|
|
81
|
+
cantonResources: {
|
|
82
|
+
instrumentUtxoCounts: {},
|
|
83
|
+
pendingTransferProposals: [],
|
|
84
|
+
},
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
expect(isAccountEmpty(emptyAccount)).toBe(true);
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
it("should return false when account has operations", () => {
|
|
91
|
+
const accountWithOperations = createCantonAccount({
|
|
92
|
+
operationsCount: 1,
|
|
93
|
+
balance: new BigNumber(0),
|
|
94
|
+
subAccounts: [],
|
|
95
|
+
cantonResources: {
|
|
96
|
+
instrumentUtxoCounts: {},
|
|
97
|
+
pendingTransferProposals: [],
|
|
98
|
+
},
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
expect(isAccountEmpty(accountWithOperations)).toBe(false);
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
it("should return false when account has non-zero balance", () => {
|
|
105
|
+
const accountWithBalance = createCantonAccount({
|
|
106
|
+
operationsCount: 0,
|
|
107
|
+
balance: new BigNumber(100),
|
|
108
|
+
subAccounts: [],
|
|
109
|
+
cantonResources: {
|
|
110
|
+
instrumentUtxoCounts: {},
|
|
111
|
+
pendingTransferProposals: [],
|
|
112
|
+
},
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
expect(isAccountEmpty(accountWithBalance)).toBe(false);
|
|
116
|
+
});
|
|
117
|
+
|
|
118
|
+
it("should return false when account has subAccounts", () => {
|
|
119
|
+
const accountWithSubAccounts = createCantonAccount({
|
|
120
|
+
operationsCount: 0,
|
|
121
|
+
balance: new BigNumber(0),
|
|
122
|
+
subAccounts: [
|
|
123
|
+
{
|
|
124
|
+
type: "TokenAccount",
|
|
125
|
+
id: "token-account-id",
|
|
126
|
+
parentId: "parent-id",
|
|
127
|
+
token: {
|
|
128
|
+
type: "TokenCurrency",
|
|
129
|
+
id: "token-id",
|
|
130
|
+
contractAddress: "0x123",
|
|
131
|
+
name: "Test Token",
|
|
132
|
+
ticker: "TEST",
|
|
133
|
+
decimals: 18,
|
|
134
|
+
parentCurrency: createMockAccount().currency,
|
|
135
|
+
},
|
|
136
|
+
balance: new BigNumber(0),
|
|
137
|
+
spendableBalance: new BigNumber(0),
|
|
138
|
+
operationsCount: 0,
|
|
139
|
+
operations: [],
|
|
140
|
+
pendingOperations: [],
|
|
141
|
+
balanceHistoryCache: {
|
|
142
|
+
HOUR: { latestDate: null, balances: [] },
|
|
143
|
+
DAY: { latestDate: null, balances: [] },
|
|
144
|
+
WEEK: { latestDate: null, balances: [] },
|
|
145
|
+
},
|
|
146
|
+
swapHistory: [],
|
|
147
|
+
creationDate: new Date(),
|
|
148
|
+
balanceHistory: [],
|
|
149
|
+
},
|
|
150
|
+
],
|
|
151
|
+
cantonResources: {
|
|
152
|
+
instrumentUtxoCounts: {},
|
|
153
|
+
pendingTransferProposals: [],
|
|
154
|
+
},
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
expect(isAccountEmpty(accountWithSubAccounts)).toBe(false);
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it("should return false when account has pending transfer proposals", () => {
|
|
161
|
+
const accountWithPendingProposals = createCantonAccount({
|
|
162
|
+
operationsCount: 0,
|
|
163
|
+
balance: new BigNumber(0),
|
|
164
|
+
subAccounts: [],
|
|
165
|
+
cantonResources: {
|
|
166
|
+
instrumentUtxoCounts: {},
|
|
167
|
+
pendingTransferProposals: [
|
|
168
|
+
{
|
|
169
|
+
contract_id: "contract-123",
|
|
170
|
+
sender: "sender-address",
|
|
171
|
+
receiver: "receiver-address",
|
|
172
|
+
instrument_id: "instrument-123",
|
|
173
|
+
amount: "100",
|
|
174
|
+
memo: "test memo",
|
|
175
|
+
expires_at_micros: Date.now() * 1000 + 86400000000,
|
|
176
|
+
},
|
|
177
|
+
],
|
|
178
|
+
},
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
expect(isAccountEmpty(accountWithPendingProposals)).toBe(false);
|
|
182
|
+
});
|
|
183
|
+
|
|
184
|
+
it("should return false when account has operations and balance", () => {
|
|
185
|
+
const accountWithBoth = createCantonAccount({
|
|
186
|
+
operationsCount: 5,
|
|
187
|
+
balance: new BigNumber(1000),
|
|
188
|
+
subAccounts: [],
|
|
189
|
+
cantonResources: {
|
|
190
|
+
instrumentUtxoCounts: {},
|
|
191
|
+
pendingTransferProposals: [],
|
|
192
|
+
},
|
|
193
|
+
});
|
|
194
|
+
|
|
195
|
+
expect(isAccountEmpty(accountWithBoth)).toBe(false);
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
it("should return false when account has operations and subAccounts", () => {
|
|
199
|
+
const accountWithOperationsAndSubAccounts = createCantonAccount({
|
|
200
|
+
operationsCount: 2,
|
|
201
|
+
balance: new BigNumber(0),
|
|
202
|
+
subAccounts: [
|
|
203
|
+
{
|
|
204
|
+
type: "TokenAccount",
|
|
205
|
+
id: "token-account-id",
|
|
206
|
+
parentId: "parent-id",
|
|
207
|
+
token: {
|
|
208
|
+
type: "TokenCurrency",
|
|
209
|
+
id: "token-id",
|
|
210
|
+
contractAddress: "0x123",
|
|
211
|
+
name: "Test Token",
|
|
212
|
+
ticker: "TEST",
|
|
213
|
+
decimals: 18,
|
|
214
|
+
parentCurrency: createMockAccount().currency,
|
|
215
|
+
},
|
|
216
|
+
balance: new BigNumber(0),
|
|
217
|
+
spendableBalance: new BigNumber(0),
|
|
218
|
+
operationsCount: 0,
|
|
219
|
+
operations: [],
|
|
220
|
+
pendingOperations: [],
|
|
221
|
+
balanceHistoryCache: {
|
|
222
|
+
HOUR: { latestDate: null, balances: [] },
|
|
223
|
+
DAY: { latestDate: null, balances: [] },
|
|
224
|
+
WEEK: { latestDate: null, balances: [] },
|
|
225
|
+
},
|
|
226
|
+
swapHistory: [],
|
|
227
|
+
creationDate: new Date(),
|
|
228
|
+
balanceHistory: [],
|
|
229
|
+
},
|
|
230
|
+
],
|
|
231
|
+
cantonResources: {
|
|
232
|
+
instrumentUtxoCounts: {},
|
|
233
|
+
pendingTransferProposals: [],
|
|
234
|
+
},
|
|
235
|
+
});
|
|
236
|
+
|
|
237
|
+
expect(isAccountEmpty(accountWithOperationsAndSubAccounts)).toBe(false);
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
it("should return false when account has balance and pending proposals", () => {
|
|
241
|
+
const accountWithBalanceAndProposals = createCantonAccount({
|
|
242
|
+
operationsCount: 0,
|
|
243
|
+
balance: new BigNumber(500),
|
|
244
|
+
subAccounts: [],
|
|
245
|
+
cantonResources: {
|
|
246
|
+
instrumentUtxoCounts: {},
|
|
247
|
+
pendingTransferProposals: [
|
|
248
|
+
{
|
|
249
|
+
contract_id: "contract-456",
|
|
250
|
+
sender: "sender-address",
|
|
251
|
+
receiver: "receiver-address",
|
|
252
|
+
instrument_id: "instrument-456",
|
|
253
|
+
amount: "50",
|
|
254
|
+
memo: "test memo",
|
|
255
|
+
expires_at_micros: Date.now() * 1000 + 86400000000, // 1 day from now
|
|
256
|
+
},
|
|
257
|
+
],
|
|
258
|
+
},
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
expect(isAccountEmpty(accountWithBalanceAndProposals)).toBe(false);
|
|
262
|
+
});
|
|
263
|
+
|
|
264
|
+
it("should return false when account has all non-empty indicators", () => {
|
|
265
|
+
const fullyUsedAccount = createCantonAccount({
|
|
266
|
+
operationsCount: 10,
|
|
267
|
+
balance: new BigNumber(10000),
|
|
268
|
+
subAccounts: [
|
|
269
|
+
{
|
|
270
|
+
type: "TokenAccount",
|
|
271
|
+
id: "token-account-id",
|
|
272
|
+
parentId: "parent-id",
|
|
273
|
+
token: {
|
|
274
|
+
type: "TokenCurrency",
|
|
275
|
+
id: "token-id",
|
|
276
|
+
contractAddress: "0x123",
|
|
277
|
+
name: "Test Token",
|
|
278
|
+
ticker: "TEST",
|
|
279
|
+
decimals: 18,
|
|
280
|
+
parentCurrency: createMockAccount().currency,
|
|
281
|
+
},
|
|
282
|
+
balance: new BigNumber(100),
|
|
283
|
+
spendableBalance: new BigNumber(100),
|
|
284
|
+
operationsCount: 5,
|
|
285
|
+
operations: [],
|
|
286
|
+
pendingOperations: [],
|
|
287
|
+
balanceHistoryCache: {
|
|
288
|
+
HOUR: { latestDate: null, balances: [] },
|
|
289
|
+
DAY: { latestDate: null, balances: [] },
|
|
290
|
+
WEEK: { latestDate: null, balances: [] },
|
|
291
|
+
},
|
|
292
|
+
swapHistory: [],
|
|
293
|
+
creationDate: new Date(),
|
|
294
|
+
balanceHistory: [],
|
|
295
|
+
},
|
|
296
|
+
],
|
|
297
|
+
cantonResources: {
|
|
298
|
+
instrumentUtxoCounts: {
|
|
299
|
+
"instrument-1": 5,
|
|
300
|
+
"instrument-2": 3,
|
|
301
|
+
},
|
|
302
|
+
pendingTransferProposals: [
|
|
303
|
+
{
|
|
304
|
+
contract_id: "contract-789",
|
|
305
|
+
sender: "sender-address",
|
|
306
|
+
receiver: "receiver-address",
|
|
307
|
+
instrument_id: "instrument-789",
|
|
308
|
+
amount: "200",
|
|
309
|
+
memo: "test memo",
|
|
310
|
+
expires_at_micros: Date.now() * 1000 + 86400000000, // 1 day from now
|
|
311
|
+
},
|
|
312
|
+
],
|
|
313
|
+
},
|
|
314
|
+
});
|
|
315
|
+
|
|
316
|
+
expect(isAccountEmpty(fullyUsedAccount)).toBe(false);
|
|
317
|
+
});
|
|
318
|
+
|
|
319
|
+
it("should handle undefined subAccounts", () => {
|
|
320
|
+
const accountWithUndefinedSubAccounts = createCantonAccount({
|
|
321
|
+
operationsCount: 0,
|
|
322
|
+
balance: new BigNumber(0),
|
|
323
|
+
subAccounts: undefined,
|
|
324
|
+
cantonResources: {
|
|
325
|
+
instrumentUtxoCounts: {},
|
|
326
|
+
pendingTransferProposals: [],
|
|
327
|
+
},
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
expect(isAccountEmpty(accountWithUndefinedSubAccounts)).toBe(true);
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
it("should handle empty subAccounts array", () => {
|
|
334
|
+
const accountWithEmptySubAccounts = createCantonAccount({
|
|
335
|
+
operationsCount: 0,
|
|
336
|
+
balance: new BigNumber(0),
|
|
337
|
+
subAccounts: [],
|
|
338
|
+
cantonResources: {
|
|
339
|
+
instrumentUtxoCounts: {},
|
|
340
|
+
pendingTransferProposals: [],
|
|
341
|
+
},
|
|
342
|
+
});
|
|
343
|
+
|
|
344
|
+
expect(isAccountEmpty(accountWithEmptySubAccounts)).toBe(true);
|
|
345
|
+
});
|
|
346
|
+
|
|
347
|
+
it("should handle empty pendingTransferProposals array", () => {
|
|
348
|
+
const accountWithEmptyProposals = createCantonAccount({
|
|
349
|
+
operationsCount: 0,
|
|
350
|
+
balance: new BigNumber(0),
|
|
351
|
+
subAccounts: [],
|
|
352
|
+
cantonResources: {
|
|
353
|
+
instrumentUtxoCounts: {},
|
|
354
|
+
pendingTransferProposals: [],
|
|
355
|
+
},
|
|
356
|
+
});
|
|
357
|
+
|
|
358
|
+
expect(isAccountEmpty(accountWithEmptyProposals)).toBe(true);
|
|
359
|
+
});
|
|
360
|
+
});
|
|
361
|
+
});
|
package/src/helpers.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import type { AccountLike } from "@ledgerhq/types-live";
|
|
2
|
+
import { isCantonAccount } from "./bridge/serialization";
|
|
3
|
+
import { CantonAccount } from "./types";
|
|
4
|
+
|
|
5
|
+
export function isCantonAccountEmpty(
|
|
6
|
+
account: Pick<CantonAccount, "operationsCount" | "balance" | "subAccounts" | "cantonResources">,
|
|
7
|
+
): boolean {
|
|
8
|
+
return (
|
|
9
|
+
account.operationsCount === 0 &&
|
|
10
|
+
account.balance.isZero() &&
|
|
11
|
+
!account.subAccounts?.length &&
|
|
12
|
+
!account.cantonResources?.pendingTransferProposals?.length
|
|
13
|
+
);
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Check if a Canton account is empty (has no operations, no balance, and no pending transfer proposals)
|
|
18
|
+
* @param account - The account to check (must be a Canton account)
|
|
19
|
+
* @returns true if the account is empty, false otherwise
|
|
20
|
+
*/
|
|
21
|
+
export function isAccountEmpty(account: AccountLike): boolean {
|
|
22
|
+
if (account.type !== "Account") {
|
|
23
|
+
return false;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
if (!isCantonAccount(account)) {
|
|
27
|
+
return false;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
return isCantonAccountEmpty(account);
|
|
31
|
+
}
|