Crate-level ABI declaration for ink! entities #2479
Labels
B-design
Designing a new component, interface or functionality.
Breaking change
This PR of issue introduces a breaking change
Uh oh!
There was an error while loading. Please reload this page.
Background
ink! v6 supports both the native ink! and Solidity ABI specifications.
Currently, ink! contracts can specify the target ABI using the
abi
config argument of the contract attribute macro (i.e.#[ink::contract(abi = "..")]
).Motivation
However, this means the specified ABI is only accessible to the contract attribute proc-macro during codegen.
This is problematic because the specified ABI is also relevant to other ink! entities (e.g. trait definitions, events and - in the future - errors) that can be defined either outside of contract module, or in separate standalone crates.
Design
Introduce a
Cargo.toml
section[package.metadata.ink-lang]
with a fieldabi
and possible values"ink"
,"sol"
and"all"
e.g.NOTE: Cargo will warn about "unused" keys by default except for keys in
"package.metadata"
(see details)Introduce a rustc
cfg
setting/flagink_abi
with possible values"ink"
,"sol"
and"all"
which is used to propagate thepackage.metadata.ink-lang.abi
value defined inCargo.toml
as described above into the build environmentUpdate
cargo-contract
to:package.metadata.ink-lang.abi
field fromCargo.toml
(if present)ink_abi
cfg
flag as appropriate (e.g.--cfg 'ink_abi="sol"'
)cargo contract new
subcommand to support ABI specification via a CLI arg (i.e.cargo contract new --abi <ink|sol|all>
)cargo contract test
subcommand for propagating the ABI specified inCargo.toml
into the build environment for testsUpdate proc-macros for ink! entities to support the new
cfg
option (e.g.#[cfg(ink_abi = "sol")]
- see also) to generate ABI specific codeImplementation
cargo-contract
Cargo.toml
and propagate ABI into build environment viacfg
flag cargo-contract#2033cargo contract test
subcommand cargo-contract#2034ink
cfg
flag in codegen #2501Docs
cargo test
withcargo contract test
in ink! v6 docs ink-docs#410The text was updated successfully, but these errors were encountered: