Skip to content

Commit

Permalink
feat: revert to permissionless v6
Browse files Browse the repository at this point in the history
  • Loading branch information
eruizgar91 committed May 14, 2024
1 parent 1d1a29a commit e860516
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 18 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@nevermined-io/sdk",
"version": "3.0.4",
"version": "3.0.6-rc1",
"description": "Javascript SDK for connecting with Nevermined Data Platform ",
"main": "./dist/node/sdk.js",
"typings": "./dist/node/sdk.d.ts",
Expand Down
4 changes: 2 additions & 2 deletions src/keeper/contracts/ContractBase.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
getInputsOfFunctionFormatted,
getSignatureOfFunction,
} from '../../nevermined/utils/BlockchainViemUtils'
import { ENTRYPOINT_ADDRESS_V07, bundlerActions } from 'permissionless'
import { ENTRYPOINT_ADDRESS_V06, bundlerActions } from 'permissionless'

export abstract class ContractBase extends Instantiable {
public readonly contractName: string
Expand Down Expand Up @@ -214,7 +214,7 @@ export abstract class ContractBase extends Instantiable {
}

// @ts-ignore
const bundlerClient = kernelClient.extend(bundlerActions(ENTRYPOINT_ADDRESS_V07))
const bundlerClient = kernelClient.extend(bundlerActions(ENTRYPOINT_ADDRESS_V06))
const txReceipt = await bundlerClient.waitForUserOperationReceipt({ hash: txHash })

if (progress) {
Expand Down
6 changes: 3 additions & 3 deletions src/models/NvmAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export class NvmAccount {
public babySecret?: string
private accountSigner?: Account | PrivateKeyAccount
private kernelClient?: KernelAccountClient<
'0x0000000071727De22E5E9d8BAf0edAc6f37da032',
'0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
Transport,
Chain,
any
Expand Down Expand Up @@ -55,7 +55,7 @@ export class NvmAccount {
*/
static async fromZeroDevSigner(
kernelClient: KernelAccountClient<
'0x0000000071727De22E5E9d8BAf0edAc6f37da032',
'0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
Transport,
Chain,
any
Expand All @@ -70,7 +70,7 @@ export class NvmAccount {

static fromZeroDevSessionKey(
kernelClient: KernelAccountClient<
'0x0000000071727De22E5E9d8BAf0edAc6f37da032',
'0x5FF137D4b0FDCD49DcA30c7CF57E578a026d2789',
Transport,
Chain,
any
Expand Down
24 changes: 12 additions & 12 deletions src/nevermined/utils/BlockchainViemUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
serializeSessionKeyAccount,
signerToSessionKeyValidator,
} from '@zerodev/session-key'
import { ENTRYPOINT_ADDRESS_V07 } from 'permissionless'
import { ENTRYPOINT_ADDRESS_V06 } from 'permissionless'
import { EntryPoint } from 'permissionless/types'
import {
Abi,
Expand Down Expand Up @@ -390,33 +390,33 @@ export async function createKernelClient(signer: any, chainId: number, zeroDevPr

const ecdsaValidator = await signerToEcdsaValidator(publicClient, {
signer,
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
})

const account = await createKernelAccount(publicClient, {
plugins: {
sudo: ecdsaValidator,
},
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
})

return createKernelAccountClient({
account,
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
chain: getChain(chainId),
bundlerTransport: http(`https://rpc.zerodev.app/api/v2/bundler/${zeroDevProjectId}`),
middleware: {
sponsorUserOperation: async ({ userOperation }) => {
const paymasterClient = createZeroDevPaymasterClient({
chain: getChain(chainId),
transport: http(`https://rpc.zerodev.app/api/v2/paymaster/${zeroDevProjectId}`),
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
})
const _userOperation =
userOperation as SponsorUserOperationParameters<EntryPoint>['userOperation']
return paymasterClient.sponsorUserOperation({
userOperation: _userOperation,
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
})
},
},
Expand All @@ -425,14 +425,14 @@ export async function createKernelClient(signer: any, chainId: number, zeroDevPr

export async function createSessionKey(signer: any, publicClient: any, permissions: any[]) {
const ecdsaValidator = await signerToEcdsaValidator(publicClient, {
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
signer,
})
const sessionPrivateKey = generatePrivateKey()
const sessionKeySigner = privateKeyToAccount(sessionPrivateKey)

const sessionKeyValidator = await signerToSessionKeyValidator(publicClient, {
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
signer: sessionKeySigner,
validatorData: {
paymaster: oneAddress,
Expand All @@ -442,7 +442,7 @@ export async function createSessionKey(signer: any, publicClient: any, permissio
},
})
const sessionKeyAccount = await createKernelAccount(publicClient, {
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
plugins: {
sudo: ecdsaValidator,
regular: sessionKeyValidator,
Expand All @@ -459,16 +459,16 @@ export async function getSessionKey(
const chainId = await publicClient.getChainId()
const sessionKeyAccount = await deserializeSessionKeyAccount(
publicClient,
ENTRYPOINT_ADDRESS_V07,
ENTRYPOINT_ADDRESS_V06,
serializedSessionKey,
)
const kernelPaymaster = createZeroDevPaymasterClient({
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
chain: getChain(chainId),
transport: http(`https://rpc.zerodev.app/api/v2/paymaster/${zeroDevProjectId}`),
})
const kernelClient = createKernelAccountClient({
entryPoint: ENTRYPOINT_ADDRESS_V07,
entryPoint: ENTRYPOINT_ADDRESS_V06,
account: sessionKeyAccount,
chain: getChain(chainId),
bundlerTransport: http(`https://rpc.zerodev.app/api/v2/bundler/${zeroDevProjectId}`),
Expand Down

0 comments on commit e860516

Please sign in to comment.