@airgap/ethereum 0.13.11-beta.0 → 0.13.11-beta.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.
Files changed (157) hide show
  1. package/package.json +11 -9
  2. package/airgap-coinlib-ethereum.min.js +0 -117080
  3. package/index.d.ts +0 -1
  4. package/index.js +0 -18
  5. package/index.js.map +0 -1
  6. package/v0/index.d.ts +0 -12
  7. package/v0/index.js +0 -39
  8. package/v0/index.js.map +0 -1
  9. package/v0/protocol/BaseEthereumProtocol.d.ts +0 -98
  10. package/v0/protocol/BaseEthereumProtocol.js +0 -939
  11. package/v0/protocol/BaseEthereumProtocol.js.map +0 -1
  12. package/v0/protocol/EthereumAddress.d.ts +0 -8
  13. package/v0/protocol/EthereumAddress.js +0 -43
  14. package/v0/protocol/EthereumAddress.js.map +0 -1
  15. package/v0/protocol/EthereumChainIDs.d.ts +0 -1
  16. package/v0/protocol/EthereumChainIDs.js +0 -340
  17. package/v0/protocol/EthereumChainIDs.js.map +0 -1
  18. package/v0/protocol/EthereumClassicProtocol.d.ts +0 -6
  19. package/v0/protocol/EthereumClassicProtocol.js +0 -30
  20. package/v0/protocol/EthereumClassicProtocol.js.map +0 -1
  21. package/v0/protocol/EthereumCryptoClient.d.ts +0 -12
  22. package/v0/protocol/EthereumCryptoClient.js +0 -148
  23. package/v0/protocol/EthereumCryptoClient.js.map +0 -1
  24. package/v0/protocol/EthereumProtocol.d.ts +0 -10
  25. package/v0/protocol/EthereumProtocol.js +0 -34
  26. package/v0/protocol/EthereumProtocol.js.map +0 -1
  27. package/v0/protocol/EthereumProtocolOptions.d.ts +0 -46
  28. package/v0/protocol/EthereumProtocolOptions.js +0 -150
  29. package/v0/protocol/EthereumProtocolOptions.js.map +0 -1
  30. package/v0/protocol/EthereumRopstenProtocol.d.ts +0 -6
  31. package/v0/protocol/EthereumRopstenProtocol.js +0 -30
  32. package/v0/protocol/EthereumRopstenProtocol.js.map +0 -1
  33. package/v0/protocol/EthereumTypes.d.ts +0 -14
  34. package/v0/protocol/EthereumTypes.js +0 -3
  35. package/v0/protocol/EthereumTypes.js.map +0 -1
  36. package/v0/protocol/clients/info-clients/EtherscanInfoClient.d.ts +0 -8
  37. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +0 -195
  38. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +0 -1
  39. package/v0/protocol/clients/info-clients/InfoClient.d.ts +0 -8
  40. package/v0/protocol/clients/info-clients/InfoClient.js +0 -11
  41. package/v0/protocol/clients/info-clients/InfoClient.js.map +0 -1
  42. package/v0/protocol/clients/node-clients/AirGapNodeClient.d.ts +0 -41
  43. package/v0/protocol/clients/node-clients/AirGapNodeClient.js +0 -353
  44. package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +0 -1
  45. package/v0/protocol/clients/node-clients/NodeClient.d.ts +0 -17
  46. package/v0/protocol/clients/node-clients/NodeClient.js +0 -11
  47. package/v0/protocol/clients/node-clients/NodeClient.js.map +0 -1
  48. package/v0/protocol/erc20/ERC20.d.ts +0 -3
  49. package/v0/protocol/erc20/ERC20.js +0 -9
  50. package/v0/protocol/erc20/ERC20.js.map +0 -1
  51. package/v0/protocol/erc20/GenericERC20.d.ts +0 -32
  52. package/v0/protocol/erc20/GenericERC20.js +0 -335
  53. package/v0/protocol/erc20/GenericERC20.js.map +0 -1
  54. package/v0/protocol/utils/utils.d.ts +0 -13
  55. package/v0/protocol/utils/utils.js +0 -140
  56. package/v0/protocol/utils/utils.js.map +0 -1
  57. package/v0/serializer/schemas/v2/transaction-sign-request-ethereum.json +0 -50
  58. package/v0/serializer/schemas/v2/transaction-sign-response-ethereum.json +0 -19
  59. package/v0/serializer/schemas/v3/transaction-sign-request-ethereum-typed.json +0 -38
  60. package/v0/serializer/schemas/v3/transaction-sign-request-ethereum.json +0 -50
  61. package/v0/serializer/schemas/v3/transaction-sign-response-ethereum.json +0 -19
  62. package/v0/serializer/validators/transaction-validator.d.ts +0 -15
  63. package/v0/serializer/validators/transaction-validator.js +0 -96
  64. package/v0/serializer/validators/transaction-validator.js.map +0 -1
  65. package/v0/serializer/validators/validators.d.ts +0 -1
  66. package/v0/serializer/validators/validators.js +0 -78
  67. package/v0/serializer/validators/validators.js.map +0 -1
  68. package/v0/types/signed-transaction-ethereum.d.ts +0 -5
  69. package/v0/types/signed-transaction-ethereum.js +0 -3
  70. package/v0/types/signed-transaction-ethereum.js.map +0 -1
  71. package/v0/types/transaction-ethereum.d.ts +0 -14
  72. package/v0/types/transaction-ethereum.js +0 -3
  73. package/v0/types/transaction-ethereum.js.map +0 -1
  74. package/v0/types/unsigned-transaction-ethereum-typed.d.ts +0 -11
  75. package/v0/types/unsigned-transaction-ethereum-typed.js +0 -3
  76. package/v0/types/unsigned-transaction-ethereum-typed.js.map +0 -1
  77. package/v0/types/unsigned-transaction-ethereum.d.ts +0 -15
  78. package/v0/types/unsigned-transaction-ethereum.js +0 -3
  79. package/v0/types/unsigned-transaction-ethereum.js.map +0 -1
  80. package/v1/block-explorer/EtherscanBlockExplorer.d.ts +0 -9
  81. package/v1/block-explorer/EtherscanBlockExplorer.js +0 -74
  82. package/v1/block-explorer/EtherscanBlockExplorer.js.map +0 -1
  83. package/v1/clients/crypto/EthereumCryptoClient.d.ts +0 -7
  84. package/v1/clients/crypto/EthereumCryptoClient.js +0 -147
  85. package/v1/clients/crypto/EthereumCryptoClient.js.map +0 -1
  86. package/v1/clients/info/EthereumInfoClient.d.ts +0 -15
  87. package/v1/clients/info/EthereumInfoClient.js +0 -11
  88. package/v1/clients/info/EthereumInfoClient.js.map +0 -1
  89. package/v1/clients/info/EtherscanInfoClient.d.ts +0 -7
  90. package/v1/clients/info/EtherscanInfoClient.js +0 -165
  91. package/v1/clients/info/EtherscanInfoClient.js.map +0 -1
  92. package/v1/clients/node/AirGapNodeClient.d.ts +0 -41
  93. package/v1/clients/node/AirGapNodeClient.js +0 -351
  94. package/v1/clients/node/AirGapNodeClient.js.map +0 -1
  95. package/v1/clients/node/EthereumNodeClient.d.ts +0 -17
  96. package/v1/clients/node/EthereumNodeClient.js +0 -11
  97. package/v1/clients/node/EthereumNodeClient.js.map +0 -1
  98. package/v1/data/EthereumAddress.d.ts +0 -7
  99. package/v1/data/EthereumAddress.js +0 -46
  100. package/v1/data/EthereumAddress.js.map +0 -1
  101. package/v1/index.d.ts +0 -10
  102. package/v1/index.js +0 -13
  103. package/v1/index.js.map +0 -1
  104. package/v1/module/ERC20Tokens.d.ts +0 -3
  105. package/v1/module/ERC20Tokens.js +0 -815
  106. package/v1/module/ERC20Tokens.js.map +0 -1
  107. package/v1/module/EthereumModule.d.ts +0 -13
  108. package/v1/module/EthereumModule.js +0 -125
  109. package/v1/module/EthereumModule.js.map +0 -1
  110. package/v1/module.d.ts +0 -3
  111. package/v1/module.js +0 -24
  112. package/v1/module.js.map +0 -1
  113. package/v1/protocol/EthereumBaseProtocol.d.ts +0 -83
  114. package/v1/protocol/EthereumBaseProtocol.js +0 -866
  115. package/v1/protocol/EthereumBaseProtocol.js.map +0 -1
  116. package/v1/protocol/EthereumChainIds.d.ts +0 -1
  117. package/v1/protocol/EthereumChainIds.js +0 -340
  118. package/v1/protocol/EthereumChainIds.js.map +0 -1
  119. package/v1/protocol/EthereumProtocol.d.ts +0 -8
  120. package/v1/protocol/EthereumProtocol.js +0 -64
  121. package/v1/protocol/EthereumProtocol.js.map +0 -1
  122. package/v1/protocol/erc20/ERC20Token.d.ts +0 -8
  123. package/v1/protocol/erc20/ERC20Token.js +0 -421
  124. package/v1/protocol/erc20/ERC20Token.js.map +0 -1
  125. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +0 -12
  126. package/v1/serializer/v3/schemas/converter/transaction-converter.js +0 -80
  127. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +0 -1
  128. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +0 -10
  129. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js +0 -3
  130. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js.map +0 -1
  131. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +0 -14
  132. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js +0 -3
  133. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js.map +0 -1
  134. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.d.ts +0 -3
  135. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js +0 -3
  136. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js.map +0 -1
  137. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +0 -41
  138. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +0 -58
  139. package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +0 -19
  140. package/v1/serializer/v3/serializer-companion.d.ts +0 -13
  141. package/v1/serializer/v3/serializer-companion.js +0 -190
  142. package/v1/serializer/v3/serializer-companion.js.map +0 -1
  143. package/v1/serializer/v3/validators/transaction-validator.d.ts +0 -7
  144. package/v1/serializer/v3/validators/transaction-validator.js +0 -71
  145. package/v1/serializer/v3/validators/transaction-validator.js.map +0 -1
  146. package/v1/types/protocol.d.ts +0 -32
  147. package/v1/types/protocol.js +0 -3
  148. package/v1/types/protocol.js.map +0 -1
  149. package/v1/types/transaction.d.ts +0 -24
  150. package/v1/types/transaction.js +0 -3
  151. package/v1/types/transaction.js.map +0 -1
  152. package/v1/utils/EthereumUtils.d.ts +0 -13
  153. package/v1/utils/EthereumUtils.js +0 -140
  154. package/v1/utils/EthereumUtils.js.map +0 -1
  155. package/v1/utils/key.d.ts +0 -5
  156. package/v1/utils/key.js +0 -88
  157. package/v1/utils/key.js.map +0 -1
