@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,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,53 +22,108 @@ 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.AdminActions = void 0;
13
- const action_helpers_1 = require("../utils/action_helpers");
14
- const library_request_1 = require("../entities/library_request");
15
- class AdminActions extends library_request_1.LibraryRequest {
16
- constructor(library, client, provider) {
17
- super(library, client, provider);
18
- }
19
- createInstance(name) {
20
- return __awaiter(this, void 0, void 0, function* () {
21
- const result = yield this.sendRequest("orby_createInstance", [{ name }]);
22
- if (result.code && result.message) {
23
- console.error("[createInstance]", result.code, result.message);
24
- return undefined;
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;
25
46
  }
26
- return result;
27
- });
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 };
28
50
  }
29
- getInstanceUrls(name) {
30
- return __awaiter(this, void 0, void 0, function* () {
31
- const result = yield this.sendRequest("orby_getInstanceUrls", [{ name }]);
32
- if (result.code && result.message) {
33
- console.error("[getInstanceUrls]", result.code, result.message);
34
- return undefined;
35
- }
36
- return result;
37
- });
51
+ };
52
+ import { extractGasSpendForInstances, extractGasSponsorshipData, } from "../utils/action_helpers";
53
+ import { LibraryRequest } from "../entities/library_request";
54
+ var AdminActions = /** @class */ (function (_super) {
55
+ __extends(AdminActions, _super);
56
+ function AdminActions(library, client, provider) {
57
+ return _super.call(this, library, client, provider) || this;
38
58
  }
39
- getGasSpentForCustomer(month, year) {
40
- return __awaiter(this, void 0, void 0, function* () {
41
- const { totalGasSpentForCustomer, code, message } = yield this.sendRequest("orby_getGasSpentForCustomer", [{ month, year }]);
42
- if (code && message) {
43
- console.error("[getGasSpentForCustomer]", code, message);
44
- return undefined;
45
- }
46
- return (0, action_helpers_1.extractGasSponsorshipData)(totalGasSpentForCustomer);
59
+ AdminActions.prototype.createInstance = function (name) {
60
+ return __awaiter(this, void 0, void 0, function () {
61
+ var result;
62
+ return __generator(this, function (_a) {
63
+ switch (_a.label) {
64
+ case 0: return [4 /*yield*/, this.sendRequest("orby_createInstance", [{ name: name }])];
65
+ case 1:
66
+ result = _a.sent();
67
+ if (result.code && result.message) {
68
+ console.error("[createInstance]", result.code, result.message);
69
+ return [2 /*return*/, undefined];
70
+ }
71
+ return [2 /*return*/, result];
72
+ }
73
+ });
47
74
  });
48
- }
49
- getGasSpentForInstances(month, year, instanceNames) {
50
- return __awaiter(this, void 0, void 0, function* () {
51
- const { totalGasSpendForInstances, code, message } = yield this.sendRequest("orby_getGasSpentForInstances", [{ month, year, instanceNames }]);
52
- if (code && message) {
53
- console.error("[getGasSpentForInstances]", code, message);
54
- return undefined;
55
- }
56
- return (0, action_helpers_1.extractGasSpendForInstances)(totalGasSpendForInstances);
75
+ };
76
+ AdminActions.prototype.getInstanceUrls = function (name) {
77
+ return __awaiter(this, void 0, void 0, function () {
78
+ var result;
79
+ return __generator(this, function (_a) {
80
+ switch (_a.label) {
81
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getInstanceUrls", [{ name: name }])];
82
+ case 1:
83
+ result = _a.sent();
84
+ if (result.code && result.message) {
85
+ console.error("[getInstanceUrls]", result.code, result.message);
86
+ return [2 /*return*/, undefined];
87
+ }
88
+ return [2 /*return*/, result];
89
+ }
90
+ });
57
91
  });
58
- }
59
- }
60
- exports.AdminActions = AdminActions;
92
+ };
93
+ AdminActions.prototype.getGasSpentForCustomer = function (month, year) {
94
+ return __awaiter(this, void 0, void 0, function () {
95
+ var _a, totalGasSpentForCustomer, code, message;
96
+ return __generator(this, function (_b) {
97
+ switch (_b.label) {
98
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getGasSpentForCustomer", [{ month: month, year: year }])];
99
+ case 1:
100
+ _a = _b.sent(), totalGasSpentForCustomer = _a.totalGasSpentForCustomer, code = _a.code, message = _a.message;
101
+ if (code && message) {
102
+ console.error("[getGasSpentForCustomer]", code, message);
103
+ return [2 /*return*/, undefined];
104
+ }
105
+ return [2 /*return*/, extractGasSponsorshipData(totalGasSpentForCustomer)];
106
+ }
107
+ });
108
+ });
109
+ };
110
+ AdminActions.prototype.getGasSpentForInstances = function (month, year, instanceNames) {
111
+ return __awaiter(this, void 0, void 0, function () {
112
+ var _a, totalGasSpendForInstances, code, message;
113
+ return __generator(this, function (_b) {
114
+ switch (_b.label) {
115
+ case 0: return [4 /*yield*/, this.sendRequest("orby_getGasSpentForInstances", [{ month: month, year: year, instanceNames: instanceNames }])];
116
+ case 1:
117
+ _a = _b.sent(), totalGasSpendForInstances = _a.totalGasSpendForInstances, code = _a.code, message = _a.message;
118
+ if (code && message) {
119
+ console.error("[getGasSpentForInstances]", code, message);
120
+ return [2 /*return*/, undefined];
121
+ }
122
+ return [2 /*return*/, extractGasSpendForInstances(totalGasSpendForInstances)];
123
+ }
124
+ });
125
+ });
126
+ };
127
+ return AdminActions;
128
+ }(LibraryRequest));
129
+ export { AdminActions };
@@ -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,24 +22,58 @@ 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.ApplicationActions = void 0;
13
- const library_request_1 = require("../entities/library_request");
14
- class ApplicationActions extends library_request_1.LibraryRequest {
15
- constructor(library, client, provider) {
16
- super(library, client, provider);
17
- }
18
- isChainAbstractionCompatible(appDomainUrl) {
19
- return __awaiter(this, void 0, void 0, function* () {
20
- const { isChainAbstractionCompatible, code, message } = yield this.sendRequest("orby_isChainAbstractionCompatible", [
21
- { appDomainUrl },
22
- ]);
23
- if (code && message) {
24
- console.error("[isChainAbstractionCompatible]", code, message);
25
- return undefined;
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;
26
46
  }
27
- return isChainAbstractionCompatible;
28
- });
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 };
29
50
  }
30
- }
31
- exports.ApplicationActions = ApplicationActions;
51
+ };
52
+ import { LibraryRequest } from "../entities/library_request";
53
+ var ApplicationActions = /** @class */ (function (_super) {
54
+ __extends(ApplicationActions, _super);
55
+ function ApplicationActions(library, client, provider) {
56
+ return _super.call(this, library, client, provider) || this;
57
+ }
58
+ ApplicationActions.prototype.isChainAbstractionCompatible = function (appDomainUrl) {
59
+ return __awaiter(this, void 0, void 0, function () {
60
+ var _a, isChainAbstractionCompatible, code, message;
61
+ return __generator(this, function (_b) {
62
+ switch (_b.label) {
63
+ case 0: return [4 /*yield*/, this.sendRequest("orby_isChainAbstractionCompatible", [
64
+ { appDomainUrl: appDomainUrl },
65
+ ])];
66
+ case 1:
67
+ _a = _b.sent(), isChainAbstractionCompatible = _a.isChainAbstractionCompatible, code = _a.code, message = _a.message;
68
+ if (code && message) {
69
+ console.error("[isChainAbstractionCompatible]", code, message);
70
+ return [2 /*return*/, undefined];
71
+ }
72
+ return [2 /*return*/, isChainAbstractionCompatible];
73
+ }
74
+ });
75
+ });
76
+ };
77
+ return ApplicationActions;
78
+ }(LibraryRequest));
79
+ export { ApplicationActions };