permissionless.js icon indicating copy to clipboard operation
permissionless.js copied to clipboard

Compile error This expression is not callable. Type 'never' has no call signatures.

Open asghaiermp opened this issue 1 year ago • 8 comments

I am getting this error when running npm run build for my nodejs app

node_modules/permissionless/utils/getAction.ts:10:9 - error TS2349: This expression is not callable. Type 'never' has no call signatures.

10 ( ~ 11 client as Client & { ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ... 13 } ~~~~~~~~~~~~~ 14 )[actionName]?.(...params) ?? action(client, ...params) ~~~~~~~~~~~~~~~~~~~~~

Found 1 error in node_modules/permissionless/utils/getAction.ts:10

Here is my ts.config file

{
  "compilerOptions": {
    "module": "CommonJS",
    "target": "ES2021",
    "noImplicitAny": true,
    "removeComments": true,
    "preserveConstEnums": true,
    "outDir": "./build",
    "sourceMap": true,
    "skipLibCheck": true,
    "resolveJsonModule":true,
    "esModuleInterop": true,
    "allowSyntheticDefaultImports": true,
  },
  "include": ["src/**/*"],
  "exclude": ["node_modules", "**/*.spec.ts"]
}

asghaiermp avatar Apr 09 '24 13:04 asghaiermp

on it!

kristofgazso avatar Apr 09 '24 19:04 kristofgazso

Hey! Can you share the code? Also, try to use the tsconfig.json from the tutorial. Using es2022 may help.

pavlovdog avatar Apr 10 '24 10:04 pavlovdog

I have tried that but still getting similar errors

here is the code we are using for AA through ZeroDev SDK

import { polygonMumbai, polygon } from "viem/chains"
import { createPublicClient, http, Hex, keccak256, toHex } from "viem"
import { getKernelAddressFromECDSA } from "@zerodev/ecdsa-validator"
import { BlockchainTypes, ContractEnvironment } from "@mentaport/serverless-common"
import { getCertificatesBlockchainEnv } from "./blockchainEnv"
 
/**
 *  Function to create a wallet from an email using account abstraction
 *
 * @param {email} email of user
 * 
 * @returns {string} Returns smart contract wallet address
 */
export async function generateWalletFromEmail(email:string, environment: ContractEnvironment, chain: BlockchainTypes):Promise<string> {

  const config = getCertificatesBlockchainEnv(environment,chain);
  // hash the customer email and convert to BigInt so always same index
  const index = BigInt(keccak256(toHex(email)));

  const publicClient = createPublicClient({
    chain: environment === ContractEnvironment.Mainnet ? polygon : polygonMumbai,
    transport: http(config.RPC_URL),
  });

  const smartAccountAddress = await getKernelAddressFromECDSA({
    publicClient, 
    eoaAddress: config.eoaAddress as Hex, 
    index
  });

  return smartAccountAddress;
}

asghaiermp avatar Apr 12 '24 17:04 asghaiermp

Can't reproduce without these dependencies

import { BlockchainTypes, ContractEnvironment } from "@mentaport/serverless-common"
import { getCertificatesBlockchainEnv } from "./blockchainEnv"

Also, it seems that you forgot to pass entryPointAddress to a getKernelAddressFromECDSA.

pavlovdog avatar Apr 19 '24 10:04 pavlovdog

@pavlovdog I am not sure what you meant by pass entryPointAddress to getKernelAddressFromECDSA

according to ZeroDev documentation the params to be passed to getKernelAddressFromECDSA are

type GetKernelAddressFromECDSAParams =
    | {
          publicClient: PublicClient
          eoaAddress: Address
          index: bigint
      }
    | {
          eoaAddress: Address
          index: bigint
          initCodeHash: Hex
      }

asghaiermp avatar Apr 19 '24 12:04 asghaiermp

@pavlovdog to reproduce here is a modified version of the code

import { polygon, polygonAmoy } from "viem/chains"
import { createPublicClient, http, Hex, keccak256, toHex } from "viem"
import { getKernelAddressFromECDSA } from "@zerodev/ecdsa-validator"
 
/**
 *  Function to create a wallet from an email using account abstraction
 *
 * @param {email} email of user
 * 
 * @returns {string} Returns smart contract wallet address
 */
export async function generateWalletFromEmail(email:string):Promise<string> {

  // hash the customer email and convert to BigInt so always same index
  const index = BigInt(keccak256(toHex(email)));

  const publicClient = createPublicClient({
    chain: polygonAmoy,
    transport: http(`https://polygon-amoy.g.alchemy.com/v2/${API_KEY}`),
  });

  const smartAccountAddress = await getKernelAddressFromECDSA({
    publicClient, 
    eoaAddress: 'ANY EOA ADDRESS', 
    index
  });

  return smartAccountAddress;
}

asghaiermp avatar Apr 19 '24 12:04 asghaiermp

I still can't reproduce this, it works on my setup. Can you share the minimal repo, including all the involved versions (node/package manager/etc) and a run command?

pavlovdog avatar May 02 '24 10:05 pavlovdog

Hi, I have this kind of compile error me too, did you figured out the solution @asghaiermp ?

yaniferhaoui avatar Jun 06 '24 13:06 yaniferhaoui

This is not relevant post [email protected]

plusminushalf avatar Nov 22 '24 09:11 plusminushalf