Skip to content

Releases: radixdlt/radix-engine-toolkit

v0.7.0

29 Dec 20:59
v0.7.0
34cb99c
Compare
Choose a tag to compare
v0.7.0

Betanet

14 Dec 10:07
betanet-v1-60f7342
60f7342
Compare
Choose a tag to compare

Betanet

This release of the Radix Engine Toolkit updates it for the Betanet release of Scrypto and the Radix Engine. This release of the toolkit comes with little new functionality but with a number of changes which make the toolkit more stable, have more consistent messages, and overall better.

General Changes

  • The Radix Engine Toolkit is now licensed under the Apache 2.0 license.
  • There has been a number of directory re-structures made to the radix-engine-toolkit-core crate. More specifically, the serde module has been removed and replaced with multiple smaller modules with the models that the toolkit relies on.

Request Models

The changes below are made to be consistent in the structure of requests. Some requests had fields which were serialized in a different way to the serialization strategy adopted by the Value model. This meant that some clients could not rely on the Value model(s) for serialization and deserialization of data from these requests and instead needed to write or rely on other models.

The changes listed below are all made so that the all non-primitive type fields are serialized through the Value model. That means that these fields will now be serialized as JSON objects with a "type" field and some field(s) of the value(s).

  • The non_fungible_address field on DeriveNonFungibleAddressFromPublicKeyResponse request is now a Value::NonFungibleAddress and not a string.

  • The resource_address and non_fungible_id fields on the DeriveNonFungibleAddressRequest request are now Value::ResourceAddress and Value::NonFungibleId respectively.

  • The non_fungible_address field on DeriveNonFungibleAddressResponse request is now a Value::NonFungibleAddress and not a string.

  • The virtual_account_address field on DeriveVirtualAccountAddressResponse request is now a Value::ComponentAddress and not a string.

  • The DeriveNonFungibleAddressFromPublicKeyRequest request now has an additional network_id field which is used for the encoding of the resource address of the derived NonFungibleAddress.

  • The public_key field on the DeriveNonFungibleAddressFromPublicKeyRequest used to be flattened as it was treated as a type alias of PublicKey. With the introduction of the network_id field, the public_key field is no longer flattened.

    Pre-Betanet Betanet
     {
     	"public_key": "03dd19f6d25ced44be67e87ce68fca053f3058a1b8382f297d7df54d6e71c1ba45",
     	"type": "EcdsaSecp256k1",
     }
     {
     	"public_key": {
     		"public_key": "03dd19f6d25ced44be67e87ce68fca053f3058a1b8382f297d7df54d6e71c1ba45",
     		"type": "EcdsaSecp256k1"
     	},
     	"network_id": 1
     }

Value Model

  • Introduced the ValueSerializationProxy serializer which allows for types convertible from and to Value to be serialized as Value. This makes the serialization of data more consistent as in the past, some requests returned representations of data which was inconsistent with the Value model.

    • With the introduction of this proxy, the traits From<Type> and TryFrom<Value> for Type has been implemented for a number of types to allow them to be serialized through the ValueSerializationProxy.
  • The functions needed to convert a value into an AST Value and back again, to convert it into an SBOR value (now called ScryptoValue in the latest release of Scrypto) and back again are now implemented on the Value struct itself and have renamed:

    • ast_value_from_value has been moved and renamed to Value::to_ast_value
    • value_from_ast_value has been moved and renamed to Value::from_ast_value
    • sbor_value_from_value has been moved and renamed to Value::to_scrypto_value
    • value_from_sbor_value has been moved and renamed to Value::from_scrypto_value
  • The recent version of Scrypto changed the NonFungibleId from being any SBOR byte array to being an enum of a set of allowed types. With this change, the serialization of NonFungibleIds has changed. The following is an example of what a Value::NonFungibleId of "HelloWorld" used to look like and what it looks looks like now:

    Pre-Betanet Betanet
     {
     	"type": "NonFungibleId",
     	"value": "0c0a00000048656c6c6f576f726c64"
     }
     {
     	"type": "NonFungibleId",
     	"variant": "String",
     	"value": "HelloWorld"
     }
  • The recent version of Scrypto changed the NonFungibleAddress' manifest representation from being just a hex-encoded string to being more human readable. The serialization of NonFungibleAddresses has been updated to be more human readable to reflect the changes made in the Scrypto repo. Below is an example of two NonFungibleAddresses and how they were serialized before and after this update.

    Pre-Betanet Betanet
     {
     	"type": "NonFungibleAddress",
     	"address": "00938664addbb9b2b554a114c0493e12633c58da18772cc36d9e960a404a000000000000"
     }
     {
     	"type": "NonFungibleAddress",
     	"resource_address": {
     		"type": "ResourceAddress",
     		"address": "resource_sim1qzfcve9dmwum9d255y2vqjf7zf3nckx6rpmjesmdn6tqz84430"
     	},
     	"non_fungible_id": {
     		"type": "NonFungibleId",
     		"variant": "U64",
     		"value": "19008"
     	}
     }
  • With the aforementioned changes to the NonFungibleIds and NonFungibleAddresses, this version adds serialization proxies for the NonFungibleId and NonFungibleAddress type (NonFungibleIdProxy and NonFungibleAddressProxy respectively) to achieve the serialization format shown above.

  • Added a Bytes type to the value model.

  • The Map, Struct, List, and Set types have been removed from the Value model to be consistent with Scrypto's transaction compiler and SBOR model.

