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 metadata for contracts verified on celoscan #169

Closed
wants to merge 47 commits into from

Conversation

aaronmgdr
Copy link
Member

@aaronmgdr aaronmgdr commented Feb 29, 2024

Description

Adds looking up of contract data verified on celoscan as well as sourcify.

Other changes

  • updates test urls to example.com. using other domains like dummy.com or test is not a good practice as those are real domains which may end up giving weird or dangerous responses whereas example.com is reserved by iana for testing.|*

  • in releasecelo log which account is used since it is dependent on internal state

  • fixed some issues with long running tests not exiting in time

  • add fetchMock so tests dont need to call external http servers

  • increases default test timeout

Tested

YEP

Related issues

Backwards compatibility

yes.

Documentation

N.A


PR-Codex overview

The focus of this PR is to enhance governance functionality by adding the ability to build and view governance proposals interacting with verified contracts on Celoscan.

Detailed summary

  • Added transactions2.json to .gitignore
  • Added fetch-mock dependency
  • Updated contracts.test.ts to output CSV
  • Modified contract address lookup in BlockExplorer to various verification services
  • Updated checks.ts to import fetch differently
  • Updated Jest config for test timeout settings
  • Added fetchMock setup in test files
  • Updated methods in proposals.ts for error handling
  • Added compliance-related imports in celo.test.ts for transfers
  • Added fetchMock setup in transfer-dollars.test.ts
  • Enhanced InteractiveProposalBuilder methods in proposals.ts
  • Updated metadata fetching in sourcify.md
  • Updated timeout settings in upvote.test.ts

The following files were skipped due to too many changes: packages/cli/src/commands/governance/upvote.test.ts, packages/cli/src/commands/transfer/dollars.test.ts, packages/cli/src/commands/transfer/euros.test.ts, packages/cli/src/base.ts, packages/cli/src/commands/releasecelo/locked-gold.test.ts, docs/sdk/explorer/classes/sourcify.Metadata.md, packages/cli/src/commands/election/vote.test.ts, packages/cli/src/commands/election/run.test.ts, packages/sdk/explorer/src/sourcify.ts, packages/cli/src/commands/election/revoke.test.ts, packages/cli/src/commands/governance/propose.test.ts, yarn.lock, packages/sdk/explorer/src/sourcify.test.ts

✨ Ask PR-Codex anything about this PR by commenting with /codex {your question}

Copy link

changeset-bot bot commented Feb 29, 2024

🦋 Changeset detected

Latest commit: 7964290

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

This PR includes changesets to release 3 packages
Name Type
@celo/celocli Minor
@celo/explorer Minor
@celo/governance 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

@aaronmgdr aaronmgdr changed the title WIP Get metadata for contracts verified on celoscan Get metadata for contracts verified on celoscan Mar 26, 2024
@aaronmgdr aaronmgdr marked this pull request as ready for review March 26, 2024 11:06
@aaronmgdr aaronmgdr requested a review from a team as a code owner March 26, 2024 11:06
wait a few seconds befoe stoping ganache for cli test for cleanup to happen
ignore openHandles,
give more space for slow tests since this is blockchain
set default timeout longer,
# Conflicts:
#	packages/cli/src/commands/lockedgold/lock.test.ts
@aaronmgdr aaronmgdr enabled auto-merge (squash) April 3, 2024 14:58
@aaronmgdr
Copy link
Member Author

after getting past the issue of "warn must be string or error not type error" issue. the true Error is

 "Cannot read properties of undefined (reading 'bind')"

        > 1 | import { BasicDataWrapper } from '@celo/identity/lib/offchain-data-wrapper'
            | ^
          2 | import { PrivateNameAccessor, PublicNameAccessor } from '@celo/identity/lib/offchain/accessors/name'
          3 | import { Flags } from '@oclif/core'
          4 | import { BaseCommand } from '../../base'

          at Object.<anonymous> (../../node_modules/cross-fetch/dist/node-polyfill.js:2:31)
          at Object.<anonymous> (../../node_modules/web3-providers-http/lib/index.js:29:1)
          at Object.<anonymous> (../../node_modules/web3-core-requestmanager/lib/index.js:45:19)
          at Object.<anonymous> (../../node_modules/@celo/identity/node_modules/web3-core/lib/index.js:22:24)
          at Object.<anonymous> (../../node_modules/@celo/identity/node_modules/web3-eth-contract/lib/index.js:30:12)
          at Object.<anonymous> (../../node_modules/@celo/identity/node_modules/@celo/connect/lib/types.js:4:27)
          at Object.<anonymous> (../../node_modules/@celo/identity/node_modules/@celo/connect/lib/index.js:19:14)
          at Object.<anonymous> (../../node_modules/@celo/identity/node_modules/@celo/contractkit/lib/wrappers/Accounts.js:14:19)
          at Object.<anonymous> (../../node_modules/@celo/identity/node_modules/@celo/contractkit/lib/identity/metadata.js:47:20)
          at Object.<anonymous> (../../node_modules/@celo/identity/lib/offchain-data-wrapper.js:19:20)
          at Object.<anonymous> (src/commands/account/offchain-read.ts:1:1)
          at loadWithData (../../node_modules/@oclif/core/lib/module-loader.js:72:93)
          at fetch (../../node_modules/@oclif/core/lib/config/plugin.js:102:23)
          at Plugin.findCommand (../../node_modules/@oclif/core/lib/config/plugin.js:119:21)
          at ../../node_modules/@oclif/core/lib/config/plugin.js:208:76
              at async Promise.all (index 36)
          at Plugin._manifest (../../node_modules/@oclif/core/lib/config/plugin.js:206:24)
          at Plugin.load (../../node_modules/@oclif/core/lib/config/plugin.js:157:25)
          at PluginLoader.loadRoot (../../node_modules/@oclif/core/lib/config/plugin-loader.js:63:13)
          at Config.load (../../node_modules/@oclif/core/lib/config/config.js:265:27)
          at Function.load (../../node_modules/@oclif/core/lib/config/config.js:155:9)
          at Function.run (../../node_modules/@oclif/core/lib/command.js:149:24)
          at Object.<anonymous> (src/commands/account/set-name.test.ts:19:5)

