@orb-labs/orby-core 0.0.4 → 0.0.6

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 (35) hide show
  1. package/dist/actions/account_cluster.d.ts +1 -1
  2. package/dist/actions/account_cluster.js +316 -158
  3. package/dist/actions/admin.js +115 -46
  4. package/dist/actions/application.js +68 -20
  5. package/dist/actions/instance.js +237 -113
  6. package/dist/actions/operation.js +242 -110
  7. package/dist/actions/token.js +107 -41
  8. package/dist/constants.js +92 -97
  9. package/dist/entities/account.js +26 -28
  10. package/dist/entities/financial/account_balance.js +22 -24
  11. package/dist/entities/financial/asset.js +15 -17
  12. package/dist/entities/financial/currency.js +37 -25
  13. package/dist/entities/financial/currency_amount.js +79 -64
  14. package/dist/entities/financial/fungible_token.js +49 -34
  15. package/dist/entities/financial/fungible_token_amount.js +85 -70
  16. package/dist/entities/financial/non_fungible_token.js +45 -30
  17. package/dist/entities/financial/semi_fungible_token.js +45 -30
  18. package/dist/entities/library_request.js +19 -24
  19. package/dist/entities/state.js +67 -60
  20. package/dist/enums.js +34 -37
  21. package/dist/index.js +27 -43
  22. package/dist/interfaces/account_cluster.d.ts +1 -1
  23. package/dist/interfaces/account_cluster.js +1 -2
  24. package/dist/interfaces/admin.js +1 -2
  25. package/dist/interfaces/application.js +1 -2
  26. package/dist/interfaces/instance.js +1 -2
  27. package/dist/interfaces/operation.js +1 -2
  28. package/dist/interfaces/orby.js +1 -2
  29. package/dist/interfaces/token.js +1 -2
  30. package/dist/tsconfig.tsbuildinfo +1 -0
  31. package/dist/types.js +1 -2
  32. package/dist/utils/action_helpers.js +99 -109
  33. package/dist/utils/utils.js +24 -32
  34. package/dist/utils/validateAndParseAddress.js +7 -11
  35. package/package.json +1 -1
@@ -1,4 +1,18 @@
1
- "use strict";
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
2
16
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
17
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
18
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,126 +22,244 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
23
  });
