@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
package/src/types.ts
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
import type { BigNumber } from "bignumber.js";
|
|
2
|
+
import { types as TyphonTypes } from "@stricahq/typhonjs";
|
|
3
|
+
import type {
|
|
4
|
+
Account,
|
|
5
|
+
AccountRaw,
|
|
6
|
+
Operation,
|
|
7
|
+
OperationRaw,
|
|
8
|
+
TransactionCommon,
|
|
9
|
+
TransactionCommonRaw,
|
|
10
|
+
TransactionStatusCommon,
|
|
11
|
+
TransactionStatusCommonRaw,
|
|
12
|
+
} from "@ledgerhq/types-live";
|
|
13
|
+
|
|
14
|
+
export enum PaymentChain {
|
|
15
|
+
external = 0,
|
|
16
|
+
internal = 1,
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
export enum StakeChain {
|
|
20
|
+
stake = 2,
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export enum NetworkId {
|
|
24
|
+
testnet = 0,
|
|
25
|
+
mainnet = 1,
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export type BipPath = {
|
|
29
|
+
purpose: number;
|
|
30
|
+
coin: number;
|
|
31
|
+
account: number;
|
|
32
|
+
chain: PaymentChain | StakeChain;
|
|
33
|
+
index: number;
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
export type BipPathRaw = {
|
|
37
|
+
purpose: number;
|
|
38
|
+
coin: number;
|
|
39
|
+
account: number;
|
|
40
|
+
chain: PaymentChain | StakeChain;
|
|
41
|
+
index: number;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
export type Token = {
|
|
45
|
+
assetName: string;
|
|
46
|
+
policyId: string;
|
|
47
|
+
amount: BigNumber;
|
|
48
|
+
};
|
|
49
|
+
|
|
50
|
+
export type TokenRaw = {
|
|
51
|
+
assetName: string;
|
|
52
|
+
policyId: string;
|
|
53
|
+
amount: string;
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
export type PaymentKeyPath = {
|
|
57
|
+
key: string;
|
|
58
|
+
path: BipPath;
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export type PaymentCredential = {
|
|
62
|
+
isUsed: boolean;
|
|
63
|
+
key: string;
|
|
64
|
+
path: BipPath;
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export type PaymentCredentialRaw = {
|
|
68
|
+
isUsed: boolean;
|
|
69
|
+
key: string;
|
|
70
|
+
path: BipPathRaw;
|
|
71
|
+
};
|
|
72
|
+
|
|
73
|
+
export type StakeCredential = {
|
|
74
|
+
key: string;
|
|
75
|
+
path: BipPath;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
export type CardanoOutput = {
|
|
79
|
+
hash: string;
|
|
80
|
+
index: number;
|
|
81
|
+
address: string;
|
|
82
|
+
amount: BigNumber;
|
|
83
|
+
tokens: Array<Token>;
|
|
84
|
+
paymentCredential: {
|
|
85
|
+
key: string;
|
|
86
|
+
path: BipPath;
|
|
87
|
+
};
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export type CardanoOutputRaw = {
|
|
91
|
+
hash: string;
|
|
92
|
+
index: number;
|
|
93
|
+
address: string;
|
|
94
|
+
amount: string;
|
|
95
|
+
tokens: Array<TokenRaw>;
|
|
96
|
+
paymentCredential: {
|
|
97
|
+
key: string;
|
|
98
|
+
path: BipPath;
|
|
99
|
+
};
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
export type ProtocolParams = {
|
|
103
|
+
minFeeA: string;
|
|
104
|
+
minFeeB: string;
|
|
105
|
+
stakeKeyDeposit: string;
|
|
106
|
+
lovelacePerUtxoWord: string;
|
|
107
|
+
collateralPercent: string;
|
|
108
|
+
priceSteps: string;
|
|
109
|
+
priceMem: string;
|
|
110
|
+
languageView: TyphonTypes.LanguageView;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
export type ProtocolParamsRaw = {
|
|
114
|
+
minFeeA: string;
|
|
115
|
+
minFeeB: string;
|
|
116
|
+
stakeKeyDeposit: string;
|
|
117
|
+
lovelacePerUtxoWord: string;
|
|
118
|
+
collateralPercent: string;
|
|
119
|
+
priceSteps: string;
|
|
120
|
+
priceMem: string;
|
|
121
|
+
// TyphonTypes.LanguageView is already a raw type
|
|
122
|
+
languageView: TyphonTypes.LanguageView;
|
|
123
|
+
};
|
|
124
|
+
|
|
125
|
+
export type CardanoDelegation = {
|
|
126
|
+
status: boolean;
|
|
127
|
+
poolId: string;
|
|
128
|
+
ticker: string;
|
|
129
|
+
name: string;
|
|
130
|
+
rewards: BigNumber;
|
|
131
|
+
};
|
|
132
|
+
|
|
133
|
+
export type CardanoDelegationRaw = {
|
|
134
|
+
status: boolean;
|
|
135
|
+
poolId: string;
|
|
136
|
+
ticker: string;
|
|
137
|
+
name: string;
|
|
138
|
+
rewards: string;
|
|
139
|
+
};
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Cardano account resources
|
|
143
|
+
*/
|
|
144
|
+
export type CardanoResources = {
|
|
145
|
+
externalCredentials: Array<PaymentCredential>;
|
|
146
|
+
internalCredentials: Array<PaymentCredential>;
|
|
147
|
+
delegation: CardanoDelegation | undefined;
|
|
148
|
+
utxos: Array<CardanoOutput>;
|
|
149
|
+
protocolParams: ProtocolParams;
|
|
150
|
+
};
|
|
151
|
+
|
|
152
|
+
/**
|
|
153
|
+
* Cardano account resources from raw JSON
|
|
154
|
+
*/
|
|
155
|
+
export type CardanoResourcesRaw = {
|
|
156
|
+
externalCredentials: Array<PaymentCredentialRaw>;
|
|
157
|
+
internalCredentials: Array<PaymentCredentialRaw>;
|
|
158
|
+
delegation: CardanoDelegationRaw | undefined;
|
|
159
|
+
utxos: Array<CardanoOutputRaw>;
|
|
160
|
+
protocolParams: ProtocolParamsRaw;
|
|
161
|
+
};
|
|
162
|
+
|
|
163
|
+
export type CardanoOperationMode = "send" | "delegate" | "undelegate";
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Cardano transaction
|
|
167
|
+
*/
|
|
168
|
+
export type Transaction = TransactionCommon & {
|
|
169
|
+
mode: CardanoOperationMode;
|
|
170
|
+
family: "cardano";
|
|
171
|
+
fees?: BigNumber;
|
|
172
|
+
memo?: string;
|
|
173
|
+
poolId: string | undefined;
|
|
174
|
+
// add here all transaction-specific fields if you implement other modes than "send"
|
|
175
|
+
};
|
|
176
|
+
|
|
177
|
+
/**
|
|
178
|
+
* Cardano transaction from a raw JSON
|
|
179
|
+
*/
|
|
180
|
+
export type TransactionRaw = TransactionCommonRaw & {
|
|
181
|
+
family: "cardano";
|
|
182
|
+
mode: CardanoOperationMode;
|
|
183
|
+
fees?: string;
|
|
184
|
+
memo?: string;
|
|
185
|
+
poolId: string | undefined;
|
|
186
|
+
// also the transaction fields as raw JSON data
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
export type CardanoLikeNetworkParameters = {
|
|
190
|
+
identifier: string;
|
|
191
|
+
networkId: number;
|
|
192
|
+
chainStartTime: number;
|
|
193
|
+
byronSlotDuration: number;
|
|
194
|
+
byronSlotsPerEpoch: number;
|
|
195
|
+
shelleyStartEpoch: number;
|
|
196
|
+
shelleySlotDuration: number;
|
|
197
|
+
shelleySlotsPerEpoch: number;
|
|
198
|
+
addressPrefix: string;
|
|
199
|
+
poolIdPrefix: string;
|
|
200
|
+
};
|
|
201
|
+
|
|
202
|
+
/**
|
|
203
|
+
* Cardano currency data that will be preloaded.
|
|
204
|
+
*/
|
|
205
|
+
export type CardanoPreloadData = {
|
|
206
|
+
protocolParams: ProtocolParams;
|
|
207
|
+
};
|
|
208
|
+
|
|
209
|
+
export type CardanoAccount = Account & { cardanoResources: CardanoResources };
|
|
210
|
+
|
|
211
|
+
export type CardanoAccountRaw = AccountRaw & {
|
|
212
|
+
cardanoResources: CardanoResourcesRaw;
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
216
|
+
|
|
217
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
218
|
+
|
|
219
|
+
export type CardanoOperation = Operation<CardanoOperationExtra>;
|
|
220
|
+
export type CardanoOperationRaw = OperationRaw<CardanoOperationExtra>;
|
|
221
|
+
|
|
222
|
+
export type CardanoOperationExtra = {
|
|
223
|
+
memo?: string;
|
|
224
|
+
deposit?: string;
|
|
225
|
+
refund?: string;
|
|
226
|
+
rewards?: string;
|
|
227
|
+
};
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
import {
|
|
2
|
+
types as TyphonTypes,
|
|
3
|
+
address as TyphonAddress,
|
|
4
|
+
Transaction as TyphonTransaction,
|
|
5
|
+
} from "@stricahq/typhonjs";
|
|
6
|
+
import groupBy from "lodash/groupBy";
|
|
7
|
+
import { getBipPathString } from "./logic";
|
|
8
|
+
import { CertificateType } from "@stricahq/typhonjs/dist/types";
|
|
9
|
+
import { SignerTxCertificate, SignerTxInput, SignerTxOutput, SignerTxWithdrawal } from "./signer";
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Convert StricaTypes Transaction into a simpler types.
|
|
13
|
+
* We are keeping the minimal necessary for a signer.
|
|
14
|
+
*/
|
|
15
|
+
export default function (transaction: TyphonTransaction, accountIndex: number) {
|
|
16
|
+
const ledgerAppInputs = transaction.getInputs().map(prepareLedgerInput(accountIndex));
|
|
17
|
+
const ledgerAppOutputs = transaction.getOutputs().map(prepareLedgerOutput(accountIndex));
|
|
18
|
+
const ledgerCertificates = transaction.getCertificates().map(prepareCertificate);
|
|
19
|
+
const ledgerWithdrawals = transaction.getWithdrawals().map(prepareWithdrawal);
|
|
20
|
+
const auxiliaryDataHashHex = transaction.getAuxiliaryDataHashHex();
|
|
21
|
+
|
|
22
|
+
return {
|
|
23
|
+
inputs: ledgerAppInputs,
|
|
24
|
+
outputs: ledgerAppOutputs,
|
|
25
|
+
certificates: ledgerCertificates,
|
|
26
|
+
withdrawals: ledgerWithdrawals,
|
|
27
|
+
fee: transaction.getFee().toString(),
|
|
28
|
+
ttl: transaction.getTTL()?.toString(),
|
|
29
|
+
validityIntervalStart: null,
|
|
30
|
+
auxiliaryData: auxiliaryDataHashHex ?? null,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* returns the formatted transactionInput for ledger cardano app
|
|
36
|
+
*
|
|
37
|
+
* @param {TyphonTypes.Input} input
|
|
38
|
+
* @param {number} accountIndex
|
|
39
|
+
* @returns {TxInput}
|
|
40
|
+
*/
|
|
41
|
+
const prepareLedgerInput =
|
|
42
|
+
(accountIndex: number) =>
|
|
43
|
+
(input: TyphonTypes.Input): SignerTxInput => {
|
|
44
|
+
const paymentKeyPath =
|
|
45
|
+
input.address.paymentCredential.type === TyphonTypes.HashType.ADDRESS
|
|
46
|
+
? input.address.paymentCredential.bipPath
|
|
47
|
+
: undefined;
|
|
48
|
+
return {
|
|
49
|
+
txHashHex: input.txId,
|
|
50
|
+
outputIndex: input.index,
|
|
51
|
+
path: paymentKeyPath
|
|
52
|
+
? getBipPathString({
|
|
53
|
+
account: accountIndex,
|
|
54
|
+
chain: paymentKeyPath.chain,
|
|
55
|
+
index: paymentKeyPath.index,
|
|
56
|
+
})
|
|
57
|
+
: null,
|
|
58
|
+
};
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* returns the formatted transactionOutput for ledger cardano app
|
|
63
|
+
*
|
|
64
|
+
* @param output
|
|
65
|
+
* @param accountIndex
|
|
66
|
+
* @returns {TxOutput}
|
|
67
|
+
*/
|
|
68
|
+
const prepareLedgerOutput =
|
|
69
|
+
(accountIndex: number) =>
|
|
70
|
+
(output: TyphonTypes.Output): SignerTxOutput => {
|
|
71
|
+
const isByronAddress = output.address instanceof TyphonAddress.ByronAddress;
|
|
72
|
+
let isDeviceOwnedAddress = false;
|
|
73
|
+
|
|
74
|
+
if (!isByronAddress) {
|
|
75
|
+
const address = output.address as TyphonTypes.ShelleyAddress;
|
|
76
|
+
isDeviceOwnedAddress =
|
|
77
|
+
address.paymentCredential &&
|
|
78
|
+
address.paymentCredential.type === TyphonTypes.HashType.ADDRESS &&
|
|
79
|
+
address.paymentCredential.bipPath !== undefined;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
let destination;
|
|
83
|
+
if (isDeviceOwnedAddress) {
|
|
84
|
+
const address = output.address as TyphonAddress.BaseAddress;
|
|
85
|
+
|
|
86
|
+
const paymentKeyPath = (address.paymentCredential as TyphonTypes.HashCredential)
|
|
87
|
+
.bipPath as TyphonTypes.BipPath;
|
|
88
|
+
const stakingKeyPath = (address.stakeCredential as TyphonTypes.HashCredential)
|
|
89
|
+
.bipPath as TyphonTypes.BipPath;
|
|
90
|
+
|
|
91
|
+
const paymentKeyPathString = getBipPathString({
|
|
92
|
+
account: accountIndex,
|
|
93
|
+
chain: paymentKeyPath.chain,
|
|
94
|
+
index: paymentKeyPath.index,
|
|
95
|
+
});
|
|
96
|
+
const stakingKeyPathString = getBipPathString({
|
|
97
|
+
account: accountIndex,
|
|
98
|
+
chain: stakingKeyPath.chain,
|
|
99
|
+
index: stakingKeyPath.index,
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
destination = {
|
|
103
|
+
isDeviceOwnedAddress,
|
|
104
|
+
params: {
|
|
105
|
+
spendingPath: paymentKeyPathString,
|
|
106
|
+
stakingPath: stakingKeyPathString,
|
|
107
|
+
},
|
|
108
|
+
};
|
|
109
|
+
} else {
|
|
110
|
+
const address = output.address;
|
|
111
|
+
destination = {
|
|
112
|
+
isDeviceOwnedAddress,
|
|
113
|
+
params: {
|
|
114
|
+
addressHex: address.getHex(),
|
|
115
|
+
},
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
const tokenBundle = Object.values(groupBy(output.tokens, ({ policyId }) => policyId)).map(
|
|
120
|
+
tokens => ({
|
|
121
|
+
policyIdHex: tokens[0].policyId,
|
|
122
|
+
tokens: tokens.map(token => ({
|
|
123
|
+
assetNameHex: token.assetName,
|
|
124
|
+
amount: token.amount.toString(),
|
|
125
|
+
})),
|
|
126
|
+
}),
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
return {
|
|
130
|
+
amount: output.amount.toString(),
|
|
131
|
+
destination,
|
|
132
|
+
tokenBundle,
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
function prepareCertificate(cert: TyphonTypes.Certificate): SignerTxCertificate {
|
|
137
|
+
if (cert.certType === CertificateType.STAKE_REGISTRATION) {
|
|
138
|
+
return prepareStakeRegistrationCertificate(cert as TyphonTypes.StakeRegistrationCertificate);
|
|
139
|
+
} else if (cert.certType === CertificateType.STAKE_DELEGATION) {
|
|
140
|
+
return prepareStakeDelegationCertificate(cert as TyphonTypes.StakeDelegationCertificate);
|
|
141
|
+
} else if (cert.certType === CertificateType.STAKE_DE_REGISTRATION) {
|
|
142
|
+
return prepareStakeDeRegistrationCertificate(
|
|
143
|
+
cert as TyphonTypes.StakeDeRegistrationCertificate,
|
|
144
|
+
);
|
|
145
|
+
} else {
|
|
146
|
+
throw new Error("Invalid Certificate type");
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
function prepareStakeRegistrationCertificate(
|
|
151
|
+
certificate: TyphonTypes.StakeRegistrationCertificate,
|
|
152
|
+
): {
|
|
153
|
+
type: "REGISTRATION";
|
|
154
|
+
params: {
|
|
155
|
+
stakeCredential: {
|
|
156
|
+
keyPath: string;
|
|
157
|
+
};
|
|
158
|
+
};
|
|
159
|
+
} {
|
|
160
|
+
if (
|
|
161
|
+
certificate.stakeCredential.type === TyphonTypes.HashType.ADDRESS &&
|
|
162
|
+
certificate.stakeCredential.bipPath
|
|
163
|
+
) {
|
|
164
|
+
return {
|
|
165
|
+
type: "REGISTRATION",
|
|
166
|
+
params: {
|
|
167
|
+
stakeCredential: {
|
|
168
|
+
keyPath: getBipPathString({
|
|
169
|
+
account: certificate.stakeCredential.bipPath.account,
|
|
170
|
+
chain: certificate.stakeCredential.bipPath.chain,
|
|
171
|
+
index: certificate.stakeCredential.bipPath.index,
|
|
172
|
+
}),
|
|
173
|
+
},
|
|
174
|
+
},
|
|
175
|
+
};
|
|
176
|
+
} else {
|
|
177
|
+
throw new Error("Invalid stakeKey type");
|
|
178
|
+
}
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function prepareStakeDelegationCertificate(certificate: TyphonTypes.StakeDelegationCertificate): {
|
|
182
|
+
type: "DELEGATION";
|
|
183
|
+
params: {
|
|
184
|
+
stakeCredential: {
|
|
185
|
+
keyPath: string;
|
|
186
|
+
};
|
|
187
|
+
poolKeyHashHex: string;
|
|
188
|
+
};
|
|
189
|
+
} {
|
|
190
|
+
if (
|
|
191
|
+
certificate.stakeCredential.type === TyphonTypes.HashType.ADDRESS &&
|
|
192
|
+
certificate.stakeCredential.bipPath
|
|
193
|
+
) {
|
|
194
|
+
return {
|
|
195
|
+
type: "DELEGATION",
|
|
196
|
+
params: {
|
|
197
|
+
stakeCredential: {
|
|
198
|
+
keyPath: getBipPathString({
|
|
199
|
+
account: certificate.stakeCredential.bipPath.account,
|
|
200
|
+
chain: certificate.stakeCredential.bipPath.chain,
|
|
201
|
+
index: certificate.stakeCredential.bipPath.index,
|
|
202
|
+
}),
|
|
203
|
+
},
|
|
204
|
+
poolKeyHashHex: certificate.poolHash,
|
|
205
|
+
},
|
|
206
|
+
};
|
|
207
|
+
} else {
|
|
208
|
+
throw new Error("Invalid stakeKey type");
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
function prepareStakeDeRegistrationCertificate(certificate: TyphonTypes.Certificate): {
|
|
213
|
+
type: "DEREGISTRATION";
|
|
214
|
+
params: {
|
|
215
|
+
stakeCredential: {
|
|
216
|
+
keyPath: string;
|
|
217
|
+
};
|
|
218
|
+
};
|
|
219
|
+
} {
|
|
220
|
+
if (
|
|
221
|
+
certificate.stakeCredential.type === TyphonTypes.HashType.ADDRESS &&
|
|
222
|
+
certificate.stakeCredential.bipPath
|
|
223
|
+
) {
|
|
224
|
+
return {
|
|
225
|
+
type: "DEREGISTRATION",
|
|
226
|
+
params: {
|
|
227
|
+
stakeCredential: {
|
|
228
|
+
keyPath: getBipPathString({
|
|
229
|
+
account: certificate.stakeCredential.bipPath.account,
|
|
230
|
+
chain: certificate.stakeCredential.bipPath.chain,
|
|
231
|
+
index: certificate.stakeCredential.bipPath.index,
|
|
232
|
+
}),
|
|
233
|
+
},
|
|
234
|
+
},
|
|
235
|
+
};
|
|
236
|
+
} else {
|
|
237
|
+
throw new Error("Invalid stakeKey type");
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
function prepareWithdrawal(withdrawal: TyphonTypes.Withdrawal): SignerTxWithdrawal {
|
|
242
|
+
if (
|
|
243
|
+
withdrawal.rewardAccount.stakeCredential.type === TyphonTypes.HashType.ADDRESS &&
|
|
244
|
+
withdrawal.rewardAccount.stakeCredential.bipPath
|
|
245
|
+
) {
|
|
246
|
+
return {
|
|
247
|
+
stakeCredential: {
|
|
248
|
+
keyPath: getBipPathString({
|
|
249
|
+
account: withdrawal.rewardAccount.stakeCredential.bipPath.account,
|
|
250
|
+
chain: withdrawal.rewardAccount.stakeCredential.bipPath.chain,
|
|
251
|
+
index: withdrawal.rewardAccount.stakeCredential.bipPath.index,
|
|
252
|
+
}),
|
|
253
|
+
},
|
|
254
|
+
amount: withdrawal.amount.toString(),
|
|
255
|
+
};
|
|
256
|
+
} else {
|
|
257
|
+
throw new Error("Invalid stakeKey type");
|
|
258
|
+
}
|
|
259
|
+
}
|
package/src/utils.ts
ADDED
package/tsconfig.json
ADDED