Releases: radixdlt/radix-engine-toolkit
v0.7.0
Betanet
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, theserde
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 onDeriveNonFungibleAddressFromPublicKeyResponse
request is now aValue::NonFungibleAddress
and not a string. -
The
resource_address
andnon_fungible_id
fields on theDeriveNonFungibleAddressRequest
request are nowValue::ResourceAddress
andValue::NonFungibleId
respectively. -
The
non_fungible_address
field onDeriveNonFungibleAddressResponse
request is now aValue::NonFungibleAddress
and not a string. -
The
virtual_account_address
field onDeriveVirtualAccountAddressResponse
request is now aValue::ComponentAddress
and not a string. -
The
DeriveNonFungibleAddressFromPublicKeyRequest
request now has an additionalnetwork_id
field which is used for the encoding of the resource address of the derivedNonFungibleAddress
. -
The
public_key
field on theDeriveNonFungibleAddressFromPublicKeyRequest
used to be flattened as it was treated as a type alias ofPublicKey
. With the introduction of thenetwork_id
field, thepublic_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 toValue
to be serialized asValue
. This makes the serialization of data more consistent as in the past, some requests returned representations of data which was inconsistent with theValue
model.- With the introduction of this proxy, the traits
From<Type>
andTryFrom<Value> for Type
has been implemented for a number of types to allow them to be serialized through theValueSerializationProxy
.
- With the introduction of this proxy, the traits
-
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 theValue
struct itself and have renamed:ast_value_from_value
has been moved and renamed toValue::to_ast_value
value_from_ast_value
has been moved and renamed toValue::from_ast_value
sbor_value_from_value
has been moved and renamed toValue::to_scrypto_value
value_from_sbor_value
has been moved and renamed toValue::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 ofNonFungibleId
s has changed. The following is an example of what aValue::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 ofNonFungibleAddress
es has been updated to be more human readable to reflect the changes made in the Scrypto repo. Below is an example of twoNonFungibleAddress
es 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
NonFungibleId
s andNonFungibleAddress
es, this version adds serialization proxies for theNonFungibleId
andNonFungibleAddress
type (NonFungibleIdProxy
andNonFungibleAddressProxy
respectively) to achieve the serialization format shown above. -
Added a
Bytes
type to the value model. -
The
Map
,Struct
,List
, andSet
types have been removed from theValue
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 toInstruction::to_ast_instruction
instruction_from_ast_instruction
has been moved and renamed toInstruction::from_ast_instruction
-
The
PublishPackage
instruction has been renamed toPublishPackageWithOwner
and has had an additionalowner_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 theSborEncode
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 thestd::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 additionalnetwork_id
field. - The
public_key
field on theDeriveNonFungibleAddressFromPublicKeyRequest
is no longer flattened. DeriveVirtualAccountAddressResponse
'svirtual_account_address
field is now aValue::ComponentAddress
and not a string.DeriveNonFungibleAddressFromPublicKeyResponse
'snon_fungible_address
field is now aValue::NonFungibleAddress
and not a string.DeriveNonFungibleAddressResponse
'snon_fungible_address
field is now aValue::NonFungibleAddress
and not a string.DeriveNonFungibleAddressRequest
'sresource_address
field is now aValue::ResourceAddress
and not a string.DeriveNonFungibleAddressRequest
'snon_fungible_id
field is now aValue::NonFungibleId
and not a string.- The serialization of
NonFungibleId
s have changed where they now have "variant" and "value" fields. - The serialization of
NonFungibleAddress
s has been changed to be more human-readable.
*...