@wallfree-dev/ethereum 0.13.42

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 (167) hide show
  1. package/LICENSE.md +7 -0
  2. package/index.d.ts +1 -0
  3. package/index.js +18 -0
  4. package/index.js.map +1 -0
  5. package/package.json +67 -0
  6. package/readme.md +121 -0
  7. package/v0/index.d.ts +12 -0
  8. package/v0/index.js +39 -0
  9. package/v0/index.js.map +1 -0
  10. package/v0/protocol/BaseEthereumProtocol.d.ts +99 -0
  11. package/v0/protocol/BaseEthereumProtocol.js +946 -0
  12. package/v0/protocol/BaseEthereumProtocol.js.map +1 -0
  13. package/v0/protocol/EthereumAddress.d.ts +8 -0
  14. package/v0/protocol/EthereumAddress.js +43 -0
  15. package/v0/protocol/EthereumAddress.js.map +1 -0
  16. package/v0/protocol/EthereumChainIDs.d.ts +1 -0
  17. package/v0/protocol/EthereumChainIDs.js +340 -0
  18. package/v0/protocol/EthereumChainIDs.js.map +1 -0
  19. package/v0/protocol/EthereumClassicProtocol.d.ts +6 -0
  20. package/v0/protocol/EthereumClassicProtocol.js +30 -0
  21. package/v0/protocol/EthereumClassicProtocol.js.map +1 -0
  22. package/v0/protocol/EthereumCryptoClient.d.ts +12 -0
  23. package/v0/protocol/EthereumCryptoClient.js +148 -0
  24. package/v0/protocol/EthereumCryptoClient.js.map +1 -0
  25. package/v0/protocol/EthereumProtocol.d.ts +10 -0
  26. package/v0/protocol/EthereumProtocol.js +34 -0
  27. package/v0/protocol/EthereumProtocol.js.map +1 -0
  28. package/v0/protocol/EthereumProtocolOptions.d.ts +46 -0
  29. package/v0/protocol/EthereumProtocolOptions.js +150 -0
  30. package/v0/protocol/EthereumProtocolOptions.js.map +1 -0
  31. package/v0/protocol/EthereumRopstenProtocol.d.ts +6 -0
  32. package/v0/protocol/EthereumRopstenProtocol.js +30 -0
  33. package/v0/protocol/EthereumRopstenProtocol.js.map +1 -0
  34. package/v0/protocol/EthereumTypes.d.ts +14 -0
  35. package/v0/protocol/EthereumTypes.js +3 -0
  36. package/v0/protocol/EthereumTypes.js.map +1 -0
  37. package/v0/protocol/clients/info-clients/EtherscanInfoClient.d.ts +8 -0
  38. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js +195 -0
  39. package/v0/protocol/clients/info-clients/EtherscanInfoClient.js.map +1 -0
  40. package/v0/protocol/clients/info-clients/InfoClient.d.ts +8 -0
  41. package/v0/protocol/clients/info-clients/InfoClient.js +11 -0
  42. package/v0/protocol/clients/info-clients/InfoClient.js.map +1 -0
  43. package/v0/protocol/clients/node-clients/AirGapNodeClient.d.ts +41 -0
  44. package/v0/protocol/clients/node-clients/AirGapNodeClient.js +353 -0
  45. package/v0/protocol/clients/node-clients/AirGapNodeClient.js.map +1 -0
  46. package/v0/protocol/clients/node-clients/NodeClient.d.ts +17 -0
  47. package/v0/protocol/clients/node-clients/NodeClient.js +11 -0
  48. package/v0/protocol/clients/node-clients/NodeClient.js.map +1 -0
  49. package/v0/protocol/erc20/ERC20.d.ts +3 -0
  50. package/v0/protocol/erc20/ERC20.js +9 -0
  51. package/v0/protocol/erc20/ERC20.js.map +1 -0
  52. package/v0/protocol/erc20/GenericERC20.d.ts +32 -0
  53. package/v0/protocol/erc20/GenericERC20.js +335 -0
  54. package/v0/protocol/erc20/GenericERC20.js.map +1 -0
  55. package/v0/protocol/utils/utils.d.ts +13 -0
  56. package/v0/protocol/utils/utils.js +140 -0
  57. package/v0/protocol/utils/utils.js.map +1 -0
  58. package/v0/serializer/schemas/v2/transaction-sign-request-ethereum.json +50 -0
  59. package/v0/serializer/schemas/v2/transaction-sign-response-ethereum.json +19 -0
  60. package/v0/serializer/schemas/v3/transaction-sign-request-ethereum-typed.json +38 -0
  61. package/v0/serializer/schemas/v3/transaction-sign-request-ethereum.json +50 -0
  62. package/v0/serializer/schemas/v3/transaction-sign-response-ethereum.json +19 -0
  63. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  64. package/v0/serializer/validators/transaction-validator.js +96 -0
  65. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  66. package/v0/serializer/validators/validators.d.ts +1 -0
  67. package/v0/serializer/validators/validators.js +78 -0
  68. package/v0/serializer/validators/validators.js.map +1 -0
  69. package/v0/types/signed-transaction-ethereum.d.ts +5 -0
  70. package/v0/types/signed-transaction-ethereum.js +3 -0
  71. package/v0/types/signed-transaction-ethereum.js.map +1 -0
  72. package/v0/types/transaction-ethereum.d.ts +14 -0
  73. package/v0/types/transaction-ethereum.js +3 -0
  74. package/v0/types/transaction-ethereum.js.map +1 -0
  75. package/v0/types/unsigned-transaction-ethereum-typed.d.ts +11 -0
  76. package/v0/types/unsigned-transaction-ethereum-typed.js +3 -0
  77. package/v0/types/unsigned-transaction-ethereum-typed.js.map +1 -0
  78. package/v0/types/unsigned-transaction-ethereum.d.ts +15 -0
  79. package/v0/types/unsigned-transaction-ethereum.js +3 -0
  80. package/v0/types/unsigned-transaction-ethereum.js.map +1 -0
  81. package/v1/block-explorer/EtherscanBlockExplorer.d.ts +9 -0
  82. package/v1/block-explorer/EtherscanBlockExplorer.js +72 -0
  83. package/v1/block-explorer/EtherscanBlockExplorer.js.map +1 -0
  84. package/v1/clients/crypto/EthereumCryptoClient.d.ts +7 -0
  85. package/v1/clients/crypto/EthereumCryptoClient.js +147 -0
  86. package/v1/clients/crypto/EthereumCryptoClient.js.map +1 -0
  87. package/v1/clients/info/EthereumInfoClient.d.ts +15 -0
  88. package/v1/clients/info/EthereumInfoClient.js +11 -0
  89. package/v1/clients/info/EthereumInfoClient.js.map +1 -0
  90. package/v1/clients/info/EtherscanInfoClient.d.ts +8 -0
  91. package/v1/clients/info/EtherscanInfoClient.js +173 -0
  92. package/v1/clients/info/EtherscanInfoClient.js.map +1 -0
  93. package/v1/clients/node/EthereumNodeClient.d.ts +18 -0
  94. package/v1/clients/node/EthereumNodeClient.js +3 -0
  95. package/v1/clients/node/EthereumNodeClient.js.map +1 -0
  96. package/v1/clients/node/HttpEthereumNodeClient.d.ts +66 -0
  97. package/v1/clients/node/HttpEthereumNodeClient.js +451 -0
  98. package/v1/clients/node/HttpEthereumNodeClient.js.map +1 -0
  99. package/v1/data/EthereumAddress.d.ts +7 -0
  100. package/v1/data/EthereumAddress.js +46 -0
  101. package/v1/data/EthereumAddress.js.map +1 -0
  102. package/v1/index.d.ts +30 -0
  103. package/v1/index.js +43 -0
  104. package/v1/index.js.map +1 -0
  105. package/v1/module/ERC20Tokens.d.ts +3 -0
  106. package/v1/module/ERC20Tokens.js +847 -0
  107. package/v1/module/ERC20Tokens.js.map +1 -0
  108. package/v1/module/EthereumModule.d.ts +16 -0
  109. package/v1/module/EthereumModule.js +127 -0
  110. package/v1/module/EthereumModule.js.map +1 -0
  111. package/v1/module.d.ts +3 -0
  112. package/v1/module.js +24 -0
  113. package/v1/module.js.map +1 -0
  114. package/v1/protocol/EthereumBaseProtocol.d.ts +87 -0
  115. package/v1/protocol/EthereumBaseProtocol.js +892 -0
  116. package/v1/protocol/EthereumBaseProtocol.js.map +1 -0
  117. package/v1/protocol/EthereumChainIds.d.ts +1 -0
  118. package/v1/protocol/EthereumChainIds.js +340 -0
  119. package/v1/protocol/EthereumChainIds.js.map +1 -0
  120. package/v1/protocol/EthereumProtocol.d.ts +8 -0
  121. package/v1/protocol/EthereumProtocol.js +65 -0
  122. package/v1/protocol/EthereumProtocol.js.map +1 -0
  123. package/v1/protocol/erc20/ERC20Protocol.d.ts +32 -0
  124. package/v1/protocol/erc20/ERC20Protocol.js +397 -0
  125. package/v1/protocol/erc20/ERC20Protocol.js.map +1 -0
  126. package/v1/protocol/erc20/ERC20Token.d.ts +19 -0
  127. package/v1/protocol/erc20/ERC20Token.js +131 -0
  128. package/v1/protocol/erc20/ERC20Token.js.map +1 -0
  129. package/v1/serializer/v3/schemas/converter/transaction-converter.d.ts +8 -0
  130. package/v1/serializer/v3/schemas/converter/transaction-converter.js +82 -0
  131. package/v1/serializer/v3/schemas/converter/transaction-converter.js.map +1 -0
  132. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.d.ts +10 -0
  133. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js +3 -0
  134. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.js.map +1 -0
  135. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.d.ts +14 -0
  136. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js +3 -0
  137. package/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.js.map +1 -0
  138. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.d.ts +3 -0
  139. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js +3 -0
  140. package/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.js.map +1 -0
  141. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +41 -0
  142. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +58 -0
  143. package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +19 -0
  144. package/v1/serializer/v3/serializer-companion.d.ts +13 -0
  145. package/v1/serializer/v3/serializer-companion.js +182 -0
  146. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  147. package/v1/serializer/v3/validators/transaction-validator.d.ts +7 -0
  148. package/v1/serializer/v3/validators/transaction-validator.js +71 -0
  149. package/v1/serializer/v3/validators/transaction-validator.js.map +1 -0
  150. package/v1/types/crypto.d.ts +2 -0
  151. package/v1/types/crypto.js +3 -0
  152. package/v1/types/crypto.js.map +1 -0
  153. package/v1/types/protocol.d.ts +35 -0
  154. package/v1/types/protocol.js +3 -0
  155. package/v1/types/protocol.js.map +1 -0
  156. package/v1/types/transaction.d.ts +24 -0
  157. package/v1/types/transaction.js +3 -0
  158. package/v1/types/transaction.js.map +1 -0
  159. package/v1/utils/EthereumUtils.d.ts +16 -0
  160. package/v1/utils/EthereumUtils.js +155 -0
  161. package/v1/utils/EthereumUtils.js.map +1 -0
  162. package/v1/utils/key.d.ts +5 -0
  163. package/v1/utils/key.js +101 -0
  164. package/v1/utils/key.js.map +1 -0
  165. package/v1/utils/protocol.d.ts +13 -0
  166. package/v1/utils/protocol.js +38 -0
  167. package/v1/utils/protocol.js.map +1 -0
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transaction.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction.js","sourceRoot":"","sources":["../../../src/v1/types/transaction.ts"],"names":[],"mappings":""}
@@ -0,0 +1,16 @@
1
+ import { BigNumber } from '@wallfree-dev/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber';
2
+ export declare class EthereumUtils {
3
+ static toHex(value: any): string;
4
+ private static readonly SHA3_NULL_S;
5
+ static sha3(value: any): string | null;
6
+ static hexToNumber(value: string): BigNumber;
7
+ private static numberToHex;
8
+ private static hexToBytes;
9
+ private static isHexStrict;
10
+ private static checkAddressChecksum;
11
+ private static isAddress;
12
+ private static isBigNumber;
13
+ static hexToUtf8(value: string): string;
14
+ private static utf8ToHex;
15
+ private static isObject;
16
+ }
@@ -0,0 +1,155 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EthereumUtils = void 0;
4
+ var bignumber_1 = require("@wallfree-dev/coinlib-core/dependencies/src/bignumber.js-9.0.0/bignumber");
5
+ var errors_1 = require("@wallfree-dev/coinlib-core/errors");
6
+ var coinlib_error_1 = require("@wallfree-dev/coinlib-core/errors/coinlib-error");
7
+ // var _ = require('underscore')
8
+ // var BN = require('@wallfree-dev/coinlib-core/dependencies/src/bn.js-4.11.8/bn')
9
+ // var numberToBN = require('number-to-bn')
10
+ var utf8 = require('@wallfree-dev/coinlib-core/dependencies/src/utf8-3.0.0/utf8');
11
+ var createKeccakHash = require('@wallfree-dev/coinlib-core/dependencies/src/keccak-1.0.2/js');
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) {
17
+ if (EthereumUtils.isAddress(value)) {
18
+ return "0x".concat(value.toLowerCase().replace(/^0x/i, ''));
19
+ }
20
+ if (typeof value === 'boolean') {
21
+ return value ? '0x01' : '0x00';
22
+ }
23
+ if (EthereumUtils.isObject(value) && !EthereumUtils.isBigNumber(value) /* && !EthereumUtils.isBN(value)*/) {
24
+ return EthereumUtils.utf8ToHex(JSON.stringify(value));
25
+ }
26
+ // if its a negative number, pass it through numberToHex
27
+ if (typeof value === 'string') {
28
+ if (value.indexOf('-0x') === 0 || value.indexOf('-0X') === 0) {
29
+ return EthereumUtils.numberToHex(value);
30
+ }
31
+ else if (value.indexOf('0x') === 0 || value.indexOf('0X') === 0) {
32
+ return value;
33
+ }
34
+ else if (!isFinite(Number(value))) {
35
+ return EthereumUtils.utf8ToHex(value);
36
+ }
37
+ }
38
+ return EthereumUtils.numberToHex(value);
39
+ };
40
+ EthereumUtils.sha3 = function (value) {
41
+ var valueInBytes = value;
42
+ if (EthereumUtils.isHexStrict(value) && /^0x/i.test(value.toString())) {
43
+ valueInBytes = EthereumUtils.hexToBytes(value);
44
+ }
45
+ var hash = createKeccakHash('keccak256').update(valueInBytes).digest('hex');
46
+ var returnValue = "0x".concat(hash);
47
+ if (returnValue === EthereumUtils.SHA3_NULL_S) {
48
+ return null;
49
+ }
50
+ else {
51
+ return returnValue;
52
+ }
53
+ };
54
+ EthereumUtils.hexToNumber = function (value) {
55
+ if (value.startsWith('0x')) {
56
+ value = value.slice(2);
57
+ }
58
+ if (value.startsWith('-0x')) {
59
+ value = "-".concat(value.slice(3));
60
+ }
61
+ return new bignumber_1.BigNumber(value, 16);
62
+ };
63
+ EthereumUtils.numberToHex = function (value) {
64
+ if (value === null || value === undefined) {
65
+ return value;
66
+ }
67
+ if (!isFinite(Number(value)) && !EthereumUtils.isHexStrict(value)) {
68
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given input \"".concat(JSON.stringify(value), "\" is not a number."));
69
+ }
70
+ // var number = EthereumUtils.toBN(value)
71
+ var myNumber = new bignumber_1.BigNumber(value);
72
+ var result = myNumber.toString(16);
73
+ return myNumber.lt(new bignumber_1.BigNumber(0)) ? "-0x".concat(result.substr(1)) : "0x".concat(result);
74
+ };
75
+ EthereumUtils.hexToBytes = function (value) {
76
+ var hex = typeof value === 'number' ? value.toString(16) : value;
77
+ if (!EthereumUtils.isHexStrict(hex)) {
78
+ throw new errors_1.InvalidValueError(coinlib_error_1.Domain.UTILS, "Given value \"".concat(JSON.stringify(hex), "\" is not a valid hex string."));
79
+ }
80
+ hex = hex.replace(/^0x/i, '');
81
+ var bytes = [];
82
+ for (var c = 0; c < hex.length; c += 2) {
83
+ bytes.push(parseInt(hex.substr(c, 2), 16));
84
+ }
85
+ return bytes;
86
+ };
87
+ EthereumUtils.isHexStrict = function (hex) {
88
+ return (typeof hex === 'string' || typeof hex === 'number') && /^(-)?0x[0-9a-f]*$/i.test(hex.toString());
89
+ };
90
+ EthereumUtils.checkAddressChecksum = function (value) {
91
+ var address = value.replace(/^0x/i, '');
92
+ var addressHash = EthereumUtils.sha3(address.toLowerCase());
93
+ if (addressHash === null) {
94
+ return false;
95
+ }
96
+ addressHash = addressHash.replace(/^0x/i, '');
97
+ for (var i = 0; i < 40; i++) {
98
+ if ((parseInt(addressHash[i], 16) > 7 && address[i].toUpperCase() !== address[i]) ||
99
+ (parseInt(addressHash[i], 16) <= 7 && address[i].toLowerCase() !== address[i])) {
100
+ return false;
101
+ }
102
+ }
103
+ return true;
104
+ };
105
+ EthereumUtils.isAddress = function (value) {
106
+ if (!/^(0x)?[0-9a-f]{40}$/i.test(value)) {
107
+ return false;
108
+ // If it's ALL lowercase or ALL upppercase
109
+ }
110
+ else if (/^(0x|0X)?[0-9a-f]{40}$/.test(value) || /^(0x|0X)?[0-9A-F]{40}$/.test(value)) {
111
+ return true;
112
+ // Otherwise check each case
113
+ }
114
+ else {
115
+ return EthereumUtils.checkAddressChecksum(value);
116
+ }
117
+ };
118
+ EthereumUtils.isBigNumber = function (value) {
119
+ if (!value) {
120
+ return false;
121
+ }
122
+ else {
123
+ return bignumber_1.BigNumber.isBigNumber(value);
124
+ }
125
+ };
126
+ EthereumUtils.hexToUtf8 = function (value) {
127
+ if (value.startsWith('0x')) {
128
+ value = value.slice(2);
129
+ }
130
+ return Buffer.from(value, 'hex').toString('utf-8');
131
+ };
132
+ EthereumUtils.utf8ToHex = function (value) {
133
+ var str = utf8.encode(value);
134
+ var hex = '';
135
+ // remove \u0000 padding from either side
136
+ str = str.replace(/^(?:\u0000)*/, '');
137
+ str = str.split('').reverse().join('');
138
+ str = str.replace(/^(?:\u0000)*/, '');
139
+ str = str.split('').reverse().join('');
140
+ for (var i = 0; i < str.length; i++) {
141
+ var code = str.charCodeAt(i);
142
+ var n = code.toString(16);
143
+ hex += n.length < 2 ? "0".concat(n) : n;
144
+ }
145
+ return "0x".concat(hex);
146
+ };
147
+ EthereumUtils.isObject = function (value) {
148
+ var type = typeof value;
149
+ return type === 'function' || (type === 'object' && !!value);
150
+ };
151
+ EthereumUtils.SHA3_NULL_S = '0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470';
152
+ return EthereumUtils;
153
+ }());
154
+ exports.EthereumUtils = EthereumUtils;
155
+ //# sourceMappingURL=EthereumUtils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"EthereumUtils.js","sourceRoot":"","sources":["../../../src/v1/utils/EthereumUtils.ts"],"names":[],"mappings":";;;AAAA,sGAAoG;AACpG,4DAAqE;AACrE,iFAAwE;AACxE,gCAAgC;AAChC,kFAAkF;AAClF,2CAA2C;AAC3C,IAAM,IAAI,GAAG,OAAO,CAAC,6DAA6D,CAAC,CAAA;AACnF,IAAM,gBAAgB,GAAG,OAAO,CAAC,6DAA6D,CAAC,CAAA;AAE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,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;IA5IuB,yBAAW,GAAW,oEAAoE,CAAA;IA6IpH,oBAAC;CAAA,AAzKD,IAyKC;AAzKY,sCAAa"}
@@ -0,0 +1,5 @@
1
+ import { ExtendedPublicKey, ExtendedSecretKey, PublicKey, SecretKey } from '@wallfree-dev/module-kit';
2
+ export declare function convertSecretKey(secretKey: SecretKey, targetFormat: SecretKey['format']): SecretKey;
3
+ export declare function convertExtendedSecretKey(extendedSecretKey: ExtendedSecretKey, targetFormat: ExtendedSecretKey['format']): ExtendedSecretKey;
4
+ export declare function convertPublicKey(publicKey: PublicKey, targetFormat: PublicKey['format']): PublicKey;
5
+ export declare function convertExtendedPublicKey(extendedPublicKey: ExtendedPublicKey, targetFormat: ExtendedPublicKey['format']): ExtendedPublicKey;
@@ -0,0 +1,101 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
+ Object.defineProperty(o, "default", { enumerable: true, value: v });
15
+ }) : function(o, v) {
16
+ o["default"] = v;
17
+ });
18
+ var __importStar = (this && this.__importStar) || function (mod) {
19
+ if (mod && mod.__esModule) return mod;
20
+ var result = {};
21
+ if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22
+ __setModuleDefault(result, mod);
23
+ return result;
24
+ };
25
+ Object.defineProperty(exports, "__esModule", { value: true });
26
+ exports.convertExtendedPublicKey = exports.convertPublicKey = exports.convertExtendedSecretKey = exports.convertSecretKey = void 0;
27
+ var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
28
+ // @ts-ignore
29
+ var bs58check = __importStar(require("@wallfree-dev/coinlib-core/dependencies/src/bs58check-2.1.2"));
30
+ var errors_1 = require("@wallfree-dev/coinlib-core/errors");
31
+ var module_kit_1 = require("@wallfree-dev/module-kit");
32
+ var EXT_SK_PREFIX = '0488b21e'; // xpriv
33
+ var EXT_PK_PREFIX = '0488b21e'; // xpub
34
+ function convertSecretKey(secretKey, targetFormat) {
35
+ if (secretKey.format === targetFormat) {
36
+ return secretKey;
37
+ }
38
+ // 'encoded' -> 'hex'
39
+ // 'hex' -> 'encoded'
40
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, 'Unsupported secret key format.');
41
+ }
42
+ exports.convertSecretKey = convertSecretKey;
43
+ function convertExtendedSecretKey(extendedSecretKey, targetFormat) {
44
+ if (extendedSecretKey.format === targetFormat) {
45
+ return extendedSecretKey;
46
+ }
47
+ switch (extendedSecretKey.format) {
48
+ case 'encoded':
49
+ if (targetFormat === 'encoded') {
50
+ return extendedSecretKey;
51
+ }
52
+ return (0, module_kit_1.newExtendedSecretKey)(decodeEncodedKey(EXT_SK_PREFIX, extendedSecretKey.value));
53
+ case 'hex':
54
+ if (targetFormat === 'hex') {
55
+ return extendedSecretKey;
56
+ }
57
+ return (0, module_kit_1.newExtendedSecretKey)(encodeHexKey(EXT_SK_PREFIX, extendedSecretKey.value));
58
+ default:
59
+ (0, coinlib_core_1.assertNever)(extendedSecretKey.format);
60
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, 'Unuspported extended secret key format.');
61
+ }
62
+ }
63
+ exports.convertExtendedSecretKey = convertExtendedSecretKey;
64
+ function convertPublicKey(publicKey, targetFormat) {
65
+ if (publicKey.format === targetFormat) {
66
+ return publicKey;
67
+ }
68
+ // 'encoded' -> 'hex'
69
+ // 'hex' -> 'encoded'
70
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, 'Unsupported public key format.');
71
+ }
72
+ exports.convertPublicKey = convertPublicKey;
73
+ function convertExtendedPublicKey(extendedPublicKey, targetFormat) {
74
+ if (extendedPublicKey.format === targetFormat) {
75
+ return extendedPublicKey;
76
+ }
77
+ switch (extendedPublicKey.format) {
78
+ case 'encoded':
79
+ if (targetFormat === 'encoded') {
80
+ return extendedPublicKey;
81
+ }
82
+ return (0, module_kit_1.newExtendedPublicKey)(decodeEncodedKey(EXT_PK_PREFIX, extendedPublicKey.value));
83
+ case 'hex':
84
+ if (targetFormat === 'hex') {
85
+ return extendedPublicKey;
86
+ }
87
+ return (0, module_kit_1.newExtendedPublicKey)(encodeHexKey(EXT_PK_PREFIX, extendedPublicKey.value));
88
+ default:
89
+ (0, coinlib_core_1.assertNever)(extendedPublicKey.format);
90
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, 'Unuspported extended public key format.');
91
+ }
92
+ }
93
+ exports.convertExtendedPublicKey = convertExtendedPublicKey;
94
+ function decodeEncodedKey(prefix, key) {
95
+ var prefixBytes = Buffer.from(prefix, 'hex').length;
96
+ return bs58check.decode(key).slice(prefixBytes).toString('hex');
97
+ }
98
+ function encodeHexKey(prefix, key) {
99
+ return bs58check.encode(Buffer.concat([Buffer.from(prefix, 'hex'), Buffer.from(key, 'hex')]));
100
+ }
101
+ //# sourceMappingURL=key.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"key.js","sourceRoot":"","sources":["../../../src/v1/utils/key.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;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,MAAM,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,KAAK,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,CAAA;AAC/F,CAAC"}
@@ -0,0 +1,13 @@
1
+ import { AirGapAnyProtocol, Schema } from '@wallfree-dev/module-kit';
2
+ import { ERC20Protocol } from '../protocol/erc20/ERC20Protocol';
3
+ import { ERC20Token } from '../protocol/erc20/ERC20Token';
4
+ import { EthereumBaseProtocol } from '../protocol/EthereumBaseProtocol';
5
+ import { EthereumProtocol } from '../protocol/EthereumProtocol';
6
+ export declare const ethereumBaseProtocolSchema: Schema<EthereumBaseProtocol>;
7
+ export declare const ethereumProtocolSchema: Schema<EthereumProtocol>;
8
+ export declare const ethereumERC20ProtocolSchema: Schema<ERC20Protocol<string>>;
9
+ export declare const ethereumERC20TokenSchema: Schema<ERC20Token>;
10
+ export declare function isAnyEthereumProtocol(protocol: AirGapAnyProtocol): protocol is EthereumBaseProtocol;
11
+ export declare function isEthereumProtocol(protocol: AirGapAnyProtocol): protocol is EthereumProtocol;
12
+ export declare function isEthereumERC20Protocol(protocol: AirGapAnyProtocol): protocol is ERC20Protocol<string>;
13
+ export declare function isEthereumERC20Token(protocol: AirGapAnyProtocol): protocol is ERC20Token;
@@ -0,0 +1,38 @@
1
+ "use strict";
2
+ var __assign = (this && this.__assign) || function () {
3
+ __assign = Object.assign || function(t) {
4
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
5
+ s = arguments[i];
6
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
7
+ t[p] = s[p];
8
+ }
9
+ return t;
10
+ };
11
+ return __assign.apply(this, arguments);
12
+ };
13
+ Object.defineProperty(exports, "__esModule", { value: true });
14
+ exports.isEthereumERC20Token = exports.isEthereumERC20Protocol = exports.isEthereumProtocol = exports.isAnyEthereumProtocol = exports.ethereumERC20TokenSchema = exports.ethereumERC20ProtocolSchema = exports.ethereumProtocolSchema = exports.ethereumBaseProtocolSchema = void 0;
15
+ var module_kit_1 = require("@wallfree-dev/module-kit");
16
+ // Schemas
17
+ exports.ethereumBaseProtocolSchema = __assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign(__assign({}, module_kit_1.offlineProtocolSchema), module_kit_1.onlineProtocolSchema), module_kit_1.bip32OfflineProtocolSchema), module_kit_1.bip32OnlineProtocolSchema), module_kit_1.aesEncryptionSchema), module_kit_1.asymmetricEncryptionOfflineSchema), module_kit_1.signMessageOfflineSchema), module_kit_1.fetchDataForAddressProtocolSchema), module_kit_1.fetchDataForMultipleAddressesProtocolSchema), module_kit_1.getTokenBalancesSchema), module_kit_1.transactionStatusCheckerSchema), module_kit_1.walletConnectProtocolSchema);
18
+ exports.ethereumProtocolSchema = __assign({}, exports.ethereumBaseProtocolSchema);
19
+ exports.ethereumERC20ProtocolSchema = __assign(__assign({}, exports.ethereumBaseProtocolSchema), { name: 'required', symbol: 'required', decimals: 'required' });
20
+ exports.ethereumERC20TokenSchema = __assign(__assign({}, exports.ethereumERC20ProtocolSchema), module_kit_1.singleTokenSubProtocolSchema);
21
+ // Implementation Checks
22
+ function isAnyEthereumProtocol(protocol) {
23
+ return (0, module_kit_1.implementsInterface)(protocol, exports.ethereumBaseProtocolSchema);
24
+ }
25
+ exports.isAnyEthereumProtocol = isAnyEthereumProtocol;
26
+ function isEthereumProtocol(protocol) {
27
+ return (0, module_kit_1.implementsInterface)(protocol, exports.ethereumProtocolSchema);
28
+ }
29
+ exports.isEthereumProtocol = isEthereumProtocol;
30
+ function isEthereumERC20Protocol(protocol) {
31
+ return (0, module_kit_1.implementsInterface)(protocol, exports.ethereumERC20ProtocolSchema);
32
+ }
33
+ exports.isEthereumERC20Protocol = isEthereumERC20Protocol;
34
+ function isEthereumERC20Token(protocol) {
35
+ return (0, module_kit_1.implementsInterface)(protocol, exports.ethereumERC20TokenSchema);
36
+ }
37
+ exports.isEthereumERC20Token = isEthereumERC20Token;
38
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/utils/protocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,uDAiBiC;AAOjC,UAAU;AAEG,QAAA,0BAA0B,mHAClC,kCAAqB,GACrB,iCAAoB,GACpB,uCAA0B,GAC1B,sCAAyB,GACzB,gCAAmB,GACnB,8CAAiC,GACjC,qCAAwB,GACxB,8CAAiC,GACjC,wDAA2C,GAC3C,mCAAsB,GACtB,2CAA8B,GAC9B,wCAA2B,EAC/B;AAEY,QAAA,sBAAsB,gBAC9B,kCAA0B,EAC9B;AAEY,QAAA,2BAA2B,yBACnC,kCAA0B,KAC7B,IAAI,EAAE,UAAU,EAChB,MAAM,EAAE,UAAU,EAClB,QAAQ,EAAE,UAAU,IACrB;AAEY,QAAA,wBAAwB,yBAChC,mCAA2B,GAC3B,yCAA4B,EAChC;AAED,wBAAwB;AAExB,SAAgB,qBAAqB,CAAC,QAA2B;IAC/D,OAAO,IAAA,gCAAmB,EAAuB,QAAQ,EAAE,kCAA0B,CAAC,CAAA;AACxF,CAAC;AAFD,sDAEC;AAED,SAAgB,kBAAkB,CAAC,QAA2B;IAC5D,OAAO,IAAA,gCAAmB,EAAmB,QAAQ,EAAE,8BAAsB,CAAC,CAAA;AAChF,CAAC;AAFD,gDAEC;AAED,SAAgB,uBAAuB,CAAC,QAA2B;IACjE,OAAO,IAAA,gCAAmB,EAAwB,QAAQ,EAAE,mCAA2B,CAAC,CAAA;AAC1F,CAAC;AAFD,0DAEC;AAED,SAAgB,oBAAoB,CAAC,QAA2B;IAC9D,OAAO,IAAA,gCAAmB,EAAa,QAAQ,EAAE,gCAAwB,CAAC,CAAA;AAC5E,CAAC;AAFD,oDAEC"}