@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.
- package/CHANGELOG.md +7 -0
- package/dist/actions/account_cluster.d.ts +12 -5
- package/dist/actions/account_cluster.js +185 -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/blockchain.d.ts +16 -0
- package/dist/actions/blockchain.js +35 -0
- package/dist/actions/instance.d.ts +3 -4
- package/dist/actions/instance.js +90 -255
- package/dist/actions/operation.d.ts +19 -10
- package/dist/actions/operation.js +323 -259
- package/dist/actions/token.d.ts +3 -3
- package/dist/actions/token.js +43 -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 +3 -3
- 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 +29 -27
- package/dist/index.js +29 -27
- package/dist/interfaces/account_cluster.d.ts +11 -4
- package/dist/interfaces/admin.d.ts +1 -1
- package/dist/interfaces/blockchain.d.ts +13 -0
- package/dist/interfaces/blockchain.js +1 -0
- package/dist/interfaces/instance.d.ts +1 -2
- package/dist/interfaces/operation.d.ts +25 -10
- package/dist/interfaces/orby.d.ts +8 -7
- package/dist/interfaces/token.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/types.d.ts +9 -9
- package/dist/utils/action_helpers.d.ts +1 -1
- package/dist/utils/action_helpers.js +43 -63
- package/dist/utils/utils.d.ts +2 -1
- package/dist/utils/utils.js +23 -19
- package/dist/utils/validateAndParseAddress.js +3 -3
- package/package.json +4 -2
@@ -1,265 +1,329 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
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;
|
1
|
+
import { extractOperationSet, extractOperationStatuses, } from "../utils/action_helpers.js";
|
2
|
+
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
3
|
+
import { OperationStatusType, OperationType, } from "../enums.js";
|
4
|
+
import { LibraryRequest } from "../entities/library_request.js";
|
5
|
+
import { getOrbyChainId } from "../utils/utils.js";
|
6
|
+
export class OperationActions extends LibraryRequest {
|
7
|
+
constructor(library, client, provider) {
|
8
|
+
super(library, client, provider);
|
9
|
+
}
|
10
|
+
async getOperationsToExecuteTransaction(accountClusterId, to, data, value, gasToken) {
|
11
|
+
const formattedGasToken = gasToken
|
12
|
+
? {
|
13
|
+
...gasToken,
|
14
|
+
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
15
|
+
chainId: getOrbyChainId(chainId),
|
16
|
+
address,
|
17
|
+
})),
|
46
18
|
}
|
47
|
-
|
48
|
-
|
49
|
-
|
19
|
+
: undefined;
|
20
|
+
const operationSet = await this.sendRequest("orby_getOperationsToExecuteTransaction", [
|
21
|
+
{
|
22
|
+
accountClusterId,
|
23
|
+
to,
|
24
|
+
data,
|
25
|
+
value,
|
26
|
+
gasToken: formattedGasToken,
|
27
|
+
},
|
28
|
+
]);
|
29
|
+
return extractOperationSet(operationSet);
|
50
30
|
}
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
return
|
31
|
+
async getOperationsToSignTypedData(accountClusterId, data) {
|
32
|
+
const operationSet = await this.sendRequest("orby_getOperationsToSignTypedData", [
|
33
|
+
{
|
34
|
+
accountClusterId,
|
35
|
+
data,
|
36
|
+
},
|
37
|
+
]);
|
38
|
+
return extractOperationSet(operationSet);
|
59
39
|
}
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
return
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
return
|
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
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
151
|
-
|
152
|
-
|
153
|
-
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
165
|
-
|
166
|
-
|
167
|
-
|
168
|
-
|
169
|
-
|
170
|
-
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
188
|
-
|
189
|
-
|
190
|
-
|
191
|
-
|
192
|
-
|
193
|
-
|
194
|
-
|
195
|
-
|
196
|
-
|
197
|
-
|
198
|
-
|
199
|
-
return
|
200
|
-
|
201
|
-
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
206
|
-
|
207
|
-
|
208
|
-
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
40
|
+
async getOperationsToCancelTransaction(accountClusterId, operationSetId) {
|
41
|
+
const operationSet = await this.sendRequest("orby_getOperationsToCancelTransaction", [
|
42
|
+
{
|
43
|
+
accountClusterId,
|
44
|
+
operationSetId,
|
45
|
+
},
|
46
|
+
]);
|
47
|
+
return extractOperationSet(operationSet);
|
48
|
+
}
|
49
|
+
async isTransactionPreconditionSatisfied(accountClusterId, to, data, value) {
|
50
|
+
const { satisfied } = await this.sendRequest("orby_isTransactionPreconditionSatisfied", [
|
51
|
+
{
|
52
|
+
accountClusterId,
|
53
|
+
to,
|
54
|
+
data,
|
55
|
+
value,
|
56
|
+
},
|
57
|
+
]);
|
58
|
+
return satisfied;
|
59
|
+
}
|
60
|
+
async isTypedDataPreconditionSatisfied(accountClusterId, data) {
|
61
|
+
const { satisfied, code, message } = await this.sendRequest("orby_isTypedDataPreconditionSatisfied", [
|
62
|
+
{
|
63
|
+
accountClusterId,
|
64
|
+
data,
|
65
|
+
},
|
66
|
+
]);
|
67
|
+
if (code && message) {
|
68
|
+
console.error("[isTypedDataPreconditionSatisfied]", code, message);
|
69
|
+
return undefined;
|
70
|
+
}
|
71
|
+
return satisfied;
|
72
|
+
}
|
73
|
+
async sendSignedOperations(accountClusterId, signedOperations) {
|
74
|
+
const { operationSetId, operationResponses, code, message } = await this.sendRequest("orby_sendSignedOperations", [
|
75
|
+
{
|
76
|
+
accountClusterId,
|
77
|
+
signedOperations,
|
78
|
+
},
|
79
|
+
]);
|
80
|
+
if (code && message) {
|
81
|
+
console.error("[sendSignedOperations]", code, message);
|
82
|
+
return undefined;
|
83
|
+
}
|
84
|
+
return {
|
85
|
+
operationSetId,
|
86
|
+
operationResponses: extractOperationStatuses(operationResponses),
|
87
|
+
};
|
88
|
+
}
|
89
|
+
async getOperationStatuses(operationIds) {
|
90
|
+
const { operationStatuses } = await this.sendRequest("orby_getOperationStatuses", [{ operationIds }]);
|
91
|
+
return extractOperationStatuses(operationStatuses);
|
92
|
+
}
|
93
|
+
async estimateFiatCostToExecuteTransaction(to, data, value) {
|
94
|
+
const { estimatedCost, code, message } = await this.sendRequest("orby_estimateFiatCostToExecuteTransaction", [
|
95
|
+
{
|
96
|
+
to,
|
97
|
+
data,
|
98
|
+
value,
|
99
|
+
},
|
100
|
+
]);
|
101
|
+
if (code && message) {
|
102
|
+
console.error("[estimateFiatCostToExecuteTransaction]", code, message);
|
103
|
+
return undefined;
|
104
|
+
}
|
105
|
+
return CurrencyAmount.toCurrencyAmount(estimatedCost);
|
106
|
+
}
|
107
|
+
async estimateFiatCostToSignTypedData(data) {
|
108
|
+
const { estimatedCost, code, message } = await this.sendRequest("orby_estimateFiatCostToSignTypedData", [{ data }]);
|
109
|
+
if (code && message) {
|
110
|
+
console.error("[estimateFiatCostToSignTypedData]", code, message);
|
111
|
+
return undefined;
|
112
|
+
}
|
113
|
+
return CurrencyAmount.toCurrencyAmount(estimatedCost);
|
114
|
+
}
|
115
|
+
async getOperationsToTransferToken(accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
|
116
|
+
const formattedGasToken = gasToken
|
117
|
+
? {
|
118
|
+
...gasToken,
|
119
|
+
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
120
|
+
chainId: getOrbyChainId(chainId),
|
121
|
+
address,
|
122
|
+
})),
|
123
|
+
}
|
124
|
+
: undefined;
|
125
|
+
const formattedRecepient = {
|
126
|
+
chainId: getOrbyChainId(recipient.chainId),
|
127
|
+
recipientAddress: recipient.recipientAddress,
|
128
|
+
};
|
129
|
+
const operationSet = await this.sendRequest("orby_getOperationsToTransferToken", [
|
130
|
+
{
|
131
|
+
accountClusterId,
|
132
|
+
standardizedTokenId,
|
133
|
+
amount,
|
134
|
+
recipient: formattedRecepient,
|
135
|
+
gasToken: formattedGasToken,
|
136
|
+
},
|
137
|
+
]);
|
138
|
+
return extractOperationSet(operationSet);
|
139
|
+
}
|
140
|
+
async getOperationsToSwap(accountClusterId, swapType, input, output, gasToken) {
|
141
|
+
const formattedInput = input
|
142
|
+
? {
|
143
|
+
...input,
|
144
|
+
tokenSources: input?.tokenSources.map(({ chainId, address }) => ({
|
145
|
+
chainId: getOrbyChainId(chainId),
|
146
|
+
address,
|
147
|
+
})),
|
148
|
+
}
|
149
|
+
: undefined;
|
150
|
+
const formattedOutput = output
|
151
|
+
? {
|
152
|
+
...output,
|
153
|
+
tokenDestination: output?.tokenDestination
|
154
|
+
? {
|
155
|
+
chainId: getOrbyChainId(output.tokenDestination.chainId),
|
156
|
+
address: output.tokenDestination.address,
|
157
|
+
}
|
158
|
+
: undefined,
|
159
|
+
}
|
160
|
+
: undefined;
|
161
|
+
const formattedGasToken = gasToken
|
162
|
+
? {
|
163
|
+
...gasToken,
|
164
|
+
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
165
|
+
chainId: getOrbyChainId(chainId),
|
166
|
+
address,
|
167
|
+
})),
|
168
|
+
}
|
169
|
+
: undefined;
|
170
|
+
const operationSet = await this.sendRequest("orby_getOperationsToSwap", [
|
171
|
+
{
|
172
|
+
accountClusterId,
|
173
|
+
swapType,
|
174
|
+
input: formattedInput,
|
175
|
+
output: formattedOutput,
|
176
|
+
gasToken: formattedGasToken,
|
177
|
+
},
|
178
|
+
]);
|
179
|
+
return extractOperationSet(operationSet);
|
180
|
+
}
|
181
|
+
async getQuote(accountClusterId, swapType, input, output) {
|
182
|
+
const formattedInput = input
|
183
|
+
? {
|
184
|
+
...input,
|
185
|
+
tokenSources: input?.tokenSources.map(({ chainId, address }) => ({
|
186
|
+
chainId: getOrbyChainId(chainId),
|
187
|
+
address,
|
188
|
+
})),
|
189
|
+
}
|
190
|
+
: undefined;
|
191
|
+
const formattedOutput = output
|
192
|
+
? {
|
193
|
+
...output,
|
194
|
+
tokenDestination: output?.tokenDestination
|
195
|
+
? {
|
196
|
+
chainId: getOrbyChainId(output.tokenDestination.chainId),
|
197
|
+
address: output.tokenDestination.address,
|
198
|
+
}
|
199
|
+
: undefined,
|
200
|
+
}
|
201
|
+
: undefined;
|
202
|
+
const operationSet = await this.sendRequest("orby_getQuote", [
|
203
|
+
{
|
204
|
+
accountClusterId,
|
205
|
+
swapType,
|
206
|
+
input: formattedInput,
|
207
|
+
output: formattedOutput,
|
208
|
+
},
|
209
|
+
]);
|
210
|
+
return extractOperationSet(operationSet);
|
211
|
+
}
|
212
|
+
async getOperationsToBridge(accountClusterId, standardizedTokenId, amount, tokenSources, tokenDestination, gasToken) {
|
213
|
+
const formattedTokenSources = tokenSources.map(({ chainId, address }) => ({
|
214
|
+
chainId: getOrbyChainId(chainId),
|
215
|
+
address,
|
216
|
+
}));
|
217
|
+
const formattedDestination = tokenDestination
|
218
|
+
? {
|
219
|
+
chainId: getOrbyChainId(tokenDestination.chainId),
|
220
|
+
address: tokenDestination.address,
|
221
|
+
}
|
222
|
+
: undefined;
|
223
|
+
const formattedGasToken = gasToken
|
224
|
+
? {
|
225
|
+
...gasToken,
|
226
|
+
tokenSources: gasToken.tokenSources?.map(({ chainId, address }) => ({
|
227
|
+
chainId: getOrbyChainId(chainId),
|
228
|
+
address,
|
229
|
+
})),
|
230
|
+
}
|
231
|
+
: undefined;
|
232
|
+
const operationSet = await this.sendRequest("orby_getOperationsToBridge", [
|
233
|
+
{
|
234
|
+
accountClusterId,
|
235
|
+
standardizedTokenId,
|
236
|
+
amount,
|
237
|
+
tokenSources: formattedTokenSources,
|
238
|
+
tokenDestination: formattedDestination,
|
239
|
+
gasToken: formattedGasToken,
|
240
|
+
},
|
241
|
+
]);
|
242
|
+
return extractOperationSet(operationSet);
|
243
|
+
}
|
244
|
+
subscribeToOperationStatuses(ids, onOperationStatusesUpdateCallback) {
|
245
|
+
let intervalId = null;
|
246
|
+
let totalWaitTime = 0;
|
247
|
+
if (ids && ids?.length > 0) {
|
248
|
+
const waitTime = 500;
|
249
|
+
intervalId = setInterval(async () => {
|
250
|
+
let statusSummary = OperationStatusType.WAITING_PRECONDITION;
|
251
|
+
try {
|
252
|
+
const statuses = ids && ids?.length > 0
|
253
|
+
? await this?.getOperationStatuses(ids)
|
254
|
+
: undefined;
|
255
|
+
if (!ids || ids?.length == 0) {
|
256
|
+
statusSummary = OperationStatusType.NOT_FOUND;
|
257
|
+
}
|
258
|
+
else if (!statuses) {
|
259
|
+
statusSummary = OperationStatusType.NOT_FOUND;
|
260
|
+
}
|
261
|
+
else if (statuses.some((status) => status.status == OperationStatusType.FAILED)) {
|
262
|
+
statusSummary = OperationStatusType.FAILED;
|
263
|
+
}
|
264
|
+
else if (statuses.every((status) => status.status == OperationStatusType.SUCCESSFUL)) {
|
265
|
+
statusSummary = OperationStatusType.SUCCESSFUL;
|
266
|
+
}
|
267
|
+
const primaryOperation = statuses?.find((status) => status.type == OperationType.FINAL_TRANSACTION);
|
268
|
+
if (primaryOperation?.status == OperationStatusType.PENDING) {
|
269
|
+
statusSummary = OperationStatusType.PENDING;
|
270
|
+
}
|
271
|
+
onOperationStatusesUpdateCallback?.(statusSummary, primaryOperation, statuses);
|
222
272
|
}
|
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)];
|
273
|
+
catch (error) {
|
274
|
+
console.error("[useWaitForStatusCompletion]", error);
|
237
275
|
}
|
238
|
-
|
239
|
-
|
240
|
-
|
241
|
-
|
242
|
-
|
243
|
-
|
244
|
-
|
245
|
-
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
|
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)];
|
276
|
+
finally {
|
277
|
+
totalWaitTime += waitTime;
|
278
|
+
if (intervalId &&
|
279
|
+
OperationStatusType.WAITING_PRECONDITION != statusSummary) {
|
280
|
+
clearInterval(intervalId);
|
281
|
+
intervalId = null;
|
282
|
+
}
|
283
|
+
else if (intervalId && totalWaitTime >= 60_000) {
|
284
|
+
// we cant wait for more than 2 ETH blocks
|
285
|
+
clearInterval(intervalId);
|
286
|
+
intervalId = null;
|
287
|
+
}
|
259
288
|
}
|
260
|
-
});
|
261
|
-
}
|
262
|
-
|
263
|
-
|
264
|
-
|
265
|
-
|
289
|
+
}, waitTime);
|
290
|
+
}
|
291
|
+
return { intervalId };
|
292
|
+
}
|
293
|
+
async sendOperationSet(accountClusterId, operationSet, signOperation) {
|
294
|
+
const signedOperations = [];
|
295
|
+
const operations = operationSet.intents
|
296
|
+
?.map((intent) => intent.intentOperations)
|
297
|
+
.flat()
|
298
|
+
?.concat(operationSet.primaryOperation)
|
299
|
+
.filter((value) => value != undefined && value != null);
|
300
|
+
if (operations?.length == 0) {
|
301
|
+
return { success: true, operationResponses: [] };
|
302
|
+
}
|
303
|
+
else if (!operations) {
|
304
|
+
return { success: false };
|
305
|
+
}
|
306
|
+
const hasPrimaryOperation = operations.find((operation) => operation.type == OperationType.FINAL_TRANSACTION);
|
307
|
+
if (!hasPrimaryOperation) {
|
308
|
+
return { success: false };
|
309
|
+
}
|
310
|
+
// Loop through all the operations and sign them
|
311
|
+
for (let i = 0; i < operations.length; i++) {
|
312
|
+
const signature = await signOperation(operations[i]);
|
313
|
+
if (!signature) {
|
314
|
+
return { success: false };
|
315
|
+
}
|
316
|
+
signedOperations.push(signature);
|
317
|
+
}
|
318
|
+
const { operationSetId, operationResponses } = await this.sendSignedOperations(accountClusterId, signedOperations);
|
319
|
+
return {
|
320
|
+
operationSetId,
|
321
|
+
operationResponses,
|
322
|
+
success: true,
|
323
|
+
primaryOperationStatus: {
|
324
|
+
type: OperationType.FINAL_TRANSACTION,
|
325
|
+
status: OperationStatusType.WAITING_PRECONDITION,
|
326
|
+
},
|
327
|
+
};
|
328
|
+
}
|
329
|
+
}
|
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: {
|