@orb-labs/orby-core 0.0.3 → 0.0.5

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 (43) hide show
  1. package/README.md +42 -1
  2. package/dist/actions/account_cluster.d.ts +1 -1
  3. package/dist/actions/account_cluster.js +308 -121
  4. package/dist/actions/admin.js +115 -28
  5. package/dist/actions/application.js +68 -14
  6. package/dist/actions/instance.js +237 -72
  7. package/dist/actions/operation.d.ts +12 -6
  8. package/dist/actions/operation.js +242 -90
  9. package/dist/actions/token.js +107 -31
  10. package/dist/constants.d.ts +8 -0
  11. package/dist/constants.js +132 -36
  12. package/dist/entities/account.js +26 -28
  13. package/dist/entities/financial/account_balance.js +22 -24
  14. package/dist/entities/financial/asset.js +15 -17
  15. package/dist/entities/financial/currency.js +37 -25
  16. package/dist/entities/financial/currency_amount.js +79 -64
  17. package/dist/entities/financial/fungible_token.js +49 -34
  18. package/dist/entities/financial/fungible_token_amount.js +85 -70
  19. package/dist/entities/financial/non_fungible_token.js +45 -30
  20. package/dist/entities/financial/semi_fungible_token.js +45 -30
  21. package/dist/entities/library_request.js +19 -24
  22. package/dist/entities/state.js +67 -60
  23. package/dist/enums.js +34 -37
  24. package/dist/index.d.ts +1 -3
  25. package/dist/index.js +27 -46
  26. package/dist/interfaces/account_cluster.d.ts +1 -1
  27. package/dist/interfaces/account_cluster.js +1 -2
  28. package/dist/interfaces/admin.js +1 -2
  29. package/dist/interfaces/application.js +1 -2
  30. package/dist/interfaces/instance.js +1 -2
  31. package/dist/interfaces/operation.d.ts +5 -5
  32. package/dist/interfaces/operation.js +1 -2
  33. package/dist/interfaces/orby.js +1 -2
  34. package/dist/interfaces/token.js +1 -2
  35. package/dist/tsconfig.tsbuildinfo +1 -0
  36. package/dist/types.d.ts +4 -0
  37. package/dist/types.js +1 -2
  38. package/dist/utils/action_helpers.d.ts +22 -0
  39. package/dist/utils/action_helpers.js +270 -0
  40. package/dist/utils/utils.d.ts +5 -22
  41. package/dist/utils/utils.js +30 -279
  42. package/dist/utils/validateAndParseAddress.js +7 -11
  43. package/package.json +6 -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,106 +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 utils_1 = require("../utils/utils");
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) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const { operationSet } = yield this.sendRequest("orby_getOperationsToExecuteTransaction", [{ accountClusterId, to, data, value }]);
23
- return (0, utils_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, utils_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 { cancellationOperationSet } = yield this.sendRequest("orby_getOperationsToCancelTransaction", [{ accountClusterId, operationSetId }]);
35
- return (0, utils_1.extractOperationSet)(cancellationOperationSet);
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 } = yield this.sendRequest("orby_isTypedDataPreconditionSatisfied", [{ accountClusterId, data }]);
47
- 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
+ });
48
110
  });
49
- }
50
- sendSignedOperations(accountClusterId, signedOperations) {
51
- return __awaiter(this, void 0, void 0, function* () {
52
- const { operationSetId, operationResponses } = yield this.sendRequest("orby_sendSignedOperations", [{ accountClusterId, signedOperations }]);
53
- return {
54
- operationSetId,
55
- operationResponses: (0, utils_1.extractOperationStatuses)(operationResponses),
56
- };
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
+ });
57
127
  });
58
- }
59
- getOperationStatuses(operationIds) {
60
- return __awaiter(this, void 0, void 0, function* () {
61
- const { operationStatuses } = yield this.sendRequest("orby_getOperationStatuses", [{ operationIds }]);
62
- return (0, utils_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
+ });
63
149
  });
64
- }
65
- estimateFiatCostToExecuteTransaction(to, data, value) {
66
- return __awaiter(this, void 0, void 0, function* () {
67
- const { estimatedCost } = yield this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [{ to, data, value }]);
68
- 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
+ });
69
162
  });
70
- }
71
- estimateFiatCostToSignTypedData(data) {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const { estimatedCost } = yield this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data }]);
74
- 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
+ });
75
179
  });
76
- }
77
- getOperationsToTransferToken(accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
78
- return __awaiter(this, void 0, void 0, function* () {
79
- const { operationSet } = yield this.sendRequest("orby_getOperationsToTransferToken", [{ accountClusterId, standardizedTokenId, amount, recipient, gasToken }]);
80
- return (0, utils_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
+ });
81
196
  });
82
- }
83
- getOperationsToSwap(accountClusterId, swapType, input, output, gasToken) {
84
- return __awaiter(this, void 0, void 0, function* () {
85
- const { operationSet } = yield this.sendRequest("orby_getOperationsToSwap", [{ accountClusterId, swapType, input, output, gasToken }]);
86
- return (0, utils_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
+ });
87
209
  });
88
- }
89
- getQuote(accountClusterId, swapType, input, output) {
90
- return __awaiter(this, void 0, void 0, function* () {
91
- const { operationSet } = yield this.sendRequest("orby_getQuote", [
92
- { accountClusterId, swapType, input, output },
93
- ]);
94
- return (0, utils_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
+ });
95
224
  });
96
- }
97
- getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
98
- return __awaiter(this, void 0, void 0, function* () {
99
- const { operationSet } = yield this.sendRequest("orby_getOperationsToBridge", [
100
- {
101
- accountClusterId,
102
- standardizedTokenId,
103
- amount,
104
- tokenSources,
105
- tokenDestination,
106
- gasToken,
107
- },
108
- ]);
109
- return (0, utils_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
+ });
110
239
  });
111
- }
112
- }
113
- 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,39 +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 utils_1 = require("../utils/utils");
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 };
18
50
  }
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 };
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;
58
+ }
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 } = yield this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }]);
25
- return standardizedTokenIds;
26
79
  });
27
- }
28
- getStandardizedTokens(tokens) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
31
- 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
+ }
32
100
  });
33
- const { standardizedTokens } = yield this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }]);
34
- return (0, utils_1.extractStandardizedTokens)(standardizedTokens);
35
101
  });
36
- }
37
- getFungibleTokenData(standardizedTokenIds) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const { data } = yield this.sendRequest("orby_getFungibleTokenData", [
40
- { standardizedTokenIds },
41
- ]);
42
- return (0, utils_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
+ });
43
118
  });
44
- }
45
- }
46
- exports.TokenActions = TokenActions;
119
+ };
120
+ return TokenActions;
121
+ }(LibraryRequest));
122
+ export { TokenActions };
@@ -1,6 +1,14 @@
1
+ import { Blockchain } from "./enums";
1
2
  import { Currency } from "./entities/financial/currency";
3
+ import { ChainConfigs } from "./types";
2
4
  export declare const Big: any;
3
5
  export declare const BLOCKCHAIN_ID: {
4
6
  [s: string]: number;
5
7
  };
8
+ export declare const CHAIN_CONFIGS: {
9
+ [s: string]: ChainConfigs;
10
+ };
11
+ export declare const BLOCKCHAIN_ID_TO_BLOCKCHAIN: {
12
+ [s: number]: Blockchain;
13
+ };
6
14
  export declare const FIAT_CURRENCY: Currency;