@airgap/ethereum 0.13.7-beta.27 → 0.13.8-beta.10

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 (70) hide show
  1. package/airgap-coinlib-ethereum.min.js +6 -1
  2. package/package.json +5 -5
  3. package/v0/protocol/BaseEthereumProtocol.js +2 -0
  4. package/v0/protocol/BaseEthereumProtocol.js.map +1 -1
  5. package/v0/protocol/EthereumAddress.js +1 -0
  6. package/v0/protocol/EthereumAddress.js.map +1 -1
  7. package/v0/protocol/EthereumCryptoClient.js +2 -1
  8. package/v0/protocol/EthereumCryptoClient.js.map +1 -1
  9. package/v0/protocol/erc20/GenericERC20.js +1 -0
  10. package/v0/protocol/erc20/GenericERC20.js.map +1 -1
  11. package/v0/serializer/validators/transaction-validator.js.map +1 -1
  12. package/v1/clients/crypto/EthereumCryptoClient.js +1 -0
  13. package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -1
  14. package/v1/data/EthereumAddress.js +1 -0
  15. package/v1/data/EthereumAddress.js.map +1 -1
  16. package/v1/index.d.ts +2 -6
  17. package/v1/index.js +1 -11
  18. package/v1/index.js.map +1 -1
  19. package/v1/module/ERC20Tokens.d.ts +3 -0
  20. package/v1/module/ERC20Tokens.js +815 -0
  21. package/v1/module/ERC20Tokens.js.map +1 -0
  22. package/v1/module/EthereumModule.d.ts +11 -5
  23. package/v1/module/EthereumModule.js +114 -21
  24. package/v1/module/EthereumModule.js.map +1 -1
  25. package/v1/protocol/EthereumBaseProtocol.d.ts +28 -16
  26. package/v1/protocol/EthereumBaseProtocol.js +139 -17
  27. package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
  28. package/v1/protocol/EthereumProtocol.d.ts +2 -2
  29. package/v1/protocol/EthereumProtocol.js +1 -249
  30. package/v1/protocol/EthereumProtocol.js.map +1 -1
  31. package/v1/protocol/erc20/ERC20Token.d.ts +3 -1
  32. package/v1/protocol/erc20/ERC20Token.js +23 -6
  33. package/v1/protocol/erc20/ERC20Token.js.map +1 -1
  34. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +3 -1
  35. package/v1/serializer/v3/schemas/converter/transaction-converter.js +56 -5
  36. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
  37. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +1 -1
  38. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +1 -1
  39. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +1 -5
  40. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +1 -5
  41. package/v1/serializer/v3/serializer-companion.d.ts +13 -0
  42. package/v1/serializer/v3/serializer-companion.js +190 -0
  43. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  44. package/v1/serializer/v3/validators/transaction-validator.d.ts +1 -4
  45. package/v1/serializer/v3/validators/transaction-validator.js +1 -10
  46. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
  47. package/v1/types/transaction.d.ts +2 -0
  48. package/v1/utils/key.js +1 -0
  49. package/v1/utils/key.js.map +1 -1
  50. package/v1/module/ERC20Module.d.ts +0 -9
  51. package/v1/module/ERC20Module.js +0 -69
  52. package/v1/module/ERC20Module.js.map +0 -1
  53. package/v1/module/EthereumBaseModule.d.ts +0 -13
  54. package/v1/module/EthereumBaseModule.js +0 -83
  55. package/v1/module/EthereumBaseModule.js.map +0 -1
  56. package/v1/module/EthereumClassicModule.d.ts +0 -7
  57. package/v1/module/EthereumClassicModule.js +0 -32
  58. package/v1/module/EthereumClassicModule.js.map +0 -1
  59. package/v1/module/EthereumRopstenModule.d.ts +0 -7
  60. package/v1/module/EthereumRopstenModule.js +0 -32
  61. package/v1/module/EthereumRopstenModule.js.map +0 -1
  62. package/v1/protocol/EthereumClassicProtocol.d.ts +0 -8
  63. package/v1/protocol/EthereumClassicProtocol.js +0 -87
  64. package/v1/protocol/EthereumClassicProtocol.js.map +0 -1
  65. package/v1/protocol/EthereumRopstenProtocol.d.ts +0 -8
  66. package/v1/protocol/EthereumRopstenProtocol.js +0 -64
  67. package/v1/protocol/EthereumRopstenProtocol.js.map +0 -1
  68. package/v1/utils/transaction.d.ts +0 -3
  69. package/v1/utils/transaction.js +0 -29
  70. package/v1/utils/transaction.js.map +0 -1
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ERC20Tokens.js","sourceRoot":"","sources":["../../../src/v1/module/ERC20Tokens.ts"],"names":[],"mappings":";;;AAGa,QAAA,WAAW,GAAuC;IAC7D,gBAAgB,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,aAAa;QACnB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,gBAAgB;QAC5B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,gBAAgB,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,oBAAoB;QAC1B,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,gBAAgB;QAC5B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,CAAC;KACZ;IACD,eAAe,EAAE;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,kBAAkB;QACxB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,eAAe;QAC3B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,eAAe,EAAE;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,cAAc;QACpB,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,eAAe;QAC3B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,gBAAgB,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,iBAAiB;QACvB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,gBAAgB;QAC5B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,eAAe,EAAE;QACf,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E,MAAM;QACpB,UAAU,EAAE,gBAAgB;QAC5B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;IACD,gBAAgB,EAAE;QAChB,MAAM,EAAE,MAAM;QACd,IAAI,EAAE,WAAW;QACjB,YAAY,EAAE,MAAM;QACpB,UAAU,EAAE,gBAAgB;QAC5B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,CAAC;KACZ;IACD,eAAe,EAAE;QACf,MAAM,EAAE,KAAK;QACb,IAAI,EAAE,QAAQ;QACd,YAAY,EAAE,KAAK;QACnB,UAAU,EAAE,eAAe;QAC3B,eAAe,EAAE,4CAA4C;QAC7D,QAAQ,EAAE,EAAE;KACb;CACF,CAAA;AAEY,QAAA,sBAAsB,GAAa,MAAM,CAAC,IAAI,CAAC,mBAAW,CAAC,CAAA"}
@@ -1,7 +1,13 @@
1
- import { ProtocolNetwork } from '@airgap/module-kit';
2
- import { EthereumBaseProtocol } from '../protocol/EthereumBaseProtocol';
3
- import { EthereumBaseModule } from './EthereumBaseModule';
4
- export declare class EthereumModule extends EthereumBaseModule {
1
+ import { AirGapModule, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@airgap/module-kit';
2
+ import { BlockExplorer } from '@airgap/module-kit/block-explorer/block-explorer';
3
+ import { OfflineProtocol, OnlineProtocol } from '@airgap/module-kit/protocol/protocol';
4
+ export declare class EthereumModule implements AirGapModule {
5
+ private readonly networkRegistries;
6
+ readonly supportedProtocols: Record<string, ProtocolConfiguration>;
5
7
  constructor();
6
- createEthereumProtocol(network?: ProtocolNetwork | undefined): EthereumBaseProtocol;
8
+ createOfflineProtocol(identifier: string): Promise<OfflineProtocol | undefined>;
9
+ createOnlineProtocol(identifier: string, networkId?: string): Promise<OnlineProtocol | undefined>;
10
+ createBlockExplorer(identifier: string, networkId?: string): Promise<BlockExplorer | undefined>;
11
+ createV3SerializerCompanion(): Promise<AirGapV3SerializerCompanion>;
12
+ private createProtocol;
7
13
  }
@@ -1,32 +1,125 @@
1
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);
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
8
10
  };
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
- })();
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
14
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
15
+ return new (P || (P = Promise))(function (resolve, reject) {
16
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
17
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
18
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
19
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
20
+ });
21
+ };
22
+ var __generator = (this && this.__generator) || function (thisArg, body) {
23
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
24
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
25
+ function verb(n) { return function (v) { return step([n, v]); }; }
26
+ function step(op) {
27
+ if (f) throw new TypeError("Generator is already executing.");
28
+ while (_) try {
29
+ 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;
30
+ if (y = 0, t) op = [op[0] & 2, t.value];
31
+ switch (op[0]) {
32
+ case 0: case 1: t = op; break;
33
+ case 4: _.label++; return { value: op[1], done: false };
34
+ case 5: _.label++; y = op[1]; op = [0]; continue;
35
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
36
+ default:
37
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
38
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
39
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
40
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
41
+ if (t[2]) _.ops.pop();
42
+ _.trys.pop(); continue;
43
+ }
44
+ op = body.call(thisArg, _);
45
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
46
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
47
+ }
48
+ };
17
49
  Object.defineProperty(exports, "__esModule", { value: true });
18
50
  exports.EthereumModule = void 0;
51
+ var coinlib_core_1 = require("@airgap/coinlib-core");
52
+ var errors_1 = require("@airgap/coinlib-core/errors");
53
+ var module_kit_1 = require("@airgap/module-kit");
54
+ var EtherscanBlockExplorer_1 = require("../block-explorer/EtherscanBlockExplorer");
55
+ var ERC20Token_1 = require("../protocol/erc20/ERC20Token");
19
56
  var EthereumProtocol_1 = require("../protocol/EthereumProtocol");
20
- var EthereumBaseModule_1 = require("./EthereumBaseModule");
21
- var EthereumModule = /** @class */ (function (_super) {
22
- __extends(EthereumModule, _super);
57
+ var serializer_companion_1 = require("../serializer/v3/serializer-companion");
58
+ var ERC20Tokens_1 = require("./ERC20Tokens");
59
+ var EthereumModule = /** @class */ (function () {
23
60
  function EthereumModule() {
24
- return _super.call(this, [EthereumProtocol_1.ETHEREUM_MAINNET_PROTOCOL_NETWORK]) || this;
61
+ var _a;
62
+ var networkRegistry = new module_kit_1.ModuleNetworkRegistry({
63
+ supportedNetworks: [EthereumProtocol_1.ETHEREUM_MAINNET_PROTOCOL_NETWORK]
64
+ });
65
+ var erc20NetworkRegistry = new module_kit_1.ModuleNetworkRegistry({
66
+ supportedNetworks: [ERC20Token_1.ETHEREUM_ERC20_MAINNET_PROTOCOL_NETWORK]
67
+ });
68
+ this.networkRegistries = __assign((_a = {}, _a[coinlib_core_1.MainProtocolSymbols.ETH] = networkRegistry, _a), ERC20Tokens_1.erc20TokensIdentifiers.reduce(function (obj, next) {
69
+ var _a;
70
+ return Object.assign(obj, (_a = {}, _a[next] = erc20NetworkRegistry, _a));
71
+ }, {}));
72
+ this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
25
73
  }
26
- EthereumModule.prototype.createEthereumProtocol = function (network) {
27
- return (0, EthereumProtocol_1.createEthereumProtocol)({ network: network });
74
+ EthereumModule.prototype.createOfflineProtocol = function (identifier) {
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ return [2 /*return*/, this.createProtocol(identifier)];
78
+ });
79
+ });
80
+ };
81
+ EthereumModule.prototype.createOnlineProtocol = function (identifier, networkId) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var network;
84
+ return __generator(this, function (_a) {
85
+ network = this.networkRegistries[identifier].findNetwork(networkId);
86
+ if (network === undefined) {
87
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ETHEREUM, 'Protocol network type not supported.');
88
+ }
89
+ return [2 /*return*/, this.createProtocol(identifier, network)];
90
+ });
91
+ });
92
+ };
93
+ EthereumModule.prototype.createBlockExplorer = function (identifier, networkId) {
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ var network;
96
+ return __generator(this, function (_a) {
97
+ network = this.networkRegistries[identifier].findNetwork(networkId);
98
+ if (network === undefined) {
99
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ETHEREUM, 'Block Explorer network type not supported.');
100
+ }
101
+ return [2 /*return*/, new EtherscanBlockExplorer_1.EtherscanBlockExplorer()];
102
+ });
103
+ });
104
+ };
105
+ EthereumModule.prototype.createV3SerializerCompanion = function () {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ return __generator(this, function (_a) {
108
+ return [2 /*return*/, new serializer_companion_1.EthereumV3SerializerCompanion()];
109
+ });
110
+ });
111
+ };
112
+ EthereumModule.prototype.createProtocol = function (identifier, network) {
113
+ if (identifier === coinlib_core_1.MainProtocolSymbols.ETH) {
114
+ return (0, EthereumProtocol_1.createEthereumProtocol)({ network: network });
115
+ }
116
+ if (ERC20Tokens_1.erc20Tokens[identifier] !== undefined) {
117
+ var tokenMetadata = ERC20Tokens_1.erc20Tokens[identifier];
118
+ return (0, ERC20Token_1.createERC20Token)(tokenMetadata);
119
+ }
120
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported."));
28
121
  };
