@airgap/ethereum 0.13.20 → 0.13.21-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +7 -7
- package/v1/clients/info/EthereumInfoClient.d.ts +7 -9
- package/v1/clients/info/EthereumInfoClient.js.map +1 -1
- package/v1/clients/info/EtherscanInfoClient.d.ts +1 -2
- package/v1/clients/info/EtherscanInfoClient.js +2 -0
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -1
- package/v1/index.d.ts +6 -19
- package/v1/index.js +1 -16
- package/v1/index.js.map +1 -1
- package/v1/module/ERC20Tokens.d.ts +1 -1
- package/v1/module/EthereumModule.d.ts +4 -4
- package/v1/module/EthereumModule.js.map +1 -1
- package/v1/protocol/EthereumBaseProtocol.d.ts +8 -84
- package/v1/protocol/EthereumBaseProtocol.js +7 -777
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumProtocol.d.ts +7 -6
- package/v1/protocol/EthereumProtocol.js +3 -3
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.d.ts +10 -15
- package/v1/protocol/erc20/ERC20Token.js +35 -26
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +9 -10
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/utils/protocol.d.ts +5 -4
- package/v1/utils/protocol.js.map +1 -1
- package/v1/clients/crypto/EthereumCryptoClient.d.ts +0 -7
- package/v1/clients/crypto/EthereumCryptoClient.js +0 -147
- package/v1/clients/crypto/EthereumCryptoClient.js.map +0 -1
- package/v1/clients/node/EthereumNodeClient.d.ts +0 -18
- package/v1/clients/node/EthereumNodeClient.js +0 -3
- package/v1/clients/node/EthereumNodeClient.js.map +0 -1
- package/v1/clients/node/HttpEthereumNodeClient.d.ts +0 -66
- package/v1/clients/node/HttpEthereumNodeClient.js +0 -443
- package/v1/clients/node/HttpEthereumNodeClient.js.map +0 -1
- package/v1/data/EthereumAddress.d.ts +0 -7
- package/v1/data/EthereumAddress.js +0 -46
- package/v1/data/EthereumAddress.js.map +0 -1
- package/v1/protocol/EthereumChainIds.d.ts +0 -1
- package/v1/protocol/EthereumChainIds.js +0 -340
- package/v1/protocol/EthereumChainIds.js.map +0 -1
- package/v1/protocol/erc20/ERC20Protocol.d.ts +0 -32
- package/v1/protocol/erc20/ERC20Protocol.js +0 -397
- package/v1/protocol/erc20/ERC20Protocol.js.map +0 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +0 -8
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +0 -76
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +0 -10
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +0 -14
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js.map +0 -1
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.d.ts +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js +0 -3
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js.map +0 -1
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +0 -41
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +0 -58
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +0 -19
- package/v1/serializer/v3/validators/transaction-validator.d.ts +0 -7
- package/v1/serializer/v3/validators/transaction-validator.js +0 -71
- package/v1/serializer/v3/validators/transaction-validator.js.map +0 -1
- package/v1/types/crypto.d.ts +0 -2
- package/v1/types/crypto.js +0 -3
- package/v1/types/crypto.js.map +0 -1
- package/v1/types/protocol.d.ts +0 -35
- package/v1/types/protocol.js +0 -3
- package/v1/types/protocol.js.map +0 -1
- package/v1/types/transaction.d.ts +0 -24
- package/v1/types/transaction.js +0 -3
- package/v1/types/transaction.js.map +0 -1
- package/v1/utils/EthereumUtils.d.ts +0 -16
- package/v1/utils/EthereumUtils.js +0 -155
- package/v1/utils/EthereumUtils.js.map +0 -1
- package/v1/utils/key.d.ts +0 -5
- package/v1/utils/key.js +0 -101
- package/v1/utils/key.js.map +0 -1
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
import { RPCBody } from '@airgap/coinlib-core/data/RPCBody';
|
|
2
|
-
import { BigNumber } from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
3
|
-
import { RPCConvertible } from '@airgap/coinlib-core/interfaces/RPCConvertible';
|
|
4
|
-
import { AirGapTransactionStatus } from '@airgap/module-kit';
|
|
5
|
-
import { EthereumNodeClient } from './EthereumNodeClient';
|
|
6
|
-
export declare class EthereumRPCBody extends RPCBody implements RPCConvertible {
|
|
7
|
-
static blockEarliest: string;
|
|
8
|
-
static blockLatest: string;
|
|
9
|
-
static blockPending: string;
|
|
10
|
-
toRPCBody(): string;
|
|
11
|
-
toJSON(): any;
|
|
12
|
-
}
|
|
13
|
-
export interface EthereumRPCResponse {
|
|
14
|
-
id: number;
|
|
15
|
-
jsonrpc: string;
|
|
16
|
-
result?: any;
|
|
17
|
-
error?: {
|
|
18
|
-
code: number;
|
|
19
|
-
message: string;
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
export declare class EthereumRPCData {
|
|
23
|
-
protected static parametersLength: number;
|
|
24
|
-
methodSignature: string;
|
|
25
|
-
constructor(methodSignature: string);
|
|
26
|
-
abiEncoded(): string;
|
|
27
|
-
static addLeadingZeroPadding(value: string, targetLength?: number): string;
|
|
28
|
-
static removeLeadingZeroPadding(value: string): string;
|
|
29
|
-
static abiDecoded(value: string, encodedType: 'bytes'): string;
|
|
30
|
-
}
|
|
31
|
-
export declare class EthereumRPCDataBalanceOf extends EthereumRPCData {
|
|
32
|
-
static methodName: string;
|
|
33
|
-
address: string;
|
|
34
|
-
constructor(address: string);
|
|
35
|
-
abiEncoded(): string;
|
|
36
|
-
}
|
|
37
|
-
export declare class EthereumRPCDataTransfer extends EthereumRPCData {
|
|
38
|
-
static methodName: string;
|
|
39
|
-
recipient: string;
|
|
40
|
-
amount: string;
|
|
41
|
-
constructor(toAddressOrData: string, amount?: string);
|
|
42
|
-
abiEncoded(): string;
|
|
43
|
-
}
|
|
44
|
-
export declare class HttpEthereumNodeClient implements EthereumNodeClient {
|
|
45
|
-
protected readonly baseURL: string;
|
|
46
|
-
protected readonly headers?: any;
|
|
47
|
-
constructor(baseURL: string, headers?: any);
|
|
48
|
-
fetchBalance(address: string): Promise<BigNumber>;
|
|
49
|
-
fetchTransactionCount(address: string): Promise<number>;
|
|
50
|
-
sendSignedTransaction(transaction: string): Promise<string>;
|
|
51
|
-
getTransactionStatus(transactionHash: string): Promise<AirGapTransactionStatus>;
|
|
52
|
-
callBalanceOf(contractAddress: string, address: string): Promise<BigNumber>;
|
|
53
|
-
callBalanceOfOnContracts(contractAddresses: string[], address: string): Promise<{
|
|
54
|
-
[contractAddress: string]: BigNumber;
|
|
55
|
-
}>;
|
|
56
|
-
private balanceOfBody;
|
|
57
|
-
estimateTransactionGas(fromAddress: string, toAddress: string, amount?: string, data?: string, gas?: string): Promise<BigNumber>;
|
|
58
|
-
estimateTransferGas(contractAddress: string, fromAddress: string, toAddress: string, hexAmount: string): Promise<BigNumber>;
|
|
59
|
-
getGasPrice(): Promise<BigNumber>;
|
|
60
|
-
getContractName(contractAddress: string): Promise<string | undefined>;
|
|
61
|
-
getContractSymbol(contractAddress: string): Promise<string | undefined>;
|
|
62
|
-
getContractDecimals(contractAddress: string): Promise<number | undefined>;
|
|
63
|
-
protected contractCallBody(contractAddress: string, data: EthereumRPCData, extraParams?: any[], id?: number, jsonrpc?: string): EthereumRPCBody;
|
|
64
|
-
protected send(body: EthereumRPCBody): Promise<EthereumRPCResponse>;
|
|
65
|
-
protected batchSend(bodies: EthereumRPCBody[]): Promise<EthereumRPCResponse[]>;
|
|
66
|
-
}
|
|
@@ -1,443 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __extends = (this && this.__extends) || (function () {
|
|
3
|
-
var extendStatics = function (d, b) {
|
|
4
|
-
extendStatics = Object.setPrototypeOf ||
|
|
5
|
-
({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
|
|
6
|
-
function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
|
|
7
|
-
return extendStatics(d, b);
|
|
8
|
-
};
|
|
9
|
-
return function (d, b) {
|
|
10
|
-
if (typeof b !== "function" && b !== null)
|
|
11
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
12
|
-
extendStatics(d, b);
|
|
13
|
-
function __() { this.constructor = d; }
|
|
14
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
15
|
-
};
|
|
16
|
-
})();
|
|
17
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
18
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
19
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
20
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
21
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
22
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
23
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
27
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
28
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
29
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
30
|
-
function step(op) {
|
|
31
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
32
|
-
while (_) try {
|
|
33
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
34
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
35
|
-
switch (op[0]) {
|
|
36
|
-
case 0: case 1: t = op; break;
|
|
37
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
38
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
39
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
40
|
-
default:
|
|
41
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
42
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
43
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
44
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
45
|
-
if (t[2]) _.ops.pop();
|
|
46
|
-
_.trys.pop(); continue;
|
|
47
|
-
}
|
|
48
|
-
op = body.call(thisArg, _);
|
|
49
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
50
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
51
|
-
}
|
|
52
|
-
};
|
|
53
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
54
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
55
|
-
if (ar || !(i in from)) {
|
|
56
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
57
|
-
ar[i] = from[i];
|
|
58
|
-
}
|
|
59
|
-
}
|
|
60
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
61
|
-
};
|
|
62
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
63
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
64
|
-
};
|
|
65
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
66
|
-
exports.HttpEthereumNodeClient = exports.EthereumRPCDataTransfer = exports.EthereumRPCDataBalanceOf = exports.EthereumRPCData = exports.EthereumRPCBody = void 0;
|
|
67
|
-
// tslint:disable: max-classes-per-file
|
|
68
|
-
var RPCBody_1 = require("@airgap/coinlib-core/data/RPCBody");
|
|
69
|
-
var axios_0_19_0_1 = __importDefault(require("@airgap/coinlib-core/dependencies/src/axios-0.19.0"));
|
|
70
|
-
var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
|
|
71
|
-
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
72
|
-
var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
73
|
-
var coinlib_core_1 = require("@airgap/coinlib-core");
|
|
74
|
-
var EthereumUtils_1 = require("../../utils/EthereumUtils");
|
|
75
|
-
var EthereumRPCBody = /** @class */ (function (_super) {
|
|
76
|
-
__extends(EthereumRPCBody, _super);
|
|
77
|
-
function EthereumRPCBody() {
|
|
78
|
-
return _super !== null && _super.apply(this, arguments) || this;
|
|
79
|
-
}
|
|
80
|
-
EthereumRPCBody.prototype.toRPCBody = function () {
|
|
81
|
-
return JSON.stringify(this.toJSON());
|
|
82
|
-
};
|
|
83
|
-
EthereumRPCBody.prototype.toJSON = function () {
|
|
84
|
-
return {
|
|
85
|
-
jsonrpc: this.jsonrpc,
|
|
86
|
-
method: this.method,
|
|
87
|
-
params: this.params,
|
|
88
|
-
id: this.id
|
|
89
|
-
};
|
|
90
|
-
};
|
|
91
|
-
EthereumRPCBody.blockEarliest = 'earliest';
|
|
92
|
-
EthereumRPCBody.blockLatest = 'latest';
|
|
93
|
-
EthereumRPCBody.blockPending = 'pending';
|
|
94
|
-
return EthereumRPCBody;
|
|
95
|
-
}(RPCBody_1.RPCBody));
|
|
96
|
-
exports.EthereumRPCBody = EthereumRPCBody;
|
|
97
|
-
var EthereumRPCData = /** @class */ (function () {
|
|
98
|
-
function EthereumRPCData(methodSignature) {
|
|
99
|
-
this.methodSignature = methodSignature;
|
|
100
|
-
}
|
|
101
|
-
EthereumRPCData.prototype.abiEncoded = function () {
|
|
102
|
-
var hash = EthereumUtils_1.EthereumUtils.sha3(this.methodSignature);
|
|
103
|
-
if (hash === null) {
|
|
104
|
-
return '';
|
|
105
|
-
}
|
|
106
|
-
return "0x".concat(hash.slice(2, 10));
|
|
107
|
-
};
|
|
108
|
-
EthereumRPCData.addLeadingZeroPadding = function (value, targetLength) {
|
|
109
|
-
if (targetLength === void 0) { targetLength = EthereumRPCData.parametersLength; }
|
|
110
|
-
var result = value;
|
|
111
|
-
while (result.length < targetLength || result.length % 2 !== 0) {
|
|
112
|
-
result = '0' + result;
|
|
113
|
-
}
|
|
114
|
-
return result;
|
|
115
|
-
};
|
|
116
|
-
EthereumRPCData.removeLeadingZeroPadding = function (value) {
|
|
117
|
-
var result = value;
|
|
118
|
-
while (result.startsWith('0')) {
|
|
119
|
-
result = result.slice(1); // this can probably be done much more efficiently with a regex
|
|
120
|
-
}
|
|
121
|
-
return result;
|
|
122
|
-
};
|
|
123
|
-
EthereumRPCData.abiDecoded = function (value, encodedType) {
|
|
124
|
-
switch (encodedType) {
|
|
125
|
-
case 'bytes':
|
|
126
|
-
if (value.startsWith('0x')) {
|
|
127
|
-
value = value.slice(2);
|
|
128
|
-
}
|
|
129
|
-
var buffer = Buffer.from(value, 'hex');
|
|
130
|
-
var offset = new bignumber_1.BigNumber(buffer.slice(0, 32).toString('hex'), 16).toNumber();
|
|
131
|
-
var length_1 = new bignumber_1.BigNumber(buffer.slice(offset, offset + 32).toString('hex'), 16).toNumber();
|
|
132
|
-
return buffer.slice(offset + 32, offset + 32 + length_1).toString('hex');
|
|
133
|
-
default:
|
|
134
|
-
(0, coinlib_core_1.assertNever)(encodedType);
|
|
135
|
-
throw new errors_1.UnsupportedError(coinlib_error_1.Domain.ETHEREUM, 'Unsupported ABI encoded type');
|
|
136
|
-
}
|
|
137
|
-
};
|
|
138
|
-
// 2 chars = 1 byte hence to get to 32 bytes we need 64 chars
|
|
139
|
-
EthereumRPCData.parametersLength = 64;
|
|
140
|
-
return EthereumRPCData;
|
|
141
|
-
}());
|
|
142
|
-
exports.EthereumRPCData = EthereumRPCData;
|
|
143
|
-
var EthereumRPCDataBalanceOf = /** @class */ (function (_super) {
|
|
144
|
-
__extends(EthereumRPCDataBalanceOf, _super);
|
|
145
|
-
function EthereumRPCDataBalanceOf(address) {
|
|
146
|
-
var _this = _super.call(this, "".concat(EthereumRPCDataBalanceOf.methodName, "(address)")) || this;
|
|
147
|
-
_this.address = address;
|
|
148
|
-
return _this;
|
|
149
|
-
}
|
|
150
|
-
EthereumRPCDataBalanceOf.prototype.abiEncoded = function () {
|
|
151
|
-
var srcAddress = this.address;
|
|
152
|
-
if (srcAddress.startsWith('0x')) {
|
|
153
|
-
srcAddress = srcAddress.slice(2);
|
|
154
|
-
}
|
|
155
|
-
return _super.prototype.abiEncoded.call(this) + EthereumRPCData.addLeadingZeroPadding(srcAddress);
|
|
156
|
-
};
|
|
157
|
-
EthereumRPCDataBalanceOf.methodName = 'balanceOf';
|
|
158
|
-
return EthereumRPCDataBalanceOf;
|
|
159
|
-
}(EthereumRPCData));
|
|
160
|
-
exports.EthereumRPCDataBalanceOf = EthereumRPCDataBalanceOf;
|
|
161
|
-
var EthereumRPCDataTransfer = /** @class */ (function (_super) {
|
|
162
|
-
__extends(EthereumRPCDataTransfer, _super);
|
|
163
|
-
function EthereumRPCDataTransfer(toAddressOrData, amount) {
|
|
164
|
-
var _this = _super.call(this, "".concat(EthereumRPCDataTransfer.methodName, "(address,uint256)")) || this;
|
|
165
|
-
if (amount) {
|
|
166
|
-
var toAddress = toAddressOrData;
|
|
167
|
-
_this.recipient = toAddress;
|
|
168
|
-
_this.amount = amount;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
var data = toAddressOrData;
|
|
172
|
-
var methodID = _super.prototype.abiEncoded.call(_this);
|
|
173
|
-
if (!data.startsWith(methodID)) {
|
|
174
|
-
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.ETHEREUM, 'unexpected method ID');
|
|
175
|
-
}
|
|
176
|
-
var params = data.slice(methodID.length);
|
|
177
|
-
var recipient = EthereumRPCData.removeLeadingZeroPadding(params.slice(0, EthereumRPCData.parametersLength));
|
|
178
|
-
var parsedAmount = EthereumRPCData.removeLeadingZeroPadding(params.slice(EthereumRPCData.parametersLength));
|
|
179
|
-
_this.recipient = "0x".concat(recipient);
|
|
180
|
-
_this.amount = "0x".concat(parsedAmount);
|
|
181
|
-
}
|
|
182
|
-
return _this;
|
|
183
|
-
}
|
|
184
|
-
EthereumRPCDataTransfer.prototype.abiEncoded = function () {
|
|
185
|
-
var dstAddress = this.recipient;
|
|
186
|
-
if (dstAddress.startsWith('0x')) {
|
|
187
|
-
dstAddress = dstAddress.slice(2);
|
|
188
|
-
}
|
|
189
|
-
var transferAmount = this.amount;
|
|
190
|
-
if (transferAmount.startsWith('0x')) {
|
|
191
|
-
transferAmount = transferAmount.slice(2);
|
|
192
|
-
}
|
|
193
|
-
return (_super.prototype.abiEncoded.call(this) +
|
|
194
|
-
EthereumRPCData.addLeadingZeroPadding(dstAddress.toLowerCase()) +
|
|
195
|
-
EthereumRPCData.addLeadingZeroPadding(transferAmount.toLowerCase()));
|
|
196
|
-
};
|
|
197
|
-
EthereumRPCDataTransfer.methodName = 'transfer';
|
|
198
|
-
return EthereumRPCDataTransfer;
|
|
199
|
-
}(EthereumRPCData));
|
|
200
|
-
exports.EthereumRPCDataTransfer = EthereumRPCDataTransfer;
|
|
201
|
-
var HttpEthereumNodeClient = /** @class */ (function () {
|
|
202
|
-
function HttpEthereumNodeClient(baseURL, headers) {
|
|
203
|
-
this.baseURL = baseURL;
|
|
204
|
-
this.headers = headers;
|
|
205
|
-
}
|
|
206
|
-
HttpEthereumNodeClient.prototype.fetchBalance = function (address) {
|
|
207
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
-
var body, response;
|
|
209
|
-
return __generator(this, function (_a) {
|
|
210
|
-
switch (_a.label) {
|
|
211
|
-
case 0:
|
|
212
|
-
body = new EthereumRPCBody('eth_getBalance', [address, EthereumRPCBody.blockLatest]);
|
|
213
|
-
return [4 /*yield*/, this.send(body)];
|
|
214
|
-
case 1:
|
|
215
|
-
response = _a.sent();
|
|
216
|
-
return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
|
|
217
|
-
}
|
|
218
|
-
});
|
|
219
|
-
});
|
|
220
|
-
};
|
|
221
|
-
HttpEthereumNodeClient.prototype.fetchTransactionCount = function (address) {
|
|
222
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
223
|
-
var body, response;
|
|
224
|
-
return __generator(this, function (_a) {
|
|
225
|
-
switch (_a.label) {
|
|
226
|
-
case 0:
|
|
227
|
-
body = new EthereumRPCBody('eth_getTransactionCount', [address, EthereumRPCBody.blockLatest]);
|
|
228
|
-
return [4 /*yield*/, this.send(body)];
|
|
229
|
-
case 1:
|
|
230
|
-
response = _a.sent();
|
|
231
|
-
return [2 /*return*/, new bignumber_1.BigNumber(response.result).toNumber()];
|
|
232
|
-
}
|
|
233
|
-
});
|
|
234
|
-
});
|
|
235
|
-
};
|
|
236
|
-
HttpEthereumNodeClient.prototype.sendSignedTransaction = function (transaction) {
|
|
237
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
238
|
-
var body;
|
|
239
|
-
return __generator(this, function (_a) {
|
|
240
|
-
switch (_a.label) {
|
|
241
|
-
case 0:
|
|
242
|
-
body = new EthereumRPCBody('eth_sendRawTransaction', [transaction]);
|
|
243
|
-
return [4 /*yield*/, this.send(body)];
|
|
244
|
-
case 1: return [2 /*return*/, (_a.sent()).result];
|
|
245
|
-
}
|
|
246
|
-
});
|
|
247
|
-
});
|
|
248
|
-
};
|
|
249
|
-
HttpEthereumNodeClient.prototype.getTransactionStatus = function (transactionHash) {
|
|
250
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
251
|
-
var body, response;
|
|
252
|
-
return __generator(this, function (_a) {
|
|
253
|
-
switch (_a.label) {
|
|
254
|
-
case 0:
|
|
255
|
-
body = new EthereumRPCBody('eth_getTransactionReceipt', [transactionHash]);
|
|
256
|
-
return [4 /*yield*/, this.send(body)];
|
|
257
|
-
case 1:
|
|
258
|
-
response = _a.sent();
|
|
259
|
-
return [2 /*return*/, response.result.status === '0x1' ? { type: 'applied' } : { type: 'failed' }];
|
|
260
|
-
}
|
|
261
|
-
});
|
|
262
|
-
});
|
|
263
|
-
};
|
|
264
|
-
HttpEthereumNodeClient.prototype.callBalanceOf = function (contractAddress, address) {
|
|
265
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
266
|
-
var body, response;
|
|
267
|
-
return __generator(this, function (_a) {
|
|
268
|
-
switch (_a.label) {
|
|
269
|
-
case 0:
|
|
270
|
-
body = this.balanceOfBody(contractAddress, address);
|
|
271
|
-
return [4 /*yield*/, this.send(body)];
|
|
272
|
-
case 1:
|
|
273
|
-
response = _a.sent();
|
|
274
|
-
return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
|
|
275
|
-
}
|
|
276
|
-
});
|
|
277
|
-
});
|
|
278
|
-
};
|
|
279
|
-
HttpEthereumNodeClient.prototype.callBalanceOfOnContracts = function (contractAddresses, address) {
|
|
280
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
281
|
-
var bodies, responses, result;
|
|
282
|
-
var _this = this;
|
|
283
|
-
return __generator(this, function (_a) {
|
|
284
|
-
switch (_a.label) {
|
|
285
|
-
case 0:
|
|
286
|
-
bodies = contractAddresses.map(function (contractAddress, index) { return _this.balanceOfBody(contractAddress, address, index); });
|
|
287
|
-
return [4 /*yield*/, this.batchSend(bodies)];
|
|
288
|
-
case 1:
|
|
289
|
-
responses = _a.sent();
|
|
290
|
-
result = {};
|
|
291
|
-
responses.forEach(function (response) {
|
|
292
|
-
var _a;
|
|
293
|
-
result[contractAddresses[response.id]] = new bignumber_1.BigNumber((_a = response.result) !== null && _a !== void 0 ? _a : 0);
|
|
294
|
-
});
|
|
295
|
-
return [2 /*return*/, result];
|
|
296
|
-
}
|
|
297
|
-
});
|
|
298
|
-
});
|
|
299
|
-
};
|
|
300
|
-
HttpEthereumNodeClient.prototype.balanceOfBody = function (contractAddress, address, id) {
|
|
301
|
-
if (id === void 0) { id = 0; }
|
|
302
|
-
var data = new EthereumRPCDataBalanceOf(address);
|
|
303
|
-
return this.contractCallBody(contractAddress, data, [EthereumRPCBody.blockLatest], id);
|
|
304
|
-
};
|
|
305
|
-
HttpEthereumNodeClient.prototype.estimateTransactionGas = function (fromAddress, toAddress, amount, data, gas) {
|
|
306
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
307
|
-
var body, response;
|
|
308
|
-
return __generator(this, function (_a) {
|
|
309
|
-
switch (_a.label) {
|
|
310
|
-
case 0:
|
|
311
|
-
body = new EthereumRPCBody('eth_estimateGas', [{ from: fromAddress, to: toAddress, gas: gas, value: amount, data: data }]);
|
|
312
|
-
return [4 /*yield*/, this.send(body)];
|
|
313
|
-
case 1:
|
|
314
|
-
response = _a.sent();
|
|
315
|
-
return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
|
|
316
|
-
}
|
|
317
|
-
});
|
|
318
|
-
});
|
|
319
|
-
};
|
|
320
|
-
HttpEthereumNodeClient.prototype.estimateTransferGas = function (contractAddress, fromAddress, toAddress, hexAmount) {
|
|
321
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
322
|
-
var data, result;
|
|
323
|
-
return __generator(this, function (_a) {
|
|
324
|
-
data = new EthereumRPCDataTransfer(toAddress, hexAmount);
|
|
325
|
-
result = this.estimateTransactionGas(fromAddress, contractAddress, undefined, data.abiEncoded());
|
|
326
|
-
return [2 /*return*/, result];
|
|
327
|
-
});
|
|
328
|
-
});
|
|
329
|
-
};
|
|
330
|
-
HttpEthereumNodeClient.prototype.getGasPrice = function () {
|
|
331
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
332
|
-
var body, response;
|
|
333
|
-
return __generator(this, function (_a) {
|
|
334
|
-
switch (_a.label) {
|
|
335
|
-
case 0:
|
|
336
|
-
body = new EthereumRPCBody('eth_gasPrice', []);
|
|
337
|
-
return [4 /*yield*/, this.send(body)];
|
|
338
|
-
case 1:
|
|
339
|
-
response = _a.sent();
|
|
340
|
-
return [2 /*return*/, new bignumber_1.BigNumber(response.result)];
|
|
341
|
-
}
|
|
342
|
-
});
|
|
343
|
-
});
|
|
344
|
-
};
|
|
345
|
-
HttpEthereumNodeClient.prototype.getContractName = function (contractAddress) {
|
|
346
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
347
|
-
var data, body, response, result;
|
|
348
|
-
return __generator(this, function (_a) {
|
|
349
|
-
switch (_a.label) {
|
|
350
|
-
case 0:
|
|
351
|
-
data = new EthereumRPCData('name()');
|
|
352
|
-
body = this.contractCallBody(contractAddress, data, [EthereumRPCBody.blockLatest]);
|
|
353
|
-
return [4 /*yield*/, this.send(body)];
|
|
354
|
-
case 1:
|
|
355
|
-
response = _a.sent();
|
|
356
|
-
if (!response.result) {
|
|
357
|
-
return [2 /*return*/, undefined];
|
|
358
|
-
}
|
|
359
|
-
result = EthereumRPCData.abiDecoded(response.result, 'bytes');
|
|
360
|
-
return [2 /*return*/, EthereumUtils_1.EthereumUtils.hexToUtf8(result)];
|
|
361
|
-
}
|
|
362
|
-
});
|
|
363
|
-
});
|
|
364
|
-
};
|
|
365
|
-
HttpEthereumNodeClient.prototype.getContractSymbol = function (contractAddress) {
|
|
366
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
367
|
-
var data, body, response, result;
|
|
368
|
-
return __generator(this, function (_a) {
|
|
369
|
-
switch (_a.label) {
|
|
370
|
-
case 0:
|
|
371
|
-
data = new EthereumRPCData('symbol()');
|
|
372
|
-
body = this.contractCallBody(contractAddress, data, [EthereumRPCBody.blockLatest]);
|
|
373
|
-
return [4 /*yield*/, this.send(body)];
|
|
374
|
-
case 1:
|
|
375
|
-
response = _a.sent();
|
|
376
|
-
if (!response.result) {
|
|
377
|
-
return [2 /*return*/, undefined];
|
|
378
|
-
}
|
|
379
|
-
result = EthereumRPCData.abiDecoded(response.result, 'bytes');
|
|
380
|
-
return [2 /*return*/, EthereumUtils_1.EthereumUtils.hexToUtf8(result)];
|
|
381
|
-
}
|
|
382
|
-
});
|
|
383
|
-
});
|
|
384
|
-
};
|
|
385
|
-
HttpEthereumNodeClient.prototype.getContractDecimals = function (contractAddress) {
|
|
386
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
387
|
-
var data, body, response;
|
|
388
|
-
return __generator(this, function (_a) {
|
|
389
|
-
switch (_a.label) {
|
|
390
|
-
case 0:
|
|
391
|
-
data = new EthereumRPCData('decimals()');
|
|
392
|
-
body = this.contractCallBody(contractAddress, data, [EthereumRPCBody.blockLatest]);
|
|
393
|
-
return [4 /*yield*/, this.send(body)];
|
|
394
|
-
case 1:
|
|
395
|
-
response = _a.sent();
|
|
396
|
-
if (!response.result) {
|
|
397
|
-
return [2 /*return*/, undefined];
|
|
398
|
-
}
|
|
399
|
-
return [2 /*return*/, EthereumUtils_1.EthereumUtils.hexToNumber(response.result).toNumber()];
|
|
400
|
-
}
|
|
401
|
-
});
|
|
402
|
-
});
|
|
403
|
-
};
|
|
404
|
-
HttpEthereumNodeClient.prototype.contractCallBody = function (contractAddress, data, extraParams, id, jsonrpc) {
|
|
405
|
-
if (extraParams === void 0) { extraParams = []; }
|
|
406
|
-
return new EthereumRPCBody('eth_call', __spreadArray([{ to: contractAddress, data: data.abiEncoded() }], extraParams, true), id, jsonrpc);
|
|
407
|
-
};
|
|
408
|
-
HttpEthereumNodeClient.prototype.send = function (body) {
|
|
409
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
410
|
-
var response;
|
|
411
|
-
return __generator(this, function (_a) {
|
|
412
|
-
switch (_a.label) {
|
|
413
|
-
case 0: return [4 /*yield*/, axios_0_19_0_1.default.post(this.baseURL, body.toRPCBody(), { headers: this.headers }).catch(function (error) {
|
|
414
|
-
throw new errors_1.NetworkError(coinlib_error_1.Domain.ETHEREUM, error);
|
|
415
|
-
})];
|
|
416
|
-
case 1:
|
|
417
|
-
response = _a.sent();
|
|
418
|
-
return [2 /*return*/, response.data];
|
|
419
|
-
}
|
|
420
|
-
});
|
|
421
|
-
});
|
|
422
|
-
};
|
|
423
|
-
HttpEthereumNodeClient.prototype.batchSend = function (bodies) {
|
|
424
|
-
return __awaiter(this, void 0, void 0, function () {
|
|
425
|
-
var response;
|
|
426
|
-
return __generator(this, function (_a) {
|
|
427
|
-
switch (_a.label) {
|
|
428
|
-
case 0: return [4 /*yield*/, axios_0_19_0_1.default
|
|
429
|
-
.post(this.baseURL, JSON.stringify(bodies.map(function (body) { return body.toJSON(); })), { headers: this.headers })
|
|
430
|
-
.catch(function (error) {
|
|
431
|
-
throw new errors_1.NetworkError(coinlib_error_1.Domain.ETHEREUM, error);
|
|
432
|
-
})];
|
|
433
|
-
case 1:
|
|
434
|
-
response = _a.sent();
|
|
435
|
-
return [2 /*return*/, response.data];
|
|
436
|
-
}
|
|
437
|
-
});
|
|
438
|
-
});
|
|
439
|
-
};
|
|
440
|
-
return HttpEthereumNodeClient;
|
|
441
|
-
}());
|
|
442
|
-
exports.HttpEthereumNodeClient = HttpEthereumNodeClient;
|
|
443
|
-
//# sourceMappingURL=HttpEthereumNodeClient.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"HttpEthereumNodeClient.js","sourceRoot":"","sources":["../../../../src/v1/clients/node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;AAzJY,wDAAsB"}
|
|
@@ -1,46 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
26
|
-
exports.EthereumAddress = void 0;
|
|
27
|
-
// @ts-ignore
|
|
28
|
-
var ethUtil = __importStar(require("@airgap/coinlib-core/dependencies/src/ethereumjs-util-5.2.0"));
|
|
29
|
-
var key_1 = require("../utils/key");
|
|
30
|
-
var EthereumAddress = /** @class */ (function () {
|
|
31
|
-
function EthereumAddress(value) {
|
|
32
|
-
this.value = value;
|
|
33
|
-
}
|
|
34
|
-
EthereumAddress.from = function (publicKey) {
|
|
35
|
-
var hexPublicKey = publicKey.type === 'pub' ? (0, key_1.convertPublicKey)(publicKey, 'hex') : (0, key_1.convertExtendedPublicKey)(publicKey, 'hex');
|
|
36
|
-
var bufferPublicKey = Buffer.from(hexPublicKey.value, 'hex');
|
|
37
|
-
var address = ethUtil.toChecksumAddress(ethUtil.pubToAddress(bufferPublicKey, true).toString('hex'));
|
|
38
|
-
return new EthereumAddress(address);
|
|
39
|
-
};
|
|
40
|
-
EthereumAddress.prototype.asString = function () {
|
|
41
|
-
return this.value;
|
|
42
|
-
};
|
|
43
|
-
return EthereumAddress;
|
|
44
|
-
}());
|
|
45
|
-
exports.EthereumAddress = EthereumAddress;
|
|
46
|
-
//# sourceMappingURL=EthereumAddress.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumAddress.js","sourceRoot":"","sources":["../../../src/v1/data/EthereumAddress.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,mGAAsF;AAGtF,oCAAyE;AAEzE;IACE,yBAAqC,KAAa;QAAb,UAAK,GAAL,KAAK,CAAQ;IAAG,CAAC;IAExC,oBAAI,GAAlB,UAAmB,SAAwC;QACzD,IAAM,YAAY,GAChB,SAAS,CAAC,IAAI,KAAK,KAAK,CAAC,CAAC,CAAC,IAAA,sBAAgB,EAAC,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAA,8BAAwB,EAAC,SAAS,EAAE,KAAK,CAAC,CAAA;QAC5G,IAAM,eAAe,GAAW,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,KAAK,EAAE,KAAK,CAAC,CAAA;QAEtE,IAAM,OAAO,GAAW,OAAO,CAAC,iBAAiB,CAAC,OAAO,CAAC,YAAY,CAAC,eAAe,EAAE,IAAI,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC,CAAA;QAE9G,OAAO,IAAI,eAAe,CAAC,OAAO,CAAC,CAAA;IACrC,CAAC;IAEM,kCAAQ,GAAf;QACE,OAAO,IAAI,CAAC,KAAK,CAAA;IACnB,CAAC;IACH,sBAAC;AAAD,CAAC,AAhBD,IAgBC;AAhBY,0CAAe"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const ETHEREUM_CHAIN_IDS: Record<number, string>;
|