@wallfree-dev/evmc 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 (39) hide show
  1. package/LICENSE.md +7 -0
  2. package/README.md +9 -0
  3. package/index.d.ts +1 -0
  4. package/index.js +18 -0
  5. package/index.js.map +1 -0
  6. package/package.json +62 -0
  7. package/v1/block-explorer/EvmcBlockExplorer.d.ts +9 -0
  8. package/v1/block-explorer/EvmcBlockExplorer.js +72 -0
  9. package/v1/block-explorer/EvmcBlockExplorer.js.map +1 -0
  10. package/v1/index.d.ts +1 -0
  11. package/v1/index.js +18 -0
  12. package/v1/index.js.map +1 -0
  13. package/v1/module/EvmcModule.d.ts +21 -0
  14. package/v1/module/EvmcModule.js +138 -0
  15. package/v1/module/EvmcModule.js.map +1 -0
  16. package/v1/module/EvmcOptions.d.ts +2 -0
  17. package/v1/module/EvmcOptions.js +825 -0
  18. package/v1/module/EvmcOptions.js.map +1 -0
  19. package/v1/protocol/EvmcProtocol.d.ts +82 -0
  20. package/v1/protocol/EvmcProtocol.js +877 -0
  21. package/v1/protocol/EvmcProtocol.js.map +1 -0
  22. package/v1/protocol/erc20/ERC20Protocol.d.ts +32 -0
  23. package/v1/protocol/erc20/ERC20Protocol.js +398 -0
  24. package/v1/protocol/erc20/ERC20Protocol.js.map +1 -0
  25. package/v1/protocol/erc20/ERC20Token.d.ts +15 -0
  26. package/v1/protocol/erc20/ERC20Token.js +134 -0
  27. package/v1/protocol/erc20/ERC20Token.js.map +1 -0
  28. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +39 -0
  29. package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +56 -0
  30. package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +19 -0
  31. package/v1/serializer/v3/serializer-companion.d.ts +16 -0
  32. package/v1/serializer/v3/serializer-companion.js +186 -0
  33. package/v1/serializer/v3/serializer-companion.js.map +1 -0
  34. package/v1/types/options.d.ts +18 -0
  35. package/v1/types/options.js +3 -0
  36. package/v1/types/options.js.map +1 -0
  37. package/v1/types/protocol.d.ts +29 -0
  38. package/v1/types/protocol.js +11 -0
  39. package/v1/types/protocol.js.map +1 -0
