@orb-labs/orby-core 0.0.6 → 0.0.8

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 (56) hide show
  1. package/CHANGELOG.md +7 -0
  2. package/dist/actions/account_cluster.d.ts +12 -5
  3. package/dist/actions/account_cluster.js +185 -338
  4. package/dist/actions/admin.d.ts +3 -3
  5. package/dist/actions/admin.js +37 -127
  6. package/dist/actions/application.d.ts +2 -2
  7. package/dist/actions/application.js +14 -77
  8. package/dist/actions/blockchain.d.ts +16 -0
  9. package/dist/actions/blockchain.js +35 -0
  10. package/dist/actions/instance.d.ts +3 -4
  11. package/dist/actions/instance.js +90 -255
  12. package/dist/actions/operation.d.ts +19 -10
  13. package/dist/actions/operation.js +323 -259
  14. package/dist/actions/token.d.ts +3 -3
  15. package/dist/actions/token.js +43 -119
  16. package/dist/constants.d.ts +3 -3
  17. package/dist/constants.js +70 -71
  18. package/dist/entities/account.d.ts +1 -1
  19. package/dist/entities/account.js +25 -30
  20. package/dist/entities/financial/account_balance.d.ts +2 -2
  21. package/dist/entities/financial/account_balance.js +20 -22
  22. package/dist/entities/financial/asset.js +13 -15
  23. package/dist/entities/financial/currency.d.ts +1 -1
  24. package/dist/entities/financial/currency.js +16 -35
  25. package/dist/entities/financial/currency_amount.d.ts +1 -1
  26. package/dist/entities/financial/currency_amount.js +49 -71
  27. package/dist/entities/financial/fungible_token.d.ts +3 -3
  28. package/dist/entities/financial/fungible_token.js +31 -52
  29. package/dist/entities/financial/fungible_token_amount.d.ts +2 -2
  30. package/dist/entities/financial/fungible_token_amount.js +53 -75
  31. package/dist/entities/financial/non_fungible_token.d.ts +2 -2
  32. package/dist/entities/financial/non_fungible_token.js +25 -45
  33. package/dist/entities/financial/semi_fungible_token.d.ts +2 -2
  34. package/dist/entities/financial/semi_fungible_token.js +25 -45
  35. package/dist/entities/library_request.d.ts +1 -1
  36. package/dist/entities/library_request.js +7 -9
  37. package/dist/entities/state.d.ts +4 -4
  38. package/dist/entities/state.js +57 -67
  39. package/dist/index.d.ts +29 -27
  40. package/dist/index.js +29 -27
  41. package/dist/interfaces/account_cluster.d.ts +11 -4
  42. package/dist/interfaces/admin.d.ts +1 -1
  43. package/dist/interfaces/blockchain.d.ts +13 -0
  44. package/dist/interfaces/blockchain.js +1 -0
  45. package/dist/interfaces/instance.d.ts +1 -2
  46. package/dist/interfaces/operation.d.ts +25 -10
  47. package/dist/interfaces/orby.d.ts +8 -7
  48. package/dist/interfaces/token.d.ts +1 -1
  49. package/dist/tsconfig.tsbuildinfo +1 -1
  50. package/dist/types.d.ts +9 -9
  51. package/dist/utils/action_helpers.d.ts +1 -1
  52. package/dist/utils/action_helpers.js +43 -63
  53. package/dist/utils/utils.d.ts +2 -1
  54. package/dist/utils/utils.js +23 -19
  55. package/dist/utils/validateAndParseAddress.js +3 -3
  56. package/package.json +4 -2
