@airgap/ethereum 0.13.45-beta.1 → 0.13.45-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.
Files changed (82) hide show
  1. package/package.json +5 -5
  2. package/v0/index.js +10 -10
  3. package/v0/index.js.map +1 -1
  4. package/v0/protocol/BaseEthereumProtocol.d.ts +0 -1
  5. package/v0/protocol/BaseEthereumProtocol.js +460 -872
  6. package/v0/protocol/BaseEthereumProtocol.js.map +1 -1
  7. package/v0/protocol/EthereumAddress.d.ts +0 -1
  8. package/v0/protocol/EthereumAddress.js +26 -17
  9. package/v0/protocol/EthereumAddress.js.map +1 -1
  10. package/v0/protocol/EthereumClassicProtocol.js +6 -23
  11. package/v0/protocol/EthereumClassicProtocol.js.map +1 -1
  12. package/v0/protocol/EthereumCryptoClient.js +66 -125
  13. package/v0/protocol/EthereumCryptoClient.js.map +1 -1
  14. package/v0/protocol/EthereumProtocol.js +9 -28
  15. package/v0/protocol/EthereumProtocol.js.map +1 -1
  16. package/v0/protocol/EthereumProtocolOptions.d.ts +1 -1
  17. package/v0/protocol/EthereumProtocolOptions.js +36 -117
  18. package/v0/protocol/EthereumProtocolOptions.js.map +1 -1
  19. package/v0/protocol/EthereumRopstenProtocol.js +6 -23
  20. package/v0/protocol/EthereumRopstenProtocol.js.map +1 -1
  21. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +86 -186
  22. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -1
  23. package/v0/protocol/clients/info-clients/InfoClient.js +3 -4
  24. package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -1
  25. package/v0/protocol/clients/node-clients/AirGapNodeClient.js +126 -298
  26. package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -1
  27. package/v0/protocol/clients/node-clients/NodeClient.js +3 -4
  28. package/v0/protocol/clients/node-clients/NodeClient.js.map +1 -1
  29. package/v0/protocol/erc20/ERC20.js +4 -4
  30. package/v0/protocol/erc20/ERC20.js.map +1 -1
  31. package/v0/protocol/erc20/GenericERC20.js +161 -300
  32. package/v0/protocol/erc20/GenericERC20.js.map +1 -1
  33. package/v0/protocol/utils/utils.js +52 -55
  34. package/v0/protocol/utils/utils.js.map +1 -1
  35. package/v0/serializer/validators/transaction-validator.js +23 -31
  36. package/v0/serializer/validators/transaction-validator.js.map +1 -1
  37. package/v0/serializer/validators/validators.js +25 -73
  38. package/v0/serializer/validators/validators.js.map +1 -1
  39. package/v1/block-explorer/EtherscanBlockExplorer.js +12 -61
  40. package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -1
  41. package/v1/clients/crypto/EthereumCryptoClient.js +69 -124
  42. package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -1
  43. package/v1/clients/info/EthereumInfoClient.d.ts +1 -1
  44. package/v1/clients/info/EthereumInfoClient.js +3 -4
  45. package/v1/clients/info/EthereumInfoClient.js.map +1 -1
  46. package/v1/clients/info/EtherscanInfoClient.js +84 -162
  47. package/v1/clients/info/EtherscanInfoClient.js.map +1 -1
  48. package/v1/clients/node/HttpEthereumNodeClient.d.ts +2 -2
  49. package/v1/clients/node/HttpEthereumNodeClient.js +164 -375
  50. package/v1/clients/node/HttpEthereumNodeClient.js.map +1 -1
  51. package/v1/data/EthereumAddress.js +29 -20
  52. package/v1/data/EthereumAddress.js.map +1 -1
  53. package/v1/index.js +14 -14
  54. package/v1/index.js.map +1 -1
  55. package/v1/module/EthereumModule.js +43 -112
  56. package/v1/module/EthereumModule.js.map +1 -1
  57. package/v1/module.js +2 -3
  58. package/v1/module.js.map +1 -1
  59. package/v1/protocol/EthereumBaseProtocol.js +467 -788
  60. package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
  61. package/v1/protocol/EthereumProtocol.js +15 -46
  62. package/v1/protocol/EthereumProtocol.js.map +1 -1
  63. package/v1/protocol/erc20/ERC20Protocol.js +213 -360
  64. package/v1/protocol/erc20/ERC20Protocol.js.map +1 -1
  65. package/v1/protocol/erc20/ERC20Token.d.ts +1 -1
  66. package/v1/protocol/erc20/ERC20Token.js +35 -113
  67. package/v1/protocol/erc20/ERC20Token.js.map +1 -1
  68. package/v1/serializer/v3/schemas/converter/transaction-converter.js +25 -42
  69. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
  70. package/v1/serializer/v3/serializer-companion.js +71 -148
  71. package/v1/serializer/v3/serializer-companion.js.map +1 -1
  72. package/v1/serializer/v3/validators/transaction-validator.js +14 -17
  73. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -1
  74. package/v1/types/crypto.d.ts +1 -1
  75. package/v1/types/protocol.d.ts +1 -1
  76. package/v1/types/transaction.d.ts +1 -1
  77. package/v1/utils/EthereumUtils.js +57 -60
  78. package/v1/utils/EthereumUtils.js.map +1 -1
  79. package/v1/utils/key.js +28 -19
  80. package/v1/utils/key.js.map +1 -1
  81. package/v1/utils/protocol.js +33 -21
  82. package/v1/utils/protocol.js.map +1 -1
