@wallfree-dev/cosmos 0.13.42

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/LICENSE.md +7 -0
  2. package/index.d.ts +1 -0
  3. package/index.js +18 -0
  4. package/index.js.map +1 -0
  5. package/package.json +62 -0
  6. package/readme.md +121 -0
  7. package/v0/index.d.ts +10 -0
  8. package/v0/index.js +32 -0
  9. package/v0/index.js.map +1 -0
  10. package/v0/protocol/CosmosAddress.d.ts +8 -0
  11. package/v0/protocol/CosmosAddress.js +28 -0
  12. package/v0/protocol/CosmosAddress.js.map +1 -0
  13. package/v0/protocol/CosmosCoin.d.ts +19 -0
  14. package/v0/protocol/CosmosCoin.js +55 -0
  15. package/v0/protocol/CosmosCoin.js.map +1 -0
  16. package/v0/protocol/CosmosCryptoClient.d.ts +8 -0
  17. package/v0/protocol/CosmosCryptoClient.js +90 -0
  18. package/v0/protocol/CosmosCryptoClient.js.map +1 -0
  19. package/v0/protocol/CosmosFee.d.ts +15 -0
  20. package/v0/protocol/CosmosFee.js +31 -0
  21. package/v0/protocol/CosmosFee.js.map +1 -0
  22. package/v0/protocol/CosmosNodeClient.d.ts +25 -0
  23. package/v0/protocol/CosmosNodeClient.js +382 -0
  24. package/v0/protocol/CosmosNodeClient.js.map +1 -0
  25. package/v0/protocol/CosmosProtocol.d.ts +125 -0
  26. package/v0/protocol/CosmosProtocol.js +1162 -0
  27. package/v0/protocol/CosmosProtocol.js.map +1 -0
  28. package/v0/protocol/CosmosProtocolOptions.d.ts +22 -0
  29. package/v0/protocol/CosmosProtocolOptions.js +116 -0
  30. package/v0/protocol/CosmosProtocolOptions.js.map +1 -0
  31. package/v0/protocol/CosmosTransaction.d.ts +37 -0
  32. package/v0/protocol/CosmosTransaction.js +106 -0
  33. package/v0/protocol/CosmosTransaction.js.map +1 -0
  34. package/v0/protocol/CosmosTypes.d.ts +310 -0
  35. package/v0/protocol/CosmosTypes.js +8 -0
  36. package/v0/protocol/CosmosTypes.js.map +1 -0
  37. package/v0/protocol/cosmos-message/CosmosDelegateMessage.d.ts +20 -0
  38. package/v0/protocol/cosmos-message/CosmosDelegateMessage.js +72 -0
  39. package/v0/protocol/cosmos-message/CosmosDelegateMessage.js.map +1 -0
  40. package/v0/protocol/cosmos-message/CosmosMessage.d.ts +39 -0
  41. package/v0/protocol/cosmos-message/CosmosMessage.js +47 -0
  42. package/v0/protocol/cosmos-message/CosmosMessage.js.map +1 -0
  43. package/v0/protocol/cosmos-message/CosmosSendMessage.d.ts +20 -0
  44. package/v0/protocol/cosmos-message/CosmosSendMessage.js +85 -0
  45. package/v0/protocol/cosmos-message/CosmosSendMessage.js.map +1 -0
  46. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.d.ts +24 -0
  47. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js +61 -0
  48. package/v0/protocol/cosmos-message/CosmosWithdrawDelegationRewardMessage.js.map +1 -0
  49. package/v0/serializer/schemas/v2/transaction-sign-request-cosmos.json +100 -0
  50. package/v0/serializer/schemas/v2/transaction-sign-response-cosmos.json +22 -0
  51. package/v0/serializer/schemas/v3/transaction-sign-request-cosmos.json +100 -0
  52. package/v0/serializer/schemas/v3/transaction-sign-response-cosmos.json +23 -0
  53. package/v0/serializer/validators/transaction-validator.d.ts +15 -0
  54. package/v0/serializer/validators/transaction-validator.js +112 -0
  55. package/v0/serializer/validators/transaction-validator.js.map +1 -0
  56. package/v0/types/signed-transaction-cosmos.d.ts +5 -0
  57. package/v0/types/signed-transaction-cosmos.js +3 -0
  58. package/v0/types/signed-transaction-cosmos.js.map +1 -0
  59. package/v0/types/transaction-cosmos.d.ts +5 -0
  60. package/v0/types/transaction-cosmos.js +3 -0
  61. package/v0/types/transaction-cosmos.js.map +1 -0
  62. package/v0/types/unsigned-transaction-cosmos.d.ts +33 -0
  63. package/v0/types/unsigned-transaction-cosmos.js +10 -0
  64. package/v0/types/unsigned-transaction-cosmos.js.map +1 -0
  65. package/v1/block-explorer/MintscanBlockExplorer.d.ts +9 -0
  66. package/v1/block-explorer/MintscanBlockExplorer.js +72 -0
  67. package/v1/block-explorer/MintscanBlockExplorer.js.map +1 -0
  68. package/v1/index.d.ts +6 -0
  69. package/v1/index.js +11 -0
  70. package/v1/index.js.map +1 -0
  71. package/v1/module/CosmosModule.d.ts +17 -0
  72. package/v1/module/CosmosModule.js +107 -0
  73. package/v1/module/CosmosModule.js.map +1 -0
  74. package/v1/module.d.ts +3 -0
  75. package/v1/module.js +24 -0
  76. package/v1/module.js.map +1 -0
  77. package/v1/protocol/CosmosProtocol.d.ts +16 -0
  78. package/v1/protocol/CosmosProtocol.js +162 -0
  79. package/v1/protocol/CosmosProtocol.js.map +1 -0
  80. package/v1/serializer/v3/serializer-companion.d.ts +12 -0
  81. package/v1/serializer/v3/serializer-companion.js +142 -0
  82. package/v1/serializer/v3/serializer-companion.js.map +1 -0