@@ -1,259 +1,94 @@
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];
1
+ import { extractGasSponsorshipPolicy, } from "../utils/action_helpers.js";
2
+ import { LibraryRequest } from "../entities/library_request.js";
3
+ import { getChainIdFromOrbyChainId, getOrbyChainId } from "../utils/utils.js";
4
+ export class InstanceActions extends LibraryRequest {
5
+ constructor(library, client, provider) {
6
+ super(library, client, provider);
7
+ }
8
+ async setCustomChainEndpointsForInstance(chainEndpoints) {
9
+ const formattedEndpoints = chainEndpoints.map((endpoint) => {
10
+ return {
11
+ chainId: getOrbyChainId(endpoint.chainId),
12
+ customRpcUrls: endpoint.customRpcUrls,
13
+ customIndexerUrls: endpoint.customIndexerUrls,
14
+ };
15
+ });
16
+ const { success, code, message } = await this.sendRequest("orby_setCustomChainEndpointsForInstance", [{ chainEndpoints: formattedEndpoints }]);
17
+ if (code && message) {
18
+ console.error("[setCustomChainEndpointsForInstance]", code, message);
19
+ return undefined;
22
20
  }
23
- return t;
24
- };
25
- return __assign.apply(this, arguments);
26
- };
27
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
28
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
29
- return new (P || (P = Promise))(function (resolve, reject) {
30
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
31
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
32
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
33
- step((generator = generator.apply(thisArg, _arguments || [])).next());
34
- });
35
- };
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 };
21
+ return success;
61
22
  }
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;
23
+ async removeCustomChainEndpointForInstance(chainIds) {
24
+ const formattedChainIds = chainIds.map((chainId) => getOrbyChainId(chainId));
25
+ const { success, code, message } = await this.sendRequest("orby_removeCustomChainEndpointForInstance", [{ chainIds: formattedChainIds }]);
26
+ if (code && message) {
27
+ console.error("[removeCustomChainEndpointForInstance]", code, message);
28
+ return undefined;
29
+ }
30
+ return success;
70
31
  }
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
- }
93
- });
94
- });
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
- });
113
- });
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
- }
135
- });
136
- });
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
- });
153
- });
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
- });
170
- });
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
- });
187
- });
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
- });
204
- });
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
- });
221
- });
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
- });
238
- });
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
- });
32
+ async getCustomChainEndpointsForInstance(returnChainIdsOnly) {
33
+ const { chainEndpoints, code, message } = await this.sendRequest("orby_getCustomChainEndpointsForInstance", [{ returnChainIdsOnly }]);
34
+ if (code && message) {
35
+ console.error("[getCustomChainEndpointsForInstance]", code, message);
36
+ return undefined;
37
+ }
38
+ return chainEndpoints.map((endpoint) => {
39
+ return {
40
+ chainId: getChainIdFromOrbyChainId(endpoint.chainId),
41
+ customRpcUrls: endpoint.customRpcUrls,
42
+ customIndexerUrls: endpoint.customIndexerUrls,
43
+ };
255
44
  });
256
- };
257
- return InstanceActions;
258
- }(LibraryRequest));
259
- export { InstanceActions };
45
+ }
46
+ async enabledChainAbstractionForInstance(enable) {
47
+ const { success, code, message } = await this.sendRequest("orby_enabledChainAbstractionForInstance", [{ enable }]);
48
+ if (code && message) {
49
+ console.error("[enabledChainAbstractionForInstance]", code, message);
50
+ return undefined;
51
+ }
52
+ return success;
53
+ }
54
+ async enableGasSponsorshipForInstance(enable) {
55
+ const { success, code, message } = await this.sendRequest("orby_enableGasSponsorshipForInstance", [{ enable }]);
56
+ if (code && message) {
57
+ console.error("[enableGasSponsorshipForInstance]", code, message);
58
+ return undefined;
59
+ }
60
+ return success;
61
+ }
62
+ async getGasSponsorForInstance() {
63
+ const { gasSponsor, code, message } = await this.sendRequest("orby_getGasSponsorForInstance", []);
64
+ if (code && message) {
65
+ console.error("[getGasSponsorForInstance]", code, message);
66
+ return undefined;
67
+ }
68
+ return gasSponsor;
69
+ }
70
+ async getOrbyGasSponsorPolicyForInstance() {
71
+ const { gasSponsorshipPolicy, message, code } = await this.sendRequest("orby_getOrbyGasSponsorPolicyForInstance", []);
72
+ if (code && message) {
73
+ console.error("[getOrbyGasSponsorPolicyForInstance]", code, message);
74
+ return undefined;
75
+ }
76
+ return extractGasSponsorshipPolicy(gasSponsorshipPolicy);
77
+ }
78
+ async setOrbyGasSponsorPolicyForInstance(gasSponsorshipPolicy) {
79
+ const { success, code, message } = await this.sendRequest("orby_setOrbyGasSponsorPolicyForInstance", [{ ...gasSponsorshipPolicy }]);
80
+ if (code && message) {
81
+ console.error("[setOrbyGasSponsorPolicyForInstance]", code, message);
82
+ return undefined;
83
+ }
84
+ return success;
85
+ }
86
+ async removeOrbyGasSponsorPolicyForInstance() {
87
+ const { success, code, message } = await this.sendRequest("orby_removeOrbyGasSponsorPolicyForInstance", []);
88
+ if (code && message) {
89
+ console.error("[removeOrbyGasSponsorPolicyForInstance]", code, message);
90
+ return undefined;
91
+ }
92
+ return success;
93
+ }
94
+ }
@@ -1,7 +1,7 @@
1
- import { OperationSet, OperationStatus, SignedOperation } from "../types";
2
- import { CurrencyAmount } from "../entities/financial/currency_amount";
3
- import { LIBRARY_TYPE, QuoteType } from "../enums";
4
- import { LibraryRequest } from "../entities/library_request";
1
+ import { OnchainOperation, OperationSet, OperationStatus, SignedOperation } from "../types.js";
2
+ import { CurrencyAmount } from "../entities/financial/currency_amount.js";
3
+ import { LIBRARY_TYPE, OperationStatusType, QuoteType } from "../enums.js";
4
+ import { LibraryRequest } from "../entities/library_request.js";
5
5
  export declare class OperationActions extends LibraryRequest {
6
6
  constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
7
7
  getOperationsToExecuteTransaction(accountClusterId: string, to: string, data: string, value?: bigint, gasToken?: {
@@ -36,14 +36,14 @@ export declare class OperationActions extends LibraryRequest {
36
36
  standardizedTokenId: string;
37
37
  amount?: bigint;
38
38
  tokenSources?: {
39
- chainId: string;
39
+ chainId: bigint;
40
40
  address?: string;
41
41
  }[];
42
42
  }, output: {
43
43
  standardizedTokenId: string;
44
44
  amount?: bigint;
45
45
  tokenDestination?: {
46
- chainId: string;
46
+ chainId: bigint;
47
47
  address?: string;
48
48
  };
49
49
  }, gasToken?: {
@@ -57,22 +57,22 @@ export declare class OperationActions extends LibraryRequest {
57
57
  standardizedTokenId: string;
58
58
  amount?: bigint;
59
59
  tokenSources?: {
60
- chainId: string;
60
+ chainId: bigint;
61
61
  address?: string;
62
62
  }[];
63
63
  }, output: {
64
64
  standardizedTokenId: string;
65
65
  amount?: bigint;
66
66
  tokenDestination?: {
67
- chainId: string;
67
+ chainId: bigint;
68
68
  address?: string;
69
69
  };
70
70
  }): Promise<OperationSet>;
71
71
  getOperationsToBridge(accountClusterId: string, standardizedTokenId: string, amount: bigint, tokenSources?: {
72
- chainId: string;
72
+ chainId: bigint;
73
73
  address?: string;
74
74
  }[], tokenDestination?: {
75
- chainId: string;
75
+ chainId: bigint;
76
76
  address?: string;
77
77
  }, gasToken?: {
78
78
  standardizedTokenId: string;
@@ -81,4 +81,13 @@ export declare class OperationActions extends LibraryRequest {
81
81
  address?: string;
82
82
  }[];
83
83
  }): Promise<OperationSet>;
84
+ subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void): {
85
+ intervalId: number | null;
86
+ };
87
+ sendOperationSet(accountClusterId: string, operationSet: OperationSet, signOperation: (operation: OnchainOperation) => Promise<SignedOperation | undefined>): Promise<{
88
+ success: boolean;
89
+ operationSetId?: string;
90
+ primaryOperationStatus?: OperationStatus;
91
+ operationResponses?: OperationStatus[];
92
+ }>;
84
93
  }