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

Smart contract schema support #274

Merged
merged 60 commits into from
Dec 12, 2023
Merged

Smart contract schema support #274

merged 60 commits into from
Dec 12, 2023

Conversation

magnusbechwind
Copy link
Contributor

@magnusbechwind magnusbechwind commented Oct 11, 2023

Purpose

Adds functionality for creating and serializing smart contract parameters as opposed to only allowing raw bytes as parameters.

Changes

Extended the FFI bindings to allow for passing parameters as json to the rust library and getting the serialized parameter back.

Added JNINError class allowing for error messages to be returned from the rust library.

Created a class, Schema, to represent smart contract schemas.

Created a class SchemaParameter to represent parameters serializable via a Schema.

Added from methods to InitContractPayload and UpdateContractPayload accepting the new SchemaParameter.

Implemented custom serialization of AbstractAddress and added ListParam, AccountAddressParam, AddressParam and ContractAddressParam for conveniently using lists of objects, AbstractAddress, ContractAddress and AccountAddress as smart contract parameters.

Extended the examples with Cis2Nft and Cis2WCCD demonstrating how to instantiate parameters for the different smart contract methods present in the cis2-nft and cis2-wCCD contracts.

Checklist

  • My code follows the style of this project.
  • The code compiles without warnings.
  • I have performed a self-review of the changes.
  • I have documented my code, in particular the intent of the
    hard-to-understand areas.
  • (If necessary) I have updated the CHANGELOG.

Custom serialization of AbstractAddress.
Refactoring of Errors returned from JNI rust layer.
Refactoring of BakerKeys- ConfigureBakerKeys- TransferToPublicJni- Result to remove Optional fields.
…eInstanceRequest with SchemaReceiveParameter
Added option to construct Schema from an InputStream
Added option to construct Schema from an InputStream
… ContractAddress for passing directly as parameters. Moved smart contract related stuff to transactions.smartcontracts. Moved test resources.
…r wrapCCD) implemented and initializes correctly
@magnusbechwind magnusbechwind marked this pull request as draft October 11, 2023 14:16
# Conflicts:
#	concordium-sdk/src/main/java/com/concordium/sdk/crypto/bakertransactions/BakerKeysResult.java
#	concordium-sdk/src/main/java/com/concordium/sdk/transactions/UpdateContractPayload.java
#	concordium-sdk/src/main/java/com/concordium/sdk/types/AccountAddress.java
CHANGELOG.md Outdated Show resolved Hide resolved
crypto-jni/src/lib.rs Outdated Show resolved Hide resolved
crypto-jni/src/lib.rs Outdated Show resolved Hide resolved
crypto-jni/src/lib.rs Show resolved Hide resolved
crypto-jni/src/lib.rs Show resolved Hide resolved
crypto-jni/src/lib.rs Outdated Show resolved Hide resolved
Copy link
Contributor

@MilkywayPirate MilkywayPirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A few extra comments for now

Copy link
Contributor

@MilkywayPirate MilkywayPirate left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks great. GJ.

Copy link
Contributor

@abizjak abizjak left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If it's not there, as it appears not to be, please add clippy & formatting to the rust JNI bindings, using the standard rustfmt.toml config from concordium-base.

crypto-jni/src/lib.rs Outdated Show resolved Hide resolved
crypto-jni/src/lib.rs Outdated Show resolved Hide resolved
crypto-jni/src/lib.rs Outdated Show resolved Hide resolved
crypto-jni/src/lib.rs Outdated Show resolved Hide resolved
magnusbechwind and others added 6 commits December 12, 2023 10:57
Co-authored-by: Aleš Bizjak <abizjak@users.noreply.github.com>
# Conflicts:
#	CHANGELOG.md
#	concordium-sdk/src/main/java/com/concordium/sdk/transactions/Hash.java
@magnusbechwind magnusbechwind merged commit 102c806 into main Dec 12, 2023
1 check passed
@magnusbechwind magnusbechwind deleted the smartContractSchema branch December 12, 2023 12:01
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.

Smart contract schema support
3 participants