10
24
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.OperationActions = void 0;
13
- const action_helpers_1 = require("../utils/action_helpers");
14
- const currency_amount_1 = require("../entities/financial/currency_amount");
15
- const library_request_1 = require("../entities/library_request");
16
- class OperationActions extends library_request_1.LibraryRequest {
17
- constructor(library, client, provider) {
18
- super(library, client, provider);
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ 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;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
19
50
  }
20
- getOperationsToExecuteTransaction(accountClusterId, to, data, value, gasToken) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const operationSet = yield this.sendRequest("orby_getOperationsToExecuteTransaction", [{ accountClusterId, to, data, value, gasToken }]);
23
- return (0, action_helpers_1.extractOperationSet)(operationSet);
24
- });
51
+ };
52
+ import { extractOperationSet, extractOperationStatuses, } from "../utils/action_helpers";
53
+ import { CurrencyAmount } from "../entities/financial/currency_amount";
54
+ import { LibraryRequest } from "../entities/library_request";
55
+ var OperationActions = /** @class */ (function (_super) {
56
+ __extends(OperationActions, _super);
57
+ function OperationActions(library, client, provider) {
58
+ return _super.call(this, library, client, provider) || this;
25
59
  }
26
- getOperationsToSignTypedData(accountClusterId, data) {
27
- return __awaiter(this, void 0, void 0, function* () {
28
- const operationSet = yield this.sendRequest("orby_getOperationsToSignTypedData", [{ accountClusterId, data }]);
29
- return (0, action_helpers_1.extractOperationSet)(operationSet);
60
+ OperationActions.prototype.getOperationsToExecuteTransaction = function (accountClusterId, to, data, value, gasToken) {
61
+ return __awaiter(this, void 0, void 0, function () {
62
+ var operationSet;
63
+ return __generator(this, function (_a) {
64
+ switch (_a.label) {
65
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOperationsToExecuteTransaction", [{ accountClusterId: accountClusterId, to: to, data: data, value: value, gasToken: gasToken }])];
66
+ case 1:
67
+ operationSet = _a.sent();
68
+ return [2 /*return*/, extractOperationSet(operationSet)];
69
+ }
70
+ });
30
71
  });
31
- }
32
- getOperationsToCancelTransaction(accountClusterId, operationSetId) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const operationSet = yield this.sendRequest("orby_getOperationsToCancelTransaction", [{ accountClusterId, operationSetId }]);
35
- return (0, action_helpers_1.extractOperationSet)(operationSet);
72
+ };
73
+ OperationActions.prototype.getOperationsToSignTypedData = function (accountClusterId, data) {
74
+ return __awaiter(this, void 0, void 0, function () {
75
+ var operationSet;
76
+ return __generator(this, function (_a) {
77
+ switch (_a.label) {
78
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOperationsToSignTypedData", [{ accountClusterId: accountClusterId, data: data }])];
79
+ case 1:
80
+ operationSet = _a.sent();
81
+ return [2 /*return*/, extractOperationSet(operationSet)];
82
+ }
83
+ });
36
84
  });
37
- }
38
- isTransactionPreconditionSatisfied(accountClusterId, to, data, value) {
39
- return __awaiter(this, void 0, void 0, function* () {
40
- const { satisfied } = yield this.sendRequest("orby_isTransactionPreconditionSatisfied", [{ accountClusterId, to, data, value }]);
41
- return satisfied;
85
+ };
86
+ OperationActions.prototype.getOperationsToCancelTransaction = function (accountClusterId, operationSetId) {
87
+ return __awaiter(this, void 0, void 0, function () {
88
+ var operationSet;
89
+ return __generator(this, function (_a) {
90
+ switch (_a.label) {
91
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOperationsToCancelTransaction", [{ accountClusterId: accountClusterId, operationSetId: operationSetId }])];
92
+ case 1:
93
+ operationSet = _a.sent();
94
+ return [2 /*return*/, extractOperationSet(operationSet)];
95
+ }
96
+ });
42
97
  });
43
- }
44
- isTypedDataPreconditionSatisfied(accountClusterId, data) {
45
- return __awaiter(this, void 0, void 0, function* () {
46
- const { satisfied, code, message } = yield this.sendRequest("orby_isTypedDataPreconditionSatisfied", [{ accountClusterId, data }]);
47
- if (code && message) {
48
- console.error("[isTypedDataPreconditionSatisfied]", code, message);
49
- return undefined;
50
- }
51
- return satisfied;
98
+ };
99
+ OperationActions.prototype.isTransactionPreconditionSatisfied = function (accountClusterId, to, data, value) {
100
+ return __awaiter(this, void 0, void 0, function () {
101
+ var satisfied;
102
+ return __generator(this, function (_a) {
103
+ switch (_a.label) {
104
+ case 0: return [4 /*yield*/, this.sendRequest("orby_isTransactionPreconditionSatisfied", [{ accountClusterId: accountClusterId, to: to, data: data, value: value }])];
105
+ case 1:
106
+ satisfied = (_a.sent()).satisfied;
107
+ return [2 /*return*/, satisfied];
108
+ }
109
+ });
52
110
  });
53
- }
54
- sendSignedOperations(accountClusterId, signedOperations) {
55
- return __awaiter(this, void 0, void 0, function* () {
56
- const { operationSetId, operationResponses, code, message } = yield this.sendRequest("orby_sendSignedOperations", [
57
- { accountClusterId, signedOperations },
58
- ]);
59
- if (code && message) {
60
- console.error("[sendSignedOperations]", code, message);
61
- return undefined;
62
- }
63
- return {
64
- operationSetId,
65
- operationResponses: (0, action_helpers_1.extractOperationStatuses)(operationResponses),
66
- };
111
+ };
112
+ OperationActions.prototype.isTypedDataPreconditionSatisfied = function (accountClusterId, data) {
113
+ return __awaiter(this, void 0, void 0, function () {
114
+ var _a, satisfied, code, message;
115
+ return __generator(this, function (_b) {
116
+ switch (_b.label) {
117
+ case 0: return [4 /*yield*/, this.sendRequest("orby_isTypedDataPreconditionSatisfied", [{ accountClusterId: accountClusterId, data: data }])];
118
+ case 1:
119
+ _a = _b.sent(), satisfied = _a.satisfied, code = _a.code, message = _a.message;
120
+ if (code && message) {
121
+ console.error("[isTypedDataPreconditionSatisfied]", code, message);
122
+ return [2 /*return*/, undefined];
123
+ }
124
+ return [2 /*return*/, satisfied];
125
+ }
126
+ });
67
127
  });
68
- }
69
- getOperationStatuses(operationIds) {
70
- return __awaiter(this, void 0, void 0, function* () {
71
- const { operationStatuses } = yield this.sendRequest("orby_getOperationStatuses", [{ operationIds }]);
72
- return (0, action_helpers_1.extractOperationStatuses)(operationStatuses);
128
+ };
129
+ OperationActions.prototype.sendSignedOperations = function (accountClusterId, signedOperations) {
130
+ return __awaiter(this, void 0, void 0, function () {
131
+ var _a, operationSetId, operationResponses, code, message;
132
+ return __generator(this, function (_b) {
133
+ switch (_b.label) {
134
+ case 0: return [4 /*yield*/, this.sendRequest("orby_sendSignedOperations", [
135
+ { accountClusterId: accountClusterId, signedOperations: signedOperations },
136
+ ])];
137
+ case 1:
138
+ _a = _b.sent(), operationSetId = _a.operationSetId, operationResponses = _a.operationResponses, code = _a.code, message = _a.message;
139
+ if (code && message) {
140
+ console.error("[sendSignedOperations]", code, message);
141
+ return [2 /*return*/, undefined];
142
+ }
143
+ return [2 /*return*/, {
144
+ operationSetId: operationSetId,
145
+ operationResponses: extractOperationStatuses(operationResponses),
146
+ }];
147
+ }
148
+ });
73
149
  });
74
- }
75
- estimateFiatCostToExecuteTransaction(to, data, value) {
76
- return __awaiter(this, void 0, void 0, function* () {
77
- const { estimatedCost, code, message } = yield this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [{ to, data, value }]);
78
- if (code && message) {
79
- console.error("[estimateFiatCostToExecuteTransaction]", code, message);
80
- return undefined;
81
- }
82
- return currency_amount_1.CurrencyAmount.toCurrencyAmount(estimatedCost);
150
+ };
151
+ OperationActions.prototype.getOperationStatuses = function (operationIds) {
152
+ return __awaiter(this, void 0, void 0, function () {
153
+ var operationStatuses;
154
+ return __generator(this, function (_a) {
155
+ switch (_a.label) {
156
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOperationStatuses", [{ operationIds: operationIds }])];
157
+ case 1:
158
+ operationStatuses = (_a.sent()).operationStatuses;
159
+ return [2 /*return*/, extractOperationStatuses(operationStatuses)];
160
+ }
161
+ });
83
162
  });
84
- }
85
- estimateFiatCostToSignTypedData(data) {
86
- return __awaiter(this, void 0, void 0, function* () {
87
- const { estimatedCost, code, message } = yield this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data }]);
88
- if (code && message) {
89
- console.error("[estimateFiatCostToSignTypedData]", code, message);
90
- return undefined;
91
- }
92
- return currency_amount_1.CurrencyAmount.toCurrencyAmount(estimatedCost);
163
+ };
164
+ OperationActions.prototype.estimateFiatCostToExecuteTransaction = function (to, data, value) {
165
+ return __awaiter(this, void 0, void 0, function () {
166
+ var _a, estimatedCost, code, message;
167
+ return __generator(this, function (_b) {
168
+ switch (_b.label) {
169
+ case 0: return [4 /*yield*/, this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [{ to: to, data: data, value: value }])];
170
+ case 1:
171
+ _a = _b.sent(), estimatedCost = _a.estimatedCost, code = _a.code, message = _a.message;
172
+ if (code && message) {
173
+ console.error("[estimateFiatCostToExecuteTransaction]", code, message);
174
+ return [2 /*return*/, undefined];
175
+ }
176
+ return [2 /*return*/, CurrencyAmount.toCurrencyAmount(estimatedCost)];
177
+ }
178
+ });
93
179
  });
94
- }
95
- getOperationsToTransferToken(accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
96
- return __awaiter(this, void 0, void 0, function* () {
97
- const operationSet = yield this.sendRequest("orby_getOperationsToTransferToken", [{ accountClusterId, standardizedTokenId, amount, recipient, gasToken }]);
98
- return (0, action_helpers_1.extractOperationSet)(operationSet);
180
+ };
181
+ OperationActions.prototype.estimateFiatCostToSignTypedData = function (data) {
182
+ return __awaiter(this, void 0, void 0, function () {
183
+ var _a, estimatedCost, code, message;
184
+ return __generator(this, function (_b) {
185
+ switch (_b.label) {
186
+ case 0: return [4 /*yield*/, this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data: data }])];
187
+ case 1:
188
+ _a = _b.sent(), estimatedCost = _a.estimatedCost, code = _a.code, message = _a.message;
189
+ if (code && message) {
190
+ console.error("[estimateFiatCostToSignTypedData]", code, message);
191
+ return [2 /*return*/, undefined];
192
+ }
193
+ return [2 /*return*/, CurrencyAmount.toCurrencyAmount(estimatedCost)];
194
+ }
195
+ });
99
196
  });
100
- }
101
- getOperationsToSwap(accountClusterId, swapType, input, output, gasToken) {
102
- return __awaiter(this, void 0, void 0, function* () {
103
- const operationSet = yield this.sendRequest("orby_getOperationsToSwap", [
104
- { accountClusterId, swapType, input, output, gasToken },
105
- ]);
106
- return (0, action_helpers_1.extractOperationSet)(operationSet);
197
+ };
198
+ OperationActions.prototype.getOperationsToTransferToken = function (accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
199
+ return __awaiter(this, void 0, void 0, function () {
200
+ var operationSet;
201
+ return __generator(this, function (_a) {
202
+ switch (_a.label) {
203
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOperationsToTransferToken", [{ accountClusterId: accountClusterId, standardizedTokenId: standardizedTokenId, amount: amount, recipient: recipient, gasToken: gasToken }])];
204
+ case 1:
205
+ operationSet = _a.sent();
206
+ return [2 /*return*/, extractOperationSet(operationSet)];
207
+ }
208
+ });
107
209
  });
108
- }
109
- getQuote(accountClusterId, swapType, input, output) {
110
- return __awaiter(this, void 0, void 0, function* () {
111
- const operationSet = yield this.sendRequest("orby_getQuote", [
112
- { accountClusterId, swapType, input, output },
113
- ]);
114
- return (0, action_helpers_1.extractOperationSet)(operationSet);
210
+ };
211
+ OperationActions.prototype.getOperationsToSwap = function (accountClusterId, swapType, input, output, gasToken) {
212
+ return __awaiter(this, void 0, void 0, function () {
213
+ var operationSet;
214
+ return __generator(this, function (_a) {
215
+ switch (_a.label) {
216
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOperationsToSwap", [
217
+ { accountClusterId: accountClusterId, swapType: swapType, input: input, output: output, gasToken: gasToken },
218
+ ])];
219
+ case 1:
220
+ operationSet = _a.sent();
221
+ return [2 /*return*/, extractOperationSet(operationSet)];
222
+ }
223
+ });
115
224
  });
116
- }
117
- getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
118
- return __awaiter(this, void 0, void 0, function* () {
119
- const operationSet = yield this.sendRequest("orby_getOperationsToBridge", [
120
- {
121
- accountClusterId,
122
- standardizedTokenId,
123
- amount,
124
- tokenSources,
125
- tokenDestination,
126
- gasToken,
127
- },
128
- ]);
129
- return (0, action_helpers_1.extractOperationSet)(operationSet);
225
+ };
226
+ OperationActions.prototype.getQuote = function (accountClusterId, swapType, input, output) {
227
+ return __awaiter(this, void 0, void 0, function () {
228
+ var operationSet;
229
+ return __generator(this, function (_a) {
230
+ switch (_a.label) {
231
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getQuote", [
232
+ { accountClusterId: accountClusterId, swapType: swapType, input: input, output: output },
233
+ ])];
234
+ case 1:
235
+ operationSet = _a.sent();
236
+ return [2 /*return*/, extractOperationSet(operationSet)];
237
+ }
238
+ });
130
239
  });
131
- }
132
- }
133
- exports.OperationActions = OperationActions;
240
+ };
241
+ OperationActions.prototype.getOperationsToBridge = function (accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
242
+ return __awaiter(this, void 0, void 0, function () {
243
+ var operationSet;
244
+ return __generator(this, function (_a) {
245
+ switch (_a.label) {
246
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOperationsToBridge", [
247
+ {
248
+ accountClusterId: accountClusterId,
249
+ standardizedTokenId: standardizedTokenId,
250
+ amount: amount,
251
+ tokenSources: tokenSources,
252
+ tokenDestination: tokenDestination,
253
+ gasToken: gasToken,
254
+ },
255
+ ])];
256
+ case 1:
257
+ operationSet = _a.sent();
258
+ return [2 /*return*/, extractOperationSet(operationSet)];
259
+ }
260
+ });
261
+ });
262
+ };
263
+ return OperationActions;
264
+ }(LibraryRequest));
265
+ export { OperationActions };
@@ -1,4 +1,18 @@
1
- "use strict";
1
+ var __extends = (this && this.__extends) || (function () {
2
+ var extendStatics = function (d, b) {
3
+ extendStatics = Object.setPrototypeOf ||
4
+ ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
5
+ function (d, b) { for (var p in b) if (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
6
+ return extendStatics(d, b);
7
+ };
8
+ return function (d, b) {
9
+ if (typeof b !== "function" && b !== null)
10
+ throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
11
+ extendStatics(d, b);
12
+ function __() { this.constructor = d; }
13
+ d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
14
+ };
15
+ })();
2
16
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
17
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
18
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,49 +22,101 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
22
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
23
  });
10
24
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.TokenActions = void 0;
13
- const action_helpers_1 = require("../utils/action_helpers");
14
- const library_request_1 = require("../entities/library_request");
15
- class TokenActions extends library_request_1.LibraryRequest {
16
- constructor(library, client, provider) {
17
- super(library, client, provider);
25
+ var __generator = (this && this.__generator) || function (thisArg, body) {
26
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
27
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
28
+ function verb(n) { return function (v) { return step([n, v]); }; }
29
+ function step(op) {
30
+ if (f) throw new TypeError("Generator is already executing.");
31
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
32
+ 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;
33
+ if (y = 0, t) op = [op[0] & 2, t.value];
34
+ switch (op[0]) {
35
+ case 0: case 1: t = op; break;
36
+ case 4: _.label++; return { value: op[1], done: false };
37
+ case 5: _.label++; y = op[1]; op = [0]; continue;
38
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
39
+ default:
40
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
41
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
42
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
43
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
44
+ if (t[2]) _.ops.pop();
45
+ _.trys.pop(); continue;
46
+ }
47
+ op = body.call(thisArg, _);
48
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
49
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
50
+ }
51
+ };
52
+ import { extractStandardizedToken, extractStandardizedTokens, } from "../utils/action_helpers";
53
+ import { LibraryRequest } from "../entities/library_request";
54
+ var TokenActions = /** @class */ (function (_super) {
55
+ __extends(TokenActions, _super);
56
+ function TokenActions(library, client, provider) {
57
+ return _super.call(this, library, client, provider) || this;
18
58
  }
19
- getStandardizedTokenIds(tokens) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
22
- return { chainId: `EIP155-${chainId}`, tokenAddress };
59
+ TokenActions.prototype.getStandardizedTokenIds = function (tokens) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ var formattedTokensInfo, _a, standardizedTokenIds, message, code;
62
+ return __generator(this, function (_b) {
63
+ switch (_b.label) {
64
+ case 0:
65
+ formattedTokensInfo = tokens.map(function (_a) {
66
+ var tokenAddress = _a.tokenAddress, chainId = _a.chainId;
67
+ return { chainId: "EIP155-".concat(chainId), tokenAddress: tokenAddress };
68
+ });
69
+ return [4 /*yield*/, this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }])];
70
+ case 1:
71
+ _a = _b.sent(), standardizedTokenIds = _a.standardizedTokenIds, message = _a.message, code = _a.code;
72
+ if (code && message) {
73
+ console.error("[getStandardizedTokenIds]", code, message);
74
+ return [2 /*return*/, undefined];
75
+ }
76
+ return [2 /*return*/, standardizedTokenIds];
77
+ }
23
78
  });
24
- const { standardizedTokenIds, message, code } = yield this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }]);
25
- if (code && message) {
26
- console.error("[getStandardizedTokenIds]", code, message);
27
- return undefined;
28
- }
29
- return standardizedTokenIds;
30
79
  });
