@airgap/ethereum 0.13.7-beta.11

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.
Files changed (67) hide show
  1. package/LICENSE.md +7 -0
  2. package/airgap-coinlib-ethereum.min.js +106148 -0
  3. package/index.d.ts +12 -0
  4. package/index.js +24 -0
  5. package/index.js.map +1 -0
  6. package/package.json +67 -0
  7. package/protocol/BaseEthereumProtocol.d.ts +98 -0
  8. package/protocol/BaseEthereumProtocol.js +933 -0
  9. package/protocol/BaseEthereumProtocol.js.map +1 -0
  10. package/protocol/EthereumAddress.d.ts +8 -0
  11. package/protocol/EthereumAddress.js +38 -0
  12. package/protocol/EthereumAddress.js.map +1 -0
  13. package/protocol/EthereumChainIDs.d.ts +1 -0
  14. package/protocol/EthereumChainIDs.js +340 -0
  15. package/protocol/EthereumChainIDs.js.map +1 -0
  16. package/protocol/EthereumClassicProtocol.d.ts +6 -0
  17. package/protocol/EthereumClassicProtocol.js +28 -0
  18. package/protocol/EthereumClassicProtocol.js.map +1 -0
  19. package/protocol/EthereumCryptoClient.d.ts +12 -0
  20. package/protocol/EthereumCryptoClient.js +141 -0
  21. package/protocol/EthereumCryptoClient.js.map +1 -0
  22. package/protocol/EthereumProtocol.d.ts +10 -0
  23. package/protocol/EthereumProtocol.js +32 -0
  24. package/protocol/EthereumProtocol.js.map +1 -0
  25. package/protocol/EthereumProtocolOptions.d.ts +46 -0
  26. package/protocol/EthereumProtocolOptions.js +148 -0
  27. package/protocol/EthereumProtocolOptions.js.map +1 -0
  28. package/protocol/EthereumRopstenProtocol.d.ts +6 -0
  29. package/protocol/EthereumRopstenProtocol.js +28 -0
  30. package/protocol/EthereumRopstenProtocol.js.map +1 -0
  31. package/protocol/EthereumTypes.d.ts +14 -0
  32. package/protocol/EthereumTypes.js +3 -0
  33. package/protocol/EthereumTypes.js.map +1 -0
  34. package/protocol/clients/info-clients/EtherscanInfoClient.d.ts +8 -0
  35. package/protocol/clients/info-clients/EtherscanInfoClient.js +193 -0
  36. package/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -0
  37. package/protocol/clients/info-clients/InfoClient.d.ts +8 -0
  38. package/protocol/clients/info-clients/InfoClient.js +11 -0
  39. package/protocol/clients/info-clients/InfoClient.js.map +1 -0
  40. package/protocol/clients/node-clients/AirGapNodeClient.d.ts +41 -0
  41. package/protocol/clients/node-clients/AirGapNodeClient.js +351 -0
  42. package/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -0
  43. package/protocol/clients/node-clients/NodeClient.d.ts +17 -0
  44. package/protocol/clients/node-clients/NodeClient.js +11 -0
  45. package/protocol/clients/node-clients/NodeClient.js.map +1 -0
  46. package/protocol/erc20/ERC20.d.ts +3 -0
  47. package/protocol/erc20/ERC20.js +9 -0
  48. package/protocol/erc20/ERC20.js.map +1 -0
  49. package/protocol/erc20/GenericERC20.d.ts +32 -0
  50. package/protocol/erc20/GenericERC20.js +328 -0
  51. package/protocol/erc20/GenericERC20.js.map +1 -0
  52. package/protocol/utils/utils.d.ts +13 -0
  53. package/protocol/utils/utils.js +140 -0
  54. package/protocol/utils/utils.js.map +1 -0
  55. package/readme.md +121 -0
  56. package/types/signed-transaction-ethereum.d.ts +5 -0
  57. package/types/signed-transaction-ethereum.js +3 -0
  58. package/types/signed-transaction-ethereum.js.map +1 -0
  59. package/types/transaction-ethereum.d.ts +14 -0
  60. package/types/transaction-ethereum.js +3 -0
  61. package/types/transaction-ethereum.js.map +1 -0
  62. package/types/unsigned-transaction-ethereum-typed.d.ts +10 -0
  63. package/types/unsigned-transaction-ethereum-typed.js +3 -0
  64. package/types/unsigned-transaction-ethereum-typed.js.map +1 -0
  65. package/types/unsigned-transaction-ethereum.d.ts +14 -0
  66. package/types/unsigned-transaction-ethereum.js +3 -0
  67. package/types/unsigned-transaction-ethereum.js.map +1 -0
