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

Get ABI from Sourcify #42

Merged
merged 17 commits into from
Nov 17, 2021
Merged

Get ABI from Sourcify #42

merged 17 commits into from
Nov 17, 2021

Conversation

hasparus
Copy link
Contributor

@hasparus hasparus commented Nov 10, 2021

What's changed?

I added two ways to grab metadata from Sourcify. It's not production-ready yet, but we can work with it.

What needs fixing here?

@ethereum-sourcify/contract-call-decoder built code is ESM, so I had to make some changes to our test setup and change "type" to "module" in package.json files. This obviously cannot be published, because it would break everything. We can find a work around to use the decoder or maybe leverage .mts extension from TypeScript 4.5

Questions

  • What if contract is not verified on Sourcify?
  • Using Abis vs Outputs (with NatSpec)?

Further work

  • Configuring sourcify vs etherscan in config?

@changeset-bot
Copy link

changeset-bot bot commented Nov 10, 2021

🦋 Changeset detected

Latest commit: 19445bd

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@dethcrypto/eth-sdk Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@hasparus hasparus changed the base branch from master to follow-proxies November 10, 2021 20:40
@krzkaczor
Copy link
Member

krzkaczor commented Nov 11, 2021

Nice work!

What if contract is not verified on Sourcify?
I think we could implement it in this way:

  1. Have config setting something like abi-source: 'sourcify' | 'etherscan' | 'manual' (abi needs to be provided manually)
  2. If the contract is not verified on sourcify then simply throw an error. I would assume that users would prefer to use sourcify when they don't trust etherscan so I am not sure if automatic fallback to etherscan makes any sense.

Using Abis vs Outputs (with NatSpec)?
We can ignore NatSpec entirely for now -- just use ABI.

I think we should prefer to use official SDK and if something's missing we should help to shape it. For now I would consider this blocked until CJS support is there.

CC: @kuzdogan

@hasparus
Copy link
Contributor Author

Hey @kuzdogan, I talked with @krzkaczor now, and we'll use the sourcify.dev endpoint for now — it's exactly what we need for eth-sdk (and we already keep a record of chainIds). This means we won't need that CJS support.

@hasparus
Copy link
Contributor Author

@krzkaczor how would you see abiSource: 'manual'? Instead of fetching ABIs we could print a warning explaining how to get them?

Base automatically changed from follow-proxies to master November 12, 2021 15:04
@hasparus hasparus changed the base branch from master to fetch-json November 12, 2021 17:03
@krzkaczor
Copy link
Member

@hasparus

@krzkaczor how would you see abiSource: 'manual'? Instead of fetching ABIs we could print a warning explaining how to get them?

More or less yes. Simply put if ABI doesn't exist already just fail with instructions on how to provide it.

Base automatically changed from fetch-json to master November 12, 2021 19:45
@hasparus hasparus marked this pull request as ready for review November 15, 2021 12:34
@hasparus hasparus force-pushed the abi-from-sourcify branch 3 times, most recently from 54fa94b to c025c72 Compare November 15, 2021 12:38
@hasparus hasparus marked this pull request as draft November 15, 2021 12:39
@hasparus
Copy link
Contributor Author

hasparus commented Nov 15, 2021

  • Since we allow arbitrary network ids, I'm fixing names we currently don't handle.

image

@hasparus hasparus marked this pull request as ready for review November 15, 2021 15:17
@@ -3,7 +3,5 @@ dist
yarn-error.log
.DS_Store
*.tsbuildinfo
packages/tests/eth-sdk
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Moved to a separate gitignore file

@hasparus
Copy link
Contributor Author

All right, this is ready for review.

Copy link
Member

@krzkaczor krzkaczor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing changeset

packages/eth-sdk/src/config/readConfig.ts Outdated Show resolved Hide resolved
@hasparus hasparus merged commit 1b4f0ce into master Nov 17, 2021
@hasparus hasparus deleted the abi-from-sourcify branch November 17, 2021 17:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants