@airgap/ethereum 0.13.16-beta.1 → 0.13.16-beta.3
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 +7 -7
- package/v1/block-explorer/EtherscanBlockExplorer.d.ts +1 -1
- package/v1/block-explorer/EtherscanBlockExplorer.js +0 -2
- package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -1
- package/v1/clients/info/EtherscanInfoClient.d.ts +1 -2
- package/v1/clients/info/EtherscanInfoClient.js +4 -6
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -1
- package/v1/clients/node/AirGapNodeClient.d.ts +0 -18
- package/v1/clients/node/AirGapNodeClient.js +1 -2
- package/v1/clients/node/AirGapNodeClient.js.map +1 -1
- package/v1/index.d.ts +6 -17
- package/v1/index.js +3 -26
- package/v1/index.js.map +1 -1
- package/v1/module/EthereumModule.d.ts +6 -3
- package/v1/module/EthereumModule.js +10 -8
- package/v1/module/EthereumModule.js.map +1 -1
- package/v1/protocol/EthereumBaseProtocol.d.ts +12 -12
- package/v1/protocol/EthereumBaseProtocol.js +1 -1
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumProtocol.d.ts +4 -2
- package/v1/protocol/EthereumProtocol.js +61 -3
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.d.ts +5 -16
- package/v1/protocol/erc20/ERC20Token.js +314 -24
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +5 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +5 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +42 -50
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/types/protocol.d.ts +6 -10
- package/v1/utils/EthereumUtils.d.ts +0 -2
- package/v1/utils/EthereumUtils.js +0 -9
- package/v1/utils/EthereumUtils.js.map +1 -1
- package/v1/protocol/erc20/ERC20Protocol.d.ts +0 -26
- package/v1/protocol/erc20/ERC20Protocol.js +0 -376
- package/v1/protocol/erc20/ERC20Protocol.js.map +0 -1
|
@@ -79,12 +79,11 @@ 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
|
-
|
|
87
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
82
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
83
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
84
|
+
}
|
|
85
|
+
else {
|
|
86
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
88
87
|
}
|
|
89
88
|
return [2 /*return*/];
|
|
90
89
|
});
|
|
@@ -93,12 +92,11 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
93
92
|
EthereumV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
94
93
|
return __awaiter(this, void 0, void 0, function () {
|
|
95
94
|
return __generator(this, function (_a) {
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
95
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
96
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
97
|
+
}
|
|
98
|
+
else {
|
|
99
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
102
100
|
}
|
|
103
101
|
return [2 /*return*/];
|
|
104
102
|
});
|
|
@@ -106,26 +104,24 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
106
104
|
};
|
|
107
105
|
EthereumV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
108
106
|
return __awaiter(this, void 0, void 0, function () {
|
|
109
|
-
var _a
|
|
110
|
-
return __generator(this, function (
|
|
111
|
-
switch (
|
|
107
|
+
var _a;
|
|
108
|
+
return __generator(this, function (_b) {
|
|
109
|
+
switch (_b.label) {
|
|
112
110
|
case 0:
|
|
113
|
-
|
|
114
|
-
|
|
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];
|
|
111
|
+
if (!(identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20))) return [3 /*break*/, 5];
|
|
112
|
+
_b.label = 1;
|
|
119
113
|
case 1:
|
|
120
|
-
|
|
114
|
+
_b.trys.push([1, 3, , 4]);
|
|
121
115
|
return [4 /*yield*/, this.ethereumTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
|
|
122
116
|
case 2:
|
|
123
|
-
|
|
117
|
+
_b.sent();
|
|
124
118
|
return [2 /*return*/, true];
|
|
125
119
|
case 3:
|
|
126
|
-
|
|
120
|
+
_a = _b.sent();
|
|
127
121
|
return [2 /*return*/, false];
|
|
128
|
-
case 4:
|
|
122
|
+
case 4: return [3 /*break*/, 6];
|
|
123
|
+
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
124
|
+
case 6: return [2 /*return*/];
|
|
129
125
|
}
|
|
130
126
|
});
|
|
131
127
|
});
|
|
@@ -133,12 +129,11 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
133
129
|
EthereumV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
|
|
134
130
|
return __awaiter(this, void 0, void 0, function () {
|
|
135
131
|
return __generator(this, function (_a) {
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
132
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
133
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
134
|
+
}
|
|
135
|
+
else {
|
|
136
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
142
137
|
}
|
|
143
138
|
return [2 /*return*/];
|
|
144
139
|
});
|
|
@@ -147,12 +142,11 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
147
142
|
EthereumV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
148
143
|
return __awaiter(this, void 0, void 0, function () {
|
|
149
144
|
return __generator(this, function (_a) {
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
145
|
+
if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
|
|
146
|
+
return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
147
|
+
}
|
|
148
|
+
else {
|
|
149
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
156
150
|
}
|
|
157
151
|
return [2 /*return*/];
|
|
158
152
|
});
|
|
@@ -160,26 +154,24 @@ var EthereumV3SerializerCompanion = /** @class */ (function () {
|
|
|
160
154
|
};
|
|
161
155
|
EthereumV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
162
156
|
return __awaiter(this, void 0, void 0, function () {
|
|
163
|
-
var _a
|
|
164
|
-
return __generator(this, function (
|
|
165
|
-
switch (
|
|
157
|
+
var _a;
|
|
158
|
+
return __generator(this, function (_b) {
|
|
159
|
+
switch (_b.label) {
|
|
166
160
|
case 0:
|
|
167
|
-
|
|
168
|
-
|
|
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];
|
|
161
|
+
if (!(identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20))) return [3 /*break*/, 5];
|
|
162
|
+
_b.label = 1;
|
|
173
163
|
case 1:
|
|
174
|
-
|
|
164
|
+
_b.trys.push([1, 3, , 4]);
|
|
175
165
|
return [4 /*yield*/, this.ethereumTransactionValidator.validateSignedTransaction(transactionSignResponse)];
|
|
176
166
|
case 2:
|
|
177
|
-
|
|
167
|
+
_b.sent();
|
|
178
168
|
return [2 /*return*/, true];
|
|
179
169
|
case 3:
|
|
180
|
-
|
|
170
|
+
_a = _b.sent();
|
|
181
171
|
return [2 /*return*/, false];
|
|
182
|
-
case 4:
|
|
172
|
+
case 4: return [3 /*break*/, 6];
|
|
173
|
+
case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
|
|
174
|
+
case 6: return [2 /*return*/];
|
|
183
175
|
}
|
|
184
176
|
});
|
|
185
177
|
});
|
|
@@ -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;gBAC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AA1F,SAA0F,CAAA;wBAE1F,sBAAO,IAAI,EAAA;;;wBAEX,sBAAO,KAAK,EAAA;;4BAGd,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,QAAQ,EAAE,mBAAY,UAAU,mBAAgB,CAAC,CAAA;;;;;KAEtF;IACH,oCAAC;AAAD,CAAC,AAzGD,IAyGC;AAzGY,sEAA6B"}
|
package/v1/types/protocol.d.ts
CHANGED
|
@@ -3,12 +3,11 @@ export declare type EthereumUnits = 'ETH' | 'GWEI' | 'WEI';
|
|
|
3
3
|
export interface EthereumProtocolNetwork extends ProtocolNetwork {
|
|
4
4
|
chainId: number;
|
|
5
5
|
blockExplorerApi: string;
|
|
6
|
-
blockExplorerApiKey: string;
|
|
7
6
|
}
|
|
8
|
-
export interface EthereumProtocolOptions
|
|
9
|
-
network:
|
|
7
|
+
export interface EthereumProtocolOptions {
|
|
8
|
+
network: EthereumProtocolNetwork;
|
|
10
9
|
}
|
|
11
|
-
export interface EthereumBaseProtocolOptions<_Units extends string = EthereumUnits
|
|
10
|
+
export interface EthereumBaseProtocolOptions<_Units extends string = EthereumUnits> extends EthereumProtocolOptions {
|
|
12
11
|
identifier: string;
|
|
13
12
|
name: string;
|
|
14
13
|
units: ProtocolUnitsMetadata<_Units>;
|
|
@@ -16,15 +15,12 @@ export interface EthereumBaseProtocolOptions<_Units extends string = EthereumUni
|
|
|
16
15
|
feeDefaults?: FeeDefaults<EthereumUnits>;
|
|
17
16
|
standardDerivationPath?: string;
|
|
18
17
|
}
|
|
19
|
-
export interface
|
|
18
|
+
export interface ERC20TokenOptions extends EthereumProtocolOptions {
|
|
20
19
|
name: string;
|
|
21
20
|
identifier: string;
|
|
22
21
|
contractAddress: string;
|
|
23
|
-
units: ProtocolUnitsMetadata<
|
|
24
|
-
mainUnit:
|
|
25
|
-
}
|
|
26
|
-
export interface ERC20TokenOptions<_ProtocolNetwork extends EthereumProtocolNetwork = EthereumProtocolNetwork> extends ERC20ProtocolOptions<string, _ProtocolNetwork> {
|
|
27
|
-
mainIdentifier: string;
|
|
22
|
+
units: ProtocolUnitsMetadata<string>;
|
|
23
|
+
mainUnit: string;
|
|
28
24
|
}
|
|
29
25
|
export interface ERC20TokenMetadata {
|
|
30
26
|
name: string;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
|
-
import { BigNumber } from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
1
|
export declare class EthereumUtils {
|
|
3
2
|
static toHex(value: any): string;
|
|
4
3
|
private static readonly SHA3_NULL_S;
|
|
5
4
|
static sha3(value: any): string | null;
|
|
6
|
-
static hexToNumber(value: string): BigNumber;
|
|
7
5
|
private static numberToHex;
|
|
8
6
|
private static hexToBytes;
|
|
9
7
|
private static isHexStrict;
|
|
@@ -51,15 +51,6 @@ var EthereumUtils = /** @class */ (function () {
|
|
|
51
51
|
return returnValue;
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
EthereumUtils.hexToNumber = function (value) {
|
|
55
|
-
if (value.startsWith('0x')) {
|
|
56
|
-
value = value.slice(2);
|
|
57
|
-
}
|
|
58
|
-
if (value.startsWith('-0x')) {
|
|
59
|
-
value = "-".concat(value.slice(3));
|
|
60
|
-
}
|
|
61
|
-
return new bignumber_1.BigNumber(value, 16);
|
|
62
|
-
};
|
|
63
54
|
EthereumUtils.numberToHex = function (value) {
|
|
64
55
|
if (value === null || value === undefined) {
|
|
65
56
|
return value;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumUtils.js","sourceRoot":"","sources":["../../../src/v1/utils/EthereumUtils.ts"],"names":[],"mappings":";;;AAAA,gGAA8F;AAC9F,sDAA+D;AAC/D,2EAAkE;AAClE,gCAAgC;AAChC,4EAA4E;AAC5E,2CAA2C;AAC3C,IAAM,IAAI,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAA;AAC7E,IAAM,gBAAgB,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAA;AAEzF,qHAAqH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AyHpH,oBAAC;CAAA,AArJD,IAqJC;AArJY,sCAAa"}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
|
-
import { AirGapTransaction, AirGapTransactionsWithCursor, Amount, Balance, ExtendedPublicKey, PublicKey, SecretKey, TransactionConfiguration, TransactionDetails } from '@airgap/module-kit';
|
|
3
|
-
import { EthereumInfoClient } from '../../clients/info/EthereumInfoClient';
|
|
4
|
-
import { EthereumNodeClient } from '../../clients/node/EthereumNodeClient';
|
|
5
|
-
import { ERC20ProtocolOptions, EthereumProtocolNetwork, EthereumUnits } from '../../types/protocol';
|
|
6
|
-
import { EthereumSignedTransaction, EthereumTransactionCursor, EthereumUnsignedTransaction } from '../../types/transaction';
|
|
7
|
-
import { EthereumBaseProtocol, EthereumBaseProtocolImpl } from '../EthereumBaseProtocol';
|
|
8
|
-
export interface ERC20Protocol<_Units extends string, _ProtocolNetwork extends EthereumProtocolNetwork = EthereumProtocolNetwork> extends EthereumBaseProtocol<_Units, _ProtocolNetwork> {
|
|
9
|
-
}
|
|
10
|
-
export declare abstract class ERC20ProtocolImpl<_Units extends string, _ProtocolNetwork extends EthereumProtocolNetwork = EthereumProtocolNetwork> extends EthereumBaseProtocolImpl<_Units, _ProtocolNetwork> implements ERC20Protocol<_Units, _ProtocolNetwork> {
|
|
11
|
-
protected readonly contractAddress: string;
|
|
12
|
-
constructor(nodeClient: EthereumNodeClient, infoClient: EthereumInfoClient, options: ERC20ProtocolOptions<_Units, _ProtocolNetwork>);
|
|
13
|
-
getDetailsFromTransaction(transaction: EthereumSignedTransaction | EthereumUnsignedTransaction, publicKey: PublicKey | ExtendedPublicKey): Promise<AirGapTransaction<_Units, EthereumUnits>[]>;
|
|
14
|
-
private getDetailsFromSignedContractTransaction;
|
|
15
|
-
private getDetailsFromUnsignedContractTransaction;
|
|
16
|
-
signTransactionWithSecretKey(transaction: EthereumUnsignedTransaction, secretKey: SecretKey): Promise<EthereumSignedTransaction>;
|
|
17
|
-
getTransactionsForPublicKey(publicKey: PublicKey | ExtendedPublicKey, limit: number, cursor?: EthereumTransactionCursor): Promise<AirGapTransactionsWithCursor<EthereumTransactionCursor, _Units, EthereumUnits>>;
|
|
18
|
-
getTransactionsForAddress(address: string, limit: number, cursor?: EthereumTransactionCursor): Promise<AirGapTransactionsWithCursor<EthereumTransactionCursor, _Units, EthereumUnits>>;
|
|
19
|
-
getTransactionsForAddresses(addresses: string[], limit: number, cursor?: EthereumTransactionCursor): Promise<AirGapTransactionsWithCursor<EthereumTransactionCursor, _Units, EthereumUnits>>;
|
|
20
|
-
getBalanceOfPublicKey(publicKey: PublicKey | ExtendedPublicKey): Promise<Balance<_Units>>;
|
|
21
|
-
getBalanceOfAddress(address: string): Promise<Balance<_Units>>;
|
|
22
|
-
getBalanceOfAddresses(addresses: string[]): Promise<Balance<_Units>>;
|
|
23
|
-
getTransactionMaxAmountWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, to: string[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<Amount<_Units>>;
|
|
24
|
-
prepareTransactionWithPublicKey(publicKey: PublicKey | ExtendedPublicKey, details: TransactionDetails<_Units>[], configuration?: TransactionConfiguration<EthereumUnits>): Promise<EthereumUnsignedTransaction>;
|
|
25
|
-
protected estimateGas(fromAddress: string, toAddress: string, amount: string | number | BigNumber | Amount, _data?: string): Promise<BigNumber>;
|
|
26
|
-
}
|