@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.
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 +1 -0
  5. package/v0/protocol/BaseEthereumProtocol.js +872 -460
  6. package/v0/protocol/BaseEthereumProtocol.js.map +1 -1
  7. package/v0/protocol/EthereumAddress.d.ts +1 -0
  8. package/v0/protocol/EthereumAddress.js +17 -26
  9. package/v0/protocol/EthereumAddress.js.map +1 -1
  10. package/v0/protocol/EthereumClassicProtocol.js +23 -6
  11. package/v0/protocol/EthereumClassicProtocol.js.map +1 -1
  12. package/v0/protocol/EthereumCryptoClient.js +125 -66
  13. package/v0/protocol/EthereumCryptoClient.js.map +1 -1
  14. package/v0/protocol/EthereumProtocol.js +28 -9
  15. package/v0/protocol/EthereumProtocol.js.map +1 -1
  16. package/v0/protocol/EthereumProtocolOptions.d.ts +1 -1
  17. package/v0/protocol/EthereumProtocolOptions.js +117 -36
  18. package/v0/protocol/EthereumProtocolOptions.js.map +1 -1
  19. package/v0/protocol/EthereumRopstenProtocol.js +23 -6
  20. package/v0/protocol/EthereumRopstenProtocol.js.map +1 -1
  21. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +186 -86
  22. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -1
  23. package/v0/protocol/clients/info-clients/InfoClient.js +4 -3
  24. package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -1
  25. package/v0/protocol/clients/node-clients/AirGapNodeClient.js +298 -126
  26. package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -1
  27. package/v0/protocol/clients/node-clients/NodeClient.js +4 -3
  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 +300 -161
  32. package/v0/protocol/erc20/GenericERC20.js.map +1 -1
  33. package/v0/protocol/utils/utils.js +55 -52
  34. package/v0/protocol/utils/utils.js.map +1 -1
  35. package/v0/serializer/validators/transaction-validator.js +31 -23
  36. package/v0/serializer/validators/transaction-validator.js.map +1 -1
  37. package/v0/serializer/validators/validators.js +73 -25
  38. package/v0/serializer/validators/validators.js.map +1 -1
  39. package/v1/block-explorer/EtherscanBlockExplorer.js +61 -12
  40. package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -1
  41. package/v1/clients/crypto/EthereumCryptoClient.js +124 -69
  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 +4 -3
  45. package/v1/clients/info/EthereumInfoClient.js.map +1 -1
  46. package/v1/clients/info/EtherscanInfoClient.js +162 -84
  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 +375 -164
  50. package/v1/clients/node/HttpEthereumNodeClient.js.map +1 -1
  51. package/v1/data/EthereumAddress.js +20 -29
  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 +112 -43
  56. package/v1/module/EthereumModule.js.map +1 -1
  57. package/v1/module.js +3 -2
  58. package/v1/module.js.map +1 -1
  59. package/v1/protocol/EthereumBaseProtocol.js +788 -467
  60. package/v1/protocol/EthereumBaseProtocol.js.map +1 -1
  61. package/v1/protocol/EthereumProtocol.js +46 -15
  62. package/v1/protocol/EthereumProtocol.js.map +1 -1
  63. package/v1/protocol/erc20/ERC20Protocol.js +360 -213
  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 +113 -35
  67. package/v1/protocol/erc20/ERC20Token.js.map +1 -1
  68. package/v1/serializer/v3/schemas/converter/transaction-converter.js +42 -25
  69. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -1
  70. package/v1/serializer/v3/serializer-companion.js +148 -71
  71. package/v1/serializer/v3/serializer-companion.js.map +1 -1
  72. package/v1/serializer/v3/validators/transaction-validator.js +17 -14
  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 +60 -57
  78. package/v1/utils/EthereumUtils.js.map +1 -1
  79. package/v1/utils/key.js +19 -28
  80. package/v1/utils/key.js.map +1 -1
  81. package/v1/utils/protocol.js +21 -33
  82. 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
