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

Sponsored tx part1 #329

Merged
merged 12 commits into from
Aug 15, 2023
1 change: 1 addition & 0 deletions concordium-cis2/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

## Unreleased changes

- Derive `PartialEq` and `Eq` for the `TransferEvent`, `MintEvent`, `BurnEvent`, `UpdateOperatorEvent`, `TokenMetadataEvent`, `OperatorUpdate`, and `UpdateOperator` types.
- Added `Cis2Client` to the library. This can be used from one smart contract to call into other cis2 compatible smart contracts in a type safe way.

## concordium-cis2 4.0.0 (2023-06-16)
Expand Down
32 changes: 25 additions & 7 deletions concordium-cis2/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -712,7 +712,7 @@ pub use u256_token::*;
/// another. For a tagged version, use `Cis2Event`.
// Note: For the serialization to be derived according to the CIS2
// specification, the order of the fields cannot be changed.
#[derive(Debug, Serialize, SchemaType)]
#[derive(Debug, Serialize, SchemaType, PartialEq, Eq)]
pub struct TransferEvent<T: IsTokenId, A: IsTokenAmount> {
/// The ID of the token being transferred.
pub token_id: T,
Expand All @@ -729,7 +729,7 @@ pub struct TransferEvent<T: IsTokenId, A: IsTokenAmount> {
/// For a tagged version, use `Cis2Event`.
// Note: For the serialization to be derived according to the CIS2
// specification, the order of the fields cannot be changed.
#[derive(Debug, Serialize, SchemaType)]
#[derive(Debug, Serialize, SchemaType, PartialEq, Eq)]
pub struct MintEvent<T: IsTokenId, A: IsTokenAmount> {
/// The ID of the token being minted, (possibly a new token ID).
pub token_id: T,
Expand All @@ -743,7 +743,7 @@ pub struct MintEvent<T: IsTokenId, A: IsTokenAmount> {
/// For a tagged version, use `Cis2Event`.
// Note: For the serialization to be derived according to the CIS2
// specification, the order of the fields cannot be changed.
#[derive(Debug, Serialize, SchemaType)]
#[derive(Debug, Serialize, SchemaType, PartialEq, Eq)]
pub struct BurnEvent<T: IsTokenId, A: IsTokenAmount> {
/// The ID of the token where an amount is being burned.
pub token_id: T,
Expand All @@ -757,7 +757,7 @@ pub struct BurnEvent<T: IsTokenId, A: IsTokenAmount> {
/// For a tagged version, use `Cis2Event`.
// Note: For the serialization to be derived according to the CIS2
// specification, the order of the fields cannot be changed.
#[derive(Debug, Serialize, SchemaType)]
#[derive(Debug, Serialize, SchemaType, PartialEq, Eq)]
pub struct UpdateOperatorEvent {
/// The update to the operator.
pub update: OperatorUpdate,
Expand All @@ -771,7 +771,7 @@ pub struct UpdateOperatorEvent {
/// For a tagged version, use `Cis2Event`.
// Note: For the serialization to be derived according to the CIS2
// specification, the order of the fields cannot be changed.
#[derive(Debug, Serialize, SchemaType)]
#[derive(Debug, Serialize, SchemaType, PartialEq, Eq)]
pub struct TokenMetadataEvent<T: IsTokenId> {
/// The ID of the token.
pub token_id: T,
Expand Down Expand Up @@ -978,6 +978,24 @@ where
fn from(err: NewReceiveNameError) -> Self { Cis2Error::Custom(X::from(err)) }
}

impl<X> From<CheckAccountSignatureError> for Cis2Error<X>
where
X: From<CheckAccountSignatureError>,
{
#[inline]
/// Converts the error by wrapping it in [Self::Custom].
fn from(err: CheckAccountSignatureError) -> Self { Cis2Error::Custom(X::from(err)) }
}

impl<X> From<QueryAccountPublicKeysError> for Cis2Error<X>
where
X: From<QueryAccountPublicKeysError>,
{
#[inline]
/// Converts the error by wrapping it in [Self::Custom].
fn from(err: QueryAccountPublicKeysError) -> Self { Cis2Error::Custom(X::from(err)) }
}

impl<X> From<NewContractNameError> for Cis2Error<X>
where
X: From<NewContractNameError>,
Expand Down Expand Up @@ -1084,7 +1102,7 @@ impl<T: IsTokenId, A: IsTokenAmount> AsRef<[Transfer<T, A>]> for TransferParams<
/// The update to an the operator.
// Note: For the serialization to be derived according to the CIS2
// specification, the order of the variants cannot be changed.
#[derive(Debug, Serialize, Clone, Copy, SchemaType)]
#[derive(Debug, Serialize, Clone, Copy, SchemaType, PartialEq, Eq)]
pub enum OperatorUpdate {
/// Remove the operator.
Remove,
Expand All @@ -1095,7 +1113,7 @@ pub enum OperatorUpdate {
/// A single update of an operator.
// Note: For the serialization to be derived according to the CIS2
// specification, the order of the fields cannot be changed.
#[derive(Debug, Serialize, Clone, SchemaType)]
#[derive(Debug, Serialize, Clone, SchemaType, PartialEq, Eq)]
pub struct UpdateOperator {
/// The update for this operator.
pub update: OperatorUpdate,
Expand Down
58 changes: 1 addition & 57 deletions concordium-std/src/impls.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2132,7 +2132,7 @@ fn query_account_public_keys_worker(address: AccountAddress) -> QueryAccountPubl
prims::invoke(INVOKE_QUERY_ACCOUNT_PUBLIC_KEYS_TAG, data.as_ptr() as *const u8, 32)
};
let mut return_value = parse_query_account_public_keys_response_code(response)?;
Ok(AccountPublicKeys::deserial(&mut return_value).unwrap_abort())
Ok(crate::AccountPublicKeys::deserial(&mut return_value).unwrap_abort())
}

fn check_account_signature_worker(
Expand Down Expand Up @@ -2918,62 +2918,6 @@ where
fn delete(mut self) { self.clear(); }
}

impl Serial for PublicKeyEd25519 {
fn serial<W: Write>(&self, out: &mut W) -> Result<(), W::Err> { self.0.serial(out) }
}

impl Deserial for PublicKeyEd25519 {
fn deserial<R: Read>(source: &mut R) -> ParseResult<Self> {
Ok(PublicKeyEd25519(Deserial::deserial(source)?))
}
}

impl schema::SchemaType for PublicKeyEd25519 {
fn get_type() -> concordium_contracts_common::schema::Type { schema::Type::ByteArray(32) }
}

impl Serial for PublicKeyEcdsaSecp256k1 {
fn serial<W: Write>(&self, out: &mut W) -> Result<(), W::Err> { self.0.serial(out) }
}

impl Deserial for PublicKeyEcdsaSecp256k1 {
fn deserial<R: Read>(source: &mut R) -> ParseResult<Self> {
Ok(PublicKeyEcdsaSecp256k1(Deserial::deserial(source)?))
}
}

impl schema::SchemaType for PublicKeyEcdsaSecp256k1 {
fn get_type() -> concordium_contracts_common::schema::Type { schema::Type::ByteArray(33) }
}

impl Serial for SignatureEd25519 {
fn serial<W: Write>(&self, out: &mut W) -> Result<(), W::Err> { self.0.serial(out) }
}

impl Deserial for SignatureEd25519 {
fn deserial<R: Read>(source: &mut R) -> ParseResult<Self> {
Ok(SignatureEd25519(Deserial::deserial(source)?))
}
}

impl schema::SchemaType for SignatureEd25519 {
fn get_type() -> concordium_contracts_common::schema::Type { schema::Type::ByteArray(64) }
}

impl Serial for SignatureEcdsaSecp256k1 {
fn serial<W: Write>(&self, out: &mut W) -> Result<(), W::Err> { self.0.serial(out) }
}

impl Deserial for SignatureEcdsaSecp256k1 {
fn deserial<R: Read>(source: &mut R) -> ParseResult<Self> {
Ok(SignatureEcdsaSecp256k1(Deserial::deserial(source)?))
}
}

impl schema::SchemaType for SignatureEcdsaSecp256k1 {
fn get_type() -> concordium_contracts_common::schema::Type { schema::Type::ByteArray(64) }
}

impl Serial for HashSha2256 {
fn serial<W: Write>(&self, out: &mut W) -> Result<(), W::Err> { self.0.serial(out) }
}
Expand Down
Loading
Loading