@@ -0,0 +1,193 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ var __generator = (this && this.__generator) || function (thisArg, body) {
25
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
+ function verb(n) { return function (v) { return step([n, v]); }; }
28
+ function step(op) {
29
+ if (f) throw new TypeError("Generator is already executing.");
30
+ while (_) try {
31
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
+ if (y = 0, t) op = [op[0] & 2, t.value];
33
+ switch (op[0]) {
34
+ case 0: case 1: t = op; break;
35
+ case 4: _.label++; return { value: op[1], done: false };
36
+ case 5: _.label++; y = op[1]; op = [0]; continue;
37
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
+ default:
39
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
+ if (t[2]) _.ops.pop();
44
+ _.trys.pop(); continue;
45
+ }
46
+ op = body.call(thisArg, _);
47
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
+ }
50
+ };
51
+ var __importDefault = (this && this.__importDefault) || function (mod) {
52
+ return (mod && mod.__esModule) ? mod : { "default": mod };
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.EtherscanInfoClient = void 0;
56
+ var axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
57
+ var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
58
+ var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
59
+ var IAirGapTransaction_1 = require("@airgap/coinlib-core/interfaces/IAirGapTransaction");
60
+ var EthereumProtocolOptions_1 = require("../../EthereumProtocolOptions");
61
+ var InfoClient_1 = require("./InfoClient");
62
+ var errors_1 = require("@airgap/coinlib-core/errors");
63
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
64
+ var EtherscanInfoClient = /** @class */ (function (_super) {
65
+ __extends(EtherscanInfoClient, _super);
66
+ function EtherscanInfoClient(baseURL) {
67
+ if (baseURL === void 0) { baseURL = EthereumProtocolOptions_1.BLOCK_EXPLORER_API; }
68
+ return _super.call(this, baseURL) || this;
69
+ }
70
+ EtherscanInfoClient.prototype.fetchTransactions = function (protocol, address, limit, cursor) {
71
+ return __awaiter(this, void 0, void 0, function () {
72
+ var airGapTransactions, url, response, transactionResponse, transactions, _i, transactions_1, transaction, fee, airGapTransaction;
73
+ var _a;
74
+ return __generator(this, function (_b) {
75
+ switch (_b.label) {
76
+ case 0:
77
+ airGapTransactions = [];
78
+ url = cursor
79
+ ? this.baseURL + "/api?module=account&action=txlist&address=" + address + "&page=" + cursor.page + "&offset=" + limit + "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7"
80
+ : this.baseURL + "/api?module=account&action=txlist&address=" + address + "&page=1&offset=" + limit + "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7";
81
+ return [4 /*yield*/, axios_0_19_0_1.default.get(url)];
82
+ case 1:
83
+ response = _b.sent();
84
+ transactionResponse = response.data;
85
+ transactions = transactionResponse.result;
86
+ if (transactionResponse.status === '0' && (transactions === undefined || !validate_1.isArray(transactions))) {
87
+ throw new errors_1.NetworkError(coinlib_error_1.Domain.ETHEREUM, { response: response });
88
+ }
89
+ _i = 0, transactions_1 = transactions;
90
+ _b.label = 2;
91
+ case 2:
92
+ if (!(_i < transactions_1.length)) return [3 /*break*/, 6];
93
+ transaction = transactions_1[_i];
94
+ fee = new bignumber_1.BigNumber(transaction.gas).times(new bignumber_1.BigNumber(transaction.gasPrice));
95
+ _a = {
96
+ hash: transaction.hash,
97
+ from: [transaction.from],
98
+ to: [transaction.to],
99
+ isInbound: transaction.to.toLowerCase() === address.toLowerCase(),
100
+ amount: new bignumber_1.BigNumber(transaction.value).toString(10),
101
+ fee: fee.toString(10),
102
+ blockHeight: transaction.blockNumber
103
+ };
104
+ return [4 /*yield*/, protocol.getIdentifier()];
105
+ case 3:
106
+ _a.protocolIdentifier = _b.sent();
107
+ return [4 /*yield*/, protocol.getOptions()];
108
+ case 4:
109
+ airGapTransaction = (_a.network = (_b.sent()).network,
110
+ _a.timestamp = parseInt(transaction.timeStamp, 10),
111
+ _a.status = transaction.txreceipt_status === undefined || transaction.txreceipt_status === '1'
112
+ ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED
113
+ : IAirGapTransaction_1.AirGapTransactionStatus.FAILED,
114
+ _a);
115
+ airGapTransactions.push(airGapTransaction);
116
+ _b.label = 5;
117
+ case 5:
118
+ _i++;
119
+ return [3 /*break*/, 2];
120
+ case 6: return [2 /*return*/, {
121
+ transactions: airGapTransactions,
122
+ cursor: {
123
+ page: cursor ? cursor.page + 1 : 2
124
+ }
125
+ }];
126
+ }
127
+ });
128
+ });
129
+ };
130
+ EtherscanInfoClient.prototype.fetchContractTransactions = function (protocol, contractAddress, address, limit, cursor) {
131
+ return __awaiter(this, void 0, void 0, function () {
132
+ var airGapTransactions, url, response, transactionResponse, transactions, _i, transactions_2, transaction, fee, airGapTransaction;
133
+ var _a;
134
+ return __generator(this, function (_b) {
135
+ switch (_b.label) {
136
+ case 0:
137
+ airGapTransactions = [];
138
+ url = cursor
139
+ ? this.baseURL + "/api?module=account&action=tokentx&address=" + address + "&contractAddress=" + contractAddress + "&page=" + cursor.page + "&offset=" + limit + "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7"
140
+ : this.baseURL + "/api?module=account&action=tokentx&address=" + address + "&contractAddress=" + contractAddress + "&page=1&offset=" + limit + "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7";
141
+ return [4 /*yield*/, axios_0_19_0_1.default.get(url)];
142
+ case 1:
143
+ response = _b.sent();
144
+ transactionResponse = response.data;
145
+ transactions = transactionResponse.result;
146
+ if (transactionResponse.status === '0' && (transactions === undefined || !validate_1.isArray(transactions))) {
147
+ throw new errors_1.NetworkError(coinlib_error_1.Domain.ETHEREUM, { response: response });
148
+ }
149
+ _i = 0, transactions_2 = transactions;
150
+ _b.label = 2;
151
+ case 2:
152
+ if (!(_i < transactions_2.length)) return [3 /*break*/, 6];
153
+ transaction = transactions_2[_i];
154
+ fee = new bignumber_1.BigNumber(transaction.gas).times(new bignumber_1.BigNumber(transaction.gasPrice));
155
+ _a = {
156
+ hash: transaction.hash,
157
+ from: [transaction.from],
158
+ to: [transaction.to],
159
+ isInbound: transaction.to.toLowerCase() === address.toLowerCase(),
160
+ blockHeight: transaction.blockNumber
161
+ };
162
+ return [4 /*yield*/, protocol.getIdentifier()];
163
+ case 3:
164
+ _a.protocolIdentifier = _b.sent();
165
+ return [4 /*yield*/, protocol.getOptions()];
166
+ case 4:
167
+ airGapTransaction = (_a.network = (_b.sent()).network,
168
+ _a.amount = new bignumber_1.BigNumber(transaction.value).toString(10),
169
+ _a.fee = fee.toString(10),
170
+ _a.timestamp = parseInt(transaction.timeStamp, 10),
171
+ _a.status = transaction.txreceipt_status === undefined || transaction.txreceipt_status === '1'
172
+ ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED
173
+ : IAirGapTransaction_1.AirGapTransactionStatus.FAILED,
174
+ _a);
175
+ airGapTransactions.push(airGapTransaction);
176
+ _b.label = 5;
177
+ case 5:
178
+ _i++;
179
+ return [3 /*break*/, 2];
180
+ case 6: return [2 /*return*/, {
181
+ transactions: airGapTransactions,
182
+ cursor: {
183
+ page: cursor ? cursor.page + 1 : 2
184
+ }
185
+ }];
186
+ }
187
+ });
188
+ });
189
+ };
190
+ return EtherscanInfoClient;
191
+ }(InfoClient_1.EthereumInfoClient));
192
+ exports.EtherscanInfoClient = EtherscanInfoClient;
193
+ //# sourceMappingURL=EtherscanInfoClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EtherscanInfoClient.js","sourceRoot":"","sources":["../../../../src/protocol/clients/info-clients/EtherscanInfoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oGAAsE;AACtE,gGAA8F;AAC9F,8FAA2F;AAC3F,yFAAgH;AAEhH,yEAAkE;AAGlE,2CAAiD;AACjD,sDAA0D;AAC1D,2EAAkE;AAElE;IAAyC,uCAAkB;IACzD,6BAAY,OAAoC;QAApC,wBAAA,EAAA,U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AE,QAAQ,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC;4BAC9C,SAAM,GACJ,WAAW,CAAC,gBAAgB,KAAK,SAAS,IAAI,WAAW,CAAC,gBAAgB,KAAK,GAAG;gCAChF,CAAC,CAAC,4CAAuB,CAAC,OAAO;gCACjC,CAAC,CAAC,4CAAuB,CAAC,MAAM;+BACrC;wBAED,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;;;wBAnBlB,IAAY,CAAA;;4BAsBtC,sBAAO;4BACL,YAAY,EAAE,kBAAkB;4BAChC,MAAM,EAAE;gCACN,IAAI,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC;6BACnC;yBACF,EAAA;;;;KACF;IACH,0BAAC;AAAD,CAAC,AArGD,CAAyC,+BAAkB,GAqG1D;AArGY,kDAAmB"}
@@ -0,0 +1,8 @@
1
+ import { BaseEthereumProtocol } from '../../BaseEthereumProtocol';
2
+ import { EthereumTransactionCursor, EthereumTransactionResult } from '../../EthereumTypes';
3
+ export declare abstract class EthereumInfoClient {
4
+ baseURL: string;
5
+ constructor(baseURL: string);
6
+ abstract fetchTransactions(protocol: BaseEthereumProtocol<any, any>, address: string, limit: number, cursor?: EthereumTransactionCursor): Promise<EthereumTransactionResult>;
7
+ abstract fetchContractTransactions(protocol: BaseEthereumProtocol<any, any>, contractAddress: string, address: string, limit: number, cursor?: EthereumTransactionCursor): Promise<EthereumTransactionResult>;
8
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EthereumInfoClient = void 0;
4
+ var EthereumInfoClient = /** @class */ (function () {
5
+ function EthereumInfoClient(baseURL) {
6
+ this.baseURL = baseURL;
7
+ }
8
+ return EthereumInfoClient;
9
+ }());
10
+ exports.EthereumInfoClient = EthereumInfoClient;
11
+ //# sourceMappingURL=InfoClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"InfoClient.js","sourceRoot":"","sources":["../../../../src/protocol/clients/info-clients/InfoClient.ts"],"names":[],"mappings":";;;AAGA;IAGE,4BAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAeH,yBAAC;AAAD,CAAC,AApBD,IAoBC;AApBqB,gDAAkB"}
@@ -0,0 +1,41 @@
1
+ import { BigNumber } from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
+ import { AirGapTransactionStatus } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
3
+ import { EthereumNodeClient } from './NodeClient';
4
+ export declare class EthereumRPCData {
5
+ protected static parametersLength: number;
6
+ methodSignature: string;
7
+ constructor(methodSignature: string);
8
+ abiEncoded(): string;
9
+ static addLeadingZeroPadding(value: string, targetLength?: number): string;
10
+ static removeLeadingZeroPadding(value: string): string;
11
+ }
12
+ export declare class EthereumRPCDataBalanceOf extends EthereumRPCData {
13
+ static methodName: string;
14
+ address: string;
15
+ constructor(address: string);
16
+ abiEncoded(): string;
17
+ }
18
+ export declare class EthereumRPCDataTransfer extends EthereumRPCData {
19
+ static methodName: string;
20
+ recipient: string;
21
+ amount: string;
22
+ constructor(toAddressOrData: string, amount?: string);
23
+ abiEncoded(): string;
24
+ }
25
+ export declare class AirGapNodeClient extends EthereumNodeClient {
26
+ constructor(baseURL?: string);
27
+ fetchBalance(address: string): Promise<BigNumber>;
28
+ fetchTransactionCount(address: string): Promise<number>;
29
+ sendSignedTransaction(transaction: string): Promise<string>;
30
+ getTransactionStatus(transactionHash: string): Promise<AirGapTransactionStatus>;
31
+ callBalanceOf(contractAddress: string, address: string): Promise<BigNumber>;
32
+ callBalanceOfOnContracts(contractAddresses: string[], address: string): Promise<{
33
+ [contractAddress: string]: BigNumber;
34
+ }>;
35
+ private balanceOfBody;
36
+ estimateTransactionGas(fromAddress: string, toAddress: string, amount?: string, data?: string, gas?: string): Promise<BigNumber>;
37
+ estimateTransferGas(contractAddress: string, fromAddress: string, toAddress: string, hexAmount: string): Promise<BigNumber>;
38
+ getGasPrice(): Promise<BigNumber>;
39
+ private send;
40
+ private batchSend;
41
+ }
@@ -0,0 +1,351 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ extendStatics(d, b);
11
+ function __() { this.constructor = d; }
12
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
13
+ };
14
+ })();
15
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
16
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
17
+ return new (P || (P = Promise))(function (resolve, reject) {
18
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
19
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
20
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
21
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
22
+ });
23
+ };
24
+ var __generator = (this && this.__generator) || function (thisArg, body) {
25
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
26
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
27
+ function verb(n) { return function (v) { return step([n, v]); }; }
28
+ function step(op) {
29
+ if (f) throw new TypeError("Generator is already executing.");
30
+ while (_) try {
31
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
32
+ if (y = 0, t) op = [op[0] & 2, t.value];
33
+ switch (op[0]) {
34
+ case 0: case 1: t = op; break;
35
+ case 4: _.label++; return { value: op[1], done: false };
36
+ case 5: _.label++; y = op[1]; op = [0]; continue;
37
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
38
+ default:
39
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
40
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
41
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
42
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
43
+ if (t[2]) _.ops.pop();
44
+ _.trys.pop(); continue;
45
+ }
46
+ op = body.call(thisArg, _);
47
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
48
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
49
+ }
50
+ };
51
+ var __importDefault = (this && this.__importDefault) || function (mod) {
52
+ return (mod && mod.__esModule) ? mod : { "default": mod };
53
+ };
54
+ Object.defineProperty(exports, "__esModule", { value: true });
55
+ exports.AirGapNodeClient = exports.EthereumRPCDataTransfer = exports.EthereumRPCDataBalanceOf = exports.EthereumRPCData = void 0;
56
+ var RPCBody_1 = require("@airgap/coinlib-core/data/RPCBody");
57
+ var axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
58
+ var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
59
+ var errors_1 = require("@airgap/coinlib-core/errors");
60
+ var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
61
+ var IAirGapTransaction_1 = require("@airgap/coinlib-core/interfaces/IAirGapTransaction");
62
+ var EthereumProtocolOptions_1 = require("../../EthereumProtocolOptions");
63
+ var utils_1 = require("../../utils/utils");
64
+ var NodeClient_1 = require("./NodeClient");
65
+ var EthereumRPCBody = /** @class */ (function (_super) {
66
+ __extends(EthereumRPCBody, _super);
67
+ function EthereumRPCBody() {
68
+ return _super !== null && _super.apply(this, arguments) || this;
69
+ }
70
+ EthereumRPCBody.prototype.toRPCBody = function () {
71
+ return JSON.stringify(this.toJSON());
72
+ };
73
+ EthereumRPCBody.prototype.toJSON = function () {
74
+ return {
75
+ jsonrpc: this.jsonrpc,
76
+ method: this.method,
77
+ params: this.params,
78
+ id: this.id
79
+ };
80
+ };
81
+ EthereumRPCBody.blockEarliest = 'earliest';
82
+ EthereumRPCBody.blockLatest = 'latest';
83
+ EthereumRPCBody.blockPending = 'pending';
84
+ return EthereumRPCBody;
85
+ }(RPCBody_1.RPCBody));
86
+ var EthereumRPCData = /** @class */ (function () {
87
+ function EthereumRPCData(methodSignature) {
88
+ this.methodSignature = methodSignature;
89
+ }
90
+ EthereumRPCData.prototype.abiEncoded = function () {
91
+ var hash = utils_1.EthereumUtils.sha3(this.methodSignature);
92
+ if (hash === null) {
93
+ return '';
94
+ }
95
+ return "0x" + hash.slice(2, 10);
96
+ };
97
+ EthereumRPCData.addLeadingZeroPadding = function (value, targetLength) {
98
+ if (targetLength === void 0) { targetLength = EthereumRPCData.parametersLength; }
99
+ var result = value;
100
+ while (result.length < targetLength) {
101
+ result = '0' + result;
102
+ }
103
+ return result;
104
+ };
105
+ EthereumRPCData.removeLeadingZeroPadding = function (value) {
106
+ var result = value;
107
+ while (result.startsWith('0')) {
108
+ result = result.slice(1); // this can probably be done much more efficiently with a regex
109
+ }
110
+ return result;
111
+ };
112
+ // 2 chars = 1 byte hence to get to 32 bytes we need 64 chars
113
+ EthereumRPCData.parametersLength = 64;
114
+ return EthereumRPCData;
115
+ }());
116
+ exports.EthereumRPCData = EthereumRPCData;
117
+ var EthereumRPCDataBalanceOf = /** @class */ (function (_super) {
118
+ __extends(EthereumRPCDataBalanceOf, _super);
119
+ function EthereumRPCDataBalanceOf(address) {
120
+ var _this = _super.call(this, EthereumRPCDataBalanceOf.methodName + "(address)") || this;
121
+ _this.address = address;
122
+ return _this;
123
+ }
124
+ EthereumRPCDataBalanceOf.prototype.abiEncoded = function () {
125
+ var srcAddress = this.address;
126
+ if (srcAddress.startsWith('0x')) {
127
+ srcAddress = srcAddress.slice(2);
128
+ }
129
+ return _super.prototype.abiEncoded.call(this) + EthereumRPCData.addLeadingZeroPadding(srcAddress);
130
+ };
131
+ EthereumRPCDataBalanceOf.methodName = 'balanceOf';
132
+ return EthereumRPCDataBalanceOf;
133
+ }(EthereumRPCData));
134
+ exports.EthereumRPCDataBalanceOf = EthereumRPCDataBalanceOf;
135
+ var EthereumRPCDataTransfer = /** @class */ (function (_super) {
136
+ __extends(EthereumRPCDataTransfer, _super);
137
+ function EthereumRPCDataTransfer(toAddressOrData, amount) {
138
+ var _this = _super.call(this, EthereumRPCDataTransfer.methodName + "(address,uint256)") || this;
139
+ if (amount) {
140
+ var toAddress = toAddressOrData;
141
+ _this.recipient = toAddress;
142
+ _this.amount = amount;
143
+ }
144
+ else {
145
+ var data = toAddressOrData;
146
+ var methodID = _super.prototype.abiEncoded.call(_this);
147
+ if (!data.startsWith(methodID)) {
148
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.ETHEREUM, 'unexpected method ID');
149
+ }
150
+ var params = data.slice(methodID.length);
151
+ var recipient = EthereumRPCData.removeLeadingZeroPadding(params.slice(0, EthereumRPCData.parametersLength));
152
+ var parsedAmount = EthereumRPCData.removeLeadingZeroPadding(params.slice(EthereumRPCData.parametersLength));
153
+ _this.recipient = "0x" + recipient;
154
+ _this.amount = "0x" + parsedAmount;
155
+ }
156
+ return _this;
157
+ }
158
+ EthereumRPCDataTransfer.prototype.abiEncoded = function () {
159
+ var dstAddress = this.recipient;
160
+ if (dstAddress.startsWith('0x')) {
161
+ dstAddress = dstAddress.slice(2);
162
+ }
163
+ var transferAmount = this.amount;
164
+ if (transferAmount.startsWith('0x')) {
165
+ transferAmount = transferAmount.slice(2);
166
+ }
167
+ return (_super.prototype.abiEncoded.call(this) +
168
+ EthereumRPCData.addLeadingZeroPadding(dstAddress.toLowerCase()) +
169
+ EthereumRPCData.addLeadingZeroPadding(transferAmount.toLowerCase()));
170
+ };
171
+ EthereumRPCDataTransfer.methodName = 'transfer';
172
+ return EthereumRPCDataTransfer;
173
+ }(EthereumRPCData));
174
+ exports.EthereumRPCDataTransfer = EthereumRPCDataTransfer;
175
+ var AirGapNodeClient = /** @class */ (function (_super) {
176
+ __extends(AirGapNodeClient, _super);
177
+ function AirGapNodeClient(baseURL) {
178
+ if (baseURL === void 0) { baseURL = EthereumProtocolOptions_1.NODE_URL; }
179
+ return _super.call(this, baseURL) || this;
180
+ }
181
+ AirGapNodeClient.prototype.fetchBalance = function (address) {
182
+ return __awaiter(this, void 0, void 0, function () {
183
+ var body, response;
184
+ return __generator(this, function (_a) {
185
+ switch (_a.label) {
186
+ case 0:
187
+ body = new EthereumRPCBody('eth_getBalance', [address, EthereumRPCBody.blockLatest]);
188
+ return [4 /*yield*/, this.send(body)];
189
+ case 1:
190
+ response = _a.sent();
191
+ return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
192
+ }
193
+ });
194
+ });
195
+ };
196
+ AirGapNodeClient.prototype.fetchTransactionCount = function (address) {
197
+ return __awaiter(this, void 0, void 0, function () {
198
+ var body, response;
199
+ return __generator(this, function (_a) {
200
+ switch (_a.label) {
201
+ case 0:
202
+ body = new EthereumRPCBody('eth_getTransactionCount', [address, EthereumRPCBody.blockLatest]);
203
+ return [4 /*yield*/, this.send(body)];
204
+ case 1:
205
+ response = _a.sent();
206
+ return [2 /*return*/, new bignumber_1.BigNumber(response.result).toNumber()];
207
+ }
208
+ });
209
+ });
210
+ };
211
+ AirGapNodeClient.prototype.sendSignedTransaction = function (transaction) {
212
+ return __awaiter(this, void 0, void 0, function () {
213
+ var body;
214
+ return __generator(this, function (_a) {
215
+ switch (_a.label) {
216
+ case 0:
217
+ body = new EthereumRPCBody('eth_sendRawTransaction', [transaction]);
218
+ return [4 /*yield*/, this.send(body)];
219
+ case 1: return [2 /*return*/, (_a.sent()).result];
220
+ }
221
+ });
222
+ });
223
+ };
224
+ AirGapNodeClient.prototype.getTransactionStatus = function (transactionHash) {
225
+ return __awaiter(this, void 0, void 0, function () {
226
+ var body, response;
227
+ return __generator(this, function (_a) {
228
+ switch (_a.label) {
229
+ case 0:
230
+ body = new EthereumRPCBody('eth_getTransactionReceipt', [transactionHash]);
231
+ return [4 /*yield*/, this.send(body)];
232
+ case 1:
233
+ response = _a.sent();
234
+ return [2 /*return*/, response.result.status === '0x1' ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED : IAirGapTransaction_1.AirGapTransactionStatus.FAILED];
235
+ }
236
+ });
237
+ });
238
+ };
239
+ AirGapNodeClient.prototype.callBalanceOf = function (contractAddress, address) {
240
+ return __awaiter(this, void 0, void 0, function () {
241
+ var body, response;
242
+ return __generator(this, function (_a) {
243
+ switch (_a.label) {
244
+ case 0:
245
+ body = this.balanceOfBody(contractAddress, address);
246
+ return [4 /*yield*/, this.send(body)];
247
+ case 1:
248
+ response = _a.sent();
249
+ return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
250
+ }
251
+ });
252
+ });
253
+ };
254
+ AirGapNodeClient.prototype.callBalanceOfOnContracts = function (contractAddresses, address) {
255
+ return __awaiter(this, void 0, void 0, function () {
256
+ var bodies, responses, result;
257
+ var _this = this;
258
+ return __generator(this, function (_a) {
259
+ switch (_a.label) {
260
+ case 0:
261
+ bodies = contractAddresses.map(function (contractAddress, index) { return _this.balanceOfBody(contractAddress, address, index); });
262
+ return [4 /*yield*/, this.batchSend(bodies)];
263
+ case 1:
264
+ responses = _a.sent();
265
+ result = {};
266
+ responses.forEach(function (response) {
267
+ var _a;
268
+ result[contractAddresses[response.id]] = new bignumber_1.BigNumber((_a = response.result) !== null && _a !== void 0 ? _a : 0);
269
+ });
270
+ return [2 /*return*/, result];
271
+ }
272
+ });
273
+ });
274
+ };
275
+ AirGapNodeClient.prototype.balanceOfBody = function (contractAddress, address, id) {
276
+ if (id === void 0) { id = 0; }
277
+ var data = new EthereumRPCDataBalanceOf(address);
278
+ return new EthereumRPCBody('eth_call', [{ to: contractAddress, data: data.abiEncoded() }, EthereumRPCBody.blockLatest], id);
279
+ };
280
+ AirGapNodeClient.prototype.estimateTransactionGas = function (fromAddress, toAddress, amount, data, gas) {
281
+ return __awaiter(this, void 0, void 0, function () {
282
+ var body, response;
283
+ return __generator(this, function (_a) {
284
+ switch (_a.label) {
285
+ case 0:
286
+ body = new EthereumRPCBody('eth_estimateGas', [{ from: fromAddress, to: toAddress, gas: gas, value: amount, data: data }]);
287
+ return [4 /*yield*/, this.send(body)];
288
+ case 1:
289
+ response = _a.sent();
290
+ return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
291
+ }
292
+ });
293
+ });
294
+ };
295
+ AirGapNodeClient.prototype.estimateTransferGas = function (contractAddress, fromAddress, toAddress, hexAmount) {
296
+ return __awaiter(this, void 0, void 0, function () {
297
+ var data, result;
298
+ return __generator(this, function (_a) {
299
+ data = new EthereumRPCDataTransfer(toAddress, hexAmount);
300
+ result = this.estimateTransactionGas(fromAddress, contractAddress, undefined, data.abiEncoded());
301
+ return [2 /*return*/, result];
302
+ });
303
+ });
304
+ };
305
+ AirGapNodeClient.prototype.getGasPrice = function () {
306
+ return __awaiter(this, void 0, void 0, function () {
307
+ var body, response;
308
+ return __generator(this, function (_a) {
309
+ switch (_a.label) {
310
+ case 0:
311
+ body = new EthereumRPCBody('eth_gasPrice', []);
312
+ return [4 /*yield*/, this.send(body)];
313
+ case 1:
314
+ response = _a.sent();
315
+ return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
316
+ }
317
+ });
318
+ });
319
+ };
320
+ AirGapNodeClient.prototype.send = function (body) {
321
+ return __awaiter(this, void 0, void 0, function () {
322
+ var response;
323
+ return __generator(this, function (_a) {
324
+ switch (_a.label) {
325
+ case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.baseURL, body.toRPCBody()).catch(function (error) {
326
+ throw new errors_1.NetworkError(coinlib_error_1.Domain.TEZOS, error);
327
+ })];
328
+ case 1:
329
+ response = _a.sent();
330
+ return [2 /*return*/, response.data];
331
+ }
332
+ });
333
+ });
334
+ };
335
+ AirGapNodeClient.prototype.batchSend = function (bodies) {
336
+ return __awaiter(this, void 0, void 0, function () {
337
+ var data;
338
+ return __generator(this, function (_a) {
339
+ switch (_a.label) {
340
+ case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.baseURL, JSON.stringify(bodies.map(function (body) { return body.toJSON(); })))];
341
+ case 1:
342
+ data = (_a.sent()).data;
343
+ return [2 /*return*/, data];
344
+ }
345
+ });
346
+ });
347
+ };
348
+ return AirGapNodeClient;
349
+ }(NodeClient_1.EthereumNodeClient));
350
+ exports.AirGapNodeClient = AirGapNodeClient;
351
+ //# sourceMappingURL=AirGapNodeClient.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"AirGapNodeClient.js","sourceRoot":"","sources":["../../../../src/protocol/clients/node-clients/AirGapNodeClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6DAA2D;AAC3D,oGAAsF;AACtF,gGAA8F;AAC9F,sDAA6E;AAC7E,2EAAkE;AAClE,yFAA4F;AAE5F,yEAAwD;AACxD,2CAAiD;AAEjD,2CAAiD;AAEjD;IAA8B,mCAAO;IAArC;;IAiBA,CAAC;IAZQ,mCAAS,GAAhB;QACE,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,EAAE,CAAC,CAAA;IACtC,CAAC;IAEM,gCAAM,GAAb;QACE,OAAO;YACL,OAAO,EAAE,IAAI,CAAC,OAAO;YACrB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,MAAM,EAAE,IAAI,CAAC,MAAM;YACnB,EAAE,EAAE,IAAI,CAAC,EAAE;SACZ,CAAA;IACH,CAAC;IAfa,6BAAa,GA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I;wBAEvG,sBAAO,IAAI,EAAA;;;;KACZ;IACH,uBAAC;AAAD,CAAC,AArGD,CAAsC,+BAAkB,GAqGvD;AArGY,4CAAgB"}
@@ -0,0 +1,17 @@
1
+ import { BigNumber } from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
+ import { AirGapTransactionStatus } from '@airgap/coinlib-core/interfaces/IAirGapTransaction';
3
+ export declare abstract class EthereumNodeClient {
4
+ baseURL: string;
5
+ constructor(baseURL: string);
6
+ abstract fetchBalance(address: string): Promise<BigNumber>;
7
+ abstract fetchTransactionCount(address: string): Promise<number>;
8
+ abstract sendSignedTransaction(transaction: string): Promise<string>;
9
+ abstract callBalanceOf(contractAddress: string, address: string): Promise<BigNumber>;
10
+ abstract getTransactionStatus(transactionHash: string): Promise<AirGapTransactionStatus>;
11
+ abstract estimateTransferGas(contractAddress: string, fromAddress: string, toAddress: string, hexAmount: string): Promise<BigNumber>;
12
+ abstract estimateTransactionGas(fromAddress: string, toAddress: string, amount?: string, data?: string, gas?: string): Promise<BigNumber>;
13
+ abstract getGasPrice(): Promise<BigNumber>;
14
+ abstract callBalanceOfOnContracts(contractAddresses: string[], address: string): Promise<{
15
+ [contractAddress: string]: BigNumber;
16
+ }>;
17
+ }