@@ -0,0 +1,162 @@
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.createCosmosProtocolOptions = exports.COSMOS_MAINNET_PROTOCOL_NETWORK = exports.createCosmosProtocol = exports.CosmosProtocolImpl = void 0;
66
+ var coinlib_core_1 = require("@wallfree-dev/coinlib-core");
67
+ var module_kit_1 = require("@wallfree-dev/module-kit");
68
+ var cosmos_core_1 = require("@wallfree-dev/cosmos-core");
69
+ // Implementation
70
+ var DEFAULT_GAS = (0, module_kit_1.newAmount)('600000', 'blockchain');
71
+ var CosmosProtocolImpl = /** @class */ (function (_super) {
72
+ __extends(CosmosProtocolImpl, _super);
73
+ function CosmosProtocolImpl(options) {
74
+ if (options === void 0) { options = {}; }
75
+ var _this = this;
76
+ var fullOptions = createCosmosProtocolOptions(options);
77
+ _this = _super.call(this, fullOptions) || this;
78
+ // Common
79
+ _this.units = {
80
+ atom: {
81
+ symbol: { value: 'ATOM', market: 'atom' },
82
+ decimals: 6
83
+ },
84
+ uatom: {
85
+ symbol: { value: 'uATOM' },
86
+ decimals: 0
87
+ }
88
+ };
89
+ _this.feeDefaults = {
90
+ low: (0, module_kit_1.newAmount)(0.0025, 'atom').blockchain(_this.units),
91
+ medium: (0, module_kit_1.newAmount)(0.005, 'atom').blockchain(_this.units),
92
+ high: (0, module_kit_1.newAmount)(0.01, 'atom').blockchain(_this.units)
93
+ };
94
+ _this.metadata = {
95
+ identifier: coinlib_core_1.MainProtocolSymbols.COSMOS,
96
+ name: 'Cosmos',
97
+ units: _this.units,
98
+ mainUnit: 'atom',
99
+ fee: {
100
+ defaults: _this.feeDefaults
101
+ },
102
+ account: {
103
+ standardDerivationPath: "m/44'/118'/0'/0/0",
104
+ address: {
105
+ isCaseSensitive: false,
106
+ placeholder: 'cosmos...',
107
+ regex: '^(cosmos|cosmosvaloper)[a-zA-Z0-9]{39}$'
108
+ }
109
+ },
110
+ transaction: {
111
+ arbitraryData: {
112
+ name: 'memo'
113
+ }
114
+ }
115
+ };
116
+ return _this;
117
+ }
118
+ CosmosProtocolImpl.prototype.getMetadata = function () {
119
+ return __awaiter(this, void 0, void 0, function () {
120
+ return __generator(this, function (_a) {
121
+ return [2 /*return*/, this.metadata];
122
+ });
123
+ });
124
+ };
125
+ CosmosProtocolImpl.prototype.getTransactionFeeWithPublicKey = function (_publicKey, _details, _configuration) {
126
+ return __awaiter(this, void 0, void 0, function () {
127
+ return __generator(this, function (_a) {
128
+ return [2 /*return*/, this.feeDefaults];
129
+ });
130
+ });
131
+ };
132
+ return CosmosProtocolImpl;
133
+ }(cosmos_core_1.CosmosBaseProtocolImpl));
134
+ exports.CosmosProtocolImpl = CosmosProtocolImpl;
135
+ // Factory
136
+ function createCosmosProtocol(options) {
137
+ if (options === void 0) { options = {}; }
138
+ return new CosmosProtocolImpl(options);
139
+ }
140
+ exports.createCosmosProtocol = createCosmosProtocol;
141
+ exports.COSMOS_MAINNET_PROTOCOL_NETWORK = {
142
+ name: 'Mainnet',
143
+ type: 'mainnet',
144
+ rpcUrl: 'https://kusama-rpc.publicnode.com',
145
+ blockExplorerUrl: 'https://www.mintscan.io'
146
+ };
147
+ var DEFAULT_COSMOS_PROTOCOL_NETWORK = exports.COSMOS_MAINNET_PROTOCOL_NETWORK;
148
+ function createCosmosProtocolOptions(partialOptions) {
149
+ var _a, _b, _c, _d, _e, _f;
150
+ if (partialOptions === void 0) { partialOptions = {}; }
151
+ return {
152
+ network: __assign(__assign({}, DEFAULT_COSMOS_PROTOCOL_NETWORK), partialOptions.network),
153
+ addressPrefix: (_a = partialOptions.addressPrefix) !== null && _a !== void 0 ? _a : 'cosmos',
154
+ baseUnit: (_b = partialOptions.baseUnit) !== null && _b !== void 0 ? _b : 'uatom',
155
+ defaultGas: {
156
+ value: (_d = (_c = partialOptions.defaultGas) === null || _c === void 0 ? void 0 : _c.value) !== null && _d !== void 0 ? _d : DEFAULT_GAS.value,
157
+ unit: (_f = (_e = partialOptions.defaultGas) === null || _e === void 0 ? void 0 : _e.unit) !== null && _f !== void 0 ? _f : DEFAULT_GAS.unit
158
+ }
159
+ };
160
+ }
161
+ exports.createCosmosProtocolOptions = createCosmosProtocolOptions;
162
+ //# sourceMappingURL=CosmosProtocol.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CosmosProtocol.js","sourceRoot":"","sources":["../../../src/v1/protocol/CosmosProtocol.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,2DAAgE;AAChE,uDAUiC;AAEjC,yDAA2I;AAI3I,iBAAiB;AACjB,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;QAGpB,SAAS;QAEQ,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,MAAM,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,KAAI,CAAC,KAAK,CAAC;YACrD,MAAM,EAAE,IAAA,sBAAS,EAAC,KAAK,EAAE,MAAM,CAAC,CAAC,UAAU,CAAC,KAAI,CAAC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AAA,mBAAyE;IAEzE,OAAO;QACL,OAAO,wBAAO,+BAA+B,GAAK,cAAc,CAAC,OAAO,CAAE;QAC1E,aAAa,EAAE,MAAA,cAAc,CAAC,aAAa,mCAAI,QAAQ;QACvD,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 CosmosV3SerializerCompanion 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.CosmosV3SerializerCompanion = 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 CosmosV3SerializerCompanion = /** @class */ (function () {
47
+ function CosmosV3SerializerCompanion() {
48
+ this.schemas = [
49
+ {
50
+ type: serializer_1.IACMessageType.TransactionSignRequest,
51
+ schema: { schema: cosmosTransactionSignRequest },
52
+ protocolIdentifier: coinlib_core_1.MainProtocolSymbols.COSMOS
53
+ },
54
+ {
55
+ type: serializer_1.IACMessageType.TransactionSignResponse,
56
+ schema: { schema: cosmosTransactionSignResponse },
57
+ protocolIdentifier: coinlib_core_1.MainProtocolSymbols.COSMOS
58
+ }
59
+ ];
60
+ }
61
+ CosmosV3SerializerCompanion.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.COSMOS:
66
+ return [2 /*return*/, (0, cosmos_core_1.cosmosUnsignedTransactionToRequest)(unsignedTransaction, publicKey, callbackUrl)];
67
+ default:
68
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, "Protocol ".concat(identifier, " not supported"));
69
+ }
70
+ return [2 /*return*/];
71
+ });
72
+ });
73
+ };
74
+ CosmosV3SerializerCompanion.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.COSMOS:
79
+ return [2 /*return*/, (0, cosmos_core_1.cosmosTransactionSignRequestToUnsigned)(transactionSignRequest)];
80
+ default:
81
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, "Protocol ".concat(identifier, " not supported"));
82
+ }
83
+ return [2 /*return*/];
84
+ });
85
+ });
86
+ };
87
+ CosmosV3SerializerCompanion.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.COSMOS:
92
+ return [2 /*return*/, true];
93
+ default:
94
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, "Protocol ".concat(identifier, " not supported"));
95
+ }
96
+ return [2 /*return*/];
97
+ });
98
+ });
99
+ };
100
+ CosmosV3SerializerCompanion.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.COSMOS:
105
+ return [2 /*return*/, (0, cosmos_core_1.cosmosSignedTransactionToResponse)(signedTransaction, accountIdentifier)];
106
+ default:
107
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, "Protocol ".concat(identifier, " not supported"));
108
+ }
109
+ return [2 /*return*/];
110
+ });
111
+ });
112
+ };
113
+ CosmosV3SerializerCompanion.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.COSMOS:
118
+ return [2 /*return*/, (0, cosmos_core_1.cosmosTransactionSignResponseToSigned)(transactionSignResponse)];
119
+ default:
120
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, "Protocol ".concat(identifier, " not supported"));
121
+ }
122
+ return [2 /*return*/];
123
+ });
124
+ });
125
+ };
126
+ CosmosV3SerializerCompanion.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.COSMOS:
131
+ return [2 /*return*/, true];
132
+ default:
133
+ throw new errors_1.UnsupportedError(coinlib_core_1.Domain.COSMOS, "Protocol ".concat(identifier, " not supported"));
134
+ }
135
+ return [2 /*return*/];
136
+ });
137
+ });
138
+ };
139
+ return CosmosV3SerializerCompanion;
140
+ }());
141
+ exports.CosmosV3SerializerCompanion = CosmosV3SerializerCompanion;
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,kCAAmB,CAAC,MAAM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