@airgap/ethereum 0.13.15-beta.1 → 0.13.15-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.
- package/index.d.ts +1 -1
- package/index.js +1 -1
- package/package.json +5 -5
- package/v1/block-explorer/EtherscanBlockExplorer.d.ts +1 -1
- package/v1/block-explorer/EtherscanBlockExplorer.js +2 -0
- package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -1
- package/v1/clients/node/AirGapNodeClient.js +1 -1
- package/v1/clients/node/AirGapNodeClient.js.map +1 -1
- package/v1/index.d.ts +11 -4
- package/v1/index.js +18 -3
- package/v1/index.js.map +1 -1
- package/v1/module/EthereumModule.d.ts +3 -6
- package/v1/module/EthereumModule.js +8 -10
- package/v1/module/EthereumModule.js.map +1 -1
- package/v1/protocol/EthereumBaseProtocol.d.ts +4 -4
- package/v1/protocol/EthereumBaseProtocol.js +1 -1
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumProtocol.d.ts +2 -4
- package/v1/protocol/EthereumProtocol.js +0 -59
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Protocol.d.ts +26 -0
- package/v1/protocol/erc20/ERC20Protocol.js +376 -0
- package/v1/protocol/erc20/ERC20Protocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Token.d.ts +4 -4
- package/v1/protocol/erc20/ERC20Token.js +6 -304
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +1 -5
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +1 -5
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +50 -42
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/types/protocol.d.ts +4 -3
|
@@ -25,29 +25,6 @@ var __assign = (this && this.__assign) || function () {
|
|
|
25
25
|
};
|
|
26
26
|
return __assign.apply(this, arguments);
|
|
27
27
|
};
|
|
28
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
29
|
-
if (k2 === undefined) k2 = k;
|
|
30
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
31
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
32
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
33
|
-
}
|
|
34
|
-
Object.defineProperty(o, k2, desc);
|
|
35
|
-
}) : (function(o, m, k, k2) {
|
|
36
|
-
if (k2 === undefined) k2 = k;
|
|
37
|
-
o[k2] = m[k];
|
|
38
|
-
}));
|
|
39
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
40
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
41
|
-
}) : function(o, v) {
|
|
42
|
-
o["default"] = v;
|
|
43
|
-
});
|
|
44
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
45
|
-
if (mod && mod.__esModule) return mod;
|
|
46
|
-
var result = {};
|
|
47
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
48
|
-
__setModuleDefault(result, mod);
|
|
49
|
-
return result;
|
|
50
|
-
};
|
|
51
28
|
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
52
29
|
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
53
30
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
@@ -84,38 +61,18 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
|
84
61
|
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
85
62
|
}
|
|
86
63
|
};
|
|
87
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
88
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
89
|
-
};
|
|
90
64
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
91
65
|
exports.createERC20TokenOptions = exports.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK = exports.createERC20Token = void 0;
|
|
92
66
|
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
93
|
-
var bignumber_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber"));
|
|
94
|
-
// @ts-ignore
|
|
95
|
-
var ethUtil = __importStar(require("@airgap/coinlib-core/dependencies/src/ethereumjs-util-5.2.0"));
|
|
96
|
-
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
97
|
-
var hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
98
|
-
var module_kit_1 = require("@airgap/module-kit");
|
|
99
|
-
var tx_1 = require("@ethereumjs/tx");
|
|
100
67
|
var EtherscanInfoClient_1 = require("../../clients/info/EtherscanInfoClient");
|
|
101
68
|
var AirGapNodeClient_1 = require("../../clients/node/AirGapNodeClient");
|
|
102
|
-
var EthereumUtils_1 = require("../../utils/EthereumUtils");
|
|
103
|
-
var EthereumBaseProtocol_1 = require("../EthereumBaseProtocol");
|
|
104
69
|
var EthereumProtocol_1 = require("../EthereumProtocol");
|
|
105
|
-
var
|
|
70
|
+
var ERC20Protocol_1 = require("./ERC20Protocol");
|
|
106
71
|
// Implementation
|
|
107
72
|
var ERC20TokenImpl = /** @class */ (function (_super) {
|
|
108
73
|
__extends(ERC20TokenImpl, _super);
|
|
109
|
-
function ERC20TokenImpl(
|
|
110
|
-
|
|
111
|
-
network: options.network,
|
|
112
|
-
name: options.name,
|
|
113
|
-
identifier: options.identifier,
|
|
114
|
-
units: options.units,
|
|
115
|
-
mainUnit: options.mainUnit
|
|
116
|
-
}) || this;
|
|
117
|
-
_this.contractAddress = options.contractAddress;
|
|
118
|
-
return _this;
|
|
74
|
+
function ERC20TokenImpl() {
|
|
75
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
119
76
|
}
|
|
120
77
|
// SubProtocol
|
|
121
78
|
ERC20TokenImpl.prototype.getType = function () {
|
|
@@ -139,267 +96,12 @@ var ERC20TokenImpl = /** @class */ (function (_super) {
|
|
|
139
96
|
});
|
|
140
97
|
});
|
|
141
98
|
};
|
|
142
|
-
// Common
|
|
143
|
-
ERC20TokenImpl.prototype.getDetailsFromTransaction = function (transaction, publicKey) {
|
|
144
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
145
|
-
var ethTransactionDetails;
|
|
146
|
-
return __generator(this, function (_a) {
|
|
147
|
-
switch (_a.label) {
|
|
148
|
-
case 0: return [4 /*yield*/, _super.prototype.getDetailsFromTransaction.call(this, transaction, publicKey)];
|
|
149
|
-
case 1:
|
|
150
|
-
ethTransactionDetails = _a.sent();
|
|
151
|
-
switch (transaction.type) {
|
|
152
|
-
case 'signed':
|
|
153
|
-
return [2 /*return*/, this.getDetailsFromSignedContractTransaction(transaction, ethTransactionDetails)];
|
|
154
|
-
case 'unsigned':
|
|
155
|
-
return [2 /*return*/, this.getDetailsFromUnsignedContractTransaction(transaction, ethTransactionDetails)];
|
|
156
|
-
default:
|
|
157
|
-
(0, coinlib_core_1.assertNever)(transaction);
|
|
158
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, 'Unsupported transaction type.');
|
|
159
|
-
}
|
|
160
|
-
return [2 /*return*/];
|
|
161
|
-
}
|
|
162
|
-
});
|
|
163
|
-
});
|
|
164
|
-
};
|
|
165
|
-
ERC20TokenImpl.prototype.getDetailsFromSignedContractTransaction = function (transaction, ethTransactionDetails) {
|
|
166
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
167
|
-
var extractedTx, tokenTransferDetails;
|
|
168
|
-
return __generator(this, function (_a) {
|
|
169
|
-
if (ethTransactionDetails.length !== 1) {
|
|
170
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ERC20, 'More than one ETH transaction detected.');
|
|
171
|
-
}
|
|
172
|
-
extractedTx = new EthereumTransaction(transaction.serialized);
|
|
173
|
-
tokenTransferDetails = new AirGapNodeClient_1.EthereumRPCDataTransfer("0x".concat(extractedTx.data.toString('hex')));
|
|
174
|
-
return [2 /*return*/, [
|
|
175
|
-
__assign(__assign({}, ethTransactionDetails[0]), { to: [ethUtil.toChecksumAddress(tokenTransferDetails.recipient)], amount: (0, module_kit_1.newAmount)(tokenTransferDetails.amount, 'blockchain') })
|
|
176
|
-
]];
|
|
177
|
-
});
|
|
178
|
-
});
|
|
179
|
-
};
|
|
180
|
-
ERC20TokenImpl.prototype.getDetailsFromUnsignedContractTransaction = function (transaction, ethTransactionDetails) {
|
|
181
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
182
|
-
var data, typedTransaction, tokenTransferDetails;
|
|
183
|
-
return __generator(this, function (_a) {
|
|
184
|
-
if (ethTransactionDetails.length !== 1) {
|
|
185
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ERC20, 'More than one ETH transaction detected.');
|
|
186
|
-
}
|
|
187
|
-
if (transaction.ethereumType === 'raw') {
|
|
188
|
-
data = transaction.data;
|
|
189
|
-
}
|
|
190
|
-
else {
|
|
191
|
-
typedTransaction = tx_1.TransactionFactory.fromSerializedData(Buffer.from(transaction.serialized, 'hex'));
|
|
192
|
-
data = typedTransaction.data.toString('hex');
|
|
193
|
-
}
|
|
194
|
-
tokenTransferDetails = new AirGapNodeClient_1.EthereumRPCDataTransfer(data);
|
|
195
|
-
return [2 /*return*/, [
|
|
196
|
-
__assign(__assign({}, ethTransactionDetails[0]), { to: [ethUtil.toChecksumAddress(tokenTransferDetails.recipient)], amount: (0, module_kit_1.newAmount)(tokenTransferDetails.amount, 'blockchain') })
|
|
197
|
-
]];
|
|
198
|
-
});
|
|
199
|
-
});
|
|
200
|
-
};
|
|
201
|
-
// Offline
|
|
202
|
-
ERC20TokenImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
203
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
204
|
-
var rawTransaction;
|
|
205
|
-
return __generator(this, function (_a) {
|
|
206
|
-
if (transaction.ethereumType !== 'raw') {
|
|
207
|
-
// no v0 implementation
|
|
208
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ERC20, 'Unsupported unsigned transaction type.');
|
|
209
|
-
}
|
|
210
|
-
rawTransaction = __assign(__assign({}, transaction), { data: !transaction.data || transaction.data === '0x'
|
|
211
|
-
? new AirGapNodeClient_1.EthereumRPCDataTransfer(transaction.to, transaction.value).abiEncoded()
|
|
212
|
-
: transaction.data });
|
|
213
|
-
return [2 /*return*/, _super.prototype.signTransactionWithSecretKey.call(this, rawTransaction, secretKey)];
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
|
-
};
|
|
217
|
-
// Online
|
|
218
|
-
ERC20TokenImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
219
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
220
|
-
var address;
|
|
221
|
-
return __generator(this, function (_a) {
|
|
222
|
-
switch (_a.label) {
|
|
223
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
224
|
-
case 1:
|
|
225
|
-
address = _a.sent();
|
|
226
|
-
return [2 /*return*/, this.getTransactionsForAddress(address, limit, cursor)];
|
|
227
|
-
}
|
|
228
|
-
});
|
|
229
|
-
});
|
|
230
|
-
};
|
|
231
|
-
ERC20TokenImpl.prototype.getTransactionsForAddress = function (address, limit, cursor) {
|
|
232
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
233
|
-
return __generator(this, function (_a) {
|
|
234
|
-
return [2 /*return*/, this.getTransactionsForAddresses([address], limit, cursor)];
|
|
235
|
-
});
|
|
236
|
-
});
|
|
237
|
-
};
|
|
238
|
-
ERC20TokenImpl.prototype.getTransactionsForAddresses = function (addresses, limit, cursor) {
|
|
239
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
240
|
-
var _this = this;
|
|
241
|
-
return __generator(this, function (_a) {
|
|
242
|
-
return [2 /*return*/, new Promise(function (overallResolve, overallReject) {
|
|
243
|
-
var promises = [];
|
|
244
|
-
for (var _i = 0, addresses_1 = addresses; _i < addresses_1.length; _i++) {
|
|
245
|
-
var address = addresses_1[_i];
|
|
246
|
-
promises.push(_this.infoClient.fetchContractTransactions(_this.contractAddress, address, limit, cursor));
|
|
247
|
-
}
|
|
248
|
-
Promise.all(promises)
|
|
249
|
-
.then(function (values) {
|
|
250
|
-
var page = Math.max.apply(Math, values.map(function (txResult) { return txResult.cursor.page; }));
|
|
251
|
-
var transactions = values.reduce(function (acc, current) {
|
|
252
|
-
return acc.concat(current.transactions.map(function (tx) { return (__assign(__assign({}, tx), { amount: (0, module_kit_1.newAmount)(tx.amount.value, 'blockchain'), fee: (0, module_kit_1.newAmount)(tx.fee.value, 'blockchain'), network: _this.options.network })); }));
|
|
253
|
-
}, []);
|
|
254
|
-
var hasNext = transactions.length >= limit;
|
|
255
|
-
overallResolve({
|
|
256
|
-
transactions: transactions,
|
|
257
|
-
cursor: {
|
|
258
|
-
hasNext: hasNext,
|
|
259
|
-
page: hasNext ? page : undefined
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
})
|
|
263
|
-
.catch(overallReject);
|
|
264
|
-
})];
|
|
265
|
-
});
|
|
266
|
-
});
|
|
267
|
-
};
|
|
268
|
-
ERC20TokenImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
269
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
270
|
-
var address;
|
|
271
|
-
return __generator(this, function (_a) {
|
|
272
|
-
switch (_a.label) {
|
|
273
|
-
case 0: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
274
|
-
case 1:
|
|
275
|
-
address = _a.sent();
|
|
276
|
-
return [2 /*return*/, this.getBalanceOfAddress(address)];
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
};
|
|
281
|
-
ERC20TokenImpl.prototype.getBalanceOfAddress = function (address) {
|
|
282
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
283
|
-
return __generator(this, function (_a) {
|
|
284
|
-
return [2 /*return*/, this.getBalanceOfAddresses([address])];
|
|
285
|
-
});
|
|
286
|
-
});
|
|
287
|
-
};
|
|
288
|
-
ERC20TokenImpl.prototype.getBalanceOfAddresses = function (addresses) {
|
|
289
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
290
|
-
var balances, totalBalance;
|
|
291
|
-
var _this = this;
|
|
292
|
-
return __generator(this, function (_a) {
|
|
293
|
-
switch (_a.label) {
|
|
294
|
-
case 0: return [4 /*yield*/, Promise.all(addresses.map(function (address) {
|
|
295
|
-
return _this.nodeClient.callBalanceOf(_this.contractAddress, address);
|
|
296
|
-
}))];
|
|
297
|
-
case 1:
|
|
298
|
-
balances = _a.sent();
|
|
299
|
-
totalBalance = balances.reduce(function (a, b) { return a.plus(b); });
|
|
300
|
-
return [2 /*return*/, { total: (0, module_kit_1.newAmount)(totalBalance, 'blockchain') }];
|
|
301
|
-
}
|
|
302
|
-
});
|
|
303
|
-
});
|
|
304
|
-
};
|
|
305
|
-
ERC20TokenImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
306
|
-
var _a;
|
|
307
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
308
|
-
var balance;
|
|
309
|
-
return __generator(this, function (_b) {
|
|
310
|
-
switch (_b.label) {
|
|
311
|
-
case 0: return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
312
|
-
case 1:
|
|
313
|
-
balance = _b.sent();
|
|
314
|
-
return [2 /*return*/, (_a = balance.transferable) !== null && _a !== void 0 ? _a : balance.total];
|
|
315
|
-
}
|
|
316
|
-
});
|
|
317
|
-
});
|
|
318
|
-
};
|
|
319
|
-
ERC20TokenImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
320
|
-
var _a;
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
-
var fee, estimatedFee, wrappedFee, wrappedAmount, balance, wrappedBalance, address, ethBalance, wrappedEthBalance, estimatedGas, txCount, gasPrice, transaction;
|
|
323
|
-
return __generator(this, function (_b) {
|
|
324
|
-
switch (_b.label) {
|
|
325
|
-
case 0:
|
|
326
|
-
if (details.length !== 1) {
|
|
327
|
-
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ETHEREUM, 'you cannot have 0 transaction details');
|
|
328
|
-
}
|
|
329
|
-
if (!((configuration === null || configuration === void 0 ? void 0 : configuration.fee) !== undefined)) return [3 /*break*/, 1];
|
|
330
|
-
fee = configuration.fee;
|
|
331
|
-
return [3 /*break*/, 3];
|
|
332
|
-
case 1: return [4 /*yield*/, this.getTransactionFeeWithPublicKey(publicKey, details)];
|
|
333
|
-
case 2:
|
|
334
|
-
estimatedFee = _b.sent();
|
|
335
|
-
fee = estimatedFee.medium;
|
|
336
|
-
_b.label = 3;
|
|
337
|
-
case 3:
|
|
338
|
-
wrappedFee = new bignumber_1.default((0, module_kit_1.newAmount)(fee).blockchain(this.feeUnits).value);
|
|
339
|
-
wrappedAmount = new bignumber_1.default((0, module_kit_1.newAmount)(details[0].amount).blockchain(this.units).value);
|
|
340
|
-
return [4 /*yield*/, this.getBalanceOfPublicKey(publicKey)];
|
|
341
|
-
case 4:
|
|
342
|
-
balance = _b.sent();
|
|
343
|
-
wrappedBalance = new bignumber_1.default((0, module_kit_1.newAmount)((_a = balance.transferable) !== null && _a !== void 0 ? _a : balance.total).blockchain(this.units).value);
|
|
344
|
-
if (!wrappedBalance.isGreaterThanOrEqualTo(wrappedAmount)) return [3 /*break*/, 11];
|
|
345
|
-
return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
|
|
346
|
-
case 5:
|
|
347
|
-
address = _b.sent();
|
|
348
|
-
return [4 /*yield*/, _super.prototype.getBalanceOfAddress.call(this, address)];
|
|
349
|
-
case 6:
|
|
350
|
-
ethBalance = _b.sent();
|
|
351
|
-
wrappedEthBalance = new bignumber_1.default((0, module_kit_1.newAmount)(ethBalance.total).blockchain(this.units).value);
|
|
352
|
-
return [4 /*yield*/, this.estimateGas(address, details[0].to, wrappedAmount)];
|
|
353
|
-
case 7:
|
|
354
|
-
estimatedGas = _b.sent();
|
|
355
|
-
if (!wrappedEthBalance.isGreaterThanOrEqualTo(wrappedFee)) return [3 /*break*/, 9];
|
|
356
|
-
return [4 /*yield*/, this.nodeClient.fetchTransactionCount(address)];
|
|
357
|
-
case 8:
|
|
358
|
-
txCount = _b.sent();
|
|
359
|
-
gasPrice = wrappedFee.isEqualTo(0)
|
|
360
|
-
? new bignumber_1.default(0)
|
|
361
|
-
: wrappedFee.div(estimatedGas).integerValue(bignumber_1.default.ROUND_CEIL);
|
|
362
|
-
transaction = (0, module_kit_1.newUnsignedTransaction)({
|
|
363
|
-
ethereumType: 'raw',
|
|
364
|
-
nonce: EthereumUtils_1.EthereumUtils.toHex(txCount),
|
|
365
|
-
gasLimit: EthereumUtils_1.EthereumUtils.toHex(estimatedGas.toFixed()),
|
|
366
|
-
gasPrice: EthereumUtils_1.EthereumUtils.toHex(gasPrice.toFixed()),
|
|
367
|
-
to: this.contractAddress,
|
|
368
|
-
value: EthereumUtils_1.EthereumUtils.toHex(new bignumber_1.default(0).toFixed()),
|
|
369
|
-
chainId: this.options.network.chainId,
|
|
370
|
-
data: new AirGapNodeClient_1.EthereumRPCDataTransfer(details[0].to, EthereumUtils_1.EthereumUtils.toHex(wrappedAmount.toFixed())).abiEncoded()
|
|
371
|
-
});
|
|
372
|
-
return [2 /*return*/, transaction];
|
|
373
|
-
case 9: throw new errors_1.BalanceError(coinlib_core_1.Domain.ERC20, 'not enough ETH balance');
|
|
374
|
-
case 10: return [3 /*break*/, 12];
|
|
375
|
-
case 11: throw new errors_1.BalanceError(coinlib_core_1.Domain.ERC20, 'not enough token balance');
|
|
376
|
-
case 12: return [2 /*return*/];
|
|
377
|
-
}
|
|
378
|
-
});
|
|
379
|
-
});
|
|
380
|
-
};
|
|
381
|
-
// Custom
|
|
382
|
-
ERC20TokenImpl.prototype.estimateGas = function (fromAddress, toAddress, amount, _data) {
|
|
383
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
384
|
-
var hexAmount, blockchainAmount;
|
|
385
|
-
return __generator(this, function (_a) {
|
|
386
|
-
if (typeof amount === 'string' && (0, hex_1.isHex)(amount)) {
|
|
387
|
-
hexAmount = amount;
|
|
388
|
-
}
|
|
389
|
-
else {
|
|
390
|
-
blockchainAmount = (0, module_kit_1.isAmount)(amount) ? (0, module_kit_1.newAmount)(amount).blockchain(this.units) : (0, module_kit_1.newAmount)(amount, 'blockchain');
|
|
391
|
-
hexAmount = EthereumUtils_1.EthereumUtils.toHex(blockchainAmount.value);
|
|
392
|
-
}
|
|
393
|
-
return [2 /*return*/, this.nodeClient.estimateTransferGas(this.contractAddress, fromAddress, toAddress, hexAmount)];
|
|
394
|
-
});
|
|
395
|
-
});
|
|
396
|
-
};
|
|
397
99
|
return ERC20TokenImpl;
|
|
398
|
-
}(
|
|
100
|
+
}(ERC20Protocol_1.ERC20ProtocolImpl));
|
|
399
101
|
// Factory
|
|
400
|
-
function createERC20Token(metadata
|
|
102
|
+
function createERC20Token(metadata) {
|
|
401
103
|
var _a;
|
|
402
|
-
var protocolOptions = createERC20TokenOptions(
|
|
104
|
+
var protocolOptions = createERC20TokenOptions();
|
|
403
105
|
var tokenOptions = __assign(__assign({}, protocolOptions), { name: metadata.name, identifier: metadata.identifier, contractAddress: metadata.contractAddress, units: (_a = {},
|
|
404
106
|
_a[metadata.symbol] = {
|
|
405
107
|
symbol: { value: metadata.symbol, market: metadata.marketSymbol },
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Token.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;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4B,+CAAuC,CAAA;AAEvG,SAAgB,uBAAuB,CAAC,OAA8C;IAA9C,wBAAA,EAAA,YAA8C;IACpF,OAAO;QACL,OAAO,wBAAO,8BAA8B,GAAK,OAAO,CAAE;KAC3D,CAAA;AACH,CAAC;AAJD,0DAIC"}
|
|
@@ -1,12 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EthereumSignedTransaction, EthereumUnsignedTransaction } from '../../../../types/transaction';
|
|
2
2
|
import { EthereumTransactionSignRequest } from '../definitions/transaction-sign-request-ethereum';
|
|
3
3
|
import { EthereumTypedTransactionSignRequest } from '../definitions/transaction-sign-request-ethereum-typed';
|
|
4
4
|
import { EthereumTransactionSignResponse } from '../definitions/transaction-sign-response-ethereum';
|
|
5
5
|
export declare function ethereumUnsignedTransactionToRequest(unsigned: EthereumUnsignedTransaction, publicKey: string, callbackUrl?: string): EthereumTransactionSignRequest | EthereumTypedTransactionSignRequest;
|
|
6
|
-
export declare function ethereumRawUnsignedTransactionToRequest(unsigned: EthereumRawUnsignedTransaction, publicKey: string, callbackUrl?: string): EthereumTransactionSignRequest;
|
|
7
|
-
export declare function ethereumTypedUnsignedTransactionToRequest(unsigned: EthereumTypedUnsignedTransaction, publicKey: string, callbackUrl?: string): EthereumTypedTransactionSignRequest;
|
|
8
6
|
export declare function ethereumSignedTransactionToResponse(signed: EthereumSignedTransaction, accountIdentifier: string): EthereumTransactionSignResponse;
|
|
9
7
|
export declare function ethereumTransactionSignRequestToUnsigned(request: EthereumTransactionSignRequest | EthereumTypedTransactionSignRequest): EthereumUnsignedTransaction;
|
|
10
|
-
export declare function ethereumTransactionSignRequestToRawUnsigned(request: EthereumTransactionSignRequest): EthereumRawUnsignedTransaction;
|
|
11
|
-
export declare function ethereumTransactionSignRequestToTypedUnsigned(request: EthereumTypedTransactionSignRequest): EthereumTypedUnsignedTransaction;
|
|
12
8
|
export declare function ethereumTransactionSignResponseToSigned(response: EthereumTransactionSignResponse): EthereumSignedTransaction;
|
|
@@ -22,7 +22,7 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
22
22
|
return t;
|
|
23
23
|
};
|
|
24
24
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
25
|
-
exports.ethereumTransactionSignResponseToSigned = exports.
|
|
25
|
+
exports.ethereumTransactionSignResponseToSigned = exports.ethereumTransactionSignRequestToUnsigned = exports.ethereumSignedTransactionToResponse = exports.ethereumUnsignedTransactionToRequest = void 0;
|
|
26
26
|
var module_kit_1 = require("@airgap/module-kit");
|
|
27
27
|
function isEthereumTypedTransactionSignRequest(request) {
|
|
28
28
|
return (0, module_kit_1.implementsInterface)(request.transaction, {
|
|
@@ -45,7 +45,6 @@ function ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUr
|
|
|
45
45
|
callbackURL: callbackUrl
|
|
46
46
|
};
|
|
47
47
|
}
|
|
48
|
-
exports.ethereumRawUnsignedTransactionToRequest = ethereumRawUnsignedTransactionToRequest;
|
|
49
48
|
function ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
|
|
50
49
|
var _ = unsigned.type, rest = __rest(unsigned, ["type"]);
|
|
51
50
|
return {
|
|
@@ -54,7 +53,6 @@ function ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callback
|
|
|
54
53
|
callbackURL: callbackUrl
|
|
55
54
|
};
|
|
56
55
|
}
|
|
57
|
-
exports.ethereumTypedUnsignedTransactionToRequest = ethereumTypedUnsignedTransactionToRequest;
|
|
58
56
|
function ethereumSignedTransactionToResponse(signed, accountIdentifier) {
|
|
59
57
|
return { transaction: signed.serialized, accountIdentifier: accountIdentifier };
|
|
60
58
|
}
|
|
@@ -68,11 +66,9 @@ exports.ethereumTransactionSignRequestToUnsigned = ethereumTransactionSignReques
|
|
|
68
66
|
function ethereumTransactionSignRequestToRawUnsigned(request) {
|
|
69
67
|
return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'raw' }, request.transaction));
|
|
70
68
|
}
|
|
71
|
-
exports.ethereumTransactionSignRequestToRawUnsigned = ethereumTransactionSignRequestToRawUnsigned;
|
|
72
69
|
function ethereumTransactionSignRequestToTypedUnsigned(request) {
|
|
73
70
|
return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'typed' }, request.transaction));
|
|
74
71
|
}
|
|
75
|
-
exports.ethereumTransactionSignRequestToTypedUnsigned = ethereumTransactionSignRequestToTypedUnsigned;
|
|
76
72
|
function ethereumTransactionSignResponseToSigned(response) {
|
|
77
73
|
return (0, module_kit_1.newSignedTransaction)({ serialized: response.transaction });
|
|
78
74
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAsG;AAetG,SAAS,qCAAqC,CAC5C,OAA6E;IAE7E,OAAO,IAAA,gCAAmB,EAA+C,OAAO,CAAC,WAAW,EAAE;QAC5F,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,UAAU;QAC7B,UAAU,EAAE,UAAU;KACvB,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,oCAAoC,CAClD,QAAqC,EACrC,SAAiB,EACjB,WAAoB;IAEpB,OAAO,QAAQ,CAAC,YAAY,KAAK,KAAK;QACpC,CAAC,CAAC,uCAAuC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC;QAC3E,CAAC,CAAC,yCAAyC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;AACjF,CAAC;AARD,oFAQC;AAED,
|
|
1
|
+
{"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iDAAsG;AAetG,SAAS,qCAAqC,CAC5C,OAA6E;IAE7E,OAAO,IAAA,gC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O,CAAC,CAAA;AAC1D,CAAC;AAND,4FAMC;AAED,SAAS,2CAA2C,CAAC,OAAuC;IAC1F,OAAO,IAAA,mCAAsB,aAAmC,YAAY,EAAE,KAAK,IAAK,OAAO,CAAC,WAAW,EAAG,CAAA;AAChH,CAAC;AAED,SAAS,6CAA6C,CAAC,OAA4C;IACjG,OAAO,IAAA,mCAAsB,aAAqC,YAAY,EAAE,OAAO,IAAK,OAAO,CAAC,WAAW,EAAG,CAAA;AACpH,CAAC;AAED,SAAgB,uCAAuC,CAAC,QAAyC;IAC/F,OAAO,IAAA,iCAAoB,EAA4B,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;AAC9F,CAAC;AAFD,0FAEC"}
|
|
@@ -79,11 +79,12 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
79
79
|
EthereumV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
|
|
80
80
|
return __awaiter(this, void 0, void 0, function () {
|
|
81
81
|
return __generator(this, function (_a) {
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
82
|
+
switch (identifier) {
|
|
83
|
+
case coinlib_core_1.MainProtocolSymbols.ETH:
|
|
84
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
85
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
86
|
+
default:
|
|
87
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
87
88
|
}
|
|
88
89
|
return [2 /*return*/];
|
|
89
90
|
});
|
|
@@ -92,11 +93,12 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
92
93
|
EthereumV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
93
94
|
return __awaiter(this, void 0, void 0, function () {
|
|
94
95
|
return __generator(this, function (_a) {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
96
|
+
switch (identifier) {
|
|
97
|
+
case coinlib_core_1.MainProtocolSymbols.ETH:
|
|
98
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
99
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
100
|
+
default:
|
|
101
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
100
102
|
}
|
|
101
103
|
return [2 /*return*/];
|
|
102
104
|
});
|
|
@@ -104,24 +106,26 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
104
106
|
};
|
|
105
107
|
EthereumV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
106
108
|
return __awaiter(this, void 0, void 0, function () {
|
|
107
|
-
var _a;
|
|
108
|
-
return __generator(this, function (
|
|
109
|
-
switch (
|
|
109
|
+
var _a, _b;
|
|
110
|
+
return __generator(this, function (_c) {
|
|
111
|
+
switch (_c.label) {
|
|
110
112
|
case 0:
|
|
111
|
-
|
|
112
|
-
|
|
113
|
+
_a = identifier;
|
|
114
|
+
switch (_a) {
|
|
115
|
+
case coinlib_core_1.MainProtocolSymbols.ETH: return [3 /*break*/, 1];
|
|
116
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20: return [3 /*break*/, 1];
|
|
117
|
+
}
|
|
118
|
+
return [3 /*break*/, 4];
|
|
113
119
|
case 1:
|
|
114
|
-
|
|
120
|
+
_c.trys.push([1, 3, , 4]);
|
|
115
121
|
return [4 /*yield*/, this.ethereumTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
|
|
116
122
|
case 2:
|
|
117
|
-
|
|
123
|
+
_c.sent();
|
|
118
124
|
return [2 /*return*/, true];
|
|
119
125
|
case 3:
|
|
120
|
-
|
|
126
|
+
_b = _c.sent();
|
|
121
127
|
return [2 /*return*/, false];
|
|
122
|
-
case 4:
|
|
123
|
-
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
124
|
-
case 6: return [2 /*return*/];
|
|
128
|
+
case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
125
129
|
}
|
|
126
130
|
});
|
|
127
131
|
});
|
|
@@ -129,11 +133,12 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
129
133
|
EthereumV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
|
|
130
134
|
return __awaiter(this, void 0, void 0, function () {
|
|
131
135
|
return __generator(this, function (_a) {
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
136
|
+
switch (identifier) {
|
|
137
|
+
case coinlib_core_1.MainProtocolSymbols.ETH:
|
|
138
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
139
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
140
|
+
default:
|
|
141
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
137
142
|
}
|
|
138
143
|
return [2 /*return*/];
|
|
139
144
|
});
|
|
@@ -142,11 +147,12 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
142
147
|
EthereumV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
143
148
|
return __awaiter(this, void 0, void 0, function () {
|
|
144
149
|
return __generator(this, function (_a) {
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
+
switch (identifier) {
|
|
151
|
+
case coinlib_core_1.MainProtocolSymbols.ETH:
|
|
152
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20:
|
|
153
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
154
|
+
default:
|
|
155
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
150
156
|
}
|
|
151
157
|
return [2 /*return*/];
|
|
152
158
|
});
|
|
@@ -154,24 +160,26 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
154
160
|
};
|
|
155
161
|
EthereumV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
156
162
|
return __awaiter(this, void 0, void 0, function () {
|
|
157
|
-
var _a;
|
|
158
|
-
return __generator(this, function (
|
|
159
|
-
switch (
|
|
163
|
+
var _a, _b;
|
|
164
|
+
return __generator(this, function (_c) {
|
|
165
|
+
switch (_c.label) {
|
|
160
166
|
case 0:
|
|
161
|
-
|
|
162
|
-
|
|
167
|
+
_a = identifier;
|
|
168
|
+
switch (_a) {
|
|
169
|
+
case coinlib_core_1.MainProtocolSymbols.ETH: return [3 /*break*/, 1];
|
|
170
|
+
case coinlib_core_1.SubProtocolSymbols.ETH_ERC20: return [3 /*break*/, 1];
|
|
171
|
+
}
|
|
172
|
+
return [3 /*break*/, 4];
|
|
163
173
|
case 1:
|
|
164
|
-
|
|
174
|
+
_c.trys.push([1, 3, , 4]);
|
|
165
175
|
return [4 /*yield*/, this.ethereumTransactionValidator.validateSignedTransaction(transactionSignResponse)];
|
|
166
176
|
case 2:
|
|
167
|
-
|
|
177
|
+
_c.sent();
|
|
168
178
|
return [2 /*return*/, true];
|
|
169
179
|
case 3:
|
|
170
|
-
|
|
180
|
+
_b = _c.sent();
|
|
171
181
|
return [2 /*return*/, false];
|
|
172
|
-
case 4:
|
|
173
|
-
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
174
|
-
case 6: return [2 /*return*/];
|
|
182
|
+
case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
175
183
|
}
|
|
176
184
|
});
|
|
177
185
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsF;AACtF,sDAA8D;AAG9D,iDAAgH;AAIhH,mFAKkD;AAClD,4EAAiF;AAEjF,IAAM,8BAA8B,GAAe,OAAO,CAAC,4DAA4D,CAAC,CAAA;AACxH,IAAM,mCAAmC,GAAe,OAAO,CAAC,kEAAkE,CAAC,CAAA;AACnI,IAAM,+BAA+B,GAAe,OAAO,CAAC,6DAA6D,CAAC,CAAA;AAE1H;IAAA;QACkB,YAAO,GAA4B;YACjD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,mCAAmC,EAAE;gBACvD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,uBAAuB;gBAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,+BAA+B,EAAE;gBACnD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,iCAAkB,CAAC,SAAS;aACjD;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,uBAAuB;gBAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,+BAA+B,EAAE;gBACnD,kBAAkB,EAAE,iCAAkB,CAAC,SAAS;aACjD;SACF,CAAA;QAEgB,iCAA4B,GAAiC,IAAI,oDAA4B,EAAE,CAAA;
|
|
1
|
+
{"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAsF;AACtF,sDAA8D;AAG9D,iDAAgH;AAIhH,mFAKkD;AAClD,4EAAiF;AAEjF,IAAM,8BAA8B,GAAe,OAAO,CAAC,4DAA4D,CAAC,CAAA;AACxH,IAAM,mCAAmC,GAAe,OAAO,CAAC,kEAAkE,CAAC,CAAA;AACnI,IAAM,+BAA+B,GAAe,OAAO,CAAC,6DAA6D,CAAC,CAAA;AAE1H;IAAA;QACkB,YAAO,GAA4B;YACjD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,mCAAmC,EAAE;gBACvD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,uBAAuB;gBAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,+BAA+B,EAAE;gBACnD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,iCAAkB,CAAC,SAAS;aACjD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AAgB,CAAC,CAAA;;;;KAExF;IACH,oCAAC;AAAD,CAAC,AArHD,IAqHC;AArHY,sEAA6B"}
|
package/v1/types/protocol.d.ts
CHANGED
|
@@ -15,13 +15,14 @@ export interface EthereumBaseProtocolOptions<_Units extends string = EthereumUni
|
|
|
15
15
|
feeDefaults?: FeeDefaults<EthereumUnits>;
|
|
16
16
|
standardDerivationPath?: string;
|
|
17
17
|
}
|
|
18
|
-
export interface
|
|
18
|
+
export interface ERC20ProtocolOptions<_Units extends string> extends EthereumProtocolOptions {
|
|
19
19
|
name: string;
|
|
20
20
|
identifier: string;
|
|
21
21
|
contractAddress: string;
|
|
22
|
-
units: ProtocolUnitsMetadata<
|
|
23
|
-
mainUnit:
|
|
22
|
+
units: ProtocolUnitsMetadata<_Units>;
|
|
23
|
+
mainUnit: _Units;
|
|
24
24
|
}
|
|
25
|
+
export declare type ERC20TokenOptions = ERC20ProtocolOptions<string>;
|
|
25
26
|
export interface ERC20TokenMetadata {
|
|
26
27
|
name: string;
|
|
27
28
|
identifier: string;
|