-
-
Notifications
You must be signed in to change notification settings - Fork 838
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: add inference to getLogs
event
#363
Conversation
🦋 Changeset detectedLatest commit: 3f8d114 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 |
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
Size Change: 0 B Total Size: 246 kB ℹ️ View Unchanged
|
Imho, there's also another issue with This woudl be better imho: export function getAbiItem<
TAbi extends Abi | readonly unknown[],
TItemName extends string,
>({
abi,
args = [],
name,
}: GetAbiItemParameters<TAbi, TItemName>): GetAbiItemReturnType<
TAbi,
TItemName
> {
const abiItems = (abi as Abi).filter((x) => 'name' in x && x.name === name)
if (abiItems.length === 0) return undefined as any
for (const abiItem of abiItems) {
if (!('inputs' in abiItem)) continue
if (!args || args.length === 0) {
if (!abiItem.inputs || abiItem.inputs.length === 0) return abiItem as any
continue
}
if (!abiItem.inputs) continue
if (abiItem.inputs.length === 0) continue
const matched = (args as readonly unknown[]).every((arg, index) => {
const abiParameter = 'inputs' in abiItem && abiItem.inputs![index]
if (!abiParameter) return false
return isArgOfType(arg, abiParameter as AbiParameter)
})
if (matched) return abiItem as any
}
return abiItems[0] as any
} |
Codecov Report
@@ Coverage Diff @@
## main #363 +/- ##
=======================================
Coverage 99.88% 99.88%
=======================================
Files 264 264
Lines 19714 19714
Branches 1848 1850 +2
=======================================
Hits 19692 19692
Misses 20 20
Partials 2 2
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
@fubhy nice catch! Want to make that a separate PR? |
Adds type inference to
getLogs
event
property#359 (reply in thread)
Automated Summary
🤖 Generated by Copilot at 3f8d114
This pull request enhances the type inference of the
getLogs
function, which fetches logs from a smart contract event. It uses theNarrow
andAbiEvent
types fromabitype
to narrow down the possible types of theevent
parameter and the returned logs. It also adds some type tests usingvitest
and documents the changeset in a markdown file.