29
122
  return EthereumModule;
30
- }(EthereumBaseModule_1.EthereumBaseModule));
123
+ }());
31
124
  exports.EthereumModule = EthereumModule;
32
125
  //# sourceMappingURL=EthereumModule.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"EthereumModule.js","sourceRoot":"","sources":["../../../src/v1/module/EthereumModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAGA,iEAAwG;AAExG,2DAAyD;AAEzD;IAAoC,kCAAkB;IACpD;eACE,kBAAM,CAAC,oDAAiC,CAAC,CAAC;IAC5C,CAAC;IAEM,+CAAsB,GAA7B,UAA8B,OAAqC;QACjE,OAAO,IAAA,yCAAsB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAA;IAC5C,CAAC;IACH,qBAAC;AAAD,CAAC,AARD,CAAoC,uCAAkB,GAQrD;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AO,IAAI,CAAC,cAAc,CAAC,UAAU,EAAE,OAAO,CAAC,EAAA;;;KAChD;IAEY,4CAAmB,GAAhC,UAAiC,UAAkB,EAAE,SAAkB;;;;gBAC/D,OAAO,GAAgC,IAAI,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,WAAW,CAAC,SAAS,CAAC,CAAA;gBACtG,IAAI,OAAO,KAAK,SAAS,EAAE;oBACzB,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,QAAQ,EAAE,4CAA4C,CAAC,CAAA;iBACjG;gBAED,sBAAO,IAAI,+CAAsB,EAAE,EAAA;;;KACpC;IAEY,oDAA2B,GAAxC;;;gBACE,sBAAO,IAAI,oDAA6B,EAAE,EAAA;;;KAC3C;IAEO,uCAAc,GAAtB,UAAuB,UAAkB,EAAE,OAAyB;QAClE,IAAI,UAAU,KAAK,kCAAmB,CAAC,GAAG,EAAE;YAC1C,OAAO,IAAA,yCAAsB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAA;SAC3C;QAED,IAAI,yBAAW,CAAC,UAAU,CAAC,KAAK,SAAS,EAAE;YACzC,IAAM,aAAa,GAAuB,yBAAW,CAAC,UAAU,CAAC,CAAA;YAEjE,OAAO,IAAA,6BAAgB,EAAC,aAAa,CAAC,CAAA;SACvC;QAED,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,QAAQ,EAAE,mBAAY,UAAU,oBAAiB,CAAC,CAAA;IAC7F,CAAC;IACH,qBAAC;AAAD,CAAC,AA7DD,IA6DC;AA7DY,wCAAc"}
