@orb-labs/orby-core 0.0.26 → 0.0.28
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 +11 -1
- package/dist/cjs/actions/blockchain.js +2 -1
- package/dist/cjs/actions/operation.d.ts +5 -1
- package/dist/cjs/actions/operation.js +66 -64
- package/dist/cjs/constants.d.ts +2 -2
- package/dist/cjs/entities/library_request.d.ts +13 -0
- package/dist/cjs/entities/library_request.js +12 -0
- package/dist/cjs/enums.d.ts +11 -2
- package/dist/cjs/enums.js +10 -1
- package/dist/cjs/interfaces/operation.d.ts +5 -1
- package/dist/cjs/types.d.ts +8 -12
- package/dist/cjs/utils/action_helpers.d.ts +1 -1
- package/dist/cjs/utils/action_helpers.js +23 -28
- package/dist/cjs/utils/utils.d.ts +3 -0
- package/dist/cjs/utils/utils.js +20 -6
- package/dist/esm/actions/blockchain.js +2 -1
- package/dist/esm/actions/operation.d.ts +5 -1
- package/dist/esm/actions/operation.js +68 -66
- package/dist/esm/constants.d.ts +2 -2
- package/dist/esm/entities/library_request.d.ts +13 -0
- package/dist/esm/entities/library_request.js +12 -0
- package/dist/esm/enums.d.ts +11 -2
- package/dist/esm/enums.js +10 -1
- package/dist/esm/interfaces/operation.d.ts +5 -1
- package/dist/esm/types.d.ts +8 -12
- package/dist/esm/utils/action_helpers.d.ts +1 -1
- package/dist/esm/utils/action_helpers.js +21 -26
- package/dist/esm/utils/utils.d.ts +3 -0
- package/dist/esm/utils/utils.js +17 -5
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
@@ -2,7 +2,17 @@
|
|
2
2
|
|
3
3
|
### Unreleased
|
4
4
|
|
5
|
-
### 0.0.
|
5
|
+
### 0.0.28
|
6
|
+
|
7
|
+
- returning the correct status
|
8
|
+
- using the same extractBlockchainInformation for all the places we need to parse blockchain information from Orby
|
9
|
+
- adding the getOperationSet function
|
10
|
+
|
11
|
+
### 0.0.27
|
12
|
+
|
13
|
+
- fix gasToken input
|
14
|
+
|
15
|
+
### 0.0.26
|
6
16
|
|
7
17
|
- updating variable name for getOperationsToTransferToken
|
8
18
|
- removing default array for gas token source
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BlockchainActions = void 0;
|
4
4
|
const action_helpers_js_1 = require("../utils/action_helpers.js");
|
5
5
|
const library_request_js_1 = require("../entities/library_request.js");
|
6
|
+
const index_js_1 = require("../index.js");
|
6
7
|
class BlockchainActions extends library_request_js_1.LibraryRequest {
|
7
8
|
constructor(library, client, provider) {
|
8
9
|
super(library, client, provider);
|
@@ -14,7 +15,7 @@ class BlockchainActions extends library_request_js_1.LibraryRequest {
|
|
14
15
|
console.error("[getBlockchainInformation]", code, message);
|
15
16
|
return undefined;
|
16
17
|
}
|
17
|
-
return (0,
|
18
|
+
return (0, index_js_1.extractBlockchainInformation)(blockchain);
|
18
19
|
}
|
19
20
|
async listBlockchainsInformation(offset, limit) {
|
20
21
|
const { pageInfo, edges, code, message } = await this.sendRequest("orby_listBlockchainsInformation", [{ offset, limit }]);
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AccountCluster, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
|
1
|
+
import { AccountCluster, Activity, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
|
2
2
|
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
3
3
|
import { LIBRARY_TYPE, OperationStatusType, QuoteType } from "../enums.js";
|
4
4
|
import { LibraryRequest } from "../entities/library_request.js";
|
@@ -32,6 +32,7 @@ export declare class OperationActions extends LibraryRequest {
|
|
32
32
|
operationSetId: string;
|
33
33
|
operationResponses: OperationStatus[];
|
34
34
|
}>;
|
35
|
+
getOperationSet(operationSetId: string): Promise<Activity>;
|
35
36
|
getOperationStatuses(operationIds: string[]): Promise<OperationStatus[]>;
|
36
37
|
estimateFiatCostToExecuteTransaction(data: string, to?: string, value?: bigint): Promise<CurrencyAmount>;
|
37
38
|
estimateFiatCostToSignTypedData(data: string): Promise<CurrencyAmount>;
|
@@ -94,6 +95,9 @@ export declare class OperationActions extends LibraryRequest {
|
|
94
95
|
address?: string;
|
95
96
|
}[];
|
96
97
|
}): Promise<OperationSet>;
|
98
|
+
subscribeToOperationSetStatus(operationSetId?: string, onOperationSetStatusUpdateCallback?: (activity?: Activity) => void, timeout?: number): {
|
99
|
+
intervalId: NodeJS.Timeout | null;
|
100
|
+
};
|
97
101
|
subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void, timout?: number): {
|
98
102
|
intervalId: NodeJS.Timeout | null;
|
99
103
|
};
|
@@ -15,62 +15,35 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
15
15
|
super(library, client, provider);
|
16
16
|
}
|
17
17
|
async getOperationsToExecuteTransaction(accountClusterId, data, to, value, gasToken) {
|
18
|
-
const formattedGasToken = gasToken
|
19
|
-
? {
|
20
|
-
...gasToken,
|
21
|
-
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
22
|
-
chainId: await this.getOrbyChainId(chainId),
|
23
|
-
address,
|
24
|
-
}))),
|
25
|
-
}
|
26
|
-
: undefined;
|
27
18
|
const operationSet = await this.sendRequest("orby_getOperationsToExecuteTransaction", [
|
28
19
|
{
|
29
20
|
accountClusterId,
|
30
21
|
to,
|
31
22
|
data,
|
32
23
|
value,
|
33
|
-
gasToken:
|
24
|
+
gasToken: await this.formatGasToken(gasToken),
|
34
25
|
},
|
35
26
|
]);
|
36
27
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
37
28
|
}
|
38
29
|
async getOperationsToSignTypedData(accountClusterId, data, gasToken) {
|
39
|
-
const formattedGasToken = gasToken
|
40
|
-
? {
|
41
|
-
...gasToken,
|
42
|
-
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
43
|
-
chainId: await this.getOrbyChainId(chainId),
|
44
|
-
address,
|
45
|
-
}))),
|
46
|
-
}
|
47
|
-
: undefined;
|
48
30
|
const operationSet = await this.sendRequest("orby_getOperationsToSignTypedData", [
|
49
31
|
{
|
50
32
|
accountClusterId,
|
51
33
|
data,
|
52
|
-
gasToken:
|
34
|
+
gasToken: await this.formatGasToken(gasToken),
|
53
35
|
},
|
54
36
|
]);
|
55
37
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
56
38
|
}
|
57
39
|
async getOperationsToSignTransactionOrSignTypedData(accountClusterId, data, to, value, gasToken) {
|
58
|
-
const formattedGasToken = gasToken
|
59
|
-
? {
|
60
|
-
...gasToken,
|
61
|
-
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
62
|
-
chainId: await this.getOrbyChainId(chainId),
|
63
|
-
address,
|
64
|
-
}))),
|
65
|
-
}
|
66
|
-
: undefined;
|
67
40
|
const operationSet = await this.sendRequest("orby_getOperationsToSignTransactionOrSignTypedData", [
|
68
41
|
{
|
69
42
|
accountClusterId,
|
70
43
|
to,
|
71
44
|
data,
|
72
45
|
value,
|
73
|
-
gasToken:
|
46
|
+
gasToken: await this.formatGasToken(gasToken),
|
74
47
|
},
|
75
48
|
]);
|
76
49
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
@@ -124,6 +97,14 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
124
97
|
operationResponses: (0, action_helpers_js_1.extractOperationStatuses)(operationResponses),
|
125
98
|
};
|
126
99
|
}
|
100
|
+
async getOperationSet(operationSetId) {
|
101
|
+
const { activity, code, message } = await this.sendRequest("orby_getOperationSet", [{ operationSetId }]);
|
102
|
+
if (code && message) {
|
103
|
+
console.error("[getOperationSet]", code, message);
|
104
|
+
return undefined;
|
105
|
+
}
|
106
|
+
return (0, action_helpers_js_1.extractActivity)(activity);
|
107
|
+
}
|
127
108
|
async getOperationStatuses(operationIds) {
|
128
109
|
const { operationStatuses } = await this.sendRequest("orby_getOperationStatuses", [{ operationIds }]);
|
129
110
|
return (0, action_helpers_js_1.extractOperationStatuses)(operationStatuses);
|
@@ -151,15 +132,6 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
151
132
|
return currency_amount_js_1.CurrencyAmount.toCurrencyAmount(estimatedCost);
|
152
133
|
}
|
153
134
|
async getOperationsToTransferToken(accountClusterId, standardizedTokenId, amount, recipient, gasToken) {
|
154
|
-
const formattedGasToken = gasToken
|
155
|
-
? {
|
156
|
-
...gasToken,
|
157
|
-
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
158
|
-
chainId: await this.getOrbyChainId(chainId),
|
159
|
-
address,
|
160
|
-
}))),
|
161
|
-
}
|
162
|
-
: undefined;
|
163
135
|
const formattedRecepient = {
|
164
136
|
chainId: await this.getOrbyChainId(recipient.chainId),
|
165
137
|
address: recipient.address,
|
@@ -170,7 +142,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
170
142
|
standardizedTokenId,
|
171
143
|
amount,
|
172
144
|
recipient: formattedRecepient,
|
173
|
-
gasToken:
|
145
|
+
gasToken: await this.formatGasToken(gasToken),
|
174
146
|
},
|
175
147
|
]);
|
176
148
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
@@ -196,22 +168,13 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
196
168
|
: undefined,
|
197
169
|
}
|
198
170
|
: undefined;
|
199
|
-
const formattedGasToken = gasToken
|
200
|
-
? {
|
201
|
-
...gasToken,
|
202
|
-
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
203
|
-
chainId: await this.getOrbyChainId(chainId),
|
204
|
-
address,
|
205
|
-
}))),
|
206
|
-
}
|
207
|
-
: undefined;
|
208
171
|
const operationSet = await this.sendRequest("orby_getOperationsToSwap", [
|
209
172
|
{
|
210
173
|
accountClusterId,
|
211
174
|
swapType,
|
212
175
|
input: formattedInput,
|
213
176
|
output: formattedOutput,
|
214
|
-
gasToken:
|
177
|
+
gasToken: await this.formatGasToken(gasToken),
|
215
178
|
},
|
216
179
|
]);
|
217
180
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
@@ -258,15 +221,6 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
258
221
|
address: tokenDestination.address,
|
259
222
|
}
|
260
223
|
: undefined;
|
261
|
-
const formattedGasToken = gasToken
|
262
|
-
? {
|
263
|
-
...gasToken,
|
264
|
-
tokenSources: await Promise.all(gasToken.tokenSources?.map(async ({ chainId, address }) => ({
|
265
|
-
chainId: await this.getOrbyChainId(chainId),
|
266
|
-
address,
|
267
|
-
}))),
|
268
|
-
}
|
269
|
-
: undefined;
|
270
224
|
const operationSet = await this.sendRequest("orby_getOperationsToBridge", [
|
271
225
|
{
|
272
226
|
accountClusterId,
|
@@ -274,11 +228,52 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
274
228
|
amount,
|
275
229
|
tokenSources: formattedTokenSources,
|
276
230
|
tokenDestination: formattedDestination,
|
277
|
-
gasToken:
|
231
|
+
gasToken: await this.formatGasToken(gasToken),
|
278
232
|
},
|
279
233
|
]);
|
280
234
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
281
235
|
}
|
236
|
+
subscribeToOperationSetStatus(operationSetId, onOperationSetStatusUpdateCallback, timeout) {
|
237
|
+
let intervalId = null;
|
238
|
+
let totalWaitTime = 0;
|
239
|
+
const timeoutOrDefault = timeout ?? 300_000;
|
240
|
+
if (operationSetId) {
|
241
|
+
const waitTime = 500;
|
242
|
+
intervalId = setInterval(async () => {
|
243
|
+
let statusSummary = enums_js_1.ActivityStatus.WAITING_PRECONDITION;
|
244
|
+
try {
|
245
|
+
const activity = operationSetId
|
246
|
+
? await this?.getOperationSet(operationSetId)
|
247
|
+
: undefined;
|
248
|
+
if (activity) {
|
249
|
+
statusSummary = activity?.overallStatus;
|
250
|
+
}
|
251
|
+
onOperationSetStatusUpdateCallback?.(activity);
|
252
|
+
}
|
253
|
+
catch (error) {
|
254
|
+
console.error("[subscribeToOperationSetStatus]", error);
|
255
|
+
}
|
256
|
+
finally {
|
257
|
+
totalWaitTime += waitTime;
|
258
|
+
if (intervalId &&
|
259
|
+
![
|
260
|
+
enums_js_1.ActivityStatus.WAITING_TOKEN_APPROVAL_TRANSACTIONS,
|
261
|
+
enums_js_1.ActivityStatus.WAITING_GAS_ABSTRACTION,
|
262
|
+
enums_js_1.ActivityStatus.WAITING_PRECONDITION,
|
263
|
+
].includes(statusSummary)) {
|
264
|
+
clearInterval(intervalId);
|
265
|
+
intervalId = null;
|
266
|
+
}
|
267
|
+
else if (intervalId && totalWaitTime >= timeoutOrDefault) {
|
268
|
+
// we cant wait for more than 2 ETH blocks
|
269
|
+
clearInterval(intervalId);
|
270
|
+
intervalId = null;
|
271
|
+
}
|
272
|
+
}
|
273
|
+
}, waitTime);
|
274
|
+
}
|
275
|
+
return { intervalId };
|
276
|
+
}
|
282
277
|
subscribeToOperationStatuses(ids, onOperationStatusesUpdateCallback, timout) {
|
283
278
|
let intervalId = null;
|
284
279
|
let totalWaitTime = 0;
|
@@ -305,18 +300,25 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
305
300
|
statusSummary = enums_js_1.OperationStatusType.SUCCESSFUL;
|
306
301
|
}
|
307
302
|
primaryOperation = statuses?.find((status) => status.type == enums_js_1.OperationType.FINAL_TRANSACTION);
|
308
|
-
if (
|
309
|
-
|
303
|
+
if ([
|
304
|
+
enums_js_1.OperationStatusType.PENDING,
|
305
|
+
enums_js_1.OperationStatusType.SUCCESSFUL,
|
306
|
+
].includes(primaryOperation?.status)) {
|
307
|
+
statusSummary = primaryOperation?.status;
|
310
308
|
}
|
311
309
|
onOperationStatusesUpdateCallback?.(statusSummary, primaryOperation, statuses);
|
312
310
|
}
|
313
311
|
catch (error) {
|
314
|
-
console.error("[
|
312
|
+
console.error("[subscribeToOperationStatuses]", error);
|
315
313
|
}
|
316
314
|
finally {
|
317
315
|
totalWaitTime += waitTime;
|
318
316
|
if (intervalId &&
|
319
|
-
|
317
|
+
![
|
318
|
+
enums_js_1.OperationStatusType.WAITING_TOKEN_APPROVAL_TRANSACTIONS,
|
319
|
+
enums_js_1.OperationStatusType.WAITING_GAS_ABSTRACTION,
|
320
|
+
enums_js_1.OperationStatusType.WAITING_PRECONDITION,
|
321
|
+
].includes(statusSummary)) {
|
320
322
|
clearInterval(intervalId);
|
321
323
|
intervalId = null;
|
322
324
|
}
|
package/dist/cjs/constants.d.ts
CHANGED
@@ -1,9 +1,9 @@
|
|
1
1
|
import { Currency } from "./entities/financial/currency.js";
|
2
|
-
import {
|
2
|
+
import { BlockchainInformation } from "./types.js";
|
3
3
|
export declare const Big: any;
|
4
4
|
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
5
5
|
export declare const ONE_ADDRESS = "0x0000000000000000000000000000000000000001";
|
6
6
|
export declare const TWO_ADDRESS = "0x0000000000000000000000000000000000000002";
|
7
7
|
export declare const NATIVE_TOKEN_ADDRESS = "0x0000000000000000000000000000000000000000";
|
8
|
-
export declare const CHAIN_CONFIGS: Record<number,
|
8
|
+
export declare const CHAIN_CONFIGS: Record<number, BlockchainInformation>;
|
9
9
|
export declare const FIAT_CURRENCY: Currency;
|
@@ -8,4 +8,17 @@ export declare class LibraryRequest {
|
|
8
8
|
protected getOrbyChainId: (chainId: bigint) => Promise<string>;
|
9
9
|
protected getVirtualEnvironment: (id: bigint) => Promise<VMType>;
|
10
10
|
protected providerUrl(): string;
|
11
|
+
formatGasToken(gasToken?: {
|
12
|
+
standardizedTokenId: string;
|
13
|
+
tokenSources?: {
|
14
|
+
chainId: bigint;
|
15
|
+
address?: string;
|
16
|
+
}[];
|
17
|
+
}): Promise<{
|
18
|
+
tokenSources: {
|
19
|
+
chainId: string;
|
20
|
+
address: string;
|
21
|
+
}[] | undefined;
|
22
|
+
standardizedTokenId: string;
|
23
|
+
} | undefined>;
|
11
24
|
}
|
@@ -73,5 +73,17 @@ class LibraryRequest {
|
|
73
73
|
const endIndex = url.indexOf(match[1]) + match[1].length;
|
74
74
|
return url.slice(0, endIndex);
|
75
75
|
}
|
76
|
+
async formatGasToken(gasToken) {
|
77
|
+
if (!gasToken) {
|
78
|
+
return undefined;
|
79
|
+
}
|
80
|
+
const tokenSources = gasToken.tokenSources
|
81
|
+
? await Promise.all(gasToken.tokenSources.map(async ({ chainId, address }) => ({
|
82
|
+
chainId: await this.getOrbyChainId(chainId),
|
83
|
+
address,
|
84
|
+
})))
|
85
|
+
: undefined;
|
86
|
+
return { ...gasToken, tokenSources };
|
87
|
+
}
|
76
88
|
}
|
77
89
|
exports.LibraryRequest = LibraryRequest;
|
package/dist/cjs/enums.d.ts
CHANGED
@@ -48,11 +48,15 @@ export declare enum Category {
|
|
48
48
|
TYPED_DATA_SIGNATURE = "TYPED_DATA_SIGNATURE"
|
49
49
|
}
|
50
50
|
export declare enum OperationStatusType {
|
51
|
+
CANCELLED = "CANCELLED",
|
51
52
|
FAILED = "FAILED",
|
52
53
|
NOT_FOUND = "NOT_FOUND",
|
53
54
|
PENDING = "PENDING",
|
54
55
|
SUCCESSFUL = "SUCCESSFUL",
|
55
|
-
|
56
|
+
WAITING_GAS_ABSTRACTION = "WAITING_GAS_ABSTRACTION",
|
57
|
+
WAITING_TOKEN_APPROVAL_TRANSACTIONS = "WAITING_TOKEN_APPROVAL_TRANSACTIONS",
|
58
|
+
WAITING_PRECONDITION = "WAITING_PRECONDITION",
|
59
|
+
WAITING_TIMEOUT = "WAITING_TIMEOUT"
|
56
60
|
}
|
57
61
|
export declare enum QuoteType {
|
58
62
|
EXACT_INPUT = "EXACT_INPUT",
|
@@ -65,8 +69,13 @@ export declare enum Order {
|
|
65
69
|
export declare enum ActivityStatus {
|
66
70
|
CANCELLED = "CANCELLED",
|
67
71
|
FAILED = "FAILED",
|
72
|
+
NOT_FOUND = "NOT_FOUND",
|
68
73
|
PENDING = "PENDING",
|
69
|
-
|
74
|
+
SUCCESSFUL = "SUCCESSFUL",
|
75
|
+
WAITING_GAS_ABSTRACTION = "WAITING_GAS_ABSTRACTION",
|
76
|
+
WAITING_TOKEN_APPROVAL_TRANSACTIONS = "WAITING_TOKEN_APPROVAL_TRANSACTIONS",
|
77
|
+
WAITING_PRECONDITION = "WAITING_PRECONDITION",
|
78
|
+
WAITING_TIMEOUT = "WAITING_TIMEOUT"
|
70
79
|
}
|
71
80
|
export declare enum BlockchainEnvironment {
|
72
81
|
MAINNET = "MAINNET",
|
package/dist/cjs/enums.js
CHANGED
@@ -60,11 +60,15 @@ var Category;
|
|
60
60
|
})(Category || (exports.Category = Category = {}));
|
61
61
|
var OperationStatusType;
|
62
62
|
(function (OperationStatusType) {
|
63
|
+
OperationStatusType["CANCELLED"] = "CANCELLED";
|
63
64
|
OperationStatusType["FAILED"] = "FAILED";
|
64
65
|
OperationStatusType["NOT_FOUND"] = "NOT_FOUND";
|
65
66
|
OperationStatusType["PENDING"] = "PENDING";
|
66
67
|
OperationStatusType["SUCCESSFUL"] = "SUCCESSFUL";
|
68
|
+
OperationStatusType["WAITING_GAS_ABSTRACTION"] = "WAITING_GAS_ABSTRACTION";
|
69
|
+
OperationStatusType["WAITING_TOKEN_APPROVAL_TRANSACTIONS"] = "WAITING_TOKEN_APPROVAL_TRANSACTIONS";
|
67
70
|
OperationStatusType["WAITING_PRECONDITION"] = "WAITING_PRECONDITION";
|
71
|
+
OperationStatusType["WAITING_TIMEOUT"] = "WAITING_TIMEOUT";
|
68
72
|
})(OperationStatusType || (exports.OperationStatusType = OperationStatusType = {}));
|
69
73
|
var QuoteType;
|
70
74
|
(function (QuoteType) {
|
@@ -80,8 +84,13 @@ var ActivityStatus;
|
|
80
84
|
(function (ActivityStatus) {
|
81
85
|
ActivityStatus["CANCELLED"] = "CANCELLED";
|
82
86
|
ActivityStatus["FAILED"] = "FAILED";
|
87
|
+
ActivityStatus["NOT_FOUND"] = "NOT_FOUND";
|
83
88
|
ActivityStatus["PENDING"] = "PENDING";
|
84
|
-
ActivityStatus["
|
89
|
+
ActivityStatus["SUCCESSFUL"] = "SUCCESSFUL";
|
90
|
+
ActivityStatus["WAITING_GAS_ABSTRACTION"] = "WAITING_GAS_ABSTRACTION";
|
91
|
+
ActivityStatus["WAITING_TOKEN_APPROVAL_TRANSACTIONS"] = "WAITING_TOKEN_APPROVAL_TRANSACTIONS";
|
92
|
+
ActivityStatus["WAITING_PRECONDITION"] = "WAITING_PRECONDITION";
|
93
|
+
ActivityStatus["WAITING_TIMEOUT"] = "WAITING_TIMEOUT";
|
85
94
|
})(ActivityStatus || (exports.ActivityStatus = ActivityStatus = {}));
|
86
95
|
var BlockchainEnvironment;
|
87
96
|
(function (BlockchainEnvironment) {
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import { AccountCluster, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
|
1
|
+
import { AccountCluster, Activity, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
|
2
2
|
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
3
3
|
import { OperationStatusType, QuoteType } from "../enums.js";
|
4
4
|
export interface IOperationActions {
|
@@ -31,6 +31,7 @@ export interface IOperationActions {
|
|
31
31
|
operationResponses: OperationStatus[];
|
32
32
|
}>;
|
33
33
|
getOperationStatuses(operationIds: string[]): Promise<OperationStatus[]>;
|
34
|
+
getOperationSet(operationSetId: string): Promise<Activity>;
|
34
35
|
estimateFiatCostToExecuteTransaction(data: string, to?: string, value?: bigint): Promise<CurrencyAmount>;
|
35
36
|
estimateFiatCostToSignTypedData(data: string): Promise<CurrencyAmount>;
|
36
37
|
getOperationsToTransferToken(accountClusterId: string, standardizedTokenId: string, amount: bigint, recipient: {
|
@@ -95,6 +96,9 @@ export interface IOperationActions {
|
|
95
96
|
subscribeToOperationStatuses(ids?: string[], onOperationStatusesUpdateCallback?: (statusSummary: OperationStatusType, primaryOperationStatus?: OperationStatus, allOperationStatuses?: OperationStatus[]) => void, timout?: number): {
|
96
97
|
intervalId: NodeJS.Timeout | null;
|
97
98
|
};
|
99
|
+
subscribeToOperationSetStatus(operationSetId?: string, onOperationSetStatusUpdateCallback?: (activity?: Activity) => void, timout?: number): {
|
100
|
+
intervalId: NodeJS.Timeout | null;
|
101
|
+
};
|
98
102
|
sendOperationSet(accountCluster: AccountCluster, operationSet: OperationSet, signTransaction?: (operation: OnchainOperation) => Promise<string | undefined>, signUserOperation?: (operations: OnchainOperation[], accountAddress: string, chainId: bigint, txRpcUrl: string) => Promise<UserOperation | undefined>, signTypedData?: (operation: OnchainOperation) => Promise<string | undefined>): Promise<{
|
99
103
|
success: boolean;
|
100
104
|
operationSetId?: string;
|
package/dist/cjs/types.d.ts
CHANGED
@@ -95,6 +95,8 @@ export type Activity = {
|
|
95
95
|
aggregateNetworkFeesInFiatCurrency?: CurrencyAmount;
|
96
96
|
aggregateProtocolFeesInFiatCurrency?: CurrencyAmount;
|
97
97
|
category: Category;
|
98
|
+
gasTokenAmount?: FungibleTokenAmount;
|
99
|
+
gasTokenAmountInFiatCurrency?: CurrencyAmount;
|
98
100
|
initiateAt?: Date;
|
99
101
|
inputState?: State;
|
100
102
|
operationStatuses: OperationStatus[];
|
@@ -120,10 +122,13 @@ export type StandardizedToken = {
|
|
120
122
|
tokens: FungibleToken[];
|
121
123
|
};
|
122
124
|
export type BlockchainInformation = {
|
123
|
-
chainId: bigint;
|
124
125
|
environment: BlockchainEnvironment;
|
125
|
-
|
126
|
-
|
126
|
+
chainId: bigint;
|
127
|
+
vmType: VMType;
|
128
|
+
logoUrl: string;
|
129
|
+
name: string;
|
130
|
+
genesisBlockHash?: string;
|
131
|
+
nativeCurrency: Currency;
|
127
132
|
};
|
128
133
|
export type ContractAllowlistWithAllMethodFallback = {
|
129
134
|
contractAddress: string;
|
@@ -161,15 +166,6 @@ export type GasSponsorshipData = {
|
|
161
166
|
totalGasSpent: CurrencyAmount;
|
162
167
|
totalTransactionCount: bigint;
|
163
168
|
};
|
164
|
-
export type ChainConfigs = {
|
165
|
-
environment: BlockchainEnvironment;
|
166
|
-
chainId: bigint;
|
167
|
-
vmType: VMType;
|
168
|
-
logoUrl: string;
|
169
|
-
name: string;
|
170
|
-
genesisBlockHash?: string;
|
171
|
-
nativeCurrency: Currency;
|
172
|
-
};
|
173
169
|
export type VirtualNodeRpcUrlForSupportedChain = {
|
174
170
|
chainId: string;
|
175
171
|
entrypointAccountAddress: string;
|
@@ -6,13 +6,13 @@ export declare const extractIntent: (intent?: any) => Intent;
|
|
6
6
|
export declare const extractOperationStatuses: (operationStatus?: any[]) => OperationStatus[];
|
7
7
|
export declare const extractOperationStatus: (status?: any) => OperationStatus;
|
8
8
|
export declare const extractActivities: (activities?: any[]) => Activity[];
|
9
|
+
export declare const extractActivity: (activity?: any) => Activity;
|
9
10
|
export declare const extractFungibleTokenOverview: (overview?: any) => FungibleTokenOverview;
|
10
11
|
export declare const extractStandardizedBalances: (balances?: any) => StandardizedBalance[];
|
11
12
|
export declare const extractStandardizedBalance: (balance?: any) => StandardizedBalance;
|
12
13
|
export declare const extractStandardizedTokens: (tokens?: any) => StandardizedToken[];
|
13
14
|
export declare const extractStandardizedToken: (token?: any) => StandardizedToken;
|
14
15
|
export declare const extractBlockchainInformations: (blockchainInformation?: any[]) => BlockchainInformation[];
|
15
|
-
export declare const extractBlockchainInformation: (blockchainInformation?: any) => BlockchainInformation;
|
16
16
|
export declare const extractMaxAmountPerInterval: (maxAmountPerInterval?: any) => MaxAmountPerInterval;
|
17
17
|
export declare const extractAllowlistWithOpenFallback: (allowlist?: any) => AllowlistWithOpenFallback;
|
18
18
|
export declare const extractGasSponsorshipPolicy: (gasSponsorshipPolicy?: any) => GasSponsorshipPolicy;
|
@@ -1,6 +1,6 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.extractGasSponsorshipData = exports.extractGasSponsorshipInformation = exports.extractGasSpendForInstance = exports.extractGasSpendForInstances = exports.extractGasSponsorshipPolicy = exports.extractAllowlistWithOpenFallback = exports.extractMaxAmountPerInterval = exports.
|
3
|
+
exports.extractGasSponsorshipData = exports.extractGasSponsorshipInformation = exports.extractGasSpendForInstance = exports.extractGasSpendForInstances = exports.extractGasSponsorshipPolicy = exports.extractAllowlistWithOpenFallback = exports.extractMaxAmountPerInterval = exports.extractBlockchainInformations = exports.extractStandardizedToken = exports.extractStandardizedTokens = exports.extractStandardizedBalance = exports.extractStandardizedBalances = exports.extractFungibleTokenOverview = exports.extractActivity = exports.extractActivities = exports.extractOperationStatus = exports.extractOperationStatuses = exports.extractIntent = exports.extractOnchainOperation = exports.extractOperationSet = exports.extractAccountCluster = void 0;
|
4
4
|
const enums_js_1 = require("../enums.js");
|
5
5
|
const currency_amount_js_1 = require("../entities/financial/currency_amount.js");
|
6
6
|
const state_js_1 = require("../entities/state.js");
|
@@ -124,22 +124,29 @@ const extractActivities = (activities) => {
|
|
124
124
|
if (!activities) {
|
125
125
|
return undefined;
|
126
126
|
}
|
127
|
-
return activities
|
128
|
-
|
129
|
-
|
130
|
-
aggregateFiatValueOfOutputState: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfOutputState),
|
131
|
-
aggregateNetworkFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateNetworkFeesInFiatCurrency),
|
132
|
-
aggregateProtocolFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateProtocolFeesInFiatCurrency),
|
133
|
-
category: activity.category,
|
134
|
-
initiateAt: activity.initiateAt,
|
135
|
-
inputState: state_js_1.State.toState(activity.inputState),
|
136
|
-
operationStatuses: (0, exports.extractOperationStatuses)(activity.operationStatuses),
|
137
|
-
outputState: state_js_1.State.toState(activity.outputState),
|
138
|
-
overallStatus: activity.overallStatus,
|
139
|
-
};
|
140
|
-
});
|
127
|
+
return activities
|
128
|
+
.map((activity) => (0, exports.extractActivity)(activity))
|
129
|
+
.filter(utils_js_1.notEmpty);
|
141
130
|
};
|
142
131
|
exports.extractActivities = extractActivities;
|
132
|
+
const extractActivity = (activity) => {
|
133
|
+
if (!activity) {
|
134
|
+
return undefined;
|
135
|
+
}
|
136
|
+
return {
|
137
|
+
aggregateFiatValueOfInputState: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfInputState),
|
138
|
+
aggregateFiatValueOfOutputState: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateFiatValueOfOutputState),
|
139
|
+
aggregateNetworkFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateNetworkFeesInFiatCurrency),
|
140
|
+
aggregateProtocolFeesInFiatCurrency: currency_amount_js_1.CurrencyAmount.toCurrencyAmount(activity.aggregateProtocolFeesInFiatCurrency),
|
141
|
+
category: activity.category,
|
142
|
+
initiateAt: activity.initiateAt,
|
143
|
+
inputState: state_js_1.State.toState(activity.inputState),
|
144
|
+
operationStatuses: (0, exports.extractOperationStatuses)(activity.operationStatuses),
|
145
|
+
outputState: state_js_1.State.toState(activity.outputState),
|
146
|
+
overallStatus: activity.overallStatus,
|
147
|
+
};
|
148
|
+
};
|
149
|
+
exports.extractActivity = extractActivity;
|
143
150
|
const extractFungibleTokenOverview = (overview) => {
|
144
151
|
if (!overview) {
|
145
152
|
return undefined;
|
@@ -189,21 +196,9 @@ const extractStandardizedToken = (token) => {
|
|
189
196
|
};
|
190
197
|
exports.extractStandardizedToken = extractStandardizedToken;
|
191
198
|
const extractBlockchainInformations = (blockchainInformation) => {
|
192
|
-
return blockchainInformation?.map((info) => (0,
|
199
|
+
return blockchainInformation?.map((info) => (0, utils_js_1.extractBlockchainInformation)(info));
|
193
200
|
};
|
194
201
|
exports.extractBlockchainInformations = extractBlockchainInformations;
|
195
|
-
const extractBlockchainInformation = (blockchainInformation) => {
|
196
|
-
if (!blockchainInformation) {
|
197
|
-
return undefined;
|
198
|
-
}
|
199
|
-
return {
|
200
|
-
chainId: (0, utils_js_1.getChainIdFromOrbyChainId)(blockchainInformation.chainId),
|
201
|
-
environment: blockchainInformation.environment,
|
202
|
-
logoUrl: blockchainInformation.logoUrl,
|
203
|
-
name: blockchainInformation.name,
|
204
|
-
};
|
205
|
-
};
|
206
|
-
exports.extractBlockchainInformation = extractBlockchainInformation;
|
207
202
|
const extractMaxAmountPerInterval = (maxAmountPerInterval) => {
|
208
203
|
if (!maxAmountPerInterval) {
|
209
204
|
return undefined;
|
@@ -3,7 +3,10 @@ import { Currency } from "../entities/financial/currency.js";
|
|
3
3
|
import { FungibleToken } from "../entities/financial/fungible_token.js";
|
4
4
|
import { FungibleTokenAmount } from "../entities/financial/fungible_token_amount.js";
|
5
5
|
import { CurrencyAmount } from "../entities/financial/currency_amount.js";
|
6
|
+
import { BlockchainInformation } from "../types.js";
|
7
|
+
export declare const notEmpty: <T>(value: T) => value is NonNullable<T>;
|
6
8
|
export declare const initializeBlockchainInformation: (orbyUrl: string) => Promise<void>;
|
9
|
+
export declare const extractBlockchainInformation: (blockchainInformation?: any) => BlockchainInformation;
|
7
10
|
export declare const getChainIdFromOrbyChainId: (value: string) => bigint | undefined;
|
8
11
|
export declare const getVirtualEnvironment: (id: bigint) => Promise<VMType>;
|
9
12
|
export declare const hasError: (data: any) => {
|
package/dist/cjs/utils/utils.js
CHANGED
@@ -1,12 +1,15 @@
|
|
1
1
|
"use strict";
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
3
|
-
exports.createNativeCurrencyAmount = exports.createNativeFungibleTokenAmount = exports.getNativeFungibleToken = exports.getNativeCurrency = exports.hasError = exports.getVirtualEnvironment = exports.getChainIdFromOrbyChainId = exports.initializeBlockchainInformation = void 0;
|
3
|
+
exports.createNativeCurrencyAmount = exports.createNativeFungibleTokenAmount = exports.getNativeFungibleToken = exports.getNativeCurrency = exports.hasError = exports.getVirtualEnvironment = exports.getChainIdFromOrbyChainId = exports.extractBlockchainInformation = exports.initializeBlockchainInformation = exports.notEmpty = void 0;
|
4
4
|
const constants_js_1 = require("../constants.js");
|
5
5
|
const validateAndParseAddress_js_1 = require("./validateAndParseAddress.js");
|
6
6
|
const currency_js_1 = require("../entities/financial/currency.js");
|
7
7
|
const fungible_token_js_1 = require("../entities/financial/fungible_token.js");
|
8
8
|
const fungible_token_amount_js_1 = require("../entities/financial/fungible_token_amount.js");
|
9
9
|
const currency_amount_js_1 = require("../entities/financial/currency_amount.js");
|
10
|
+
// used to filter out null and undefined values: https://stackoverflow.com/questions/43118692/typescript-filter-out-nulls-from-an-array
|
11
|
+
const notEmpty = (value) => value != undefined && value != null;
|
12
|
+
exports.notEmpty = notEmpty;
|
10
13
|
const initializeBlockchainInformation = async (orbyUrl) => {
|
11
14
|
const response = await fetch(orbyUrl, {
|
12
15
|
method: "POST",
|
@@ -28,15 +31,26 @@ const initializeBlockchainInformation = async (orbyUrl) => {
|
|
28
31
|
result.edges?.map((blockchainInfo) => {
|
29
32
|
const chainId = (0, exports.getChainIdFromOrbyChainId)(blockchainInfo.chainId);
|
30
33
|
if (chainId && blockchainInfo?.name) {
|
31
|
-
constants_js_1.CHAIN_CONFIGS[Number(chainId)] =
|
32
|
-
|
33
|
-
chainId: chainId,
|
34
|
-
nativeCurrency: currency_js_1.Currency.toCurrency(blockchainInfo?.nativeCurrency),
|
35
|
-
};
|
34
|
+
constants_js_1.CHAIN_CONFIGS[Number(chainId)] =
|
35
|
+
(0, exports.extractBlockchainInformation)(blockchainInfo);
|
36
36
|
}
|
37
37
|
});
|
38
38
|
};
|
39
39
|
exports.initializeBlockchainInformation = initializeBlockchainInformation;
|
40
|
+
const extractBlockchainInformation = (blockchainInformation) => {
|
41
|
+
if (!blockchainInformation) {
|
42
|
+
return undefined;
|
43
|
+
}
|
44
|
+
return {
|
45
|
+
chainId: (0, exports.getChainIdFromOrbyChainId)(blockchainInformation.chainId),
|
46
|
+
environment: blockchainInformation.environment,
|
47
|
+
logoUrl: blockchainInformation.logoUrl,
|
48
|
+
name: blockchainInformation.name,
|
49
|
+
vmType: blockchainInformation.vmType,
|
50
|
+
nativeCurrency: currency_js_1.Currency.toCurrency(blockchainInformation.nativeCurrency),
|
51
|
+
};
|
52
|
+
};
|
53
|
+
exports.extractBlockchainInformation = extractBlockchainInformation;
|
40
54
|
const getChainIdFromOrbyChainId = (value) => {
|
41
55
|
let chainId = undefined;
|
42
56
|
const formattedValue = (0, validateAndParseAddress_js_1.validateAndLowerCase)(value);
|
@@ -1,5 +1,6 @@
|
|
1
|
-
import {
|
1
|
+
import { extractBlockchainInformations } from "../utils/action_helpers.js";
|
2
2
|
import { LibraryRequest } from "../entities/library_request.js";
|
3
|
+
import { extractBlockchainInformation } from "../index.js";
|
3
4
|
export class BlockchainActions extends LibraryRequest {
|
4
5
|
constructor(library, client, provider) {
|
5
6
|
super(library, client, provider);
|