@airgap/ethereum 0.13.45-beta.3 → 0.13.45-beta.5
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 +5 -5
- package/v0/index.js +10 -10
- package/v0/index.js.map +1 -1
- package/v0/protocol/BaseEthereumProtocol.d.ts +1 -0
- package/v0/protocol/BaseEthereumProtocol.js +872 -460
- package/v0/protocol/BaseEthereumProtocol.js.map +1 -1
- package/v0/protocol/EthereumAddress.d.ts +1 -0
- package/v0/protocol/EthereumAddress.js +17 -26
- package/v0/protocol/EthereumAddress.js.map +1 -1
- package/v0/protocol/EthereumClassicProtocol.js +23 -6
- package/v0/protocol/EthereumClassicProtocol.js.map +1 -1
- package/v0/protocol/EthereumCryptoClient.js +125 -66
- package/v0/protocol/EthereumCryptoClient.js.map +1 -1
- package/v0/protocol/EthereumProtocol.js +28 -9
- package/v0/protocol/EthereumProtocol.js.map +1 -1
- package/v0/protocol/EthereumProtocolOptions.d.ts +1 -1
- package/v0/protocol/EthereumProtocolOptions.js +117 -36
- package/v0/protocol/EthereumProtocolOptions.js.map +1 -1
- package/v0/protocol/EthereumRopstenProtocol.js +23 -6
- package/v0/protocol/EthereumRopstenProtocol.js.map +1 -1
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +186 -86
- package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -1
- package/v0/protocol/clients/info-clients/InfoClient.js +4 -3
- package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -1
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js +298 -126
- package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -1
- package/v0/protocol/clients/node-clients/NodeClient.js +4 -3
- package/v0/protocol/clients/node-clients/NodeClient.js.map +1 -1
- package/v0/protocol/erc20/ERC20.js +4 -4
- package/v0/protocol/erc20/ERC20.js.map +1 -1
- package/v0/protocol/erc20/GenericERC20.js +300 -161
- package/v0/protocol/erc20/GenericERC20.js.map +1 -1
- package/v0/protocol/utils/utils.js +55 -52
- package/v0/protocol/utils/utils.js.map +1 -1
- package/v0/serializer/validators/transaction-validator.js +31 -23
- package/v0/serializer/validators/transaction-validator.js.map +1 -1
- package/v0/serializer/validators/validators.js +73 -25
- package/v0/serializer/validators/validators.js.map +1 -1
- package/v1/block-explorer/EtherscanBlockExplorer.js +61 -12
- package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -1
- package/v1/clients/crypto/EthereumCryptoClient.js +124 -69
- package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -1
- package/v1/clients/info/EthereumInfoClient.d.ts +1 -1
- package/v1/clients/info/EthereumInfoClient.js +4 -3
- package/v1/clients/info/EthereumInfoClient.js.map +1 -1
- package/v1/clients/info/EtherscanInfoClient.js +162 -84
- package/v1/clients/info/EtherscanInfoClient.js.map +1 -1
- package/v1/clients/node/HttpEthereumNodeClient.d.ts +2 -2
- package/v1/clients/node/HttpEthereumNodeClient.js +375 -164
- package/v1/clients/node/HttpEthereumNodeClient.js.map +1 -1
- package/v1/data/EthereumAddress.js +20 -29
- package/v1/data/EthereumAddress.js.map +1 -1
- package/v1/index.js +14 -14
- package/v1/index.js.map +1 -1
- package/v1/module/EthereumModule.js +112 -43
- package/v1/module/EthereumModule.js.map +1 -1
- package/v1/module.js +3 -2
- package/v1/module.js.map +1 -1
- package/v1/protocol/EthereumBaseProtocol.js +788 -467
- package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
- package/v1/protocol/EthereumProtocol.js +46 -15
- package/v1/protocol/EthereumProtocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Protocol.js +360 -213
- package/v1/protocol/erc20/ERC20Protocol.js.map +1 -1
- package/v1/protocol/erc20/ERC20Token.d.ts +1 -1
- package/v1/protocol/erc20/ERC20Token.js +113 -35
- package/v1/protocol/erc20/ERC20Token.js.map +1 -1
- package/v1/serializer/v3/schemas/converter/transaction-converter.js +42 -25
- package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
- package/v1/serializer/v3/serializer-companion.js +148 -71
- package/v1/serializer/v3/serializer-companion.js.map +1 -1
- package/v1/serializer/v3/validators/transaction-validator.js +17 -14
- package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
- package/v1/types/crypto.d.ts +1 -1
- package/v1/types/protocol.d.ts +1 -1
- package/v1/types/transaction.d.ts +1 -1
- package/v1/utils/EthereumUtils.js +60 -57
- package/v1/utils/EthereumUtils.js.map +1 -1
- package/v1/utils/key.js +19 -28
- package/v1/utils/key.js.map +1 -1
- package/v1/utils/protocol.js +21 -33
- package/v1/utils/protocol.js.map +1 -1
|
@@ -1,19 +1,21 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EthereumUtils = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
var bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
|
|
5
|
+
var errors_1 = require("@airgap/coinlib-core/errors");
|
|
6
|
+
var coinlib_error_1 = require("@airgap/coinlib-core/errors/coinlib-error");
|
|
7
7
|
// var _ = require('underscore')
|
|
8
8
|
// var BN = require('@airgap/coinlib-core/dependencies/src/bn.js-4.11.8/bn')
|
|
9
9
|
// var numberToBN = require('number-to-bn')
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
var utf8 = require('@airgap/coinlib-core/dependencies/src/utf8-3.0.0/utf8');
|
|
11
|
+
var createKeccakHash = require('@airgap/coinlib-core/dependencies/src/keccak-1.0.2/js');
|
|
12
12
|
// this code was adapted from web3.js (https://github.com/ethereum/web3.js/blob/2.x/packages/web3-utils/src/Utils.js)
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
var EthereumUtils = /** @class */ (function () {
|
|
14
|
+
function EthereumUtils() {
|
|
15
|
+
}
|
|
16
|
+
EthereumUtils.toHex = function (value) {
|
|
15
17
|
if (EthereumUtils.isAddress(value)) {
|
|
16
|
-
return
|
|
18
|
+
return "0x".concat(value.toLowerCase().replace(/^0x/i, ''));
|
|
17
19
|
}
|
|
18
20
|
if (typeof value === 'boolean') {
|
|
19
21
|
return value ? '0x01' : '0x00';
|
|
@@ -34,65 +36,64 @@ class EthereumUtils {
|
|
|
34
36
|
}
|
|
35
37
|
}
|
|
36
38
|
return EthereumUtils.numberToHex(value);
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
let valueInBytes = value;
|
|
39
|
+
};
|
|
40
|
+
EthereumUtils.sha3 = function (value) {
|
|
41
|
+
var valueInBytes = value;
|
|
41
42
|
if (EthereumUtils.isHexStrict(value) && /^0x/i.test(value.toString())) {
|
|
42
43
|
valueInBytes = EthereumUtils.hexToBytes(value);
|
|
43
44
|
}
|
|
44
|
-
|
|
45
|
-
|
|
45
|
+
var hash = createKeccakHash('keccak256').update(valueInBytes).digest('hex');
|
|
46
|
+
var returnValue = "0x".concat(hash);
|
|
46
47
|
if (returnValue === EthereumUtils.SHA3_NULL_S) {
|
|
47
48
|
return null;
|
|
48
49
|
}
|
|
49
50
|
else {
|
|
50
51
|
return returnValue;
|
|
51
52
|
}
|
|
52
|
-
}
|
|
53
|
-
|
|
53
|
+
};
|
|
54
|
+
EthereumUtils.numberToHex = function (value) {
|
|
54
55
|
if (value === null || value === undefined) {
|
|
55
56
|
return value;
|
|
56
57
|
}
|
|
57
58
|
if (!isFinite(Number(value)) && !EthereumUtils.isHexStrict(value)) {
|
|
58
|
-
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS,
|
|
59
|
+
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given input \"".concat(JSON.stringify(value), "\" is not a number."));
|
|
59
60
|
}
|
|
60
61
|
// var number = EthereumUtils.toBN(value)
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
return myNumber.lt(new bignumber_1.BigNumber(0)) ?
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
|
|
62
|
+
var myNumber = new bignumber_1.BigNumber(value);
|
|
63
|
+
var result = myNumber.toString(16);
|
|
64
|
+
return myNumber.lt(new bignumber_1.BigNumber(0)) ? "-0x".concat(result.substr(1)) : "0x".concat(result);
|
|
65
|
+
};
|
|
66
|
+
EthereumUtils.hexToBytes = function (value) {
|
|
67
|
+
var hex = typeof value === 'number' ? value.toString(16) : value;
|
|
67
68
|
if (!EthereumUtils.isHexStrict(hex)) {
|
|
68
|
-
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS,
|
|
69
|
+
throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given value \"".concat(JSON.stringify(hex), "\" is not a valid hex string."));
|
|
69
70
|
}
|
|
70
71
|
hex = hex.replace(/^0x/i, '');
|
|
71
|
-
|
|
72
|
-
for (
|
|
72
|
+
var bytes = [];
|
|
73
|
+
for (var c = 0; c < hex.length; c += 2) {
|
|
73
74
|
bytes.push(parseInt(hex.substr(c, 2), 16));
|
|
74
75
|
}
|
|
75
76
|
return bytes;
|
|
76
|
-
}
|
|
77
|
-
|
|
77
|
+
};
|
|
78
|
+
EthereumUtils.isHexStrict = function (hex) {
|
|
78
79
|
return (typeof hex === 'string' || typeof hex === 'number') && /^(-)?0x[0-9a-f]*$/i.test(hex.toString());
|
|
79
|
-
}
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
};
|
|
81
|
+
EthereumUtils.checkAddressChecksum = function (value) {
|
|
82
|
+
var address = value.replace(/^0x/i, '');
|
|
83
|
+
var addressHash = EthereumUtils.sha3(address.toLowerCase());
|
|
83
84
|
if (addressHash === null) {
|
|
84
85
|
return false;
|
|
85
86
|
}
|
|
86
87
|
addressHash = addressHash.replace(/^0x/i, '');
|
|
87
|
-
for (
|
|
88
|
+
for (var i = 0; i < 40; i++) {
|
|
88
89
|
if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) ||
|
|
89
90
|
(parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
|
|
90
91
|
return false;
|
|
91
92
|
}
|
|
92
93
|
}
|
|
93
94
|
return true;
|
|
94
|
-
}
|
|
95
|
-
|
|
95
|
+
};
|
|
96
|
+
EthereumUtils.isAddress = function (value) {
|
|
96
97
|
if (!/^(0x)?[0-9a-f]{40}$/i.test(value)) {
|
|
97
98
|
return false;
|
|
98
99
|
// If it's ALL lowercase or ALL upppercase
|
|
@@ -104,34 +105,36 @@ class EthereumUtils {
|
|
|
104
105
|
else {
|
|
105
106
|
return EthereumUtils.checkAddressChecksum(value);
|
|
106
107
|
}
|
|
107
|
-
}
|
|
108
|
-
|
|
108
|
+
};
|
|
109
|
+
EthereumUtils.isBigNumber = function (value) {
|
|
109
110
|
if (!value) {
|
|
110
111
|
return false;
|
|
111
112
|
}
|
|
112
113
|
else {
|
|
113
114
|
return bignumber_1.BigNumber.isBigNumber(value);
|
|
114
115
|
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
116
|
+
};
|
|
117
|
+
EthereumUtils.utf8ToHex = function (value) {
|
|
118
|
+
var str = utf8.encode(value);
|
|
119
|
+
var hex = '';
|
|
119
120
|
// remove \u0000 padding from either side
|
|
120
121
|
str = str.replace(/^(?:\u0000)*/, '');
|
|
121
122
|
str = str.split('').reverse().join('');
|
|
122
123
|
str = str.replace(/^(?:\u0000)*/, '');
|
|
123
124
|
str = str.split('').reverse().join('');
|
|
124
|
-
for (
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
hex += n.length < 2 ?
|
|
128
|
-
}
|
|
129
|
-
return
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
|
|
125
|
+
for (var i = 0; i < str.length; i++) {
|
|
126
|
+
var code = str.charCodeAt(i);
|
|
127
|
+
var n = code.toString(16);
|
|
128
|
+
hex += n.length < 2 ? "0".concat(n) : n;
|
|
129
|
+
}
|
|
130
|
+
return "0x".concat(hex);
|
|
131
|
+
};
|
|
132
|
+
EthereumUtils.isObject = function (value) {
|
|
133
|
+
var type = typeof value;
|
|
133
134
|
return type === 'function' || (type === 'object' && !!value);
|
|
134
|
-
}
|
|
135
|
-
|
|
135
|
+
};
|
|
136
|
+
EthereumUtils.SHA3_NULL_S = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';
|
|
137
|
+
return EthereumUtils;
|
|
138
|
+
}());
|
|
136
139
|
exports.EthereumUtils = EthereumUtils;
|
|
137
140
|
//# sourceMappingURL=utils.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/v0/protocol/utils/utils.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/v0/protocol/utils/utils.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;AACrH;IAAA;IAqJA,CAAC;IApJe,mBAAK,GAAnB,UAAoB,KAAU;QAC5B,IAAI,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE;YAClC,OAAO,YAAK,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAE,CAAA;SACtD;QAED,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE;YAC9B,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;SAC/B;QAED,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,kCAAkC,EAAE;YACzG,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,CA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CAAA;YACnC,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,WAAI,CAAC,CAAE,CAAC,CAAC,CAAC,CAAC,CAAA;SAClC;QAED,OAAO,YAAK,GAAG,CAAE,CAAA;IACnB,CAAC;IAEc,sBAAQ,GAAvB,UAAwB,KAAc;QACpC,IAAM,IAAI,GAAW,OAAO,KAAK,CAAA;QAEjC,OAAO,IAAI,KAAK,UAAU,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,CAAA;IAC9D,CAAC;IAxHuB,yBAAW,GAAW,oEAAoE,CAAA;IAyHpH,oBAAC;CAAA,AArJD,IAqJC;AArJY,sCAAa"}
|
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.EthereumTransactionValidatorFactoryV2 = exports.EthereumTransactionValidatorFactory = exports.EthereumTransactionValidator = void 0;
|
|
4
4
|
// tslint:disable: max-classes-per-file
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
6
|
+
var serializer_1 = require("@airgap/serializer");
|
|
7
|
+
var unsignedTransactionConstraints = {
|
|
8
8
|
nonce: {
|
|
9
9
|
presence: { allowEmpty: false },
|
|
10
10
|
type: 'String',
|
|
@@ -25,7 +25,7 @@ const unsignedTransactionConstraints = {
|
|
|
25
25
|
type: 'String',
|
|
26
26
|
isHexStringWithPrefix: true,
|
|
27
27
|
format: {
|
|
28
|
-
pattern: '^0x[a-fA-F0-9]{40}$',
|
|
28
|
+
pattern: '^0x[a-fA-F0-9]{40}$',
|
|
29
29
|
flags: 'i',
|
|
30
30
|
message: 'is not a valid ethereum address'
|
|
31
31
|
}
|
|
@@ -45,21 +45,22 @@ const unsignedTransactionConstraints = {
|
|
|
45
45
|
isHexStringWithPrefix: true
|
|
46
46
|
}
|
|
47
47
|
};
|
|
48
|
-
|
|
48
|
+
var signedTransactionConstraints = {
|
|
49
49
|
transaction: {
|
|
50
50
|
presence: { allowEmpty: false },
|
|
51
51
|
type: 'String',
|
|
52
52
|
isValidEthereumTransactionString: true
|
|
53
53
|
}
|
|
54
54
|
};
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
55
|
+
var success = function () { return undefined; };
|
|
56
|
+
var error = function (errors) { return errors; };
|
|
57
|
+
var EthereumTransactionValidator = /** @class */ (function () {
|
|
58
|
+
function EthereumTransactionValidator(version) {
|
|
59
|
+
if (version === void 0) { version = 'v3'; }
|
|
59
60
|
this.version = version;
|
|
60
61
|
}
|
|
61
|
-
validateUnsignedTransaction(unsignedTx) {
|
|
62
|
-
|
|
62
|
+
EthereumTransactionValidator.prototype.validateUnsignedTransaction = function (unsignedTx) {
|
|
63
|
+
var rawTx = unsignedTx.transaction;
|
|
63
64
|
if (this.version === 'v3') {
|
|
64
65
|
(0, serializer_1.validateSyncScheme)({});
|
|
65
66
|
}
|
|
@@ -67,22 +68,29 @@ class EthereumTransactionValidator {
|
|
|
67
68
|
(0, serializer_1.validateSyncSchemeV2)({});
|
|
68
69
|
}
|
|
69
70
|
return (0, validate_1.async)(rawTx, unsignedTransactionConstraints).then(success, error);
|
|
70
|
-
}
|
|
71
|
-
validateSignedTransaction(signedTx) {
|
|
71
|
+
};
|
|
72
|
+
EthereumTransactionValidator.prototype.validateSignedTransaction = function (signedTx) {
|
|
72
73
|
return (0, validate_1.async)(signedTx, signedTransactionConstraints).then(success, error);
|
|
73
|
-
}
|
|
74
|
-
|
|
74
|
+
};
|
|
75
|
+
return EthereumTransactionValidator;
|
|
76
|
+
}());
|
|
75
77
|
exports.EthereumTransactionValidator = EthereumTransactionValidator;
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
return new EthereumTransactionValidator('v3');
|
|
78
|
+
var EthereumTransactionValidatorFactory = /** @class */ (function () {
|
|
79
|
+
function EthereumTransactionValidatorFactory() {
|
|
79
80
|
}
|
|
80
|
-
|
|
81
|
+
EthereumTransactionValidatorFactory.prototype.create = function () {
|
|
82
|
+
return new EthereumTransactionValidator('v3');
|
|
83
|
+
};
|
|
84
|
+
return EthereumTransactionValidatorFactory;
|
|
85
|
+
}());
|
|
81
86
|
exports.EthereumTransactionValidatorFactory = EthereumTransactionValidatorFactory;
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
return new EthereumTransactionValidator('v2');
|
|
87
|
+
var EthereumTransactionValidatorFactoryV2 = /** @class */ (function () {
|
|
88
|
+
function EthereumTransactionValidatorFactoryV2() {
|
|
85
89
|
}
|
|
86
|
-
|
|
90
|
+
EthereumTransactionValidatorFactoryV2.prototype.create = function () {
|
|
91
|
+
return new EthereumTransactionValidator('v2');
|
|
92
|
+
};
|
|
93
|
+
return EthereumTransactionValidatorFactoryV2;
|
|
94
|
+
}());
|
|
87
95
|
exports.EthereumTransactionValidatorFactoryV2 = EthereumTransactionValidatorFactoryV2;
|
|
88
96
|
//# sourceMappingURL=transaction-validator.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,
|
|
1
|
+
{"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,iDAO2B;AAK3B,IAAM,8BAA8B,GAAG;IACrC,KAAK,EAAE;QACL,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;KAC5B;IACD,QAAQ,EAAE;QACR,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;KAC5B;IACD,QAAQ,EAA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AW,CAAA;QAE5D,IAAI,IAAI,CAAC,OAAO,KAAK,IAAI,EAAE;YACzB,IAAA,+BAAkB,EAAC,EAAE,CAAC,CAAA;SACvB;aAAM;YACL,IAAA,iCAAoB,EAAC,EAAE,CAAC,CAAA;SACzB;QAED,OAAO,IAAA,gBAAK,EAAC,KAAK,EAAE,8BAA8B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC1E,CAAC;IACM,gEAAyB,GAAhC,UAAiC,QAAmC;QAClE,OAAO,IAAA,gBAAK,EAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC3E,CAAC;IACH,mCAAC;AAAD,CAAC,AAjBD,IAiBC;AAjBY,oEAA4B;AAmBzC;IAAA;IAIA,CAAC;IAHQ,oDAAM,GAAb;QACE,OAAO,IAAI,4BAA4B,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IACH,0CAAC;AAAD,CAAC,AAJD,IAIC;AAJY,kFAAmC;AAMhD;IAAA;IAIA,CAAC;IAHQ,sDAAM,GAAb;QACE,OAAO,IAAI,4BAA4B,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;IACH,4CAAC;AAAD,CAAC,AAJD,IAIC;AAJY,sFAAqC"}
|
|
@@ -1,30 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
validate_1.validators.isValidEthereumTransactionString = (transaction)
|
|
39
|
+
var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
|
|
40
|
+
var EthereumProtocol_1 = require("../../protocol/EthereumProtocol");
|
|
41
|
+
validate_1.validators.isValidEthereumTransactionString = function (transaction) {
|
|
6
42
|
// console.log(binaryTransaction)
|
|
7
|
-
return new Promise(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
43
|
+
return new Promise(function (resolve, reject) { return __awaiter(void 0, void 0, void 0, function () {
|
|
44
|
+
var signedTx, protocol, error_1;
|
|
45
|
+
return __generator(this, function (_a) {
|
|
46
|
+
switch (_a.label) {
|
|
47
|
+
case 0:
|
|
48
|
+
if (transaction === null || typeof transaction === 'undefined') {
|
|
49
|
+
reject('not a valid Ethereum transaction');
|
|
50
|
+
}
|
|
51
|
+
signedTx = {
|
|
52
|
+
accountIdentifier: '',
|
|
53
|
+
transaction: transaction
|
|
54
|
+
};
|
|
55
|
+
protocol = new EthereumProtocol_1.EthereumProtocol();
|
|
56
|
+
// allow empty values by default (needs to be checked by "presence" check)
|
|
57
|
+
if (transaction === null || typeof transaction === 'undefined') {
|
|
58
|
+
reject();
|
|
59
|
+
}
|
|
60
|
+
_a.label = 1;
|
|
61
|
+
case 1:
|
|
62
|
+
_a.trys.push([1, 3, , 4]);
|
|
63
|
+
return [4 /*yield*/, protocol.getTransactionDetailsFromSigned(signedTx)];
|
|
64
|
+
case 2:
|
|
65
|
+
_a.sent();
|
|
66
|
+
resolve();
|
|
67
|
+
return [3 /*break*/, 4];
|
|
68
|
+
case 3:
|
|
69
|
+
error_1 = _a.sent();
|
|
70
|
+
// console.log(error)
|
|
71
|
+
reject('not a valid Ethereum transaction');
|
|
72
|
+
return [3 /*break*/, 4];
|
|
73
|
+
case 4: return [2 /*return*/];
|
|
74
|
+
}
|
|
75
|
+
});
|
|
76
|
+
}); });
|
|
29
77
|
};
|
|
30
78
|
//# sourceMappingURL=validators.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/validators.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/validators.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8FAA8F;AAE9F,oEAAkE;AAGlE,qBAAU,CAAC,gCAAgC,GAAG,UAAC,WAAmB;IAChE,iCAAiC;IACjC,OAAO,IAAI,OAAO,CAAO,UAAO,OAAO,EAAE,MAAM;;;;;oBAC7C,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;wBAC9D,MAAM,CAAC,kCAAkC,CAAC,CAAA;qBAC3C;oBACK,QAAQ,GAA8B;wBAC1C,iBAAiB,EAAE,EAAE;wBACrB,WAAW,aAAA;qBACZ,CAAA;oBACK,QAAQ,GAAG,IAAI,mCAAgB,EAAE,CAAA;oBACvC,0EAA0E;oBAC1E,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE;wBAC9D,MAAM,EAAE,CAAA;qBACT;;;;oBAEC,qBAAM,QAAQ,CAAC,+BAA+B,CAAC,QAAQ,CAAC,EAAA;;oBAAxD,SAAwD,CAAA;oBACxD,OAAO,EAAE,CAAA;;;;oBAET,qBAAqB;oBACrB,MAAM,CAAC,kCAAkC,CAAC,CAAA;;;;;SAE7C,CAAC,CAAA;AACJ,CAAC,CAAA"}
|
|
@@ -1,23 +1,72 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
+
function step(op) {
|
|
16
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
+
while (_) try {
|
|
18
|
+
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;
|
|
19
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
+
switch (op[0]) {
|
|
21
|
+
case 0: case 1: t = op; break;
|
|
22
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
+
default:
|
|
26
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
+
if (t[2]) _.ops.pop();
|
|
31
|
+
_.trys.pop(); continue;
|
|
32
|
+
}
|
|
33
|
+
op = body.call(thisArg, _);
|
|
34
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
+
}
|
|
37
|
+
};
|
|
2
38
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
39
|
exports.EtherscanBlockExplorer = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
40
|
+
var EtherscanBlockExplorer = /** @class */ (function () {
|
|
41
|
+
function EtherscanBlockExplorer(url) {
|
|
6
42
|
this.url = url;
|
|
7
43
|
this.metadata = {
|
|
8
44
|
name: 'Etherscan',
|
|
9
45
|
url: this.url
|
|
10
46
|
};
|
|
11
47
|
}
|
|
12
|
-
|
|
13
|
-
return this
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
48
|
+
EtherscanBlockExplorer.prototype.getMetadata = function () {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
return [2 /*return*/, this.metadata];
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
EtherscanBlockExplorer.prototype.createAddressUrl = function (address) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
return [2 /*return*/, "".concat(this.url, "/address/").concat(address)];
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
EtherscanBlockExplorer.prototype.createTransactionUrl = function (transactionId) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
return [2 /*return*/, "".concat(this.url, "/tx/").concat(transactionId)];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return EtherscanBlockExplorer;
|
|
70
|
+
}());
|
|
22
71
|
exports.EtherscanBlockExplorer = EtherscanBlockExplorer;
|
|
23
72
|
//# sourceMappingURL=EtherscanBlockExplorer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EtherscanBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/EtherscanBlockExplorer.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EtherscanBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/EtherscanBlockExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAME,gCAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAL9B,aAAQ,GAA0B;YACjD,IAAI,EAAE,WAAW;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IAEiD,CAAC;IAEtC,4CAAW,GAAxB;;;gBACE,sBAAO,IAAI,CAAC,QAAQ,EAAA;;;KACrB;IAEY,iDAAgB,GAA7B,UAA8B,OAAe;;;gBAC3C,sBAAO,UAAG,IAAI,CAAC,GAAG,sBAAY,OAAO,CAAE,EAAA;;;KACxC;IAEY,qDAAoB,GAAjC,UAAkC,aAAqB;;;gBACrD,sBAAO,UAAG,IAAI,CAAC,GAAG,iBAAO,aAAa,CAAE,EAAA;;;KACzC;IACH,6BAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,wDAAsB"}
|