Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Migrate from ethers.js to viem #113

Open
ch4r10t33r opened this issue Jul 8, 2024 · 7 comments
Open

feat: Migrate from ethers.js to viem #113

ch4r10t33r opened this issue Jul 8, 2024 · 7 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers

Comments

@ch4r10t33r
Copy link
Member

Arka backend presently uses ethers.js to interact with the blockchain. We ought to be migrating all these functions to viem.

@ch4r10t33r ch4r10t33r added enhancement New feature or request good first issue Good for newcomers labels Jul 8, 2024
@nikhilkumar1612
Copy link
Contributor

i'm working on this @ch4r10t33r

@nikhilkumar1612
Copy link
Contributor

For any transactions to be made using walletClient of viem requires a field of chain. So we will have to get viem defined chain at runtime. I plan to add the following code to /utils/common.ts which will return viem defined chain using chainId. This will be used in all the functions which needs walletClient to make transactions.

import * as chains from "viem/chains"; 

export function getViemChain(chainId: number): chains.Chain {
  for(const chain of Object.values(chains)) {
    if (chain.id === chainId) {
      return chain;
    }
  }
  throw Error(`Chain with id ${chainId} not found`);
}

let me know if there are any suggestions or improvements.

@nikhilkumar1612
Copy link
Contributor

what is the format of private key stored in AWS secrets manager
does it follow the viem's Hex (0x${string}) type ?

@kanthgithub
Copy link
Contributor

what is the format of private key stored in AWS secrets manager does it follow the viem's Hex (0x${string}) type ?

Hi @nikhilkumar1612 yeah it follows viem's hex format

@nikhilkumar1612
Copy link
Contributor

hi @kanthgithub @ch4r10t33r
i have followed the above code to obtain viem defined chain.
For PriceUpdate cronjob i cannot find the chainID, please let me know how can i proceed there.

@vignesha22
Copy link
Contributor

Hi the chainId would be there on the DEPLOYED_ERC20_PAYMASTERS if you look at the structure of ERC20_PAYMASTERS on the README.md you would see that the key is the chainId and if you see inside PriceUpdate cron fn, on the first parameter of getNetworkConfig, chain is the chainId associated to each of the paymaster addresses

@nikhilkumar1612
Copy link
Contributor

hey i have raised a pr please review.
@kanthgithub @vignesha22 @ch4r10t33r

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers
Development

No branches or pull requests

4 participants