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

necessary changes for spica upgrade #1888

Open
wants to merge 17 commits into
base: rc/v0.55
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ members = [
"contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child",
"contracts/feature-tests/composability/execute-on-dest-esdt-issue-callback/child/meta",
"contracts/feature-tests/composability/forwarder",
"contracts/feature-tests/composability/forwarder-interactor",
"contracts/feature-tests/composability/forwarder/meta",
"contracts/feature-tests/composability/forwarder-legacy",
"contracts/feature-tests/composability/forwarder-legacy/meta",
Expand Down
5 changes: 5 additions & 0 deletions chain/core/src/builtin_func_names.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,8 @@ pub const SET_USERNAME_FUNC_NAME: &str = "SetUserName";
pub const MIGRATE_USERNAME_FUNC_NAME: &str = "migrateUserName";
pub const DELETE_USERNAME_FUNC_NAME: &str = "DeleteUserName";
pub const UPGRADE_CONTRACT_FUNC_NAME: &str = "upgradeContract";
pub const ESDT_MODIFY_ROYALTIES_FUNC_NAME: &str = "ESDTModifyRoyalties";
pub const ESDT_SET_NEW_URIS_FUNC_NAME: &str = "ESDTSetNewURIs";
pub const ESDT_MODIFY_CREATOR_FUNC_NAME: &str = "ESDTModifyCreator";
pub const ESDT_METADATA_RECREATE_FUNC_NAME: &str = "ESDTMetaDataRecreate";
pub const ESDT_METADATA_UPDATE_FUNC_NAME: &str = "ESDTMetaDataUpdate";
47 changes: 46 additions & 1 deletion chain/core/src/types/flags/esdt_local_role.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,11 @@ const ESDT_ROLE_NFT_BURN: &str = "ESDTRoleNFTBurn";
const ESDT_ROLE_NFT_ADD_URI: &str = "ESDTRoleNFTAddURI";
const ESDT_ROLE_NFT_UPDATE_ATTRIBUTES: &str = "ESDTRoleNFTUpdateAttributes";
const ESDT_ROLE_TRANSFER: &str = "ESDTTransferRole";
const ESDT_ROLE_SET_NEW_URI: &str = "ESDTRoleSetNewURI";
const ESDT_ROLE_MODIFY_ROYALTIES: &str = "ESDTRoleModifyRoyalties";
const ESDT_ROLE_MODIFY_CREATOR: &str = "ESDTRoleModifyCreator";
const ESDT_ROLE_NFT_RECREATE: &str = "ESDTRoleNFTRecreate";
const ESDT_ROLE_NFT_UPDATE: &str = "ESDTRoleNFTUpdate";

#[derive(TopDecode, TopEncode, NestedDecode, NestedEncode, Clone, PartialEq, Eq, Debug, Copy)]
pub enum EsdtLocalRole {
Expand All @@ -25,6 +30,11 @@ pub enum EsdtLocalRole {
NftAddUri,
NftUpdateAttributes,
Transfer,
SetNewUri,
ModifyRoyalties,
ModifyCreator,
NftRecreate,
NftUpdate,
}

impl EsdtLocalRole {
Expand All @@ -39,6 +49,11 @@ impl EsdtLocalRole {
Self::NftAddUri => 6,
Self::NftUpdateAttributes => 7,
Self::Transfer => 8,
Self::SetNewUri => 9,
Self::ModifyRoyalties => 10,
Self::ModifyCreator => 11,
Self::NftRecreate => 12,
Self::NftUpdate => 13,
}
}

Expand All @@ -57,6 +72,11 @@ impl EsdtLocalRole {
Self::NftAddUri => ESDT_ROLE_NFT_ADD_URI,
Self::NftUpdateAttributes => ESDT_ROLE_NFT_UPDATE_ATTRIBUTES,
Self::Transfer => ESDT_ROLE_TRANSFER,
Self::SetNewUri => ESDT_ROLE_SET_NEW_URI,
Self::ModifyRoyalties => ESDT_ROLE_MODIFY_ROYALTIES,
Self::ModifyCreator => ESDT_ROLE_MODIFY_CREATOR,
Self::NftRecreate => ESDT_ROLE_NFT_RECREATE,
Self::NftUpdate => ESDT_ROLE_NFT_UPDATE,
}
}

Expand All @@ -71,13 +91,18 @@ impl EsdtLocalRole {
Self::NftAddUri => EsdtLocalRoleFlags::NFT_ADD_URI,
Self::NftUpdateAttributes => EsdtLocalRoleFlags::NFT_UPDATE_ATTRIBUTES,
Self::Transfer => EsdtLocalRoleFlags::TRANSFER,
Self::SetNewUri => EsdtLocalRoleFlags::SET_NEW_URI,
Self::ModifyRoyalties => EsdtLocalRoleFlags::MODIFY_ROYALTIES,
Self::ModifyCreator => EsdtLocalRoleFlags::MODIFY_CREATOR,
Self::NftRecreate => EsdtLocalRoleFlags::NFT_RECREATE,
Self::NftUpdate => EsdtLocalRoleFlags::NFT_UPDATE,
}
}
}

