@airgap/ethereum 0.13.7-beta.22 → 0.13.7-beta.26
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/airgap-coinlib-ethereum.min.js +17284 -6305
- package/index.d.ts +1 -12
- package/index.js +15 -21
- package/index.js.map +1 -1
- package/package.json +5 -3
- package/v0/index.d.ts +12 -0
- package/v0/index.js +39 -0
- package/v0/index.js.map +1 -0
- package/{protocol → v0/protocol}/BaseEthereumProtocol.d.ts +0 -0
- package/{protocol → v0/protocol}/BaseEthereumProtocol.js +14 -10
- package/v0/protocol/BaseEthereumProtocol.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumAddress.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumAddress.js +5 -1
- package/v0/protocol/EthereumAddress.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumChainIDs.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumChainIDs.js +0 -0
- package/v0/protocol/EthereumChainIDs.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumClassicProtocol.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumClassicProtocol.js +2 -0
- package/v0/protocol/EthereumClassicProtocol.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumCryptoClient.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumCryptoClient.js +10 -4
- package/v0/protocol/EthereumCryptoClient.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumProtocol.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumProtocol.js +2 -0
- package/v0/protocol/EthereumProtocol.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumProtocolOptions.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumProtocolOptions.js +4 -2
- package/v0/protocol/EthereumProtocolOptions.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumRopstenProtocol.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumRopstenProtocol.js +2 -0
- package/v0/protocol/EthereumRopstenProtocol.js.map +1 -0
- package/{protocol → v0/protocol}/EthereumTypes.d.ts +0 -0
- package/{protocol → v0/protocol}/EthereumTypes.js +0 -0
- package/v0/protocol/EthereumTypes.js.map +1 -0
- package/{protocol → v0/protocol}/clients/info-clients/EtherscanInfoClient.d.ts +0 -0
- package/{protocol → v0/protocol}/clients/info-clients/EtherscanInfoClient.js +8 -6
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -0
- package/{protocol → v0/protocol}/clients/info-clients/InfoClient.d.ts +0 -0
- package/{protocol → v0/protocol}/clients/info-clients/InfoClient.js +0 -0
- package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -0
- package/{protocol → v0/protocol}/clients/node-clients/AirGapNodeClient.d.ts +0 -0
- package/{protocol → v0/protocol}/clients/node-clients/AirGapNodeClient.js +8 -6
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -0
- package/{protocol → v0/protocol}/clients/node-clients/NodeClient.d.ts +0 -0
- package/{protocol → v0/protocol}/clients/node-clients/NodeClient.js +0 -0
- package/v0/protocol/clients/node-clients/NodeClient.js.map +1 -0
- package/{protocol → v0/protocol}/erc20/ERC20.d.ts +0 -0
- package/{protocol → v0/protocol}/erc20/ERC20.js +0 -0
- package/v0/protocol/erc20/ERC20.js.map +1 -0
- package/{protocol → v0/protocol}/erc20/GenericERC20.d.ts +0 -0
- package/{protocol → v0/protocol}/erc20/GenericERC20.js +8 -2
- package/v0/protocol/erc20/GenericERC20.js.map +1 -0
- package/{protocol → v0/protocol}/utils/utils.d.ts +0 -0
- package/{protocol → v0/protocol}/utils/utils.js +7 -7
- package/v0/protocol/utils/utils.js.map +1 -0
- package/v0/serializer/schemas/v2/transaction-sign-request-ethereum.json +50 -0
- package/v0/serializer/schemas/v2/transaction-sign-response-ethereum.json +19 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-ethereum-typed.json +38 -0
- package/v0/serializer/schemas/v3/transaction-sign-request-ethereum.json +50 -0
- package/v0/serializer/schemas/v3/transaction-sign-response-ethereum.json +19 -0
- package/v0/serializer/validators/transaction-validator.d.ts +15 -0
- package/v0/serializer/validators/transaction-validator.js +96 -0
- package/v0/serializer/validators/transaction-validator.js.map +1 -0
- package/v0/serializer/validators/validators.d.ts +1 -0
- package/v0/serializer/validators/validators.js +78 -0
- package/v0/serializer/validators/validators.js.map +1 -0
- package/v0/types/signed-transaction-ethereum.d.ts +5 -0
- package/{types → v0/types}/signed-transaction-ethereum.js +0 -0
- package/v0/types/signed-transaction-ethereum.js.map +1 -0
- package/{types → v0/types}/transaction-ethereum.d.ts +0 -0
- package/{types → v0/types}/transaction-ethereum.js +0 -0
- package/v0/types/transaction-ethereum.js.map +1 -0
- package/v0/types/unsigned-transaction-ethereum-typed.d.ts +11 -0
- package/{types → v0/types}/unsigned-transaction-ethereum-typed.js +0 -0
- package/v0/types/unsigned-transaction-ethereum-typed.js.map +1 -0
- package/v0/types/unsigned-transaction-ethereum.d.ts +15 -0
- package/{types → v0/types}/unsigned-transaction-ethereum.js +0 -0
- package/v0/types/unsigned-transaction-ethereum.js.map +1 -0
- package/v1/block-explorer/EtherscanBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/EtherscanBlockExplorer.js +74 -0
- package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -0
- package/v1/clients/crypto/EthereumCryptoClient.d.ts +7 -0
- package/v1/clients/crypto/EthereumCryptoClient.js +146 -0
- package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -0
- package/v1/clients/info/EthereumInfoClient.d.ts +15 -0
- package/v1/clients/info/EthereumInfoClient.js +11 -0
- package/v1/clients/info/EthereumInfoClient.js.map +1 -0
- package/v1/clients/info/EtherscanInfoClient.d.ts +7 -0
- package/v1/clients/info/EtherscanInfoClient.js +165 -0
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -0
- package/v1/clients/node/AirGapNodeClient.d.ts +41 -0
- package/v1/clients/node/AirGapNodeClient.js +351 -0
- package/v1/clients/node/AirGapNodeClient.js.map +1 -0
- package/v1/clients/node/EthereumNodeClient.d.ts +17 -0
- package/v1/clients/node/EthereumNodeClient.js +11 -0
- package/v1/clients/node/EthereumNodeClient.js.map +1 -0
- package/v1/data/EthereumAddress.d.ts +7 -0
- package/v1/data/EthereumAddress.js +45 -0
- package/v1/data/EthereumAddress.js.map +1 -0
- package/v1/index.d.ts +14 -0
- package/v1/index.js +23 -0
- package/v1/index.js.map +1 -0
- package/v1/module/ERC20Module.d.ts +9 -0
- package/v1/module/ERC20Module.js +69 -0
- package/v1/module/ERC20Module.js.map +1 -0
- package/v1/module/EthereumBaseModule.d.ts +13 -0
- package/v1/module/EthereumBaseModule.js +83 -0
- package/v1/module/EthereumBaseModule.js.map +1 -0
- package/v1/module/EthereumClassicModule.d.ts +7 -0
- package/v1/module/EthereumClassicModule.js +32 -0
- package/v1/module/EthereumClassicModule.js.map +1 -0
- package/v1/module/EthereumModule.d.ts +7 -0
- package/v1/module/EthereumModule.js +32 -0
- package/v1/module/EthereumModule.js.map +1 -0
- package/v1/module/EthereumRopstenModule.d.ts +7 -0
- package/v1/module/EthereumRopstenModule.js +32 -0
- package/v1/module/EthereumRopstenModule.js.map +1 -0
- package/v1/protocol/EthereumBaseProtocol.d.ts +71 -0
- package/v1/protocol/EthereumBaseProtocol.js +744 -0
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -0
- package/v1/protocol/EthereumChainIds.d.ts +1 -0
- package/v1/protocol/EthereumChainIds.js +340 -0
- package/v1/protocol/EthereumChainIds.js.map +1 -0
- package/v1/protocol/EthereumClassicProtocol.d.ts +8 -0
- package/v1/protocol/EthereumClassicProtocol.js +87 -0
- package/v1/protocol/EthereumClassicProtocol.js.map +1 -0
- package/v1/protocol/EthereumProtocol.d.ts +8 -0
- package/v1/protocol/EthereumProtocol.js +312 -0
- package/v1/protocol/EthereumProtocol.js.map +1 -0
- package/v1/protocol/EthereumRopstenProtocol.d.ts +8 -0
- package/v1/protocol/EthereumRopstenProtocol.js +64 -0
- package/v1/protocol/EthereumRopstenProtocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Token.d.ts +6 -0
- package/v1/protocol/erc20/ERC20Token.js +404 -0
- package/v1/protocol/erc20/ERC20Token.js.map +1 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +10 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +29 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +10 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +14 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +45 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +62 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +19 -0
- package/v1/serializer/v3/validators/transaction-validator.d.ts +10 -0
- package/v1/serializer/v3/validators/transaction-validator.js +80 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/types/protocol.d.ts +32 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +22 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/EthereumUtils.d.ts +13 -0
- package/v1/utils/EthereumUtils.js +140 -0
- package/v1/utils/EthereumUtils.js.map +1 -0
- package/v1/utils/key.d.ts +5 -0
- package/v1/utils/key.js +87 -0
- package/v1/utils/key.js.map +1 -0
- package/v1/utils/transaction.d.ts +3 -0
- package/v1/utils/transaction.js +29 -0
- package/v1/utils/transaction.js.map +1 -0
- package/protocol/BaseEthereumProtocol.js.map +0 -1
- package/protocol/EthereumAddress.js.map +0 -1
- package/protocol/EthereumChainIDs.js.map +0 -1
- package/protocol/EthereumClassicProtocol.js.map +0 -1
- package/protocol/EthereumCryptoClient.js.map +0 -1
- package/protocol/EthereumProtocol.js.map +0 -1
- package/protocol/EthereumProtocolOptions.js.map +0 -1
- package/protocol/EthereumRopstenProtocol.js.map +0 -1
- package/protocol/EthereumTypes.js.map +0 -1
- package/protocol/clients/info-clients/EtherscanInfoClient.js.map +0 -1
- package/protocol/clients/info-clients/InfoClient.js.map +0 -1
- package/protocol/clients/node-clients/AirGapNodeClient.js.map +0 -1
- package/protocol/clients/node-clients/NodeClient.js.map +0 -1
- package/protocol/erc20/ERC20.js.map +0 -1
- package/protocol/erc20/GenericERC20.js.map +0 -1
- package/protocol/utils/utils.js.map +0 -1
- package/types/signed-transaction-ethereum.d.ts +0 -5
- package/types/signed-transaction-ethereum.js.map +0 -1
- package/types/transaction-ethereum.js.map +0 -1
- package/types/unsigned-transaction-ethereum-typed.d.ts +0 -10
- package/types/unsigned-transaction-ethereum-typed.js.map +0 -1
- package/types/unsigned-transaction-ethereum.d.ts +0 -14
- package/types/unsigned-transaction-ethereum.js.map +0 -1
|
@@ -0,0 +1,312 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.createEthereumProtocolOptions = exports.ETHEREUM_MAINNET_PROTOCOL_NETWORK = exports.createEthereumProtocol = void 0;
|
|
66
|
+
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
67
|
+
var bip39_2_5_0_1 = require("@airgap/coinlib-core/dependencies/src/bip39-2.5.0");
|
|
68
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
69
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
70
|
+
var EtherscanInfoClient_1 = require("../clients/info/EtherscanInfoClient");
|
|
71
|
+
var AirGapNodeClient_1 = require("../clients/node/AirGapNodeClient");
|
|
72
|
+
var key_1 = require("../utils/key");
|
|
73
|
+
var transaction_1 = require("../utils/transaction");
|
|
74
|
+
var EthereumBaseProtocol_1 = require("./EthereumBaseProtocol");
|
|
75
|
+
// Implementation
|
|
76
|
+
var EthereumProtocolImpl = /** @class */ (function (_super) {
|
|
77
|
+
__extends(EthereumProtocolImpl, _super);
|
|
78
|
+
function EthereumProtocolImpl(options) {
|
|
79
|
+
if (options === void 0) { options = {}; }
|
|
80
|
+
var completeOptions = createEthereumProtocolOptions(options.network);
|
|
81
|
+
return _super.call(this, new AirGapNodeClient_1.AirGapNodeClient(completeOptions.network.rpcUrl), new EtherscanInfoClient_1.EtherscanInfoClient(completeOptions.network.blockExplorerApi), __assign(__assign({}, completeOptions), { standardDerivationPath: "m/44'/60'/0'" })) || this;
|
|
82
|
+
}
|
|
83
|
+
// Common
|
|
84
|
+
EthereumProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
|
|
85
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
86
|
+
return __generator(this, function (_a) {
|
|
87
|
+
return [2 /*return*/, _super.prototype.getAddressFromPublicKey.call(this, this.nonExtendedPublicKey(publicKey))];
|
|
88
|
+
});
|
|
89
|
+
});
|
|
90
|
+
};
|
|
91
|
+
EthereumProtocolImpl.prototype.deriveFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
|
|
92
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
93
|
+
return __generator(this, function (_a) {
|
|
94
|
+
return [2 /*return*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex)];
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
};
|
|
98
|
+
EthereumProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, publicKey) {
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
var _a, dps, derivedPublicKey, ownAddress, derivedPublicKey, ownAddress;
|
|
101
|
+
return __generator(this, function (_b) {
|
|
102
|
+
switch (_b.label) {
|
|
103
|
+
case 0:
|
|
104
|
+
if (publicKey.type === 'pub') {
|
|
105
|
+
return [2 /*return*/, _super.prototype.getDetailsFromTransaction.call(this, transaction, publicKey)];
|
|
106
|
+
}
|
|
107
|
+
_a = transaction.type;
|
|
108
|
+
switch (_a) {
|
|
109
|
+
case 'signed': return [3 /*break*/, 1];
|
|
110
|
+
case 'unsigned': return [3 /*break*/, 2];
|
|
111
|
+
}
|
|
112
|
+
return [3 /*break*/, 6];
|
|
113
|
+
case 1: return [2 /*return*/, this.getDetailsFromSignedTransaction(transaction)];
|
|
114
|
+
case 2:
|
|
115
|
+
if (!(0, transaction_1.isTypedUnsignedTransaction)(transaction)) return [3 /*break*/, 4];
|
|
116
|
+
dps = transaction.derivationPath.split('/');
|
|
117
|
+
derivedPublicKey = this.getPublicKeyFromExtendedPublicKey(publicKey, Number(dps[dps.length - 2]), Number(dps[dps.length - 1]));
|
|
118
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(derivedPublicKey)];
|
|
119
|
+
case 3:
|
|
120
|
+
ownAddress = _b.sent();
|
|
121
|
+
return [2 /*return*/, this.getDetailsFromTypedUnsignedTransaction(transaction, ownAddress)];
|
|
122
|
+
case 4:
|
|
123
|
+
derivedPublicKey = this.getPublicKeyFromExtendedPublicKey(publicKey, 0, 0);
|
|
124
|
+
return [4 /*yield*/, this.getAddressFromPublicKey(derivedPublicKey)];
|
|
125
|
+
case 5:
|
|
126
|
+
ownAddress = _b.sent();
|
|
127
|
+
return [2 /*return*/, this.getDetailsFromRawUnsignedTransaction(transaction, ownAddress)];
|
|
128
|
+
case 6:
|
|
129
|
+
(0, coinlib_core_1.assertNever)(transaction);
|
|
130
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, 'Unsupported transaction type.');
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
};
|
|
135
|
+
EthereumProtocolImpl.prototype.verifyMessageWithPublicKey = function (message, signature, publicKey) {
|
|
136
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
137
|
+
return __generator(this, function (_a) {
|
|
138
|
+
return [2 /*return*/, _super.prototype.verifyMessageWithPublicKey.call(this, message, signature, this.nonExtendedPublicKey(publicKey))];
|
|
139
|
+
});
|
|
140
|
+
});
|
|
141
|
+
};
|
|
142
|
+
EthereumProtocolImpl.prototype.encryptAsymmetricWithPublicKey = function (payload, publicKey) {
|
|
143
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
144
|
+
return __generator(this, function (_a) {
|
|
145
|
+
return [2 /*return*/, _super.prototype.encryptAsymmetricWithPublicKey.call(this, payload, this.nonExtendedPublicKey(publicKey))];
|
|
146
|
+
});
|
|
147
|
+
});
|
|
148
|
+
};
|
|
149
|
+
// Offline
|
|
150
|
+
EthereumProtocolImpl.prototype.getExtendedKeyPairFromSecret = function (secret, derivationPath) {
|
|
151
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
152
|
+
return __generator(this, function (_a) {
|
|
153
|
+
switch (secret.type) {
|
|
154
|
+
case 'hex':
|
|
155
|
+
return [2 /*return*/, this.getExtendedKeyPairFromHexSecret(secret.value, derivationPath)];
|
|
156
|
+
case 'mnemonic':
|
|
157
|
+
return [2 /*return*/, this.getExtendedKeyPairFromMnemonic(secret.value, derivationPath, secret.password)];
|
|
158
|
+
default:
|
|
159
|
+
(0, coinlib_core_1.assertNever)(secret);
|
|
160
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported secret type.');
|
|
161
|
+
}
|
|
162
|
+
return [2 /*return*/];
|
|
163
|
+
});
|
|
164
|
+
});
|
|
165
|
+
};
|
|
166
|
+
EthereumProtocolImpl.prototype.getExtendedKeyPairFromHexSecret = function (secret, derivationPath) {
|
|
167
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
168
|
+
var node, derivedNode;
|
|
169
|
+
return __generator(this, function (_a) {
|
|
170
|
+
node = this.bitcoinJS.lib.HDNode.fromSeedHex(secret, this.bitcoinJS.config.network);
|
|
171
|
+
derivedNode = derivationPath ? node.derivePath(derivationPath) : node;
|
|
172
|
+
return [2 /*return*/, {
|
|
173
|
+
secretKey: (0, module_kit_1.newExtendedSecretKey)(derivedNode.toBase58(), 'encoded'),
|
|
174
|
+
publicKey: (0, module_kit_1.newExtendedPublicKey)(derivedNode.neutered().toBase58(), 'encoded')
|
|
175
|
+
}];
|
|
176
|
+
});
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
EthereumProtocolImpl.prototype.getExtendedKeyPairFromMnemonic = function (mnemonic, derivationPath, password) {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
+
var secret;
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
secret = (0, bip39_2_5_0_1.mnemonicToSeed)(mnemonic, password);
|
|
184
|
+
return [2 /*return*/, this.getExtendedKeyPairFromHexSecret(secret.toString('hex'), derivationPath)];
|
|
185
|
+
});
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
EthereumProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
|
|
189
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
190
|
+
return __generator(this, function (_a) {
|
|
191
|
+
return [2 /*return*/, _super.prototype.signTransactionWithSecretKey.call(this, transaction, this.nonExtendedSecretKey(secretKey))];
|
|
192
|
+
});
|
|
193
|
+
});
|
|
194
|
+
};
|
|
195
|
+
EthereumProtocolImpl.prototype.signMessageWithKeyPair = function (message, keyPair) {
|
|
196
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
197
|
+
return __generator(this, function (_a) {
|
|
198
|
+
return [2 /*return*/, _super.prototype.signMessageWithKeyPair.call(this, message, {
|
|
199
|
+
secretKey: this.nonExtendedSecretKey(keyPair.secretKey),
|
|
200
|
+
publicKey: this.nonExtendedPublicKey(keyPair.publicKey)
|
|
201
|
+
})];
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
EthereumProtocolImpl.prototype.decryptAsymmetricWithKeyPair = function (payload, keyPair) {
|
|
206
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
207
|
+
return __generator(this, function (_a) {
|
|
208
|
+
return [2 /*return*/, _super.prototype.decryptAsymmetricWithKeyPair.call(this, payload, {
|
|
209
|
+
secretKey: this.nonExtendedSecretKey(keyPair.secretKey),
|
|
210
|
+
publicKey: this.nonExtendedPublicKey(keyPair.publicKey)
|
|
211
|
+
})];
|
|
212
|
+
});
|
|
213
|
+
});
|
|
214
|
+
};
|
|
215
|
+
EthereumProtocolImpl.prototype.encryptAESWithSecretKey = function (payload, secretKey) {
|
|
216
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
217
|
+
return __generator(this, function (_a) {
|
|
218
|
+
return [2 /*return*/, _super.prototype.encryptAESWithSecretKey.call(this, payload, this.nonExtendedSecretKey(secretKey))];
|
|
219
|
+
});
|
|
220
|
+
});
|
|
221
|
+
};
|
|
222
|
+
EthereumProtocolImpl.prototype.decryptAESWithSecretKey = function (payload, secretKey) {
|
|
223
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
224
|
+
return __generator(this, function (_a) {
|
|
225
|
+
return [2 /*return*/, _super.prototype.decryptAESWithSecretKey.call(this, payload, this.nonExtendedSecretKey(secretKey))];
|
|
226
|
+
});
|
|
227
|
+
});
|
|
228
|
+
};
|
|
229
|
+
// Online
|
|
230
|
+
EthereumProtocolImpl.prototype.getTransactionsForPublicKey = function (publicKey, limit, cursor) {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
return __generator(this, function (_a) {
|
|
233
|
+
return [2 /*return*/, _super.prototype.getTransactionsForPublicKey.call(this, this.nonExtendedPublicKey(publicKey), limit, cursor)];
|
|
234
|
+
});
|
|
235
|
+
});
|
|
236
|
+
};
|
|
237
|
+
EthereumProtocolImpl.prototype.getBalanceOfPublicKey = function (publicKey) {
|
|
238
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
239
|
+
return __generator(this, function (_a) {
|
|
240
|
+
return [2 /*return*/, _super.prototype.getBalanceOfPublicKey.call(this, this.nonExtendedPublicKey(publicKey))];
|
|
241
|
+
});
|
|
242
|
+
});
|
|
243
|
+
};
|
|
244
|
+
EthereumProtocolImpl.prototype.getTransactionMaxAmountWithPublicKey = function (publicKey, to, configuration) {
|
|
245
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
246
|
+
return __generator(this, function (_a) {
|
|
247
|
+
return [2 /*return*/, _super.prototype.getTransactionMaxAmountWithPublicKey.call(this, this.nonExtendedPublicKey(publicKey), to, configuration)];
|
|
248
|
+
});
|
|
249
|
+
});
|
|
250
|
+
};
|
|
251
|
+
EthereumProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (publicKey, details) {
|
|
252
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
253
|
+
return __generator(this, function (_a) {
|
|
254
|
+
return [2 /*return*/, _super.prototype.getTransactionFeeWithPublicKey.call(this, this.nonExtendedPublicKey(publicKey), details)];
|
|
255
|
+
});
|
|
256
|
+
});
|
|
257
|
+
};
|
|
258
|
+
EthereumProtocolImpl.prototype.prepareTransactionWithPublicKey = function (publicKey, details, configuration) {
|
|
259
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
260
|
+
return __generator(this, function (_a) {
|
|
261
|
+
return [2 /*return*/, _super.prototype.prepareTransactionWithPublicKey.call(this, this.nonExtendedPublicKey(publicKey), details, configuration)];
|
|
262
|
+
});
|
|
263
|
+
});
|
|
264
|
+
};
|
|
265
|
+
// Custom
|
|
266
|
+
EthereumProtocolImpl.prototype.nonExtendedPublicKey = function (publicKey) {
|
|
267
|
+
return publicKey.type === 'pub' ? publicKey : this.getPublicKeyFromExtendedPublicKey(publicKey);
|
|
268
|
+
};
|
|
269
|
+
EthereumProtocolImpl.prototype.nonExtendedSecretKey = function (secretKey) {
|
|
270
|
+
return secretKey.type === 'priv' ? secretKey : this.getSecretKeyFromExtendedSecretKey(secretKey);
|
|
271
|
+
};
|
|
272
|
+
EthereumProtocolImpl.prototype.getPublicKeyFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
|
|
273
|
+
if (visibilityIndex === void 0) { visibilityIndex = 0; }
|
|
274
|
+
if (addressIndex === void 0) { addressIndex = 0; }
|
|
275
|
+
var encodedExtendedPublicKey = (0, key_1.convertExtendedPublicKey)(extendedPublicKey, 'encoded');
|
|
276
|
+
var derivedNode = this.deriveNode(encodedExtendedPublicKey.value, visibilityIndex, addressIndex);
|
|
277
|
+
return (0, module_kit_1.newPublicKey)(derivedNode.neutered().keyPair.getPublicKeyBuffer().toString('hex'), 'hex');
|
|
278
|
+
};
|
|
279
|
+
EthereumProtocolImpl.prototype.getSecretKeyFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
|
|
280
|
+
if (visibilityIndex === void 0) { visibilityIndex = 0; }
|
|
281
|
+
if (addressIndex === void 0) { addressIndex = 0; }
|
|
282
|
+
var encodedExtendedSecretKey = (0, key_1.convertExtendedSecretKey)(extendedSecretKey, 'encoded');
|
|
283
|
+
var derivedNode = this.deriveNode(encodedExtendedSecretKey.value, visibilityIndex, addressIndex);
|
|
284
|
+
return (0, module_kit_1.newSecretKey)(derivedNode.keyPair.getPrivateKeyBuffer().toString('hex'), 'hex');
|
|
285
|
+
};
|
|
286
|
+
EthereumProtocolImpl.prototype.deriveNode = function (base58, visibilityIndex, addressIndex) {
|
|
287
|
+
return [visibilityIndex, addressIndex].reduce(function (node, index) { return node.derive(index); }, this.bitcoinJS.lib.HDNode.fromBase58(base58, this.bitcoinJS.config.network));
|
|
288
|
+
};
|
|
289
|
+
return EthereumProtocolImpl;
|
|
290
|
+
}(EthereumBaseProtocol_1.DefaultEthereumBaseProtocolImpl));
|
|
291
|
+
// Factory
|
|
292
|
+
function createEthereumProtocol(options) {
|
|
293
|
+
if (options === void 0) { options = {}; }
|
|
294
|
+
return new EthereumProtocolImpl(options);
|
|
295
|
+
}
|
|
296
|
+
exports.createEthereumProtocol = createEthereumProtocol;
|
|
297
|
+
exports.ETHEREUM_MAINNET_PROTOCOL_NETWORK = {
|
|
298
|
+
name: 'Mainnet',
|
|
299
|
+
type: 'mainnet',
|
|
300
|
+
rpcUrl: 'https://eth-rpc-proxy.airgap.prod.gke.papers.tech',
|
|
301
|
+
chainId: 1,
|
|
302
|
+
blockExplorerApi: 'https://api.etherscan.io'
|
|
303
|
+
};
|
|
304
|
+
var DEFAULT_ETHEREUM_PROTOCOL_NETWORK = exports.ETHEREUM_MAINNET_PROTOCOL_NETWORK;
|
|
305
|
+
function createEthereumProtocolOptions(network) {
|
|
306
|
+
if (network === void 0) { network = {}; }
|
|
307
|
+
return {
|
|
308
|
+
network: __assign(__assign({}, DEFAULT_ETHEREUM_PROTOCOL_NETWORK), network)
|
|
309
|
+
};
|
|
310
|
+
}
|
|
311
|
+
exports.createEthereumProtocolOptions = createEthereumProtocolOptions;
|
|
312
|
+
//# sourceMappingURL=EthereumProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthereumProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/EthereumProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,qDAA0D;AAC1D,iFAAkF;AAClF,sDAA8D;AAC9D,iDAsB2B;AAE3B,2EAAyE;AACzE,qEAAmE;AAGnE,oCAAiF;AACjF,oDAAiE;AAEjE,+DAA8F;AAM9F,iBAAiB;AAEjB;IAAmC,wCAA+B;IAChE,8BAAmB,OAAuD;QAAvD,wBAAA,EAAA,YAAuD;QACxE,IAAM,eAAe,GAA4B,6BAA6B,CAAC,OAAO,CA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AAC;AAJD,sEAIC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RecursivePartial } from '@airgap/module-kit';
|
|
2
|
+
import { EthereumProtocolNetwork, EthereumProtocolOptions } from '../types/protocol';
|
|
3
|
+
import { EthereumBaseProtocol } from './EthereumBaseProtocol';
|
|
4
|
+
export interface EthereumRopstenProtocol extends EthereumBaseProtocol {
|
|
5
|
+
}
|
|
6
|
+
export declare function createEthereumRopstenProtocol(options?: RecursivePartial<EthereumProtocolOptions>): EthereumRopstenProtocol;
|
|
7
|
+
export declare const ETHEREUM_ROPSTEN_MAINNET_PROTOCOL_NETWORK: EthereumProtocolNetwork;
|
|
8
|
+
export declare function createEthereumRopstenProtocolOptions(network?: Partial<EthereumProtocolNetwork>): EthereumProtocolOptions;
|
|
@@ -0,0 +1,64 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
+
exports.createEthereumRopstenProtocolOptions = exports.ETHEREUM_ROPSTEN_MAINNET_PROTOCOL_NETWORK = exports.createEthereumRopstenProtocol = void 0;
|
|
30
|
+
var EtherscanInfoClient_1 = require("../clients/info/EtherscanInfoClient");
|
|
31
|
+
var AirGapNodeClient_1 = require("../clients/node/AirGapNodeClient");
|
|
32
|
+
var EthereumBaseProtocol_1 = require("./EthereumBaseProtocol");
|
|
33
|
+
// Implementation
|
|
34
|
+
var EthereumRopstenProtocolImpl = /** @class */ (function (_super) {
|
|
35
|
+
__extends(EthereumRopstenProtocolImpl, _super);
|
|
36
|
+
function EthereumRopstenProtocolImpl(options) {
|
|
37
|
+
if (options === void 0) { options = {}; }
|
|
38
|
+
var completeOptions = createEthereumRopstenProtocolOptions(options.network);
|
|
39
|
+
return _super.call(this, new AirGapNodeClient_1.AirGapNodeClient(completeOptions.network.rpcUrl), new EtherscanInfoClient_1.EtherscanInfoClient(completeOptions.network.blockExplorerApi), completeOptions) || this;
|
|
40
|
+
}
|
|
41
|
+
return EthereumRopstenProtocolImpl;
|
|
42
|
+
}(EthereumBaseProtocol_1.DefaultEthereumBaseProtocolImpl));
|
|
43
|
+
// Factory
|
|
44
|
+
function createEthereumRopstenProtocol(options) {
|
|
45
|
+
if (options === void 0) { options = {}; }
|
|
46
|
+
return new EthereumRopstenProtocolImpl(options);
|
|
47
|
+
}
|
|
48
|
+
exports.createEthereumRopstenProtocol = createEthereumRopstenProtocol;
|
|
49
|
+
exports.ETHEREUM_ROPSTEN_MAINNET_PROTOCOL_NETWORK = {
|
|
50
|
+
name: 'Mainnet',
|
|
51
|
+
type: 'mainnet',
|
|
52
|
+
rpcUrl: 'https://ropsten.infura.io',
|
|
53
|
+
chainId: 3,
|
|
54
|
+
blockExplorerApi: 'https://api-ropsten.etherscan.io/'
|
|
55
|
+
};
|
|
56
|
+
var DEFAULT_ETHEREUM_ROPSTEN_PROTOCOL_NETWORK = exports.ETHEREUM_ROPSTEN_MAINNET_PROTOCOL_NETWORK;
|
|
57
|
+
function createEthereumRopstenProtocolOptions(network) {
|
|
58
|
+
if (network === void 0) { network = {}; }
|
|
59
|
+
return {
|
|
60
|
+
network: __assign(__assign({}, DEFAULT_ETHEREUM_ROPSTEN_PROTOCOL_NETWORK), network)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
exports.createEthereumRopstenProtocolOptions = createEthereumRopstenProtocolOptions;
|
|
64
|
+
//# sourceMappingURL=EthereumRopstenProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthereumRopstenProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/EthereumRopstenProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,2EAAyE;AACzE,qEAAmE;AAGnE,+DAA8F;AAM9F,iBAAiB;AAEjB;IAA0C,+CAA+B;IACvE,qCAAmB,OAAuD;QAAvD,wBAAA,EAAA,YAAuD;QACxE,IAAM,eAAe,GAA4B,oCAAoC,CAAC,OAAO,CAAC,OAAO,CAAC,CAAA;eAEtG,kBACE,IAAI,mCAAgB,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,EACpD,IAAI,yCAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,EACjE,eAAe,CAChB;IACH,CAAC;IACH,kCAAC;AAAD,CAAC,AAVD,CAA0C,sDAA+B,GAUxE;AAED,UAAU;AAEV,SAAgB,6BAA6B,CAAC,OAAuD;IAAvD,wBAAA,EAAA,YAAuD;IACnG,OAAO,IAAI,2BAA2B,CAAC,OAAO,CAAC,CAAA;AACjD,CAAC;AAFD,sEAEC;AAEY,QAAA,yCAAyC,GAA4B;IAChF,IAAI,EAAE,SAAS;IACf,IAAI,EAAE,SAAS;IACf,MAAM,EAAE,2BAA2B;IACnC,OAAO,EAAE,CAAC;IACV,gBAAgB,EAAE,mCAAmC;CACtD,CAAA;AAED,IAAM,yCAAyC,GAA4B,iDAAyC,CAAA;AAEpH,SAAgB,oCAAoC,CAAC,OAA8C;IAA9C,wBAAA,EAAA,YAA8C;IACjG,OAAO;QACL,OAAO,wBAAO,yCAAyC,GAAK,OAAO,CAAE;KACtE,CAAA;AACH,CAAC;AAJD,oFAIC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { AirGapInterface } from '@airgap/module-kit';
|
|
2
|
+
import { ERC20TokenMetadata } from '../../types/protocol';
|
|
3
|
+
import { EthereumBaseProtocol } from '../EthereumBaseProtocol';
|
|
4
|
+
export interface ERC20Token extends AirGapInterface<EthereumBaseProtocol<string>, 'SingleTokenSubProtocol'> {
|
|
5
|
+
}
|
|
6
|
+
export declare function createERC20Token(metadata: ERC20TokenMetadata): ERC20Token;
|