@@ -1,5 +1,5 @@
1
1
  import { BigNumber } from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
- import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionStatus, AirGapTransactionsWithCursor, Amount, Balance, FeeDefaults, KeyPair, ProtocolMetadata, ProtocolUnitsMetadata, PublicKey, Secret, SecretKey, Signature, TransactionConfiguration, TransactionDetails } from '@airgap/module-kit';
2
+ import { Address, AirGapProtocol, AirGapTransaction, AirGapTransactionStatus, AirGapTransactionsWithCursor, Amount, Balance, ExtendedKeyPair, ExtendedPublicKey, ExtendedSecretKey, FeeDefaults, KeyPair, ProtocolMetadata, ProtocolUnitsMetadata, PublicKey, Secret, SecretKey, Signature, TransactionConfiguration, TransactionDetails } from '@airgap/module-kit';
3
3
  import { EthereumCryptoClient } from '../clients/crypto/EthereumCryptoClient';
4
4
  import { EthereumInfoClient } from '../clients/info/EthereumInfoClient';
5
5
  import { EthereumNodeClient } from '../clients/node/EthereumNodeClient';
@@ -14,7 +14,7 @@ export interface EthereumBaseProtocol<_Units extends string = EthereumUnits> ext
14
14
  SignedTransaction: EthereumSignedTransaction;
