@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.
- package/dist/actions/account_cluster.js +308 -158
- package/dist/actions/admin.js +115 -46
- package/dist/actions/application.js +68 -20
- package/dist/actions/instance.js +237 -113
- package/dist/actions/operation.js +242 -110
- package/dist/actions/token.js +107 -41
- package/dist/constants.js +92 -97
- package/dist/entities/account.js +26 -28
- package/dist/entities/financial/account_balance.js +22 -24
- package/dist/entities/financial/asset.js +15 -17
- package/dist/entities/financial/currency.js +37 -25
- package/dist/entities/financial/currency_amount.js +79 -64
- package/dist/entities/financial/fungible_token.js +49 -34
- package/dist/entities/financial/fungible_token_amount.js +85 -70
- package/dist/entities/financial/non_fungible_token.js +45 -30
- package/dist/entities/financial/semi_fungible_token.js +45 -30
- package/dist/entities/library_request.js +19 -24
- package/dist/entities/state.js +67 -60
- package/dist/enums.js +34 -37
- package/dist/index.js +27 -43
- package/dist/interfaces/account_cluster.js +1 -2
- package/dist/interfaces/admin.js +1 -2
- package/dist/interfaces/application.js +1 -2
- package/dist/interfaces/instance.js +1 -2
- package/dist/interfaces/operation.js +1 -2
- package/dist/interfaces/orby.js +1 -2
- package/dist/interfaces/token.js +1 -2
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types.js +1 -2
- package/dist/utils/action_helpers.js +99 -109
- package/dist/utils/utils.js +24 -32
- package/dist/utils/validateAndParseAddress.js +7 -11
- package/package.json +1 -1
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
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,126 +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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
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
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
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
|
-
|
|
27
|
-
return __awaiter(this, void 0, void 0, function
|
|
28
|
-
|
|
29
|
-
return (
|
|
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
|
-
|
|
33
|
-
return __awaiter(this, void 0, void 0, function
|
|
34
|
-
|
|
35
|
-
return (
|
|
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
|
-
|
|
39
|
-
return __awaiter(this, void 0, void 0, function
|
|
40
|
-
|
|
41
|
-
return
|
|
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
|
-
|
|
45
|
-
return __awaiter(this, void 0, void 0, function
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
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
|
+
});
|
|
52
110
|
});
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
return __awaiter(this, void 0, void 0, function
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
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
|
+
});
|
|
67
127
|
});
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
return __awaiter(this, void 0, void 0, function
|
|
71
|
-
|
|
72
|
-
return (
|
|
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
|
+
});
|
|
73
149
|
});
|
|
74
|
-
}
|
|
75
|
-
|
|
76
|
-
return __awaiter(this, void 0, void 0, function
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
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
|
+
});
|
|
83
162
|
});
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
return __awaiter(this, void 0, void 0, function
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
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
|
+
});
|
|
93
179
|
});
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
return __awaiter(this, void 0, void 0, function
|
|
97
|
-
|
|
98
|
-
return (
|
|
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
|
+
});
|
|
99
196
|
});
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
return __awaiter(this, void 0, void 0, function
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
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
|
+
});
|
|
107
209
|
});
|
|
108
|
-
}
|
|
109
|
-
|
|
110
|
-
return __awaiter(this, void 0, void 0, function
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
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
|
+
});
|
|
115
224
|
});
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
return __awaiter(this, void 0, void 0, function
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
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
|
+
});
|
|
130
239
|
});
|
|
131
|
-
}
|
|
132
|
-
|
|
133
|
-
|
|
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 };
|
package/dist/actions/token.js
CHANGED
|
@@ -1,4 +1,18 @@
|
|
|
1
|
-
|
|
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,49 +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
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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 };
|
|
50
|
+
}
|
|
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;
|
|
18
58
|
}
|
|
19
|
-
getStandardizedTokenIds(tokens) {
|
|
20
|
-
return __awaiter(this, void 0, void 0, function
|
|
21
|
-
|
|
22
|
-
|
|
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, message, code } = yield this.sendRequest("orby_getStandardizedTokenIds", [{ tokens: formattedTokensInfo }]);
|
|
25
|
-
if (code && message) {
|
|
26
|
-
console.error("[getStandardizedTokenIds]", code, message);
|
|
27
|
-
return undefined;
|
|
28
|
-
}
|
|
29
|
-
return standardizedTokenIds;
|
|
30
79
|
});
|
|
31
|
-
}
|
|
32
|
-
getStandardizedTokens(tokens) {
|
|
33
|
-
return __awaiter(this, void 0, void 0, function
|
|
34
|
-
|
|
35
|
-
|
|
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
|
+
}
|
|
36
100
|
});
|
|
37
|
-
const { standardizedTokens, message, code } = yield this.sendRequest("orby_getStandardizedTokens", [{ tokens: formattedTokensInfo }]);
|
|
38
|
-
if (code && message) {
|
|
39
|
-
console.error("[getStandardizedTokens]", code, message);
|
|
40
|
-
return undefined;
|
|
41
|
-
}
|
|
42
|
-
return (0, action_helpers_1.extractStandardizedTokens)(standardizedTokens);
|
|
43
101
|
});
|
|
44
|
-
}
|
|
45
|
-
getFungibleTokenData(standardizedTokenIds) {
|
|
46
|
-
return __awaiter(this, void 0, void 0, function
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
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
|
+
});
|
|
53
118
|
});
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
119
|
+
};
|
|
120
|
+
return TokenActions;
|
|
121
|
+
}(LibraryRequest));
|
|
122
|
+
export { TokenActions };
|