@@ -1,195 +0,0 @@
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
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- 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;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __importDefault = (this && this.__importDefault) || function (mod) {
54
- return (mod && mod.__esModule) ? mod : { "default": mod };
55
- };
56
- Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.EtherscanInfoClient = void 0;
58
- var axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
59
- var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
60
- var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
61
- var IAirGapTransaction_1 = require("@airgap/coinlib-core/interfaces/IAirGapTransaction");
62
- var EthereumProtocolOptions_1 = require("../../EthereumProtocolOptions");
63
- var InfoClient_1 = require("./InfoClient");
64
- var errors_1 = require("@airgap/coinlib-core/errors");
65
- var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
66
- var EtherscanInfoClient = /** @class */ (function (_super) {
67
- __extends(EtherscanInfoClient, _super);
68
- function EtherscanInfoClient(baseURL) {
69
- if (baseURL === void 0) { baseURL = EthereumProtocolOptions_1.BLOCK_EXPLORER_API; }
70
- return _super.call(this, baseURL) || this;
71
- }
72
- EtherscanInfoClient.prototype.fetchTransactions = function (protocol, address, limit, cursor) {
73
- return __awaiter(this, void 0, void 0, function () {
74
- var airGapTransactions, url, response, transactionResponse, transactions, _i, transactions_1, transaction, fee, airGapTransaction;
75
- var _a;
76
- return __generator(this, function (_b) {
77
- switch (_b.label) {
78
- case 0:
79
- airGapTransactions = [];
80
- url = cursor
81
- ? "".concat(this.baseURL, "/api?module=account&action=txlist&address=").concat(address, "&page=").concat(cursor.page, "&offset=").concat(limit, "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7")
82
- : "".concat(this.baseURL, "/api?module=account&action=txlist&address=").concat(address, "&page=1&offset=").concat(limit, "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7");
83
- return [4 /*yield*/, axios_0_19_0_1.default.get(url)];
84
- case 1:
85
- response = _b.sent();
86
- transactionResponse = response.data;
87
- transactions = transactionResponse.result;
88
- if (transactionResponse.status === '0' && (transactions === undefined || !(0, validate_1.isArray)(transactions))) {
89
- throw new errors_1.NetworkError(coinlib_error_1.Domain.ETHEREUM, { response: response });
90
- }
91
- _i = 0, transactions_1 = transactions;
92
- _b.label = 2;
93
- case 2:
94
- if (!(_i < transactions_1.length)) return [3 /*break*/, 6];
95
- transaction = transactions_1[_i];
96
- fee = new bignumber_1.BigNumber(transaction.gas).times(new bignumber_1.BigNumber(transaction.gasPrice));
97
- _a = {
98
- hash: transaction.hash,
99
- from: [transaction.from],
100
- to: [transaction.to],
101
- isInbound: transaction.to.toLowerCase() === address.toLowerCase(),
102
- amount: new bignumber_1.BigNumber(transaction.value).toString(10),
103
- fee: fee.toString(10),
104
- blockHeight: transaction.blockNumber
105
- };
106
- return [4 /*yield*/, protocol.getIdentifier()];
107
- case 3:
108
- _a.protocolIdentifier = _b.sent();
109
- return [4 /*yield*/, protocol.getOptions()];
110
- case 4:
111
- airGapTransaction = (_a.network = (_b.sent()).network,
112
- _a.timestamp = parseInt(transaction.timeStamp, 10),
113
- _a.status = transaction.txreceipt_status === undefined || transaction.txreceipt_status === '1'
114
- ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED
115
- : IAirGapTransaction_1.AirGapTransactionStatus.FAILED,
116
- _a);
117
- airGapTransactions.push(airGapTransaction);
118
- _b.label = 5;
119
- case 5:
120
- _i++;
121
- return [3 /*break*/, 2];
122
- case 6: return [2 /*return*/, {
123
- transactions: airGapTransactions,
124
- cursor: {
125
- page: cursor ? cursor.page + 1 : 2
126
- }
127
- }];
128
- }
129
- });
130
- });
131
- };
132
- EtherscanInfoClient.prototype.fetchContractTransactions = function (protocol, contractAddress, address, limit, cursor) {
133
- return __awaiter(this, void 0, void 0, function () {
134
- var airGapTransactions, url, response, transactionResponse, transactions, _i, transactions_2, transaction, fee, airGapTransaction;
135
- var _a;
136
- return __generator(this, function (_b) {
137
- switch (_b.label) {
138
- case 0:
139
- airGapTransactions = [];
140
- url = cursor
141
- ? "".concat(this.baseURL, "/api?module=account&action=tokentx&address=").concat(address, "&contractAddress=").concat(contractAddress, "&page=").concat(cursor.page, "&offset=").concat(limit, "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7")
142
- : "".concat(this.baseURL, "/api?module=account&action=tokentx&address=").concat(address, "&contractAddress=").concat(contractAddress, "&page=1&offset=").concat(limit, "&sort=desc&apiKey=P63MEHEYBM5BGEG5WFN76VPNCET8B2MAP7");
143
- return [4 /*yield*/, axios_0_19_0_1.default.get(url)];
144
- case 1:
145
- response = _b.sent();
146
- transactionResponse = response.data;
147
- transactions = transactionResponse.result;
148
- if (transactionResponse.status === '0' && (transactions === undefined || !(0, validate_1.isArray)(transactions))) {
149
- throw new errors_1.NetworkError(coinlib_error_1.Domain.ETHEREUM, { response: response });
150
- }
151
- _i = 0, transactions_2 = transactions;
152
- _b.label = 2;
153
- case 2:
154
- if (!(_i < transactions_2.length)) return [3 /*break*/, 6];
155
- transaction = transactions_2[_i];
156
- fee = new bignumber_1.BigNumber(transaction.gas).times(new bignumber_1.BigNumber(transaction.gasPrice));
157
- _a = {
158
- hash: transaction.hash,
159
- from: [transaction.from],
160
- to: [transaction.to],
161
- isInbound: transaction.to.toLowerCase() === address.toLowerCase(),
162
- blockHeight: transaction.blockNumber
163
- };
164
- return [4 /*yield*/, protocol.getIdentifier()];
165
- case 3:
166
- _a.protocolIdentifier = _b.sent();
167
- return [4 /*yield*/, protocol.getOptions()];
168
- case 4:
169
- airGapTransaction = (_a.network = (_b.sent()).network,
170
- _a.amount = new bignumber_1.BigNumber(transaction.value).toString(10),
171
- _a.fee = fee.toString(10),
172
- _a.timestamp = parseInt(transaction.timeStamp, 10),
173
- _a.status = transaction.txreceipt_status === undefined || transaction.txreceipt_status === '1'
174
- ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED
175
- : IAirGapTransaction_1.AirGapTransactionStatus.FAILED,
176
- _a);
177
- airGapTransactions.push(airGapTransaction);
178
- _b.label = 5;
179
- case 5:
180
- _i++;
181
- return [3 /*break*/, 2];
182
- case 6: return [2 /*return*/, {
183
- transactions: airGapTransactions,
184
- cursor: {
185
- page: cursor ? cursor.page + 1 : 2
186
- }
187
- }];
188
- }
189
- });
190
- });
191
- };
192
- return EtherscanInfoClient;
193
- }(InfoClient_1.EthereumInfoClient));
194
- exports.EtherscanInfoClient = EtherscanInfoClient;
195
- //# sourceMappingURL=EtherscanInfoClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"EtherscanInfoClient.js","sourceRoot":"","sources":["../../../../../src/v0/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,UAAkB,4CAAkB;eAC9C,kBAAM,OAAO,CAAC;IAChB,CAAC;IAEY,+CAAiB,GAA9B,UACE,QAA0B,EAC1B,OAAe,EACf,KAAU,EACV,MAAkC;;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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"}
@@ -1,8 +0,0 @@
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
- }
@@ -1,11 +0,0 @@
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
@@ -1 +0,0 @@
1
- {"version":3,"file":"InfoClient.js","sourceRoot":"","sources":["../../../../../src/v0/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"}
@@ -1,41 +0,0 @@
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
- }
@@ -1,353 +0,0 @@
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
- if (typeof b !== "function" && b !== null)
11
- throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
- extendStatics(d, b);
13
- function __() { this.constructor = d; }
14
- d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
- };
16
- })();
17
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
- return new (P || (P = Promise))(function (resolve, reject) {
20
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
- step((generator = generator.apply(thisArg, _arguments || [])).next());
24
- });
25
- };
26
- var __generator = (this && this.__generator) || function (thisArg, body) {
27
- var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
- return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
- function verb(n) { return function (v) { return step([n, v]); }; }
30
- function step(op) {
31
- if (f) throw new TypeError("Generator is already executing.");
32
- while (_) try {
33
- 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;
34
- if (y = 0, t) op = [op[0] & 2, t.value];
35
- switch (op[0]) {
36
- case 0: case 1: t = op; break;
37
- case 4: _.label++; return { value: op[1], done: false };
38
- case 5: _.label++; y = op[1]; op = [0]; continue;
39
- case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
- default:
41
- if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
- if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
- if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
- if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
- if (t[2]) _.ops.pop();
46
- _.trys.pop(); continue;
47
- }
48
- op = body.call(thisArg, _);
49
- } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
- if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
- }
52
- };
53
- var __importDefault = (this && this.__importDefault) || function (mod) {
54
- return (mod && mod.__esModule) ? mod : { "default": mod };
55
- };
56
- Object.defineProperty(exports, "__esModule", { value: true });
57
- exports.AirGapNodeClient = exports.EthereumRPCDataTransfer = exports.EthereumRPCDataBalanceOf = exports.EthereumRPCData = void 0;
58
- var RPCBody_1 = require("@airgap/coinlib-core/data/RPCBody");
59
- var axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
60
- var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
61
- var errors_1 = require("@airgap/coinlib-core/errors");
62
- var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
63
- var IAirGapTransaction_1 = require("@airgap/coinlib-core/interfaces/IAirGapTransaction");
64
- var EthereumProtocolOptions_1 = require("../../EthereumProtocolOptions");
65
- var utils_1 = require("../../utils/utils");
66
- var NodeClient_1 = require("./NodeClient");
67
- var EthereumRPCBody = /** @class */ (function (_super) {
68
- __extends(EthereumRPCBody, _super);
69
- function EthereumRPCBody() {
70
- return _super !== null && _super.apply(this, arguments) || this;
71
- }
72
- EthereumRPCBody.prototype.toRPCBody = function () {
73
- return JSON.stringify(this.toJSON());
74
- };
75
- EthereumRPCBody.prototype.toJSON = function () {
76
- return {
77
- jsonrpc: this.jsonrpc,
78
- method: this.method,
79
- params: this.params,
80
- id: this.id
81
- };
82
- };
83
- EthereumRPCBody.blockEarliest = 'earliest';
84
- EthereumRPCBody.blockLatest = 'latest';
85
- EthereumRPCBody.blockPending = 'pending';
86
- return EthereumRPCBody;
87
- }(RPCBody_1.RPCBody));
88
- var EthereumRPCData = /** @class */ (function () {
89
- function EthereumRPCData(methodSignature) {
90
- this.methodSignature = methodSignature;
91
- }
92
- EthereumRPCData.prototype.abiEncoded = function () {
93
- var hash = utils_1.EthereumUtils.sha3(this.methodSignature);
94
- if (hash === null) {
95
- return '';
96
- }
97
- return "0x".concat(hash.slice(2, 10));
98
- };
99
- EthereumRPCData.addLeadingZeroPadding = function (value, targetLength) {
100
- if (targetLength === void 0) { targetLength = EthereumRPCData.parametersLength; }
101
- var result = value;
102
- while (result.length < targetLength) {
103
- result = '0' + result;
104
- }
105
- return result;
106
- };
107
- EthereumRPCData.removeLeadingZeroPadding = function (value) {
108
- var result = value;
109
- while (result.startsWith('0')) {
110
- result = result.slice(1); // this can probably be done much more efficiently with a regex
111
- }
112
- return result;
113
- };
114
- // 2 chars = 1 byte hence to get to 32 bytes we need 64 chars
115
- EthereumRPCData.parametersLength = 64;
116
- return EthereumRPCData;
117
- }());
118
- exports.EthereumRPCData = EthereumRPCData;
119
- var EthereumRPCDataBalanceOf = /** @class */ (function (_super) {
120
- __extends(EthereumRPCDataBalanceOf, _super);
121
- function EthereumRPCDataBalanceOf(address) {
122
- var _this = _super.call(this, "".concat(EthereumRPCDataBalanceOf.methodName, "(address)")) || this;
123
- _this.address = address;
124
- return _this;
125
- }
126
- EthereumRPCDataBalanceOf.prototype.abiEncoded = function () {
127
- var srcAddress = this.address;
128
- if (srcAddress.startsWith('0x')) {
129
- srcAddress = srcAddress.slice(2);
130
- }
131
- return _super.prototype.abiEncoded.call(this) + EthereumRPCData.addLeadingZeroPadding(srcAddress);
132
- };
133
- EthereumRPCDataBalanceOf.methodName = 'balanceOf';
134
- return EthereumRPCDataBalanceOf;
135
- }(EthereumRPCData));
136
- exports.EthereumRPCDataBalanceOf = EthereumRPCDataBalanceOf;
137
- var EthereumRPCDataTransfer = /** @class */ (function (_super) {
138
- __extends(EthereumRPCDataTransfer, _super);
139
- function EthereumRPCDataTransfer(toAddressOrData, amount) {
140
- var _this = _super.call(this, "".concat(EthereumRPCDataTransfer.methodName, "(address,uint256)")) || this;
141
- if (amount) {
142
- var toAddress = toAddressOrData;
143
- _this.recipient = toAddress;
144
- _this.amount = amount;
145
- }
146
- else {
147
- var data = toAddressOrData;
148
- var methodID = _super.prototype.abiEncoded.call(_this);
149
- if (!data.startsWith(methodID)) {
150
- throw new errors_1.InvalidValueError(coinlib_error_1.Domain.ETHEREUM, 'unexpected method ID');
151
- }
152
- var params = data.slice(methodID.length);
153
- var recipient = EthereumRPCData.removeLeadingZeroPadding(params.slice(0, EthereumRPCData.parametersLength));
154
- var parsedAmount = EthereumRPCData.removeLeadingZeroPadding(params.slice(EthereumRPCData.parametersLength));
155
- _this.recipient = "0x".concat(recipient);
156
- _this.amount = "0x".concat(parsedAmount);
157
- }
158
- return _this;
159
- }
160
- EthereumRPCDataTransfer.prototype.abiEncoded = function () {
161
- var dstAddress = this.recipient;
162
- if (dstAddress.startsWith('0x')) {
163
- dstAddress = dstAddress.slice(2);
164
- }
165
- var transferAmount = this.amount;
166
- if (transferAmount.startsWith('0x')) {
167
- transferAmount = transferAmount.slice(2);
168
- }
169
- return (_super.prototype.abiEncoded.call(this) +
170
- EthereumRPCData.addLeadingZeroPadding(dstAddress.toLowerCase()) +
171
- EthereumRPCData.addLeadingZeroPadding(transferAmount.toLowerCase()));
172
- };
173
- EthereumRPCDataTransfer.methodName = 'transfer';
174
- return EthereumRPCDataTransfer;
175
- }(EthereumRPCData));
176
- exports.EthereumRPCDataTransfer = EthereumRPCDataTransfer;
177
- var AirGapNodeClient = /** @class */ (function (_super) {
178
- __extends(AirGapNodeClient, _super);
179
- function AirGapNodeClient(baseURL) {
180
- if (baseURL === void 0) { baseURL = EthereumProtocolOptions_1.NODE_URL; }
181
- return _super.call(this, baseURL) || this;
182
- }
183
- AirGapNodeClient.prototype.fetchBalance = function (address) {
184
- return __awaiter(this, void 0, void 0, function () {
185
- var body, response;
186
- return __generator(this, function (_a) {
187
- switch (_a.label) {
188
- case 0:
189
- body = new EthereumRPCBody('eth_getBalance', [address, EthereumRPCBody.blockLatest]);
190
- return [4 /*yield*/, this.send(body)];
191
- case 1:
192
- response = _a.sent();
193
- return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
194
- }
195
- });
196
- });
197
- };
198
- AirGapNodeClient.prototype.fetchTransactionCount = function (address) {
199
- return __awaiter(this, void 0, void 0, function () {
200
- var body, response;
201
- return __generator(this, function (_a) {
202
- switch (_a.label) {
203
- case 0:
204
- body = new EthereumRPCBody('eth_getTransactionCount', [address, EthereumRPCBody.blockLatest]);
205
- return [4 /*yield*/, this.send(body)];
206
- case 1:
207
- response = _a.sent();
208
- return [2 /*return*/, new bignumber_1.BigNumber(response.result).toNumber()];
209
- }
210
- });
211
- });
212
- };
213
- AirGapNodeClient.prototype.sendSignedTransaction = function (transaction) {
214
- return __awaiter(this, void 0, void 0, function () {
215
- var body;
216
- return __generator(this, function (_a) {
217
- switch (_a.label) {
218
- case 0:
219
- body = new EthereumRPCBody('eth_sendRawTransaction', [transaction]);
220
- return [4 /*yield*/, this.send(body)];
221
- case 1: return [2 /*return*/, (_a.sent()).result];
222
- }
223
- });
224
- });
225
- };
226
- AirGapNodeClient.prototype.getTransactionStatus = function (transactionHash) {
227
- return __awaiter(this, void 0, void 0, function () {
228
- var body, response;
229
- return __generator(this, function (_a) {
230
- switch (_a.label) {
231
- case 0:
232
- body = new EthereumRPCBody('eth_getTransactionReceipt', [transactionHash]);
233
- return [4 /*yield*/, this.send(body)];
234
- case 1:
235
- response = _a.sent();
236
- return [2 /*return*/, response.result.status === '0x1' ? IAirGapTransaction_1.AirGapTransactionStatus.APPLIED : IAirGapTransaction_1.AirGapTransactionStatus.FAILED];
237
- }
238
- });
239
- });
240
- };
241
- AirGapNodeClient.prototype.callBalanceOf = function (contractAddress, address) {
242
- return __awaiter(this, void 0, void 0, function () {
243
- var body, response;
244
- return __generator(this, function (_a) {
245
- switch (_a.label) {
246
- case 0:
247
- body = this.balanceOfBody(contractAddress, address);
248
- return [4 /*yield*/, this.send(body)];
249
- case 1:
250
- response = _a.sent();
251
- return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
252
- }
253
- });
254
- });
255
- };
256
- AirGapNodeClient.prototype.callBalanceOfOnContracts = function (contractAddresses, address) {
257
- return __awaiter(this, void 0, void 0, function () {
258
- var bodies, responses, result;
259
- var _this = this;
260
- return __generator(this, function (_a) {
261
- switch (_a.label) {
262
- case 0:
263
- bodies = contractAddresses.map(function (contractAddress, index) { return _this.balanceOfBody(contractAddress, address, index); });
264
- return [4 /*yield*/, this.batchSend(bodies)];
265
- case 1:
266
- responses = _a.sent();
267
- result = {};
268
- responses.forEach(function (response) {
269
- var _a;
270
- result[contractAddresses[response.id]] = new bignumber_1.BigNumber((_a = response.result) !== null && _a !== void 0 ? _a : 0);
271
- });
272
- return [2 /*return*/, result];
273
- }
274
- });
275
- });
276
- };
277
- AirGapNodeClient.prototype.balanceOfBody = function (contractAddress, address, id) {
278
- if (id === void 0) { id = 0; }
279
- var data = new EthereumRPCDataBalanceOf(address);
280
- return new EthereumRPCBody('eth_call', [{ to: contractAddress, data: data.abiEncoded() }, EthereumRPCBody.blockLatest], id);
281
- };
282
- AirGapNodeClient.prototype.estimateTransactionGas = function (fromAddress, toAddress, amount, data, gas) {
283
- return __awaiter(this, void 0, void 0, function () {
284
- var body, response;
285
- return __generator(this, function (_a) {
286
- switch (_a.label) {
287
- case 0:
288
- body = new EthereumRPCBody('eth_estimateGas', [{ from: fromAddress, to: toAddress, gas: gas, value: amount, data: data }]);
289
- return [4 /*yield*/, this.send(body)];
290
- case 1:
291
- response = _a.sent();
292
- return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
293
- }
294
- });
295
- });
296
- };
297
- AirGapNodeClient.prototype.estimateTransferGas = function (contractAddress, fromAddress, toAddress, hexAmount) {
298
- return __awaiter(this, void 0, void 0, function () {
299
- var data, result;
300
- return __generator(this, function (_a) {
301
- data = new EthereumRPCDataTransfer(toAddress, hexAmount);
302
- result = this.estimateTransactionGas(fromAddress, contractAddress, undefined, data.abiEncoded());
303
- return [2 /*return*/, result];
304
- });
305
- });
306
- };
307
- AirGapNodeClient.prototype.getGasPrice = function () {
308
- return __awaiter(this, void 0, void 0, function () {
309
- var body, response;
310
- return __generator(this, function (_a) {
311
- switch (_a.label) {
312
- case 0:
313
- body = new EthereumRPCBody('eth_gasPrice', []);
314
- return [4 /*yield*/, this.send(body)];
315
- case 1:
316
- response = _a.sent();
317
- return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
318
- }
319
- });
320
- });
321
- };
322
- AirGapNodeClient.prototype.send = function (body) {
323
- return __awaiter(this, void 0, void 0, function () {
324
- var response;
325
- return __generator(this, function (_a) {
326
- switch (_a.label) {
327
- case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.baseURL, body.toRPCBody()).catch(function (error) {
328
- throw new errors_1.NetworkError(coinlib_error_1.Domain.ETHEREUM, error);
329
- })];
330
- case 1:
331
- response = _a.sent();
332
- return [2 /*return*/, response.data];
333
- }
334
- });
335
- });
336
- };
337
- AirGapNodeClient.prototype.batchSend = function (bodies) {
338
- return __awaiter(this, void 0, void 0, function () {
339
- var data;
340
- return __generator(this, function (_a) {
341
- switch (_a.label) {
342
- case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.baseURL, JSON.stringify(bodies.map(function (body) { return body.toJSON(); })))];
343
- case 1:
344
- data = (_a.sent()).data;
345
- return [2 /*return*/, data];
346
- }
347
- });
348
- });
349
- };
350
- return AirGapNodeClient;
351
- }(NodeClient_1.EthereumNodeClient));
352
- exports.AirGapNodeClient = AirGapNodeClient;
353
- //# sourceMappingURL=AirGapNodeClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AirGapNodeClient.js","sourceRoot":"","sources":["../../../../../src/v0/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,GAAW,UAAU,CAAA;IAClC,2BAAW,GAAW,QAAQ,CAAA;IAC9B,4BAAY,GAAW,SAAS,CAAA;IAchD,sBAAC;CAAA,AAjBD,CAA8B,iBAAO,GAiBpC;AAYD;IAKE,yBAAY,eAAuB;QACjC,IAAI,CAAC,eAAe,GAAG,eAAe,CAAA;IACxC,CAAC;IAEM,oCAAU,GAAjB;QACE,IAAM,IAAI,GAAG,qBAAa,CAAC,IAAI,CAAC,IAAI,CAAC,eAAe,CAAC,CAAA;QACrD,IAAI,IAAI,KAAK,IAAI,EAAE;YACjB,OAAO,EAAE,CAAA;SACV;QAED,OAAO,YAAK,IAAI,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,CAAE,CAAA;IACjC,CAAC;IAEa,qCAAqB,GA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