15
15
  UnsignedTransaction: EthereumUnsignedTransaction;
16
16
  TransactionCursor: EthereumTransactionCursor;
17
- }, 'Crypto', 'FetchDataForAddress', 'FetchDataForMultipleAddresses', 'TransactionStatusChecker'> {
17
+ }, 'Bip32', 'Crypto', 'FetchDataForAddress', 'FetchDataForMultipleAddresses', 'TransactionStatusChecker'> {
18
18
  }
19
19
  export declare const DEFAULT_ETHEREUM_UNITS_METADATA: ProtocolUnitsMetadata<EthereumUnits>;
20
20
  export declare abstract class EthereumBaseProtocolImpl<_Units extends string = EthereumUnits> implements EthereumBaseProtocol<_Units> {
@@ -34,36 +34,48 @@ export declare abstract class EthereumBaseProtocolImpl<_Units extends string = E
34
34
  protected readonly feeDefaults: FeeDefaults<EthereumUnits>;
35
35
  protected readonly metadata: ProtocolMetadata<_Units, EthereumUnits>;
36
36
  getMetadata(): Promise<ProtocolMetadata<_Units, EthereumUnits>>;
37
- getAddressFromPublicKey(publicKey: PublicKey): Promise<string>;
38
- getDetailsFromTransaction(transaction: EthereumSignedTransaction | EthereumUnsignedTransaction, publicKey: PublicKey): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
37
+ getAddressFromPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
38
+ deriveFromExtendedPublicKey(extendedPublicKey: ExtendedPublicKey, visibilityIndex: number, addressIndex: number): Promise<PublicKey>;
39
+ getDetailsFromTransaction(transaction: EthereumSignedTransaction | EthereumUnsignedTransaction, publicKey: PublicKey | ExtendedPublicKey): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
40
+ private getDetailsFromTransactionWithPublicKey;
41
+ private getDetailsFromTransactionWithExtendedPublicKey;
39
42
  protected getDetailsFromSignedTransaction(transaction: EthereumSignedTransaction): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
40
43
  protected getDetailsFromTypedUnsignedTransaction(transaction: EthereumTypedUnsignedTransaction, ownAddress: string): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
41
44
  protected getDetailsFromRawUnsignedTransaction(transaction: EthereumRawUnsignedTransaction, ownAddress: string): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
42
- verifyMessageWithPublicKey(message: string, signature: Signature, publicKey: PublicKey): Promise<boolean>;
43
- encryptAsymmetricWithPublicKey(payload: string, publicKey: PublicKey): Promise<string>;
45
+ verifyMessageWithPublicKey(message: string, signature: Signature, publicKey: PublicKey | ExtendedPublicKey): Promise<boolean>;
46
+ encryptAsymmetricWithPublicKey(payload: string, publicKey: PublicKey | ExtendedPublicKey): Promise<string>;
44
47
  getKeyPairFromSecret(secret: Secret, derivationPath?: string): Promise<KeyPair>;
45
48
  private getKeyPairFromHexSecret;
46
49
  private getKeyPairFromMnemonic;
47
- signTransactionWithSecretKey(transaction: EthereumUnsignedTransaction, secretKey: SecretKey): Promise<EthereumSignedTransaction>;
50
+ getExtendedKeyPairFromSecret(secret: Secret, derivationPath?: string): Promise<ExtendedKeyPair>;
51
+ private getExtendedKeyPairFromHexSecret;
52
+ private getExtendedKeyPairFromMnemonic;
53
+ deriveFromExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, visibilityIndex: number, addressIndex: number): Promise<SecretKey>;
54
+ signTransactionWithSecretKey(transaction: EthereumUnsignedTransaction, secretKey: SecretKey | ExtendedSecretKey): Promise<EthereumSignedTransaction>;
48
55
  private signTypedUnsignedTransactionWithSecretKey;
49
56
  private signRawUnsignedTransactionWithSecretKey;
50
57
  private signTypedTransactionWithSecretKey;
51
- signMessageWithKeyPair(message: string, keyPair: KeyPair): Promise<Signature>;
52
- decryptAsymmetricWithKeyPair(payload: string, keyPair: KeyPair): Promise<string>;
53
- encryptAESWithSecretKey(payload: string, secretKey: SecretKey): Promise<string>;
54
- decryptAESWithSecretKey(payload: string, secretKey: SecretKey): Promise<string>;
58
+ signMessageWithKeyPair(message: string, keyPair: KeyPair | ExtendedKeyPair): Promise<Signature>;
59
+ decryptAsymmetricWithKeyPair(payload: string, keyPair: KeyPair | ExtendedKeyPair): Promise<string>;
60
+ encryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
61
+ decryptAESWithSecretKey(payload: string, secretKey: SecretKey | ExtendedSecretKey): Promise<string>;
55
62
  getNetwork(): Promise<EthereumProtocolNetwork>;
