@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,26 @@
|
|
|
1
|
+
import type { Account, TokenAccount } from "@ledgerhq/types-live";
|
|
2
|
+
import type { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
3
|
+
import { PaymentCredential, Token } from "./types";
|
|
4
|
+
import { APITransaction } from "./api/api-types";
|
|
5
|
+
export declare const getTokenAssetId: ({ policyId, assetName, }: {
|
|
6
|
+
policyId: string;
|
|
7
|
+
assetName: string;
|
|
8
|
+
}) => string;
|
|
9
|
+
export declare const decodeTokenAssetId: (id: string) => {
|
|
10
|
+
policyId: string;
|
|
11
|
+
assetName: string;
|
|
12
|
+
};
|
|
13
|
+
export declare const decodeTokenCurrencyId: (id: string) => {
|
|
14
|
+
parentCurrencyId: string;
|
|
15
|
+
type: string;
|
|
16
|
+
assetId: string;
|
|
17
|
+
};
|
|
18
|
+
export declare function buildSubAccounts({ initialAccount, parentAccountId, parentCurrency, newTransactions, tokens, accountCredentialsMap, }: {
|
|
19
|
+
initialAccount: Account | undefined;
|
|
20
|
+
parentAccountId: string;
|
|
21
|
+
parentCurrency: CryptoCurrency;
|
|
22
|
+
newTransactions: Array<APITransaction>;
|
|
23
|
+
tokens: Array<Token>;
|
|
24
|
+
accountCredentialsMap: Record<string, PaymentCredential>;
|
|
25
|
+
}): Array<TokenAccount>;
|
|
26
|
+
//# sourceMappingURL=buildSubAccounts.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSubAccounts.d.ts","sourceRoot":"","sources":["../src/buildSubAccounts.ts"],"names":[],"mappings":"AAUA,OAAO,KAAK,EAAE,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAClE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAGnE,OAAO,EAA2C,iBAAiB,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAE5F,OAAO,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEjD,eAAO,MAAM,eAAe;cAIhB,MAAM;eACL,MAAM;MACf,MAAmC,CAAC;AAExC,eAAO,MAAM,kBAAkB,OAAQ,MAAM;cAAe,MAAM;eAAa,MAAM;CAIpF,CAAC;AAKF,eAAO,MAAM,qBAAqB,OAC5B,MAAM;sBACW,MAAM;UAAQ,MAAM;aAAW,MAAM;CAO3D,CAAC;AAiEF,wBAAgB,gBAAgB,CAAC,EAC/B,cAAc,EACd,eAAe,EACf,cAAc,EACd,eAAe,EACf,MAAM,EACN,qBAAqB,GACtB,EAAE;IACD,cAAc,EAAE,OAAO,GAAG,SAAS,CAAC;IACpC,eAAe,EAAE,MAAM,CAAC;IACxB,cAAc,EAAE,cAAc,CAAC;IAC/B,eAAe,EAAE,KAAK,CAAC,cAAc,CAAC,CAAC;IACvC,MAAM,EAAE,KAAK,CAAC,KAAK,CAAC,CAAC;IACrB,qBAAqB,EAAE,MAAM,CAAC,MAAM,EAAE,iBAAiB,CAAC,CAAC;CAC1D,GAAG,KAAK,CAAC,YAAY,CAAC,CA8CtB"}
|
|
@@ -0,0 +1,124 @@
|
|
|
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
|
+
exports.buildSubAccounts = exports.decodeTokenCurrencyId = exports.decodeTokenAssetId = exports.getTokenAssetId = void 0;
|
|
7
|
+
const index_1 = require("@ledgerhq/coin-framework/account/index");
|
|
8
|
+
const keyBy_1 = __importDefault(require("lodash/keyBy"));
|
|
9
|
+
const groupBy_1 = __importDefault(require("lodash/groupBy"));
|
|
10
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
11
|
+
const cryptoassets_1 = require("@ledgerhq/cryptoassets");
|
|
12
|
+
const typhonjs_1 = require("@stricahq/typhonjs");
|
|
13
|
+
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
14
|
+
const operation_1 = require("@ledgerhq/coin-framework/operation");
|
|
15
|
+
const logic_1 = require("./logic");
|
|
16
|
+
const getTokenAssetId = ({ policyId, assetName, }) => `${policyId}${assetName}`;
|
|
17
|
+
exports.getTokenAssetId = getTokenAssetId;
|
|
18
|
+
const decodeTokenAssetId = (id) => {
|
|
19
|
+
const policyId = id.slice(0, 56);
|
|
20
|
+
const assetName = id.slice(56);
|
|
21
|
+
return { policyId, assetName };
|
|
22
|
+
};
|
|
23
|
+
exports.decodeTokenAssetId = decodeTokenAssetId;
|
|
24
|
+
const encodeTokenCurrencyId = (parentCurrency, assetId) => `${parentCurrency.id}/native/${assetId}`;
|
|
25
|
+
const decodeTokenCurrencyId = (id) => {
|
|
26
|
+
const [parentCurrencyId, type, assetId] = id.split("/");
|
|
27
|
+
return {
|
|
28
|
+
parentCurrencyId,
|
|
29
|
+
type,
|
|
30
|
+
assetId,
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
exports.decodeTokenCurrencyId = decodeTokenCurrencyId;
|
|
34
|
+
/**
|
|
35
|
+
* @returns operations of tokens that are defined in ledgerjs cryptoassets
|
|
36
|
+
*/
|
|
37
|
+
const mapTxToTokenAccountOperation = ({ parentAccountId, parentCurrency, newTransactions, accountCredentialsMap, }) => {
|
|
38
|
+
const operations = [];
|
|
39
|
+
newTransactions.forEach(tx => {
|
|
40
|
+
const accountChange = (0, logic_1.getAccountChange)(tx, accountCredentialsMap);
|
|
41
|
+
accountChange.tokens.forEach(token => {
|
|
42
|
+
const assetId = (0, exports.getTokenAssetId)({
|
|
43
|
+
policyId: token.policyId,
|
|
44
|
+
assetName: token.assetName,
|
|
45
|
+
});
|
|
46
|
+
const tokenCurrencyId = encodeTokenCurrencyId(parentCurrency, assetId);
|
|
47
|
+
const tokenCurrency = (0, cryptoassets_1.findTokenById)(tokenCurrencyId);
|
|
48
|
+
// skip the unsupported tokens by ledger-live
|
|
49
|
+
if (tokenCurrency === null || tokenCurrency === undefined) {
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
const tokenAccountId = (0, index_1.encodeTokenAccountId)(parentAccountId, tokenCurrency);
|
|
53
|
+
const tokenOperationType = token.amount.lt(0) ? "OUT" : "IN";
|
|
54
|
+
const memo = (0, logic_1.getMemoFromTx)(tx);
|
|
55
|
+
const extra = {};
|
|
56
|
+
if (memo) {
|
|
57
|
+
extra.memo = memo;
|
|
58
|
+
}
|
|
59
|
+
const operation = {
|
|
60
|
+
accountId: tokenAccountId,
|
|
61
|
+
id: (0, operation_1.encodeOperationId)(tokenAccountId, tx.hash, tokenOperationType),
|
|
62
|
+
hash: tx.hash,
|
|
63
|
+
type: tokenOperationType,
|
|
64
|
+
fee: new bignumber_js_1.default(tx.fees),
|
|
65
|
+
value: token.amount.absoluteValue(),
|
|
66
|
+
senders: tx.inputs.map(i => (0, logic_1.isHexString)(i.address) ? typhonjs_1.utils.getAddressFromHex(i.address).getBech32() : i.address),
|
|
67
|
+
recipients: tx.outputs.map(o => (0, logic_1.isHexString)(o.address) ? typhonjs_1.utils.getAddressFromHex(o.address).getBech32() : o.address),
|
|
68
|
+
blockHeight: tx.blockHeight,
|
|
69
|
+
date: new Date(tx.timestamp),
|
|
70
|
+
extra,
|
|
71
|
+
blockHash: undefined,
|
|
72
|
+
};
|
|
73
|
+
operations.push(operation);
|
|
74
|
+
});
|
|
75
|
+
});
|
|
76
|
+
return operations;
|
|
77
|
+
};
|
|
78
|
+
function buildSubAccounts({ initialAccount, parentAccountId, parentCurrency, newTransactions, tokens, accountCredentialsMap, }) {
|
|
79
|
+
var _a;
|
|
80
|
+
const tokenAccountsById = {};
|
|
81
|
+
if (initialAccount && initialAccount.subAccounts) {
|
|
82
|
+
for (const existingAccount of initialAccount.subAccounts) {
|
|
83
|
+
if (existingAccount.type === "TokenAccount") {
|
|
84
|
+
tokenAccountsById[existingAccount.id] = existingAccount;
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const tokenOperations = mapTxToTokenAccountOperation({
|
|
89
|
+
parentAccountId,
|
|
90
|
+
parentCurrency,
|
|
91
|
+
newTransactions: newTransactions,
|
|
92
|
+
accountCredentialsMap,
|
|
93
|
+
});
|
|
94
|
+
const tokenOperationsByAccId = (0, groupBy_1.default)(tokenOperations, o => o.accountId);
|
|
95
|
+
const tokensBalanceByAssetId = (0, keyBy_1.default)(tokens, t => (0, exports.getTokenAssetId)(t));
|
|
96
|
+
for (const tokenAccountId in tokenOperationsByAccId) {
|
|
97
|
+
const initialTokenAccount = tokenAccountsById[tokenAccountId];
|
|
98
|
+
const oldOperations = (initialTokenAccount === null || initialTokenAccount === void 0 ? void 0 : initialTokenAccount.operations) || [];
|
|
99
|
+
const newOperations = tokenOperationsByAccId[tokenAccountId] || [];
|
|
100
|
+
const operations = (0, jsHelpers_1.mergeOps)(oldOperations, newOperations);
|
|
101
|
+
const { token: tokenCurrency } = (0, index_1.decodeTokenAccountId)(tokenAccountId);
|
|
102
|
+
if (tokenCurrency) {
|
|
103
|
+
const accountBalance = ((_a = tokensBalanceByAssetId[tokenCurrency.contractAddress]) === null || _a === void 0 ? void 0 : _a.amount) || new bignumber_js_1.default(0);
|
|
104
|
+
const tokenAccount = {
|
|
105
|
+
type: "TokenAccount",
|
|
106
|
+
id: tokenAccountId,
|
|
107
|
+
parentId: parentAccountId,
|
|
108
|
+
token: tokenCurrency,
|
|
109
|
+
balance: accountBalance,
|
|
110
|
+
spendableBalance: accountBalance,
|
|
111
|
+
creationDate: operations.length > 0 ? operations[operations.length - 1].date : new Date(),
|
|
112
|
+
operationsCount: operations.length,
|
|
113
|
+
operations,
|
|
114
|
+
pendingOperations: [],
|
|
115
|
+
balanceHistoryCache: index_1.emptyHistoryCache,
|
|
116
|
+
swapHistory: [],
|
|
117
|
+
};
|
|
118
|
+
tokenAccountsById[tokenAccountId] = tokenAccount;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
return Object.values(tokenAccountsById);
|
|
122
|
+
}
|
|
123
|
+
exports.buildSubAccounts = buildSubAccounts;
|
|
124
|
+
//# sourceMappingURL=buildSubAccounts.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildSubAccounts.js","sourceRoot":"","sources":["../src/buildSubAccounts.ts"],"names":[],"mappings":";;;;;;AAAA,kEAIgD;AAChD,yDAAiC;AACjC,6DAAqC;AACrC,gEAAqC;AACrC,yDAAuD;AACvD,iDAA0D;AAG1D,yEAAqE;AACrE,kEAAuE;AAEvE,mCAAuE;AAGhE,MAAM,eAAe,GAAG,CAAC,EAC9B,QAAQ,EACR,SAAS,GAIV,EAAU,EAAE,CAAC,GAAG,QAAQ,GAAG,SAAS,EAAE,CAAC;AAN3B,QAAA,eAAe,mBAMY;AAEjC,MAAM,kBAAkB,GAAG,CAAC,EAAU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onTransaction } from "@stricahq/typhonjs";
|
|
2
|
+
import { CardanoAccount, Transaction } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
*
|
|
5
|
+
* @param {CardanoAccount} account
|
|
6
|
+
* @param {Transaction} transaction
|
|
7
|
+
*
|
|
8
|
+
* @returns {TyphonTransaction}
|
|
9
|
+
*/
|
|
10
|
+
export declare const buildTransaction: (account: CardanoAccount, transaction: Transaction) => Promise<TyphonTransaction>;
|
|
11
|
+
//# sourceMappingURL=buildTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTransaction.d.ts","sourceRoot":"","sources":["../src/buildTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,WAAW,IAAI,iBAAiB,EAGjC,MAAM,oBAAoB,CAAC;AAO5B,OAAO,EACL,cAAc,EAKd,WAAW,EACZ,MAAM,SAAS,CAAC;AAuUjB;;;;;;GAMG;AACH,eAAO,MAAM,gBAAgB,YAClB,cAAc,eACV,WAAW,KACvB,QAAQ,iBAAiB,CA+E3B,CAAC"}
|
|
@@ -0,0 +1,342 @@
|
|
|
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.buildTransaction = void 0;
|
|
16
|
+
const typhonjs_1 = require("@stricahq/typhonjs");
|
|
17
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
18
|
+
const address_1 = require("@stricahq/typhonjs/dist/address");
|
|
19
|
+
const logic_1 = require("./logic");
|
|
20
|
+
const buildSubAccounts_1 = require("./buildSubAccounts");
|
|
21
|
+
const networks_1 = require("./networks");
|
|
22
|
+
function getTyphonInputFromUtxo(utxo) {
|
|
23
|
+
const address = typhonjs_1.utils.getAddressFromHex(utxo.address);
|
|
24
|
+
if (address.paymentCredential.type === typhonjs_1.types.HashType.ADDRESS) {
|
|
25
|
+
address.paymentCredential.bipPath = utxo.paymentCredential.path;
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
txId: utxo.hash,
|
|
29
|
+
index: utxo.index,
|
|
30
|
+
amount: new bignumber_js_1.default(utxo.amount),
|
|
31
|
+
tokens: utxo.tokens,
|
|
32
|
+
address: address,
|
|
33
|
+
};
|
|
34
|
+
}
|
|
35
|
+
function getRewardWithdrawalCertificate(account) {
|
|
36
|
+
var _a;
|
|
37
|
+
if (!((_a = account.cardanoResources.delegation) === null || _a === void 0 ? void 0 : _a.rewards.gt(0))) {
|
|
38
|
+
return null;
|
|
39
|
+
}
|
|
40
|
+
const stakeCredential = (0, logic_1.getAccountStakeCredential)(account.xpub, account.index);
|
|
41
|
+
const stakeKeyHashCredential = {
|
|
42
|
+
hash: stakeCredential.key,
|
|
43
|
+
type: typhonjs_1.types.HashType.ADDRESS,
|
|
44
|
+
bipPath: stakeCredential.path,
|
|
45
|
+
};
|
|
46
|
+
const networkId = (0, logic_1.isTestnet)(account.currency)
|
|
47
|
+
? typhonjs_1.types.NetworkId.TESTNET
|
|
48
|
+
: typhonjs_1.types.NetworkId.MAINNET;
|
|
49
|
+
const rewardAddress = new address_1.RewardAddress(networkId, stakeKeyHashCredential);
|
|
50
|
+
const rewardsWithdrawalCertificate = {
|
|
51
|
+
rewardAccount: rewardAddress,
|
|
52
|
+
amount: account.cardanoResources.delegation.rewards,
|
|
53
|
+
};
|
|
54
|
+
return rewardsWithdrawalCertificate;
|
|
55
|
+
}
|
|
56
|
+
const buildSendTokenTransaction = (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, transaction, tokenAccount, typhonTx, receiverAddress, changeAddress, }) {
|
|
57
|
+
const cardanoResources = account.cardanoResources;
|
|
58
|
+
const { assetId } = (0, buildSubAccounts_1.decodeTokenCurrencyId)(tokenAccount.token.id);
|
|
59
|
+
const { policyId, assetName } = (0, buildSubAccounts_1.decodeTokenAssetId)(assetId);
|
|
60
|
+
const transactionAmount = transaction.useAllAmount ? tokenAccount.balance : transaction.amount;
|
|
61
|
+
const tokensToSend = [
|
|
62
|
+
{
|
|
63
|
+
policyId,
|
|
64
|
+
assetName,
|
|
65
|
+
amount: transactionAmount,
|
|
66
|
+
},
|
|
67
|
+
];
|
|
68
|
+
const tokenUtxos = [];
|
|
69
|
+
const otherUtxos = [];
|
|
70
|
+
cardanoResources.utxos.forEach(u => {
|
|
71
|
+
if (u.tokens.some(t => (0, buildSubAccounts_1.getTokenAssetId)(t) === assetId)) {
|
|
72
|
+
tokenUtxos.push(u);
|
|
73
|
+
}
|
|
74
|
+
else {
|
|
75
|
+
otherUtxos.push(u);
|
|
76
|
+
}
|
|
77
|
+
});
|
|
78
|
+
const sortedTokenUtxo = tokenUtxos.sort((a, b) => {
|
|
79
|
+
const sendingTokenA = a.tokens.find(t => (0, buildSubAccounts_1.getTokenAssetId)(t) === assetId);
|
|
80
|
+
const sendingTokenB = b.tokens.find(t => (0, buildSubAccounts_1.getTokenAssetId)(t) === assetId);
|
|
81
|
+
const diff = sendingTokenB.amount.minus(sendingTokenA.amount);
|
|
82
|
+
return diff.eq(0) ? 0 : diff.lt(0) ? -1 : 1;
|
|
83
|
+
});
|
|
84
|
+
const sortedOtherUtxos = otherUtxos.sort((a, b) => {
|
|
85
|
+
const diff = b.amount.minus(a.amount);
|
|
86
|
+
return diff.eq(0) ? 0 : diff.lt(0) ? -1 : 1;
|
|
87
|
+
});
|
|
88
|
+
const totalAddedTokenAmount = new bignumber_js_1.default(0);
|
|
89
|
+
const requiredMinAdaForTokens = typhonjs_1.utils.calculateMinUtxoAmount(tokensToSend, new bignumber_js_1.default(cardanoResources.protocolParams.lovelacePerUtxoWord));
|
|
90
|
+
// Add enough utxo to cover token amount
|
|
91
|
+
for (let i = 0; i < sortedTokenUtxo.length; i++) {
|
|
92
|
+
const u = sortedTokenUtxo[i];
|
|
93
|
+
const sendingToken = u.tokens.find(t => (0, buildSubAccounts_1.getTokenAssetId)(t) === assetId);
|
|
94
|
+
typhonTx.addInput(getTyphonInputFromUtxo(u));
|
|
95
|
+
totalAddedTokenAmount.plus(sendingToken.amount);
|
|
96
|
+
if (totalAddedTokenAmount.gte(transactionAmount))
|
|
97
|
+
break;
|
|
98
|
+
}
|
|
99
|
+
const requiredInputAmount = requiredMinAdaForTokens.plus(10e6);
|
|
100
|
+
// Add enough utxos to cover the transaction fees
|
|
101
|
+
for (let i = 0; i < sortedOtherUtxos.length; i++) {
|
|
102
|
+
const u = sortedOtherUtxos[i];
|
|
103
|
+
if (typhonTx.getInputAmount().ada.gte(requiredInputAmount)) {
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
typhonTx.addInput(getTyphonInputFromUtxo(u));
|
|
107
|
+
}
|
|
108
|
+
const rewardsWithdrawalCertificate = getRewardWithdrawalCertificate(account);
|
|
109
|
+
if (rewardsWithdrawalCertificate)
|
|
110
|
+
typhonTx.addWithdrawal(rewardsWithdrawalCertificate);
|
|
111
|
+
typhonTx.addOutput({
|
|
112
|
+
address: receiverAddress,
|
|
113
|
+
amount: requiredMinAdaForTokens,
|
|
114
|
+
tokens: tokensToSend,
|
|
115
|
+
});
|
|
116
|
+
return typhonTx.prepareTransaction({
|
|
117
|
+
inputs: [],
|
|
118
|
+
changeAddress,
|
|
119
|
+
});
|
|
120
|
+
});
|
|
121
|
+
const buildSendAdaTransaction = (_b) => __awaiter(void 0, [_b], void 0, function* ({ account, transaction, typhonTx, receiverAddress, changeAddress, }) {
|
|
122
|
+
const cardanoResources = account.cardanoResources;
|
|
123
|
+
const protocolParams = cardanoResources.protocolParams;
|
|
124
|
+
if (transaction.useAllAmount) {
|
|
125
|
+
// add all utxo as input
|
|
126
|
+
cardanoResources.utxos.forEach(u => typhonTx.addInput(getTyphonInputFromUtxo(u)));
|
|
127
|
+
const tokenBalance = (0, logic_1.mergeTokens)(cardanoResources.utxos.map(u => u.tokens).flat());
|
|
128
|
+
// if account holds any tokens then add it to changeAddress,
|
|
129
|
+
// with minimum required ADA to spend those tokens
|
|
130
|
+
if (tokenBalance.length) {
|
|
131
|
+
const minAmountToSpendTokens = typhonjs_1.utils.calculateMinUtxoAmount(tokenBalance, new bignumber_js_1.default(protocolParams.lovelacePerUtxoWord), false);
|
|
132
|
+
typhonTx.addOutput({
|
|
133
|
+
address: changeAddress,
|
|
134
|
+
amount: minAmountToSpendTokens,
|
|
135
|
+
tokens: tokenBalance,
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
const rewardsWithdrawalCertificate = getRewardWithdrawalCertificate(account);
|
|
139
|
+
if (rewardsWithdrawalCertificate)
|
|
140
|
+
typhonTx.addWithdrawal(rewardsWithdrawalCertificate);
|
|
141
|
+
return typhonTx.prepareTransaction({
|
|
142
|
+
inputs: [],
|
|
143
|
+
changeAddress: receiverAddress,
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
// sorting utxo from higher to lower ADA value
|
|
147
|
+
// to minimize the number of utxo use in transaction
|
|
148
|
+
const sortedUtxos = cardanoResources.utxos.sort((a, b) => {
|
|
149
|
+
const diff = b.amount.minus(a.amount);
|
|
150
|
+
return diff.eq(0) ? 0 : diff.lt(0) ? -1 : 1;
|
|
151
|
+
});
|
|
152
|
+
const transactionInputs = [];
|
|
153
|
+
const usedUtxoAdaAmount = new bignumber_js_1.default(0);
|
|
154
|
+
// Add 10 ADA as buffer for utxo selection to cover the transaction fees.
|
|
155
|
+
const requiredInputAmount = transaction.amount.plus(10e6);
|
|
156
|
+
for (let i = 0; i < sortedUtxos.length && usedUtxoAdaAmount.lte(requiredInputAmount); i++) {
|
|
157
|
+
const utxo = sortedUtxos[i];
|
|
158
|
+
const transactionInput = getTyphonInputFromUtxo(utxo);
|
|
159
|
+
transactionInputs.push(transactionInput);
|
|
160
|
+
usedUtxoAdaAmount.plus(transactionInput.amount);
|
|
161
|
+
}
|
|
162
|
+
const rewardsWithdrawalCertificate = getRewardWithdrawalCertificate(account);
|
|
163
|
+
if (rewardsWithdrawalCertificate)
|
|
164
|
+
typhonTx.addWithdrawal(rewardsWithdrawalCertificate);
|
|
165
|
+
typhonTx.addOutput({
|
|
166
|
+
address: receiverAddress,
|
|
167
|
+
amount: transaction.amount,
|
|
168
|
+
tokens: [],
|
|
169
|
+
});
|
|
170
|
+
return typhonTx.prepareTransaction({
|
|
171
|
+
inputs: transactionInputs,
|
|
172
|
+
changeAddress,
|
|
173
|
+
});
|
|
174
|
+
});
|
|
175
|
+
const buildDelegateTransaction = (_c) => __awaiter(void 0, [_c], void 0, function* ({ account, transaction, typhonTx, changeAddress, }) {
|
|
176
|
+
const cardanoResources = account.cardanoResources;
|
|
177
|
+
const stakeCredential = (0, logic_1.getAccountStakeCredential)(account.xpub, account.index);
|
|
178
|
+
const stakeKeyHashCredential = {
|
|
179
|
+
hash: stakeCredential.key,
|
|
180
|
+
type: typhonjs_1.types.HashType.ADDRESS,
|
|
181
|
+
bipPath: stakeCredential.path,
|
|
182
|
+
};
|
|
183
|
+
if (!cardanoResources.delegation || !cardanoResources.delegation.status) {
|
|
184
|
+
const stakeRegistrationCert = {
|
|
185
|
+
certType: typhonjs_1.types.CertificateType.STAKE_REGISTRATION,
|
|
186
|
+
stakeCredential: stakeKeyHashCredential,
|
|
187
|
+
};
|
|
188
|
+
typhonTx.addCertificate(stakeRegistrationCert);
|
|
189
|
+
}
|
|
190
|
+
const delegationCert = {
|
|
191
|
+
certType: typhonjs_1.types.CertificateType.STAKE_DELEGATION,
|
|
192
|
+
stakeCredential: stakeKeyHashCredential,
|
|
193
|
+
poolHash: transaction.poolId,
|
|
194
|
+
};
|
|
195
|
+
typhonTx.addCertificate(delegationCert);
|
|
196
|
+
// sorting utxo from higher to lower ADA value
|
|
197
|
+
// to minimize the number of utxo use in transaction
|
|
198
|
+
const sortedUtxos = cardanoResources.utxos.sort((a, b) => {
|
|
199
|
+
const diff = b.amount.minus(a.amount);
|
|
200
|
+
return diff.eq(0) ? 0 : diff.lt(0) ? -1 : 1;
|
|
201
|
+
});
|
|
202
|
+
const transactionInputs = [];
|
|
203
|
+
const usedUtxoAdaAmount = new bignumber_js_1.default(0);
|
|
204
|
+
// Add 10 ADA as buffer for utxo selection to cover the transaction fees.
|
|
205
|
+
const requiredInputAmount = transaction.amount.plus(10e6);
|
|
206
|
+
for (let i = 0; i < sortedUtxos.length && usedUtxoAdaAmount.lte(requiredInputAmount); i++) {
|
|
207
|
+
const utxo = sortedUtxos[i];
|
|
208
|
+
const transactionInput = getTyphonInputFromUtxo(utxo);
|
|
209
|
+
transactionInputs.push(transactionInput);
|
|
210
|
+
usedUtxoAdaAmount.plus(transactionInput.amount);
|
|
211
|
+
}
|
|
212
|
+
const rewardsWithdrawalCertificate = getRewardWithdrawalCertificate(account);
|
|
213
|
+
if (rewardsWithdrawalCertificate)
|
|
214
|
+
typhonTx.addWithdrawal(rewardsWithdrawalCertificate);
|
|
215
|
+
return typhonTx.prepareTransaction({
|
|
216
|
+
inputs: transactionInputs,
|
|
217
|
+
changeAddress,
|
|
218
|
+
});
|
|
219
|
+
});
|
|
220
|
+
const buildUndelegateTransaction = (_d) => __awaiter(void 0, [_d], void 0, function* ({ account, transaction, typhonTx, changeAddress, }) {
|
|
221
|
+
const cardanoResources = account.cardanoResources;
|
|
222
|
+
const stakeCredential = (0, logic_1.getAccountStakeCredential)(account.xpub, account.index);
|
|
223
|
+
const stakeKeyHashCredential = {
|
|
224
|
+
hash: stakeCredential.key,
|
|
225
|
+
type: typhonjs_1.types.HashType.ADDRESS,
|
|
226
|
+
bipPath: stakeCredential.path,
|
|
227
|
+
};
|
|
228
|
+
if (!cardanoResources.delegation || !cardanoResources.delegation.status) {
|
|
229
|
+
throw new Error("StakeKey is not registered");
|
|
230
|
+
}
|
|
231
|
+
const rewardsWithdrawalCertificate = getRewardWithdrawalCertificate(account);
|
|
232
|
+
if (rewardsWithdrawalCertificate)
|
|
233
|
+
typhonTx.addWithdrawal(rewardsWithdrawalCertificate);
|
|
234
|
+
const stakeKeyDeRegistrationCertificate = {
|
|
235
|
+
certType: typhonjs_1.types.CertificateType.STAKE_DE_REGISTRATION,
|
|
236
|
+
stakeCredential: stakeKeyHashCredential,
|
|
237
|
+
};
|
|
238
|
+
typhonTx.addCertificate(stakeKeyDeRegistrationCertificate);
|
|
239
|
+
// sorting utxo from higher to lower ADA value
|
|
240
|
+
// to minimize the number of utxo use in transaction
|
|
241
|
+
const sortedUtxos = cardanoResources.utxos.sort((a, b) => {
|
|
242
|
+
const diff = b.amount.minus(a.amount);
|
|
243
|
+
return diff.eq(0) ? 0 : diff.lt(0) ? -1 : 1;
|
|
244
|
+
});
|
|
245
|
+
const transactionInputs = [];
|
|
246
|
+
const usedUtxoAdaAmount = new bignumber_js_1.default(0);
|
|
247
|
+
// Add 10 ADA as buffer for utxo selection to cover the transaction fees.
|
|
248
|
+
const requiredInputAmount = transaction.amount.plus(10e6);
|
|
249
|
+
for (let i = 0; i < sortedUtxos.length && usedUtxoAdaAmount.lte(requiredInputAmount); i++) {
|
|
250
|
+
const utxo = sortedUtxos[i];
|
|
251
|
+
const transactionInput = getTyphonInputFromUtxo(utxo);
|
|
252
|
+
transactionInputs.push(transactionInput);
|
|
253
|
+
usedUtxoAdaAmount.plus(transactionInput.amount);
|
|
254
|
+
}
|
|
255
|
+
return typhonTx.prepareTransaction({
|
|
256
|
+
inputs: transactionInputs,
|
|
257
|
+
changeAddress,
|
|
258
|
+
});
|
|
259
|
+
});
|
|
260
|
+
/**
|
|
261
|
+
*
|
|
262
|
+
* @param {CardanoAccount} account
|
|
263
|
+
* @param {Transaction} transaction
|
|
264
|
+
*
|
|
265
|
+
* @returns {TyphonTransaction}
|
|
266
|
+
*/
|
|
267
|
+
const buildTransaction = (account, transaction) => __awaiter(void 0, void 0, void 0, function* () {
|
|
268
|
+
const cardanoResources = account.cardanoResources;
|
|
269
|
+
const protocolParams = cardanoResources.protocolParams;
|
|
270
|
+
const typhonTx = new typhonjs_1.Transaction({
|
|
271
|
+
protocolParams: {
|
|
272
|
+
minFeeA: new bignumber_js_1.default(protocolParams.minFeeA),
|
|
273
|
+
minFeeB: new bignumber_js_1.default(protocolParams.minFeeB),
|
|
274
|
+
stakeKeyDeposit: new bignumber_js_1.default(protocolParams.stakeKeyDeposit),
|
|
275
|
+
lovelacePerUtxoWord: new bignumber_js_1.default(protocolParams.lovelacePerUtxoWord),
|
|
276
|
+
collateralPercent: new bignumber_js_1.default(protocolParams.collateralPercent),
|
|
277
|
+
priceSteps: new bignumber_js_1.default(protocolParams.priceSteps),
|
|
278
|
+
priceMem: new bignumber_js_1.default(protocolParams.priceMem),
|
|
279
|
+
languageView: protocolParams.languageView,
|
|
280
|
+
},
|
|
281
|
+
});
|
|
282
|
+
const ttl = (0, logic_1.getTTL)(account.currency.id);
|
|
283
|
+
typhonTx.setTTL(ttl);
|
|
284
|
+
const metadata = [];
|
|
285
|
+
if (transaction.memo) {
|
|
286
|
+
metadata.push({
|
|
287
|
+
label: 674,
|
|
288
|
+
data: new Map([["msg", [transaction.memo]]]),
|
|
289
|
+
});
|
|
290
|
+
}
|
|
291
|
+
if (metadata.length) {
|
|
292
|
+
typhonTx.setAuxiliaryData({ metadata });
|
|
293
|
+
}
|
|
294
|
+
const networkParams = (0, networks_1.getNetworkParameters)(account.currency.id);
|
|
295
|
+
const unusedInternalCred = cardanoResources.internalCredentials.find(cred => !cred.isUsed);
|
|
296
|
+
const changeAddress = (0, logic_1.getBaseAddress)({
|
|
297
|
+
networkId: networkParams.networkId,
|
|
298
|
+
paymentCred: unusedInternalCred,
|
|
299
|
+
stakeCred: (0, logic_1.getAccountStakeCredential)(account.xpub, account.index),
|
|
300
|
+
});
|
|
301
|
+
if (transaction.mode === "send") {
|
|
302
|
+
const receiverAddress = typhonjs_1.utils.getAddressFromBech32(transaction.recipient);
|
|
303
|
+
if (transaction.subAccountId) {
|
|
304
|
+
// Token Transaction
|
|
305
|
+
const tokenAccount = account.subAccounts
|
|
306
|
+
? account.subAccounts.find(a => {
|
|
307
|
+
return a.id === transaction.subAccountId;
|
|
308
|
+
})
|
|
309
|
+
: undefined;
|
|
310
|
+
if (!tokenAccount || tokenAccount.type !== "TokenAccount") {
|
|
311
|
+
throw new Error("TokenAccount not found");
|
|
312
|
+
}
|
|
313
|
+
return buildSendTokenTransaction({
|
|
314
|
+
account,
|
|
315
|
+
transaction,
|
|
316
|
+
tokenAccount,
|
|
317
|
+
typhonTx,
|
|
318
|
+
receiverAddress,
|
|
319
|
+
changeAddress,
|
|
320
|
+
});
|
|
321
|
+
}
|
|
322
|
+
// Normal ADA Transaction
|
|
323
|
+
return buildSendAdaTransaction({
|
|
324
|
+
account,
|
|
325
|
+
transaction,
|
|
326
|
+
typhonTx,
|
|
327
|
+
receiverAddress,
|
|
328
|
+
changeAddress,
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
else if (transaction.mode === "delegate") {
|
|
332
|
+
return buildDelegateTransaction({ account, transaction, typhonTx, changeAddress });
|
|
333
|
+
}
|
|
334
|
+
else if (transaction.mode === "undelegate") {
|
|
335
|
+
return buildUndelegateTransaction({ account, transaction, typhonTx, changeAddress });
|
|
336
|
+
}
|
|
337
|
+
else {
|
|
338
|
+
throw new Error("Invalid transaction mode");
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
exports.buildTransaction = buildTransaction;
|
|
342
|
+
//# sourceMappingURL=buildTransa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,WAAW,EAAE,QAAQ,EAAE,aAAa,EAAE,CAAC,CAAC;IACvF,CAAC;SAAM,CAAC;QACN,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;AACH,CAAC,CAAA,CAAC;AAlFW,QAAA,gBAAgB,oBAkF3B"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Account, AccountLike, TokenAccount } from "@ledgerhq/types-live";
|
|
2
|
+
import { Transaction } from "./types";
|
|
3
|
+
declare function inferAccounts(account: Account, opts: Record<string, any>): Account[] | TokenAccount[];
|
|
4
|
+
declare function inferTransactions(transactions: Array<{
|
|
5
|
+
account: AccountLike;
|
|
6
|
+
transaction: Transaction;
|
|
7
|
+
}>, opts: Record<string, any>): Transaction[];
|
|
8
|
+
export default function makeCliTools(): {
|
|
9
|
+
options: {
|
|
10
|
+
name: string;
|
|
11
|
+
type: StringConstructor;
|
|
12
|
+
desc: string;
|
|
13
|
+
}[];
|
|
14
|
+
inferAccounts: typeof inferAccounts;
|
|
15
|
+
inferTransactions: typeof inferTransactions;
|
|
16
|
+
};
|
|
17
|
+
export {};
|
|
18
|
+
//# sourceMappingURL=cli-transaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-transaction.d.ts","sourceRoot":"","sources":["../src/cli-transaction.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAI1E,OAAO,EAAkB,WAAW,EAAE,MAAM,SAAS,CAAC;AAoBtD,iBAAS,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,OAAO,EAAE,GAAG,YAAY,EAAE,CA2B9F;AAED,iBAAS,iBAAiB,CACxB,YAAY,EAAE,KAAK,CAAC;IAAE,OAAO,EAAE,WAAW,CAAC;IAAC,WAAW,EAAE,WAAW,CAAA;CAAE,CAAC,EACvE,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,WAAW,EAAE,CAiBf;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;;;;;;;;EAMnC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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 invariant_1 = __importDefault(require("invariant"));
|
|
7
|
+
const flatMap_1 = __importDefault(require("lodash/flatMap"));
|
|
8
|
+
const index_1 = require("@ledgerhq/coin-framework/account/index");
|
|
9
|
+
const options = [
|
|
10
|
+
{
|
|
11
|
+
name: "mode",
|
|
12
|
+
type: String,
|
|
13
|
+
desc: "mode of transaction: send, delegate, undelegate",
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
name: "token",
|
|
17
|
+
type: String,
|
|
18
|
+
desc: "uses subAccount(TokenAccount) of the account",
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "poolId",
|
|
22
|
+
type: String,
|
|
23
|
+
desc: "Cardano stake pool id to delegate",
|
|
24
|
+
},
|
|
25
|
+
];
|
|
26
|
+
function inferAccounts(account, opts) {
|
|
27
|
+
(0, invariant_1.default)(account.currency.family === "cardano", "cardano family");
|
|
28
|
+
if (!opts.token) {
|
|
29
|
+
const accounts = [account];
|
|
30
|
+
return accounts;
|
|
31
|
+
}
|
|
32
|
+
return opts.token.map((token) => {
|
|
33
|
+
const subAccounts = account.subAccounts || [];
|
|
34
|
+
const subAccount = subAccounts.find(a => {
|
|
35
|
+
const currency = (0, index_1.getAccountCurrency)(a);
|
|
36
|
+
return token.toLowerCase() === currency.id.toLowerCase();
|
|
37
|
+
});
|
|
38
|
+
if (!subAccount) {
|
|
39
|
+
throw new Error("token account '" +
|
|
40
|
+
token +
|
|
41
|
+
"' not found. Available: " +
|
|
42
|
+
subAccounts.map(t => t.id).join("\n"));
|
|
43
|
+
}
|
|
44
|
+
return subAccount;
|
|
45
|
+
});
|
|
46
|
+
}
|
|
47
|
+
function inferTransactions(transactions, opts) {
|
|
48
|
+
return (0, flatMap_1.default)(transactions, ({ transaction, account }) => {
|
|
49
|
+
if (transaction.family !== "cardano") {
|
|
50
|
+
throw new Error("transaction is not of type cardano");
|
|
51
|
+
}
|
|
52
|
+
if (account.type === "Account" && !account.cardanoResources) {
|
|
53
|
+
throw new Error("unactivated account");
|
|
54
|
+
}
|
|
55
|
+
return Object.assign(Object.assign({}, transaction), { mode: opts.mode || "send", subAccountId: account.type === "TokenAccount" ? account.id : undefined, poolId: opts.poolId || "" });
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
function makeCliTools() {
|
|
59
|
+
return {
|
|
60
|
+
options,
|
|
61
|
+
inferAccounts,
|
|
62
|
+
inferTransactions,
|
|
63
|
+
};
|
|
64
|
+
}
|
|
65
|
+
exports.default = makeCliTools;
|
|
66
|
+
//# sourceMappingURL=cli-transaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli-transaction.js","sourceRoot":"","sources":["../src/cli-transaction.ts"],"names":[],"mappings":";;;;;AACA,0DAAkC;AAClC,6DAAqC;AACrC,kEAA4E;AAG5E,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,iDAAiD;KACxD;IACD;QACE,IAAI,EAAE,OAAO;QACb,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,8CAA8C;KACrD;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,mCAAmC;KAC1C;CACF,CAAC;AAEF,SAAS,aAAa,CAAC,OAAgB,EAAE,IAAyB;IAChE,IAAA,mBAAS,EAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,KA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zC,CAAC;QAED,uCACK,WAAW,KACd,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,MAAM,EACzB,YAAY,EAAE,OAAO,CAAC,IAAI,KAAK,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC,CAAC,SAAS,EACtE,MAAM,EAAE,IAAI,CAAC,MAAM,IAAI,EAAE,IACzB;IACJ,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAwB,YAAY;IAClC,OAAO;QACL,OAAO;QACP,aAAa;QACb,iBAAiB;KAClB,CAAC;AACJ,CAAC;AAND,+BAMC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export declare const STAKING_ADDRESS_INDEX = 0;
|
|
2
|
+
export declare const TTL_GAP = 7200;
|
|
3
|
+
export declare const CARDANO_PURPOSE = 1852;
|
|
4
|
+
export declare const CARDANO_COIN_TYPE = 1815;
|
|
5
|
+
export declare const MEMO_LABEL = 674;
|
|
6
|
+
export declare const CARDANO_API_ENDPOINT: string;
|
|
7
|
+
export declare const CARDANO_TESTNET_API_ENDPOINT: string;
|
|
8
|
+
//# sourceMappingURL=constants.d.ts.map
|