@@ -0,0 +1,134 @@
1
+ "use strict";
2
+ var __extends = (this && this.__extends) || (function () {
3
+ var extendStatics = function (d, b) {
4
+ extendStatics = Object.setPrototypeOf ||
5
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
6
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
7
+ return extendStatics(d, b);
8
+ };
9
+ return function (d, b) {
10
+ if (typeof b !== "function" && b !== null)
11
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
12
+ extendStatics(d, b);
13
+ function __() { this.constructor = d; }
14
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
15
+ };
16
+ })();
17
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
18
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
19
+ return new (P || (P = Promise))(function (resolve, reject) {
20
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
21
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
22
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
23
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
24
+ });
25
+ };
26
+ var __generator = (this && this.__generator) || function (thisArg, body) {
27
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
28
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
29
+ function verb(n) { return function (v) { return step([n, v]); }; }
30
+ function step(op) {
31
+ if (f) throw new TypeError("Generator is already executing.");
32
+ while (_) try {
33
+ 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;
34
+ if (y = 0, t) op = [op[0] & 2, t.value];
35
+ switch (op[0]) {
36
+ case 0: case 1: t = op; break;
37
+ case 4: _.label++; return { value: op[1], done: false };
38
+ case 5: _.label++; y = op[1]; op = [0]; continue;
39
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
40
+ default:
41
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
42
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
43
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
44
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
45
+ if (t[2]) _.ops.pop();
46
+ _.trys.pop(); continue;
47
+ }
48
+ op = body.call(thisArg, _);
49
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
50
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
51
+ }
52
+ };
53
+ Object.defineProperty(exports, "__esModule", { value: true });
54
+ exports.createERC20Token = exports.ERC20TokenImpl = void 0;
55
+ var EtherscanInfoClient_1 = require("@wallfree-dev/ethereum/v1/clients/info/EtherscanInfoClient");
56
+ var HttpEthereumNodeClient_1 = require("@wallfree-dev/ethereum/v1/clients/node/HttpEthereumNodeClient");
57
+ var ERC20Protocol_1 = require("./ERC20Protocol");
58
+ // Implementation
59
+ var ERC20TokenImpl = /** @class */ (function (_super) {
60
+ __extends(ERC20TokenImpl, _super);
61
+ function ERC20TokenImpl(nodeClient, infoClient, options) {
62
+ var _this = _super.call(this, nodeClient, infoClient, options) || this;
63
+ _this._mainProtocol = options.mainIdentifier;
64
+ return _this;
65
+ }
66
+ // SubProtocol
67
+ ERC20TokenImpl.prototype.getType = function () {
68
+ return __awaiter(this, void 0, void 0, function () {
69
+ return __generator(this, function (_a) {
70
+ return [2 /*return*/, 'token'];
71
+ });
72
+ });
73
+ };
74
+ ERC20TokenImpl.prototype.mainProtocol = function () {
75
+ return __awaiter(this, void 0, void 0, function () {
76
+ return __generator(this, function (_a) {
77
+ return [2 /*return*/, this._mainProtocol];
78
+ });
79
+ });
80
+ };
81
+ ERC20TokenImpl.prototype.getContractAddress = function () {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ return [2 /*return*/, this.contractAddress];
85
+ });
86
+ });
87
+ };
88
+ return ERC20TokenImpl;
89
+ }(ERC20Protocol_1.ERC20ProtocolImpl));
90
+ exports.ERC20TokenImpl = ERC20TokenImpl;
91
+ // Factory
92
+ // type ERC20TokenOptionsWithoutMetadata = Omit<
93
+ // ERC20TokenOptions,
94
+ // 'name' | 'identifier' | 'contractAddress' | 'symbol' | 'marketSymbol' | 'decimals'
95
+ // >
96
+ function createERC20Token(
97
+ // metadata: ERC20TokenMetadata,
98
+ // options: RecursivePartial<ERC20TokenOptionsWithoutMetadata> = {}
99
+ completeOptions) {
100
+ // const completeOptions: ERC20TokenOptions = createERC20TokenOptions(metadata, options.network, options.mainIdentifier)
101
+ return new ERC20TokenImpl(new HttpEthereumNodeClient_1.HttpEthereumNodeClient(completeOptions.network.rpcUrl), new EtherscanInfoClient_1.EtherscanInfoClient(completeOptions.network.blockExplorerApi), completeOptions);
102
+ }
103
+ exports.createERC20Token = createERC20Token;
104
+ // export const CONFLUX_ERC20_MAINNET_PROTOCOL_NETWORK: EvmcProtocolNetwork = {
105
+ // // ...CONFLUX_MAINNET_PROTOCOL_NETWORK
106
+ // name: 'Conflux eSpace (Hydra)',
107
+ // type: 'mainnet',
108
+ // chainId: 1030,
109
+ // rpcUrl: 'https://evm.confluxrpc.com',
110
+ // blockExplorerUrl: 'https://evm.confluxscan.org',
111
+ // blockExplorerApi: 'https://evmapi.confluxscan.org'
112
+ // }
113
+ // const DEFAULT_ERC20_PROTOCOL_NETWORK: EvmcProtocolNetwork = CONFLUX_ERC20_MAINNET_PROTOCOL_NETWORK
114
+ // export function createERC20TokenOptions(
115
+ // metadata: ERC20TokenMetadata,
116
+ // network: Partial<EvmcProtocolNetwork> = {},
117
+ // mainIdentifier?: string
118
+ // ): ERC20TokenOptions {
119
+ // return {
120
+ // network: { ...DEFAULT_ERC20_PROTOCOL_NETWORK, ...network },
121
+ // name: metadata.name,
122
+ // identifier: metadata.identifier,
123
+ // mainIdentifier: mainIdentifier ?? MainProtocolSymbols.CONFLUX,
124
+ // contractAddress: metadata.contractAddress,
125
+ // units: {
126
+ // [metadata.symbol]: {
127
+ // symbol: { value: metadata.symbol, market: metadata.marketSymbol },
128
+ // decimals: metadata.decimals
129
+ // }
130
+ // },
131
+ // mainUnit: metadata.symbol
132
+ // }
133
+ // }
134
+ //# sourceMappingURL=ERC20Token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ERC20Token.js","sourceRoot":"","sources":["../../../../src/v1/protocol/erc20/ERC20Token.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,kGAAgG;AAChG,wGAAsG;AAItG,iDAAkE;AAOlE,iBAAiB;AAEjB;IACU,kCAA2C;IAGnD,wBAAmB,UAA8B,EAAE,UAA8B,EAAE,OAA4C;QAA/H,YACE,kBAAM,UAAU,EAAE,UAAU,EAAE,OAAO,CAAC,SAGvC;QADC,KAAI,CAAC,aAAa,GAAG,OAAO,CAAC,cAAc,CAAA;;IAC7C,CAAC;IAED,cAAc;IAED,gCAAO,GAApB;;;gBACE,sBAAO,OAAO,EAAA;;;KACf;IAGY,qCAAY,GAAzB;;;gBACE,sBAAO,IAAI,CAAC,aAAa,EAAA;;;KAC1B;IAEY,2CAAkB,GAA/B;;;gBACE,sBAAO,IAAI,CAAC,eAAe,EAAA;;;KAC5B;IACH,qBAAC;AAAD,CAAC,AAxBD,CACU,iCAAiB,GAuB1B;AAxBY,wCAAc;AA0B3B,UAAU;AAEV,gDAAgD;AAChD,uBAAuB;AACvB,uFAAuF;AACvF,IAAI;AAEJ,SAAgB,gBAAgB;AAC9B,gCAAgC;AAChC,mEAAmE;AACnE,eAAkC;IAElC,wHAAwH;IAExH,OAAO,IAAI,cAAc,CACvB,IAAI,+CAAsB,CAAC,eAAe,CAAC,OAAO,CAAC,MAAM,CAAC,EAC1D,IAAI,yCAAmB,CAAC,eAAe,CAAC,OAAO,CAAC,gBAAgB,CAAC,EACjE,eAAe,CAChB,CAAA;AACH,CAAC;AAZD,4CAYC;AAED,+EAA+E;AAC/E,2CAA2C;AAC3C,oCAAoC;AACpC,qBAAqB;AACrB,mBAAmB;AACnB,0CAA0C;AAC1C,qDAAqD;AACrD,uDAAuD;AACvD,IAAI;AAEJ,qGAAqG;AAErG,2CAA2C;AAC3C,kCAAkC;AAClC,gDAAgD;AAChD,4BAA4B;AAC5B,yBAAyB;AACzB,aAAa;AACb,kEAAkE;AAClE,2BAA2B;AAC3B,uCAAuC;AACvC,qEAAqE;AAErE,iDAAiD;AAEjD,eAAe;AACf,6BAA6B;AAC7B,6EAA6E;AAC7E,sCAAsC;AACtC,UAAU;AACV,SAAS;AACT,gCAAgC;AAChC,MAAM;AACN,IAAI"}
@@ -0,0 +1,39 @@
1
+ {
2
+ "$ref": "#/definitions/EthereumTypedTransactionSignRequest",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "EthereumTypedTransactionSignRequest": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "callbackURL": {
9
+ "type": "string"
10
+ },
11
+ "publicKey": {
12
+ "type": "string"
13
+ },
14
+ "transaction": {
15
+ "additionalProperties": false,
16
+ "properties": {
17
+ "derivationPath": {
18
+ "type": "string"
19
+ },
20
+ "masterFingerprint": {
21
+ "type": "string"
22
+ },
23
+ "serialized": {
24
+ "$ref": "#/definitions/HexString",
25
+ "type": "string"
26
+ }
27
+ },
28
+ "required": ["derivationPath", "masterFingerprint", "serialized"],
29
+ "type": "object"
30
+ }
31
+ },
32
+ "required": ["publicKey", "transaction"],
33
+ "type": "object"
34
+ },
35
+ "HexString": {
36
+ "type": "string"
37
+ }
38
+ }
39
+ }
@@ -0,0 +1,56 @@
1
+ {
2
+ "$ref": "#/definitions/EthereumTransactionSignRequest",
3
+ "$schema": "http://json-schema.org/draft-07/schema#",
4
+ "definitions": {
5
+ "EthereumTransactionSignRequest": {
6
+ "additionalProperties": false,
7
+ "properties": {
8
+ "callbackURL": {
9
+ "type": "string"
10
+ },
11
+ "publicKey": {
12
+ "type": "string"
13
+ },
14
+ "transaction": {
15
+ "additionalProperties": false,
16
+ "properties": {
17
+ "chainId": {
18
+ "type": "number"
19
+ },
20
+ "data": {
21
+ "$ref": "#/definitions/HexString",
22
+ "type": "string"
23
+ },
24
+ "gasLimit": {
25
+ "$ref": "#/definitions/HexString",
26
+ "type": "string"
27
+ },
28
+ "gasPrice": {
29
+ "$ref": "#/definitions/HexString",
30
+ "type": "string"
31
+ },
32
+ "nonce": {
33
+ "$ref": "#/definitions/HexString",
34
+ "type": "string"
35
+ },
36
+ "to": {
37
+ "$ref": "#/definitions/HexString",
38
+ "type": "string"
39
+ },
40
+ "value": {
41
+ "$ref": "#/definitions/HexString",
42
+ "type": "string"
43
+ }
44
+ },
45
+ "required": ["chainId", "data", "gasLimit", "gasPrice", "nonce", "to", "value"],
46
+ "type": "object"
47
+ }
48
+ },
49
+ "required": ["publicKey", "transaction"],
50
+ "type": "object"
51
+ },
52
+ "HexString": {
53
+ "type": "string"
54
+ }
55
+ }
56
+ }
@@ -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,16 @@
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 EvmcV3SerializerCompanion implements AirGapV3SerializerCompanion {
5
+ private readonly protocolIdentifier;
6
+ constructor(protocolIdentifier: string);
7
+ private isSupportedProtocol;
8
+ readonly schemas: V3SchemaConfiguration[];
9
+ private readonly ethereumTransactionValidator;
10
+ toTransactionSignRequest(identifier: string, unsignedTransaction: UnsignedTransaction, publicKey: string, callbackUrl?: string): Promise<TransactionSignRequest>;
11
+ fromTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<UnsignedTransaction>;
12
+ validateTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<boolean>;
13
+ toTransactionSignResponse(identifier: string, signedTransaction: SignedTransaction, accountIdentifier: string): Promise<TransactionSignResponse>;
14
+ fromTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<SignedTransaction>;
15
+ validateTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<boolean>;
16
+ }
@@ -0,0 +1,186 @@
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.EvmcV3SerializerCompanion = 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("@wallfree-dev/ethereum/v1/serializer/v3/schemas/converter/transaction-converter");
44
+ var transaction_validator_1 = require("@wallfree-dev/ethereum/v1/serializer/v3/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 EvmcV3SerializerCompanion = /** @class */ (function () {
49
+ function EvmcV3SerializerCompanion(protocolIdentifier) {
50
+ this.protocolIdentifier = protocolIdentifier;
51
+ this.schemas = [
52
+ {
53
+ type: serializer_1.IACMessageType.TransactionSignRequest,
54
+ schema: { schema: ethereumTransactionSignRequest },
55
+ protocolIdentifier: this.protocolIdentifier
56
+ },
57
+ {
58
+ type: serializer_1.IACMessageType.TransactionSignRequest,
59
+ schema: { schema: ethereumTypedTransactionSignRequest },
60
+ protocolIdentifier: this.protocolIdentifier
61
+ },
62
+ {
63
+ type: serializer_1.IACMessageType.TransactionSignResponse,
64
+ schema: { schema: ethereumTransactionSignResponse },
65
+ protocolIdentifier: this.protocolIdentifier
66
+ },
67
+ {
68
+ type: serializer_1.IACMessageType.TransactionSignRequest,
69
+ schema: { schema: ethereumTransactionSignRequest },
70
+ protocolIdentifier: "".concat(this.protocolIdentifier, "-erc20")
71
+ },
72
+ {
73
+ type: serializer_1.IACMessageType.TransactionSignResponse,
74
+ schema: { schema: ethereumTransactionSignResponse },
75
+ protocolIdentifier: "".concat(this.protocolIdentifier, "-erc20")
76
+ }
77
+ ];
78
+ this.ethereumTransactionValidator = new transaction_validator_1.EthereumTransactionValidator();
79
+ }
80
+ EvmcV3SerializerCompanion.prototype.isSupportedProtocol = function (identifier) {
81
+ return identifier === this.protocolIdentifier || identifier.startsWith("".concat(this.protocolIdentifier, "-erc20-"));
82
+ };
83
+ EvmcV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
84
+ return __awaiter(this, void 0, void 0, function () {
85
+ return __generator(this, function (_a) {
86
+ if (this.isSupportedProtocol(identifier)) {
87
+ return [2 /*return*/, (0, transaction_converter_1.ethereumUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
88
+ }
89
+ else {
90
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.EVMC, "Protocol ".concat(identifier, " not supported"));
91
+ }
92
+ return [2 /*return*/];
93
+ });
94
+ });
95
+ };
96
+ EvmcV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ return __generator(this, function (_a) {
99
+ if (this.isSupportedProtocol(identifier)) {
100
+ return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignRequestToUnsigned)(transactionSignRequest)];
101
+ }
102
+ else {
103
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.EVMC, "Protocol ".concat(identifier, " not supported"));
104
+ }
105
+ return [2 /*return*/];
106
+ });
107
+ });
108
+ };
109
+ EvmcV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
110
+ return __awaiter(this, void 0, void 0, function () {
111
+ var _a;
112
+ return __generator(this, function (_b) {
113
+ switch (_b.label) {
114
+ case 0:
115
+ if (!this.isSupportedProtocol(identifier)) return [3 /*break*/, 5];
116
+ _b.label = 1;
117
+ case 1:
118
+ _b.trys.push([1, 3, , 4]);
119
+ return [4 /*yield*/, this.ethereumTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
120
+ case 2:
121
+ _b.sent();
122
+ return [2 /*return*/, true];
123
+ case 3:
124
+ _a = _b.sent();
125
+ return [2 /*return*/, false];
126
+ case 4: return [3 /*break*/, 6];
127
+ case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.EVMC, "Protocol ".concat(identifier, " not supported"));
128
+ case 6: return [2 /*return*/];
129
+ }
130
+ });
131
+ });
132
+ };
133
+ EvmcV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
134
+ return __awaiter(this, void 0, void 0, function () {
135
+ return __generator(this, function (_a) {
136
+ if (this.isSupportedProtocol(identifier)) {
137
+ return [2 /*return*/, (0, transaction_converter_1.ethereumSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
138
+ }
139
+ else {
140
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.EVMC, "Protocol ".concat(identifier, " not supported"));
141
+ }
142
+ return [2 /*return*/];
143
+ });
144
+ });
145
+ };
146
+ EvmcV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
147
+ return __awaiter(this, void 0, void 0, function () {
148
+ return __generator(this, function (_a) {
149
+ if (this.isSupportedProtocol(identifier)) {
150
+ return [2 /*return*/, (0, transaction_converter_1.ethereumTransactionSignResponseToSigned)(transactionSignResponse)];
151
+ }
152
+ else {
153
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.EVMC, "Protocol ".concat(identifier, " not supported"));
154
+ }
155
+ return [2 /*return*/];
156
+ });
157
+ });
158
+ };
159
+ EvmcV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
160
+ return __awaiter(this, void 0, void 0, function () {
161
+ var _a;
162
+ return __generator(this, function (_b) {
163
+ switch (_b.label) {
164
+ case 0:
165
+ if (!this.isSupportedProtocol(identifier)) return [3 /*break*/, 5];
166
+ _b.label = 1;
167
+ case 1:
168
+ _b.trys.push([1, 3, , 4]);
169
+ return [4 /*yield*/, this.ethereumTransactionValidator.validateSignedTransaction(transactionSignResponse)];
170
+ case 2:
171
+ _b.sent();
172
+ return [2 /*return*/, true];
173
+ case 3:
174
+ _a = _b.sent();
175
+ return [2 /*return*/, false];
176
+ case 4: return [3 /*break*/, 6];
177
+ case 5: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.EVMC, "Protocol ".concat(identifier, " not supported"));
178
+ case 6: return [2 /*return*/];
179
+ }
180
+ });
181
+ });
182
+ };
183
+ return EvmcV3SerializerCompanion;
184
+ }());
185
+ exports.EvmcV3SerializerCompanion = EvmcV3SerializerCompanion;
186
+ //# 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,2DAAgG;AAChG,4DAAoE;AAGpE,uDAAsH;AAItH,yHAKwF;AACxF,kHAAuH;AAEvH,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;IACE,mCAA6B,kBAA0B;QAA1B,uBAAkB,GAAlB,kBAAkB,CAAQ;QAMvC,YAAO,GAA4B;YACjD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,mCAAmC,EAAE;gBACvD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,uBAAuB;gBAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,+BAA+B,EAAE;gBACnD,kBAAkB,EAAE,IAAI,CAAC,kBAAkB;aAC5C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,8BAA8B,EAAE;gBAClD,kBAAkB,EAAE,UAAG,IAAI,CAAC,kBAAkB,WAAQ;aACvD;YACD;gBACE,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import { ProtocolUnitsMetadata, FeeDefaults } from '@wallfree-dev/module-kit';
2
+ import { EvmcUnits, EvmcProtocolNetwork } from './protocol';
3
+ export interface EvmcErc20Options {
4
+ identifier: string;
5
+ name: string;
6
+ contractAddress: string;
7
+ units: ProtocolUnitsMetadata<EvmcUnits>;
8
+ mainUnit: EvmcUnits;
9
+ }
10
+ export interface EvmcOptions {
11
+ identifier: string;
12
+ name: string;
13
+ network: EvmcProtocolNetwork;
14
+ units: ProtocolUnitsMetadata<EvmcUnits>;
15
+ mainUnit: EvmcUnits;
16
+ feeDefaults?: FeeDefaults<EvmcUnits>;
17
+ erc20Tokens: EvmcErc20Options[];
18
+ }
@@ -0,0 +1,3 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/v1/types/options.ts"],"names":[],"mappings":""}
@@ -0,0 +1,29 @@
1
+ import { FeeDefaults, ProtocolNetwork, ProtocolUnitsMetadata } from '@wallfree-dev/module-kit';
2
+ export declare type EvmcUnits = string;
3
+ export interface EvmcProtocolNetwork extends ProtocolNetwork {
4
+ chainId: number;
5
+ blockExplorerApi: string;
6
+ }
7
+ export interface EvmcProtocolOptions<_ProtocolNetwork extends EvmcProtocolNetwork = EvmcProtocolNetwork> {
8
+ network: _ProtocolNetwork;
9
+ }
10
+ export interface EvmcBaseProtocolOptions<_Units extends string = EvmcUnits, _ProtocolNetwork extends EvmcProtocolNetwork = EvmcProtocolNetwork> extends EvmcProtocolOptions<_ProtocolNetwork> {
11
+ identifier: string;
12
+ name: string;
13
+ units: ProtocolUnitsMetadata<_Units>;
14
+ mainUnit: _Units;
15
+ feeUnits: ProtocolUnitsMetadata<_Units>;
16
+ feeDefaults?: FeeDefaults<EvmcUnits>;
17
+ standardDerivationPath?: string;
18
+ }
19
+ export interface ERC20ProtocolOptions<_Units extends string, _ProtocolNetwork extends EvmcProtocolNetwork = EvmcProtocolNetwork> extends EvmcProtocolOptions<_ProtocolNetwork> {
20
+ name: string;
21
+ identifier: string;
22
+ contractAddress: string;
23
+ units: ProtocolUnitsMetadata<_Units>;
24
+ mainUnit: _Units;
25
+ feeUnits: ProtocolUnitsMetadata<_Units>;
26
+ }
27
+ export interface ERC20TokenOptions<_ProtocolNetwork extends EvmcProtocolNetwork = EvmcProtocolNetwork> extends ERC20ProtocolOptions<string, _ProtocolNetwork> {
28
+ mainIdentifier: string;
29
+ }
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ // export interface ERC20TokenMetadata {
4
+ // name: string
5
+ // identifier: string
6
+ // symbol: string
7
+ // marketSymbol: string
8
+ // contractAddress: string
9
+ // decimals: number
10
+ // }
11
+ //# sourceMappingURL=protocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"protocol.js","sourceRoot":"","sources":["../../../src/v1/types/protocol.ts"],"names":[],"mappings":";;AA8CA,wCAAwC;AACxC,iBAAiB;AACjB,uBAAuB;AAEvB,mBAAmB;AACnB,yBAAyB;AAEzB,4BAA4B;AAE5B,qBAAqB;AACrB,IAAI"}