Skip to content

Commit

Permalink
Merge pull request #664 from nevermined-io/feat/back-to-permissionles…
Browse files Browse the repository at this point in the history
…s-v6

feat: revert to permissionless v6
  • Loading branch information
eruizgar91 committed May 14, 2024
2 parents 1d1a29a + 6445e01 commit c05655f
Show file tree
Hide file tree
Showing 6 changed files with 57 additions and 20 deletions.
37 changes: 37 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,43 @@ All notable changes to this project will be documented in this file. Dates are d

Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog).

#### [v3.0.6-rc2](https://github.com/nevermined-io/sdk-js/compare/v3.0.6-rc1...v3.0.6-rc2)

> 14 May 2024
- Automated CHANGELOG.md update [`715afd0`](https://github.com/nevermined-io/sdk-js/commit/715afd0304610f1bb1c8d9427fa67640f95137f7)
- feat: use 0x046d0698926aFa3ab6D6591f03063488F3Fb4327 nodeAddress [`b56546d`](https://github.com/nevermined-io/sdk-js/commit/b56546d87f0287a76f8d16705a4ff8ab66d1ee79)

#### [v3.0.6-rc1](https://github.com/nevermined-io/sdk-js/compare/v3.0.6-rc0...v3.0.6-rc1)

> 14 May 2024
- feat: revert to permissionless v6 [`e860516`](https://github.com/nevermined-io/sdk-js/commit/e860516b2d35b8fce7414e5782f00d89ca230b67)

#### [v3.0.6-rc0](https://github.com/nevermined-io/sdk-js/compare/v3.0.5...v3.0.6-rc0)

> 14 May 2024
- feat: add more logs [`b618b0d`](https://github.com/nevermined-io/sdk-js/commit/b618b0d50ac1b9f8a9b56fd02220bb88736ec60a)
- Automated CHANGELOG.md update [`b24aae6`](https://github.com/nevermined-io/sdk-js/commit/b24aae609317d48c6c58640ddb86a2c92267edfe)
- feat: add more logs [`bc3e8f0`](https://github.com/nevermined-io/sdk-js/commit/bc3e8f02aa596c8a6ab2ffd29a3128e48558740d)

#### [v3.0.5](https://github.com/nevermined-io/sdk-js/compare/v3.0.5-rc0...v3.0.5)

> 13 May 2024
- feat: bump to node v20 [`b4a1a4b`](https://github.com/nevermined-io/sdk-js/commit/b4a1a4be8aef2a47d9e97237e393db947bb715cd)
- Automated CHANGELOG.md update [`b5ed850`](https://github.com/nevermined-io/sdk-js/commit/b5ed850a4a519cad96e47a57f9f2350c155c5432)
- feat: revert node v20 [`ce0db47`](https://github.com/nevermined-io/sdk-js/commit/ce0db47064699de7850c3de8318bce806e4c557f)

#### [v3.0.5-rc0](https://github.com/nevermined-io/sdk-js/compare/v3.0.4...v3.0.5-rc0)

> 13 May 2024
- feat: remove no needed dependency [`f52b5e3`](https://github.com/nevermined-io/sdk-js/commit/f52b5e3454aa27856754003d713c05c414f55405)
- feat: update to use session keys with permissionless v7 [`7c25418`](https://github.com/nevermined-io/sdk-js/commit/7c25418ebae5d929f968827c280a1eee9905fedf)
- feat: update types [`e8a9842`](https://github.com/nevermined-io/sdk-js/commit/e8a9842831b8773a7075121e19cea7c0c660bcbb)

#### [v3.0.4](https://github.com/nevermined-io/sdk-js/compare/v3.0.3...v3.0.4)

> 10 May 2024
Expand Down
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",
"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
4 changes: 2 additions & 2 deletions src/nevermined/resources/AppNetworks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class AppDeploymentStaging extends NeverminedAppOptions {
marketplaceUri = 'https://marketplace-api.staging.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.staging.nevermined.app'
neverminedNodeAddress = '0x5838B5512cF9f12FE9f2beccB20eb47211F9B0bc'
neverminedNodeAddress = '0x046d0698926aFa3ab6D6591f03063488F3Fb4327'
verbose = true
gasMultiplier = 0
gasPriceMultiplier = 0
Expand All @@ -45,7 +45,7 @@ export class AppDeploymentTesting extends NeverminedAppOptions {
marketplaceUri = 'https://marketplace-api.testing.nevermined.app'
graphHttpUri = 'https://api.thegraph.com/subgraphs/name/nevermined-io/public'
neverminedNodeUri = 'https://node.testing.nevermined.app'
neverminedNodeAddress = '0x5838B5512cF9f12FE9f2beccB20eb47211F9B0bc'
neverminedNodeAddress = '0x046d0698926aFa3ab6D6591f03063488F3Fb4327'
verbose = true
gasMultiplier = 0
gasPriceMultiplier = 0
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 c05655f

Please sign in to comment.