@airgap/aeternity 0.13.7-beta.27 → 0.13.8-beta.10

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.
@@ -68232,6 +68232,12 @@ exports.NonExtendedProtocol = void 0;
68232
68232
  var NonExtendedProtocol = /** @class */ (function () {
68233
68233
  function NonExtendedProtocol() {
68234
68234
  }
68235
+ NonExtendedProtocol.prototype.getExtendedPublicKeyFromMnemonic = function (mnemonic, derivationPath, password) {
68236
+ throw Promise.reject('extended public key support not implemented');
68237
+ };
68238
+ NonExtendedProtocol.prototype.getExtendedPublicKeyFromHexSecret = function (secret, derivationPath) {
68239
+ throw Promise.reject('extended public key support not implemented');
68240
+ };
68235
68241
  NonExtendedProtocol.prototype.getExtendedPrivateKeyFromMnemonic = function (mnemonic, derivationPath, password) {
68236
68242
  throw Promise.reject('extended private key support not implemented');
68237
68243
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@airgap/aeternity",
3
- "version": "0.13.7-beta.27",
3
+ "version": "0.13.8-beta.10",
4
4
  "description": "The @airgap/aeternity is an Aeternity implementation of the ICoinProtocol interface from @airgap/coinlib-core.",
5
5
  "keywords": [
6
6
  "airgap",
@@ -24,16 +24,16 @@
24
24
  "lint:prettier": "prettier --write \"src/**/*.ts\" \"test/**/*.ts\"",
25
25
  "lint-ci": "tslint -t json -o ../../lint-reports/aeternity.json --project . || true",
26
26
  "lint-ci:prettier": "prettier \"src/**/*.ts\" \"test/**/*.ts\" --list-different",
27
- "test": "nyc mocha --bail --require ts-node/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
27
+ "test": "TS_NODE_PROJECT='./test/tsconfig.json' nyc mocha --bail --require ts-node/register --require source-map-support/register --full-trace --delay --timeout 40000 ./test/**/**.spec.ts",
28
28
  "test-ci": "nyc --reporter=lcov npm test",
29
29
  "test-legacy": "",
30
30
  "browserify": "browserify ./dist/index.js -p realpathify -s airgapCoinLibAeternity > ./dist/airgap-coinlib-aeternity.min.js"
31
31
  },
32
32
  "author": "Papers GmbH <contact@papers.ch> (https://papers.ch)",
33
33
  "peerDependencies": {
34
- "@airgap/coinlib-core": "^0.13.7-beta.0",
35
- "@airgap/module-kit": "^0.13.7-beta.0",
36
- "@airgap/serializer": "^0.13.7-beta.0",
34
+ "@airgap/coinlib-core": "^0.13.8-beta.6",
35
+ "@airgap/module-kit": "^0.13.8-beta.6",
36
+ "@airgap/serializer": "^0.13.8-beta.6",
37
37
  "@stablelib/ed25519": "1.0.3"
38
38
  },
39
39
  "localDependencies": {},
@@ -1,8 +1,15 @@
1
- import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, ProtocolNetwork } from '@airgap/module-kit';
2
- export declare class AeternityModule implements AirGapModule {
3
- private readonly networkRegistry;
4
- supportedNetworks: Record<string, ProtocolNetwork>;
5
- createOfflineProtocol(): Promise<AirGapOfflineProtocol | undefined>;
6
- createOnlineProtocol(networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
7
- createBlockExplorer(networkId?: string): Promise<AirGapBlockExplorer | undefined>;
1
+ import { MainProtocolSymbols } from '@airgap/coinlib-core';
2
+ import { AirGapBlockExplorer, AirGapModule, AirGapOfflineProtocol, AirGapOnlineProtocol, AirGapV3SerializerCompanion, ProtocolConfiguration } from '@airgap/module-kit';
3
+ declare type SupportedProtocols = MainProtocolSymbols.AE;
4
+ export declare class AeternityModule implements AirGapModule<{
5
+ Protocols: SupportedProtocols;
6
+ }> {
7
+ private readonly networkRegistries;
8
+ readonly supportedProtocols: Record<SupportedProtocols, ProtocolConfiguration>;
9
+ createOfflineProtocol(identifier: SupportedProtocols): Promise<AirGapOfflineProtocol | undefined>;
10
+ createOnlineProtocol(identifier: SupportedProtocols, networkId?: string): Promise<AirGapOnlineProtocol | undefined>;
11
+ createBlockExplorer(identifier: SupportedProtocols, networkId?: string): Promise<AirGapBlockExplorer | undefined>;
12
+ createV3SerializerCompanion(): Promise<AirGapV3SerializerCompanion>;
13
+ private createProtocol;
8
14
  }
15
+ export {};
@@ -42,37 +42,43 @@ var errors_1 = require("@airgap/coinlib-core/errors");
42
42
  var module_kit_1 = require("@airgap/module-kit");
43
43
  var AeternityBlockExplorer_1 = require("../block-explorer/AeternityBlockExplorer");
44
44
  var AeternityProtocol_1 = require("../protocol/AeternityProtocol");
45
+ var serializer_companion_1 = require("../serializer/v3/serializer-companion");
45
46
  var AeternityModule = /** @class */ (function () {
46
47
  function AeternityModule() {
47
- this.networkRegistry = new module_kit_1.ModuleNetworkRegistry({
48
- supportedNetworks: [AeternityProtocol_1.AETERNITY_MAINNET_PROTOCOL_NETWORK]
49
- });
50
- this.supportedNetworks = this.networkRegistry.supportedNetworks;
48
+ var _a;
49
+ this.networkRegistries = (_a = {},
50
+ _a[coinlib_core_1.MainProtocolSymbols.AE] = new module_kit_1.ModuleNetworkRegistry({
51
+ supportedNetworks: [AeternityProtocol_1.AETERNITY_MAINNET_PROTOCOL_NETWORK]
52
+ }),
53
+ _a);
54
+ this.supportedProtocols = (0, module_kit_1.createSupportedProtocols)(this.networkRegistries);
51
55
  }
52
- AeternityModule.prototype.createOfflineProtocol = function () {
56
+ AeternityModule.prototype.createOfflineProtocol = function (identifier) {
53
57
  return __awaiter(this, void 0, void 0, function () {
54
58
  return __generator(this, function (_a) {
55
- return [2 /*return*/, (0, AeternityProtocol_1.createAeternityProtocol)()];
59
+ return [2 /*return*/, this.createProtocol(identifier)];
56
60
  });
57
61
  });
58
62
  };
59
- AeternityModule.prototype.createOnlineProtocol = function (networkId) {
63
+ AeternityModule.prototype.createOnlineProtocol = function (identifier, networkId) {
64
+ var _a;
60
65
  return __awaiter(this, void 0, void 0, function () {
61
66
  var network;
62
- return __generator(this, function (_a) {
63
- network = this.networkRegistry.findNetwork(networkId);
67
+ return __generator(this, function (_b) {
68
+ network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
64
69
  if (network === undefined) {
65
70
  throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Protocol network not supported.');
66
71
  }
67
- return [2 /*return*/, (0, AeternityProtocol_1.createAeternityProtocol)({ network: network })];
72
+ return [2 /*return*/, this.createProtocol(identifier, network)];
68
73
  });
69
74
  });
70
75
  };
71
- AeternityModule.prototype.createBlockExplorer = function (networkId) {
76
+ AeternityModule.prototype.createBlockExplorer = function (identifier, networkId) {
77
+ var _a;
72
78
  return __awaiter(this, void 0, void 0, function () {
73
79
  var network;
74
- return __generator(this, function (_a) {
75
- network = this.networkRegistry.findNetwork(networkId);
80
+ return __generator(this, function (_b) {
81
+ network = (_a = this.networkRegistries[identifier]) === null || _a === void 0 ? void 0 : _a.findNetwork(networkId);
76
82
  if ((network === null || network === void 0 ? void 0 : network.type) !== 'mainnet') {
77
83
  throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, 'Block Explorer network not supported.');
78
84
  }
@@ -80,6 +86,21 @@ var AeternityModule = /** @class */ (function () {
80
86
  });
81
87
  });
82
88
  };
89
+ AeternityModule.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.AeternityV3SerializerCompanion()];
93
+ });
94
+ });
95
+ };
96
+ AeternityModule.prototype.createProtocol = function (identifier, network) {
97
+ switch (identifier) {
98
+ case coinlib_core_1.MainProtocolSymbols.AE:
99
+ return (0, AeternityProtocol_1.createAeternityProtocol)({ network: network });
100
+ default:
101
+ throw new errors_1.ConditionViolationError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported."));
102
+ }
103
+ };
83
104
  return AeternityModule;
84
105
  }());
85
106
  exports.AeternityModule = AeternityModule;
@@ -1 +1 @@
1
- {"version":3,"file":"AeternityModule.js","sourceRoot":"","sources":["../../../src/v1/module/AeternityModule.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;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yB;QAC9E,QAAQ,UAAU,EAAE;YAClB,KAAK,kCAAmB,CAAC,EAAE;gBACzB,OAAO,IAAA,2CAAuB,EAAC,EAAE,OAAO,SAAA,EAAE,CAAC,CAAA;YAC7C;gBACE,MAAM,IAAI,gCAAuB,CAAC,qBAAM,CAAC,SAAS,EAAE,mBAAY,UAAU,oBAAiB,CAAC,CAAA;SAC/F;IACH,CAAC;IACH,sBAAC;AAAD,CAAC,AA1CD,IA0CC;AA1CY,0CAAe"}
@@ -1,9 +1,25 @@
1
1
  "use strict";
2
+ var __rest = (this && this.__rest) || function (s, e) {
3
+ var t = {};
4
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
5
+ t[p] = s[p];
6
+ if (s != null && typeof Object.getOwnPropertySymbols === "function")
7
+ for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
8
+ if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
9
+ t[p[i]] = s[p[i]];
10
+ }
11
+ return t;
12
+ };
2
13
  Object.defineProperty(exports, "__esModule", { value: true });
3
14
  exports.aeternityTransactionSignResponseToSigned = exports.aeternityTransactionSignRequestToUnsigned = exports.aeternitySignedTransactionToResponse = exports.aeternityUnsignedTransactionToRequest = void 0;
4
15
  var module_kit_1 = require("@airgap/module-kit");
5
16
  function aeternityUnsignedTransactionToRequest(unsigned, publicKey, callbackUrl) {
6
- return { transaction: unsigned, publicKey: publicKey, callbackURL: callbackUrl };
17
+ var _ = unsigned.type, rest = __rest(unsigned, ["type"]);
18
+ return {
19
+ transaction: rest,
20
+ publicKey: publicKey,
21
+ callbackURL: callbackUrl
22
+ };
7
23
  }
8
24
  exports.aeternityUnsignedTransactionToRequest = aeternityUnsignedTransactionToRequest;
9
25
  function aeternitySignedTransactionToResponse(signed, accountIdentifier) {
@@ -11,7 +27,7 @@ function aeternitySignedTransactionToResponse(signed, accountIdentifier) {
11
27
  }
12
28
  exports.aeternitySignedTransactionToResponse = aeternitySignedTransactionToResponse;
13
29
  function aeternityTransactionSignRequestToUnsigned(request) {
14
- return request.transaction;
30
+ return (0, module_kit_1.newUnsignedTransaction)(request.transaction);
15
31
  }
16
32
  exports.aeternityTransactionSignRequestToUnsigned = aeternityTransactionSignRequestToUnsigned;
17
33
  function aeternityTransactionSignResponseToSigned(response) {
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;AAAA,iDAAyD;AAKzD,SAAgB,qCAAqC,CACnD,QAAsC,EACtC,SAAiB,EACjB,WAAoB;IAEpB,OAAO,EAAE,WAAW,EAAE,QAAQ,EAAE,SAAS,WAAA,EAAE,WAAW,EAAE,WAAW,EAAE,CAAA;AACvE,CAAC;AAND,sFAMC;AAED,SAAgB,oCAAoC,CAClD,MAAkC,EAClC,iBAAyB;IAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,mBAAA,EAAE,CAAA;AAC/D,CAAC;AALD,oFAKC;AAED,SAAgB,yCAAyC,CAAC,OAAwC;IAChG,OAAO,OAAO,CAAC,WAAW,CAAA;AAC5B,CAAC;AAFD,8FAEC;AAED,SAAgB,wCAAwC,CAAC,QAA0C;IACjG,OAAO,IAAA,iCAAoB,EAA6B,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;AAChG,CAAC;AAFD,4FAEC"}
1
+ {"version":3,"file":"transaction-converter.js","sourceRoot":"","sources":["../../../../../../src/v1/serializer/v3/schemas/converter/transaction-converter.ts"],"names":[],"mappings":";;;;;;;;;;;;;;AAAA,iDAAiF;AAKjF,SAAgB,qCAAqC,CACnD,QAAsC,EACtC,SAAiB,EACjB,WAAoB;IAEZ,IAAM,CAAC,GAAc,QAAQ,KAAtB,EAAK,IAAI,UAAK,QAAQ,EAA/B,QAAoB,CAAF,CAAa;IAErC,OAAO;QACL,WAAW,EAAE,IAAI;QACjB,SAAS,WAAA;QACT,WAAW,EAAE,WAAW;KACzB,CAAA;AACH,CAAC;AAZD,sFAYC;AAED,SAAgB,oCAAoC,CAClD,MAAkC,EAClC,iBAAyB;IAEzB,OAAO,EAAE,WAAW,EAAE,MAAM,CAAC,WAAW,EAAE,iBAAiB,mBAAA,EAAE,CAAA;AAC/D,CAAC;AALD,oFAKC;AAED,SAAgB,yCAAyC,CAAC,OAAwC;IAChG,OAAO,IAAA,mCAAsB,EAA+B,OAAO,CAAC,WAAW,CAAC,CAAA;AAClF,CAAC;AAFD,8FAEC;AAED,SAAgB,wCAAwC,CAAC,QAA0C;IACjG,OAAO,IAAA,iCAAoB,EAA6B,EAAE,WAAW,EAAE,QAAQ,CAAC,WAAW,EAAE,CAAC,CAAA;AAChG,CAAC;AAFD,4FAEC"}
@@ -1,4 +1,4 @@
1
1
  import { TransactionSignRequest } from '@airgap/serializer';
2
2
  import { AeternityUnsignedTransaction } from '../../../../types/transaction';
3
- export interface AeternityTransactionSignRequest extends TransactionSignRequest<AeternityUnsignedTransaction> {
3
+ export interface AeternityTransactionSignRequest extends TransactionSignRequest<Omit<AeternityUnsignedTransaction, 'type'>> {
4
4
  }
@@ -12,28 +12,21 @@
12
12
  "type": "string"
13
13
  },
14
14
  "transaction": {
15
- "$ref": "#/definitions/AeternityUnsignedTransaction"
15
+ "additionalProperties": false,
16
+ "properties": {
17
+ "networkId": {
18
+ "type": "string"
19
+ },
20
+ "transaction": {
21
+ "type": "string"
22
+ }
23
+ },
24
+ "required": ["networkId", "transaction"],
25
+ "type": "object"
16
26
  }
17
27
  },
18
28
  "required": ["publicKey", "transaction"],
19
29
  "type": "object"
20
- },
21
- "AeternityUnsignedTransaction": {
22
- "additionalProperties": false,
23
- "properties": {
24
- "networkId": {
25
- "type": "string"
26
- },
27
- "transaction": {
28
- "type": "string"
29
- },
30
- "type": {
31
- "enum": ["unsigned"],
32
- "type": "string"
33
- }
34
- },
35
- "required": ["networkId", "transaction", "type"],
36
- "type": "object"
37
30
  }
38
31
  }
39
32
  }
@@ -0,0 +1,14 @@
1
+ import { AirGapV3SerializerCompanion, SignedTransaction, UnsignedTransaction } from '@airgap/module-kit';
2
+ import { V3SchemaConfiguration } from '@airgap/module-kit/types/serializer';
3
+ import { TransactionSignRequest, TransactionSignResponse } from '@airgap/serializer';
4
+ export declare class AeternityV3SerializerCompanion implements AirGapV3SerializerCompanion {
5
+ readonly schemas: V3SchemaConfiguration[];
6
+ private readonly aeternityTransactionValidator;
7
+ constructor();
8
+ toTransactionSignRequest(identifier: string, unsignedTransaction: UnsignedTransaction, publicKey: string, callbackUrl?: string): Promise<TransactionSignRequest>;
9
+ fromTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<UnsignedTransaction>;
10
+ validateTransactionSignRequest(identifier: string, transactionSignRequest: TransactionSignRequest): Promise<boolean>;
11
+ toTransactionSignResponse(identifier: string, signedTransaction: SignedTransaction, accountIdentifier: string): Promise<TransactionSignResponse>;
12
+ fromTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<SignedTransaction>;
13
+ validateTransactionSignResponse(identifier: string, transactionSignResponse: TransactionSignResponse): Promise<boolean>;
14
+ }
@@ -0,0 +1,173 @@
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.AeternityV3SerializerCompanion = void 0;
40
+ var coinlib_core_1 = require("@airgap/coinlib-core");
41
+ var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
42
+ var errors_1 = require("@airgap/coinlib-core/errors");
43
+ var serializer_1 = require("@airgap/serializer");
44
+ var transaction_converter_1 = require("./schemas/converter/transaction-converter");
45
+ var transaction_validator_1 = require("./validators/transaction-validator");
46
+ var validators_1 = require("./validators/validators");
47
+ var aeternityTransactionSignRequest = require('./schemas/generated/transaction-sign-request-aeternity.json');
48
+ var aeternityTransactionSignResponse = require('./schemas/generated/transaction-sign-response-aeternity.json');
49
+ var AeternityV3SerializerCompanion = /** @class */ (function () {
50
+ function AeternityV3SerializerCompanion() {
51
+ this.schemas = [
52
+ {
53
+ type: serializer_1.IACMessageType.TransactionSignRequest,
54
+ schema: { schema: aeternityTransactionSignRequest },
55
+ protocolIdentifier: coinlib_core_1.MainProtocolSymbols.AE
56
+ },
57
+ {
58
+ type: serializer_1.IACMessageType.TransactionSignResponse,
59
+ schema: { schema: aeternityTransactionSignResponse },
60
+ protocolIdentifier: coinlib_core_1.MainProtocolSymbols.AE
61
+ }
62
+ ];
63
+ this.aeternityTransactionValidator = new transaction_validator_1.AeternityTransactionValidator();
64
+ Object.keys(validators_1.aeternityValidators).forEach(function (key) {
65
+ validate_1.validators[key] = validators_1.aeternityValidators[key];
66
+ });
67
+ }
68
+ AeternityV3SerializerCompanion.prototype.toTransactionSignRequest = function (identifier, unsignedTransaction, publicKey, callbackUrl) {
69
+ return __awaiter(this, void 0, void 0, function () {
70
+ return __generator(this, function (_a) {
71
+ switch (identifier) {
72
+ case coinlib_core_1.MainProtocolSymbols.AE:
73
+ return [2 /*return*/, (0, transaction_converter_1.aeternityUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
74
+ default:
75
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported"));
76
+ }
77
+ return [2 /*return*/];
78
+ });
79
+ });
80
+ };
81
+ AeternityV3SerializerCompanion.prototype.fromTransactionSignRequest = function (identifier, transactionSignRequest) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ return __generator(this, function (_a) {
84
+ switch (identifier) {
85
+ case coinlib_core_1.MainProtocolSymbols.AE:
86
+ return [2 /*return*/, (0, transaction_converter_1.aeternityTransactionSignRequestToUnsigned)(transactionSignRequest)];
87
+ default:
88
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported"));
89
+ }
90
+ return [2 /*return*/];
91
+ });
92
+ });
93
+ };
94
+ AeternityV3SerializerCompanion.prototype.validateTransactionSignRequest = function (identifier, transactionSignRequest) {
95
+ return __awaiter(this, void 0, void 0, function () {
96
+ var _a, _b;
97
+ return __generator(this, function (_c) {
98
+ switch (_c.label) {
99
+ case 0:
100
+ _a = identifier;
101
+ switch (_a) {
102
+ case coinlib_core_1.MainProtocolSymbols.AE: return [3 /*break*/, 1];
103
+ }
104
+ return [3 /*break*/, 4];
105
+ case 1:
106
+ _c.trys.push([1, 3, , 4]);
107
+ return [4 /*yield*/, this.aeternityTransactionValidator.validateUnsignedTransaction(transactionSignRequest)];
108
+ case 2:
109
+ _c.sent();
110
+ return [2 /*return*/, true];
111
+ case 3:
112
+ _b = _c.sent();
113
+ return [2 /*return*/, false];
114
+ case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported"));
115
+ }
116
+ });
117
+ });
118
+ };
119
+ AeternityV3SerializerCompanion.prototype.toTransactionSignResponse = function (identifier, signedTransaction, accountIdentifier) {
120
+ return __awaiter(this, void 0, void 0, function () {
121
+ return __generator(this, function (_a) {
122
+ switch (identifier) {
123
+ case coinlib_core_1.MainProtocolSymbols.AE:
124
+ return [2 /*return*/, (0, transaction_converter_1.aeternitySignedTransactionToResponse)(signedTransaction, accountIdentifier)];
125
+ default:
126
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported"));
127
+ }
128
+ return [2 /*return*/];
129
+ });
130
+ });
131
+ };
132
+ AeternityV3SerializerCompanion.prototype.fromTransactionSignResponse = function (identifier, transactionSignResponse) {
133
+ return __awaiter(this, void 0, void 0, function () {
134
+ return __generator(this, function (_a) {
135
+ switch (identifier) {
136
+ case coinlib_core_1.MainProtocolSymbols.AE:
137
+ return [2 /*return*/, (0, transaction_converter_1.aeternityTransactionSignResponseToSigned)(transactionSignResponse)];
138
+ default:
139
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported"));
140
+ }
141
+ return [2 /*return*/];
142
+ });
143
+ });
144
+ };
145
+ AeternityV3SerializerCompanion.prototype.validateTransactionSignResponse = function (identifier, transactionSignResponse) {
146
+ return __awaiter(this, void 0, void 0, function () {
147
+ var _a, _b;
148
+ return __generator(this, function (_c) {
149
+ switch (_c.label) {
150
+ case 0:
151
+ _a = identifier;
152
+ switch (_a) {
153
+ case coinlib_core_1.MainProtocolSymbols.AE: return [3 /*break*/, 1];
154
+ }
155
+ return [3 /*break*/, 4];
156
+ case 1:
157
+ _c.trys.push([1, 3, , 4]);
158
+ return [4 /*yield*/, this.aeternityTransactionValidator.validateSignedTransaction(transactionSignResponse)];
159
+ case 2:
160
+ _c.sent();
161
+ return [2 /*return*/, true];
162
+ case 3:
163
+ _b = _c.sent();
164
+ return [2 /*return*/, false];
165
+ case 4: throw new errors_1.UnsupportedError(coinlib_core_1.Domain.AETERNITY, "Protocol ".concat(identifier, " not supported"));
166
+ }
167
+ });
168
+ });
169
+ };
170
+ return AeternityV3SerializerCompanion;
171
+ }());
172
+ exports.AeternityV3SerializerCompanion = AeternityV3SerializerCompanion;
173
+ //# 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,qDAAkE;AAClE,8FAA8F;AAC9F,sDAA8D;AAG9D,iDAAgH;AAIhH,mFAKkD;AAClD,4EAAkF;AAClF,sDAA6D;AAE7D,IAAM,+BAA+B,GAAe,OAAO,CAAC,6DAA6D,CAAC,CAAA;AAC1H,IAAM,gCAAgC,GAAe,OAAO,CAAC,8DAA8D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BAAO,KAAK,EAAA;4BAGd,MAAM,IAAI,yBAAgB,CAAC,qBAAM,CAAC,SAAS,EAAE,mBAAY,UAAU,mBAAgB,CAAC,CAAA;;;;KAEzF;IACH,qCAAC;AAAD,CAAC,AAtGD,IAsGC;AAtGY,wEAA8B"}
@@ -1,10 +1,7 @@
1
- import { TransactionValidator, TransactionValidatorFactory } from '@airgap/serializer';
1
+ import { TransactionValidator } from '@airgap/serializer';
2
2
  import { AeternityTransactionSignRequest } from '../schemas/definitions/transaction-sign-request-aeternity';
3
3
  import { AeternityTransactionSignResponse } from '../schemas/definitions/transaction-sign-response-aeternity';
4
4
  export declare class AeternityTransactionValidator implements TransactionValidator {
5
5
  validateUnsignedTransaction(request: AeternityTransactionSignRequest): Promise<any>;
6
6
  validateSignedTransaction(response: AeternityTransactionSignResponse): Promise<any>;
7
7
  }
8
- export declare class AeternityTransactionValidatorFactory implements TransactionValidatorFactory<AeternityTransactionValidator> {
9
- create(): AeternityTransactionValidator;
10
- }
@@ -36,7 +36,7 @@ var __generator = (this && this.__generator) || function (thisArg, body) {
36
36
  }
37
37
  };
38
38
  Object.defineProperty(exports, "__esModule", { value: true });
39
- exports.AeternityTransactionValidatorFactory = exports.AeternityTransactionValidator = void 0;
39
+ exports.AeternityTransactionValidator = void 0;
40
40
  // tslint:disable: max-classes-per-file
41
41
  var validate_1 = require("@airgap/coinlib-core/dependencies/src/validate.js-0.13.1/validate");
42
42
  var serializer_1 = require("@airgap/serializer");
@@ -88,13 +88,4 @@ var AeternityTransactionValidator = /** @class */ (function () {
88
88
  return AeternityTransactionValidator;
89
89
  }());
90
90
  exports.AeternityTransactionValidator = AeternityTransactionValidator;
91
- var AeternityTransactionValidatorFactory = /** @class */ (function () {
92
- function AeternityTransactionValidatorFactory() {
93
- }
94
- AeternityTransactionValidatorFactory.prototype.create = function () {
95
- return new AeternityTransactionValidator();
96
- };
97
- return AeternityTransactionValidatorFactory;
98
- }());
99
- exports.AeternityTransactionValidatorFactory = AeternityTransactionValidatorFactory;
100
91
  //# sourceMappingURL=transaction-validator.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,iDAA0G;AAM1G,IAAM,8BAA8B,GAAG;IACrC,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,kBAAkB,EAAE,IAAI;KACzB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;CACF,CAAA;AACD,IAAM,4BAA4B,GAAG;IACnC,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,kBAAkB,EAAE,IAAI;KACzB;IACD,iBAAiB,EAAE;QACjB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;KACf;CACF,CAAA;AACD,IAAM,OAAO,GAAG,cAAM,OAAA,SAAS,EAAT,CAAS,CAAA;AAC/B,IAAM,KAAK,GAAG,UAAC,MAAM,IAAK,OAAA,MAAM,EAAN,CAAM,CAAA;AAEhC;IAAA;IAUA,CAAC;IATc,mEAA2B,GAAxC,UAAyC,OAAwC;;;;gBACzE,WAAW,GAAiC,OAAO,CAAC,WAAW,CAAA;gBACrE,IAAA,+BAAkB,EAAC,EAAE,CAAC,CAAA;gBAEtB,sBAAO,IAAA,gBAAK,EAAC,WAAW,EAAE,8BAA8B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAA;;;KAC/E;IACY,iEAAyB,GAAtC,UAAuC,QAA0C;;;gBAC/E,sBAAO,IAAA,gBAAK,EAAC,QAAQ,EAAE,4BAA4B,CAAC,CAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,EAAA;;;KAC1E;IACH,oCAAC;AAAD,CAAC,AAVD,IAUC;AAVY,sEAA6B;AAY1C;IAAA;IAIA,CAAC;IAHQ,qDAAM,GAAb;QACE,OAAO,IAAI,6BAA6B,EAAE,CAAA;IAC5C,CAAC;IACH,2CAAC;AAAD,CAAC,AAJD,IAIC;AAJY,oFAAoC"}
1
+ {"version":3,"file":"transaction-validator.js","sourceRoot":"","sources":["../../../../../src/v1/serializer/v3/validators/transaction-validator.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,uCAAuC;AACvC,8FAAyF;AACzF,iDAA6E;AAK7E,IAAM,8BAA8B,GAAG;IACrC,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,kBAAkB,EAAE,IAAI;KACzB;IACD,SAAS,EAAE;QACT,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,SAAS,EAAE,IAAI;KAChB;CACF,CAAA;AACD,IAAM,4BAA4B,GAAG;IACnC,WAAW,EAAE;QACX,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;QACd,kBAAkB,EAAE,IAAI;KACzB;IACD,iBAAiB,EAAE;QACjB,QAAQ,EAAE,EAAE,UAAU,EAAE,KAAK,EAAE;QAC/B,IAAI,EAAE,QAAQ;KACf;CACF,CAAA;AACD,IAAM,OAAO,GAAG,cAAM,OAAA,SAAS,EAAT,CAAS,CAAA;AAC/B,IAAM,KAAK,GAAG,UAAC,MAAM,IAAK,OAAA,MAAM,EAAN,CAAM,CAAA;AAEhC;IAAA;IAUA,CAAC;IATc,mEAA2B,GAAxC,UAAyC,OAAwC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