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

feat: multicall + contract error cleanup #56

Merged
merged 6 commits into from
Feb 8, 2023
Merged

feat: multicall + contract error cleanup #56

merged 6 commits into from
Feb 8, 2023

Conversation

jxom
Copy link
Member

@jxom jxom commented Feb 7, 2023

  • Added multicall
  • Support overloaded functions
  • Renamed humanMessage to shortMessage
  • Tightened up handling contract errors

@changeset-bot
Copy link

changeset-bot bot commented Feb 7, 2023

🦋 Changeset detected

Latest commit: 74b16a5

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

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

@vercel
Copy link

vercel bot commented Feb 7, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
viem-benchmark ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 9, 2023 at 0:02AM (UTC)
viem-playground ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 9, 2023 at 0:02AM (UTC)
viem-site ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 9, 2023 at 0:02AM (UTC)

@jxom jxom requested a review from tmm February 7, 2023 21:59
@@ -1,6 +1,16 @@
{
"files": {
"ignore": ["cache", "coverage", "node_modules", "dist", "generated", "CHANGELOG.md", "pnpm-lock.yaml", ".next"]
"ignore": [
"**/types/multicall.ts",
Copy link
Member Author

Choose a reason for hiding this comment

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

Rome doesn't support some TypeScript syntax for the multicall types, so I'm excluding it for now.

@github-actions
Copy link
Contributor

github-actions bot commented Feb 7, 2023

Size Change: +1.15 kB (+3%)

Total Size: 35.5 kB

Filename Size Change
dist/chunk-AZL5JWVK.js 0 B -18.5 kB (removed) 🏆
dist/chunk-EKCAJ44A.js 0 B -1.84 kB (removed) 🏆
dist/chunk-IL3YCVBH.js 0 B -1.52 kB (removed) 🏆
dist/chunk-UOROMU4F.js 0 B -1.35 kB (removed) 🏆
dist/chunk-V7FYHNEX.js 0 B -4.96 kB (removed) 🏆
dist/clients/index.js 288 B +1 B (0%)
dist/index.js 2.33 kB +214 B (+10%) ⚠️
dist/public.js 491 B -1 B (0%)
dist/test.js 512 B +1 B (0%)
dist/utils/index.js 882 B -2 B (0%)
dist/chunk-36OJLEHW.js 1.35 kB +1.35 kB (new file) 🆕
dist/chunk-G542SHAG.js 4.99 kB +4.99 kB (new file) 🆕
dist/chunk-IKQX7BFG.js 1.86 kB +1.86 kB (new file) 🆕
dist/chunk-R7HOX3JP.js 1.52 kB +1.52 kB (new file) 🆕
dist/chunk-WJDG6K5L.js 19.4 kB +19.4 kB (new file) 🆕
ℹ️ View Unchanged
Filename Size
dist/chains.js 1.3 kB
dist/ens.js 209 B
dist/wallet.js 296 B
dist/window.js 67 B

compressed-size-action

? (ContractConfig & TProperties)[]
: TContracts extends []
? []
: TContracts extends [infer Head extends Contract]
Copy link
Member Author

Choose a reason for hiding this comment

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

Rome doesn't like the [infer Head extends Contract] part. 😢

name: ExtractNameFromAbi<TAbi, TFunctionName>
} & Partial<ExtractArgsFromAbi<TAbi, TFunctionName>>

export function getAbiItem<
Copy link
Member Author

Choose a reason for hiding this comment

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

This change to support function overloads. Similar to normalizeFunctionName in wagmi.

decodedData = decodeErrorResult({ abi, data })
const { errorName, args: errorArgs } = decodedData
if (errorName === 'Error') reason = (errorArgs as string[])[0]
// TODO: Support Panic(uint256) & custom errors.
Copy link
Member Author

Choose a reason for hiding this comment

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

Will do this one in next PR.

@codecov
Copy link

codecov bot commented Feb 8, 2023

Codecov upload limit reached ⚠️

This org is currently on the free Basic Plan; which includes 250 free private repo uploads each rolling month. This limit has been reached and additional reports cannot be generated. For unlimited uploads, upgrade to our pro plan.

Do you have questions or need help? Connect with our sales team today at [email protected]

Copy link
Member

@tmm tmm left a comment

Choose a reason for hiding this comment

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

looks good!

initialBlockNumber,
publicClient,
usdcContractConfig,
vitalikAddress,
Copy link
Member

Choose a reason for hiding this comment

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

Not really part of the PR, but thoughts on making an address lookup? Could make it easier to import and use in tests since you only need to know single import versus multiple.

const address = {
  vitalik: '0x…',
  'wagmi-dev.eth': '0x…',
}

Copy link
Member Author

Choose a reason for hiding this comment

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

good idea! will do this in next pr

@@ -0,0 +1,556 @@
/* [Multicall3](https://github.com/mds1/multicall) */
export const multicallAbi = [
Copy link
Member

Choose a reason for hiding this comment

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

Should we call this multicall3Abi to be future-proof? I guess it might not matter though if it's just an implementation detail (e.g. we change to Multicall4 without needing to continue supporting Multicall3).

Copy link
Member Author

Choose a reason for hiding this comment

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

yup

details: string
docsPath?: string
metaMessages?: string[]
shortMessage: string
Copy link
Member

@tmm tmm Feb 8, 2023

Choose a reason for hiding this comment

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

Would I use shortMessage to display to users in interface, etc.?

/** Contract address */
address: Address
/** Function to invoke on the contract */
functionName: ExtractFunctionNameFromAbi<
Copy link
Member

Choose a reason for hiding this comment

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

Random thought: Instead of functionName should we call it just name everywhere?

Copy link
Member

Choose a reason for hiding this comment

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

Same goes for eventName

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, probably makes sense! can do that in next PR!

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.

2 participants