@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.
- package/LICENSE.md +7 -0
- package/README.md +9 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +62 -0
- package/v1/block-explorer/EvmcBlockExplorer.d.ts +9 -0
- package/v1/block-explorer/EvmcBlockExplorer.js +72 -0
- package/v1/block-explorer/EvmcBlockExplorer.js.map +1 -0
- package/v1/index.d.ts +1 -0
- package/v1/index.js +18 -0
- package/v1/index.js.map +1 -0
- package/v1/module/EvmcModule.d.ts +21 -0
- package/v1/module/EvmcModule.js +138 -0
- package/v1/module/EvmcModule.js.map +1 -0
- package/v1/module/EvmcOptions.d.ts +2 -0
- package/v1/module/EvmcOptions.js +825 -0
- package/v1/module/EvmcOptions.js.map +1 -0
- package/v1/protocol/EvmcProtocol.d.ts +82 -0
- package/v1/protocol/EvmcProtocol.js +877 -0
- package/v1/protocol/EvmcProtocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Protocol.d.ts +32 -0
- package/v1/protocol/erc20/ERC20Protocol.js +398 -0
- package/v1/protocol/erc20/ERC20Protocol.js.map +1 -0
- package/v1/protocol/erc20/ERC20Token.d.ts +15 -0
- package/v1/protocol/erc20/ERC20Token.js +134 -0
- package/v1/protocol/erc20/ERC20Token.js.map +1 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum-typed.json +39 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-request-ethereum.json +56 -0
- package/v1/serializer/v3/schemas/generated/transaction-sign-response-ethereum.json +19 -0
- package/v1/serializer/v3/serializer-companion.d.ts +16 -0
- package/v1/serializer/v3/serializer-companion.js +186 -0
- package/v1/serializer/v3/serializer-companion.js.map +1 -0
- package/v1/types/options.d.ts +18 -0
- package/v1/types/options.js +3 -0
- package/v1/types/options.js.map +1 -0
- package/v1/types/protocol.d.ts +29 -0
- package/v1/types/protocol.js +11 -0
- package/v1/types/protocol.js.map +1 -0
package/LICENSE.md
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
Copyright 2019 Papers AG
|
|
2
|
+
|
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
|
4
|
+
|
|
5
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
6
|
+
|
|
7
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
package/README.md
ADDED
package/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './v1';
|
package/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./v1"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uCAAoB"}
|
package/package.json
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wallfree-dev/evmc",
|
|
3
|
+
"version": "0.13.42",
|
|
4
|
+
"description": "The @wallfree-dev/evmc is a EVM Compatible implementation of the ICoinProtocol interface from @wallfree-dev/coinlib-core.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"airgap",
|
|
7
|
+
"blockchain",
|
|
8
|
+
"crypto",
|
|
9
|
+
"evmc"
|
|
10
|
+
],
|
|
11
|
+
"homepage": "https://www.airgap.it",
|
|
12
|
+
"license": "MIT",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/airgap-it/airgap-coin-lib.git"
|
|
16
|
+
},
|
|
17
|
+
"publishConfig": {
|
|
18
|
+
"access": "public"
|
|
19
|
+
},
|
|
20
|
+
"scripts": {
|
|
21
|
+
"build": "rm -rf ./dist && tsc && node scripts/copy-files-after-build.js",
|
|
22
|
+
"build-scripts": "tsc scripts/copy-files-after-build.ts",
|
|
23
|
+
"lint": "tslint -c ./tslint.json --project ./tsconfig.json --format stylish --fix",
|
|
24
|
+
"lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
|
|
25
|
+
"lint-ci": "tslint -t json -o ../../lint-reports/evmc.json --project . || true",
|
|
26
|
+
"lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
|
|
27
|
+
"test": "",
|
|
28
|
+
"test-ci": "nyc --reporter=lcov pnpm test",
|
|
29
|
+
"browserify": "browserify ./dist/index.js -s airgapCoinLibEvmc > ./dist/airgap-coinlib-evmc.min.js"
|
|
30
|
+
},
|
|
31
|
+
"author": "Papers AG <contact@papers.ch> (https://papers.ch)",
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@wallfree-dev/coinlib-core": "0.13.42",
|
|
34
|
+
"@wallfree-dev/cosmos-core": "0.13.42",
|
|
35
|
+
"@wallfree-dev/crypto": "0.13.42",
|
|
36
|
+
"@wallfree-dev/module-kit": "0.13.42",
|
|
37
|
+
"@wallfree-dev/serializer": "0.13.42",
|
|
38
|
+
"@ethereumjs/common": "2.6.5",
|
|
39
|
+
"@ethereumjs/tx": "3.4.0"
|
|
40
|
+
},
|
|
41
|
+
"nyc": {
|
|
42
|
+
"include": [
|
|
43
|
+
"src/**/*.ts"
|
|
44
|
+
],
|
|
45
|
+
"exclude": [
|
|
46
|
+
"test/**/*.spec.ts"
|
|
47
|
+
],
|
|
48
|
+
"extension": [
|
|
49
|
+
".ts"
|
|
50
|
+
],
|
|
51
|
+
"require": [
|
|
52
|
+
"ts-node/register"
|
|
53
|
+
],
|
|
54
|
+
"reporter": [
|
|
55
|
+
"text",
|
|
56
|
+
"text-summary"
|
|
57
|
+
],
|
|
58
|
+
"report-dir": "../../coverage/evmc",
|
|
59
|
+
"sourceMap": true,
|
|
60
|
+
"instrument": true
|
|
61
|
+
}
|
|
62
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AirGapBlockExplorer, BlockExplorerMetadata } from '@wallfree-dev/module-kit';
|
|
2
|
+
export declare class EvmcBlockExplorer implements AirGapBlockExplorer {
|
|
3
|
+
private readonly url;
|
|
4
|
+
private readonly metadata;
|
|
5
|
+
constructor(url: string);
|
|
6
|
+
getMetadata(): Promise<BlockExplorerMetadata>;
|
|
7
|
+
createAddressUrl(address: string): Promise<string>;
|
|
8
|
+
createTransactionUrl(transactionId: string): Promise<string>;
|
|
9
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
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.EvmcBlockExplorer = void 0;
|
|
40
|
+
var EvmcBlockExplorer = /** @class */ (function () {
|
|
41
|
+
function EvmcBlockExplorer(url) {
|
|
42
|
+
this.url = url;
|
|
43
|
+
this.metadata = {
|
|
44
|
+
name: 'Evmc Explorer',
|
|
45
|
+
url: this.url
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
EvmcBlockExplorer.prototype.getMetadata = function () {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
return __generator(this, function (_a) {
|
|
51
|
+
return [2 /*return*/, this.metadata];
|
|
52
|
+
});
|
|
53
|
+
});
|
|
54
|
+
};
|
|
55
|
+
EvmcBlockExplorer.prototype.createAddressUrl = function (address) {
|
|
56
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
return [2 /*return*/, "".concat(this.url, "/address/").concat(address)];
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
EvmcBlockExplorer.prototype.createTransactionUrl = function (transactionId) {
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
return __generator(this, function (_a) {
|
|
65
|
+
return [2 /*return*/, "".concat(this.url, "/tx/").concat(transactionId)];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return EvmcBlockExplorer;
|
|
70
|
+
}());
|
|
71
|
+
exports.EvmcBlockExplorer = EvmcBlockExplorer;
|
|
72
|
+
//# sourceMappingURL=EvmcBlockExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvmcBlockExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/EvmcBlockExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAME,2BAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAL9B,aAAQ,GAA0B;YACjD,IAAI,EAAE,eAAe;YACrB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IAEiD,CAAC;IAEtC,uCAAW,GAAxB;;;gBACE,sBAAO,IAAI,CAAC,QAAQ,EAAA;;;KACrB;IAEY,4CAAgB,GAA7B,UAA8B,OAAe;;;gBAC3C,sBAAO,UAAG,IAAI,CAAC,GAAG,sBAAY,OAAO,CAAE,EAAA;;;KACxC;IAEY,gDAAoB,GAAjC,UAAkC,aAAqB;;;gBACrD,sBAAO,UAAG,IAAI,CAAC,GAAG,iBAAO,aAAa,CAAE,EAAA;;;KACzC;IACH,wBAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,8CAAiB"}
|
package/v1/index.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './module/EvmcModule';
|
package/v1/index.js
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
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 __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./module/EvmcModule"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
package/v1/index.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/v1/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,sDAAmC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import { AirGapModule, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@wallfree-dev/module-kit';
|
|
2
|
+
import { BlockExplorer } from '@wallfree-dev/module-kit/block-explorer/block-explorer';
|
|
3
|
+
import { OfflineProtocol, OnlineProtocol } from '@wallfree-dev/module-kit/protocol/protocol';
|
|
4
|
+
import { EvmcProtocolNetwork } from '../types/protocol';
|
|
5
|
+
import { EvmcOptions } from '../types/options';
|
|
6
|
+
export declare class EvmcModule implements AirGapModule<{
|
|
7
|
+
ProtocolNetwork: EvmcProtocolNetwork;
|
|
8
|
+
}> {
|
|
9
|
+
private readonly option;
|
|
10
|
+
supportedProtocols: Record<string, ProtocolConfiguration>;
|
|
11
|
+
private readonly networkRegistries;
|
|
12
|
+
constructor(option: EvmcOptions);
|
|
13
|
+
createOfflineProtocol(identifier: string): Promise<OfflineProtocol | undefined>;
|
|
14
|
+
createOnlineProtocol(identifier: string, networkOrId?: EvmcProtocolNetwork | string): Promise<OnlineProtocol | undefined>;
|
|
15
|
+
createBlockExplorer(identifier: string, networkOrId?: EvmcProtocolNetwork | string): Promise<BlockExplorer | undefined>;
|
|
16
|
+
createV3SerializerCompanion(): Promise<AirGapV3SerializerCompanion>;
|
|
17
|
+
private createProtocol;
|
|
18
|
+
}
|
|
19
|
+
export declare const evmcModules: Record<string, EvmcModule>;
|
|
20
|
+
export declare const base: EvmcModule;
|
|
21
|
+
export declare const conflux: EvmcModule;
|
|
@@ -0,0 +1,138 @@
|
|
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
50
|
+
exports.conflux = exports.base = exports.evmcModules = exports.EvmcModule = void 0;
|
|
51
|
+
var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
|
|
52
|
+
var errors_1 = require("@wallfree-dev/coinlib-core/errors");
|
|
53
|
+
var module_kit_1 = require("@wallfree-dev/module-kit");
|
|
54
|
+
var EvmcBlockExplorer_1 = require("../block-explorer/EvmcBlockExplorer");
|
|
55
|
+
var ERC20Token_1 = require("../protocol/erc20/ERC20Token");
|
|
56
|
+
var EvmcProtocol_1 = require("../protocol/EvmcProtocol");
|
|
57
|
+
var serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
58
|
+
var EvmcOptions_1 = require("./EvmcOptions");
|
|
59
|
+
var EvmcModule = /** @class */ (function () {
|
|
60
|
+
function EvmcModule(option) {
|
|
61
|
+
var _a;
|
|
62
|
+
this.option = option;
|
|
63
|
+
var mainRegistry = new module_kit_1.ModuleNetworkRegistry({
|
|
64
|
+
supportedNetworks: [this.option.network]
|
|
65
|
+
});
|
|
66
|
+
var erc20Registry = new module_kit_1.ModuleNetworkRegistry({
|
|
67
|
+
supportedNetworks: [this.option.network]
|
|
68
|
+
});
|
|
69
|
+
this.networkRegistries = __assign((_a = {}, _a[this.option.identifier] = mainRegistry, _a), this.option.erc20Tokens.reduce(
|
|
70
|
+
// 把主币的 symbol 加到代币 symbol 上作为前缀
|
|
71
|
+
function (obj, token) {
|
|
72
|
+
var _a;
|
|
73
|
+
return Object.assign(obj, (_a = {}, _a[token.identifier] = erc20Registry, _a));
|
|
74
|
+
}, {}));
|
|
75
|
+
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
76
|
+
}
|
|
77
|
+
EvmcModule.prototype.createOfflineProtocol = function (identifier) {
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
return __generator(this, function (_a) {
|
|
80
|
+
return [2 /*return*/, this.createProtocol(identifier)];
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
};
|
|
84
|
+
EvmcModule.prototype.createOnlineProtocol = function (identifier, networkOrId) {
|
|
85
|
+
var _a;
|
|
86
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
87
|
+
var network;
|
|
88
|
+
return __generator(this, function (_b) {
|
|
89
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
90
|
+
if (network === undefined) {
|
|
91
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.EVMC, 'Protocol network type not supported.');
|
|
92
|
+
}
|
|
93
|
+
return [2 /*return*/, this.createProtocol(identifier, network)];
|
|
94
|
+
});
|
|
95
|
+
});
|
|
96
|
+
};
|
|
97
|
+
EvmcModule.prototype.createBlockExplorer = function (identifier, networkOrId) {
|
|
98
|
+
var _a;
|
|
99
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
100
|
+
var network;
|
|
101
|
+
return __generator(this, function (_b) {
|
|
102
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
103
|
+
if (network === undefined) {
|
|
104
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.EVMC, 'Block Explorer network type not supported.');
|
|
105
|
+
}
|
|
106
|
+
return [2 /*return*/, new EvmcBlockExplorer_1.EvmcBlockExplorer(network.blockExplorerUrl)];
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
};
|
|
110
|
+
EvmcModule.prototype.createV3SerializerCompanion = function () {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
112
|
+
return __generator(this, function (_a) {
|
|
113
|
+
return [2 /*return*/, new serializer_companion_1.EvmcV3SerializerCompanion(this.option.identifier)];
|
|
114
|
+
});
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
EvmcModule.prototype.createProtocol = function (identifier, network) {
|
|
118
|
+
if (identifier === this.option.identifier) {
|
|
119
|
+
var baseOption = __assign(__assign({}, this.option), { feeUnits: this.option.units });
|
|
120
|
+
return (0, EvmcProtocol_1.createEvmcProtocol)(baseOption);
|
|
121
|
+
}
|
|
122
|
+
var erc20Token = this.option.erc20Tokens.find(function (token) { return token.identifier === identifier; });
|
|
123
|
+
if (erc20Token !== undefined) {
|
|
124
|
+
var completeOptions = __assign(__assign({ network: this.option.network, mainIdentifier: this.option.identifier }, erc20Token), { feeUnits: this.option.units });
|
|
125
|
+
return (0, ERC20Token_1.createERC20Token)(completeOptions);
|
|
126
|
+
}
|
|
127
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.EVMC, "Protocol ".concat(identifier, " not supported."));
|
|
128
|
+
};
|
|
129
|
+
return EvmcModule;
|
|
130
|
+
}());
|
|
131
|
+
exports.EvmcModule = EvmcModule;
|
|
132
|
+
exports.evmcModules = EvmcOptions_1.evmcOptionsList.reduce(function (evmcModules, option) {
|
|
133
|
+
evmcModules[option.identifier] = new EvmcModule(option);
|
|
134
|
+
return evmcModules;
|
|
135
|
+
}, {});
|
|
136
|
+
exports.base = exports.evmcModules['base'];
|
|
137
|
+
exports.conflux = exports.evmcModules['conflux'];
|
|
138
|
+
//# sourceMappingURL=EvmcModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"EvmcModule.js","sourceRoot":"","sources":["../../../src/v1/module/EvmcModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAmD;AACnD,4DAA2E;AAC3E,uDAOiC;AAIjC,yEAAuE;AACvE,2DAA+D;AAC/D,yDAA6D;AAC7D,8EAAiF;AAGjF,6CAA+C;AAE/C;IAIE,oBACmB,MAAmB;;QAAnB,WAAM,GAAN,MAAM,CAAa;QAEpC,IAAI,YAAY,GAAG,IAAI,kCAAqB,CAAC;YAC3C,iBAAiB,EAAE,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC;SACzC,CAAC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