@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
package/dist/execution/utils.js
DELETED
|
@@ -1,482 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.prepareTransaction = prepareTransaction;
|
|
4
|
-
exports.signTransaction = signTransaction;
|
|
5
|
-
exports.submitTransaction = submitTransaction;
|
|
6
|
-
exports.getOrchestratorByChain = getOrchestratorByChain;
|
|
7
|
-
exports.getUserOpOrderPath = getUserOpOrderPath;
|
|
8
|
-
exports.getUserOp = getUserOp;
|
|
9
|
-
exports.signIntent = signIntent;
|
|
10
|
-
exports.signUserOp = signUserOp;
|
|
11
|
-
exports.submitUserOp = submitUserOp;
|
|
12
|
-
exports.prepareTransactionAsIntent = prepareTransactionAsIntent;
|
|
13
|
-
exports.submitIntentInternal = submitIntentInternal;
|
|
14
|
-
exports.getValidatorAccount = getValidatorAccount;
|
|
15
|
-
const viem_1 = require("viem");
|
|
16
|
-
const account_abstraction_1 = require("viem/account-abstraction");
|
|
17
|
-
const accounts_1 = require("../accounts");
|
|
18
|
-
const utils_1 = require("../accounts/utils");
|
|
19
|
-
const validators_1 = require("../modules/validators");
|
|
20
|
-
const core_1 = require("../modules/validators/core");
|
|
21
|
-
const orchestrator_1 = require("../orchestrator");
|
|
22
|
-
const consts_1 = require("../orchestrator/consts");
|
|
23
|
-
const registry_1 = require("../orchestrator/registry");
|
|
24
|
-
const smart_session_1 = require("./smart-session");
|
|
25
|
-
async function prepareTransaction(config, transaction) {
|
|
26
|
-
const { sourceChain, targetChain, tokenRequests, signers } = getTransactionParams(transaction);
|
|
27
|
-
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
28
|
-
let bundleData;
|
|
29
|
-
if (signers) {
|
|
30
|
-
if (!sourceChain) {
|
|
31
|
-
throw new Error(`Specifying source chain is required when using smart sessions or guardians`);
|
|
32
|
-
}
|
|
33
|
-
// Smart sessions require a UserOp flow
|
|
34
|
-
bundleData = await prepareTransactionAsUserOp(config, sourceChain, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress, signers);
|
|
35
|
-
}
|
|
36
|
-
else {
|
|
37
|
-
bundleData = await prepareTransactionAsIntent(config, sourceChain, targetChain, transaction.calls, transaction.gasLimit, tokenRequests, accountAddress);
|
|
38
|
-
}
|
|
39
|
-
return {
|
|
40
|
-
bundleData,
|
|
41
|
-
transaction,
|
|
42
|
-
};
|
|
43
|
-
}
|
|
44
|
-
async function signTransaction(config, preparedTransaction) {
|
|
45
|
-
const { sourceChain, targetChain, signers } = getTransactionParams(preparedTransaction.transaction);
|
|
46
|
-
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
47
|
-
const bundleData = preparedTransaction.bundleData;
|
|
48
|
-
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
49
|
-
let signature;
|
|
50
|
-
if (withSession) {
|
|
51
|
-
if (!sourceChain) {
|
|
52
|
-
throw new Error(`Specifying source chain is required when using smart sessions`);
|
|
53
|
-
}
|
|
54
|
-
const userOp = bundleData.userOp;
|
|
55
|
-
if (!userOp) {
|
|
56
|
-
throw new Error(`User operation is required when using smart sessions`);
|
|
57
|
-
}
|
|
58
|
-
// Smart sessions require a UserOp flow
|
|
59
|
-
signature = await signUserOp(config, sourceChain, targetChain, accountAddress, signers, userOp, bundleData.orderPath);
|
|
60
|
-
}
|
|
61
|
-
else {
|
|
62
|
-
signature = await signIntent(config, sourceChain, targetChain, bundleData.hash);
|
|
63
|
-
}
|
|
64
|
-
return {
|
|
65
|
-
bundleData,
|
|
66
|
-
transaction: preparedTransaction.transaction,
|
|
67
|
-
signature,
|
|
68
|
-
};
|
|
69
|
-
}
|
|
70
|
-
async function submitTransaction(config, signedTransaction) {
|
|
71
|
-
const { bundleData, transaction, signature } = signedTransaction;
|
|
72
|
-
const { sourceChain, targetChain, signers } = getTransactionParams(transaction);
|
|
73
|
-
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
74
|
-
if (withSession) {
|
|
75
|
-
if (!sourceChain) {
|
|
76
|
-
throw new Error(`Specifying source chain is required when using smart sessions`);
|
|
77
|
-
}
|
|
78
|
-
const userOp = bundleData.userOp;
|
|
79
|
-
if (!userOp) {
|
|
80
|
-
throw new Error(`User operation is required when using smart sessions`);
|
|
81
|
-
}
|
|
82
|
-
// Smart sessions require a UserOp flow
|
|
83
|
-
return await submitUserOp(config, sourceChain, targetChain, userOp, signature, bundleData.orderPath);
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
const orderPath = bundleData.orderPath;
|
|
87
|
-
if (!orderPath) {
|
|
88
|
-
throw new Error('Order path is required when using intents');
|
|
89
|
-
}
|
|
90
|
-
return await submitIntent(config, sourceChain, targetChain, orderPath, signature);
|
|
91
|
-
}
|
|
92
|
-
}
|
|
93
|
-
function getTransactionParams(transaction) {
|
|
94
|
-
const sourceChain = 'chain' in transaction ? transaction.chain : transaction.sourceChain;
|
|
95
|
-
const targetChain = 'chain' in transaction ? transaction.chain : transaction.targetChain;
|
|
96
|
-
const initialTokenRequests = transaction.tokenRequests;
|
|
97
|
-
const signers = transaction.signers;
|
|
98
|
-
// Across requires passing some value to repay the solvers
|
|
99
|
-
const tokenRequests = initialTokenRequests.length === 0
|
|
100
|
-
? [
|
|
101
|
-
{
|
|
102
|
-
address: viem_1.zeroAddress,
|
|
103
|
-
amount: 1n,
|
|
104
|
-
},
|
|
105
|
-
]
|
|
106
|
-
: initialTokenRequests;
|
|
107
|
-
return {
|
|
108
|
-
sourceChain,
|
|
109
|
-
targetChain,
|
|
110
|
-
tokenRequests,
|
|
111
|
-
signers,
|
|
112
|
-
};
|
|
113
|
-
}
|
|
114
|
-
async function prepareTransactionAsUserOp(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress, signers) {
|
|
115
|
-
if (sourceChain.id === targetChain.id) {
|
|
116
|
-
const chain = sourceChain;
|
|
117
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
118
|
-
chain,
|
|
119
|
-
transport: (0, viem_1.http)(),
|
|
120
|
-
});
|
|
121
|
-
const validatorAccount = await getValidatorAccount(config, signers, publicClient, chain);
|
|
122
|
-
if (!validatorAccount) {
|
|
123
|
-
throw new Error('No validator account found');
|
|
124
|
-
}
|
|
125
|
-
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
126
|
-
const userOp = await bundlerClient.prepareUserOperation({
|
|
127
|
-
account: validatorAccount,
|
|
128
|
-
calls,
|
|
129
|
-
});
|
|
130
|
-
return {
|
|
131
|
-
userOp,
|
|
132
|
-
hash: (0, account_abstraction_1.getUserOperationHash)({
|
|
133
|
-
userOperation: userOp,
|
|
134
|
-
chainId: chain.id,
|
|
135
|
-
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
136
|
-
entryPointVersion: '0.7',
|
|
137
|
-
}),
|
|
138
|
-
};
|
|
139
|
-
}
|
|
140
|
-
const orderPath = await getUserOpOrderPath(sourceChain, targetChain, tokenRequests, accountAddress, gasLimit, config.rhinestoneApiKey);
|
|
141
|
-
const userOp = await getUserOp(config, targetChain, signers, orderPath, calls, tokenRequests, accountAddress);
|
|
142
|
-
const hash = (0, account_abstraction_1.getUserOperationHash)({
|
|
143
|
-
userOperation: userOp,
|
|
144
|
-
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
145
|
-
entryPointVersion: '0.7',
|
|
146
|
-
chainId: targetChain.id,
|
|
147
|
-
});
|
|
148
|
-
return {
|
|
149
|
-
orderPath,
|
|
150
|
-
userOp,
|
|
151
|
-
hash,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
async function prepareTransactionAsIntent(config, sourceChain, targetChain, calls, gasLimit, tokenRequests, accountAddress) {
|
|
155
|
-
const accountAccessList = sourceChain
|
|
156
|
-
? {
|
|
157
|
-
chainIds: [sourceChain.id],
|
|
158
|
-
}
|
|
159
|
-
: undefined;
|
|
160
|
-
const metaIntent = {
|
|
161
|
-
targetChainId: targetChain.id,
|
|
162
|
-
tokenTransfers: tokenRequests.map((tokenRequest) => ({
|
|
163
|
-
tokenAddress: tokenRequest.address,
|
|
164
|
-
amount: tokenRequest.amount,
|
|
165
|
-
})),
|
|
166
|
-
targetAccount: accountAddress,
|
|
167
|
-
targetExecutions: calls.map((call) => ({
|
|
168
|
-
value: call.value ?? 0n,
|
|
169
|
-
to: call.to,
|
|
170
|
-
data: call.data ?? '0x',
|
|
171
|
-
})),
|
|
172
|
-
targetGasUnits: gasLimit,
|
|
173
|
-
accountAccessList,
|
|
174
|
-
};
|
|
175
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
|
|
176
|
-
const orderPath = await orchestrator.getOrderPath(metaIntent, accountAddress);
|
|
177
|
-
orderPath[0].orderBundle.segments[0].witness.execs = [
|
|
178
|
-
...orderPath[0].injectedExecutions,
|
|
179
|
-
...metaIntent.targetExecutions,
|
|
180
|
-
];
|
|
181
|
-
const orderBundleHash = (0, orchestrator_1.getOrderBundleHash)(orderPath[0].orderBundle);
|
|
182
|
-
return {
|
|
183
|
-
orderPath,
|
|
184
|
-
hash: orderBundleHash,
|
|
185
|
-
};
|
|
186
|
-
}
|
|
187
|
-
async function signIntent(config, sourceChain, targetChain, bundleHash, signers) {
|
|
188
|
-
const validator = getValidator(config, signers);
|
|
189
|
-
if (!validator) {
|
|
190
|
-
throw new Error('Validator not available');
|
|
191
|
-
}
|
|
192
|
-
const ownerValidator = (0, validators_1.getOwnerValidator)(config);
|
|
193
|
-
const isRoot = validator.address === ownerValidator.address;
|
|
194
|
-
const owners = getOwners(config, signers);
|
|
195
|
-
if (!owners) {
|
|
196
|
-
throw new Error('No owners found');
|
|
197
|
-
}
|
|
198
|
-
const signature = await (0, accounts_1.getPackedSignature)(config, owners, sourceChain || targetChain, {
|
|
199
|
-
address: validator.address,
|
|
200
|
-
isRoot,
|
|
201
|
-
}, bundleHash);
|
|
202
|
-
return signature;
|
|
203
|
-
}
|
|
204
|
-
async function signUserOp(config, sourceChain, targetChain, accountAddress, signers, userOp, orderPath) {
|
|
205
|
-
const validator = getValidator(config, signers);
|
|
206
|
-
if (!validator) {
|
|
207
|
-
throw new Error('Validator not available');
|
|
208
|
-
}
|
|
209
|
-
const targetPublicClient = (0, viem_1.createPublicClient)({
|
|
210
|
-
chain: targetChain,
|
|
211
|
-
transport: (0, viem_1.http)(),
|
|
212
|
-
});
|
|
213
|
-
const targetAccount = await getValidatorAccount(config, signers, targetPublicClient, targetChain);
|
|
214
|
-
if (!targetAccount) {
|
|
215
|
-
throw new Error('No account found');
|
|
216
|
-
}
|
|
217
|
-
userOp.signature = await targetAccount.signUserOperation(userOp);
|
|
218
|
-
if (!orderPath) {
|
|
219
|
-
return userOp.signature;
|
|
220
|
-
}
|
|
221
|
-
const userOpHash = (0, account_abstraction_1.getUserOperationHash)({
|
|
222
|
-
userOperation: userOp,
|
|
223
|
-
chainId: targetChain.id,
|
|
224
|
-
entryPointAddress: account_abstraction_1.entryPoint07Address,
|
|
225
|
-
entryPointVersion: '0.7',
|
|
226
|
-
});
|
|
227
|
-
orderPath[0].orderBundle.segments[0].witness.userOpHash = userOpHash;
|
|
228
|
-
const { hash, appDomainSeparator, contentsType, structHash } = await (0, smart_session_1.hashErc7739)(sourceChain, orderPath, accountAddress);
|
|
229
|
-
const owners = getOwners(config, signers);
|
|
230
|
-
if (!owners) {
|
|
231
|
-
throw new Error('No owners found');
|
|
232
|
-
}
|
|
233
|
-
const signature = await (0, accounts_1.getPackedSignature)(config, owners, targetChain, {
|
|
234
|
-
address: validator.address,
|
|
235
|
-
isRoot: false,
|
|
236
|
-
}, hash, (signature) => {
|
|
237
|
-
const sessionData = signers?.type === 'session' ? signers.session : null;
|
|
238
|
-
return sessionData
|
|
239
|
-
? (0, smart_session_1.getSessionSignature)(signature, appDomainSeparator, structHash, contentsType, sessionData)
|
|
240
|
-
: signature;
|
|
241
|
-
});
|
|
242
|
-
return signature;
|
|
243
|
-
}
|
|
244
|
-
async function submitUserOp(config, sourceChain, targetChain, userOp, signature, orderPath) {
|
|
245
|
-
if (!orderPath) {
|
|
246
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
247
|
-
chain: sourceChain,
|
|
248
|
-
transport: (0, viem_1.http)(),
|
|
249
|
-
});
|
|
250
|
-
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
251
|
-
const hash = await bundlerClient.request({
|
|
252
|
-
method: 'eth_sendUserOperation',
|
|
253
|
-
params: [
|
|
254
|
-
{
|
|
255
|
-
sender: userOp.sender,
|
|
256
|
-
nonce: (0, viem_1.toHex)(userOp.nonce),
|
|
257
|
-
factory: userOp.factory,
|
|
258
|
-
factoryData: userOp.factoryData,
|
|
259
|
-
callData: userOp.callData,
|
|
260
|
-
callGasLimit: (0, viem_1.toHex)(userOp.callGasLimit),
|
|
261
|
-
verificationGasLimit: (0, viem_1.toHex)(userOp.verificationGasLimit),
|
|
262
|
-
preVerificationGas: (0, viem_1.toHex)(userOp.preVerificationGas),
|
|
263
|
-
maxPriorityFeePerGas: (0, viem_1.toHex)(userOp.maxPriorityFeePerGas),
|
|
264
|
-
maxFeePerGas: (0, viem_1.toHex)(userOp.maxFeePerGas),
|
|
265
|
-
paymaster: userOp.paymaster,
|
|
266
|
-
paymasterVerificationGasLimit: userOp.paymasterVerificationGasLimit
|
|
267
|
-
? (0, viem_1.toHex)(userOp.paymasterVerificationGasLimit)
|
|
268
|
-
: undefined,
|
|
269
|
-
paymasterPostOpGasLimit: userOp.paymasterPostOpGasLimit
|
|
270
|
-
? (0, viem_1.toHex)(userOp.paymasterPostOpGasLimit)
|
|
271
|
-
: undefined,
|
|
272
|
-
paymasterData: userOp.paymasterData,
|
|
273
|
-
signature,
|
|
274
|
-
},
|
|
275
|
-
account_abstraction_1.entryPoint07Address,
|
|
276
|
-
],
|
|
277
|
-
});
|
|
278
|
-
return {
|
|
279
|
-
type: 'userop',
|
|
280
|
-
hash,
|
|
281
|
-
sourceChain: sourceChain.id,
|
|
282
|
-
targetChain: targetChain.id,
|
|
283
|
-
};
|
|
284
|
-
}
|
|
285
|
-
const signedOrderBundle = {
|
|
286
|
-
...orderPath[0].orderBundle,
|
|
287
|
-
originSignatures: Array(orderPath[0].orderBundle.segments.length).fill(signature),
|
|
288
|
-
targetSignature: signature,
|
|
289
|
-
};
|
|
290
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
|
|
291
|
-
const bundleResults = await orchestrator.postSignedOrderBundle([
|
|
292
|
-
{
|
|
293
|
-
signedOrderBundle,
|
|
294
|
-
userOp,
|
|
295
|
-
},
|
|
296
|
-
]);
|
|
297
|
-
return {
|
|
298
|
-
type: 'bundle',
|
|
299
|
-
id: bundleResults[0].bundleId,
|
|
300
|
-
sourceChain: sourceChain.id,
|
|
301
|
-
targetChain: targetChain.id,
|
|
302
|
-
};
|
|
303
|
-
}
|
|
304
|
-
async function submitIntent(config, sourceChain, targetChain, orderPath, signature) {
|
|
305
|
-
return submitIntentInternal(config, sourceChain, targetChain, orderPath, signature, false);
|
|
306
|
-
}
|
|
307
|
-
function getOrchestratorByChain(chainId, apiKey) {
|
|
308
|
-
const orchestratorUrl = (0, registry_1.isTestnet)(chainId)
|
|
309
|
-
? consts_1.DEV_ORCHESTRATOR_URL
|
|
310
|
-
: consts_1.PROD_ORCHESTRATOR_URL;
|
|
311
|
-
return (0, orchestrator_1.getOrchestrator)(apiKey, orchestratorUrl);
|
|
312
|
-
}
|
|
313
|
-
async function getUserOpOrderPath(sourceChain, targetChain, tokenRequests, accountAddress, gasLimit, rhinestoneApiKey) {
|
|
314
|
-
const accountAccessList = sourceChain
|
|
315
|
-
? {
|
|
316
|
-
chainIds: [sourceChain.id],
|
|
317
|
-
}
|
|
318
|
-
: undefined;
|
|
319
|
-
const metaIntent = {
|
|
320
|
-
targetChainId: targetChain.id,
|
|
321
|
-
tokenTransfers: tokenRequests.map((tokenRequest) => ({
|
|
322
|
-
tokenAddress: tokenRequest.address,
|
|
323
|
-
amount: tokenRequest.amount,
|
|
324
|
-
})),
|
|
325
|
-
targetAccount: accountAddress,
|
|
326
|
-
targetGasUnits: gasLimit,
|
|
327
|
-
userOp: (0, orchestrator_1.getEmptyUserOp)(),
|
|
328
|
-
accountAccessList,
|
|
329
|
-
};
|
|
330
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, rhinestoneApiKey);
|
|
331
|
-
const orderPath = await orchestrator.getOrderPath(metaIntent, accountAddress);
|
|
332
|
-
return orderPath;
|
|
333
|
-
}
|
|
334
|
-
async function getUserOp(config, targetChain, signers, orderPath, calls, tokenRequests, accountAddress) {
|
|
335
|
-
const targetPublicClient = (0, viem_1.createPublicClient)({
|
|
336
|
-
chain: targetChain,
|
|
337
|
-
transport: (0, viem_1.http)(),
|
|
338
|
-
});
|
|
339
|
-
const targetAccount = await getValidatorAccount(config, signers, targetPublicClient, targetChain);
|
|
340
|
-
if (!targetAccount) {
|
|
341
|
-
throw new Error('No account found');
|
|
342
|
-
}
|
|
343
|
-
const targetBundlerClient = (0, utils_1.getBundlerClient)(config, targetPublicClient);
|
|
344
|
-
return await targetBundlerClient.prepareUserOperation({
|
|
345
|
-
account: targetAccount,
|
|
346
|
-
calls: [...orderPath[0].injectedExecutions, ...calls],
|
|
347
|
-
stateOverride: [
|
|
348
|
-
...tokenRequests.map((request) => {
|
|
349
|
-
const rootBalanceSlot = (0, registry_1.getTokenRootBalanceSlot)(targetChain, request.address);
|
|
350
|
-
const balanceSlot = rootBalanceSlot
|
|
351
|
-
? (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)([{ type: 'address' }, { type: 'uint256' }], [accountAddress, rootBalanceSlot]))
|
|
352
|
-
: viem_1.zeroHash;
|
|
353
|
-
return {
|
|
354
|
-
address: request.address,
|
|
355
|
-
stateDiff: [
|
|
356
|
-
{
|
|
357
|
-
slot: balanceSlot,
|
|
358
|
-
value: (0, viem_1.pad)((0, viem_1.toHex)(request.amount)),
|
|
359
|
-
},
|
|
360
|
-
],
|
|
361
|
-
};
|
|
362
|
-
}),
|
|
363
|
-
],
|
|
364
|
-
});
|
|
365
|
-
}
|
|
366
|
-
async function submitIntentInternal(config, sourceChain, targetChain, orderPath, signature, deploy) {
|
|
367
|
-
const signedOrderBundle = {
|
|
368
|
-
...orderPath[0].orderBundle,
|
|
369
|
-
originSignatures: Array(orderPath[0].orderBundle.segments.length).fill(signature),
|
|
370
|
-
targetSignature: signature,
|
|
371
|
-
};
|
|
372
|
-
if (deploy) {
|
|
373
|
-
await (0, accounts_1.deployTarget)(targetChain, config, false);
|
|
374
|
-
}
|
|
375
|
-
const initCode = (0, accounts_1.getBundleInitCode)(config);
|
|
376
|
-
const orchestrator = getOrchestratorByChain(targetChain.id, config.rhinestoneApiKey);
|
|
377
|
-
const bundleResults = await orchestrator.postSignedOrderBundle([
|
|
378
|
-
{
|
|
379
|
-
signedOrderBundle,
|
|
380
|
-
initCode,
|
|
381
|
-
},
|
|
382
|
-
]);
|
|
383
|
-
return {
|
|
384
|
-
type: 'bundle',
|
|
385
|
-
id: bundleResults[0].bundleId,
|
|
386
|
-
sourceChain: sourceChain?.id,
|
|
387
|
-
targetChain: targetChain.id,
|
|
388
|
-
};
|
|
389
|
-
}
|
|
390
|
-
async function getValidatorAccount(config, signers, publicClient, chain) {
|
|
391
|
-
if (!signers) {
|
|
392
|
-
return undefined;
|
|
393
|
-
}
|
|
394
|
-
const withSession = signers.type === 'session' ? signers : null;
|
|
395
|
-
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
396
|
-
return withSession
|
|
397
|
-
? await (0, accounts_1.getSmartSessionSmartAccount)(config, publicClient, chain, withSession.session, withSession.enableData || null)
|
|
398
|
-
: withGuardians
|
|
399
|
-
? await (0, accounts_1.getGuardianSmartAccount)(config, publicClient, chain, {
|
|
400
|
-
type: 'ecdsa',
|
|
401
|
-
accounts: withGuardians.guardians,
|
|
402
|
-
})
|
|
403
|
-
: null;
|
|
404
|
-
}
|
|
405
|
-
function getValidator(config, signers) {
|
|
406
|
-
if (!signers) {
|
|
407
|
-
return (0, validators_1.getOwnerValidator)(config);
|
|
408
|
-
}
|
|
409
|
-
// Owners
|
|
410
|
-
const withOwner = signers.type === 'owner' ? signers : null;
|
|
411
|
-
if (withOwner) {
|
|
412
|
-
// ECDSA
|
|
413
|
-
if (withOwner.kind === 'ecdsa') {
|
|
414
|
-
return (0, core_1.getOwnableValidator)({
|
|
415
|
-
threshold: 1,
|
|
416
|
-
owners: withOwner.accounts.map((account) => account.address),
|
|
417
|
-
});
|
|
418
|
-
}
|
|
419
|
-
// Passkeys (WebAuthn)
|
|
420
|
-
if (withOwner.kind === 'passkey') {
|
|
421
|
-
const passkeyAccount = withOwner.account;
|
|
422
|
-
return (0, core_1.getWebAuthnValidator)({
|
|
423
|
-
pubKey: passkeyAccount.publicKey,
|
|
424
|
-
authenticatorId: passkeyAccount.id,
|
|
425
|
-
});
|
|
426
|
-
}
|
|
427
|
-
}
|
|
428
|
-
// Smart sessions
|
|
429
|
-
const withSession = signers.type === 'session' ? signers.session : null;
|
|
430
|
-
if (withSession) {
|
|
431
|
-
return (0, validators_1.getSmartSessionValidator)(config);
|
|
432
|
-
}
|
|
433
|
-
// Guardians (social recovery)
|
|
434
|
-
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
435
|
-
if (withGuardians) {
|
|
436
|
-
return (0, core_1.getSocialRecoveryValidator)(withGuardians.guardians);
|
|
437
|
-
}
|
|
438
|
-
// Fallback
|
|
439
|
-
return undefined;
|
|
440
|
-
}
|
|
441
|
-
function getOwners(config, signers) {
|
|
442
|
-
if (!signers) {
|
|
443
|
-
return config.owners;
|
|
444
|
-
}
|
|
445
|
-
// Owners
|
|
446
|
-
const withOwner = signers.type === 'owner' ? signers : null;
|
|
447
|
-
if (withOwner) {
|
|
448
|
-
// ECDSA
|
|
449
|
-
if (withOwner.kind === 'ecdsa') {
|
|
450
|
-
return {
|
|
451
|
-
type: 'ecdsa',
|
|
452
|
-
accounts: withOwner.accounts,
|
|
453
|
-
};
|
|
454
|
-
}
|
|
455
|
-
// Passkeys (WebAuthn)
|
|
456
|
-
if (withOwner.kind === 'passkey') {
|
|
457
|
-
// Pull credentialIds from config.owners, which should be a WebauthnValidatorConfig
|
|
458
|
-
const credentialIds = config.owners.type === 'passkey'
|
|
459
|
-
? config.owners.credentialIds
|
|
460
|
-
: [];
|
|
461
|
-
return {
|
|
462
|
-
type: 'passkey',
|
|
463
|
-
account: withOwner.account,
|
|
464
|
-
credentialIds: credentialIds,
|
|
465
|
-
};
|
|
466
|
-
}
|
|
467
|
-
}
|
|
468
|
-
// Smart sessions
|
|
469
|
-
const withSession = signers.type === 'session' ? signers.session : null;
|
|
470
|
-
if (withSession) {
|
|
471
|
-
return withSession.owners;
|
|
472
|
-
}
|
|
473
|
-
// Guardians (social recovery)
|
|
474
|
-
const withGuardians = signers.type === 'guardians' ? signers : null;
|
|
475
|
-
if (withGuardians) {
|
|
476
|
-
return {
|
|
477
|
-
type: 'ecdsa',
|
|
478
|
-
accounts: withGuardians.guardians,
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
return undefined;
|
|
482
|
-
}
|
package/dist/index.d.ts
DELETED
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import type { Address, Chain, Hex } from 'viem';
|
|
2
|
-
import { UserOperationReceipt } from 'viem/account-abstraction';
|
|
3
|
-
import { addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, encodeSmartSessionSignature, recover, removeOwner, setUpRecovery, trustAttester } from './actions';
|
|
4
|
-
import type { TransactionResult } from './execution';
|
|
5
|
-
import { SessionDetails } from './execution/smart-session';
|
|
6
|
-
import { BundleData, PreparedTransactionData, SignedTransactionData } from './execution/utils';
|
|
7
|
-
import type { BundleResult, BundleStatus, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact, UserTokenBalance } from './orchestrator';
|
|
8
|
-
import type { Call, Execution, RhinestoneAccountConfig, Session, Transaction } from './types';
|
|
9
|
-
interface RhinestoneAccount {
|
|
10
|
-
config: RhinestoneAccountConfig;
|
|
11
|
-
deploy: (chain: Chain, session?: Session) => Promise<void>;
|
|
12
|
-
prepareTransaction: (transaction: Transaction) => Promise<PreparedTransactionData>;
|
|
13
|
-
signTransaction: (preparedTransaction: PreparedTransactionData) => Promise<SignedTransactionData>;
|
|
14
|
-
submitTransaction: (signedTransaction: SignedTransactionData) => Promise<TransactionResult>;
|
|
15
|
-
sendTransaction: (transaction: Transaction) => Promise<TransactionResult>;
|
|
16
|
-
waitForExecution: (result: TransactionResult, acceptsPreconfirmations?: boolean) => Promise<BundleResult | UserOperationReceipt>;
|
|
17
|
-
getAddress: () => Address;
|
|
18
|
-
getPortfolio: (onTestnets?: boolean) => Promise<UserTokenBalance[]>;
|
|
19
|
-
getMaxSpendableAmount: (chain: Chain, tokenAddress: Address, gasUnits: bigint) => Promise<bigint>;
|
|
20
|
-
deploySource: (chain: Chain) => Promise<void>;
|
|
21
|
-
getSessionDetails: (sessions: Session[], sessionIndex: number, signature?: Hex) => Promise<SessionDetails>;
|
|
22
|
-
areAttestersTrusted: (chain: Chain) => Promise<boolean>;
|
|
23
|
-
getOwners: (chain: Chain) => Promise<{
|
|
24
|
-
accounts: Address[];
|
|
25
|
-
threshold: number;
|
|
26
|
-
} | null>;
|
|
27
|
-
getValidators: (chain: Chain) => Promise<Address[]>;
|
|
28
|
-
}
|
|
29
|
-
/**
|
|
30
|
-
* Initialize a Rhinestone account
|
|
31
|
-
* Note: accounts are deployed onchain only when the first transaction is sent.
|
|
32
|
-
* @param config Account config (e.g. implementation vendor, owner signers, smart sessions)
|
|
33
|
-
* @returns account
|
|
34
|
-
*/
|
|
35
|
-
declare function createRhinestoneAccount(config: RhinestoneAccountConfig): Promise<RhinestoneAccount>;
|
|
36
|
-
export { createRhinestoneAccount, addOwner, changeThreshold, disableEcdsa, disablePasskeys, enableEcdsa, enablePasskeys, recover, removeOwner, setUpRecovery, encodeSmartSessionSignature, trustAttester, };
|
|
37
|
-
export type { RhinestoneAccount, BundleStatus, Session, Call, Execution, MetaIntent, MultiChainCompact, PostOrderBundleResult, SignedMultiChainCompact, BundleData, PreparedTransactionData, SignedTransactionData, TransactionResult, };
|
|
38
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map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O,EACP,WAAW,EACX,aAAa,EACb,2BAA2B,EAC3B,aAAa,GACd,CAAA;AACD,YAAY,EACV,iBAAiB,EACjB,YAAY,EACZ,OAAO,EACP,IAAI,EACJ,SAAS,EACT,UAAU,EACV,iBAAiB,EACjB,qBAAqB,EACrB,uBAAuB,EACvB,UAAU,EACV,uBAAuB,EACvB,qBAAqB,EACrB,iBAAiB,GAClB,CAAA"}
|
package/dist/index.js
DELETED
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.trustAttester = exports.encodeSmartSessionSignature = exports.setUpRecovery = exports.removeOwner = exports.recover = exports.enablePasskeys = exports.enableEcdsa = exports.disablePasskeys = exports.disableEcdsa = exports.changeThreshold = exports.addOwner = void 0;
|
|
4
|
-
exports.createRhinestoneAccount = createRhinestoneAccount;
|
|
5
|
-
const accounts_1 = require("./accounts");
|
|
6
|
-
const actions_1 = require("./actions");
|
|
7
|
-
Object.defineProperty(exports, "addOwner", { enumerable: true, get: function () { return actions_1.addOwner; } });
|
|
8
|
-
Object.defineProperty(exports, "changeThreshold", { enumerable: true, get: function () { return actions_1.changeThreshold; } });
|
|
9
|
-
Object.defineProperty(exports, "disableEcdsa", { enumerable: true, get: function () { return actions_1.disableEcdsa; } });
|
|
10
|
-
Object.defineProperty(exports, "disablePasskeys", { enumerable: true, get: function () { return actions_1.disablePasskeys; } });
|
|
11
|
-
Object.defineProperty(exports, "enableEcdsa", { enumerable: true, get: function () { return actions_1.enableEcdsa; } });
|
|
12
|
-
Object.defineProperty(exports, "enablePasskeys", { enumerable: true, get: function () { return actions_1.enablePasskeys; } });
|
|
13
|
-
Object.defineProperty(exports, "encodeSmartSessionSignature", { enumerable: true, get: function () { return actions_1.encodeSmartSessionSignature; } });
|
|
14
|
-
Object.defineProperty(exports, "recover", { enumerable: true, get: function () { return actions_1.recover; } });
|
|
15
|
-
Object.defineProperty(exports, "removeOwner", { enumerable: true, get: function () { return actions_1.removeOwner; } });
|
|
16
|
-
Object.defineProperty(exports, "setUpRecovery", { enumerable: true, get: function () { return actions_1.setUpRecovery; } });
|
|
17
|
-
Object.defineProperty(exports, "trustAttester", { enumerable: true, get: function () { return actions_1.trustAttester; } });
|
|
18
|
-
const execution_1 = require("./execution");
|
|
19
|
-
const smart_session_1 = require("./execution/smart-session");
|
|
20
|
-
const utils_1 = require("./execution/utils");
|
|
21
|
-
const modules_1 = require("./modules");
|
|
22
|
-
/**
|
|
23
|
-
* Initialize a Rhinestone account
|
|
24
|
-
* Note: accounts are deployed onchain only when the first transaction is sent.
|
|
25
|
-
* @param config Account config (e.g. implementation vendor, owner signers, smart sessions)
|
|
26
|
-
* @returns account
|
|
27
|
-
*/
|
|
28
|
-
async function createRhinestoneAccount(config) {
|
|
29
|
-
function deploy(chain, session) {
|
|
30
|
-
return (0, accounts_1.deploy)(config, chain, session);
|
|
31
|
-
}
|
|
32
|
-
function prepareTransaction(transaction) {
|
|
33
|
-
return (0, utils_1.prepareTransaction)(config, transaction);
|
|
34
|
-
}
|
|
35
|
-
function signTransaction(preparedTransaction) {
|
|
36
|
-
return (0, utils_1.signTransaction)(config, preparedTransaction);
|
|
37
|
-
}
|
|
38
|
-
function submitTransaction(signedTransaction) {
|
|
39
|
-
return (0, utils_1.submitTransaction)(config, signedTransaction);
|
|
40
|
-
}
|
|
41
|
-
/**
|
|
42
|
-
* Sign and send a transaction
|
|
43
|
-
* @param transaction Transaction to send
|
|
44
|
-
* @returns transaction result object (a bundle ID or a UserOp hash)
|
|
45
|
-
*/
|
|
46
|
-
function sendTransaction(transaction) {
|
|
47
|
-
return (0, execution_1.sendTransaction)(config, transaction);
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Wait for the transaction execution onchain
|
|
51
|
-
* @param result transaction result object
|
|
52
|
-
* @param acceptsPreconfirmations whether to accept preconfirmations from relayers before the transaction lands onchain (enabled by default)
|
|
53
|
-
* @returns bundle result or a UserOp receipt
|
|
54
|
-
*/
|
|
55
|
-
function waitForExecution(result, acceptsPreconfirmations = true) {
|
|
56
|
-
return (0, execution_1.waitForExecution)(config, result, acceptsPreconfirmations);
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Get account address
|
|
60
|
-
* @returns Address of the smart account
|
|
61
|
-
*/
|
|
62
|
-
function getAddress() {
|
|
63
|
-
return (0, accounts_1.getAddress)(config);
|
|
64
|
-
}
|
|
65
|
-
/**
|
|
66
|
-
* Get account portfolio
|
|
67
|
-
* @param onTestnets Whether to query the testnet balances (default is `false`)
|
|
68
|
-
* @returns Account balances
|
|
69
|
-
*/
|
|
70
|
-
function getPortfolio(onTestnets = false) {
|
|
71
|
-
return (0, execution_1.getPortfolio)(config, onTestnets);
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Get the maximum spendable token amount on the target chain
|
|
75
|
-
* @param chain Target chain
|
|
76
|
-
* @param tokenAddress Token address (on the target chain)
|
|
77
|
-
* @param gasUnits Gas cost estimate for the transaction execution
|
|
78
|
-
* @returns Maximum spendable amount in absolute units
|
|
79
|
-
*/
|
|
80
|
-
function getMaxSpendableAmount(chain, tokenAddress, gasUnits) {
|
|
81
|
-
return (0, execution_1.getMaxSpendableAmount)(config, chain, tokenAddress, gasUnits);
|
|
82
|
-
}
|
|
83
|
-
function deploySource(chain) {
|
|
84
|
-
return (0, accounts_1.deploySource)(chain, config);
|
|
85
|
-
}
|
|
86
|
-
function getSessionDetails(sessions, sessionIndex, signature) {
|
|
87
|
-
return (0, smart_session_1.getSessionDetails)(config, sessions, sessionIndex, signature);
|
|
88
|
-
}
|
|
89
|
-
function areAttestersTrusted(chain) {
|
|
90
|
-
const account = getAddress();
|
|
91
|
-
return (0, modules_1.areAttestersTrusted)(account, chain);
|
|
92
|
-
}
|
|
93
|
-
function getOwners(chain) {
|
|
94
|
-
const account = getAddress();
|
|
95
|
-
return (0, modules_1.getOwners)(account, chain);
|
|
96
|
-
}
|
|
97
|
-
function getValidators(chain) {
|
|
98
|
-
const accountType = config.account?.type || 'nexus';
|
|
99
|
-
const account = getAddress();
|
|
100
|
-
return (0, modules_1.getValidators)(accountType, account, chain);
|
|
101
|
-
}
|
|
102
|
-
return {
|
|
103
|
-
config,
|
|
104
|
-
deploy,
|
|
105
|
-
prepareTransaction,
|
|
106
|
-
signTransaction,
|
|
107
|
-
submitTransaction,
|
|
108
|
-
sendTransaction,
|
|
109
|
-
waitForExecution,
|
|
110
|
-
getAddress,
|
|
111
|
-
getPortfolio,
|
|
112
|
-
getMaxSpendableAmount,
|
|
113
|
-
deploySource,
|
|
114
|
-
getSessionDetails,
|
|
115
|
-
areAttestersTrusted,
|
|
116
|
-
getOwners,
|
|
117
|
-
getValidators,
|
|
118
|
-
};
|
|
119
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"smart-sessions.d.ts","sourceRoot":"","sources":["../../../modules/abi/smart-sessions.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,iBAAiB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA8Hb,CAAA;AAEV,OAAO,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../modules/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAExC,KAAK,UAAU,GACX,OAAO,wBAAwB,GAC/B,OAAO,uBAAuB,GAC9B,OAAO,uBAAuB,GAC9B,OAAO,mBAAmB,CAAA;AAE9B,UAAU,MAAM;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,QAAQ,EAAE,GAAG,CAAA;IACb,UAAU,EAAE,GAAG,CAAA;IACf,iBAAiB,EAAE,GAAG,CAAA;IACtB,IAAI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zB,CAAC,EAAE,MAAM,CAAA;IACT,CAAC,EAAE,MAAM,CAAA;CACV;AAED,UAAU,WAAW;IACnB,UAAU,EAAE,MAAM,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,SAAS,EAAE,MAAM,EAAE,CAAA;IACnB,KAAK,EAAE,MAAM,EAAE,CAAA;IACf,QAAQ,EAAE,OAAO,CAAA;IACjB,SAAS,EAAE,OAAO,EAAE,CAAA;IACpB,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,iBAAS,QAAQ,CAAC,MAAM,EAAE,uBAAuB,GAAG,WAAW,CA0F9D;AAED,iBAAS,6BAA6B,CAAC,MAAM,EAAE,0BAA0B,GAAG,GAAG,CA6C9E;AAED,iBAAS,yBAAyB,CAAC,KAAK,EAAE,KAAK,WAa9C;AAaD,iBAAS,YAAY,IAAI;IACvB,IAAI,EAAE,OAAO,EAAE,CAAA;IACf,SAAS,EAAE,MAAM,CAAA;CAClB,CAKA;AAED,OAAO,EACL,YAAY,EACZ,QAAQ,EACR,oBAAoB,EACpB,mBAAmB,EACnB,iBAAiB,EACjB,6BAA6B,EAC7B,YAAY,EACZ,mBAAmB,EACnB,SAAS,EACT,aAAa,EACb,yBAAyB,GAC1B,CAAA"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { Address } from 'viem';
|
|
2
|
-
declare const OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS: Address;
|
|
3
|
-
declare const RHINESTONE_MODULE_REGISTRY_ADDRESS: Address;
|
|
4
|
-
declare const RHINESTONE_ATTESTER_ADDRESS: Address;
|
|
5
|
-
declare const HOOK_ADDRESS: Address;
|
|
6
|
-
declare const TARGET_MODULE_ADDRESS: Address;
|
|
7
|
-
declare const SAME_CHAIN_MODULE_ADDRESS: Address;
|
|
8
|
-
export { OMNI_ACCOUNT_MOCK_ATTESTER_ADDRESS, RHINESTONE_MODULE_REGISTRY_ADDRESS, RHINESTONE_ATTESTER_ADDRESS, HOOK_ADDRESS, TARGET_MODULE_ADDRESS, SAME_CHAIN_MODULE_ADDRESS, };
|
|
9
|
-
//# sourceMappingURL=omni-account.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"omni-account.d.ts","sourceRoot":"","sources":["../../modules/omni-account.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,MAAM,CAAA;AAEnC,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAE9C,QAAA,MAAM,kCAAkC,EAAE,OACI,CAAA;AAC9C,QAAA,MAAM,2BAA2B,EAAE,OACW,CAAA;AAE9C,QAAA,MAAM,YAAY,EAAE,OAAsD,CAAA;AAC1E,QAAA,MAAM,qBAAqB,EAAE,OACiB,CAAA;AAC9C,QAAA,MAAM,yBAAyB,EAAE,OACa,CAAA;AAE9C,OAAO,EACL,kCAAkC,EAClC,kCAAkC,EAClC,2BAA2B,EAC3B,YAAY,EACZ,qBAAqB,EACrB,yBAAyB,GAC1B,CAAA"}
|