@orb-labs/orby-core 0.0.4 → 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 (33) hide show
  1. package/dist/actions/account_cluster.js +308 -158
  2. package/dist/actions/admin.js +115 -46
  3. package/dist/actions/application.js +68 -20
  4. package/dist/actions/instance.js +237 -113
  5. package/dist/actions/operation.js +242 -110
  6. package/dist/actions/token.js +107 -41
  7. package/dist/constants.js +92 -97
  8. package/dist/entities/account.js +26 -28
  9. package/dist/entities/financial/account_balance.js +22 -24
  10. package/dist/entities/financial/asset.js +15 -17
  11. package/dist/entities/financial/currency.js +37 -25
  12. package/dist/entities/financial/currency_amount.js +79 -64
  13. package/dist/entities/financial/fungible_token.js +49 -34
  14. package/dist/entities/financial/fungible_token_amount.js +85 -70
  15. package/dist/entities/financial/non_fungible_token.js +45 -30
  16. package/dist/entities/financial/semi_fungible_token.js +45 -30
  17. package/dist/entities/library_request.js +19 -24
  18. package/dist/entities/state.js +67 -60
  19. package/dist/enums.js +34 -37
  20. package/dist/index.js +27 -43
  21. package/dist/interfaces/account_cluster.js +1 -2
  22. package/dist/interfaces/admin.js +1 -2
  23. package/dist/interfaces/application.js +1 -2
  24. package/dist/interfaces/instance.js +1 -2
  25. package/dist/interfaces/operation.js +1 -2
  26. package/dist/interfaces/orby.js +1 -2
  27. package/dist/interfaces/token.js +1 -2
  28. package/dist/tsconfig.tsbuildinfo +1 -0
  29. package/dist/types.js +1 -2
  30. package/dist/utils/action_helpers.js +99 -109
  31. package/dist/utils/utils.js +24 -32
  32. package/dist/utils/validateAndParseAddress.js +7 -11
  33. package/package.json +1 -1
@@ -1,4 +1,29 @@
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
+ })();
16
+ var __assign = (this && this.__assign) || function () {
17
+ __assign = Object.assign || function(t) {
18
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
19
+ s = arguments[i];
20
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
21
+ t[p] = s[p];
22
+ }
23
+ return t;
24
+ };
25
+ return __assign.apply(this, arguments);
26
+ };
2
27
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
28
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
29
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -8,128 +33,227 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
8
33
  step((generator = generator.apply(thisArg, _arguments || [])).next());
9
34
  });
10
35
  };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.InstanceActions = void 0;
