@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,82 @@
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
+ var __rest = (this && this.__rest) || function (s, e) {
14
+ var t = {};
15
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
16
+ t[p] = s[p];
17
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
18
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
19
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
20
+ t[p[i]] = s[p[i]];
21
+ }
22
+ return t;
23
+ };
24
+ Object.defineProperty(exports, "__esModule", { value: true });
25
+ exports.ethereumTransactionSignResponseToSigned = exports.ethereumTransactionSignRequestToUnsigned = exports.ethereumSignedTransactionToResponse = exports.ethereumUnsignedTransactionToRequest = void 0;
26
+ var module_kit_1 = require("@wallfree-dev/module-kit");
27
+ function isEthereumTypedTransactionSignRequest(request) {
28
+ return (0, module_kit_1.implementsInterface)(request.transaction, {
29
+ derivationPath: 'required',
30
+ masterFingerprint: 'required',
31
+ serialized: 'required'
32
+ });
33
+ }
34
+ function ethereumUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
35
+ return unsigned.ethereumType === 'raw'
36
+ ? ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl)
37
+ : ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl);
38
+ }
39
+ exports.ethereumUnsignedTransactionToRequest = ethereumUnsignedTransactionToRequest;
40
+ function ethereumRawUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
41
+ var _ = unsigned.type, to = unsigned.to, rest = __rest(unsigned, ["type", "to"]);
42
+ var toHEX = Buffer.from(to, 'utf-8').toString('hex');
43
+ var transaction = __assign(__assign({}, rest), { to: toHEX });
44
+ return {
45
+ transaction: transaction,
46
+ publicKey: publicKey,
47
+ callbackURL: callbackUrl
48
+ };
49
+ }
50
+ function ethereumTypedUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
51
+ var _ = unsigned.type, rest = __rest(unsigned, ["type"]);
52
+ return {
53
+ transaction: rest,
54
+ publicKey: publicKey,
55
+ callbackURL: callbackUrl
56
+ };
57
+ }
58
+ function ethereumSignedTransactionToResponse(signed, accountIdentifier) {
59
+ return { transaction: signed.serialized, accountIdentifier: accountIdentifier };
60
+ }
61
+ exports.ethereumSignedTransactionToResponse = ethereumSignedTransactionToResponse;
62
+ function ethereumTransactionSignRequestToUnsigned(request) {
63
+ return isEthereumTypedTransactionSignRequest(request)
64
+ ? ethereumTransactionSignRequestToTypedUnsigned(request)
65
+ : ethereumTransactionSignRequestToRawUnsigned(request);
66
+ }
67
+ exports.ethereumTransactionSignRequestToUnsigned = ethereumTransactionSignRequestToUnsigned;
68
+ function ethereumTransactionSignRequestToRawUnsigned(request) {
69
+ var _a = request.transaction, to = _a.to, rest = __rest(_a, ["to"]);
70
+ var isStringAddress = /^0x[0-9a-fA-F]{40}$/.test(to);
71
+ var toUTF8 = Buffer.from(to, 'hex').toString('utf-8');
72
+ var transaction = __assign(__assign({}, rest), { to: isStringAddress ? to : toUTF8 });
73
+ return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'raw' }, transaction));
74
+ }
75
+ function ethereumTransactionSignRequestToTypedUnsigned(request) {
76
+ return (0, module_kit_1.newUnsignedTransaction)(__assign({ ethereumType: 'typed' }, request.transaction));
77
+ }
78
+ function ethereumTransactionSignResponseToSigned(response) {
79
+ return (0, module_kit_1.newSignedTransaction)({ serialized: response.transaction });
80
+ }
81
+ exports.ethereumTransactionSignResponseToSigned = ethereumTransactionSignResponseToSigned;
82
+ //# sourceMappingURL=transaction-converter.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uDAA4G;AAe5G,SAAS,qCAAqC,CAC5C,OAA6E;IAE7E,OAAO,IAAA,gCAAmB,EAA+C,OAAO,CAAC,WAAW,EAAE;QAC5F,cAAc,EAAE,UAAU;QAC1B,iBAAiB,EAAE,UAAU;QAC7B,UAAU,EAAE,UAAU;KACvB,CAAC,CAAA;AACJ,CAAC;AAED,SAAgB,oCAAoC,CAClD,QAAqC,EACrC,SAAiB,EACjB,WAAoB;IAEpB,OAAO,QAAQ,CAAC,YAAY,KAAK,KAAK;QACpC,CAAC,CAAC,uCAAuC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC;QAC3E,CAAC,CAAC,yCAAyC,CAAC,QAAQ,EAAE,SAAS,EAAE,WAAW,CAAC,CAAA;AACjF,CAAC;AARD,oFAQC;AAED,SAAS,uCAAuC,CAC9C,QAAwC,EACxC,SAAiB,EACjB,WAAoB;IAEZ,IAAM,CAAC,GAAkB,QAAQ,KAA1B,EAAE,EAAE,GAAc,QAAQ,GAAtB,EAAK,IAAI,UAAK,QAAQ,EAAnC,cAAwB,CAAF,CAAa;IAEzC,IAAM,KAAK,GAAG,MAAM,CAAC,IAAI,CAAC,EAAE,EAAE,OAAO,CAAC,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAA;IAEtD,IAAM,WAAW,yBACZ,IAAI,KACP,EAAE,EAAE,KAAK,GACV,CAAA;IAED,OAAO;QACL,WAAW,aAAA;QACX,SAAS,WAAA;QAC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OAAO,IAAK,OAAO,CAAC,WAAW,EAAG,CAAA;AACpH,CAAC;AAED,SAAgB,uCAAuC,CAAC,QAAyC;IAC/F,OAAO,IAAA,iCAAoB,EAA4B,EAAE,UAAU,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;AAC9F,CAAC;AAFD,0FAEC"}
@@ -0,0 +1,10 @@
1
+ import { TransactionSignRequest } from '@wallfree-dev/serializer';
2
+ import { HexString } from '@wallfree-dev/serializer/v3/schemas/definitions/hex-string';
3
+ import { EthereumTypedUnsignedTransaction } from '../../../../types/transaction';
4
+ export interface SerializableEthereumTypedUnsignedTransaction extends Omit<EthereumTypedUnsignedTransaction, 'type' | 'ethereumType'> {
5
+ serialized: HexString;
6
+ derivationPath: string;
7
+ masterFingerprint: string;
8
+ }
9
+ export interface EthereumTypedTransactionSignRequest extends TransactionSignRequest<SerializableEthereumTypedUnsignedTransaction> {
10
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transaction-sign-request-ethereum-typed.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-sign-request-ethereum-typed.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum-typed.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ import { TransactionSignRequest } from '@wallfree-dev/serializer';
2
+ import { HexString } from '@wallfree-dev/serializer/v3/schemas/definitions/hex-string';
3
+ import { EthereumRawUnsignedTransaction } from '../../../../types/transaction';
4
+ export interface SerializableEthereumRawUnsignedTransaction extends Omit<EthereumRawUnsignedTransaction, 'type' | 'ethereumType'> {
5
+ nonce: HexString;
6
+ gasPrice: HexString;
7
+ gasLimit: HexString;
8
+ to: HexString;
9
+ value: HexString;
10
+ chainId: number;
11
+ data: HexString;
12
+ }
13
+ export interface EthereumTransactionSignRequest extends TransactionSignRequest<SerializableEthereumRawUnsignedTransaction> {
14
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transaction-sign-request-ethereum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-sign-request-ethereum.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-request-ethereum.ts"],"names":[],"mappings":""}
@@ -0,0 +1,3 @@
1
+ import { TransactionSignResponse } from '@wallfree-dev/serializer';
2
+ export interface EthereumTransactionSignResponse extends TransactionSignResponse {
3
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=transaction-sign-response-ethereum.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-sign-response-ethereum.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/definitions/transaction-sign-response-ethereum.ts"],"names":[],"mappings":""}
@@ -0,0 +1,41 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "definitions": {
4
+ "EthereumTypedTransactionSignRequest": {
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "callbackURL": {
8
+ "type": "string"
9
+ },
10
+ "publicKey": {
11
+ "type": "string"
12
+ },
13
+ "transaction": {
14
+ "$ref": "#/definitions/SerializableEthereumTypedUnsignedTransaction"
15
+ }
16
+ },
17
+ "required": ["publicKey", "transaction"],
18
+ "type": "object"
19
+ },
20
+ "HexString": {
21
+ "type": "string"
22
+ },
23
+ "SerializableEthereumTypedUnsignedTransaction": {
24
+ "additionalProperties": false,
25
+ "properties": {
26
+ "derivationPath": {
27
+ "type": "string"
28
+ },
29
+ "masterFingerprint": {
30
+ "type": "string"
31
+ },
32
+ "serialized": {
33
+ "$ref": "#/definitions/HexString",
34
+ "type": "string"
35
+ }
36
+ },
37
+ "required": ["derivationPath", "masterFingerprint", "serialized"],
38
+ "type": "object"
39
+ }
40
+ }
41
+ }
@@ -0,0 +1,58 @@
1
+ {
2
+ "$schema": "http://json-schema.org/draft-07/schema#",
3
+ "definitions": {
4
+ "EthereumTransactionSignRequest": {
5
+ "additionalProperties": false,
6
+ "properties": {
7
+ "callbackURL": {
8
+ "type": "string"
9
+ },
10
+ "publicKey": {
11
+ "type": "string"
12
+ },
13
+ "transaction": {
14
+ "$ref": "#/definitions/SerializableEthereumRawUnsignedTransaction"
15
+ }
16
+ },
17
+ "required": ["publicKey", "transaction"],
18
+ "type": "object"
19
+ },
20
+ "HexString": {
21
+ "type": "string"
22
+ },
23
+ "SerializableEthereumRawUnsignedTransaction": {
24
+ "additionalProperties": false,
25
+ "properties": {
26
+ "chainId": {
27
+ "type": "number"
28
+ },
29
+ "data": {
30
+ "$ref": "#/definitions/HexString",
31
+ "type": "string"
32
+ },
33
+ "gasLimit": {
34
+ "$ref": "#/definitions/HexString",
35
+ "type": "string"
36
+ },
37
+ "gasPrice": {
38
+ "$ref": "#/definitions/HexString",
39
+ "type": "string"
40
+ },
41
+ "nonce": {
42
+ "$ref": "#/definitions/HexString",
43
+ "type": "string"
44
+ },
45
+ "to": {
46
+ "$ref": "#/definitions/HexString",
47
+ "type": "string"
48
+ },
49
+ "value": {
50
+ "$ref": "#/definitions/HexString",
51
+ "type": "string"
52
+ }
53
+ },
54
+ "required": ["chainId", "data", "gasLimit", "gasPrice", "nonce", "to", "value"],
55
+ "type": "object"
56
+ }
57
+ }
58
+ }
@@ -0,0 +1,19 @@
1
+ {
2
+ "$ref": "#/definitions/EthereumTransactionSignResponse",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "EthereumTransactionSignResponse": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "accountIdentifier": {
9
+ "type": "string"
10
+ },
11
+ "transaction": {
12
+ "type": "string"
13
+ }
14
+ },
15
+ "required": ["accountIdentifier", "transaction"],
16
+ "type": "object"
17
+ }
18
+ }
19
+ }
@@ -0,0 +1,13 @@
1
+ import { AirGapV3SerializerCompanion, SignedTransaction, UnsignedTransaction } from '@wallfree-dev/module-kit';
2
+ import { V3SchemaConfiguration } from '@wallfree-dev/module-kit/types/serializer';
3
+ import { TransactionSignRequest, TransactionSignResponse } from '@wallfree-dev/serializer';
4
+ export declare class EthereumV3SerializerCompanion implements AirGapV3SerializerCompanion {
5
+ readonly schemas: V3SchemaConfiguration[];
6
+ private readonly ethereumTransactionValidator;
7
+ toTransactionSignRequest(identifier: string, unsignedTransaction: UnsignedTransaction, publicKey: string, callbackUrl?: string): Promise<TransactionSignRequest>;
8
+ fromTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<UnsignedTransaction>;
9
+ validateTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<boolean>;
10
+ toTransactionSignResponse(identifier: string, signedTransaction: SignedTransaction, accountIdentifier: string): Promise<TransactionSignResponse>;
11
+ fromTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<SignedTransaction>;
12
+ validateTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<boolean>;
13
+ }
@@ -0,0 +1,182 @@
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
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.EthereumV3SerializerCompanion = void 0;
40
+ var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
41
+ var errors_1 = require("@wallfree-dev/coinlib-core/errors");
42
+ var serializer_1 = require("@wallfree-dev/serializer");
43
+ var transaction_converter_1 = require("./schemas/converter/transaction-converter");
44
+ var transaction_validator_1 = require("./validators/transaction-validator");
45
+ var ethereumTransactionSignRequest = require('./schemas/generated/transaction-sign-request-ethereum.json');
46
+ var ethereumTypedTransactionSignRequest = require('./schemas/generated/transaction-sign-request-ethereum-typed.json');
47
+ var ethereumTransactionSignResponse = require('./schemas/generated/transaction-sign-response-ethereum.json');
48
+ var EthereumV3SerializerCompanion = /** @class */ (function () {
49
+ function EthereumV3SerializerCompanion() {
50
+ this.schemas = [
51
+ {
52
+ type: serializer_1.IACMessageType.TransactionSignRequest,
53
+ schema: { schema: ethereumTransactionSignRequest },
54
+ protocolIdentifier: coinlib_core_1.MainProtocolSymbols.ETH
55
+ },
56
+ {
57
+ type: serializer_1.IACMessageType.TransactionSignRequest,
58
+ schema: { schema: ethereumTypedTransactionSignRequest },
59
+ protocolIdentifier: coinlib_core_1.MainProtocolSymbols.ETH
60
+ },
61
+ {
62
+ type: serializer_1.IACMessageType.TransactionSignResponse,
63
+ schema: { schema: ethereumTransactionSignResponse },
64
+ protocolIdentifier: coinlib_core_1.MainProtocolSymbols.ETH
65
+ },
66
+ {
67
+ type: serializer_1.IACMessageType.TransactionSignRequest,
68
+ schema: { schema: ethereumTransactionSignRequest },
69
+ protocolIdentifier: coinlib_core_1.SubProtocolSymbols.ETH_ERC20
70
+ },
71
+ {
72
+ type: serializer_1.IACMessageType.TransactionSignResponse,
73
+ schema: { schema: ethereumTransactionSignResponse },
74
+ protocolIdentifier: coinlib_core_1.SubProtocolSymbols.ETH_ERC20
75
+ }
76
+ ];
77
+ this.ethereumTransactionValidator = new transaction_validator_1.EthereumTransactionValidator();
78
+ }
79
+ EthereumV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
80
+ return __awaiter(this, void 0, void 0, function () {
81
+ return __generator(this, function (_a) {
82
+ if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
83
+ return [2 /*return*/, (0, transaction_converter_1.ethereumUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
84
+ }
85
+ else {
86
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
87
+ }
88
+ return [2 /*return*/];
89
+ });
90
+ });
91
+ };
92
+ EthereumV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
93
+ return __awaiter(this, void 0, void 0, function () {
94
+ return __generator(this, function (_a) {
95
+ if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
96
+ return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignRequestToUnsigned)(transactionSignRequest)];
97
+ }
98
+ else {
99
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
100
+ }
101
+ return [2 /*return*/];
102
+ });
103
+ });
104
+ };
105
+ EthereumV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
106
+ return __awaiter(this, void 0, void 0, function () {
107
+ var _a;
108
+ return __generator(this, function (_b) {
109
+ switch (_b.label) {
110
+ case 0:
111
+ if (!(identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20))) return [3 /*break*/, 5];
112
+ _b.label = 1;
113
+ case 1:
114
+ _b.trys.push([1, 3, , 4]);
115
+ return [4 /*yield*/, this.ethereumTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
116
+ case 2:
117
+ _b.sent();
118
+ return [2 /*return*/, true];
119
+ case 3:
120
+ _a = _b.sent();
121
+ return [2 /*return*/, false];
122
+ case 4: return [3 /*break*/, 6];
123
+ case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
124
+ case 6: return [2 /*return*/];
125
+ }
126
+ });
127
+ });
128
+ };
129
+ EthereumV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ return __generator(this, function (_a) {
132
+ if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
133
+ return [2 /*return*/, (0, transaction_converter_1.ethereumSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
134
+ }
135
+ else {
136
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
137
+ }
138
+ return [2 /*return*/];
139
+ });
140
+ });
141
+ };
142
+ EthereumV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
143
+ return __awaiter(this, void 0, void 0, function () {
144
+ return __generator(this, function (_a) {
145
+ if (identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20)) {
146
+ return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignResponseToSigned)(transactionSignResponse)];
147
+ }
148
+ else {
149
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
150
+ }
151
+ return [2 /*return*/];
152
+ });
153
+ });
154
+ };
155
+ EthereumV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ var _a;
158
+ return __generator(this, function (_b) {
159
+ switch (_b.label) {
160
+ case 0:
161
+ if (!(identifier === coinlib_core_1.MainProtocolSymbols.ETH || identifier.startsWith(coinlib_core_1.SubProtocolSymbols.ETH_ERC20))) return [3 /*break*/, 5];
162
+ _b.label = 1;
163
+ case 1:
164
+ _b.trys.push([1, 3, , 4]);
165
+ return [4 /*yield*/, this.ethereumTransactionValidator.validateSignedTransaction(transactionSignResponse)];
166
+ case 2:
167
+ _b.sent();
168
+ return [2 /*return*/, true];
169
+ case 3:
170
+ _a = _b.sent();
171
+ return [2 /*return*/, false];
172
+ case 4: return [3 /*break*/, 6];
173
+ case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.ETHEREUM, "Protocol ".concat(identifier, " not supported"));
174
+ case 6: return [2 /*return*/];
175
+ }
176
+ });
177
+ });
178
+ };
179
+ return EthereumV3SerializerCompanion;
180
+ }());
181
+ exports.EthereumV3SerializerCompanion = EthereumV3SerializerCompanion;
182
+ //# sourceMappingURL=serializer-companion.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"serializer-companion.js","sourceRoot":"","sources":["../../../../src/v1/serializer/v3/serializer-companion.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAA4F;AAC5F,4DAAoE;AAGpE,uDAAsH;AAItH,mFAKkD;AAClD,4EAAiF;AAEjF,IAAM,8BAA8B,GAAe,OAAO,CAAC,4DAA4D,CAAC,CAAA;AACxH,IAAM,mCAAmC,GAAe,OAAO,CAAC,kEAAkE,CAAC,CAAA;AACnI,IAAM,+BAA+B,GAAe,OAAO,CAAC,6DAA6D,CAAC,CAAA;AAE1H;IAAA;QACkB,YAAO,GAA4B;YACjD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,mCAAmC,EAAE;gBACvD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,uBAAuB;gBAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,+BAA+B,EAAE;gBACnD,kBAAkB,EAAE,kCAAmB,CAAC,GAAG;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,iCAAkB,CAAC,SAAS;aACjD;YACD;gBACE,IAAI,EAAE,2BAAc,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AQ,EAAE,mBAAY,UAAU,mBAAgB,CAAC,CAAA;;;;;KAEtF;IACH,oCAAC;AAAD,CAAC,AAzGD,IAyGC;AAzGY,sEAA6B"}
@@ -0,0 +1,7 @@
1
+ import { TransactionValidator, TransactionValidatorV2 } from '@wallfree-dev/serializer';
2
+ import { EthereumTransactionSignRequest } from '../schemas/definitions/transaction-sign-request-ethereum';
3
+ import { EthereumTransactionSignResponse } from '../schemas/definitions/transaction-sign-response-ethereum';
4
+ export declare class EthereumTransactionValidator implements TransactionValidator, TransactionValidatorV2 {
5
+ validateUnsignedTransaction(request: EthereumTransactionSignRequest): Promise<any>;
6
+ validateSignedTransaction(signedTx: EthereumTransactionSignResponse): any;
7
+ }
@@ -0,0 +1,71 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.EthereumTransactionValidator = void 0;
4
+ // tslint:disable: max-classes-per-file
5
+ var validate_1 = require("@wallfree-dev/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
6
+ var serializer_1 = require("@wallfree-dev/serializer");
7
+ var unsignedTransactionConstraints = {
8
+ nonce: {
9
+ presence: { allowEmpty: false },
10
+ type: 'String',
11
+ isHexStringWithPrefix: true
12
+ },
13
+ gasPrice: {
14
+ presence: { allowEmpty: false },
15
+ type: 'String',
16
+ isHexStringWithPrefix: true
17
+ },
18
+ gasLimit: {
19
+ presence: { allowEmpty: false },
20
+ type: 'String',
21
+ isHexStringWithPrefix: true
22
+ },
23
+ to: {
24
+ presence: { allowEmpty: false },
25
+ type: 'String',
26
+ isHexStringWithPrefix: true,
27
+ format: {
28
+ pattern: '^0x[a-fA-F0-9]{40}$',
29
+ flags: 'i',
30
+ message: 'is not a valid ethereum address'
31
+ }
32
+ },
33
+ value: {
34
+ presence: { allowEmpty: false },
35
+ type: 'String',
36
+ isHexStringWithPrefix: true
37
+ },
38
+ chainId: {
39
+ presence: { allowEmpty: false },
40
+ numericality: { noStrings: true, onlyInteger: true, greaterThanOrEqualTo: 0 }
41
+ },
42
+ data: {
43
+ presence: { allowEmpty: false },
44
+ type: 'String',
45
+ isHexStringWithPrefix: true
46
+ }
47
+ };
48
+ var signedTransactionConstraints = {
49
+ transaction: {
50
+ presence: { allowEmpty: false },
51
+ type: 'String',
52
+ isValidEthereumTransactionString: true
53
+ }
54
+ };
55
+ var success = function () { return undefined; };
56
+ var error = function (errors) { return errors; };
57
+ var EthereumTransactionValidator = /** @class */ (function () {
58
+ function EthereumTransactionValidator() {
59
+ }
60
+ EthereumTransactionValidator.prototype.validateUnsignedTransaction = function (request) {
61
+ var transaction = request.transaction;
62
+ (0, serializer_1.validateSyncScheme)({});
63
+ return (0, validate_1.async)(transaction, unsignedTransactionConstraints).then(success, error);
64
+ };
65
+ EthereumTransactionValidator.prototype.validateSignedTransaction = function (signedTx) {
66
+ return (0, validate_1.async)(signedTx, signedTransactionConstraints).then(success, error);
67
+ };
68
+ return EthereumTransactionValidator;
69
+ }());
70
+ exports.EthereumTransactionValidator = EthereumTransactionValidator;
71
+ //# sourceMappingURL=transaction-validator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;AAAA,uCAAuC;AACvC,oGAA+F;AAC/F,uDAA2G;AAK3G,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,EAA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,QAAyC;QACxE,OAAO,IAAA,gBAAK,EAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;IAC3E,CAAC;IACH,mCAAC;AAAD,CAAC,AAVD,IAUC;AAVY,oEAA4B"}
@@ -0,0 +1,2 @@
1
+ import { Secp256K1CryptoConfiguration } from '@wallfree-dev/module-kit';
2
+ export declare type EthereumCryptoConfiguration = Secp256K1CryptoConfiguration;
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=crypto.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"crypto.js","sourceRoot":"","sources":["../../../src/v1/types/crypto.ts"],"names":[],"mappings":""}
@@ -0,0 +1,35 @@
1
+ import { FeeDefaults, ProtocolNetwork, ProtocolUnitsMetadata } from '@wallfree-dev/module-kit';
2
+ export declare type EthereumUnits = 'ETH' | 'GWEI' | 'WEI';
3
+ export interface EthereumProtocolNetwork extends ProtocolNetwork {
4
+ chainId: number;
5
+ blockExplorerApi: string;
6
+ }
7
+ export interface EthereumProtocolOptions<_ProtocolNetwork extends EthereumProtocolNetwork = EthereumProtocolNetwork> {
8
+ network: _ProtocolNetwork;
9
+ }
10
+ export interface EthereumBaseProtocolOptions<_Units extends string = EthereumUnits, _ProtocolNetwork extends EthereumProtocolNetwork = EthereumProtocolNetwork> extends EthereumProtocolOptions<_ProtocolNetwork> {
11
+ identifier: string;
12
+ name: string;
13
+ units: ProtocolUnitsMetadata<_Units>;
14
+ mainUnit: _Units;
15
+ feeDefaults?: FeeDefaults<EthereumUnits>;
16
+ standardDerivationPath?: string;
17
+ }
18
+ export interface ERC20ProtocolOptions<_Units extends string, _ProtocolNetwork extends EthereumProtocolNetwork = EthereumProtocolNetwork> extends EthereumProtocolOptions<_ProtocolNetwork> {
19
+ name: string;
20
+ identifier: string;
21
+ contractAddress: string;
22
+ units: ProtocolUnitsMetadata<_Units>;
23
+ mainUnit: _Units;
24
+ }
25
+ export interface ERC20TokenOptions<_ProtocolNetwork extends EthereumProtocolNetwork = EthereumProtocolNetwork> extends ERC20ProtocolOptions<string, _ProtocolNetwork> {
26
+ mainIdentifier: string;
27
+ }
28
+ export interface ERC20TokenMetadata {
29
+ name: string;
30
+ identifier: string;
31
+ symbol: string;
32
+ marketSymbol: string;
33
+ contractAddress: string;
34
+ decimals: number;
35
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/types/protocol.ts"],"names":[],"mappings":""}
@@ -0,0 +1,24 @@
1
+ import { SignedTransaction, TransactionCursor, UnsignedTransaction } from '@wallfree-dev/module-kit';
2
+ export interface EthereumRawUnsignedTransaction extends UnsignedTransaction {
3
+ ethereumType: 'raw';
4
+ nonce: string;
5
+ gasPrice: string;
6
+ gasLimit: string;
7
+ to: string;
8
+ value: string;
9
+ chainId: number;
10
+ data: string;
11
+ }
12
+ export interface EthereumTypedUnsignedTransaction extends UnsignedTransaction {
13
+ ethereumType: 'typed';
14
+ serialized: string;
15
+ derivationPath: string;
16
+ masterFingerprint: string;
17
+ }
18
+ export declare type EthereumUnsignedTransaction = EthereumRawUnsignedTransaction | EthereumTypedUnsignedTransaction;
19
+ export interface EthereumSignedTransaction extends SignedTransaction {
20
+ serialized: string;
21
+ }
22
+ export interface EthereumTransactionCursor extends TransactionCursor {
23
+ page?: number;
24
+ }