Override runMethod in version 5 Contract class #1911
Replies: 4 comments
-
FYI, I copied the This means I can now send contract calls as private transactions to Pantheon |
Beta Was this translation helpful? Give feedback.
-
Hmm. Would it make more sense to override the |
Beta Was this translation helpful? Give feedback.
-
The problem I had was the signatures to |
Beta Was this translation helpful? Give feedback.
-
I'm planning to add a custom field to the Overrides type in the next minor bump, which I think will address the issues here. I don't know if there is a good way to expose the needed methods in a way that remains abstract. I am trying to avoid making these sorts of changes now on the v5 branch, so I can focus on v6, so I'm going to move this to discussions in case there is any further discussion to have. :) |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
I'm trying to extend Ethers to support Pantheon's private transactions. In order to do that I need to override the
Contract
class to call private transaction APIs instead of the traditioneth_sendRawTransaction
andeth_call
APIs.I tried extending the
Contract
class and then overriding the constructor with a newrunMethod
function. See the v5Contract
class at https://github.com/ethers-io/ethers.js/blob/ethers-v5-beta/packages/contracts/src.ts/index.ts#L414The problem is the super constructor needs to be called before other logic in the constructor of the extension class. This sets the
callStatic
andfunctions
like properties. As these properties are readonly, they can't then be overridden in my constructor.Here's my current failed attempt
https://github.com/naddison36/pantheon-ethers/blob/master/src/ts/privateContract.ts#L60
Being able to pass the
runMethod
in as an option function into theContract
constructor is one way to address this. Another is to make therunMethod
function a static function on theContract
that can be overridden. But I'm open to other solutions.Beta Was this translation helpful? Give feedback.
All reactions