Skip to content

Commit 49eaccd

Browse files
authored
Enable gas estimation and paymaster of user-op builder service for updated smart-session module (#705)
* add getDummySignature impl * chore:run prettier * update @biconomy/permission-context-builder deps * use chain specific module address * add base-sepolia to supported chains data * chores: run prettier * update @rhinestone/module-kit deps * use SMART_SESSION_ADDRESS from module-sdk * impl ContextBuilderUtil using module-sdk * enable safeSmartAccount on sepolia and baseSepolia * added smart-session support on base-sepolia * attest and install modules in single userOp * chores: run prettier * update co-signer handling and url * chores: move constants to single source * return smartAccount on allowed chains * display smartAccount on requested chains only * chores:run prettier
1 parent c062f18 commit 49eaccd

24 files changed

+1140
-615
lines changed

advanced/wallets/react-wallet-v2/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
"prettier:write": "prettier --write '**/*.{js,ts,jsx,tsx}'"
1111
},
1212
"dependencies": {
13-
"@biconomy/permission-context-builder": "^1.0.9",
1413
"@cosmjs/amino": "0.32.3",
1514
"@cosmjs/encoding": "0.32.3",
1615
"@cosmjs/proto-signing": "0.32.3",
@@ -29,7 +28,7 @@
2928
"@nextui-org/react": "1.0.8-beta.5",
3029
"@polkadot/keyring": "^10.1.2",
3130
"@polkadot/types": "^9.3.3",
32-
"@rhinestone/module-sdk": "0.1.2",
31+
"@rhinestone/module-sdk": "0.1.16",
3332
"@solana/web3.js": "1.89.2",
3433
"@taquito/signer": "^15.1.0",
3534
"@taquito/taquito": "^15.1.0",
@@ -71,4 +70,4 @@
7170
"prettier": "2.6.2",
7271
"typescript": "5.2.2"
7372
}
74-
}
73+
}

advanced/wallets/react-wallet-v2/src/consts/smartAccounts.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
import { KernelSmartAccountLib } from '@/lib/smart-accounts/KernelSmartAccountLib'
22
import { SafeSmartAccountLib } from '@/lib/smart-accounts/SafeSmartAccountLib'
33
import { getAddress } from 'viem'
4-
import { goerli, polygonMumbai, sepolia } from 'viem/chains'
4+
import { baseSepolia, goerli, polygonMumbai, sepolia } from 'viem/chains'
55

