@wallfree-dev/coreum 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 +11 -0
- package/index.d.ts +1 -0
- package/index.js +18 -0
- package/index.js.map +1 -0
- package/package.json +60 -0
- package/v1/block-explorer/CoreumExplorer.d.ts +9 -0
- package/v1/block-explorer/CoreumExplorer.js +72 -0
- package/v1/block-explorer/CoreumExplorer.js.map +1 -0
- package/v1/index.d.ts +6 -0
- package/v1/index.js +11 -0
- package/v1/index.js.map +1 -0
- package/v1/module/CoreumModule.d.ts +17 -0
- package/v1/module/CoreumModule.js +107 -0
- package/v1/module/CoreumModule.js.map +1 -0
- package/v1/module.d.ts +3 -0
- package/v1/module.js +24 -0
- package/v1/module.js.map +1 -0
- package/v1/protocol/CoreumProtocol.d.ts +16 -0
- package/v1/protocol/CoreumProtocol.js +161 -0
- package/v1/protocol/CoreumProtocol.js.map +1 -0
- package/v1/serializer/v3/serializer-companion.d.ts +12 -0
- package/v1/serializer/v3/serializer-companion.js +142 -0
- package/v1/serializer/v3/serializer-companion.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,60 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@wallfree-dev/coreum",
|
|
3
|
+
"version": "0.13.42",
|
|
4
|
+
"description": "The @wallfree-dev/coreum is a Coreum implementation of the ICoinProtocol interface from @wallfree-dev/coinlib-core.",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"airgap",
|
|
7
|
+
"blockchain",
|
|
8
|
+
"crypto",
|
|
9
|
+
"coreum"
|
|
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/coreum.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 airgapCoinLibCoreum > ./dist/airgap-coinlib-coreum.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
|
+
},
|
|
39
|
+
"nyc": {
|
|
40
|
+
"include": [
|
|
41
|
+
"src/**/*.ts"
|
|
42
|
+
],
|
|
43
|
+
"exclude": [
|
|
44
|
+
"test/**/*.spec.ts"
|
|
45
|
+
],
|
|
46
|
+
"extension": [
|
|
47
|
+
".ts"
|
|
48
|
+
],
|
|
49
|
+
"require": [
|
|
50
|
+
"ts-node/register"
|
|
51
|
+
],
|
|
52
|
+
"reporter": [
|
|
53
|
+
"text",
|
|
54
|
+
"text-summary"
|
|
55
|
+
],
|
|
56
|
+
"report-dir": "../../coverage/coreum",
|
|
57
|
+
"sourceMap": true,
|
|
58
|
+
"instrument": true
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { AirGapBlockExplorer, BlockExplorerMetadata } from '@wallfree-dev/module-kit';
|
|
2
|
+
export declare class CoreumBlockExplorer 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.CoreumBlockExplorer = void 0;
|
|
40
|
+
var CoreumBlockExplorer = /** @class */ (function () {
|
|
41
|
+
function CoreumBlockExplorer(url) {
|
|
42
|
+
this.url = url;
|
|
43
|
+
this.metadata = {
|
|
44
|
+
name: 'Coreum Explorer',
|
|
45
|
+
url: this.url
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
CoreumBlockExplorer.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
|
+
CoreumBlockExplorer.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, "/accounts/").concat(address)];
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
};
|
|
62
|
+
CoreumBlockExplorer.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, "/transactions/").concat(transactionId)];
|
|
66
|
+
});
|
|
67
|
+
});
|
|
68
|
+
};
|
|
69
|
+
return CoreumBlockExplorer;
|
|
70
|
+
}());
|
|
71
|
+
exports.CoreumBlockExplorer = CoreumBlockExplorer;
|
|
72
|
+
//# sourceMappingURL=CoreumExplorer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreumExplorer.js","sourceRoot":"","sources":["../../../src/v1/block-explorer/CoreumExplorer.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA;IAME,6BAAoC,GAAW;QAAX,QAAG,GAAH,GAAG,CAAQ;QAL9B,aAAQ,GAA0B;YACjD,IAAI,EAAE,iBAAiB;YACvB,GAAG,EAAE,IAAI,CAAC,GAAG;SACd,CAAA;IAEiD,CAAC;IAEtC,yCAAW,GAAxB;;;gBACE,sBAAO,IAAI,CAAC,QAAQ,EAAA;;;KACrB;IAEY,8CAAgB,GAA7B,UAA8B,OAAe;;;gBAC3C,sBAAO,UAAG,IAAI,CAAC,GAAG,uBAAa,OAAO,CAAE,EAAA;;;KACzC;IAEY,kDAAoB,GAAjC,UAAkC,aAAqB;;;gBACrD,sBAAO,UAAG,IAAI,CAAC,GAAG,2BAAiB,aAAa,CAAE,EAAA;;;KACnD;IACH,0BAAC;AAAD,CAAC,AAnBD,IAmBC;AAnBY,kDAAmB"}
|
package/v1/index.d.ts
ADDED
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { CoreumBlockExplorer } from './block-explorer/CoreumExplorer';
|
|
2
|
+
import { CoreumModule } from './module/CoreumModule';
|
|
3
|
+
import { CoreumProtocol, createCoreumProtocol, createCoreumProtocolOptions } from './protocol/CoreumProtocol';
|
|
4
|
+
export { CoreumModule };
|
|
5
|
+
export { CoreumProtocol, createCoreumProtocol, createCoreumProtocolOptions };
|
|
6
|
+
export { CoreumBlockExplorer };
|
package/v1/index.js
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.CoreumBlockExplorer = exports.createCoreumProtocolOptions = exports.createCoreumProtocol = exports.CoreumModule = void 0;
|
|
4
|
+
var CoreumExplorer_1 = require("./block-explorer/CoreumExplorer");
|
|
5
|
+
Object.defineProperty(exports, "CoreumBlockExplorer", { enumerable: true, get: function () { return CoreumExplorer_1.CoreumBlockExplorer; } });
|
|
6
|
+
var CoreumModule_1 = require("./module/CoreumModule");
|
|
7
|
+
Object.defineProperty(exports, "CoreumModule", { enumerable: true, get: function () { return CoreumModule_1.CoreumModule; } });
|
|
8
|
+
var CoreumProtocol_1 = require("./protocol/CoreumProtocol");
|
|
9
|
+
Object.defineProperty(exports, "createCoreumProtocol", { enumerable: true, get: function () { return CoreumProtocol_1.createCoreumProtocol; } });
|
|
10
|
+
Object.defineProperty(exports, "createCoreumProtocolOptions", { enumerable: true, get: function () { return CoreumProtocol_1.createCoreumProtocolOptions; } });
|
|
11
|
+
//# 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,kEAAqE;AAc5D,oGAdA,oCAAmB,OAcA;AAb5B,sDAAoD;AAK3C,6FALA,2BAAY,OAKA;AAJrB,4DAA6G;AAQpF,qGARA,qCAAoB,OAQA;AAAE,4GARA,4CAA2B,OAQA"}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { MainProtocolSymbols } from '@wallfree-dev/coinlib-core';
|
|
2
|
+
import { CosmosProtocolNetwork } from '@wallfree-dev/cosmos-core';
|
|
3
|
+
import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@wallfree-dev/module-kit';
|
|
4
|
+
declare type SupportedProtocols = MainProtocolSymbols.COREUM;
|
|
5
|
+
export declare class CoreumModule implements AirGapModule<{
|
|
6
|
+
Protocols: SupportedProtocols;
|
|
7
|
+
ProtocolNetwork: CosmosProtocolNetwork;
|
|
8
|
+
}> {
|
|
9
|
+
private readonly networkRegistries;
|
|
10
|
+
readonly supportedProtocols: Record<MainProtocolSymbols.COREUM, ProtocolConfiguration>;
|
|
11
|
+
createOfflineProtocol(identifier: MainProtocolSymbols.COREUM): Promise<AirGapOfflineProtocol | undefined>;
|
|
12
|
+
createOnlineProtocol(identifier: MainProtocolSymbols.COREUM, networkOrId?: CosmosProtocolNetwork | string): Promise<AirGapOnlineProtocol | undefined>;
|
|
13
|
+
createBlockExplorer(identifier: MainProtocolSymbols.COREUM, networkOrId?: CosmosProtocolNetwork | string): Promise<AirGapBlockExplorer | undefined>;
|
|
14
|
+
createV3SerializerCompanion(): Promise<AirGapV3SerializerCompanion>;
|
|
15
|
+
private createProtocol;
|
|
16
|
+
}
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,107 @@
|
|
|
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.CoreumModule = void 0;
|
|
40
|
+
var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
|
|
41
|
+
var errors_1 = require("@wallfree-dev/coinlib-core/errors");
|
|
42
|
+
var module_kit_1 = require("@wallfree-dev/module-kit");
|
|
43
|
+
var CoreumExplorer_1 = require("../block-explorer/CoreumExplorer");
|
|
44
|
+
var CoreumProtocol_1 = require("../protocol/CoreumProtocol");
|
|
45
|
+
var serializer_companion_1 = require("../serializer/v3/serializer-companion");
|
|
46
|
+
var CoreumModule = /** @class */ (function () {
|
|
47
|
+
function CoreumModule() {
|
|
48
|
+
var _a;
|
|
49
|
+
this.networkRegistries = (_a = {},
|
|
50
|
+
_a[coinlib_core_1.MainProtocolSymbols.COREUM] = new module_kit_1.ModuleNetworkRegistry({
|
|
51
|
+
supportedNetworks: [CoreumProtocol_1.COREUM_PROTOCOL_NETWORK]
|
|
52
|
+
}),
|
|
53
|
+
_a);
|
|
54
|
+
this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
|
|
55
|
+
}
|
|
56
|
+
CoreumModule.prototype.createOfflineProtocol = function (identifier) {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
58
|
+
return __generator(this, function (_a) {
|
|
59
|
+
return [2 /*return*/, this.createProtocol(identifier)];
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
};
|
|
63
|
+
CoreumModule.prototype.createOnlineProtocol = function (identifier, networkOrId) {
|
|
64
|
+
var _a;
|
|
65
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
66
|
+
var network;
|
|
67
|
+
return __generator(this, function (_b) {
|
|
68
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
69
|
+
if (network === undefined) {
|
|
70
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.COREUM, 'Protocol network type not supported.');
|
|
71
|
+
}
|
|
72
|
+
return [2 /*return*/, this.createProtocol(identifier, network)];
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
};
|
|
76
|
+
CoreumModule.prototype.createBlockExplorer = function (identifier, networkOrId) {
|
|
77
|
+
var _a;
|
|
78
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
79
|
+
var network;
|
|
80
|
+
return __generator(this, function (_b) {
|
|
81
|
+
network = typeof networkOrId === 'object' ? networkOrId : (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkOrId);
|
|
82
|
+
if (network === undefined) {
|
|
83
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.COSMOS, 'Block Explorer network type not supported.');
|
|
84
|
+
}
|
|
85
|
+
return [2 /*return*/, new CoreumExplorer_1.CoreumBlockExplorer(network.blockExplorerUrl)];
|
|
86
|
+
});
|
|
87
|
+
});
|
|
88
|
+
};
|
|
89
|
+
CoreumModule.prototype.createV3SerializerCompanion = function () {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
return __generator(this, function (_a) {
|
|
92
|
+
return [2 /*return*/, new serializer_companion_1.CoreumV3SerializerCompanion()];
|
|
93
|
+
});
|
|
94
|
+
});
|
|
95
|
+
};
|
|
96
|
+
CoreumModule.prototype.createProtocol = function (identifier, network) {
|
|
97
|
+
switch (identifier) {
|
|
98
|
+
case coinlib_core_1.MainProtocolSymbols.COREUM:
|
|
99
|
+
return (0, CoreumProtocol_1.createCoreumProtocol)({ network: network });
|
|
100
|
+
default:
|
|
101
|
+
throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.COREUM, "Protocol ".concat(identifier, " not supported."));
|
|
102
|
+
}
|
|
103
|
+
};
|
|
104
|
+
return CoreumModule;
|
|
105
|
+
}());
|
|
106
|
+
exports.CoreumModule = CoreumModule;
|
|
107
|
+
//# sourceMappingURL=CoreumModule.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreumModule.js","sourceRoot":"","sources":["../../../src/v1/module/CoreumModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAwE;AACxE,4DAA2E;AAE3E,uDAWiC;AAEjC,mEAAsE;AACtE,6DAA0F;AAC1F,8EAAmF;AAInF;IAAA;;QACmB,sBAAiB;YAChC,GAAC,kCAAmB,CAAC,MAAM,IAAG,IAAI,kCAAqB,CAAC;gBACtD,iBAAiB,EAAE,CAAC,wCAAuB,CAAC;aAC7C,CAAC;gBACH;QACe,uBAAkB,GAA8D,IAAA,qCAAwB,EACtH,IAAI,CAAC,iBAAiB,CACvB,CAAA;IA8CH,CAAC;IA5Cc,4CAAqB,GAAlC,UAAmC,UAAsC;;;gBACvE,sBAAO,IAAI,CAAC,cAAc,CAAC,UAAU,CAAC,EAAA;;;KACvC;IAEY,2CAAoB,GAAjC,UACE,UAAsC,EACtC,WAA4C;;;;;gBAEtC,OAAO,GACX,OAAO,WAAW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0 +1,24 @@
|
|
|
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
|
+
exports.create = void 0;
|
|
18
|
+
var CoreumModule_1 = require("./module/CoreumModule");
|
|
19
|
+
__exportStar(require("./index"), exports);
|
|
20
|
+
function create() {
|
|
21
|
+
return new CoreumModule_1.CoreumModule();
|
|
22
|
+
}
|
|
23
|
+
exports.create = create;
|
|
24
|
+
//# sourceMappingURL=module.js.map
|
package/v1/module.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"module.js","sourceRoot":"","sources":["../../src/v1/module.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,sDAAoD;AAEpD,0CAAuB;AAEvB,SAAgB,MAAM;IACpB,OAAO,IAAI,2BAAY,EAAE,CAAA;AAC3B,CAAC;AAFD,wBAEC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { CosmosBaseProtocolImpl, CosmosBaseStakingProtocol, CosmosProtocolNetwork, CosmosProtocolOptions } from '@wallfree-dev/cosmos-core';
|
|
2
|
+
import { FeeDefaults, ProtocolMetadata, PublicKey, RecursivePartial, TransactionDetails, TransactionSimpleConfiguration } from '@wallfree-dev/module-kit';
|
|
3
|
+
export declare type CoreumDenom = 'core' | 'ucore';
|
|
4
|
+
export interface CoreumProtocol extends CosmosBaseStakingProtocol<CoreumDenom> {
|
|
5
|
+
}
|
|
6
|
+
export declare class CoreumProtocolImpl extends CosmosBaseProtocolImpl<CoreumDenom> implements CoreumProtocol {
|
|
7
|
+
constructor(options?: RecursivePartial<CosmosProtocolOptions<CoreumDenom>>);
|
|
8
|
+
private readonly units;
|
|
9
|
+
private readonly feeDefaults;
|
|
10
|
+
private readonly metadata;
|
|
11
|
+
getMetadata(): Promise<ProtocolMetadata<CoreumDenom>>;
|
|
12
|
+
getTransactionFeeWithPublicKey(_publicKey: PublicKey, _details: TransactionDetails<CoreumDenom>[], _configuration?: TransactionSimpleConfiguration): Promise<FeeDefaults<CoreumDenom>>;
|
|
13
|
+
}
|
|
14
|
+
export declare function createCoreumProtocol(options?: RecursivePartial<CosmosProtocolOptions<CoreumDenom>>): CoreumProtocol;
|
|
15
|
+
export declare const COREUM_PROTOCOL_NETWORK: CosmosProtocolNetwork;
|
|
16
|
+
export declare function createCoreumProtocolOptions(partialOptions?: RecursivePartial<CosmosProtocolOptions<CoreumDenom>>): CosmosProtocolOptions<CoreumDenom>;
|
|
@@ -0,0 +1,161 @@
|
|
|
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 __assign = (this && this.__assign) || function () {
|
|
18
|
+
__assign = Object.assign || function(t) {
|
|
19
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
20
|
+
s = arguments[i];
|
|
21
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
22
|
+
t[p] = s[p];
|
|
23
|
+
}
|
|
24
|
+
return t;
|
|
25
|
+
};
|
|
26
|
+
return __assign.apply(this, arguments);
|
|
27
|
+
};
|
|
28
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
29
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
30
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
31
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
32
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
33
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
34
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
38
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
39
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
40
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
41
|
+
function step(op) {
|
|
42
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
43
|
+
while (_) try {
|
|
44
|
+
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;
|
|
45
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
46
|
+
switch (op[0]) {
|
|
47
|
+
case 0: case 1: t = op; break;
|
|
48
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
49
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
50
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
51
|
+
default:
|
|
52
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
53
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
54
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
55
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
56
|
+
if (t[2]) _.ops.pop();
|
|
57
|
+
_.trys.pop(); continue;
|
|
58
|
+
}
|
|
59
|
+
op = body.call(thisArg, _);
|
|
60
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
61
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
65
|
+
exports.createCoreumProtocolOptions = exports.COREUM_PROTOCOL_NETWORK = exports.createCoreumProtocol = exports.CoreumProtocolImpl = void 0;
|
|
66
|
+
var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
|
|
67
|
+
var cosmos_core_1 = require("@wallfree-dev/cosmos-core");
|
|
68
|
+
var module_kit_1 = require("@wallfree-dev/module-kit");
|
|
69
|
+
var DEFAULT_GAS = (0, module_kit_1.newAmount)('200000', 'blockchain');
|
|
70
|
+
var CoreumProtocolImpl = /** @class */ (function (_super) {
|
|
71
|
+
__extends(CoreumProtocolImpl, _super);
|
|
72
|
+
function CoreumProtocolImpl(options) {
|
|
73
|
+
if (options === void 0) { options = {}; }
|
|
74
|
+
var _this = this;
|
|
75
|
+
var fullOptions = createCoreumProtocolOptions(options);
|
|
76
|
+
_this = _super.call(this, fullOptions) || this;
|
|
77
|
+
_this.units = {
|
|
78
|
+
core: {
|
|
79
|
+
symbol: { value: 'CORE', market: 'CORE' },
|
|
80
|
+
decimals: 6
|
|
81
|
+
},
|
|
82
|
+
ucore: {
|
|
83
|
+
symbol: { value: 'uCORE' },
|
|
84
|
+
decimals: 0
|
|
85
|
+
}
|
|
86
|
+
};
|
|
87
|
+
_this.feeDefaults = {
|
|
88
|
+
low: (0, module_kit_1.newAmount)(0.007, 'core').blockchain(_this.units),
|
|
89
|
+
medium: (0, module_kit_1.newAmount)(0.0085, 'core').blockchain(_this.units),
|
|
90
|
+
high: (0, module_kit_1.newAmount)(0.01, 'core').blockchain(_this.units)
|
|
91
|
+
};
|
|
92
|
+
_this.metadata = {
|
|
93
|
+
identifier: coinlib_core_1.MainProtocolSymbols.COREUM,
|
|
94
|
+
name: 'Coreum',
|
|
95
|
+
units: _this.units,
|
|
96
|
+
mainUnit: 'core',
|
|
97
|
+
fee: {
|
|
98
|
+
defaults: _this.feeDefaults
|
|
99
|
+
},
|
|
100
|
+
account: {
|
|
101
|
+
standardDerivationPath: "m/44'/990'/0'/0/0",
|
|
102
|
+
address: {
|
|
103
|
+
isCaseSensitive: false,
|
|
104
|
+
placeholder: 'core...',
|
|
105
|
+
regex: '^(core|corevaloper)[a-zA-Z0-9]{39}$'
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
transaction: {
|
|
109
|
+
arbitraryData: {
|
|
110
|
+
name: 'memo'
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
};
|
|
114
|
+
return _this;
|
|
115
|
+
}
|
|
116
|
+
CoreumProtocolImpl.prototype.getMetadata = function () {
|
|
117
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
118
|
+
return __generator(this, function (_a) {
|
|
119
|
+
return [2 /*return*/, this.metadata];
|
|
120
|
+
});
|
|
121
|
+
});
|
|
122
|
+
};
|
|
123
|
+
CoreumProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (_publicKey, _details, _configuration) {
|
|
124
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
125
|
+
return __generator(this, function (_a) {
|
|
126
|
+
return [2 /*return*/, this.feeDefaults];
|
|
127
|
+
});
|
|
128
|
+
});
|
|
129
|
+
};
|
|
130
|
+
return CoreumProtocolImpl;
|
|
131
|
+
}(cosmos_core_1.CosmosBaseProtocolImpl));
|
|
132
|
+
exports.CoreumProtocolImpl = CoreumProtocolImpl;
|
|
133
|
+
// Factory
|
|
134
|
+
function createCoreumProtocol(options) {
|
|
135
|
+
if (options === void 0) { options = {}; }
|
|
136
|
+
return new CoreumProtocolImpl(options);
|
|
137
|
+
}
|
|
138
|
+
exports.createCoreumProtocol = createCoreumProtocol;
|
|
139
|
+
exports.COREUM_PROTOCOL_NETWORK = {
|
|
140
|
+
name: 'Mainnet',
|
|
141
|
+
type: 'mainnet',
|
|
142
|
+
rpcUrl: 'https://coreum-node.prod.gke.papers.tech',
|
|
143
|
+
blockExplorerUrl: 'https://explorer.coreum.com/coreum',
|
|
144
|
+
useCORSProxy: true
|
|
145
|
+
};
|
|
146
|
+
var DEFAULT_COREUM_PROTOCOL_NETWORK = exports.COREUM_PROTOCOL_NETWORK;
|
|
147
|
+
function createCoreumProtocolOptions(partialOptions) {
|
|
148
|
+
var _a, _b, _c, _d, _e, _f;
|
|
149
|
+
if (partialOptions === void 0) { partialOptions = {}; }
|
|
150
|
+
return {
|
|
151
|
+
network: __assign(__assign({}, DEFAULT_COREUM_PROTOCOL_NETWORK), partialOptions.network),
|
|
152
|
+
addressPrefix: (_a = partialOptions.addressPrefix) !== null && _a !== void 0 ? _a : 'core',
|
|
153
|
+
baseUnit: (_b = partialOptions.baseUnit) !== null && _b !== void 0 ? _b : 'ucore',
|
|
154
|
+
defaultGas: {
|
|
155
|
+
value: (_d = (_c = partialOptions.defaultGas) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : DEFAULT_GAS.value,
|
|
156
|
+
unit: (_f = (_e = partialOptions.defaultGas) === null || _e === void 0 ? void 0 : _e.unit) !== null && _f !== void 0 ? _f : DEFAULT_GAS.unit
|
|
157
|
+
}
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
exports.createCoreumProtocolOptions = createCoreumProtocolOptions;
|
|
161
|
+
//# sourceMappingURL=CoreumProtocol.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CoreumProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/CoreumProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAgE;AAChE,yDAA2I;AAC3I,uDAUiC;AAIjC,IAAM,WAAW,GAAwB,IAAA,sBAAS,EAAC,QAAQ,EAAE,YAAY,CAAC,CAAA;AAI1E;IAAwC,sCAAmC;IACzE,4BAAmB,OAAkE;QAAlE,wBAAA,EAAA,YAAkE;QAArF,iBAIC;QAHC,IAAM,WAAW,GAAG,2BAA2B,CAAC,OAAO,CAAC,CAAA;gBAExD,kBAAM,WAAW,CAAC;QAGH,WAAK,GAAuC;YAC3D,IAAI,EAAE;gBACJ,MAAM,EAAE,EAAE,KAAK,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE;gBACzC,QAAQ,EAAE,CAAC;aACZ;YACD,KAAK,EAAE;gBACL,MAAM,EAAE,EAAE,KAAK,EAAE,OAAO,EAAE;gBAC1B,QAAQ,EAAE,CAAC;aACZ;SACF,CAAA;QAEgB,iBAAW,GAA6B;YACvD,GAAG,EAAE,IAAA,sBAAS,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,KAAI,CAAC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ACtD,YAAY,EAAE,IAAI;CACnB,CAAA;AAED,IAAM,+BAA+B,GAA0B,+BAAuB,CAAA;AAEtF,SAAgB,2BAA2B,CACzC,cAAyE;;IAAzE,+BAAA,EAAA,mBAAyE;IAEzE,OAAO;QACL,OAAO,wBAAO,+BAA+B,GAAK,cAAc,CAAC,OAAO,CAAE;QAC1E,aAAa,EAAE,MAAA,cAAc,CAAC,aAAa,mCAAI,MAAM;QACrD,QAAQ,EAAE,MAAA,cAAc,CAAC,QAAQ,mCAAI,OAAO;QAC5C,UAAU,EAAE;YACV,KAAK,EAAE,MAAA,MAAA,cAAc,CAAC,UAAU,0CAAE,KAAK,mCAAI,WAAW,CAAC,KAAK;YAC5D,IAAI,EAAE,MAAA,MAAA,cAAc,CAAC,UAAU,0CAAE,IAAI,mCAAI,WAAW,CAAC,IAAI;SAC1D;KACF,CAAA;AACH,CAAC;AAZD,kEAYC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
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 CoreumV3SerializerCompanion implements AirGapV3SerializerCompanion {
|
|
5
|
+
readonly schemas: V3SchemaConfiguration[];
|
|
6
|
+
toTransactionSignRequest(identifier: string, unsignedTransaction: UnsignedTransaction, publicKey: string, callbackUrl?: string): Promise<TransactionSignRequest>;
|
|
7
|
+
fromTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<UnsignedTransaction>;
|
|
8
|
+
validateTransactionSignRequest(identifier: string, _transactionSignRequest: TransactionSignRequest): Promise<boolean>;
|
|
9
|
+
toTransactionSignResponse(identifier: string, signedTransaction: SignedTransaction, accountIdentifier: string): Promise<TransactionSignResponse>;
|
|
10
|
+
fromTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<SignedTransaction>;
|
|
11
|
+
validateTransactionSignResponse(identifier: string, _transactionSignResponse: TransactionSignResponse): Promise<boolean>;
|
|
12
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
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.CoreumV3SerializerCompanion = void 0;
|
|
40
|
+
var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
|
|
41
|
+
var errors_1 = require("@wallfree-dev/coinlib-core/errors");
|
|
42
|
+
var cosmos_core_1 = require("@wallfree-dev/cosmos-core");
|
|
43
|
+
var serializer_1 = require("@wallfree-dev/serializer");
|
|
44
|
+
var cosmosTransactionSignRequest = require('@wallfree-dev/cosmos-core/v1/serializer/v3/schemas/generated/transaction-sign-request-cosmos.json');
|
|
45
|
+
var cosmosTransactionSignResponse = require('@wallfree-dev/cosmos-core/v1/serializer/v3/schemas/generated/transaction-sign-response-cosmos.json');
|
|
46
|
+
var CoreumV3SerializerCompanion = /** @class */ (function () {
|
|
47
|
+
function CoreumV3SerializerCompanion() {
|
|
48
|
+
this.schemas = [
|
|
49
|
+
{
|
|
50
|
+
type: serializer_1.IACMessageType.TransactionSignRequest,
|
|
51
|
+
schema: { schema: cosmosTransactionSignRequest },
|
|
52
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.COREUM
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
type: serializer_1.IACMessageType.TransactionSignResponse,
|
|
56
|
+
schema: { schema: cosmosTransactionSignResponse },
|
|
57
|
+
protocolIdentifier: coinlib_core_1.MainProtocolSymbols.COREUM
|
|
58
|
+
}
|
|
59
|
+
];
|
|
60
|
+
}
|
|
61
|
+
CoreumV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
|
|
62
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
63
|
+
return __generator(this, function (_a) {
|
|
64
|
+
switch (identifier) {
|
|
65
|
+
case coinlib_core_1.MainProtocolSymbols.COREUM:
|
|
66
|
+
return [2 /*return*/, (0, cosmos_core_1.cosmosUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
|
|
67
|
+
default:
|
|
68
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COREUM, "Protocol ".concat(identifier, " not supported"));
|
|
69
|
+
}
|
|
70
|
+
return [2 /*return*/];
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
};
|
|
74
|
+
CoreumV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
|
|
75
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
76
|
+
return __generator(this, function (_a) {
|
|
77
|
+
switch (identifier) {
|
|
78
|
+
case coinlib_core_1.MainProtocolSymbols.COREUM:
|
|
79
|
+
return [2 /*return*/, (0, cosmos_core_1.cosmosTransactionSignRequestToUnsigned)(transactionSignRequest)];
|
|
80
|
+
default:
|
|
81
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COREUM, "Protocol ".concat(identifier, " not supported"));
|
|
82
|
+
}
|
|
83
|
+
return [2 /*return*/];
|
|
84
|
+
});
|
|
85
|
+
});
|
|
86
|
+
};
|
|
87
|
+
CoreumV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, _transactionSignRequest) {
|
|
88
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
89
|
+
return __generator(this, function (_a) {
|
|
90
|
+
switch (identifier) {
|
|
91
|
+
case coinlib_core_1.MainProtocolSymbols.COREUM:
|
|
92
|
+
return [2 /*return*/, true];
|
|
93
|
+
default:
|
|
94
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COREUM, "Protocol ".concat(identifier, " not supported"));
|
|
95
|
+
}
|
|
96
|
+
return [2 /*return*/];
|
|
97
|
+
});
|
|
98
|
+
});
|
|
99
|
+
};
|
|
100
|
+
CoreumV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
|
|
101
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
102
|
+
return __generator(this, function (_a) {
|
|
103
|
+
switch (identifier) {
|
|
104
|
+
case coinlib_core_1.MainProtocolSymbols.COREUM:
|
|
105
|
+
return [2 /*return*/, (0, cosmos_core_1.cosmosSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
|
|
106
|
+
default:
|
|
107
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COREUM, "Protocol ".concat(identifier, " not supported"));
|
|
108
|
+
}
|
|
109
|
+
return [2 /*return*/];
|
|
110
|
+
});
|
|
111
|
+
});
|
|
112
|
+
};
|
|
113
|
+
CoreumV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
|
|
114
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
115
|
+
return __generator(this, function (_a) {
|
|
116
|
+
switch (identifier) {
|
|
117
|
+
case coinlib_core_1.MainProtocolSymbols.COREUM:
|
|
118
|
+
return [2 /*return*/, (0, cosmos_core_1.cosmosTransactionSignResponseToSigned)(transactionSignResponse)];
|
|
119
|
+
default:
|
|
120
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COREUM, "Protocol ".concat(identifier, " not supported"));
|
|
121
|
+
}
|
|
122
|
+
return [2 /*return*/];
|
|
123
|
+
});
|
|
124
|
+
});
|
|
125
|
+
};
|
|
126
|
+
CoreumV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, _transactionSignResponse) {
|
|
127
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
128
|
+
return __generator(this, function (_a) {
|
|
129
|
+
switch (identifier) {
|
|
130
|
+
case coinlib_core_1.MainProtocolSymbols.COREUM:
|
|
131
|
+
return [2 /*return*/, true];
|
|
132
|
+
default:
|
|
133
|
+
throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COREUM, "Protocol ".concat(identifier, " not supported"));
|
|
134
|
+
}
|
|
135
|
+
return [2 /*return*/];
|
|
136
|
+
});
|
|
137
|
+
});
|
|
138
|
+
};
|
|
139
|
+
return CoreumV3SerializerCompanion;
|
|
140
|
+
}());
|
|
141
|
+
exports.CoreumV3SerializerCompanion = CoreumV3SerializerCompanion;
|
|
142
|
+
//# 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,2DAAwE;AACxE,4DAAoE;AACpE,yDAOkC;AAGlC,uDAAsH;AAEtH,IAAM,4BAA4B,GAAe,OAAO,CAAC,mGAAmG,CAAC,CAAA;AAC7J,IAAM,6BAA6B,GAAe,OAAO,CAAC,oGAAoG,CAAC,CAAA;AAE/J;IAAA;QACkB,YAAO,GAA4B;YACjD;gBACE,IAAI,EAAE,2BAAc,CAAC,sBAAsB;gBAC3C,MAAM,EAAE,EAAE,MAAM,EAAE,4BAA4B,EAAE;gBAChD,kBAAkB,EAAE,kCAAmB,CAAC,MAAM;aAC/C;YACD;gBACE,IAAI,EAAE,2BAAc,CAAC,uBAAuB;gBAC5C,MAAM,EAAE,EAAE,MAAM,EAAE,6BAA6B,EAAE;gBACjD,kBAAkB,EAAE,k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