31
- }
32
- getStandardizedTokens(tokens) {
33
- return __awaiter(this, void 0, void 0, function* () {
34
- const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
35
- return { chainId: `EIP155-${chainId}`, tokenAddress };
80
+ };
81
+ TokenActions.prototype.getStandardizedTokens = function (tokens) {
82
+ return __awaiter(this, void 0, void 0, function () {
83
+ var formattedTokensInfo, _a, standardizedTokens, message, code;
84
+ return __generator(this, function (_b) {
85
+ switch (_b.label) {
86
+ case 0:
87
+ formattedTokensInfo = tokens.map(function (_a) {
88
+ var tokenAddress = _a.tokenAddress, chainId = _a.chainId;
89
+ return { chainId: "EIP155-".concat(chainId), tokenAddress: tokenAddress };
90
+ });
91
+ return [4 /*yield*/, this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }])];
92
+ case 1:
93
+ _a = _b.sent(), standardizedTokens = _a.standardizedTokens, message = _a.message, code = _a.code;
94
+ if (code && message) {
95
+ console.error("[getStandardizedTokens]", code, message);
96
+ return [2 /*return*/, undefined];
97
+ }
98
+ return [2 /*return*/, extractStandardizedTokens(standardizedTokens)];
99
+ }
36
100
  });
37
- const { standardizedTokens, message, code } = yield this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }]);
38
- if (code && message) {
39
- console.error("[getStandardizedTokens]", code, message);
40
- return undefined;
41
- }
42
- return (0, action_helpers_1.extractStandardizedTokens)(standardizedTokens);
43
101
  });
