fix: add methods to pxe that fetch contract instance and artifact from node instead of db #10669
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
[Edited by Rahul]:
pxe.registerContract
requires a contract instance. To add the instance of a new contract is a bit cumbersome.pxe.getContractInstance(contractAddress)
only checks the local DB so ofcourse givesundefined
for any new contracts (which is majority of the cases outside of sandbox).Then the only to get the instance today is
getContractInstanceFromDeployParams
for which you need to passdeployment salt, constructor args, public keys, deployer wallet address
which wallets won't knowThe right solution is
pxe.getContractInstance()
should fetch data from the node/archiver which anyway stores this data in the contract_instance_store.[ Original content]:
Related to this discord post.
Currently, PXE doesn't have an easy way to register ( import ) an existing contract that's been deployed in other PXEs. Contract instance, one of the
pxe.registerContract()
's param, has to be manually reconstructed which requires several params such as, salt, constructor args, public keys, deployer wallet address, etc.*
pxe.getContractInstance()
only returns instance stored in db if it's already been registered, or undefined.Since these info is stored in the node, it'd be really helpful for app devs if it can be fetched from node via PXE service. Then, we don't have to hard-code them or run server that holds these information.
Added Methods