Giter Site home page Giter Site logo

etherspot / etherspot-prime-sdk Goto Github PK

View Code? Open in Web Editor NEW
116.0 6.0 19.0 1.81 MB

Etherspot Prime - Account Abstraction SDK

Home Page: https://etherspot.fyi

License: MIT License

JavaScript 0.06% TypeScript 90.84% Shell 0.07% CSS 6.38% Handlebars 2.65%
account-abstraction

etherspot-prime-sdk's People

Contributors

0xsulpiride avatar arddluma avatar ch4r10t33r avatar kaushalrajbacancy avatar lbw33 avatar poocart avatar sarthakprp avatar taylorferran avatar vignesha22 avatar ymaghzaz avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

etherspot-prime-sdk's Issues

Factual wallet address is not being created when using MetaMaskWalletProvider

It was working fine till yesterday , now it's showing error:

code:

here you can see i have simply used MetaMaskWalletProvider to create an instance of primeSdk,

  if (!MetaMaskWalletProvider.detect()) {
      toast("Metamask not detected");
      return;
    }
    
    const walletProvider = await MetaMaskWalletProvider.connect();

    console.log("walletProvider: ",walletProvider)

    const _primeSdk = new PrimeSdk(walletProvider, {
      chainId: 80001,
    });
    
     console.log(_primeSdk);
    
    const _addresss = await _primeSdk.getCounterFactualAddress();

The walletProvider was consoled with the wallet i wanted to connect to without any issue, but when i console.log _primeSdk i got:

image

here you can see the accountAddress in etherspotWallet is undefined.

here is my walletProvider:

image

The SDK ought to handle errors related to custom networks

Whenever Etherspot Prime SDK is used on a custom network which is not supported by Prime, the SDK errors out.

Example:

TypeError: Cannot read properties of undefined (reading 'bundler')
    at new PrimeSdk (/home/henrik/london/chatchampion/telegram-service/node_modules/@etherspot/prime-sdk/dist/sdk/sdk.js:28:55)
    at /home/henrik/london/chatchampion/telegram-service/src/flock-main.ts:127:20
    at Generator.next (<anonymous>)
    at fulfilled (/home/henrik/london/chatchampion/telegram-service/src/flock-main.ts:5:58)
TypeError: Cannot read properties of undefined (reading 'contracts')
  at new PrimeSdk (/Users/mmm/Dev/bundler/etherspot-prime-sdk/src/sdk/sdk.ts:68:27)
  at main (/Users/mmm/Dev/bundler/etherspot-prime-sdk/examples/01-get-address.ts:9:20)
  at Object.<anonymous> (/Users/mmm/Dev/bundler/etherspot-prime-sdk/examples/01-get-address.ts:16:1)
  at Module._compile (node:internal/modules/cjs/loader:1256:14)
  at Module.m._compile (/Users/mmm/Dev/bundler/etherspot-prime-sdk/node_modules/ts-node/src/index.ts:858:23)
  at Module._extensions..js (node:internal/modules/cjs/loader:1310:10)
  at Object.require.extensions.<computed> [as .ts] (/Users/mmm/Dev/bundler/etherspot-prime-sdk/node_modules/ts-node/src/index.ts:861:12)
  at Module.load (node:internal/modules/cjs/loader:1119:32)
  at Function.Module._load (node:internal/modules/cjs/loader:960:12)
  at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:86:12)

The SDK has to handle this scenarios and error out gracefully.

[BUG] this library work in server side nodejs api

Describe the bug

I'm getting this error on : await primeSdk.estimate()

