Skip to content

Commit 8ff95b0

Browse files
authored
update: 7579 actions (#90)
1 parent 2b0d694 commit 8ff95b0

File tree

3 files changed

+59
-14
lines changed

3 files changed

+59
-14
lines changed

packages/sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
"name": "yoanslvy"
77
}
88
],
9-
"version": "1.0.12",
9+
"version": "1.0.13",
1010
"description": "SDK Cometh Connect 4337",
1111
"repository": "https://github.com/cometh-hq/connect-sdk-4337.git",
1212
"keywords": [

packages/sdk/src/core/actions/accounts/7579/setFallbackTo7579.ts

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
getSmartSessionsValidator,
1212
} from "@rhinestone/module-sdk";
1313
import { isSmartAccountDeployed } from "permissionless";
14+
import { isModuleInstalled } from "permissionless/actions/erc7579";
1415

1516
import { sendTransaction } from "permissionless/actions/smartAccount";
1617
import {
@@ -23,6 +24,7 @@ import {
2324
type Transport,
2425
createPublicClient,
2526
} from "viem";
27+
import type { SmartAccount } from "viem/account-abstraction";
2628
import { encodeFunctionData, getAction, parseAbi } from "viem/utils";
2729

2830
export async function setFallbackTo7579<
@@ -70,6 +72,32 @@ export async function setFallbackTo7579<
7072

7173
const smartSessions = getSmartSessionsValidator({});
7274

75+
let isSessionValidatorInstalled: boolean;
76+
77+
try {
78+
isSessionValidatorInstalled = await getAction(
79+
client,
80+
isModuleInstalled,
81+
"isModuleInstalled"
82+
)({
83+
type: smartSessions.type,
84+
address: smartSessions.address,
85+
context: smartSessions.initData,
86+
account: client.account as SmartAccount,
87+
});
88+
} catch {
89+
isSessionValidatorInstalled = false;
90+
}
91+
92+
const validators = !isSessionValidatorInstalled
93+
? [
94+
{
95+
module: smartSessions.address,
96+
initData: smartSessions.initData,
97+
},
98+
]
99+
: [];
100+
73101
const txs = [
74102
{
75103
to: LAUNCHPAD_ADDRESS,
@@ -81,12 +109,7 @@ export async function setFallbackTo7579<
81109
functionName: "addSafe7579",
82110
args: [
83111
SAFE_7579_ADDRESS,
84-
[
85-
{
86-
module: smartSessions.address,
87-
initData: smartSessions.initData,
88-
},
89-
],
112+
validators,
90113
[],
91114
[],
92115
[],

packages/sdk/src/core/modules/sessionKey/decorators/grantPermission.ts

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,9 @@ import {
1111
RHINESTONE_ATTESTER_ADDRESS,
1212
getSmartSessionsValidator,
1313
} from "@rhinestone/module-sdk";
14+
import { isModuleInstalled } from "permissionless/actions/erc7579";
1415
import type { Chain, Client, Hex, PublicClient, Transport } from "viem";
15-
import { sendUserOperation } from "viem/account-abstraction";
16+
import { type SmartAccount, sendUserOperation } from "viem/account-abstraction";
1617
import { encodeFunctionData, getAction, parseAbi } from "viem/utils";
1718
import type { Call } from "../types";
1819
import { preparePermission } from "./preparePermission";
@@ -71,6 +72,32 @@ export async function grantPermission<
7172
if (!is7579FallbackSet) {
7273
const smartSessions = getSmartSessionsValidator({});
7374

75+
let isSessionValidatorInstalled: boolean;
76+
77+
try {
78+
isSessionValidatorInstalled = await getAction(
79+
client,
80+
isModuleInstalled,
81+
"isModuleInstalled"
82+
)({
83+
type: smartSessions.type,
84+
address: smartSessions.address,
85+
context: smartSessions.initData,
86+
account: client.account as SmartAccount,
87+
});
88+
} catch {
89+
isSessionValidatorInstalled = false;
90+
}
91+
92+
const validators = !isSessionValidatorInstalled
93+
? [
94+
{
95+
module: smartSessions.address,
96+
initData: smartSessions.initData,
97+
},
98+
]
99+
: [];
100+
74101
calls.unshift({
75102
to: LAUNCHPAD_ADDRESS,
76103
data: encodeFunctionData({
@@ -81,12 +108,7 @@ export async function grantPermission<
81108
functionName: "addSafe7579",
82109
args: [
83110
SAFE_7579_ADDRESS,
84-
[
85-
{
86-
module: smartSessions.address,
87-
initData: smartSessions.initData,
88-
},
89-
],
111+
validators,
90112
[],
91113
[],
92114
[],

0 commit comments

Comments
 (0)