@ledgerhq/coin-cardano 0.1.0-next.0
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/.eslintrc.js +20 -0
- package/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +35 -0
- package/CHANGELOG.md +19 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/account.d.ts +7 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +41 -0
- package/lib/account.js.map +1 -0
- package/lib/address.unit.test.d.ts +2 -0
- package/lib/address.unit.test.d.ts.map +1 -0
- package/lib/address.unit.test.js +21 -0
- package/lib/address.unit.test.js.map +1 -0
- package/lib/api/api-types.d.ts +106 -0
- package/lib/api/api-types.d.ts.map +1 -0
- package/lib/api/api-types.js +9 -0
- package/lib/api/api-types.js.map +1 -0
- package/lib/api/getDelegationInfo.d.ts +4 -0
- package/lib/api/getDelegationInfo.d.ts.map +1 -0
- package/lib/api/getDelegationInfo.js +48 -0
- package/lib/api/getDelegationInfo.js.map +1 -0
- package/lib/api/getNetworkInfo.d.ts +5 -0
- package/lib/api/getNetworkInfo.d.ts.map +1 -0
- package/lib/api/getNetworkInfo.js +46 -0
- package/lib/api/getNetworkInfo.js.map +1 -0
- package/lib/api/getPools.d.ts +5 -0
- package/lib/api/getPools.d.ts.map +1 -0
- package/lib/api/getPools.js +45 -0
- package/lib/api/getPools.js.map +1 -0
- package/lib/api/getTransactions.d.ts +10 -0
- package/lib/api/getTransactions.d.ts.map +1 -0
- package/lib/api/getTransactions.js +139 -0
- package/lib/api/getTransactions.js.map +1 -0
- package/lib/api/submitTransaction.d.ts +7 -0
- package/lib/api/submitTransaction.d.ts.map +1 -0
- package/lib/api/submitTransaction.js +34 -0
- package/lib/api/submitTransaction.js.map +1 -0
- package/lib/bridge/index.d.ts +11 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +70 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge.integration.test.d.ts +4 -0
- package/lib/bridge.integration.test.d.ts.map +1 -0
- package/lib/bridge.integration.test.js +113 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/broadcast.d.ts +8 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +28 -0
- package/lib/broadcast.js.map +1 -0
- package/lib/buildOptimisticOperation.d.ts +4 -0
- package/lib/buildOptimisticOperation.d.ts.map +1 -0
- package/lib/buildOptimisticOperation.js +125 -0
- package/lib/buildOptimisticOperation.js.map +1 -0
- package/lib/buildSubAccounts.d.ts +26 -0
- package/lib/buildSubAccounts.d.ts.map +1 -0
- package/lib/buildSubAccounts.js +124 -0
- package/lib/buildSubAccounts.js.map +1 -0
- package/lib/buildTransaction.d.ts +11 -0
- package/lib/buildTransaction.d.ts.map +1 -0
- package/lib/buildTransaction.js +342 -0
- package/lib/buildTransaction.js.map +1 -0
- package/lib/cli-transaction.d.ts +18 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +66 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/constants.d.ts +8 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +12 -0
- package/lib/constants.js.map +1 -0
- package/lib/createTransaction.d.ts +9 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +23 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/datasets/rawAccount.1.d.ts +3 -0
- package/lib/datasets/rawAccount.1.d.ts.map +1 -0
- package/lib/datasets/rawAccount.1.js +20 -0
- package/lib/datasets/rawAccount.1.js.map +1 -0
- package/lib/datasets/scanAccounts.d.ts +5 -0
- package/lib/datasets/scanAccounts.d.ts.map +1 -0
- package/lib/datasets/scanAccounts.js +27 -0
- package/lib/datasets/scanAccounts.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +11 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +106 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +22 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +18 -0
- package/lib/errors.js.map +1 -0
- package/lib/estimateMaxSpendable.d.ts +9 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +53 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +4 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +214 -0
- package/lib/getTransactionStatus.js.map +1 -0
- package/lib/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib/getTransactionStatus.unit.test.js +54 -0
- package/lib/getTransactionStatus.unit.test.js.map +1 -0
- package/lib/hw-getAddress.d.ts +6 -0
- package/lib/hw-getAddress.d.ts.map +1 -0
- package/lib/hw-getAddress.js +37 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/logic.d.ts +88 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +264 -0
- package/lib/logic.js.map +1 -0
- package/lib/logic.unit.test.d.ts +2 -0
- package/lib/logic.unit.test.d.ts.map +1 -0
- package/lib/logic.unit.test.js +40 -0
- package/lib/logic.unit.test.js.map +1 -0
- package/lib/networks.d.ts +3 -0
- package/lib/networks.d.ts.map +1 -0
- package/lib/networks.js +36 -0
- package/lib/networks.js.map +1 -0
- package/lib/postSyncPatch.d.ts +6 -0
- package/lib/postSyncPatch.d.ts.map +1 -0
- package/lib/postSyncPatch.js +35 -0
- package/lib/postSyncPatch.js.map +1 -0
- package/lib/prepareTransaction.d.ts +10 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +44 -0
- package/lib/prepareTransaction.js.map +1 -0
- package/lib/serialization.d.ts +7 -0
- package/lib/serialization.d.ts.map +1 -0
- package/lib/serialization.js +146 -0
- package/lib/serialization.js.map +1 -0
- package/lib/signOperation.d.ts +9 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +71 -0
- package/lib/signOperation.js.map +1 -0
- package/lib/signer.d.ts +92 -0
- package/lib/signer.d.ts.map +1 -0
- package/lib/signer.js +3 -0
- package/lib/signer.js.map +1 -0
- package/lib/specs.d.ts +7 -0
- package/lib/specs.d.ts.map +1 -0
- package/lib/specs.js +218 -0
- package/lib/specs.js.map +1 -0
- package/lib/speculos-deviceActions.d.ts +4 -0
- package/lib/speculos-deviceActions.d.ts.map +1 -0
- package/lib/speculos-deviceActions.js +128 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/synchronisation.d.ts +6 -0
- package/lib/synchronisation.d.ts.map +1 -0
- package/lib/synchronisation.js +237 -0
- package/lib/synchronisation.js.map +1 -0
- package/lib/synchronisation.unit.test.d.ts +2 -0
- package/lib/synchronisation.unit.test.d.ts.map +1 -0
- package/lib/synchronisation.unit.test.js +129 -0
- package/lib/synchronisation.unit.test.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +43 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types.d.ts +188 -0
- package/lib/types.d.ts.map +1 -0
- package/lib/types.js +18 -0
- package/lib/types.js.map +1 -0
- package/lib/typhonSerializer.d.ts +17 -0
- package/lib/typhonSerializer.d.ts.map +1 -0
- package/lib/typhonSerializer.js +213 -0
- package/lib/typhonSerializer.js.map +1 -0
- package/lib/utils.d.ts +2 -0
- package/lib/utils.d.ts.map +1 -0
- package/lib/utils.js +8 -0
- package/lib/utils.js.map +1 -0
- package/lib-es/account.d.ts +7 -0
- package/lib-es/account.d.ts.map +1 -0
- package/lib-es/account.js +34 -0
- package/lib-es/account.js.map +1 -0
- package/lib-es/address.unit.test.d.ts +2 -0
- package/lib-es/address.unit.test.d.ts.map +1 -0
- package/lib-es/address.unit.test.js +19 -0
- package/lib-es/address.unit.test.js.map +1 -0
- package/lib-es/api/api-types.d.ts +106 -0
- package/lib-es/api/api-types.d.ts.map +1 -0
- package/lib-es/api/api-types.js +6 -0
- package/lib-es/api/api-types.js.map +1 -0
- package/lib-es/api/getDelegationInfo.d.ts +4 -0
- package/lib-es/api/getDelegationInfo.d.ts.map +1 -0
- package/lib-es/api/getDelegationInfo.js +41 -0
- package/lib-es/api/getDelegationInfo.js.map +1 -0
- package/lib-es/api/getNetworkInfo.d.ts +5 -0
- package/lib-es/api/getNetworkInfo.d.ts.map +1 -0
- package/lib-es/api/getNetworkInfo.js +39 -0
- package/lib-es/api/getNetworkInfo.js.map +1 -0
- package/lib-es/api/getPools.d.ts +5 -0
- package/lib-es/api/getPools.d.ts.map +1 -0
- package/lib-es/api/getPools.js +37 -0
- package/lib-es/api/getPools.js.map +1 -0
- package/lib-es/api/getTransactions.d.ts +10 -0
- package/lib-es/api/getTransactions.d.ts.map +1 -0
- package/lib-es/api/getTransactions.js +132 -0
- package/lib-es/api/getTransactions.js.map +1 -0
- package/lib-es/api/submitTransaction.d.ts +7 -0
- package/lib-es/api/submitTransaction.d.ts.map +1 -0
- package/lib-es/api/submitTransaction.js +27 -0
- package/lib-es/api/submitTransaction.js.map +1 -0
- package/lib-es/bridge/index.d.ts +11 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +61 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge.integration.test.d.ts +4 -0
- package/lib-es/bridge.integration.test.d.ts.map +1 -0
- package/lib-es/bridge.integration.test.js +107 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/broadcast.d.ts +8 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +24 -0
- package/lib-es/broadcast.js.map +1 -0
- package/lib-es/buildOptimisticOperation.d.ts +4 -0
- package/lib-es/buildOptimisticOperation.d.ts.map +1 -0
- package/lib-es/buildOptimisticOperation.js +118 -0
- package/lib-es/buildOptimisticOperation.js.map +1 -0
- package/lib-es/buildSubAccounts.d.ts +26 -0
- package/lib-es/buildSubAccounts.d.ts.map +1 -0
- package/lib-es/buildSubAccounts.js +114 -0
- package/lib-es/buildSubAccounts.js.map +1 -0
- package/lib-es/buildTransaction.d.ts +11 -0
- package/lib-es/buildTransaction.d.ts.map +1 -0
- package/lib-es/buildTransaction.js +335 -0
- package/lib-es/buildTransaction.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +18 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +60 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/constants.d.ts +8 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +9 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/createTransaction.d.ts +9 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +16 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/datasets/rawAccount.1.d.ts +3 -0
- package/lib-es/datasets/rawAccount.1.d.ts.map +1 -0
- package/lib-es/datasets/rawAccount.1.js +17 -0
- package/lib-es/datasets/rawAccount.1.js.map +1 -0
- package/lib-es/datasets/scanAccounts.d.ts +5 -0
- package/lib-es/datasets/scanAccounts.d.ts.map +1 -0
- package/lib-es/datasets/scanAccounts.js +24 -0
- package/lib-es/datasets/scanAccounts.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +11 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +101 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +22 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +15 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/estimateMaxSpendable.d.ts +9 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +49 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/getTransactionStatus.d.ts +4 -0
- package/lib-es/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.js +210 -0
- package/lib-es/getTransactionStatus.js.map +1 -0
- package/lib-es/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib-es/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib-es/getTransactionStatus.unit.test.js +49 -0
- package/lib-es/getTransactionStatus.unit.test.js.map +1 -0
- package/lib-es/hw-getAddress.d.ts +6 -0
- package/lib-es/hw-getAddress.d.ts.map +1 -0
- package/lib-es/hw-getAddress.js +35 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/logic.d.ts +88 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +236 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/logic.unit.test.d.ts +2 -0
- package/lib-es/logic.unit.test.d.ts.map +1 -0
- package/lib-es/logic.unit.test.js +35 -0
- package/lib-es/logic.unit.test.js.map +1 -0
- package/lib-es/networks.d.ts +3 -0
- package/lib-es/networks.d.ts.map +1 -0
- package/lib-es/networks.js +32 -0
- package/lib-es/networks.js.map +1 -0
- package/lib-es/postSyncPatch.d.ts +6 -0
- package/lib-es/postSyncPatch.d.ts.map +1 -0
- package/lib-es/postSyncPatch.js +31 -0
- package/lib-es/postSyncPatch.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts +10 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -0
- package/lib-es/prepareTransaction.js +40 -0
- package/lib-es/prepareTransaction.js.map +1 -0
- package/lib-es/serialization.d.ts +7 -0
- package/lib-es/serialization.d.ts.map +1 -0
- package/lib-es/serialization.js +139 -0
- package/lib-es/serialization.js.map +1 -0
- package/lib-es/signOperation.d.ts +9 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +64 -0
- package/lib-es/signOperation.js.map +1 -0
- package/lib-es/signer.d.ts +92 -0
- package/lib-es/signer.d.ts.map +1 -0
- package/lib-es/signer.js +2 -0
- package/lib-es/signer.js.map +1 -0
- package/lib-es/specs.d.ts +7 -0
- package/lib-es/specs.d.ts.map +1 -0
- package/lib-es/specs.js +213 -0
- package/lib-es/specs.js.map +1 -0
- package/lib-es/speculos-deviceActions.d.ts +4 -0
- package/lib-es/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/speculos-deviceActions.js +125 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/synchronisation.d.ts +6 -0
- package/lib-es/synchronisation.d.ts.map +1 -0
- package/lib-es/synchronisation.js +230 -0
- package/lib-es/synchronisation.js.map +1 -0
- package/lib-es/synchronisation.unit.test.d.ts +2 -0
- package/lib-es/synchronisation.unit.test.d.ts.map +1 -0
- package/lib-es/synchronisation.unit.test.js +124 -0
- package/lib-es/synchronisation.unit.test.js.map +1 -0
- package/lib-es/transaction.d.ts +15 -0
- package/lib-es/transaction.d.ts.map +1 -0
- package/lib-es/transaction.js +37 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types.d.ts +188 -0
- package/lib-es/types.d.ts.map +1 -0
- package/lib-es/types.js +15 -0
- package/lib-es/types.js.map +1 -0
- package/lib-es/typhonSerializer.d.ts +17 -0
- package/lib-es/typhonSerializer.d.ts.map +1 -0
- package/lib-es/typhonSerializer.js +207 -0
- package/lib-es/typhonSerializer.js.map +1 -0
- package/lib-es/utils.d.ts +2 -0
- package/lib-es/utils.d.ts.map +1 -0
- package/lib-es/utils.js +5 -0
- package/lib-es/utils.js.map +1 -0
- package/package.json +91 -0
- package/src/account.ts +39 -0
- package/src/address.unit.test.ts +32 -0
- package/src/api/api-types.ts +115 -0
- package/src/api/getDelegationInfo.ts +39 -0
- package/src/api/getNetworkInfo.ts +34 -0
- package/src/api/getPools.ts +35 -0
- package/src/api/getTransactions.ts +218 -0
- package/src/api/submitTransaction.ts +24 -0
- package/src/bridge/index.ts +69 -0
- package/src/bridge.integration.test.ts +113 -0
- package/src/broadcast.ts +21 -0
- package/src/buildOptimisticOperation.ts +181 -0
- package/src/buildSubAccounts.ts +170 -0
- package/src/buildTransaction.ts +435 -0
- package/src/cli-transaction.ts +82 -0
- package/src/constants.ts +10 -0
- package/src/createTransaction.ts +18 -0
- package/src/datasets/rawAccount.1.ts +19 -0
- package/src/datasets/scanAccounts.ts +23 -0
- package/src/deviceTransactionConfig.ts +128 -0
- package/src/errors.ts +18 -0
- package/src/estimateMaxSpendable.ts +61 -0
- package/src/getTransactionStatus.ts +251 -0
- package/src/getTransactionStatus.unit.test.ts +45 -0
- package/src/hw-getAddress.ts +37 -0
- package/src/logic.ts +330 -0
- package/src/logic.unit.test.ts +39 -0
- package/src/networks.ts +33 -0
- package/src/postSyncPatch.ts +42 -0
- package/src/prepareTransaction.ts +41 -0
- package/src/serialization.ts +219 -0
- package/src/signOperation.ts +82 -0
- package/src/signer.ts +98 -0
- package/src/specs.ts +253 -0
- package/src/speculos-deviceActions.ts +132 -0
- package/src/synchronisation.ts +347 -0
- package/src/synchronisation.unit.test.ts +137 -0
- package/src/transaction.ts +66 -0
- package/src/types.ts +227 -0
- package/src/typhonSerializer.ts +259 -0
- package/src/utils.ts +4 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { CardanoAccount, Transaction } from "./types";
|
|
2
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
3
|
+
/**
|
|
4
|
+
* Prepare transaction before checking status
|
|
5
|
+
*
|
|
6
|
+
* @param {Account} account
|
|
7
|
+
* @param {Transaction} transaction
|
|
8
|
+
*/
|
|
9
|
+
export declare const prepareTransaction: AccountBridge<Transaction, CardanoAccount>["prepareTransaction"];
|
|
10
|
+
//# sourceMappingURL=prepareTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareTransaction.d.ts","sourceRoot":"","sources":["../src/prepareTransaction.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAEtD,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD;;;;;GAKG;AACH,eAAO,MAAM,kBAAkB,EAAE,aAAa,CAC5C,WAAW,EACX,cAAc,CACf,CAAC,oBAAoB,CAuBrB,CAAC"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.prepareTransaction = void 0;
|
|
13
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
14
|
+
const typhonjs_1 = require("@stricahq/typhonjs");
|
|
15
|
+
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
16
|
+
const buildTransaction_1 = require("./buildTransaction");
|
|
17
|
+
/**
|
|
18
|
+
* Prepare transaction before checking status
|
|
19
|
+
*
|
|
20
|
+
* @param {Account} account
|
|
21
|
+
* @param {Transaction} transaction
|
|
22
|
+
*/
|
|
23
|
+
const prepareTransaction = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
24
|
+
let patch = {};
|
|
25
|
+
try {
|
|
26
|
+
const cardanoTransaction = yield (0, buildTransaction_1.buildTransaction)(account, transaction);
|
|
27
|
+
const transactionFees = cardanoTransaction.getFee();
|
|
28
|
+
const transactionAmount = transaction.subAccountId
|
|
29
|
+
? transaction.amount
|
|
30
|
+
: cardanoTransaction
|
|
31
|
+
.getOutputs()
|
|
32
|
+
.filter(o => !(o.address instanceof typhonjs_1.address.BaseAddress) ||
|
|
33
|
+
!(o.address.paymentCredential.type === typhonjs_1.types.HashType.ADDRESS) ||
|
|
34
|
+
o.address.paymentCredential.bipPath === undefined)
|
|
35
|
+
.reduce((total, o) => total.plus(o.amount), new bignumber_js_1.BigNumber(0));
|
|
36
|
+
patch = { fees: transactionFees, amount: transactionAmount };
|
|
37
|
+
}
|
|
38
|
+
catch (error) {
|
|
39
|
+
patch = { fees: new bignumber_js_1.BigNumber(0), amount: transaction.amount };
|
|
40
|
+
}
|
|
41
|
+
return (0, jsHelpers_1.defaultUpdateTransaction)(transaction, patch);
|
|
42
|
+
});
|
|
43
|
+
exports.prepareTransaction = prepareTransaction;
|
|
44
|
+
//# sourceMappingURL=prepareTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"prepareTransaction.js","sourceRoot":"","sources":["../src/prepareTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,+CAAyC;AACzC,iDAAoF;AACpF,yEAAqF;AAGrF,yDAAsD;AAGtD;;;;;GAKG;AACI,MAAM,kBAAkB,GAGL,CAAO,OAAO,EAAE,WAAW,EAAE,EAAE;IACvD,IAAI,KAAK,GAAG,EAAE,CAAC;IACf,IAAI,CAAC;QACH,MAAM,kBAAkB,GAAG,MAAM,IAAA,mCAAgB,EAAC,OAAO,EAAE,WAAW,CAAC,CAAC;QACxE,MAAM,eAAe,GAAG,kBAAkB,CAAC,MAAM,EAAE,CAAC;QACpD,MAAM,iBAAiB,GAAG,WAAW,CAAC,YAAY;YAChD,CAAC,CAAC,WAAW,CAAC,MAAM;YACpB,CAAC,CAAC,kBAAkB;iBACf,UAAU,EAAE;iBACZ,MAAM,CACL,CAAC,CAAC,EAAE,CACF,CAAC,CAAC,CAAC,CAAC,OAAO,YAAY,kBAAa,CAAC,WAAW,CAAC;gBACjD,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,IAAI,KAAK,gBAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;gBACpE,CAAC,CAAC,OAAO,CAAC,iBAAiB,CAAC,OAAO,KAAK,SAAS,CACpD;iBACA,MAAM,CAAC,CAAC,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC,MAAM,CAAC,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC,CAAC,CAAC;QAEpE,KAAK,GAAG,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;IAC/D,CAAC;IAAC,OAAO,KAAK,EAAE,CAAC;QACf,KAAK,GAAG,EAAE,IAAI,EAAE,IAAI,wBAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,CAAC,MAAM,EAAE,CAAC;IACjE,CAAC;IAED,OAAO,IAAA,oCAAwB,EAAC,WAAW,EAAE,KAAK,CAAC,CAAC;AACtD,CAAC,CAAA,CAAC;AA1BW,QAAA,kBAAkB,sBA0B7B"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CardanoResources, CardanoResourcesRaw } from "./types";
|
|
2
|
+
import { Account, AccountRaw } from "@ledgerhq/types-live";
|
|
3
|
+
export declare function toCardanoResourceRaw(r: CardanoResources): CardanoResourcesRaw;
|
|
4
|
+
export declare function fromCardanoResourceRaw(r: CardanoResourcesRaw): CardanoResources;
|
|
5
|
+
export declare function assignToAccountRaw(account: Account, accountRaw: AccountRaw): void;
|
|
6
|
+
export declare function assignFromAccountRaw(accountRaw: AccountRaw, account: Account): void;
|
|
7
|
+
//# sourceMappingURL=serialization.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.d.ts","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EASV,gBAAgB,EAChB,mBAAmB,EAOpB,MAAM,SAAS,CAAC;AACjB,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAsK3D,wBAAgB,oBAAoB,CAAC,CAAC,EAAE,gBAAgB,GAAG,mBAAmB,CAQ7E;AAED,wBAAgB,sBAAsB,CAAC,CAAC,EAAE,mBAAmB,GAAG,gBAAgB,CAQ/E;AAED,wBAAgB,kBAAkB,CAAC,OAAO,EAAE,OAAO,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAOjF;AAED,wBAAgB,oBAAoB,CAAC,UAAU,EAAE,UAAU,EAAE,OAAO,EAAE,OAAO,QAI5E"}
|
|
@@ -0,0 +1,146 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.assignFromAccountRaw = exports.assignToAccountRaw = exports.fromCardanoResourceRaw = exports.toCardanoResourceRaw = void 0;
|
|
4
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
5
|
+
function toTokenRaw({ assetName, policyId, amount }) {
|
|
6
|
+
return {
|
|
7
|
+
assetName,
|
|
8
|
+
policyId,
|
|
9
|
+
amount: amount.toString(),
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function fromTokenRaw({ assetName, policyId, amount }) {
|
|
13
|
+
return {
|
|
14
|
+
assetName,
|
|
15
|
+
policyId,
|
|
16
|
+
amount: new bignumber_js_1.BigNumber(amount),
|
|
17
|
+
};
|
|
18
|
+
}
|
|
19
|
+
function toBipPathRaw({ purpose, coin, account, chain, index }) {
|
|
20
|
+
return {
|
|
21
|
+
purpose,
|
|
22
|
+
coin,
|
|
23
|
+
account,
|
|
24
|
+
chain,
|
|
25
|
+
index,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
function fromBipPathRaw({ purpose, coin, account, chain, index }) {
|
|
29
|
+
return {
|
|
30
|
+
purpose,
|
|
31
|
+
coin,
|
|
32
|
+
account,
|
|
33
|
+
chain,
|
|
34
|
+
index,
|
|
35
|
+
};
|
|
36
|
+
}
|
|
37
|
+
function toPaymentCredentialRaw(r) {
|
|
38
|
+
return {
|
|
39
|
+
isUsed: r.isUsed,
|
|
40
|
+
key: r.key,
|
|
41
|
+
path: toBipPathRaw(r.path),
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
function fromPaymentCredentialRaw(r) {
|
|
45
|
+
return {
|
|
46
|
+
isUsed: r.isUsed,
|
|
47
|
+
key: r.key,
|
|
48
|
+
path: fromBipPathRaw(r.path),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
function toCardanoOutputRaw({ hash, index, address, amount, tokens, paymentCredential, }) {
|
|
52
|
+
return {
|
|
53
|
+
hash,
|
|
54
|
+
index,
|
|
55
|
+
address,
|
|
56
|
+
amount: amount.toString(),
|
|
57
|
+
tokens: tokens.map(toTokenRaw),
|
|
58
|
+
paymentCredential,
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
function fromCardanoOutputRaw({ hash, index, address, amount, tokens, paymentCredential, }) {
|
|
62
|
+
return {
|
|
63
|
+
hash,
|
|
64
|
+
index,
|
|
65
|
+
address,
|
|
66
|
+
amount: new bignumber_js_1.BigNumber(amount),
|
|
67
|
+
tokens: tokens.map(fromTokenRaw),
|
|
68
|
+
paymentCredential,
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function toProtocolParamsRaw({ minFeeA, minFeeB, stakeKeyDeposit, lovelacePerUtxoWord, collateralPercent, priceSteps, priceMem, languageView, }) {
|
|
72
|
+
return {
|
|
73
|
+
minFeeA,
|
|
74
|
+
minFeeB,
|
|
75
|
+
stakeKeyDeposit,
|
|
76
|
+
lovelacePerUtxoWord,
|
|
77
|
+
collateralPercent,
|
|
78
|
+
priceSteps,
|
|
79
|
+
priceMem,
|
|
80
|
+
languageView,
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
function fromProtocolParamsRaw({ minFeeA, minFeeB, stakeKeyDeposit, lovelacePerUtxoWord, collateralPercent, priceSteps, priceMem, languageView, }) {
|
|
84
|
+
return {
|
|
85
|
+
minFeeA,
|
|
86
|
+
minFeeB,
|
|
87
|
+
stakeKeyDeposit,
|
|
88
|
+
lovelacePerUtxoWord,
|
|
89
|
+
collateralPercent,
|
|
90
|
+
priceSteps,
|
|
91
|
+
priceMem,
|
|
92
|
+
languageView,
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function toDelegationRaw({ status, poolId, ticker, name, rewards, }) {
|
|
96
|
+
return {
|
|
97
|
+
status,
|
|
98
|
+
poolId,
|
|
99
|
+
ticker,
|
|
100
|
+
name,
|
|
101
|
+
rewards: rewards.toString(),
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
function fromDelegationRaw({ status, poolId, ticker, name, rewards, }) {
|
|
105
|
+
return {
|
|
106
|
+
status,
|
|
107
|
+
poolId,
|
|
108
|
+
ticker,
|
|
109
|
+
name,
|
|
110
|
+
rewards: new bignumber_js_1.BigNumber(rewards),
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
function toCardanoResourceRaw(r) {
|
|
114
|
+
return {
|
|
115
|
+
internalCredentials: r.internalCredentials.map(toPaymentCredentialRaw),
|
|
116
|
+
externalCredentials: r.externalCredentials.map(toPaymentCredentialRaw),
|
|
117
|
+
delegation: r.delegation ? toDelegationRaw(r.delegation) : undefined,
|
|
118
|
+
utxos: r.utxos.map(toCardanoOutputRaw),
|
|
119
|
+
protocolParams: toProtocolParamsRaw(r.protocolParams),
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
exports.toCardanoResourceRaw = toCardanoResourceRaw;
|
|
123
|
+
function fromCardanoResourceRaw(r) {
|
|
124
|
+
return {
|
|
125
|
+
internalCredentials: r.internalCredentials.map(fromPaymentCredentialRaw),
|
|
126
|
+
externalCredentials: r.externalCredentials.map(fromPaymentCredentialRaw),
|
|
127
|
+
delegation: r.delegation ? fromDelegationRaw(r.delegation) : undefined,
|
|
128
|
+
utxos: r.utxos.map(fromCardanoOutputRaw),
|
|
129
|
+
protocolParams: fromProtocolParamsRaw(r.protocolParams),
|
|
130
|
+
};
|
|
131
|
+
}
|
|
132
|
+
exports.fromCardanoResourceRaw = fromCardanoResourceRaw;
|
|
133
|
+
function assignToAccountRaw(account, accountRaw) {
|
|
134
|
+
const cardanoAccount = account;
|
|
135
|
+
if (cardanoAccount.cardanoResources) {
|
|
136
|
+
accountRaw.cardanoResources = toCardanoResourceRaw(cardanoAccount.cardanoResources);
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
exports.assignToAccountRaw = assignToAccountRaw;
|
|
140
|
+
function assignFromAccountRaw(accountRaw, account) {
|
|
141
|
+
const cardanoResourcesRaw = accountRaw.cardanoResources;
|
|
142
|
+
if (cardanoResourcesRaw)
|
|
143
|
+
account.cardanoResources = fromCardanoResourceRaw(cardanoResourcesRaw);
|
|
144
|
+
}
|
|
145
|
+
exports.assignFromAccountRaw = assignFromAccountRaw;
|
|
146
|
+
//# sourceMappingURL=serialization.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../src/serialization.ts"],"names":[],"mappings":";;;AAAA,+CAAyC;AAqBzC,SAAS,UAAU,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAS;IACxD,OAAO;QACL,SAAS;QACT,QAAQ;QACR,MAAM,EAAE,MAAM,CAAC,QAAQ,EAAE;KAC1B,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAY;IAC7D,OAAO;QACL,SAAS;QACT,QAAQ;QACR,MAAM,EAAE,IAAI,wBAAS,CAAC,MAAM,CAAC;KAC9B,CAAC;AACJ,CAAC;AAED,SAAS,YAAY,CAAC,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAW;IACrE,OAAO;QACL,OAAO;QACP,IAAI;QACJ,OAAO;QACP,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AAG,CAAC,kBAAkB,CAAC;QACtC,cAAc,EAAE,mBAAmB,CAAC,CAAC,CAAC,cAAc,CAAC;KACtD,CAAC;AACJ,CAAC;AARD,oDAQC;AAED,SAAgB,sBAAsB,CAAC,CAAsB;IAC3D,OAAO;QACL,mBAAmB,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,wBAAwB,CAAC;QACxE,mBAAmB,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG,CAAC,wBAAwB,CAAC;QACxE,UAAU,EAAE,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,iBAAiB,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,SAAS;QACtE,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,GAAG,CAAC,oBAAoB,CAAC;QACxC,cAAc,EAAE,qBAAqB,CAAC,CAAC,CAAC,cAAc,CAAC;KACxD,CAAC;AACJ,CAAC;AARD,wDAQC;AAED,SAAgB,kBAAkB,CAAC,OAAgB,EAAE,UAAsB;IACzE,MAAM,cAAc,GAAG,OAAyB,CAAC;IACjD,IAAI,cAAc,CAAC,gBAAgB,EAAE,CAAC;QACnC,UAAgC,CAAC,gBAAgB,GAAG,oBAAoB,CACvE,cAAc,CAAC,gBAAgB,CAChC,CAAC;IACJ,CAAC;AACH,CAAC;AAPD,gDAOC;AAED,SAAgB,oBAAoB,CAAC,UAAsB,EAAE,OAAgB;IAC3E,MAAM,mBAAmB,GAAI,UAAgC,CAAC,gBAAgB,CAAC;IAC/E,IAAI,mBAAmB;QACpB,OAA0B,CAAC,gBAAgB,GAAG,sBAAsB,CAAC,mBAAmB,CAAC,CAAC;AAC/F,CAAC;AAJD,oDAIC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
2
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
3
|
+
import type { CardanoAccount, Transaction } from "./types";
|
|
4
|
+
import { CardanoSigner } from "./signer";
|
|
5
|
+
/**
|
|
6
|
+
* Sign Transaction with Ledger hardware
|
|
7
|
+
*/
|
|
8
|
+
export declare const buildSignOperation: (signerContext: SignerContext<CardanoSigner>) => AccountBridge<Transaction, CardanoAccount>["signOperation"];
|
|
9
|
+
//# sourceMappingURL=signOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signOperation.d.ts","sourceRoot":"","sources":["../src/signOperation.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,aAAa,EAAsB,MAAM,sBAAsB,CAAC;AAGzE,OAAO,KAAK,EAAE,cAAc,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAI3D,OAAO,EAAE,aAAa,EAAW,MAAM,UAAU,CAAC;AAGlD;;GAEG;AACH,eAAO,MAAM,kBAAkB,kBAEZ,cAAc,aAAa,CAAC,KAC1C,cAAc,WAAW,EAAE,cAAc,CAAC,CAAC,eAAe,CAwCzD,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.buildSignOperation = void 0;
|
|
16
|
+
const rxjs_1 = require("rxjs");
|
|
17
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
18
|
+
const buildOptimisticOperation_1 = require("./buildOptimisticOperation");
|
|
19
|
+
const logic_1 = require("./logic");
|
|
20
|
+
const buildTransaction_1 = require("./buildTransaction");
|
|
21
|
+
const networks_1 = require("./networks");
|
|
22
|
+
const typhonSerializer_1 = __importDefault(require("./typhonSerializer"));
|
|
23
|
+
/**
|
|
24
|
+
* Sign Transaction with Ledger hardware
|
|
25
|
+
*/
|
|
26
|
+
const buildSignOperation = (signerContext) => ({ account, deviceId, transaction }) => new rxjs_1.Observable(o => {
|
|
27
|
+
function main() {
|
|
28
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
29
|
+
o.next({ type: "device-signature-requested" });
|
|
30
|
+
if (!transaction.fees) {
|
|
31
|
+
throw new errors_1.FeeNotLoaded();
|
|
32
|
+
}
|
|
33
|
+
const unsignedTransaction = yield (0, buildTransaction_1.buildTransaction)(account, transaction);
|
|
34
|
+
const signerTransaction = (0, typhonSerializer_1.default)(unsignedTransaction, account.index);
|
|
35
|
+
const networkParams = (0, networks_1.getNetworkParameters)(account.currency.id);
|
|
36
|
+
const signedData = yield signerContext(deviceId, signer => signer.sign({
|
|
37
|
+
transaction: signerTransaction,
|
|
38
|
+
networkParams,
|
|
39
|
+
}));
|
|
40
|
+
const accountPubKey = (0, logic_1.getExtendedPublicKeyFromHex)(account.xpub);
|
|
41
|
+
const signed = signTx(unsignedTransaction, accountPubKey, signedData.witnesses);
|
|
42
|
+
o.next({ type: "device-signature-granted" });
|
|
43
|
+
const operation = (0, buildOptimisticOperation_1.buildOptimisticOperation)(account, unsignedTransaction, transaction);
|
|
44
|
+
o.next({
|
|
45
|
+
type: "signed",
|
|
46
|
+
signedOperation: {
|
|
47
|
+
operation,
|
|
48
|
+
signature: signed.payload,
|
|
49
|
+
},
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
main().then(() => o.complete(), e => o.error(e));
|
|
54
|
+
});
|
|
55
|
+
exports.buildSignOperation = buildSignOperation;
|
|
56
|
+
/**
|
|
57
|
+
* Adds signatures to unsigned transaction
|
|
58
|
+
*/
|
|
59
|
+
const signTx = (unsignedTransaction, accountKey, witnesses) => {
|
|
60
|
+
witnesses.forEach(witness => {
|
|
61
|
+
const [, , , chainType, index] = witness.path;
|
|
62
|
+
const publicKey = accountKey.derive(chainType).derive(index).toPublicKey().toBytes();
|
|
63
|
+
const vKeyWitness = {
|
|
64
|
+
signature: Buffer.from(witness.witnessSignatureHex, "hex"),
|
|
65
|
+
publicKey: Buffer.from(publicKey),
|
|
66
|
+
};
|
|
67
|
+
unsignedTransaction.addWitness(vKeyWitness);
|
|
68
|
+
});
|
|
69
|
+
return unsignedTransaction.buildTransaction();
|
|
70
|
+
};
|
|
71
|
+
//# sourceMappingURL=signOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signOperation.js","sourceRoot":"","sources":["../src/signOperation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+BAAkC;AAClC,6CAAgD;AAKhD,yEAAsE;AAEtE,mCAAsD;AACtD,yDAAsD;AACtD,yCAAkD;AAElD,0EAAkD;AAElD;;GAEG;AACI,MAAM,kBAAkB,GAC7B,CACE,aAA2C,EACkB,EAAE,CACjE,CAAC,EAAE,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,EAAkC,EAAE,CACrE,IAAI,iBAAU,CAAC,CAAC,CAAC,EAAE;IACjB,SAAe,IAAI;;YACjB,CAAC,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,4BAA4B,EAAE,CAAC,CAAC;YAE/C,IAAI,CAAC,WAAW,CAAC,IAAI,EAAE,CAAC;gBACtB,MAAM,IAAI,qBAAY,EAAE,CAAC;YAC3B,CAAC;YAED,MAAM,mBAAmB,GAAG,MAAM,IAAA,mCAAg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AC1B,MAAM,CAAC,EAAE,AAAD,EAAG,AAAD,EAAG,SAAS,EAAE,KAAK,CAAC,GAAG,OAAO,CAAC,IAAI,CAAC;QAC9C,MAAM,SAAS,GAAG,UAAU,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,WAAW,EAAE,CAAC,OAAO,EAAE,CAAC;QACrF,MAAM,WAAW,GAA4B;YAC3C,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,mBAAmB,EAAE,KAAK,CAAC;YAC1D,SAAS,EAAE,MAAM,CAAC,IAAI,CAAC,SAAS,CAAC;SAClC,CAAC;QACF,mBAAmB,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,OAAO,mBAAmB,CAAC,gBAAgB,EAAE,CAAC;AAChD,CAAC,CAAC"}
|
package/lib/signer.d.ts
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { CardanoLikeNetworkParameters } from "./types";
|
|
2
|
+
export type CardanoAddress = {
|
|
3
|
+
addressHex: string;
|
|
4
|
+
};
|
|
5
|
+
type BIP32Path = Array<number>;
|
|
6
|
+
export type Witness = {
|
|
7
|
+
path: BIP32Path;
|
|
8
|
+
witnessSignatureHex: string;
|
|
9
|
+
};
|
|
10
|
+
export type CardanoSignature = {
|
|
11
|
+
txHashHex: string;
|
|
12
|
+
witnesses: Array<Witness>;
|
|
13
|
+
};
|
|
14
|
+
export type CardanoExtendedPublicKey = {
|
|
15
|
+
publicKeyHex: string;
|
|
16
|
+
chainCodeHex: string;
|
|
17
|
+
};
|
|
18
|
+
export type GetAddressRequest = {
|
|
19
|
+
path: string;
|
|
20
|
+
stakingPathString: string;
|
|
21
|
+
networkParams: CardanoLikeNetworkParameters;
|
|
22
|
+
verify?: boolean;
|
|
23
|
+
};
|
|
24
|
+
export type SignerTxInput = {
|
|
25
|
+
txHashHex: string;
|
|
26
|
+
outputIndex: number;
|
|
27
|
+
path: string | null;
|
|
28
|
+
};
|
|
29
|
+
export type SignerTxOutput = {
|
|
30
|
+
amount: string;
|
|
31
|
+
destination: {
|
|
32
|
+
isDeviceOwnedAddress: false;
|
|
33
|
+
params: {
|
|
34
|
+
addressHex: string;
|
|
35
|
+
};
|
|
36
|
+
} | {
|
|
37
|
+
isDeviceOwnedAddress: true;
|
|
38
|
+
params: {
|
|
39
|
+
spendingPath: string;
|
|
40
|
+
stakingPath: string;
|
|
41
|
+
};
|
|
42
|
+
};
|
|
43
|
+
tokenBundle: Array<{
|
|
44
|
+
policyIdHex: string;
|
|
45
|
+
tokens: Array<{
|
|
46
|
+
assetNameHex: string;
|
|
47
|
+
amount: string;
|
|
48
|
+
}>;
|
|
49
|
+
}>;
|
|
50
|
+
};
|
|
51
|
+
export type SignerTxCertificate = {
|
|
52
|
+
type: "REGISTRATION" | "DEREGISTRATION";
|
|
53
|
+
params: {
|
|
54
|
+
stakeCredential: {
|
|
55
|
+
keyPath: string;
|
|
56
|
+
};
|
|
57
|
+
};
|
|
58
|
+
} | {
|
|
59
|
+
type: "DELEGATION";
|
|
60
|
+
params: {
|
|
61
|
+
stakeCredential: {
|
|
62
|
+
keyPath: string;
|
|
63
|
+
};
|
|
64
|
+
poolKeyHashHex: string;
|
|
65
|
+
};
|
|
66
|
+
};
|
|
67
|
+
export type SignerTxWithdrawal = {
|
|
68
|
+
stakeCredential: {
|
|
69
|
+
keyPath: string;
|
|
70
|
+
};
|
|
71
|
+
amount: string;
|
|
72
|
+
};
|
|
73
|
+
export type SignerTransaction = {
|
|
74
|
+
inputs: Array<SignerTxInput>;
|
|
75
|
+
outputs: Array<SignerTxOutput>;
|
|
76
|
+
certificates: Array<SignerTxCertificate>;
|
|
77
|
+
withdrawals: Array<SignerTxWithdrawal>;
|
|
78
|
+
fee: string;
|
|
79
|
+
ttl?: string;
|
|
80
|
+
auxiliaryData: string | null;
|
|
81
|
+
};
|
|
82
|
+
export type CardanoSignRequest = {
|
|
83
|
+
transaction: SignerTransaction;
|
|
84
|
+
networkParams: CardanoLikeNetworkParameters;
|
|
85
|
+
};
|
|
86
|
+
export interface CardanoSigner {
|
|
87
|
+
getAddress(addressRequest: GetAddressRequest): Promise<CardanoAddress>;
|
|
88
|
+
getPublicKey(accountPath: string): Promise<CardanoExtendedPublicKey>;
|
|
89
|
+
sign(signRequest: CardanoSignRequest): Promise<CardanoSignature>;
|
|
90
|
+
}
|
|
91
|
+
export {};
|
|
92
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,4BAA4B,EAAE,MAAM,SAAS,CAAC;AAEvD,MAAM,MAAM,cAAc,GAAG;IAC3B,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,KAAK,SAAS,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC;AAC/B,MAAM,MAAM,OAAO,GAAG;IACpB,IAAI,EAAE,SAAS,CAAC;IAChB,mBAAmB,EAAE,MAAM,CAAC;CAC7B,CAAC;AACF,MAAM,MAAM,gBAAgB,GAAG;IAC7B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,KAAK,CAAC,OAAO,CAAC,CAAC;CAC3B,CAAC;AAEF,MAAM,MAAM,wBAAwB,GAAG;IACrC,YAAY,EAAE,MAAM,CAAC;IACrB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AACF,MAAM,MAAM,iBAAiB,GAAG;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,4BAA4B,CAAC;IAC5C,MAAM,CAAC,EAAE,OAAO,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,aAAa,GAAG;IAC1B,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,MAAM,GAAG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AAG,EAAE,MAAM,CAAC;IACZ,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,aAAa,EAAE,MAAM,GAAG,IAAI,CAAC;CAC9B,CAAC;AACF,MAAM,MAAM,kBAAkB,GAAG;IAC/B,WAAW,EAAE,iBAAiB,CAAC;IAC/B,aAAa,EAAE,4BAA4B,CAAC;CAC7C,CAAC;AACF,MAAM,WAAW,aAAa;IAC5B,UAAU,CAAC,cAAc,EAAE,iBAAiB,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;IACvE,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,wBAAwB,CAAC,CAAC;IACrE,IAAI,CAAC,WAAW,EAAE,kBAAkB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC;CAClE"}
|
package/lib/signer.js
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":""}
|
package/lib/specs.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"specs.d.ts","sourceRoot":"","sources":["../src/specs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oCAAoC,CAAC;AAClE,OAAO,KAAK,EAA2D,WAAW,EAAE,MAAM,SAAS,CAAC;;;;AA0PpG,wBAA2B"}
|
package/lib/specs.js
ADDED
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const expect_1 = __importDefault(require("expect"));
|
|
7
|
+
const specs_1 = require("@ledgerhq/coin-framework/bot/specs");
|
|
8
|
+
const cryptoassets_1 = require("@ledgerhq/cryptoassets");
|
|
9
|
+
const devices_1 = require("@ledgerhq/devices");
|
|
10
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
11
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
12
|
+
const typhonjs_1 = require("@stricahq/typhonjs");
|
|
13
|
+
const logic_1 = require("./logic");
|
|
14
|
+
const index_1 = require("@ledgerhq/coin-framework/currencies/index");
|
|
15
|
+
const speculos_deviceActions_1 = require("./speculos-deviceActions");
|
|
16
|
+
const maxAccounts = 5;
|
|
17
|
+
const currency = (0, cryptoassets_1.getCryptoCurrencyById)("cardano");
|
|
18
|
+
const minBalanceRequired = (0, index_1.parseCurrencyUnit)(currency.units[0], "2.2");
|
|
19
|
+
const minBalanceRequiredForMaxSend = (0, index_1.parseCurrencyUnit)(currency.units[0], "1");
|
|
20
|
+
const minBalanceRequiredForDelegate = (0, index_1.parseCurrencyUnit)(currency.units[0], "3");
|
|
21
|
+
const minSpendableRequiredForTokenTx = (0, index_1.parseCurrencyUnit)(currency.units[0], "1");
|
|
22
|
+
const cardano = {
|
|
23
|
+
name: "cardano",
|
|
24
|
+
currency: (0, cryptoassets_1.getCryptoCurrencyById)("cardano"),
|
|
25
|
+
appQuery: {
|
|
26
|
+
model: devices_1.DeviceModelId.nanoSP,
|
|
27
|
+
appName: "CardanoADA",
|
|
28
|
+
// FIXME latest (v7) app version requires to update cardano libs
|
|
29
|
+
appVersion: "6.1.2",
|
|
30
|
+
},
|
|
31
|
+
minViableAmount: minBalanceRequired,
|
|
32
|
+
genericDeviceAction: speculos_deviceActions_1.acceptTransaction,
|
|
33
|
+
testTimeout: 5 * 60 * 1000,
|
|
34
|
+
mutations: [
|
|
35
|
+
{
|
|
36
|
+
name: "move ~10% token",
|
|
37
|
+
maxRun: 1,
|
|
38
|
+
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
39
|
+
var _a;
|
|
40
|
+
(0, invariant_1.default)(maxSpendable.gte(minSpendableRequiredForTokenTx), "balance is too low");
|
|
41
|
+
const sibling = (0, specs_1.pickSiblings)(siblings, maxAccounts);
|
|
42
|
+
const recipient = sibling.freshAddress;
|
|
43
|
+
const transaction = bridge.createTransaction(account);
|
|
44
|
+
const subAccount = (_a = account.subAccounts) === null || _a === void 0 ? void 0 : _a.find(subAccount => subAccount.balance.gt(1));
|
|
45
|
+
(0, invariant_1.default)(subAccount, "No token account with balance");
|
|
46
|
+
const updates = [
|
|
47
|
+
{ subAccountId: subAccount.id },
|
|
48
|
+
{ recipient },
|
|
49
|
+
{
|
|
50
|
+
amount: new bignumber_js_1.default(subAccount.balance.dividedBy(10)).dp(0, bignumber_js_1.default.ROUND_CEIL),
|
|
51
|
+
},
|
|
52
|
+
];
|
|
53
|
+
return {
|
|
54
|
+
transaction,
|
|
55
|
+
updates,
|
|
56
|
+
};
|
|
57
|
+
},
|
|
58
|
+
test: ({ operation, transaction }) => {
|
|
59
|
+
(0, specs_1.botTest)("subOperations is defined", () => (0, expect_1.default)(operation.subOperations).toBeTruthy());
|
|
60
|
+
(0, specs_1.botTest)("there's only one subOperation", () => { var _a; return (0, expect_1.default)((_a = operation.subOperations) === null || _a === void 0 ? void 0 : _a.length).toEqual(1); });
|
|
61
|
+
const subOperation = operation.subOperations && operation.subOperations[0];
|
|
62
|
+
(0, specs_1.botTest)("subOperation have correct tx amount", () => (0, expect_1.default)(subOperation === null || subOperation === void 0 ? void 0 : subOperation.value).toEqual(transaction.amount));
|
|
63
|
+
},
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
testDestination: specs_1.genericTestDestination,
|
|
67
|
+
name: "move ~50%",
|
|
68
|
+
maxRun: 1,
|
|
69
|
+
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
70
|
+
(0, invariant_1.default)(maxSpendable.gt(minBalanceRequired), "balance is too low");
|
|
71
|
+
const sibling = (0, specs_1.pickSiblings)(siblings, maxAccounts);
|
|
72
|
+
const recipient = sibling.freshAddress;
|
|
73
|
+
const transaction = bridge.createTransaction(account);
|
|
74
|
+
const updates = [
|
|
75
|
+
{ recipient },
|
|
76
|
+
{
|
|
77
|
+
amount: new bignumber_js_1.default(account.balance.dividedBy(2)).dp(0, bignumber_js_1.default.ROUND_CEIL),
|
|
78
|
+
},
|
|
79
|
+
{ memo: "LedgerLiveBot" },
|
|
80
|
+
];
|
|
81
|
+
return {
|
|
82
|
+
transaction,
|
|
83
|
+
updates,
|
|
84
|
+
};
|
|
85
|
+
},
|
|
86
|
+
test: ({ accountBeforeTransaction, operation, transaction }) => {
|
|
87
|
+
var _a;
|
|
88
|
+
const cardanoResources = accountBeforeTransaction
|
|
89
|
+
.cardanoResources;
|
|
90
|
+
const extra = {
|
|
91
|
+
memo: transaction.memo,
|
|
92
|
+
};
|
|
93
|
+
if ((_a = cardanoResources.delegation) === null || _a === void 0 ? void 0 : _a.rewards.gt(0)) {
|
|
94
|
+
extra.rewards = (0, index_1.formatCurrencyUnit)(accountBeforeTransaction.currency.units[0], new bignumber_js_1.default(cardanoResources.delegation.rewards), {
|
|
95
|
+
showCode: true,
|
|
96
|
+
disableRounding: true,
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
(0, specs_1.botTest)("operation extra matches memo", () => (0, expect_1.default)(operation.extra).toEqual(extra));
|
|
100
|
+
(0, specs_1.botTest)("optimistic value matches transaction amount", () => (0, expect_1.default)(transaction.amount).toEqual(operation.value.minus(operation.fee)));
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
name: "send max",
|
|
105
|
+
maxRun: 1,
|
|
106
|
+
testDestination: specs_1.genericTestDestination,
|
|
107
|
+
transaction: ({ account, siblings, bridge, maxSpendable }) => {
|
|
108
|
+
(0, invariant_1.default)(maxSpendable.gt(minBalanceRequiredForMaxSend), "balance is too low");
|
|
109
|
+
const sibling = (0, specs_1.pickSiblings)(siblings, maxAccounts);
|
|
110
|
+
const recipient = sibling.freshAddress;
|
|
111
|
+
const transaction = bridge.createTransaction(account);
|
|
112
|
+
const updates = [{ recipient }, { useAllAmount: true }];
|
|
113
|
+
return {
|
|
114
|
+
transaction,
|
|
115
|
+
updates,
|
|
116
|
+
};
|
|
117
|
+
},
|
|
118
|
+
test: ({ account }) => {
|
|
119
|
+
const cardanoResources = account.cardanoResources;
|
|
120
|
+
const utxoTokens = cardanoResources.utxos.map(u => u.tokens).flat();
|
|
121
|
+
const tokenBalance = (0, logic_1.mergeTokens)(utxoTokens);
|
|
122
|
+
const requiredAdaForTokens = tokenBalance.length
|
|
123
|
+
? typhonjs_1.utils.calculateMinUtxoAmount(tokenBalance, new bignumber_js_1.default(cardanoResources.protocolParams.lovelacePerUtxoWord), false)
|
|
124
|
+
: new bignumber_js_1.default(0);
|
|
125
|
+
(0, specs_1.botTest)("remaining balance equals requiredAdaForTokens)", () => (0, expect_1.default)(account.balance).toEqual(requiredAdaForTokens));
|
|
126
|
+
},
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
name: "delegate to pool",
|
|
130
|
+
maxRun: 1,
|
|
131
|
+
transaction: ({ account, bridge, maxSpendable }) => {
|
|
132
|
+
(0, invariant_1.default)(maxSpendable.gte(minBalanceRequiredForDelegate), "balance is too low");
|
|
133
|
+
const transaction = bridge.createTransaction(account);
|
|
134
|
+
return {
|
|
135
|
+
transaction,
|
|
136
|
+
updates: [
|
|
137
|
+
{
|
|
138
|
+
mode: "delegate",
|
|
139
|
+
poolId: "7df262feae9201d1b2e32d4c825ca91b29fbafb2b8e556f6efb7f549",
|
|
140
|
+
},
|
|
141
|
+
],
|
|
142
|
+
};
|
|
143
|
+
},
|
|
144
|
+
test: ({ operation, transaction, accountBeforeTransaction }) => {
|
|
145
|
+
(0, specs_1.botTest)("check delegate operation type", () => {
|
|
146
|
+
(0, expect_1.default)(operation.type).toEqual("DELEGATE");
|
|
147
|
+
});
|
|
148
|
+
(0, specs_1.botTest)("check operation value", () => {
|
|
149
|
+
var _a, _b;
|
|
150
|
+
const cardanoResources = accountBeforeTransaction.cardanoResources;
|
|
151
|
+
const isStakeKeyRegistered = (_b = (_a = cardanoResources.delegation) === null || _a === void 0 ? void 0 : _a.status) !== null && _b !== void 0 ? _b : false;
|
|
152
|
+
let opValue = transaction.fees;
|
|
153
|
+
if (!isStakeKeyRegistered) {
|
|
154
|
+
opValue = opValue.plus(cardanoResources.protocolParams.stakeKeyDeposit);
|
|
155
|
+
}
|
|
156
|
+
(0, expect_1.default)(operation.value.toString()).toEqual(opValue.toString());
|
|
157
|
+
});
|
|
158
|
+
},
|
|
159
|
+
},
|
|
160
|
+
{
|
|
161
|
+
name: "redelegate to pool",
|
|
162
|
+
maxRun: 1,
|
|
163
|
+
transaction: ({ account, bridge, maxSpendable }) => {
|
|
164
|
+
var _a;
|
|
165
|
+
(0, invariant_1.default)(maxSpendable.gte(minBalanceRequiredForDelegate), "balance is too low");
|
|
166
|
+
(0, invariant_1.default)((_a = account.cardanoResources.delegation) === null || _a === void 0 ? void 0 : _a.poolId, "account should already be delegated to redelegate");
|
|
167
|
+
const transaction = bridge.createTransaction(account);
|
|
168
|
+
return {
|
|
169
|
+
transaction,
|
|
170
|
+
updates: [
|
|
171
|
+
{
|
|
172
|
+
mode: "delegate",
|
|
173
|
+
poolId: "da50099e7aa1d926e1888990b1c404caf554dd6f68a1cb0322999d1d",
|
|
174
|
+
},
|
|
175
|
+
],
|
|
176
|
+
};
|
|
177
|
+
},
|
|
178
|
+
test: ({ operation, transaction }) => {
|
|
179
|
+
(0, specs_1.botTest)("check delegate operation type", () => {
|
|
180
|
+
(0, expect_1.default)(operation.type).toEqual("DELEGATE");
|
|
181
|
+
});
|
|
182
|
+
(0, specs_1.botTest)("op value should be equal to fees", () => {
|
|
183
|
+
var _a;
|
|
184
|
+
(0, expect_1.default)(operation.value.toString()).toEqual((_a = transaction.fees) === null || _a === void 0 ? void 0 : _a.toString());
|
|
185
|
+
});
|
|
186
|
+
},
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
name: "undelegate",
|
|
190
|
+
maxRun: 1,
|
|
191
|
+
transaction: ({ account, bridge, maxSpendable }) => {
|
|
192
|
+
var _a;
|
|
193
|
+
(0, invariant_1.default)(maxSpendable.gte(minBalanceRequiredForDelegate), "balance is too low");
|
|
194
|
+
(0, invariant_1.default)((_a = account.cardanoResources.delegation) === null || _a === void 0 ? void 0 : _a.poolId, "account should already be delegated to undelegate");
|
|
195
|
+
const transaction = bridge.createTransaction(account);
|
|
196
|
+
return {
|
|
197
|
+
transaction,
|
|
198
|
+
updates: [
|
|
199
|
+
{
|
|
200
|
+
mode: "undelegate",
|
|
201
|
+
},
|
|
202
|
+
],
|
|
203
|
+
};
|
|
204
|
+
},
|
|
205
|
+
test: ({ operation, transaction }) => {
|
|
206
|
+
(0, specs_1.botTest)("check undelegate operation type", () => {
|
|
207
|
+
(0, expect_1.default)(operation.type).toEqual("UNDELEGATE");
|
|
208
|
+
});
|
|
209
|
+
(0, specs_1.botTest)("op value should be equal to fees", () => {
|
|
210
|
+
var _a;
|
|
211
|
+
(0, expect_1.default)(operation.value.toString()).toEqual((_a = transaction.fees) === null || _a === void 0 ? void 0 : _a.toString());
|
|
212
|
+
});
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
],
|
|
216
|
+
};
|
|
217
|
+
exports.default = { cardano };
|
|
218
|
+
//# sourceMappingURL=specs.js.map
|