@rhinestone/sdk 1.0.0-alpha.9 → 1.0.0-beta.38
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/dist/src/accounts/error.d.ts +38 -3
- package/dist/src/accounts/error.d.ts.map +1 -1
- package/dist/src/accounts/error.js +55 -7
- package/dist/src/accounts/index.d.ts +30 -15
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +284 -140
- package/dist/src/accounts/index.test.js +3 -5
- package/dist/src/accounts/json-rpc/index.d.ts +5 -0
- package/dist/src/accounts/json-rpc/index.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.js +16 -0
- package/dist/src/accounts/json-rpc/index.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/index.test.js +16 -0
- package/dist/src/accounts/json-rpc/providers.d.ts +4 -0
- package/dist/src/accounts/json-rpc/providers.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.js +14 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts +2 -0
- package/dist/src/accounts/json-rpc/providers.test.d.ts.map +1 -0
- package/dist/src/accounts/json-rpc/providers.test.js +15 -0
- package/dist/src/accounts/kernel.d.ts +4 -3
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +32 -6
- package/dist/src/accounts/kernel.test.js +41 -19
- package/dist/src/accounts/nexus.d.ts +11 -4
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +182 -25
- package/dist/src/accounts/nexus.test.js +44 -18
- package/dist/src/accounts/safe.d.ts +2 -2
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +88 -58
- package/dist/src/accounts/safe.test.js +40 -14
- package/dist/src/accounts/signing/common.d.ts +27 -0
- package/dist/src/accounts/signing/common.d.ts.map +1 -0
- package/dist/src/accounts/signing/common.js +145 -0
- package/dist/src/accounts/signing/message.d.ts +5 -0
- package/dist/src/accounts/signing/message.d.ts.map +1 -0
- package/dist/src/accounts/signing/message.js +47 -0
- package/dist/src/accounts/signing/passkeys.d.ts +36 -0
- package/dist/src/accounts/signing/passkeys.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.js +125 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts +2 -0
- package/dist/src/accounts/signing/passkeys.test.d.ts.map +1 -0
- package/dist/src/accounts/signing/passkeys.test.js +88 -0
- package/dist/src/accounts/signing/typedData.d.ts +5 -0
- package/dist/src/accounts/signing/typedData.d.ts.map +1 -0
- package/dist/src/accounts/signing/typedData.js +35 -0
- package/dist/src/accounts/startale.d.ts +2 -2
- package/dist/src/accounts/startale.d.ts.map +1 -1
- package/dist/src/accounts/startale.js +3 -3
- package/dist/src/accounts/startale.test.js +9 -14
- package/dist/src/accounts/utils.d.ts +4 -4
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +3 -40
- package/dist/src/accounts/walletClient.d.ts +7 -0
- package/dist/src/accounts/walletClient.d.ts.map +1 -0
- package/dist/src/accounts/walletClient.js +38 -0
- package/dist/src/actions/compact.d.ts +13 -0
- package/dist/src/actions/compact.d.ts.map +1 -0
- package/dist/src/actions/compact.js +210 -0
- package/dist/src/actions/ecdsa.d.ts +35 -0
- package/dist/src/actions/ecdsa.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.js +114 -0
- package/dist/src/actions/ecdsa.test.d.ts +2 -0
- package/dist/src/actions/ecdsa.test.d.ts.map +1 -0
- package/dist/src/actions/ecdsa.test.js +99 -0
- package/dist/src/actions/index.d.ts +23 -38
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +29 -294
- package/dist/src/actions/mfa.d.ts +37 -0
- package/dist/src/actions/mfa.d.ts.map +1 -0
- package/dist/src/actions/mfa.js +133 -0
- package/dist/src/actions/passkeys.d.ts +37 -0
- package/dist/src/actions/passkeys.d.ts.map +1 -0
- package/dist/src/actions/passkeys.js +129 -0
- package/dist/src/actions/passkeys.test.d.ts +2 -0
- package/dist/src/actions/passkeys.test.d.ts.map +1 -0
- package/dist/src/actions/passkeys.test.js +54 -0
- package/dist/src/actions/recovery.d.ts +33 -0
- package/dist/src/actions/recovery.d.ts.map +1 -0
- package/dist/src/actions/recovery.js +193 -0
- package/dist/src/actions/recovery.test.d.ts +2 -0
- package/dist/src/actions/recovery.test.d.ts.map +1 -0
- package/dist/src/actions/recovery.test.js +168 -0
- package/dist/src/actions/smart-session.d.ts +6 -0
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/actions/smart-session.js +6 -0
- package/dist/src/errors/index.d.ts +5 -0
- package/dist/src/errors/index.d.ts.map +1 -0
- package/dist/src/errors/index.js +35 -0
- package/dist/src/execution/compact.d.ts +150 -7
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +112 -95
- package/dist/src/execution/error.d.ts +2 -9
- package/dist/src/execution/error.d.ts.map +1 -1
- package/dist/src/execution/error.js +4 -13
- package/dist/src/execution/index.d.ts +34 -22
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +62 -42
- package/dist/src/execution/permit2.d.ts +148 -0
- package/dist/src/execution/permit2.d.ts.map +1 -0
- package/dist/src/execution/permit2.js +282 -0
- package/dist/src/execution/smart-session.d.ts +3 -3
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/types.d.ts +35 -0
- package/dist/src/execution/types.d.ts.map +1 -0
- package/dist/src/execution/types.js +2 -0
- package/dist/src/execution/utils.d.ts +36 -27
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +357 -103
- package/dist/src/index.d.ts +41 -22
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +199 -65
- package/dist/src/modules/common.d.ts +10 -4
- package/dist/src/modules/common.d.ts.map +1 -1
- package/dist/src/modules/common.js +22 -1
- package/dist/src/modules/index.d.ts +4 -18
- package/dist/src/modules/index.d.ts.map +1 -1
- package/dist/src/modules/index.js +15 -63
- package/dist/src/modules/index.test.js +9 -26
- package/dist/src/modules/omni-account.d.ts +2 -1
- package/dist/src/modules/omni-account.d.ts.map +1 -1
- package/dist/src/modules/omni-account.js +3 -1
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +4 -0
- package/dist/src/modules/validators/core.d.ts +5 -3
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/core.js +64 -41
- package/dist/src/modules/validators/core.test.js +7 -7
- package/dist/src/modules/validators/smart-sessions.js +3 -3
- package/dist/src/modules/validators/smart-sessions.test.js +4 -7
- package/dist/src/orchestrator/client.d.ts +4 -4
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +30 -15
- package/dist/src/orchestrator/index.d.ts +2 -3
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -3
- package/dist/src/orchestrator/registry.d.ts +1 -23
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +37 -33
- package/dist/src/orchestrator/registry.test.js +7 -7
- package/dist/src/orchestrator/types.d.ts +97 -29
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts +1 -3
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.js +0 -102
- package/dist/src/types.d.ts +74 -10
- package/dist/src/types.d.ts.map +1 -1
- package/package.json +72 -1
- package/dist/src/actions/index.test.d.ts.map +0 -1
- package/dist/src/actions/index.test.js +0 -302
- package/dist/src/orchestrator/registry.json +0 -365
- /package/dist/src/{actions → accounts/json-rpc}/index.test.d.ts +0 -0
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.getTypedData = getTypedData;
|
|
4
|
+
exports.checkERC20Allowance = checkERC20Allowance;
|
|
5
|
+
exports.checkERC20AllowanceDirect = checkERC20AllowanceDirect;
|
|
6
|
+
exports.getPermit2Address = getPermit2Address;
|
|
7
|
+
exports.signPermit2Batch = signPermit2Batch;
|
|
8
|
+
exports.signPermit2Sequential = signPermit2Sequential;
|
|
9
|
+
const viem_1 = require("viem");
|
|
10
|
+
const utils_1 = require("../accounts/utils");
|
|
11
|
+
const PERMIT2_ADDRESS = '0x000000000022D473030F116dDEE9F6B43aC78BA3';
|
|
12
|
+
function toToken(id) {
|
|
13
|
+
return `0x${(id & ((1n << 160n) - 1n)).toString(16).padStart(40, '0')}`;
|
|
14
|
+
}
|
|
15
|
+
function getTypedData(intentOp) {
|
|
16
|
+
const element = intentOp.elements[0];
|
|
17
|
+
const tokens = element.idsAndAmounts.map(([id, amount]) => [
|
|
18
|
+
BigInt(id),
|
|
19
|
+
BigInt(amount),
|
|
20
|
+
]);
|
|
21
|
+
const tokenPermissions = tokens.reduce((permissions, [id, amountIn]) => {
|
|
22
|
+
const token = toToken(BigInt(id));
|
|
23
|
+
const amount = BigInt(amountIn);
|
|
24
|
+
const permission = { token, amount };
|
|
25
|
+
permissions.push(permission);
|
|
26
|
+
return permissions;
|
|
27
|
+
}, []);
|
|
28
|
+
const spender = element.arbiter;
|
|
29
|
+
const mandate = element.mandate;
|
|
30
|
+
const typedData = {
|
|
31
|
+
domain: {
|
|
32
|
+
name: 'Permit2',
|
|
33
|
+
chainId: Number(intentOp.elements[0].chainId),
|
|
34
|
+
verifyingContract: PERMIT2_ADDRESS,
|
|
35
|
+
},
|
|
36
|
+
types: {
|
|
37
|
+
TokenPermissions: [
|
|
38
|
+
{ name: 'token', type: 'address' },
|
|
39
|
+
{ name: 'amount', type: 'uint256' },
|
|
40
|
+
],
|
|
41
|
+
Token: [
|
|
42
|
+
{ name: 'token', type: 'address' },
|
|
43
|
+
{ name: 'amount', type: 'uint256' },
|
|
44
|
+
],
|
|
45
|
+
Target: [
|
|
46
|
+
{ name: 'recipient', type: 'address' },
|
|
47
|
+
{ name: 'tokenOut', type: 'Token[]' },
|
|
48
|
+
{ name: 'targetChain', type: 'uint256' },
|
|
49
|
+
{ name: 'fillExpiry', type: 'uint256' },
|
|
50
|
+
],
|
|
51
|
+
Op: [
|
|
52
|
+
{ name: 'to', type: 'address' },
|
|
53
|
+
{ name: 'value', type: 'uint256' },
|
|
54
|
+
{ name: 'data', type: 'bytes' },
|
|
55
|
+
],
|
|
56
|
+
Mandate: [
|
|
57
|
+
{ name: 'target', type: 'Target' },
|
|
58
|
+
{ name: 'v', type: 'uint8' },
|
|
59
|
+
{ name: 'minGas', type: 'uint128' },
|
|
60
|
+
{ name: 'originOps', type: 'Op[]' },
|
|
61
|
+
{ name: 'destOps', type: 'Op[]' },
|
|
62
|
+
{ name: 'q', type: 'bytes32' },
|
|
63
|
+
],
|
|
64
|
+
PermitBatchWitnessTransferFrom: [
|
|
65
|
+
{ name: 'permitted', type: 'TokenPermissions[]' },
|
|
66
|
+
{ name: 'spender', type: 'address' },
|
|
67
|
+
{ name: 'nonce', type: 'uint256' },
|
|
68
|
+
{ name: 'deadline', type: 'uint256' },
|
|
69
|
+
{ name: 'mandate', type: 'Mandate' },
|
|
70
|
+
],
|
|
71
|
+
},
|
|
72
|
+
primaryType: 'PermitBatchWitnessTransferFrom',
|
|
73
|
+
message: {
|
|
74
|
+
permitted: tokenPermissions,
|
|
75
|
+
spender: spender,
|
|
76
|
+
nonce: BigInt(intentOp.nonce),
|
|
77
|
+
deadline: BigInt(intentOp.expires),
|
|
78
|
+
mandate: {
|
|
79
|
+
target: {
|
|
80
|
+
recipient: mandate.recipient,
|
|
81
|
+
tokenOut: mandate.tokenOut.map((token) => ({
|
|
82
|
+
token: toToken(BigInt(token[0])),
|
|
83
|
+
amount: BigInt(token[1]),
|
|
84
|
+
})),
|
|
85
|
+
targetChain: BigInt(mandate.destinationChainId),
|
|
86
|
+
fillExpiry: BigInt(mandate.fillDeadline),
|
|
87
|
+
},
|
|
88
|
+
v: mandate.v || 0,
|
|
89
|
+
minGas: BigInt(mandate.minGas || '0'),
|
|
90
|
+
originOps: mandate.preClaimOps.map((op) => ({
|
|
91
|
+
to: op.to,
|
|
92
|
+
value: BigInt(op.value),
|
|
93
|
+
data: op.data,
|
|
94
|
+
})),
|
|
95
|
+
destOps: mandate.destinationOps.map((op) => ({
|
|
96
|
+
to: op.to,
|
|
97
|
+
value: BigInt(op.value),
|
|
98
|
+
data: op.data,
|
|
99
|
+
})),
|
|
100
|
+
q: (0, viem_1.keccak256)(mandate.qualifier.encodedVal),
|
|
101
|
+
},
|
|
102
|
+
},
|
|
103
|
+
};
|
|
104
|
+
return typedData;
|
|
105
|
+
}
|
|
106
|
+
async function checkERC20AllowanceDirect(owner, spender, tokenAddress, publicClient) {
|
|
107
|
+
try {
|
|
108
|
+
const allowance = await publicClient.readContract({
|
|
109
|
+
address: tokenAddress,
|
|
110
|
+
abi: [
|
|
111
|
+
{
|
|
112
|
+
name: 'allowance',
|
|
113
|
+
type: 'function',
|
|
114
|
+
stateMutability: 'view',
|
|
115
|
+
inputs: [
|
|
116
|
+
{ name: 'owner', type: 'address' },
|
|
117
|
+
{ name: 'spender', type: 'address' },
|
|
118
|
+
],
|
|
119
|
+
outputs: [{ name: '', type: 'uint256' }],
|
|
120
|
+
},
|
|
121
|
+
],
|
|
122
|
+
functionName: 'allowance',
|
|
123
|
+
args: [owner, spender],
|
|
124
|
+
});
|
|
125
|
+
return BigInt(allowance.toString());
|
|
126
|
+
}
|
|
127
|
+
catch (error) {
|
|
128
|
+
console.error('Error checking ERC20 allowance:', error);
|
|
129
|
+
throw new Error('Failed to check ERC20 allowance');
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
async function checkERC20Allowance(tokenAddress, chain, config) {
|
|
133
|
+
try {
|
|
134
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
135
|
+
chain,
|
|
136
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
137
|
+
});
|
|
138
|
+
// Get the account owner from the config
|
|
139
|
+
const owner = config.eoa?.address;
|
|
140
|
+
if (!owner) {
|
|
141
|
+
throw new Error('No EOA address found in account config');
|
|
142
|
+
}
|
|
143
|
+
return await checkERC20AllowanceDirect(owner, PERMIT2_ADDRESS, tokenAddress, publicClient);
|
|
144
|
+
}
|
|
145
|
+
catch (error) {
|
|
146
|
+
console.error('Error checking ERC20 allowance:', error);
|
|
147
|
+
throw new Error('Failed to check ERC20 allowance');
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Get the Permit2 contract address
|
|
152
|
+
* @returns The Permit2 contract address
|
|
153
|
+
*/
|
|
154
|
+
function getPermit2Address() {
|
|
155
|
+
return PERMIT2_ADDRESS;
|
|
156
|
+
}
|
|
157
|
+
/**
|
|
158
|
+
* Signs permit2 calls across multiple chains using batch approach.
|
|
159
|
+
* Collects all signatures first, then returns them all at once.
|
|
160
|
+
*
|
|
161
|
+
* This approach is efficient for backend signers but may be memory-intensive
|
|
162
|
+
* for frontend applications with many chains.
|
|
163
|
+
*
|
|
164
|
+
* @param configs - Array of permit2 signing configurations for different chains
|
|
165
|
+
* @returns Promise<BatchPermit2Result> - All signatures collected
|
|
166
|
+
*/
|
|
167
|
+
async function signPermit2Batch(configs) {
|
|
168
|
+
const results = [];
|
|
169
|
+
let successfulSignatures = 0;
|
|
170
|
+
let failedSignatures = 0;
|
|
171
|
+
// Process all signing operations in parallel
|
|
172
|
+
const signingPromises = configs.map(async (config) => {
|
|
173
|
+
try {
|
|
174
|
+
// Get typed data for this chain
|
|
175
|
+
const typedData = getTypedData(config.intentOp);
|
|
176
|
+
// Sign with EOA account
|
|
177
|
+
if (!config.eoaAccount.signTypedData) {
|
|
178
|
+
throw new Error('EOA account does not support typed data signing');
|
|
179
|
+
}
|
|
180
|
+
const signature = await config.eoaAccount.signTypedData(typedData);
|
|
181
|
+
const result = {
|
|
182
|
+
chainId: config.chain.id,
|
|
183
|
+
signature,
|
|
184
|
+
success: true,
|
|
185
|
+
};
|
|
186
|
+
successfulSignatures++;
|
|
187
|
+
return result;
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
const result = {
|
|
191
|
+
chainId: config.chain.id,
|
|
192
|
+
signature: '0x',
|
|
193
|
+
success: false,
|
|
194
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
195
|
+
};
|
|
196
|
+
failedSignatures++;
|
|
197
|
+
return result;
|
|
198
|
+
}
|
|
199
|
+
});
|
|
200
|
+
// Wait for all signing operations to complete
|
|
201
|
+
const signingResults = await Promise.allSettled(signingPromises);
|
|
202
|
+
// Process results
|
|
203
|
+
for (const result of signingResults) {
|
|
204
|
+
if (result.status === 'fulfilled') {
|
|
205
|
+
results.push(result.value);
|
|
206
|
+
}
|
|
207
|
+
else {
|
|
208
|
+
// This shouldn't happen since we catch errors in the promise
|
|
209
|
+
failedSignatures++;
|
|
210
|
+
results.push({
|
|
211
|
+
chainId: 0,
|
|
212
|
+
signature: '0x',
|
|
213
|
+
success: false,
|
|
214
|
+
error: result.reason,
|
|
215
|
+
});
|
|
216
|
+
}
|
|
217
|
+
}
|
|
218
|
+
return {
|
|
219
|
+
results,
|
|
220
|
+
totalChains: configs.length,
|
|
221
|
+
successfulSignatures,
|
|
222
|
+
failedSignatures,
|
|
223
|
+
allSuccessful: failedSignatures === 0,
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Signs permit2 calls across multiple chains sequentially.
|
|
228
|
+
* Signs one by one, useful for frontend applications to avoid memory issues.
|
|
229
|
+
*
|
|
230
|
+
* This approach is more memory-efficient for frontend applications but slower
|
|
231
|
+
* due to sequential processing.
|
|
232
|
+
*
|
|
233
|
+
* @param configs - Array of permit2 signing configurations for different chains
|
|
234
|
+
* @param onProgress - Optional callback for progress updates
|
|
235
|
+
* @returns Promise<BatchPermit2Result> - All signatures collected
|
|
236
|
+
*/
|
|
237
|
+
async function signPermit2Sequential(configs, onProgress) {
|
|
238
|
+
const results = [];
|
|
239
|
+
let successfulSignatures = 0;
|
|
240
|
+
let failedSignatures = 0;
|
|
241
|
+
// Process signing operations sequentially
|
|
242
|
+
for (let i = 0; i < configs.length; i++) {
|
|
243
|
+
const config = configs[i];
|
|
244
|
+
try {
|
|
245
|
+
// Get typed data for this chain
|
|
246
|
+
const typedData = getTypedData(config.intentOp);
|
|
247
|
+
// Sign with EOA account
|
|
248
|
+
if (!config.eoaAccount.signTypedData) {
|
|
249
|
+
throw new Error('EOA account does not support typed data signing');
|
|
250
|
+
}
|
|
251
|
+
const signature = await config.eoaAccount.signTypedData(typedData);
|
|
252
|
+
const result = {
|
|
253
|
+
chainId: config.chain.id,
|
|
254
|
+
signature,
|
|
255
|
+
success: true,
|
|
256
|
+
};
|
|
257
|
+
results.push(result);
|
|
258
|
+
successfulSignatures++;
|
|
259
|
+
// Call progress callback if provided
|
|
260
|
+
onProgress?.(i + 1, configs.length, result);
|
|
261
|
+
}
|
|
262
|
+
catch (error) {
|
|
263
|
+
const result = {
|
|
264
|
+
chainId: config.chain.id,
|
|
265
|
+
signature: '0x',
|
|
266
|
+
success: false,
|
|
267
|
+
error: error instanceof Error ? error : new Error(String(error)),
|
|
268
|
+
};
|
|
269
|
+
results.push(result);
|
|
270
|
+
failedSignatures++;
|
|
271
|
+
// Call progress callback if provided
|
|
272
|
+
onProgress?.(i + 1, configs.length, result);
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
return {
|
|
276
|
+
results,
|
|
277
|
+
totalChains: configs.length,
|
|
278
|
+
successfulSignatures,
|
|
279
|
+
failedSignatures,
|
|
280
|
+
allSuccessful: failedSignatures === 0,
|
|
281
|
+
};
|
|
282
|
+
}
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import { type Chain, type Hex } from 'viem';
|
|
2
2
|
import { type ChainDigest, type EnableSessionData, type SmartSessionModeType } from '../modules/validators/smart-sessions';
|
|
3
|
-
import type {
|
|
3
|
+
import type { RhinestoneConfig, Session } from '../types';
|
|
4
4
|
interface SessionDetails {
|
|
5
5
|
permissionEnableHash: Hex;
|
|
6
6
|
mode: SmartSessionModeType;
|
|
7
7
|
hashesAndChainIds: ChainDigest[];
|
|
8
8
|
enableSessionData: EnableSessionData;
|
|
9
9
|
}
|
|
10
|
-
declare function getSessionDetails(config:
|
|
10
|
+
declare function getSessionDetails(config: RhinestoneConfig, sessions: Session[], sessionIndex: number, signature?: Hex): Promise<SessionDetails>;
|
|
11
11
|
declare function getMultichainDigest(chainDigests: ChainDigest[]): Hex;
|
|
12
|
-
declare function enableSmartSession(chain: Chain, config:
|
|
12
|
+
declare function enableSmartSession(chain: Chain, config: RhinestoneConfig, session: Session): Promise<void>;
|
|
13
13
|
export { enableSmartSession, getSessionDetails, getMultichainDigest };
|
|
14
14
|
export type { SessionDetails };
|
|
15
15
|
//# sourceMappingURL=smart-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../execution/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAIV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAmBb,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,EAC1B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAGV,
|
|
1
|
+
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../execution/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,KAAK,KAAK,EAIV,KAAK,GAAG,EAGT,MAAM,MAAM,CAAA;AAmBb,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,EAC1B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAGV,gBAAgB,EAChB,OAAO,EACR,MAAM,UAAU,CAAA;AAGjB,UAAU,cAAc;IACtB,oBAAoB,EAAE,GAAG,CAAA;IACzB,IAAI,EAAE,oBAAoB,CAAA;IAC1B,iBAAiB,EAAE,WAAW,EAAE,CAAA;IAChC,iBAAiB,EAAE,iBAAiB,CAAA;CACrC;AAED,iBAAe,iBAAiB,CAC9B,MAAM,EAAE,gBAAgB,EACxB,QAAQ,EAAE,OAAO,EAAE,EACnB,YAAY,EAAE,MAAM,EACpB,SAAS,CAAC,EAAE,GAAG,GACd,OAAO,CAAC,cAAc,CAAC,CA4BzB;AAgGD,iBAAS,mBAAmB,CAAC,YAAY,EAAE,WAAW,EAAE,GAAG,GAAG,CAgC7D;AAiLD,iBAAe,kBAAkB,CAC/B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,gBAAgB,EACxB,OAAO,EAAE,OAAO,iBA+BjB;AAED,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACrE,YAAY,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import type { Account, Address, Chain, Hex } from 'viem';
|
|
2
|
+
import type { IntentOp } from '../orchestrator/types';
|
|
3
|
+
interface TokenPermissions {
|
|
4
|
+
token: Address;
|
|
5
|
+
amount: bigint;
|
|
6
|
+
}
|
|
7
|
+
/**
|
|
8
|
+
* Multi-chain permit2 signing configuration
|
|
9
|
+
*/
|
|
10
|
+
interface MultiChainPermit2Config {
|
|
11
|
+
chain: Chain;
|
|
12
|
+
intentOp: IntentOp;
|
|
13
|
+
eoaAccount: Account;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Result of a multi-chain permit2 signing operation
|
|
17
|
+
*/
|
|
18
|
+
interface MultiChainPermit2Result {
|
|
19
|
+
chainId: number;
|
|
20
|
+
signature: Hex;
|
|
21
|
+
success: boolean;
|
|
22
|
+
error?: Error;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Batch permit2 signing result
|
|
26
|
+
*/
|
|
27
|
+
interface BatchPermit2Result {
|
|
28
|
+
results: MultiChainPermit2Result[];
|
|
29
|
+
totalChains: number;
|
|
30
|
+
successfulSignatures: number;
|
|
31
|
+
failedSignatures: number;
|
|
32
|
+
allSuccessful: boolean;
|
|
33
|
+
}
|
|
34
|
+
export type { TokenPermissions, MultiChainPermit2Config, MultiChainPermit2Result, BatchPermit2Result, };
|
|
35
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../execution/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AACxD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAErD,UAAU,gBAAgB;IACxB,KAAK,EAAE,OAAO,CAAA;IACd,MAAM,EAAE,MAAM,CAAA;CACf;AAED;;GAEG;AACH,UAAU,uBAAuB;IAC/B,KAAK,EAAE,KAAK,CAAA;IACZ,QAAQ,EAAE,QAAQ,CAAA;IAClB,UAAU,EAAE,OAAO,CAAA;CACpB;AAED;;GAEG;AACH,UAAU,uBAAuB;IAC/B,OAAO,EAAE,MAAM,CAAA;IACf,SAAS,EAAE,GAAG,CAAA;IACd,OAAO,EAAE,OAAO,CAAA;IAChB,KAAK,CAAC,EAAE,KAAK,CAAA;CACd;AAED;;GAEG;AACH,UAAU,kBAAkB;IAC1B,OAAO,EAAE,uBAAuB,EAAE,CAAA;IAClC,WAAW,EAAE,MAAM,CAAA;IACnB,oBAAoB,EAAE,MAAM,CAAA;IAC5B,gBAAgB,EAAE,MAAM,CAAA;IACxB,aAAa,EAAE,OAAO,CAAA;CACvB;AAED,YAAY,EACV,gBAAgB,EAChB,uBAAuB,EACvB,uBAAuB,EACvB,kBAAkB,GACnB,CAAA"}
|
|
@@ -1,43 +1,52 @@
|
|
|
1
|
-
import { type Address, type Chain, type Hex, type PublicClient } from 'viem';
|
|
1
|
+
import { type Address, type Chain, type HashTypedDataParameters, type Hex, type PublicClient, type SignableMessage, type SignedAuthorization, type SignedAuthorizationList, type TypedData } from 'viem';
|
|
2
2
|
import { type UserOperation } from 'viem/account-abstraction';
|
|
3
3
|
import { type IntentOp, type IntentRoute } from '../orchestrator';
|
|
4
|
-
import type {
|
|
5
|
-
type
|
|
4
|
+
import type { SettlementLayer } from '../orchestrator/types';
|
|
5
|
+
import type { Call, CalldataInput, CallInput, RhinestoneConfig, SignerSet, SourceAssetInput, TokenRequest, TokenSymbol, Transaction, UserOperationTransaction } from '../types';
|
|
6
|
+
interface UserOperationResult {
|
|
6
7
|
type: 'userop';
|
|
7
8
|
hash: Hex;
|
|
8
9
|
chain: number;
|
|
9
|
-
}
|
|
10
|
+
}
|
|
11
|
+
interface TransactionResult {
|
|
10
12
|
type: 'intent';
|
|
11
13
|
id: bigint;
|
|
12
|
-
|
|
14
|
+
sourceChains?: number[];
|
|
13
15
|
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
16
|
}
|
|
25
17
|
interface PreparedTransactionData {
|
|
26
|
-
|
|
18
|
+
intentRoute: IntentRoute;
|
|
27
19
|
transaction: Transaction;
|
|
28
20
|
}
|
|
21
|
+
interface PreparedUserOperationData {
|
|
22
|
+
userOperation: UserOperation;
|
|
23
|
+
hash: Hex;
|
|
24
|
+
transaction: UserOperationTransaction;
|
|
25
|
+
}
|
|
29
26
|
interface SignedTransactionData extends PreparedTransactionData {
|
|
30
27
|
signature: Hex;
|
|
31
28
|
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
declare function
|
|
36
|
-
declare function
|
|
37
|
-
declare function
|
|
38
|
-
declare function
|
|
39
|
-
declare function
|
|
40
|
-
declare function
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
interface SignedUserOperationData extends PreparedUserOperationData {
|
|
30
|
+
signature: Hex;
|
|
31
|
+
}
|
|
32
|
+
declare function prepareTransaction(config: RhinestoneConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
33
|
+
declare function prepareUserOperation(config: RhinestoneConfig, transaction: UserOperationTransaction): Promise<PreparedUserOperationData>;
|
|
34
|
+
declare function resolveCallInputs(inputs: CallInput[], config: RhinestoneConfig, chain: Chain, accountAddress: Address): Promise<CalldataInput[]>;
|
|
35
|
+
declare function signTransaction(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
36
|
+
declare function signUserOperation(config: RhinestoneConfig, preparedUserOperation: PreparedUserOperationData): Promise<SignedUserOperationData>;
|
|
37
|
+
declare function signAuthorizations(config: RhinestoneConfig, preparedTransaction: PreparedTransactionData): Promise<SignedAuthorization[]>;
|
|
38
|
+
declare function signMessage(config: RhinestoneConfig, message: SignableMessage, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
39
|
+
declare function signTypedData<typedData extends TypedData | Record<string, unknown> = TypedData, primaryType extends keyof typedData | 'EIP712Domain' = keyof typedData>(config: RhinestoneConfig, parameters: HashTypedDataParameters<typedData, primaryType>, chain: Chain, signers: SignerSet | undefined): Promise<`0x${string}`>;
|
|
40
|
+
declare function signAuthorizationsInternal(config: RhinestoneConfig, data: IntentRoute | UserOperation): Promise<SignedAuthorization[]>;
|
|
41
|
+
declare function submitTransaction(config: RhinestoneConfig, signedTransaction: SignedTransactionData, authorizations: SignedAuthorizationList, dryRun?: boolean): Promise<TransactionResult>;
|
|
42
|
+
declare function submitUserOperation(config: RhinestoneConfig, signedUserOperation: SignedUserOperationData): Promise<UserOperationResult>;
|
|
43
|
+
declare function getTokenRequests(sourceChains: Chain[], targetChain: Chain, initialTokenRequests: TokenRequest[] | undefined, settlementLayers: SettlementLayer[] | undefined): TokenRequest[];
|
|
44
|
+
declare function prepareTransactionAsIntent(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, callInputs: CalldataInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address, isSponsored: boolean, eip7702InitSignature: Hex | undefined, settlementLayers: SettlementLayer[] | undefined, sourceAssets: SourceAssetInput | undefined, feeAsset: Address | TokenSymbol | undefined, lockFunds?: boolean): Promise<IntentRoute>;
|
|
45
|
+
declare function signIntent(config: RhinestoneConfig, targetChain: Chain, intentOp: IntentOp, signers?: SignerSet): Promise<`0x${string}`>;
|
|
46
|
+
declare function getOrchestratorByChain(chainId: number, apiKey: string | undefined, orchestratorUrl?: string): import("../orchestrator").Orchestrator;
|
|
47
|
+
declare function submitIntentInternal(config: RhinestoneConfig, sourceChains: Chain[] | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex, authorizations: SignedAuthorizationList, dryRun: boolean): Promise<TransactionResult>;
|
|
48
|
+
declare function getValidatorAccount(config: RhinestoneConfig, 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>;
|
|
49
|
+
declare function parseCalls(calls: CalldataInput[], chainId: number): Call[];
|
|
50
|
+
export { prepareTransaction, signTransaction, signAuthorizations, signAuthorizationsInternal, signMessage, signTypedData, submitTransaction, prepareUserOperation, signUserOperation, submitUserOperation, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, getTokenRequests, resolveCallInputs, };
|
|
51
|
+
export type { IntentRoute, TransactionResult, PreparedTransactionData, PreparedUserOperationData, SignedTransactionData, SignedUserOperationData, UserOperationResult, };
|
|
43
52
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAA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