Instruction Model

  • The instruction model is now structured and strongly typed. This is made possible by the introduction of the ValueSerializationProxy. This change makes instructions require less validation, makes them easier to work with, and reduces the mental overhead of the instruction model. The following is an example of one of the variants from the old and new instruction models.

    Pre-Betanet Betanet
     #[derive(Serialize, Deserialize)]
     pub enum Instruction {
     	TakeFromWorktopByIds {
     		ids: HashSet<Value>,
     		resource_address: Value,
     		into_bucket: Value,
     	},
     }
     #[derive(Serialize, Deserialize)]
     pub enum Instruction {
     	TakeFromWorktopByIds {
     		#[serde_as(as = "HashSet<ValueSerializationProxy>")]
     		ids: HashSet<NonFungibleId>,
    
     		#[serde_as(as = "ValueSerializationProxy")]
     		resource_address: NetworkAwareResourceAddress,
    
     		#[serde_as(as = "ValueSerializationProxy")]
     		into_bucket: BucketId,
     	},
     }
  • The functions needed to convert an instruction into an AST Instruction and back again are now implemented on the Instruction struct itself and have renamed:

    • ast_instruction_from_instruction has been moved and renamed to Instruction::to_ast_instruction
    • instruction_from_ast_instruction has been moved and renamed to Instruction::from_ast_instruction
  • The PublishPackage instruction has been renamed to PublishPackageWithOwner and has had an additional owner_badge field added to it to be consistent with Scrypto's transaction compiler.

Radix Engine Node Identifier (RENodeId) Model

  • Added a new RENode type for the Clock Radix Engine Node.

Errors

  • SBOR encode operations could succeed or return an SborEncodeError if there were errors encountered when performing the encoding. This applies to the SborEncode requests and the transaction compilation requests.
  • A HexDecodeError type has been added for situations where the decoding of hex strings fails.
  • The Error type now has an implementation for the std::fmt::Display trait. The implementation displays errors in an identical way to the debug trait.

Miscellaneous Changes

  • The toolkit now comes with a built script at the root of the repo to build it for all of the supported targets and output the builds to a directory.
    • Note: Building can potentially take long since some targets rely on cross-rs which takes a while to build for certain targets. A better solution is needed in the future.

Summary of Interface Changes for Integrators

  • The DeriveNonFungibleAddressFromPublicKeyRequest now has an additional network_id field.
  • The public_key field on the DeriveNonFungibleAddressFromPublicKeyRequest is no longer flattened.
  • DeriveVirtualAccountAddressResponse's virtual_account_address field is now a Value::ComponentAddress and not a string.
  • DeriveNonFungibleAddressFromPublicKeyResponse's non_fungible_address field is now a Value::NonFungibleAddress and not a string.
  • DeriveNonFungibleAddressResponse's non_fungible_address field is now a Value::NonFungibleAddress and not a string.
  • DeriveNonFungibleAddressRequest's resource_address field is now a Value::ResourceAddress and not a string.
  • DeriveNonFungibleAddressRequest's non_fungible_id field is now a Value::NonFungibleId and not a string.
  • The serialization of NonFungibleIds have changed where they now have "variant" and "value" fields.
  • The serialization of NonFungibleAddresss has been changed to be more human-readable.
    *...
Read more