@ledgerhq/coin-filecoin 1.3.2
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/.turbo/turbo-build.log +4 -0
- package/.unimportedrc.json +21 -0
- package/CHANGELOG.md +19 -0
- package/LICENSE.txt +21 -0
- package/jest.config.js +8 -0
- package/lib/api/api.d.ts +9 -0
- package/lib/api/api.d.ts.map +1 -0
- package/lib/api/api.js +99 -0
- package/lib/api/api.js.map +1 -0
- package/lib/api/index.d.ts +2 -0
- package/lib/api/index.d.ts.map +1 -0
- package/lib/api/index.js +18 -0
- package/lib/api/index.js.map +1 -0
- package/lib/bridge/broadcast.d.ts +4 -0
- package/lib/bridge/broadcast.d.ts.map +1 -0
- package/lib/bridge/broadcast.js +27 -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 +62 -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 +24 -0
- package/lib/bridge/createTransaction.js.map +1 -0
- package/lib/bridge/deviceTransactionConfig.d.ts +33 -0
- package/lib/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib/bridge/deviceTransactionConfig.js +71 -0
- package/lib/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib/bridge/estimateMaxSpendable.js +100 -0
- package/lib/bridge/estimateMaxSpendable.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 +84 -0
- package/lib/bridge/getTransactionStatus.js.map +1 -0
- package/lib/bridge/index.d.ts +8 -0
- package/lib/bridge/index.d.ts.map +1 -0
- package/lib/bridge/index.js +54 -0
- package/lib/bridge/index.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 +75 -0
- package/lib/bridge/prepareTransaction.js.map +1 -0
- package/lib/bridge/serializer.d.ts +13 -0
- package/lib/bridge/serializer.d.ts.map +1 -0
- package/lib/bridge/serializer.js +65 -0
- package/lib/bridge/serializer.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 +80 -0
- package/lib/bridge/signOperation.js.map +1 -0
- package/lib/bridge/transaction.d.ts +14 -0
- package/lib/bridge/transaction.d.ts.map +1 -0
- package/lib/bridge/transaction.js +41 -0
- package/lib/bridge/transaction.js.map +1 -0
- package/lib/bridge/utils.d.ts +26 -0
- package/lib/bridge/utils.d.ts.map +1 -0
- package/lib/bridge/utils.js +67 -0
- package/lib/bridge/utils.js.map +1 -0
- package/lib/bridge/utils.unit.test.d.ts +2 -0
- package/lib/bridge/utils.unit.test.d.ts.map +1 -0
- package/lib/bridge/utils.unit.test.js +23 -0
- package/lib/bridge/utils.unit.test.js.map +1 -0
- package/lib/common-logic/index.d.ts +2 -0
- package/lib/common-logic/index.d.ts.map +1 -0
- package/lib/common-logic/index.js +13 -0
- package/lib/common-logic/index.js.map +1 -0
- package/lib/common-logic/utils.d.ts +22 -0
- package/lib/common-logic/utils.d.ts.map +1 -0
- package/lib/common-logic/utils.js +189 -0
- package/lib/common-logic/utils.js.map +1 -0
- package/lib/erc20/ERC20.json +12 -0
- package/lib/erc20/tokenAccounts.d.ts +10 -0
- package/lib/erc20/tokenAccounts.d.ts.map +1 -0
- package/lib/erc20/tokenAccounts.js +169 -0
- package/lib/erc20/tokenAccounts.js.map +1 -0
- package/lib/errors.d.ts +7 -0
- package/lib/errors.d.ts.map +1 -0
- package/lib/errors.js +13 -0
- package/lib/errors.js.map +1 -0
- package/lib/hw-signMessage.d.ts +12 -0
- package/lib/hw-signMessage.d.ts.map +1 -0
- package/lib/hw-signMessage.js +32 -0
- package/lib/hw-signMessage.js.map +1 -0
- package/lib/index.d.ts +2 -0
- package/lib/index.d.ts.map +1 -0
- package/lib/index.js +6 -0
- package/lib/index.js.map +1 -0
- package/lib/network/addresses.d.ts +16 -0
- package/lib/network/addresses.d.ts.map +1 -0
- package/lib/network/addresses.js +75 -0
- package/lib/network/addresses.js.map +1 -0
- package/lib/network/index.d.ts +2 -0
- package/lib/network/index.d.ts.map +1 -0
- package/lib/network/index.js +18 -0
- package/lib/network/index.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 +30 -0
- package/lib/signer/getAddress.js.map +1 -0
- package/lib/signer/index.d.ts +3 -0
- package/lib/signer/index.d.ts.map +1 -0
- package/lib/signer/index.js +8 -0
- package/lib/signer/index.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 +151 -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 +401 -0
- package/lib/test/bridgeDatasetTest.js.map +1 -0
- package/lib/test/cli.d.ts +19 -0
- package/lib/test/cli.d.ts.map +1 -0
- package/lib/test/cli.js +59 -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/test/speculos-deviceActions.d.ts +5 -0
- package/lib/test/speculos-deviceActions.d.ts.map +1 -0
- package/lib/test/speculos-deviceActions.js +159 -0
- package/lib/test/speculos-deviceActions.js.map +1 -0
- package/lib/types/bridge.d.ts +35 -0
- package/lib/types/bridge.d.ts.map +1 -0
- package/lib/types/bridge.js +3 -0
- package/lib/types/bridge.js.map +1 -0
- package/lib/types/common.d.ts +96 -0
- package/lib/types/common.d.ts.map +1 -0
- package/lib/types/common.js +10 -0
- package/lib/types/common.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 +20 -0
- package/lib/types/index.js.map +1 -0
- package/lib/types/signer.d.ts +19 -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/api/api.d.ts +9 -0
- package/lib-es/api/api.d.ts.map +1 -0
- package/lib-es/api/api.js +87 -0
- package/lib-es/api/api.js.map +1 -0
- package/lib-es/api/index.d.ts +2 -0
- package/lib-es/api/index.d.ts.map +1 -0
- package/lib-es/api/index.js +2 -0
- package/lib-es/api/index.js.map +1 -0
- package/lib-es/bridge/broadcast.d.ts +4 -0
- package/lib-es/bridge/broadcast.d.ts.map +1 -0
- package/lib-es/bridge/broadcast.js +23 -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 +58 -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 +17 -0
- package/lib-es/bridge/createTransaction.js.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts +33 -0
- package/lib-es/bridge/deviceTransactionConfig.d.ts.map +1 -0
- package/lib-es/bridge/deviceTransactionConfig.js +69 -0
- package/lib-es/bridge/deviceTransactionConfig.js.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts +4 -0
- package/lib-es/bridge/estimateMaxSpendable.d.ts.map +1 -0
- package/lib-es/bridge/estimateMaxSpendable.js +93 -0
- package/lib-es/bridge/estimateMaxSpendable.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 +80 -0
- package/lib-es/bridge/getTransactionStatus.js.map +1 -0
- package/lib-es/bridge/index.d.ts +8 -0
- package/lib-es/bridge/index.d.ts.map +1 -0
- package/lib-es/bridge/index.js +47 -0
- package/lib-es/bridge/index.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 +68 -0
- package/lib-es/bridge/prepareTransaction.js.map +1 -0
- package/lib-es/bridge/serializer.d.ts +13 -0
- package/lib-es/bridge/serializer.d.ts.map +1 -0
- package/lib-es/bridge/serializer.js +58 -0
- package/lib-es/bridge/serializer.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 +76 -0
- package/lib-es/bridge/signOperation.js.map +1 -0
- package/lib-es/bridge/transaction.d.ts +14 -0
- package/lib-es/bridge/transaction.d.ts.map +1 -0
- package/lib-es/bridge/transaction.js +33 -0
- package/lib-es/bridge/transaction.js.map +1 -0
- package/lib-es/bridge/utils.d.ts +26 -0
- package/lib-es/bridge/utils.d.ts.map +1 -0
- package/lib-es/bridge/utils.js +57 -0
- package/lib-es/bridge/utils.js.map +1 -0
- package/lib-es/bridge/utils.unit.test.d.ts +2 -0
- package/lib-es/bridge/utils.unit.test.d.ts.map +1 -0
- package/lib-es/bridge/utils.unit.test.js +21 -0
- package/lib-es/bridge/utils.unit.test.js.map +1 -0
- package/lib-es/common-logic/index.d.ts +2 -0
- package/lib-es/common-logic/index.d.ts.map +1 -0
- package/lib-es/common-logic/index.js +2 -0
- package/lib-es/common-logic/index.js.map +1 -0
- package/lib-es/common-logic/utils.d.ts +22 -0
- package/lib-es/common-logic/utils.d.ts.map +1 -0
- package/lib-es/common-logic/utils.js +175 -0
- package/lib-es/common-logic/utils.js.map +1 -0
- package/lib-es/erc20/ERC20.json +12 -0
- package/lib-es/erc20/tokenAccounts.d.ts +10 -0
- package/lib-es/erc20/tokenAccounts.d.ts.map +1 -0
- package/lib-es/erc20/tokenAccounts.js +158 -0
- package/lib-es/erc20/tokenAccounts.js.map +1 -0
- package/lib-es/errors.d.ts +7 -0
- package/lib-es/errors.d.ts.map +1 -0
- package/lib-es/errors.js +10 -0
- package/lib-es/errors.js.map +1 -0
- package/lib-es/hw-signMessage.d.ts +12 -0
- package/lib-es/hw-signMessage.d.ts.map +1 -0
- package/lib-es/hw-signMessage.js +28 -0
- package/lib-es/hw-signMessage.js.map +1 -0
- package/lib-es/index.d.ts +2 -0
- package/lib-es/index.d.ts.map +1 -0
- package/lib-es/index.js +2 -0
- package/lib-es/index.js.map +1 -0
- package/lib-es/network/addresses.d.ts +16 -0
- package/lib-es/network/addresses.d.ts.map +1 -0
- package/lib-es/network/addresses.js +64 -0
- package/lib-es/network/addresses.js.map +1 -0
- package/lib-es/network/index.d.ts +2 -0
- package/lib-es/network/index.d.ts.map +1 -0
- package/lib-es/network/index.js +2 -0
- package/lib-es/network/index.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 +28 -0
- package/lib-es/signer/getAddress.js.map +1 -0
- package/lib-es/signer/index.d.ts +3 -0
- package/lib-es/signer/index.d.ts.map +1 -0
- package/lib-es/signer/index.js +3 -0
- package/lib-es/signer/index.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 +146 -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 +395 -0
- package/lib-es/test/bridgeDatasetTest.js.map +1 -0
- package/lib-es/test/cli.d.ts +19 -0
- package/lib-es/test/cli.d.ts.map +1 -0
- package/lib-es/test/cli.js +53 -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/test/speculos-deviceActions.d.ts +5 -0
- package/lib-es/test/speculos-deviceActions.d.ts.map +1 -0
- package/lib-es/test/speculos-deviceActions.js +152 -0
- package/lib-es/test/speculos-deviceActions.js.map +1 -0
- package/lib-es/types/bridge.d.ts +35 -0
- package/lib-es/types/bridge.d.ts.map +1 -0
- package/lib-es/types/bridge.js +2 -0
- package/lib-es/types/bridge.js.map +1 -0
- package/lib-es/types/common.d.ts +96 -0
- package/lib-es/types/common.d.ts.map +1 -0
- package/lib-es/types/common.js +7 -0
- package/lib-es/types/common.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 +4 -0
- package/lib-es/types/index.js.map +1 -0
- package/lib-es/types/signer.d.ts +19 -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 +135 -0
- package/src/api/api.ts +125 -0
- package/src/api/index.ts +1 -0
- package/src/bridge/broadcast.ts +20 -0
- package/src/bridge/buildOptimisticOperation.ts +58 -0
- package/src/bridge/createTransaction.ts +20 -0
- package/src/bridge/deviceTransactionConfig.ts +119 -0
- package/src/bridge/estimateMaxSpendable.ts +120 -0
- package/src/bridge/getTransactionStatus.ts +80 -0
- package/src/bridge/index.ts +63 -0
- package/src/bridge/prepareTransaction.ts +82 -0
- package/src/bridge/serializer.ts +63 -0
- package/src/bridge/signOperation.ts +97 -0
- package/src/bridge/transaction.ts +69 -0
- package/src/bridge/utils.ts +73 -0
- package/src/bridge/utils.unit.test.ts +27 -0
- package/src/common-logic/index.ts +10 -0
- package/src/common-logic/utils.ts +232 -0
- package/src/erc20/ERC20.json +12 -0
- package/src/erc20/tokenAccounts.ts +183 -0
- package/src/errors.ts +13 -0
- package/src/hw-signMessage.ts +27 -0
- package/src/index.ts +1 -0
- package/src/network/addresses.ts +93 -0
- package/src/network/index.ts +1 -0
- package/src/signer/getAddress.ts +28 -0
- package/src/signer/index.ts +3 -0
- package/src/test/bot-specs.ts +163 -0
- package/src/test/bridgeDatasetTest.ts +403 -0
- package/src/test/cli.ts +80 -0
- package/src/test/index.ts +6 -0
- package/src/test/speculos-deviceActions.ts +166 -0
- package/src/types/bridge.ts +42 -0
- package/src/types/common.ts +105 -0
- package/src/types/index.ts +3 -0
- package/src/types/signer.ts +19 -0
- package/tsconfig.json +14 -0
|
@@ -0,0 +1,159 @@
|
|
|
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.generateDeviceActionFlow = void 0;
|
|
7
|
+
const specs_1 = require("@ledgerhq/coin-framework/bot/specs");
|
|
8
|
+
const utils_1 = require("../bridge/utils");
|
|
9
|
+
const network_1 = require("../network");
|
|
10
|
+
const address_1 = require("iso-filecoin/address");
|
|
11
|
+
const common_logic_1 = require("../common-logic");
|
|
12
|
+
const invariant_1 = __importDefault(require("invariant"));
|
|
13
|
+
const generateDeviceActionFlow = (scenario) => {
|
|
14
|
+
const data = { steps: [] };
|
|
15
|
+
data.steps = data.steps.concat([
|
|
16
|
+
{
|
|
17
|
+
title: "Please",
|
|
18
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
19
|
+
},
|
|
20
|
+
]);
|
|
21
|
+
if (scenario == utils_1.BotScenario.F4_RECIPIENT) {
|
|
22
|
+
data.steps.push({
|
|
23
|
+
title: "To",
|
|
24
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
25
|
+
expectedValue: ({ transaction }) => {
|
|
26
|
+
const addr = (0, address_1.fromString)(transaction.recipient);
|
|
27
|
+
if ((0, network_1.isFilEthAddress)(addr)) {
|
|
28
|
+
return (0, address_1.toEthAddress)(addr) + transaction.recipient;
|
|
29
|
+
}
|
|
30
|
+
return "unexpected flow... address should be eth type";
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
else if (scenario == utils_1.BotScenario.ETH_RECIPIENT) {
|
|
35
|
+
data.steps.push({
|
|
36
|
+
title: "To",
|
|
37
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
38
|
+
expectedValue: ({ transaction }) => {
|
|
39
|
+
const addr = (0, address_1.fromEthAddress)(transaction.recipient, "mainnet");
|
|
40
|
+
return transaction.recipient + addr.toString();
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
else if (scenario == utils_1.BotScenario.TOKEN_TRANSFER) {
|
|
45
|
+
data.steps.push({
|
|
46
|
+
title: "To",
|
|
47
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
48
|
+
expectedValue: ({ transaction }) => {
|
|
49
|
+
return (0, utils_1.expectedToFieldForTokenTransfer)(transaction.recipient);
|
|
50
|
+
},
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
else {
|
|
54
|
+
data.steps.push({
|
|
55
|
+
title: "To",
|
|
56
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
57
|
+
expectedValue: ({ transaction }) => transaction.recipient,
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
data.steps = data.steps.concat([
|
|
61
|
+
{
|
|
62
|
+
title: "From",
|
|
63
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
64
|
+
expectedValue: ({ account }) => account.freshAddress,
|
|
65
|
+
},
|
|
66
|
+
{
|
|
67
|
+
title: "Nonce",
|
|
68
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
69
|
+
expectedValue: ({ transaction }) => transaction.nonce.toString(),
|
|
70
|
+
},
|
|
71
|
+
]);
|
|
72
|
+
if (scenario == utils_1.BotScenario.TOKEN_TRANSFER) {
|
|
73
|
+
data.steps.push({
|
|
74
|
+
title: "Value",
|
|
75
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
76
|
+
expectedValue: ({ account, transaction }) => {
|
|
77
|
+
const subAccount = (0, common_logic_1.getSubAccount)(account, transaction);
|
|
78
|
+
(0, invariant_1.default)(subAccount, "subAccount is required for token transfer");
|
|
79
|
+
return (0, specs_1.formatDeviceAmount)(subAccount.token, transaction.amount, {
|
|
80
|
+
hideCode: false,
|
|
81
|
+
showAllDigits: true,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
84
|
+
});
|
|
85
|
+
}
|
|
86
|
+
else {
|
|
87
|
+
data.steps.push({
|
|
88
|
+
title: "Value",
|
|
89
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
90
|
+
expectedValue: ({ account, status }) => (0, specs_1.formatDeviceAmount)(account.currency, status.amount, {
|
|
91
|
+
hideCode: true,
|
|
92
|
+
showAllDigits: true,
|
|
93
|
+
}),
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
if (scenario === utils_1.BotScenario.TOKEN_TRANSFER) {
|
|
97
|
+
data.steps.push({
|
|
98
|
+
title: "Gas Limit",
|
|
99
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
100
|
+
expectedValue: ({ transaction, account }) => (0, specs_1.formatDeviceAmount)(account.currency, transaction.gasLimit, {
|
|
101
|
+
hideCode: false,
|
|
102
|
+
showAllDigits: true,
|
|
103
|
+
}),
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
else {
|
|
107
|
+
data.steps = data.steps.concat([
|
|
108
|
+
{
|
|
109
|
+
title: "Gas Limit",
|
|
110
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
111
|
+
expectedValue: ({ transaction }) => transaction.gasLimit.toFixed(),
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
title: "Gas Premium",
|
|
115
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
116
|
+
expectedValue: ({ account, transaction }) => (0, specs_1.formatDeviceAmount)(account.currency, transaction.gasPremium, {
|
|
117
|
+
hideCode: true,
|
|
118
|
+
showAllDigits: true,
|
|
119
|
+
}),
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
title: "Gas Fee Cap",
|
|
123
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
124
|
+
expectedValue: ({ account, transaction }) => (0, specs_1.formatDeviceAmount)(account.currency, transaction.gasFeeCap, {
|
|
125
|
+
hideCode: true,
|
|
126
|
+
showAllDigits: true,
|
|
127
|
+
}),
|
|
128
|
+
},
|
|
129
|
+
]);
|
|
130
|
+
}
|
|
131
|
+
if (scenario == utils_1.BotScenario.ETH_RECIPIENT || scenario == utils_1.BotScenario.F4_RECIPIENT) {
|
|
132
|
+
data.steps.push({
|
|
133
|
+
title: "Method",
|
|
134
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
135
|
+
expectedValue: () => utils_1.Methods.InvokeEVM.toString(),
|
|
136
|
+
});
|
|
137
|
+
}
|
|
138
|
+
else if (scenario == utils_1.BotScenario.TOKEN_TRANSFER) {
|
|
139
|
+
data.steps.push({
|
|
140
|
+
title: "Method",
|
|
141
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
142
|
+
expectedValue: () => (0, utils_1.methodToString)(utils_1.Methods.ERC20Transfer),
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
else {
|
|
146
|
+
data.steps.push({
|
|
147
|
+
title: "Method",
|
|
148
|
+
button: specs_1.SpeculosButton.RIGHT,
|
|
149
|
+
expectedValue: () => "Transfer",
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
data.steps.push({
|
|
153
|
+
title: "APPROVE",
|
|
154
|
+
button: specs_1.SpeculosButton.BOTH,
|
|
155
|
+
});
|
|
156
|
+
return (0, specs_1.deviceActionFlow)(data);
|
|
157
|
+
};
|
|
158
|
+
exports.generateDeviceActionFlow = generateDeviceActionFlow;
|
|
159
|
+
//# sourceMappingURL=speculos-deviceActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"speculos-deviceActions.js","sourceRoot":"","sources":["../../src/test/speculos-deviceActions.ts"],"names":[],"mappings":";;;;;;AAEA,8DAI4C;AAC5C,2CAKyB;AACzB,wCAA6C;AAC7C,kDAAgF;AAChF,kDAAgD;AAChD,0DAAkC;AAE3B,MAAM,wBAAwB,GAAG,CAAC,QAAqB,EAAkC,EAAE;IAChG,MAAM,IAAI,GAAwD,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC;IAChF,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,CAAC;QAC7B;YACE,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,sBAAc,CAAC,KAAK;SAC7B;KACF,CAAC,CAAC;IACH,IAAI,QAAQ,IAAI,mBAAW,CAAC,YAAY,EAAE,CAAC;QACzC,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACd,KAAK,EAAE,IAAI;YACX,MAAM,EAAE,sBAAc,CAAC,KAAK;YAC5B,aAAa,EAAE,CAAC,EAAE,WAAW,EAAE,EAAE,EAAE;gBACjC,MAAM,IAAI,GAAG,IAAA,oBAAU,EAAC,WAAW,CAAC,SAAS,CAAC,CAAC;gBAC/C,IAAI,IAAA,yBAAe,EAAC,IAAI,CAAC,EAAE,CAAC;oBAC1B,OAAO,IAAA,sBAAY,EAAC,IAAI,CAAC,GAAG,WAAW,CAAC,SAAS,CAAC;gBACpD,CAAC;gBACD,OAAO,+CAA+C,CAAC;YACzD,CAAC;SACF,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,QAAQ,IAAI,mBAAW,CAAC,aAAa,EAAE,C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AQ,EAAE;SAClD,CAAC,CAAC;IACL,CAAC;SAAM,IAAI,QAAQ,IAAI,mBAAW,CAAC,cAAc,EAAE,CAAC;QAClD,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACd,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,sBAAc,CAAC,KAAK;YAC5B,aAAa,EAAE,GAAG,EAAE,CAAC,IAAA,sBAAc,EAAC,eAAO,CAAC,aAAa,CAAC;SAC3D,CAAC,CAAC;IACL,CAAC;SAAM,CAAC;QACN,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;YACd,KAAK,EAAE,QAAQ;YACf,MAAM,EAAE,sBAAc,CAAC,KAAK;YAC5B,aAAa,EAAE,GAAG,EAAE,CAAC,UAAU;SAChC,CAAC,CAAC;IACL,CAAC;IAED,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC;QACd,KAAK,EAAE,SAAS;QAChB,MAAM,EAAE,sBAAc,CAAC,IAAI;KAC5B,CAAC,CAAC;IACH,OAAO,IAAA,wBAAgB,EAAC,IAAI,CAAC,CAAC;AAChC,CAAC,CAAC;AAnJW,QAAA,wBAAwB,4BAmJnC"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
import { TransactionCommon, TransactionCommonRaw, TransactionStatusCommon, TransactionStatusCommonRaw } from "@ledgerhq/types-live";
|
|
3
|
+
import { BigNumber } from "bignumber.js";
|
|
4
|
+
type FamilyType = "filecoin";
|
|
5
|
+
export type NetworkInfo = {
|
|
6
|
+
family: FamilyType;
|
|
7
|
+
};
|
|
8
|
+
export type NetworkInfoRaw = {
|
|
9
|
+
family: FamilyType;
|
|
10
|
+
};
|
|
11
|
+
export type Transaction = TransactionCommon & {
|
|
12
|
+
family: FamilyType;
|
|
13
|
+
nonce: number;
|
|
14
|
+
data?: Buffer;
|
|
15
|
+
method: number;
|
|
16
|
+
version: number;
|
|
17
|
+
params?: string | undefined;
|
|
18
|
+
gasLimit: BigNumber;
|
|
19
|
+
gasFeeCap: BigNumber;
|
|
20
|
+
gasPremium: BigNumber;
|
|
21
|
+
};
|
|
22
|
+
export type TransactionRaw = TransactionCommonRaw & {
|
|
23
|
+
family: FamilyType;
|
|
24
|
+
version: number;
|
|
25
|
+
nonce: number;
|
|
26
|
+
data?: string;
|
|
27
|
+
method: number;
|
|
28
|
+
gasLimit: number;
|
|
29
|
+
gasFeeCap: string;
|
|
30
|
+
gasPremium: string;
|
|
31
|
+
};
|
|
32
|
+
export type TransactionStatus = TransactionStatusCommon;
|
|
33
|
+
export type TransactionStatusRaw = TransactionStatusCommonRaw;
|
|
34
|
+
export {};
|
|
35
|
+
//# sourceMappingURL=bridge.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.d.ts","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":";AAAA,OAAO,EACL,iBAAiB,EACjB,oBAAoB,EACpB,uBAAuB,EACvB,0BAA0B,EAC3B,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAEzC,KAAK,UAAU,GAAG,UAAU,CAAC;AAE7B,MAAM,MAAM,WAAW,GAAG;IACxB,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG;IAC3B,MAAM,EAAE,UAAU,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,WAAW,GAAG,iBAAiB,GAAG;IAC5C,MAAM,EAAE,UAAU,CAAC;IACnB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,QAAQ,EAAE,SAAS,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;IACrB,UAAU,EAAE,SAAS,CAAC;CACvB,CAAC;AACF,MAAM,MAAM,cAAc,GAAG,oBAAoB,GAAG;IAClD,MAAM,EAAE,UAAU,CAAC;IACnB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,iBAAiB,GAAG,uBAAuB,CAAC;AAExD,MAAM,MAAM,oBAAoB,GAAG,0BAA0B,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridge.js","sourceRoot":"","sources":["../../src/types/bridge.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
export declare const BroadcastBlockIncl = 1;
|
|
2
|
+
export declare enum TxStatus {
|
|
3
|
+
Ok = "Ok",
|
|
4
|
+
Fail = "Fail"
|
|
5
|
+
}
|
|
6
|
+
export interface EstimatedFeesRequest {
|
|
7
|
+
to?: string | undefined;
|
|
8
|
+
from: string;
|
|
9
|
+
methodNum?: number;
|
|
10
|
+
blockIncl?: number;
|
|
11
|
+
params?: string;
|
|
12
|
+
value?: string;
|
|
13
|
+
}
|
|
14
|
+
export interface EstimatedFeesResponse {
|
|
15
|
+
gas_limit: number;
|
|
16
|
+
gas_fee_cap: string;
|
|
17
|
+
gas_premium: string;
|
|
18
|
+
nonce: number;
|
|
19
|
+
}
|
|
20
|
+
export interface TransactionsResponse {
|
|
21
|
+
txs: TransactionResponse[];
|
|
22
|
+
}
|
|
23
|
+
export interface TransactionResponse {
|
|
24
|
+
amount: number;
|
|
25
|
+
to: string;
|
|
26
|
+
from: string;
|
|
27
|
+
status: string;
|
|
28
|
+
type: string;
|
|
29
|
+
hash: string;
|
|
30
|
+
timestamp: number;
|
|
31
|
+
height: number;
|
|
32
|
+
fee?: number;
|
|
33
|
+
}
|
|
34
|
+
export interface BalanceResponse {
|
|
35
|
+
locked_balance: string;
|
|
36
|
+
spendable_balance: string;
|
|
37
|
+
total_balance: string;
|
|
38
|
+
}
|
|
39
|
+
export interface NetworkStatusResponse {
|
|
40
|
+
current_block_identifier: BlockIdentifier;
|
|
41
|
+
genesis_block_identifier: BlockIdentifier;
|
|
42
|
+
oldest_block_identifier?: BlockIdentifier;
|
|
43
|
+
current_block_timestamp: number;
|
|
44
|
+
}
|
|
45
|
+
export interface BroadcastTransactionRequest {
|
|
46
|
+
message: {
|
|
47
|
+
version: number;
|
|
48
|
+
to: string;
|
|
49
|
+
from: string;
|
|
50
|
+
nonce: number;
|
|
51
|
+
value: string;
|
|
52
|
+
gaslimit: number;
|
|
53
|
+
gasfeecap: string;
|
|
54
|
+
gaspremium: string;
|
|
55
|
+
method: number;
|
|
56
|
+
params: string;
|
|
57
|
+
};
|
|
58
|
+
signature: {
|
|
59
|
+
type: number;
|
|
60
|
+
data: string;
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
export interface BroadcastTransactionResponse {
|
|
64
|
+
hash: string;
|
|
65
|
+
}
|
|
66
|
+
interface BlockIdentifier {
|
|
67
|
+
index: number;
|
|
68
|
+
hash: string;
|
|
69
|
+
}
|
|
70
|
+
export interface ConvertFilToEthResponse {
|
|
71
|
+
address: string;
|
|
72
|
+
}
|
|
73
|
+
export interface FetchERC20TransactionsResponse {
|
|
74
|
+
txs: ERC20Transfer[];
|
|
75
|
+
}
|
|
76
|
+
export interface ERC20Transfer {
|
|
77
|
+
id: string;
|
|
78
|
+
height: number;
|
|
79
|
+
type: string;
|
|
80
|
+
status: string;
|
|
81
|
+
to: string;
|
|
82
|
+
from: string;
|
|
83
|
+
amount: string;
|
|
84
|
+
contract_address: string;
|
|
85
|
+
timestamp: number;
|
|
86
|
+
tx_hash: string;
|
|
87
|
+
tx_cid?: string;
|
|
88
|
+
}
|
|
89
|
+
export interface ERC20BalanceResponse {
|
|
90
|
+
data: {
|
|
91
|
+
balance: string;
|
|
92
|
+
height: number;
|
|
93
|
+
}[];
|
|
94
|
+
}
|
|
95
|
+
export {};
|
|
96
|
+
//# sourceMappingURL=common.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,kBAAkB,IAAI,CAAC;AAEpC,oBAAY,QAAQ;IAClB,EAAE,OAAO;IACT,IAAI,SAAS;CACd;AAED,MAAM,WAAW,oBAAoB;IACnC,EAAE,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IACxB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB;AAED,MAAM,WAAW,qBAAqB;IACpC,SAAS,EAAE,MAAM,CAAC;IAClB,WAAW,EAAE,MAAM,CAAC;IACpB,WAAW,EAAE,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;CACf;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,EAAE,mBAAmB,EAAE,CAAC;CAC5B;AAED,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,EAAE,MAAM,CAAC;IACb,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,MAAM,CAAC;IACf,GAAG,CAAC,EAAE,MAAM,CAAC;CACd;AAED,MAAM,WAAW,eAAe;IAC9B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,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,MAAM,WAAW,oBAAoB;IACnC,IAAI,EAAE;QAAE,OAAO,EAAE,MAAM,CAAC;QAAC,MAAM,EAAE,MAAM,CAAA;KAAE,EAAE,CAAC;CAC7C"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TxStatus = exports.BroadcastBlockIncl = void 0;
|
|
4
|
+
exports.BroadcastBlockIncl = 1;
|
|
5
|
+
var TxStatus;
|
|
6
|
+
(function (TxStatus) {
|
|
7
|
+
TxStatus["Ok"] = "Ok";
|
|
8
|
+
TxStatus["Fail"] = "Fail";
|
|
9
|
+
})(TxStatus || (exports.TxStatus = TxStatus = {}));
|
|
10
|
+
//# sourceMappingURL=common.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"common.js","sourceRoot":"","sources":["../../src/types/common.ts"],"names":[],"mappings":";;;AAAa,QAAA,kBAAkB,GAAG,CAAC,CAAC;AAEpC,IAAY,QAGX;AAHD,WAAY,QAAQ;IAClB,qBAAS,CAAA;IACT,yBAAa,CAAA;AACf,CAAC,EAHW,QAAQ,wBAAR,QAAQ,QAGnB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC"}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./bridge"), exports);
|
|
18
|
+
__exportStar(require("./signer"), exports);
|
|
19
|
+
__exportStar(require("./common"), exports);
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,2CAAyB;AACzB,2CAAyB"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type FilecoinSignature = {
|
|
2
|
+
return_code: number;
|
|
3
|
+
error_message: string;
|
|
4
|
+
signature_der: Uint8Array;
|
|
5
|
+
signature_compact: Uint8Array;
|
|
6
|
+
};
|
|
7
|
+
export type FilecoinGetAddrResponse = {
|
|
8
|
+
addrByte: Uint8Array;
|
|
9
|
+
addrString: string;
|
|
10
|
+
compressed_pk: Uint8Array;
|
|
11
|
+
return_code: number;
|
|
12
|
+
error_message: string;
|
|
13
|
+
};
|
|
14
|
+
export interface FilecoinSigner {
|
|
15
|
+
showAddressAndPubKey(path: string): Promise<FilecoinGetAddrResponse>;
|
|
16
|
+
getAddressAndPubKey(path: string): Promise<FilecoinGetAddrResponse>;
|
|
17
|
+
sign(path: string, message: Uint8Array): Promise<FilecoinSignature>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=signer.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,iBAAiB,GAAG;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,aAAa,EAAE,UAAU,CAAC;IAC1B,iBAAiB,EAAE,UAAU,CAAC;CAC/B,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAAG;IACpC,QAAQ,EAAE,UAAU,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,aAAa,EAAE,UAAU,CAAC;IAC1B,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;CACvB,CAAC;AACF,MAAM,WAAW,cAAc;IAC7B,oBAAoB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACrE,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAC;IACpE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,UAAU,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACrE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signer.js","sourceRoot":"","sources":["../../src/types/signer.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BalanceResponse, BroadcastTransactionRequest, BroadcastTransactionResponse, EstimatedFeesRequest, EstimatedFeesResponse, NetworkStatusResponse, TransactionResponse, ERC20Transfer } from "../types";
|
|
2
|
+
export declare const fetchBalances: (addr: string) => Promise<BalanceResponse>;
|
|
3
|
+
export declare const fetchEstimatedFees: import("@ledgerhq/live-network/cache").CacheRes<[request: EstimatedFeesRequest], EstimatedFeesResponse>;
|
|
4
|
+
export declare const fetchBlockHeight: () => Promise<NetworkStatusResponse>;
|
|
5
|
+
export declare const fetchTxs: (addr: string) => Promise<TransactionResponse[]>;
|
|
6
|
+
export declare const broadcastTx: (message: BroadcastTransactionRequest) => Promise<BroadcastTransactionResponse>;
|
|
7
|
+
export declare const fetchERC20TokenBalance: (ethAddr: string, contractAddr: string) => Promise<string>;
|
|
8
|
+
export declare const fetchERC20Transactions: (ethAddr: string) => Promise<ERC20Transfer[]>;
|
|
9
|
+
//# sourceMappingURL=api.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":"AAOA,OAAO,EACL,eAAe,EACf,2BAA2B,EAC3B,4BAA4B,EAC5B,oBAAoB,EACpB,qBAAqB,EACrB,qBAAqB,EACrB,mBAAmB,EAGnB,aAAa,EAEd,MAAM,UAAU,CAAC;AA+ClB,eAAO,MAAM,aAAa,SAAgB,MAAM,KAAG,QAAQ,eAAe,CAGzE,CAAC;AAEF,eAAO,MAAM,kBAAkB,yGAc9B,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAa,QAAQ,qBAAqB,CAGtE,CAAC;AAEF,eAAO,MAAM,QAAQ,SAAgB,MAAM,KAAG,QAAQ,mBAAmB,EAAE,CAG1E,CAAC;AAEF,eAAO,MAAM,WAAW,YACb,2BAA2B,KACnC,QAAQ,4BAA4B,CAGtC,CAAC;AAEF,eAAO,MAAM,sBAAsB,YACxB,MAAM,gBACD,MAAM,KACnB,QAAQ,MAAM,CAUhB,CAAC;AAEF,eAAO,MAAM,sBAAsB,YAAmB,MAAM,KAAG,QAAQ,aAAa,EAAE,CAKrF,CAAC"}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { log } from "@ledgerhq/logs";
|
|
11
|
+
import network from "@ledgerhq/live-network/network";
|
|
12
|
+
import { makeLRUCache } from "@ledgerhq/live-network/cache";
|
|
13
|
+
import { getEnv } from "@ledgerhq/live-env";
|
|
14
|
+
import { FilecoinFeeEstimationFailed } from "../errors";
|
|
15
|
+
const getFilecoinURL = (path) => {
|
|
16
|
+
const baseUrl = getEnv("API_FILECOIN_ENDPOINT");
|
|
17
|
+
if (!baseUrl)
|
|
18
|
+
throw new Error("API base URL not available");
|
|
19
|
+
return `${baseUrl}${path ? path : ""}`;
|
|
20
|
+
};
|
|
21
|
+
const fetch = (path) => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
const url = getFilecoinURL(path);
|
|
23
|
+
// We force data to this way as network func is not using the correct param type. Changing that func will generate errors in other implementations
|
|
24
|
+
const opts = {
|
|
25
|
+
method: "GET",
|
|
26
|
+
url,
|
|
27
|
+
};
|
|
28
|
+
const rawResponse = yield network(opts);
|
|
29
|
+
// We force data to this way as network func is not using the correct param type. Changing that func will generate errors in other implementations
|
|
30
|
+
const { data } = rawResponse;
|
|
31
|
+
log("http", url);
|
|
32
|
+
return data;
|
|
33
|
+
});
|
|
34
|
+
const send = (path, data) => __awaiter(void 0, void 0, void 0, function* () {
|
|
35
|
+
const url = getFilecoinURL(path);
|
|
36
|
+
const opts = {
|
|
37
|
+
method: "POST",
|
|
38
|
+
url,
|
|
39
|
+
data: JSON.stringify(data),
|
|
40
|
+
headers: { "Content-Type": "application/json" },
|
|
41
|
+
};
|
|
42
|
+
const rawResponse = yield network(opts);
|
|
43
|
+
// We force data to this way as network func is not using generics. Changing that func will generate errors in other implementations
|
|
44
|
+
const { data: responseData } = rawResponse;
|
|
45
|
+
log("http", url);
|
|
46
|
+
return responseData;
|
|
47
|
+
});
|
|
48
|
+
export const fetchBalances = (addr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
+
const data = yield fetch(`/addresses/${addr}/balance`);
|
|
50
|
+
return data; // TODO Validate if the response fits this interface
|
|
51
|
+
});
|
|
52
|
+
export const fetchEstimatedFees = makeLRUCache((request) => __awaiter(void 0, void 0, void 0, function* () {
|
|
53
|
+
try {
|
|
54
|
+
const data = yield send(`/fees/estimate`, request);
|
|
55
|
+
return data; // TODO Validate if the response fits this interface
|
|
56
|
+
}
|
|
57
|
+
catch (e) {
|
|
58
|
+
log("error", "filecoin fetchEstimatedFees", e);
|
|
59
|
+
throw new FilecoinFeeEstimationFailed();
|
|
60
|
+
}
|
|
61
|
+
}), request => `${request.from}-${request.to}`, {
|
|
62
|
+
ttl: 5 * 1000, // 5 seconds
|
|
63
|
+
});
|
|
64
|
+
export const fetchBlockHeight = () => __awaiter(void 0, void 0, void 0, function* () {
|
|
65
|
+
const data = yield fetch("/network/status");
|
|
66
|
+
return data; // TODO Validate if the response fits this interface
|
|
67
|
+
});
|
|
68
|
+
export const fetchTxs = (addr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
69
|
+
const response = yield fetch(`/addresses/${addr}/transactions`);
|
|
70
|
+
return response.txs; // TODO Validate if the response fits this interface
|
|
71
|
+
});
|
|
72
|
+
export const broadcastTx = (message) => __awaiter(void 0, void 0, void 0, function* () {
|
|
73
|
+
const response = yield send(`/transaction/broadcast`, message);
|
|
74
|
+
return response; // TODO Validate if the response fits this interface
|
|
75
|
+
});
|
|
76
|
+
export const fetchERC20TokenBalance = (ethAddr, contractAddr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
+
const res = yield fetch(`/contract/${contractAddr}/address/${ethAddr}/balance/erc20`);
|
|
78
|
+
if (res.data.length) {
|
|
79
|
+
return res.data[0].balance;
|
|
80
|
+
}
|
|
81
|
+
return "0";
|
|
82
|
+
});
|
|
83
|
+
export const fetchERC20Transactions = (ethAddr) => __awaiter(void 0, void 0, void 0, function* () {
|
|
84
|
+
const res = yield fetch(`/addresses/${ethAddr}/transactions/erc20`);
|
|
85
|
+
return res.txs.sort((a, b) => b.timestamp - a.timestamp);
|
|
86
|
+
});
|
|
87
|
+
//# sourceMappingURL=api.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.js","sourceRoot":"","sources":["../../src/api/api.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAC;AAGrC,OAAO,OAAO,MAAM,gCAAgC,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,8BAA8B,CAAC;AAC5D,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAe5C,OAAO,EAAE,2BAA2B,EAAE,MAAM,WAAW,CAAC;AAExD,MAAM,cAAc,GAAG,CAAC,IAAa,EAAU,EAAE;IAC/C,MAAM,OAAO,GAAG,MAAM,CAAC,uBAAuB,CAAC,CAAC;IAChD,IAAI,CAAC,OAAO;QAAE,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;IAE5D,OAAO,GAAG,OAAO,GAAG,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC;AACzC,CAAC,CAAC;AAEF,MAAM,KAAK,GAAG,CAAU,IAAY,EAAE,EAAE;IACtC,MAAM,GAAG,GAAG,cAAc,CAAC,IAAI,CAAC,CAAC;IAEjC,kJAAkJ;IAClJ,MAAM,IAAI,GAAuB;QAC/B,MAAM,EAAE,KAAK;QACb,GAAG;KACJ,CAAC;IAEF,MAAM,WAAW,GAAG,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC;IAExC,kJAAkJ;IAClJ,MAAM,EAAE,IAAI,EAAE,GAAG,WAA+B,CAAC;IAEjD,GAAG,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACjB,OAAO,IAAI,CAAC;AACd,CAAC,CA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AG,CAAC,CAAC,SAAS,CAAC,CAAC;AAC3D,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/api/index.ts"],"names":[],"mappings":"AAAA,cAAc,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.d.ts","sourceRoot":"","sources":["../../src/bridge/broadcast.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAIrD,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAEvC,eAAO,MAAM,SAAS,EAAE,aAAa,CAAC,WAAW,CAAC,CAAC,WAAW,CAa7D,CAAC"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { patchOperationWithHash } from "@ledgerhq/coin-framework/operation";
|
|
11
|
+
import { getTxToBroadcast } from "../common-logic";
|
|
12
|
+
import { broadcastTx } from "../api";
|
|
13
|
+
export const broadcast = (_a) => __awaiter(void 0, [_a], void 0, function* ({ signedOperation }) {
|
|
14
|
+
// log("debug", "[broadcast] start fn");
|
|
15
|
+
const { operation, signature, rawData } = signedOperation;
|
|
16
|
+
const tx = getTxToBroadcast(operation, signature, rawData);
|
|
17
|
+
const resp = yield broadcastTx(tx);
|
|
18
|
+
const { hash } = resp;
|
|
19
|
+
const result = patchOperationWithHash(signedOperation.operation, hash);
|
|
20
|
+
// log("debug", "[broadcast] finish fn");
|
|
21
|
+
return result;
|
|
22
|
+
});
|
|
23
|
+
//# sourceMappingURL=broadcast.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"broadcast.js","sourceRoot":"","sources":["../../src/bridge/broadcast.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,sBAAsB,EAAE,MAAM,oCAAoC,CAAC;AAC5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,iBAAiB,CAAC;AACnD,OAAO,EAAE,WAAW,EAAE,MAAM,QAAQ,CAAC;AAGrC,MAAM,CAAC,MAAM,SAAS,GAA4C,KAA4B,EAAE,4CAAvB,EAAE,eAAe,EAAE;IAC1F,wCAAwC;IACxC,MAAM,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,GAAG,eAAe,CAAC;IAC1D,MAAM,EAAE,GAAG,gBAAgB,CAAC,SAAS,EAAE,SAAS,EAAE,OAAQ,CAAC,CAAC;IAE5D,MAAM,IAAI,GAAG,MAAM,WAAW,CAAC,EAAE,CAAC,CAAC;IACnC,MAAM,EAAE,IAAI,EAAE,GAAG,IAAI,CAAC;IAEtB,MAAM,MAAM,GAAG,sBAAsB,CAAC,eAAe,CAAC,SAAS,EAAE,IAAI,CAAC,CAAC;IAEvE,yCAAyC;IAEzC,OAAO,MAAM,CAAC;AAChB,CAAC,CAAA,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { Account, Operation, OperationType } from "@ledgerhq/types-live";
|
|
2
|
+
import { Transaction } from "../types";
|
|
3
|
+
import { toCBORResponse } from "../bridge/serializer";
|
|
4
|
+
export declare const buildOptimisticOperation: (account: Account, transaction: Transaction, serializationRes: toCBORResponse, operationType?: OperationType) => Promise<Operation>;
|
|
5
|
+
//# sourceMappingURL=buildOptimisticOperation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildOptimisticOperation.d.ts","sourceRoot":"","sources":["../../src/bridge/buildOptimisticOperation.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAEzE,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAKtD,eAAO,MAAM,wBAAwB,YAC1B,OAAO,eACH,WAAW,oBACN,cAAc,kBACjB,aAAa,KAC3B,QAAQ,SAAS,CA4CnB,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import { encodeOperationId } from "@ledgerhq/coin-framework/operation";
|
|
11
|
+
import { calculateEstimatedFees } from "../bridge/utils";
|
|
12
|
+
import { convertAddressEthToFil } from "../network";
|
|
13
|
+
import { getSubAccount } from "../common-logic/utils";
|
|
14
|
+
export const buildOptimisticOperation = (account_1, transaction_1, serializationRes_1, ...args_1) => __awaiter(void 0, [account_1, transaction_1, serializationRes_1, ...args_1], void 0, function* (account, transaction, serializationRes, operationType = "OUT") {
|
|
15
|
+
const type = operationType;
|
|
16
|
+
const subAccount = getSubAccount(account, transaction);
|
|
17
|
+
// resolved at broadcast time
|
|
18
|
+
const txHash = "";
|
|
19
|
+
const { gasFeeCap, gasLimit } = transaction;
|
|
20
|
+
const { parsedSender, recipientToBroadcast, amountToBroadcast: finalAmount } = serializationRes;
|
|
21
|
+
const fee = calculateEstimatedFees(gasFeeCap, gasLimit);
|
|
22
|
+
let operation;
|
|
23
|
+
if (subAccount) {
|
|
24
|
+
const recipientFilAddr = convertAddressEthToFil(transaction.recipient);
|
|
25
|
+
operation = {
|
|
26
|
+
id: encodeOperationId(subAccount.id, txHash, "OUT"),
|
|
27
|
+
hash: txHash,
|
|
28
|
+
type,
|
|
29
|
+
value: finalAmount,
|
|
30
|
+
fee,
|
|
31
|
+
blockHeight: null,
|
|
32
|
+
blockHash: null,
|
|
33
|
+
accountId: subAccount.id,
|
|
34
|
+
senders: [parsedSender],
|
|
35
|
+
recipients: [recipientFilAddr],
|
|
36
|
+
date: new Date(),
|
|
37
|
+
extra: {},
|
|
38
|
+
};
|
|
39
|
+
}
|
|
40
|
+
else {
|
|
41
|
+
operation = {
|
|
42
|
+
id: encodeOperationId(account.id, txHash, "OUT"),
|
|
43
|
+
hash: txHash,
|
|
44
|
+
type,
|
|
45
|
+
senders: [parsedSender],
|
|
46
|
+
recipients: [recipientToBroadcast],
|
|
47
|
+
accountId: account.id,
|
|
48
|
+
value: finalAmount.plus(fee),
|
|
49
|
+
fee,
|
|
50
|
+
blockHash: null,
|
|
51
|
+
blockHeight: null,
|
|
52
|
+
date: new Date(),
|
|
53
|
+
extra: {},
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
return operation;
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=buildOptimisticOperation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buildOptimisticOperation.js","sourceRoot":"","sources":["../../src/bridge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