44
- }
45
- getFungibleTokenData(standardizedTokenIds) {
46
- return __awaiter(this, void 0, void 0, function* () {
47
- const { data, message, code } = yield this.sendRequest("orby_getFungibleTokenData", [{ standardizedTokenIds }]);
48
- if (code && message) {
49
- console.error("[getFungibleTokenData]", code, message);
50
- return undefined;
51
- }
52
- return (0, action_helpers_1.extractStandardizedToken)(data);
102
+ };
103
+ TokenActions.prototype.getFungibleTokenData = function (standardizedTokenIds) {
104
+ return __awaiter(this, void 0, void 0, function () {
105
+ var _a, data, message, code;
106
+ return __generator(this, function (_b) {
107
+ switch (_b.label) {
108
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getFungibleTokenData", [{ standardizedTokenIds: standardizedTokenIds }])];
109
+ case 1:
110
+ _a = _b.sent(), data = _a.data, message = _a.message, code = _a.code;
111
+ if (code && message) {
112
+ console.error("[getFungibleTokenData]", code, message);
113
+ return [2 /*return*/, undefined];
114
+ }
115
+ return [2 /*return*/, extractStandardizedToken(data)];
116
+ }
117
+ });
53
118
  });
54
- }
55
- }
56
- exports.TokenActions = TokenActions;
119
+ };
120
+ return TokenActions;
121
+ }(LibraryRequest));
122
+ export { TokenActions };