etherspot / etherspot-prime-sdk Goto Github PK
View Code? Open in Web Editor NEWEtherspot Prime - Account Abstraction SDK
Home Page: https://etherspot.fyi
License: MIT License
Etherspot Prime - Account Abstraction SDK
Home Page: https://etherspot.fyi
License: MIT License
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:
here you can see the accountAddress in etherspotWallet is undefined.
here is my walletProvider:
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.
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)
Work well inserver side nodejs
No response
No response
Linux
latest
Create example programs which use validUntil
and validAfter
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 {
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
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] 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
Reuse the instance of PrimeSdk in another function to send an transaction
No response
No response
Linux
latest
how to reuse later in the code the same instance of an new PrimeSdk() ?
reuse the same instance of new PrimeSdk() ?
No response
No response
Linux
latest
Hi @0xSulpiride ,
can i get an api key for arka paymaster for mumbai testnet. I creatde a support ticket in discord, seemms its not working
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.
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. 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
at new PrimeSdk
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());
`
No response
No response
macOS
1.3.13
Both the dependencies of Prime SDK namely Apollo Client and @nerdwallet/apollo-cache-policies packages appear to have issues when used in transaction-kit. Can we replace this with urql
instead?
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.
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.
{ 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',
},
);
Windows
v1.3.12
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)
I found the function getTokenBalance(tokenAddress: string) in the documentation and I expected the function to exist and return the balance
No response
No response
Linux
latest
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.