13
- const action_helpers_1 = require("../utils/action_helpers");
14
- const library_request_1 = require("../entities/library_request");
15
- const utils_1 = require("../utils/utils");
16
- class InstanceActions extends library_request_1.LibraryRequest {
17
- constructor(library, client, provider) {
18
- super(library, client, provider);
36
+ var __generator = (this && this.__generator) || function (thisArg, body) {
37
+ 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);
38
+ return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
39
+ function verb(n) { return function (v) { return step([n, v]); }; }
40
+ function step(op) {
41
+ if (f) throw new TypeError("Generator is already executing.");
42
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
43
+ 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;
44
+ if (y = 0, t) op = [op[0] & 2, t.value];
45
+ switch (op[0]) {
46
+ case 0: case 1: t = op; break;
47
+ case 4: _.label++; return { value: op[1], done: false };
48
+ case 5: _.label++; y = op[1]; op = [0]; continue;
49
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
50
+ default:
51
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
52
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
53
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
54
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
55
+ if (t[2]) _.ops.pop();
56
+ _.trys.pop(); continue;
57
+ }
58
+ op = body.call(thisArg, _);
59
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
60
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
61
+ }
62
+ };
63
+ import { extractBlockchainInformations, extractGasSponsorshipPolicy, } from "../utils/action_helpers";
64
+ import { LibraryRequest } from "../entities/library_request";
65
+ import { getChainIdFromOrbyChainId } from "../utils/utils";
66
+ var InstanceActions = /** @class */ (function (_super) {
67
+ __extends(InstanceActions, _super);
68
+ function InstanceActions(library, client, provider) {
69
+ return _super.call(this, library, client, provider) || this;
19
70
  }
20
- setCustomChainEndpointsForInstance(chainEndpoints) {
21
- return __awaiter(this, void 0, void 0, function* () {
22
- const formattedEndpoints = chainEndpoints.map((endpoint) => {
23
- return {
24
- chainId: `EIP155-${endpoint.chainId}`,
25
- customRpcUrls: endpoint.customRpcUrls,
26
- customIndexerUrls: endpoint.customIndexerUrls,
27
- };
71
+ InstanceActions.prototype.setCustomChainEndpointsForInstance = function (chainEndpoints) {
72
+ return __awaiter(this, void 0, void 0, function () {
73
+ var formattedEndpoints, _a, success, code, message;
74
+ return __generator(this, function (_b) {
75
+ switch (_b.label) {
76
+ case 0:
77
+ formattedEndpoints = chainEndpoints.map(function (endpoint) {
78
+ return {
79
+ chainId: "EIP155-".concat(endpoint.chainId),
80
+ customRpcUrls: endpoint.customRpcUrls,
81
+ customIndexerUrls: endpoint.customIndexerUrls,
82
+ };
83
+ });
84
+ return [4 /*yield*/, this.sendRequest("orby_setCustomChainEndpointsForInstance", [{ chainEndpoints: formattedEndpoints }])];
85
+ case 1:
86
+ _a = _b.sent(), success = _a.success, code = _a.code, message = _a.message;
87
+ if (code && message) {
88
+ console.error("[setCustomChainEndpointsForInstance]", code, message);
89
+ return [2 /*return*/, undefined];
90
+ }
91
+ return [2 /*return*/, success];
92
+ }
28
93
  });
29
- const { success, code, message } = yield this.sendRequest("orby_setCustomChainEndpointsForInstance", [{ chainEndpoints: formattedEndpoints }]);
30
- if (code && message) {
31
- console.error("[setCustomChainEndpointsForInstance]", code, message);
32
- return undefined;
33
- }
34
- return success;
35
94
  });
36
- }
37
- removeCustomChainEndpointForInstance(chainIds) {
38
- return __awaiter(this, void 0, void 0, function* () {
39
- const formattedChainIds = chainIds.map((chainId) => `EIP155-${chainId}`);
40
- const { success, code, message } = yield this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
41
- if (code && message) {
42
- console.error("[removeCustomChainEndpointForInstance]", code, message);
43
- return undefined;
44
- }
45
- return success;
95
+ };
96
+ InstanceActions.prototype.removeCustomChainEndpointForInstance = function (chainIds) {
97
+ return __awaiter(this, void 0, void 0, function () {
98
+ var formattedChainIds, _a, success, code, message;
99
+ return __generator(this, function (_b) {
100
+ switch (_b.label) {
101
+ case 0:
102
+ formattedChainIds = chainIds.map(function (chainId) { return "EIP155-".concat(chainId); });
103
+ return [4 /*yield*/, this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }])];
104
+ case 1:
105
+ _a = _b.sent(), success = _a.success, code = _a.code, message = _a.message;
106
+ if (code && message) {
107
+ console.error("[removeCustomChainEndpointForInstance]", code, message);
108
+ return [2 /*return*/, undefined];
109
+ }
110
+ return [2 /*return*/, success];
111
+ }
112
+ });
46
113
  });
47
- }
48
- getCustomChainEndpointsForInstance(returnChainIdsOnly) {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const { chainEndpoints, code, message } = yield this.sendRequest("orby_getCustomChainEndpointsForInstance", [{ returnChainIdsOnly }]);
51
- if (code && message) {
52
- console.error("[getCustomChainEndpointsForInstance]", code, message);
53
- return undefined;
54
- }
55
- return chainEndpoints.map((endpoint) => {
56
- return {
57
- chainId: (0, utils_1.getChainIdFromOrbyChainId)(endpoint.chainId),
58
- customRpcUrls: endpoint.customRpcUrls,
59
- customIndexerUrls: endpoint.customIndexerUrls,
60
- };
114
+ };
115
+ InstanceActions.prototype.getCustomChainEndpointsForInstance = function (returnChainIdsOnly) {
116
+ return __awaiter(this, void 0, void 0, function () {
117
+ var _a, chainEndpoints, code, message;
118
+ return __generator(this, function (_b) {
119
+ switch (_b.label) {
120
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getCustomChainEndpointsForInstance", [{ returnChainIdsOnly: returnChainIdsOnly }])];
121
+ case 1:
122
+ _a = _b.sent(), chainEndpoints = _a.chainEndpoints, code = _a.code, message = _a.message;
123
+ if (code && message) {
124
+ console.error("[getCustomChainEndpointsForInstance]", code, message);
125
+ return [2 /*return*/, undefined];
126
+ }
127
+ return [2 /*return*/, chainEndpoints.map(function (endpoint) {
128
+ return {
129
+ chainId: getChainIdFromOrbyChainId(endpoint.chainId),
130
+ customRpcUrls: endpoint.customRpcUrls,
131
+ customIndexerUrls: endpoint.customIndexerUrls,
132
+ };
133
+ })];
134
+ }
61
135
  });
62
136
  });
63
- }
64
- getChainsSupportedByDefault() {
65
- return __awaiter(this, void 0, void 0, function* () {
66
- const { supportedChains, code, message } = yield this.sendRequest("orby_getChainsSupportedByDefault", [{}]);
67
- if (code && message) {
68
- console.error("[getChainsSupportedByDefault]", code, message);
69
- return undefined;
70
- }
71
- return (0, action_helpers_1.extractBlockchainInformations)(supportedChains);
137
+ };
138
+ InstanceActions.prototype.getChainsSupportedByDefault = function () {
139
+ return __awaiter(this, void 0, void 0, function () {
140
+ var _a, supportedChains, code, message;
141
+ return __generator(this, function (_b) {
142
+ switch (_b.label) {
143
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getChainsSupportedByDefault", [{}])];
144
+ case 1:
145
+ _a = _b.sent(), supportedChains = _a.supportedChains, code = _a.code, message = _a.message;
146
+ if (code && message) {
147
+ console.error("[getChainsSupportedByDefault]", code, message);
148
+ return [2 /*return*/, undefined];
149
+ }
150
+ return [2 /*return*/, extractBlockchainInformations(supportedChains)];
151
+ }
152
+ });
72
153
  });
73
- }
74
- enabledChainAbstractionForInstance(enable) {
75
- return __awaiter(this, void 0, void 0, function* () {
76
- const { success, code, message } = yield this.sendRequest("orby_enabledChainAbstractionForInstance", [{ enable }]);
77
- if (code && message) {
78
- console.error("[enabledChainAbstractionForInstance]", code, message);
79
- return undefined;
80
- }
81
- return success;
154
+ };
155
+ InstanceActions.prototype.enabledChainAbstractionForInstance = function (enable) {
156
+ return __awaiter(this, void 0, void 0, function () {
157
+ var _a, success, code, message;
158
+ return __generator(this, function (_b) {
159
+ switch (_b.label) {
160
+ case 0: return [4 /*yield*/, this.sendRequest("orby_enabledChainAbstractionForInstance", [{ enable: enable }])];
161
+ case 1:
162
+ _a = _b.sent(), success = _a.success, code = _a.code, message = _a.message;
163
+ if (code && message) {
164
+ console.error("[enabledChainAbstractionForInstance]", code, message);
165
+ return [2 /*return*/, undefined];
166
+ }
167
+ return [2 /*return*/, success];
168
+ }
169
+ });
82
170
  });
83
- }
84
- enableGasSponsorshipForInstance(enable) {
85
- return __awaiter(this, void 0, void 0, function* () {
86
- const { success, code, message } = yield this.sendRequest("orby_enableGasSponsorshipForInstance", [{ enable }]);
87
- if (code && message) {
88
- console.error("[enableGasSponsorshipForInstance]", code, message);
89
- return undefined;
90
- }
91
- return success;
171
+ };
172
+ InstanceActions.prototype.enableGasSponsorshipForInstance = function (enable) {
173
+ return __awaiter(this, void 0, void 0, function () {
174
+ var _a, success, code, message;
175
+ return __generator(this, function (_b) {
176
+ switch (_b.label) {
177
+ case 0: return [4 /*yield*/, this.sendRequest("orby_enableGasSponsorshipForInstance", [{ enable: enable }])];
178
+ case 1:
179
+ _a = _b.sent(), success = _a.success, code = _a.code, message = _a.message;
180
+ if (code && message) {
181
+ console.error("[enableGasSponsorshipForInstance]", code, message);
182
+ return [2 /*return*/, undefined];
183
+ }
184
+ return [2 /*return*/, success];
185
+ }
186
+ });
92
187
  });
93
- }
94
- getGasSponsorForInstance() {
95
- return __awaiter(this, void 0, void 0, function* () {
96
- const { gasSponsor, code, message } = yield this.sendRequest("orby_getGasSponsorForInstance", [{}]);
97
- if (code && message) {
98
- console.error("[getGasSponsorForInstance]", code, message);
99
- return undefined;
100
- }
101
- return gasSponsor;
188
+ };
189
+ InstanceActions.prototype.getGasSponsorForInstance = function () {
190
+ return __awaiter(this, void 0, void 0, function () {
191
+ var _a, gasSponsor, code, message;
192
+ return __generator(this, function (_b) {
193
+ switch (_b.label) {
194
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getGasSponsorForInstance", [{}])];
195
+ case 1:
196
+ _a = _b.sent(), gasSponsor = _a.gasSponsor, code = _a.code, message = _a.message;
197
+ if (code && message) {
198
+ console.error("[getGasSponsorForInstance]", code, message);
199
+ return [2 /*return*/, undefined];
200
+ }
201
+ return [2 /*return*/, gasSponsor];
202
+ }
203
+ });
102
204
  });
103
- }
104
- getOrbyGasSponsorPolicyForInstance() {
105
- return __awaiter(this, void 0, void 0, function* () {
106
- const { gasSponsorshipPolicy, message, code } = yield this.sendRequest("orby_getOrbyGasSponsorPolicyForInstance", [{}]);
107
- if (code && message) {
108
- console.error("[getOrbyGasSponsorPolicyForInstance]", code, message);
109
- return undefined;
110
- }
111
- return (0, action_helpers_1.extractGasSponsorshipPolicy)(gasSponsorshipPolicy);
205
+ };
206
+ InstanceActions.prototype.getOrbyGasSponsorPolicyForInstance = function () {
207
+ return __awaiter(this, void 0, void 0, function () {
208
+ var _a, gasSponsorshipPolicy, message, code;
209
+ return __generator(this, function (_b) {
210
+ switch (_b.label) {
211
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getOrbyGasSponsorPolicyForInstance", [{}])];
212
+ case 1:
213
+ _a = _b.sent(), gasSponsorshipPolicy = _a.gasSponsorshipPolicy, message = _a.message, code = _a.code;
214
+ if (code && message) {
215
+ console.error("[getOrbyGasSponsorPolicyForInstance]", code, message);
216
+ return [2 /*return*/, undefined];
217
+ }
218
+ return [2 /*return*/, extractGasSponsorshipPolicy(gasSponsorshipPolicy)];
219
+ }
220
+ });
112
221
  });
113
- }
114
- setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy) {
115
- return __awaiter(this, void 0, void 0, function* () {
116
- const { success, code, message } = yield this.sendRequest("orby_setOrbyGasSponsorPolicyForInstance", [Object.assign({}, gasSponsorshipPolicy)]);
117
- if (code && message) {
118
- console.error("[setOrbyGasSponsorPolicyForInstance]", code, message);
119
- return undefined;
120
- }
121
- return success;
222
+ };
223
+ InstanceActions.prototype.setOrbyGasSponsorPolicyForInstance = function (gasSponsorshipPolicy) {
224
+ return __awaiter(this, void 0, void 0, function () {
225
+ var _a, success, code, message;
226
+ return __generator(this, function (_b) {
227
+ switch (_b.label) {
228
+ case 0: return [4 /*yield*/, this.sendRequest("orby_setOrbyGasSponsorPolicyForInstance", [__assign({}, gasSponsorshipPolicy)])];
229
+ case 1:
230
+ _a = _b.sent(), success = _a.success, code = _a.code, message = _a.message;
231
+ if (code && message) {
232
+ console.error("[setOrbyGasSponsorPolicyForInstance]", code, message);
233
+ return [2 /*return*/, undefined];
234
+ }
235
+ return [2 /*return*/, success];
236
+ }
237
+ });
122
238
  });
123
- }
124
- removeOrbyGasSponsorPolicyForInstance() {
125
- return __awaiter(this, void 0, void 0, function* () {
126
- const { success, code, message } = yield this.sendRequest("orby_removeOrbyGasSponsorPolicyForInstance", [{}]);
127
- if (code && message) {
128
- console.error("[removeOrbyGasSponsorPolicyForInstance]", code, message);
129
- return undefined;
130
- }
131
- return success;
239
+ };
240
+ InstanceActions.prototype.removeOrbyGasSponsorPolicyForInstance = function () {
241
+ return __awaiter(this, void 0, void 0, function () {
242
+ var _a, success, code, message;
243
+ return __generator(this, function (_b) {
244
+ switch (_b.label) {
245
+ case 0: return [4 /*yield*/, this.sendRequest("orby_removeOrbyGasSponsorPolicyForInstance", [{}])];
246
+ case 1:
247
+ _a = _b.sent(), success = _a.success, code = _a.code, message = _a.message;
248
+ if (code && message) {
249
+ console.error("[removeOrbyGasSponsorPolicyForInstance]", code, message);
250
+ return [2 /*return*/, undefined];
251
+ }
252
+ return [2 /*return*/, success];
253
+ }
254
+ });
132
255
  });
133
- }
134
- }
135
- exports.InstanceActions = InstanceActions;
256
+ };
257
+ return InstanceActions;
258
+ }(LibraryRequest));
259
+ export { InstanceActions };