plebbit / plebbit-js

A Javascript API to build applications using plebbit
GNU General Public License v2.0
41 stars 7 forks source link

implement EVM challenge #20

Closed estebanabaroa closed 8 months ago

Rinse12 commented 10 months ago

What is needed to implement EVM challenge?

I see verifyAuthorAddress and getContractCallResponse are mocked in evm-contract-calls/index. If we implement these two function will EVM challenge work?

estebanabaroa commented 10 months ago

If we implement these two function will EVM challenge work?

correct, in theory it should only take a few hours. then once this works we would have to make it easy in the frontends for people to link their ETH address to their plebbit account, that's something tom would work on

I guess another issue is that you have to convert the operators to using big numbers, or big ints or something, because 1 PLEB is actually 1000000000000000000 so the simple operators ><= won't work

Rinse12 commented 10 months ago

so if I understand correctly, the getContractCallResponse will perform a read against the contract address's own function and the author address (The EVM one) will be provided as an argument. Don't we need to provide the function name?

Viem has a function I think we can use to implement getContractCallResponse: https://viem.sh/docs/contract/readContract.html

I implemented most of verifyAuthorAddress in this commit. I also left a couple of questions in the comments

Also if you can provide an example of settings.challenges as an EVM challenge it would be great

estebanabaroa commented 10 months ago

Don't we need to provide the function name?

the 'evm-contract-call' options.abi is the ABI of only the method we want to target, it's not an array of the full contract's ABI, so we don't need to provide the function name, because the ABI provides it, there's only 1.

Viem has a function I think we can use to implement getContractCallResponse: https://viem.sh/docs/contract/readContract.html

you can do it with viem or ethers.js, whatever you prefer

I implemented most of verifyAuthorAddress in this commit. I also left a couple of questions in the comments

don't have time to check it right now, I'll try to check it when it's finished.

Also if you can provide an example of settings.challenges as an EVM challenge it would be great

already is one https://github.com/plebbit/plebbit-js/blob/819b9458a0bfdfa1c3bd559ff31b26de4dcd9980/test/challenges/fixtures/fixtures.js#L199