@ledgerhq/coin-canton 0.9.0-nightly.1 → 0.9.0-nightly.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.turbo/turbo-build.log +1 -1
- package/CHANGELOG.md +27 -0
- package/README.md +75 -0
- package/lib/bridge/deviceTransactionConfig.d.ts +1 -1
- package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -1
- package/lib/bridge/deviceTransactionConfig.js +1 -1
- package/lib/bridge/deviceTransactionConfig.js.map +1 -1
- package/lib/bridge/onboard.d.ts.map +1 -1
- package/lib/bridge/onboard.js +48 -22
- package/lib/bridge/onboard.js.map +1 -1
- package/lib/bridge/signOperation.d.ts.map +1 -1
- package/lib/bridge/signOperation.js +11 -4
- package/lib/bridge/signOperation.js.map +1 -1
- package/lib/common-logic/index.d.ts +1 -0
- package/lib/common-logic/index.d.ts.map +1 -1
- package/lib/common-logic/index.js +3 -1
- package/lib/common-logic/index.js.map +1 -1
- package/lib/common-logic/transaction/sign.d.ts +8 -0
- package/lib/common-logic/transaction/sign.d.ts.map +1 -0
- package/lib/common-logic/transaction/sign.js +45 -0
- package/lib/common-logic/transaction/sign.js.map +1 -0
- package/lib/common-logic/transaction/split.d.ts +9 -0
- package/lib/common-logic/transaction/split.d.ts.map +1 -0
- package/lib/common-logic/transaction/split.js +119 -0
- package/lib/common-logic/transaction/split.js.map +1 -0
- package/lib/common-logic/utils.js +2 -2
- package/lib/common-logic/utils.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 +6 -9
- package/lib/network/gateway.js.map +1 -1
- package/lib/test/cantonTestUtils.d.ts +4 -9
- package/lib/test/cantonTestUtils.d.ts.map +1 -1
- package/lib/test/cantonTestUtils.js +736 -27
- package/lib/test/cantonTestUtils.js.map +1 -1
- package/lib/types/signer.d.ts +15 -2
- package/lib/types/signer.d.ts.map +1 -1
- package/lib/types/transaction-proto.json +1238 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts +1 -1
- package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -1
- package/lib-es/bridge/deviceTransactionConfig.js +1 -1
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -1
- package/lib-es/bridge/onboard.d.ts.map +1 -1
- package/lib-es/bridge/onboard.js +49 -23
- package/lib-es/bridge/onboard.js.map +1 -1
- package/lib-es/bridge/signOperation.d.ts.map +1 -1
- package/lib-es/bridge/signOperation.js +11 -4
- package/lib-es/bridge/signOperation.js.map +1 -1
- package/lib-es/common-logic/index.d.ts +1 -0
- package/lib-es/common-logic/index.d.ts.map +1 -1
- package/lib-es/common-logic/index.js +1 -0
- package/lib-es/common-logic/index.js.map +1 -1
- package/lib-es/common-logic/transaction/sign.d.ts +8 -0
- package/lib-es/common-logic/transaction/sign.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/sign.js +42 -0
- package/lib-es/common-logic/transaction/sign.js.map +1 -0
- package/lib-es/common-logic/transaction/split.d.ts +9 -0
- package/lib-es/common-logic/transaction/split.d.ts.map +1 -0
- package/lib-es/common-logic/transaction/split.js +83 -0
- package/lib-es/common-logic/transaction/split.js.map +1 -0
- package/lib-es/common-logic/utils.js +2 -2
- package/lib-es/common-logic/utils.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 +5 -10
- package/lib-es/network/gateway.js.map +1 -1
- package/lib-es/test/cantonTestUtils.d.ts +4 -9
- package/lib-es/test/cantonTestUtils.d.ts.map +1 -1
- package/lib-es/test/cantonTestUtils.js +697 -21
- package/lib-es/test/cantonTestUtils.js.map +1 -1
- package/lib-es/types/signer.d.ts +15 -2
- package/lib-es/types/signer.d.ts.map +1 -1
- package/lib-es/types/transaction-proto.json +1238 -0
- package/package.json +10 -7
- package/scripts/generate.js +261 -0
- package/src/bridge/deviceTransactionConfig.test.ts +14 -10
- package/src/bridge/deviceTransactionConfig.ts +2 -2
- package/src/bridge/getTransactionStatus.test.ts +19 -19
- package/src/bridge/onboard.integ.test.ts +0 -20
- package/src/bridge/onboard.ts +58 -33
- package/src/bridge/signOperation.test.ts +129 -0
- package/src/bridge/signOperation.ts +13 -6
- package/src/bridge/sync.integ.test.ts +157 -132
- package/src/common-logic/index.ts +1 -0
- package/src/common-logic/transaction/sign.test.ts +389 -0
- package/src/common-logic/transaction/sign.ts +59 -0
- package/src/common-logic/transaction/split.test.ts +50 -0
- package/src/common-logic/transaction/split.ts +101 -0
- package/src/common-logic/utils.test.ts +22 -30
- package/src/common-logic/utils.ts +2 -2
- package/src/network/gateway.integ.test.ts +5 -6
- package/src/network/gateway.ts +12 -10
- package/src/test/cantonTestUtils.ts +789 -24
- package/src/test/prepare-transfer-serialized.json +26 -0
- package/src/test/prepare-transfer.json +3298 -0
- package/src/types/signer.ts +21 -3
- package/src/types/transaction-proto.json +1238 -0
|
@@ -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 = {
|
|
@@ -107,6 +104,8 @@ describe("gateway (devnet)", () => {
|
|
|
107
104
|
testIfPrepared(
|
|
108
105
|
"should not throw when already onboarded",
|
|
109
106
|
async () => {
|
|
107
|
+
// Add delay to ensure previous operations are complete
|
|
108
|
+
await new Promise(resolve => setTimeout(resolve, 10000));
|
|
110
109
|
// GIVEN
|
|
111
110
|
const { keyPair } = getOnboardedAccount();
|
|
112
111
|
const signature = keyPair.sign(prepareResponse!.transactions.combined_hash);
|
|
@@ -116,7 +115,7 @@ describe("gateway (devnet)", () => {
|
|
|
116
115
|
mockCurrency,
|
|
117
116
|
keyPair.publicKeyHex,
|
|
118
117
|
prepareResponse!,
|
|
119
|
-
signature,
|
|
118
|
+
{ signature },
|
|
120
119
|
);
|
|
121
120
|
|
|
122
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 = {
|
|
@@ -283,7 +287,8 @@ export type OperationInfo =
|
|
|
283
287
|
const getGatewayUrl = (currency: CryptoCurrency) => coinConfig.getCoinConfig(currency).gatewayUrl;
|
|
284
288
|
const getNodeId = (currency: CryptoCurrency) =>
|
|
285
289
|
coinConfig.getCoinConfig(currency).nodeId || "ledger-live-devnet";
|
|
286
|
-
const getNetworkType = (currency: CryptoCurrency) =>
|
|
290
|
+
export const getNetworkType = (currency: CryptoCurrency) =>
|
|
291
|
+
coinConfig.getCoinConfig(currency).networkType;
|
|
287
292
|
|
|
288
293
|
const gatewayNetwork = <T, U = unknown>(req: LiveNetworkRequest<U>) => {
|
|
289
294
|
const API_KEY = getEnv("CANTON_API_KEY");
|
|
@@ -324,7 +329,7 @@ export async function submitOnboarding(
|
|
|
324
329
|
currency: CryptoCurrency,
|
|
325
330
|
publicKey: string,
|
|
326
331
|
prepareResponse: OnboardingPrepareResponse,
|
|
327
|
-
signature:
|
|
332
|
+
{ signature, applicationSignature }: CantonSignature,
|
|
328
333
|
) {
|
|
329
334
|
try {
|
|
330
335
|
const { data } = await gatewayNetwork<OnboardingSubmitResponse, OnboardingSubmitRequest>({
|
|
@@ -337,6 +342,7 @@ export async function submitOnboarding(
|
|
|
337
342
|
},
|
|
338
343
|
prepare_response: prepareResponse,
|
|
339
344
|
signature,
|
|
345
|
+
...(applicationSignature ? { application_signature: applicationSignature } : {}),
|
|
340
346
|
},
|
|
341
347
|
});
|
|
342
348
|
return data;
|
|
@@ -448,18 +454,13 @@ export async function prepareTapRequest(
|
|
|
448
454
|
currency: CryptoCurrency,
|
|
449
455
|
{ partyId, amount = 1000000 }: PrepareTapRequest,
|
|
450
456
|
) {
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
serialized: "",
|
|
454
|
-
json: null,
|
|
455
|
-
hash: "",
|
|
456
|
-
};
|
|
457
|
-
}
|
|
457
|
+
const fixedPointAmount = BigInt(amount) * BigInt(10) ** BigInt(38);
|
|
458
|
+
|
|
458
459
|
const { data } = await gatewayNetwork<PrepareTapResponse, { amount: string; type: string }>({
|
|
459
460
|
method: "POST",
|
|
460
461
|
url: `${getGatewayUrl(currency)}/v1/node/${getNodeId(currency)}/party/${partyId}/transaction/prepare`,
|
|
461
462
|
data: {
|
|
462
|
-
amount:
|
|
463
|
+
amount: fixedPointAmount.toString(),
|
|
463
464
|
type: TransactionType.TAP_REQUEST,
|
|
464
465
|
},
|
|
465
466
|
});
|
|
@@ -505,6 +506,7 @@ export async function prepareTransferRequest(
|
|
|
505
506
|
url: `${getGatewayUrl(currency)}/v1/node/${getNodeId(currency)}/party/${partyId}/transaction/prepare`,
|
|
506
507
|
data: params,
|
|
507
508
|
});
|
|
509
|
+
|
|
508
510
|
return data;
|
|
509
511
|
}
|
|
510
512
|
|