@orb-labs/orby-core 0.0.6 → 0.0.7
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.
- package/CHANGELOG.md +7 -0
- package/dist/actions/account_cluster.d.ts +4 -4
- package/dist/actions/account_cluster.js +147 -338
- package/dist/actions/admin.d.ts +3 -3
- package/dist/actions/admin.js +37 -127
- package/dist/actions/application.d.ts +2 -2
- package/dist/actions/application.js +14 -77
- package/dist/actions/instance.d.ts +3 -3
- package/dist/actions/instance.js +98 -255
- package/dist/actions/operation.d.ts +4 -4
- package/dist/actions/operation.js +92 -263
- package/dist/actions/token.d.ts +3 -3
- package/dist/actions/token.js +34 -119
- package/dist/constants.d.ts +3 -3
- package/dist/constants.js +70 -71
- package/dist/entities/account.d.ts +1 -1
- package/dist/entities/account.js +25 -30
- package/dist/entities/financial/account_balance.d.ts +2 -2
- package/dist/entities/financial/account_balance.js +20 -22
- package/dist/entities/financial/asset.js +13 -15
- package/dist/entities/financial/currency.d.ts +1 -1
- package/dist/entities/financial/currency.js +16 -35
- package/dist/entities/financial/currency_amount.d.ts +1 -1
- package/dist/entities/financial/currency_amount.js +49 -71
- package/dist/entities/financial/fungible_token.d.ts +2 -2
- package/dist/entities/financial/fungible_token.js +31 -52
- package/dist/entities/financial/fungible_token_amount.d.ts +2 -2
- package/dist/entities/financial/fungible_token_amount.js +53 -75
- package/dist/entities/financial/non_fungible_token.d.ts +2 -2
- package/dist/entities/financial/non_fungible_token.js +25 -45
- package/dist/entities/financial/semi_fungible_token.d.ts +2 -2
- package/dist/entities/financial/semi_fungible_token.js +25 -45
- package/dist/entities/library_request.d.ts +1 -1
- package/dist/entities/library_request.js +7 -9
- package/dist/entities/state.d.ts +4 -4
- package/dist/entities/state.js +57 -67
- package/dist/index.d.ts +27 -27
- package/dist/index.js +27 -27
- package/dist/interfaces/account_cluster.d.ts +3 -3
- package/dist/interfaces/admin.d.ts +1 -1
- package/dist/interfaces/instance.d.ts +1 -1
- package/dist/interfaces/operation.d.ts +3 -3
- package/dist/interfaces/orby.d.ts +6 -6
- package/dist/interfaces/token.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +7 -7
- package/dist/utils/action_helpers.d.ts +1 -1
- package/dist/utils/action_helpers.js +42 -58
- package/dist/utils/jsbi.d.ts +2 -0
- package/dist/utils/jsbi.js +2 -0
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.js +17 -19
- package/dist/utils/validateAndParseAddress.js +3 -3
- package/package.json +4 -2
@@ -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 { OperationSet, OperationStatus, SignedOperation } from "../types.js";
|
2
|
+
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
3
|
+
import { LIBRARY_TYPE, 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?: {
|
@@ -1,265 +1,94 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
23
|
-
});
|
24
|
-
};
|
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 };
|
1
|
+
import { extractOperationSet, extractOperationStatuses, } from "../utils/action_helpers.js";
|
2
|
+
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
3
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
4
|
+
export class OperationActions extends LibraryRequest {
|
5
|
+
constructor(library, client, provider) {
|
6
|
+
super(library, client, provider);
|
50
7
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
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;
|
8
|
+
async getOperationsToExecuteTransaction(accountClusterId, to, data, value, gasToken) {
|
9
|
+
const operationSet = await this.sendRequest("orby_getOperationsToExecuteTransaction", [{ accountClusterId, to, data, value, gasToken }]);
|
10
|
+
return extractOperationSet(operationSet);
|
59
11
|
}
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
return
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
}
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
}
|
129
|
-
|
130
|
-
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
return [2 /*return*/, {
|
144
|
-
operationSetId: operationSetId,
|
145
|
-
operationResponses: extractOperationStatuses(operationResponses),
|
146
|
-
}];
|
147
|
-
}
|
148
|
-
});
|
149
|
-
});
|
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
|
-
});
|
162
|
-
});
|
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
|
-
});
|
179
|
-
});
|
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
|
-
});
|
196
|
-
});
|
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
|
-
});
|
209
|
-
});
|
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
|
-
});
|
224
|
-
});
|
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
|
-
});
|
239
|
-
});
|
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 };
|
12
|
+
async getOperationsToSignTypedData(accountClusterId, data) {
|
13
|
+
const operationSet = await this.sendRequest("orby_getOperationsToSignTypedData", [{ accountClusterId, data }]);
|
14
|
+
return extractOperationSet(operationSet);
|
15
|
+
}
|
16
|
+
async getOperationsToCancelTransaction(accountClusterId, operationSetId) {
|
17
|
+
const operationSet = await this.sendRequest("orby_getOperationsToCancelTransaction", [{ accountClusterId, operationSetId }]);
|
18
|
+
return extractOperationSet(operationSet);
|
19
|
+
}
|
20
|
+
async isTransactionPreconditionSatisfied(accountClusterId, to, data, value) {
|
21
|
+
const { satisfied } = await this.sendRequest("orby_isTransactionPreconditionSatisfied", [{ accountClusterId, to, data, value }]);
|
22
|
+
return satisfied;
|
23
|
+
}
|
24
|
+
async isTypedDataPreconditionSatisfied(accountClusterId, data) {
|
25
|
+
const { satisfied, code, message } = await this.sendRequest("orby_isTypedDataPreconditionSatisfied", [{ accountClusterId, data }]);
|
26
|
+
if (code && message) {
|
27
|
+
console.error("[isTypedDataPreconditionSatisfied]", code, message);
|
28
|
+
return undefined;
|
29
|
+
}
|
30
|
+
return satisfied;
|
31
|
+
}
|
32
|
+
async sendSignedOperations(accountClusterId, signedOperations) {
|
33
|
+
const { operationSetId, operationResponses, code, message } = await this.sendRequest("orby_sendSignedOperations", [
|
34
|
+
{ accountClusterId, signedOperations },
|
35
|
+
]);
|
36
|
+
if (code && message) {
|
37
|
+
console.error("[sendSignedOperations]", code, message);
|
38
|
+
return undefined;
|
39
|
+
}
|
40
|
+
return {
|
41
|
+
operationSetId,
|
42
|
+
operationResponses: extractOperationStatuses(operationResponses),
|
43
|
+
};
|
44
|
+
}
|
45
|
+
async getOperationStatuses(operationIds) {
|
46
|
+
const { operationStatuses } = await this.sendRequest("orby_getOperationStatuses", [{ operationIds }]);
|
47
|
+
return extractOperationStatuses(operationStatuses);
|
48
|
+
}
|
49
|
+
async estimateFiatCostToExecuteTransaction(to, data, value) {
|
50
|
+
const { estimatedCost, code, message } = await this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [{ to, data, value }]);
|
51
|
+
if (code && message) {
|
52
|
+
console.error("[estimateFiatCostToExecuteTransaction]", code, message);
|
53
|
+
return undefined;
|
54
|
+
}
|
55
|
+
return CurrencyAmount.toCurrencyAmount(estimatedCost);
|
56
|
+
}
|
57
|
+
async estimateFiatCostToSignTypedData(data) {
|
58
|
+
const { estimatedCost, code, message } = await this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data }]);
|
59
|
+
if (code && message) {
|
60
|
+
console.error("[estimateFiatCostToSignTypedData]", code, message);
|
61
|
+
return undefined;
|
62
|
+
}
|
63
|
+
return CurrencyAmount.toCurrencyAmount(estimatedCost);
|
64
|
+
}
|
65
|
+
async getOperationsToTransferToken(accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
|
66
|
+
const operationSet = await this.sendRequest("orby_getOperationsToTransferToken", [{ accountClusterId, standardizedTokenId, amount, recipient, gasToken }]);
|
67
|
+
return extractOperationSet(operationSet);
|
68
|
+
}
|
69
|
+
async getOperationsToSwap(accountClusterId, swapType, input, output, gasToken) {
|
70
|
+
const operationSet = await this.sendRequest("orby_getOperationsToSwap", [
|
71
|
+
{ accountClusterId, swapType, input, output, gasToken },
|
72
|
+
]);
|
73
|
+
return extractOperationSet(operationSet);
|
74
|
+
}
|
75
|
+
async getQuote(accountClusterId, swapType, input, output) {
|
76
|
+
const operationSet = await this.sendRequest("orby_getQuote", [
|
77
|
+
{ accountClusterId, swapType, input, output },
|
78
|
+
]);
|
79
|
+
return extractOperationSet(operationSet);
|
80
|
+
}
|
81
|
+
async getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
|
82
|
+
const operationSet = await this.sendRequest("orby_getOperationsToBridge", [
|
83
|
+
{
|
84
|
+
accountClusterId,
|
85
|
+
standardizedTokenId,
|
86
|
+
amount,
|
87
|
+
tokenSources,
|
88
|
+
tokenDestination,
|
89
|
+
gasToken,
|
90
|
+
},
|
91
|
+
]);
|
92
|
+
return extractOperationSet(operationSet);
|
93
|
+
}
|
94
|
+
}
|
package/dist/actions/token.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { StandardizedToken } from "../types";
|
2
|
-
import { LibraryRequest } from "../entities/library_request";
|
3
|
-
import { LIBRARY_TYPE } from "../enums";
|
1
|
+
import { StandardizedToken } from "../types.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { LIBRARY_TYPE } from "../enums.js";
|
4
4
|
export declare class TokenActions extends LibraryRequest {
|
5
5
|
constructor(library: LIBRARY_TYPE, client?: any, provider?: any);
|
6
6
|
getStandardizedTokenIds(tokens: {
|
package/dist/actions/token.js
CHANGED
@@ -1,122 +1,37 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
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 __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
17
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
18
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
19
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
20
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
21
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
22
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
23
|
-
});
|
24
|
-
};
|
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 };
|
1
|
+
import { extractStandardizedToken, extractStandardizedTokens, } from "../utils/action_helpers.js";
|
2
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
export class TokenActions extends LibraryRequest {
|
4
|
+
constructor(library, client, provider) {
|
5
|
+
super(library, client, provider);
|
50
6
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
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
|
-
}
|
78
|
-
});
|
79
|
-
});
|
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
|
-
}
|
100
|
-
});
|
7
|
+
async getStandardizedTokenIds(tokens) {
|
8
|
+
const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
|
9
|
+
return { chainId: `EIP155-${chainId}`, tokenAddress };
|
101
10
|
});
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
console.error("[getFungibleTokenData]", code, message);
|
113
|
-
return [2 /*return*/, undefined];
|
114
|
-
}
|
115
|
-
return [2 /*return*/, extractStandardizedToken(data)];
|
116
|
-
}
|
117
|
-
});
|
11
|
+
const { standardizedTokenIds, message, code } = await this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }]);
|
12
|
+
if (code && message) {
|
13
|
+
console.error("[getStandardizedTokenIds]", code, message);
|
14
|
+
return undefined;
|
15
|
+
}
|
16
|
+
return standardizedTokenIds;
|
17
|
+
}
|
18
|
+
async getStandardizedTokens(tokens) {
|
19
|
+
const formattedTokensInfo = tokens.map(({ tokenAddress, chainId }) => {
|
20
|
+
return { chainId: `EIP155-${chainId}`, tokenAddress };
|
118
21
|
});
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
22
|
+
const { standardizedTokens, message, code } = await this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }]);
|
23
|
+
if (code && message) {
|
24
|
+
console.error("[getStandardizedTokens]", code, message);
|
25
|
+
return undefined;
|
26
|
+
}
|
27
|
+
return extractStandardizedTokens(standardizedTokens);
|
28
|
+
}
|
29
|
+
async getFungibleTokenData(standardizedTokenIds) {
|
30
|
+
const { data, message, code } = await this.sendRequest("orby_getFungibleTokenData", [{ standardizedTokenIds }]);
|
31
|
+
if (code && message) {
|
32
|
+
console.error("[getFungibleTokenData]", code, message);
|
33
|
+
return undefined;
|
34
|
+
}
|
35
|
+
return extractStandardizedToken(data);
|
36
|
+
}
|
37
|
+
}
|
package/dist/constants.d.ts
CHANGED
@@ -1,6 +1,6 @@
|
|
1
|
-
import { Blockchain } from "./enums";
|
2
|
-
import { Currency } from "./entities/financial/currency";
|
3
|
-
import { ChainConfigs } from "./types";
|
1
|
+
import { Blockchain } from "./enums.js";
|
2
|
+
import { Currency } from "./entities/financial/currency.js";
|
3
|
+
import { ChainConfigs } from "./types.js";
|
4
4
|
export declare const Big: any;
|
5
5
|
export declare const BLOCKCHAIN_ID: {
|
6
6
|
[s: string]: number;
|