@orb-labs/orby-core 0.0.31 → 0.0.34
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 +20 -0
- package/dist/cjs/actions/account_cluster.d.ts +2 -1
- package/dist/cjs/actions/account_cluster.js +8 -0
- package/dist/cjs/actions/operation.d.ts +22 -2
- package/dist/cjs/actions/operation.js +193 -7
- package/dist/cjs/actions/token.d.ts +1 -0
- package/dist/cjs/actions/token.js +11 -0
- package/dist/cjs/enums.d.ts +4 -0
- package/dist/cjs/enums.js +6 -1
- package/dist/cjs/interfaces/account_cluster.d.ts +2 -1
- package/dist/cjs/interfaces/operation.d.ts +22 -2
- package/dist/cjs/interfaces/token.d.ts +1 -0
- package/dist/cjs/types.d.ts +22 -2
- package/dist/cjs/utils/action_helpers.d.ts +7 -1
- package/dist/cjs/utils/action_helpers.js +62 -1
- package/dist/esm/actions/account_cluster.d.ts +2 -1
- package/dist/esm/actions/account_cluster.js +9 -1
- package/dist/esm/actions/operation.d.ts +22 -2
- package/dist/esm/actions/operation.js +194 -8
- package/dist/esm/actions/token.d.ts +1 -0
- package/dist/esm/actions/token.js +11 -0
- package/dist/esm/enums.d.ts +4 -0
- package/dist/esm/enums.js +5 -0
- package/dist/esm/interfaces/account_cluster.d.ts +2 -1
- package/dist/esm/interfaces/operation.d.ts +22 -2
- package/dist/esm/interfaces/token.d.ts +1 -0
- package/dist/esm/types.d.ts +22 -2
- package/dist/esm/utils/action_helpers.d.ts +7 -1
- package/dist/esm/utils/action_helpers.js +55 -0
- package/dist/tsconfig.cjs.tsbuildinfo +1 -1
- package/dist/tsconfig.esm.tsbuildinfo +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,26 @@
|
|
|
2
2
|
|
|
3
3
|
### Unreleased
|
|
4
4
|
|
|
5
|
+
### 0.0.34
|
|
6
|
+
|
|
7
|
+
- fix listAbstractableStablecoins interface to return StandardizedToken[] directly instead of wrapped object
|
|
8
|
+
- add listAbstractableStablecoins function to TokenActions for fetching abstractable stablecoins
|
|
9
|
+
- add getStablecoinAutoDepositSettingsForAccount function to AccountClusterActions for fetching stablecoin auto deposit settings
|
|
10
|
+
- add getOperationsForStablecoinAutoDepositSettings function to OperationActions for getting operations for stablecoin auto deposit settings
|
|
11
|
+
|
|
12
|
+
### 0.0.33
|
|
13
|
+
|
|
14
|
+
- add support for sending and orchestrating writes locally
|
|
15
|
+
- update calls to isTransactionPreconditionSatisfied
|
|
16
|
+
|
|
17
|
+
### 0.0.32
|
|
18
|
+
|
|
19
|
+
- make getOperationsToSignTransactionOrSignTypedData support evm transactions as well
|
|
20
|
+
- fix: make subscribeToOperationStatuses return success for empty operations sets
|
|
21
|
+
- add operation origin to the Operation type
|
|
22
|
+
- add isChainAbstractionEnabled to the accountCluster
|
|
23
|
+
- make sendOperationSet filter out operations whose origin is not orby
|
|
24
|
+
|
|
5
25
|
### 0.0.31
|
|
6
26
|
|
|
7
27
|
- fixing the chainId type in the VirtualNodeRpcUrlForSupportedChain type
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Account } from "../entities/account.js";
|
|
2
|
-
import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StandardizedBalance, VirtualNodeRpcUrlForSupportedChain } from "../types.js";
|
|
2
|
+
import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StablecoinAutoDepositSettingsForAccount, StandardizedBalance, VirtualNodeRpcUrlForSupportedChain } from "../types.js";
|
|
3
3
|
import { ChainSupportStatus, LIBRARY_TYPE, Order } from "../enums.js";
|
|
4
4
|
import { LibraryRequest } from "../entities/library_request.js";
|
|
5
5
|
export declare class AccountClusterActions extends LibraryRequest {
|
|
@@ -29,4 +29,5 @@ export declare class AccountClusterActions extends LibraryRequest {
|
|
|
29
29
|
getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
|
|
30
30
|
getFungibleTokenPortfolio(accountClusterId: string): Promise<StandardizedBalance[]>;
|
|
31
31
|
getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, chainId?: bigint, tokensToOmit?: string[], standardizedTokenIds?: string[]): Promise<StandardizedBalance[]>;
|
|
32
|
+
getStablecoinAutoDepositSettingsForAccount(accountClusterId: string, account?: Account): Promise<StablecoinAutoDepositSettingsForAccount[]>;
|
|
32
33
|
}
|
|
@@ -215,5 +215,13 @@ class AccountClusterActions extends library_request_js_1.LibraryRequest {
|
|
|
215
215
|
}
|
|
216
216
|
return (0, action_helpers_js_1.extractStandardizedBalances)(fungibleTokenBalances);
|
|
217
217
|
}
|
|
218
|
+
async getStablecoinAutoDepositSettingsForAccount(accountClusterId, account) {
|
|
219
|
+
const { settings, message, code } = await this.sendRequest("orby_getStablecoinAutoDepositSettingsForAccount", [{ accountClusterId, account: account?.toAccountModel() }]);
|
|
220
|
+
if (code && message) {
|
|
221
|
+
console.error("[getStablecoinAutoDepositSettingsForAccountCluster]", code, message);
|
|
222
|
+
return undefined;
|
|
223
|
+
}
|
|
224
|
+
return (0, action_helpers_js_1.extractStablecoinAutoDepositSettingsForAccount)(settings);
|
|
225
|
+
}
|
|
218
226
|
}
|
|
219
227
|
exports.AccountClusterActions = AccountClusterActions;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountCluster, Activity, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
|
|
1
|
+
import { AccountCluster, Activity, MiniProgram, 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";
|
|
@@ -24,9 +24,24 @@ export declare class OperationActions extends LibraryRequest {
|
|
|
24
24
|
chainId: bigint;
|
|
25
25
|
address?: string;
|
|
26
26
|
}[];
|
|
27
|
+
}, options?: Map<string, any>): Promise<OperationSet>;
|
|
28
|
+
getOperationsForStablecoinAutoDepositSettings(accountClusterId: string, settings: {
|
|
29
|
+
userStablecoins: {
|
|
30
|
+
stablecoinAddress: string;
|
|
31
|
+
targetPercentage: number;
|
|
32
|
+
}[];
|
|
33
|
+
chainId: bigint;
|
|
34
|
+
miniProgramHash: string;
|
|
35
|
+
miniProgram: MiniProgram;
|
|
36
|
+
}[], gasToken?: {
|
|
37
|
+
standardizedTokenId: string;
|
|
38
|
+
tokenSources?: {
|
|
39
|
+
chainId: bigint;
|
|
40
|
+
address?: string;
|
|
41
|
+
}[];
|
|
27
42
|
}): Promise<OperationSet>;
|
|
28
43
|
getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<OperationSet>;
|
|
29
|
-
isTransactionPreconditionSatisfied(accountClusterId: string, data: string, to?: string, value?: bigint): Promise<boolean>;
|
|
44
|
+
isTransactionPreconditionSatisfied(accountClusterId: string, data: string, to?: string, value?: bigint, gasLimit?: bigint, maxFeePerGas?: bigint, maxPriorityFeePerGas?: bigint, gasPrice?: bigint): Promise<boolean>;
|
|
30
45
|
isTypedDataPreconditionSatisfied(accountClusterId: string, data: string): Promise<boolean>;
|
|
31
46
|
sendSignedOperations(accountClusterId: string, signedOperations: SignedOperation[]): Promise<{
|
|
32
47
|
operationSetId: string;
|
|
@@ -107,4 +122,9 @@ export declare class OperationActions extends LibraryRequest {
|
|
|
107
122
|
primaryOperationStatus?: OperationStatus;
|
|
108
123
|
operationResponses?: OperationStatus[];
|
|
109
124
|
}>;
|
|
125
|
+
sendOperationSetWithLocalOrchestration(accountCluster: AccountCluster, operationSet: OperationSet, sendTransaction?: (operation: OnchainOperation) => Promise<string | undefined>, sendUserOperation?: (operations: OnchainOperation[], accountAddress: string, chainId: bigint, txRpcUrl: string) => Promise<string | undefined>, signTypedData?: (operation: OnchainOperation) => Promise<string | undefined>, onCompletionCallback?: (operationStatuses?: {
|
|
126
|
+
operationId: string;
|
|
127
|
+
status: OperationStatusType;
|
|
128
|
+
operations: OnchainOperation[];
|
|
129
|
+
}[], statusSummary?: OperationStatusType) => void, onOperationSubmissionCallback?: (operationId: string, status: OperationStatusType, operations: OnchainOperation[]) => void, timeout?: number): Promise<void>;
|
|
110
130
|
}
|
|
@@ -6,6 +6,8 @@ const currency_amount_js_1 = require("../entities/financial/currency_amount.js")
|
|
|
6
6
|
const enums_js_1 = require("../enums.js");
|
|
7
7
|
const library_request_js_1 = require("../entities/library_request.js");
|
|
8
8
|
const account_js_1 = require("../entities/account.js");
|
|
9
|
+
const viem_1 = require("viem");
|
|
10
|
+
const ethers_1 = require("ethers");
|
|
9
11
|
// from here: https://stackoverflow.com/questions/65152373/typescript-serialize-bigint-in-json
|
|
10
12
|
BigInt.prototype.toJSON = function () {
|
|
11
13
|
return this.toString();
|
|
@@ -36,7 +38,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
36
38
|
]);
|
|
37
39
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
|
38
40
|
}
|
|
39
|
-
async getOperationsToSignTransactionOrSignTypedData(accountClusterId, data, to, value, gasToken) {
|
|
41
|
+
async getOperationsToSignTransactionOrSignTypedData(accountClusterId, data, to, value, gasToken, options) {
|
|
40
42
|
const operationSet = await this.sendRequest("orby_getOperationsToSignTransactionOrSignTypedData", [
|
|
41
43
|
{
|
|
42
44
|
accountClusterId,
|
|
@@ -44,6 +46,21 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
44
46
|
data,
|
|
45
47
|
value,
|
|
46
48
|
gasToken: await this.formatGasToken(gasToken),
|
|
49
|
+
options: options ? Object.fromEntries(options) : undefined,
|
|
50
|
+
},
|
|
51
|
+
]);
|
|
52
|
+
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
|
53
|
+
}
|
|
54
|
+
async getOperationsForStablecoinAutoDepositSettings(accountClusterId, settings, gasToken) {
|
|
55
|
+
const formattedSettings = await Promise.all(settings.map(async (setting) => ({
|
|
56
|
+
...setting,
|
|
57
|
+
chainId: await this.getOrbyChainId(setting.chainId),
|
|
58
|
+
})));
|
|
59
|
+
const operationSet = await this.sendRequest("orby_getOperationsForStablecoinAutoDepositSettings", [
|
|
60
|
+
{
|
|
61
|
+
accountClusterId,
|
|
62
|
+
settings: formattedSettings,
|
|
63
|
+
gasToken: await this.formatGasToken(gasToken),
|
|
47
64
|
},
|
|
48
65
|
]);
|
|
49
66
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
|
@@ -57,13 +74,17 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
57
74
|
]);
|
|
58
75
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
|
59
76
|
}
|
|
60
|
-
async isTransactionPreconditionSatisfied(accountClusterId, data, to, value) {
|
|
77
|
+
async isTransactionPreconditionSatisfied(accountClusterId, data, to, value, gasLimit, maxFeePerGas, maxPriorityFeePerGas, gasPrice) {
|
|
61
78
|
const { satisfied } = await this.sendRequest("orby_isTransactionPreconditionSatisfied", [
|
|
62
79
|
{
|
|
63
80
|
accountClusterId,
|
|
64
81
|
to,
|
|
65
82
|
data,
|
|
66
83
|
value,
|
|
84
|
+
gasLimit,
|
|
85
|
+
maxFeePerGas,
|
|
86
|
+
maxPriorityFeePerGas,
|
|
87
|
+
gasPrice,
|
|
67
88
|
},
|
|
68
89
|
]);
|
|
69
90
|
return satisfied;
|
|
@@ -85,7 +106,10 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
85
106
|
const { operationSetId, operationResponses, code, message } = await this.sendRequest("orby_sendSignedOperations", [
|
|
86
107
|
{
|
|
87
108
|
accountClusterId,
|
|
88
|
-
signedOperations
|
|
109
|
+
signedOperations: await Promise.all(signedOperations.map(async (signedOperation) => ({
|
|
110
|
+
...signedOperation,
|
|
111
|
+
chainId: await this.getOrbyChainId(signedOperation.chainId),
|
|
112
|
+
}))),
|
|
89
113
|
},
|
|
90
114
|
]);
|
|
91
115
|
if (code && message) {
|
|
@@ -278,7 +302,10 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
278
302
|
let intervalId = null;
|
|
279
303
|
let totalWaitTime = 0;
|
|
280
304
|
const timeoutOrDefault = timout ?? 300_000;
|
|
281
|
-
if (ids
|
|
305
|
+
if (!ids || ids?.length == 0) {
|
|
306
|
+
onOperationStatusesUpdateCallback?.(enums_js_1.OperationStatusType.SUCCESSFUL, undefined, []);
|
|
307
|
+
}
|
|
308
|
+
else if (ids && ids?.length > 0) {
|
|
282
309
|
const waitTime = 500;
|
|
283
310
|
intervalId = setInterval(async () => {
|
|
284
311
|
let statusSummary = enums_js_1.OperationStatusType.WAITING_PRECONDITION;
|
|
@@ -338,7 +365,8 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
338
365
|
?.map((intent) => intent.intentOperations)
|
|
339
366
|
.flat()
|
|
340
367
|
?.concat(operationSet.primaryOperation)
|
|
341
|
-
.filter((value) => value != undefined && value != null)
|
|
368
|
+
.filter((value) => (value != undefined && value != null) ||
|
|
369
|
+
value?.origin == enums_js_1.OperationOrigin.EXTERNAL);
|
|
342
370
|
if (operations?.length == 0) {
|
|
343
371
|
return { success: true, operationResponses: [] };
|
|
344
372
|
}
|
|
@@ -395,7 +423,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
395
423
|
signature: signature,
|
|
396
424
|
data: operation.data,
|
|
397
425
|
from: operation.from,
|
|
398
|
-
chainId:
|
|
426
|
+
chainId: operation.chainId,
|
|
399
427
|
});
|
|
400
428
|
}
|
|
401
429
|
// batch sign all the smart contract transactions
|
|
@@ -425,7 +453,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
425
453
|
signature: userOperation.signature,
|
|
426
454
|
data: JSON.stringify(userOperation),
|
|
427
455
|
from: transactions[0].from,
|
|
428
|
-
chainId:
|
|
456
|
+
chainId: transactions[0].chainId,
|
|
429
457
|
});
|
|
430
458
|
}
|
|
431
459
|
const { operationSetId, operationResponses } = await this.sendSignedOperations(accountCluster.accountClusterId, signedOperations);
|
|
@@ -439,5 +467,163 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
439
467
|
},
|
|
440
468
|
};
|
|
441
469
|
}
|
|
470
|
+
async sendOperationSetWithLocalOrchestration(accountCluster, operationSet, sendTransaction, sendUserOperation, signTypedData, onCompletionCallback, onOperationSubmissionCallback, timeout) {
|
|
471
|
+
// 1. filter out all the operations that are not orby operations
|
|
472
|
+
const orbyOperations = operationSet.intents
|
|
473
|
+
?.map((intent) => intent.intentOperations)
|
|
474
|
+
.flat()
|
|
475
|
+
?.concat(operationSet.primaryOperation)
|
|
476
|
+
.filter((value) => (value != undefined && value != null) ||
|
|
477
|
+
value?.origin == enums_js_1.OperationOrigin.EXTERNAL);
|
|
478
|
+
if (orbyOperations?.length == 0) {
|
|
479
|
+
onCompletionCallback?.([], enums_js_1.OperationStatusType.SUCCESSFUL);
|
|
480
|
+
return;
|
|
481
|
+
}
|
|
482
|
+
else if (!orbyOperations) {
|
|
483
|
+
onCompletionCallback?.([], enums_js_1.OperationStatusType.FAILED);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
// 2. group operations that can be sent in a single transaction together
|
|
487
|
+
const accountsMap = accountCluster.accounts.reduce((acc, account) => {
|
|
488
|
+
acc.set(account.key, account);
|
|
489
|
+
return acc;
|
|
490
|
+
}, new Map());
|
|
491
|
+
const smartAccountTransactions = orbyOperations.reduce((acc, operation) => {
|
|
492
|
+
const accountKey = account_js_1.Account.key(operation.from, operation.chainId);
|
|
493
|
+
const account = accountsMap.get(accountKey);
|
|
494
|
+
if (account?.type == enums_js_1.AccountType.SCA &&
|
|
495
|
+
operation.format == enums_js_1.OperationDataFormat.TRANSACTION) {
|
|
496
|
+
if (!acc.has(accountKey)) {
|
|
497
|
+
acc.set(accountKey, []);
|
|
498
|
+
}
|
|
499
|
+
acc.get(accountKey).push(operation);
|
|
500
|
+
}
|
|
501
|
+
return acc;
|
|
502
|
+
}, new Map());
|
|
503
|
+
const groupedOperations = [];
|
|
504
|
+
for (let i = 0; i < orbyOperations.length; i++) {
|
|
505
|
+
const operation = orbyOperations[i];
|
|
506
|
+
if (operation.format == enums_js_1.OperationDataFormat.TRANSACTION) {
|
|
507
|
+
const accountKey = account_js_1.Account.key(operation.from, operation.chainId);
|
|
508
|
+
const account = accountsMap.get(accountKey);
|
|
509
|
+
if (account?.type == enums_js_1.AccountType.SCA) {
|
|
510
|
+
continue;
|
|
511
|
+
}
|
|
512
|
+
else {
|
|
513
|
+
groupedOperations.push([operation]);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
else if (operation.format == enums_js_1.OperationDataFormat.TYPED_DATA) {
|
|
517
|
+
groupedOperations.push([operation]);
|
|
518
|
+
}
|
|
519
|
+
}
|
|
520
|
+
// 3. group the operations that can be sent in a single transaction together
|
|
521
|
+
for (const accountKey of smartAccountTransactions.keys()) {
|
|
522
|
+
const transactions = smartAccountTransactions.get(accountKey);
|
|
523
|
+
transactions.sort((operationA, _) => {
|
|
524
|
+
if (operationA.type == enums_js_1.OperationType.APPROVE_ERC20_TOKEN) {
|
|
525
|
+
return -1;
|
|
526
|
+
}
|
|
527
|
+
return 0;
|
|
528
|
+
});
|
|
529
|
+
groupedOperations.push(transactions);
|
|
530
|
+
}
|
|
531
|
+
const timeoutOrDefault = timeout ?? 300_000;
|
|
532
|
+
const waitTime = 2000;
|
|
533
|
+
let intervalId = null;
|
|
534
|
+
let totalWaitTime = 0;
|
|
535
|
+
let isProcessing = false;
|
|
536
|
+
const hashedOperations = new Array(groupedOperations.length).fill(undefined);
|
|
537
|
+
// 3. send the operations in batches
|
|
538
|
+
intervalId = setInterval(async () => {
|
|
539
|
+
if (isProcessing) {
|
|
540
|
+
return;
|
|
541
|
+
}
|
|
542
|
+
try {
|
|
543
|
+
isProcessing = true;
|
|
544
|
+
const promises = groupedOperations.map(async (operations, index) => {
|
|
545
|
+
if (hashedOperations[index]) {
|
|
546
|
+
return;
|
|
547
|
+
}
|
|
548
|
+
const operation = operations[0];
|
|
549
|
+
// create a new operation actions client for each operation
|
|
550
|
+
let opsActions;
|
|
551
|
+
if (this.library == enums_js_1.LIBRARY_TYPE.VIEM) {
|
|
552
|
+
opsActions = new OperationActions(enums_js_1.LIBRARY_TYPE.VIEM, (0, viem_1.createClient)({
|
|
553
|
+
transport: (0, viem_1.http)(operation.txRpcUrl),
|
|
554
|
+
}), undefined);
|
|
555
|
+
}
|
|
556
|
+
else if (this.library == enums_js_1.LIBRARY_TYPE.ETHERS) {
|
|
557
|
+
opsActions = new OperationActions(enums_js_1.LIBRARY_TYPE.ETHERS, undefined, new ethers_1.ethers.providers.JsonRpcProvider(operation.txRpcUrl));
|
|
558
|
+
}
|
|
559
|
+
if (operation.format === enums_js_1.OperationDataFormat.TRANSACTION) {
|
|
560
|
+
const isPreconditionSatisfied = await opsActions.isTransactionPreconditionSatisfied(accountCluster.accountClusterId, operation.data, operation.to, operation.value, operation.gasLimit, operation.maxFeePerGas, operation.maxPriorityFeePerGas, operation.gasPrice);
|
|
561
|
+
if (isPreconditionSatisfied) {
|
|
562
|
+
const accountKey = account_js_1.Account.key(operation.from, operation.chainId);
|
|
563
|
+
const account = accountsMap.get(accountKey);
|
|
564
|
+
if (account?.type == enums_js_1.AccountType.SCA) {
|
|
565
|
+
const hash = await sendUserOperation?.(operations, operation.from, operation.chainId, operation.txRpcUrl);
|
|
566
|
+
onOperationSubmissionCallback?.(hash, enums_js_1.OperationStatusType.PENDING, operations);
|
|
567
|
+
hashedOperations[index] = {
|
|
568
|
+
operationId: hash,
|
|
569
|
+
status: enums_js_1.OperationStatusType.SUCCESSFUL,
|
|
570
|
+
operations,
|
|
571
|
+
};
|
|
572
|
+
}
|
|
573
|
+
else {
|
|
574
|
+
const hash = await sendTransaction?.(operation);
|
|
575
|
+
onOperationSubmissionCallback?.(hash, enums_js_1.OperationStatusType.PENDING, operations);
|
|
576
|
+
hashedOperations[index] = {
|
|
577
|
+
operationId: hash,
|
|
578
|
+
status: enums_js_1.OperationStatusType.SUCCESSFUL,
|
|
579
|
+
operations,
|
|
580
|
+
};
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
}
|
|
584
|
+
else if (operation.format === enums_js_1.OperationDataFormat.TYPED_DATA) {
|
|
585
|
+
const isPreconditionSatisfied = await opsActions.isTypedDataPreconditionSatisfied(accountCluster.accountClusterId, operation.data);
|
|
586
|
+
if (isPreconditionSatisfied) {
|
|
587
|
+
const signature = await signTypedData?.(operation);
|
|
588
|
+
const sendOperation = await opsActions.sendSignedOperations(accountCluster.accountClusterId, [
|
|
589
|
+
{
|
|
590
|
+
type: operation.type,
|
|
591
|
+
signature,
|
|
592
|
+
data: operation.data,
|
|
593
|
+
from: operation.from,
|
|
594
|
+
chainId: operation.chainId,
|
|
595
|
+
},
|
|
596
|
+
]);
|
|
597
|
+
onOperationSubmissionCallback?.(sendOperation.operationResponses[0].hash, enums_js_1.OperationStatusType.SUCCESSFUL, operations);
|
|
598
|
+
hashedOperations[index] = {
|
|
599
|
+
operationId: sendOperation.operationResponses[0].hash,
|
|
600
|
+
status: enums_js_1.OperationStatusType.SUCCESSFUL,
|
|
601
|
+
operations,
|
|
602
|
+
};
|
|
603
|
+
}
|
|
604
|
+
}
|
|
605
|
+
});
|
|
606
|
+
await Promise.all(promises);
|
|
607
|
+
if (hashedOperations.every((result) => result)) {
|
|
608
|
+
onCompletionCallback?.(hashedOperations, enums_js_1.OperationStatusType.SUCCESSFUL);
|
|
609
|
+
clearInterval(intervalId);
|
|
610
|
+
intervalId = null;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
catch (error) {
|
|
614
|
+
console.error("[sendOperationSetWithLocalOrchestration]", error);
|
|
615
|
+
}
|
|
616
|
+
finally {
|
|
617
|
+
isProcessing = false; // Reset processing flag
|
|
618
|
+
totalWaitTime += waitTime;
|
|
619
|
+
if (intervalId && totalWaitTime >= timeoutOrDefault) {
|
|
620
|
+
onCompletionCallback?.(hashedOperations, enums_js_1.OperationStatusType.WAITING_PRECONDITION);
|
|
621
|
+
// we cant wait for more than 2 ETH blocks
|
|
622
|
+
clearInterval(intervalId);
|
|
623
|
+
intervalId = null;
|
|
624
|
+
}
|
|
625
|
+
}
|
|
626
|
+
}, waitTime);
|
|
627
|
+
}
|
|
442
628
|
}
|
|
443
629
|
exports.OperationActions = OperationActions;
|
|
@@ -12,4 +12,5 @@ export declare class TokenActions extends LibraryRequest {
|
|
|
12
12
|
chainId: bigint;
|
|
13
13
|
}[]): Promise<StandardizedToken[]>;
|
|
14
14
|
getFungibleTokenData(standardizedTokenIds: string[]): Promise<StandardizedToken[]>;
|
|
15
|
+
listAbstractableStablecoins(chainId?: bigint): Promise<StandardizedToken[]>;
|
|
15
16
|
}
|
|
@@ -47,5 +47,16 @@ class TokenActions extends library_request_js_1.LibraryRequest {
|
|
|
47
47
|
}
|
|
48
48
|
return (0, action_helpers_js_1.extractStandardizedTokens)(data);
|
|
49
49
|
}
|
|
50
|
+
async listAbstractableStablecoins(chainId) {
|
|
51
|
+
const orbyChainId = chainId
|
|
52
|
+
? await this.getOrbyChainId(chainId)
|
|
53
|
+
: undefined;
|
|
54
|
+
const { stablecoins, message, code } = await this.sendRequest("orby_listAbstractableStablecoins", [{ chainId: orbyChainId }]);
|
|
55
|
+
if (code && message) {
|
|
56
|
+
console.error("[listAbstractableStablecoins]", code, message);
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
59
|
+
return (0, action_helpers_js_1.extractStandardizedTokens)(stablecoins);
|
|
60
|
+
}
|
|
50
61
|
}
|
|
51
62
|
exports.TokenActions = TokenActions;
|
package/dist/cjs/enums.d.ts
CHANGED
|
@@ -29,6 +29,10 @@ export declare enum OperationDataFormat {
|
|
|
29
29
|
TRANSACTION = "TRANSACTION",
|
|
30
30
|
TYPED_DATA = "TYPED_DATA"
|
|
31
31
|
}
|
|
32
|
+
export declare enum OperationOrigin {
|
|
33
|
+
EXTERNAL = "external",
|
|
34
|
+
ORBY = "orby"
|
|
35
|
+
}
|
|
32
36
|
export declare enum OperationType {
|
|
33
37
|
APPROVE_ERC20_TOKEN = "APPROVE_ERC20_TOKEN",
|
|
34
38
|
CANCEL_OPERATION = "CANCEL_OPERATION",
|
package/dist/cjs/enums.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LIBRARY_TYPE = exports.TimeIntervalUnits = exports.TokenAllowlistType = exports.BlockchainEnvironment = exports.ActivityStatus = exports.Order = exports.QuoteType = exports.OperationStatusType = exports.Category = exports.OperationType = exports.OperationDataFormat = exports.CreateOperationsStatus = exports.ChainSupportStatus = exports.VMType = exports.AccountType = exports.TokenType = void 0;
|
|
3
|
+
exports.LIBRARY_TYPE = exports.TimeIntervalUnits = exports.TokenAllowlistType = exports.BlockchainEnvironment = exports.ActivityStatus = exports.Order = exports.QuoteType = exports.OperationStatusType = exports.Category = exports.OperationType = exports.OperationOrigin = exports.OperationDataFormat = exports.CreateOperationsStatus = exports.ChainSupportStatus = exports.VMType = exports.AccountType = exports.TokenType = void 0;
|
|
4
4
|
var TokenType;
|
|
5
5
|
(function (TokenType) {
|
|
6
6
|
TokenType["FUNGIBLE_TOKEN"] = "FUNGIBLE_TOKEN";
|
|
@@ -38,6 +38,11 @@ var OperationDataFormat;
|
|
|
38
38
|
OperationDataFormat["TRANSACTION"] = "TRANSACTION";
|
|
39
39
|
OperationDataFormat["TYPED_DATA"] = "TYPED_DATA";
|
|
40
40
|
})(OperationDataFormat || (exports.OperationDataFormat = OperationDataFormat = {}));
|
|
41
|
+
var OperationOrigin;
|
|
42
|
+
(function (OperationOrigin) {
|
|
43
|
+
OperationOrigin["EXTERNAL"] = "external";
|
|
44
|
+
OperationOrigin["ORBY"] = "orby";
|
|
45
|
+
})(OperationOrigin || (exports.OperationOrigin = OperationOrigin = {}));
|
|
41
46
|
var OperationType;
|
|
42
47
|
(function (OperationType) {
|
|
43
48
|
OperationType["APPROVE_ERC20_TOKEN"] = "APPROVE_ERC20_TOKEN";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Account } from "../entities/account.js";
|
|
2
|
-
import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StandardizedBalance, VirtualNodeRpcUrlForSupportedChain } from "../types.js";
|
|
2
|
+
import { AccountCluster, Activity, ChainEndpoint, FungibleTokenOverview, StablecoinAutoDepositSettingsForAccount, StandardizedBalance, VirtualNodeRpcUrlForSupportedChain } from "../types.js";
|
|
3
3
|
import { ChainSupportStatus, Order } from "../enums.js";
|
|
4
4
|
export interface IAccountClusterActions {
|
|
5
5
|
createAccountCluster(accounts: Account[]): Promise<AccountCluster>;
|
|
@@ -27,4 +27,5 @@ export interface IAccountClusterActions {
|
|
|
27
27
|
getPortfolioOverview(accountClusterId: string): Promise<FungibleTokenOverview>;
|
|
28
28
|
getFungibleTokenPortfolio(accountClusterId: string): Promise<StandardizedBalance[]>;
|
|
29
29
|
getFungibleTokenBalances(accountClusterId: string, offset?: number, limit?: number, chainId?: bigint, tokensToOmit?: string[], standardizedTokenIds?: string[]): Promise<StandardizedBalance[]>;
|
|
30
|
+
getStablecoinAutoDepositSettingsForAccount(accountClusterId: string, account?: Account): Promise<StablecoinAutoDepositSettingsForAccount[]>;
|
|
30
31
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountCluster, Activity, OnchainOperation, OperationSet, OperationStatus, SignedOperation, UserOperation } from "../types.js";
|
|
1
|
+
import { AccountCluster, Activity, MiniProgram, 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 {
|
|
@@ -22,9 +22,24 @@ export interface IOperationActions {
|
|
|
22
22
|
chainId: bigint;
|
|
23
23
|
address?: string;
|
|
24
24
|
}[];
|
|
25
|
+
}, options?: Map<string, any>): Promise<OperationSet>;
|
|
26
|
+
getOperationsForStablecoinAutoDepositSettings(accountClusterId: string, settings: {
|
|
27
|
+
userStablecoins: {
|
|
28
|
+
stablecoinAddress: string;
|
|
29
|
+
targetPercentage: number;
|
|
30
|
+
}[];
|
|
31
|
+
chainId: bigint;
|
|
32
|
+
miniProgramHash: string;
|
|
33
|
+
miniProgram: MiniProgram;
|
|
34
|
+
}[], gasToken?: {
|
|
35
|
+
standardizedTokenId: string;
|
|
36
|
+
tokenSources?: {
|
|
37
|
+
chainId: bigint;
|
|
38
|
+
address?: string;
|
|
39
|
+
}[];
|
|
25
40
|
}): Promise<OperationSet>;
|
|
26
41
|
getOperationsToCancelTransaction(accountClusterId: string, operationSetId: string): Promise<OperationSet>;
|
|
27
|
-
isTransactionPreconditionSatisfied(accountClusterId: string, data: string, to?: string, value?: bigint): Promise<boolean>;
|
|
42
|
+
isTransactionPreconditionSatisfied(accountClusterId: string, data: string, to?: string, value?: bigint, gasLimit?: bigint, maxFeePerGas?: bigint, maxPriorityFeePerGas?: bigint, gasPrice?: bigint): Promise<boolean>;
|
|
28
43
|
isTypedDataPreconditionSatisfied(accountClusterId: string, data: string): Promise<boolean>;
|
|
29
44
|
sendSignedOperations(accountClusterId: string, signedOperations: SignedOperation[]): Promise<{
|
|
30
45
|
operationSetId: string;
|
|
@@ -105,4 +120,9 @@ export interface IOperationActions {
|
|
|
105
120
|
primaryOperationStatus?: OperationStatus;
|
|
106
121
|
operationResponses?: OperationStatus[];
|
|
107
122
|
}>;
|
|
123
|
+
sendOperationSetWithLocalOrchestration(accountCluster: AccountCluster, operationSet: OperationSet, sendTransaction?: (operation: OnchainOperation) => Promise<string | undefined>, sendUserOperation?: (operations: OnchainOperation[], accountAddress: string, chainId: bigint, txRpcUrl: string) => Promise<string | undefined>, signTypedData?: (operation: OnchainOperation) => Promise<string | undefined>, onCompletionCallback?: (operationStatuses?: {
|
|
124
|
+
operationId: string;
|
|
125
|
+
status: OperationStatusType;
|
|
126
|
+
operations: OnchainOperation[];
|
|
127
|
+
}[], statusSummary?: OperationStatusType) => void, onOperationSubmissionCallback?: (operationId: string, status: OperationStatusType, operations: OnchainOperation[]) => void, timeout?: number): Promise<void>;
|
|
108
128
|
}
|
package/dist/cjs/types.d.ts
CHANGED
|
@@ -4,10 +4,11 @@ import { CurrencyAmount } from "./entities/financial/currency_amount.js";
|
|
|
4
4
|
import { FungibleToken } from "./entities/financial/fungible_token.js";
|
|
5
5
|
import { FungibleTokenAmount } from "./entities/financial/fungible_token_amount.js";
|
|
6
6
|
import { State } from "./entities/state.js";
|
|
7
|
-
import { ActivityStatus, BlockchainEnvironment, Category, CreateOperationsStatus, OperationDataFormat, OperationStatusType, OperationType, TimeIntervalUnits, TokenAllowlistType, VMType } from "./enums.js";
|
|
7
|
+
import { ActivityStatus, BlockchainEnvironment, Category, CreateOperationsStatus, OperationDataFormat, OperationOrigin, OperationStatusType, OperationType, TimeIntervalUnits, TokenAllowlistType, VMType } from "./enums.js";
|
|
8
8
|
export type AccountCluster = {
|
|
9
9
|
accountClusterId: string;
|
|
10
10
|
accounts: Account[];
|
|
11
|
+
isChainAbstractionEnabled: boolean;
|
|
11
12
|
};
|
|
12
13
|
export type ChainEndpoint = {
|
|
13
14
|
chainId: bigint;
|
|
@@ -70,6 +71,7 @@ export interface OnchainOperation {
|
|
|
70
71
|
txRpcUrl: string;
|
|
71
72
|
type: OperationType;
|
|
72
73
|
value?: bigint;
|
|
74
|
+
origin: OperationOrigin;
|
|
73
75
|
}
|
|
74
76
|
export type SignedOperation = {
|
|
75
77
|
type: OperationType;
|
|
@@ -77,7 +79,7 @@ export type SignedOperation = {
|
|
|
77
79
|
category?: Category;
|
|
78
80
|
data?: string;
|
|
79
81
|
from?: string;
|
|
80
|
-
chainId?:
|
|
82
|
+
chainId?: bigint;
|
|
81
83
|
};
|
|
82
84
|
export type OperationStatus = {
|
|
83
85
|
blockHash?: string;
|
|
@@ -171,3 +173,21 @@ export type VirtualNodeRpcUrlForSupportedChain = {
|
|
|
171
173
|
entrypointAccountAddress: string;
|
|
172
174
|
virtualNodeRpcUrl: string;
|
|
173
175
|
};
|
|
176
|
+
export type MiniProgram = {
|
|
177
|
+
verificationContract: string;
|
|
178
|
+
miniProgram: string;
|
|
179
|
+
};
|
|
180
|
+
export type StablecoinAutoDepositProportion = {
|
|
181
|
+
token: FungibleToken;
|
|
182
|
+
targetPercentage: number;
|
|
183
|
+
};
|
|
184
|
+
export type StablecoinAutoDepositPerChainUserStablecoinsSettings = {
|
|
185
|
+
userStablecoins: StablecoinAutoDepositProportion[];
|
|
186
|
+
chainId: bigint;
|
|
187
|
+
miniProgram: MiniProgram;
|
|
188
|
+
miniProgramHash: string;
|
|
189
|
+
};
|
|
190
|
+
export type StablecoinAutoDepositSettingsForAccount = {
|
|
191
|
+
account: Account;
|
|
192
|
+
settings: StablecoinAutoDepositPerChainUserStablecoinsSettings[];
|
|
193
|
+
};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AccountCluster, Activity, AllowlistWithOpenFallback, BlockchainInformation, FungibleTokenOverview, GasSpendForInstance, GasSponsorshipData, GasSponsorshipPolicy, Intent, MaxAmountPerInterval, OnchainOperation, OperationSet, OperationStatus, StandardizedBalance, StandardizedToken } from "../types.js";
|
|
1
|
+
import { AccountCluster, Activity, AllowlistWithOpenFallback, BlockchainInformation, FungibleTokenOverview, GasSpendForInstance, GasSponsorshipData, GasSponsorshipPolicy, Intent, MaxAmountPerInterval, OnchainOperation, OperationSet, OperationStatus, StablecoinAutoDepositPerChainUserStablecoinsSettings, StablecoinAutoDepositProportion, StablecoinAutoDepositSettingsForAccount, StandardizedBalance, StandardizedToken } from "../types.js";
|
|
2
2
|
export declare const extractAccountCluster: (accountCluster?: any) => AccountCluster;
|
|
3
3
|
export declare const extractOperationSet: (operationSet?: any) => OperationSet;
|
|
4
4
|
export declare const extractOnchainOperation: (onchainOperation?: any) => OnchainOperation;
|
|
@@ -20,3 +20,9 @@ export declare const extractGasSpendForInstances: (gasSpendForInstances?: any[])
|
|
|
20
20
|
export declare const extractGasSpendForInstance: (gasSpendForInstance?: any) => GasSpendForInstance;
|
|
21
21
|
export declare const extractGasSponsorshipInformation: (gasSponsorshipData?: any[]) => GasSponsorshipData[];
|
|
22
22
|
export declare const extractGasSponsorshipData: (gasSponsorshipData?: any) => GasSponsorshipData;
|
|
23
|
+
export declare const extractStablecoinAutoDepositSettingsForAccount: (settings?: any[]) => StablecoinAutoDepositSettingsForAccount[];
|
|
24
|
+
export declare const extractStablecoinAutoDepositSettingsForAccountItem: (setting?: any) => StablecoinAutoDepositSettingsForAccount;
|
|
25
|
+
export declare const extractStablecoinAutoDepositPerChainUserStablecoinsSettings: (settings?: any[]) => StablecoinAutoDepositPerChainUserStablecoinsSettings[];
|
|
26
|
+
export declare const extractStablecoinAutoDepositPerChainUserStablecoinsSettingsItem: (setting?: any) => StablecoinAutoDepositPerChainUserStablecoinsSettings;
|
|
27
|
+
export declare const extractStablecoinAutoDepositProportions: (proportions?: any[]) => StablecoinAutoDepositProportion[];
|
|
28
|
+
export declare const extractStablecoinAutoDepositProportion: (proportion?: any) => StablecoinAutoDepositProportion;
|
|
@@ -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.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;
|
|
3
|
+
exports.extractStablecoinAutoDepositProportion = exports.extractStablecoinAutoDepositProportions = exports.extractStablecoinAutoDepositPerChainUserStablecoinsSettingsItem = exports.extractStablecoinAutoDepositPerChainUserStablecoinsSettings = exports.extractStablecoinAutoDepositSettingsForAccountItem = exports.extractStablecoinAutoDepositSettingsForAccount = 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");
|
|
@@ -19,6 +19,7 @@ const extractAccountCluster = (accountCluster) => {
|
|
|
19
19
|
}
|
|
20
20
|
return {
|
|
21
21
|
accountClusterId: accountCluster?.accountClusterId,
|
|
22
|
+
isChainAbstractionEnabled: accountCluster?.isChainAbstractionEnabled,
|
|
22
23
|
accounts: accountCluster?.accounts?.map((account) => account_js_1.Account.toAccount(account)),
|
|
23
24
|
};
|
|
24
25
|
};
|
|
@@ -78,6 +79,7 @@ const extractOnchainOperation = (onchainOperation) => {
|
|
|
78
79
|
txRpcUrl: onchainOperation.txRpcUrl,
|
|
79
80
|
type: onchainOperation.type,
|
|
80
81
|
value: onchainOperation.value ? BigInt(onchainOperation.value) : undefined,
|
|
82
|
+
origin: onchainOperation.origin,
|
|
81
83
|
};
|
|
82
84
|
};
|
|
83
85
|
exports.extractOnchainOperation = extractOnchainOperation;
|
|
@@ -269,3 +271,62 @@ const extractGasSponsorshipData = (gasSponsorshipData) => {
|
|
|
269
271
|
};
|
|
270
272
|
};
|
|
271
273
|
exports.extractGasSponsorshipData = extractGasSponsorshipData;
|
|
274
|
+
const extractStablecoinAutoDepositSettingsForAccount = (settings) => {
|
|
275
|
+
if (!settings) {
|
|
276
|
+
return undefined;
|
|
277
|
+
}
|
|
278
|
+
return settings
|
|
279
|
+
.map((setting) => (0, exports.extractStablecoinAutoDepositSettingsForAccountItem)(setting))
|
|
280
|
+
.filter(utils_js_1.notEmpty);
|
|
281
|
+
};
|
|
282
|
+
exports.extractStablecoinAutoDepositSettingsForAccount = extractStablecoinAutoDepositSettingsForAccount;
|
|
283
|
+
const extractStablecoinAutoDepositSettingsForAccountItem = (setting) => {
|
|
284
|
+
if (!setting) {
|
|
285
|
+
return undefined;
|
|
286
|
+
}
|
|
287
|
+
return {
|
|
288
|
+
account: account_js_1.Account.toAccount(setting.account),
|
|
289
|
+
settings: (0, exports.extractStablecoinAutoDepositPerChainUserStablecoinsSettings)(setting.settings),
|
|
290
|
+
};
|
|
291
|
+
};
|
|
292
|
+
exports.extractStablecoinAutoDepositSettingsForAccountItem = extractStablecoinAutoDepositSettingsForAccountItem;
|
|
293
|
+
const extractStablecoinAutoDepositPerChainUserStablecoinsSettings = (settings) => {
|
|
294
|
+
if (!settings) {
|
|
295
|
+
return undefined;
|
|
296
|
+
}
|
|
297
|
+
return settings
|
|
298
|
+
.map((setting) => (0, exports.extractStablecoinAutoDepositPerChainUserStablecoinsSettingsItem)(setting))
|
|
299
|
+
.filter(utils_js_1.notEmpty);
|
|
300
|
+
};
|
|
301
|
+
exports.extractStablecoinAutoDepositPerChainUserStablecoinsSettings = extractStablecoinAutoDepositPerChainUserStablecoinsSettings;
|
|
302
|
+
const extractStablecoinAutoDepositPerChainUserStablecoinsSettingsItem = (setting) => {
|
|
303
|
+
if (!setting) {
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
return {
|
|
307
|
+
userStablecoins: (0, exports.extractStablecoinAutoDepositProportions)(setting.userStablecoins),
|
|
308
|
+
chainId: (0, utils_js_1.getChainIdFromOrbyChainId)(setting.chainId),
|
|
309
|
+
miniProgram: setting.miniProgram,
|
|
310
|
+
miniProgramHash: setting.miniProgramHash,
|
|
311
|
+
};
|
|
312
|
+
};
|
|
313
|
+
exports.extractStablecoinAutoDepositPerChainUserStablecoinsSettingsItem = extractStablecoinAutoDepositPerChainUserStablecoinsSettingsItem;
|
|
314
|
+
const extractStablecoinAutoDepositProportions = (proportions) => {
|
|
315
|
+
if (!proportions) {
|
|
316
|
+
return undefined;
|
|
317
|
+
}
|
|
318
|
+
return proportions
|
|
319
|
+
.map((proportion) => (0, exports.extractStablecoinAutoDepositProportion)(proportion))
|
|
320
|
+
.filter(utils_js_1.notEmpty);
|
|
321
|
+
};
|
|
322
|
+
exports.extractStablecoinAutoDepositProportions = extractStablecoinAutoDepositProportions;
|
|
323
|
+
const extractStablecoinAutoDepositProportion = (proportion) => {
|
|
324
|
+
if (!proportion) {
|
|
325
|
+
return undefined;
|
|
326
|
+
}
|
|
327
|
+
return {
|
|
328
|
+
token: fungible_token_js_1.FungibleToken.toFungibleToken(proportion.token),
|
|
329
|
+
targetPercentage: proportion.targetPercentage,
|
|
330
|
+
};
|
|
331
|
+
};
|
|
332
|
+
exports.extractStablecoinAutoDepositProportion = extractStablecoinAutoDepositProportion;
|