56
- getTransactionsForPublicKey(publicKey: PublicKey, limit: number, cursor?: EthereumTransactionCursor): Promise<AirGapTransactionsWithCursor<EthereumTransactionCursor, _Units, EthereumUnits>>;
63
+ getTransactionsForPublicKey(publicKey: PublicKey | ExtendedPublicKey, limit: number, cursor?: EthereumTransactionCursor): Promise<AirGapTransactionsWithCursor<EthereumTransactionCursor, _Units, EthereumUnits>>;
57
64
  getTransactionsForAddress(address: string, limit: number, cursor?: EthereumTransactionCursor): Promise<AirGapTransactionsWithCursor<EthereumTransactionCursor, _Units, EthereumUnits>>;
58
65
  getTransactionsForAddresses(addresses: string[], limit: number, cursor?: EthereumTransactionCursor): Promise<AirGapTransactionsWithCursor<EthereumTransactionCursor, _Units, EthereumUnits>>;
59
66
  getTransactionStatus(transactionIds: string[]): Promise<Record<string, AirGapTransactionStatus>>;
60
- getBalanceOfPublicKey(publicKey: PublicKey): Promise<Balance<_Units>>;
67
+ getBalanceOfPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<Balance<_Units>>;
61
68
  getBalanceOfAddress(address: string): Promise<Balance<_Units>>;
62
69
  getBalanceOfAddresses(addresses: string[]): Promise<Balance<_Units>>;
