@ledgerhq/coin-canton 0.9.0-nightly.2 → 0.9.0-nightly.20251031023756
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 +18 -17
- 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 +27 -10
- 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 +14 -6
- 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/estimateFees.js +1 -1
- package/lib/common-logic/transaction/estimateFees.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 +27 -10
- 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 +14 -6
- 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/estimateFees.js +1 -1
- package/lib-es/common-logic/transaction/estimateFees.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 +10 -10
- package/src/bridge/estimateMaxSpendable.ts +6 -8
- package/src/bridge/getTransactionStatus.test.ts +88 -150
- package/src/bridge/getTransactionStatus.ts +43 -11
- 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 +5 -1
- package/src/bridge/sync.ts +18 -7
- 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/estimateFees.test.ts +10 -0
- package/src/common-logic/transaction/estimateFees.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
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import { OnboardingPrepareResponse, PrepareTransferResponse } from "../../network/gateway";
|
|
2
|
-
import {
|
|
2
|
+
import {
|
|
3
|
+
CantonPreparedTransaction,
|
|
4
|
+
CantonSigner,
|
|
5
|
+
CantonSignature,
|
|
6
|
+
CantonUntypedVersionedMessage,
|
|
7
|
+
} from "../../types/signer";
|
|
3
8
|
import { signTransaction } from "./sign";
|
|
4
9
|
|
|
5
10
|
class MockCantonSigner implements CantonSigner {
|
|
@@ -13,12 +18,22 @@ class MockCantonSigner implements CantonSigner {
|
|
|
13
18
|
|
|
14
19
|
async signTransaction(
|
|
15
20
|
path: string,
|
|
16
|
-
data: CantonPreparedTransaction |
|
|
17
|
-
) {
|
|
18
|
-
if ("
|
|
19
|
-
return `
|
|
21
|
+
data: CantonPreparedTransaction | CantonUntypedVersionedMessage | string,
|
|
22
|
+
): Promise<CantonSignature> {
|
|
23
|
+
if (typeof data === "string") {
|
|
24
|
+
return { signature: `txhash-signature-${data}` };
|
|
25
|
+
} else if ("transactions" in data) {
|
|
26
|
+
const result: CantonSignature = {
|
|
27
|
+
signature: `untyped-signature-${data.transactions.length}`,
|
|
28
|
+
};
|
|
29
|
+
if (data.challenge) {
|
|
30
|
+
result.applicationSignature = `challenge-signature-${data.challenge}`;
|
|
31
|
+
}
|
|
32
|
+
return result;
|
|
20
33
|
} else {
|
|
21
|
-
return
|
|
34
|
+
return {
|
|
35
|
+
signature: `prepared-transaction-signature-${data.damlTransaction.length}-${data.nodes.length}`,
|
|
36
|
+
};
|
|
22
37
|
}
|
|
23
38
|
}
|
|
24
39
|
}
|
|
@@ -85,7 +100,7 @@ describe("signTransaction", () => {
|
|
|
85
100
|
);
|
|
86
101
|
|
|
87
102
|
// THEN
|
|
88
|
-
expect(result).
|
|
103
|
+
expect(result).toEqual({ signature: "prepared-transaction-signature-10-1" });
|
|
89
104
|
});
|
|
90
105
|
|
|
91
106
|
it("should sign untyped versioned message", async () => {
|
|
@@ -122,7 +137,7 @@ describe("signTransaction", () => {
|
|
|
122
137
|
);
|
|
123
138
|
|
|
124
139
|
// THEN
|
|
125
|
-
expect(result).
|
|
140
|
+
expect(result).toEqual({ signature: "untyped-signature-3" });
|
|
126
141
|
});
|
|
127
142
|
|
|
128
143
|
it("should handle empty signature from signer", async () => {
|
|
@@ -201,7 +216,7 @@ describe("signTransaction", () => {
|
|
|
201
216
|
|
|
202
217
|
it("should call signer with correct parameters for prepared transaction", async () => {
|
|
203
218
|
// GIVEN
|
|
204
|
-
const mockSignerSpy = jest.fn().mockResolvedValue("test-signature");
|
|
219
|
+
const mockSignerSpy = jest.fn().mockResolvedValue({ signature: "test-signature" });
|
|
205
220
|
const mockSignerWithSpy = {
|
|
206
221
|
...mockSigner,
|
|
207
222
|
signTransaction: mockSignerSpy,
|
|
@@ -270,9 +285,9 @@ describe("signTransaction", () => {
|
|
|
270
285
|
);
|
|
271
286
|
});
|
|
272
287
|
|
|
273
|
-
it("should call signer with correct parameters for untyped versioned message", async () => {
|
|
288
|
+
it("should call signer with correct parameters for untyped versioned message without challenge", async () => {
|
|
274
289
|
// GIVEN
|
|
275
|
-
const mockSignerSpy = jest.fn().mockResolvedValue("test-signature");
|
|
290
|
+
const mockSignerSpy = jest.fn().mockResolvedValue({ signature: "test-signature" });
|
|
276
291
|
const mockSignerWithSpy = {
|
|
277
292
|
...mockSigner,
|
|
278
293
|
signTransaction: mockSignerSpy,
|
|
@@ -314,4 +329,61 @@ describe("signTransaction", () => {
|
|
|
314
329
|
],
|
|
315
330
|
});
|
|
316
331
|
});
|
|
332
|
+
|
|
333
|
+
it("should call signer with correct parameters for untyped versioned message with challenge", async () => {
|
|
334
|
+
const mockSignerSpy = jest.fn().mockResolvedValue({
|
|
335
|
+
signature: "main-signature",
|
|
336
|
+
applicationSignature: "challenge-signature",
|
|
337
|
+
});
|
|
338
|
+
const mockSignerWithSpy = {
|
|
339
|
+
...mockSigner,
|
|
340
|
+
signTransaction: mockSignerSpy,
|
|
341
|
+
} as unknown as CantonSigner;
|
|
342
|
+
|
|
343
|
+
const mockOnboardingPrepareResponse: OnboardingPrepareResponse = {
|
|
344
|
+
party_id: "test-party-id",
|
|
345
|
+
party_name: "test-party-name",
|
|
346
|
+
public_key_fingerprint: "test-fingerprint",
|
|
347
|
+
challenge_nonce: "1234567890abcdef",
|
|
348
|
+
challenge_deadline: 1735689599,
|
|
349
|
+
transactions: {
|
|
350
|
+
namespace_transaction: {
|
|
351
|
+
serialized: "namespace-transaction-data",
|
|
352
|
+
json: {},
|
|
353
|
+
hash: "namespace-hash",
|
|
354
|
+
},
|
|
355
|
+
party_to_key_transaction: {
|
|
356
|
+
serialized: "party-to-key-transaction-data",
|
|
357
|
+
json: {},
|
|
358
|
+
hash: "party-to-key-hash",
|
|
359
|
+
},
|
|
360
|
+
party_to_participant_transaction: {
|
|
361
|
+
serialized: "party-to-participant-transaction-data",
|
|
362
|
+
json: {},
|
|
363
|
+
hash: "party-to-participant-hash",
|
|
364
|
+
},
|
|
365
|
+
combined_hash: "combined-hash",
|
|
366
|
+
},
|
|
367
|
+
};
|
|
368
|
+
|
|
369
|
+
const result = await signTransaction(
|
|
370
|
+
mockSignerWithSpy,
|
|
371
|
+
mockDerivationPath,
|
|
372
|
+
mockOnboardingPrepareResponse,
|
|
373
|
+
);
|
|
374
|
+
|
|
375
|
+
expect(result).toEqual({
|
|
376
|
+
signature: "main-signature",
|
|
377
|
+
applicationSignature: "challenge-signature",
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
expect(mockSignerSpy).toHaveBeenCalledWith(mockDerivationPath, {
|
|
381
|
+
transactions: [
|
|
382
|
+
"namespace-transaction-data",
|
|
383
|
+
"party-to-key-transaction-data",
|
|
384
|
+
"party-to-participant-transaction-data",
|
|
385
|
+
],
|
|
386
|
+
challenge: "181234567890abcdef000000006774857f",
|
|
387
|
+
});
|
|
388
|
+
});
|
|
317
389
|
});
|
|
@@ -1,33 +1,59 @@
|
|
|
1
1
|
import { OnboardingPrepareResponse, PrepareTransferResponse } from "../../network/gateway";
|
|
2
2
|
import { PrepareTransactionResponse } from "../../types/onboard";
|
|
3
|
-
import { CantonSigner } from "../../types/signer";
|
|
3
|
+
import { CantonSigner, CantonSignature } from "../../types/signer";
|
|
4
4
|
import { splitTransaction } from "./split";
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* Sign a Canton transaction - handles both prepared transactions and untyped versioned messages
|
|
8
8
|
*/
|
|
9
|
+
|
|
9
10
|
export async function signTransaction(
|
|
10
11
|
signer: CantonSigner,
|
|
11
12
|
derivationPath: string,
|
|
12
|
-
transactionData: PrepareTransferResponse |
|
|
13
|
-
): Promise<
|
|
14
|
-
let signature:
|
|
13
|
+
transactionData: PrepareTransferResponse | PrepareTransactionResponse | OnboardingPrepareResponse,
|
|
14
|
+
): Promise<CantonSignature> {
|
|
15
|
+
let signature: CantonSignature;
|
|
15
16
|
|
|
16
17
|
if ("json" in transactionData) {
|
|
17
18
|
const components = splitTransaction(transactionData.json);
|
|
18
19
|
signature = await signer.signTransaction(derivationPath, components);
|
|
19
20
|
} else {
|
|
21
|
+
const challenge = getTransactionChallenge(transactionData);
|
|
22
|
+
|
|
20
23
|
const transactions = [
|
|
21
24
|
transactionData.transactions.namespace_transaction.serialized,
|
|
22
25
|
transactionData.transactions.party_to_key_transaction.serialized,
|
|
23
26
|
transactionData.transactions.party_to_participant_transaction.serialized,
|
|
24
27
|
];
|
|
25
|
-
|
|
28
|
+
|
|
29
|
+
signature = await signer.signTransaction(derivationPath, {
|
|
30
|
+
transactions,
|
|
31
|
+
...(challenge && { challenge }),
|
|
32
|
+
});
|
|
26
33
|
}
|
|
27
34
|
|
|
28
|
-
if (!signature
|
|
35
|
+
if (!signature?.signature) {
|
|
29
36
|
throw new Error("Device returned empty signature");
|
|
30
37
|
}
|
|
31
38
|
|
|
32
39
|
return signature;
|
|
33
40
|
}
|
|
41
|
+
|
|
42
|
+
const getTransactionChallenge = ({
|
|
43
|
+
challenge_nonce,
|
|
44
|
+
challenge_deadline,
|
|
45
|
+
}: OnboardingPrepareResponse) => {
|
|
46
|
+
if (!challenge_nonce || !challenge_deadline) {
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
try {
|
|
51
|
+
const deadlineHex = Buffer.alloc(8);
|
|
52
|
+
deadlineHex.writeBigInt64BE(BigInt(challenge_deadline), 0);
|
|
53
|
+
|
|
54
|
+
// Format: [length (1B) = 0x18][challenge (16 bytes)][deadline (8 bytes)]
|
|
55
|
+
return "18" + challenge_nonce.toLowerCase() + deadlineHex.toString("hex");
|
|
56
|
+
} catch (error) {
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
};
|
|
@@ -83,12 +83,9 @@ describe("gateway (devnet)", () => {
|
|
|
83
83
|
const signature = keyPair.sign(prepareResponse.transactions.combined_hash);
|
|
84
84
|
|
|
85
85
|
// WHEN
|
|
86
|
-
const response = await submitOnboarding(
|
|
87
|
-
mockCurrency,
|
|
88
|
-
keyPair.publicKeyHex,
|
|
89
|
-
prepareResponse,
|
|
86
|
+
const response = await submitOnboarding(mockCurrency, keyPair.publicKeyHex, prepareResponse, {
|
|
90
87
|
signature,
|
|
91
|
-
);
|
|
88
|
+
});
|
|
92
89
|
|
|
93
90
|
// Save onboarded account for next tests that need a valid party ID
|
|
94
91
|
onboardedAccount = {
|
|
@@ -118,7 +115,7 @@ describe("gateway (devnet)", () => {
|
|
|
118
115
|
mockCurrency,
|
|
119
116
|
keyPair.publicKeyHex,
|
|
120
117
|
prepareResponse!,
|
|
121
|
-
signature,
|
|
118
|
+
{ signature },
|
|
122
119
|
);
|
|
123
120
|
|
|
124
121
|
// THEN
|
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 {
|