@ledgerhq/coin-canton 0.9.0-nightly.3 → 0.9.0-nightly.4
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 +17 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +2 -2
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib/bridge/estimateMaxSpendable.js +2 -3
- package/lib/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib/bridge/getTransactionStatus.d.ts +5 -3
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib/bridge/getTransactionStatus.js +26 -5
- package/lib/bridge/getTransactionStatus.js.map +1 -1
- package/lib/bridge/index.d.ts +2 -2
- package/lib/bridge/index.d.ts.map +1 -1
- package/lib/bridge/index.js +3 -3
- package/lib/bridge/index.js.map +1 -1
- package/lib/bridge/prepareTransaction.js +1 -1
- package/lib/bridge/prepareTransaction.js.map +1 -1
- package/lib/bridge/serialization.d.ts +4 -0
- package/lib/bridge/serialization.d.ts.map +1 -0
- package/lib/bridge/serialization.js +36 -0
- package/lib/bridge/serialization.js.map +1 -0
- package/lib/bridge/sync.d.ts.map +1 -1
- package/lib/bridge/sync.js +13 -5
- package/lib/bridge/sync.js.map +1 -1
- package/lib/bridge/transaction.js +1 -1
- package/lib/bridge/transaction.js.map +1 -1
- package/lib/common-logic/account/getBalance.d.ts +5 -1
- package/lib/common-logic/account/getBalance.d.ts.map +1 -1
- package/lib/common-logic/account/getBalance.js +2 -0
- package/lib/common-logic/account/getBalance.js.map +1 -1
- package/lib/common-logic/transaction/craftTransaction.js +1 -1
- package/lib/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib/network/gateway.d.ts +1 -0
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.js.map +1 -1
- package/lib/test/fixtures.d.ts +5 -0
- package/lib/test/fixtures.d.ts.map +1 -0
- package/lib/test/fixtures.js +57 -0
- package/lib/test/fixtures.js.map +1 -0
- package/lib/types/bridge.d.ts +14 -2
- package/lib/types/bridge.d.ts.map +1 -1
- package/lib/types/errors.d.ts +6 -0
- package/lib/types/errors.d.ts.map +1 -1
- package/lib/types/errors.js +3 -1
- package/lib/types/errors.js.map +1 -1
- package/lib/types/index.d.ts +1 -0
- package/lib/types/index.d.ts.map +1 -1
- package/lib/types/index.js +1 -0
- package/lib/types/index.js.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.d.ts +2 -2
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -1
- package/lib-es/bridge/estimateMaxSpendable.js +2 -3
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -1
- package/lib-es/bridge/getTransactionStatus.d.ts +5 -3
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -1
- package/lib-es/bridge/getTransactionStatus.js +26 -5
- package/lib-es/bridge/getTransactionStatus.js.map +1 -1
- package/lib-es/bridge/index.d.ts +2 -2
- package/lib-es/bridge/index.d.ts.map +1 -1
- package/lib-es/bridge/index.js +3 -3
- package/lib-es/bridge/index.js.map +1 -1
- package/lib-es/bridge/prepareTransaction.js +1 -1
- package/lib-es/bridge/prepareTransaction.js.map +1 -1
- package/lib-es/bridge/serialization.d.ts +4 -0
- package/lib-es/bridge/serialization.d.ts.map +1 -0
- package/lib-es/bridge/serialization.js +32 -0
- package/lib-es/bridge/serialization.js.map +1 -0
- package/lib-es/bridge/sync.d.ts.map +1 -1
- package/lib-es/bridge/sync.js +13 -5
- package/lib-es/bridge/sync.js.map +1 -1
- package/lib-es/bridge/transaction.js +1 -1
- package/lib-es/bridge/transaction.js.map +1 -1
- package/lib-es/common-logic/account/getBalance.d.ts +5 -1
- package/lib-es/common-logic/account/getBalance.d.ts.map +1 -1
- package/lib-es/common-logic/account/getBalance.js +2 -0
- package/lib-es/common-logic/account/getBalance.js.map +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.js +1 -1
- package/lib-es/common-logic/transaction/craftTransaction.js.map +1 -1
- package/lib-es/network/gateway.d.ts +1 -0
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.js.map +1 -1
- package/lib-es/test/fixtures.d.ts +5 -0
- package/lib-es/test/fixtures.d.ts.map +1 -0
- package/lib-es/test/fixtures.js +49 -0
- package/lib-es/test/fixtures.js.map +1 -0
- package/lib-es/types/bridge.d.ts +14 -2
- package/lib-es/types/bridge.d.ts.map +1 -1
- package/lib-es/types/errors.d.ts +6 -0
- package/lib-es/types/errors.d.ts.map +1 -1
- package/lib-es/types/errors.js +2 -0
- package/lib-es/types/errors.js.map +1 -1
- package/lib-es/types/index.d.ts +1 -0
- package/lib-es/types/index.d.ts.map +1 -1
- package/lib-es/types/index.js +1 -0
- package/lib-es/types/index.js.map +1 -1
- package/package.json +6 -6
- package/src/bridge/estimateMaxSpendable.ts +6 -8
- package/src/bridge/getTransactionStatus.test.ts +84 -146
- package/src/bridge/getTransactionStatus.ts +42 -7
- package/src/bridge/index.ts +6 -5
- package/src/bridge/onboard.integ.test.ts +8 -31
- package/src/bridge/prepareTransaction.ts +1 -1
- package/src/bridge/serialization.ts +44 -0
- package/src/bridge/signOperation.test.ts +3 -9
- package/src/bridge/sync.test.ts +4 -0
- package/src/bridge/sync.ts +17 -6
- package/src/bridge/transaction.ts +1 -1
- package/src/common-logic/account/getBalance.ts +12 -2
- package/src/common-logic/account/getBalance.unit.test.ts +7 -1
- package/src/common-logic/transaction/craftTransaction.ts +1 -1
- package/src/network/gateway.ts +1 -0
- package/src/test/fixtures.ts +53 -0
- package/src/types/bridge.ts +15 -2
- package/src/types/errors.ts +3 -0
- package/src/types/index.ts +1 -0
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gateway.js","sourceRoot":"","sources":["../../src/network/gateway.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,wBAAwB,CAAC;AAE7C,OAAO,EAAE,MAAM,EAAE,MAA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AAU,EAA8B,EAC1C,SAAiB;IAEjB,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,cAAc,CAAsD;QACzF,MAAM,EAAE,MAAM;QACd,GAAG,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAY,SAAS,CAAC,QAAQ,CAAC,UAAU,OAAO,qBAAqB;QACpG,IAAI,EAAE;YACJ,UAAU;YACV,SAAS;SACV;KACF,CAAC,CAAC;IAEH,OAAO;QACL,UAAU,EAAE,IAAI;QAChB,YAAY,EAAE,IAAI,CAAC,aAAa;QAChC,QAAQ,EAAE,IAAI,CAAC,SAAS;KACG,CAAC;AAChC,CAAC;AAWD,MAAM,CAAC,KAAK,UAAU,sBAAsB,CAAC,QAAwB,EAAE,OAAe;IACpF,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,cAAc,CAAiC;QACpE,MAAM,EAAE,KAAK;QACb,GAAG,EAAE,GAAG,aAAa,CAAC,QAAQ,CAAC,YAAY,SAAS,CAAC,QAAQ,CAAC,UAAU,OAAO,uBAAuB;KACvG,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Account } from "@ledgerhq/types-live";
|
|
2
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
export declare const createMockCantonCurrency: () => CryptoCurrency;
|
|
4
|
+
export declare const createMockAccount: (overrides?: Partial<Account>) => Account;
|
|
5
|
+
//# sourceMappingURL=fixtures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.d.ts","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAI9D,eAAO,MAAM,wBAAwB,QAAO,cAe3C,CAAC;AAEF,eAAO,MAAM,iBAAiB,GAAI,YAAW,OAAO,CAAC,OAAO,CAAM,KAAG,OA6BpE,CAAC"}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { getDerivationScheme, runDerivationScheme } from "@ledgerhq/coin-framework/derivation";
|
|
3
|
+
import { createEmptyHistoryCache } from "@ledgerhq/coin-framework/account";
|
|
4
|
+
export const createMockCantonCurrency = () => {
|
|
5
|
+
const mockCurrency = {
|
|
6
|
+
id: "canton_network",
|
|
7
|
+
name: "Canton",
|
|
8
|
+
type: "CryptoCurrency",
|
|
9
|
+
family: "canton",
|
|
10
|
+
units: [{ name: "Canton", code: "CANTON", magnitude: 38 }],
|
|
11
|
+
ticker: "CANTON",
|
|
12
|
+
scheme: "canton",
|
|
13
|
+
color: "#000000",
|
|
14
|
+
managerAppName: "Canton",
|
|
15
|
+
coinType: 6767,
|
|
16
|
+
explorerViews: [],
|
|
17
|
+
};
|
|
18
|
+
return mockCurrency;
|
|
19
|
+
};
|
|
20
|
+
export const createMockAccount = (overrides = {}) => {
|
|
21
|
+
const currency = createMockCantonCurrency();
|
|
22
|
+
const derivationMode = "canton";
|
|
23
|
+
const scheme = getDerivationScheme({ derivationMode, currency });
|
|
24
|
+
const freshAddressPath = runDerivationScheme(scheme, currency, { account: 0 });
|
|
25
|
+
return {
|
|
26
|
+
id: "js:2:canton_network:test-address:canton",
|
|
27
|
+
type: "Account",
|
|
28
|
+
used: true,
|
|
29
|
+
currency,
|
|
30
|
+
derivationMode,
|
|
31
|
+
index: 0,
|
|
32
|
+
freshAddress: "test_address",
|
|
33
|
+
freshAddressPath,
|
|
34
|
+
creationDate: new Date(),
|
|
35
|
+
lastSyncDate: new Date(),
|
|
36
|
+
balance: new BigNumber(0),
|
|
37
|
+
spendableBalance: new BigNumber(0),
|
|
38
|
+
seedIdentifier: "test_seed",
|
|
39
|
+
blockHeight: 0,
|
|
40
|
+
operationsCount: 0,
|
|
41
|
+
operations: [],
|
|
42
|
+
pendingOperations: [],
|
|
43
|
+
balanceHistoryCache: createEmptyHistoryCache(),
|
|
44
|
+
swapHistory: [],
|
|
45
|
+
subAccounts: [],
|
|
46
|
+
...overrides,
|
|
47
|
+
};
|
|
48
|
+
};
|
|
49
|
+
//# sourceMappingURL=fixtures.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fixtures.js","sourceRoot":"","sources":["../../src/test/fixtures.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,EAAE,mBAAmB,EAAE,mBAAmB,EAAE,MAAM,qCAAqC,CAAC;AAC/F,OAAO,EAAE,uBAAuB,EAAE,MAAM,kCAAkC,CAAC;AAE3E,MAAM,CAAC,MAAM,wBAAwB,GAAG,GAAmB,EAAE;IAC3D,MAAM,YAAY,GAAG;QACnB,EAAE,EAAE,gBAAgB;QACpB,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,gBAAgB;QACtB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,QAAQ,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC;QAC1D,MAAM,EAAE,QAAQ;QAChB,MAAM,EAAE,QAAQ;QAChB,KAAK,EAAE,SAAS;QAChB,cAAc,EAAE,QAAQ;QACxB,QAAQ,EAAE,IAAI;QACd,aAAa,EAAE,EAAE;KACO,CAAC;IAC3B,OAAO,YAAY,CAAC;AACtB,CAAC,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAG,CAAC,YAA8B,EAAE,EAAW,EAAE;IAC7E,MAAM,QAAQ,GAAG,wBAAwB,EAAE,CAAC;IAC5C,MAAM,cAAc,GAAG,QAAiB,CAAC;IACzC,MAAM,MAAM,GAAG,mBAAmB,CAAC,EAAE,cAAc,EAAE,QAAQ,EAAE,CAAC,CAAC;IACjE,MAAM,gBAAgB,GAAG,mBAAmB,CAAC,MAAM,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC,CAAC;IAE/E,OAAO;QACL,EAAE,EAAE,yCAAyC;QAC7C,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,IAAI;QACV,QAAQ;QACR,cAAc;QACd,KAAK,EAAE,CAAC;QACR,YAAY,EAAE,cAAc;QAC5B,gBAAgB;QAChB,YAAY,EAAE,IAAI,IAAI,EAAE;QACxB,YAAY,EAAE,IAAI,IAAI,EAAE;QACxB,OAAO,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;QACzB,gBAAgB,EAAE,IAAI,SAAS,CAAC,CAAC,CAAC;QAClC,cAAc,EAAE,WAAW;QAC3B,WAAW,EAAE,CAAC;QACd,eAAe,EAAE,CAAC;QAClB,UAAU,EAAE,EAAE;QACd,iBAAiB,EAAE,EAAE;QACrB,mBAAmB,EAAE,uBAAuB,EAAE;QAC9C,WAAW,EAAE,EAAE;QACf,WAAW,EAAE,EAAE;QACf,GAAG,SAAS;KACb,CAAC;AACJ,CAAC,CAAC"}
|
package/lib-es/types/bridge.d.ts
CHANGED
|
@@ -22,15 +22,27 @@ export type Transaction = TransactionCommon & {
|
|
|
22
22
|
fee: BigNumber | null | undefined;
|
|
23
23
|
memo?: string;
|
|
24
24
|
tokenId: string;
|
|
25
|
+
expireInSeconds?: number;
|
|
25
26
|
};
|
|
26
27
|
export type TransactionRaw = TransactionCommonRaw & {
|
|
27
28
|
family: "canton";
|
|
28
29
|
fee: string | null | undefined;
|
|
29
30
|
memo?: string;
|
|
30
31
|
tokenId: string;
|
|
32
|
+
expireInSeconds?: number;
|
|
31
33
|
};
|
|
32
34
|
export type TransactionStatus = TransactionStatusCommon;
|
|
33
35
|
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
34
|
-
export type
|
|
35
|
-
|
|
36
|
+
export type CantonResources = {
|
|
37
|
+
instrumentUtxoCounts: Record<string, number>;
|
|
38
|
+
};
|
|
39
|
+
export type CantonResourcesRaw = {
|
|
40
|
+
instrumentUtxoCounts: Record<string, number>;
|
|
41
|
+
};
|
|
42
|
+
export type CantonAccount = Account & {
|
|
43
|
+
cantonResources: CantonResources;
|
|
44
|
+
};
|
|
45
|
+
export type CantonAccountRaw = AccountRaw & {
|
|
46
|
+
cantonResources: CantonResourcesRaw;
|
|
47
|
+
};
|
|
36
48
|
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC9C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AACvC,OAAO,KAAK,EACV,OAAO,EACP,UAAU,EACV,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,KAAK,EACV,qBAAqB,EACrB,mBAAmB,EACnB,uBAAuB,EACvB,qBAAqB,EACtB,MAAM,WAAW,CAAC;AAEnB,MAAM,WAAW,oBAAqB,SAAQ,cAAc;IAC1D,cAAc,EAAE,CACd,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,OAAO,KACtB,UAAU,CAAC,qBAAqB,GAAG,mBAAmB,CAAC,CAAC;IAC7D,oBAAoB,EAAE,CACpB,QAAQ,EAAE,cAAc,EACxB,QAAQ,EAAE,MAAM,EAChB,gBAAgB,EAAE,OAAO,EACzB,OAAO,EAAE,MAAM,KACZ,UAAU,CAAC,uBAAuB,GAAG,qBAAqB,CAAC,CAAC;CAClE;AAED,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,QAAQ,CAAC;IACjB,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,SAAS,CAAC;CACxB,CAAC;AA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1,10 @@
|
|
|
1
1
|
export declare const SimulationError: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
2
2
|
[key: string]: unknown;
|
|
3
3
|
}>;
|
|
4
|
+
export declare const TooManyUtxosCritical: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
5
|
+
[key: string]: unknown;
|
|
6
|
+
}>;
|
|
7
|
+
export declare const TooManyUtxosWarning: import("@ledgerhq/errors/lib/helpers").LedgerErrorConstructor<{
|
|
8
|
+
[key: string]: unknown;
|
|
9
|
+
}>;
|
|
4
10
|
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;EAA4C,CAAC"}
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,eAAe;;EAA4C,CAAC;AAEzE,eAAO,MAAM,oBAAoB;;EAAiD,CAAC;AACnF,eAAO,MAAM,mBAAmB;;EAAgD,CAAC"}
|
package/lib-es/types/errors.js
CHANGED
|
@@ -1,3 +1,5 @@
|
|
|
1
1
|
import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
2
2
|
export const SimulationError = createCustomErrorClass("SimulationError");
|
|
3
|
+
export const TooManyUtxosCritical = createCustomErrorClass("TooManyUtxosCritical");
|
|
4
|
+
export const TooManyUtxosWarning = createCustomErrorClass("TooManyUtxosWarning");
|
|
3
5
|
//# sourceMappingURL=errors.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC"}
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../../src/types/errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,CAAC,MAAM,eAAe,GAAG,sBAAsB,CAAC,iBAAiB,CAAC,CAAC;AAEzE,MAAM,CAAC,MAAM,oBAAoB,GAAG,sBAAsB,CAAC,sBAAsB,CAAC,CAAC;AACnF,MAAM,CAAC,MAAM,mBAAmB,GAAG,sBAAsB,CAAC,qBAAqB,CAAC,CAAC"}
|
package/lib-es/types/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/lib-es/types/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,WAAW,CAAC;AAC1B,cAAc,UAAU,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ledgerhq/coin-canton",
|
|
3
|
-
"version": "0.9.0-nightly.
|
|
3
|
+
"version": "0.9.0-nightly.4",
|
|
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.8.0-nightly.
|
|
106
|
-
"@ledgerhq/cryptoassets": "^13.32.0-nightly.
|
|
105
|
+
"@ledgerhq/coin-framework": "^6.8.0-nightly.4",
|
|
106
|
+
"@ledgerhq/cryptoassets": "^13.32.0-nightly.2",
|
|
107
107
|
"@ledgerhq/devices": "8.6.2-nightly.0",
|
|
108
108
|
"@ledgerhq/errors": "^6.27.0-nightly.0",
|
|
109
|
-
"@ledgerhq/live-env": "^2.
|
|
110
|
-
"@ledgerhq/live-network": "^2.1.0-nightly.
|
|
109
|
+
"@ledgerhq/live-env": "^2.20.0-nightly.0",
|
|
110
|
+
"@ledgerhq/live-network": "^2.1.0-nightly.1",
|
|
111
111
|
"@ledgerhq/logs": "^6.13.0",
|
|
112
|
-
"@ledgerhq/types-live": "^6.88.0-nightly.
|
|
112
|
+
"@ledgerhq/types-live": "^6.88.0-nightly.2"
|
|
113
113
|
},
|
|
114
114
|
"devDependencies": {
|
|
115
115
|
"@types/invariant": "^2.2.37",
|
|
@@ -5,19 +5,17 @@ import { getAbandonSeedAddress } from "@ledgerhq/cryptoassets/abandonseed";
|
|
|
5
5
|
import { getTransactionStatus } from "./getTransactionStatus";
|
|
6
6
|
import { prepareTransaction } from "./prepareTransaction";
|
|
7
7
|
import { createTransaction } from "./createTransaction";
|
|
8
|
-
import { Transaction } from "../types";
|
|
8
|
+
import { Transaction, CantonAccount } from "../types";
|
|
9
9
|
|
|
10
|
-
export const estimateMaxSpendable: AccountBridge<
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
}) => {
|
|
10
|
+
export const estimateMaxSpendable: AccountBridge<
|
|
11
|
+
Transaction,
|
|
12
|
+
CantonAccount
|
|
13
|
+
>["estimateMaxSpendable"] = async ({ account, parentAccount, transaction }) => {
|
|
15
14
|
const mainAccount = getMainAccount(account, parentAccount);
|
|
16
15
|
const newTransaction = await prepareTransaction(mainAccount, {
|
|
17
16
|
...createTransaction(account),
|
|
18
17
|
...transaction,
|
|
19
|
-
|
|
20
|
-
recipient: transaction?.recipient || getAbandonSeedAddress("boilerplate"),
|
|
18
|
+
recipient: transaction?.recipient || getAbandonSeedAddress("canton_network"),
|
|
21
19
|
amount: new BigNumber(0),
|
|
22
20
|
});
|
|
23
21
|
const status = await getTransactionStatus(mainAccount, newTransaction);
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
import BigNumber from "bignumber.js";
|
|
2
|
-
import { Account } from "@ledgerhq/types-live";
|
|
3
|
-
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
1
|
import {
|
|
5
2
|
AmountRequired,
|
|
6
3
|
FeeNotLoaded,
|
|
@@ -12,76 +9,37 @@ import {
|
|
|
12
9
|
NotEnoughSpendableBalance,
|
|
13
10
|
RecipientRequired,
|
|
14
11
|
} from "@ledgerhq/errors";
|
|
15
|
-
import
|
|
16
|
-
import { Transaction } from "../types";
|
|
12
|
+
import BigNumber from "bignumber.js";
|
|
17
13
|
import coinConfig from "../config";
|
|
14
|
+
import { createMockAccount } from "../test/fixtures";
|
|
15
|
+
import { CantonAccount, TooManyUtxosCritical, TooManyUtxosWarning, Transaction } from "../types";
|
|
16
|
+
import {
|
|
17
|
+
getTransactionStatus,
|
|
18
|
+
TO_MANY_UTXOS_CRITICAL_COUNT,
|
|
19
|
+
TO_MANY_UTXOS_WARNING_COUNT,
|
|
20
|
+
} from "./getTransactionStatus";
|
|
18
21
|
|
|
19
|
-
|
|
20
|
-
jest.mock("../config", () => ({
|
|
21
|
-
getCoinConfig: jest.fn(),
|
|
22
|
-
}));
|
|
23
|
-
|
|
22
|
+
jest.mock("../config", () => ({ getCoinConfig: jest.fn() }));
|
|
24
23
|
const mockCoinConfig = jest.mocked(coinConfig);
|
|
25
24
|
|
|
26
25
|
describe("getTransactionStatus", () => {
|
|
27
|
-
const
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
26
|
+
const mockAccount: CantonAccount = {
|
|
27
|
+
...createMockAccount({
|
|
28
|
+
balance: new BigNumber(1000),
|
|
29
|
+
spendableBalance: new BigNumber(1000),
|
|
30
|
+
freshAddress: "test::33333333333333333333333333333333333333333333333333333333333333333333",
|
|
31
|
+
}),
|
|
32
|
+
cantonResources: {
|
|
33
|
+
instrumentUtxoCounts: {
|
|
34
|
+
Amulet: 5,
|
|
36
35
|
},
|
|
37
|
-
],
|
|
38
|
-
ticker: "CANTON",
|
|
39
|
-
scheme: "canton",
|
|
40
|
-
color: "#000000",
|
|
41
|
-
type: "CryptoCurrency",
|
|
42
|
-
managerAppName: "Canton",
|
|
43
|
-
coinType: 0,
|
|
44
|
-
disableCountervalue: false,
|
|
45
|
-
delisted: false,
|
|
46
|
-
keywords: ["canton"],
|
|
47
|
-
explorerViews: [],
|
|
48
|
-
terminated: {
|
|
49
|
-
link: "",
|
|
50
36
|
},
|
|
51
37
|
};
|
|
52
38
|
|
|
53
|
-
const mockAccount: Account = {
|
|
54
|
-
id: "test-account-id",
|
|
55
|
-
seedIdentifier: "test-seed-identifier",
|
|
56
|
-
currency: mockCurrency,
|
|
57
|
-
balance: new BigNumber(1000), // 1000 units
|
|
58
|
-
spendableBalance: new BigNumber(1000),
|
|
59
|
-
freshAddress: "test::33333333333333333333333333333333333333333333333333333333333333333333",
|
|
60
|
-
freshAddressPath: "44'/60'/0'/0/0",
|
|
61
|
-
index: 0,
|
|
62
|
-
derivationMode: "canton",
|
|
63
|
-
used: true,
|
|
64
|
-
operations: [],
|
|
65
|
-
pendingOperations: [],
|
|
66
|
-
lastSyncDate: new Date(),
|
|
67
|
-
creationDate: new Date(),
|
|
68
|
-
operationsCount: 0,
|
|
69
|
-
blockHeight: 100,
|
|
70
|
-
balanceHistoryCache: {
|
|
71
|
-
HOUR: { latestDate: null, balances: [] },
|
|
72
|
-
DAY: { latestDate: null, balances: [] },
|
|
73
|
-
WEEK: { latestDate: null, balances: [] },
|
|
74
|
-
},
|
|
75
|
-
swapHistory: [],
|
|
76
|
-
nfts: [],
|
|
77
|
-
subAccounts: [],
|
|
78
|
-
type: "Account",
|
|
79
|
-
};
|
|
80
|
-
|
|
81
39
|
beforeEach(() => {
|
|
82
40
|
jest.clearAllMocks();
|
|
83
41
|
mockCoinConfig.getCoinConfig.mockReturnValue({
|
|
84
|
-
minReserve: 100,
|
|
42
|
+
minReserve: 100,
|
|
85
43
|
networkType: "mainnet",
|
|
86
44
|
status: { type: "active" },
|
|
87
45
|
nativeInstrumentId: "Amulet",
|
|
@@ -122,9 +80,9 @@ describe("getTransactionStatus", () => {
|
|
|
122
80
|
it("should add FeeTooHigh warning when fee is more than 10 times the amount", async () => {
|
|
123
81
|
const transaction: Transaction = {
|
|
124
82
|
family: "canton",
|
|
125
|
-
amount: new BigNumber(100),
|
|
83
|
+
amount: new BigNumber(100),
|
|
126
84
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
127
|
-
fee: new BigNumber(1500),
|
|
85
|
+
fee: new BigNumber(1500),
|
|
128
86
|
tokenId: "",
|
|
129
87
|
};
|
|
130
88
|
|
|
@@ -139,7 +97,7 @@ describe("getTransactionStatus", () => {
|
|
|
139
97
|
family: "canton",
|
|
140
98
|
amount: new BigNumber(100),
|
|
141
99
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
142
|
-
fee: new BigNumber(10),
|
|
100
|
+
fee: new BigNumber(10),
|
|
143
101
|
tokenId: "",
|
|
144
102
|
};
|
|
145
103
|
|
|
@@ -154,7 +112,9 @@ describe("getTransactionStatus", () => {
|
|
|
154
112
|
it("should return NotEnoughSpendableBalance error when total spent exceeds balance minus reserve", async () => {
|
|
155
113
|
const transaction: Transaction = {
|
|
156
114
|
family: "canton",
|
|
157
|
-
amount:
|
|
115
|
+
amount: mockAccount.balance
|
|
116
|
+
.minus(new BigNumber(mockCoinConfig.getCoinConfig().minReserve))
|
|
117
|
+
.plus(1),
|
|
158
118
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
159
119
|
fee: new BigNumber(10),
|
|
160
120
|
tokenId: "",
|
|
@@ -168,7 +128,7 @@ describe("getTransactionStatus", () => {
|
|
|
168
128
|
it("should return NotEnoughBalanceBecauseDestinationNotCreated error when amount is below reserve", async () => {
|
|
169
129
|
const transaction: Transaction = {
|
|
170
130
|
family: "canton",
|
|
171
|
-
amount: new BigNumber(
|
|
131
|
+
amount: new BigNumber(mockCoinConfig.getCoinConfig().minReserve).minus(1),
|
|
172
132
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
173
133
|
fee: new BigNumber(10),
|
|
174
134
|
tokenId: "",
|
|
@@ -182,7 +142,7 @@ describe("getTransactionStatus", () => {
|
|
|
182
142
|
it("should pass balance validation when transaction is within limits", async () => {
|
|
183
143
|
const transaction: Transaction = {
|
|
184
144
|
family: "canton",
|
|
185
|
-
amount:
|
|
145
|
+
amount: mockAccount.balance.multipliedBy(0.5),
|
|
186
146
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
187
147
|
fee: new BigNumber(10),
|
|
188
148
|
tokenId: "",
|
|
@@ -209,18 +169,18 @@ describe("getTransactionStatus", () => {
|
|
|
209
169
|
expect(result.errors.recipient).toBeInstanceOf(RecipientRequired);
|
|
210
170
|
});
|
|
211
171
|
|
|
212
|
-
it("should return
|
|
172
|
+
it("should not return error when sending to self", async () => {
|
|
213
173
|
const transaction: Transaction = {
|
|
214
174
|
family: "canton",
|
|
215
175
|
amount: new BigNumber(100),
|
|
216
|
-
recipient:
|
|
176
|
+
recipient: mockAccount.freshAddress,
|
|
217
177
|
fee: new BigNumber(10),
|
|
218
178
|
tokenId: "",
|
|
219
179
|
};
|
|
220
180
|
|
|
221
181
|
const result = await getTransactionStatus(mockAccount, transaction);
|
|
222
182
|
|
|
223
|
-
expect(result.errors.recipient).
|
|
183
|
+
expect(result.errors.recipient).toBeUndefined();
|
|
224
184
|
});
|
|
225
185
|
|
|
226
186
|
it("should return InvalidAddress error when recipient is invalid", async () => {
|
|
@@ -254,16 +214,8 @@ describe("getTransactionStatus", () => {
|
|
|
254
214
|
|
|
255
215
|
describe("amount validation", () => {
|
|
256
216
|
it("should return AmountRequired error when amount is zero", async () => {
|
|
257
|
-
// Create a scenario where there are no other amount errors
|
|
258
|
-
// Use a high balance and amount above reserve to avoid other amount errors
|
|
259
|
-
const accountWithHighBalance = {
|
|
260
|
-
...mockAccount,
|
|
261
|
-
balance: new BigNumber(10000), // High balance to avoid balance errors
|
|
262
|
-
};
|
|
263
|
-
|
|
264
|
-
// Set a high reserve to avoid the NotEnoughBalanceBecauseDestinationNotCreated error
|
|
265
217
|
mockCoinConfig.getCoinConfig.mockReturnValue({
|
|
266
|
-
minReserve: 0,
|
|
218
|
+
minReserve: 0,
|
|
267
219
|
networkType: "mainnet",
|
|
268
220
|
status: { type: "active" },
|
|
269
221
|
nativeInstrumentId: "Amulet",
|
|
@@ -277,7 +229,7 @@ describe("getTransactionStatus", () => {
|
|
|
277
229
|
tokenId: "",
|
|
278
230
|
};
|
|
279
231
|
|
|
280
|
-
const result = await getTransactionStatus(
|
|
232
|
+
const result = await getTransactionStatus(mockAccount, transaction);
|
|
281
233
|
|
|
282
234
|
expect(result.errors.amount).toBeInstanceOf(AmountRequired);
|
|
283
235
|
});
|
|
@@ -330,11 +282,15 @@ describe("getTransactionStatus", () => {
|
|
|
330
282
|
});
|
|
331
283
|
});
|
|
332
284
|
|
|
333
|
-
describe("
|
|
334
|
-
it("should
|
|
335
|
-
const
|
|
285
|
+
describe("UTXO count validation", () => {
|
|
286
|
+
it("should show critical warning when UTXO count exceeds TO_MANY_UTXOS_CRITICAL_COUNT", async () => {
|
|
287
|
+
const accountWithTooManyUtxos = {
|
|
336
288
|
...mockAccount,
|
|
337
|
-
|
|
289
|
+
cantonResources: {
|
|
290
|
+
instrumentUtxoCounts: {
|
|
291
|
+
Amulet: TO_MANY_UTXOS_CRITICAL_COUNT + 1,
|
|
292
|
+
},
|
|
293
|
+
},
|
|
338
294
|
};
|
|
339
295
|
|
|
340
296
|
const transaction: Transaction = {
|
|
@@ -342,18 +298,23 @@ describe("getTransactionStatus", () => {
|
|
|
342
298
|
amount: new BigNumber(50),
|
|
343
299
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
344
300
|
fee: new BigNumber(10),
|
|
345
|
-
tokenId: "",
|
|
301
|
+
tokenId: "Amulet",
|
|
346
302
|
};
|
|
347
303
|
|
|
348
|
-
const result = await getTransactionStatus(
|
|
304
|
+
const result = await getTransactionStatus(accountWithTooManyUtxos, transaction);
|
|
349
305
|
|
|
350
|
-
expect(result.
|
|
306
|
+
expect(result.warnings.tooManyUtxos).toBeDefined();
|
|
307
|
+
expect(result.warnings.tooManyUtxos).toBeInstanceOf(TooManyUtxosCritical);
|
|
351
308
|
});
|
|
352
309
|
|
|
353
|
-
it("should
|
|
354
|
-
const
|
|
310
|
+
it("should show warning when UTXO count exceeds TO_MANY_UTXOS_WARNING_COUNT", async () => {
|
|
311
|
+
const accountWithManyUtxos = {
|
|
355
312
|
...mockAccount,
|
|
356
|
-
|
|
313
|
+
cantonResources: {
|
|
314
|
+
instrumentUtxoCounts: {
|
|
315
|
+
Amulet: TO_MANY_UTXOS_WARNING_COUNT + 1,
|
|
316
|
+
},
|
|
317
|
+
},
|
|
357
318
|
};
|
|
358
319
|
|
|
359
320
|
const transaction: Transaction = {
|
|
@@ -361,86 +322,63 @@ describe("getTransactionStatus", () => {
|
|
|
361
322
|
amount: new BigNumber(50),
|
|
362
323
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
363
324
|
fee: new BigNumber(10),
|
|
364
|
-
tokenId: "",
|
|
325
|
+
tokenId: "Amulet",
|
|
365
326
|
};
|
|
366
327
|
|
|
367
|
-
const result = await getTransactionStatus(
|
|
328
|
+
const result = await getTransactionStatus(accountWithManyUtxos, transaction);
|
|
368
329
|
|
|
369
|
-
expect(result.
|
|
330
|
+
expect(result.warnings.tooManyUtxos).toBeDefined();
|
|
331
|
+
expect(result.warnings.tooManyUtxos).toBeInstanceOf(TooManyUtxosWarning);
|
|
332
|
+
expect(result.warnings.tooManyUtxos?.message).toContain(
|
|
333
|
+
"families.canton.tooManyUtxos.warning",
|
|
334
|
+
);
|
|
370
335
|
});
|
|
371
336
|
|
|
372
|
-
it("should
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
const transaction: Transaction = {
|
|
381
|
-
family: "canton",
|
|
382
|
-
amount: new BigNumber(50),
|
|
383
|
-
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
384
|
-
fee: new BigNumber(10),
|
|
385
|
-
tokenId: "",
|
|
337
|
+
it("should not show warning or error when UTXO count is less than TO_MANY_UTXOS_WARNING_COUNT", async () => {
|
|
338
|
+
const accountWithFewUtxos = {
|
|
339
|
+
...mockAccount,
|
|
340
|
+
cantonResources: {
|
|
341
|
+
instrumentUtxoCounts: {
|
|
342
|
+
Amulet: TO_MANY_UTXOS_WARNING_COUNT - 1,
|
|
343
|
+
},
|
|
344
|
+
},
|
|
386
345
|
};
|
|
387
346
|
|
|
388
|
-
const result = await getTransactionStatus(mockAccount, transaction);
|
|
389
|
-
|
|
390
|
-
expect(result.errors.amount).toBeUndefined();
|
|
391
|
-
});
|
|
392
|
-
|
|
393
|
-
it("should handle undefined reserve amount", async () => {
|
|
394
|
-
mockCoinConfig.getCoinConfig.mockReturnValue({
|
|
395
|
-
networkType: "mainnet",
|
|
396
|
-
status: { type: "active" },
|
|
397
|
-
nativeInstrumentId: "Amulet",
|
|
398
|
-
});
|
|
399
|
-
|
|
400
347
|
const transaction: Transaction = {
|
|
401
348
|
family: "canton",
|
|
402
349
|
amount: new BigNumber(50),
|
|
403
350
|
recipient: "valid::11111111111111111111111111111111111111111111111111111111111111111111",
|
|
404
351
|
fee: new BigNumber(10),
|
|
405
|
-
tokenId: "",
|
|
352
|
+
tokenId: "Amulet", // Use the same tokenId as in cantonResources
|
|
406
353
|
};
|
|
407
354
|
|
|
408
|
-
const result = await getTransactionStatus(
|
|
355
|
+
const result = await getTransactionStatus(accountWithFewUtxos, transaction);
|
|
409
356
|
|
|
410
|
-
expect(result.
|
|
357
|
+
expect(result.warnings.tooManyUtxos).toBeUndefined();
|
|
411
358
|
});
|
|
412
|
-
});
|
|
413
359
|
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
360
|
+
it("should not show warning or error for abandon seed address transactions", async () => {
|
|
361
|
+
const accountWithManyUtxos = {
|
|
362
|
+
...mockAccount,
|
|
363
|
+
cantonResources: {
|
|
364
|
+
instrumentUtxoCounts: {
|
|
365
|
+
Amulet: 25,
|
|
366
|
+
},
|
|
367
|
+
},
|
|
422
368
|
};
|
|
423
369
|
|
|
424
|
-
const result = await getTransactionStatus(mockAccount, transaction);
|
|
425
|
-
|
|
426
|
-
expect(result.errors.amount).toBeInstanceOf(AmountRequired);
|
|
427
|
-
expect(result.errors.recipient).toBeInstanceOf(RecipientRequired);
|
|
428
|
-
expect(result.errors.fee).toBeInstanceOf(FeeNotLoaded);
|
|
429
|
-
});
|
|
430
|
-
|
|
431
|
-
it("should return both errors and warnings", async () => {
|
|
432
370
|
const transaction: Transaction = {
|
|
433
371
|
family: "canton",
|
|
434
|
-
amount: new BigNumber(
|
|
435
|
-
recipient: "
|
|
436
|
-
fee: new BigNumber(
|
|
437
|
-
tokenId: "",
|
|
372
|
+
amount: new BigNumber(50),
|
|
373
|
+
recipient: "abandon::ffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff",
|
|
374
|
+
fee: new BigNumber(10),
|
|
375
|
+
tokenId: "Amulet",
|
|
438
376
|
};
|
|
439
377
|
|
|
440
|
-
const result = await getTransactionStatus(
|
|
378
|
+
const result = await getTransactionStatus(accountWithManyUtxos, transaction);
|
|
441
379
|
|
|
442
|
-
expect(result.warnings.
|
|
443
|
-
expect(result.errors.
|
|
380
|
+
expect(result.warnings.tooManyUtxos).toBeUndefined();
|
|
381
|
+
expect(result.errors.utxoCount).toBeUndefined();
|
|
444
382
|
});
|
|
445
383
|
});
|
|
446
384
|
});
|