Skip to content

Commit ce95cf3

Browse files
committed
Upgrade viem peer dependency
1 parent 65cd885 commit ce95cf3

36 files changed

Lines changed: 228 additions & 158 deletions

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@
6060
"prettier": "^3.3.3",
6161
"turbo": "latest",
6262
"typescript": "5.0.4",
63-
"viem": "2.21.55",
63+
"viem": "^2.31.4",
6464
"webauthn-p256": "^0.0.10"
6565
},
6666
"packageManager": "yarn@4.2.2",

packages/delegation-toolkit/package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,9 +157,9 @@
157157
"tsconfig-paths": "^4.2.0",
158158
"tsup": "^7.2.0",
159159
"typescript": "5.0.4",
160-
"viem": "2.21.55"
160+
"viem": "2.31.4"
161161
},
162162
"peerDependencies": {
163-
"viem": ">=2.18.2 <3.0.0"
163+
"viem": "^2.31.4"
164164
}
165165
}

packages/delegation-toolkit/src/types.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,9 @@ import type {
88
Account,
99
Address,
1010
Chain,
11-
Client,
1211
Hex,
1312
OneOf,
13+
PublicClient,
1414
Transport,
1515
WalletClient,
1616
} from 'viem';
@@ -143,7 +143,7 @@ export type DeployParams<TImplementation extends Implementation> = {
143143
export type ToMetaMaskSmartAccountParameters<
144144
TImplementation extends Implementation,
145145
> = {
146-
client: Client;
146+
client: PublicClient;
147147
implementation: TImplementation;
148148
signatory: SignatoryConfigByImplementation<TImplementation>;
149149
environment?: DeleGatorEnvironment;

packages/delegation-toolkit/test/experimental/erc7710RedeemDelegationAction.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import type {
1010
WalletClient,
1111
} from 'viem';
1212
import {
13-
createClient,
13+
createPublicClient,
1414
createWalletClient,
1515
custom,
1616
encodeFunctionData,
@@ -61,7 +61,7 @@ describe('erc7710RedeemDelegationAction', () => {
6161
} as any as DeleGatorEnvironment);
6262

6363
metaMaskSmartAccount = await toMetaMaskSmartAccount({
64-
client: createClient({
64+
client: createPublicClient({
6565
transport: await createHardhatTransport(),
6666
chain: publicClient.chain,
6767
}),

packages/delegation-toolkit/test/toMetaMaskSmartAccount.test.ts

Lines changed: 10 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
11
import { expect } from 'chai';
22
import hre from 'hardhat';
3-
import type { Account, Client, PublicClient, WalletClient } from 'viem';
4-
import {
5-
createClient,
6-
createPublicClient,
7-
hashTypedData,
8-
recoverAddress,
9-
} from 'viem';
3+
import type { Account, PublicClient, WalletClient } from 'viem';
4+
import { createPublicClient, hashTypedData, recoverAddress } from 'viem';
105
import { toPackedUserOperation } from 'viem/account-abstraction';
116
import { generatePrivateKey, privateKeyToAccount } from 'viem/accounts';
127
import { hardhat as chain } from 'viem/chains';
@@ -22,7 +17,6 @@ import type { DeleGatorEnvironment, MetaMaskSmartAccount } from '../src/types';
2217
import { SIGNABLE_USER_OP_TYPED_DATA } from '../src/userOp';
2318

2419
describe('MetaMaskSmartAccount', () => {
25-
let client: Client;
2620
let publicClient: PublicClient;
2721
let walletClient: WalletClient;
2822
let alice: Account;
@@ -31,7 +25,6 @@ describe('MetaMaskSmartAccount', () => {
3125

3226
beforeEach(async () => {
3327
const transport = await createHardhatTransport();
34-
client = createClient({ transport, chain });
3528
publicClient = createPublicClient({ transport, chain });
3629
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
3730
walletClient = (await hre.viem.getWalletClients())[0]!;
@@ -49,7 +42,7 @@ describe('MetaMaskSmartAccount', () => {
4942
describe('toMetaMaskSmartAccount()', () => {
5043
it('should create a MetaMaskSmartAccount for Hybrid implementation', async () => {
5144
const smartAccount = await toMetaMaskSmartAccount({
52-
client,
45+
client: publicClient,
5346
implementation: Implementation.Hybrid,
5447
deployParams: [alice.address, [], [], []],
5548
deploySalt: '0x0',
@@ -85,7 +78,7 @@ describe('MetaMaskSmartAccount', () => {
8578

8679
it('should create a MetaMaskSmartAccount for MultiSig implementation', async () => {
8780
const smartAccount = await toMetaMaskSmartAccount({
88-
client,
81+
client: publicClient,
8982
implementation: Implementation.MultiSig,
9083
deployParams: [[alice.address, bob.address], 2n],
9184
deploySalt: '0x0',
@@ -121,7 +114,7 @@ describe('MetaMaskSmartAccount', () => {
121114

122115
it('should create a MetaMaskSmartAccount for Stateless7702 implementation with existing address', async () => {
123116
const smartAccount = await toMetaMaskSmartAccount({
124-
client,
117+
client: publicClient,
125118
implementation: Implementation.Stateless7702,
126119
address: alice.address,
127120
signatory: { account: alice },
@@ -141,7 +134,7 @@ describe('MetaMaskSmartAccount', () => {
141134
it('should throw error when creating Stateless7702 without address (counterfactual not supported)', async () => {
142135
await expect(
143136
toMetaMaskSmartAccount({
144-
client,
137+
client: publicClient,
145138
implementation: Implementation.Stateless7702,
146139
signatory: { account: alice },
147140
environment,
@@ -154,7 +147,7 @@ describe('MetaMaskSmartAccount', () => {
154147
it('should throw an error for unsupported implementation', async () => {
155148
await expect(
156149
toMetaMaskSmartAccount({
157-
client,
150+
client: publicClient,
158151
implementation: 99 as any as Implementation,
159152
deployParams: [alice.address, [], [], []],
160153
deploySalt: '0x0',
@@ -167,7 +160,7 @@ describe('MetaMaskSmartAccount', () => {
167160
it('should have a default for MetaMaskSmartAccount generic TImplementation parameter', async () => {
168161
// MetaMaskSmartAccount requires a generic parameter, and defaults to `Implementation` which covers all implementations
169162
const smartAccount: MetaMaskSmartAccount = await toMetaMaskSmartAccount({
170-
client,
163+
client: publicClient,
171164
implementation: Implementation.MultiSig,
172165
deployParams: [[alice.address, bob.address], 2n],
173166
deploySalt: '0x0',
@@ -183,7 +176,7 @@ describe('MetaMaskSmartAccount', () => {
183176
// this is a special case test, because as of Framework 1.2, user operations are signed via typed data
184177
it('should sign a user operation', async () => {
185178
const smartAccount = await toMetaMaskSmartAccount({
186-
client,
179+
client: publicClient,
187180
implementation: Implementation.MultiSig,
188181
deployParams: [[alice.address, bob.address], 2n],
189182
deploySalt: '0x0',
@@ -229,7 +222,7 @@ describe('MetaMaskSmartAccount', () => {
229222

230223
it('should sign a user operation for Stateless7702 implementation', async () => {
231224
const smartAccount = await toMetaMaskSmartAccount({
232-
client,
225+
client: publicClient,
233226
implementation: Implementation.Stateless7702,
234227
address: alice.address,
235228
signatory: { account: alice },

packages/delegation-toolkit/test/utils.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@ import type {
77
WalletClient,
88
PublicClient,
99
Account,
10-
Client,
1110
} from 'viem';
1211
import {
1312
generatePrivateKey,
@@ -47,7 +46,7 @@ export const randomBytes = (byteLength: number): Hex => {
4746

4847
export const counterfactualAccountConfig: ToMetaMaskSmartAccountParameters<Implementation.Hybrid> =
4948
{
50-
client: {} as Client,
49+
client: {} as PublicClient,
5150
implementation: Implementation.Hybrid,
5251
deployParams: [
5352
OWNER_ACCOUNT.address,
@@ -61,7 +60,7 @@ export const counterfactualAccountConfig: ToMetaMaskSmartAccountParameters<Imple
6160

6261
export const multiSigAccountConfig: ToMetaMaskSmartAccountParameters<Implementation.MultiSig> =
6362
{
64-
client: {} as Client,
63+
client: {} as PublicClient,
6564
implementation: Implementation.MultiSig,
6665
deployParams: [[OWNER_ACCOUNT.address], 1n],
6766
deploySalt: SALT,
@@ -70,7 +69,7 @@ export const multiSigAccountConfig: ToMetaMaskSmartAccountParameters<Implementat
7069

7170
export const deployedAccountConfig: ToMetaMaskSmartAccountParameters<Implementation.Hybrid> =
7271
{
73-
client: {} as Client,
72+
client: {} as PublicClient,
7473
implementation: Implementation.Hybrid,
7574
address: DEPLOYED_ADDRESS,
7675
signatory: { account: OWNER_ACCOUNT },

packages/delegator-e2e/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,6 @@
2020
"teardown": "docker compose down"
2121
},
2222
"peerDependencies": {
23-
"viem": ">=2.18.2 <3.0.0"
23+
"viem": "^2.31.4"
2424
}
2525
}

packages/delegator-e2e/test/caveats/allowedCalldata.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ const runTest_expectFailure = async (
249249
],
250250
...gasPrice,
251251
}),
252-
).rejects.toThrow(expectedError);
252+
).rejects.toThrow(Buffer.from(expectedError).toString('hex'));
253253

254254
const counterAfter = await aliceCounter.read.count?.();
255255
expect(counterAfter, 'Expected count to remain 0n').toEqual(0n);

packages/delegator-e2e/test/caveats/allowedMethods.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ const runTest_expectFailure = async (
249249
],
250250
...gasPrice,
251251
}),
252-
).rejects.toThrow(expectedError);
252+
).rejects.toThrow(Buffer.from(expectedError).toString('hex'));
253253

254254
const counterAfter = await aliceCounter.read.count();
255255
expect(counterAfter, 'Expected count to remain 0n').toEqual(0n);

packages/delegator-e2e/test/caveats/allowedTargets.test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@ const runTest_expectFailure = async (
219219
],
220220
...gasPrice,
221221
}),
222-
).rejects.toThrow(expectedError);
222+
).rejects.toThrow(Buffer.from(expectedError).toString('hex'));
223223

224224
const counterAfter = await aliceCounter.read.count();
225225
expect(counterAfter, 'Expected count to remain 0n').toEqual(0n);

0 commit comments

Comments
 (0)