@airgap/ethereum 0.13.21-beta.7 → 0.13.22-beta.0
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/crypto/EthereumCryptoClient.d.ts +7 -0
- package/v1/clients/crypto/EthereumCryptoClient.js +147 -0
- package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -0
- package/v1/clients/info/EthereumInfoClient.d.ts +9 -7
- package/v1/clients/info/EthereumInfoClient.js.map +1 -1
- package/v1/clients/info/EtherscanInfoClient.d.ts +2 -1
- package/v1/clients/info/EtherscanInfoClient.js +0 -2
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -1
- package/v1/clients/node/EthereumNodeClient.d.ts +18 -0
- package/v1/clients/node/EthereumNodeClient.js +3 -0
- package/v1/clients/node/EthereumNodeClient.js.map +1 -0
- package/v1/clients/node/HttpEthereumNodeClient.d.ts +66 -0
- package/v1/clients/node/HttpEthereumNodeClient.js +443 -0
- package/v1/clients/node/HttpEthereumNodeClient.js.map +1 -0
- package/v1/data/EthereumAddress.d.ts +7 -0
- package/v1/data/EthereumAddress.js +46 -0
- package/v1/data/EthereumAddress.js.map +1 -0
- package/v1/index.d.ts +19 -6
- package/v1/index.js +16 -1
- 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 +84 -7
- package/v1/protocol/EthereumBaseProtocol.js +779 -8
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumChainIds.d.ts +1 -0
- package/v1/protocol/EthereumChainIds.js +340 -0
- package/v1/protocol/EthereumChainIds.js.map +1 -0
- package/v1/protocol/EthereumProtocol.d.ts +6 -7
- package/v1/protocol/EthereumProtocol.js +3 -4
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Protocol.d.ts +32 -0
- package/v1/protocol/erc20/ERC20Protocol.js +397 -0
- package/v1/protocol/erc20/ERC20Protocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Token.d.ts +15 -10
- package/v1/protocol/erc20/ERC20Token.js +26 -35
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +8 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +76 -0
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +10 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +14 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js.map +1 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.d.ts +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js +3 -0
- package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +41 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +58 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +19 -0
- package/v1/serializer/v3/serializer-companion.js +10 -9
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.d.ts +7 -0
- package/v1/serializer/v3/validators/transaction-validator.js +71 -0
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
- package/v1/types/crypto.d.ts +2 -0
- package/v1/types/crypto.js +3 -0
- package/v1/types/crypto.js.map +1 -0
- package/v1/types/protocol.d.ts +35 -0
- package/v1/types/protocol.js +3 -0
- package/v1/types/protocol.js.map +1 -0
- package/v1/types/transaction.d.ts +24 -0
- package/v1/types/transaction.js +3 -0
- package/v1/types/transaction.js.map +1 -0
- package/v1/utils/EthereumUtils.d.ts +16 -0
- package/v1/utils/EthereumUtils.js +155 -0
- package/v1/utils/EthereumUtils.js.map +1 -0
- package/v1/utils/key.d.ts +5 -0
- package/v1/utils/key.js +101 -0
- package/v1/utils/key.js.map +1 -0
- package/v1/utils/protocol.d.ts +4 -5
- package/v1/utils/protocol.js.map +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@airgap/ethereum",
|
|
3
|
-
"version": "0.13.
|
|
3
|
+
"version": "0.13.22-beta.0",
|
|
4
4
|
"description": "The @airgap/ethereum is an Ethereum implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"airgap",
|
|
@@ -30,13 +30,13 @@
|
|
|
30
30
|
},
|
|
31
31
|
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@airgap/coinlib-core": "^0.13.
|
|
34
|
-
"@airgap/crypto": "^0.13.
|
|
35
|
-
"@airgap/
|
|
36
|
-
"@airgap/
|
|
37
|
-
"@airgap/serializer": "^0.13.21-beta.7",
|
|
33
|
+
"@airgap/coinlib-core": "^0.13.22-beta.0",
|
|
34
|
+
"@airgap/crypto": "^0.13.22-beta.0",
|
|
35
|
+
"@airgap/module-kit": "^0.13.22-beta.0",
|
|
36
|
+
"@airgap/serializer": "^0.13.22-beta.0",
|
|
38
37
|
"@ethereumjs/common": "2.6.5",
|
|
39
|
-
"@ethereumjs/tx": "3.4.0"
|
|
38
|
+
"@ethereumjs/tx": "3.4.0",
|
|
39
|
+
"@metamask/eth-sig-util": "4.0.0"
|
|
40
40
|
},
|
|
41
41
|
"localDependencies": {
|
|
42
42
|
"ethereumjs-tx": "1.3.7",
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { Secp256k1CryptoClient } from '@airgap/coinlib-core/protocols/Secp256k1CryptoClient';
|
|
2
|
+
export declare class EthereumCryptoClient extends Secp256k1CryptoClient {
|
|
3
|
+
signMessage(message: string, keypair: {
|
|
4
|
+
privateKey: string;
|
|
5
|
+
}): Promise<string>;
|
|
6
|
+
verifyMessage(message: string, signature: string, publicKey: string): Promise<boolean>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,147 @@
|
|
|
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 __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
18
|
+
if (k2 === undefined) k2 = k;
|
|
19
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
20
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
21
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
22
|
+
}
|
|
23
|
+
Object.defineProperty(o, k2, desc);
|
|
24
|
+
}) : (function(o, m, k, k2) {
|
|
25
|
+
if (k2 === undefined) k2 = k;
|
|
26
|
+
o[k2] = m[k];
|
|
27
|
+
}));
|
|
28
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
29
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
30
|
+
}) : function(o, v) {
|
|
31
|
+
o["default"] = v;
|
|
32
|
+
});
|
|
33
|
+
var __importStar = (this && this.__importStar) || function (mod) {
|
|
34
|
+
if (mod && mod.__esModule) return mod;
|
|
35
|
+
var result = {};
|
|
36
|
+
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
37
|
+
__setModuleDefault(result, mod);
|
|
38
|
+
return result;
|
|
39
|
+
};
|
|
40
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
41
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
42
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
43
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
44
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
45
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
46
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
47
|
+
});
|
|
48
|
+
};
|
|
49
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
50
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
51
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
52
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
53
|
+
function step(op) {
|
|
54
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
55
|
+
while (_) try {
|
|
56
|
+
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;
|
|
57
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
58
|
+
switch (op[0]) {
|
|
59
|
+
case 0: case 1: t = op; break;
|
|
60
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
61
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
62
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
63
|
+
default:
|
|
64
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
65
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
66
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
67
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
68
|
+
if (t[2]) _.ops.pop();
|
|
69
|
+
_.trys.pop(); continue;
|
|
70
|
+
}
|
|
71
|
+
op = body.call(thisArg, _);
|
|
72
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
73
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
77
|
+
exports.EthereumCryptoClient = void 0;
|
|
78
|
+
// @ts-ignore
|
|
79
|
+
var EthereumJSUtils = __importStar(require("@airgap/coinlib-core/dependencies/src/ethereumjs-util-5.2.0"));
|
|
80
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
81
|
+
var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
82
|
+
var Secp256k1CryptoClient_1 = require("@airgap/coinlib-core/protocols/Secp256k1CryptoClient");
|
|
83
|
+
var hex_1 = require("@airgap/coinlib-core/utils/hex");
|
|
84
|
+
var module_kit_1 = require("@airgap/module-kit");
|
|
85
|
+
var eth_sig_util_1 = require("@metamask/eth-sig-util");
|
|
86
|
+
var EthereumAddress_1 = require("../../data/EthereumAddress");
|
|
87
|
+
var EthereumCryptoClient = /** @class */ (function (_super) {
|
|
88
|
+
__extends(EthereumCryptoClient, _super);
|
|
89
|
+
function EthereumCryptoClient() {
|
|
90
|
+
return _super !== null && _super.apply(this, arguments) || this;
|
|
91
|
+
}
|
|
92
|
+
EthereumCryptoClient.prototype.signMessage = function (message, keypair) {
|
|
93
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
94
|
+
var privateKey, msgParams_1, msgParams_2, msgParams, messageBuffer, signature;
|
|
95
|
+
return __generator(this, function (_a) {
|
|
96
|
+
if (!keypair.privateKey) {
|
|
97
|
+
throw new errors_1.NotFoundError(coinlib_error_1.Domain.ETHEREUM, "Private key not provided");
|
|
98
|
+
}
|
|
99
|
+
privateKey = Buffer.from(keypair.privateKey, 'hex');
|
|
100
|
+
try {
|
|
101
|
+
try {
|
|
102
|
+
msgParams_1 = JSON.parse(message) // TODO types
|
|
103
|
+
;
|
|
104
|
+
return [2 /*return*/, (0, eth_sig_util_1.signTypedData)({ privateKey: privateKey, data: msgParams_1, version: eth_sig_util_1.SignTypedDataVersion.V4 })];
|
|
105
|
+
}
|
|
106
|
+
catch (e) { }
|
|
107
|
+
try {
|
|
108
|
+
msgParams_2 = JSON.parse(message) // TODO types
|
|
109
|
+
;
|
|
110
|
+
return [2 /*return*/, (0, eth_sig_util_1.signTypedData)({ privateKey: privateKey, data: msgParams_2, version: eth_sig_util_1.SignTypedDataVersion.V3 })];
|
|
111
|
+
}
|
|
112
|
+
catch (e) { }
|
|
113
|
+
msgParams = JSON.parse(message);
|
|
114
|
+
return [2 /*return*/, (0, eth_sig_util_1.signTypedData)({ privateKey: privateKey, data: msgParams, version: eth_sig_util_1.SignTypedDataVersion.V1 })];
|
|
115
|
+
}
|
|
116
|
+
catch (error) {
|
|
117
|
+
messageBuffer = EthereumJSUtils.hashPersonalMessage(EthereumJSUtils.toBuffer(message));
|
|
118
|
+
signature = EthereumJSUtils.ecsign(messageBuffer, privateKey);
|
|
119
|
+
return [2 /*return*/, EthereumJSUtils.toRpcSig(signature.v, signature.r, signature.s)];
|
|
120
|
+
}
|
|
121
|
+
return [2 /*return*/];
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
};
|
|
125
|
+
EthereumCryptoClient.prototype.verifyMessage = function (message, signature, publicKey) {
|
|
126
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
127
|
+
var msgBuffer, msgHash, signatureBuffer, signatureParams, recoveredPublicKey, recoveredAddressBuffer, recoveredAddress, hexPublicKey, address;
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
msgBuffer = EthereumJSUtils.toBuffer(message);
|
|
130
|
+
msgHash = EthereumJSUtils.hashPersonalMessage(msgBuffer);
|
|
131
|
+
signatureBuffer = EthereumJSUtils.toBuffer(signature);
|
|
132
|
+
signatureParams = EthereumJSUtils.fromRpcSig(signatureBuffer);
|
|
133
|
+
recoveredPublicKey = EthereumJSUtils.ecrecover(msgHash, signatureParams.v, signatureParams.r, signatureParams.s);
|
|
134
|
+
recoveredAddressBuffer = EthereumJSUtils.publicToAddress(recoveredPublicKey);
|
|
135
|
+
recoveredAddress = EthereumJSUtils.bufferToHex(recoveredAddressBuffer);
|
|
136
|
+
hexPublicKey = (0, hex_1.isHex)(publicKey)
|
|
137
|
+
? (0, module_kit_1.newPublicKey)(publicKey, 'hex')
|
|
138
|
+
: (0, module_kit_1.newExtendedPublicKey)(publicKey, 'encoded');
|
|
139
|
+
address = EthereumAddress_1.EthereumAddress.from(hexPublicKey);
|
|
140
|
+
return [2 /*return*/, recoveredAddress.toLowerCase() === address.asString().toLowerCase()];
|
|
141
|
+
});
|
|
142
|
+
});
|
|
143
|
+
};
|
|
144
|
+
return EthereumCryptoClient;
|
|
145
|
+
}(Secp256k1CryptoClient_1.Secp256k1CryptoClient));
|
|
146
|
+
exports.EthereumCryptoClient = EthereumCryptoClient;
|
|
147
|
+
//# sourceMappingURL=EthereumCryptoClient.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthereumCryptoClient.js","sourceRoot":"","sources":["../../../../src/v1/clients/crypto/EthereumCryptoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,aAAa;AACb,2GAA8F;AAC9F,sDAA2D;AAC3D,2EAAkE;AAClE,8FAA4F;AAC5F,sDAAsD;AACtD,iDAAqG;AACrG,uDAAuG;AAEvG,8DAA4D;AAE5D;IAA0C,wCAAqB;IAA/D;;IAgDA,CAAC;IA/Cc,0CAAW,GAAxB,UAAyB,OAAe,EAAE,OAA+B;;;;gBACvE,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE;oBACvB,MAAM,IAAI,sBAAa,CAAC,sBAAM,CAAC,QAAQ,EAAE,0BAA0B,CAAC,CAAA;iBACrE;gBAEK,UAAU,GAAG,MAAM,CAAC,IAAI,CAAC,OAAO,CAAC,UAAU,EAAE,KAAK,CAAC,CAAA;gBAEzD,IAAI;oBACF,IAAI;wBAEI,cAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB,CAAC,aAAa;wBAAd,CAAA;wBAC1D,sBAAO,IAAA,4BAAa,EAAC,EAAE,UAAU,YAAA,EAAE,IAAI,EAAE,WAAS,EAAE,OAAO,EAAE,mCAAoB,CAAC,EAAE,EAAE,CAAC,EAAA;qBACxF;oBAAC,OAAO,CAAC,EAAE,GAAE;oBACd,IAAI;wBAEI,cAAY,IAAI,CAAC,KAAK,CAAC,OAAO,CAAsB,CAAC,aAAa;wBAAd,CAAA;wBAC1D,sBAAO,IAAA,4BAAa,EAAC,EAAE,UAAU,YAAA,EAAE,IAAI,EAAE,WAAS,EAAE,OAAO,EAAE,mCAAoB,CAAC,EA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E,CAAC,CAAC,IAAA,yBAAY,EAAC,SAAS,EAAE,KAAK,CAAC;oBAChC,CAAC,CAAC,IAAA,iCAAoB,EAAC,SAAS,EAAE,SAAS,CAAC,CAAA;gBACxC,OAAO,GAAoB,iCAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAA;gBAEnE,sBAAO,gBAAgB,CAAC,WAAW,EAAE,KAAK,OAAO,CAAC,QAAQ,EAAE,CAAC,WAAW,EAAE,EAAA;;;KAC3E;IACH,2BAAC;AAAD,CAAC,AAhDD,CAA0C,6CAAqB,GAgD9D;AAhDY,oDAAoB"}
|
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
export
|
|
4
|
-
|
|
1
|
+
import { AirGapTransaction } from '@airgap/module-kit';
|
|
2
|
+
import { EthereumTransactionCursor } from '../../types/transaction';
|
|
3
|
+
export declare type EthereumInfoClientTransaction = Omit<AirGapTransaction, 'network'>;
|
|
4
|
+
export interface EthereumInfoClientTransactionsResult {
|
|
5
|
+
transactions: EthereumInfoClientTransaction[];
|
|
6
|
+
cursor: {
|
|
7
|
+
page: number;
|
|
8
|
+
};
|
|
5
9
|
}
|
|
6
|
-
export
|
|
7
|
-
}
|
|
8
|
-
export declare abstract class EthereumInfoClient implements EvmInfoClient<EthereumTransactionCursor, EthereumInfoClientTransactionsResult> {
|
|
10
|
+
export declare abstract class EthereumInfoClient {
|
|
9
11
|
baseURL: string;
|
|
10
12
|
constructor(baseURL: string);
|
|
11
13
|
abstract fetchTransactions(address: string, limit: number, cursor?: EthereumTransactionCursor): Promise<EthereumInfoClientTransactionsResult>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthereumInfoClient.js","sourceRoot":"","sources":["../../../../src/v1/clients/info/EthereumInfoClient.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"EthereumInfoClient.js","sourceRoot":"","sources":["../../../../src/v1/clients/info/EthereumInfoClient.ts"],"names":[],"mappings":";;;AAYA;IAGE,4BAAY,OAAe;QACzB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAA;IACxB,CAAC;IAaH,yBAAC;AAAD,CAAC,AAlBD,IAkBC;AAlBqB,gDAAkB"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { EthereumTransactionCursor } from '../../types/transaction';
|
|
2
|
+
import { EthereumInfoClient, EthereumInfoClientTransactionsResult } from './EthereumInfoClient';
|
|
2
3
|
export declare class EtherscanInfoClient extends EthereumInfoClient {
|
|
3
4
|
private readonly apiKey?;
|
|
4
5
|
constructor(baseURL: string, apiKey?: string | undefined);
|
|
@@ -111,7 +111,6 @@ var EtherscanInfoClient = /** @class */ (function (_super) {
|
|
|
111
111
|
return [2 /*return*/, {
|
|
112
112
|
transactions: airGapTransactions,
|
|
113
113
|
cursor: {
|
|
114
|
-
hasNext: limit == airGapTransactions.length,
|
|
115
114
|
page: page + 1
|
|
116
115
|
}
|
|
117
116
|
}];
|
|
@@ -161,7 +160,6 @@ var EtherscanInfoClient = /** @class */ (function (_super) {
|
|
|
161
160
|
return [2 /*return*/, {
|
|
162
161
|
transactions: airGapTransactions,
|
|
163
162
|
cursor: {
|
|
164
|
-
hasNext: limit == airGapTransactions.length,
|
|
165
163
|
page: page + 1
|
|
166
164
|
}
|
|
167
165
|
}];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EtherscanInfoClient.js","sourceRoot":"","sources":["../../../../src/v1/clients/info/EtherscanInfoClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,oGAAsE;AACtE,gGAA8F;AAC9F,8FAA2F;AAC3F,sDAA0D;AAC1D,2EAAkE;AAClE,iDAA8C;
|
|
1
|
+
{"version":3,"file":"EtherscanInfoClient.js","sourceRoot":"","sources":["../../../../src/v1/clients/info/EtherscanInfoClient.ts"],"names":[],"mappings":";;;;;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,CAAC,WAAW,CAAC,SAAS,EAAE,EAAE,CAAC;gCAC9C,MAAM,EAAE;oCACN,IAAI,EAAE,WAAW,CAAC,gBAAgB,KAAK,SAAS,IAAI,WAAW,CAAC,gBAAgB,KAAK,GAAG,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,QAAQ;oCAC/G,IAAI,EAAE,WAAW,CAAC,IAAI;oCACtB,KAAK,EAAE,WAAW,CAAC,WAAW;iCAC/B;6BACF,CAAA;4BAED,kBAAkB,CAAC,IAAI,CAAC,iBAAiB,CAAC,CAAA;yBAC3C;wBAED,sBAAO;gCACL,YAAY,EAAE,kBAAkB;gCAChC,MAAM,EAAE;oCACN,IAAI,EAAE,IAAI,GAAG,CAAC;iCACf;6BACF,EAAA;;;;KACF;IACH,0BAAC;AAAD,CAAC,AArGD,CAAyC,uCAAkB,GAqG1D;AArGY,kDAAmB"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import BigNumber from '@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
|
|
2
|
+
import { AirGapTransactionStatus } from '@airgap/module-kit';
|
|
3
|
+
export interface EthereumNodeClient {
|
|
4
|
+
fetchBalance(address: string): Promise<BigNumber>;
|
|
5
|
+
fetchTransactionCount(address: string): Promise<number>;
|
|
6
|
+
sendSignedTransaction(transaction: string): Promise<string>;
|
|
7
|
+
callBalanceOf(contractAddress: string, address: string): Promise<BigNumber>;
|
|
8
|
+
getTransactionStatus(transactionHash: string): Promise<AirGapTransactionStatus>;
|
|
9
|
+
estimateTransferGas(contractAddress: string, fromAddress: string, toAddress: string, hexAmount: string): Promise<BigNumber>;
|
|
10
|
+
estimateTransactionGas(fromAddress: string, toAddress: string, amount?: string, data?: string, gas?: string): Promise<BigNumber>;
|
|
11
|
+
getGasPrice(): Promise<BigNumber>;
|
|
12
|
+
callBalanceOfOnContracts(contractAddresses: string[], address: string): Promise<{
|
|
13
|
+
[contractAddress: string]: BigNumber;
|
|
14
|
+
}>;
|
|
15
|
+
getContractName(contractAddress: string): Promise<string | undefined>;
|
|
16
|
+
getContractSymbol(contractAddress: string): Promise<string | undefined>;
|
|
17
|
+
getContractDecimals(contractAddress: string): Promise<number | undefined>;
|
|
18
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EthereumNodeClient.js","sourceRoot":"","sources":["../../../../src/v1/clients/node/EthereumNodeClient.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
+
}
|