66
// Types
7-
export const allowedChains = [sepolia, polygonMumbai, goerli]
7+
export const allowedChains = [sepolia, polygonMumbai, goerli, baseSepolia]
88
// build chains so I can access them by id
99
export const chains = allowedChains.reduce((acc, chain) => {
1010
acc[chain.id] = chain

advanced/wallets/react-wallet-v2/src/data/EIP155Data.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,15 @@ export const EIP155_TEST_CHAINS: Record<string, EIP155Chain> = {
9999
namespace: 'eip155',
100100
smartAccountEnabled: true
101101
},
102+
'eip155:84532': {
103+
chainId: 84532,
104+
name: 'Base Sepolia',
105+
logo: '/chain-logos/eip155-1.png',
106+
rgb: '99, 125, 234',
107+
rpc: 'https://sepolia.base.org',
108+
namespace: 'eip155',
109+
smartAccountEnabled: true
110+
},
102111
'eip155:43113': {
103112
chainId: 43113,
104113
name: 'Avalanche Fuji',
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,82 @@
1+
import { Address } from 'viem'
2+
13
/**
24
* EIP7715Method
35
*/
46
export const EIP7715_METHOD = {
57
WALLET_GRANT_PERMISSIONS: 'wallet_grantPermissions'
68
}
9+
10+
// `data` is not necessary for this signer type as the wallet is both the signer and grantor of these permissions
11+
export type WalletSigner = {
12+
type: 'wallet'
13+
data: {}
14+
}
15+
16+
// A signer representing a single key.
17+
// `id` is a did:key identifier and can therefore represent both Secp256k1 or Secp256r1 keys, among other key types.
18+
export type KeySigner = {
19+
type: 'key'
20+
data: {
21+
id: string
22+
}
23+
}
24+
25+
// A signer representing a multisig signer.
26+
// Each element of `ids` is a did:key identifier just like the `key` signer.
27+
export type MultiKeySigner = {
28+
type: 'keys'
29+
data: {
30+
ids: string[]
31+
address?: Address
32+
}
33+
}
34+
35+
// An account that can be granted with permissions as in ERC-7710.
36+
export type AccountSigner = {
37+
type: 'account'
38+
data: {
39+
id: `0x${string}`
40+
}
41+
}
42+
43+
export enum SignerType {
44+
EOA,
45+
PASSKEY
46+
}
47+
48+
export type Signer = {
49+
type: SignerType
50+
data: string
51+
}
52+
53+
export type Permission = {
54+
type: PermissionType
55+
policies: Policy[]
56+
required: boolean
57+
data: any
58+
}
59+
export type Policy = {
60+
type: PolicyType
61+
data: any
62+
}
63+
export type PermissionType =
64+
| 'native-token-transfer'
65+
| 'erc20-token-transfer'
66+
| 'erc721-token-transfer'
67+
| 'erc1155-token-transfer'
68+
| {
69+
custom: any
70+
}
71+
export type PolicyType =
72+
| 'gas-limit'
73+
| 'call-limit'
74+
| 'rate-limit'
75+
| 'spent-limit'
76+
| 'value-limit'
77+
| 'time-frame'
78+
| 'uni-action'
79+
| 'simpler-signer'
80+
| {
81+
custom: any
82+
}

advanced/wallets/react-wallet-v2/src/data/ERC7579ModuleData.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { smartSessionAddress } from '@biconomy/permission-context-builder'
21
import { ModuleType } from '@rhinestone/module-sdk'
32
//Note: ES6 syntax dont work for this package
43
const {
4+
SMART_SESSIONS_ADDRESS,
55
MULTI_FACTOR_VALIDATOR_ADDRESS,
66
OWNABLE_VALIDATOR_ADDRESS,
77
WEBAUTHN_VALIDATOR_ADDRESS,
@@ -31,7 +31,7 @@ export const supportedModules: Module[] = [
3131
name: 'Permission Validator',
3232
type: 'validator',
3333
url: '/permission-validator',
34-
moduleAddress: smartSessionAddress,
34+
moduleAddress: SMART_SESSIONS_ADDRESS,
3535
description: `The Permission Validator module is a module that allows DApp to request permissions from a wallet in order to execute transactions on users's behalf that is scoped with permissions`,
3636
moduleData: '0x'
3737
},

advanced/wallets/react-wallet-v2/src/hooks/useSmartAccounts.ts

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { EIP155Chain } from '@/data/EIP155Data'
12
import SettingsStore from '@/store/SettingsStore'
23
import {
34
createOrRestoreBiconomySmartAccount,
@@ -51,8 +52,28 @@ export default function useSmartAccounts() {
5152
return accounts
5253
}
5354

55+
const getAvailableSmartAccountsOnNamespaceChains = (chains: string[] | undefined) => {
56+
if (!smartAccountEnabled || chains === undefined) {
57+
return []
58+
}
59+
const accounts = []
60+
for (const [key, lib] of Object.entries(smartAccountWallets)) {
61+
accounts.push({
62+
address: key.split(':')[1],
63+
type: lib.type,
64+
chain: lib.chain
65+
})
66+
}
67+
68+
const filteredAccounts = accounts.filter(account =>
69+
chains.some(chain => chain && parseInt(chain.split(':')[1]) === account.chain.id)
70+
)
71+
return filteredAccounts
72+
}
73+
5474
return {
5575
initializeSmartAccounts,
56-
getAvailableSmartAccounts
76+
getAvailableSmartAccounts,
77+
getAvailableSmartAccountsOnNamespaceChains
5778
}
5879
}

0 commit comments

Comments
 (0)