Copy link

codecov bot commented May 14, 2024

Codecov Report

Attention: Patch coverage is 96.15385% with 1 line in your changes missing coverage. Please review.

Project coverage is 68.71%. Comparing base (3f5f65d) to head (7964290).
Report is 72 commits behind head on master.

Files with missing lines Patch % Lines
packages/sdk/explorer/src/sourcify.ts 96.15% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master     #169      +/-   ##
==========================================
- Coverage   72.91%   68.71%   -4.20%     
==========================================
  Files          77      128      +51     
  Lines        3589     5981    +2392     
  Branches      734      962     +228     
==========================================
+ Hits         2617     4110    +1493     
- Misses        925     1792     +867     
- Partials       47       79      +32     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

aaronmgdr added 4 commits May 15, 2024 10:24
# Conflicts:
#	docs/sdk/explorer/classes/block_explorer.BlockExplorer.md
#	docs/sdk/explorer/classes/log_explorer.LogExplorer.md
#	docs/sdk/explorer/classes/sourcify.Metadata.md
#	docs/sdk/explorer/interfaces/base.ContractDetails.md
#	docs/sdk/explorer/interfaces/base.ContractMapping.md
#	docs/sdk/explorer/interfaces/block_explorer.CallDetails.md
#	docs/sdk/explorer/interfaces/block_explorer.ContractNameAndMethodAbi.md
#	docs/sdk/explorer/interfaces/block_explorer.ParsedBlock.md
#	docs/sdk/explorer/interfaces/block_explorer.ParsedTx.md
#	docs/sdk/explorer/interfaces/sourcify.MetadataResponse.md
#	docs/sdk/explorer/modules/base.md
#	docs/sdk/explorer/modules/block_explorer.md
#	docs/sdk/explorer/modules/log_explorer.md
#	docs/sdk/explorer/modules/sourcify.md
#	packages/cli/package.json
#	packages/cli/src/commands/account/register.test.ts
#	packages/cli/src/commands/account/set-name.test.ts
#	packages/cli/src/commands/governance/propose.test.ts
#	packages/cli/src/commands/governance/upvote.test.ts
#	packages/cli/src/commands/governance/withdraw.test.ts
#	packages/cli/src/commands/lockedgold/lock.test.ts
#	packages/cli/src/commands/lockedgold/unlock.test.ts
#	packages/cli/src/commands/lockedgold/update-delegated-amount.test.ts
#	packages/cli/src/commands/network/__snapshots__/contracts.test.ts.snap
#	packages/cli/src/commands/transfer/dollars.test.ts
#	packages/cli/src/commands/transfer/euros.test.ts
#	packages/cli/src/test-utils/cliUtils.ts
#	packages/docs/sdk/docs/explorer/modules/globals.md
#	packages/sdk/network-utils/jestSetup.ts
Copy link

socket-security bot commented Jun 25, 2024

New dependencies detected. Learn more about Socket for GitHub ↗︎

Package New capabilities Transitives Size Publisher
npm/[email protected] environment, eval, filesystem 0 1.23 MB zloirock
npm/[email protected] environment, eval, network +8 4.35 MB wheresrhys

View full report↗︎

Copy link

socket-security bot commented Jun 25, 2024

👍 Dependency issues cleared. Learn more about Socket for GitHub ↗︎

This PR previously contained dependency changes with security issues that have been resolved, removed, or ignored.

Ignoring: npm/[email protected]

View full report↗︎

Next steps

Take a deeper look at the dependency

Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support [AT] socket [DOT] dev.

Remove the package

If you happen to install a dependency that Socket reports as Known Malware you should immediately remove it and select a different dependency. For other alert types, you may may wish to investigate alternative packages or consider if there are other ways to mitigate the specific risk posed by the dependency.

Mark a package as acceptable risk

To ignore an alert, reply with a comment starting with @SocketSecurity ignore followed by a space separated list of ecosystem/package-name@version specifiers. e.g. @SocketSecurity ignore npm/[email protected] or ignore all packages with @SocketSecurity ignore-all

@aaronmgdr
Copy link
Member Author

it seems like fetch is not being intercepted by fetchMock anymore

@aaronmgdr
Copy link
Member Author

@SocketSecurity ignore npm/[email protected]

@aaronmgdr
Copy link
Member Author

Realizing for this to be actually usable we need to provide users with a way to add their own celoscan api key to celocli config and then pass it down and only call celoscan if the key is available.

Copy link
Contributor

This PR is stale and will be closed in 30 days without activity

@github-actions github-actions bot added the stale label Oct 26, 2024
@aaronmgdr aaronmgdr closed this Nov 14, 2024
auto-merge was automatically disabled November 14, 2024 14:34

Pull request was closed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support contracts verified via celoscan in governance:show command
2 participants