checking nonce...
2 | Object.defineProperty(exports, "__esModule", { value: true });
3 | exports.ErrorHandler = void 0;
4 | const constants_1 = require("./constants");
5 | class ErrorHandler extends Error {
6 | constructor(error, code) {
7 | super(error);
^
error: AA21 didn't pay prefund
code: "-32500"

  at new ErrorHandler (/home/francel/Bureau/etherspot_prime_test/node_modules/@etherspot/prime-sdk/dist/sdk/errorHandler/errorHandler.service.js:7:8)
  at /home/francel/Bureau/etherspot_prime_test/node_modules/@etherspot/prime-sdk/dist/sdk/base/HttpRpcClient.js:41:22
  at processTicksAndRejections (:61:76)

Expected behavior

Work well inserver side nodejs

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Prime SDK version or commit hash

latest

SDK fails to build

Version 1.3.9 fails to build with the following error

error TS2415: Class 'InvalidationPolicyCache' incorrectly extends base class 'InMemoryCache'.
  Types have separate declarations of a private property 'init'.

11 export default class InvalidationPolicyCache extends InMemoryCache {

Problem with gasDetails

On the local version of my application, the operations are sending maxFeePerGas: 0x01. On the hosted version the gas cost is already with an adequate value.
I decided to specify explicit constant values for the gas cost. It turned out that you can't specify them, because your code overwrites my passed values first by 1 and then by the values from the bundler if they exist

async estimate(gasDetails?: TransactionGasInfoForUserOp) {
    if (this.userOpsBatch.to.length < 1) {
      throw new Error("cannot sign empty transaction batch");
    }

    const tx: TransactionDetailsForUserOp = {
      target: this.userOpsBatch.to,
      values: this.userOpsBatch.value,
      data: this.userOpsBatch.data,
      ...gasDetails,
    }

    let partialtx = await this.etherspotWallet.createUnsignedUserOp({
      ...tx,
      maxFeePerGas: 1,
      maxPriorityFeePerGas: 1,
    });
    
    

This is where you overwrite the value of the custom gasDetails
What you probably wanted to do?
let partialtx = await this.etherspotWallet.createUnsignedUserOp({
maxFeePerGas: 1,
maxPriorityFeePerGas: 1,
...tx,
});
Next is the code that completely conflicts with the custom value of gas in transactions

    const bundlerGasEstimate = await this.bundler.getVerificationGasInfo(partialtx);

    // if estimation has gas prices use them, otherwise fetch them in a separate call
    if (bundlerGasEstimate.maxFeePerGas && bundlerGasEstimate.maxPriorityFeePerGas) {
      partialtx.maxFeePerGas = bundlerGasEstimate.maxFeePerGas;
      partialtx.maxPriorityFeePerGas = bundlerGasEstimate.maxPriorityFeePerGas;
    } else {
      const gas = await this.getGasFee();
      partialtx.maxFeePerGas = gas.maxFeePerGas;
      partialtx.maxPriorityFeePerGas = gas.maxPriorityFeePerGas;
    }

    if (bundlerGasEstimate.preVerificationGas) {
      partialtx.preVerificationGas = BigNumber.from(bundlerGasEstimate.preVerificationGas);
      partialtx.verificationGasLimit = BigNumber.from(bundlerGasEstimate.verificationGasLimit ?? bundlerGasEstimate.verificationGas);
      partialtx.callGasLimit = BigNumber.from(bundlerGasEstimate.callGasLimit);
    }

    return partialtx;

  }

In view of the whole situation, I am worried about two questions

  1. what does the value of bundlerGasEstimate depend on?
  2. Is not being able to install custom gas a bug?

getAccountBalances throwing error

Hi,

i have been trying to get all account balances and it keeps throwing me an error

error: failed to execute "open" on xmlhttprequest : invalid URL.

i use node v.20 and next 13.5.4..

how do i fix this?

[BUG] How to reuse the instance of PrimeSdk in another function to send an transaction

Describe the bug

[BUG] When we create an instance of PrimeSdk and create an SCW with await primeSdk.getCounterFactualAddress(), how to reuse the instance of PrimeSdk in another function to send an transaction

Expected behavior

Reuse the instance of PrimeSdk in another function to send an transaction

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Prime SDK version or commit hash

latest

Update a default ProjectKey in example programs

Presently several programs under the /examples/ folder fail to run due to an empty ProjectKey. These programs have to be updated to include a dummy/temp project key to ensure the programs run successfully.

few package issues

whenever i have installed this package: @etherspot/prime-sdk
and tried to use it i got a same error that few required packages of prime-sdk were missing:

1.rxjs
2. reflect-metadata

it works fine when i install this 2 packages to my app package.json.

and 1 more issue , in your file node-polyfill.js (node_modules@etherspot\prime-sdk\dist\node-polyfill.js)

websocket is considered as an part of global object, and i was getting error because my browsers (chrome and barve) were not able to understand what global is , so i changed it to windows ,

from : global.WebSocket = WebSocketConstructor;
to : window.WebSocket = WebSocketConstructor;

and then installed my updated package, after this it's working fine.

Customize PVG, VG and CGL for a UserOp

Customize PVG, VG and CGL for a UserOp. At the moment we cannot customize these values and the SDK resorts to the default values provided by the bundler with no means to change it.

Invalid Wallet Provider [BUG]

Screenshot 2023-12-07 at 2 30 50 PM ### Describe the bug

Invalid wallet provider
at new PrimeSdk

Expected behavior

Im trying to inistantiate the prive sdk with "npm run 01-get-address"
`
import { PrimeSdk } from '../src';
import * as dotenv from 'dotenv';

dotenv.config();

async function main() {
// initializating sdk...
const primeSdk = new PrimeSdk({ privateKey: process.env.WALLET_PRIVATE_KEY }, { chainId: Number(process.env.CHAIN_ID), projectKey: 'public-prime-testnet-key' })

// get EtherspotWallet address...
const address: string = await primeSdk.getCounterFactualAddress();
console.log('\x1b[33m%s\x1b[0m', EtherspotWallet address: ${address});
}

main()
.catch(console.error)
.finally(() => process.exit());

`

Steps to reproduce

No response

Additional context

No response

Operating system

macOS

Prime SDK version or commit hash

1.3.13

Unsupported network error when initializing custom chain in Prime SDK [BUG]

Describe the bug

I am encountering an "Unsupported network" error when attempting to initialize a custom chain using the Prime SDK. This issue seems to occur during the initialization process with the provided configuration.

Expected behavior

I expected the Prime SDK to successfully initialize the custom chain with the provided parameters, connecting to the specified network without encountering an "Unsupported network" error.

Steps to reproduce

  1. Initialize the Prime SDK with the following configuration:
   { privateKey: process.env.WALLET_PRIVATE_KEY },
   {
      chainId: 49088,
      projectKey: 'public-prime-testnet-key',
      entryPointAddress: '0x793949275B35D3E394f5C218DC88ae6C7D04a252',
      bundlerRpcUrl: 'https://bifrost-testnet-bundler.kanalabs.io/',
      factoryWallet: Factory.ETHERSPOT,
      walletFactoryAddress: '0x91037ED7B25d72F61B80D4376C0E66680997Ce5E',
   },
);
  1. Observe the "Unsupported network" error during initialization.

Additional context

code

image

error

image

Operating system

Windows

Prime SDK version or commit hash

v1.3.12

[BUG] Property 'getTokenBalance' does not exist on type 'PrimeSdk'.ts(2339)

Describe the bug

I want to get the balance of an token of a SCW address. When i call the function getTokenBalance on the instance of PrimeSdk i get :Property 'getTokenBalance' does not exist on type 'PrimeSdk'.ts(2339)

Expected behavior

I found the function getTokenBalance(tokenAddress: string) in the documentation and I expected the function to exist and return the balance

Steps to reproduce

No response

Additional context

No response

Operating system

Linux

Prime SDK version or commit hash

latest

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.