@ledgerhq/coin-tron 0.0.1
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 +25 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/jest.integ.config.js +7 -0
- package/lib/bridge/broadcast.d.ts +7 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +26 -0
- package/lib/bridge/broadcast.js.map +1 -0
- package/lib/bridge/buildOptimisticOperation.d.ts +5 -0
- package/lib/bridge/buildOptimisticOperation.d.ts.map +1 -0
- package/lib/bridge/buildOptimisticOperation.js +101 -0
- package/lib/bridge/buildOptimisticOperation.js.map +1 -0
- package/lib/bridge/createTransaction.d.ts +4 -0
- package/lib/bridge/createTransaction.d.ts.map +1 -0
- package/lib/bridge/createTransaction.js +19 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/deviceTransactionConfig.d.ts +20 -0
- package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/bridge/deviceTransactionConfig.js +65 -0
- package/lib/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +5 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +30 -0
- package/lib/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib/bridge/getEstimateFees.d.ts +6 -0
- package/lib/bridge/getEstimateFees.d.ts.map +1 -0
- package/lib/bridge/getEstimateFees.js +52 -0
- package/lib/bridge/getEstimateFees.js.map +1 -0
- package/lib/bridge/getTransactionStatus.d.ts +4 -0
- package/lib/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib/bridge/getTransactionStatus.js +218 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +10 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +60 -0
- package/lib/bridge/index.js.map +1 -0
- package/lib/bridge/preload.d.ts +8 -0
- package/lib/bridge/preload.d.ts.map +1 -0
- package/lib/bridge/preload.js +32 -0
- package/lib/bridge/preload.js.map +1 -0
- package/lib/bridge/prepareTransaction.d.ts +4 -0
- package/lib/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib/bridge/prepareTransaction.js +19 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/serialization.d.ts +9 -0
- package/lib/bridge/serialization.d.ts.map +1 -0
- package/lib/bridge/serialization.js +238 -0
- package/lib/bridge/serialization.js.map +1 -0
- package/lib/bridge/signOperation.d.ts +5 -0
- package/lib/bridge/signOperation.d.ts.map +1 -0
- package/lib/bridge/signOperation.js +92 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/synchronization.d.ts +5 -0
- package/lib/bridge/synchronization.d.ts.map +1 -0
- package/lib/bridge/synchronization.integ.test.d.ts +3 -0
- package/lib/bridge/synchronization.integ.test.d.ts.map +1 -0
- package/lib/bridge/synchronization.integ.test.js +96 -0
- package/lib/bridge/synchronization.integ.test.js.map +1 -0
- package/lib/bridge/synchronization.js +216 -0
- package/lib/bridge/synchronization.js.map +1 -0
- package/lib/bridge/transaction.d.ts +15 -0
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js +61 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/config.d.ts +10 -0
- package/lib/config.d.ts.map +1 -0
- package/lib/config.js +17 -0
- package/lib/config.js.map +1 -0
- package/lib/index.d.ts +3 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +21 -0
- package/lib/index.js.map +1 -0
- package/lib/logic/constants.d.ts +4 -0
- package/lib/logic/constants.d.ts.map +1 -0
- package/lib/logic/constants.js +7 -0
- package/lib/logic/constants.js.map +1 -0
- package/lib/logic/pagination.d.ts +3 -0
- package/lib/logic/pagination.d.ts.map +1 -0
- package/lib/logic/pagination.js +19 -0
- package/lib/logic/pagination.js.map +1 -0
- package/lib/logic/utils.d.ts +12 -0
- package/lib/logic/utils.d.ts.map +1 -0
- package/lib/logic/utils.js +177 -0
- package/lib/logic/utils.js.map +1 -0
- package/lib/network/format.d.ts +9 -0
- package/lib/network/format.d.ts.map +1 -0
- package/lib/network/format.js +127 -0
- package/lib/network/format.js.map +1 -0
- package/lib/network/index.d.ts +30 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.integ.test.d.ts +2 -0
- package/lib/network/index.integ.test.d.ts.map +1 -0
- package/lib/network/index.integ.test.js +38 -0
- package/lib/network/index.integ.test.js.map +1 -0
- package/lib/network/index.js +555 -0
- package/lib/network/index.js.map +1 -0
- package/lib/network/index.test.d.ts +2 -0
- package/lib/network/index.test.d.ts.map +1 -0
- package/lib/network/index.test.js +66 -0
- package/lib/network/index.test.js.map +1 -0
- package/lib/network/superRepresentativesData.mock.d.ts +69 -0
- package/lib/network/superRepresentativesData.mock.d.ts.map +1 -0
- package/lib/network/superRepresentativesData.mock.js +2208 -0
- package/lib/network/superRepresentativesData.mock.js.map +1 -0
- package/lib/network/types.d.ts +122 -0
- package/lib/network/types.d.ts.map +1 -0
- package/lib/network/types.fixture.d.ts +498 -0
- package/lib/network/types.fixture.d.ts.map +1 -0
- package/lib/network/types.fixture.js +4375 -0
- package/lib/network/types.fixture.js.map +1 -0
- package/lib/network/types.js +13 -0
- package/lib/network/types.js.map +1 -0
- package/lib/signer/getAddress.d.ts +6 -0
- package/lib/signer/getAddress.d.ts.map +1 -0
- package/lib/signer/getAddress.js +19 -0
- package/lib/signer/getAddress.js.map +1 -0
- package/lib/signer/index.d.ts +6 -0
- package/lib/signer/index.d.ts.map +1 -0
- package/lib/signer/index.js +11 -0
- package/lib/signer/index.js.map +1 -0
- package/lib/test/bot-deviceActions.d.ts +4 -0
- package/lib/test/bot-deviceActions.d.ts.map +1 -0
- package/lib/test/bot-deviceActions.js +103 -0
- package/lib/test/bot-deviceActions.js.map +1 -0
- package/lib/test/bot-specs.d.ts +7 -0
- package/lib/test/bot-specs.d.ts.map +1 -0
- package/lib/test/bot-specs.js +433 -0
- package/lib/test/bot-specs.js.map +1 -0
- package/lib/test/bridgeDatasetTest.d.ts +4 -0
- package/lib/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib/test/bridgeDatasetTest.js +1284 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/cli.d.ts +52 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +155 -0
- package/lib/test/cli.js.map +1 -0
- package/lib/test/index.d.ts +6 -0
- package/lib/test/index.d.ts.map +1 -0
- package/lib/test/index.js +26 -0
- package/lib/test/index.js.map +1 -0
- package/lib/types/bridge.d.ts +245 -0
- package/lib/types/bridge.d.ts.map +1 -0
- package/lib/types/bridge.js +16 -0
- package/lib/types/bridge.js.map +1 -0
- package/lib/types/errors.d.ts +49 -0
- package/lib/types/errors.d.ts.map +1 -0
- package/lib/types/errors.js +21 -0
- package/lib/types/errors.js.map +1 -0
- package/lib/types/index.d.ts +4 -0
- package/lib/types/index.d.ts.map +1 -0
- package/lib/types/index.js +21 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/signer.d.ts +10 -0
- package/lib/types/signer.d.ts.map +1 -0
- package/lib/types/signer.js +3 -0
- package/lib/types/signer.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +7 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +24 -0
- package/lib-es/bridge/broadcast.js.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.d.ts +5 -0
- package/lib-es/bridge/buildOptimisticOperation.d.ts.map +1 -0
- package/lib-es/bridge/buildOptimisticOperation.js +94 -0
- package/lib-es/bridge/buildOptimisticOperation.js.map +1 -0
- package/lib-es/bridge/createTransaction.d.ts +4 -0
- package/lib-es/bridge/createTransaction.d.ts.map +1 -0
- package/lib-es/bridge/createTransaction.js +14 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts +20 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.js +63 -0
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +5 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +25 -0
- package/lib-es/bridge/estimateMaxSpendable.js.map +1 -0
- package/lib-es/bridge/getEstimateFees.d.ts +6 -0
- package/lib-es/bridge/getEstimateFees.d.ts.map +1 -0
- package/lib-es/bridge/getEstimateFees.js +47 -0
- package/lib-es/bridge/getEstimateFees.js.map +1 -0
- package/lib-es/bridge/getTransactionStatus.d.ts +4 -0
- package/lib-es/bridge/getTransactionStatus.d.ts.map +1 -0
- package/lib-es/bridge/getTransactionStatus.js +213 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +10 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +53 -0
- package/lib-es/bridge/index.js.map +1 -0
- package/lib-es/bridge/preload.d.ts +8 -0
- package/lib-es/bridge/preload.d.ts.map +1 -0
- package/lib-es/bridge/preload.js +27 -0
- package/lib-es/bridge/preload.js.map +1 -0
- package/lib-es/bridge/prepareTransaction.d.ts +4 -0
- package/lib-es/bridge/prepareTransaction.d.ts.map +1 -0
- package/lib-es/bridge/prepareTransaction.js +15 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/serialization.d.ts +9 -0
- package/lib-es/bridge/serialization.d.ts.map +1 -0
- package/lib-es/bridge/serialization.js +229 -0
- package/lib-es/bridge/serialization.js.map +1 -0
- package/lib-es/bridge/signOperation.d.ts +5 -0
- package/lib-es/bridge/signOperation.d.ts.map +1 -0
- package/lib-es/bridge/signOperation.js +85 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/synchronization.d.ts +5 -0
- package/lib-es/bridge/synchronization.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.integ.test.d.ts +3 -0
- package/lib-es/bridge/synchronization.integ.test.d.ts.map +1 -0
- package/lib-es/bridge/synchronization.integ.test.js +89 -0
- package/lib-es/bridge/synchronization.integ.test.js.map +1 -0
- package/lib-es/bridge/synchronization.js +209 -0
- package/lib-es/bridge/synchronization.js.map +1 -0
- package/lib-es/bridge/transaction.d.ts +15 -0
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js +55 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/config.d.ts +10 -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/index.d.ts +3 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +3 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/logic/constants.d.ts +4 -0
- package/lib-es/logic/constants.d.ts.map +1 -0
- package/lib-es/logic/constants.js +4 -0
- package/lib-es/logic/constants.js.map +1 -0
- package/lib-es/logic/pagination.d.ts +3 -0
- package/lib-es/logic/pagination.d.ts.map +1 -0
- package/lib-es/logic/pagination.js +15 -0
- package/lib-es/logic/pagination.js.map +1 -0
- package/lib-es/logic/utils.d.ts +12 -0
- package/lib-es/logic/utils.d.ts.map +1 -0
- package/lib-es/logic/utils.js +167 -0
- package/lib-es/logic/utils.js.map +1 -0
- package/lib-es/network/format.d.ts +9 -0
- package/lib-es/network/format.d.ts.map +1 -0
- package/lib-es/network/format.js +117 -0
- package/lib-es/network/format.js.map +1 -0
- package/lib-es/network/index.d.ts +30 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.integ.test.d.ts +2 -0
- package/lib-es/network/index.integ.test.d.ts.map +1 -0
- package/lib-es/network/index.integ.test.js +36 -0
- package/lib-es/network/index.integ.test.js.map +1 -0
- package/lib-es/network/index.js +524 -0
- package/lib-es/network/index.js.map +1 -0
- package/lib-es/network/index.test.d.ts +2 -0
- package/lib-es/network/index.test.d.ts.map +1 -0
- package/lib-es/network/index.test.js +63 -0
- package/lib-es/network/index.test.js.map +1 -0
- package/lib-es/network/superRepresentativesData.mock.d.ts +69 -0
- package/lib-es/network/superRepresentativesData.mock.d.ts.map +1 -0
- package/lib-es/network/superRepresentativesData.mock.js +2206 -0
- package/lib-es/network/superRepresentativesData.mock.js.map +1 -0
- package/lib-es/network/types.d.ts +122 -0
- package/lib-es/network/types.d.ts.map +1 -0
- package/lib-es/network/types.fixture.d.ts +498 -0
- package/lib-es/network/types.fixture.d.ts.map +1 -0
- package/lib-es/network/types.fixture.js +4371 -0
- package/lib-es/network/types.fixture.js.map +1 -0
- package/lib-es/network/types.js +8 -0
- package/lib-es/network/types.js.map +1 -0
- package/lib-es/signer/getAddress.d.ts +6 -0
- package/lib-es/signer/getAddress.d.ts.map +1 -0
- package/lib-es/signer/getAddress.js +17 -0
- package/lib-es/signer/getAddress.js.map +1 -0
- package/lib-es/signer/index.d.ts +6 -0
- package/lib-es/signer/index.d.ts.map +1 -0
- package/lib-es/signer/index.js +6 -0
- package/lib-es/signer/index.js.map +1 -0
- package/lib-es/test/bot-deviceActions.d.ts +4 -0
- package/lib-es/test/bot-deviceActions.d.ts.map +1 -0
- package/lib-es/test/bot-deviceActions.js +100 -0
- package/lib-es/test/bot-deviceActions.js.map +1 -0
- package/lib-es/test/bot-specs.d.ts +7 -0
- package/lib-es/test/bot-specs.d.ts.map +1 -0
- package/lib-es/test/bot-specs.js +428 -0
- package/lib-es/test/bot-specs.js.map +1 -0
- package/lib-es/test/bridgeDatasetTest.d.ts +4 -0
- package/lib-es/test/bridgeDatasetTest.d.ts.map +1 -0
- package/lib-es/test/bridgeDatasetTest.js +1278 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/cli.d.ts +52 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +149 -0
- package/lib-es/test/cli.js.map +1 -0
- package/lib-es/test/index.d.ts +6 -0
- package/lib-es/test/index.d.ts.map +1 -0
- package/lib-es/test/index.js +6 -0
- package/lib-es/test/index.js.map +1 -0
- package/lib-es/types/bridge.d.ts +245 -0
- package/lib-es/types/bridge.d.ts.map +1 -0
- package/lib-es/types/bridge.js +11 -0
- package/lib-es/types/bridge.js.map +1 -0
- package/lib-es/types/errors.d.ts +49 -0
- package/lib-es/types/errors.d.ts.map +1 -0
- package/lib-es/types/errors.js +18 -0
- package/lib-es/types/errors.js.map +1 -0
- package/lib-es/types/index.d.ts +4 -0
- package/lib-es/types/index.d.ts.map +1 -0
- package/lib-es/types/index.js +5 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/signer.d.ts +10 -0
- package/lib-es/types/signer.d.ts.map +1 -0
- package/lib-es/types/signer.js +2 -0
- package/lib-es/types/signer.js.map +1 -0
- package/package.json +133 -0
- package/src/bridge/broadcast.ts +24 -0
- package/src/bridge/buildOptimisticOperation.ts +133 -0
- package/src/bridge/createTransaction.ts +16 -0
- package/src/bridge/deviceTransactionConfig.ts +99 -0
- package/src/bridge/estimateMaxSpendable.ts +32 -0
- package/src/bridge/getEstimateFees.ts +52 -0
- package/src/bridge/getTransactionStatus.ts +263 -0
- package/src/bridge/index.ts +78 -0
- package/src/bridge/preload.ts +24 -0
- package/src/bridge/prepareTransaction.ts +12 -0
- package/src/bridge/serialization.ts +288 -0
- package/src/bridge/signOperation.ts +123 -0
- package/src/bridge/synchronization.integ.test.ts +105 -0
- package/src/bridge/synchronization.ts +284 -0
- package/src/bridge/transaction.ts +84 -0
- package/src/config.ts +24 -0
- package/src/index.ts +3 -0
- package/src/logic/constants.ts +4 -0
- package/src/logic/pagination.ts +21 -0
- package/src/logic/utils.ts +231 -0
- package/src/network/format.ts +148 -0
- package/src/network/index.integ.test.ts +33 -0
- package/src/network/index.test.ts +61 -0
- package/src/network/index.ts +747 -0
- package/src/network/superRepresentativesData.mock.ts +2205 -0
- package/src/network/types.fixture.ts +4476 -0
- package/src/network/types.ts +147 -0
- package/src/signer/getAddress.ts +13 -0
- package/src/signer/index.ts +7 -0
- package/src/test/bot-deviceActions.ts +121 -0
- package/src/test/bot-specs.ts +457 -0
- package/src/test/bridgeDatasetTest.ts +1343 -0
- package/src/test/cli.ts +219 -0
- package/src/test/index.ts +6 -0
- package/src/types/bridge.ts +304 -0
- package/src/types/errors.ts +22 -0
- package/src/types/index.ts +4 -0
- package/src/types/signer.ts +9 -0
- package/tsconfig.json +14 -0
- package/types/tronweb/index.d.ts +5 -0
package/.eslintrc.js
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
module.exports = {
|
|
2
|
+
env: {
|
|
3
|
+
browser: true,
|
|
4
|
+
es6: true,
|
|
5
|
+
},
|
|
6
|
+
overrides: [
|
|
7
|
+
{
|
|
8
|
+
files: ["src/**/*.test.{ts,tsx}"],
|
|
9
|
+
env: {
|
|
10
|
+
"jest/globals": true,
|
|
11
|
+
},
|
|
12
|
+
plugins: ["jest"],
|
|
13
|
+
},
|
|
14
|
+
],
|
|
15
|
+
rules: {
|
|
16
|
+
"no-console": ["error", { allow: ["warn", "error"] }],
|
|
17
|
+
"@typescript-eslint/no-empty-function": "off",
|
|
18
|
+
"@typescript-eslint/no-explicit-any": "warn",
|
|
19
|
+
},
|
|
20
|
+
};
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
{
|
|
2
|
+
"entry": [
|
|
3
|
+
"src/index.ts",
|
|
4
|
+
"src/bridge/index.ts",
|
|
5
|
+
"src/network/index.ts",
|
|
6
|
+
"src/signer/index.ts"
|
|
7
|
+
],
|
|
8
|
+
"ignoreUnimported": [
|
|
9
|
+
"src/bridge/deviceTransactionConfig.ts",
|
|
10
|
+
"src/bridge/transaction.ts",
|
|
11
|
+
"src/network/superRepresentativesData.mock.ts",
|
|
12
|
+
"src/test/bot-deviceActions.ts",
|
|
13
|
+
"src/test/bot-specs.ts",
|
|
14
|
+
"src/test/bridgeDatasetTest.ts",
|
|
15
|
+
"src/test/cli.ts",
|
|
16
|
+
"src/test/index.ts"
|
|
17
|
+
],
|
|
18
|
+
"ignorePatterns": ["**/node_modules/**", "**/*.fixture.ts", "**/*.mock.ts", "**/*.test.ts"],
|
|
19
|
+
"ignoreUnused": [
|
|
20
|
+
"@ledgerhq/devices",
|
|
21
|
+
"@ledgerhq/live-env",
|
|
22
|
+
"expect",
|
|
23
|
+
"invariant"
|
|
24
|
+
]
|
|
25
|
+
}
|
package/LICENSE.txt
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
The MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2017-present Ledger https://www.ledger.com/
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in
|
|
13
|
+
all copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|
21
|
+
THE SOFTWARE.
|
package/jest.config.js
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** @type {import('ts-jest/dist/types').JestConfigWithTsJest} */
|
|
2
|
+
module.exports = {
|
|
3
|
+
collectCoverageFrom: ["src/**/*.ts"],
|
|
4
|
+
coverageDirectory: "coverage",
|
|
5
|
+
preset: "ts-jest",
|
|
6
|
+
testEnvironment: "node",
|
|
7
|
+
testPathIgnorePatterns: ["lib/", "lib-es/", ".*\\.integ\\.test\\.[tj]s"],
|
|
8
|
+
};
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Account, Operation, SignedOperation } from "@ledgerhq/types-live";
|
|
2
|
+
declare const broadcast: ({ signedOperation: { signature, operation, rawData }, }: {
|
|
3
|
+
account: Account;
|
|
4
|
+
signedOperation: SignedOperation;
|
|
5
|
+
}) => Promise<Operation>;
|
|
6
|
+
export default broadcast;
|
|
7
|
+
//# sourceMappingURL=broadcast.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../src/bridge/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAG3E,QAAA,MAAM,SAAS,4DAEZ;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,eAAe,EAAE,eAAe,CAAC;CAClC,KAAG,QAAQ,SAAS,CAapB,CAAC;AAEF,eAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,26 @@
|
|
|
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
|
+
const network_1 = require("../network");
|
|
13
|
+
const broadcast = (_a) => __awaiter(void 0, [_a], void 0, function* ({ signedOperation: { signature, operation, rawData }, }) {
|
|
14
|
+
const transaction = {
|
|
15
|
+
raw_data: rawData,
|
|
16
|
+
txID: operation.hash,
|
|
17
|
+
signature: [signature],
|
|
18
|
+
};
|
|
19
|
+
const submittedTransaction = yield (0, network_1.broadcastTron)(transaction);
|
|
20
|
+
if (submittedTransaction.result !== true) {
|
|
21
|
+
throw new Error(submittedTransaction.resultMessage);
|
|
22
|
+
}
|
|
23
|
+
return operation;
|
|
24
|
+
});
|
|
25
|
+
exports.default = broadcast;
|
|
26
|
+
//# sourceMappingURL=broadcast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../src/bridge/broadcast.ts"],"names":[],"mappings":";;;;;;;;;;;AACA,wCAA2C;AAE3C,MAAM,SAAS,GAAG,KAKK,EAAE,4CALA,EACvB,eAAe,EAAE,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,GAInD;IACC,MAAM,WAAW,GAAG;QAClB,QAAQ,EAAE,OAAO;QACjB,IAAI,EAAE,SAAS,CAAC,IAAI;QACpB,SAAS,EAAE,CAAC,SAAS,CAAC;KACvB,CAAC;IACF,MAAM,oBAAoB,GAAG,MAAM,IAAA,uBAAa,EAAC,WAAW,CAAC,CAAC;IAE9D,IAAI,oBAAoB,CAAC,MAAM,KAAK,IAAI,EAAE,CAAC;QACzC,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,aAAa,CAAC,CAAC;IACtD,CAAC;IAED,OAAO,SAAS,CAAC;AACnB,CAAC,CAAA,CAAC;AAEF,kBAAe,SAAS,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { TokenAccount } from "@ledgerhq/types-live";
|
|
2
|
+
import BigNumber from "bignumber.js";
|
|
3
|
+
import { Transaction, TronAccount, TronOperation } from "../types";
|
|
4
|
+
export declare const buildOptimisticOperation: (account: TronAccount, subAccount: TokenAccount | undefined, transaction: Transaction, fee: BigNumber, hash: string) => TronOperation;
|
|
5
|
+
//# sourceMappingURL=buildOptimisticOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildOptimisticOperation.d.ts","sourceRoot":"","sources":["../../src/bridge/buildOptimisticOperation.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACpD,OAAO,SAAS,MAAM,cAAc,CAAC;AAGrC,OAAO,EACL,WAAW,EACX,WAAW,EACX,aAAa,EAGd,MAAM,UAAU,CAAC;AA8DlB,eAAO,MAAM,wBAAwB,YAC1B,WAAW,cACR,YAAY,GAAG,SAAS,eACvB,WAAW,OACnB,SAAS,QACR,MAAM,KACX,aAqDF,CAAC"}
|
|
@@ -0,0 +1,101 @@
|
|
|
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.buildOptimisticOperation = void 0;
|
|
7
|
+
const operation_1 = require("@ledgerhq/coin-framework/operation");
|
|
8
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
9
|
+
const get_1 = __importDefault(require("lodash/get"));
|
|
10
|
+
const utils_1 = require("../logic/utils");
|
|
11
|
+
const getValue = (account, subAccount, transaction, fee) => {
|
|
12
|
+
switch (transaction.mode) {
|
|
13
|
+
case "send":
|
|
14
|
+
return subAccount ? fee : new bignumber_js_1.default(transaction.amount || 0).plus(fee);
|
|
15
|
+
case "claimReward": {
|
|
16
|
+
return account.tronResources ? account.tronResources.unwithdrawnReward : new bignumber_js_1.default(0);
|
|
17
|
+
}
|
|
18
|
+
default:
|
|
19
|
+
return new bignumber_js_1.default(0);
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
const getExtra = (account, transaction, resource) => {
|
|
23
|
+
switch (transaction.mode) {
|
|
24
|
+
case "freeze":
|
|
25
|
+
return {
|
|
26
|
+
frozenAmount: transaction.amount,
|
|
27
|
+
};
|
|
28
|
+
case "unfreeze":
|
|
29
|
+
return {
|
|
30
|
+
unfreezeAmount: transaction.amount,
|
|
31
|
+
};
|
|
32
|
+
case "vote":
|
|
33
|
+
return {
|
|
34
|
+
votes: transaction.votes,
|
|
35
|
+
};
|
|
36
|
+
case "unDelegateResource":
|
|
37
|
+
return {
|
|
38
|
+
unDelegatedAmount: transaction.amount,
|
|
39
|
+
receiverAddress: transaction.recipient,
|
|
40
|
+
};
|
|
41
|
+
case "legacyUnfreeze":
|
|
42
|
+
return {
|
|
43
|
+
unfreezeAmount: (0, get_1.default)(account.tronResources, `frozen.${resource.toLocaleLowerCase()}.amount`, new bignumber_js_1.default(0)),
|
|
44
|
+
};
|
|
45
|
+
default:
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const buildOptimisticOperation = (account, subAccount, transaction, fee, hash) => {
|
|
50
|
+
const value = getValue(account, subAccount, transaction, fee);
|
|
51
|
+
const operationType = (0, utils_1.getOperationTypefromMode)(transaction.mode);
|
|
52
|
+
const resource = transaction.resource || "BANDWIDTH";
|
|
53
|
+
const extra = getExtra(account, transaction, resource) || {};
|
|
54
|
+
/**
|
|
55
|
+
* FIXME
|
|
56
|
+
*
|
|
57
|
+
* This is not working and cannot work simply because this "NONE" type doesn't exist during a sync,
|
|
58
|
+
* as well as subOperations which are never created either.
|
|
59
|
+
*
|
|
60
|
+
* And even after fixing this, we're getting wrong fee estimation for TRC20 transactions
|
|
61
|
+
* which are considered as 0 all the time, while it always being between 1 and 10 TRX.
|
|
62
|
+
*/
|
|
63
|
+
const operation = {
|
|
64
|
+
id: (0, operation_1.encodeOperationId)(account.id, hash, operationType),
|
|
65
|
+
hash,
|
|
66
|
+
// if it's a token op and there is no fee, this operation does not exist and is a "NONE"
|
|
67
|
+
type: subAccount && value.eq(0) ? "NONE" : operationType,
|
|
68
|
+
value,
|
|
69
|
+
fee,
|
|
70
|
+
blockHash: null,
|
|
71
|
+
blockHeight: null,
|
|
72
|
+
senders: [account.freshAddress],
|
|
73
|
+
recipients: [transaction.recipient],
|
|
74
|
+
accountId: account.id,
|
|
75
|
+
date: new Date(),
|
|
76
|
+
extra,
|
|
77
|
+
subOperations: subAccount
|
|
78
|
+
? [
|
|
79
|
+
{
|
|
80
|
+
id: (0, operation_1.encodeOperationId)(subAccount.id, hash, "OUT"),
|
|
81
|
+
hash,
|
|
82
|
+
type: "OUT",
|
|
83
|
+
value: transaction.useAllAmount && subAccount
|
|
84
|
+
? subAccount.balance
|
|
85
|
+
: new bignumber_js_1.default(transaction.amount || 0),
|
|
86
|
+
fee: new bignumber_js_1.default(0),
|
|
87
|
+
blockHash: null,
|
|
88
|
+
blockHeight: null,
|
|
89
|
+
senders: [account.freshAddress],
|
|
90
|
+
recipients: [transaction.recipient],
|
|
91
|
+
accountId: subAccount.id,
|
|
92
|
+
date: new Date(),
|
|
93
|
+
extra: {},
|
|
94
|
+
},
|
|
95
|
+
]
|
|
96
|
+
: [],
|
|
97
|
+
};
|
|
98
|
+
return operation;
|
|
99
|
+
};
|
|
100
|
+
exports.buildOptimisticOperation = buildOptimisticOperation;
|
|
101
|
+
//# sourceMappingURL=buildOptimisticOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildOptimisticOperation.js","sourceRoot":"","sources":["../../src/bridge/buildOptimisticOperation.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AAI;oBACJ,IAAI,EAAE,KAAK;oBACX,KAAK,EACH,WAAW,CAAC,YAAY,IAAI,UAAU;wBACpC,CAAC,CAAC,UAAU,CAAC,OAAO;wBACpB,CAAC,CAAC,IAAI,sBAAS,CAAC,WAAW,CAAC,MAAM,IAAI,CAAC,CAAC;oBAC5C,GAAG,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;oBACrB,SAAS,EAAE,IAAI;oBACf,WAAW,EAAE,IAAI;oBACjB,OAAO,EAAE,CAAC,OAAO,CAAC,YAAY,CAAC;oBAC/B,UAAU,EAAE,CAAC,WAAW,CAAC,SAAS,CAAC;oBACnC,SAAS,EAAE,UAAU,CAAC,EAAE;oBACxB,IAAI,EAAE,IAAI,IAAI,EAAE;oBAChB,KAAK,EAAE,EAAE;iBACV;aACF;YACH,CAAC,CAAC,EAAE;KACP,CAAC;IAEF,OAAO,SAAS,CAAC;AACnB,CAAC,CAAC;AA3DW,QAAA,wBAAwB,4BA2DnC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransaction.d.ts","sourceRoot":"","sources":["../../src/bridge/createTransaction.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,QAAA,MAAM,iBAAiB,QAAO,WAU5B,CAAC;AAEH,eAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,19 @@
|
|
|
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 bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
7
|
+
const createTransaction = () => ({
|
|
8
|
+
family: "tron",
|
|
9
|
+
amount: new bignumber_js_1.default(0),
|
|
10
|
+
useAllAmount: false,
|
|
11
|
+
mode: "send",
|
|
12
|
+
duration: 3,
|
|
13
|
+
recipient: "",
|
|
14
|
+
networkInfo: null,
|
|
15
|
+
resource: null,
|
|
16
|
+
votes: [],
|
|
17
|
+
});
|
|
18
|
+
exports.default = createTransaction;
|
|
19
|
+
//# sourceMappingURL=createTransaction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"createTransaction.js","sourceRoot":"","sources":["../../src/bridge/createTransaction.ts"],"names":[],"mappings":";;;;;AAAA,gEAAqC;AAGrC,MAAM,iBAAiB,GAAG,GAAgB,EAAE,CAAC,CAAC;IAC5C,MAAM,EAAE,MAAM;IACd,MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC;IACxB,YAAY,EAAE,KAAK;IACnB,IAAI,EAAE,MAAM;IACZ,QAAQ,EAAE,CAAC;IACX,SAAS,EAAE,EAAE;IACb,WAAW,EAAE,IAAI;IACjB,QAAQ,EAAE,IAAI;IACd,KAAK,EAAE,EAAE;CACV,CAAC,CAAC;AAEH,kBAAe,iBAAiB,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import type { AccountLike, Account } from "@ledgerhq/types-live";
|
|
2
|
+
import type { CommonDeviceTransactionField } from "@ledgerhq/coin-framework/transaction/common";
|
|
3
|
+
import type { Transaction, TransactionStatus } from "../types";
|
|
4
|
+
export type ExtraDeviceTransactionField = {
|
|
5
|
+
type: "tron.resource";
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
} | {
|
|
9
|
+
type: "tron.votes";
|
|
10
|
+
label: string;
|
|
11
|
+
};
|
|
12
|
+
type DeviceTransactionField = CommonDeviceTransactionField | ExtraDeviceTransactionField;
|
|
13
|
+
declare function getDeviceTransactionConfig({ transaction: { votes, resource, mode, recipient }, account, parentAccount, status: { amount }, }: {
|
|
14
|
+
account: AccountLike;
|
|
15
|
+
parentAccount: Account | null | undefined;
|
|
16
|
+
transaction: Transaction;
|
|
17
|
+
status: TransactionStatus;
|
|
18
|
+
}): Array<DeviceTransactionField>;
|
|
19
|
+
export default getDeviceTransactionConfig;
|
|
20
|
+
//# sourceMappingURL=deviceTransactionConfig.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.d.ts","sourceRoot":"","sources":["../../src/bridge/deviceTransactionConfig.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,KAAK,EAAE,4BAA4B,EAAE,MAAM,6CAA6C,CAAC;AAChG,OAAO,KAAK,EAAE,WAAW,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAE/D,MAAM,MAAM,2BAA2B,GACnC;IACE,IAAI,EAAE,eAAe,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;CACf,GACD;IACE,IAAI,EAAE,YAAY,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEN,KAAK,sBAAsB,GAAG,4BAA4B,GAAG,2BAA2B,CAAC;AAEzF,iBAAS,0BAA0B,CAAC,EAClC,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EACjD,OAAO,EACP,aAAa,EACb,MAAM,EAAE,EAAE,MAAM,EAAE,GACnB,EAAE;IACD,OAAO,EAAE,WAAW,CAAC;IACrB,aAAa,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAC1C,WAAW,EAAE,WAAW,CAAC;IACzB,MAAM,EAAE,iBAAiB,CAAC;CAC3B,GAAG,KAAK,CAAC,sBAAsB,CAAC,CAoEhC;AAED,eAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
4
|
+
function getDeviceTransactionConfig({ transaction: { votes, resource, mode, recipient }, account, parentAccount, status: { amount }, }) {
|
|
5
|
+
const mainAccount = (0, account_1.getMainAccount)(account, parentAccount);
|
|
6
|
+
const fields = [];
|
|
7
|
+
if (resource) {
|
|
8
|
+
fields.push({
|
|
9
|
+
type: "tron.resource",
|
|
10
|
+
label: "Resource",
|
|
11
|
+
value: resource.slice(0, 1).toUpperCase() + resource.slice(1).toLowerCase(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
if (votes && votes.length > 0) {
|
|
15
|
+
// NB in future if we unify UI with other coin, we could converge to a "votes" top level
|
|
16
|
+
fields.push({
|
|
17
|
+
type: "tron.votes",
|
|
18
|
+
label: "Votes",
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
if (!amount.isZero()) {
|
|
22
|
+
fields.push({
|
|
23
|
+
type: "amount",
|
|
24
|
+
label: "Amount",
|
|
25
|
+
});
|
|
26
|
+
}
|
|
27
|
+
if (mode === "freeze") {
|
|
28
|
+
fields.push({
|
|
29
|
+
type: "address",
|
|
30
|
+
label: "Freeze To",
|
|
31
|
+
address: mainAccount.freshAddress,
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
if (mode === "unfreeze" || mode === "legacyUnfreeze") {
|
|
35
|
+
fields.push({
|
|
36
|
+
type: "address",
|
|
37
|
+
label: "Unfreeze To",
|
|
38
|
+
address: mainAccount.freshAddress,
|
|
39
|
+
});
|
|
40
|
+
}
|
|
41
|
+
if (mode === "withdrawExpireUnfreeze") {
|
|
42
|
+
fields.push({
|
|
43
|
+
type: "address",
|
|
44
|
+
label: "Withdraw unfrozen to",
|
|
45
|
+
address: mainAccount.freshAddress,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
if (mode === "unDelegateResource") {
|
|
49
|
+
fields.push({
|
|
50
|
+
type: "address",
|
|
51
|
+
label: "Undelegate from",
|
|
52
|
+
address: recipient,
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
if (mode !== "send") {
|
|
56
|
+
fields.push({
|
|
57
|
+
type: "address",
|
|
58
|
+
label: "From Address",
|
|
59
|
+
address: mainAccount.freshAddress,
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return fields;
|
|
63
|
+
}
|
|
64
|
+
exports.default = getDeviceTransactionConfig;
|
|
65
|
+
//# sourceMappingURL=deviceTransactionConfig.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"deviceTransactionConfig.js","sourceRoot":"","sources":["../../src/bridge/deviceTransactionConfig.ts"],"names":[],"mappings":";;AACA,8DAAkE;AAiBlE,SAAS,0BAA0B,CAAC,EAClC,WAAW,EAAE,EAAE,KAAK,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE,EACjD,OAAO,EACP,aAAa,EACb,MAAM,EAAE,EAAE,MAAM,EAAE,GAMnB;IACC,MAAM,WAAW,GAAG,IAAA,wBAAc,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3D,MAAM,MAAM,GAAkC,EAAE,CAAC;IAEjD,IAAI,QAAQ,EAAE,CAAC;QACb,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,eAAe;YACrB,KAAK,EAAE,UAAU;YACjB,KAAK,EAAE,QAAQ,CAAC,KAAK,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,WAAW,EAAE;SAC5E,CAAC,CAAC;IACL,CAAC;IAED,IAAI,KAAK,IAAI,KAAK,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QAC9B,wFAAwF;QACxF,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,YAAY;YAClB,KAAK,EAAE,OAAO;SACf,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,MAAM,CAAC,MAAM,EAAE,EAAE,CAAC;QACrB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,QAAQ;SAChB,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,QAAQ,EAAE,CAAC;QACtB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,WAAW;YAClB,OAAO,EAAE,WAAW,CAAC,YAAY;SAClC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,UAAU,IAAI,IAAI,KAAK,gBAAgB,EAAE,CAAC;QACrD,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,aAAa;YACpB,OAAO,EAAE,WAAW,CAAC,YAAY;SAClC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,wBAAwB,EAAE,CAAC;QACtC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,sBAAsB;YAC7B,OAAO,EAAE,WAAW,CAAC,YAAY;SAClC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,oBAAoB,EAAE,CAAC;QAClC,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,iBAAiB;YACxB,OAAO,EAAE,SAAS;SACnB,CAAC,CAAC;IACL,CAAC;IAED,IAAI,IAAI,KAAK,MAAM,EAAE,CAAC;QACpB,MAAM,CAAC,IAAI,CAAC;YACV,IAAI,EAAE,SAAS;YACf,KAAK,EAAE,cAAc;YACrB,OAAO,EAAE,WAAW,CAAC,YAAY;SAClC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,kBAAe,0BAA0B,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { AccountBridge } from "@ledgerhq/types-live";
|
|
2
|
+
import { Transaction, TronAccount } from "../types";
|
|
3
|
+
declare const estimateMaxSpendable: AccountBridge<Transaction, TronAccount>["estimateMaxSpendable"];
|
|
4
|
+
export default estimateMaxSpendable;
|
|
5
|
+
//# sourceMappingURL=estimateMaxSpendable.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimateMaxSpendable.d.ts","sourceRoot":"","sources":["../../src/bridge/estimateMaxSpendable.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAErD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAIpD,QAAA,MAAM,oBAAoB,EAAE,aAAa,CACvC,WAAW,EACX,WAAW,CACZ,CAAC,sBAAsB,CAkBvB,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
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
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
16
|
+
const account_1 = require("@ledgerhq/coin-framework/account");
|
|
17
|
+
const network_1 = require("../network");
|
|
18
|
+
const createTransaction_1 = __importDefault(require("./createTransaction"));
|
|
19
|
+
const getEstimateFees_1 = __importDefault(require("./getEstimateFees"));
|
|
20
|
+
const estimateMaxSpendable = (_a) => __awaiter(void 0, [_a], void 0, function* ({ account, parentAccount, transaction }) {
|
|
21
|
+
const mainAccount = (0, account_1.getMainAccount)(account, parentAccount);
|
|
22
|
+
const fees = yield (0, getEstimateFees_1.default)(mainAccount, Object.assign(Object.assign(Object.assign(Object.assign({}, (0, createTransaction_1.default)()), { subAccountId: account.type === "Account" ? null : account.id }), transaction), { recipient: (transaction === null || transaction === void 0 ? void 0 : transaction.recipient) || "0x0000000000000000000000000000000000000000", amount: new bignumber_js_1.default(0) }), transaction && transaction.recipient
|
|
23
|
+
? (yield (0, network_1.fetchTronContract)(transaction.recipient)) !== undefined
|
|
24
|
+
: false);
|
|
25
|
+
return account.type === "Account"
|
|
26
|
+
? bignumber_js_1.default.max(0, account.spendableBalance.minus(fees))
|
|
27
|
+
: account.balance;
|
|
28
|
+
});
|
|
29
|
+
exports.default = estimateMaxSpendable;
|
|
30
|
+
//# sourceMappingURL=estimateMaxSpendable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"estimateMaxSpendable.js","sourceRoot":"","sources":["../../src/bridge/estimateMaxSpendable.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AACrC,8DAAkE;AAElE,wCAA+C;AAE/C,4EAAoD;AACpD,wEAAiD;AAEjD,MAAM,oBAAoB,GAGE,KAAoE,EAAE,4CAA/D,EAAE,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE;IACxE,MAAM,WAAW,GAAG,IAAA,wBAAc,EAAC,OAAO,EAAE,aAAa,CAAC,CAAC;IAC3D,MAAM,IAAI,GAAG,MAAM,IAAA,yBAAgB,EACjC,WAAW,8DAEN,IAAA,2BAAiB,GAAE,KACtB,YAAY,EAAE,OAAO,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,OAAO,CAAC,EAAE,KACzD,WAAW,KACd,SAAS,EAAE,CAAA,WAAW,aAAX,WAAW,uBAAX,WAAW,CAAE,SAAS,KAAI,4CAA4C,EACjF,MAAM,EAAE,IAAI,sBAAS,CAAC,CAAC,CAAC,KAE1B,WAAW,IAAI,WAAW,CAAC,SAAS;QAClC,CAAC,CAAC,CAAC,MAAM,IAAA,2BAAiB,EAAC,WAAW,CAAC,SAAS,CAAC,CAAC,KAAK,SAAS;QAChE,CAAC,CAAC,KAAK,CACV,CAAC;IACF,OAAO,OAAO,CAAC,IAAI,KAAK,SAAS;QAC/B,CAAC,CAAC,sBAAS,CAAC,GAAG,CAAC,CAAC,EAAE,OAAO,CAAC,gBAAgB,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACxD,CAAC,CAAC,OAAO,CAAC,OAAO,CAAC;AACtB,CAAC,CAAA,CAAC;AAEF,kBAAe,oBAAoB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { Account } from "@ledgerhq/types-live";
|
|
3
|
+
import { Transaction } from "../types";
|
|
4
|
+
declare const getEstimatedFees: (a: Account, t: Transaction, isContract: boolean) => Promise<BigNumber>;
|
|
5
|
+
export default getEstimatedFees;
|
|
6
|
+
//# sourceMappingURL=getEstimateFees.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEstimateFees.d.ts","sourceRoot":"","sources":["../../src/bridge/getEstimateFees.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC/C,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAqCvC,QAAA,MAAM,gBAAgB,MAAa,OAAO,KAAK,WAAW,cAAc,OAAO,uBAU9E,CAAC;AAEF,eAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
const bignumber_js_1 = __importDefault(require("bignumber.js"));
|
|
16
|
+
const network_1 = require("../network");
|
|
17
|
+
const constants_1 = require("../logic/constants");
|
|
18
|
+
const utils_1 = require("../logic/utils");
|
|
19
|
+
// see : https://developers.tron.network/docs/bandwith#section-bandwidth-points-consumption
|
|
20
|
+
// 1. cost around 200 Bandwidth, if not enough check Free Bandwidth
|
|
21
|
+
// 2. If not enough, will cost some TRX
|
|
22
|
+
// 3. normal transfert cost around 0.002 TRX
|
|
23
|
+
const getFeesFromBandwidth = (account, transaction) => {
|
|
24
|
+
const { freeUsed, freeLimit, gainedUsed, gainedLimit } = (0, utils_1.extractBandwidthInfo)(transaction.networkInfo);
|
|
25
|
+
const available = freeLimit.minus(freeUsed).plus(gainedLimit).minus(gainedUsed);
|
|
26
|
+
const estimatedBandwidthCost = (0, utils_1.getEstimatedBlockSize)(account, transaction);
|
|
27
|
+
if (available.lt(estimatedBandwidthCost)) {
|
|
28
|
+
return new bignumber_js_1.default(2000); // cost is around 0.002 TRX
|
|
29
|
+
}
|
|
30
|
+
return new bignumber_js_1.default(0); // no fee
|
|
31
|
+
};
|
|
32
|
+
// Special case: If activated an account, cost around 0.1 TRX
|
|
33
|
+
const getFeesFromAccountActivation = (a, t) => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const recipientAccount = yield (0, network_1.fetchTronAccount)(t.recipient);
|
|
35
|
+
const { gainedUsed, gainedLimit } = (0, utils_1.extractBandwidthInfo)(t.networkInfo);
|
|
36
|
+
const available = gainedLimit.minus(gainedUsed);
|
|
37
|
+
const estimatedBandwidthCost = (0, utils_1.getEstimatedBlockSize)(a, t);
|
|
38
|
+
if (recipientAccount.length === 0 && available.lt(estimatedBandwidthCost)) {
|
|
39
|
+
return constants_1.ACTIVATION_FEES; // cost is around 1 TRX
|
|
40
|
+
}
|
|
41
|
+
return new bignumber_js_1.default(0); // no fee
|
|
42
|
+
});
|
|
43
|
+
const getEstimatedFees = (a, t, isContract) => __awaiter(void 0, void 0, void 0, function* () {
|
|
44
|
+
const feesFromAccountActivation = t.mode === "send" && !isContract ? yield getFeesFromAccountActivation(a, t) : new bignumber_js_1.default(0);
|
|
45
|
+
if (feesFromAccountActivation.gt(0)) {
|
|
46
|
+
return feesFromAccountActivation;
|
|
47
|
+
}
|
|
48
|
+
const feesFromBandwidth = getFeesFromBandwidth(a, t);
|
|
49
|
+
return feesFromBandwidth;
|
|
50
|
+
});
|
|
51
|
+
exports.default = getEstimatedFees;
|
|
52
|
+
//# sourceMappingURL=getEstimateFees.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getEstimateFees.js","sourceRoot":"","sources":["../../src/bridge/getEstimateFees.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,gEAAqC;AAGrC,wCAA8C;AAC9C,kDAAqD;AACrD,0CAA6E;AAE7E,2FAA2F;AAC3F,mEAAmE;AACnE,uCAAuC;AACvC,4CAA4C;AAC5C,MAAM,oBAAoB,GAAG,CAAC,OAAgB,EAAE,WAAwB,EAAa,EAAE;IACrF,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,UAAU,EAAE,WAAW,EAAE,GAAG,IAAA,4BAAoB,EAC3E,WAAW,CAAC,WAAW,CACxB,CA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C,CAAC,MAAM,4BAA4B,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,sBAAS,CAAC,CAAC,CAAC,CAAC;IAEjG,IAAI,yBAAyB,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QACpC,OAAO,yBAAyB,CAAC;IACnC,CAAC;IAED,MAAM,iBAAiB,GAAG,oBAAoB,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IACrD,OAAO,iBAAiB,CAAC;AAC3B,CAAC,CAAA,CAAC;AAEF,kBAAe,gBAAgB,CAAC"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { Transaction, TransactionStatus, TronAccount } from "../types";
|
|
2
|
+
declare const getTransactionStatus: (acc: TronAccount, transaction: Transaction) => Promise<TransactionStatus>;
|
|
3
|
+
export default getTransactionStatus;
|
|
4
|
+
//# sourceMappingURL=getTransactionStatus.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"getTransactionStatus.d.ts","sourceRoot":"","sources":["../../src/bridge/getTransactionStatus.ts"],"names":[],"mappings":"AAoBA,OAAO,EAAE,WAAW,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAoBvE,QAAA,MAAM,oBAAoB,QACnB,WAAW,eACH,WAAW,KACvB,QAAQ,iBAAiB,CAyN3B,CAAC;AAEF,eAAe,oBAAoB,CAAC"}
|