63
- getTransactionMaxAmountWithPublicKey(publicKey: PublicKey, to: string[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<Amount<_Units>>;
64
- getTransactionFeeWithPublicKey(publicKey: PublicKey, details: TransactionDetails<_Units>[]): Promise<FeeDefaults<EthereumUnits>>;
65
- prepareTransactionWithPublicKey(publicKey: PublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<EthereumUnsignedTransaction>;
70
+ getTransactionMaxAmountWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, to: string[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<Amount<_Units>>;
71
+ getTransactionFeeWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[]): Promise<FeeDefaults<EthereumUnits>>;
72
+ prepareTransactionWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<EthereumUnsignedTransaction>;
66
73
  broadcastTransaction(transaction: EthereumSignedTransaction): Promise<string>;
74
+ private nonExtendedPublicKey;
75
+ private nonExtendedSecretKey;
76
+ private getPublicKeyFromExtendedPublicKey;
77
+ private getSecretKeyFromExtendedSecretKey;
78
+ private deriveNode;
67
79
  protected estimateGas(fromAddress: string, toAddress: string, amount: string | number | BigNumber | Amount<_Units>, data?: string): Promise<BigNumber>;
68
80
  }
69
81
  export declare abstract class DefaultEthereumBaseProtocolImpl extends EthereumBaseProtocolImpl {
@@ -92,7 +92,9 @@ exports.DefaultEthereumBaseProtocolImpl = exports.EthereumBaseProtocolImpl = exp
92
92
  // tslint:disable: max-classes-per-file
93
93
  var coinlib_core_1 = require("@airgap/coinlib-core");
94
94
  var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
95
+ // @ts-ignore
95
96
  var bip39_2_5_0_1 = require("@airgap/coinlib-core/dependencies/src/bip39-2.5.0");
97
+ // @ts-ignore
96
98
  var BitGo = __importStar(require("@airgap/coinlib-core/dependencies/src/bitgo-utxo-lib-5d91049fd7a988382df81c8260e244ee56d57aac/src"));
97
99
  var errors_1 = require("@airgap/coinlib-core/errors");
98
100
  var hex_1 = require("@airgap/coinlib-core/utils/hex");
@@ -104,7 +106,6 @@ var EthereumCryptoClient_1 = require("../clients/crypto/EthereumCryptoClient");
104
106
  var EthereumAddress_1 = require("../data/EthereumAddress");
105
107
  var EthereumUtils_1 = require("../utils/EthereumUtils");
106
108
  var key_1 = require("../utils/key");
107
- var transaction_1 = require("../utils/transaction");
108
109
  var EthereumChainIds_1 = require("./EthereumChainIds");
109
110
  // Implementation
110
111
  exports.DEFAULT_ETHEREUM_UNITS_METADATA = {
@@ -146,10 +147,12 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
146
147
  units: options.units,
147
148
  mainUnit: options.mainUnit,
148
149
  fee: {
149
- defaults: this.feeDefaults
150
+ defaults: this.feeDefaults,
151
+ units: this.feeUnits,
152
+ mainUnit: 'ETH'
150
153
  },
151
154
  account: {
152
- standardDerivationPath: (_b = options.standardDerivationPath) !== null && _b !== void 0 ? _b : "m/44'/60'/0'/0/0",
155
+ standardDerivationPath: (_b = options.standardDerivationPath) !== null && _b !== void 0 ? _b : "m/44'/60'/0'",
153
156
  address: {
154
157
  isCaseSensitive: false,
155
158
  placeholder: '0xabc...',
@@ -173,11 +176,27 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
173
176
  EthereumBaseProtocolImpl.prototype.getAddressFromPublicKey = function (publicKey) {
174
177
  return __awaiter(this, void 0, void 0, function () {
175
178
  return __generator(this, function (_a) {
176
- return [2 /*return*/, EthereumAddress_1.EthereumAddress.from(publicKey).asString()];
179
+ return [2 /*return*/, EthereumAddress_1.EthereumAddress.from(this.nonExtendedPublicKey(publicKey)).asString()];
180
+ });
181
+ });
182
+ };
183
+ EthereumBaseProtocolImpl.prototype.deriveFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
184
+ return __awaiter(this, void 0, void 0, function () {
185
+ return __generator(this, function (_a) {
186
+ return [2 /*return*/, this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, visibilityIndex, addressIndex)];
177
187
  });
178
188
  });
179
189
  };
180
190
  EthereumBaseProtocolImpl.prototype.getDetailsFromTransaction = function (transaction, publicKey) {
191
+ return __awaiter(this, void 0, void 0, function () {
192
+ return __generator(this, function (_a) {
193
+ return [2 /*return*/, publicKey.type === 'pub'
194
+ ? this.getDetailsFromTransactionWithPublicKey(transaction, publicKey)
195
+ : this.getDetailsFromTransactionWithExtendedPublicKey(transaction, publicKey)];
196
+ });
197
+ });
198
+ };
199
+ EthereumBaseProtocolImpl.prototype.getDetailsFromTransactionWithPublicKey = function (transaction, publicKey) {
181
200
  return __awaiter(this, void 0, void 0, function () {
182
201
  var _a, ownAddress;
183
202
  return __generator(this, function (_b) {
@@ -193,7 +212,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
193
212
  case 2: return [4 /*yield*/, this.getAddressFromPublicKey(publicKey)];
194
213
  case 3:
195
214
  ownAddress = _b.sent();
196
- if ((0, transaction_1.isTypedUnsignedTransaction)(transaction)) {
215
+ if (transaction.ethereumType === 'typed') {
197
216
  return [2 /*return*/, this.getDetailsFromTypedUnsignedTransaction(transaction, ownAddress)];
198
217
  }
199
218
  else {
@@ -207,6 +226,40 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
207
226
  });
208
227
  });
209
228
  };
229
+ EthereumBaseProtocolImpl.prototype.getDetailsFromTransactionWithExtendedPublicKey = function (transaction, extendedPublicKey) {
230
+ return __awaiter(this, void 0, void 0, function () {
231
+ var _a, dps, derivedPublicKey, ownAddress, derivedPublicKey, ownAddress;
232
+ return __generator(this, function (_b) {
233
+ switch (_b.label) {
234
+ case 0:
235
+ _a = transaction.type;
236
+ switch (_a) {
237
+ case 'signed': return [3 /*break*/, 1];
238
+ case 'unsigned': return [3 /*break*/, 2];
239
+ }
240
+ return [3 /*break*/, 6];
241
+ case 1: return [2 /*return*/, this.getDetailsFromSignedTransaction(transaction)];
242
+ case 2:
243
+ if (!(transaction.ethereumType === 'typed')) return [3 /*break*/, 4];
244
+ dps = transaction.derivationPath.split('/');
245
+ derivedPublicKey = this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, Number(dps[dps.length - 2]), Number(dps[dps.length - 1]));
246
+ return [4 /*yield*/, this.getAddressFromPublicKey(derivedPublicKey)];
247
+ case 3:
248
+ ownAddress = _b.sent();
249
+ return [2 /*return*/, this.getDetailsFromTypedUnsignedTransaction(transaction, ownAddress)];
250
+ case 4:
251
+ derivedPublicKey = this.getPublicKeyFromExtendedPublicKey(extendedPublicKey, 0, 0);
252
+ return [4 /*yield*/, this.getAddressFromPublicKey(derivedPublicKey)];
253
+ case 5:
254
+ ownAddress = _b.sent();
255
+ return [2 /*return*/, this.getDetailsFromRawUnsignedTransaction(transaction, ownAddress)];
256
+ case 6:
257
+ (0, coinlib_core_1.assertNever)(transaction);
258
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, 'Unsupported transaction type.');
259
+ }
260
+ });
261
+ });
262
+ };
210
263
  EthereumBaseProtocolImpl.prototype.getDetailsFromSignedTransaction = function (transaction) {
211
264
  var _a, _b;
212
265
  return __awaiter(this, void 0, void 0, function () {
@@ -237,7 +290,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
237
290
  hash: "0x".concat(tx.hash().toString('hex'))
238
291
  },
239
292
  arbitraryData: "0x".concat(tx.data.toString('hex')),
240
- json: {
293
+ extra: {
241
294
  chainId: chainId,
242
295
  nonce: parseInt(hexNonce, 16)
243
296
  }
@@ -255,7 +308,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
255
308
  fee: (0, module_kit_1.newAmount)(new bignumber_1.BigNumber(feeTx.gasLimit.toString(10)).multipliedBy(feeTx.maxFeePerGas.toString(10)), 'blockchain'),
256
309
  network: this.options.network,
257
310
  arbitraryData: feeTx.data.toString('hex'),
258
- json: {
311
+ extra: {
259
312
  chainId: feeTx.chainId.toNumber(),
260
313
  nonce: feeTx.nonce.toNumber()
261
314
  }
@@ -318,7 +371,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
318
371
  var hexSignature, hexPublicKey;
319
372
  return __generator(this, function (_a) {
320
373
  hexSignature = signature;
321
- hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex');
374
+ hexPublicKey = (0, key_1.convertPublicKey)(this.nonExtendedPublicKey(publicKey), 'hex');
322
375
  return [2 /*return*/, this.cryptoClient.verifyMessage(message, hexSignature.value, hexPublicKey.value)];
323
376
  });
324
377
  });
@@ -327,7 +380,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
327
380
  return __awaiter(this, void 0, void 0, function () {
328
381
  var hexPublicKey;
329
382
  return __generator(this, function (_a) {
330
- hexPublicKey = (0, key_1.convertPublicKey)(publicKey, 'hex');
383
+ hexPublicKey = (0, key_1.convertPublicKey)(this.nonExtendedPublicKey(publicKey), 'hex');
331
384
  return [2 /*return*/, this.cryptoClient.encryptAsymmetric(payload, hexPublicKey.value)];
332
385
  });
333
386
  });
@@ -371,12 +424,57 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
371
424
  });
372
425
  });
373
426
  };
427
+ EthereumBaseProtocolImpl.prototype.getExtendedKeyPairFromSecret = function (secret, derivationPath) {
428
+ return __awaiter(this, void 0, void 0, function () {
429
+ return __generator(this, function (_a) {
430
+ switch (secret.type) {
431
+ case 'hex':
432
+ return [2 /*return*/, this.getExtendedKeyPairFromHexSecret(secret.value, derivationPath)];
433
+ case 'mnemonic':
434
+ return [2 /*return*/, this.getExtendedKeyPairFromMnemonic(secret.value, derivationPath, secret.password)];
435
+ default:
436
+ (0, coinlib_core_1.assertNever)(secret);
437
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.BITCOIN, 'Unsupported secret type.');
438
+ }
439
+ return [2 /*return*/];
440
+ });
441
+ });
442
+ };
443
+ EthereumBaseProtocolImpl.prototype.getExtendedKeyPairFromHexSecret = function (secret, derivationPath) {
444
+ return __awaiter(this, void 0, void 0, function () {
445
+ var node, derivedNode;
446
+ return __generator(this, function (_a) {
447
+ node = this.bitcoinJS.lib.HDNode.fromSeedHex(secret, this.bitcoinJS.config.network);
448
+ derivedNode = derivationPath ? node.derivePath(derivationPath) : node;
449
+ return [2 /*return*/, {
450
+ secretKey: (0, module_kit_1.newExtendedSecretKey)(derivedNode.toBase58(), 'encoded'),
451
+ publicKey: (0, module_kit_1.newExtendedPublicKey)(derivedNode.neutered().toBase58(), 'encoded')
452
+ }];
453
+ });
454
+ });
455
+ };
456
+ EthereumBaseProtocolImpl.prototype.getExtendedKeyPairFromMnemonic = function (mnemonic, derivationPath, password) {
457
+ return __awaiter(this, void 0, void 0, function () {
458
+ var secret;
459
+ return __generator(this, function (_a) {
460
+ secret = (0, bip39_2_5_0_1.mnemonicToSeed)(mnemonic, password);
461
+ return [2 /*return*/, this.getExtendedKeyPairFromHexSecret(secret.toString('hex'), derivationPath)];
462
+ });
463
+ });
464
+ };
465
+ EthereumBaseProtocolImpl.prototype.deriveFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
466
+ return __awaiter(this, void 0, void 0, function () {
467
+ return __generator(this, function (_a) {
468
+ return [2 /*return*/, this.getSecretKeyFromExtendedSecretKey(extendedSecretKey, visibilityIndex, addressIndex)];
469
+ });
470
+ });
471
+ };
374
472
  EthereumBaseProtocolImpl.prototype.signTransactionWithSecretKey = function (transaction, secretKey) {
375
473
  return __awaiter(this, void 0, void 0, function () {
376
474
  return __generator(this, function (_a) {
377
- return [2 /*return*/, (0, transaction_1.isTypedUnsignedTransaction)(transaction)
378
- ? this.signTypedUnsignedTransactionWithSecretKey(transaction, secretKey)
379
- : this.signRawUnsignedTransactionWithSecretKey(transaction, secretKey)];
475
+ return [2 /*return*/, transaction.ethereumType === 'typed'
476
+ ? this.signTypedUnsignedTransactionWithSecretKey(transaction, this.nonExtendedSecretKey(secretKey))
477
+ : this.signRawUnsignedTransactionWithSecretKey(transaction, this.nonExtendedSecretKey(secretKey))];
380
478
  });
381
479
  });
382
480
  };