- 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");
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
- 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');
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
- class EthereumUtils {
14
- static toHex(value) {
13
+ var EthereumUtils = /** @class */ (function () {
14
+ function EthereumUtils() {
15
+ }
16
+ EthereumUtils.toHex = function (value) {
15
17
  if (EthereumUtils.isAddress(value)) {
16
- return `0x${value.toLowerCase().replace(/^0x/i, '')}`;
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
- static { this.SHA3_NULL_S = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470'; }
39
- static sha3(value) {
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
- const hash = createKeccakHash('keccak256').update(valueInBytes).digest('hex');
45
- const returnValue = `0x${hash}`;
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
- static numberToHex(value) {
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, `Given input "${JSON.stringify(value)}" is not a number.`);
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
- 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;
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, `Given value "${JSON.stringify(hex)}" is not a valid hex string.`);
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
- const bytes = [];
72
- for (let c = 0; c < hex.length; c += 2) {
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
- static isHexStrict(hex) {
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
- static checkAddressChecksum(value) {
81
- const address = value.replace(/^0x/i, '');
82
- let addressHash = EthereumUtils.sha3(address.toLowerCase());
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 (let i = 0; i < 40; i++) {
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
- static isAddress(value) {
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
- static isBigNumber(value) {
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
- static utf8ToHex(value) {
117
- let str = utf8.encode(value);
118
- let hex = '';
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 (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;
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,kGAA8F;AAC9F,wDAA+D;AAC/D,6EAAkE;AAClE,gCAAgC;AAChC,4EAA4E;AAC5E,2CAA2C;AAC3C,MAAM,IAAI,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAA;AAC7E,MAAM,gBAAgB,GAAG,OAAO,CAAC,uDAAuD,CAAC,CAAA;AAEzF,qHAAqH;AACrH,MAAa,aAAa;IACjB,MAAM,CAAC,KAAK,CAAC,KAAU;QAC5B,IAAI,aAAa,CAAC,SAAS,CAAC,KAAK,CAAC,EAAE,CAAC;YACnC,OAAO,KAAK,KAAK,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,EAAE,CAAA;QACvD,CAAC;QAED,IAAI,OAAO,KAAK,KAAK,SAAS,EAAE,CAAC;YAC/B,OAAO,KAAK,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAA;QAChC,CAAC;QAED,IAAI,aAAa,CAAC,QAAQ,CAAC,KAAK,CAAC,IAAI,CAAC,aAAa,CAAC,WAAW,CAAC,KAAK,CAAC,CAAC,kCAAkC,EAAE,CAAC;YAC1G,OAAO,aAAa,CAAC,SAAS,CAAC,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAA;QACvD,CAAC;QAED,wDAAwD;QACxD,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;YAC9B,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,IAAI,KAAK,CAAC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AA;YACtC,IAAM,CAAC,GAAW,IAAI,CAAC,QAAQ,CAAC,EAAE,CAAC,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
- 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 = {
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}$', // Should be new EthereumProtocol().addressValidationPattern, but then there is a runtime issue because of circular dependencies
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
- const signedTransactionConstraints = {
48
+ var signedTransactionConstraints = {
49
49
  transaction: {
50
50
  presence: { allowEmpty: false },
51
51
  type: 'String',
52
52
  isValidEthereumTransactionString: true
53
53
  }
54
54
  };
55
- const success = () => undefined;
56
- const error = (errors) => errors;
57
- class EthereumTransactionValidator {
58
- constructor(version = 'v3') {
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
- const rawTx = unsignedTx.transaction;
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
- class EthereumTransactionValidatorFactory {
77
- create() {
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
- class EthereumTransactionValidatorFactoryV2 {
83
- create() {
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,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,EAAE;QACL,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EA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;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
+ {"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,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,qBAAqB,EAAE,IAAI;KAC5B;IACD,OAAO,EAAE;QACP,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,YAAY,EAAE,E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,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
- 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) => {
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(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
- });
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":";;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
+ {"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
- class EtherscanBlockExplorer {
5
- constructor(url) {
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
- 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
- }
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":";;;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"}
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"}