@@ -1,21 +1,19 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.EthereumUtils = void 0;
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");
4
+ const bignumber_1 = require("@airgap/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
5
+ const errors_1 = require("@airgap/coinlib-core/errors");
6
+ const 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
- 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');
10
+ const utf8 = require('@airgap/coinlib-core/dependencies/src/utf8-3.0.0/utf8');
11
+ const 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
- var EthereumUtils = /** @class */ (function () {
14
- function EthereumUtils() {
15
- }
16
- EthereumUtils.toHex = function (value) {
13
+ class EthereumUtils {
14
+ static toHex(value) {
17
15
  if (EthereumUtils.isAddress(value)) {
18
- return "0x".concat(value.toLowerCase().replace(/^0x/i, ''));
16
+ return `0x${value.toLowerCase().replace(/^0x/i, '')}`;
19
17
  }
20
18
  if (typeof value === 'boolean') {
21
19
  return value ? '0x01' : '0x00';
@@ -36,64 +34,65 @@ var EthereumUtils = /** @class */ (function () {
36
34
  }
37
35
  }
38
36
  return EthereumUtils.numberToHex(value);
39
- };
40
- EthereumUtils.sha3 = function (value) {
41
- var valueInBytes = value;
37
+ }
38
+ static { this.SHA3_NULL_S = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'; }
39
+ static sha3(value) {
40
+ let valueInBytes = value;
42
41
  if (EthereumUtils.isHexStrict(value) && /^0x/i.test(value.toString())) {
43
42
  valueInBytes = EthereumUtils.hexToBytes(value);
44
43
  }
45
- var hash = createKeccakHash('keccak256').update(valueInBytes).digest('hex');
46
- var returnValue = "0x".concat(hash);
44
+ const hash = createKeccakHash('keccak256').update(valueInBytes).digest('hex');
45
+ const returnValue = `0x${hash}`;
47
46
  if (returnValue === EthereumUtils.SHA3_NULL_S) {
48
47
  return null;
49
48
  }
50
49
  else {
51
50
  return returnValue;
52
51
  }
53
- };
54
- EthereumUtils.numberToHex = function (value) {
52
+ }
53
+ static numberToHex(value) {
55
54
  if (value === null || value === undefined) {
56
55
  return value;
57
56
  }
58
57
  if (!isFinite(Number(value)) && !EthereumUtils.isHexStrict(value)) {
59
- throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given input \"".concat(JSON.stringify(value), "\" is not a number."));
58
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, `Given input "${JSON.stringify(value)}" is not a number.`);
60
59
  }
61
60
  // var number = EthereumUtils.toBN(value)
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;
61
+ const myNumber = new bignumber_1.BigNumber(value);
62
+ const result = myNumber.toString(16);
63
+ return myNumber.lt(new bignumber_1.BigNumber(0)) ? `-0x${result.substr(1)}` : `0x${result}`;
64
+ }
65
+ static hexToBytes(value) {
66
+ let hex = typeof value === 'number' ? value.toString(16) : value;
68
67
  if (!EthereumUtils.isHexStrict(hex)) {
69
- throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given value \"".concat(JSON.stringify(hex), "\" is not a valid hex string."));
68
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, `Given value "${JSON.stringify(hex)}" is not a valid hex string.`);
70
69
  }
71
70
  hex = hex.replace(/^0x/i, '');
72
- var bytes = [];
73
- for (var c = 0; c < hex.length; c += 2) {
71
+ const bytes = [];
72
+ for (let c = 0; c < hex.length; c += 2) {
74
73
  bytes.push(parseInt(hex.substr(c, 2), 16));
75
74
  }
76
75
  return bytes;
77
- };
78
- EthereumUtils.isHexStrict = function (hex) {
76
+ }
77
+ static isHexStrict(hex) {
79
78
  return (typeof hex === 'string' || typeof hex === 'number') && /^(-)?0x[0-9a-f]*$/i.test(hex.toString());
80
- };
81
- EthereumUtils.checkAddressChecksum = function (value) {
82
- var address = value.replace(/^0x/i, '');
83
- var addressHash = EthereumUtils.sha3(address.toLowerCase());
79
+ }
80
+ static checkAddressChecksum(value) {
81
+ const address = value.replace(/^0x/i, '');
82
+ let addressHash = EthereumUtils.sha3(address.toLowerCase());
84
83
  if (addressHash === null) {
85
84
  return false;
86
85
  }
87
86
  addressHash = addressHash.replace(/^0x/i, '');
88
- for (var i = 0; i < 40; i++) {
87
+ for (let i = 0; i < 40; i++) {
89
88
  if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) ||
90
89
  (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
91
90
  return false;
92
91
  }
93
92
  }
94
93
  return true;
95
- };
96
- EthereumUtils.isAddress = function (value) {
94
+ }
95
+ static isAddress(value) {
97
96
  if (!/^(0x)?[0-9a-f]{40}$/i.test(value)) {
98
97
  return false;
99
98
  // If it's ALL lowercase or ALL upppercase
@@ -105,36 +104,34 @@ var EthereumUtils = /** @class */ (function () {
105
104
  else {
106
105
  return EthereumUtils.checkAddressChecksum(value);
107
106
  }
108
- };
109
- EthereumUtils.isBigNumber = function (value) {
107
+ }
108
+ static isBigNumber(value) {
110
109
  if (!value) {
111
110
  return false;
112
111
  }
113
112
  else {
114
113
  return bignumber_1.BigNumber.isBigNumber(value);
115
114
  }
116
- };
117
- EthereumUtils.utf8ToHex = function (value) {
118
- var str = utf8.encode(value);
119
- var hex = '';
115
+ }
116
+ static utf8ToHex(value) {
117
+ let str = utf8.encode(value);
118
+ let hex = '';
120
119
  // remove \u0000 padding from either side
121
120
  str = str.replace(/^(?:\u0000)*/, '');
122
121
  str = str.split('').reverse().join('');
123
122
  str = str.replace(/^(?:\u0000)*/, '');
124
123
  str = str.split('').reverse().join('');
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;
124
+ for (let i = 0; i < str.length; i++) {
125
+ const code = str.charCodeAt(i);
126
+ const n = code.toString(16);
127
+ hex += n.length < 2 ? `0${n}` : n;
128
+ }
129
+ return `0x${hex}`;
130
+ }
131
+ static isObject(value) {
132
+ const type = typeof value;
134
133
  return type === 'function' || (type === 'object' && !!value);
135
- };
136
- EthereumUtils.SHA3_NULL_S = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';
137
- return EthereumUtils;
138
- }());
134
+ }
135
+ }
139
136
  exports.EthereumUtils = EthereumUtils;
140
137
  //# sourceMappingURL=utils.js.map
@@ -1 +1 @@
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,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;SACtD;QAED,wDAAwD;QACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE;YAC7B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC,OAAO,CAAC,KAA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EAAE,EAAE,CAAC;YACpC,MAAM,IAAI,GAAW,GAAG,CAAC,UAAU,CAAC,CAAC,CAAC,CAAA;YACtC,MAAM,CAAC,GAAW,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAA;YACnC,GAAG,IAAI,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAA;QACnC,CAAC;QAED,OAAO,KAAK,GAAG,EAAE,CAAA;IACnB,CAAC;IAEO,MAAM,CAAC,QAAQ,CAAC,KAAc;QACpC,MAAM,IAAI,GAAW,OAAO,KAAK,CAAA;QAEjC,OAAO,IAAI,KAAK,UAAU,IAAI,CAAC,IAAI,KAAK,QAAQ,IAAI,CAAC,CAAC,KAAK,CAAC,CAAA;IAC9D,CAAC;;AApJH,sCAqJC"}
@@ -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
- 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 = {
5
+ const validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
6
+ const serializer_1 = require("@airgap/serializer");
7
+ const unsignedTransactionConstraints = {
8
8
  nonce: {
9
9
  presence: { allowEmpty: false },
10
10
  type: 'String',
@@ -25,7 +25,7 @@ var 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}$', // Should be new EthereumProtocol().addressValidationPattern, but then there is a runtime issue because of circular dependencies
29
29
  flags: 'i',
30
30
  message: 'is not a valid ethereum address'
31
31
  }
@@ -45,22 +45,21 @@ var unsignedTransactionConstraints = {
45
45
  isHexStringWithPrefix: true
46
46
  }
47
47
  };
48
- var signedTransactionConstraints = {
48
+ const signedTransactionConstraints = {
49
49
  transaction: {
50
50
  presence: { allowEmpty: false },
51
51
  type: 'String',
52
52
  isValidEthereumTransactionString: true
53
53
  }
54
54
  };
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'; }
55
+ const success = () => undefined;
56
+ const error = (errors) => errors;
57
+ class EthereumTransactionValidator {
58
+ constructor(version = 'v3') {
60
59
  this.version = version;
61
60
  }
62
- EthereumTransactionValidator.prototype.validateUnsignedTransaction = function (unsignedTx) {
63
- var rawTx = unsignedTx.transaction;
61
+ validateUnsignedTransaction(unsignedTx) {
62
+ const rawTx = unsignedTx.transaction;
64
63
  if (this.version === 'v3') {
65
64
  (0, serializer_1.validateSyncScheme)({});
66
65
  }
@@ -68,29 +67,22 @@ var EthereumTransactionValidator = /** @class */ (function () {
68
67
  (0, serializer_1.validateSyncSchemeV2)({});
69
68
  }
70
69
  return (0, validate_1.async)(rawTx, unsignedTransactionConstraints).then(success, error);
71
- };
72
- EthereumTransactionValidator.prototype.validateSignedTransaction = function (signedTx) {
70
+ }
71
+ validateSignedTransaction(signedTx) {
73
72
  return (0, validate_1.async)(signedTx, signedTransactionConstraints).then(success, error);
74
- };
75
- return EthereumTransactionValidator;
76
- }());
77
- exports.EthereumTransactionValidator = EthereumTransactionValidator;
78
- var EthereumTransactionValidatorFactory = /** @class */ (function () {
79
- function EthereumTransactionValidatorFactory() {
80
73
  }
81
- EthereumTransactionValidatorFactory.prototype.create = function () {
74
+ }
75
+ exports.EthereumTransactionValidator = EthereumTransactionValidator;
76
+ class EthereumTransactionValidatorFactory {
77
+ create() {
82
78
  return new EthereumTransactionValidator('v3');
83
- };
84
- return EthereumTransactionValidatorFactory;
85
- }());
86
- exports.EthereumTransactionValidatorFactory = EthereumTransactionValidatorFactory;
87
- var EthereumTransactionValidatorFactoryV2 = /** @class */ (function () {
88
- function EthereumTransactionValidatorFactoryV2() {
89
79
  }
90
- EthereumTransactionValidatorFactoryV2.prototype.create = function () {
80
+ }
81
+ exports.EthereumTransactionValidatorFactory = EthereumTransactionValidatorFactory;
82
+ class EthereumTransactionValidatorFactoryV2 {
83
+ create() {
91
84
  return new EthereumTransactionValidator('v2');
92
- };
93
- return EthereumTransactionValidatorFactoryV2;
94
- }());
85
+ }
86
+ }
95
87
  exports.EthereumTransactionValidatorFactoryV2 = EthereumTransactionValidatorFactoryV2;
96
88
  //# 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,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,EAAE;QACR,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;KAC5B;IACD,EAAE,EAAE;QACF,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;QAC3B,MAAM,EAAE;YACN,OAAO,EAAE,qBAAqB;YAC9B,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,iCAAiC;SAC3C;KACF;IACD,KAAK,EAAE;QACL,QAAQ,EAAE,EA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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
+ {"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,gGAAyF;AACzF,mDAO2B;AAK3B,MAAM,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,EAAE;QACR,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;KAC5B;IACD,EAAE,EAAE;QACF,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;QAC3B,MAAM,EAAE;YACN,OAAO,EAAE,qBAAqB,EAAE,gIAAgI;YAChK,KAAK,EAAE,GAAG;YACV,OAAO,EAAE,iCAAiC;SAC3C;KACF;IACD,KAAK,EAA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AAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC3E,CAAC;CACF;AAjBD,oEAiBC;AAED,MAAa,mCAAmC;IACvC,MAAM;QACX,OAAO,IAAI,4BAA4B,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;CACF;AAJD,kFAIC;AAED,MAAa,qCAAqC;IACzC,MAAM;QACX,OAAO,IAAI,4BAA4B,CAAC,IAAI,CAAC,CAAA;IAC/C,CAAC;CACF;AAJD,sFAIC"}
@@ -1,78 +1,30 @@
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
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
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) {
3
+ const validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
4
+ const EthereumProtocol_1 = require("../../protocol/EthereumProtocol");
5
+ validate_1.validators.isValidEthereumTransactionString = (transaction) => {
42
6
  // console.log(binaryTransaction)
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
- }); });
7
+ return new Promise(async (resolve, reject) => {
8
+ if (transaction === null || typeof transaction === 'undefined') {
9
+ reject('not a valid Ethereum transaction');
10
+ }
11
+ const signedTx = {
12
+ accountIdentifier: '',
13
+ transaction
14
+ };
15
+ const protocol = new EthereumProtocol_1.EthereumProtocol();
16
+ // allow empty values by default (needs to be checked by "presence" check)
17
+ if (transaction === null || typeof transaction === 'undefined') {
18
+ reject();
19
+ }
20
+ try {
21
+ await protocol.getTransactionDetailsFromSigned(signedTx);
22
+ resolve();
23
+ }
24
+ catch (error) {
25
+ // console.log(error)
26
+ reject('not a valid Ethereum transaction');
27
+ }
28
+ });
77
29
  };
78
30
  //# sourceMappingURL=validators.js.map
@@ -1 +1 @@
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
+ {"version":3,"file":"validators.js","sourceRoot":"","sources":["../../../../src/v0/serializer/validators/validators.ts"],"names":[],"mappings":";;AAAA,gGAA8F;AAE9F,sEAAkE;AAGlE,qBAAU,CAAC,gCAAgC,GAAG,CAAC,WAAmB,EAAE,EAAE;IACpE,iCAAiC;IACjC,OAAO,IAAI,OAAO,CAAO,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE;QACjD,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;YAC/D,MAAM,CAAC,kCAAkC,CAAC,CAAA;QAC5C,CAAC;QACD,MAAM,QAAQ,GAA8B;YAC1C,iBAAiB,EAAE,EAAE;YACrB,WAAW;SACZ,CAAA;QACD,MAAM,QAAQ,GAAG,IAAI,mCAAgB,EAAE,CAAA;QACvC,0EAA0E;QAC1E,IAAI,WAAW,KAAK,IAAI,IAAI,OAAO,WAAW,KAAK,WAAW,EAAE,CAAC;YAC/D,MAAM,EAAE,CAAA;QACV,CAAC;QACD,IAAI,CAAC;YACH,MAAM,QAAQ,CAAC,+BAA+B,CAAC,QAAQ,CAAC,CAAA;YACxD,OAAO,EAAE,CAAA;QACX,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,qBAAqB;YACrB,MAAM,CAAC,kCAAkC,CAAC,CAAA;QAC5C,CAAC;IACH,CAAC,CAAC,CAAA;AACJ,CAAC,CAAA"}
@@ -1,72 +1,23 @@
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
- };
38
2
  Object.defineProperty(exports, "__esModule", { value: true });
