diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b6f86078..b27787192 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1709,7 +1709,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 2 May 2022 -- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) +- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) - Adding v0.19.21 Changelog updates [`c93cdc5`](https://github.com/nevermined-io/sdk-js/commit/c93cdc55f139a43db4130ccb0f80924d2645a931) #### [v0.19.21](https://github.com/nevermined-io/sdk-js/compare/v0.19.20...v0.19.21) @@ -1972,7 +1972,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). > 18 January 2022 -- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) +- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) - [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183) - Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177) - Adding v0.17.2 Changelog updates [`5eddda4`](https://github.com/nevermined-io/sdk-js/commit/5eddda43954e013e6e6f7344c9a877d801aacb5c) @@ -2478,7 +2478,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Feature/sync develop [`#268`](https://github.com/nevermined-io/sdk-js/pull/268) - Quick fix for non-eip1559 networks [`#266`](https://github.com/nevermined-io/sdk-js/pull/266) - integrate Permissions and refactor search query [`#264`](https://github.com/nevermined-io/sdk-js/pull/264) -- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) +- add aave service agreement to ddo when creating nft721 asset [`#248`](https://github.com/nevermined-io/sdk-js/pull/248) - Get the keeper version from the artifacts instead of package version [`#244`](https://github.com/nevermined-io/sdk-js/pull/244) - replace `metadata-api` url by `marketplace-api` and sort type [`#243`](https://github.com/nevermined-io/sdk-js/pull/243) - fixing issues with BigNumbers [`#246`](https://github.com/nevermined-io/sdk-js/pull/246) @@ -2517,7 +2517,7 @@ Generated by [`auto-changelog`](https://github.com/CookPete/auto-changelog). - Feature/190 add did to sec markets [`#191`](https://github.com/nevermined-io/sdk-js/pull/191) - Adding utility methods for getting nft token uri [`#189`](https://github.com/nevermined-io/sdk-js/pull/189) - Lint ... [`#187`](https://github.com/nevermined-io/sdk-js/pull/187) -- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) +- Removing not used parameter [`#186`](https://github.com/nevermined-io/sdk-js/pull/186) - [wip] Create agreement+pay in one transaction [`#183`](https://github.com/nevermined-io/sdk-js/pull/183) - Adapting to contracts `v1.3.3` [`#177`](https://github.com/nevermined-io/sdk-js/pull/177) - Correct typo in route [`#184`](https://github.com/nevermined-io/sdk-js/pull/184) diff --git a/package.json b/package.json index 3e9235996..23421beea 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@nevermined-io/sdk", - "version": "3.0.0-rc9", + "version": "3.0.0-rc10", "description": "Javascript SDK for connecting with Nevermined Data Platform ", "main": "./dist/node/sdk.js", "typings": "./dist/node/sdk.d.ts", diff --git a/src/models/NvmAccount.ts b/src/models/NvmAccount.ts index 0e99b3dd7..00ac0dc79 100644 --- a/src/models/NvmAccount.ts +++ b/src/models/NvmAccount.ts @@ -13,7 +13,7 @@ export class NvmAccount { public babyY?: string public babySecret?: string private accountSigner?: Account - private zeroDevSigner?: KernelSmartAccount // ZeroDevAccountSigner<'ECDSA'> | SessionKeyProvider + private zeroDevSigner?: KernelSmartAccount // ZeroDevAccountSigner<'ECDSA'> | SessionKeyProvider public accountType: NvmAccountType = { signerType: 'local', isZeroDev: false } /** @@ -48,7 +48,7 @@ export class NvmAccount { * @returns The nevermined account */ static async fromZeroDevSigner( - signer: KernelSmartAccount, // | ZeroDevAccountSigner<'ECDSA'> | SessionKeyProvider, + signer: KernelSmartAccount, // | ZeroDevAccountSigner<'ECDSA'> | SessionKeyProvider, ): Promise { const address = signer.address const account = new NvmAccount(address, { signerType: 'zerodev', isZeroDev: true }) @@ -71,7 +71,7 @@ export class NvmAccount { public getType() { return this.accountType.signerType } - public getZeroDevSigner(): KernelSmartAccount { + public getZeroDevSigner(): KernelSmartAccount { return this.zeroDevSigner } diff --git a/src/nevermined/NvmApp.ts b/src/nevermined/NvmApp.ts index 55400d6a7..0e74bc0da 100644 --- a/src/nevermined/NvmApp.ts +++ b/src/nevermined/NvmApp.ts @@ -31,7 +31,7 @@ import { SubscribablePromise } from '../utils/SubscribablePromise' import { CreateProgressStep, OrderProgressStep, UpdateProgressStep } from './ProgressSteps' import { createEcdsaKernelAccountClient } from '@zerodev/presets/zerodev' import { arbitrumSepolia } from 'viem/chains' -import { ENTRYPOINT_ADDRESS_V07 } from 'permissionless' +import { ENTRYPOINT_ADDRESS_V07, providerToSmartAccountSigner } from 'permissionless' export enum NVMAppEnvironments { Staging = 'staging', @@ -160,14 +160,15 @@ export class NvmApp { if (config && config.zeroDevProjectId) { const signer = this.fullSDK.accounts.getAccount(account as string) - if (!signer) { + const smartAccountSigner = providerToSmartAccountSigner(config.web3Provider) + if (!smartAccountSigner) { throw new Web3Error('Account not found') } const kernelClient = await createEcdsaKernelAccountClient({ chain: arbitrumSepolia, projectId: config.zeroDevProjectId, - signer: signer.getAccountSigner(), + signer: smartAccountSigner, paymaster: 'SPONSOR', entryPointAddress: ENTRYPOINT_ADDRESS_V07, }) diff --git a/src/nevermined/utils/JwtUtils.ts b/src/nevermined/utils/JwtUtils.ts index 458fbb5f5..4821fe7c5 100644 --- a/src/nevermined/utils/JwtUtils.ts +++ b/src/nevermined/utils/JwtUtils.ts @@ -1,4 +1,3 @@ -import { KernelSmartAccount } from '@zerodev/sdk' import { JWSHeaderParameters, SignJWT, decodeJwt, importJWK } from 'jose' import { Account, Hash, LocalAccount, hexToBytes, toHex } from 'viem' import { Instantiable, InstantiableConfig } from '../../Instantiable.abstract' @@ -119,14 +118,6 @@ export class JwtUtils extends Instantiable { this.tokenCache = new Map() } - public async getSigner(account: NvmAccount): Promise> { - const address = getChecksumAddress(account.getId()) - - return account.isZeroDev() - ? account.getZeroDevSigner() - : await this.nevermined.accounts.getAccount(address) - } - public generateCacheKey(...args: string[]): string { return args.join() } diff --git a/src/nevermined/utils/SignatureUtils.ts b/src/nevermined/utils/SignatureUtils.ts index 12c529340..7a12bd335 100644 --- a/src/nevermined/utils/SignatureUtils.ts +++ b/src/nevermined/utils/SignatureUtils.ts @@ -17,9 +17,7 @@ export class SignatureUtils extends Instantiable { typeof account === 'string' ? this.nevermined.accounts.getAccount(account) : account if (nvmAccount.isZeroDev()) { - const result = await nvmAccount - .getZeroDevSigner() - .signMessage({ message: text as `0x${string}` }) + const result = await nvmAccount.getAccountSigner().signMessage({ message }) return result } else if (nvmAccount.accountType.signerType === 'local') { return (nvmAccount.getAccountSigner() as LocalAccount).signMessage({ @@ -46,7 +44,7 @@ export class SignatureUtils extends Instantiable { typeof account === 'string' ? this.nevermined.accounts.getAccount(account) : account if (nvmAccount.isZeroDev()) { - const signature = await nvmAccount.getZeroDevSigner().signTypedData({ + const signature = await nvmAccount.getAccountSigner().signTypedData({ domain, types: types as any, message: value, @@ -77,7 +75,7 @@ export class SignatureUtils extends Instantiable { typeof account === 'string' ? this.nevermined.accounts.getAccount(account) : account if (nvmAccount.isZeroDev()) { - return await nvmAccount.getZeroDevSigner().signTransaction({ data: tx }) + return await nvmAccount.getAccountSigner().signTransaction({ data: tx }) // TODO: Implement ZeroDev signing return `0x` } else if (nvmAccount.accountType.signerType === 'local') {