// TODO: can be done with macros, but I didn't find a public library that does it and is no_std
// we can implement it, it's easy
const ALL_ROLES: [EsdtLocalRole; 8] = [
const ALL_ROLES: [EsdtLocalRole; 13] = [
EsdtLocalRole::Mint,
EsdtLocalRole::Burn,
EsdtLocalRole::NftCreate,
Expand All @@ -86,6 +111,11 @@ const ALL_ROLES: [EsdtLocalRole; 8] = [
EsdtLocalRole::NftAddUri,
EsdtLocalRole::NftUpdateAttributes,
EsdtLocalRole::Transfer,
EsdtLocalRole::SetNewUri,
EsdtLocalRole::ModifyRoyalties,
EsdtLocalRole::ModifyCreator,
EsdtLocalRole::NftRecreate,
EsdtLocalRole::NftUpdate,
];

impl EsdtLocalRole {
Expand All @@ -106,6 +136,11 @@ impl From<u16> for EsdtLocalRole {
6 => Self::NftAddUri,
7 => Self::NftUpdateAttributes,
8 => Self::Transfer,
9 => Self::SetNewUri,
10 => Self::ModifyRoyalties,
11 => Self::ModifyCreator,
12 => Self::NftRecreate,
13 => Self::NftUpdate,
_ => Self::None,
}
}
Expand All @@ -130,6 +165,16 @@ impl<'a> From<&'a [u8]> for EsdtLocalRole {
Self::NftUpdateAttributes
} else if byte_slice == ESDT_ROLE_TRANSFER.as_bytes() {
Self::Transfer
} else if byte_slice == ESDT_ROLE_SET_NEW_URI.as_bytes() {
Self::SetNewUri
} else if byte_slice == ESDT_ROLE_MODIFY_ROYALTIES.as_bytes() {
Self::ModifyRoyalties
} else if byte_slice == ESDT_ROLE_MODIFY_CREATOR.as_bytes() {
Self::ModifyCreator
} else if byte_slice == ESDT_ROLE_NFT_RECREATE.as_bytes() {
Self::NftRecreate
} else if byte_slice == ESDT_ROLE_NFT_UPDATE.as_bytes() {
Self::NftUpdate
} else {
Self::None
}
Expand Down
5 changes: 5 additions & 0 deletions chain/core/src/types/flags/esdt_local_role_flags.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,11 @@ bitflags! {
const NFT_ADD_URI = 0b00100000;
const NFT_UPDATE_ATTRIBUTES = 0b01000000;
const TRANSFER = 0b10000000;
const SET_NEW_URI = 0b00000001_00000000;
const MODIFY_ROYALTIES = 0b00000010_00000000;
const MODIFY_CREATOR = 0b00000100_00000000;
const NFT_RECREATE = 0b00001000_00000000;
const NFT_UPDATE = 0b00010000_00000000;
}
}

Expand Down
23 changes: 22 additions & 1 deletion chain/core/src/types/flags/esdt_token_type.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ const ESDT_TYPE_FUNGIBLE: &[u8] = b"FungibleESDT";
const ESDT_TYPE_NON_FUNGIBLE: &[u8] = b"NonFungibleESDT";
const ESDT_TYPE_SEMI_FUNGIBLE: &[u8] = b"SemiFungibleESDT";
const ESDT_TYPE_META: &[u8] = b"MetaESDT";
const ESDT_TYPE_DYNAMIC_NON_FUNGIBLE: &[u8] = b"DynamicNonFungibleESDT";
const ESDT_TYPE_DYNAMIC_SEMI_FUNGIBLE: &[u8] = b"DynamicSemiFungibleESDT";
const ESDT_TYPE_DYNAMIC_META: &[u8] = b"DynamicMetaESDT";
const ESDT_TYPE_INVALID: &[u8] = &[];

// Note: In the current implementation, SemiFungible is never returned
Expand All @@ -19,6 +22,9 @@ pub enum EsdtTokenType {
NonFungible,
SemiFungible,
Meta,
DynamicNFT,
DynamicSFT,
DynamicMeta,
Invalid,
}

Expand All @@ -37,7 +43,10 @@ impl EsdtTokenType {
Self::NonFungible => 1,
Self::SemiFungible => 2,
Self::Meta => 3,
Self::Invalid => 4,
Self::DynamicNFT => 4,
Self::DynamicSFT => 5,
Self::DynamicMeta => 6,
Self::Invalid => 7,
}
}