39
3
  exports.EtherscanBlockExplorer = void 0;
40
- var EtherscanBlockExplorer = /** @class */ (function () {
41
- function EtherscanBlockExplorer(url) {
4
+ class EtherscanBlockExplorer {
5
+ constructor(url) {
42
6
  this.url = url;
43
7
  this.metadata = {
44
8
  name: 'Etherscan',
45
9
  url: this.url
46
10
  };
47
11
  }
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
- }());
12
+ async getMetadata() {
13
+ return this.metadata;
14
+ }
15
+ async createAddressUrl(address) {
16
+ return `${this.url}/address/${address}`;
17
+ }
18
+ async createTransactionUrl(transactionId) {
19
+ return `${this.url}/tx/${transactionId}`;
20
+ }
21
+ }
71
22
  exports.EtherscanBlockExplorer = EtherscanBlockExplorer;
72
23
  //# sourceMappingURL=EtherscanBlockExplorer.js.map
@@ -1 +1 @@
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"}
1
+ {"version":3,"file":"EtherscanBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/EtherscanBlockExplorer.ts"],"names":[],"mappings":";;;AAEA,MAAa,sBAAsB;IAMjC,YAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAL9B,aAAQ,GAA0B;YACjD,IAAI,EAAE,WAAW;YACjB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IAEiD,CAAC;IAE5C,KAAK,CAAC,WAAW;QACtB,OAAO,IAAI,CAAC,QAAQ,CAAA;IACtB,CAAC;IAEM,KAAK,CAAC,gBAAgB,CAAC,OAAe;QAC3C,OAAO,GAAG,IAAI,CAAC,GAAG,YAAY,OAAO,EAAE,CAAA;IACzC,CAAC;IAEM,KAAK,CAAC,oBAAoB,CAAC,aAAqB;QACrD,OAAO,GAAG,IAAI,CAAC,GAAG,OAAO,aAAa,EAAE,CAAA;IAC1C,CAAC;CACF;AAnBD,wDAmBC"}