@rhinestone/sdk 1.0.0-alpha.2 → 1.0.0-alpha.4
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/index.d.ts +8 -6
- package/dist/src/accounts/index.d.ts.map +1 -1
- package/dist/src/accounts/index.js +32 -151
- package/dist/src/accounts/kernel.d.ts +7 -9
- package/dist/src/accounts/kernel.d.ts.map +1 -1
- package/dist/src/accounts/kernel.js +0 -9
- package/dist/src/accounts/nexus.d.ts +5 -10
- package/dist/src/accounts/nexus.d.ts.map +1 -1
- package/dist/src/accounts/nexus.js +0 -70
- package/dist/src/accounts/safe.d.ts +4 -6
- package/dist/src/accounts/safe.d.ts.map +1 -1
- package/dist/src/accounts/safe.js +0 -9
- package/dist/src/accounts/utils.d.ts +4 -3
- package/dist/src/accounts/utils.d.ts.map +1 -1
- package/dist/src/accounts/utils.js +44 -0
- package/dist/src/actions/index.d.ts +5 -5
- package/dist/src/actions/index.d.ts.map +1 -1
- package/dist/src/actions/index.js +8 -4
- package/dist/src/actions/index.test.js +18 -0
- package/dist/src/actions/registry.d.ts +1 -1
- package/dist/src/actions/registry.d.ts.map +1 -1
- package/dist/src/actions/registry.test.js +1 -2
- package/dist/src/actions/smart-session.d.ts +2 -2
- package/dist/src/actions/smart-session.d.ts.map +1 -1
- package/dist/src/execution/compact.d.ts +2 -2
- package/dist/src/execution/compact.d.ts.map +1 -1
- package/dist/src/execution/compact.js +3 -1
- package/dist/src/execution/index.d.ts.map +1 -1
- package/dist/src/execution/index.js +17 -17
- package/dist/src/execution/smart-session.d.ts +1 -1
- package/dist/src/execution/smart-session.d.ts.map +1 -1
- package/dist/src/execution/smart-session.js +10 -10
- package/dist/src/execution/utils.d.ts +8 -7
- package/dist/src/execution/utils.d.ts.map +1 -1
- package/dist/src/execution/utils.js +38 -21
- package/dist/src/index.d.ts +8 -8
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +10 -8
- package/dist/src/modules/read.d.ts +5 -5
- package/dist/src/modules/read.d.ts.map +1 -1
- package/dist/src/modules/read.js +7 -6
- package/dist/src/modules/registry.d.ts +2 -2
- package/dist/src/modules/registry.d.ts.map +1 -1
- package/dist/src/modules/validators/core.d.ts +1 -1
- package/dist/src/modules/validators/core.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.d.ts +3 -3
- package/dist/src/modules/validators/smart-sessions.d.ts.map +1 -1
- package/dist/src/modules/validators/smart-sessions.js +7 -6
- package/dist/src/orchestrator/client.d.ts.map +1 -1
- package/dist/src/orchestrator/client.js +69 -39
- package/dist/src/orchestrator/index.d.ts +2 -2
- package/dist/src/orchestrator/index.d.ts.map +1 -1
- package/dist/src/orchestrator/index.js +1 -7
- package/dist/src/orchestrator/registry.d.ts +31 -12
- package/dist/src/orchestrator/registry.d.ts.map +1 -1
- package/dist/src/orchestrator/registry.js +56 -379
- package/dist/src/orchestrator/registry.json +356 -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 +9 -6
- package/dist/src/orchestrator/types.d.ts.map +1 -1
- package/dist/src/orchestrator/utils.d.ts.map +1 -1
- package/dist/src/types.d.ts +20 -17
- package/dist/src/types.d.ts.map +1 -1
- package/dist/test/consts.d.ts +2 -2
- package/dist/test/consts.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -3,9 +3,11 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.encode7579Calls = encode7579Calls;
|
|
4
4
|
exports.getAccountNonce = getAccountNonce;
|
|
5
5
|
exports.getBundlerClient = getBundlerClient;
|
|
6
|
+
exports.createTransport = createTransport;
|
|
6
7
|
const viem_1 = require("viem");
|
|
7
8
|
const account_abstraction_1 = require("viem/account-abstraction");
|
|
8
9
|
const actions_1 = require("viem/actions");
|
|
10
|
+
const chains_1 = require("viem/chains");
|
|
9
11
|
const utils_1 = require("viem/utils");
|
|
10
12
|
function parseCallType(callType) {
|
|
11
13
|
switch (callType) {
|
|
@@ -140,12 +142,16 @@ function getBundlerClient(config, client) {
|
|
|
140
142
|
switch (config.type) {
|
|
141
143
|
case 'pimlico':
|
|
142
144
|
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=${config.apiKey}`;
|
|
145
|
+
case 'biconomy':
|
|
146
|
+
return `https://bundler.biconomy.io/api/v3/${chainId}/${config.apiKey}`;
|
|
143
147
|
}
|
|
144
148
|
}
|
|
145
149
|
function getPaymasterEndpoint(config, chainId) {
|
|
146
150
|
switch (config.type) {
|
|
147
151
|
case 'pimlico':
|
|
148
152
|
return `https://api.pimlico.io/v2/${chainId}/rpc?apikey=${config.apiKey}`;
|
|
153
|
+
case 'biconomy':
|
|
154
|
+
return `https://paymaster.biconomy.io/api/v2/${chainId}/${config.apiKey}`;
|
|
149
155
|
}
|
|
150
156
|
}
|
|
151
157
|
const { bundler, paymaster } = config;
|
|
@@ -192,3 +198,41 @@ async function getGasPriceEstimate(bundlerUrl) {
|
|
|
192
198
|
maxPriorityFeePerGas: BigInt(json.result.fast.maxPriorityFeePerGas),
|
|
193
199
|
};
|
|
194
200
|
}
|
|
201
|
+
function createTransport(chain, provider) {
|
|
202
|
+
if (!provider) {
|
|
203
|
+
return (0, viem_1.http)();
|
|
204
|
+
}
|
|
205
|
+
switch (provider.type) {
|
|
206
|
+
case 'alchemy': {
|
|
207
|
+
const alchemyNetwork = getAlchemyNetworkName(chain.id);
|
|
208
|
+
const jsonRpcEndpoint = `https://${alchemyNetwork}.g.alchemy.com/v2/${provider.apiKey}`;
|
|
209
|
+
return (0, viem_1.http)(jsonRpcEndpoint);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
function getAlchemyNetworkName(chainId) {
|
|
214
|
+
switch (chainId) {
|
|
215
|
+
case chains_1.mainnet.id:
|
|
216
|
+
return 'eth-mainnet';
|
|
217
|
+
case chains_1.sepolia.id:
|
|
218
|
+
return 'eth-sepolia';
|
|
219
|
+
case chains_1.polygon.id:
|
|
220
|
+
return 'polygon-mainnet';
|
|
221
|
+
case chains_1.polygonAmoy.id:
|
|
222
|
+
return 'polygon-amoy';
|
|
223
|
+
case chains_1.optimism.id:
|
|
224
|
+
return 'opt-mainnet';
|
|
225
|
+
case chains_1.optimismSepolia.id:
|
|
226
|
+
return 'opt-sepolia';
|
|
227
|
+
case chains_1.arbitrum.id:
|
|
228
|
+
return 'arb-mainnet';
|
|
229
|
+
case chains_1.arbitrumSepolia.id:
|
|
230
|
+
return 'arb-sepolia';
|
|
231
|
+
case chains_1.base.id:
|
|
232
|
+
return 'base-mainnet';
|
|
233
|
+
case chains_1.baseSepolia.id:
|
|
234
|
+
return 'base-sepolia';
|
|
235
|
+
case chains_1.zksync.id:
|
|
236
|
+
return 'zksync-mainnet';
|
|
237
|
+
}
|
|
238
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import { Address, Chain } from 'viem';
|
|
2
|
-
import { RhinestoneAccount } from '..';
|
|
3
|
-
import { WebauthnCredential } from '../modules/validators/core';
|
|
4
|
-
import { Call, OwnerSet, Recovery } from '../types';
|
|
1
|
+
import { type Address, type Chain } from 'viem';
|
|
2
|
+
import type { RhinestoneAccount } from '..';
|
|
3
|
+
import { type WebauthnCredential } from '../modules/validators/core';
|
|
4
|
+
import type { Call, OwnerSet, ProviderConfig, Recovery } from '../types';
|
|
5
5
|
import { trustAttester } from './registry';
|
|
6
6
|
import { encodeSmartSessionSignature } from './smart-session';
|
|
7
7
|
declare function setUpRecovery({ rhinestoneAccount, guardians, threshold, }: {
|
|
8
8
|
rhinestoneAccount: RhinestoneAccount;
|
|
9
9
|
} & Recovery): Call[];
|
|
10
|
-
declare function recover(address: Address, newOwners: OwnerSet, chain: Chain): Promise<Call[]>;
|
|
10
|
+
declare function recover(address: Address, newOwners: OwnerSet, chain: Chain, provider?: ProviderConfig): Promise<Call[]>;
|
|
11
11
|
declare function enableEcdsa({ rhinestoneAccount, owners, threshold, }: {
|
|
12
12
|
rhinestoneAccount: RhinestoneAccount;
|
|
13
13
|
owners: Address[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../actions/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAGX,MAAM,MAAM,CAAA;AAEb,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAM3C,OAAO,EAKL,KAAK,kBAAkB,EACxB,MAAM,4BAA4B,CAAA;AACnC,OAAO,KAAK,EACV,IAAI,EAEJ,QAAQ,EACR,cAAc,EACd,QAAQ,EACT,MAAM,UAAU,CAAA;AAEjB,OAAO,EAAE,aAAa,EAAE,MAAM,YAAY,CAAA;AAC1C,OAAO,EAAE,2BAA2B,EAAE,MAAM,iBAAiB,CAAA;AAE7D,iBAAS,aAAa,CAAC,EACrB,iBAAiB,EACjB,SAAS,EACT,SAAa,GACd,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,GAAG,QAAQ,UAIX;AAED,iBAAe,OAAO,CACpB,OAAO,EAAE,OAAO,EAChB,SAAS,EAAE,QAAQ,EACnB,KAAK,EAAE,KAAK,EACZ,QAAQ,CAAC,EAAE,cAAc,GACxB,OAAO,CAAC,IAAI,EAAE,CAAC,CASjB;AAED,iBAAS,WAAW,CAAC,EACnB,iBAAiB,EACjB,MAAM,EACN,SAAa,GACd,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;IACpC,MAAM,EAAE,OAAO,EAAE,CAAA;IACjB,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,UAOA;AAED,iBAAS,cAAc,CAAC,EACtB,iBAAiB,EACjB,MAAM,EACN,eAAe,GAChB,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,GAAG,kBAAkB,UAIrB;AAED,iBAAS,YAAY,CAAC,EACpB,iBAAiB,GAClB,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,UAOA;AAED,iBAAS,eAAe,CAAC,EACvB,iBAAiB,GAClB,EAAE;IACD,iBAAiB,EAAE,iBAAiB,CAAA;CACrC,UASA;AAED,iBAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,IAAI,CAkBtC;AAED,iBAAS,WAAW,CAAC,SAAS,EAAE,OAAO,EAAE,aAAa,EAAE,OAAO,GAAG,IAAI,CAqBrE;AAED,iBAAS,eAAe,CAAC,YAAY,EAAE,MAAM,GAAG,IAAI,CAoBnD;AAgHD,OAAO,EACL,WAAW,EACX,cAAc,EACd,YAAY,EACZ,eAAe,EACf,QAAQ,EACR,WAAW,EACX,eAAe,EACf,OAAO,EACP,aAAa,EACb,2BAA2B,EAC3B,aAAa,GACd,CAAA"}
|
|
@@ -12,6 +12,7 @@ exports.recover = recover;
|
|
|
12
12
|
exports.setUpRecovery = setUpRecovery;
|
|
13
13
|
const viem_1 = require("viem");
|
|
14
14
|
const accounts_1 = require("../accounts");
|
|
15
|
+
const utils_1 = require("../accounts/utils");
|
|
15
16
|
const core_1 = require("../modules/validators/core");
|
|
16
17
|
const registry_1 = require("./registry");
|
|
17
18
|
Object.defineProperty(exports, "trustAttester", { enumerable: true, get: function () { return registry_1.trustAttester; } });
|
|
@@ -22,10 +23,10 @@ function setUpRecovery({ rhinestoneAccount, guardians, threshold = 1, }) {
|
|
|
22
23
|
const calls = (0, accounts_1.getModuleInstallationCalls)(rhinestoneAccount.config, module);
|
|
23
24
|
return calls;
|
|
24
25
|
}
|
|
25
|
-
async function recover(address, newOwners, chain) {
|
|
26
|
+
async function recover(address, newOwners, chain, provider) {
|
|
26
27
|
switch (newOwners.type) {
|
|
27
28
|
case 'ecdsa': {
|
|
28
|
-
return recoverEcdsaOwnership(address, newOwners, chain);
|
|
29
|
+
return recoverEcdsaOwnership(address, newOwners, chain, provider);
|
|
29
30
|
}
|
|
30
31
|
case 'passkey': {
|
|
31
32
|
throw new Error('Passkey ownership recovery is not yet supported');
|
|
@@ -65,6 +66,7 @@ function disablePasskeys({ rhinestoneAccount, }) {
|
|
|
65
66
|
function addOwner(owner) {
|
|
66
67
|
return {
|
|
67
68
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
69
|
+
value: 0n,
|
|
68
70
|
data: (0, viem_1.encodeFunctionData)({
|
|
69
71
|
abi: [
|
|
70
72
|
{
|
|
@@ -83,6 +85,7 @@ function addOwner(owner) {
|
|
|
83
85
|
function removeOwner(prevOwner, ownerToRemove) {
|
|
84
86
|
return {
|
|
85
87
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
88
|
+
value: 0n,
|
|
86
89
|
data: (0, viem_1.encodeFunctionData)({
|
|
87
90
|
abi: [
|
|
88
91
|
{
|
|
@@ -104,6 +107,7 @@ function removeOwner(prevOwner, ownerToRemove) {
|
|
|
104
107
|
function changeThreshold(newThreshold) {
|
|
105
108
|
return {
|
|
106
109
|
to: core_1.OWNABLE_VALIDATOR_ADDRESS,
|
|
110
|
+
value: 0n,
|
|
107
111
|
data: (0, viem_1.encodeFunctionData)({
|
|
108
112
|
abi: [
|
|
109
113
|
{
|
|
@@ -121,10 +125,10 @@ function changeThreshold(newThreshold) {
|
|
|
121
125
|
}),
|
|
122
126
|
};
|
|
123
127
|
}
|
|
124
|
-
async function recoverEcdsaOwnership(address, newOwners, chain) {
|
|
128
|
+
async function recoverEcdsaOwnership(address, newOwners, chain, provider) {
|
|
125
129
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
126
130
|
chain,
|
|
127
|
-
transport: (0,
|
|
131
|
+
transport: (0, utils_1.createTransport)(chain, provider),
|
|
128
132
|
});
|
|
129
133
|
// Read the existing config
|
|
130
134
|
const results = await publicClient.multicall({
|
|
@@ -36,6 +36,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
36
36
|
})).toEqual([
|
|
37
37
|
{
|
|
38
38
|
to: accountAddress,
|
|
39
|
+
value: 0n,
|
|
39
40
|
data: '0x9517e29f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000002483da3a338895199e5e538530213157e931bf0600000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000001000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
|
|
40
41
|
},
|
|
41
42
|
]);
|
|
@@ -47,6 +48,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
47
48
|
})).toEqual([
|
|
48
49
|
{
|
|
49
50
|
to: accountAddress,
|
|
51
|
+
value: 0n,
|
|
50
52
|
data: '0x9517e29f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000002483da3a338895199e5e538530213157e931bf06000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000a0000000000000000000000000000000000000000000000000000000000000000100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000002000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
51
53
|
},
|
|
52
54
|
]);
|
|
@@ -59,6 +61,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
59
61
|
})).toEqual([
|
|
60
62
|
{
|
|
61
63
|
to: accountAddress,
|
|
64
|
+
value: 0n,
|
|
62
65
|
data: '0x9517e29f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000002483da3a338895199e5e538530213157e931bf06000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c0000000000000000000000000000000000000000000000000000000000000000200000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000003000000000000000000000000b31e76f19defe76edc4b7eceeb4b0a2d6ddaca39000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
63
66
|
},
|
|
64
67
|
]);
|
|
@@ -80,6 +83,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
80
83
|
})).toEqual([
|
|
81
84
|
{
|
|
82
85
|
to: accountAddress,
|
|
86
|
+
value: 0n,
|
|
83
87
|
data: '0x9517e29f00000000000000000000000000000000000000000000000000000000000000010000000000000000000000002f167e55d42584f65e2e30a748f41ee75a31141400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000060580a9af0569ad3905b26a703201b358aa0904236642ebe79b22a19d00d3737637d46f725a5427ae45a9569259bf67e1e16b187d7b3ad1ed70138c4f0409677d19c9a01073b202db2ed56e604ad11db557d8c3ad75181619597f21b830f2da82a',
|
|
84
88
|
},
|
|
85
89
|
]);
|
|
@@ -99,6 +103,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
99
103
|
})).toEqual([
|
|
100
104
|
{
|
|
101
105
|
to: accountAddress,
|
|
106
|
+
value: 0n,
|
|
102
107
|
data: '0xa71763a800000000000000000000000000000000000000000000000000000000000000010000000000000000000000002483da3a338895199e5e538530213157e931bf0600000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000',
|
|
103
108
|
},
|
|
104
109
|
]);
|
|
@@ -118,6 +123,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
118
123
|
})).toEqual([
|
|
119
124
|
{
|
|
120
125
|
to: accountAddress,
|
|
126
|
+
value: 0n,
|
|
121
127
|
data: '0xa71763a800000000000000000000000000000000000000000000000000000000000000010000000000000000000000002f167e55d42584f65e2e30a748f41ee75a31141400000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000000',
|
|
122
128
|
},
|
|
123
129
|
]);
|
|
@@ -127,6 +133,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
127
133
|
(0, vitest_1.test)('', () => {
|
|
128
134
|
(0, vitest_1.expect)((0, _1.addOwner)(MOCK_OWNER_A)).toEqual({
|
|
129
135
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
136
|
+
value: 0n,
|
|
130
137
|
data: '0x7065cb48000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a',
|
|
131
138
|
});
|
|
132
139
|
});
|
|
@@ -135,6 +142,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
135
142
|
(0, vitest_1.test)('', () => {
|
|
136
143
|
(0, vitest_1.expect)((0, _1.removeOwner)(MOCK_OWNER_A, MOCK_OWNER_B)).toEqual({
|
|
137
144
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
145
|
+
value: 0n,
|
|
138
146
|
data: '0xfbe5ce0a000000000000000000000000d1aefebdceefc094f1805b241fa5e6db63a9181a000000000000000000000000eddfcb50d18f6d3d51c4f7cbca5ed6bdebc59817',
|
|
139
147
|
});
|
|
140
148
|
});
|
|
@@ -143,6 +151,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
143
151
|
(0, vitest_1.test)('', () => {
|
|
144
152
|
(0, vitest_1.expect)((0, _1.changeThreshold)(1)).toEqual({
|
|
145
153
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
154
|
+
value: 0n,
|
|
146
155
|
data: '0x960bfe040000000000000000000000000000000000000000000000000000000000000001',
|
|
147
156
|
});
|
|
148
157
|
});
|
|
@@ -163,6 +172,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
163
172
|
})).toEqual([
|
|
164
173
|
{
|
|
165
174
|
to: accountAddress,
|
|
175
|
+
value: 0n,
|
|
166
176
|
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000800000000000000000000000000000000000000000000000000000000000000001000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000010000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
|
|
167
177
|
},
|
|
168
178
|
]);
|
|
@@ -175,6 +185,7 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
175
185
|
})).toEqual([
|
|
176
186
|
{
|
|
177
187
|
to: accountAddress,
|
|
188
|
+
value: 0n,
|
|
178
189
|
data: '0x9517e29f0000000000000000000000000000000000000000000000000000000000000001000000000000000000000000a04d053b3c8021e8d5bf641816c42daa75d8b597000000000000000000000000000000000000000000000000000000000000006000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000000000000000000000000000000000000000000002000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000030000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
179
190
|
},
|
|
180
191
|
]);
|
|
@@ -206,10 +217,12 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
206
217
|
(0, vitest_1.expect)(result).toEqual([
|
|
207
218
|
{
|
|
208
219
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
220
|
+
value: 0n,
|
|
209
221
|
data: '0x7065cb480000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7',
|
|
210
222
|
},
|
|
211
223
|
{
|
|
212
224
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
225
|
+
value: 0n,
|
|
213
226
|
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
214
227
|
},
|
|
215
228
|
]);
|
|
@@ -237,10 +250,12 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
237
250
|
(0, vitest_1.expect)(result).toEqual([
|
|
238
251
|
{
|
|
239
252
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
253
|
+
value: 0n,
|
|
240
254
|
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
241
255
|
},
|
|
242
256
|
{
|
|
243
257
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
258
|
+
value: 0n,
|
|
244
259
|
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
245
260
|
},
|
|
246
261
|
]);
|
|
@@ -268,14 +283,17 @@ vitest_1.vi.mock('viem', async (importOriginal) => {
|
|
|
268
283
|
(0, vitest_1.expect)(result).toEqual([
|
|
269
284
|
{
|
|
270
285
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
286
|
+
value: 0n,
|
|
271
287
|
data: '0x7065cb48000000000000000000000000c5587d912c862252599b61926adaef316ba06da0',
|
|
272
288
|
},
|
|
273
289
|
{
|
|
274
290
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
291
|
+
value: 0n,
|
|
275
292
|
data: '0xfbe5ce0a000000000000000000000000c5587d912c862252599b61926adaef316ba06da0000000000000000000000000f6c02c78ded62973b43bfa523b247da099486936',
|
|
276
293
|
},
|
|
277
294
|
{
|
|
278
295
|
to: '0x2483DA3A338895199E5e538530213157e931Bf06',
|
|
296
|
+
value: 0n,
|
|
279
297
|
data: '0xfbe5ce0a0000000000000000000000006092086a3dc0020cd604a68fcf5d430007d51bb7000000000000000000000000c27b7578151c5ef713c62c65db09763d57ac3596',
|
|
280
298
|
},
|
|
281
299
|
]);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../actions/registry.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;
|
|
1
|
+
{"version":3,"file":"registry.d.ts","sourceRoot":"","sources":["../../../actions/registry.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,IAAI,CAAA;AAG3C,iBAAS,aAAa,CAAC,OAAO,EAAE,iBAAiB;;;EAEhD;AAED,OAAO,EAAE,aAAa,EAAE,CAAA"}
|
|
@@ -2,14 +2,13 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const vitest_1 = require("vitest");
|
|
4
4
|
const consts_1 = require("../../test/consts");
|
|
5
|
-
const consts_2 = require("../../test/consts");
|
|
6
5
|
const __1 = require("..");
|
|
7
6
|
const registry_1 = require("./registry");
|
|
8
7
|
(0, vitest_1.describe)('Actions', async () => {
|
|
9
8
|
const rhinestoneAccount = await (0, __1.createRhinestoneAccount)({
|
|
10
9
|
owners: {
|
|
11
10
|
type: 'ecdsa',
|
|
12
|
-
accounts: [
|
|
11
|
+
accounts: [consts_1.accountA],
|
|
13
12
|
},
|
|
14
13
|
rhinestoneApiKey: consts_1.MOCK_API_KEY,
|
|
15
14
|
});
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Hex } from 'viem';
|
|
2
|
-
import { SessionDetails } from '../execution/smart-session';
|
|
1
|
+
import type { Hex } from 'viem';
|
|
2
|
+
import type { SessionDetails } from '../execution/smart-session';
|
|
3
3
|
declare function encodeSmartSessionSignature(sessionDetails: SessionDetails, sessionSignature: Hex): `0x${string}`;
|
|
4
4
|
export { encodeSmartSessionSignature };
|
|
5
5
|
//# sourceMappingURL=smart-session.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"smart-session.d.ts","sourceRoot":"","sources":["../../../actions/smart-session.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,MAAM,CAAA;AAC/B,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAA;AAGhE,iBAAS,2BAA2B,CAClC,cAAc,EAAE,cAAc,EAC9B,gBAAgB,EAAE,GAAG,iBAQtB;AAED,OAAO,EAAE,2BAA2B,EAAE,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Address } from 'viem';
|
|
2
|
-
import { Call } from '../types';
|
|
1
|
+
import { type Address } from 'viem';
|
|
2
|
+
import type { Call } from '../types';
|
|
3
3
|
declare const COMPACT_ADDRESS = "0xa2E6C7Ba8613E1534dCB990e7e4962216C0a5d58";
|
|
4
4
|
declare function getDepositEtherCall(account: Address, value: bigint): Call;
|
|
5
5
|
declare function getDepositErc20Call(account: Address, tokenAddress: Address, amount: bigint): Call;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../execution/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,
|
|
1
|
+
{"version":3,"file":"compact.d.ts","sourceRoot":"","sources":["../../../execution/compact.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,OAAO,EAA0C,MAAM,MAAM,CAAA;AAC3E,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAcpC,QAAA,MAAM,eAAe,+CAA+C,CAAA;AAKpE,iBAAS,mBAAmB,CAAC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI,CAqBlE;AAED,iBAAS,mBAAmB,CAC1B,OAAO,EAAE,OAAO,EAChB,YAAY,EAAE,OAAO,EACrB,MAAM,EAAE,MAAM,GACb,IAAI,CA2BN;AAED,iBAAS,mBAAmB,CAAC,YAAY,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,GAAG,IAAI,CAUxE;AAoCD,OAAO,EACL,eAAe,EACf,mBAAmB,EACnB,mBAAmB,EACnB,mBAAmB,GACpB,CAAA"}
|
|
@@ -35,6 +35,7 @@ function getDepositEtherCall(account, value) {
|
|
|
35
35
|
function getDepositErc20Call(account, tokenAddress, amount) {
|
|
36
36
|
return {
|
|
37
37
|
to: COMPACT_ADDRESS,
|
|
38
|
+
value: 0n,
|
|
38
39
|
data: (0, viem_1.encodeFunctionData)({
|
|
39
40
|
abi: [
|
|
40
41
|
{
|
|
@@ -62,6 +63,7 @@ function getDepositErc20Call(account, tokenAddress, amount) {
|
|
|
62
63
|
function getApproveErc20Call(tokenAddress, amount) {
|
|
63
64
|
return {
|
|
64
65
|
to: tokenAddress,
|
|
66
|
+
value: 0n,
|
|
65
67
|
data: (0, viem_1.encodeFunctionData)({
|
|
66
68
|
abi: viem_1.erc20Abi,
|
|
67
69
|
functionName: 'approve',
|
|
@@ -90,7 +92,7 @@ function toCompactFlag(allocator) {
|
|
|
90
92
|
}
|
|
91
93
|
function usingAllocatorId(allocator = ALLOCATOR_ADDRESS) {
|
|
92
94
|
const compactFlag = BigInt(toCompactFlag(allocator));
|
|
93
|
-
const last88Bits = BigInt(
|
|
95
|
+
const last88Bits = BigInt(`0x${allocator.slice(-22)}`); // Extract last 88 bits (11 bytes * 2 hex chars per byte)
|
|
94
96
|
return (compactFlag << 88n) | last88Bits;
|
|
95
97
|
}
|
|
96
98
|
function lockTag() {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../execution/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAIX,MAAM,MAAM,CAAA;AAKb,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAA;AAQrD,OAAO,KAAK,EAGV,uBAAuB,EAGvB,WAAW,EACZ,MAAM,UAAU,CAAA;AAOjB,OAAO,EACL,cAAc,EACd,iBAAiB,EACjB,gBAAgB,EAChB,gCAAgC,EAChC,yBAAyB,EACzB,wCAAwC,EACxC,8BAA8B,EAC9B,0CAA0C,EAC3C,MAAM,SAAS,CAAA;AAEhB,OAAO,KAAK,EAAE,UAAU,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAY5D,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,8BAyBzB;AAqID,iBAAe,gBAAgB,CAC7B,MAAM,EAAE,uBAAuB,EAC/B,MAAM,EAAE,iBAAiB,EACzB,uBAAuB,EAAE,OAAO;;;;;;;;;;;;GA2CjC;AAED,iBAAe,qBAAqB,CAClC,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,YAAY,EAAE,OAAO,EACrB,QAAQ,EAAE,MAAM,GACf,OAAO,CAAC,MAAM,CAAC,CASjB;AAED,iBAAe,YAAY,CACzB,MAAM,EAAE,uBAAuB,EAC/B,UAAU,EAAE,OAAO,gDAMpB;AAED,iBAAe,OAAO,CACpB,MAAM,EAAE,uBAAuB,EAC/B,KAAK,EAAE,KAAK,EACZ,MAAM,EAAE,MAAM,EACd,YAAY,CAAC,EAAE,OAAO,8BAgDvB;AAED,OAAO,EACL,eAAe,EACf,gBAAgB,EAChB,qBAAqB,EACrB,YAAY,EACZ,OAAO,EAEP,gBAAgB,EAChB,iBAAiB,EACjB,cAAc,EACd,wCAAwC,EACxC,8BAA8B,EAC9B,0CAA0C,EAC1C,gCAAgC,EAChC,yBAAyB,GAC1B,CAAA;AACD,YAAY,EAAE,UAAU,EAAE,iBAAiB,EAAE,CAAA"}
|
|
@@ -35,16 +35,10 @@ async function sendTransaction(config, transaction) {
|
|
|
35
35
|
return await sendTransactionInternal(config, transaction.sourceChain, transaction.targetChain, transaction.calls, transaction.gasLimit, transaction.tokenRequests, transaction.signers);
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
|
-
async function sendTransactionInternal(config, sourceChain, targetChain,
|
|
39
|
-
if (sourceChain) {
|
|
40
|
-
const isAccountDeployed = await (0, accounts_1.isDeployed)(sourceChain, config);
|
|
41
|
-
if (!isAccountDeployed) {
|
|
42
|
-
await (0, accounts_1.deploySource)(sourceChain, config);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
38
|
+
async function sendTransactionInternal(config, sourceChain, targetChain, callInputs, gasLimit, initialTokenRequests, signers) {
|
|
45
39
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
46
40
|
// Across requires passing some value to repay the solvers
|
|
47
|
-
const tokenRequests = initialTokenRequests.length === 0
|
|
41
|
+
const tokenRequests = !initialTokenRequests || initialTokenRequests.length === 0
|
|
48
42
|
? [
|
|
49
43
|
{
|
|
50
44
|
address: viem_1.zeroAddress,
|
|
@@ -62,17 +56,19 @@ async function sendTransactionInternal(config, sourceChain, targetChain, calls,
|
|
|
62
56
|
await (0, smart_session_1.enableSmartSession)(sourceChain, config, withSession);
|
|
63
57
|
}
|
|
64
58
|
// Smart sessions require a UserOp flow
|
|
65
|
-
return await sendTransactionAsUserOp(config, sourceChain, targetChain,
|
|
59
|
+
return await sendTransactionAsUserOp(config, sourceChain, targetChain, callInputs, signers);
|
|
66
60
|
}
|
|
67
61
|
else {
|
|
68
|
-
return await sendTransactionAsIntent(config, sourceChain, targetChain,
|
|
62
|
+
return await sendTransactionAsIntent(config, sourceChain, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers);
|
|
69
63
|
}
|
|
70
64
|
}
|
|
71
|
-
async function sendTransactionAsUserOp(config, sourceChain, targetChain,
|
|
65
|
+
async function sendTransactionAsUserOp(config, sourceChain, targetChain, callInputs, signers) {
|
|
66
|
+
// Make sure the account is deployed
|
|
67
|
+
await (0, accounts_1.deploy)(config, sourceChain);
|
|
72
68
|
const withSession = signers?.type === 'session' ? signers.session : null;
|
|
73
69
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
74
70
|
chain: sourceChain,
|
|
75
|
-
transport: (0,
|
|
71
|
+
transport: (0, utils_1.createTransport)(sourceChain, config.provider),
|
|
76
72
|
});
|
|
77
73
|
const validatorAccount = await (0, utils_2.getValidatorAccount)(config, signers, publicClient, sourceChain);
|
|
78
74
|
if (!validatorAccount) {
|
|
@@ -82,6 +78,7 @@ async function sendTransactionAsUserOp(config, sourceChain, targetChain, calls,
|
|
|
82
78
|
if (withSession) {
|
|
83
79
|
await (0, smart_session_1.enableSmartSession)(targetChain, config, withSession);
|
|
84
80
|
}
|
|
81
|
+
const calls = (0, utils_2.parseCalls)(callInputs, targetChain.id);
|
|
85
82
|
const hash = await bundlerClient.sendUserOperation({
|
|
86
83
|
account: validatorAccount,
|
|
87
84
|
calls,
|
|
@@ -93,13 +90,13 @@ async function sendTransactionAsUserOp(config, sourceChain, targetChain, calls,
|
|
|
93
90
|
targetChain: targetChain.id,
|
|
94
91
|
};
|
|
95
92
|
}
|
|
96
|
-
async function sendTransactionAsIntent(config, sourceChain, targetChain,
|
|
97
|
-
const { intentRoute, hash: intentHash } = await (0, utils_2.prepareTransactionAsIntent)(config, sourceChain, targetChain,
|
|
93
|
+
async function sendTransactionAsIntent(config, sourceChain, targetChain, callInputs, gasLimit, tokenRequests, accountAddress, signers) {
|
|
94
|
+
const { intentRoute, hash: intentHash } = await (0, utils_2.prepareTransactionAsIntent)(config, sourceChain, targetChain, callInputs, gasLimit, tokenRequests, accountAddress);
|
|
98
95
|
if (!intentRoute) {
|
|
99
96
|
throw new error_1.OrderPathRequiredForIntentsError();
|
|
100
97
|
}
|
|
101
98
|
const signature = await (0, utils_2.signIntent)(config, sourceChain, targetChain, intentHash, signers);
|
|
102
|
-
return await (0, utils_2.submitIntentInternal)(config, sourceChain, targetChain, intentRoute.intentOp, signature
|
|
99
|
+
return await (0, utils_2.submitIntentInternal)(config, sourceChain, targetChain, intentRoute.intentOp, signature);
|
|
103
100
|
}
|
|
104
101
|
async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
105
102
|
const validStatuses = new Set([
|
|
@@ -125,9 +122,12 @@ async function waitForExecution(config, result, acceptsPreconfirmations) {
|
|
|
125
122
|
}
|
|
126
123
|
case 'userop': {
|
|
127
124
|
const targetChain = (0, registry_1.getChainById)(result.targetChain);
|
|
125
|
+
if (!targetChain) {
|
|
126
|
+
throw new Error(`Unsupported chain ID: ${result.targetChain}`);
|
|
127
|
+
}
|
|
128
128
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
129
129
|
chain: targetChain,
|
|
130
|
-
transport: (0,
|
|
130
|
+
transport: (0, utils_1.createTransport)(targetChain, config.provider),
|
|
131
131
|
});
|
|
132
132
|
const bundlerClient = (0, utils_1.getBundlerClient)(config, publicClient);
|
|
133
133
|
const receipt = await bundlerClient.waitForUserOperationReceipt({
|
|
@@ -158,7 +158,7 @@ async function deposit(config, chain, amount, tokenAddress) {
|
|
|
158
158
|
// ERC20 deposit
|
|
159
159
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
160
160
|
chain,
|
|
161
|
-
transport: (0,
|
|
161
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
162
162
|
});
|
|
163
163
|
const allowance = await publicClient.readContract({
|
|
164
164
|
address: tokenAddress,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { type Chain, type Hex } from 'viem';
|
|
2
|
-
import { ChainDigest, EnableSessionData, SmartSessionModeType } from '../modules/validators/smart-sessions';
|
|
2
|
+
import { type ChainDigest, type EnableSessionData, type SmartSessionModeType } from '../modules/validators/smart-sessions';
|
|
3
3
|
import type { RhinestoneAccountConfig, Session } from '../types';
|
|
4
4
|
interface SessionDetails {
|
|
5
5
|
permissionEnableHash: Hex;
|
|
@@ -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,
|
|
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;AAoBb,OAAO,EACL,KAAK,WAAW,EAEhB,KAAK,iBAAiB,EAGtB,KAAK,oBAAoB,EAC1B,MAAM,sCAAsC,CAAA;AAC7C,OAAO,KAAK,EAGV,uBAAuB,EACvB,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,uBAAuB,EAC/B,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,uBAAuB,EAC/B,OAAO,EAAE,OAAO,iBAqCjB;AAED,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,mBAAmB,EAAE,CAAA;AACrE,YAAY,EAAE,cAAc,EAAE,CAAA"}
|
|
@@ -13,7 +13,7 @@ const error_1 = require("./error");
|
|
|
13
13
|
async function getSessionDetails(config, sessions, sessionIndex, signature) {
|
|
14
14
|
const account = (0, accounts_1.getAccountProvider)(config);
|
|
15
15
|
const accountAddress = (0, accounts_1.getAddress)(config);
|
|
16
|
-
const sessionDetails = await getEnableSessionDetails(account.type, sessions, sessionIndex, accountAddress);
|
|
16
|
+
const sessionDetails = await getEnableSessionDetails(account.type, sessions, sessionIndex, accountAddress, config.provider);
|
|
17
17
|
const chain = sessions[sessionIndex].chain;
|
|
18
18
|
if (!chain) {
|
|
19
19
|
throw new error_1.SessionChainRequiredError();
|
|
@@ -27,21 +27,21 @@ async function getSessionDetails(config, sessions, sessionIndex, signature) {
|
|
|
27
27
|
(await (0, accounts_1.getPackedSignature)(config, config.owners, chain, validator, sessionDetails.permissionEnableHash));
|
|
28
28
|
return sessionDetails;
|
|
29
29
|
}
|
|
30
|
-
async function getEnableSessionDetails(accountType, sessions, sessionIndex, accountAddress) {
|
|
30
|
+
async function getEnableSessionDetails(accountType, sessions, sessionIndex, accountAddress, provider) {
|
|
31
31
|
const chainDigests = [];
|
|
32
32
|
const chainSessions = [];
|
|
33
33
|
for (const session of sessions) {
|
|
34
34
|
const permissionId = (0, validators_1.getPermissionId)(session);
|
|
35
|
-
const publicClient = (0, viem_1.createPublicClient)({
|
|
36
|
-
chain: session.chain,
|
|
37
|
-
transport: (0, viem_1.http)(),
|
|
38
|
-
});
|
|
39
35
|
const sessionChain = session.chain;
|
|
40
36
|
if (!sessionChain) {
|
|
41
37
|
throw new error_1.SessionChainRequiredError();
|
|
42
38
|
}
|
|
39
|
+
const publicClient = (0, viem_1.createPublicClient)({
|
|
40
|
+
chain: sessionChain,
|
|
41
|
+
transport: (0, utils_1.createTransport)(sessionChain, provider),
|
|
42
|
+
});
|
|
43
43
|
const sessionNonce = await getSessionNonce(publicClient, accountAddress, permissionId);
|
|
44
|
-
const sessionData = await (0, smart_sessions_1.getSessionData)(sessionChain, session);
|
|
44
|
+
const sessionData = await (0, smart_sessions_1.getSessionData)(sessionChain, session, provider);
|
|
45
45
|
const sessionDigest = await getSessionDigest(publicClient, accountAddress, sessionData, permissionId, validators_1.SMART_SESSION_MODE_ENABLE);
|
|
46
46
|
chainDigests.push({
|
|
47
47
|
chainId: BigInt(sessionChain.id),
|
|
@@ -74,7 +74,7 @@ async function getEnableSessionDetails(accountType, sessions, sessionIndex, acco
|
|
|
74
74
|
if (!sessionChain) {
|
|
75
75
|
throw new error_1.SessionChainRequiredError();
|
|
76
76
|
}
|
|
77
|
-
const sessionData = await (0, smart_sessions_1.getSessionData)(sessionChain, sessionToEnable);
|
|
77
|
+
const sessionData = await (0, smart_sessions_1.getSessionData)(sessionChain, sessionToEnable, provider);
|
|
78
78
|
return {
|
|
79
79
|
permissionEnableHash,
|
|
80
80
|
mode: validators_1.SMART_SESSION_MODE_ENABLE,
|
|
@@ -274,14 +274,14 @@ async function getSessionDigest(client, account, session, permissionId, mode) {
|
|
|
274
274
|
async function enableSmartSession(chain, config, session) {
|
|
275
275
|
const publicClient = (0, viem_1.createPublicClient)({
|
|
276
276
|
chain,
|
|
277
|
-
transport: (0,
|
|
277
|
+
transport: (0, utils_1.createTransport)(chain, config.provider),
|
|
278
278
|
});
|
|
279
279
|
const address = (0, accounts_1.getAddress)(config);
|
|
280
280
|
const isEnabled = await (0, validators_1.isSessionEnabled)(publicClient, address, (0, validators_1.getPermissionId)(session));
|
|
281
281
|
if (isEnabled) {
|
|
282
282
|
return;
|
|
283
283
|
}
|
|
284
|
-
const enableSessionCall = await (0, validators_1.getEnableSessionCall)(chain, session);
|
|
284
|
+
const enableSessionCall = await (0, validators_1.getEnableSessionCall)(chain, session, config.provider);
|
|
285
285
|
const trustedAttesters = await (0, modules_1.getTrustedAttesters)(publicClient, address);
|
|
286
286
|
const trustAttesterCall = trustedAttesters.length === 0 ? (0, modules_1.getTrustAttesterCall)(config) : undefined;
|
|
287
287
|
const smartAccount = await (0, accounts_1.getSmartAccount)(config, publicClient, chain);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { Address, Chain, Hex, PublicClient } from 'viem';
|
|
2
|
-
import { UserOperation } from 'viem/account-abstraction';
|
|
3
|
-
import { IntentOp, IntentRoute } from '../orchestrator';
|
|
4
|
-
import { Call, RhinestoneAccountConfig, SignerSet, TokenRequest, Transaction } from '../types';
|
|
1
|
+
import { type Address, type Chain, type Hex, type PublicClient } 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
5
|
type TransactionResult = {
|
|
6
6
|
type: 'userop';
|
|
7
7
|
hash: Hex;
|
|
@@ -33,11 +33,12 @@ interface SignedTransactionData extends PreparedTransactionData {
|
|
|
33
33
|
declare function prepareTransaction(config: RhinestoneAccountConfig, transaction: Transaction): Promise<PreparedTransactionData>;
|
|
34
34
|
declare function signTransaction(config: RhinestoneAccountConfig, preparedTransaction: PreparedTransactionData): Promise<SignedTransactionData>;
|
|
35
35
|
declare function submitTransaction(config: RhinestoneAccountConfig, signedTransaction: SignedTransactionData): Promise<TransactionResult>;
|
|
36
|
-
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain,
|
|
36
|
+
declare function prepareTransactionAsIntent(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, callInputs: CallInput[], gasLimit: bigint | undefined, tokenRequests: TokenRequest[], accountAddress: Address): Promise<IntentData>;
|
|
37
37
|
declare function signIntent(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, intentHash: Hex, signers?: SignerSet): Promise<`0x${string}`>;
|
|
38
38
|
declare function getOrchestratorByChain(chainId: number, apiKey: string): import("../orchestrator").Orchestrator;
|
|
39
|
-
declare function submitIntentInternal(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex
|
|
39
|
+
declare function submitIntentInternal(config: RhinestoneAccountConfig, sourceChain: Chain | undefined, targetChain: Chain, intentOp: IntentOp, signature: Hex): Promise<TransactionResult>;
|
|
40
40
|
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>;
|
|
41
|
-
|
|
41
|
+
declare function parseCalls(calls: CallInput[], chainId: number): Call[];
|
|
42
|
+
export { prepareTransaction, signTransaction, submitTransaction, getOrchestratorByChain, signIntent, prepareTransactionAsIntent, submitIntentInternal, getValidatorAccount, parseCalls, };
|
|
42
43
|
export type { IntentData, TransactionResult, PreparedTransactionData, SignedTransactionData, };
|
|
43
44
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,OAAO,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../../execution/utils.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,OAAO,EACZ,KAAK,KAAK,EAEV,KAAK,GAAG,EACR,KAAK,YAAY,EAGlB,MAAM,MAAM,CAAA;AACb,OAAO,EAGL,KAAK,aAAa,EACnB,MAAM,0BAA0B,CAAA;AAmBjC,OAAO,EAIL,KAAK,QAAQ,EACb,KAAK,WAAW,EAEjB,MAAM,iBAAiB,CAAA;AAMxB,OAAO,KAAK,EACV,IAAI,EACJ,SAAS,EAET,uBAAuB,EACvB,SAAS,EACT,YAAY,EACZ,WAAW,EACZ,MAAM,UAAU,CAAA;AAQjB,KAAK,iBAAiB,GAClB;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,WAAW,EAAE,MAAM,CAAA;IACnB,WAAW,EAAE,MAAM,CAAA;CACpB,GACD;IACE,IAAI,EAAE,QAAQ,CAAA;IACd,EAAE,EAAE,MAAM,CAAA;IACV,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,WAAW,EAAE,MAAM,CAAA;CACpB,CAAA;AAEL,UAAU,UAAU;IAClB,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,WAAW,EAAE,WAAW,CAAA;CACzB;AAED,UAAU,UAAU;IAClB,IAAI,EAAE,QAAQ,CAAA;IACd,IAAI,EAAE,GAAG,CAAA;IACT,MAAM,EAAE,aAAa,CAAA;CACtB;AAED,UAAU,uBAAuB;IAC/B,IAAI,EAAE,UAAU,GAAG,UAAU,CAAA;IAC7B,WAAW,EAAE,WAAW,CAAA;CACzB;AAED,UAAU,qBAAsB,SAAQ,uBAAuB;IAC7D,SAAS,EAAE,GAAG,CAAA;CACf;AAED,iBAAe,kBAAkB,CAC/B,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,WAAW,GACvB,OAAO,CAAC,uBAAuB,CAAC,CAsClC;AAED,iBAAe,eAAe,CAC5B,MAAM,EAAE,uBAAuB,EAC/B,mBAAmB,EAAE,uBAAuB,GAC3C,OAAO,CAAC,qBAAqB,CAAC,CAyBhC;AAED,iBAAe,iBAAiB,CAC9B,MAAM,EAAE,uBAAuB,EAC/B,iBAAiB,EAAE,qBAAqB,GACvC,OAAO,CAAC,iBAAiB,CAAC,CA2B5B;AAkED,iBAAe,0BAA0B,CACvC,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,KAAK,GAAG,SAAS,EAC9B,WAAW,EAAE,KAAK,EAClB,UAAU,EAAE,SAAS,EAAE,EACvB,QAAQ,EAAE,MAAM,GAAG,SAAS,EAC5B,aAAa,EAAE,YAAY,EAAE,EAC7B,cAAc,EAAE,OAAO,uBAkDxB;AAED,iBAAe,UAAU,CACvB,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,KAAK,GAAG,SAAS,EAC9B,WAAW,EAAE,KAAK,EAClB,UAAU,EAAE,GAAG,EACf,OAAO,CAAC,EAAE,SAAS,0BAwBpB;AA4FD,iBAAS,sBAAsB,CAAC,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,0CAK9D;AAED,iBAAe,oBAAoB,CACjC,MAAM,EAAE,uBAAuB,EAC/B,WAAW,EAAE,KAAK,GAAG,SAAS,EAC9B,WAAW,EAAE,KAAK,EAClB,QAAQ,EAAE,QAAQ,EAClB,SAAS,EAAE,GAAG,8BAkBf;AAED,iBAAe,mBAAmB,CAChC,MAAM,EAAE,uBAAuB,EAC/B,OAAO,EAAE,SAAS,GAAG,SAAS,EAC9B,YAAY,EAAE,YAAY,EAC1B,KAAK,EAAE,KAAK,yKA6Bb;AA0FD,iBAAS,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,EAAE,CAM/D;AAED,OAAO,EACL,kBAAkB,EAClB,eAAe,EACf,iBAAiB,EACjB,sBAAsB,EACtB,UAAU,EACV,0BAA0B,EAC1B,oBAAoB,EACpB,mBAAmB,EACnB,UAAU,GACX,CAAA;AACD,YAAY,EACV,UAAU,EACV,iBAAiB,EACjB,uBAAuB,EACvB,qBAAqB,GACtB,CAAA"}
|