-
-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
BREAKING feat(core): use human readable abis (#486)
## Description Make the type used by EVMts human readable abis ## Testing Explain the quality checks that have been done on the code changes ## Additional Information - [ ] I read the [contributing docs](../docs/contributing.md) (if this is your first contribution) Your ENS/address: --------- Co-authored-by: Will Cory <[email protected]>
- Loading branch information
1 parent
b8a8440
commit a1b10f2
Showing
32 changed files
with
511 additions
and
1,088 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
--- | ||
"@evmts/core": major | ||
--- | ||
|
||
Changed EvmtsContract to use human readable ABIs by default | ||
|
||
Before | ||
<img width="429" alt="image" src="https://github.com/evmts/evmts-monorepo/assets/35039927/74ce632f-bc39-4cc7-85ee-1f6cd0014005"> | ||
|
||
After | ||
<img width="527" alt="image" src="https://github.com/evmts/evmts-monorepo/assets/35039927/4f4ea9a6-adfb-4751-9446-dd721118f3a9"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,16 @@ | ||
import type { Events } from './event/Event' | ||
import type { Read } from './read/Read' | ||
import type { Write } from './write/Write' | ||
import type { Abi, FormatAbi } from 'abitype' | ||
import type { ParseAbi } from 'abitype' | ||
|
||
export type EvmtsContract< | ||
TName extends string, | ||
TAbi extends Abi, | ||
THumanReadableAbi = FormatAbi<TAbi>, | ||
THumanReadableAbi extends ReadonlyArray<string>, | ||
> = { | ||
abi: TAbi | ||
abi: ParseAbi<THumanReadableAbi> | ||
humanReadableAbi: THumanReadableAbi | ||
name: TName | ||
events: Events<TName, TAbi> | ||
read: Read<TName, TAbi> | ||
write: Write<TName, TAbi> | ||
events: Events<TName, THumanReadableAbi> | ||
read: Read<TName, THumanReadableAbi> | ||
write: Write<TName, THumanReadableAbi> | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,52 @@ | ||
import type { | ||
Abi, | ||
ExtractAbiEvent, | ||
ExtractAbiEventNames, | ||
FormatAbi, | ||
ParseAbi, | ||
} from 'abitype' | ||
import type { BlockNumber, BlockTag, CreateEventFilterParameters } from 'viem' | ||
import type { MaybeExtractEventArgsFromAbi } from 'viem/dist/types/types/contract' | ||
|
||
export type ValueOf<T> = T[keyof T] | ||
|
||
export type Events<TName extends string, TAbi extends Abi> = { | ||
[TEventName in ExtractAbiEventNames<TAbi>]: (< | ||
export type Events< | ||
TName extends string, | ||
THumanReadableAbi extends readonly string[], | ||
> = { | ||
[TEventName in ExtractAbiEventNames<ParseAbi<THumanReadableAbi>>]: (< | ||
TStrict extends boolean = false, | ||
TFromBlock extends BlockNumber | BlockTag | undefined = undefined, | ||
TToBlock extends BlockNumber | BlockTag | undefined = undefined, | ||
>( | ||
params: Pick< | ||
CreateEventFilterParameters< | ||
ExtractAbiEvent<TAbi, TEventName>, | ||
TAbi, | ||
ExtractAbiEvent<ParseAbi<THumanReadableAbi>, TEventName>, | ||
ParseAbi<THumanReadableAbi>, | ||
TStrict, | ||
TFromBlock, | ||
TToBlock, | ||
TEventName, | ||
MaybeExtractEventArgsFromAbi<TAbi, TEventName> | ||
MaybeExtractEventArgsFromAbi<ParseAbi<THumanReadableAbi>, TEventName> | ||
>, | ||
'fromBlock' | 'toBlock' | 'args' | 'strict' | ||
>, | ||
) => CreateEventFilterParameters< | ||
ExtractAbiEvent<TAbi, TEventName>, | ||
TAbi, | ||
ExtractAbiEvent<ParseAbi<THumanReadableAbi>, TEventName>, | ||
ParseAbi<THumanReadableAbi>, | ||
TStrict, | ||
TFromBlock, | ||
TToBlock, | ||
TEventName, | ||
MaybeExtractEventArgsFromAbi<TAbi, TEventName> | ||
MaybeExtractEventArgsFromAbi<ParseAbi<THumanReadableAbi>, TEventName> | ||
> & { | ||
evmtsContractName: TName | ||
eventName: TEventName | ||
abi: [ExtractAbiEvent<TAbi, TEventName>] | ||
abi: [ExtractAbiEvent<ParseAbi<THumanReadableAbi>, TEventName>] | ||
}) & { | ||
eventName: TEventName | ||
abi: [ExtractAbiEvent<TAbi, TEventName>] | ||
humanReadableAbi: FormatAbi<[ExtractAbiEvent<TAbi, TEventName>]> | ||
humanReadableAbi: FormatAbi< | ||
[ExtractAbiEvent<ParseAbi<THumanReadableAbi>, TEventName>] | ||
> | ||
abi: [ExtractAbiEvent<ParseAbi<THumanReadableAbi>, TEventName>] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
export * from './EvmtsContract' | ||
export * from './evmtsContractFactory' | ||
// reexported because they are needed to be able to | ||
// instanciate an EvmtsContract with a json abi | ||
export { formatAbi, parseAbi } from 'abitype' |
Oops, something went wrong.
a1b10f2
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Successfully deployed to the following URLs:
evmts-docs – ./
evmts-docs-evmts.vercel.app
evmts-docs-git-main-evmts.vercel.app
evmts.dev