-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
feat: ABI refactor #3085
base: master
Are you sure you want to change the base?
feat: ABI refactor #3085
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
1 Skipped Deployment
|
--- | ||
--- | ||
|
||
feat: ABI refactor |
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.
Note
This is not to be merged until we've concluded development
…/feat/abi-refactor
Coverage Report:
Changed Files:Coverage values did not change👌. |
* feat: ABI parser * remove casts * remove unnecessary throw * centralize abi cleanup logic * remove rawUntypedPtr from swayTypeMatchers * rename method * Update cleanup-abi.ts * Update cleanup-abi.ts * refactor abi type mappers * refactor into using maps for types * refactor from array of tuples into `Map` * rename variables * refactorings, comments * split test up into multiple tests --------- Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk>
* parser scaffolding * lint fix * chore: ABI parser - API alterations (#3164) * Add `AbiTypeMetadata` and fix bug * chore: adjust attributes to match spec * chore: added `FuelError` * chore: fixed test for matchers * fix generic type resolution edge case * changeset * refactoring, commenting * chore: favour `concreteTypeId` * chore: fix up errors for the parser specification * docs: added error code * chore: nit * chore: attribute arguments always defined * chore: fix incorrect inline attribute arguments * chore: re-adjusted `mapAttribute` * chore: added helper functions for finding concreteTypes and metadataTypes * chore: removed static methods + further `findConcreteType` + `findMetadataType` simplifications * chore: more verbose variable names * chore: constructor as first public method * chore: rename `type` for `swayType` * chore: removed `specVersion` * add comments * chore: added name to typeArguments * comments * fix? * fix? * chore: rollback to working state * refactoring * add test group * revert changes * format projects * export parser from fuels * cleanup * renamings * renamings * add comments to `Abi` * add docs * update docs * rename test * rename to * formatting * more explanations * cleaner * formatting * comments * add double generic case * fix test * update changeset * revert * fix changeset * not breaking * fix test * add import check * fix linting * fix lint * add comments to abi interface * Update .changeset/tender-tigers-fry.md Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com> * fix changeset * add implicit generic edge case * feat: ABI Gen * fix storage slots and imports in tests * fix linting * fix linting * Update .changeset/poor-years-hang.md Co-authored-by: Peter Smith <peter@blueoceancomputing.co.uk> * improve type arguments representation * fix type arguments * explanatory comment * move types to separate file * move fixtures into folders * move `mapComponents` and add explanations * move logic to shared folder * add type docs explaining functions * add doc blocks for `AbiGen` and related types * remove unnecessary flags * remove todo * input/output * feat: ABI parser * remove casts * remove unnecessary throw * centralize abi cleanup logic * remove rawUntypedPtr from swayTypeMatchers * remove rawUntypedPtr * made `abi` and `storage-slots` ts files * move from linting to cast * remove usage of `fuels-typegen` * change to `FuelError` * simplify inputs/output types for script and predicate * improve index file rendering * export types from base program file (and thus index) * cleanup type rendering * simplified program rendering * fix recipes * reorder deps * refactor render-index-files * remove file * update changeset * fix changeset * fix recipes build * fix test * cleanup * fix knip * fix lint * export inputs, outputs and configurables * rename method * Update cleanup-abi.ts * Update cleanup-abi.ts * refactor abi type mappers * refactor into using maps for types * refactor from array of tuples into `Map` * rename variables * refactorings, comments * split test up into multiple tests * remove already included --silent flag * added non-happy paths testing * mvoed cli into abi package * cleanup * export types from contract/predicate/script * improve upon index exports now that types are also re-exported * fix pnpm-lock.yaml * rename * fix recipes * log instead of throwing * fix lint * add `forc` and `fuel-core` to path * try again * try again * fix lint * Increase timeout * cleanup * revert timeout * chore: use playwright in browser tests * revert isolate flag for safety * revert some changes * update docs * update imports * revert file * revert input * fix import * update * revert file * remove flags * fix lint * lock file fix * fix tests * fix lint * fix lint 2 * fix lock file * chore: sync build * chore: removed `Vec` --------- Co-authored-by: nedsalk <nedim.salkic@fuel.sh> Co-authored-by: Chad Nehemiah <chad.nehemiah94@gmail.com>
export function getProgramDetails(paths: string[]) { | ||
const details: ProgramDetails[] = []; | ||
paths.forEach((path) => { | ||
const abiPath = path.match(/.+-abi\.json/) ? path : globSync(`${path}/*-abi.json`)[0]; |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High generated
regular expression
library input
return; | ||
} | ||
|
||
const dir = abiPath.match(/.*\//)?.[0] as string; |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High generated
regular expression
library input
} | ||
|
||
const dir = abiPath.match(/.*\//)?.[0] as string; | ||
const projectName = abiPath.match(/([^/])+(?=-abi\.json)/)?.[0] as string; |
Check failure
Code scanning / CodeQL
Polynomial regular expression used on uncontrolled data High generated
regular expression
library input
* feat: ABI parser * feat: ABI coder * remove casts * remove unnecessary throw * centralize abi cleanup logic * fix function signature for bytes * remove rawUntypedPtr from swayTypeMatchers * remove rawUntypedPtr from swayTypeMatchers * remove rawUntypedPtr * fix lint * rename method * Update cleanup-abi.ts * Update cleanup-abi.ts * refactor abi type mappers * refactor into using maps for types * refactor from array of tuples into `Map` * rename variables * refactor out function * fix comments, add comments * refactorings, comments * split test up into multiple tests * docs: update variable * chore: applying unsafe integer validation * chore: refactored coder matchers * chore: perform renames * chore: fix package version * chore: missing lock file * chore: finalize integration with the ABI * chore: remove parser from export * chore: added auto-update for typegen fixtures * chore: added auto-update for typegen fixtures * chore: updated fixtures * chore: removed unused dependency --------- Co-authored-by: nedsalk <nedim.salkic@fuel.sh>
Release notes
In this release, we:
@fuel-ts/abi
for all things ABI relatedSummary
AbiParser
which will transform an ABI into an easier to use entity.Breakdown
ABI Parser
Summary
Adds the parsing functionality for an ABI. The
Abi
interface outputted byAbiParser
will be the (hopefully) unchanging interface that will be used both by us in coders and typers, as well as external users who wish to work with the abi but not be affected by changing specifications.The
AbiParser
output is tested both by a comprehensive test in this PR as well as feat!: ABI Gen #3249 and feat: ABI coder #3402 which are based off of this PR and are directly consuming the output.Flow diagrams
ABI Typegen
Summary
The implementation has two parts:
1.
AbiGen
and its type generation which is done by using theAbiParser
outputs,2. The CLI providing inputs to
AbiGen
and saving its outputs to diskABI Coder
Summary
Breaking Changes
fuels typegen
no longer accepts-s
,-p
and-c
flagspnpm fuels typegen
can now automatically recognize the type of program it's building so the flags--script
,--predicate
and--contract
and their shorthands have been removed.The
storageSlots
static field has been moved from a typegen'd contract into its factoryStorage slots don't need to be on the typegen'd
Contract
because they are only used during contract deployment.Typegen'd simple sway enums don't have the
Input
/Output
suffix anymoreGiven the following enum:
The outputted type looks like this:
Vec<T>
has been removed in favor ofT[]
and cannot be imported anymoreThe
Interface
class has been removed in favour of theAbiCoder
.The
Interface.decodeFunctionResult
has moved to theAbiCoderFunction.decodeOutput
The
Interface.decodeLog
has moved to theAbiCoderLog.decode
The
Interface.encodeConfigurable
has moved to theAbiCoderConfigurable.encode
The
Interface.encodeType
andInterface.encodeType
has moved to theAbiCoderType
Accessing underlying coders is now achieved through a convenient class,
AbiEncoding
.Removal of the constant
INPUT_COIN_FIXED_SIZE
Renamed
Encoding
from the@fuel-ts/crypto
package toBufferEncoding
.Checklist