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

ABI embedding #31

Merged
merged 49 commits into from
Aug 29, 2022
Merged

ABI embedding #31

merged 49 commits into from
Aug 29, 2022

Conversation

miraclx
Copy link
Contributor

@miraclx miraclx commented Aug 21, 2022

Based off #23.

Introduces the cargo near build subcommand with the --embed-abi flag.

Building without the --embed-abi flag is effectively analogous to the convention of using ./build.sh to build contracts.

With the flag however, cargo near inspects the contract, generating ABI that describes the contract and thereafter, embeds it into the contract. Which can be returned by calling the view method __contract_abi.

Some numbers (compiling the abi example in sdk):

  • Without embedding ABI

    $ cargo near build --out-dir res --release
    $ wc -c < res/abi.wasm
    97313
  • With embedded ABI

    $ cargo near build --out-dir res --release --embed-abi
    $ wc -c < res/abi.wasm
    99081

That's an increase of 1768 bytes (1.78% of the final binary).

Related: near/near-sdk-rs#893

@miraclx miraclx changed the title use near-abi-rs ABI embedding Aug 21, 2022
cargo-near/src/lib.rs Show resolved Hide resolved
cargo-near/src/build.rs Outdated Show resolved Hide resolved
@miraclx miraclx linked an issue Aug 26, 2022 that may be closed by this pull request
Base automatically changed from miraclx/lib-abi to main August 26, 2022 22:23
cargo-near/src/util.rs Outdated Show resolved Hide resolved
cargo-near/src/build.rs Outdated Show resolved Hide resolved
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.

Allow developers to ignore abi generation Option to embed ABI within contract wasm metadata
3 participants