difftreelog
Smart contract update
in: master
7 files changed
pallets/nft/src/lib.rsdiffbeforeafterboth--- a/pallets/nft/src/lib.rs
+++ b/pallets/nft/src/lib.rs
@@ -96,15 +96,6 @@
// this is needed only if you are using events in your pallet
fn deposit_event() = default;
- // Initializing events
- // this is needed only if you are using events in your module
- // fn deposit_event<T>() = default;
-
- // Create collection of NFT with given parameters
- //
- // @param customDataSz size of custom data in each collection item
- // returns collection ID
-
// Create collection of NFT with given parameters
//
// @param customDataSz size of custom data in each collection item
runtime/src/lib.rsdiffbeforeafterboth1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use grandpa::fg_primitives;12use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};13use sp_api::impl_runtime_apis;14use sp_consensus_aura::sr25519::AuthorityId as AuraId;15use sp_core::{crypto::KeyTypeId, OpaqueMetadata};16use sp_runtime::traits::{17 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating, Verify,18};19use sp_runtime::{20 create_runtime_str, generic, impl_opaque_keys,21 transaction_validity::{TransactionSource, TransactionValidity},22 ApplyExtrinsicResult, MultiSignature,23};24use contracts_rpc_runtime_api::ContractExecResult;25use sp_std::prelude::*;26#[cfg(feature = "std")]27use sp_version::NativeVersion;28use sp_version::RuntimeVersion;2930// A few exports that help ease life for downstream crates.31pub use balances::Call as BalancesCall;32pub use contracts::Schedule as ContractsSchedule;33pub use frame_support::{34 construct_runtime, parameter_types,35 traits::{KeyOwnerProofSystem, Randomness},36 weights::{37 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},38 IdentityFee, Weight,39 },40 StorageValue,41};42#[cfg(any(feature = "std", test))]43pub use sp_runtime::BuildStorage;44pub use sp_runtime::{Perbill, Permill};45pub use timestamp::Call as TimestampCall;4647/// Importing a nft pallet48pub use nft;4950/// An index to a block.51pub type BlockNumber = u32;5253/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.54pub type Signature = MultiSignature;5556/// Some way of identifying an account on the chain. We intentionally make it equivalent57/// to the public key of our transaction signing scheme.58pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;5960/// The type for looking up accounts. We don't expect more than 4 billion of them, but you61/// never know...62pub type AccountIndex = u32;6364/// Balance of an account.65pub type Balance = u128;6667/// Index of a transaction in the chain.68pub type Index = u32;6970/// A hash of some data used by the chain.71pub type Hash = sp_core::H256;7273/// Digest item type.74pub type DigestItem = generic::DigestItem<Hash>;7576/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know77/// the specifics of the runtime. They can then be made to be agnostic over specific formats78/// of data like extrinsics, allowing for them to continue syncing the network through upgrades79/// to even the core data structures.80pub mod opaque {81 use super::*;8283 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;8485 /// Opaque block header type.86 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;87 /// Opaque block type.88 pub type Block = generic::Block<Header, UncheckedExtrinsic>;89 /// Opaque block identifier type.90 pub type BlockId = generic::BlockId<Block>;9192 impl_opaque_keys! {93 pub struct SessionKeys {94 pub aura: Aura,95 pub grandpa: Grandpa,96 }97 }98}99100/// This runtime version.101pub const VERSION: RuntimeVersion = RuntimeVersion {102 spec_name: create_runtime_str!("nft"),103 impl_name: create_runtime_str!("nft"),104 authoring_version: 1,105 spec_version: 1,106 impl_version: 1,107 apis: RUNTIME_API_VERSIONS,108 transaction_version: 1,109};110111pub const MILLISECS_PER_BLOCK: u64 = 6000;112113pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;114115// These time units are defined in number of blocks.116pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);117pub const HOURS: BlockNumber = MINUTES * 60;118pub const DAYS: BlockNumber = HOURS * 24;119120/// The version information used to identify this runtime when compiled natively.121#[cfg(feature = "std")]122pub fn native_version() -> NativeVersion {123 NativeVersion {124 runtime_version: VERSION,125 can_author_with: Default::default(),126 }127}128129parameter_types! {130 pub const BlockHashCount: BlockNumber = 2400;131 /// We allow for 2 seconds of compute with a 6 second average block time.132 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;133 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);134 /// Assume 10% of weight for average on_initialize calls.135 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()136 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();137 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;138 pub const Version: RuntimeVersion = VERSION;139}140141impl system::Trait for Runtime {142 /// The identifier used to distinguish between accounts.143 type AccountId = AccountId;144 /// The aggregated dispatch type that is available for extrinsics.145 type Call = Call;146 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.147 type Lookup = IdentityLookup<AccountId>;148 /// The index type for storing how many extrinsics an account has signed.149 type Index = Index;150 /// The index type for blocks.151 type BlockNumber = BlockNumber;152 /// The type for hashing blocks and tries.153 type Hash = Hash;154 /// The hashing algorithm used.155 type Hashing = BlakeTwo256;156 /// The header type.157 type Header = generic::Header<BlockNumber, BlakeTwo256>;158 /// The ubiquitous event type.159 type Event = Event;160 /// The ubiquitous origin type.161 type Origin = Origin;162 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).163 type BlockHashCount = BlockHashCount;164 /// Maximum weight of each block.165 type MaximumBlockWeight = MaximumBlockWeight;166 /// The weight of database operations that the runtime can invoke.167 type DbWeight = RocksDbWeight;168 /// The weight of the overhead invoked on the block import process, independent of the169 /// extrinsics included in that block.170 type BlockExecutionWeight = BlockExecutionWeight;171 /// The base weight of any extrinsic processed by the runtime, independent of the172 /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)173 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;174 /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,175 /// idependent of the logic of that extrinsics. (Roughly max block weight - average on176 /// initialize cost).177 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;178 /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.179 type MaximumBlockLength = MaximumBlockLength;180 /// Portion of the block weight that is available to all normal transactions.181 type AvailableBlockRatio = AvailableBlockRatio;182 /// Version of the runtime.183 type Version = Version;184 /// Converts a module to the index of the module in `construct_runtime!`.185 ///186 /// This type is being generated by `construct_runtime!`.187 type ModuleToIndex = ModuleToIndex;188 /// What to do if a new account is created.189 type OnNewAccount = ();190 /// What to do if an account is fully reaped from the system.191 type OnKilledAccount = ();192 /// The data to be stored in an account.193 type AccountData = balances::AccountData<Balance>;194}195196impl aura::Trait for Runtime {197 type AuthorityId = AuraId;198}199200impl grandpa::Trait for Runtime {201 type Event = Event;202 type Call = Call;203204 type KeyOwnerProofSystem = ();205206 type KeyOwnerProof =207 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;208209 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(210 KeyTypeId,211 GrandpaId,212 )>>::IdentificationTuple;213214 type HandleEquivocation = ();215}216217parameter_types! {218 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;219}220221impl timestamp::Trait for Runtime {222 /// A timestamp: milliseconds since the unix epoch.223 type Moment = u64;224 type OnTimestampSet = Aura;225 type MinimumPeriod = MinimumPeriod;226}227228parameter_types! {229 pub const ExistentialDeposit: u128 = 500;230}231232impl balances::Trait for Runtime {233 /// The type for recording an account's balance.234 type Balance = Balance;235 /// The ubiquitous event type.236 type Event = Event;237 type DustRemoval = ();238 type ExistentialDeposit = ExistentialDeposit;239 type AccountStore = System;240}241242pub const MILLICENTS: Balance = 1_000_000_000;243pub const CENTS: Balance = 1_000 * MILLICENTS;244pub const DOLLARS: Balance = 100 * CENTS;245246parameter_types! {247 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;248 pub const RentByteFee: Balance = 4 * MILLICENTS;249 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;250 pub const SurchargeReward: Balance = 150 * MILLICENTS;251}252253impl contracts::Trait for Runtime {254 type Time = Timestamp;255 type Randomness = RandomnessCollectiveFlip;256 type Call = Call;257 type Event = Event;258 type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;259 type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;260 type RentPayment = ();261 type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;262 type TombstoneDeposit = TombstoneDeposit;263 type StorageSizeOffset = contracts::DefaultStorageSizeOffset;264 type RentByteFee = RentByteFee;265 type RentDepositOffset = RentDepositOffset;266 type SurchargeReward = SurchargeReward;267 type MaxDepth = contracts::DefaultMaxDepth;268 type MaxValueSize = contracts::DefaultMaxValueSize;269}270271parameter_types! {272 pub const TransactionByteFee: Balance = 1;273}274275impl transaction_payment::Trait for Runtime {276 type Currency = balances::Module<Runtime>;277 type OnTransactionPayment = ();278 type TransactionByteFee = TransactionByteFee;279 type WeightToFee = IdentityFee<Balance>;280 type FeeMultiplierUpdate = ();281}282283impl sudo::Trait for Runtime {284 type Event = Event;285 type Call = Call;286}287288/// Used for the module nft in `./nft.rs`289impl nft::Trait for Runtime {290 type Event = Event;291}292293construct_runtime!(294 pub enum Runtime where295 Block = Block,296 NodeBlock = opaque::Block,297 UncheckedExtrinsic = UncheckedExtrinsic298 {299 System: system::{Module, Call, Config, Storage, Event<T>},300 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},301 Contracts: contracts::{Module, Call, Config, Storage, Event<T>},302 Timestamp: timestamp::{Module, Call, Storage, Inherent},303 Aura: aura::{Module, Config<T>, Inherent(Timestamp)},304 Grandpa: grandpa::{Module, Call, Storage, Config, Event},305 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},306 TransactionPayment: transaction_payment::{Module, Storage},307 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},308 Nft: nft::{Module, Call, Storage, Event<T>},309 }310);311312/// The address format for describing accounts.313pub type Address = AccountId;314/// Block header type as expected by this runtime.315pub type Header = generic::Header<BlockNumber, BlakeTwo256>;316/// Block type as expected by this runtime.317pub type Block = generic::Block<Header, UncheckedExtrinsic>;318/// A Block signed with a Justification319pub type SignedBlock = generic::SignedBlock<Block>;320/// BlockId type as expected by this runtime.321pub type BlockId = generic::BlockId<Block>;322/// The SignedExtension to the basic transaction logic.323pub type SignedExtra = (324 system::CheckSpecVersion<Runtime>,325 system::CheckTxVersion<Runtime>,326 system::CheckGenesis<Runtime>,327 system::CheckEra<Runtime>,328 system::CheckNonce<Runtime>,329 system::CheckWeight<Runtime>,330 transaction_payment::ChargeTransactionPayment<Runtime>,331);332/// Unchecked extrinsic type as expected by this runtime.333pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;334/// Extrinsic type that has already been checked.335pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;336/// Executive: handles dispatch to the various modules.337pub type Executive =338 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;339340impl_runtime_apis! {341342 impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>343 for Runtime344 {345 fn call(346 origin: AccountId,347 dest: AccountId,348 value: Balance,349 gas_limit: u64,350 input_data: Vec<u8>,351 ) -> ContractExecResult {352 let exec_result =353 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);354 match exec_result {355 Ok(v) => ContractExecResult::Success {356 status: v.status,357 data: v.data,358 },359 Err(_) => ContractExecResult::Error,360 }361 }362363 fn get_storage(364 address: AccountId,365 key: [u8; 32],366 ) -> contracts_primitives::GetStorageResult {367 Contracts::get_storage(address, key)368 }369370 fn rent_projection(371 address: AccountId,372 ) -> contracts_primitives::RentProjectionResult<BlockNumber> {373 Contracts::rent_projection(address)374 }375 }376377 impl sp_api::Core<Block> for Runtime {378 fn version() -> RuntimeVersion {379 VERSION380 }381382 fn execute_block(block: Block) {383 Executive::execute_block(block)384 }385386 fn initialize_block(header: &<Block as BlockT>::Header) {387 Executive::initialize_block(header)388 }389 }390391 impl sp_api::Metadata<Block> for Runtime {392 fn metadata() -> OpaqueMetadata {393 Runtime::metadata().into()394 }395 }396397 impl sp_block_builder::BlockBuilder<Block> for Runtime {398 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {399 Executive::apply_extrinsic(extrinsic)400 }401402 fn finalize_block() -> <Block as BlockT>::Header {403 Executive::finalize_block()404 }405406 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {407 data.create_extrinsics()408 }409410 fn check_inherents(411 block: Block,412 data: sp_inherents::InherentData,413 ) -> sp_inherents::CheckInherentsResult {414 data.check_extrinsics(&block)415 }416417 fn random_seed() -> <Block as BlockT>::Hash {418 RandomnessCollectiveFlip::random_seed()419 }420 }421422 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {423 fn validate_transaction(424 source: TransactionSource,425 tx: <Block as BlockT>::Extrinsic,426 ) -> TransactionValidity {427 Executive::validate_transaction(source, tx)428 }429 }430431 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {432 fn offchain_worker(header: &<Block as BlockT>::Header) {433 Executive::offchain_worker(header)434 }435 }436437 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {438 fn slot_duration() -> u64 {439 Aura::slot_duration()440 }441442 fn authorities() -> Vec<AuraId> {443 Aura::authorities()444 }445 }446447 impl sp_session::SessionKeys<Block> for Runtime {448 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {449 opaque::SessionKeys::generate(seed)450 }451452 fn decode_session_keys(453 encoded: Vec<u8>,454 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {455 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)456 }457 }458459 impl fg_primitives::GrandpaApi<Block> for Runtime {460 fn grandpa_authorities() -> GrandpaAuthorityList {461 Grandpa::grandpa_authorities()462 }463464 fn submit_report_equivocation_extrinsic(465 _equivocation_proof: fg_primitives::EquivocationProof<466 <Block as BlockT>::Hash,467 NumberFor<Block>,468 >,469 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,470 ) -> Option<()> {471 None472 }473474 fn generate_key_ownership_proof(475 _set_id: fg_primitives::SetId,476 _authority_id: GrandpaId,477 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {478 // NOTE: this is the only implementation possible since we've479 // defined our key owner proof type as a bottom type (i.e. a type480 // with no values).481 None482 }483 }484}1//! The Substrate Node Template runtime. This can be compiled with `#[no_std]`, ready for Wasm.23#![cfg_attr(not(feature = "std"), no_std)]4// `construct_runtime!` does a lot of recursion and requires us to increase the limit to 256.5#![recursion_limit = "256"]67// Make the WASM binary available.8#[cfg(feature = "std")]9include!(concat!(env!("OUT_DIR"), "/wasm_binary.rs"));1011use contracts_rpc_runtime_api::ContractExecResult;12use grandpa::fg_primitives;13use grandpa::{AuthorityId as GrandpaId, AuthorityList as GrandpaAuthorityList};14use sp_api::impl_runtime_apis;15use sp_consensus_aura::sr25519::AuthorityId as AuraId;16use sp_core::{crypto::KeyTypeId, OpaqueMetadata};17use sp_runtime::traits::{18 BlakeTwo256, Block as BlockT, IdentifyAccount, IdentityLookup, NumberFor, Saturating, Verify,19};20use sp_runtime::{21 create_runtime_str, generic, impl_opaque_keys,22 transaction_validity::{TransactionSource, TransactionValidity},23 ApplyExtrinsicResult, MultiSignature,24};25use sp_std::prelude::*;26#[cfg(feature = "std")]27use sp_version::NativeVersion;28use sp_version::RuntimeVersion;2930// A few exports that help ease life for downstream crates.31pub use balances::Call as BalancesCall;32pub use contracts::Schedule as ContractsSchedule;33pub use frame_support::{34 construct_runtime, parameter_types,35 traits::{KeyOwnerProofSystem, Randomness},36 weights::{37 constants::{BlockExecutionWeight, ExtrinsicBaseWeight, RocksDbWeight, WEIGHT_PER_SECOND},38 IdentityFee, Weight,39 },40 StorageValue,41};42#[cfg(any(feature = "std", test))]43pub use sp_runtime::BuildStorage;44pub use sp_runtime::{Perbill, Permill};45pub use timestamp::Call as TimestampCall;4647/// Importing a nft pallet48pub use nft;4950/// An index to a block.51pub type BlockNumber = u32;5253/// Alias to 512-bit hash when used in the context of a transaction signature on the chain.54pub type Signature = MultiSignature;5556/// Some way of identifying an account on the chain. We intentionally make it equivalent57/// to the public key of our transaction signing scheme.58pub type AccountId = <<Signature as Verify>::Signer as IdentifyAccount>::AccountId;5960/// The type for looking up accounts. We don't expect more than 4 billion of them, but you61/// never know...62pub type AccountIndex = u32;6364/// Balance of an account.65pub type Balance = u128;6667/// Index of a transaction in the chain.68pub type Index = u32;6970/// A hash of some data used by the chain.71pub type Hash = sp_core::H256;7273/// Digest item type.74pub type DigestItem = generic::DigestItem<Hash>;7576/// Opaque types. These are used by the CLI to instantiate machinery that don't need to know77/// the specifics of the runtime. They can then be made to be agnostic over specific formats78/// of data like extrinsics, allowing for them to continue syncing the network through upgrades79/// to even the core data structures.80pub mod opaque {81 use super::*;8283 pub use sp_runtime::OpaqueExtrinsic as UncheckedExtrinsic;8485 /// Opaque block header type.86 pub type Header = generic::Header<BlockNumber, BlakeTwo256>;87 /// Opaque block type.88 pub type Block = generic::Block<Header, UncheckedExtrinsic>;89 /// Opaque block identifier type.90 pub type BlockId = generic::BlockId<Block>;9192 impl_opaque_keys! {93 pub struct SessionKeys {94 pub aura: Aura,95 pub grandpa: Grandpa,96 }97 }98}99100/// This runtime version.101pub const VERSION: RuntimeVersion = RuntimeVersion {102 spec_name: create_runtime_str!("nft"),103 impl_name: create_runtime_str!("nft"),104 authoring_version: 1,105 spec_version: 1,106 impl_version: 1,107 apis: RUNTIME_API_VERSIONS,108 transaction_version: 1,109};110111pub const MILLISECS_PER_BLOCK: u64 = 6000;112113pub const SLOT_DURATION: u64 = MILLISECS_PER_BLOCK;114115// These time units are defined in number of blocks.116pub const MINUTES: BlockNumber = 60_000 / (MILLISECS_PER_BLOCK as BlockNumber);117pub const HOURS: BlockNumber = MINUTES * 60;118pub const DAYS: BlockNumber = HOURS * 24;119120/// The version information used to identify this runtime when compiled natively.121#[cfg(feature = "std")]122pub fn native_version() -> NativeVersion {123 NativeVersion {124 runtime_version: VERSION,125 can_author_with: Default::default(),126 }127}128129parameter_types! {130 pub const BlockHashCount: BlockNumber = 2400;131 /// We allow for 2 seconds of compute with a 6 second average block time.132 pub const MaximumBlockWeight: Weight = 2 * WEIGHT_PER_SECOND;133 pub const AvailableBlockRatio: Perbill = Perbill::from_percent(75);134 /// Assume 10% of weight for average on_initialize calls.135 pub MaximumExtrinsicWeight: Weight = AvailableBlockRatio::get()136 .saturating_sub(Perbill::from_percent(10)) * MaximumBlockWeight::get();137 pub const MaximumBlockLength: u32 = 5 * 1024 * 1024;138 pub const Version: RuntimeVersion = VERSION;139}140141impl system::Trait for Runtime {142 /// The identifier used to distinguish between accounts.143 type AccountId = AccountId;144 /// The aggregated dispatch type that is available for extrinsics.145 type Call = Call;146 /// The lookup mechanism to get account ID from whatever is passed in dispatchers.147 type Lookup = IdentityLookup<AccountId>;148 /// The index type for storing how many extrinsics an account has signed.149 type Index = Index;150 /// The index type for blocks.151 type BlockNumber = BlockNumber;152 /// The type for hashing blocks and tries.153 type Hash = Hash;154 /// The hashing algorithm used.155 type Hashing = BlakeTwo256;156 /// The header type.157 type Header = generic::Header<BlockNumber, BlakeTwo256>;158 /// The ubiquitous event type.159 type Event = Event;160 /// The ubiquitous origin type.161 type Origin = Origin;162 /// Maximum number of block number to block hash mappings to keep (oldest pruned first).163 type BlockHashCount = BlockHashCount;164 /// Maximum weight of each block.165 type MaximumBlockWeight = MaximumBlockWeight;166 /// The weight of database operations that the runtime can invoke.167 type DbWeight = RocksDbWeight;168 /// The weight of the overhead invoked on the block import process, independent of the169 /// extrinsics included in that block.170 type BlockExecutionWeight = BlockExecutionWeight;171 /// The base weight of any extrinsic processed by the runtime, independent of the172 /// logic of that extrinsic. (Signature verification, nonce increment, fee, etc...)173 type ExtrinsicBaseWeight = ExtrinsicBaseWeight;174 /// The maximum weight that a single extrinsic of `Normal` dispatch class can have,175 /// idependent of the logic of that extrinsics. (Roughly max block weight - average on176 /// initialize cost).177 type MaximumExtrinsicWeight = MaximumExtrinsicWeight;178 /// Maximum size of all encoded transactions (in bytes) that are allowed in one block.179 type MaximumBlockLength = MaximumBlockLength;180 /// Portion of the block weight that is available to all normal transactions.181 type AvailableBlockRatio = AvailableBlockRatio;182 /// Version of the runtime.183 type Version = Version;184 /// Converts a module to the index of the module in `construct_runtime!`.185 ///186 /// This type is being generated by `construct_runtime!`.187 type ModuleToIndex = ModuleToIndex;188 /// What to do if a new account is created.189 type OnNewAccount = ();190 /// What to do if an account is fully reaped from the system.191 type OnKilledAccount = ();192 /// The data to be stored in an account.193 type AccountData = balances::AccountData<Balance>;194}195196impl aura::Trait for Runtime {197 type AuthorityId = AuraId;198}199200impl grandpa::Trait for Runtime {201 type Event = Event;202 type Call = Call;203204 type KeyOwnerProofSystem = ();205206 type KeyOwnerProof =207 <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(KeyTypeId, GrandpaId)>>::Proof;208209 type KeyOwnerIdentification = <Self::KeyOwnerProofSystem as KeyOwnerProofSystem<(210 KeyTypeId,211 GrandpaId,212 )>>::IdentificationTuple;213214 type HandleEquivocation = ();215}216217parameter_types! {218 pub const MinimumPeriod: u64 = SLOT_DURATION / 2;219}220221impl timestamp::Trait for Runtime {222 /// A timestamp: milliseconds since the unix epoch.223 type Moment = u64;224 type OnTimestampSet = Aura;225 type MinimumPeriod = MinimumPeriod;226}227228parameter_types! {229 pub const ExistentialDeposit: u128 = 500;230}231232impl balances::Trait for Runtime {233 /// The type for recording an account's balance.234 type Balance = Balance;235 /// The ubiquitous event type.236 type Event = Event;237 type DustRemoval = ();238 type ExistentialDeposit = ExistentialDeposit;239 type AccountStore = System;240}241242pub const MILLICENTS: Balance = 1_000_000_000;243pub const CENTS: Balance = 1_000 * MILLICENTS;244pub const DOLLARS: Balance = 100 * CENTS;245246parameter_types! {247 pub const TombstoneDeposit: Balance = 16 * MILLICENTS;248 pub const RentByteFee: Balance = 4 * MILLICENTS;249 pub const RentDepositOffset: Balance = 1000 * MILLICENTS;250 pub const SurchargeReward: Balance = 150 * MILLICENTS;251}252253impl contracts::Trait for Runtime {254 type Time = Timestamp;255 type Randomness = RandomnessCollectiveFlip;256 type Call = Call;257 type Event = Event;258 type DetermineContractAddress = contracts::SimpleAddressDeterminer<Runtime>;259 type TrieIdGenerator = contracts::TrieIdFromParentCounter<Runtime>;260 type RentPayment = ();261 type SignedClaimHandicap = contracts::DefaultSignedClaimHandicap;262 type TombstoneDeposit = TombstoneDeposit;263 type StorageSizeOffset = contracts::DefaultStorageSizeOffset;264 type RentByteFee = RentByteFee;265 type RentDepositOffset = RentDepositOffset;266 type SurchargeReward = SurchargeReward;267 type MaxDepth = contracts::DefaultMaxDepth;268 type MaxValueSize = contracts::DefaultMaxValueSize;269}270271parameter_types! {272 pub const TransactionByteFee: Balance = 1;273}274275impl transaction_payment::Trait for Runtime {276 type Currency = balances::Module<Runtime>;277 type OnTransactionPayment = ();278 type TransactionByteFee = TransactionByteFee;279 type WeightToFee = IdentityFee<Balance>;280 type FeeMultiplierUpdate = ();281}282283impl sudo::Trait for Runtime {284 type Event = Event;285 type Call = Call;286}287288/// Used for the module nft in `./nft.rs`289impl nft::Trait for Runtime {290 type Event = Event;291}292293construct_runtime!(294 pub enum Runtime where295 Block = Block,296 NodeBlock = opaque::Block,297 UncheckedExtrinsic = UncheckedExtrinsic298 {299 System: system::{Module, Call, Config, Storage, Event<T>},300 RandomnessCollectiveFlip: randomness_collective_flip::{Module, Call, Storage},301 Contracts: contracts::{Module, Call, Config, Storage, Event<T>},302 Timestamp: timestamp::{Module, Call, Storage, Inherent},303 Aura: aura::{Module, Config<T>, Inherent(Timestamp)},304 Grandpa: grandpa::{Module, Call, Storage, Config, Event},305 Balances: balances::{Module, Call, Storage, Config<T>, Event<T>},306 TransactionPayment: transaction_payment::{Module, Storage},307 Sudo: sudo::{Module, Call, Config<T>, Storage, Event<T>},308 Nft: nft::{Module, Call, Storage, Event<T>},309 }310);311312/// The address format for describing accounts.313pub type Address = AccountId;314/// Block header type as expected by this runtime.315pub type Header = generic::Header<BlockNumber, BlakeTwo256>;316/// Block type as expected by this runtime.317pub type Block = generic::Block<Header, UncheckedExtrinsic>;318/// A Block signed with a Justification319pub type SignedBlock = generic::SignedBlock<Block>;320/// BlockId type as expected by this runtime.321pub type BlockId = generic::BlockId<Block>;322/// The SignedExtension to the basic transaction logic.323pub type SignedExtra = (324 system::CheckSpecVersion<Runtime>,325 system::CheckTxVersion<Runtime>,326 system::CheckGenesis<Runtime>,327 system::CheckEra<Runtime>,328 system::CheckNonce<Runtime>,329 system::CheckWeight<Runtime>,330 transaction_payment::ChargeTransactionPayment<Runtime>,331);332/// Unchecked extrinsic type as expected by this runtime.333pub type UncheckedExtrinsic = generic::UncheckedExtrinsic<Address, Call, Signature, SignedExtra>;334/// Extrinsic type that has already been checked.335pub type CheckedExtrinsic = generic::CheckedExtrinsic<AccountId, Call, SignedExtra>;336/// Executive: handles dispatch to the various modules.337pub type Executive =338 frame_executive::Executive<Runtime, Block, system::ChainContext<Runtime>, Runtime, AllModules>;339340impl_runtime_apis! {341342 impl contracts_rpc_runtime_api::ContractsApi<Block, AccountId, Balance, BlockNumber>343 for Runtime344 {345 fn call(346 origin: AccountId,347 dest: AccountId,348 value: Balance,349 gas_limit: u64,350 input_data: Vec<u8>,351 ) -> ContractExecResult {352 let exec_result =353 Contracts::bare_call(origin, dest.into(), value, gas_limit, input_data);354 match exec_result {355 Ok(v) => ContractExecResult::Success {356 status: v.status,357 data: v.data,358 },359 Err(_) => ContractExecResult::Error,360 }361 }362363 fn get_storage(364 address: AccountId,365 key: [u8; 32],366 ) -> contracts_primitives::GetStorageResult {367 Contracts::get_storage(address, key)368 }369370 fn rent_projection(371 address: AccountId,372 ) -> contracts_primitives::RentProjectionResult<BlockNumber> {373 Contracts::rent_projection(address)374 }375 }376377 impl sp_api::Core<Block> for Runtime {378 fn version() -> RuntimeVersion {379 VERSION380 }381382 fn execute_block(block: Block) {383 Executive::execute_block(block)384 }385386 fn initialize_block(header: &<Block as BlockT>::Header) {387 Executive::initialize_block(header)388 }389 }390391 impl sp_api::Metadata<Block> for Runtime {392 fn metadata() -> OpaqueMetadata {393 Runtime::metadata().into()394 }395 }396397 impl sp_block_builder::BlockBuilder<Block> for Runtime {398 fn apply_extrinsic(extrinsic: <Block as BlockT>::Extrinsic) -> ApplyExtrinsicResult {399 Executive::apply_extrinsic(extrinsic)400 }401402 fn finalize_block() -> <Block as BlockT>::Header {403 Executive::finalize_block()404 }405406 fn inherent_extrinsics(data: sp_inherents::InherentData) -> Vec<<Block as BlockT>::Extrinsic> {407 data.create_extrinsics()408 }409410 fn check_inherents(411 block: Block,412 data: sp_inherents::InherentData,413 ) -> sp_inherents::CheckInherentsResult {414 data.check_extrinsics(&block)415 }416417 fn random_seed() -> <Block as BlockT>::Hash {418 RandomnessCollectiveFlip::random_seed()419 }420 }421422 impl sp_transaction_pool::runtime_api::TaggedTransactionQueue<Block> for Runtime {423 fn validate_transaction(424 source: TransactionSource,425 tx: <Block as BlockT>::Extrinsic,426 ) -> TransactionValidity {427 Executive::validate_transaction(source, tx)428 }429 }430431 impl sp_offchain::OffchainWorkerApi<Block> for Runtime {432 fn offchain_worker(header: &<Block as BlockT>::Header) {433 Executive::offchain_worker(header)434 }435 }436437 impl sp_consensus_aura::AuraApi<Block, AuraId> for Runtime {438 fn slot_duration() -> u64 {439 Aura::slot_duration()440 }441442 fn authorities() -> Vec<AuraId> {443 Aura::authorities()444 }445 }446447 impl sp_session::SessionKeys<Block> for Runtime {448 fn generate_session_keys(seed: Option<Vec<u8>>) -> Vec<u8> {449 opaque::SessionKeys::generate(seed)450 }451452 fn decode_session_keys(453 encoded: Vec<u8>,454 ) -> Option<Vec<(Vec<u8>, KeyTypeId)>> {455 opaque::SessionKeys::decode_into_raw_public_keys(&encoded)456 }457 }458459 impl fg_primitives::GrandpaApi<Block> for Runtime {460 fn grandpa_authorities() -> GrandpaAuthorityList {461 Grandpa::grandpa_authorities()462 }463464 fn submit_report_equivocation_extrinsic(465 _equivocation_proof: fg_primitives::EquivocationProof<466 <Block as BlockT>::Hash,467 NumberFor<Block>,468 >,469 _key_owner_proof: fg_primitives::OpaqueKeyOwnershipProof,470 ) -> Option<()> {471 None472 }473474 fn generate_key_ownership_proof(475 _set_id: fg_primitives::SetId,476 _authority_id: GrandpaId,477 ) -> Option<fg_primitives::OpaqueKeyOwnershipProof> {478 // NOTE: this is the only implementation possible since we've479 // defined our key owner proof type as a bottom type (i.e. a type480 // with no values).481 None482 }483 }484}smart_contract/ink-types-node-runtime/Cargo.tomldiffbeforeafterboth--- a/smart_contract/ink-types-node-runtime/Cargo.toml
+++ b/smart_contract/ink-types-node-runtime/Cargo.toml
@@ -19,6 +19,7 @@
[dependencies]
ink_core = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_core", default-features = false }
+ink_prelude = { version = "2", git = "https://github.com/paritytech/ink", tag = "latest-v2", package = "ink_prelude", default-features = false }
frame-system = { git = "https://github.com/paritytech/substrate/", tag = "v2.0.0-rc3", package = "frame-system", default-features = false }
pallet-indices = { git = "https://github.com/paritytech/substrate/", tag = "v2.0.0-rc3", package = "pallet-indices", default-features = false }
sp-core = { git = "https://github.com/paritytech/substrate/", tag = "v2.0.0-rc3", package = "sp-core", default-features = false }
smart_contract/ink-types-node-runtime/examples/calls/Cargo.lockdiffbeforeafterboth--- a/smart_contract/ink-types-node-runtime/examples/calls/Cargo.lock
+++ b/smart_contract/ink-types-node-runtime/examples/calls/Cargo.lock
@@ -803,6 +803,7 @@
dependencies = [
"frame-system",
"ink_core",
+ "ink_prelude",
"pallet-indices",
"parity-scale-codec",
"sp-core",
smart_contract/ink-types-node-runtime/examples/calls/lib.rsdiffbeforeafterboth--- a/smart_contract/ink-types-node-runtime/examples/calls/lib.rs
+++ b/smart_contract/ink-types-node-runtime/examples/calls/lib.rs
@@ -7,7 +7,7 @@
use ink_core::env;
use ink_prelude::*;
use ink_types_node_runtime::{calls as runtime_calls, NodeRuntimeTypes};
- use ink_core::{memory::vec::Vec, storage};
+ use ink_prelude::vec::Vec;
/// This simple dummy contract dispatches substrate runtime calls
#[ink(storage)]
@@ -17,43 +17,167 @@
#[ink(constructor)]
fn new(&mut self) {}
- /// Dispatches a `transfer` call to the Balances srml module
#[ink(message)]
- fn create_collection(&self, collection_name: Vec<u16>, collection_description: Vec<u16>,
- token_prefix: Vec<u8>,
- custom_data_sz: u32) {
- // create the Balances::transfer Call
+ fn transfer(&self, collection_id: u64, item_id: u64, new_owner: AccountId) {
- // collection_name: Vec<u16>,
- // collection_description: Vec<u16>,
- // token_prefix: Vec<u8>,
- // custom_data_sz: u32
+ env::println(&format!(
+ "transfer invoke_runtime params {:?}, {:?}, {:?} ",
+ collection_id,
+ item_id,
+ new_owner
+ ));
- let transfer_call = runtime_calls::create_collection(collection_name, collection_description, token_prefix, custom_data_sz);
+ let transfer_call = runtime_calls::transfer(collection_id, item_id, new_owner);
// dispatch the call to the runtime
let result = self.env().invoke_runtime(&transfer_call);
// report result to console
// NOTE: println should only be used on a development chain)
env::println(&format!(
- "Balance transfer invoke_runtime result {:?}",
+ "transfer invoke_runtime result {:?}",
+ result
+ ));
+ }
+
+ // SafeTransfer
+
+ #[ink(message)]
+ fn approve(&self, approved: AccountId, collection_id: u64, item_id: u64) {
+
+ env::println(&format!(
+ "approve invoke_runtime params {:?}, {:?}, {:?} ",
+ approved,
+ collection_id,
+ item_id
+ ));
+
+ let approve_call = runtime_calls::approve(approved, collection_id, item_id);
+ // dispatch the call to the runtime
+ let result = self.env().invoke_runtime(&approve_call);
+
+ // report result to console
+ // NOTE: println should only be used on a development chain)
+ env::println(&format!(
+ "approve invoke_runtime result {:?}",
+ result
+ ));
+ }
+
+ ////////////////////////////////////////// GetApproved
+ ///
+ /// Returns an account's free balance, read directly from runtime storage
+ ///
+ /// # Key Scheme
+ ///
+ /// A key for the [substrate storage map]
+ /// (https://github.com/paritytech/substrate/blob/dd97b1478b31a4715df7e88a5ebc6664425fb6c6/frame/support/src/storage/generator/map.rs#L28)
+ /// is constructed with:
+ ///
+ /// ```nocompile
+ /// Twox128(module_prefix) ++ Twox128(storage_prefix) ++ Hasher(encode(key))
+ /// ```
+ ///
+ /// For the `System` module's `Account` map, the [hasher implementation]
+ /// (https://github.com/paritytech/substrate/blob/2c87fe171bc341755a43a3b32d67560469f8daac/frame/system/src/lib.rs#L349)
+ /// is `blake2_128_concat`.
+ // #[ink(message)]
+ // fn get_balance(&self, account: AccountId) -> Balance {
+ // let mut key = vec![
+ // // Precomputed: Twox128("System")
+ // 38, 170, 57, 78, 234, 86, 48, 224, 124, 72, 174, 12, 149, 88, 206, 247,
+ // // Precomputed: Twox128("Account")
+ // 185, 157, 136, 14, 198, 129, 121, 156, 12, 243, 14, 136, 134, 55, 29, 169,
+ // ];
+
+ // let encoded_account = account.encode();
+ // let hashed_account = <Blake2x128>::hash_bytes(&encoded_account);
+
+ // // The hasher is `Blake2_128Concat` which appends the unhashed account to the hashed account
+ // key.extend_from_slice(&hashed_account);
+ // key.extend_from_slice(&encoded_account);
+
+ // // fetch from runtime storage
+ // let result = self.env().get_runtime_storage::<AccountInfo>(&key[..]);
+ // match result {
+ // Some(Ok(account_info)) => account_info.data.free,
+ // Some(Err(err)) => {
+ // env::println(&format!("Error reading AccountInfo {:?}", err));
+ // 0
+ // }
+ // None => {
+ // env::println(&format!("No data at key {:?}", key));
+ // 0
+ // }
+ // }
+ // }
+
+ #[ink(message)]
+ fn transfer_from(&self, collection_id: u64, item_id: u64, new_owner: AccountId) {
+
+ env::println(&format!(
+ "transfer_from invoke_runtime params {:?}, {:?}, {:?} ",
+ collection_id,
+ item_id,
+ new_owner
+ ));
+
+ let transfer_from_call = runtime_calls::transfer_from(collection_id, item_id, new_owner);
+ // dispatch the call to the runtime
+ let result = self.env().invoke_runtime(&transfer_from_call);
+
+ // report result to console
+ // NOTE: println should only be used on a development chain)
+ env::println(&format!(
+ "transfer_from invoke_runtime result {:?}",
+ result
+ ));
+ }
+
+ // SafeTransferFrom
+
+ #[ink(message)]
+ fn create_item(&self, collection_id: u64, properties: Vec<u8>) {
+
+ env::println(&format!(
+ "create_item invoke_runtime params {:?}, {:?} ",
+ collection_id,
+ properties
+ ));
+
+ let create_item_call = runtime_calls::create_item(collection_id, properties);
+ // dispatch the call to the runtime
+ let result = self.env().invoke_runtime(&create_item_call);
+
+ // report result to console
+ // NOTE: println should only be used on a development chain)
+ env::println(&format!(
+ "create_item invoke_runtime result {:?}",
result
));
}
- }
- #[cfg(test)]
- mod tests {
- use super::*;
- use sp_keyring::AccountKeyring;
+ #[ink(message)]
+ fn burn_item(&self, collection_id: u64, item_id: u64) {
- #[test]
- fn dispatches_balances_call() {
- let calls = Calls::new();
- let alice = AccountId::from(AccountKeyring::Alice.to_account_id());
- // assert_eq!(calls.env().dispatched_calls().into_iter().count(), 0);
- calls.balance_transfer(alice, 10000);
- // assert_eq!(calls.env().dispatched_calls().into_iter().count(), 1);
+ env::println(&format!(
+ "burn_item invoke_runtime params {:?}, {:?}",
+ collection_id,
+ item_id
+ ));
+
+ let burn_item_call = runtime_calls::burn_item(collection_id, item_id);
+ // dispatch the call to the runtime
+ let result = self.env().invoke_runtime(&burn_item_call);
+
+ // report result to console
+ // NOTE: println should only be used on a development chain)
+ env::println(&format!(
+ "burn_item invoke_runtime result {:?}",
+ result
+ ));
}
+
+ // GetOwner
+ // BalanceOf
}
}
smart_contract/ink-types-node-runtime/src/calls.rsdiffbeforeafterboth--- a/smart_contract/ink-types-node-runtime/src/calls.rs
+++ b/smart_contract/ink-types-node-runtime/src/calls.rs
@@ -50,46 +50,6 @@
// Balances::<NodeRuntimeTypes>::transfer(account.into(), balance).into()
// }
-// #[cfg(test)]
-// mod tests {
-// use crate::{calls, NodeRuntimeTypes};
-// use super::Call;
-
-// use node_runtime::{self, Runtime};
-// use pallet_indices::address;
-// use scale::{Decode, Encode};
-
-
-// #[test]
-// fn call_balance_transfer() {
-// let balance = 10_000;
-// let account_index = 0;
-
-// let contract_address = calls::Address::Index(account_index);
-// let contract_transfer =
-// calls::Balances::<NodeRuntimeTypes>::transfer(contract_address, balance);
-// let contract_call = Call::Balances(contract_transfer);
-
-// let srml_address = address::Address::Index(account_index);
-// let srml_transfer = node_runtime::BalancesCall::<Runtime>::transfer(srml_address, balance);
-// let srml_call = node_runtime::Call::Balances(srml_transfer);
-
-// let contract_call_encoded = contract_call.encode();
-// let srml_call_encoded = srml_call.encode();
-
-// assert_eq!(srml_call_encoded, contract_call_encoded);
-
-// let srml_call_decoded: node_runtime::Call =
-// Decode::decode(&mut contract_call_encoded.as_slice())
-// .expect("Balances transfer call decodes to srml type");
-// let srml_call_encoded = srml_call_decoded.encode();
-// let contract_call_decoded: Call = Decode::decode(&mut srml_call_encoded.as_slice())
-// .expect("Balances transfer call decodes back to contract type");
-// assert!(contract_call == contract_call_decoded);
-// }
-// }
-
-
@@ -114,18 +74,18 @@
use ink_core::env::EnvTypes;
use scale::{Codec, Decode, Encode};
-use pallet_indices::address::Address;
use sp_runtime::traits::Member;
+use ink_prelude::vec::Vec;
use crate::{AccountId, Balance, NodeRuntimeTypes};
-use sp_runtime::sp_std::prelude::Vec;
+
/// Default runtime Call type, a subset of the runtime Call module variants
///
/// The codec indices of the modules *MUST* match those in the concrete runtime.
#[derive(Encode, Decode)]
#[cfg_attr(feature = "std", derive(Clone, PartialEq, Eq))]
pub enum Call {
- #[codec(index = "8")]
+ #[codec(index = "7")]
Nft(Nft<NodeRuntimeTypes>),
}
@@ -140,61 +100,74 @@
where
T: EnvTypes,
T::AccountId: Member + Codec,
-{
- #[allow(non_camel_case_types)]
- create_nft_collection(Vec<u16>, Vec<u16>, Vec<u8>, u32),
+ {
+ #[allow(non_camel_case_types)]
+ create_collection(Vec<u16>, Vec<u16>, Vec<u8>, u32),
- #[allow(non_camel_case_types)]
- add_collection_admin(u64, T::AccountId),
+ #[allow(non_camel_case_types)]
+ destroy_collection(u64),
- // collection_name: Vec<u16>,
- // collection_description: Vec<u16>,
- // token_prefix: Vec<u8>,
- // custom_data_sz: u32
+ #[allow(non_camel_case_types)]
+ change_collection_owner(u64, T::AccountId),
-}
+ #[allow(non_camel_case_types)]
+ add_collection_admin(u64, T::AccountId),
-// Construct a `Balances::transfer` call
-pub fn create_collection(collection_name: Vec<u16>, collection_description: Vec<u16>,
- token_prefix: Vec<u8>, custom_data_sz: u32) -> Call {
- Nft::<NodeRuntimeTypes>::create_nft_collection(collection_name, collection_description, token_prefix, custom_data_sz).into()
-}
+ #[allow(non_camel_case_types)]
+ remove_collection_admin(u64, T::AccountId),
-#[cfg(test)]
-mod tests {
- use crate::{calls, NodeRuntimeTypes};
- use super::Call;
+ #[allow(non_camel_case_types)]
+ create_item(u64, Vec<u8>),
- use node_runtime::{self, Runtime};
- use pallet_indices::address;
- use scale::{Decode, Encode};
+ #[allow(non_camel_case_types)]
+ burn_item(u64, u64),
+ #[allow(non_camel_case_types)]
+ transfer(u64, u64, T::AccountId),
- #[test]
- fn call_balance_transfer() {
- let balance = 10_000;
- let account_index = 0;
+ #[allow(non_camel_case_types)]
+ nft_approve(T::AccountId, u64, u64),
- let contract_address = calls::Address::Index(account_index);
- let contract_transfer =
- calls::Balances::<NodeRuntimeTypes>::transfer(contract_address, balance);
- let contract_call = Call::Balances(contract_transfer);
+ #[allow(non_camel_case_types)]
+ nft_transfer_from(u64, u64, T::AccountId),
- let srml_address = address::Address::Index(account_index);
- let srml_transfer = node_runtime::BalancesCall::<Runtime>::transfer(srml_address, balance);
- let srml_call = node_runtime::Call::Balances(srml_transfer);
+ #[allow(non_camel_case_types)]
+ nft_safe_transfer(u64, u64, T::AccountId),
+ }
- let contract_call_encoded = contract_call.encode();
- let srml_call_encoded = srml_call.encode();
- assert_eq!(srml_call_encoded, contract_call_encoded);
- let srml_call_decoded: node_runtime::Call =
- Decode::decode(&mut contract_call_encoded.as_slice())
- .expect("Balances transfer call decodes to srml type");
- let srml_call_encoded = srml_call_decoded.encode();
- let contract_call_decoded: Call = Decode::decode(&mut srml_call_encoded.as_slice())
- .expect("Balances transfer call decodes back to contract type");
- assert!(contract_call == contract_call_decoded);
- }
+
+pub fn transfer(collection_id: u64, item_id: u64, new_owner: AccountId) -> Call {
+ Nft::<NodeRuntimeTypes>::transfer(collection_id, item_id, new_owner.into()).into()
+}
+
+pub fn create_collection(collection_name: Vec<u16>, collection_description: Vec<u16>,
+ token_prefix: Vec<u8>, custom_data_sz: u32) -> Call {
+ Nft::<NodeRuntimeTypes>::create_collection(collection_name, collection_description, token_prefix, custom_data_sz).into()
+}
+
+// pub fn safe_transfer(collection_id: u64, item_id: u64, new_owner: AccountId) -> Call {
+// Nft::<NodeRuntimeTypes>::nft_safe_transfer(collection_id, item_id, new_owner.into()).into()
+// }
+
+pub fn approve(approved: AccountId, collection_id: u64, item_id: u64) -> Call {
+ Nft::<NodeRuntimeTypes>::nft_approve(approved.into(), collection_id, item_id).into()
+}
+
+//GetApproved
+
+pub fn transfer_from(collection_id: u64, item_id: u64, new_owner: AccountId) -> Call {
+ Nft::<NodeRuntimeTypes>::nft_transfer_from(collection_id, item_id, new_owner.into()).into()
+}
+
+pub fn create_item(collection_id: u64, properties: Vec<u8>) -> Call {
+ Nft::<NodeRuntimeTypes>::create_item(collection_id, properties).into()
+}
+
+pub fn burn_item(collection_id: u64, item_id: u64) -> Call {
+ Nft::<NodeRuntimeTypes>::burn_item(collection_id, item_id).into()
}
+
+//GetOwner
+//BalanceOf
\ No newline at end of file
smart_contract/ink-types-node-runtime/src/lib.rsdiffbeforeafterboth--- a/smart_contract/ink-types-node-runtime/src/lib.rs
+++ b/smart_contract/ink-types-node-runtime/src/lib.rs
@@ -36,6 +36,7 @@
#[derive(Clone, Debug, PartialEq, Eq, PartialOrd, Ord, Encode, Decode)]
pub struct AccountId (AccountId32);
+
impl From<AccountId32> for AccountId {
fn from(account: AccountId32) -> Self {
AccountId(account)