@charterlabs/rhinestone-sdk 0.1.0 → 0.1.2
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/README.md +74 -181
- package/dist/src/accounts/error.d.ts +69 -0
- package/dist/src/accounts/error.d.ts.map +1 -0
- package/dist/src/accounts/error.js +109 -0
- package/dist/{accounts → src/accounts}/index.d.ts +14 -21
- package/dist/src/accounts/index.d.ts.map +1 -0
- package/dist/src/accounts/index.js +469 -0
- package/dist/src/accounts/index.test.d.ts +2 -0
- package/dist/src/accounts/index.test.d.ts.map +1 -0
- package/dist/src/accounts/index.test.js +36 -0
- package/dist/{accounts → src/accounts}/kernel.d.ts +7 -9
- package/dist/src/accounts/kernel.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/kernel.js +0 -8
- package/dist/src/accounts/kernel.test.d.ts +2 -0
- package/dist/src/accounts/kernel.test.d.ts.map +1 -0
- package/dist/src/accounts/kernel.test.js +105 -0
- package/dist/{accounts → src/accounts}/nexus.d.ts +14 -13
- package/dist/src/accounts/nexus.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/nexus.js +92 -88
- package/dist/src/accounts/nexus.test.d.ts +2 -0
- package/dist/src/accounts/nexus.test.d.ts.map +1 -0
- package/dist/src/accounts/nexus.test.js +87 -0
- package/dist/{accounts → src/accounts}/safe.d.ts +4 -6
- package/dist/src/accounts/safe.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/safe.js +20 -29
- package/dist/src/accounts/safe.test.d.ts +2 -0
- package/dist/src/accounts/safe.test.d.ts.map +1 -0
- package/dist/src/accounts/safe.test.js +87 -0
- package/dist/src/accounts/startale.d.ts +20 -0
- package/dist/src/accounts/startale.d.ts.map +1 -0
- package/dist/src/accounts/startale.js +100 -0
- package/dist/src/accounts/startale.test.d.ts +2 -0
- package/dist/src/accounts/startale.test.d.ts.map +1 -0
- package/dist/src/accounts/startale.test.js +99 -0
- package/dist/{accounts → src/accounts}/utils.d.ts +4 -3
- package/dist/src/accounts/utils.d.ts.map +1 -0
- package/dist/{accounts → src/accounts}/utils.js +44 -0
- package/dist/src/accounts/utils.test.d.ts +2 -0
- package/dist/src/accounts/utils.test.d.ts.map +1 -0
- package/dist/src/accounts/utils.test.js +49 -0
- package/dist/src/actions/index.d.ts +39 -0
- package/dist/src/actions/index.d.ts.map +1 -0
- package/dist/{actions → src/actions}/index.js +108 -15
- package/dist/src/actions/index.test.d.ts +2 -0
- package/dist/src/actions/index.test.d.ts.map +1 -0
- package/dist/src/actions/index.test.js +302 -0
- package/dist/{actions → src/actions}/smart-session.d.ts +2 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -0
- package/dist/src/execution/compact.d.ts +8 -0
- package/dist/src/execution/compact.d.ts.map +1 -0
- package/dist/src/execution/compact.js +105 -0
- package/dist/src/execution/error.d.ts +54 -0
- package/dist/src/execution/error.d.ts.map +1 -0
- package/dist/src/execution/error.js +78 -0
- package/dist/{execution → src/execution}/index.d.ts +7 -6
- package/dist/src/execution/index.d.ts.map +1 -0
- package/dist/src/execution/index.js +150 -0
- package/dist/src/execution/smart-session.d.ts +15 -0
- package/dist/src/execution/smart-session.d.ts.map +1 -0
- package/dist/{execution → src/execution}/smart-session.js +16 -77
- package/dist/src/execution/smart-session.test.d.ts +2 -0
- package/dist/src/execution/smart-session.test.d.ts.map +1 -0
- package/dist/src/execution/smart-session.test.js +34 -0
- package/dist/src/execution/utils.d.ts +45 -0
- package/dist/src/execution/utils.d.ts.map +1 -0
- package/dist/src/execution/utils.js +433 -0
- package/dist/src/index.d.ts +41 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +154 -0
- package/dist/src/modules/abi/smart-sessions.d.ts.map +1 -0
- package/dist/src/modules/common.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.d.ts +3 -11
- package/dist/src/modules/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/index.js +3 -45
- package/dist/src/modules/index.test.d.ts +2 -0
- package/dist/src/modules/index.test.d.ts.map +1 -0
- package/dist/src/modules/index.test.js +107 -0
- package/dist/src/modules/omni-account.d.ts +7 -0
- package/dist/src/modules/omni-account.d.ts.map +1 -0
- package/dist/src/modules/omni-account.js +11 -0
- package/dist/src/modules/read.d.ts +9 -0
- package/dist/src/modules/read.d.ts.map +1 -0
- package/dist/{modules → src/modules}/read.js +6 -37
- package/dist/{modules → src/modules}/validators/core.d.ts +6 -7
- package/dist/src/modules/validators/core.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/core.js +83 -8
- package/dist/src/modules/validators/core.test.d.ts +2 -0
- package/dist/src/modules/validators/core.test.d.ts.map +1 -0
- package/dist/src/modules/validators/core.test.js +108 -0
- package/dist/src/modules/validators/index.d.ts +4 -0
- package/dist/src/modules/validators/index.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/index.js +1 -3
- package/dist/{modules → src/modules}/validators/smart-sessions.d.ts +4 -15
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -0
- package/dist/{modules → src/modules}/validators/smart-sessions.js +7 -61
- package/dist/src/modules/validators/smart-sessions.test.d.ts +2 -0
- package/dist/src/modules/validators/smart-sessions.test.d.ts.map +1 -0
- package/dist/src/modules/validators/smart-sessions.test.js +226 -0
- package/dist/src/orchestrator/client.d.ts +21 -0
- package/dist/src/orchestrator/client.d.ts.map +1 -0
- package/dist/src/orchestrator/client.js +284 -0
- package/dist/src/orchestrator/consts.d.ts +5 -0
- package/dist/src/orchestrator/consts.d.ts.map +1 -0
- package/dist/src/orchestrator/consts.js +9 -0
- package/dist/src/orchestrator/error.d.ts +96 -0
- package/dist/src/orchestrator/error.d.ts.map +1 -0
- package/dist/src/orchestrator/error.js +132 -0
- package/dist/src/orchestrator/index.d.ts +11 -0
- package/dist/src/orchestrator/index.d.ts.map +1 -0
- package/dist/src/orchestrator/index.js +42 -0
- package/dist/src/orchestrator/registry.d.ts +39 -0
- package/dist/src/orchestrator/registry.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.js +121 -0
- package/dist/src/orchestrator/registry.json +365 -0
- package/dist/src/orchestrator/registry.test.d.ts +2 -0
- package/dist/src/orchestrator/registry.test.d.ts.map +1 -0
- package/dist/src/orchestrator/registry.test.js +137 -0
- package/dist/src/orchestrator/types.d.ts +275 -0
- package/dist/src/orchestrator/types.d.ts.map +1 -0
- package/dist/src/orchestrator/types.js +19 -0
- package/dist/src/orchestrator/utils.d.ts +5 -0
- package/dist/src/orchestrator/utils.d.ts.map +1 -0
- package/dist/src/orchestrator/utils.js +126 -0
- package/dist/{types.d.ts → src/types.d.ts} +42 -21
- package/dist/src/types.d.ts.map +1 -0
- package/dist/test/consts.d.ts +10 -0
- package/dist/test/consts.d.ts.map +1 -0
- package/dist/test/consts.js +22 -0
- package/package.json +11 -20
- package/dist/accounts/index.d.ts.map +0 -1
- package/dist/accounts/index.js +0 -419
- package/dist/accounts/kernel.d.ts.map +0 -1
- package/dist/accounts/nexus.d.ts.map +0 -1
- package/dist/accounts/safe.d.ts.map +0 -1
- package/dist/accounts/utils.d.ts.map +0 -1
- package/dist/actions/index.d.ts +0 -29
- package/dist/actions/index.d.ts.map +0 -1
- package/dist/actions/registry.d.ts +0 -7
- package/dist/actions/registry.d.ts.map +0 -1
- package/dist/actions/registry.js +0 -7
- package/dist/actions/smart-session.d.ts.map +0 -1
- package/dist/execution/index.d.ts.map +0 -1
- package/dist/execution/index.js +0 -149
- package/dist/execution/smart-session.d.ts +0 -23
- package/dist/execution/smart-session.d.ts.map +0 -1
- package/dist/execution/utils.d.ts +0 -68
- package/dist/execution/utils.d.ts.map +0 -1
- package/dist/execution/utils.js +0 -482
- package/dist/index.d.ts +0 -38
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js +0 -119
- package/dist/modules/abi/smart-sessions.d.ts.map +0 -1
- package/dist/modules/common.d.ts.map +0 -1
- package/dist/modules/index.d.ts.map +0 -1
- package/dist/modules/omni-account.d.ts +0 -9
- package/dist/modules/omni-account.d.ts.map +0 -1
- package/dist/modules/omni-account.js +0 -15
- package/dist/modules/read.d.ts +0 -10
- package/dist/modules/read.d.ts.map +0 -1
- package/dist/modules/registry.d.ts +0 -9
- package/dist/modules/registry.d.ts.map +0 -1
- package/dist/modules/registry.js +0 -60
- package/dist/modules/validators/core.d.ts.map +0 -1
- package/dist/modules/validators/index.d.ts +0 -4
- package/dist/modules/validators/index.d.ts.map +0 -1
- package/dist/modules/validators/smart-sessions.d.ts.map +0 -1
- package/dist/orchestrator/client.d.ts +0 -29
- package/dist/orchestrator/client.d.ts.map +0 -1
- package/dist/orchestrator/client.js +0 -250
- package/dist/orchestrator/consts.d.ts +0 -5
- package/dist/orchestrator/consts.d.ts.map +0 -1
- package/dist/orchestrator/consts.js +0 -9
- package/dist/orchestrator/error.d.ts +0 -18
- package/dist/orchestrator/error.d.ts.map +0 -1
- package/dist/orchestrator/error.js +0 -33
- package/dist/orchestrator/index.d.ts +0 -11
- package/dist/orchestrator/index.d.ts.map +0 -1
- package/dist/orchestrator/index.js +0 -40
- package/dist/orchestrator/registry.d.ts +0 -20
- package/dist/orchestrator/registry.d.ts.map +0 -1
- package/dist/orchestrator/registry.js +0 -444
- package/dist/orchestrator/types.d.ts +0 -242
- package/dist/orchestrator/types.d.ts.map +0 -1
- package/dist/orchestrator/types.js +0 -19
- package/dist/orchestrator/utils.d.ts +0 -29
- package/dist/orchestrator/utils.d.ts.map +0 -1
- package/dist/orchestrator/utils.js +0 -319
- package/dist/types.d.ts.map +0 -1
- /package/dist/{actions → src/actions}/smart-session.js +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.d.ts +0 -0
- /package/dist/{modules → src/modules}/abi/smart-sessions.js +0 -0
- /package/dist/{modules → src/modules}/common.d.ts +0 -0
- /package/dist/{modules → src/modules}/common.js +0 -0
- /package/dist/{types.js → src/types.js} +0 -0
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { type Address, type Chain, type Hex, type PublicClient, type SignedAuthorization, type SignedAuthorizationList } from 'viem';
|
|
2
|
+
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
|
+
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
4
|
+
import type { Call, CallInput, RhinestoneAccountConfig, SignerSet, TokenRequest, Transaction } from '../types';
|
|
5
|
+
type TransactionResult = {
|
|
6
|
+
type: 'userop';
|
|
7
|
+
hash: Hex;
|
|
8
|
+
chain: number;
|
|
9
|
+
} | {
|
|
10
|
+
type: 'intent';
|
|
11
|
+
id: bigint;
|
|
12
|
+
sourceChain?: number;
|
|
13
|
+
targetChain: number;
|
|
14
|
+
};
|
|
15
|
+
interface IntentData {
|
|
16
|
+
type: 'intent';
|
|
17
|
+
hash: Hex;
|
|
18
|
+
intentRoute: IntentRoute;
|
|
19
|
+
}
|
|
20
|
+
interface UserOpData {
|
|
21
|
+
type: 'userop';
|
|
22
|
+
hash: Hex;
|
|
23
|
+
userOp: UserOperation;
|
|
24
|
+
}
|
|
25
|
+
interface PreparedTransactionData {
|
|
26
|
+
data: IntentData | UserOpData;
|
|
27
|
+
transaction: Transaction;
|
|
28
|
+
}
|
|
29
|
+
interface SignedTransactionData extends PreparedTransactionData {
|
|
30
|
+
signature: Hex;
|
|
31
|
+
}
|
|
32
|
+
declare function prepareTransaction(config: RhinestoneAccountConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
33
|
+
declare function signTransaction(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
34
|
+
declare function signAuthorizations(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
|
|
35
|
+
declare function signAuthorizationsInternal(config: RhinestoneAccountConfig, data: IntentData | UserOpData): Promise<SignedAuthorization[]>;
|
|
36
|
+
declare function submitTransaction(config: RhinestoneAccountConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
37
|
+
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CallInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address, isSponsored: boolean, eip7702InitSignature?: Hex): Promise<IntentData>;
|
|
38
|
+
declare function signIntent(config: RhinestoneAccountConfig, targetChain: Chain, intentHash: Hex, signers?: SignerSet): Promise<`0x${string}`>;
|
|
39
|
+
declare function getOrchestratorByChain(chainId: number, apiKey: string): import("../orchestrator").Orchestrator;
|
|
40
|
+
declare function submitIntentInternal(config: RhinestoneAccountConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex, authorizations: SignedAuthorizationList): Promise<TransactionResult>;
|
|
41
|
+
declare function getValidatorAccount(config: RhinestoneAccountConfig, signers: SignerSet | undefined, publicClient: PublicClient, chain: Chain): Promise<import("viem/account-abstraction").SmartAccount<import("viem/account-abstraction").SmartAccountImplementation<import("viem").Abi, "0.7">> | null | undefined>;
|
|
42
|
+
declare function parseCalls(calls: CallInput[], chainId: number): Call[];
|
|
43
|
+
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, submitTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, };
|
|
44
|
+
export type { IntentData, TransactionResult, PreparedTransactionData, SignedTransactionData, };
|
|
45
|
+
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIV,KAAK,GAAG,EACR,KAAK,YAAY,EAEjB,KAAK,mBAAmB,EACxB,KAAK,uBAAuB,EAG7B,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAqBjC,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,WAAW,EAGjB,MAAM,iBAAiB,CAAA;AAUxB,OAAO,KAA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,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|
|
@@ -0,0 +1,433 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.prepareTransaction = prepareTransaction;
|
|
4
|
+
exports.signTransaction = signTransaction;
|
|
5
|
+
exports.signAuthorizations = signAuthorizations;
|
|
6
|
+
exports.signAuthorizationsInternal = signAuthorizationsInternal;
|
|
7
|
+
exports.submitTransaction = submitTransaction;
|
|
8
|
+
exports.getOrchestratorByChain = getOrchestratorByChain;
|
|
9
|
+
exports.signIntent = signIntent;
|
|
10
|
+
exports.prepareTransactionAsIntent = prepareTransactionAsIntent;
|
|
11
|
+
exports.submitIntentInternal = submitIntentInternal;
|
|
12
|
+
exports.getValidatorAccount = getValidatorAccount;
|
|
13
|
+
exports.parseCalls = parseCalls;
|
|
14
|
+
const viem_1 = require("viem");
|
|
15
|
+
const account_abstraction_1 = require("viem/account-abstraction");
|
|
16
|
+
const accounts_1 = require("../accounts");
|
|
17
|
+
const utils_1 = require("../accounts/utils");
|
|
18
|
+
const validators_1 = require("../modules/validators");
|
|
19
|
+
const core_1 = require("../modules/validators/core");
|
|
20
|
+
const orchestrator_1 = require("../orchestrator");
|
|
21
|
+
const consts_1 = require("../orchestrator/consts");
|
|
22
|
+
const registry_1 = require("../orchestrator/registry");
|
|
23
|
+
const error_1 = require("./error");
|
|
24
|
+
async function prepareTransaction(config, transaction) {
|
|
25
|
+
const { sourceChains, targetChain, tokenRequests, signers, sponsored, eip7702InitSignature, } = getTransactionParams(transaction);
|
|
26
|
+
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
27
|
+
let data;
|
|
28
|
+
const asUserOp = signers?.type === 'guardians' || signers?.type === 'session';
|
|
29
|
+
if (asUserOp) {
|
|
30
|
+
if (sourceChains && sourceChains.length > 0) {
|
|
31
|
+
throw new error_1.SourceChainsNotAvailableForUserOpFlowError();
|
|
32
|
+
}
|
|
33
|
+
// Smart sessions require a UserOp flow
|
|
34
|
+
data = await prepareTransactionAsUserOp(config, targetChain, transaction.calls, signers);
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
data = await prepareTransactionAsIntent(config, sourceChains, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress, sponsored ?? false, eip7702InitSignature);
|
|
38
|
+
}
|
|
39
|
+
return {
|
|
40
|
+
data,
|
|
41
|
+
transaction,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
async function signTransaction(config, preparedTransaction) {
|
|
45
|
+
const { targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
|
|
46
|
+
const data = preparedTransaction.data;
|
|
47
|
+
const asUserOp = data.type === 'userop';
|
|
48
|
+
let signature;
|
|
49
|
+
if (asUserOp) {
|
|
50
|
+
const chain = targetChain;
|
|
51
|
+
const userOp = data.userOp;
|
|
52
|
+
if (!userOp) {
|
|
53
|
+
throw new error_1.UserOperationRequiredForSmartSessionsError();
|
|
54
|
+
}
|
|
55
|
+
// Smart sessions require a UserOp flow
|
|
56
|
+
signature = await signUserOp(config, chain, signers, userOp);
|
|
57
|
+
}
|
|
58
|
+
else {
|
|
59
|
+
signature = await signIntent(config, targetChain, data.hash, signers);
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
data,
|
|
63
|
+
transaction: preparedTransaction.transaction,
|
|
64
|
+
signature,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async function signAuthorizations(config, preparedTransaction) {
|
|
68
|
+
return await signAuthorizationsInternal(config, preparedTransaction.data);
|
|
69
|
+
}
|
|
70
|
+
async function signAuthorizationsInternal(config, data) {
|
|
71
|
+
const eoa = config.eoa;
|
|
72
|
+
if (!eoa) {
|
|
73
|
+
throw new Error('EIP-7702 initialization is required for EOA accounts');
|
|
74
|
+
}
|
|
75
|
+
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
76
|
+
const requiredDelegations = data.type === 'intent'
|
|
77
|
+
? data.intentRoute.intentOp.signedMetadata.account.requiredDelegations ||
|
|
78
|
+
{}
|
|
79
|
+
: {};
|
|
80
|
+
const authorizations = [];
|
|
81
|
+
for (const chainId in requiredDelegations) {
|
|
82
|
+
const delegation = requiredDelegations[chainId];
|
|
83
|
+
const chain = (0, registry_1.getChainById)(Number(chainId));
|
|
84
|
+
if (!chain) {
|
|
85
|
+
throw new Error(`Chain not supported: ${chainId}`);
|
|
86
|
+
}
|
|
87
|
+
const walletClient = (0, viem_1.createWalletClient)({
|
|
88
|
+
chain,
|
|
89
|
+
account: eoa,
|
|
90
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
91
|
+
}).extend(viem_1.publicActions);
|
|
92
|
+
const code = await walletClient.getCode({
|
|
93
|
+
address: accountAddress,
|
|
94
|
+
});
|
|
95
|
+
const isDelegated = code === (0, viem_1.concat)(['0xef0100', delegation.contract.toLowerCase()]);
|
|
96
|
+
if (isDelegated) {
|
|
97
|
+
continue;
|
|
98
|
+
}
|
|
99
|
+
const authorization = await walletClient.signAuthorization({
|
|
100
|
+
contractAddress: delegation.contract,
|
|
101
|
+
chainId: Number(chainId),
|
|
102
|
+
});
|
|
103
|
+
authorizations.push(authorization);
|
|
104
|
+
}
|
|
105
|
+
return authorizations;
|
|
106
|
+
}
|
|
107
|
+
async function submitTransaction(config, signedTransaction, authorizations) {
|
|
108
|
+
const { data, transaction, signature } = signedTransaction;
|
|
109
|
+
const { sourceChains, targetChain } = getTransactionParams(transaction);
|
|
110
|
+
const asUserOp = data.type === 'userop';
|
|
111
|
+
if (asUserOp) {
|
|
112
|
+
const chain = targetChain;
|
|
113
|
+
const userOp = data.userOp;
|
|
114
|
+
if (!userOp) {
|
|
115
|
+
throw new error_1.UserOperationRequiredForSmartSessionsError();
|
|
116
|
+
}
|
|
117
|
+
// Smart sessions require a UserOp flow
|
|
118
|
+
return await submitUserOp(config, chain, userOp, signature);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
const intentOp = data.intentRoute.intentOp;
|
|
122
|
+
if (!intentOp) {
|
|
123
|
+
throw new error_1.OrderPathRequiredForIntentsError();
|
|
124
|
+
}
|
|
125
|
+
return await submitIntent(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
128
|
+
function getTransactionParams(transaction) {
|
|
129
|
+
const sourceChains = 'chain' in transaction ? [transaction.chain] : transaction.sourceChains;
|
|
130
|
+
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
131
|
+
const initialTokenRequests = transaction.tokenRequests;
|
|
132
|
+
const signers = transaction.signers;
|
|
133
|
+
const eip7702InitSignature = transaction.eip7702InitSignature;
|
|
134
|
+
const sponsored = transaction.sponsored;
|
|
135
|
+
// Across requires passing some value to repay the solvers
|
|
136
|
+
const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
|
|
137
|
+
? [
|
|
138
|
+
{
|
|
139
|
+
address: viem_1.zeroAddress,
|
|
140
|
+
amount: 1n,
|
|
141
|
+
},
|
|
142
|
+
]
|
|
143
|
+
: initialTokenRequests;
|
|
144
|
+
return {
|
|
145
|
+
sourceChains,
|
|
146
|
+
targetChain,
|
|
147
|
+
tokenRequests,
|
|
148
|
+
signers,
|
|
149
|
+
sponsored,
|
|
150
|
+
eip7702InitSignature,
|
|
151
|
+
};
|
|
152
|
+
}
|
|
153
|
+
async function prepareTransactionAsUserOp(config, chain, callInputs, signers) {
|
|
154
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
155
|
+
chain,
|
|
156
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
157
|
+
});
|
|
158
|
+
const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
|
|
159
|
+
if (!validatorAccount) {
|
|
160
|
+
throw new Error('No validator account found');
|
|
161
|
+
}
|
|
162
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
163
|
+
const calls = parseCalls(callInputs, chain.id);
|
|
164
|
+
const userOp = await bundlerClient.prepareUserOperation({
|
|
165
|
+
account: validatorAccount,
|
|
166
|
+
calls,
|
|
167
|
+
});
|
|
168
|
+
return {
|
|
169
|
+
type: 'userop',
|
|
170
|
+
userOp,
|
|
171
|
+
hash: (0, account_abstraction_1.getUserOperationHash)({
|
|
172
|
+
userOperation: userOp,
|
|
173
|
+
chainId: chain.id,
|
|
174
|
+
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
175
|
+
entryPointVersion: '0.7',
|
|
176
|
+
}),
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
async function prepareTransactionAsIntent(config, sourceChains, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, isSponsored, eip7702InitSignature) {
|
|
180
|
+
const calls = parseCalls(callInputs, targetChain.id);
|
|
181
|
+
const accountAccessList = sourceChains && sourceChains.length > 0
|
|
182
|
+
? {
|
|
183
|
+
chainIds: sourceChains.map((chain) => chain.id),
|
|
184
|
+
}
|
|
185
|
+
: undefined;
|
|
186
|
+
const { setupOps, delegations } = await getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature);
|
|
187
|
+
const metaIntent = {
|
|
188
|
+
destinationChainId: targetChain.id,
|
|
189
|
+
tokenTransfers: tokenRequests.map((tokenRequest) => ({
|
|
190
|
+
tokenAddress: (0, registry_1.resolveTokenAddress)(tokenRequest.address, targetChain.id),
|
|
191
|
+
amount: tokenRequest.amount,
|
|
192
|
+
})),
|
|
193
|
+
account: {
|
|
194
|
+
address: accountAddress,
|
|
195
|
+
accountType: 'ERC7579',
|
|
196
|
+
setupOps: setupOps || [],
|
|
197
|
+
delegations,
|
|
198
|
+
},
|
|
199
|
+
destinationExecutions: calls,
|
|
200
|
+
destinationGasUnits: gasLimit,
|
|
201
|
+
accountAccessList,
|
|
202
|
+
options: {
|
|
203
|
+
topupCompact: false,
|
|
204
|
+
sponsorSettings: {
|
|
205
|
+
gasSponsored: isSponsored,
|
|
206
|
+
bridgeFeesSponsored: isSponsored,
|
|
207
|
+
swapFeesSponsored: isSponsored,
|
|
208
|
+
},
|
|
209
|
+
},
|
|
210
|
+
};
|
|
211
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
|
|
212
|
+
const intentRoute = await orchestrator.getIntentRoute(metaIntent);
|
|
213
|
+
const intentHash = (0, orchestrator_1.getIntentOpHash)(intentRoute.intentOp);
|
|
214
|
+
return {
|
|
215
|
+
type: 'intent',
|
|
216
|
+
intentRoute,
|
|
217
|
+
hash: intentHash,
|
|
218
|
+
};
|
|
219
|
+
}
|
|
220
|
+
async function signIntent(config, targetChain, intentHash, signers) {
|
|
221
|
+
const validator = getValidator(config, signers);
|
|
222
|
+
if (!validator) {
|
|
223
|
+
throw new Error('Validator not available');
|
|
224
|
+
}
|
|
225
|
+
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
226
|
+
const isRoot = validator.address === ownerValidator.address;
|
|
227
|
+
const signature = await (0, accounts_1.getPackedSignature)(config, signers, targetChain, {
|
|
228
|
+
address: validator.address,
|
|
229
|
+
isRoot,
|
|
230
|
+
}, intentHash);
|
|
231
|
+
return signature;
|
|
232
|
+
}
|
|
233
|
+
async function signUserOp(config, chain, signers, userOp) {
|
|
234
|
+
const validator = getValidator(config, signers);
|
|
235
|
+
if (!validator) {
|
|
236
|
+
throw new Error('Validator not available');
|
|
237
|
+
}
|
|
238
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
239
|
+
chain,
|
|
240
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
241
|
+
});
|
|
242
|
+
const account = await getValidatorAccount(config, signers, publicClient, chain);
|
|
243
|
+
if (!account) {
|
|
244
|
+
throw new Error('No account found');
|
|
245
|
+
}
|
|
246
|
+
return await account.signUserOperation(userOp);
|
|
247
|
+
}
|
|
248
|
+
async function submitUserOp(config, chain, userOp, signature) {
|
|
249
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
250
|
+
chain,
|
|
251
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
252
|
+
});
|
|
253
|
+
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
254
|
+
const hash = await bundlerClient.request({
|
|
255
|
+
method: 'eth_sendUserOperation',
|
|
256
|
+
params: [
|
|
257
|
+
{
|
|
258
|
+
sender: userOp.sender,
|
|
259
|
+
nonce: (0, viem_1.toHex)(userOp.nonce),
|
|
260
|
+
factory: userOp.factory,
|
|
261
|
+
factoryData: userOp.factoryData,
|
|
262
|
+
callData: userOp.callData,
|
|
263
|
+
callGasLimit: (0, viem_1.toHex)(userOp.callGasLimit),
|
|
264
|
+
verificationGasLimit: (0, viem_1.toHex)(userOp.verificationGasLimit),
|
|
265
|
+
preVerificationGas: (0, viem_1.toHex)(userOp.preVerificationGas),
|
|
266
|
+
maxPriorityFeePerGas: (0, viem_1.toHex)(userOp.maxPriorityFeePerGas),
|
|
267
|
+
maxFeePerGas: (0, viem_1.toHex)(userOp.maxFeePerGas),
|
|
268
|
+
paymaster: userOp.paymaster,
|
|
269
|
+
paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit
|
|
270
|
+
? (0, viem_1.toHex)(userOp.paymasterVerificationGasLimit)
|
|
271
|
+
: undefined,
|
|
272
|
+
paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit
|
|
273
|
+
? (0, viem_1.toHex)(userOp.paymasterPostOpGasLimit)
|
|
274
|
+
: undefined,
|
|
275
|
+
paymasterData: userOp.paymasterData,
|
|
276
|
+
signature,
|
|
277
|
+
},
|
|
278
|
+
account_abstraction_1.entryPoint07Address,
|
|
279
|
+
],
|
|
280
|
+
});
|
|
281
|
+
return {
|
|
282
|
+
type: 'userop',
|
|
283
|
+
hash,
|
|
284
|
+
chain: chain.id,
|
|
285
|
+
};
|
|
286
|
+
}
|
|
287
|
+
async function submitIntent(config, sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
288
|
+
return submitIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations);
|
|
289
|
+
}
|
|
290
|
+
function getOrchestratorByChain(chainId, apiKey) {
|
|
291
|
+
const orchestratorUrl = (0, registry_1.isTestnet)(chainId)
|
|
292
|
+
? consts_1.STAGING_ORCHESTRATOR_URL
|
|
293
|
+
: consts_1.PROD_ORCHESTRATOR_URL;
|
|
294
|
+
return (0, orchestrator_1.getOrchestrator)(apiKey, orchestratorUrl);
|
|
295
|
+
}
|
|
296
|
+
async function submitIntentInternal(config, sourceChains, targetChain, intentOp, signature, authorizations) {
|
|
297
|
+
const signedIntentOp = {
|
|
298
|
+
...intentOp,
|
|
299
|
+
originSignatures: Array(intentOp.elements.length).fill(signature),
|
|
300
|
+
destinationSignature: signature,
|
|
301
|
+
signedAuthorizations: authorizations.length > 0
|
|
302
|
+
? authorizations.map((authorization) => ({
|
|
303
|
+
chainId: authorization.chainId,
|
|
304
|
+
address: authorization.address,
|
|
305
|
+
nonce: authorization.nonce,
|
|
306
|
+
yParity: authorization.yParity ?? 0,
|
|
307
|
+
r: authorization.r,
|
|
308
|
+
s: authorization.s,
|
|
309
|
+
}))
|
|
310
|
+
: undefined,
|
|
311
|
+
};
|
|
312
|
+
const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
|
|
313
|
+
const intentResults = await orchestrator.submitIntent(signedIntentOp);
|
|
314
|
+
return {
|
|
315
|
+
type: 'intent',
|
|
316
|
+
id: BigInt(intentResults.result.id),
|
|
317
|
+
sourceChains: sourceChains?.map((chain) => chain.id),
|
|
318
|
+
targetChain: targetChain.id,
|
|
319
|
+
};
|
|
320
|
+
}
|
|
321
|
+
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
322
|
+
if (!signers) {
|
|
323
|
+
return undefined;
|
|
324
|
+
}
|
|
325
|
+
// Owners
|
|
326
|
+
const withOwner = signers.type === 'owner' ? signers : null;
|
|
327
|
+
if (withOwner) {
|
|
328
|
+
return (0, accounts_1.getSmartAccount)(config, publicClient, chain);
|
|
329
|
+
}
|
|
330
|
+
const withSession = signers.type === 'session' ? signers : null;
|
|
331
|
+
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
332
|
+
return withSession
|
|
333
|
+
? await (0, accounts_1.getSmartSessionSmartAccount)(config, publicClient, chain, withSession.session, withSession.enableData || null)
|
|
334
|
+
: withGuardians
|
|
335
|
+
? await (0, accounts_1.getGuardianSmartAccount)(config, publicClient, chain, {
|
|
336
|
+
type: 'ecdsa',
|
|
337
|
+
accounts: withGuardians.guardians,
|
|
338
|
+
})
|
|
339
|
+
: null;
|
|
340
|
+
}
|
|
341
|
+
function getValidator(config, signers) {
|
|
342
|
+
if (!signers) {
|
|
343
|
+
return (0, validators_1.getOwnerValidator)(config);
|
|
344
|
+
}
|
|
345
|
+
// Owners
|
|
346
|
+
const withOwner = signers.type === 'owner' ? signers : null;
|
|
347
|
+
if (withOwner) {
|
|
348
|
+
// ECDSA
|
|
349
|
+
if (withOwner.kind === 'ecdsa') {
|
|
350
|
+
return (0, core_1.getOwnableValidator)(1, withOwner.accounts.map((account) => account.address));
|
|
351
|
+
}
|
|
352
|
+
// Passkeys (WebAuthn)
|
|
353
|
+
if (withOwner.kind === 'passkey') {
|
|
354
|
+
const passkeyAccount = withOwner.account;
|
|
355
|
+
return (0, core_1.getWebAuthnValidator)({
|
|
356
|
+
pubKey: passkeyAccount.publicKey,
|
|
357
|
+
authenticatorId: passkeyAccount.id,
|
|
358
|
+
});
|
|
359
|
+
}
|
|
360
|
+
// Multi-factor
|
|
361
|
+
if (withOwner.kind === 'multi-factor') {
|
|
362
|
+
// Convert validators to proper format
|
|
363
|
+
const validators = withOwner.validators.map(validator => {
|
|
364
|
+
if (validator.type === 'ecdsa') {
|
|
365
|
+
return { type: 'ecdsa', accounts: validator.accounts, threshold: 1 };
|
|
366
|
+
}
|
|
367
|
+
else {
|
|
368
|
+
return { type: 'passkey', account: validator.account, credentialIds: [] };
|
|
369
|
+
}
|
|
370
|
+
});
|
|
371
|
+
return (0, core_1.getMultiFactorValidator)(1, validators);
|
|
372
|
+
}
|
|
373
|
+
}
|
|
374
|
+
// Smart sessions
|
|
375
|
+
const withSession = signers.type === 'session' ? signers.session : null;
|
|
376
|
+
if (withSession) {
|
|
377
|
+
return (0, validators_1.getSmartSessionValidator)(config);
|
|
378
|
+
}
|
|
379
|
+
// Guardians (social recovery)
|
|
380
|
+
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
381
|
+
if (withGuardians) {
|
|
382
|
+
return (0, core_1.getSocialRecoveryValidator)(withGuardians.guardians);
|
|
383
|
+
}
|
|
384
|
+
// Fallback
|
|
385
|
+
return undefined;
|
|
386
|
+
}
|
|
387
|
+
function parseCalls(calls, chainId) {
|
|
388
|
+
return calls.map((call) => ({
|
|
389
|
+
data: call.data ?? '0x',
|
|
390
|
+
value: call.value ?? 0n,
|
|
391
|
+
to: (0, registry_1.resolveTokenAddress)(call.to, chainId),
|
|
392
|
+
}));
|
|
393
|
+
}
|
|
394
|
+
async function getSetupOperationsAndDelegations(config, accountAddress, eip7702InitSignature) {
|
|
395
|
+
const initCode = (0, accounts_1.getInitCode)(config);
|
|
396
|
+
if (config.eoa) {
|
|
397
|
+
// EIP-7702 initialization is only needed for EOA accounts
|
|
398
|
+
if (!eip7702InitSignature || eip7702InitSignature === '0x') {
|
|
399
|
+
throw new Error('EIP-7702 initialization signature is required for EOA accounts');
|
|
400
|
+
}
|
|
401
|
+
const { initData: eip7702InitData, contract: eip7702Contract } = await (0, accounts_1.getEip7702InitCall)(config, eip7702InitSignature);
|
|
402
|
+
return {
|
|
403
|
+
setupOps: [
|
|
404
|
+
{
|
|
405
|
+
to: accountAddress,
|
|
406
|
+
data: eip7702InitData,
|
|
407
|
+
},
|
|
408
|
+
],
|
|
409
|
+
delegations: {
|
|
410
|
+
0: {
|
|
411
|
+
contract: eip7702Contract,
|
|
412
|
+
},
|
|
413
|
+
},
|
|
414
|
+
};
|
|
415
|
+
}
|
|
416
|
+
else if (initCode) {
|
|
417
|
+
// Contract account with init code
|
|
418
|
+
return {
|
|
419
|
+
setupOps: [
|
|
420
|
+
{
|
|
421
|
+
to: initCode.factory,
|
|
422
|
+
data: initCode.factoryData,
|
|
423
|
+
},
|
|
424
|
+
],
|
|
425
|
+
};
|
|
426
|
+
}
|
|
427
|
+
else {
|
|
428
|
+
// Already deployed contract account
|
|
429
|
+
return {
|
|
430
|
+
setupOps: [],
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { Address, Chain, Hex, SignedAuthorizationList } from 'viem';
|
|
2
|
+
import type { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
|
+
import { AccountError, Eip7702AccountMustHaveEoaError, Eip7702NotSupportedForAccountError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, isAccountError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, SmartSessionsNotEnabledError } from './accounts';
|
|
4
|
+
import { createTransport } from './accounts/utils';
|
|
5
|
+
import { addOwner, changeMultiFactorThreshold, changeThreshold, disableEcdsa, disableMultiFactor, disablePasskeys, enableEcdsa, enableMultiFactor, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, removeSubValidator, setSubValidator, setUpRecovery } from './actions';
|
|
6
|
+
import type { TransactionResult } from './execution';
|
|
7
|
+
import { ExecutionError, IntentFailedError, isExecutionError, OrderPathRequiredForIntentsError, SessionChainRequiredError, SourceChainsNotAvailableForUserOpFlowError, UserOperationRequiredForSmartSessionsError } from './execution';
|
|
8
|
+
import { type SessionDetails } from './execution/smart-session';
|
|
9
|
+
import { type IntentData, type PreparedTransactionData, type SignedTransactionData } from './execution/utils';
|
|
10
|
+
import { AuthenticationRequiredError, InsufficientBalanceError, type IntentCost, type IntentInput, IntentNotFoundError, type IntentOp, type IntentOpStatus, type IntentResult, type IntentRoute, InvalidApiKeyError, InvalidIntentSignatureError, isOrchestratorError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, type Portfolio, type SettlementSystem, type SignedIntentOp, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError } from './orchestrator';
|
|
11
|
+
import type { Call, RhinestoneAccountConfig, Session, Transaction } from './types';
|
|
12
|
+
interface RhinestoneAccount {
|
|
13
|
+
config: RhinestoneAccountConfig;
|
|
14
|
+
deploy: (chain: Chain, session?: Session) => Promise<void>;
|
|
15
|
+
signEip7702InitData: () => Promise<Hex>;
|
|
16
|
+
prepareTransaction: (transaction: Transaction) => Promise<PreparedTransactionData>;
|
|
17
|
+
signTransaction: (preparedTransaction: PreparedTransactionData) => Promise<SignedTransactionData>;
|
|
18
|
+
signAuthorizations: (preparedTransaction: PreparedTransactionData) => Promise<SignedAuthorizationList>;
|
|
19
|
+
submitTransaction: (signedTransaction: SignedTransactionData, authorizations?: SignedAuthorizationList) => Promise<TransactionResult>;
|
|
20
|
+
sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
|
|
21
|
+
waitForExecution: (result: TransactionResult, acceptsPreconfirmations?: boolean) => Promise<IntentOpStatus | UserOperationReceipt>;
|
|
22
|
+
getAddress: () => Address;
|
|
23
|
+
getPortfolio: (onTestnets?: boolean) => Promise<Portfolio>;
|
|
24
|
+
getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint) => Promise<bigint>;
|
|
25
|
+
getSessionDetails: (sessions: Session[], sessionIndex: number, signature?: Hex) => Promise<SessionDetails>;
|
|
26
|
+
getOwners: (chain: Chain) => Promise<{
|
|
27
|
+
accounts: Address[];
|
|
28
|
+
threshold: number;
|
|
29
|
+
} | null>;
|
|
30
|
+
getValidators: (chain: Chain) => Promise<Address[]>;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Initialize a Rhinestone account
|
|
34
|
+
* Note: accounts are deployed onchain only when the first transaction is sent.
|
|
35
|
+
* @param config Account config (e.g. implementation vendor, owner signers, smart sessions)
|
|
36
|
+
* @returns account
|
|
37
|
+
*/
|
|
38
|
+
declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
39
|
+
export { createRhinestoneAccount, createTransport, addOwner, changeMultiFactorThreshold, changeThreshold, disableEcdsa, disableMultiFactor, disablePasskeys, enableEcdsa, enableMultiFactor, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, removeSubValidator, setSubValidator, setUpRecovery, isAccountError, AccountError, Eip7702AccountMustHaveEoaError, ExistingEip7702AccountsNotSupportedError, FactoryArgsNotAvailableError, SmartSessionsNotEnabledError, SigningNotSupportedForAccountError, SignMessageNotSupportedByAccountError, Eip7702NotSupportedForAccountError, isExecutionError, IntentFailedError, ExecutionError, SourceChainsNotAvailableForUserOpFlowError, UserOperationRequiredForSmartSessionsError, OrderPathRequiredForIntentsError, SessionChainRequiredError, isOrchestratorError, AuthenticationRequiredError, InsufficientBalanceError, InvalidApiKeyError, InvalidIntentSignatureError, NoPathFoundError, OnlyOneTargetTokenAmountCanBeUnsetError, OrchestratorError, IntentNotFoundError, TokenNotSupportedError, UnsupportedChainError, UnsupportedChainIdError, UnsupportedTokenError, };
|
|
40
|
+
export type { RhinestoneAccount, Session, Call, IntentData, PreparedTransactionData, SignedTransactionData, TransactionResult, IntentCost, IntentInput, IntentOp, IntentOpStatus, IntentResult, IntentRoute, SettlementSystem, SignedIntentOp, Portfolio, };
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,uBAAuB,EAAE,MAAM,MAAM,CAAA;AACxE,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,0BAA0B,CAAA;AACpE,OAAO,EACL,YAAY,EAEZ,8BAA8B,EAC9B,kCAAkC,EAClC,wCAAwC,EACxC,4BAA4B,EAE5B,cAAc,EACd,kCAAkC,EAClC,qCAAqC,EACrC,4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