@orb-labs/orby-core 0.0.32 → 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 +12 -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 +185 -4
- package/dist/cjs/actions/token.d.ts +1 -0
- package/dist/cjs/actions/token.js +11 -0
- 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 +19 -1
- package/dist/cjs/utils/action_helpers.d.ts +7 -1
- package/dist/cjs/utils/action_helpers.js +60 -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 +186 -5
- package/dist/esm/actions/token.d.ts +1 -0
- package/dist/esm/actions/token.js +11 -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 +19 -1
- package/dist/esm/utils/action_helpers.d.ts +7 -1
- package/dist/esm/utils/action_helpers.js +53 -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,18 @@
|
|
|
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
|
+
|
|
5
17
|
### 0.0.32
|
|
6
18
|
|
|
7
19
|
- make getOperationsToSignTransactionOrSignTypedData support evm transactions as well
|
|
@@ -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";
|
|
@@ -25,8 +25,23 @@ export declare class OperationActions extends LibraryRequest {
|
|
|
25
25
|
address?: string;
|
|
26
26
|
}[];
|
|
27
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
|
+
}[];
|
|
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();
|
|
@@ -49,6 +51,20 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
49
51
|
]);
|
|
50
52
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
|
51
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),
|
|
64
|
+
},
|
|
65
|
+
]);
|
|
66
|
+
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
|
67
|
+
}
|
|
52
68
|
async getOperationsToCancelTransaction(accountClusterId, operationSetId) {
|
|
53
69
|
const operationSet = await this.sendRequest("orby_getOperationsToCancelTransaction", [
|
|
54
70
|
{
|
|
@@ -58,13 +74,17 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
58
74
|
]);
|
|
59
75
|
return (0, action_helpers_js_1.extractOperationSet)(operationSet);
|
|
60
76
|
}
|
|
61
|
-
async isTransactionPreconditionSatisfied(accountClusterId, data, to, value) {
|
|
77
|
+
async isTransactionPreconditionSatisfied(accountClusterId, data, to, value, gasLimit, maxFeePerGas, maxPriorityFeePerGas, gasPrice) {
|
|
62
78
|
const { satisfied } = await this.sendRequest("orby_isTransactionPreconditionSatisfied", [
|
|
63
79
|
{
|
|
64
80
|
accountClusterId,
|
|
65
81
|
to,
|
|
66
82
|
data,
|
|
67
83
|
value,
|
|
84
|
+
gasLimit,
|
|
85
|
+
maxFeePerGas,
|
|
86
|
+
maxPriorityFeePerGas,
|
|
87
|
+
gasPrice,
|
|
68
88
|
},
|
|
69
89
|
]);
|
|
70
90
|
return satisfied;
|
|
@@ -86,7 +106,10 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
86
106
|
const { operationSetId, operationResponses, code, message } = await this.sendRequest("orby_sendSignedOperations", [
|
|
87
107
|
{
|
|
88
108
|
accountClusterId,
|
|
89
|
-
signedOperations
|
|
109
|
+
signedOperations: await Promise.all(signedOperations.map(async (signedOperation) => ({
|
|
110
|
+
...signedOperation,
|
|
111
|
+
chainId: await this.getOrbyChainId(signedOperation.chainId),
|
|
112
|
+
}))),
|
|
90
113
|
},
|
|
91
114
|
]);
|
|
92
115
|
if (code && message) {
|
|
@@ -400,7 +423,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
400
423
|
signature: signature,
|
|
401
424
|
data: operation.data,
|
|
402
425
|
from: operation.from,
|
|
403
|
-
chainId:
|
|
426
|
+
chainId: operation.chainId,
|
|
404
427
|
});
|
|
405
428
|
}
|
|
406
429
|
// batch sign all the smart contract transactions
|
|
@@ -430,7 +453,7 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
430
453
|
signature: userOperation.signature,
|
|
431
454
|
data: JSON.stringify(userOperation),
|
|
432
455
|
from: transactions[0].from,
|
|
433
|
-
chainId:
|
|
456
|
+
chainId: transactions[0].chainId,
|
|
434
457
|
});
|
|
435
458
|
}
|
|
436
459
|
const { operationSetId, operationResponses } = await this.sendSignedOperations(accountCluster.accountClusterId, signedOperations);
|
|
@@ -444,5 +467,163 @@ class OperationActions extends library_request_js_1.LibraryRequest {
|
|
|
444
467
|
},
|
|
445
468
|
};
|
|
446
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
|
+
}
|
|
447
628
|
}
|
|
448
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;
|
|
@@ -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 {
|
|
@@ -23,8 +23,23 @@ export interface IOperationActions {
|
|
|
23
23
|
address?: string;
|
|
24
24
|
}[];
|
|
25
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
|
+
}[];
|
|
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
|
@@ -79,7 +79,7 @@ export type SignedOperation = {
|
|
|
79
79
|
category?: Category;
|
|
80
80
|
data?: string;
|
|
81
81
|
from?: string;
|
|
82
|
-
chainId?:
|
|
82
|
+
chainId?: bigint;
|
|
83
83
|
};
|
|
84
84
|
export type OperationStatus = {
|
|
85
85
|
blockHash?: string;
|
|
@@ -173,3 +173,21 @@ export type VirtualNodeRpcUrlForSupportedChain = {
|
|
|
173
173
|
entrypointAccountAddress: string;
|
|
174
174
|
virtualNodeRpcUrl: string;
|
|
175
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");
|
|
@@ -271,3 +271,62 @@ const extractGasSponsorshipData = (gasSponsorshipData) => {
|
|
|
271
271
|
};
|
|
272
272
|
};
|
|
273
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;
|
|
@@ -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
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { extractAccountCluster, extractActivities, extractFungibleTokenOverview, extractStandardizedBalances, } from "../utils/action_helpers.js";
|
|
1
|
+
import { extractAccountCluster, extractActivities, extractFungibleTokenOverview, extractStablecoinAutoDepositSettingsForAccount, extractStandardizedBalances, } from "../utils/action_helpers.js";
|
|
2
2
|
import { LibraryRequest } from "../entities/library_request.js";
|
|
3
3
|
import { getChainIdFromOrbyChainId } from "../utils/utils.js";
|
|
4
4
|
import { validateAndFormatAddress } from "../utils/validateAndParseAddress.js";
|
|
@@ -212,4 +212,12 @@ export class AccountClusterActions extends LibraryRequest {
|
|
|
212
212
|
}
|
|
213
213
|
return extractStandardizedBalances(fungibleTokenBalances);
|
|
214
214
|
}
|
|
215
|
+
async getStablecoinAutoDepositSettingsForAccount(accountClusterId, account) {
|
|
216
|
+
const { settings, message, code } = await this.sendRequest("orby_getStablecoinAutoDepositSettingsForAccount", [{ accountClusterId, account: account?.toAccountModel() }]);
|
|
217
|
+
if (code && message) {
|
|
218
|
+
console.error("[getStablecoinAutoDepositSettingsForAccountCluster]", code, message);
|
|
219
|
+
return undefined;
|
|
220
|
+
}
|
|
221
|
+
return extractStablecoinAutoDepositSettingsForAccount(settings);
|
|
222
|
+
}
|
|
215
223
|
}
|
|
@@ -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";
|
|
@@ -25,8 +25,23 @@ export declare class OperationActions extends LibraryRequest {
|
|
|
25
25
|
address?: string;
|
|
26
26
|
}[];
|
|
27
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
|
+
}[];
|
|
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
|
}
|