Expand All @@ -47,6 +56,9 @@ impl EsdtTokenType {
Self::NonFungible => ESDT_TYPE_NON_FUNGIBLE,
Self::SemiFungible => ESDT_TYPE_SEMI_FUNGIBLE,
Self::Meta => ESDT_TYPE_META,
Self::DynamicNFT => ESDT_TYPE_DYNAMIC_NON_FUNGIBLE,
Self::DynamicSFT => ESDT_TYPE_DYNAMIC_SEMI_FUNGIBLE,
Self::DynamicMeta => ESDT_TYPE_DYNAMIC_META,
Self::Invalid => ESDT_TYPE_INVALID,
}
}
Expand All @@ -60,6 +72,9 @@ impl From<u8> for EsdtTokenType {
1 => Self::NonFungible,
2 => Self::SemiFungible,
3 => Self::Meta,
4 => Self::DynamicNFT,
5 => Self::DynamicSFT,
6 => Self::DynamicMeta,
_ => Self::Invalid,
}
}
Expand All @@ -76,6 +91,12 @@ impl<'a> From<&'a [u8]> for EsdtTokenType {
Self::SemiFungible
} else if byte_slice == ESDT_TYPE_META {
Self::Meta
} else if byte_slice == ESDT_TYPE_DYNAMIC_NON_FUNGIBLE {
Self::DynamicNFT
} else if byte_slice == ESDT_TYPE_DYNAMIC_SEMI_FUNGIBLE {
Self::DynamicSFT
} else if byte_slice == ESDT_TYPE_DYNAMIC_META {
Self::DynamicMeta
} else {
Self::Invalid
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Pem files are used for interactions, but shouldn't be committed
*.pem
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
[package]
name = "forwarder-interact"
version = "0.0.0"
authors = ["you"]
edition = "2021"
publish = false

[[bin]]
name = "forwarder-interact"
path = "src/interactor_main.rs"

[lib]
path = "src/interact.rs"

[dependencies.forwarder]
path = "../forwarder"

[dependencies.multiversx-sc-snippets]
version = "0.54.5"
path = "../../../../framework/snippets"

[dependencies.multiversx-sc]
version = "0.54.5"
path = "../../../../framework/base"

[dependencies]
clap = { version = "4.4.7", features = ["derive"] }
serde = { version = "1.0", features = ["derive"] }
toml = "0.8.6"

[features]
chain-simulator-tests = []
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# chain_type = 'simulator'
# gateway_uri = 'http://localhost:8085'

chain_type = 'real'
gateway_uri = 'https://devnet-gateway.multiversx.com'

Loading
Loading