@ledgerhq/coin-icon 0.4.1-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 +41 -0
- package/CHANGELOG.md +495 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +11 -0
- package/lib/__test__/api/index.unit.test.d.ts +2 -0
- package/lib/__test__/api/index.unit.test.d.ts.map +1 -0
- package/lib/__test__/api/index.unit.test.js +173 -0
- package/lib/__test__/api/index.unit.test.js.map +1 -0
- package/lib/__test__/unit/buildTransaction.test.d.ts +2 -0
- package/lib/__test__/unit/buildTransaction.test.d.ts.map +1 -0
- package/lib/__test__/unit/buildTransaction.test.js +76 -0
- package/lib/__test__/unit/buildTransaction.test.js.map +1 -0
- package/lib/__test__/unit/getFeesForTransaction.unit.test.d.ts +2 -0
- package/lib/__test__/unit/getFeesForTransaction.unit.test.d.ts.map +1 -0
- package/lib/__test__/unit/getFeesForTransaction.unit.test.js +101 -0
- package/lib/__test__/unit/getFeesForTransaction.unit.test.js.map +1 -0
- package/lib/__test__/unit/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib/__test__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib/__test__/unit/getTransactionStatus.unit.test.js +178 -0
- package/lib/__test__/unit/getTransactionStatus.unit.test.js.map +1 -0
- package/lib/__test__/unit/logic.unit.test.d.ts +2 -0
- package/lib/__test__/unit/logic.unit.test.d.ts.map +1 -0
- package/lib/__test__/unit/logic.unit.test.js +112 -0
- package/lib/__test__/unit/logic.unit.test.js.map +1 -0
- package/lib/__test__/unit/serializations.unit.test.d.ts +2 -0
- package/lib/__test__/unit/serializations.unit.test.d.ts.map +1 -0
- package/lib/__test__/unit/serializations.unit.test.js +73 -0
- package/lib/__test__/unit/serializations.unit.test.js.map +1 -0
- package/lib/__test__/unit/transaction.unit.test.d.ts +2 -0
- package/lib/__test__/unit/transaction.unit.test.d.ts.map +1 -0
- package/lib/__test__/unit/transaction.unit.test.js +130 -0
- package/lib/__test__/unit/transaction.unit.test.js.map +1 -0
- package/lib/account.d.ts +7 -0
- package/lib/account.d.ts.map +1 -0
- package/lib/account.js +26 -0
- package/lib/account.js.map +1 -0
- package/lib/api/api-type.d.ts +62 -0
- package/lib/api/api-type.d.ts.map +1 -0
- package/lib/api/api-type.js +3 -0
- package/lib/api/api-type.js.map +1 -0
- package/lib/api/index.d.ts +13 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +134 -0
- package/lib/api/index.js.map +1 -0
- package/lib/api/node.d.ts +31 -0
- package/lib/api/node.d.ts.map +1 -0
- package/lib/api/node.js +112 -0
- package/lib/api/node.js.map +1 -0
- package/lib/bridge/index.d.ts +13 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +71 -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 +105 -0
- package/lib/bridge.integration.test.js.map +1 -0
- package/lib/broadcast.d.ts +9 -0
- package/lib/broadcast.d.ts.map +1 -0
- package/lib/broadcast.js +25 -0
- package/lib/broadcast.js.map +1 -0
- package/lib/buildTransaction.d.ts +12 -0
- package/lib/buildTransaction.d.ts.map +1 -0
- package/lib/buildTransaction.js +55 -0
- package/lib/buildTransaction.js.map +1 -0
- package/lib/cli-transaction.d.ts +16 -0
- package/lib/cli-transaction.d.ts.map +1 -0
- package/lib/cli-transaction.js +35 -0
- package/lib/cli-transaction.js.map +1 -0
- package/lib/config.d.ts +15 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +17 -0
- package/lib/config.js.map +1 -0
- package/lib/constants.d.ts +14 -0
- package/lib/constants.d.ts.map +1 -0
- package/lib/constants.js +17 -0
- package/lib/constants.js.map +1 -0
- package/lib/createTransaction.d.ts +8 -0
- package/lib/createTransaction.d.ts.map +1 -0
- package/lib/createTransaction.js +19 -0
- package/lib/createTransaction.js.map +1 -0
- package/lib/deviceTransactionConfig.d.ts +15 -0
- package/lib/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/deviceTransactionConfig.js +24 -0
- package/lib/deviceTransactionConfig.js.map +1 -0
- package/lib/errors.d.ts +10 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +8 -0
- package/lib/errors.js.map +1 -0
- package/lib/estimateMaxSpendable.d.ts +14 -0
- package/lib/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/estimateMaxSpendable.js +38 -0
- package/lib/estimateMaxSpendable.js.map +1 -0
- package/lib/getFeesForTransaction.d.ts +14 -0
- package/lib/getFeesForTransaction.d.ts.map +1 -0
- package/lib/getFeesForTransaction.js +44 -0
- package/lib/getFeesForTransaction.js.map +1 -0
- package/lib/getTransactionStatus.d.ts +4 -0
- package/lib/getTransactionStatus.d.ts.map +1 -0
- package/lib/getTransactionStatus.js +114 -0
- package/lib/getTransactionStatus.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 +23 -0
- package/lib/hw-getAddress.js.map +1 -0
- package/lib/initAccount.d.ts +3 -0
- package/lib/initAccount.d.ts.map +1 -0
- package/lib/initAccount.js +13 -0
- package/lib/initAccount.js.map +1 -0
- package/lib/logic.d.ts +55 -0
- package/lib/logic.d.ts.map +1 -0
- package/lib/logic.js +124 -0
- package/lib/logic.js.map +1 -0
- package/lib/prepareTransaction.d.ts +9 -0
- package/lib/prepareTransaction.d.ts.map +1 -0
- package/lib/prepareTransaction.js +33 -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 +36 -0
- package/lib/serialization.js.map +1 -0
- package/lib/signOperation.d.ts +10 -0
- package/lib/signOperation.d.ts.map +1 -0
- package/lib/signOperation.js +96 -0
- package/lib/signOperation.js.map +1 -0
- package/lib/signer.d.ts +14 -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 +100 -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 +44 -0
- package/lib/speculos-deviceActions.js.map +1 -0
- package/lib/synchronization.d.ts +3 -0
- package/lib/synchronization.d.ts.map +1 -0
- package/lib/synchronization.js +76 -0
- package/lib/synchronization.js.map +1 -0
- package/lib/transaction.d.ts +15 -0
- package/lib/transaction.d.ts.map +1 -0
- package/lib/transaction.js +39 -0
- package/lib/transaction.js.map +1 -0
- package/lib/types/bridge.fixture.d.ts +5 -0
- package/lib/types/bridge.fixture.d.ts.map +1 -0
- package/lib/types/bridge.fixture.js +77 -0
- package/lib/types/bridge.fixture.js.map +1 -0
- package/lib/types/index.d.ts +46 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +3 -0
- package/lib/types/index.js.map +1 -0
- package/lib-es/__test__/api/index.unit.test.d.ts +2 -0
- package/lib-es/__test__/api/index.unit.test.d.ts.map +1 -0
- package/lib-es/__test__/api/index.unit.test.js +145 -0
- package/lib-es/__test__/api/index.unit.test.js.map +1 -0
- package/lib-es/__test__/unit/buildTransaction.test.d.ts +2 -0
- package/lib-es/__test__/unit/buildTransaction.test.d.ts.map +1 -0
- package/lib-es/__test__/unit/buildTransaction.test.js +71 -0
- package/lib-es/__test__/unit/buildTransaction.test.js.map +1 -0
- package/lib-es/__test__/unit/getFeesForTransaction.unit.test.d.ts +2 -0
- package/lib-es/__test__/unit/getFeesForTransaction.unit.test.d.ts.map +1 -0
- package/lib-es/__test__/unit/getFeesForTransaction.unit.test.js +73 -0
- package/lib-es/__test__/unit/getFeesForTransaction.unit.test.js.map +1 -0
- package/lib-es/__test__/unit/getTransactionStatus.unit.test.d.ts +2 -0
- package/lib-es/__test__/unit/getTransactionStatus.unit.test.d.ts.map +1 -0
- package/lib-es/__test__/unit/getTransactionStatus.unit.test.js +153 -0
- package/lib-es/__test__/unit/getTransactionStatus.unit.test.js.map +1 -0
- package/lib-es/__test__/unit/logic.unit.test.d.ts +2 -0
- package/lib-es/__test__/unit/logic.unit.test.d.ts.map +1 -0
- package/lib-es/__test__/unit/logic.unit.test.js +107 -0
- package/lib-es/__test__/unit/logic.unit.test.js.map +1 -0
- package/lib-es/__test__/unit/serializations.unit.test.d.ts +2 -0
- package/lib-es/__test__/unit/serializations.unit.test.d.ts.map +1 -0
- package/lib-es/__test__/unit/serializations.unit.test.js +71 -0
- package/lib-es/__test__/unit/serializations.unit.test.js.map +1 -0
- package/lib-es/__test__/unit/transaction.unit.test.d.ts +2 -0
- package/lib-es/__test__/unit/transaction.unit.test.d.ts.map +1 -0
- package/lib-es/__test__/unit/transaction.unit.test.js +128 -0
- package/lib-es/__test__/unit/transaction.unit.test.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 +24 -0
- package/lib-es/account.js.map +1 -0
- package/lib-es/api/api-type.d.ts +62 -0
- package/lib-es/api/api-type.d.ts.map +1 -0
- package/lib-es/api/api-type.js +2 -0
- package/lib-es/api/api-type.js.map +1 -0
- package/lib-es/api/index.d.ts +13 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +123 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/api/node.d.ts +31 -0
- package/lib-es/api/node.d.ts.map +1 -0
- package/lib-es/api/node.js +99 -0
- package/lib-es/api/node.js.map +1 -0
- package/lib-es/bridge/index.d.ts +13 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +62 -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 +99 -0
- package/lib-es/bridge.integration.test.js.map +1 -0
- package/lib-es/broadcast.d.ts +9 -0
- package/lib-es/broadcast.d.ts.map +1 -0
- package/lib-es/broadcast.js +21 -0
- package/lib-es/broadcast.js.map +1 -0
- package/lib-es/buildTransaction.d.ts +12 -0
- package/lib-es/buildTransaction.d.ts.map +1 -0
- package/lib-es/buildTransaction.js +48 -0
- package/lib-es/buildTransaction.js.map +1 -0
- package/lib-es/cli-transaction.d.ts +16 -0
- package/lib-es/cli-transaction.d.ts.map +1 -0
- package/lib-es/cli-transaction.js +29 -0
- package/lib-es/cli-transaction.js.map +1 -0
- package/lib-es/config.d.ts +15 -0
- package/lib-es/config.d.ts.map +1 -0
- package/lib-es/config.js +12 -0
- package/lib-es/config.js.map +1 -0
- package/lib-es/constants.d.ts +14 -0
- package/lib-es/constants.d.ts.map +1 -0
- package/lib-es/constants.js +14 -0
- package/lib-es/constants.js.map +1 -0
- package/lib-es/createTransaction.d.ts +8 -0
- package/lib-es/createTransaction.d.ts.map +1 -0
- package/lib-es/createTransaction.js +15 -0
- package/lib-es/createTransaction.js.map +1 -0
- package/lib-es/deviceTransactionConfig.d.ts +15 -0
- package/lib-es/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/deviceTransactionConfig.js +22 -0
- package/lib-es/deviceTransactionConfig.js.map +1 -0
- package/lib-es/errors.d.ts +10 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +5 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/estimateMaxSpendable.d.ts +14 -0
- package/lib-es/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/estimateMaxSpendable.js +31 -0
- package/lib-es/estimateMaxSpendable.js.map +1 -0
- package/lib-es/getFeesForTransaction.d.ts +14 -0
- package/lib-es/getFeesForTransaction.d.ts.map +1 -0
- package/lib-es/getFeesForTransaction.js +42 -0
- package/lib-es/getFeesForTransaction.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 +109 -0
- package/lib-es/getTransactionStatus.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 +21 -0
- package/lib-es/hw-getAddress.js.map +1 -0
- package/lib-es/initAccount.d.ts +3 -0
- package/lib-es/initAccount.d.ts.map +1 -0
- package/lib-es/initAccount.js +9 -0
- package/lib-es/initAccount.js.map +1 -0
- package/lib-es/logic.d.ts +55 -0
- package/lib-es/logic.d.ts.map +1 -0
- package/lib-es/logic.js +109 -0
- package/lib-es/logic.js.map +1 -0
- package/lib-es/prepareTransaction.d.ts +9 -0
- package/lib-es/prepareTransaction.d.ts.map +1 -0
- package/lib-es/prepareTransaction.js +26 -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 +29 -0
- package/lib-es/serialization.js.map +1 -0
- package/lib-es/signOperation.d.ts +10 -0
- package/lib-es/signOperation.d.ts.map +1 -0
- package/lib-es/signOperation.js +89 -0
- package/lib-es/signOperation.js.map +1 -0
- package/lib-es/signer.d.ts +14 -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 +95 -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 +41 -0
- package/lib-es/speculos-deviceActions.js.map +1 -0
- package/lib-es/synchronization.d.ts +3 -0
- package/lib-es/synchronization.d.ts.map +1 -0
- package/lib-es/synchronization.js +69 -0
- package/lib-es/synchronization.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 +33 -0
- package/lib-es/transaction.js.map +1 -0
- package/lib-es/types/bridge.fixture.d.ts +5 -0
- package/lib-es/types/bridge.fixture.d.ts.map +1 -0
- package/lib-es/types/bridge.fixture.js +68 -0
- package/lib-es/types/bridge.fixture.js.map +1 -0
- package/lib-es/types/index.d.ts +46 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +2 -0
- package/lib-es/types/index.js.map +1 -0
- package/package.json +85 -0
- package/src/__test__/api/index.unit.test.ts +151 -0
- package/src/__test__/unit/buildTransaction.test.ts +76 -0
- package/src/__test__/unit/getFeesForTransaction.unit.test.ts +76 -0
- package/src/__test__/unit/getTransactionStatus.unit.test.ts +172 -0
- package/src/__test__/unit/logic.unit.test.ts +145 -0
- package/src/__test__/unit/serializations.unit.test.ts +92 -0
- package/src/__test__/unit/transaction.unit.test.ts +144 -0
- package/src/account.ts +30 -0
- package/src/api/api-type.ts +65 -0
- package/src/api/index.ts +156 -0
- package/src/api/node.ts +115 -0
- package/src/bridge/index.ts +76 -0
- package/src/bridge.integration.test.ts +107 -0
- package/src/broadcast.ts +18 -0
- package/src/buildTransaction.ts +53 -0
- package/src/cli-transaction.ts +49 -0
- package/src/config.ts +29 -0
- package/src/constants.ts +14 -0
- package/src/createTransaction.ts +16 -0
- package/src/deviceTransactionConfig.ts +44 -0
- package/src/errors.ts +5 -0
- package/src/estimateMaxSpendable.ts +34 -0
- package/src/getFeesForTransaction.ts +46 -0
- package/src/getTransactionStatus.ts +139 -0
- package/src/hw-getAddress.ts +19 -0
- package/src/initAccount.ts +11 -0
- package/src/logic.ts +132 -0
- package/src/prepareTransaction.ts +24 -0
- package/src/serialization.ts +34 -0
- package/src/signOperation.ts +140 -0
- package/src/signer.ts +14 -0
- package/src/specs.ts +124 -0
- package/src/speculos-deviceActions.ts +46 -0
- package/src/synchronization.ts +70 -0
- package/src/transaction.ts +60 -0
- package/src/types/bridge.fixture.ts +75 -0
- package/src/types/index.ts +61 -0
- package/tsconfig.json +12 -0
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { BigNumber } from "bignumber.js";
|
|
2
|
+
import type { IcxTransaction } from "icon-sdk-js";
|
|
3
|
+
import { CryptoCurrency } from "@ledgerhq/types-cryptoassets";
|
|
4
|
+
import { IconAccount } from "../types/index";
|
|
5
|
+
import { SignedOperation } from "@ledgerhq/types-live";
|
|
6
|
+
import { IconDelegationType } from "./api-type";
|
|
7
|
+
/**
|
|
8
|
+
* Returns Testnet RPC URL if the current currency is testnet
|
|
9
|
+
* @param {currency} currency
|
|
10
|
+
*/
|
|
11
|
+
export declare function getRpcUrl(currency: CryptoCurrency): string;
|
|
12
|
+
export declare function getDebugRpcUrl(currency: CryptoCurrency): string;
|
|
13
|
+
/**
|
|
14
|
+
* Broadcast blob to blockchain
|
|
15
|
+
*/
|
|
16
|
+
export declare const broadcastTransaction: (signedOperation: SignedOperation, currency: CryptoCurrency) => Promise<{
|
|
17
|
+
hash: string;
|
|
18
|
+
}>;
|
|
19
|
+
export declare const submit: (signedOperation: SignedOperation, currency: CryptoCurrency) => Promise<{
|
|
20
|
+
hash: string;
|
|
21
|
+
}>;
|
|
22
|
+
/**
|
|
23
|
+
* Obtain fees from blockchain
|
|
24
|
+
*/
|
|
25
|
+
export declare const getFees: (unsigned: IcxTransaction, account: IconAccount) => Promise<BigNumber>;
|
|
26
|
+
/**
|
|
27
|
+
* Get step price from governance contract
|
|
28
|
+
*/
|
|
29
|
+
export declare const getStepPrice: (account: IconAccount) => Promise<BigNumber>;
|
|
30
|
+
export declare const getDelegation: (address: string, currency: CryptoCurrency) => Promise<IconDelegationType>;
|
|
31
|
+
//# sourceMappingURL=node.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.d.ts","sourceRoot":"","sources":["../../src/api/node.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,OAAO,KAAK,EAAE,cAAc,EAAqB,MAAM,aAAa,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAG9D,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAMhD;;;GAGG;AACH,wBAAgB,SAAS,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAO1D;AAED,wBAAgB,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,MAAM,CAO/D;AAED;;GAEG;AACH,eAAO,MAAM,oBAAoB,oBACd,eAAe,YACtB,cAAc;;EAIzB,CAAC;AAEF,eAAO,MAAM,MAAM,oBAA2B,eAAe,YAAY,cAAc;;EAiBtF,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,OAAO,aACR,cAAc,WACf,WAAW,KACnB,QAAQ,SAAS,CAMnB,CAAC;AAEF;;GAEG;AACH,eAAO,MAAM,YAAY,YAAmB,WAAW,KAAG,QAAQ,SAAS,CAQ1E,CAAC;AAEF,eAAO,MAAM,aAAa,YACf,MAAM,YACL,cAAc,KACvB,QAAQ,kBAAkB,CAkB5B,CAAC"}
|
package/lib/api/node.js
ADDED
|
@@ -0,0 +1,112 @@
|
|
|
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.getDelegation = exports.getStepPrice = exports.getFees = exports.submit = exports.broadcastTransaction = exports.getDebugRpcUrl = exports.getRpcUrl = void 0;
|
|
16
|
+
const bignumber_js_1 = require("bignumber.js");
|
|
17
|
+
const icon_sdk_js_1 = __importDefault(require("icon-sdk-js"));
|
|
18
|
+
const logic_1 = require("../logic");
|
|
19
|
+
const constants_1 = require("../constants");
|
|
20
|
+
const config_1 = require("../config");
|
|
21
|
+
const { HttpProvider } = icon_sdk_js_1.default;
|
|
22
|
+
const { IconBuilder } = icon_sdk_js_1.default;
|
|
23
|
+
/**
|
|
24
|
+
* Returns Testnet RPC URL if the current currency is testnet
|
|
25
|
+
* @param {currency} currency
|
|
26
|
+
*/
|
|
27
|
+
function getRpcUrl(currency) {
|
|
28
|
+
const currencyConfig = (0, config_1.getCoinConfig)();
|
|
29
|
+
let rpcUrl = currencyConfig.infra.node_endpoint;
|
|
30
|
+
if ((0, logic_1.isTestnet)(currency)) {
|
|
31
|
+
rpcUrl = currencyConfig.infra.node_testnet_endpoint;
|
|
32
|
+
}
|
|
33
|
+
return rpcUrl;
|
|
34
|
+
}
|
|
35
|
+
exports.getRpcUrl = getRpcUrl;
|
|
36
|
+
function getDebugRpcUrl(currency) {
|
|
37
|
+
const currencyConfig = (0, config_1.getCoinConfig)();
|
|
38
|
+
let rpcUrl = currencyConfig.infra.debug_endpoint;
|
|
39
|
+
if ((0, logic_1.isTestnet)(currency)) {
|
|
40
|
+
rpcUrl = currencyConfig.infra.debug_testnet_endpoint;
|
|
41
|
+
}
|
|
42
|
+
return rpcUrl;
|
|
43
|
+
}
|
|
44
|
+
exports.getDebugRpcUrl = getDebugRpcUrl;
|
|
45
|
+
/**
|
|
46
|
+
* Broadcast blob to blockchain
|
|
47
|
+
*/
|
|
48
|
+
const broadcastTransaction = (signedOperation, currency) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const { hash } = yield (0, exports.submit)(signedOperation, currency);
|
|
50
|
+
return { hash };
|
|
51
|
+
});
|
|
52
|
+
exports.broadcastTransaction = broadcastTransaction;
|
|
53
|
+
const submit = (signedOperation, currency) => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
const rpcURL = getRpcUrl(currency);
|
|
55
|
+
const httpProvider = new HttpProvider(rpcURL);
|
|
56
|
+
const iconService = new icon_sdk_js_1.default(httpProvider);
|
|
57
|
+
const signedTransaction = {
|
|
58
|
+
getProperties: () => signedOperation.rawData,
|
|
59
|
+
getSignature: () => signedOperation.signature,
|
|
60
|
+
};
|
|
61
|
+
const response = yield iconService
|
|
62
|
+
.sendTransaction(signedTransaction)
|
|
63
|
+
.execute();
|
|
64
|
+
return {
|
|
65
|
+
hash: response,
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
exports.submit = submit;
|
|
69
|
+
/**
|
|
70
|
+
* Obtain fees from blockchain
|
|
71
|
+
*/
|
|
72
|
+
const getFees = (unsigned, account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const debugRpcUrl = getDebugRpcUrl(account.currency);
|
|
74
|
+
const httpProvider = new HttpProvider(debugRpcUrl);
|
|
75
|
+
const iconService = new icon_sdk_js_1.default(httpProvider);
|
|
76
|
+
const res = yield iconService.estimateStep(unsigned).execute();
|
|
77
|
+
return new bignumber_js_1.BigNumber(res);
|
|
78
|
+
});
|
|
79
|
+
exports.getFees = getFees;
|
|
80
|
+
/**
|
|
81
|
+
* Get step price from governance contract
|
|
82
|
+
*/
|
|
83
|
+
const getStepPrice = (account) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const rpcURL = getRpcUrl(account.currency);
|
|
85
|
+
const httpProvider = new HttpProvider(rpcURL);
|
|
86
|
+
const iconService = new icon_sdk_js_1.default(httpProvider);
|
|
87
|
+
const txBuilder = new IconBuilder.CallBuilder();
|
|
88
|
+
const stepPriceTx = txBuilder.to(constants_1.GOVERNANCE_SCORE_ADDRESS).method("getStepPrice").build();
|
|
89
|
+
const res = yield iconService.call(stepPriceTx).execute();
|
|
90
|
+
return new bignumber_js_1.BigNumber(res);
|
|
91
|
+
});
|
|
92
|
+
exports.getStepPrice = getStepPrice;
|
|
93
|
+
const getDelegation = (address, currency) => __awaiter(void 0, void 0, void 0, function* () {
|
|
94
|
+
const rpcURL = getRpcUrl(currency);
|
|
95
|
+
const httpProvider = new HttpProvider(rpcURL);
|
|
96
|
+
const iconService = new icon_sdk_js_1.default(httpProvider);
|
|
97
|
+
const delegationTx = new IconBuilder.CallBuilder()
|
|
98
|
+
.to(constants_1.IISS_SCORE_ADDRESS)
|
|
99
|
+
.method("getDelegation")
|
|
100
|
+
.params({
|
|
101
|
+
address,
|
|
102
|
+
})
|
|
103
|
+
.build();
|
|
104
|
+
const res = yield iconService.call(delegationTx).execute();
|
|
105
|
+
return {
|
|
106
|
+
delegations: res.delegations,
|
|
107
|
+
totalDelegated: new bignumber_js_1.BigNumber(res.totalDelegated),
|
|
108
|
+
votingPower: new bignumber_js_1.BigNumber(res.votingPower),
|
|
109
|
+
};
|
|
110
|
+
});
|
|
111
|
+
exports.getDelegation = getDelegation;
|
|
112
|
+
//# sourceMappingURL=node.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"node.js","sourceRoot":"","sources":["../../src/api/node.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,+CAAyC;AACzC,8DAAsC;AAGtC,oCAAqC;AACrC,4CAA4E;AAI5E,sCAA0C;AAE1C,MAAM,EAAE,YAAY,EAAE,GAAG,qBAAW,CAAC;AACrC,MAAM,EAAE,WAAW,EAAE,GAAG,qBAAW,CAAC;AAEpC;;;GAGG;AACH,SAAgB,SA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,CAAC,CAAC;AAC5B,CAAC,CAAA,CAAC;AARW,QAAA,YAAY,gBAQvB;AAEK,MAAM,aAAa,GAAG,CAC3B,OAAe,EACf,QAAwB,EACK,EAAE;IAC/B,MAAM,MAAM,GAAG,SAAS,CAAC,QAAQ,CAAC,CAAC;IACnC,MAAM,YAAY,GAAG,IAAI,YAAY,CAAC,MAAM,CAAC,CAAC;IAC9C,MAAM,WAAW,GAAG,IAAI,qBAAW,CAAC,YAAY,CAAC,CAAC;IAClD,MAAM,YAAY,GAAG,IAAI,WAAW,CAAC,WAAW,EAAE;SAC/C,EAAE,CAAC,8BAAkB,CAAC;SACtB,MAAM,CAAC,eAAe,CAAC;SACvB,MAAM,CAAC;QACN,OAAO;KACR,CAAC;SACD,KAAK,EAAE,CAAC;IAEX,MAAM,GAAG,GAAG,MAAM,WAAW,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC,OAAO,EAAE,CAAC;IAC3D,OAAO;QACL,WAAW,EAAE,GAAG,CAAC,WAAW;QAC5B,cAAc,EAAE,IAAI,wBAAS,CAAC,GAAG,CAAC,cAAc,CAAC;QACjD,WAAW,EAAE,IAAI,wBAAS,CAAC,GAAG,CAAC,WAAW,CAAC;KAC5C,CAAC;AACJ,CAAC,CAAA,CAAC;AArBW,QAAA,aAAa,iBAqBxB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SignerContext } from "@ledgerhq/coin-framework/signer";
|
|
2
|
+
import { CoinConfig } from "@ledgerhq/coin-framework/config";
|
|
3
|
+
import type { AccountBridge, CurrencyBridge } from "@ledgerhq/types-live";
|
|
4
|
+
import type { Transaction } from "../types/index";
|
|
5
|
+
import { IconSigner } from "../signer";
|
|
6
|
+
import { IconCoinConfig } from "../config";
|
|
7
|
+
export declare function buildCurrencyBridge(signerContext: SignerContext<IconSigner>): CurrencyBridge;
|
|
8
|
+
export declare function buildAccountBridge(signerContext: SignerContext<IconSigner>): AccountBridge<Transaction>;
|
|
9
|
+
export declare function createBridges(signerContext: SignerContext<IconSigner>, coinConfig: CoinConfig<IconCoinConfig>): {
|
|
10
|
+
currencyBridge: CurrencyBridge;
|
|
11
|
+
accountBridge: AccountBridge<Transaction, import("@ledgerhq/types-live").Account, import("@ledgerhq/types-live").TransactionStatusCommon, import("@ledgerhq/types-live").AccountRaw>;
|
|
12
|
+
};
|
|
13
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/bridge/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,aAAa,EAAE,MAAM,iCAAiC,CAAC;AAChE,OAAO,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAE7D,OAAO,KAAK,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAW1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAClD,OAAO,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACvC,OAAO,EAAE,cAAc,EAAiB,MAAM,WAAW,CAAC;AAE1D,wBAAgB,mBAAmB,CAAC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,GAAG,cAAc,CAa5F;AAED,wBAAgB,kBAAkB,CAChC,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,GACvC,aAAa,CAAC,WAAW,CAAC,CAqB5B;AAED,wBAAgB,aAAa,CAC3B,aAAa,EAAE,aAAa,CAAC,UAAU,CAAC,EACxC,UAAU,EAAE,UAAU,CAAC,cAAc,CAAC;;;EAQvC"}
|
|
@@ -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.createBridges = exports.buildAccountBridge = exports.buildCurrencyBridge = void 0;
|
|
16
|
+
const getAddressWrapper_1 = __importDefault(require("@ledgerhq/coin-framework/bridge/getAddressWrapper"));
|
|
17
|
+
const jsHelpers_1 = require("@ledgerhq/coin-framework/bridge/jsHelpers");
|
|
18
|
+
const hw_getAddress_1 = __importDefault(require("../hw-getAddress"));
|
|
19
|
+
const initAccount_1 = require("../initAccount");
|
|
20
|
+
const broadcast_1 = require("../broadcast");
|
|
21
|
+
const createTransaction_1 = require("../createTransaction");
|
|
22
|
+
const estimateMaxSpendable_1 = require("../estimateMaxSpendable");
|
|
23
|
+
const getTransactionStatus_1 = require("../getTransactionStatus");
|
|
24
|
+
const prepareTransaction_1 = require("../prepareTransaction");
|
|
25
|
+
const signOperation_1 = require("../signOperation");
|
|
26
|
+
const synchronization_1 = require("../synchronization");
|
|
27
|
+
const serialization_1 = require("../serialization");
|
|
28
|
+
const config_1 = require("../config");
|
|
29
|
+
function buildCurrencyBridge(signerContext) {
|
|
30
|
+
const getAddress = (0, hw_getAddress_1.default)(signerContext);
|
|
31
|
+
const scanAccounts = (0, jsHelpers_1.makeScanAccounts)({
|
|
32
|
+
getAccountShape: synchronization_1.getAccountShape,
|
|
33
|
+
getAddressFn: getAddress,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
preload: () => __awaiter(this, void 0, void 0, function* () { return Promise.resolve({}); }),
|
|
37
|
+
hydrate: () => { },
|
|
38
|
+
scanAccounts,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
exports.buildCurrencyBridge = buildCurrencyBridge;
|
|
42
|
+
function buildAccountBridge(signerContext) {
|
|
43
|
+
const getAddress = (0, hw_getAddress_1.default)(signerContext);
|
|
44
|
+
const receive = (0, jsHelpers_1.makeAccountBridgeReceive)((0, getAddressWrapper_1.default)(getAddress));
|
|
45
|
+
const signOperation = (0, signOperation_1.buildSignOperation)(signerContext);
|
|
46
|
+
const sync = (0, jsHelpers_1.makeSync)({ getAccountShape: synchronization_1.getAccountShape });
|
|
47
|
+
return {
|
|
48
|
+
createTransaction: createTransaction_1.createTransaction,
|
|
49
|
+
updateTransaction: jsHelpers_1.defaultUpdateTransaction,
|
|
50
|
+
prepareTransaction: prepareTransaction_1.prepareTransaction,
|
|
51
|
+
getTransactionStatus: getTransactionStatus_1.getTransactionStatus,
|
|
52
|
+
sync,
|
|
53
|
+
receive,
|
|
54
|
+
assignToAccountRaw: serialization_1.assignToAccountRaw,
|
|
55
|
+
assignFromAccountRaw: serialization_1.assignFromAccountRaw,
|
|
56
|
+
initAccount: initAccount_1.initAccount,
|
|
57
|
+
signOperation,
|
|
58
|
+
broadcast: broadcast_1.broadcast,
|
|
59
|
+
estimateMaxSpendable: estimateMaxSpendable_1.estimateMaxSpendable,
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
exports.buildAccountBridge = buildAccountBridge;
|
|
63
|
+
function createBridges(signerContext, coinConfig) {
|
|
64
|
+
(0, config_1.setCoinConfig)(coinConfig);
|
|
65
|
+
return {
|
|
66
|
+
currencyBridge: buildCurrencyBridge(signerContext),
|
|
67
|
+
accountBridge: buildAccountBridge(signerContext),
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
exports.createBridges = createBridges;
|
|
71
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources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a;QACb,SAAS,EAAT,qBAAS;QACT,oBAAoB,EAApB,2CAAoB;KACrB,CAAC;AACJ,CAAC;AAvBD,gDAuBC;AAED,SAAgB,aAAa,CAC3B,aAAwC,EACxC,UAAsC;IAEtC,IAAA,sBAAa,EAAC,UAAU,CAAC,CAAC;IAE1B,OAAO;QACL,cAAc,EAAE,mBAAmB,CAAC,aAAa,CAAC;QAClD,aAAa,EAAE,kBAAkB,CAAC,aAAa,CAAC;KACjD,CAAC;AACJ,CAAC;AAVD,sCAUC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.integration.test.d.ts","sourceRoot":"","sources":["../src/bridge.integration.test.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAkB,MAAM,sBAAsB,CAAC;AACxE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAoG3C,eAAO,MAAM,OAAO,EAAE,WAAW,CAAC,WAAW,CAK5C,CAAC"}
|
|
@@ -0,0 +1,105 @@
|
|
|
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.dataset = void 0;
|
|
7
|
+
const transaction_1 = require("./transaction");
|
|
8
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
+
const errors_1 = require("@ledgerhq/errors");
|
|
10
|
+
const TEST_ADDRESS = "hxe52720d9125586e64c745bf3c2c1917dbb46f9ba";
|
|
11
|
+
const icon = {
|
|
12
|
+
scanAccounts: [
|
|
13
|
+
{
|
|
14
|
+
name: "icon seed 1",
|
|
15
|
+
apdus: `
|
|
16
|
+
=> e00200010d038000002c8049435880000000
|
|
17
|
+
<= 410426dd3cdd69f3604e9c1d8f3021b20e133524f12894b9ef8e35d3f1f5244516d18b7bb0d1fee7b7c2972d5cde08190d66cf932d0addd5ac87f53198d050940ccb2a6878626232396531313463626434303939346136346462303137626363323233616661353135363966669fd5109b2b2077b50f18fee878efef03cef0cfb5c3256ea9e55f44fa0e9ae5289000
|
|
18
|
+
=> e002000115058000002c80494358800000008000000080000000
|
|
19
|
+
<= 4104c1142d5b765d3026e801fd3946d9673051c7e3c3bd0eecd8ca27b6be079c9ee6b7b9f311b9eecb2995efd7e4a7ef9287a7f8878751d3227689c25a324270e8082a687863663465326339346235323631396637326161346461313333373061613663316333646164303064ff4e5e0cebe9462a469955997216658ce22953f79d272a6a1ecf3b3cdcb3549a9000
|
|
20
|
+
=> e002000115058000002c80494358800000008000000080000001
|
|
21
|
+
<= 410429e40c4a50f96a32b622e218114c9204f66763c997dadb8c719a95d3a2d98fda3b00ccc9f3d491906d453fa2a63298817eb6af94c77a47f5eb4baa43cbb73a832a6878666330343962346365363063633539363834383764313830643963343236336536333138313733392ed566d1841e629d6f3040a23918ee84015fb60b99824d7dcadde65bcb01bb089000
|
|
22
|
+
=> e002000115058000002c80494358800000008000000080000002
|
|
23
|
+
<= 41040310ab9742ae76a33cfb81fbb90f7d2c16af8dbe543cea73dc62dda4eb79eea4363cabad566329103dc8c6d1f29d6e005d608e35d97d80337e1ca5fd07f3da5b2a6878303139393332346162343038343733313565633339373264313738316239646363643136323061650ce87de91bb446401889398f585fc09a525bf7841dc254d94def7023b40523069000
|
|
24
|
+
`,
|
|
25
|
+
},
|
|
26
|
+
],
|
|
27
|
+
accounts: [
|
|
28
|
+
{
|
|
29
|
+
FIXME_tests: ["balance is sum of ops"],
|
|
30
|
+
raw: {
|
|
31
|
+
id: `js:2:icon:${TEST_ADDRESS}:`,
|
|
32
|
+
seedIdentifier: `${TEST_ADDRESS}`,
|
|
33
|
+
name: "ICON 1",
|
|
34
|
+
derivationMode: "",
|
|
35
|
+
index: 0,
|
|
36
|
+
freshAddress: `${TEST_ADDRESS}`,
|
|
37
|
+
freshAddressPath: "44'/4801368'/0'/0'/0'",
|
|
38
|
+
blockHeight: 0,
|
|
39
|
+
operations: [],
|
|
40
|
+
pendingOperations: [],
|
|
41
|
+
currencyId: "icon",
|
|
42
|
+
lastSyncDate: "",
|
|
43
|
+
balance: "299569965",
|
|
44
|
+
},
|
|
45
|
+
transactions: [
|
|
46
|
+
{
|
|
47
|
+
name: "recipient and sender must not be the same",
|
|
48
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
49
|
+
family: "icon",
|
|
50
|
+
recipient: `${TEST_ADDRESS}`,
|
|
51
|
+
amount: "100000000",
|
|
52
|
+
mode: "send",
|
|
53
|
+
fees: "0.00125",
|
|
54
|
+
}),
|
|
55
|
+
expectedStatus: {
|
|
56
|
+
amount: new bignumber_js_1.default("100000000"),
|
|
57
|
+
errors: {
|
|
58
|
+
recipient: new errors_1.InvalidAddressBecauseDestinationIsAlsoSource(),
|
|
59
|
+
},
|
|
60
|
+
warnings: {},
|
|
61
|
+
},
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
name: "Not a valid address",
|
|
65
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
66
|
+
family: "icon",
|
|
67
|
+
recipient: "iconinv",
|
|
68
|
+
amount: "100000000",
|
|
69
|
+
mode: "send",
|
|
70
|
+
fees: null,
|
|
71
|
+
}),
|
|
72
|
+
expectedStatus: {
|
|
73
|
+
errors: {
|
|
74
|
+
recipient: new errors_1.InvalidAddress(),
|
|
75
|
+
},
|
|
76
|
+
warnings: {},
|
|
77
|
+
},
|
|
78
|
+
},
|
|
79
|
+
{
|
|
80
|
+
name: "Not enough balance",
|
|
81
|
+
transaction: (0, transaction_1.fromTransactionRaw)({
|
|
82
|
+
family: "icon",
|
|
83
|
+
recipient: "hxedaf3b2027fbbc0a31f589299c0b34533cd8edac",
|
|
84
|
+
amount: "1000000000000000000000000",
|
|
85
|
+
mode: "send",
|
|
86
|
+
fees: null,
|
|
87
|
+
}),
|
|
88
|
+
expectedStatus: {
|
|
89
|
+
errors: {
|
|
90
|
+
amount: new errors_1.NotEnoughBalance(),
|
|
91
|
+
},
|
|
92
|
+
warnings: {},
|
|
93
|
+
},
|
|
94
|
+
},
|
|
95
|
+
],
|
|
96
|
+
},
|
|
97
|
+
],
|
|
98
|
+
};
|
|
99
|
+
exports.dataset = {
|
|
100
|
+
implementations: ["js"],
|
|
101
|
+
currencies: {
|
|
102
|
+
icon,
|
|
103
|
+
},
|
|
104
|
+
};
|
|
105
|
+
//# sourceMappingURL=bridge.integration.test.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.integration.test.js","sourceRoot":"","sources":["../src/bridge.integration.test.ts"],"names":[],"mappings":";;;;;;AAEA,+CAAmD;AACnD,gEAAqC;AACrC,6CAI0B;AAE1B,MAAM,YAAY,GAAG,4CAA4C,CAAC;AAElE,MAAM,IAAI,GAAgC;IACxC,YAAY,EAAE;QACZ;YACE,IAAI,EAAE,aAAa;YACnB,KAAK,EAAE;;;;;;;;;OASN;SACF;KACF;IACD,QAAQ,EAAE;QACR;YACE,WAAW,EAAE,CAAC,uBAAuB,CAAC;YACtC,GAAG,EAAE;gBACH,EAAE,EAAE,aAAa,YAAY,GAAG;gBAChC,cAAc,EAAE,GAAG,YAAY,EAAE;gBACjC,IAAI,EAAE,QAAQ;gBACd,cAAc,EAAE,EAAE;gBAClB,KAAK,EAAE,CAAC;gBACR,YAAY,EAAE,GAAG,YAAY,EAAE;gBAC/B,gBAAgB,EAAE,uBAAuB;gBACzC,WAAW,EAAE,CAAC;gBACd,UAAU,EAAE,EAAE;gBACd,iBAAiB,EAAE,EAAE;gBACrB,UAAU,EAAE,MAAM;gBAClB,YAAY,EAAE,EAAE;gBAChB,OAAO,EAAE,WAAW;aACrB;YACD,YAAY,EAAE;gBACZ;oBACE,IAAI,EAAE,2CAA2C;oBACjD,WAAW,EAAE,IAAA,gCAAkB,EAAC;wBAC9B,MAAM,EAAE,MAAM;wBACd,SAAS,EAAE,GAAG,YAAY,EAAE;wBAC5B,MAAM,EAAE,WAAW;wBACnB,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,SAAS;qBAChB,CAAC;oBACF,cAAc,EAAE;wBACd,MAAM,EAAE,IAAI,sBAAS,CAAC,WAAW,CAAC;wBAClC,MAAM,EAAE;4BACN,SAAS,EAAE,IAAI,qDAA4C,EAAE;yBAC9D;wBACD,QAAQ,EAAE,EAAE;qBACb;iBACF;gBACD;oBACE,IAAI,EAAE,qBAAqB;oBAC3B,WAAW,EAAE,IAAA,gCAAkB,EAAC;wBAC9B,MAAM,EAAE,MAAM;wBACd,SAAS,EAAE,SAAS;wBACpB,MAAM,EAAE,WAAW;wBACnB,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI;qBACX,CAAC;oBACF,cAAc,EAAE;wBACd,MAAM,EAAE;4BACN,SAAS,EAAE,IAAI,uBAAc,EAAE;yBAChC;wBACD,QAAQ,EAAE,EAAE;qBACb;iBACF;gBACD;oBACE,IAAI,EAAE,oBAAoB;oBAC1B,WAAW,EAAE,IAAA,gCAAkB,EAAC;wBAC9B,MAAM,EAAE,MAAM;wBACd,SAAS,EAAE,4CAA4C;wBACvD,MAAM,EAAE,2BAA2B;wBACnC,IAAI,EAAE,MAAM;wBACZ,IAAI,EAAE,IAAI;qBACX,CAAC;oBACF,cAAc,EAAE;wBACd,MAAM,EAAE;4BACN,MAAM,EAAE,IAAI,yBAAgB,EAAE;yBAC/B;wBACD,QAAQ,EAAE,EAAE;qBACb;iBACF;aACF;SACF;KACF;CACF,CAAC;AAEW,QAAA,OAAO,GAA6B;IAC/C,eAAe,EAAE,CAAC,IAAI,CAAC;IACvB,UAAU,EAAE;QACV,IAAI;KACL;CACF,CAAC"}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { Account, Operation, SignedOperation } from "@ledgerhq/types-live";
|
|
2
|
+
/**
|
|
3
|
+
* Broadcast the signed transaction
|
|
4
|
+
*/
|
|
5
|
+
export declare function broadcast({ account, signedOperation, }: {
|
|
6
|
+
account: Account;
|
|
7
|
+
signedOperation: SignedOperation;
|
|
8
|
+
}): Promise<Operation>;
|
|
9
|
+
//# sourceMappingURL=broadcast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAK3E;;GAEG;AACH,wBAAsB,SAAS,CAAC,EAC9B,OAAO,EACP,eAAe,GAChB,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;CAClC,GAAG,OAAO,CAAC,SAAS,CAAC,CAGrB"}
|
package/lib/broadcast.js
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
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.broadcast = void 0;
|
|
13
|
+
const operation_1 = require("@ledgerhq/coin-framework/operation");
|
|
14
|
+
const node_1 = require("./api/node");
|
|
15
|
+
/**
|
|
16
|
+
* Broadcast the signed transaction
|
|
17
|
+
*/
|
|
18
|
+
function broadcast(_a) {
|
|
19
|
+
return __awaiter(this, arguments, void 0, function* ({ account, signedOperation, }) {
|
|
20
|
+
const { hash } = yield (0, node_1.broadcastTransaction)(signedOperation, account.currency);
|
|
21
|
+
return (0, operation_1.patchOperationWithHash)(signedOperation.operation, hash);
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
exports.broadcast = broadcast;
|
|
25
|
+
//# sourceMappingURL=broadcast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../src/broadcast.ts"],"names":[],"mappings":";;;;;;;;;;;;AACA,kEAA4E;AAE5E,qCAAkD;AAElD;;GAEG;AACH,SAAsB,SAAS;yDAAC,EAC9B,OAAO,EACP,eAAe,GAIhB;QACC,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAA,2BAAoB,EAAC,eAAe,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC;QAC/E,OAAO,IAAA,kCAAsB,EAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IACjE,CAAC;CAAA;AATD,8BASC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { IconAccount, Transaction } from "./types";
|
|
2
|
+
import type { IcxTransaction } from "icon-sdk-js";
|
|
3
|
+
import BigNumber from "bignumber.js";
|
|
4
|
+
/**
|
|
5
|
+
*
|
|
6
|
+
* @param {Account} account
|
|
7
|
+
* @param {Transaction} transaction
|
|
8
|
+
*/
|
|
9
|
+
export declare const buildTransaction: (account: IconAccount, transaction: Transaction, stepLimit?: BigNumber | undefined) => Promise<{
|
|
10
|
+
unsigned: IcxTransaction;
|
|
11
|
+
}>;
|
|
12
|
+
//# sourceMappingURL=buildTransaction.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTransaction.d.ts","sourceRoot":"","sources":["../src/buildTransaction.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AAExD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAElD,OAAO,SAAS,MAAM,cAAc,CAAC;AA2BrC;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,YAClB,WAAW,eACP,WAAW,cACZ,SAAS,GAAG,SAAS;;EAalC,CAAC"}
|
|
@@ -0,0 +1,55 @@
|
|
|
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 icon_sdk_js_1 = __importDefault(require("icon-sdk-js"));
|
|
17
|
+
const logic_1 = require("./logic");
|
|
18
|
+
const constants_1 = require("./constants");
|
|
19
|
+
const { IconBuilder, IconConverter } = icon_sdk_js_1.default;
|
|
20
|
+
const buildTransferTransaction = (account, transaction, stepLimit) => {
|
|
21
|
+
const address = account.freshAddress;
|
|
22
|
+
const icxTransactionBuilder = new IconBuilder.IcxTransactionBuilder();
|
|
23
|
+
const icxTransferData = icxTransactionBuilder
|
|
24
|
+
.from(address)
|
|
25
|
+
.to(transaction.recipient)
|
|
26
|
+
.value(IconConverter.toHexNumber(transaction.amount))
|
|
27
|
+
.nid(IconConverter.toHexNumber((0, logic_1.getNid)(account.currency)))
|
|
28
|
+
.nonce(IconConverter.toHexNumber((0, logic_1.getNonce)(account)))
|
|
29
|
+
.timestamp(IconConverter.toHexNumber(new Date().getTime() * 1000))
|
|
30
|
+
.version(IconConverter.toHexNumber(constants_1.RPC_VERSION));
|
|
31
|
+
if (stepLimit) {
|
|
32
|
+
icxTransferData.stepLimit(IconConverter.toHexNumber(stepLimit));
|
|
33
|
+
}
|
|
34
|
+
return icxTransferData.build();
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
*
|
|
38
|
+
* @param {Account} account
|
|
39
|
+
* @param {Transaction} transaction
|
|
40
|
+
*/
|
|
41
|
+
const buildTransaction = (account, transaction, stepLimit) => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
let unsigned;
|
|
43
|
+
switch (transaction.mode) {
|
|
44
|
+
case "send":
|
|
45
|
+
unsigned = buildTransferTransaction(account, transaction, stepLimit);
|
|
46
|
+
break;
|
|
47
|
+
default:
|
|
48
|
+
throw new Error(`Unsupported transaction mode: ${transaction.mode}`);
|
|
49
|
+
}
|
|
50
|
+
return {
|
|
51
|
+
unsigned,
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
exports.buildTransaction = buildTransaction;
|
|
55
|
+
//# sourceMappingURL=buildTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildTransaction.js","sourceRoot":"","sources":["../src/buildTransaction.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AACA,8DAAsC;AAEtC,mCAA2C;AAE3C,2CAA0C;AAE1C,MAAM,EAAE,WAAW,EAAE,aAAa,EAAE,GAAG,qBAAW,CAAC;AAEnD,MAAM,wBAAwB,GAAG,CAC/B,OAAoB,EACpB,WAAwB,EACxB,SAAiC,EACjB,EAAE;IAClB,MAAM,OAAO,GAAG,OAAO,CAAC,YAAY,CAAC;IACrC,MAAM,qBAAqB,GAAG,IAAI,WAAW,CAAC,qBAAqB,EAAE,CAAC;IACtE,MAAM,eAAe,GAAG,q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3
|
+
declare function inferTransactions(transactions: Array<{
|
|
4
|
+
account: AccountLike;
|
|
5
|
+
transaction: Transaction;
|
|
6
|
+
}>, opts: Record<string, any>): Transaction[];
|
|
7
|
+
export default function makeCliTools(): {
|
|
8
|
+
options: {
|
|
9
|
+
name: string;
|
|
10
|
+
type: StringConstructor;
|
|
11
|
+
desc: string;
|
|
12
|
+
}[];
|
|
13
|
+
inferTransactions: typeof inferTransactions;
|
|
14
|
+
};
|
|
15
|
+
export {};
|
|
16
|
+
//# 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,KAAK,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGxD,OAAO,KAAK,EAAe,WAAW,EAAE,MAAM,SAAS,CAAC;AAUxD,iBAAS,iBAAiB,CACxB,YAAY,EAAE,KAAK,CAAC;IAClB,OAAO,EAAE,WAAW,CAAC;IACrB,WAAW,EAAE,WAAW,CAAC;CAC1B,CAAC,EACF,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACxB,WAAW,EAAE,CAsBf;AAED,MAAM,CAAC,OAAO,UAAU,YAAY;;;;;;;EAKnC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
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 options = [
|
|
9
|
+
{
|
|
10
|
+
name: "mode",
|
|
11
|
+
type: String,
|
|
12
|
+
desc: "mode of transaction: send, stake, unstake",
|
|
13
|
+
},
|
|
14
|
+
];
|
|
15
|
+
function inferTransactions(transactions, opts) {
|
|
16
|
+
return (0, flatMap_1.default)(transactions, ({ transaction, account }) => {
|
|
17
|
+
(0, invariant_1.default)(transaction.family === "icon", "[cli-transaction] inferTransactions expects icon family transaction");
|
|
18
|
+
if (account.type === "Account") {
|
|
19
|
+
(0, invariant_1.default)(account.iconResources, "unactivated account");
|
|
20
|
+
}
|
|
21
|
+
if (account.type === "TokenAccount") {
|
|
22
|
+
const isDelisted = account.token.delisted === true;
|
|
23
|
+
(0, invariant_1.default)(!isDelisted, "token is delisted");
|
|
24
|
+
}
|
|
25
|
+
return Object.assign(Object.assign({}, transaction), { family: "icon", mode: opts.mode || "send" });
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
function makeCliTools() {
|
|
29
|
+
return {
|
|
30
|
+
options,
|
|
31
|
+
inferTransactions,
|
|
32
|
+
};
|
|
33
|
+
}
|
|
34
|
+
exports.default = makeCliTools;
|
|
35
|
+
//# 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;AAGrC,MAAM,OAAO,GAAG;IACd;QACE,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,MAAM;QACZ,IAAI,EAAE,2CAA2C;KAClD;CACF,CAAC;AAEF,SAAS,iBAAiB,CACxB,YAGE,EACF,IAAyB;IAEzB,OAAO,IAAA,iBAAO,EAAC,YAAY,EAAE,CAAC,EAAE,WAAW,EAAE,OAAO,EAAE,EAAE,EAAE;QACxD,IAAA,mBAAS,EACP,WAAW,CAAC,MAAM,KAAK,MAAM,EAC7B,qEAAqE,CACtE,CAAC;QAEF,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;YAC/B,IAAA,mBAAS,EAAE,OAAuB,CAAC,aAAa,EAAE,qBAAqB,CAAC,CAAC;QAC3E,CAAC;QAED,IAAI,OAAO,CAAC,IAAI,KAAK,cAAc,EAAE,CAAC;YACpC,MAAM,UAAU,GAAG,OAAO,CAAC,KAAK,CAAC,QAAQ,KAAK,IAAI,CAAC;YACnD,IAAA,mBAAS,EAAC,CAAC,UAAU,EAAE,mBAAmB,CAAC,CAAC;QAC9C,CAAC;QAED,OAAO,gCACF,WAAW,KACd,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,IAAI,CAAC,IAAI,IAAI,MAAM,GACX,CAAC;IACnB,CAAC,CAAC,CAAC;AACL,CAAC;AAED,SAAwB,YAAY;IAClC,OAAO;QACL,OAAO;QACP,iBAAiB;KAClB,CAAC;AACJ,CAAC;AALD,+BAKC"}
|
package/lib/config.d.ts
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { CurrencyConfig, CoinConfig } from "@ledgerhq/coin-framework/config";
|
|
2
|
+
export type IconConfig = {
|
|
3
|
+
infra: {
|
|
4
|
+
indexer: string;
|
|
5
|
+
indexer_testnet: string;
|
|
6
|
+
node_endpoint: string;
|
|
7
|
+
node_testnet_endpoint: string;
|
|
8
|
+
debug_endpoint: string;
|
|
9
|
+
debug_testnet_endpoint: string;
|
|
10
|
+
};
|
|
11
|
+
};
|
|
12
|
+
export type IconCoinConfig = CurrencyConfig & IconConfig;
|
|
13
|
+
export declare const setCoinConfig: (config: CoinConfig<IconCoinConfig>) => void;
|
|
14
|
+
export declare const getCoinConfig: () => IconCoinConfig;
|
|
15
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,iCAAiC,CAAC;AAG7E,MAAM,MAAM,UAAU,GAAG;IACvB,KAAK,EAAE;QACL,OAAO,EAAE,MAAM,CAAC;QAChB,eAAe,EAAE,MAAM,CAAC;QACxB,aAAa,EAAE,MAAM,CAAC;QACtB,qBAAqB,EAAE,MAAM,CAAC;QAC9B,cAAc,EAAE,MAAM,CAAC;QACvB,sBAAsB,EAAE,MAAM,CAAC;KAChC,CAAC;CACH,CAAC;AAEF,MAAM,MAAM,cAAc,GAAG,cAAc,GAAG,UAAU,CAAC;AAIzD,eAAO,MAAM,aAAa,WAAY,WAAW,cAAc,CAAC,KAAG,IAElE,CAAC;AAEF,eAAO,MAAM,aAAa,QAAO,cAMhC,CAAC"}
|
package/lib/config.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getCoinConfig = exports.setCoinConfig = void 0;
|
|
4
|
+
const errors_1 = require("@ledgerhq/coin-framework/errors");
|
|
5
|
+
let coinConfig;
|
|
6
|
+
const setCoinConfig = (config) => {
|
|
7
|
+
coinConfig = config;
|
|
8
|
+
};
|
|
9
|
+
exports.setCoinConfig = setCoinConfig;
|
|
10
|
+
const getCoinConfig = () => {
|
|
11
|
+
if (!coinConfig) {
|
|
12
|
+
throw new errors_1.MissingCoinConfig();
|
|
13
|
+
}
|
|
14
|
+
return coinConfig();
|
|
15
|
+
};
|
|
16
|
+
exports.getCoinConfig = getCoinConfig;
|
|
17
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";;;AACA,4DAAoE;AAepE,IAAI,UAAkD,CAAC;AAEhD,MAAM,aAAa,GAAG,CAAC,MAAkC,EAAQ,EAAE;IACxE,UAAU,GAAG,MAAM,CAAC;AACtB,CAAC,CAAC;AAFW,QAAA,aAAa,iBAExB;AAEK,MAAM,aAAa,GAAG,GAAmB,EAAE;IAChD,IAAI,CAAC,UAAU,EAAE,CAAC;QAChB,MAAM,IAAI,0BAAiB,EAAE,CAAC;IAChC,CAAC;IAED,OAAO,UAAU,EAAE,CAAC;AACtB,CAAC,CAAC;AANW,QAAA,aAAa,iBAMxB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare const GOVERNANCE_SCORE_ADDRESS = "cx0000000000000000000000000000000000000001";
|
|
2
|
+
export declare const IISS_SCORE_ADDRESS = "cx0000000000000000000000000000000000000000";
|
|
3
|
+
export declare const LIMIT = 100;
|
|
4
|
+
export declare const BERLIN_TESTNET_NID = 7;
|
|
5
|
+
export declare const MAINNET_NID = 1;
|
|
6
|
+
export declare const I_SCORE_UNIT = 1000;
|
|
7
|
+
export declare const RPC_VERSION = 3;
|
|
8
|
+
export declare const DEFAULT_STEP_LIMIT = 200000;
|
|
9
|
+
export declare const PREP_TYPE: {
|
|
10
|
+
MAIN: string;
|
|
11
|
+
SUB: string;
|
|
12
|
+
CANDIDATE: string;
|
|
13
|
+
};
|
|
14
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,wBAAwB,+CAA+C,CAAC;AACrF,eAAO,MAAM,kBAAkB,+CAA+C,CAAC;AAC/E,eAAO,MAAM,KAAK,MAAM,CAAC;AACzB,eAAO,MAAM,kBAAkB,IAAI,CAAC;AACpC,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,YAAY,OAAO,CAAC;AACjC,eAAO,MAAM,WAAW,IAAI,CAAC;AAC7B,eAAO,MAAM,kBAAkB,SAAS,CAAC;AAEzC,eAAO,MAAM,SAAS;;;;CAIrB,CAAC"}
|
package/lib/constants.js
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.PREP_TYPE = exports.DEFAULT_STEP_LIMIT = exports.RPC_VERSION = exports.I_SCORE_UNIT = exports.MAINNET_NID = exports.BERLIN_TESTNET_NID = exports.LIMIT = exports.IISS_SCORE_ADDRESS = exports.GOVERNANCE_SCORE_ADDRESS = void 0;
|
|
4
|
+
exports.GOVERNANCE_SCORE_ADDRESS = "cx0000000000000000000000000000000000000001";
|
|
5
|
+
exports.IISS_SCORE_ADDRESS = "cx0000000000000000000000000000000000000000";
|
|
6
|
+
exports.LIMIT = 100;
|
|
7
|
+
exports.BERLIN_TESTNET_NID = 7;
|
|
8
|
+
exports.MAINNET_NID = 1;
|
|
9
|
+
exports.I_SCORE_UNIT = 1000;
|
|
10
|
+
exports.RPC_VERSION = 3;
|
|
11
|
+
exports.DEFAULT_STEP_LIMIT = 200000;
|
|
12
|
+
exports.PREP_TYPE = {
|
|
13
|
+
MAIN: "Main P-Rep",
|
|
14
|
+
SUB: "Sub P-Rep",
|
|
15
|
+
CANDIDATE: "Candidate",
|
|
16
|
+
};
|
|
17
|
+
//# sourceMappingURL=constants.js.map
|