@ledgerhq/coin-canton 0.9.0-nightly.2 → 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 +28 -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/onboard.d.ts.map +1 -1
- package/lib/bridge/onboard.js +2 -2
- package/lib/bridge/onboard.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/signOperation.js +2 -2
- package/lib/bridge/signOperation.js.map +1 -1
- 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/common-logic/transaction/sign.d.ts +2 -2
- package/lib/common-logic/transaction/sign.d.ts.map +1 -1
- package/lib/common-logic/transaction/sign.js +20 -2
- package/lib/common-logic/transaction/sign.js.map +1 -1
- package/lib/network/gateway.d.ts +5 -1
- package/lib/network/gateway.d.ts.map +1 -1
- package/lib/network/gateway.js +4 -2
- 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/types/signer.d.ts +5 -1
- package/lib/types/signer.d.ts.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/onboard.d.ts.map +1 -1
- package/lib-es/bridge/onboard.js +2 -2
- package/lib-es/bridge/onboard.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/signOperation.js +2 -2
- package/lib-es/bridge/signOperation.js.map +1 -1
- 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/common-logic/transaction/sign.d.ts +2 -2
- package/lib-es/common-logic/transaction/sign.d.ts.map +1 -1
- package/lib-es/common-logic/transaction/sign.js +20 -2
- package/lib-es/common-logic/transaction/sign.js.map +1 -1
- package/lib-es/network/gateway.d.ts +5 -1
- package/lib-es/network/gateway.d.ts.map +1 -1
- package/lib-es/network/gateway.js +4 -2
- 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/lib-es/types/signer.d.ts +5 -1
- package/lib-es/types/signer.d.ts.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/onboard.ts +3 -2
- package/src/bridge/prepareTransaction.ts +1 -1
- package/src/bridge/serialization.ts +44 -0
- package/src/bridge/signOperation.test.ts +24 -15
- package/src/bridge/signOperation.ts +2 -2
- 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/common-logic/transaction/sign.test.ts +83 -11
- package/src/common-logic/transaction/sign.ts +32 -6
- package/src/network/gateway.integ.test.ts +3 -6
- package/src/network/gateway.ts +10 -2
- 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
- package/src/types/signer.ts +5 -1
package/src/network/gateway.ts
CHANGED
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
PreApprovalResult,
|
|
11
11
|
} from "../types/onboard";
|
|
12
12
|
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
13
|
+
import type { CantonSignature } from "../types/signer";
|
|
13
14
|
|
|
14
15
|
export type OnboardingPrepareResponse = {
|
|
15
16
|
party_id: string;
|
|
@@ -33,6 +34,8 @@ export type OnboardingPrepareResponse = {
|
|
|
33
34
|
};
|
|
34
35
|
combined_hash: string;
|
|
35
36
|
};
|
|
37
|
+
challenge_nonce?: string;
|
|
38
|
+
challenge_deadline?: number;
|
|
36
39
|
};
|
|
37
40
|
|
|
38
41
|
type OnboardingPrepareRequest = {
|
|
@@ -59,6 +62,7 @@ type OnboardingSubmitRequest = {
|
|
|
59
62
|
prepare_request: OnboardingPrepareRequest;
|
|
60
63
|
prepare_response: OnboardingPrepareResponse;
|
|
61
64
|
signature: string;
|
|
65
|
+
application_signature?: string;
|
|
62
66
|
};
|
|
63
67
|
|
|
64
68
|
type OnboardingSubmitResponse = {
|
|
@@ -87,6 +91,7 @@ export type InstrumentBalance = {
|
|
|
87
91
|
instrument_id: string;
|
|
88
92
|
amount: string;
|
|
89
93
|
locked: boolean;
|
|
94
|
+
utxo_count: number;
|
|
90
95
|
};
|
|
91
96
|
|
|
92
97
|
type PartyInfo = {
|
|
@@ -325,7 +330,7 @@ export async function submitOnboarding(
|
|
|
325
330
|
currency: CryptoCurrency,
|
|
326
331
|
publicKey: string,
|
|
327
332
|
prepareResponse: OnboardingPrepareResponse,
|
|
328
|
-
signature:
|
|
333
|
+
{ signature, applicationSignature }: CantonSignature,
|
|
329
334
|
) {
|
|
330
335
|
try {
|
|
331
336
|
const { data } = await gatewayNetwork<OnboardingSubmitResponse, OnboardingSubmitRequest>({
|
|
@@ -338,6 +343,7 @@ export async function submitOnboarding(
|
|
|
338
343
|
},
|
|
339
344
|
prepare_response: prepareResponse,
|
|
340
345
|
signature,
|
|
346
|
+
...(applicationSignature ? { application_signature: applicationSignature } : {}),
|
|
341
347
|
},
|
|
342
348
|
});
|
|
343
349
|
return data;
|
|
@@ -449,11 +455,13 @@ export async function prepareTapRequest(
|
|
|
449
455
|
currency: CryptoCurrency,
|
|
450
456
|
{ partyId, amount = 1000000 }: PrepareTapRequest,
|
|
451
457
|
) {
|
|
458
|
+
const fixedPointAmount = BigInt(amount) * BigInt(10) ** BigInt(38);
|
|
459
|
+
|
|
452
460
|
const { data } = await gatewayNetwork<PrepareTapResponse, { amount: string; type: string }>({
|
|
453
461
|
method: "POST",
|
|
454
462
|
url: `${getGatewayUrl(currency)}/v1/node/${getNodeId(currency)}/party/${partyId}/transaction/prepare`,
|
|
455
463
|
data: {
|
|
456
|
-
amount:
|
|
464
|
+
amount: fixedPointAmount.toString(),
|
|
457
465
|
type: TransactionType.TAP_REQUEST,
|
|
458
466
|
},
|
|
459
467
|
});
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { Account } from "@ledgerhq/types-live";
|
|
3
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
|
+
import { getDerivationScheme, runDerivationScheme } from "@ledgerhq/coin-framework/derivation";
|
|
5
|
+
import { createEmptyHistoryCache } from "@ledgerhq/coin-framework/account";
|
|
6
|
+
|
|
7
|
+
export const createMockCantonCurrency = (): CryptoCurrency => {
|
|
8
|
+
const mockCurrency = {
|
|
9
|
+
id: "canton_network",
|
|
10
|
+
name: "Canton",
|
|
11
|
+
type: "CryptoCurrency",
|
|
12
|
+
family: "canton",
|
|
13
|
+
units: [{ name: "Canton", code: "CANTON", magnitude: 38 }],
|
|
14
|
+
ticker: "CANTON",
|
|
15
|
+
scheme: "canton",
|
|
16
|
+
color: "#000000",
|
|
17
|
+
managerAppName: "Canton",
|
|
18
|
+
coinType: 6767,
|
|
19
|
+
explorerViews: [],
|
|
20
|
+
} satisfies CryptoCurrency;
|
|
21
|
+
return mockCurrency;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
export const createMockAccount = (overrides: Partial<Account> = {}): Account => {
|
|
25
|
+
const currency = createMockCantonCurrency();
|
|
26
|
+
const derivationMode = "canton" as const;
|
|
27
|
+
const scheme = getDerivationScheme({ derivationMode, currency });
|
|
28
|
+
const freshAddressPath = runDerivationScheme(scheme, currency, { account: 0 });
|
|
29
|
+
|
|
30
|
+
return {
|
|
31
|
+
id: "js:2:canton_network:test-address:canton",
|
|
32
|
+
type: "Account",
|
|
33
|
+
used: true,
|
|
34
|
+
currency,
|
|
35
|
+
derivationMode,
|
|
36
|
+
index: 0,
|
|
37
|
+
freshAddress: "test_address",
|
|
38
|
+
freshAddressPath,
|
|
39
|
+
creationDate: new Date(),
|
|
40
|
+
lastSyncDate: new Date(),
|
|
41
|
+
balance: new BigNumber(0),
|
|
42
|
+
spendableBalance: new BigNumber(0),
|
|
43
|
+
seedIdentifier: "test_seed",
|
|
44
|
+
blockHeight: 0,
|
|
45
|
+
operationsCount: 0,
|
|
46
|
+
operations: [],
|
|
47
|
+
pendingOperations: [],
|
|
48
|
+
balanceHistoryCache: createEmptyHistoryCache(),
|
|
49
|
+
swapHistory: [],
|
|
50
|
+
subAccounts: [],
|
|
51
|
+
...overrides,
|
|
52
|
+
};
|
|
53
|
+
};
|
package/src/types/bridge.ts
CHANGED
|
@@ -48,6 +48,7 @@ export type Transaction = TransactionCommon & {
|
|
|
48
48
|
fee: BigNumber | null | undefined;
|
|
49
49
|
memo?: string;
|
|
50
50
|
tokenId: string;
|
|
51
|
+
expireInSeconds?: number;
|
|
51
52
|
};
|
|
52
53
|
|
|
53
54
|
export type TransactionRaw = TransactionCommonRaw & {
|
|
@@ -55,10 +56,22 @@ export type TransactionRaw = TransactionCommonRaw & {
|
|
|
55
56
|
fee: string | null | undefined;
|
|
56
57
|
memo?: string;
|
|
57
58
|
tokenId: string;
|
|
59
|
+
expireInSeconds?: number;
|
|
58
60
|
};
|
|
59
61
|
|
|
60
62
|
export type TransactionStatus = TransactionStatusCommon;
|
|
61
63
|
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
62
64
|
|
|
63
|
-
export type
|
|
64
|
-
|
|
65
|
+
export type CantonResources = {
|
|
66
|
+
instrumentUtxoCounts: Record<string, number>;
|
|
67
|
+
};
|
|
68
|
+
export type CantonResourcesRaw = {
|
|
69
|
+
instrumentUtxoCounts: Record<string, number>;
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
export type CantonAccount = Account & {
|
|
73
|
+
cantonResources: CantonResources;
|
|
74
|
+
};
|
|
75
|
+
export type CantonAccountRaw = AccountRaw & {
|
|
76
|
+
cantonResources: CantonResourcesRaw;
|
|
77
|
+
};
|
package/src/types/errors.ts
CHANGED
|
@@ -1,3 +1,6 @@
|
|
|
1
1
|
import { createCustomErrorClass } from "@ledgerhq/errors";
|
|
2
2
|
|
|
3
3
|
export const SimulationError = createCustomErrorClass("SimulationError");
|
|
4
|
+
|
|
5
|
+
export const TooManyUtxosCritical = createCustomErrorClass("TooManyUtxosCritical");
|
|
6
|
+
export const TooManyUtxosWarning = createCustomErrorClass("TooManyUtxosWarning");
|
package/src/types/index.ts
CHANGED
package/src/types/signer.ts
CHANGED
|
@@ -4,7 +4,10 @@ export type CantonAddress = {
|
|
|
4
4
|
path: string;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
|
-
export type CantonSignature =
|
|
7
|
+
export type CantonSignature = {
|
|
8
|
+
signature: string;
|
|
9
|
+
applicationSignature?: string;
|
|
10
|
+
};
|
|
8
11
|
|
|
9
12
|
export interface CantonPreparedTransaction {
|
|
10
13
|
damlTransaction: Uint8Array;
|
|
@@ -15,6 +18,7 @@ export interface CantonPreparedTransaction {
|
|
|
15
18
|
|
|
16
19
|
export interface CantonUntypedVersionedMessage {
|
|
17
20
|
transactions: string[];
|
|
21
|
+
challenge?: string;
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
export interface CantonSigner {
|