@@ -430,7 +528,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
430
528
  return __generator(this, function (_a) {
431
529
  switch (_a.label) {
432
530
  case 0:
433
- hexSecretKey = (0, key_1.convertSecretKey)(keyPair.secretKey, 'hex');
531
+ hexSecretKey = (0, key_1.convertSecretKey)(this.nonExtendedSecretKey(keyPair.secretKey), 'hex');
434
532
  return [4 /*yield*/, this.cryptoClient.signMessage(message, { privateKey: hexSecretKey.value })];
435
533
  case 1:
436
534
  signature = _a.sent();
@@ -443,8 +541,8 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
443
541
  return __awaiter(this, void 0, void 0, function () {
444
542
  var hexSecretKey, hexPublicKey;
445
543
  return __generator(this, function (_a) {
446
- hexSecretKey = (0, key_1.convertSecretKey)(keyPair.secretKey, 'hex');
447
- hexPublicKey = (0, key_1.convertPublicKey)(keyPair.publicKey, 'hex');
544
+ hexSecretKey = (0, key_1.convertSecretKey)(this.nonExtendedSecretKey(keyPair.secretKey), 'hex');
545
+ hexPublicKey = (0, key_1.convertPublicKey)(this.nonExtendedPublicKey(keyPair.publicKey), 'hex');
448
546
  return [2 /*return*/, this.cryptoClient.decryptAsymmetric(payload, { privateKey: hexSecretKey.value, publicKey: hexPublicKey.value })];
449
547
  });
450
548
  });
@@ -453,7 +551,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
453
551
  return __awaiter(this, void 0, void 0, function () {
454
552
  var hexSecretKey;
455
553
  return __generator(this, function (_a) {
456
- hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex');
554
+ hexSecretKey = (0, key_1.convertSecretKey)(this.nonExtendedSecretKey(secretKey), 'hex');
457
555
  return [2 /*return*/, this.cryptoClient.encryptAES(payload, hexSecretKey.value)];
458
556
  });
459
557
  });
@@ -462,7 +560,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
462
560
  return __awaiter(this, void 0, void 0, function () {
463
561
  var hexSecretKey;
464
562
  return __generator(this, function (_a) {
465
- hexSecretKey = (0, key_1.convertSecretKey)(secretKey, 'hex');
563
+ hexSecretKey = (0, key_1.convertSecretKey)(this.nonExtendedSecretKey(secretKey), 'hex');
466
564
  return [2 /*return*/, this.cryptoClient.decryptAES(payload, hexSecretKey.value)];
467
565
  });
468
566
  });
@@ -693,6 +791,7 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
693
791
  case 7:
694
792
  txCount = _b.sent();
695
793
  transaction = (0, module_kit_1.newUnsignedTransaction)({
794
+ ethereumType: 'raw',
696
795
  nonce: EthereumUtils_1.EthereumUtils.toHex(txCount),
697
796
  gasLimit: EthereumUtils_1.EthereumUtils.toHex(gasLimit.toFixed()),
698
797
  gasPrice: EthereumUtils_1.EthereumUtils.toHex(gasPrice.toFixed()),
@@ -715,6 +814,29 @@ var EthereumBaseProtocolImpl = /** @class */ (function () {
715
814
  });
716
815
  };
717
816
  // Custom
817
+ EthereumBaseProtocolImpl.prototype.nonExtendedPublicKey = function (publicKey) {
818
+ return publicKey.type === 'pub' ? publicKey : this.getPublicKeyFromExtendedPublicKey(publicKey);
819
+ };
820
+ EthereumBaseProtocolImpl.prototype.nonExtendedSecretKey = function (secretKey) {
821
+ return secretKey.type === 'priv' ? secretKey : this.getSecretKeyFromExtendedSecretKey(secretKey);
822
+ };
823
+ EthereumBaseProtocolImpl.prototype.getPublicKeyFromExtendedPublicKey = function (extendedPublicKey, visibilityIndex, addressIndex) {
824
+ if (visibilityIndex === void 0) { visibilityIndex = 0; }
825
+ if (addressIndex === void 0) { addressIndex = 0; }
826
+ var encodedExtendedPublicKey = (0, key_1.convertExtendedPublicKey)(extendedPublicKey, 'encoded');
827
+ var derivedNode = this.deriveNode(encodedExtendedPublicKey.value, visibilityIndex, addressIndex);
828
+ return (0, module_kit_1.newPublicKey)(derivedNode.neutered().keyPair.getPublicKeyBuffer().toString('hex'), 'hex');
829
+ };
830
+ EthereumBaseProtocolImpl.prototype.getSecretKeyFromExtendedSecretKey = function (extendedSecretKey, visibilityIndex, addressIndex) {
831
+ if (visibilityIndex === void 0) { visibilityIndex = 0; }
832
+ if (addressIndex === void 0) { addressIndex = 0; }
833
+ var encodedExtendedSecretKey = (0, key_1.convertExtendedSecretKey)(extendedSecretKey, 'encoded');
834
+ var derivedNode = this.deriveNode(encodedExtendedSecretKey.value, visibilityIndex, addressIndex);
835
+ return (0, module_kit_1.newSecretKey)(derivedNode.keyPair.getPrivateKeyBuffer().toString('hex'), 'hex');
836
+ };
837
+ EthereumBaseProtocolImpl.prototype.deriveNode = function (base58, visibilityIndex, addressIndex) {
838
+ return [visibilityIndex, addressIndex].reduce(function (node, index) { return node.derive(index); }, this.bitcoinJS.lib.HDNode.fromBase58(base58, this.bitcoinJS.config.network));
839
+ };
718
840
  EthereumBaseProtocolImpl.prototype.estimateGas = function (fromAddress, toAddress, amount, data) {
719
841
  return __awaiter(this, void 0, void 0, function () {
720
842
  var hexAmount, blockchainAmount;