-
Notifications
You must be signed in to change notification settings - Fork 0
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: viem wrapper with readContract and base methods #25
Conversation
ZKS-94 EVM Provider - Base
Base should include a
Also add non-contract related function, for example: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
GJ ser! Just a few changes :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IEvmProvider interface is not needed imo, given that we are not going to have many implementations of EvmProvider
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also notice that readContract()
has a very specific signature coupled to viem
types. Probably a better approach for interfaces, in case are needed, would be segregation, having 2 different interfaces for example, IEvmProvider
and IContractReader
* Acts as a wrapper around Viem library to provide methods to interact with an EVM-based blockchain. | ||
*/ | ||
@Injectable() | ||
export class ViemProviderService implements IEvmProvider { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rename this ViemProviderService to EvmProviderService
/** | ||
* Retrieves the value from a storage slot at a given address. | ||
* @param {Address} address The address of the contract. | ||
* @param {number} slot The slot number to read. | ||
* @returns {Promise<Hex>} A Promise that resolves to the value of the storage slot. | ||
* @throws {InvalidArgumentException} If the slot is not a positive integer. | ||
*/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a suggestion here. When you are implementing an interface i think you can inherit the natspec from it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ooaa nice jajaja
http: jest.fn(), | ||
})); | ||
|
||
describe("ViemProviderService", () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
rename here also
providers: [EvmProviderService, ViemProviderService], | ||
exports: [EvmProviderService, ViemProviderService], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can get rid of EvmProviderService. Here should be just 1 providers item and 1 exports item
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
dismiss this comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think packages
directory is no longer used. Lets remove it on this pr pls :)
🤖 Linear
Closes ZKS-67 ZKS-94 ZKS-93
Description
Create a Viem library wrapper service with base methods functionality:
getBalance
getBlockNumber
getGasPrice
getStorageAt
readContract
readContract
allows to perform an eth_call for view/pure functions in a type-safe way by providing the contract ABI