From 461ca2c5031370567afa600727b501a52fa6b338 Mon Sep 17 00:00:00 2001 From: Michael Mueller Date: Mon, 17 Mar 2025 18:46:23 +0100 Subject: [PATCH 1/4] Upgrade examples to v6.0.0-alpha --- call-runtime/Cargo.toml | 17 +- call-runtime/README.md | 6 +- call-runtime/lib.rs | 36 ++- combined-extension/Cargo.toml | 4 +- combined-extension/lib.rs | 22 +- conditional-compilation/Cargo.toml | 6 +- conditional-compilation/lib.rs | 4 +- contract-storage/Cargo.toml | 6 +- contract-terminate/Cargo.toml | 7 +- contract-terminate/lib.rs | 18 +- contract-transfer/Cargo.toml | 7 +- contract-transfer/lib.rs | 130 ++++++--- contract-xcm/Cargo.toml | 10 +- contract-xcm/lib.rs | 81 ++++-- cross-contract-calls/Cargo.toml | 7 +- cross-contract-calls/e2e_tests.rs | 102 +++---- cross-contract-calls/lib.rs | 56 +--- .../other-contract/Cargo.toml | 7 +- custom-allocator/Cargo.toml | 13 +- custom-allocator/lib.rs | 64 ++++- custom-environment/Cargo.toml | 6 +- custom-environment/README.md | 6 +- custom-environment/lib.rs | 3 +- dns/Cargo.toml | 4 +- dns/lib.rs | 69 ++--- e2e-call-runtime/Cargo.toml | 6 +- e2e-call-runtime/lib.rs | 27 +- erc1155/Cargo.toml | 4 +- erc1155/lib.rs | 260 ++++++++++-------- erc20/Cargo.toml | 6 +- erc20/lib.rs | 231 +++++++++------- erc721/Cargo.toml | 4 +- erc721/lib.rs | 150 +++++----- events/Cargo.toml | 11 +- events/event-def-unused/Cargo.toml | 6 +- events/event-def/Cargo.toml | 6 +- events/event-def2/Cargo.toml | 6 +- events/lib.rs | 14 +- flipper/Cargo.toml | 6 +- flipper/lib.rs | 19 +- incrementer/Cargo.toml | 4 +- lazyvec/Cargo.toml | 6 +- lazyvec/lib.rs | 4 +- multi-contract-caller/Cargo.toml | 6 +- multi-contract-caller/accumulator/Cargo.toml | 5 +- multi-contract-caller/adder/Cargo.toml | 4 +- multi-contract-caller/lib.rs | 25 +- multi-contract-caller/subber/Cargo.toml | 4 +- multisig/Cargo.toml | 4 +- multisig/lib.rs | 72 ++--- payment-channel/Cargo.toml | 9 +- payment-channel/lib.rs | 120 ++++---- psp22-extension/Cargo.toml | 4 +- psp22-extension/README.md | 4 +- psp22-extension/lib.rs | 87 +++--- .../runtime/psp22-extension-example.rs | 49 ++-- rand-extension/Cargo.toml | 4 +- rand-extension/README.md | 4 +- rand-extension/lib.rs | 1 + .../runtime/chain-extension-example.rs | 2 +- runtime-call-contract/Cargo.toml | 25 +- runtime-call-contract/e2e_tests.rs | 16 +- .../sandbox-runtime/Cargo.toml | 4 +- .../sandbox-runtime/src/lib.rs | 4 +- runtime-call-contract/traits/Cargo.toml | 4 +- trait-dyn-cross-contract-calls/Cargo.toml | 6 +- .../contracts/incrementer/Cargo.toml | 4 +- trait-dyn-cross-contract-calls/lib.rs | 4 +- .../traits/Cargo.toml | 4 +- trait-erc20/Cargo.toml | 4 +- trait-erc20/lib.rs | 206 +++++++------- trait-flipper/Cargo.toml | 4 +- trait-flipper/lib.rs | 12 +- trait-incrementer/Cargo.toml | 4 +- trait-incrementer/traits/Cargo.toml | 5 +- upgradeable-contracts/README.md | 18 +- upgradeable-contracts/delegator/Cargo.toml | 6 +- .../delegator/delegatee/Cargo.toml | 4 +- .../delegator/delegatee/lib.rs | 27 +- .../delegator/delegatee2/Cargo.toml | 4 +- .../delegator/delegatee2/lib.rs | 26 +- upgradeable-contracts/delegator/lib.rs | 124 +++++++-- .../set-code-hash-migration/Cargo.toml | 6 +- .../set-code-hash-migration/e2e_tests.rs | 3 +- .../set-code-hash-migration/lib.rs | 8 +- .../migration/Cargo.toml | 4 +- .../set-code-hash-migration/migration/lib.rs | 2 +- .../updated-incrementer/Cargo.toml | 4 +- .../updated-incrementer/lib.rs | 5 +- .../set-code-hash/Cargo.toml | 6 +- upgradeable-contracts/set-code-hash/lib.rs | 9 +- .../updated-incrementer/Cargo.toml | 4 +- .../set-code-hash/updated-incrementer/lib.rs | 9 +- wildcard-selector/Cargo.toml | 6 +- wildcard-selector/lib.rs | 59 +++- 95 files changed, 1400 insertions(+), 1105 deletions(-) diff --git a/call-runtime/Cargo.toml b/call-runtime/Cargo.toml index bf6a8b09..565de766 100644 --- a/call-runtime/Cargo.toml +++ b/call-runtime/Cargo.toml @@ -1,24 +1,24 @@ [package] name = "call-runtime" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } -# Substrate -# # We need to explicitly turn off some of the `sp-io` features, to avoid conflicts # (especially for global allocator). -# # See also: https://substrate.stackexchange.com/questions/4733/error-when-compiling-a-contract-using-the-xcm-chain-extension. -sp-io = { version = "23.0.0", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] } -sp-runtime = { version = "24.0.0", default-features = false } +# +# For `sp-runtime-interface` we need to turn off static asserts. +sp-io = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["disable_panic_handler", "disable_oom", "disable_allocator"] } +sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["disable_target_static_assertions"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" @@ -28,6 +28,7 @@ default = ["std"] std = [ "ink/std", "sp-runtime/std", + "sp-runtime-interface/std", "sp-io/std", ] ink-as-dependency = [] diff --git a/call-runtime/README.md b/call-runtime/README.md index acf3c726..9a3c2cc2 100644 --- a/call-runtime/README.md +++ b/call-runtime/README.md @@ -9,10 +9,10 @@ It demonstrates how to call a runtime dispatchable from an ink! contract. To integrate this example into Substrate you need to adjust pallet contracts configuration in your runtime: ```rust // In your node's runtime configuration file (runtime.rs) - impl pallet_contracts::Config for Runtime { + impl pallet_revive::Config for Runtime { … // `Everything` or anything that will allow for the `Balances::transfer` extrinsic. - type CallFilter = frame_support::traits::Everything; + type CallFilter = frame_support::traits::Everything; type UnsafeUnstableInterface = ConstBool; … } @@ -21,7 +21,7 @@ To integrate this example into Substrate you need to adjust pallet contracts con ## Comparison to `ChainExtension` Just as a chain extension, `call_runtime` API allows contracts for direct calling to the runtime. -You can trigger any extrinsic that is not forbidden by `pallet_contracts::Config::CallFilter`. +You can trigger any extrinsic that is not forbidden by `pallet_revive::Config::CallFilter`. Consider writing a chain extension if you need to perform one of the following tasks: - Return data. - Provide functionality **exclusively** to contracts. diff --git a/call-runtime/lib.rs b/call-runtime/lib.rs index 0511e3a1..1a8b46e1 100644 --- a/call-runtime/lib.rs +++ b/call-runtime/lib.rs @@ -67,7 +67,7 @@ mod runtime_call { EnvError::ReturnError(ReturnErrorCode::CallRuntimeFailed) => { RuntimeError::CallRuntimeFailed } - _ => panic!("Unexpected error from `pallet-contracts`."), + _ => panic!("Unexpected error from `pallet-revive`."), } } } @@ -112,6 +112,13 @@ mod runtime_call { pub fn call_nonexistent_extrinsic(&mut self) -> Result<(), RuntimeError> { self.env().call_runtime(&()).map_err(Into::into) } + + /// todo + /// Returns the `AccountId` of this contract. + #[ink(message)] + pub fn account_id(&mut self) -> AccountId { + self.env().account_id() + } } #[cfg(all(test, feature = "e2e-tests"))] @@ -122,13 +129,7 @@ mod runtime_call { ContractsBackend, }; - use ink::{ - env::{ - test::default_accounts, - DefaultEnvironment, - }, - primitives::AccountId, - }; + use ink::primitives::AccountId; type E2EResult = Result>; @@ -167,10 +168,20 @@ mod runtime_call { .expect("instantiate failed"); let mut call_builder = contract.call_builder::(); - let receiver: AccountId = default_accounts::().bob; + // todo + let acc = call_builder.account_id(); + let call_res = client + .call(&ink_e2e::alice(), &acc) + .submit() + .await + .expect("call failed"); + let account_id: AccountId = call_res.return_value(); + + //let receiver: AccountId = default_accounts().bob; + let receiver = AccountId::from([0x02; 32]); let contract_balance_before = client - .free_balance(contract.account_id) + .free_balance(account_id) .await .expect("Failed to get account balance"); let receiver_balance_before = client @@ -192,7 +203,7 @@ mod runtime_call { // then let contract_balance_after = client - .free_balance(contract.account_id) + .free_balance(account_id) .await .expect("Failed to get account balance"); let receiver_balance_after = client @@ -231,7 +242,8 @@ mod runtime_call { .expect("instantiate failed"); let mut call_builder = contract.call_builder::(); - let receiver: AccountId = default_accounts::().bob; + //let receiver: ink::H160 = default_accounts().bob; + let receiver = AccountId::from([0x02; 32]); // when let transfer_message = call_builder diff --git a/combined-extension/Cargo.toml b/combined-extension/Cargo.toml index 1dcacfbe..706a840b 100755 --- a/combined-extension/Cargo.toml +++ b/combined-extension/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "combined_extension" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } psp22_extension = { path = "../psp22-extension", default-features = false, features = ["ink-as-dependency"] } rand_extension = { path = "../rand-extension", default-features = false, features = ["ink-as-dependency"] } diff --git a/combined-extension/lib.rs b/combined-extension/lib.rs index 5c5cd76a..3a6306ff 100755 --- a/combined-extension/lib.rs +++ b/combined-extension/lib.rs @@ -1,8 +1,11 @@ #![cfg_attr(not(feature = "std"), no_std, no_main)] -use ink::env::{ - DefaultEnvironment, - Environment, +use ink::{ + env::{ + DefaultEnvironment, + Environment, + }, + U256, }; use psp22_extension::Psp22Extension; use rand_extension::{ @@ -42,6 +45,7 @@ impl Environment for CustomEnvironment { type Hash = ::Hash; type Timestamp = ::Timestamp; type BlockNumber = ::BlockNumber; + type EventRecord = ::EventRecord; /// Setting up the combined chain extension as a primary extension. /// @@ -78,7 +82,7 @@ mod combined_extension { /// Returns the total supply from PSP22 extension. #[ink(message)] - pub fn get_total_supply(&self) -> Result { + pub fn get_total_supply(&self) -> Result { self.env().extension().psp22.total_supply(0) } } @@ -126,7 +130,9 @@ mod combined_extension { assert_eq!(contract.get_rand(), Ok(RANDOM_VALUE)); } - const TOTAL_SUPPLY: u128 = 1377; + fn total_supply() -> U256 { + U256::from(1337) + } /// Mocking the PSP22 extension to return results that we want in the tests. /// @@ -143,7 +149,7 @@ mod combined_extension { fn call(&mut self, func_id: u16, _input: &[u8], output: &mut Vec) -> u32 { match func_id { 0x162d /* `func_id` of the `total_supply` function */ => { - ink::scale::Encode::encode_to(&TOTAL_SUPPLY, output); + ink::scale::Encode::encode_to(&total_supply(), output); 0 } _ => { @@ -166,7 +172,7 @@ mod combined_extension { ink::env::test::register_chain_extension(MockedPSP22Extension); // then - assert_eq!(contract.get_total_supply(), Ok(TOTAL_SUPPLY)); + assert_eq!(contract.get_total_supply(), Ok(total_supply())); } #[ink::test] @@ -183,7 +189,7 @@ mod combined_extension { // then assert_eq!(contract.get_rand(), Ok(RANDOM_VALUE)); - assert_eq!(contract.get_total_supply(), Ok(TOTAL_SUPPLY)); + assert_eq!(contract.get_total_supply(), Ok(total_supply())); } } } diff --git a/conditional-compilation/Cargo.toml b/conditional-compilation/Cargo.toml index 86afe242..07574803 100755 --- a/conditional-compilation/Cargo.toml +++ b/conditional-compilation/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "conditional-compilation" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/conditional-compilation/lib.rs b/conditional-compilation/lib.rs index 8619493b..86bd55bd 100755 --- a/conditional-compilation/lib.rs +++ b/conditional-compilation/lib.rs @@ -27,7 +27,7 @@ pub mod conditional_compilation { // attributing event field with `cfg` is not allowed new_value: bool, #[ink(topic)] - by: AccountId, + by: ink::H160, } /// Feature gated event @@ -37,7 +37,7 @@ pub mod conditional_compilation { // attributing event field with `cfg` is not allowed new_value: bool, #[ink(topic)] - by: AccountId, + by: ink::H160, when: BlockNumber, } diff --git a/contract-storage/Cargo.toml b/contract-storage/Cargo.toml index 13355ead..2ae79dff 100755 --- a/contract-storage/Cargo.toml +++ b/contract-storage/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "contract-storage" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/contract-terminate/Cargo.toml b/contract-terminate/Cargo.toml index 3c96a74c..973f2983 100644 --- a/contract-terminate/Cargo.toml +++ b/contract-terminate/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "contract_terminate" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" @@ -19,5 +19,6 @@ default = ["std"] std = [ "ink/std", ] + ink-as-dependency = [] e2e-tests = [] diff --git a/contract-terminate/lib.rs b/contract-terminate/lib.rs index c2430bb8..c242c5f2 100644 --- a/contract-terminate/lib.rs +++ b/contract-terminate/lib.rs @@ -31,14 +31,10 @@ pub mod just_terminates { #[ink::test] fn terminating_works() { // given - let accounts = - ink::env::test::default_accounts::(); - let contract_id = ink::env::test::callee::(); - ink::env::test::set_caller::(accounts.alice); - ink::env::test::set_account_balance::( - contract_id, - 100, - ); + let accounts = ink::env::test::default_accounts(); + let contract_id = ink::env::test::callee(); + ink::env::test::set_caller(accounts.alice); + ink::env::test::set_account_balance(contract_id, 100.into()); let mut contract = JustTerminate::new(); // when @@ -48,7 +44,7 @@ pub mod just_terminates { ink::env::test::assert_contract_termination::( should_terminate, accounts.alice, - 100, + 100.into(), ); } } @@ -89,7 +85,9 @@ pub mod just_terminates { // then assert!(call_res.contains_event("System", "KilledAccount")); assert!(call_res.contains_event("Balances", "Withdraw")); - assert!(call_res.contains_event("Contracts", "Terminated")); + // todo this event below no longer exists, but we could try getting + // info for the contract and asserting that it fails. + // assert!(call_res.contains_event("Revive", "Terminated")); Ok(()) } diff --git a/contract-transfer/Cargo.toml b/contract-transfer/Cargo.toml index 17154b49..cf203d62 100644 --- a/contract-transfer/Cargo.toml +++ b/contract-transfer/Cargo.toml @@ -1,15 +1,16 @@ [package] name = "contract_transfer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +#ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/contract-transfer/lib.rs b/contract-transfer/lib.rs index c175f719..bf943422 100644 --- a/contract-transfer/lib.rs +++ b/contract-transfer/lib.rs @@ -6,6 +6,7 @@ #[ink::contract] pub mod give_me { + use ink::primitives::U256; /// No storage is needed for this simple contract. #[ink(storage)] pub struct GiveMe {} @@ -26,10 +27,7 @@ pub mod give_me { /// balance below the minimum balance (i.e. the chain's existential deposit). /// - Panics in case the transfer failed for another reason. #[ink(message)] - pub fn give_me(&mut self, value: Balance) { - ink::env::debug_println!("requested value: {}", value); - ink::env::debug_println!("contract balance: {}", self.env().balance()); - + pub fn give_me(&mut self, value: U256) { assert!(value <= self.env().balance(), "insufficient funds!"); if self.env().transfer(self.env().caller(), value).is_err() { @@ -51,45 +49,58 @@ pub mod give_me { /// allowed to receive value as part of the call. #[ink(message, payable, selector = 0xCAFEBABE)] pub fn was_it_ten(&self) { + /* ink::env::debug_println!( "received payment: {}", self.env().transferred_value() ); - assert!(self.env().transferred_value() == 10, "payment was not ten"); + */ + assert!( + self.env().transferred_value() == U256::from(10), + "payment was not ten" + ); + } + + /// todo + /// Returns the `AccountId` of this contract. + #[ink(message)] + pub fn account_id(&mut self) -> AccountId { + self.env().account_id() } } #[cfg(test)] mod tests { use super::*; + use ink::H160; #[ink::test] fn transfer_works() { // given - let contract_balance = 100; + let contract_balance = 100.into(); let accounts = default_accounts(); let mut give_me = create_contract(contract_balance); // when set_sender(accounts.eve); - set_balance(accounts.eve, 0); - give_me.give_me(80); + set_balance(accounts.eve, 0.into()); + give_me.give_me(80.into()); // then - assert_eq!(get_balance(accounts.eve), 80); + assert_eq!(get_balance(accounts.eve), 80.into()); } #[ink::test] #[should_panic(expected = "insufficient funds!")] fn transfer_fails_insufficient_funds() { // given - let contract_balance = 100; + let contract_balance = 100.into(); let accounts = default_accounts(); let mut give_me = create_contract(contract_balance); // when set_sender(accounts.eve); - give_me.give_me(120); + give_me.give_me(120.into()); // then // `give_me` must already have panicked here @@ -100,28 +111,28 @@ pub mod give_me { use ink::codegen::Env; // given let accounts = default_accounts(); - let give_me = create_contract(100); - let contract_account = give_me.env().account_id(); + let give_me = create_contract(100.into()); + let contract_account = give_me.env().address(); // when // Push the new execution context which sets initial balances and // sets Eve as the caller - set_balance(accounts.eve, 100); - set_balance(contract_account, 0); + set_balance(accounts.eve, 100.into()); + set_balance(contract_account, 0.into()); set_sender(accounts.eve); // then // we use helper macro to emulate method invocation coming with payment, // and there must be no panic - ink::env::pay_with_call!(give_me.was_it_ten(), 10); + ink::env::pay_with_call!(give_me.was_it_ten(), 10.into()); // and // balances should be changed properly let contract_new_balance = get_balance(contract_account); let caller_new_balance = get_balance(accounts.eve); - assert_eq!(caller_new_balance, 100 - 10); - assert_eq!(contract_new_balance, 10); + assert_eq!(caller_new_balance, (100 - 10).into()); + assert_eq!(contract_new_balance, 10.into()); } #[ink::test] @@ -129,14 +140,14 @@ pub mod give_me { fn test_transferred_value_must_fail() { // given let accounts = default_accounts(); - let give_me = create_contract(100); + let give_me = create_contract(100.into()); // when // Push the new execution context which sets Eve as caller and // the `mock_transferred_value` as the value which the contract // will see as transferred to it. set_sender(accounts.eve); - ink::env::test::set_value_transferred::(13); + ink::env::test::set_value_transferred(13.into()); // then give_me.was_it_ten(); @@ -145,37 +156,35 @@ pub mod give_me { /// Creates a new instance of `GiveMe` with `initial_balance`. /// /// Returns the `contract_instance`. - fn create_contract(initial_balance: Balance) -> GiveMe { + fn create_contract(initial_balance: U256) -> GiveMe { let accounts = default_accounts(); set_sender(accounts.alice); set_balance(contract_id(), initial_balance); GiveMe::new() } - fn contract_id() -> AccountId { - ink::env::test::callee::() + fn contract_id() -> H160 { + ink::env::test::callee() } - fn set_sender(sender: AccountId) { - ink::env::test::set_caller::(sender); + fn set_sender(sender: H160) { + ink::env::test::set_caller(sender); } - fn default_accounts( - ) -> ink::env::test::DefaultAccounts { - ink::env::test::default_accounts::() + fn default_accounts() -> ink::env::test::DefaultAccounts { + ink::env::test::default_accounts() } - fn set_balance(account_id: AccountId, balance: Balance) { - ink::env::test::set_account_balance::( - account_id, balance, - ) + // todo change all to addr + fn set_balance(account_id: H160, balance: U256) { + ink::env::test::set_account_balance(account_id, balance) } - fn get_balance(account_id: AccountId) -> Balance { + fn get_balance(account_id: H160) -> U256 { ink::env::test::get_account_balance::( account_id, ) - .expect("Cannot get account balance") + .expect("Cannot get contract balance") } } @@ -190,6 +199,7 @@ pub mod give_me { type E2EResult = std::result::Result>; #[ink_e2e::test] + //#[ink_e2e::test(backend(runtime_only))] async fn e2e_sending_value_to_give_me_must_fail( mut client: Client, ) -> E2EResult<()> { @@ -197,31 +207,36 @@ pub mod give_me { let mut constructor = GiveMeRef::new(); let contract = client .instantiate("contract_transfer", &ink_e2e::alice(), &mut constructor) - .value(1000) + .value(1_000_000_000) .submit() .await .expect("instantiate failed"); let mut call_builder = contract.call_builder::(); // when - let transfer = call_builder.give_me(120); + let transfer = call_builder.give_me(120_000_000.into()); let call_res = client .call(&ink_e2e::bob(), &transfer) - .value(10) + .value(10_000_000) .submit() .await; // then + assert!(call_res.is_err(), "call must have errored"); + /* + // todo bug with wrong printing of message if let Err(ink_e2e::Error::CallDryRun(dry_run)) = call_res { assert!(dry_run.debug_message.contains("paid an unpayable message")) } else { panic!("Paying an unpayable message should fail") } + */ Ok(()) } - #[ink_e2e::test] + //#[ink_e2e::test] + #[ink_e2e::test(backend(runtime_only))] async fn e2e_contract_must_transfer_value_to_sender( mut client: Client, ) -> E2EResult<()> { @@ -229,19 +244,36 @@ pub mod give_me { let mut constructor = GiveMeRef::new(); let contract = client .instantiate("contract_transfer", &ink_e2e::bob(), &mut constructor) - .value(1337) + // todo convert the argument type to U256 + .value(1_337_000_000) .submit() .await .expect("instantiate failed"); + let contract_addr = contract.addr; + #[allow(non_upper_case_globals)] + const NativeToEthRatio: u128 = 1_000_000; // todo add to environment? + assert_eq!( + contract.trace.clone().unwrap().value, + Some(U256::from(1_337_000_000 * NativeToEthRatio)) + ); let mut call_builder = contract.call_builder::(); + // todo extract account id from something else + let acc = call_builder.account_id(); + let call_res = client + .call(&ink_e2e::eve(), &acc) + .submit() + .await + .expect("call failed"); + let account_id: AccountId = call_res.return_value(); + let balance_before: Balance = client - .free_balance(contract.account_id.clone()) + .free_balance(account_id.clone()) // todo can't we take a ref here? .await .expect("getting balance failed"); // when - let transfer = call_builder.give_me(120); + let transfer = call_builder.give_me(120_000_000.into()); let call_res = client .call(&ink_e2e::eve(), &transfer) @@ -250,10 +282,22 @@ pub mod give_me { .expect("call failed"); // then - assert!(call_res.debug_message().contains("requested value: 120\n")); + /* + // todo + assert!(call_res + .debug_message() + .contains("requested value: 120000000\n")); + */ + let outgoing_trace = &call_res.trace.unwrap().calls[0]; + //assert_eq!(outgoing_trace.value, Some(U256::from(120_000_000 * + // NativeToEthRatio))); + assert_eq!(outgoing_trace.value, Some(U256::from(120_000_000))); + assert_eq!(outgoing_trace.from, contract_addr); + //let eve = AccountId32Mapper::to_address(&ink_e2e::eve().account_id(). + // encode()[..20]); assert_eq!(trace.to, eve); let balance_after: Balance = client - .free_balance(contract.account_id.clone()) + .free_balance(account_id) .await .expect("getting balance failed"); assert_eq!(balance_before - balance_after, 120); diff --git a/contract-xcm/Cargo.toml b/contract-xcm/Cargo.toml index fcfb36bb..3a4eeff7 100644 --- a/contract-xcm/Cargo.toml +++ b/contract-xcm/Cargo.toml @@ -1,17 +1,17 @@ [package] name = "contract-xcm" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } -frame-support = { version = "32.0.0", default-features = false } -pallet-balances = { version = "33.0.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0", features = ["sandbox"] } +ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/contract-xcm/lib.rs b/contract-xcm/lib.rs index 93cf0486..85631d0a 100644 --- a/contract-xcm/lib.rs +++ b/contract-xcm/lib.rs @@ -1,3 +1,4 @@ +// todo example needs to be fixed, but this requires the map AccountId -> H160 function #![cfg_attr(not(feature = "std"), no_std, no_main)] #[ink::contract] @@ -5,6 +6,7 @@ mod contract_xcm { use ink::{ env::Error as EnvError, xcm::prelude::*, + //xcm::v4::*, }; /// A trivial contract used to exercise XCM API. @@ -29,7 +31,7 @@ mod contract_xcm { EnvError::ReturnError(ReturnErrorCode::XcmSendFailed) => { RuntimeError::XcmSendFailed } - _ => panic!("Unexpected error from `pallet-contracts`."), + _ => panic!("Unexpected error from `pallet-revive`."), } } } @@ -61,14 +63,14 @@ mod contract_xcm { id: *receiver.as_ref(), }; - let message: Xcm<()> = Xcm::builder() - .withdraw_asset(asset.clone().into()) + let message: ink::xcm::v5::Xcm<()> = Xcm::builder() + .withdraw_asset(asset.clone()) .buy_execution(asset.clone(), Unlimited) - .deposit_asset(asset.into(), beneficiary.into()) + .deposit_asset(asset, beneficiary) .build(); self.env() - .xcm_execute(&VersionedXcm::V4(message)) + .xcm_execute(&VersionedXcm::V5(message)) .map_err(Into::into) } @@ -85,26 +87,35 @@ mod contract_xcm { value: Balance, fee: Balance, ) -> Result { - let destination: Location = Parent.into(); + let destination: ink::xcm::v5::Location = ink::xcm::v5::Parent.into(); let asset: Asset = (Here, value).into(); + //let alice = AccountId32::from(ink_e2e::alice().public_key().0); let beneficiary = AccountId32 { network: None, - id: *self.env().caller().as_ref(), + // todo + id: [0x01; 32], }; let message: Xcm<()> = Xcm::builder() - .withdraw_asset(asset.clone().into()) - .buy_execution((Here, fee).into(), WeightLimit::Unlimited) - .deposit_asset(asset.into(), beneficiary.into()) + .withdraw_asset(asset.clone()) + .buy_execution((Here, fee), WeightLimit::Unlimited) + .deposit_asset(asset, beneficiary) .build(); let hash = self.env().xcm_send( - &VersionedLocation::V4(destination), - &VersionedXcm::V4(message), + &VersionedLocation::V5(destination), + &VersionedXcm::V5(message), )?; Ok(hash) } + + /// todo + /// Returns the `AccountId` of this contract. + #[ink(message)] + pub fn account_id(&mut self) -> AccountId { + self.env().account_id() + } } #[cfg(all(test, feature = "e2e-tests"))] @@ -113,13 +124,7 @@ mod contract_xcm { sp_runtime::AccountId32, traits::tokens::currency::Currency, }; - use ink::{ - env::{ - test::default_accounts, - DefaultEnvironment, - }, - primitives::AccountId, - }; + use ink::primitives::AccountId; use ink_e2e::{ preset::mock_network::{ self, @@ -161,10 +166,20 @@ mod contract_xcm { .expect("instantiate failed"); let mut call_builder = contract.call_builder::(); - let receiver: AccountId = default_accounts::().bob; + //let receiver: AccountId = default_accounts().bob; + let receiver = AccountId::from([0x02; 32]); + + // todo + let acc = call_builder.account_id(); + let call_res = client + .call(&ink_e2e::alice(), &acc) + .submit() + .await + .expect("call failed"); + let account_id: AccountId = call_res.return_value(); let contract_balance_before = client - .free_balance(contract.account_id) + .free_balance(account_id) .await .expect("Failed to get account balance"); let receiver_balance_before = client @@ -186,7 +201,7 @@ mod contract_xcm { // then let contract_balance_after = client - .free_balance(contract.account_id) + .free_balance(account_id) .await .expect("Failed to get account balance"); let receiver_balance_after = client @@ -215,7 +230,8 @@ mod contract_xcm { // This will fail since we have insufficient balance let transfer_message = call_builder.transfer_through_xcm( - default_accounts::().bob, + //default_accounts().bob, + AccountId::from([0x02; 32]), CONTRACT_BALANCE + 1, ); @@ -238,13 +254,27 @@ mod contract_xcm { .submit() .await .expect("instantiate failed"); + let mut call_builder = contract.call_builder::(); + + // todo + let acc = call_builder.account_id(); + let call_res = client + .call(&ink_e2e::alice(), &acc) + .submit() + .await + .expect("call failed"); + let account_id: AccountId = call_res.return_value(); Relay::execute_with(|| { let sovereign_account = parachain_account_sovereign_account_id( 1u32, - AccountId32::from(contract.account_id.0), + //AccountId32::from(contract.account_id.0), + AccountId32::from(account_id.0), + //account_id.into() ); + // The contract will be given 1000 tokens during instantiation. + //pub const CONTRACT_BALANCE: u128 = 1_000 * UNITS; // Fund the contract's derivative account, so we can use it as a sink, to // transfer funds to the caller. relay_chain::Balances::make_free_balance_be( @@ -262,7 +292,8 @@ mod contract_xcm { assert!(call_res.return_value().is_ok()); Relay::execute_with(|| { - let alice = AccountId32::from(ink_e2e::alice().public_key().0); + //let alice = AccountId32::from(ink_e2e::alice().public_key().0); + let alice = AccountId32::from([0x01; 32]); assert_eq!(relay_chain::Balances::free_balance(&alice), amount - fee); }); diff --git a/cross-contract-calls/Cargo.toml b/cross-contract-calls/Cargo.toml index ef3c3d19..aade132f 100755 --- a/cross-contract-calls/Cargo.toml +++ b/cross-contract-calls/Cargo.toml @@ -1,20 +1,21 @@ [package] name = "cross-contract-calls" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } # Note: We **need** to specify the `ink-as-dependency` feature. # # If we don't we will end up with linking errors! other-contract = { path = "other-contract", default-features = false, features = ["ink-as-dependency"] } +pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/cross-contract-calls/e2e_tests.rs b/cross-contract-calls/e2e_tests.rs index 26d168aa..dd0061c0 100644 --- a/cross-contract-calls/e2e_tests.rs +++ b/cross-contract-calls/e2e_tests.rs @@ -4,38 +4,7 @@ use ink_e2e::ContractsBackend; type E2EResult = std::result::Result>; #[ink_e2e::test] -async fn flip_and_get(mut client: Client) -> E2EResult<()> { - // given - let other_contract_code = client - .upload("other-contract", &ink_e2e::alice()) - .submit() - .await - .expect("other_contract upload failed"); - - let mut constructor = CrossContractCallsRef::new_v1(other_contract_code.code_hash); - let contract = client - .instantiate("cross-contract-calls", &ink_e2e::alice(), &mut constructor) - .submit() - .await - .expect("basic-contract-caller instantiate failed"); - let mut call_builder = contract.call_builder::(); - let call = call_builder.flip_and_get_v1(); - - // when - let result = client - .call(&ink_e2e::alice(), &call) - .submit() - .await - .expect("Calling `flip_and_get` failed") - .return_value(); - - assert!(!result); - - Ok(()) -} - -#[ink_e2e::test] -async fn instantiate_v2_with_insufficient_storage_deposit_limit( +async fn instantiate_with_insufficient_storage_deposit_limit( mut client: Client, ) -> E2EResult<()> { // given @@ -45,38 +14,32 @@ async fn instantiate_v2_with_insufficient_storage_deposit_limit( +async fn instantiate_with_sufficient_limits( mut client: Client, ) -> E2EResult<()> { // given @@ -86,15 +49,17 @@ async fn instantiate_v2_with_sufficient_limits( .await .expect("other_contract upload failed"); - const REF_TIME_LIMIT: u64 = 500_000_000; - const PROOF_SIZE_LIMIT: u64 = 100_000; - const STORAGE_DEPOSIT_LIMIT: u128 = 500_000_000_000; + const REF_TIME_LIMIT: u64 = 500_000_000_000_000; + const PROOF_SIZE_LIMIT: u64 = 100_000_000_000; + // todo remove the last group of `000` to get an `OutOfGas` error in + // `pallet-revive`. but they should throw an error about `StorageLimitExhausted`. + let storage_deposit_limit = ink::U256::from(100_000_000_000_000u64); - let mut constructor = CrossContractCallsRef::new_v2_with_limits( + let mut constructor = CrossContractCallsRef::new_with_limits( other_contract_code.code_hash, REF_TIME_LIMIT, PROOF_SIZE_LIMIT, - STORAGE_DEPOSIT_LIMIT, + storage_deposit_limit, ); let contract = client .instantiate("cross-contract-calls", &ink_e2e::alice(), &mut constructor) @@ -107,9 +72,7 @@ async fn instantiate_v2_with_sufficient_limits( } #[ink_e2e::test] -async fn instantiate_v2_no_limits( - mut client: Client, -) -> E2EResult<()> { +async fn instantiate_no_limits(mut client: Client) -> E2EResult<()> { // given let other_contract_code = client .upload("other-contract", &ink_e2e::alice()) @@ -118,7 +81,7 @@ async fn instantiate_v2_no_limits( .expect("other_contract upload failed"); let mut constructor = - CrossContractCallsRef::new_v2_no_limits(other_contract_code.code_hash); + CrossContractCallsRef::new_no_limits(other_contract_code.code_hash); let contract = client .instantiate("cross-contract-calls", &ink_e2e::alice(), &mut constructor) .submit() @@ -130,7 +93,7 @@ async fn instantiate_v2_no_limits( } #[ink_e2e::test] -async fn flip_and_get_v2(mut client: Client) -> E2EResult<()> { +async fn flip_and_get(mut client: Client) -> E2EResult<()> { // given let other_contract_code = client .upload("other-contract", &ink_e2e::alice()) @@ -138,7 +101,8 @@ async fn flip_and_get_v2(mut client: Client) -> E2EResult<() .await .expect("other_contract upload failed"); - let mut constructor = CrossContractCallsRef::new_v1(other_contract_code.code_hash); + let mut constructor = + CrossContractCallsRef::new_no_limits(other_contract_code.code_hash); let contract = client .instantiate("cross-contract-calls", &ink_e2e::alice(), &mut constructor) .submit() @@ -148,29 +112,29 @@ async fn flip_and_get_v2(mut client: Client) -> E2EResult<() const REF_TIME_LIMIT: u64 = 500_000_000; const PROOF_SIZE_LIMIT: u64 = 100_000; - const STORAGE_DEPOSIT_LIMIT: u128 = 1_000_000_000; + let storage_deposit_limit = ink::U256::from(1_000_000_000); // when - let call = call_builder.flip_and_get_invoke_v2_with_limits( + let call = call_builder.flip_and_get_invoke_with_limits( REF_TIME_LIMIT, PROOF_SIZE_LIMIT, - STORAGE_DEPOSIT_LIMIT, + storage_deposit_limit, ); let result = client .call(&ink_e2e::alice(), &call) .submit() .await - .expect("Calling `flip_and_get` failed") + .expect("Calling `flip_and_get_invoke_with_limits` failed") .return_value(); assert!(!result); - let call = call_builder.flip_and_get_invoke_v2_no_weight_limit(); + let call = call_builder.flip_and_get_invoke_no_weight_limit(); let result = client .call(&ink_e2e::alice(), &call) .submit() .await - .expect("Calling `flip_and_get` failed") + .expect("Calling `flip_and_get_invoke_no_weight_limit` failed") .return_value(); assert!(result); diff --git a/cross-contract-calls/lib.rs b/cross-contract-calls/lib.rs index 297c544d..2106df75 100755 --- a/cross-contract-calls/lib.rs +++ b/cross-contract-calls/lib.rs @@ -12,19 +12,19 @@ mod cross_contract_calls { impl CrossContractCalls { /// Initializes the contract by instantiating the code at the given code hash via - /// `instantiate_v2` host function with the supplied weight and storage + /// `instantiate` host function with the supplied weight and storage /// limits. #[ink(constructor)] - pub fn new_v2_with_limits( - other_contract_code_hash: Hash, + pub fn new_with_limits( + other_contract_code_hash: ink::H256, ref_time_limit: u64, proof_size_limit: u64, - storage_deposit_limit: Balance, + storage_deposit_limit: ink::U256, ) -> Self { let other_contract = OtherContractRef::new(true) .code_hash(other_contract_code_hash) - .endowment(0) - .salt_bytes([0xDE, 0xAD, 0xBE, 0xEF]) + .endowment(0.into()) + .salt_bytes(Some([1u8; 32])) .ref_time_limit(ref_time_limit) .proof_size_limit(proof_size_limit) .storage_deposit_limit(storage_deposit_limit) @@ -34,56 +34,30 @@ mod cross_contract_calls { } /// Initializes the contract by instantiating the code at the given code hash via - /// the `instantiate_v2` host function with no weight or storage limits. + /// the `instantiate` host function with no weight or storage limits. #[ink(constructor)] - pub fn new_v2_no_limits(other_contract_code_hash: Hash) -> Self { + pub fn new_no_limits(other_contract_code_hash: ink::H256) -> Self { let other_contract = OtherContractRef::new(true) .code_hash(other_contract_code_hash) - .endowment(0) - .salt_bytes([0xDE, 0xAD, 0xBE, 0xEF]) + .endowment(0.into()) + .salt_bytes(Some([1u8; 32])) .instantiate(); Self { other_contract } } - /// Initializes the contract by instantiating the code at the given code hash via - /// the original `instantiate` host function. - #[ink(constructor)] - pub fn new_v1(other_contract_code_hash: Hash) -> Self { - let other_contract = OtherContractRef::new(true) - .instantiate_v1() - .code_hash(other_contract_code_hash) - .endowment(0) - .salt_bytes([0xDE, 0xAD, 0xBE, 0xEF]) - .instantiate(); - - Self { other_contract } - } - - /// Basic invocation of the other contract via the contract reference. - /// - /// *Note* this will invoke the original `call` (V1) host function, which will be - /// deprecated in the future. - #[ink(message)] - pub fn flip_and_get_v1(&mut self) -> bool { - let call_builder = self.other_contract.call_mut(); - - call_builder.flip().call_v1().invoke(); - call_builder.get().call_v1().invoke() - } - - /// Use the new `call_v2` host function via the call builder to forward calls to + /// Use the `call` host function via the call builder to forward calls to /// the other contract, initially calling `flip` and then `get` to return the /// result. /// /// This demonstrates how to set the new weight and storage limit parameters via /// the call builder API. #[ink(message)] - pub fn flip_and_get_invoke_v2_with_limits( + pub fn flip_and_get_invoke_with_limits( &mut self, ref_time_limit: u64, proof_size_limit: u64, - storage_deposit_limit: Balance, + storage_deposit_limit: ink::U256, ) -> bool { let call_builder = self.other_contract.call_mut(); @@ -102,10 +76,10 @@ mod cross_contract_calls { .invoke() } - /// Demonstrate that the `call_v2` succeeds without having specified the weight + /// Demonstrate that the `call` succeeds without having specified the weight /// and storage limit parameters #[ink(message)] - pub fn flip_and_get_invoke_v2_no_weight_limit(&mut self) -> bool { + pub fn flip_and_get_invoke_no_weight_limit(&mut self) -> bool { self.other_contract.flip(); self.other_contract.get() } diff --git a/cross-contract-calls/other-contract/Cargo.toml b/cross-contract-calls/other-contract/Cargo.toml index 6eb419bd..bde6cd88 100755 --- a/cross-contract-calls/other-contract/Cargo.toml +++ b/cross-contract-calls/other-contract/Cargo.toml @@ -1,15 +1,16 @@ [package] name = "other-contract" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } +pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/custom-allocator/Cargo.toml b/custom-allocator/Cargo.toml index a962be71..beb15271 100755 --- a/custom-allocator/Cargo.toml +++ b/custom-allocator/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "custom-allocator" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false @@ -8,13 +8,16 @@ publish = false [dependencies] # We're going to use a different allocator than the one provided by ink!. To do that we # first need to disable the included memory allocator. -ink = { version = "5.1.0", default-features = false, features = ["no-allocator"] } +ink = { path = "../../../crates/ink", default-features = false, features = ["no-allocator"] } -# This is going to be our new global memory allocator. -dlmalloc = {version = "0.2", default-features = false, features = ["global"] } +# todo +#foo = { path = "../../../foo", default-features = false } +#This is going to be our new global memory allocator. +#dlmalloc = {version = "0.2", default-features = false, features = ["global"] } +#bumpalo = "3.16.0" [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/custom-allocator/lib.rs b/custom-allocator/lib.rs index cc99a259..128d5762 100755 --- a/custom-allocator/lib.rs +++ b/custom-allocator/lib.rs @@ -27,14 +27,67 @@ //! Providing your own allocator lets you choose the right tradeoffs for your use case. #![cfg_attr(not(feature = "std"), no_std, no_main)] +#![feature(sync_unsafe_cell)] +#![feature(allocator_api)] +// todo // Here we set `dlmalloc` to be the global memory allocator. // // The [`GlobalAlloc`](https://doc.rust-lang.org/std/alloc/trait.GlobalAlloc.html) trait is // important to understand if you're swapping our your allocator. +//#[cfg(not(feature = "std"))] +//#[global_allocator] +//static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc; + +use core::{ + alloc::{ + GlobalAlloc, + Layout, + }, + cell::SyncUnsafeCell, +}; + #[cfg(not(feature = "std"))] #[global_allocator] -static ALLOC: dlmalloc::GlobalDlmalloc = dlmalloc::GlobalDlmalloc; +static ALLOC: BumpAllocator = BumpAllocator {}; + +pub struct BumpAllocator {} + +struct BumpMemory { + buffer: [u8; 1024 * 1024], // Pre-allocated memory buffer + offset: usize, // Current allocation offset +} + +static mut MEMORY: Option> = None; + +#[allow(clippy::arithmetic_side_effects)] +unsafe impl GlobalAlloc for BumpAllocator { + #[allow(static_mut_refs)] + unsafe fn alloc(&self, layout: Layout) -> *mut u8 { + if MEMORY.is_none() { + MEMORY = Some(SyncUnsafeCell::new(BumpMemory { + buffer: [0; 1024 * 1024], + offset: 0, + })); + } + let memory = unsafe { &mut *MEMORY.as_ref().unwrap().get() }; + let start = memory.offset; + let end = start + layout.size(); + + if end > memory.buffer.len() { + panic!("too large"); + } else { + memory.offset = end; + //ink::env::debug_println!("Allocated {} from {start} to {}", end-start, + // end-1); + &mut memory.buffer[start] + } + } + + unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) { + // No-op: deallocation is unsupported in a bump allocator. + } +} #[ink::contract] mod custom_allocator { @@ -129,13 +182,12 @@ mod custom_allocator { // Then let get = call_builder.get(); let get_result = client.call(&ink_e2e::alice(), &get).dry_run().await?; - assert!(matches!(get_result.return_value(), false)); + assert!(!get_result.return_value()); Ok(()) } - /// We test that we can read and write a value from the on-chain contract - /// contract. + /// We test that we can read and write a value from the on-chain contract. #[ink_e2e::test] async fn it_works(mut client: Client) -> E2EResult<()> { // Given @@ -149,7 +201,7 @@ mod custom_allocator { let get = call_builder.get(); let get_result = client.call(&ink_e2e::bob(), &get).dry_run().await?; - assert!(matches!(get_result.return_value(), false)); + assert!(!get_result.return_value()); // When let flip = call_builder.flip(); @@ -162,7 +214,7 @@ mod custom_allocator { // Then let get = call_builder.get(); let get_result = client.call(&ink_e2e::bob(), &get).dry_run().await?; - assert!(matches!(get_result.return_value(), true)); + assert!(get_result.return_value()); Ok(()) } diff --git a/custom-environment/Cargo.toml b/custom-environment/Cargo.toml index e79f8a90..3853d653 100644 --- a/custom-environment/Cargo.toml +++ b/custom-environment/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "custom-environment" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/custom-environment/README.md b/custom-environment/README.md index 8bd35b46..237980c7 100644 --- a/custom-environment/README.md +++ b/custom-environment/README.md @@ -11,8 +11,8 @@ To integrate this example into Substrate you need to adjust pallet contracts con ```rust // In your node's runtime configuration file (runtime.rs) parameter_types! { - pub Schedule: pallet_contracts::Schedule = pallet_contracts::Schedule:: { - limits: pallet_contracts::Limits { + pub Schedule: pallet_revive::Schedule = pallet_revive::Schedule:: { + limits: pallet_revive::Limits { event_topics: 6, ..Default::default() }, @@ -20,7 +20,7 @@ parameter_types! { }; } -impl pallet_contracts::Config for Runtime { +impl pallet_revive::Config for Runtime { … type Schedule = Schedule; … diff --git a/custom-environment/lib.rs b/custom-environment/lib.rs index f78f2c23..441b6b11 100644 --- a/custom-environment/lib.rs +++ b/custom-environment/lib.rs @@ -23,6 +23,7 @@ impl Environment for EnvironmentWithManyTopics { type Hash = ::Hash; type BlockNumber = ::BlockNumber; type Timestamp = ::Timestamp; + type EventRecord = ::EventRecord; type ChainExtension = ::ChainExtension; } @@ -109,7 +110,7 @@ mod runtime_call { .expect("call failed"); // then - call_res.contains_event("Contracts", "ContractEmitted"); + assert!(call_res.contains_event("Revive", "ContractEmitted")); Ok(()) } diff --git a/dns/Cargo.toml b/dns/Cargo.toml index c7eef8f6..6779f4ff 100644 --- a/dns/Cargo.toml +++ b/dns/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "dns" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/dns/lib.rs b/dns/lib.rs index a46cdb6e..24239dad 100644 --- a/dns/lib.rs +++ b/dns/lib.rs @@ -2,39 +2,43 @@ #[ink::contract] mod dns { - use ink::storage::Mapping; + use ink::{ + storage::Mapping, + H160, + H256, + }; /// Emitted whenever a new name is being registered. #[ink(event)] pub struct Register { #[ink(topic)] - name: Hash, + name: H256, #[ink(topic)] - from: AccountId, + from: H160, } /// Emitted whenever an address changes. #[ink(event)] pub struct SetAddress { #[ink(topic)] - name: Hash, - from: AccountId, + name: H256, + from: H160, #[ink(topic)] - old_address: Option, + old_address: Option, #[ink(topic)] - new_address: AccountId, + new_address: H160, } /// Emitted whenever a name is being transferred. #[ink(event)] pub struct Transfer { #[ink(topic)] - name: Hash, - from: AccountId, + name: H256, + from: H160, #[ink(topic)] - old_owner: Option, + old_owner: Option, #[ink(topic)] - new_owner: AccountId, + new_owner: H160, } /// Domain name service contract inspired by @@ -55,19 +59,19 @@ mod dns { #[ink(storage)] pub struct DomainNameService { /// A hashmap to store all name to addresses mapping. - name_to_address: Mapping, + name_to_address: Mapping, /// A hashmap to store all name to owners mapping. - name_to_owner: Mapping, + name_to_owner: Mapping, /// The default address. - default_address: AccountId, + default_address: H160, } impl Default for DomainNameService { fn default() -> Self { let mut name_to_address = Mapping::new(); - name_to_address.insert(Hash::default(), &zero_address()); + name_to_address.insert(H256::default(), &zero_address()); let mut name_to_owner = Mapping::new(); - name_to_owner.insert(Hash::default(), &zero_address()); + name_to_owner.insert(H256::default(), &zero_address()); Self { name_to_address, @@ -99,7 +103,7 @@ mod dns { /// Register specific name with caller as owner. #[ink(message)] - pub fn register(&mut self, name: Hash) -> Result<()> { + pub fn register(&mut self, name: H256) -> Result<()> { let caller = self.env().caller(); if self.name_to_owner.contains(name) { return Err(Error::NameAlreadyExists) @@ -113,7 +117,7 @@ mod dns { /// Set address for specific name. #[ink(message)] - pub fn set_address(&mut self, name: Hash, new_address: AccountId) -> Result<()> { + pub fn set_address(&mut self, name: H256, new_address: H160) -> Result<()> { let caller = self.env().caller(); let owner = self.get_owner_or_default(name); if caller != owner { @@ -134,7 +138,7 @@ mod dns { /// Transfer owner to another address. #[ink(message)] - pub fn transfer(&mut self, name: Hash, to: AccountId) -> Result<()> { + pub fn transfer(&mut self, name: H256, to: H160) -> Result<()> { let caller = self.env().caller(); let owner = self.get_owner_or_default(name); if caller != owner { @@ -156,23 +160,23 @@ mod dns { /// Get address for specific name. #[ink(message)] - pub fn get_address(&self, name: Hash) -> AccountId { + pub fn get_address(&self, name: H256) -> H160 { self.get_address_or_default(name) } /// Get owner of specific name. #[ink(message)] - pub fn get_owner(&self, name: Hash) -> AccountId { + pub fn get_owner(&self, name: H256) -> H160 { self.get_owner_or_default(name) } /// Returns the owner given the hash or the default address. - fn get_owner_or_default(&self, name: Hash) -> AccountId { + fn get_owner_or_default(&self, name: H256) -> H160 { self.name_to_owner.get(name).unwrap_or(self.default_address) } /// Returns the address given the hash or the default address. - fn get_address_or_default(&self, name: Hash) -> AccountId { + fn get_address_or_default(&self, name: H256) -> H160 { self.name_to_address .get(name) .unwrap_or(self.default_address) @@ -182,27 +186,26 @@ mod dns { /// Helper for referencing the zero address (`0x00`). Note that in practice this /// address should not be treated in any special way (such as a default /// placeholder) since it has a known private key. - fn zero_address() -> AccountId { - [0u8; 32].into() + fn zero_address() -> H160 { + [0u8; 20].into() } #[cfg(test)] mod tests { use super::*; - fn default_accounts( - ) -> ink::env::test::DefaultAccounts { - ink::env::test::default_accounts::() + fn default_accounts() -> ink::env::test::DefaultAccounts { + ink::env::test::default_accounts() } - fn set_next_caller(caller: AccountId) { - ink::env::test::set_caller::(caller); + fn set_next_caller(caller: H160) { + ink::env::test::set_caller(caller); } #[ink::test] fn register_works() { let default_accounts = default_accounts(); - let name = Hash::from([0x99; 32]); + let name = H256::from([0x99; 32]); set_next_caller(default_accounts.alice); let mut contract = DomainNameService::new(); @@ -214,7 +217,7 @@ mod dns { #[ink::test] fn set_address_works() { let accounts = default_accounts(); - let name = Hash::from([0x99; 32]); + let name = H256::from([0x99; 32]); set_next_caller(accounts.alice); @@ -237,7 +240,7 @@ mod dns { #[ink::test] fn transfer_works() { let accounts = default_accounts(); - let name = Hash::from([0x99; 32]); + let name = H256::from([0x99; 32]); set_next_caller(accounts.alice); diff --git a/e2e-call-runtime/Cargo.toml b/e2e-call-runtime/Cargo.toml index c3dc54f8..578ec918 100644 --- a/e2e-call-runtime/Cargo.toml +++ b/e2e-call-runtime/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "e2e_call_runtime" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/e2e-call-runtime/lib.rs b/e2e-call-runtime/lib.rs index aa8941f5..ec3eb92c 100644 --- a/e2e-call-runtime/lib.rs +++ b/e2e-call-runtime/lib.rs @@ -13,9 +13,16 @@ pub mod e2e_call_runtime { } #[ink(message)] - pub fn get_contract_balance(&self) -> Balance { + pub fn get_contract_balance(&self) -> ink::U256 { self.env().balance() } + + /// todo + /// Returns the `AccountId` of this contract. + #[ink(message)] + pub fn account_id(&mut self) -> AccountId { + self.env().account_id() + } } #[cfg(all(test, feature = "e2e-tests"))] @@ -40,8 +47,18 @@ pub mod e2e_call_runtime { .submit() .await .expect("instantiate failed"); - let call_builder = contract.call_builder::(); + let mut call_builder = contract.call_builder::(); + + // todo + let acc = call_builder.account_id(); + let call_res = client + .call(&ink_e2e::alice(), &acc) + .submit() + .await + .expect("call failed"); + let account_id: AccountId = call_res.return_value(); + // todo let transfer_amount = 100_000_000_000u128; // when @@ -49,7 +66,7 @@ pub mod e2e_call_runtime { // A value representing a `MultiAddress`. We want the // "Id" variant, and that will ultimately contain the // bytes for our destination address - Value::unnamed_variant("Id", [Value::from_bytes(&contract.account_id)]), + Value::unnamed_variant("Id", [Value::from_bytes(account_id)]), // A value representing the amount we'd like to transfer. Value::u128(transfer_amount), ]; @@ -79,8 +96,10 @@ pub mod e2e_call_runtime { .dry_run() .await?; + // todo NativeToEthRatio should be part of `Environment` + let native_to_eth_ratio = ink::U256::from(1_000_000); assert_eq!( - get_balance_res.return_value(), + get_balance_res.return_value() / native_to_eth_ratio, pre_balance + transfer_amount ); diff --git a/erc1155/Cargo.toml b/erc1155/Cargo.toml index 73fb8df9..e5f495e9 100644 --- a/erc1155/Cargo.toml +++ b/erc1155/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "erc1155" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/erc1155/lib.rs b/erc1155/lib.rs index f6cbf569..fad1060f 100644 --- a/erc1155/lib.rs +++ b/erc1155/lib.rs @@ -2,7 +2,8 @@ use ink::{ prelude::vec::Vec, - primitives::AccountId, + H160, + U256, }; // This is the return value that we expect if a smart contract supports receiving ERC-1155 @@ -25,8 +26,6 @@ const _ON_ERC_1155_BATCH_RECEIVED_SELECTOR: [u8; 4] = [0xBC, 0x19, 0x7C, 0x81]; /// A type representing the unique IDs of tokens managed by this contract. pub type TokenId = u128; -type Balance = ::Balance; - // The ERC-1155 error types. #[derive(Debug, PartialEq, Eq)] #[ink::scale_derive(Encode, Decode, TypeInfo)] @@ -38,7 +37,7 @@ pub enum Error { /// The caller is not approved to transfer tokens on behalf of the account. NotApproved, /// The account does not have enough funds to complete the transfer. - InsufficientBalance, + InsufficientU256, /// An account does not need to approve themselves to transfer tokens. SelfApproval, /// The number of tokens being transferred does not match the specified number of @@ -79,10 +78,10 @@ pub trait Erc1155 { #[ink(message)] fn safe_transfer_from( &mut self, - from: AccountId, - to: AccountId, + from: H160, + to: H160, token_id: TokenId, - value: Balance, + value: U256, data: Vec, ) -> Result<()>; @@ -97,16 +96,16 @@ pub trait Erc1155 { #[ink(message)] fn safe_batch_transfer_from( &mut self, - from: AccountId, - to: AccountId, + from: H160, + to: H160, token_ids: Vec, - values: Vec, + values: Vec, data: Vec, ) -> Result<()>; /// Query the balance of a specific token for the provided account. #[ink(message)] - fn balance_of(&self, owner: AccountId, token_id: TokenId) -> Balance; + fn balance_of(&self, owner: H160, token_id: TokenId) -> U256; /// Query the balances for a set of tokens for a set of accounts. /// @@ -116,24 +115,19 @@ pub trait Erc1155 { /// This will return all the balances for a given owner before moving on to the next /// owner. In the example above this means that the return value should look like: /// - /// [Alice Balance of Token ID 1, Alice Balance of Token ID 2, Bob Balance of Token ID - /// 1, Bob Balance of Token ID 2] + /// [Alice U256 of Token ID 1, Alice U256 of Token ID 2, Bob U256 of Token ID + /// 1, Bob U256 of Token ID 2] #[ink(message)] - fn balance_of_batch( - &self, - owners: Vec, - token_ids: Vec, - ) -> Vec; + fn balance_of_batch(&self, owners: Vec, token_ids: Vec) -> Vec; /// Enable or disable a third party, known as an `operator`, to control all tokens on /// behalf of the caller. #[ink(message)] - fn set_approval_for_all(&mut self, operator: AccountId, approved: bool) - -> Result<()>; + fn set_approval_for_all(&mut self, operator: H160, approved: bool) -> Result<()>; /// Query if the given `operator` is allowed to control all of `owner`'s tokens. #[ink(message)] - fn is_approved_for_all(&self, owner: AccountId, operator: AccountId) -> bool; + fn is_approved_for_all(&self, owner: H160, operator: H160) -> bool; } /// The interface for an ERC-1155 Token Receiver contract. @@ -160,10 +154,10 @@ pub trait Erc1155TokenReceiver { #[ink(message, selector = 0xF23A6E61)] fn on_received( &mut self, - operator: AccountId, - from: AccountId, + operator: H160, + from: H160, token_id: TokenId, - value: Balance, + value: U256, data: Vec, ) -> Vec; @@ -181,10 +175,10 @@ pub trait Erc1155TokenReceiver { #[ink(message, selector = 0xBC197C81)] fn on_batch_received( &mut self, - operator: AccountId, - from: AccountId, + operator: H160, + from: H160, token_ids: Vec, - values: Vec, + values: Vec, data: Vec, ) -> Vec; } @@ -193,10 +187,14 @@ pub trait Erc1155TokenReceiver { mod erc1155 { use super::*; - use ink::storage::Mapping; + use ink::{ + storage::Mapping, + H160, + U256, + }; - type Owner = AccountId; - type Operator = AccountId; + type Owner = H160; + type Operator = H160; /// Indicate that a token transfer has occured. /// @@ -204,22 +202,22 @@ mod erc1155 { #[ink(event)] pub struct TransferSingle { #[ink(topic)] - operator: Option, + operator: Option, #[ink(topic)] - from: Option, + from: Option, #[ink(topic)] - to: Option, + to: Option, token_id: TokenId, - value: Balance, + value: U256, } /// Indicate that an approval event has happened. #[ink(event)] pub struct ApprovalForAll { #[ink(topic)] - owner: AccountId, + owner: H160, #[ink(topic)] - operator: AccountId, + operator: H160, approved: bool, } @@ -237,7 +235,7 @@ mod erc1155 { pub struct Contract { /// Tracks the balances of accounts across the different tokens that they might /// be holding. - balances: Mapping<(AccountId, TokenId), Balance>, + balances: Mapping<(H160, TokenId), U256>, /// Which accounts (called operators) have been approved to spend funds on behalf /// of an owner. approvals: Mapping<(Owner, Operator), ()>, @@ -262,7 +260,7 @@ mod erc1155 { /// this contract in a production environment you'd probably want to lock down /// the addresses that are allowed to create tokens. #[ink(message)] - pub fn create(&mut self, value: Balance) -> TokenId { + pub fn create(&mut self, value: U256) -> TokenId { let caller = self.env().caller(); // Given that TokenId is a `u128` the likelihood of this overflowing is pretty @@ -277,7 +275,11 @@ mod erc1155 { self.env().emit_event(TransferSingle { operator: Some(caller), from: None, - to: if value == 0 { None } else { Some(caller) }, + to: if value == U256::zero() { + None + } else { + Some(caller) + }, token_id: self.token_id_nonce, value, }); @@ -294,7 +296,7 @@ mod erc1155 { /// this contract in a production environment you'd probably want to lock down /// the addresses that are allowed to mint tokens. #[ink(message)] - pub fn mint(&mut self, token_id: TokenId, value: Balance) -> Result<()> { + pub fn mint(&mut self, token_id: TokenId, value: U256) -> Result<()> { ensure!(token_id <= self.token_id_nonce, Error::UnexistentToken); let caller = self.env().caller(); @@ -323,10 +325,10 @@ mod erc1155 { // If `from` does not hold any `token_id` tokens. fn perform_transfer( &mut self, - from: AccountId, - to: AccountId, + from: H160, + to: H160, token_id: TokenId, - value: Balance, + value: U256, ) { let mut sender_balance = self .balances @@ -339,7 +341,8 @@ mod erc1155 { } self.balances.insert((from, token_id), &sender_balance); - let mut recipient_balance = self.balances.get((to, token_id)).unwrap_or(0); + let mut recipient_balance = + self.balances.get((to, token_id)).unwrap_or(U256::zero()); recipient_balance = recipient_balance.checked_add(value).unwrap(); self.balances.insert((to, token_id), &recipient_balance); @@ -362,11 +365,11 @@ mod erc1155 { #[cfg_attr(test, allow(unused_variables))] fn transfer_acceptance_check( &mut self, - caller: AccountId, - from: AccountId, - to: AccountId, + caller: H160, + from: H160, + to: H160, token_id: TokenId, - value: Balance, + value: U256, data: Vec, ) { // This is disabled during tests due to the use of `invoke_contract()` not @@ -398,6 +401,8 @@ mod erc1155 { match result { Ok(v) => { + /* + // todo ink::env::debug_println!( "Received return value \"{:?}\" from contract {:?}", v.clone().expect( @@ -405,6 +410,7 @@ mod erc1155 { ), from ); + */ assert_eq!( v.clone().expect("Call should be valid, don't expect a `LangError`."), &ON_ERC_1155_RECEIVED_SELECTOR[..], @@ -417,13 +423,18 @@ mod erc1155 { match e { ink::env::Error::ReturnError( - ReturnErrorCode::CodeNotFound - | ReturnErrorCode::NotCallable, + ReturnErrorCode::Unknown, /* todo: these error codes + * don't exist in uapi yet, + * fallback + * is `Unknown` + * ReturnErrorCode::CodeNotFound | ReturnErrorCode::NotCallable, */ ) => { // Our recipient wasn't a smart contract, so there's // nothing more for // us to do - ink::env::debug_println!("Recipient at {:?} from is not a smart contract ({:?})", from, e); + // todo + // ink::env::debug_println!("Recipient at {:?} from is not + // a smart contract ({:?})", from, e); } _ => { // We got some sort of error from the call to our @@ -444,10 +455,10 @@ mod erc1155 { #[ink(message)] fn safe_transfer_from( &mut self, - from: AccountId, - to: AccountId, + from: H160, + to: H160, token_id: TokenId, - value: Balance, + value: U256, data: Vec, ) -> Result<()> { let caller = self.env().caller(); @@ -458,7 +469,7 @@ mod erc1155 { ensure!(to != zero_address(), Error::ZeroAddressTransfer); let balance = self.balance_of(from, token_id); - ensure!(balance >= value, Error::InsufficientBalance); + ensure!(balance >= value, Error::InsufficientU256); self.perform_transfer(from, to, token_id, value); self.transfer_acceptance_check(caller, from, to, token_id, value, data); @@ -469,10 +480,10 @@ mod erc1155 { #[ink(message)] fn safe_batch_transfer_from( &mut self, - from: AccountId, - to: AccountId, + from: H160, + to: H160, token_ids: Vec, - values: Vec, + values: Vec, data: Vec, ) -> Result<()> { let caller = self.env().caller(); @@ -490,14 +501,14 @@ mod erc1155 { let transfers = token_ids.iter().zip(values.iter()); for (&id, &v) in transfers.clone() { let balance = self.balance_of(from, id); - ensure!(balance >= v, Error::InsufficientBalance); + ensure!(balance >= v, Error::InsufficientU256); } for (&id, &v) in transfers { self.perform_transfer(from, to, id, v); } - // Can use the any token ID/value here, we really just care about knowing if + // Can use any token ID/value here, we really just care about knowing if // `to` is a smart contract which accepts transfers self.transfer_acceptance_check( caller, @@ -512,16 +523,16 @@ mod erc1155 { } #[ink(message)] - fn balance_of(&self, owner: AccountId, token_id: TokenId) -> Balance { - self.balances.get((owner, token_id)).unwrap_or(0) + fn balance_of(&self, owner: H160, token_id: TokenId) -> U256 { + self.balances.get((owner, token_id)).unwrap_or(0.into()) } #[ink(message)] fn balance_of_batch( &self, - owners: Vec, + owners: Vec, token_ids: Vec, - ) -> Vec { + ) -> Vec { let mut output = Vec::new(); for o in &owners { for t in &token_ids { @@ -533,11 +544,7 @@ mod erc1155 { } #[ink(message)] - fn set_approval_for_all( - &mut self, - operator: AccountId, - approved: bool, - ) -> Result<()> { + fn set_approval_for_all(&mut self, operator: H160, approved: bool) -> Result<()> { let caller = self.env().caller(); ensure!(operator != caller, Error::SelfApproval); @@ -557,7 +564,7 @@ mod erc1155 { } #[ink(message)] - fn is_approved_for_all(&self, owner: AccountId, operator: AccountId) -> bool { + fn is_approved_for_all(&self, owner: H160, operator: H160) -> bool { self.approvals.contains((&owner, &operator)) } } @@ -566,10 +573,10 @@ mod erc1155 { #[ink(message, selector = 0xF23A6E61)] fn on_received( &mut self, - _operator: AccountId, - _from: AccountId, + _operator: H160, + _from: H160, _token_id: TokenId, - _value: Balance, + _value: U256, _data: Vec, ) -> Vec { // The ERC-1155 standard dictates that if a contract does not accept token @@ -589,10 +596,10 @@ mod erc1155 { #[ink(message, selector = 0xBC197C81)] fn on_batch_received( &mut self, - _operator: AccountId, - _from: AccountId, + _operator: H160, + _from: H160, _token_ids: Vec, - _values: Vec, + _values: Vec, _data: Vec, ) -> Vec { // The ERC-1155 standard dictates that if a contract does not accept token @@ -613,8 +620,8 @@ mod erc1155 { /// Helper for referencing the zero address (`0x00`). Note that in practice this /// address should not be treated in any special way (such as a default /// placeholder) since it has a known private key. - fn zero_address() -> AccountId { - [0u8; 32].into() + fn zero_address() -> H160 { + [0u8; 20].into() } #[cfg(test)] @@ -623,31 +630,32 @@ mod erc1155 { use super::*; use crate::Erc1155; - fn set_sender(sender: AccountId) { - ink::env::test::set_caller::(sender); + fn set_sender(sender: H160) { + ink::env::test::set_caller(sender); } - fn default_accounts() -> ink::env::test::DefaultAccounts { - ink::env::test::default_accounts::() + fn default_accounts() -> ink::env::test::DefaultAccounts { + ink::env::test::default_accounts() } - fn alice() -> AccountId { + fn alice() -> H160 { default_accounts().alice } - fn bob() -> AccountId { + fn bob() -> H160 { default_accounts().bob } - fn charlie() -> AccountId { + fn charlie() -> H160 { default_accounts().charlie } fn init_contract() -> Contract { + set_sender(alice()); let mut erc = Contract::new(); - erc.balances.insert((alice(), 1), &10); - erc.balances.insert((alice(), 2), &20); - erc.balances.insert((bob(), 1), &10); + erc.balances.insert((alice(), 1), &U256::from(10)); + erc.balances.insert((alice(), 2), &U256::from(20)); + erc.balances.insert((bob(), 1), &U256::from(10)); erc } @@ -656,10 +664,10 @@ mod erc1155 { fn can_get_correct_balance_of() { let erc = init_contract(); - assert_eq!(erc.balance_of(alice(), 1), 10); - assert_eq!(erc.balance_of(alice(), 2), 20); - assert_eq!(erc.balance_of(alice(), 3), 0); - assert_eq!(erc.balance_of(bob(), 2), 0); + assert_eq!(erc.balance_of(alice(), 1), U256::from(10)); + assert_eq!(erc.balance_of(alice(), 2), U256::from(20)); + assert_eq!(erc.balance_of(alice(), 3), U256::zero()); + assert_eq!(erc.balance_of(bob(), 2), U256::zero()); } #[ink::test] @@ -668,16 +676,23 @@ mod erc1155 { assert_eq!( erc.balance_of_batch(vec![alice()], vec![1, 2, 3]), - vec![10, 20, 0] + vec![U256::from(10), 20.into(), 0.into()] ); assert_eq!( erc.balance_of_batch(vec![alice(), bob()], vec![1]), - vec![10, 10] + vec![U256::from(10), 10.into()] ); assert_eq!( erc.balance_of_batch(vec![alice(), bob(), charlie()], vec![1, 2]), - vec![10, 20, 10, 0, 0, 0] + vec![ + U256::from(10), + 20.into(), + 10.into(), + 0.into(), + 0.into(), + 0.into() + ] ); } @@ -685,28 +700,32 @@ mod erc1155 { fn can_send_tokens_between_accounts() { let mut erc = init_contract(); - assert!(erc.safe_transfer_from(alice(), bob(), 1, 5, vec![]).is_ok()); - assert_eq!(erc.balance_of(alice(), 1), 5); - assert_eq!(erc.balance_of(bob(), 1), 15); + assert!(erc + .safe_transfer_from(alice(), bob(), 1, 5.into(), vec![]) + .is_ok()); + assert_eq!(erc.balance_of(alice(), 1), U256::from(5)); + assert_eq!(erc.balance_of(bob(), 1), U256::from(15)); - assert!(erc.safe_transfer_from(alice(), bob(), 2, 5, vec![]).is_ok()); - assert_eq!(erc.balance_of(alice(), 2), 15); - assert_eq!(erc.balance_of(bob(), 2), 5); + assert!(erc + .safe_transfer_from(alice(), bob(), 2, 5.into(), vec![]) + .is_ok()); + assert_eq!(erc.balance_of(alice(), 2), U256::from(15)); + assert_eq!(erc.balance_of(bob(), 2), U256::from(5)); } #[ink::test] fn sending_too_many_tokens_fails() { let mut erc = init_contract(); - let res = erc.safe_transfer_from(alice(), bob(), 1, 99, vec![]); - assert_eq!(res.unwrap_err(), Error::InsufficientBalance); + let res = erc.safe_transfer_from(alice(), bob(), 1, 99.into(), vec![]); + assert_eq!(res.unwrap_err(), Error::InsufficientU256); } #[ink::test] fn sending_tokens_to_zero_address_fails() { - let burn: AccountId = [0; 32].into(); + let burn: H160 = [0; 20].into(); let mut erc = init_contract(); - let res = erc.safe_transfer_from(alice(), burn, 1, 10, vec![]); + let res = erc.safe_transfer_from(alice(), burn, 1, 10.into(), vec![]); assert_eq!(res.unwrap_err(), Error::ZeroAddressTransfer); } @@ -714,11 +733,20 @@ mod erc1155 { fn can_send_batch_tokens() { let mut erc = init_contract(); assert!(erc - .safe_batch_transfer_from(alice(), bob(), vec![1, 2], vec![5, 10], vec![]) + .safe_batch_transfer_from( + alice(), + bob(), + vec![1, 2], + vec![U256::from(5), U256::from(10)], + vec![] + ) .is_ok()); let balances = erc.balance_of_batch(vec![alice(), bob()], vec![1, 2]); - assert_eq!(balances, vec![5, 10, 15, 10]) + assert_eq!( + balances, + vec![U256::from(5), 10.into(), 15.into(), 10.into()] + ); } #[ink::test] @@ -728,7 +756,7 @@ mod erc1155 { alice(), bob(), vec![1, 2, 3], - vec![5], + vec![U256::from(5)], vec![], ); assert_eq!(res.unwrap_err(), Error::BatchTransferMismatch); @@ -754,10 +782,10 @@ mod erc1155 { set_sender(operator); assert!(erc - .safe_transfer_from(owner, charlie(), 1, 5, vec![]) + .safe_transfer_from(owner, charlie(), 1, 5.into(), vec![]) .is_ok()); - assert_eq!(erc.balance_of(alice(), 1), 5); - assert_eq!(erc.balance_of(charlie(), 1), 5); + assert_eq!(erc.balance_of(alice(), 1), U256::from(5)); + assert_eq!(erc.balance_of(charlie(), 1), U256::from(5)); } #[ink::test] @@ -787,18 +815,18 @@ mod erc1155 { let mut erc = Contract::new(); set_sender(alice()); - assert_eq!(erc.create(0), 1); - assert_eq!(erc.balance_of(alice(), 1), 0); + assert_eq!(erc.create(0.into()), 1); + assert_eq!(erc.balance_of(alice(), 1), U256::zero()); - assert!(erc.mint(1, 123).is_ok()); - assert_eq!(erc.balance_of(alice(), 1), 123); + assert!(erc.mint(1, 123.into()).is_ok()); + assert_eq!(erc.balance_of(alice(), 1), U256::from(123)); } #[ink::test] fn minting_not_allowed_for_nonexistent_tokens() { let mut erc = Contract::new(); - let res = erc.mint(1, 123); + let res = erc.mint(1, 123.into()); assert_eq!(res.unwrap_err(), Error::UnexistentToken); } } diff --git a/erc20/Cargo.toml b/erc20/Cargo.toml index 848080d7..550fac7e 100644 --- a/erc20/Cargo.toml +++ b/erc20/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "erc20" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/erc20/lib.rs b/erc20/lib.rs index 82a4c438..51fd8a75 100644 --- a/erc20/lib.rs +++ b/erc20/lib.rs @@ -2,29 +2,33 @@ #[ink::contract] mod erc20 { - use ink::storage::Mapping; + use ink::{ + storage::Mapping, + H160, + U256, + }; /// A simple ERC-20 contract. #[ink(storage)] #[derive(Default)] pub struct Erc20 { /// Total token supply. - total_supply: Balance, + total_supply: U256, /// Mapping from owner to number of owned token. - balances: Mapping, + balances: Mapping, /// Mapping of the token amount which an account is allowed to withdraw /// from another account. - allowances: Mapping<(AccountId, AccountId), Balance>, + allowances: Mapping<(H160, H160), U256>, } /// Event emitted when a token transfer occurs. #[ink(event)] pub struct Transfer { #[ink(topic)] - from: Option, + from: Option, #[ink(topic)] - to: Option, - value: Balance, + to: Option, + value: U256, } /// Event emitted when an approval occurs that `spender` is allowed to withdraw @@ -32,10 +36,10 @@ mod erc20 { #[ink(event)] pub struct Approval { #[ink(topic)] - owner: AccountId, + owner: H160, #[ink(topic)] - spender: AccountId, - value: Balance, + spender: H160, + value: U256, } /// The ERC-20 error types. @@ -54,7 +58,7 @@ mod erc20 { impl Erc20 { /// Creates a new ERC-20 contract with the specified initial supply. #[ink(constructor)] - pub fn new(total_supply: Balance) -> Self { + pub fn new(total_supply: U256) -> Self { let mut balances = Mapping::default(); let caller = Self::env().caller(); balances.insert(caller, &total_supply); @@ -72,7 +76,7 @@ mod erc20 { /// Returns the total token supply. #[ink(message)] - pub fn total_supply(&self) -> Balance { + pub fn total_supply(&self) -> U256 { self.total_supply } @@ -80,7 +84,7 @@ mod erc20 { /// /// Returns `0` if the account is non-existent. #[ink(message)] - pub fn balance_of(&self, owner: AccountId) -> Balance { + pub fn balance_of(&self, owner: H160) -> U256 { self.balance_of_impl(&owner) } @@ -91,9 +95,9 @@ mod erc20 { /// # Note /// /// Prefer to call this method over `balance_of` since this - /// works using references which are more efficient in Wasm. + /// works using references which are more efficient. #[inline] - fn balance_of_impl(&self, owner: &AccountId) -> Balance { + fn balance_of_impl(&self, owner: &H160) -> U256 { self.balances.get(owner).unwrap_or_default() } @@ -101,7 +105,7 @@ mod erc20 { /// /// Returns `0` if no allowance has been set. #[ink(message)] - pub fn allowance(&self, owner: AccountId, spender: AccountId) -> Balance { + pub fn allowance(&self, owner: H160, spender: H160) -> U256 { self.allowance_impl(&owner, &spender) } @@ -112,9 +116,9 @@ mod erc20 { /// # Note /// /// Prefer to call this method over `allowance` since this - /// works using references which are more efficient in Wasm. + /// works using references which are more efficient. #[inline] - fn allowance_impl(&self, owner: &AccountId, spender: &AccountId) -> Balance { + fn allowance_impl(&self, owner: &H160, spender: &H160) -> U256 { self.allowances.get((owner, spender)).unwrap_or_default() } @@ -127,7 +131,7 @@ mod erc20 { /// Returns `InsufficientBalance` error if there are not enough tokens on /// the caller's account balance. #[ink(message)] - pub fn transfer(&mut self, to: AccountId, value: Balance) -> Result<()> { + pub fn transfer(&mut self, to: H160, value: U256) -> Result<()> { let from = self.env().caller(); self.transfer_from_to(&from, &to, value) } @@ -140,7 +144,7 @@ mod erc20 { /// /// An `Approval` event is emitted. #[ink(message)] - pub fn approve(&mut self, spender: AccountId, value: Balance) -> Result<()> { + pub fn approve(&mut self, spender: H160, value: U256) -> Result<()> { let owner = self.env().caller(); self.allowances.insert((&owner, &spender), &value); self.env().emit_event(Approval { @@ -166,12 +170,7 @@ mod erc20 { /// Returns `InsufficientBalance` error if there are not enough tokens on /// the account balance of `from`. #[ink(message)] - pub fn transfer_from( - &mut self, - from: AccountId, - to: AccountId, - value: Balance, - ) -> Result<()> { + pub fn transfer_from(&mut self, from: H160, to: H160, value: U256) -> Result<()> { let caller = self.env().caller(); let allowance = self.allowance_impl(&from, &caller); if allowance < value { @@ -195,9 +194,9 @@ mod erc20 { /// the caller's account balance. fn transfer_from_to( &mut self, - from: &AccountId, - to: &AccountId, - value: Balance, + from: &H160, + to: &H160, + value: U256, ) -> Result<()> { let from_balance = self.balance_of_impl(from); if from_balance < value { @@ -218,6 +217,11 @@ mod erc20 { } } + #[cfg(test)] + fn set_caller(sender: H160) { + ink::env::test::set_caller(sender); + } + #[cfg(test)] mod tests { use super::*; @@ -229,9 +233,9 @@ mod erc20 { fn assert_transfer_event( event: &ink::env::test::EmittedEvent, - expected_from: Option, - expected_to: Option, - expected_value: Balance, + expected_from: Option, + expected_to: Option, + expected_value: U256, ) { let decoded_event = ::decode(&mut &event.data[..]) @@ -243,8 +247,7 @@ mod erc20 { let mut expected_topics = Vec::new(); expected_topics.push( - ink::blake2x256!("Transfer(Option,Option,Balance)") - .into(), + ink::blake2x256!("Transfer(Option,Option,U256)").into(), ); if let Some(from) = expected_from { expected_topics.push(encoded_into_hash(from)); @@ -277,7 +280,8 @@ mod erc20 { #[ink::test] fn new_works() { // Constructor works. - let _erc20 = Erc20::new(100); + set_caller(H160::from([0x01; 20])); + let _erc20 = Erc20::new(100.into()); // Transfer event triggered during initial construction. let emitted_events = ink::env::test::recorded_events().collect::>(); @@ -286,8 +290,8 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(H160::from([0x01; 20])), + 100.into(), ); } @@ -295,53 +299,56 @@ mod erc20 { #[ink::test] fn total_supply_works() { // Constructor works. - let erc20 = Erc20::new(100); + set_caller(H160::from([0x01; 20])); + let erc20 = Erc20::new(100.into()); // Transfer event triggered during initial construction. let emitted_events = ink::env::test::recorded_events().collect::>(); assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(H160::from([0x01; 20])), + 100.into(), ); // Get the token total supply. - assert_eq!(erc20.total_supply(), 100); + assert_eq!(erc20.total_supply(), U256::from(100)); } /// Get the actual balance of an account. #[ink::test] fn balance_of_works() { + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + // Constructor works - let erc20 = Erc20::new(100); + let erc20 = Erc20::new(100.into()); // Transfer event triggered during initial construction let emitted_events = ink::env::test::recorded_events().collect::>(); assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); // Alice owns all the tokens on contract instantiation - assert_eq!(erc20.balance_of(accounts.alice), 100); + assert_eq!(erc20.balance_of(accounts.alice), U256::from(100)); // Bob does not owns tokens - assert_eq!(erc20.balance_of(accounts.bob), 0); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); } #[ink::test] fn transfer_works() { + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + // Constructor works. - let mut erc20 = Erc20::new(100); + let mut erc20 = Erc20::new(100.into()); // Transfer event triggered during initial construction. - let accounts = - ink::env::test::default_accounts::(); - - assert_eq!(erc20.balance_of(accounts.bob), 0); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); // Alice transfers 10 tokens to Bob. - assert_eq!(erc20.transfer(accounts.bob, 10), Ok(())); + assert_eq!(erc20.transfer(accounts.bob, U256::from(10)), Ok(())); // Bob owns 10 tokens. - assert_eq!(erc20.balance_of(accounts.bob), 10); + assert_eq!(erc20.balance_of(accounts.bob), U256::from(10)); let emitted_events = ink::env::test::recorded_events().collect::>(); assert_eq!(emitted_events.len(), 2); @@ -349,41 +356,43 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); // Check the second transfer event relating to the actual trasfer. assert_transfer_event( &emitted_events[1], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x02; 32])), - 10, + Some(accounts.alice), + Some(accounts.bob), + 10.into(), ); } #[ink::test] fn invalid_transfer_should_fail() { // Constructor works. - let mut erc20 = Erc20::new(100); - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + + let initial_supply = 100.into(); + let mut erc20 = Erc20::new(initial_supply); - assert_eq!(erc20.balance_of(accounts.bob), 0); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); // Set the contract as callee and Bob as caller. - let contract = ink::env::account_id::(); - ink::env::test::set_callee::(contract); - ink::env::test::set_caller::(accounts.bob); + let contract = ink::env::address(); + ink::env::test::set_callee(contract); + set_caller(accounts.bob); - // Bob fails to transfers 10 tokens to Eve. + // Bob fails to transfer 10 tokens to Eve. assert_eq!( - erc20.transfer(accounts.eve, 10), + erc20.transfer(accounts.eve, 10.into()), Err(Error::InsufficientBalance) ); // Alice owns all the tokens. - assert_eq!(erc20.balance_of(accounts.alice), 100); - assert_eq!(erc20.balance_of(accounts.bob), 0); - assert_eq!(erc20.balance_of(accounts.eve), 0); + assert_eq!(erc20.balance_of(accounts.alice), U256::from(100)); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); + assert_eq!(erc20.balance_of(accounts.eve), U256::zero()); // Transfer event triggered during initial construction. let emitted_events = ink::env::test::recorded_events().collect::>(); @@ -391,42 +400,42 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); } #[ink::test] fn transfer_from_works() { // Constructor works. - let mut erc20 = Erc20::new(100); - // Transfer event triggered during initial construction. - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + + let mut erc20 = Erc20::new(100.into()); // Bob fails to transfer tokens owned by Alice. assert_eq!( - erc20.transfer_from(accounts.alice, accounts.eve, 10), + erc20.transfer_from(accounts.alice, accounts.eve, 10.into()), Err(Error::InsufficientAllowance) ); // Alice approves Bob for token transfers on her behalf. - assert_eq!(erc20.approve(accounts.bob, 10), Ok(())); + assert_eq!(erc20.approve(accounts.bob, 10.into()), Ok(())); // The approve event takes place. assert_eq!(ink::env::test::recorded_events().count(), 2); // Set the contract as callee and Bob as caller. - let contract = ink::env::account_id::(); - ink::env::test::set_callee::(contract); - ink::env::test::set_caller::(accounts.bob); + let contract = ink::env::address(); + ink::env::test::set_callee(contract); + ink::env::test::set_caller(accounts.bob); // Bob transfers tokens from Alice to Eve. assert_eq!( - erc20.transfer_from(accounts.alice, accounts.eve, 10), + erc20.transfer_from(accounts.alice, accounts.eve, 10.into()), Ok(()) ); // Eve owns tokens. - assert_eq!(erc20.balance_of(accounts.eve), 10); + assert_eq!(erc20.balance_of(accounts.eve), U256::from(10)); // Check all transfer events that happened during the previous calls: let emitted_events = ink::env::test::recorded_events().collect::>(); @@ -434,24 +443,24 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); // The second event `emitted_events[1]` is an Approve event that we skip // checking. assert_transfer_event( &emitted_events[2], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x05; 32])), - 10, + Some(accounts.alice), + Some(accounts.eve), + 10.into(), ); } #[ink::test] fn allowance_must_not_change_on_failed_transfer() { - let mut erc20 = Erc20::new(100); - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + let mut erc20 = Erc20::new(100.into()); // Alice approves Bob for token transfers on her behalf. let alice_balance = erc20.balance_of(accounts.alice); @@ -459,14 +468,18 @@ mod erc20 { assert_eq!(erc20.approve(accounts.bob, initial_allowance), Ok(())); // Get contract address. - let callee = ink::env::account_id::(); - ink::env::test::set_callee::(callee); - ink::env::test::set_caller::(accounts.bob); + let callee = ink::env::address(); + ink::env::test::set_callee(callee); + ink::env::test::set_caller(accounts.bob); // Bob tries to transfer tokens from Alice to Eve. let emitted_events_before = ink::env::test::recorded_events().count(); assert_eq!( - erc20.transfer_from(accounts.alice, accounts.eve, alice_balance + 1), + erc20.transfer_from( + accounts.alice, + accounts.eve, + alice_balance + U256::from(1) + ), Err(Error::InsufficientBalance) ); // Allowance must have stayed the same @@ -521,7 +534,7 @@ mod erc20 { #[ink_e2e::test] async fn e2e_transfer(mut client: Client) -> E2EResult<()> { // given - let total_supply = 1_000_000_000; + let total_supply = U256::from(1_000_000_000); let mut constructor = Erc20Ref::new(total_supply); let erc20 = client .instantiate("erc20", &ink_e2e::alice(), &mut constructor) @@ -537,8 +550,10 @@ mod erc20 { .dry_run() .await?; - let bob_account = ink_e2e::account_id(ink_e2e::AccountKeyring::Bob); - let transfer_to_bob = 500_000_000u128; + let bob_account = ink_e2e::address::( + ink_e2e::Sr25519Keyring::Bob, + ); + let transfer_to_bob = U256::from(500_000_000); let transfer = call_builder.transfer(bob_account, transfer_to_bob); let _transfer_res = client .call(&ink_e2e::alice(), &transfer) @@ -566,7 +581,7 @@ mod erc20 { #[ink_e2e::test] async fn e2e_allowances(mut client: Client) -> E2EResult<()> { // given - let total_supply = 1_000_000_000; + let total_supply = U256::from(1_000_000_000); let mut constructor = Erc20Ref::new(total_supply); let erc20 = client .instantiate("erc20", &ink_e2e::bob(), &mut constructor) @@ -577,10 +592,14 @@ mod erc20 { // when - let bob_account = ink_e2e::account_id(ink_e2e::AccountKeyring::Bob); - let charlie_account = ink_e2e::account_id(ink_e2e::AccountKeyring::Charlie); + let bob_account = ink_e2e::address::( + ink_e2e::Sr25519Keyring::Bob, + ); + let charlie_account = ink_e2e::address::( + ink_e2e::Sr25519Keyring::Charlie, + ); - let amount = 500_000_000u128; + let amount = U256::from(500_000_000); // tx let transfer_from = call_builder.transfer_from(bob_account, charlie_account, amount); @@ -595,7 +614,7 @@ mod erc20 { ); // Bob approves Charlie to transfer up to amount on his behalf - let approved_value = 1_000u128; + let approved_value = U256::from(1_000); let approve_call = call_builder.approve(charlie_account, approved_value); client .call(&ink_e2e::bob(), &approve_call) @@ -623,7 +642,7 @@ mod erc20 { // `transfer_from` again, this time exceeding the approved amount let transfer_from = - call_builder.transfer_from(bob_account, charlie_account, 1); + call_builder.transfer_from(bob_account, charlie_account, 1.into()); let transfer_from_result = client .call(&ink_e2e::charlie(), &transfer_from) .submit() diff --git a/erc721/Cargo.toml b/erc721/Cargo.toml index b07e5d50..75862765 100644 --- a/erc721/Cargo.toml +++ b/erc721/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "erc721" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/erc721/lib.rs b/erc721/lib.rs index 5b2cbafd..98ae93f1 100644 --- a/erc721/lib.rs +++ b/erc721/lib.rs @@ -54,7 +54,10 @@ #[ink::contract] mod erc721 { - use ink::storage::Mapping; + use ink::{ + storage::Mapping, + H160, + }; /// A token ID. pub type TokenId = u32; @@ -63,13 +66,13 @@ mod erc721 { #[derive(Default)] pub struct Erc721 { /// Mapping from token to owner. - token_owner: Mapping, + token_owner: Mapping, /// Mapping from token to approvals users. - token_approvals: Mapping, + token_approvals: Mapping, /// Mapping from owner to number of owned token. - owned_tokens_count: Mapping, + owned_tokens_count: Mapping, /// Mapping from owner to operator approvals. - operator_approvals: Mapping<(AccountId, AccountId), ()>, + operator_approvals: Mapping<(H160, H160), ()>, } #[derive(Debug, PartialEq, Eq, Copy, Clone)] @@ -88,9 +91,9 @@ mod erc721 { #[ink(event)] pub struct Transfer { #[ink(topic)] - from: Option, + from: Option, #[ink(topic)] - to: Option, + to: Option, #[ink(topic)] id: TokenId, } @@ -99,9 +102,9 @@ mod erc721 { #[ink(event)] pub struct Approval { #[ink(topic)] - from: AccountId, + from: H160, #[ink(topic)] - to: AccountId, + to: H160, #[ink(topic)] id: TokenId, } @@ -111,9 +114,9 @@ mod erc721 { #[ink(event)] pub struct ApprovalForAll { #[ink(topic)] - owner: AccountId, + owner: H160, #[ink(topic)] - operator: AccountId, + operator: H160, approved: bool, } @@ -128,25 +131,25 @@ mod erc721 { /// /// This represents the amount of unique tokens the owner has. #[ink(message)] - pub fn balance_of(&self, owner: AccountId) -> u32 { + pub fn balance_of(&self, owner: H160) -> u32 { self.balance_of_or_zero(&owner) } /// Returns the owner of the token. #[ink(message)] - pub fn owner_of(&self, id: TokenId) -> Option { + pub fn owner_of(&self, id: TokenId) -> Option { self.token_owner.get(id) } /// Returns the approved account ID for this token if any. #[ink(message)] - pub fn get_approved(&self, id: TokenId) -> Option { + pub fn get_approved(&self, id: TokenId) -> Option { self.token_approvals.get(id) } /// Returns `true` if the operator is approved by the owner. #[ink(message)] - pub fn is_approved_for_all(&self, owner: AccountId, operator: AccountId) -> bool { + pub fn is_approved_for_all(&self, owner: H160, operator: H160) -> bool { self.approved_for_all(owner, operator) } @@ -154,7 +157,7 @@ mod erc721 { #[ink(message)] pub fn set_approval_for_all( &mut self, - to: AccountId, + to: H160, approved: bool, ) -> Result<(), Error> { self.approve_for_all(to, approved)?; @@ -163,18 +166,14 @@ mod erc721 { /// Approves the account to transfer the specified token on behalf of the caller. #[ink(message)] - pub fn approve(&mut self, to: AccountId, id: TokenId) -> Result<(), Error> { + pub fn approve(&mut self, to: H160, id: TokenId) -> Result<(), Error> { self.approve_for(&to, id)?; Ok(()) } /// Transfers the token from the caller to the given destination. #[ink(message)] - pub fn transfer( - &mut self, - destination: AccountId, - id: TokenId, - ) -> Result<(), Error> { + pub fn transfer(&mut self, destination: H160, id: TokenId) -> Result<(), Error> { let caller = self.env().caller(); self.transfer_token_from(&caller, &destination, id)?; Ok(()) @@ -184,8 +183,8 @@ mod erc721 { #[ink(message)] pub fn transfer_from( &mut self, - from: AccountId, - to: AccountId, + from: H160, + to: H160, id: TokenId, ) -> Result<(), Error> { self.transfer_token_from(&from, &to, id)?; @@ -198,7 +197,7 @@ mod erc721 { let caller = self.env().caller(); self.add_token_to(&caller, id)?; self.env().emit_event(Transfer { - from: Some(AccountId::from([0x0; 32])), + from: Some(H160::from([0x0; 20])), to: Some(caller), id, }); @@ -230,18 +229,18 @@ mod erc721 { self.env().emit_event(Transfer { from: Some(caller), - to: Some(AccountId::from([0x0; 32])), + to: Some(H160::from([0x0; 20])), id, }); Ok(()) } - /// Transfers token `id` `from` the sender to the `to` `AccountId`. + /// Transfers token `id` `from` the sender to the `to` `H160`. fn transfer_token_from( &mut self, - from: &AccountId, - to: &AccountId, + from: &H160, + to: &H160, id: TokenId, ) -> Result<(), Error> { let caller = self.env().caller(); @@ -264,11 +263,7 @@ mod erc721 { } /// Removes token `id` from the owner. - fn remove_token_from( - &mut self, - from: &AccountId, - id: TokenId, - ) -> Result<(), Error> { + fn remove_token_from(&mut self, from: &H160, id: TokenId) -> Result<(), Error> { let Self { token_owner, owned_tokens_count, @@ -290,7 +285,7 @@ mod erc721 { } /// Adds the token `id` to the `to` AccountID. - fn add_token_to(&mut self, to: &AccountId, id: TokenId) -> Result<(), Error> { + fn add_token_to(&mut self, to: &H160, id: TokenId) -> Result<(), Error> { let Self { token_owner, owned_tokens_count, @@ -301,7 +296,7 @@ mod erc721 { return Err(Error::TokenExists); } - if *to == AccountId::from([0x0; 32]) { + if *to == H160::from([0x0; 20]) { return Err(Error::NotAllowed); }; @@ -317,11 +312,7 @@ mod erc721 { } /// Approves or disapproves the operator to transfer all tokens of the caller. - fn approve_for_all( - &mut self, - to: AccountId, - approved: bool, - ) -> Result<(), Error> { + fn approve_for_all(&mut self, to: H160, approved: bool) -> Result<(), Error> { let caller = self.env().caller(); if to == caller { return Err(Error::NotAllowed); @@ -341,16 +332,16 @@ mod erc721 { Ok(()) } - /// Approve the passed `AccountId` to transfer the specified token on behalf of + /// Approve the passed `H160` to transfer the specified token on behalf of /// the message's sender. - fn approve_for(&mut self, to: &AccountId, id: TokenId) -> Result<(), Error> { + fn approve_for(&mut self, to: &H160, id: TokenId) -> Result<(), Error> { let caller = self.env().caller(); let owner = self.owner_of(id).ok_or(Error::TokenNotFound)?; if !(owner == caller || self.approved_for_all(owner, caller)) { return Err(Error::NotAllowed); }; - if *to == AccountId::from([0x0; 32]) { + if *to == H160::from([0x0; 20]) { return Err(Error::NotAllowed); }; @@ -375,24 +366,19 @@ mod erc721 { } // Returns the total number of tokens from an account. - fn balance_of_or_zero(&self, of: &AccountId) -> u32 { + fn balance_of_or_zero(&self, of: &H160) -> u32 { self.owned_tokens_count.get(of).unwrap_or(0) } /// Gets an operator on other Account's behalf. - fn approved_for_all(&self, owner: AccountId, operator: AccountId) -> bool { + fn approved_for_all(&self, owner: H160, operator: H160) -> bool { self.operator_approvals.contains((&owner, &operator)) } - /// Returns true if the `AccountId` `from` is the owner of token `id` + /// Returns true if the `H160` `from` is the owner of token `id` /// or it has been approved on behalf of the token `id` owner. - fn approved_or_owner( - &self, - from: AccountId, - id: TokenId, - owner: AccountId, - ) -> bool { - from != AccountId::from([0x0; 32]) + fn approved_or_owner(&self, from: H160, id: TokenId, owner: H160) -> bool { + from != H160::from([0x0; 20]) && (from == owner || self.token_approvals.get(id) == Some(from) || self.approved_for_all(owner, from)) @@ -407,8 +393,8 @@ mod erc721 { #[ink::test] fn mint_works() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Token 1 does not exists. @@ -423,8 +409,8 @@ mod erc721 { #[ink::test] fn mint_existing_should_fail() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1. @@ -442,8 +428,8 @@ mod erc721 { #[ink::test] fn transfer_works() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1 for Alice @@ -464,8 +450,8 @@ mod erc721 { #[ink::test] fn invalid_transfer_should_fail() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Transfer token fails if it does not exists. @@ -486,8 +472,8 @@ mod erc721 { #[ink::test] fn approved_transfer_works() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1. @@ -515,8 +501,8 @@ mod erc721 { #[ink::test] fn approved_for_all_works() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1. @@ -558,8 +544,8 @@ mod erc721 { #[ink::test] fn approve_nonexistent_token_should_fail() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Approve transfer of nonexistent token id 1 @@ -568,8 +554,8 @@ mod erc721 { #[ink::test] fn not_approved_transfer_should_fail() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1. @@ -597,8 +583,8 @@ mod erc721 { #[ink::test] fn burn_works() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1 for Alice @@ -625,8 +611,8 @@ mod erc721 { #[ink::test] fn burn_fails_not_owner() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1 for Alice @@ -638,8 +624,8 @@ mod erc721 { #[ink::test] fn burn_clears_approval() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1 for Alice @@ -663,8 +649,8 @@ mod erc721 { #[ink::test] fn transfer_from_fails_not_owner() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1 for Alice @@ -686,8 +672,8 @@ mod erc721 { #[ink::test] fn transfer_fails_not_owner() { - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); // Create a new contract instance. let mut erc721 = Erc721::new(); // Create token Id 1 for Alice @@ -700,8 +686,8 @@ mod erc721 { assert_eq!(erc721.transfer(accounts.bob, 1), Err(Error::NotOwner)); } - fn set_caller(sender: AccountId) { - ink::env::test::set_caller::(sender); + fn set_caller(sender: H160) { + ink::env::test::set_caller(sender); } } } diff --git a/events/Cargo.toml b/events/Cargo.toml index fc814e85..39be08c3 100644 --- a/events/Cargo.toml +++ b/events/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "events" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } event-def = { path = "event-def", default-features = false } event-def2 = { path = "event-def2", default-features = false } event-def-unused = { path = "event-def-unused", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" @@ -28,8 +28,3 @@ std = [ ] ink-as-dependency = [] e2e-tests = [] - -[profile.test] -# Need this for linkme crate to work for the event metadata unit test. -# See https://github.com/dtolnay/linkme/issues/61#issuecomment-1503653702 -lto = "thin" diff --git a/events/event-def-unused/Cargo.toml b/events/event-def-unused/Cargo.toml index fe283ee0..0f22aaa8 100644 --- a/events/event-def-unused/Cargo.toml +++ b/events/event-def-unused/Cargo.toml @@ -1,10 +1,14 @@ [package] name = "event-def-unused" +authors = ["Use Ink "] version = "0.1.0" edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } + +[lib] +path = "src/lib.rs" [features] default = ["std"] diff --git a/events/event-def/Cargo.toml b/events/event-def/Cargo.toml index 2e72cfc8..7c4ec74b 100644 --- a/events/event-def/Cargo.toml +++ b/events/event-def/Cargo.toml @@ -1,10 +1,14 @@ [package] name = "event-def" +authors = ["Use Ink "] version = "0.1.0" edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } + +[lib] +path = "src/lib.rs" [features] default = ["std"] diff --git a/events/event-def2/Cargo.toml b/events/event-def2/Cargo.toml index 10956b53..ae45732d 100644 --- a/events/event-def2/Cargo.toml +++ b/events/event-def2/Cargo.toml @@ -1,10 +1,14 @@ [package] name = "event-def2" +authors = ["Use Ink "] version = "0.1.0" edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } + +[lib] +path = "src/lib.rs" [features] default = ["std"] diff --git a/events/lib.rs b/events/lib.rs index 211b55b3..6cc43b71 100644 --- a/events/lib.rs +++ b/events/lib.rs @@ -110,7 +110,6 @@ pub mod events { #[test] fn collects_specs_for_all_linked_and_used_events() { let event_specs = ink::metadata::collect_events(); - assert_eq!(8, event_specs.len()); assert!(event_specs .iter() @@ -134,11 +133,13 @@ pub mod events { .iter() .any(|evt| evt.label() == &"InlineAnonymousEvent")); - // The event is not used in the code by being included in the metadata - // because we implement trait form `event_def_unused` crate. + // The event is not used in the code by being included in the metadata, + // byt because we implement the trait from the `event_def_unused` crate. assert!(event_specs .iter() .any(|evt| evt.label() == &"EventDefUnused")); + + assert_eq!(8, event_specs.len()); } #[ink::test] @@ -238,10 +239,8 @@ pub mod events { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; - use ink_e2e::{ - ContractsBackend, - H256, - }; + use ink::H256; + use ink_e2e::ContractsBackend; type E2EResult = std::result::Result>; @@ -404,6 +403,7 @@ pub mod events { // then assert_eq!(1, contract_events.len()); + // todo the emitted event is not actually checked here let signature_topic = ::SIGNATURE_TOPIC; diff --git a/flipper/Cargo.toml b/flipper/Cargo.toml index 03556314..7f77efce 100644 --- a/flipper/Cargo.toml +++ b/flipper/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "flipper" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } hex = { version = "0.4.3" } [lib] diff --git a/flipper/lib.rs b/flipper/lib.rs index 3730b8e2..8370b60f 100644 --- a/flipper/lib.rs +++ b/flipper/lib.rs @@ -64,15 +64,15 @@ pub mod flipper { // given let mut constructor = FlipperRef::new(false); let contract = client - .instantiate("flipper", &ink_e2e::alice(), &mut constructor) + .instantiate("flipper", &ink_e2e::bob(), &mut constructor) .submit() .await .expect("instantiate failed"); let mut call_builder = contract.call_builder::(); let get = call_builder.get(); - let get_res = client.call(&ink_e2e::bob(), &get).dry_run().await?; - assert!(matches!(get_res.return_value(), false)); + let get_res = client.call(&ink_e2e::bob(), &get).submit().await?; + assert!(!get_res.return_value()); // when let flip = call_builder.flip(); @@ -85,7 +85,7 @@ pub mod flipper { // then let get = call_builder.get(); let get_res = client.call(&ink_e2e::bob(), &get).dry_run().await?; - assert!(matches!(get_res.return_value(), true)); + assert!(get_res.return_value()); Ok(()) } @@ -106,7 +106,7 @@ pub mod flipper { // then let get = call_builder.get(); let get_res = client.call(&ink_e2e::bob(), &get).dry_run().await?; - assert!(matches!(get_res.return_value(), false)); + assert!(!get_res.return_value()); Ok(()) } @@ -144,11 +144,12 @@ pub mod flipper { mut client: Client, ) -> E2EResult<()> { // given + use ink::H160; let addr = std::env::var("CONTRACT_ADDR_HEX") .unwrap() .replace("0x", ""); - let acc_id = hex::decode(addr).unwrap(); - let acc_id = AccountId::try_from(&acc_id[..]).unwrap(); + let addr_bytes: Vec = hex::decode(addr).unwrap(); + let addr = H160::from_slice(&addr_bytes[..]); use std::str::FromStr; let suri = ink_e2e::subxt_signer::SecretUri::from_str("//Alice").unwrap(); @@ -156,12 +157,12 @@ pub mod flipper { // when // Invoke `Flipper::get()` from `caller`'s account - let call_builder = ink_e2e::create_call_builder::(acc_id); + let call_builder = ink_e2e::create_call_builder::(addr); let get = call_builder.get(); let get_res = client.call(&caller, &get).dry_run().await?; // then - assert_eq!(get_res.return_value(), true); + assert!(get_res.return_value()); Ok(()) } diff --git a/incrementer/Cargo.toml b/incrementer/Cargo.toml index 247cbc43..7cde84af 100644 --- a/incrementer/Cargo.toml +++ b/incrementer/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "incrementer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/lazyvec/Cargo.toml b/lazyvec/Cargo.toml index e8e0e407..70c5d54c 100755 --- a/lazyvec/Cargo.toml +++ b/lazyvec/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "lazyvec" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/lazyvec/lib.rs b/lazyvec/lib.rs index 8c520680..d1c503a0 100755 --- a/lazyvec/lib.rs +++ b/lazyvec/lib.rs @@ -39,7 +39,7 @@ mod lazyvec { /// Checks whether given account is allowed to vote and didn't already /// participate. - fn is_eligible(&self, _voter: AccountId) -> bool { + fn is_eligible(&self, _voter: ink::H160) -> bool { // ToDo: In production, the contract would actually verify eligible voters. // For example, a merkle proof could be an efficient way to do this. true @@ -110,7 +110,7 @@ mod lazyvec { let mut call_builder = contract.call_builder::(); // when - let create = call_builder.create_proposal(vec![0x41], 5, 1); + let create = call_builder.create_proposal(vec![0x41], 15, 1); let _ = client .call(&ink_e2e::alice(), &create) .submit() diff --git a/multi-contract-caller/Cargo.toml b/multi-contract-caller/Cargo.toml index 3d7ea172..cbd4d85c 100644 --- a/multi-contract-caller/Cargo.toml +++ b/multi-contract-caller/Cargo.toml @@ -1,19 +1,19 @@ [package] name = "multi-contract-caller" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } adder = { path = "adder", default-features = false, features = ["ink-as-dependency"] } subber = { path = "subber", default-features = false, features = ["ink-as-dependency"] } accumulator = { path = "accumulator", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/multi-contract-caller/accumulator/Cargo.toml b/multi-contract-caller/accumulator/Cargo.toml index 4f570f5f..9f75347d 100644 --- a/multi-contract-caller/accumulator/Cargo.toml +++ b/multi-contract-caller/accumulator/Cargo.toml @@ -1,11 +1,12 @@ [package] name = "accumulator" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } + [lib] path = "lib.rs" diff --git a/multi-contract-caller/adder/Cargo.toml b/multi-contract-caller/adder/Cargo.toml index 3c6f1100..a33e5613 100644 --- a/multi-contract-caller/adder/Cargo.toml +++ b/multi-contract-caller/adder/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "adder" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multi-contract-caller/lib.rs b/multi-contract-caller/lib.rs index bab0f4f8..70b3043b 100644 --- a/multi-contract-caller/lib.rs +++ b/multi-contract-caller/lib.rs @@ -52,24 +52,26 @@ mod multi_contract_caller { pub fn new( init_value: i32, version: u32, - accumulator_code_hash: Hash, - adder_code_hash: Hash, - subber_code_hash: Hash, + accumulator_code_hash: ink::H256, + adder_code_hash: ink::H256, + subber_code_hash: ink::H256, ) -> Self { let total_balance = Self::env().balance(); - let salt = version.to_le_bytes(); + let one_fourth = total_balance.checked_div(4.into()).expect("div failed"); + + let salt = salt_from_version(version); let accumulator = AccumulatorRef::new(init_value) - .endowment(total_balance / 4) + .endowment(one_fourth) .code_hash(accumulator_code_hash) .salt_bytes(salt) .instantiate(); let adder = AdderRef::new(accumulator.clone()) - .endowment(total_balance / 4) + .endowment(one_fourth) .code_hash(adder_code_hash) .salt_bytes(salt) .instantiate(); let subber = SubberRef::new(accumulator.clone()) - .endowment(total_balance / 4) + .endowment(one_fourth) .code_hash(subber_code_hash) .salt_bytes(salt) .instantiate(); @@ -110,6 +112,13 @@ mod multi_contract_caller { } } + fn salt_from_version(version: u32) -> Option<[u8; 32]> { + let version: [u8; 4] = version.to_le_bytes(); + let mut salt: [u8; 32] = [0u8; 32]; + salt[..4].copy_from_slice(&version); + Some(salt) + } + #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; @@ -153,7 +162,7 @@ mod multi_contract_caller { let multi_contract_caller = client .instantiate("multi_contract_caller", &ink_e2e::alice(), &mut constructor) - .value(10_000_000_000_000) + .value(100_000_000_000) .submit() .await .expect("instantiate failed"); diff --git a/multi-contract-caller/subber/Cargo.toml b/multi-contract-caller/subber/Cargo.toml index 2b8d683f..e9c6f1fa 100644 --- a/multi-contract-caller/subber/Cargo.toml +++ b/multi-contract-caller/subber/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "subber" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index 6731967a..364b217a 100755 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "multisig" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/multisig/lib.rs b/multisig/lib.rs index f7c0bf62..3d5dce0e 100755 --- a/multisig/lib.rs +++ b/multisig/lib.rs @@ -74,6 +74,8 @@ mod multisig { prelude::vec::Vec, scale::Output, storage::Mapping, + H160, + U256, }; /// Tune this to your liking but be wary that allowing too many owners will not @@ -90,7 +92,7 @@ mod multisig { #[derive(Clone)] struct CallInput<'a>(&'a [u8]); - impl<'a> ink::scale::Encode for CallInput<'a> { + impl ink::scale::Encode for CallInput<'_> { fn encode_to(&self, dest: &mut T) { dest.write(self.0); } @@ -117,15 +119,15 @@ mod multisig { )] #[ink::scale_derive(Encode, Decode, TypeInfo)] pub struct Transaction { - /// The `AccountId` of the contract that is called in this transaction. - pub callee: AccountId, + /// The address of the contract that is called in this transaction. + pub callee: H160, /// The selector bytes that identifies the function of the callee that should be /// called. pub selector: [u8; 4], /// The SCALE encoded parameters that are passed to the called function. pub input: Vec, /// The amount of chain balance that is transferred to the callee. - pub transferred_value: Balance, + pub transferred_value: U256, /// Gas limit for the execution of the call. pub ref_time_limit: u64, /// If set to true the transaction will be allowed to re-enter the multisig @@ -167,7 +169,7 @@ mod multisig { transaction: TransactionId, /// The owner that sent the confirmation. #[ink(topic)] - from: AccountId, + from: H160, /// The confirmation status after this confirmation was applied. #[ink(topic)] status: ConfirmationStatus, @@ -181,7 +183,7 @@ mod multisig { transaction: TransactionId, /// The owner that sent the revocation. #[ink(topic)] - from: AccountId, + from: H160, } /// Emitted when an owner submits a transaction. @@ -219,7 +221,7 @@ mod multisig { pub struct OwnerAddition { /// The owner that was added. #[ink(topic)] - owner: AccountId, + owner: H160, } /// Emitted when an owner is removed from the wallet. @@ -227,7 +229,7 @@ mod multisig { pub struct OwnerRemoval { /// The owner that was removed. #[ink(topic)] - owner: AccountId, + owner: H160, } /// Emitted when the requirement changed. @@ -242,7 +244,7 @@ mod multisig { pub struct Multisig { /// Every entry in this map represents the confirmation of an owner for a /// transaction. This is effectively a set rather than a map. - confirmations: Mapping<(TransactionId, AccountId), ()>, + confirmations: Mapping<(TransactionId, H160), ()>, /// The amount of confirmations for every transaction. This is a redundant /// information and is kept in order to prevent iterating through the /// confirmation set to check if a transaction is confirmed. @@ -254,9 +256,9 @@ mod multisig { transaction_list: Transactions, /// The list is a vector because iterating over it is necessary when cleaning /// up the confirmation set. - owners: Vec, + owners: Vec, /// Redundant information to speed up the check whether a caller is an owner. - is_owner: Mapping, + is_owner: Mapping, /// Minimum number of owners that have to confirm a transaction to be executed. requirement: u32, } @@ -271,7 +273,7 @@ mod multisig { /// /// If `requirement` violates our invariant. #[ink(constructor)] - pub fn new(requirement: u32, mut owners: Vec) -> Self { + pub fn new(requirement: u32, mut owners: Vec) -> Self { let mut contract = Multisig::default(); owners.sort_unstable(); owners.dedup(); @@ -321,20 +323,18 @@ mod multisig { /// Transaction, /// }; /// - /// type AccountId = ::AccountId; - /// /// // address of an existing `Multisig` contract - /// let wallet_id: AccountId = [7u8; 32].into(); + /// let wallet_id: ink::H160 = [7u8; 20].into(); /// /// // first create the transaction that adds `alice` through `add_owner` - /// let alice: AccountId = [1u8; 32].into(); + /// let alice: ink::H160 = [1u8; 20].into(); /// let add_owner_args = ArgumentList::empty().push_arg(&alice); /// /// let transaction_candidate = Transaction { /// callee: wallet_id, /// selector: selector_bytes!("add_owner"), /// input: add_owner_args.encode(), - /// transferred_value: 0, + /// transferred_value: ink::U256::zero(), /// ref_time_limit: 0, /// allow_reentry: true, /// }; @@ -365,7 +365,7 @@ mod multisig { /// .invoke(); /// ``` #[ink(message)] - pub fn add_owner(&mut self, new_owner: AccountId) { + pub fn add_owner(&mut self, new_owner: H160) { self.ensure_from_wallet(); self.ensure_no_owner(&new_owner); ensure_requirement_is_valid( @@ -387,7 +387,7 @@ mod multisig { /// /// If `owner` is no owner of the wallet. #[ink(message)] - pub fn remove_owner(&mut self, owner: AccountId) { + pub fn remove_owner(&mut self, owner: H160) { self.ensure_from_wallet(); self.ensure_owner(&owner); // If caller is an owner the len has to be > 0 @@ -411,7 +411,7 @@ mod multisig { /// /// If `old_owner` is no owner or if `new_owner` already is one. #[ink(message)] - pub fn replace_owner(&mut self, old_owner: AccountId, new_owner: AccountId) { + pub fn replace_owner(&mut self, old_owner: H160, new_owner: H160) { self.ensure_from_wallet(); self.ensure_owner(&old_owner); self.ensure_no_owner(&new_owner); @@ -620,7 +620,7 @@ mod multisig { /// by `confirmer`. fn confirm_by_caller( &mut self, - confirmer: AccountId, + confirmer: H160, transaction: TransactionId, ) -> ConfirmationStatus { let mut count = self.confirmation_count.get(transaction).unwrap_or(0); @@ -652,7 +652,7 @@ mod multisig { /// Get the index of `owner` in `self.owners`. /// Panics if `owner` is not found in `self.owners`. - fn owner_index(&self, owner: &AccountId) -> u32 { + fn owner_index(&self, owner: &H160) -> u32 { self.owners.iter().position(|x| *x == *owner).expect( "This is only called after it was already verified that the id is actually an owner.", @@ -682,7 +682,7 @@ mod multisig { /// Remove all confirmation state associated with `owner`. /// Also adjusts the `self.confirmation_count` variable. - fn clean_owner_confirmations(&mut self, owner: &AccountId) { + fn clean_owner_confirmations(&mut self, owner: &H160) { for trans_id in &self.transaction_list.transactions { let key = (*trans_id, *owner); if self.confirmations.contains(key) { @@ -717,16 +717,16 @@ mod multisig { /// Panic if the sender is not this wallet. fn ensure_from_wallet(&self) { - assert_eq!(self.env().caller(), self.env().account_id()); + assert_eq!(self.env().caller(), self.env().address()); } /// Panic if `owner` is not an owner, - fn ensure_owner(&self, owner: &AccountId) { + fn ensure_owner(&self, owner: &H160) { assert!(self.is_owner.contains(owner)); } /// Panic if `owner` is an owner. - fn ensure_no_owner(&self, owner: &AccountId) { + fn ensure_no_owner(&self, owner: &H160) { assert!(!self.is_owner.contains(owner)); } } @@ -745,7 +745,7 @@ mod multisig { test, }; - const WALLET: [u8; 32] = [7; 32]; + const WALLET: [u8; 20] = [7; 20]; impl Transaction { fn change_requirement(requirement: u32) -> Self { @@ -754,22 +754,22 @@ mod multisig { // Multisig::change_requirement() Self { - callee: AccountId::from(WALLET), + callee: H160::from(WALLET), selector: ink::selector_bytes!("change_requirement"), input: call_args.encode(), - transferred_value: 0, + transferred_value: U256::zero(), ref_time_limit: 1000000, allow_reentry: false, } } } - fn set_caller(sender: AccountId) { - ink::env::test::set_caller::(sender); + fn set_caller(sender: H160) { + ink::env::test::set_caller(sender); } fn set_from_wallet() { - let callee = AccountId::from(WALLET); + let callee = H160::from(WALLET); set_caller(callee); } @@ -783,14 +783,14 @@ mod multisig { set_caller(accounts.django); } - fn default_accounts() -> test::DefaultAccounts { - ink::env::test::default_accounts::() + fn default_accounts() -> test::DefaultAccounts { + ink::env::test::default_accounts() } fn build_contract() -> Multisig { // Set the contract's address as `WALLET`. - let callee: AccountId = AccountId::from(WALLET); - ink::env::test::set_callee::(callee); + let callee: H160 = H160::from(WALLET); + ink::env::test::set_callee(callee); let accounts = default_accounts(); let owners = vec![accounts.alice, accounts.bob, accounts.eve]; diff --git a/payment-channel/Cargo.toml b/payment-channel/Cargo.toml index 997dc257..51cac5e2 100755 --- a/payment-channel/Cargo.toml +++ b/payment-channel/Cargo.toml @@ -1,16 +1,16 @@ [package] name = "payment_channel" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } +sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] -hex-literal = { version = "0.4.1" } -sp-core = { version = "21.0.0", default-features = false } +hex-literal = "1" [lib] path = "lib.rs" @@ -19,7 +19,6 @@ path = "lib.rs" default = ["std"] std = [ "ink/std", - "sp-core/std", ] ink-as-dependency = [] diff --git a/payment-channel/lib.rs b/payment-channel/lib.rs index 877d0393..66c88e27 100755 --- a/payment-channel/lib.rs +++ b/payment-channel/lib.rs @@ -24,7 +24,7 @@ //! //! ### Deposits //! -//! The creator of the contract, i.e the `sender`, can deposit funds to the payment +//! The creator of the contract, i.e. the `sender`, can deposit funds to the payment //! channel while creating the payment channel. Any subsequent deposits can be made by //! transferring funds to the contract's address. //! @@ -41,21 +41,25 @@ #[ink::contract] mod payment_channel { + use ink::{ + H160, + U256, + }; /// Struct for storing the payment channel details. - /// The creator of the contract, i.e the `sender`, can deposit funds to the payment + /// The creator of the contract, i.e. the `sender`, can deposit funds to the payment /// channel while deploying the contract. #[ink(storage)] pub struct PaymentChannel { - /// The `AccountId` of the sender of the payment channel. - sender: AccountId, - /// The `AccountId` of the recipient of the payment channel. - recipient: AccountId, + /// The `H160` of the sender of the payment channel. + sender: H160, + /// The `H160` of the recipient of the payment channel. + recipient: H160, /// The `Timestamp` at which the contract expires. The field is optional. /// The contract never expires if set to `None`. expiration: Option, /// The `Amount` withdrawn by the recipient. - withdrawn: Balance, + withdrawn: U256, /// The `Timestamp` which will be added to the current time when the sender /// wishes to close the channel. This will be set at the time of contract /// instantiation. @@ -71,7 +75,7 @@ mod payment_channel { /// Returned if caller is not the `recipient` while required to. CallerIsNotRecipient, /// Returned if the requested withdrawal amount is less than the amount - /// that is already already withdrawn. + /// that is already withdrawn. AmountIsLessThanWithdrawn, /// Returned if the requested transfer failed. This can be the case if the /// contract does not have sufficient free funds or if the transfer would @@ -104,12 +108,12 @@ mod payment_channel { /// this. `sender` will be able to claim the remaining balance by calling /// `claim_timeout` after `expiration` has passed. #[ink(constructor)] - pub fn new(recipient: AccountId, close_duration: Timestamp) -> Self { + pub fn new(recipient: H160, close_duration: Timestamp) -> Self { Self { sender: Self::env().caller(), recipient, expiration: None, - withdrawn: 0, + withdrawn: 0.into(), close_duration, } } @@ -118,13 +122,13 @@ mod payment_channel { /// `amount` will be sent to the `recipient` and the remainder will go /// back to the `sender`. #[ink(message)] - pub fn close(&mut self, amount: Balance, signature: [u8; 65]) -> Result<()> { + pub fn close(&mut self, amount: U256, signature: [u8; 65]) -> Result<()> { self.close_inner(amount, signature)?; self.env().terminate_contract(self.sender); } /// We split this out in order to make testing `close` simpler. - fn close_inner(&mut self, amount: Balance, signature: [u8; 65]) -> Result<()> { + fn close_inner(&mut self, amount: U256, signature: [u8; 65]) -> Result<()> { if self.env().caller() != self.recipient { return Err(Error::CallerIsNotRecipient) } @@ -194,7 +198,7 @@ mod payment_channel { /// The `recipient` can withdraw the funds from the channel at any time. #[ink(message)] - pub fn withdraw(&mut self, amount: Balance, signature: [u8; 65]) -> Result<()> { + pub fn withdraw(&mut self, amount: U256, signature: [u8; 65]) -> Result<()> { if self.env().caller() != self.recipient { return Err(Error::CallerIsNotRecipient) } @@ -223,13 +227,13 @@ mod payment_channel { /// Returns the `sender` of the contract. #[ink(message)] - pub fn get_sender(&self) -> AccountId { + pub fn get_sender(&self) -> H160 { self.sender } /// Returns the `recipient` of the contract. #[ink(message)] - pub fn get_recipient(&self) -> AccountId { + pub fn get_recipient(&self) -> H160 { self.recipient } @@ -241,7 +245,7 @@ mod payment_channel { /// Returns the `withdrawn` amount of the contract. #[ink(message)] - pub fn get_withdrawn(&self) -> Balance { + pub fn get_withdrawn(&self) -> U256 { self.withdrawn } @@ -253,15 +257,15 @@ mod payment_channel { /// Returns the `balance` of the contract. #[ink(message)] - pub fn get_balance(&self) -> Balance { + pub fn get_balance(&self) -> U256 { self.env().balance() } } #[ink(impl)] impl PaymentChannel { - fn is_signature_valid(&self, amount: Balance, signature: [u8; 65]) -> bool { - let encodable = (self.env().account_id(), amount); + fn is_signature_valid(&self, amount: U256, signature: [u8; 65]) -> bool { + let encodable = (self.env().address(), amount); let mut message = ::Type::default(); ink::env::hash_encoded::( @@ -272,13 +276,14 @@ mod payment_channel { let mut pub_key = [0; 33]; ink::env::ecdsa_recover(&signature, &message, &mut pub_key) .unwrap_or_else(|err| panic!("recover failed: {err:?}")); - let mut signature_account_id = [0; 32]; + let mut signature_account_id = [0u8; 32]; ::hash( &pub_key, &mut signature_account_id, ); - self.recipient == signature_account_id.into() + self.recipient + == ink::primitives::AccountIdMapper::to_address(&signature_account_id) } } @@ -292,22 +297,19 @@ mod payment_channel { Pair, }; - fn default_accounts( - ) -> ink::env::test::DefaultAccounts { - ink::env::test::default_accounts::() + fn default_accounts() -> ink::env::test::DefaultAccounts { + ink::env::test::default_accounts() } - fn set_next_caller(caller: AccountId) { - ink::env::test::set_caller::(caller); + fn set_next_caller(caller: H160) { + ink::env::test::set_caller(caller); } - fn set_account_balance(account: AccountId, balance: Balance) { - ink::env::test::set_account_balance::( - account, balance, - ); + fn set_account_balance(account: H160, balance: U256) { + ink::env::test::set_account_balance(account, balance); } - fn get_account_balance(account: AccountId) -> Balance { + fn get_account_balance(account: H160) -> U256 { ink::env::test::get_account_balance::(account) .expect("Cannot get account balance") } @@ -324,7 +326,7 @@ mod payment_channel { + since_the_epoch.subsec_nanos() as u64 / 1_000_000_000 } - fn get_dan() -> AccountId { + fn get_dan() -> H160 { // Use Dan's seed // `subkey inspect //Dan --scheme Ecdsa --output-type json | jq .secretSeed` let seed = hex_literal::hex!( @@ -340,17 +342,17 @@ mod payment_channel { &compressed_pub_key, &mut account_id, ); - account_id.into() + ink::primitives::AccountIdMapper::to_address(&account_id) } - fn contract_id() -> AccountId { + fn contract_id() -> H160 { let accounts = default_accounts(); let contract_id = accounts.charlie; - ink::env::test::set_callee::(contract_id); + ink::env::test::set_callee(contract_id); contract_id } - fn sign(contract_id: AccountId, amount: Balance) -> [u8; 65] { + fn sign(contract_id: H160, amount: U256) -> [u8; 65] { let encodable = (contract_id, amount); let mut hash = ::Type::default(); // 256-bit buffer @@ -371,9 +373,9 @@ mod payment_channel { fn test_deposit() { // given let accounts = default_accounts(); - let initial_balance = 10_000; + let initial_balance = 10_000.into(); let close_duration = 360_000; - let mock_deposit_value = 1_000; + let mock_deposit_value = 1_000.into(); set_account_balance(accounts.alice, initial_balance); set_account_balance(accounts.bob, initial_balance); @@ -396,9 +398,9 @@ mod payment_channel { let accounts = default_accounts(); let dan = get_dan(); let close_duration = 360_000; - let mock_deposit_value = 1_000; - let amount = 500; - let initial_balance = 10_000; + let mock_deposit_value = 1_000.into(); + let amount = 500.into(); + let initial_balance = 10_000.into(); set_account_balance(accounts.alice, initial_balance); set_account_balance(dan, initial_balance); @@ -425,11 +427,11 @@ mod payment_channel { // given let accounts = default_accounts(); let dan = get_dan(); - let mock_deposit_value = 1_000; + let mock_deposit_value = 1_000.into(); let close_duration = 360_000; - let amount = 400; - let unexpected_amount = amount + 1; - let initial_balance = 10_000; + let amount = 400.into(); + let unexpected_amount = amount + U256::from(1); + let initial_balance = 10_000.into(); set_account_balance(accounts.alice, initial_balance); set_account_balance(dan, initial_balance); @@ -452,10 +454,10 @@ mod payment_channel { // given let accounts = default_accounts(); let dan = get_dan(); - let initial_balance = 10_000; - let mock_deposit_value = 1_000; + let initial_balance = 10_000.into(); + let mock_deposit_value = 1_000.into(); let close_duration = 360_000; - let amount = 500; + let amount = 500.into(); set_account_balance(accounts.alice, initial_balance); set_account_balance(dan, initial_balance); @@ -481,11 +483,11 @@ mod payment_channel { // given let accounts = default_accounts(); let dan = get_dan(); - let initial_balance = 10_000; + let initial_balance = 10_000.into(); let close_duration = 360_000; - let amount = 400; - let unexpected_amount = amount + 1; - let mock_deposit_value = 1_000; + let amount = 400.into(); + let unexpected_amount = amount + U256::from(1); + let mock_deposit_value = 1_000.into(); set_account_balance(accounts.alice, initial_balance); set_account_balance(dan, initial_balance); @@ -507,8 +509,8 @@ mod payment_channel { fn test_start_sender_close() { // given let accounts = default_accounts(); - let initial_balance = 10_000; - let mock_deposit_value = 1_000; + let initial_balance = 10_000.into(); + let mock_deposit_value = 1_000.into(); let close_duration = 1; set_account_balance(accounts.alice, initial_balance); set_account_balance(accounts.bob, initial_balance); @@ -533,9 +535,9 @@ mod payment_channel { fn test_claim_timeout() { // given let accounts = default_accounts(); - let initial_balance = 10_000; + let initial_balance = 10_000.into(); let close_duration = 1; - let mock_deposit_value = 1_000; + let mock_deposit_value = 1_000.into(); set_account_balance(accounts.alice, initial_balance); set_account_balance(accounts.bob, initial_balance); @@ -567,8 +569,8 @@ mod payment_channel { fn test_getters() { // given let accounts = default_accounts(); - let initial_balance = 10_000; - let mock_deposit_value = 1_000; + let initial_balance = 10_000.into(); + let mock_deposit_value = 1_000.into(); let close_duration = 360_000; set_account_balance(accounts.alice, initial_balance); set_account_balance(accounts.bob, initial_balance); @@ -584,7 +586,7 @@ mod payment_channel { assert_eq!(payment_channel.get_recipient(), accounts.bob); assert_eq!(payment_channel.get_balance(), mock_deposit_value); assert_eq!(payment_channel.get_close_duration(), close_duration); - assert_eq!(payment_channel.get_withdrawn(), 0); + assert_eq!(payment_channel.get_withdrawn(), U256::zero()); } } } diff --git a/psp22-extension/Cargo.toml b/psp22-extension/Cargo.toml index ca264390..44c39d55 100755 --- a/psp22-extension/Cargo.toml +++ b/psp22-extension/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "psp22_extension" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/psp22-extension/README.md b/psp22-extension/README.md index feab477a..40f77bb7 100644 --- a/psp22-extension/README.md +++ b/psp22-extension/README.md @@ -27,9 +27,9 @@ To integrate this example into Substrate you need to do two things: You can just copy/paste that file as a new module, e.g. `runtime/src/chain_extension.rs`. * In your runtime, use the implementation as the associated type `ChainExtension` of the - trait `pallet_contracts::Config`: + trait `pallet_revive::Config`: ```rust - impl pallet_contracts::Config for Runtime { + impl pallet_revive::Config for Runtime { … type ChainExtension = Psp22Extension; … diff --git a/psp22-extension/lib.rs b/psp22-extension/lib.rs index 3691ca28..5cec8b62 100755 --- a/psp22-extension/lib.rs +++ b/psp22-extension/lib.rs @@ -3,11 +3,10 @@ use ink::{ env::Environment, prelude::vec::Vec, + H160, + U256, }; -type DefaultAccountId = ::AccountId; -type DefaultBalance = ::Balance; - #[ink::chain_extension(extension = 13)] pub trait Psp22Extension { type ErrorCode = Psp22Error; @@ -26,55 +25,33 @@ pub trait Psp22Extension { // PSP22 interface queries #[ink(function = 0x162d)] - fn total_supply(asset_id: u32) -> Result; + fn total_supply(asset_id: u32) -> Result; #[ink(function = 0x6568)] - fn balance_of(asset_id: u32, owner: DefaultAccountId) -> Result; + fn balance_of(asset_id: u32, owner: H160) -> Result; #[ink(function = 0x4d47)] - fn allowance( - asset_id: u32, - owner: DefaultAccountId, - spender: DefaultAccountId, - ) -> Result; + fn allowance(asset_id: u32, owner: H160, spender: H160) -> Result; // PSP22 transfer #[ink(function = 0xdb20)] - fn transfer(asset_id: u32, to: DefaultAccountId, value: DefaultBalance) - -> Result<()>; + fn transfer(asset_id: u32, to: H160, value: U256) -> Result<()>; // PSP22 transfer_from #[ink(function = 0x54b3)] - fn transfer_from( - asset_id: u32, - from: DefaultAccountId, - to: DefaultAccountId, - value: DefaultBalance, - ) -> Result<()>; + fn transfer_from(asset_id: u32, from: H160, to: H160, value: U256) -> Result<()>; // PSP22 approve #[ink(function = 0xb20f)] - fn approve( - asset_id: u32, - spender: DefaultAccountId, - value: DefaultBalance, - ) -> Result<()>; + fn approve(asset_id: u32, spender: H160, value: U256) -> Result<()>; // PSP22 increase_allowance #[ink(function = 0x96d6)] - fn increase_allowance( - asset_id: u32, - spender: DefaultAccountId, - value: DefaultBalance, - ) -> Result<()>; + fn increase_allowance(asset_id: u32, spender: H160, value: U256) -> Result<()>; // PSP22 decrease_allowance #[ink(function = 0xfecb)] - fn decrease_allowance( - asset_id: u32, - spender: DefaultAccountId, - value: DefaultBalance, - ) -> Result<()>; + fn decrease_allowance(asset_id: u32, spender: H160, value: U256) -> Result<()>; } #[derive(Debug, PartialEq, Eq)] @@ -110,11 +87,12 @@ impl Environment for CustomEnvironment { const MAX_EVENT_TOPICS: usize = ::MAX_EVENT_TOPICS; - type AccountId = DefaultAccountId; - type Balance = DefaultBalance; + type AccountId = ::AccountId; + type Balance = ::Balance; type Hash = ::Hash; type Timestamp = ::Timestamp; type BlockNumber = ::BlockNumber; + type EventRecord = ::EventRecord; type ChainExtension = crate::Psp22Extension; } @@ -125,6 +103,10 @@ mod psp22_ext { Result, Vec, }; + use ink::{ + H160, + U256, + }; /// A chain extension which implements the PSP-22 fungible token standard. /// For more details see @@ -163,13 +145,13 @@ mod psp22_ext { /// Returns the total token supply of the specified asset. #[ink(message, selector = 0x162df8c2)] - pub fn total_supply(&self, asset_id: u32) -> Result { + pub fn total_supply(&self, asset_id: u32) -> Result { self.env().extension().total_supply(asset_id) } /// Returns the account balance for the specified asset & owner. #[ink(message, selector = 0x6568382f)] - pub fn balance_of(&self, asset_id: u32, owner: AccountId) -> Result { + pub fn balance_of(&self, asset_id: u32, owner: H160) -> Result { self.env().extension().balance_of(asset_id, owner) } @@ -179,9 +161,9 @@ mod psp22_ext { pub fn allowance( &self, asset_id: u32, - owner: AccountId, - spender: AccountId, - ) -> Result { + owner: H160, + spender: H160, + ) -> Result { self.env().extension().allowance(asset_id, owner, spender) } @@ -190,12 +172,7 @@ mod psp22_ext { /// Transfers `value` amount of specified asset from the caller's account to the /// account `to`. #[ink(message, selector = 0xdb20f9f5)] - pub fn transfer( - &mut self, - asset_id: u32, - to: AccountId, - value: Balance, - ) -> Result<()> { + pub fn transfer(&mut self, asset_id: u32, to: H160, value: U256) -> Result<()> { self.env().extension().transfer(asset_id, to, value) } @@ -207,9 +184,9 @@ mod psp22_ext { pub fn transfer_from( &mut self, asset_id: u32, - from: AccountId, - to: AccountId, - value: Balance, + from: H160, + to: H160, + value: U256, ) -> Result<()> { self.env() .extension() @@ -224,8 +201,8 @@ mod psp22_ext { pub fn approve( &mut self, asset_id: u32, - spender: AccountId, - value: Balance, + spender: H160, + value: U256, ) -> Result<()> { self.env().extension().approve(asset_id, spender, value) } @@ -238,8 +215,8 @@ mod psp22_ext { pub fn increase_allowance( &mut self, asset_id: u32, - spender: AccountId, - value: Balance, + spender: H160, + value: U256, ) -> Result<()> { self.env() .extension() @@ -254,8 +231,8 @@ mod psp22_ext { pub fn decrease_allowance( &mut self, asset_id: u32, - spender: AccountId, - value: Balance, + spender: H160, + value: U256, ) -> Result<()> { self.env() .extension() diff --git a/psp22-extension/runtime/psp22-extension-example.rs b/psp22-extension/runtime/psp22-extension-example.rs index aa11d819..29ee57d3 100644 --- a/psp22-extension/runtime/psp22-extension-example.rs +++ b/psp22-extension/runtime/psp22-extension-example.rs @@ -1,3 +1,4 @@ +// todo use codec::{ Decode, Encode, @@ -24,7 +25,7 @@ use pallet_assets::{ self, WeightInfo, }; -use pallet_contracts::chain_extension::{ +use pallet_revive::chain_extension::{ ChainExtension, Environment, Ext, @@ -151,7 +152,7 @@ fn metadata( env: Environment, ) -> Result<(), DispatchError> where - T: pallet_assets::Config + pallet_contracts::Config, + T: pallet_assets::Config + pallet_revive::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, E: Ext, { @@ -187,7 +188,7 @@ fn query( env: Environment, ) -> Result<(), DispatchError> where - T: pallet_assets::Config + pallet_contracts::Config, + T: pallet_assets::Config + pallet_revive::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, E: Ext, { @@ -225,18 +226,18 @@ where fn transfer(env: Environment) -> Result<(), DispatchError> where - T: pallet_assets::Config + pallet_contracts::Config, + T: pallet_assets::Config + pallet_revive::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, E: Ext, { let mut env = env.buf_in_buf_out(); let base_weight = ::WeightInfo::transfer(); - // debug_message weight is a good approximation of the additional overhead of going - // from contract layer to substrate layer. + // `transferred_value` weight is a good approximation of the additional overhead of + // going from contract layer to substrate layer. let overhead = Weight::from_ref_time( - ::Schedule::get() + ::Schedule::get() .host_fn_weights - .debug_message, + .transferred_value, ); let charged_weight = env.charge_weight(base_weight.saturating_add(overhead))?; trace!( @@ -267,18 +268,18 @@ where fn transfer_from(env: Environment) -> Result<(), DispatchError> where - T: pallet_assets::Config + pallet_contracts::Config, + T: pallet_assets::Config + pallet_revive::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, E: Ext, { let mut env = env.buf_in_buf_out(); let base_weight = ::WeightInfo::transfer(); - // debug_message weight is a good approximation of the additional overhead of going - // from contract layer to substrate layer. + // `transferred_value` weight is a good approximation of the additional overhead of + // going from contract layer to substrate layer. let overhead = Weight::from_ref_time( - ::Schedule::get() + ::Schedule::get() .host_fn_weights - .debug_message, + .transferred_value, ); let charged_amount = env.charge_weight(base_weight.saturating_add(overhead))?; trace!( @@ -308,18 +309,18 @@ where fn approve(env: Environment) -> Result<(), DispatchError> where - T: pallet_assets::Config + pallet_contracts::Config, + T: pallet_assets::Config + pallet_revive::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, E: Ext, { let mut env = env.buf_in_buf_out(); let base_weight = ::WeightInfo::approve_transfer(); - // debug_message weight is a good approximation of the additional overhead of going - // from contract layer to substrate layer. + // `transferred_value` weight is a good approximation of the additional overhead of + // going from contract layer to substrate layer. let overhead = Weight::from_ref_time( - ::Schedule::get() + ::Schedule::get() .host_fn_weights - .debug_message, + .transferred_value, ); let charged_weight = env.charge_weight(base_weight.saturating_add(overhead))?; trace!( @@ -346,7 +347,7 @@ where fn decrease_allowance(env: Environment) -> Result<(), DispatchError> where - T: pallet_assets::Config + pallet_contracts::Config, + T: pallet_assets::Config + pallet_revive::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, E: Ext, { @@ -358,12 +359,12 @@ where let base_weight = ::WeightInfo::cancel_approval() .saturating_add(::WeightInfo::approve_transfer()); - // debug_message weight is a good approximation of the additional overhead of going - // from contract layer to substrate layer. + // `transferred_value` weight is a good approximation of the additional overhead of + // going from contract layer to substrate layer. let overhead = Weight::from_ref_time( - ::Schedule::get() + ::Schedule::get() .host_fn_weights - .debug_message, + .transferred_value, ); let charged_weight = env.charge_weight(base_weight.saturating_add(overhead))?; trace!( @@ -417,7 +418,7 @@ where impl ChainExtension for Psp22Extension where - T: pallet_assets::Config + pallet_contracts::Config, + T: pallet_assets::Config + pallet_revive::Config, ::AccountId: UncheckedFrom<::Hash> + AsRef<[u8]>, { fn call( diff --git a/rand-extension/Cargo.toml b/rand-extension/Cargo.toml index cf2846a7..eb714463 100755 --- a/rand-extension/Cargo.toml +++ b/rand-extension/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "rand_extension" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/rand-extension/README.md b/rand-extension/README.md index 19d4cc48..f3e75b31 100644 --- a/rand-extension/README.md +++ b/rand-extension/README.md @@ -21,9 +21,9 @@ To integrate this example into Substrate you need to do two things: You can just copy/paste the content of that file into e.g. your `runtime/src/lib.rs`. * Use the implementation as the associated type `ChainExtension` of the trait - `pallet_contracts::Config`: + `pallet_revive::Config`: ```rust - impl pallet_contracts::Config for Runtime { + impl pallet_revive::Config for Runtime { … type ChainExtension = FetchRandomExtension; … diff --git a/rand-extension/lib.rs b/rand-extension/lib.rs index 861c9f96..c96cc498 100755 --- a/rand-extension/lib.rs +++ b/rand-extension/lib.rs @@ -47,6 +47,7 @@ impl Environment for CustomEnvironment { type Hash = ::Hash; type BlockNumber = ::BlockNumber; type Timestamp = ::Timestamp; + type EventRecord = ::EventRecord; type ChainExtension = FetchRandom; } diff --git a/rand-extension/runtime/chain-extension-example.rs b/rand-extension/runtime/chain-extension-example.rs index 4d4a4a9b..9cbd865a 100644 --- a/rand-extension/runtime/chain-extension-example.rs +++ b/rand-extension/runtime/chain-extension-example.rs @@ -3,7 +3,7 @@ use frame_support::log::{ error, trace, }; -use pallet_contracts::chain_extension::{ +use pallet_revive::chain_extension::{ ChainExtension, Environment, Ext, diff --git a/runtime-call-contract/Cargo.toml b/runtime-call-contract/Cargo.toml index 152f1c0d..0ec0cdb9 100644 --- a/runtime-call-contract/Cargo.toml +++ b/runtime-call-contract/Cargo.toml @@ -5,36 +5,39 @@ members = ["sandbox-runtime", "traits"] authors = ["Use Ink "] edition = "2021" homepage = "https://use.ink" -keywords = ["wasm", "ink", "webassembly", "blockchain", "edsl"] license = "Apache-2.0" repository = "https://github.com/use-ink/ink" +keywords = ["polkavm", "ink", "riscv", "blockchain", "edsl"] +publish = false [workspace.dependencies] -frame-support = { version = "32.0.0", default-features = false } -frame-system = { version = "32.0.0", default-features = false } -pallet-contracts = { version = "31.0.0", default-features = false } -sp-runtime = { version = "35.0.0", default-features = false } -codec = { package = "parity-scale-codec", version = "3.6.9", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } +frame-system = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } +pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } +pallet-revive = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } +sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } +# todo +codec = { package = "parity-scale-codec", version = "3.7.4", default-features = false } scale-info = { version = "2.11.1", default-features = false } [package] name = "runtime-call-contract" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } flipper-traits = { path = "traits", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0", features = ["sandbox"] } +ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } sandbox-runtime = { path = "sandbox-runtime", default-features = false } -scale-value = "0.14.1" +scale-value = "0.18.0" # can't use workspace dependency because of `cargo-contract` build not # working with workspace dependencies -frame-support = { version = "32.0.0", default-features = false } +frame-support = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [lib] path = "lib.rs" diff --git a/runtime-call-contract/e2e_tests.rs b/runtime-call-contract/e2e_tests.rs index f4b73396..0a9ae532 100644 --- a/runtime-call-contract/e2e_tests.rs +++ b/runtime-call-contract/e2e_tests.rs @@ -29,6 +29,7 @@ async fn instantiate_and_get(mut client: Client) -> E2EResul .dry_run() .await?; let gas_required = flip_dry_run.exec_result.gas_required; + // todo do same thing as above with storage_deposit_limit // call pallet dispatchable client @@ -37,13 +38,16 @@ async fn instantiate_and_get(mut client: Client) -> E2EResul "ContractCaller", "contract_call_flip", vec![ - scale_value::Value::from_bytes(contract.account_id), - scale_value::serde::to_value(frame_support::weights::Weight::from_parts( - gas_required.ref_time(), - gas_required.proof_size(), - )) + ink_e2e::subxt::dynamic::Value::from_bytes(contract.addr), + ink_e2e::subxt::ext::scale_value::serde::to_value( + frame_support::weights::Weight::from_parts( + gas_required.ref_time(), + gas_required.proof_size(), + ), + ) .unwrap(), - scale_value::serde::to_value(None::).unwrap(), + // todo + ink_e2e::subxt::ext::scale_value::serde::to_value(0u128).unwrap(), ], ) .await diff --git a/runtime-call-contract/sandbox-runtime/Cargo.toml b/runtime-call-contract/sandbox-runtime/Cargo.toml index fabffd81..771e6192 100644 --- a/runtime-call-contract/sandbox-runtime/Cargo.toml +++ b/runtime-call-contract/sandbox-runtime/Cargo.toml @@ -10,7 +10,7 @@ repository.workspace = true [dependencies] ink_sandbox = { path = "../../../../crates/e2e/sandbox" } -pallet-contract-caller = { path = "pallet-contract-caller", default-features = false } +pallet-revive-caller = { path = "pallet-revive-caller", default-features = false } frame-support = { workspace = true } frame-system = { workspace = true } codec = { workspace = true } @@ -19,5 +19,5 @@ scale-info = { workspace = true } [features] default = ["std"] std = [ - "pallet-contract-caller/std", + "pallet-revive-caller/std", ] diff --git a/runtime-call-contract/sandbox-runtime/src/lib.rs b/runtime-call-contract/sandbox-runtime/src/lib.rs index 78a39d89..65feb89b 100644 --- a/runtime-call-contract/sandbox-runtime/src/lib.rs +++ b/runtime-call-contract/sandbox-runtime/src/lib.rs @@ -5,7 +5,7 @@ #![cfg_attr(not(feature = "std"), no_std)] ink_sandbox::create_sandbox!(ContractCallerSandbox, ContractCallerSandboxRuntime, (), (), { - ContractCaller: pallet_contract_caller, + ContractCaller: pallet_revive_caller, }); -impl pallet_contract_caller::Config for ContractCallerSandboxRuntime {} +impl pallet_revive_caller::Config for ContractCallerSandboxRuntime {} diff --git a/runtime-call-contract/traits/Cargo.toml b/runtime-call-contract/traits/Cargo.toml index 101fd590..a760fa8a 100644 --- a/runtime-call-contract/traits/Cargo.toml +++ b/runtime-call-contract/traits/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "flipper-traits" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/trait-dyn-cross-contract-calls/Cargo.toml b/trait-dyn-cross-contract-calls/Cargo.toml index 77dc1219..b33f767b 100644 --- a/trait-dyn-cross-contract-calls/Cargo.toml +++ b/trait-dyn-cross-contract-calls/Cargo.toml @@ -1,17 +1,17 @@ [package] name = "trait-incrementer-caller" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } dyn-traits = { path = "./traits", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } trait-incrementer = { path = "./contracts/incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml index 64db9bfc..088a7a5f 100644 --- a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml +++ b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "trait-incrementer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../../crates/ink", default-features = false } dyn-traits = { path = "../../traits", default-features = false } diff --git a/trait-dyn-cross-contract-calls/lib.rs b/trait-dyn-cross-contract-calls/lib.rs index d49911ba..12d1cdf2 100644 --- a/trait-dyn-cross-contract-calls/lib.rs +++ b/trait-dyn-cross-contract-calls/lib.rs @@ -21,7 +21,7 @@ pub mod caller { impl Caller { /// Creates a new caller smart contract around the `incrementer` account id. #[ink(constructor)] - pub fn new(incrementer: AccountId) -> Self { + pub fn new(incrementer: ink::H160) -> Self { Self { incrementer: incrementer.into(), } @@ -89,7 +89,7 @@ mod e2e_tests { .expect("instantiate failed"); let incrementer_call = incrementer.call_builder::(); - let mut constructor = CallerRef::new(incrementer.account_id.clone()); + let mut constructor = CallerRef::new(incrementer.addr.clone()); let caller = client .instantiate( diff --git a/trait-dyn-cross-contract-calls/traits/Cargo.toml b/trait-dyn-cross-contract-calls/traits/Cargo.toml index 1685ae46..646ff3c5 100644 --- a/trait-dyn-cross-contract-calls/traits/Cargo.toml +++ b/trait-dyn-cross-contract-calls/traits/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "dyn-traits" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/trait-erc20/Cargo.toml b/trait-erc20/Cargo.toml index 56d9d63d..fc0c2f57 100644 --- a/trait-erc20/Cargo.toml +++ b/trait-erc20/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "trait_erc20" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/trait-erc20/lib.rs b/trait-erc20/lib.rs index 56c9c739..3d838b39 100644 --- a/trait-erc20/lib.rs +++ b/trait-erc20/lib.rs @@ -2,7 +2,11 @@ #[ink::contract] mod erc20 { - use ink::storage::Mapping; + use ink::{ + storage::Mapping, + H160, + U256, + }; /// The ERC-20 error types. #[derive(Debug, PartialEq, Eq)] @@ -22,33 +26,28 @@ mod erc20 { pub trait BaseErc20 { /// Returns the total token supply. #[ink(message)] - fn total_supply(&self) -> Balance; + fn total_supply(&self) -> U256; /// Returns the account balance for the specified `owner`. #[ink(message)] - fn balance_of(&self, owner: AccountId) -> Balance; + fn balance_of(&self, owner: H160) -> U256; /// Returns the amount which `spender` is still allowed to withdraw from `owner`. #[ink(message)] - fn allowance(&self, owner: AccountId, spender: AccountId) -> Balance; + fn allowance(&self, owner: H160, spender: H160) -> U256; /// Transfers `value` amount of tokens from the caller's account to account `to`. #[ink(message)] - fn transfer(&mut self, to: AccountId, value: Balance) -> Result<()>; + fn transfer(&mut self, to: H160, value: U256) -> Result<()>; /// Allows `spender` to withdraw from the caller's account multiple times, up to /// the `value` amount. #[ink(message)] - fn approve(&mut self, spender: AccountId, value: Balance) -> Result<()>; + fn approve(&mut self, spender: H160, value: U256) -> Result<()>; /// Transfers `value` tokens on the behalf of `from` to the account `to`. #[ink(message)] - fn transfer_from( - &mut self, - from: AccountId, - to: AccountId, - value: Balance, - ) -> Result<()>; + fn transfer_from(&mut self, from: H160, to: H160, value: U256) -> Result<()>; } /// A simple ERC-20 contract. @@ -56,23 +55,23 @@ mod erc20 { #[derive(Default)] pub struct Erc20 { /// Total token supply. - total_supply: Balance, + total_supply: U256, /// Mapping from owner to number of owned token. - balances: Mapping, + balances: Mapping, /// Mapping of the token amount which an account is allowed to withdraw /// from another account. - allowances: Mapping<(AccountId, AccountId), Balance>, + allowances: Mapping<(H160, H160), U256>, } /// Event emitted when a token transfer occurs. #[ink(event)] pub struct Transfer { #[ink(topic)] - from: Option, + from: Option, #[ink(topic)] - to: Option, + to: Option, #[ink(topic)] - value: Balance, + value: U256, } /// Event emitted when an approval occurs that `spender` is allowed to withdraw @@ -80,17 +79,17 @@ mod erc20 { #[ink(event)] pub struct Approval { #[ink(topic)] - owner: AccountId, + owner: H160, #[ink(topic)] - spender: AccountId, + spender: H160, #[ink(topic)] - value: Balance, + value: U256, } impl Erc20 { /// Creates a new ERC-20 contract with the specified initial supply. #[ink(constructor)] - pub fn new(total_supply: Balance) -> Self { + pub fn new(total_supply: U256) -> Self { let mut balances = Mapping::default(); let caller = Self::env().caller(); balances.insert(caller, &total_supply); @@ -110,7 +109,7 @@ mod erc20 { impl BaseErc20 for Erc20 { /// Returns the total token supply. #[ink(message)] - fn total_supply(&self) -> Balance { + fn total_supply(&self) -> U256 { self.total_supply } @@ -118,7 +117,7 @@ mod erc20 { /// /// Returns `0` if the account is non-existent. #[ink(message)] - fn balance_of(&self, owner: AccountId) -> Balance { + fn balance_of(&self, owner: H160) -> U256 { self.balance_of_impl(&owner) } @@ -126,7 +125,7 @@ mod erc20 { /// /// Returns `0` if no allowance has been set. #[ink(message)] - fn allowance(&self, owner: AccountId, spender: AccountId) -> Balance { + fn allowance(&self, owner: H160, spender: H160) -> U256 { self.allowance_impl(&owner, &spender) } @@ -139,7 +138,7 @@ mod erc20 { /// Returns `InsufficientBalance` error if there are not enough tokens on /// the caller's account balance. #[ink(message)] - fn transfer(&mut self, to: AccountId, value: Balance) -> Result<()> { + fn transfer(&mut self, to: H160, value: U256) -> Result<()> { let from = self.env().caller(); self.transfer_from_to(&from, &to, value) } @@ -152,7 +151,7 @@ mod erc20 { /// /// An `Approval` event is emitted. #[ink(message)] - fn approve(&mut self, spender: AccountId, value: Balance) -> Result<()> { + fn approve(&mut self, spender: H160, value: U256) -> Result<()> { let owner = self.env().caller(); self.allowances.insert((&owner, &spender), &value); self.env().emit_event(Approval { @@ -178,12 +177,7 @@ mod erc20 { /// Returns `InsufficientBalance` error if there are not enough tokens on /// the account balance of `from`. #[ink(message)] - fn transfer_from( - &mut self, - from: AccountId, - to: AccountId, - value: Balance, - ) -> Result<()> { + fn transfer_from(&mut self, from: H160, to: H160, value: U256) -> Result<()> { let caller = self.env().caller(); let allowance = self.allowance_impl(&from, &caller); if allowance < value { @@ -207,9 +201,9 @@ mod erc20 { /// # Note /// /// Prefer to call this method over `balance_of` since this - /// works using references which are more efficient in Wasm. + /// works using references which are more efficient. #[inline] - fn balance_of_impl(&self, owner: &AccountId) -> Balance { + fn balance_of_impl(&self, owner: &H160) -> U256 { self.balances.get(owner).unwrap_or_default() } @@ -220,9 +214,9 @@ mod erc20 { /// # Note /// /// Prefer to call this method over `allowance` since this - /// works using references which are more efficient in Wasm. + /// works using references which are more efficient. #[inline] - fn allowance_impl(&self, owner: &AccountId, spender: &AccountId) -> Balance { + fn allowance_impl(&self, owner: &H160, spender: &H160) -> U256 { self.allowances.get((owner, spender)).unwrap_or_default() } @@ -236,9 +230,9 @@ mod erc20 { /// the caller's account balance. fn transfer_from_to( &mut self, - from: &AccountId, - to: &AccountId, - value: Balance, + from: &H160, + to: &H160, + value: U256, ) -> Result<()> { let from_balance = self.balance_of_impl(from); if from_balance < value { @@ -275,9 +269,9 @@ mod erc20 { fn assert_transfer_event( event: &ink::env::test::EmittedEvent, - expected_from: Option, - expected_to: Option, - expected_value: Balance, + expected_from: Option, + expected_to: Option, + expected_value: U256, ) { let decoded_event = ::decode(&mut &event.data[..]) @@ -309,8 +303,7 @@ mod erc20 { let mut expected_topics = Vec::new(); expected_topics.push( - ink::blake2x256!("Transfer(Option,Option,Balance)") - .into(), + ink::blake2x256!("Transfer(Option,Option,U256)").into(), ); if let Some(from) = expected_from { expected_topics.push(encoded_into_hash(from)); @@ -337,7 +330,8 @@ mod erc20 { #[ink::test] fn new_works() { // Constructor works. - let initial_supply = 100; + set_caller(H160::from([0x01; 20])); + let initial_supply = 100.into(); let erc20 = Erc20::new(initial_supply); // The `BaseErc20` trait has indeed been implemented. @@ -350,8 +344,8 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(H160::from([0x01; 20])), + 100.into(), ); } @@ -359,56 +353,58 @@ mod erc20 { #[ink::test] fn total_supply_works() { // Constructor works. - let initial_supply = 100; + set_caller(H160::from([0x01; 20])); + let initial_supply = 100.into(); let erc20 = Erc20::new(initial_supply); // Transfer event triggered during initial construction. let emitted_events = ink::env::test::recorded_events().collect::>(); assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(H160::from([0x01; 20])), + 100.into(), ); // Get the token total supply. - assert_eq!(erc20.total_supply(), 100); + assert_eq!(erc20.total_supply(), 100.into()); } /// Get the actual balance of an account. #[ink::test] fn balance_of_works() { + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + // Constructor works - let initial_supply = 100; + let initial_supply = 100.into(); let erc20 = Erc20::new(initial_supply); // Transfer event triggered during initial construction let emitted_events = ink::env::test::recorded_events().collect::>(); assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); - let accounts = - ink::env::test::default_accounts::(); // Alice owns all the tokens on contract instantiation - assert_eq!(erc20.balance_of(accounts.alice), 100); + assert_eq!(erc20.balance_of(accounts.alice), 100.into()); // Bob does not owns tokens - assert_eq!(erc20.balance_of(accounts.bob), 0); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); } #[ink::test] fn transfer_works() { + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + // Constructor works. - let initial_supply = 100; + let initial_supply = 100.into(); let mut erc20 = Erc20::new(initial_supply); // Transfer event triggered during initial construction. - let accounts = - ink::env::test::default_accounts::(); - - assert_eq!(erc20.balance_of(accounts.bob), 0); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); // Alice transfers 10 tokens to Bob. - assert_eq!(erc20.transfer(accounts.bob, 10), Ok(())); + assert_eq!(erc20.transfer(accounts.bob, U256::from(10)), Ok(())); // Bob owns 10 tokens. - assert_eq!(erc20.balance_of(accounts.bob), 10); + assert_eq!(erc20.balance_of(accounts.bob), U256::from(10)); let emitted_events = ink::env::test::recorded_events().collect::>(); assert_eq!(emitted_events.len(), 2); @@ -416,39 +412,40 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); // Check the second transfer event relating to the actual trasfer. assert_transfer_event( &emitted_events[1], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x02; 32])), - 10, + Some(accounts.alice), + Some(accounts.bob), + 10.into(), ); } #[ink::test] fn invalid_transfer_should_fail() { // Constructor works. - let initial_supply = 100; + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + + let initial_supply = 100.into(); let mut erc20 = Erc20::new(initial_supply); - let accounts = - ink::env::test::default_accounts::(); - assert_eq!(erc20.balance_of(accounts.bob), 0); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); // Set Bob as caller set_caller(accounts.bob); - // Bob fails to transfers 10 tokens to Eve. + // Bob fails to transfer 10 tokens to Eve. assert_eq!( - erc20.transfer(accounts.eve, 10), + erc20.transfer(accounts.eve, 10.into()), Err(Error::InsufficientBalance) ); // Alice owns all the tokens. - assert_eq!(erc20.balance_of(accounts.alice), 100); - assert_eq!(erc20.balance_of(accounts.bob), 0); - assert_eq!(erc20.balance_of(accounts.eve), 0); + assert_eq!(erc20.balance_of(accounts.alice), 100.into()); + assert_eq!(erc20.balance_of(accounts.bob), U256::zero()); + assert_eq!(erc20.balance_of(accounts.eve), U256::zero()); // Transfer event triggered during initial construction. let emitted_events = ink::env::test::recorded_events().collect::>(); @@ -456,27 +453,30 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); } #[ink::test] fn transfer_from_works() { // Constructor works. - let initial_supply = 100; + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + + let initial_supply = 100.into(); let mut erc20 = Erc20::new(initial_supply); + // Transfer event triggered during initial construction. - let accounts = - ink::env::test::default_accounts::(); + let accounts = ink::env::test::default_accounts(); // Bob fails to transfer tokens owned by Alice. assert_eq!( - erc20.transfer_from(accounts.alice, accounts.eve, 10), + erc20.transfer_from(accounts.alice, accounts.eve, 10.into()), Err(Error::InsufficientAllowance) ); // Alice approves Bob for token transfers on her behalf. - assert_eq!(erc20.approve(accounts.bob, 10), Ok(())); + assert_eq!(erc20.approve(accounts.bob, U256::from(10)), Ok(())); // The approve event takes place. assert_eq!(ink::env::test::recorded_events().count(), 2); @@ -486,11 +486,11 @@ mod erc20 { // Bob transfers tokens from Alice to Eve. assert_eq!( - erc20.transfer_from(accounts.alice, accounts.eve, 10), + erc20.transfer_from(accounts.alice, accounts.eve, 10.into()), Ok(()) ); // Eve owns tokens. - assert_eq!(erc20.balance_of(accounts.eve), 10); + assert_eq!(erc20.balance_of(accounts.eve), U256::from(10)); // Check all transfer events that happened during the previous calls: let emitted_events = ink::env::test::recorded_events().collect::>(); @@ -498,29 +498,29 @@ mod erc20 { assert_transfer_event( &emitted_events[0], None, - Some(AccountId::from([0x01; 32])), - 100, + Some(accounts.alice), + 100.into(), ); // The second event `emitted_events[1]` is an Approve event that we skip // checking. assert_transfer_event( &emitted_events[2], - Some(AccountId::from([0x01; 32])), - Some(AccountId::from([0x05; 32])), - 10, + Some(accounts.alice), + Some(accounts.eve), + 10.into(), ); } #[ink::test] fn allowance_must_not_change_on_failed_transfer() { - let initial_supply = 100; + let accounts = ink::env::test::default_accounts(); + set_caller(accounts.alice); + let initial_supply = 100.into(); let mut erc20 = Erc20::new(initial_supply); - let accounts = - ink::env::test::default_accounts::(); // Alice approves Bob for token transfers on her behalf. let alice_balance = erc20.balance_of(accounts.alice); - let initial_allowance = alice_balance + 2; + let initial_allowance = alice_balance + U256::from(2); assert_eq!(erc20.approve(accounts.bob, initial_allowance), Ok(())); // Set Bob as caller. @@ -529,7 +529,11 @@ mod erc20 { // Bob tries to transfer tokens from Alice to Eve. let emitted_events_before = ink::env::test::recorded_events(); assert_eq!( - erc20.transfer_from(accounts.alice, accounts.eve, alice_balance + 1), + erc20.transfer_from( + accounts.alice, + accounts.eve, + alice_balance + U256::from(1) + ), Err(Error::InsufficientBalance) ); // Allowance must have stayed the same @@ -542,8 +546,8 @@ mod erc20 { assert_eq!(emitted_events_before.count(), emitted_events_after.count()); } - fn set_caller(sender: AccountId) { - ink::env::test::set_caller::(sender); + fn set_caller(sender: H160) { + ink::env::test::set_caller(sender); } } } diff --git a/trait-flipper/Cargo.toml b/trait-flipper/Cargo.toml index b46735e2..d22a706f 100644 --- a/trait-flipper/Cargo.toml +++ b/trait-flipper/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "trait_flipper" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/trait-flipper/lib.rs b/trait-flipper/lib.rs index 7be1ac64..9077c4e2 100644 --- a/trait-flipper/lib.rs +++ b/trait-flipper/lib.rs @@ -1,7 +1,7 @@ #![cfg_attr(not(feature = "std"), no_std, no_main)] #![allow(clippy::new_without_default)] -#[ink::trait_definition] +#[::ink::trait_definition] pub trait Flip { /// Flips the current value of the Flipper's boolean. #[ink(message)] @@ -12,7 +12,7 @@ pub trait Flip { fn get(&self) -> bool; } -#[ink::contract] +#[::ink::contract] pub mod flipper { use super::Flip; @@ -25,9 +25,7 @@ pub mod flipper { /// Creates a new flipper smart contract initialized to `false`. #[ink(constructor)] pub fn new() -> Self { - Self { - value: Default::default(), - } + Self { value: true } } } @@ -47,13 +45,13 @@ pub mod flipper { mod tests { use super::*; - #[ink::test] + #[::ink::test] fn default_works() { let flipper = Flipper::new(); assert!(!flipper.get()); } - #[ink::test] + #[::ink::test] fn it_works() { let mut flipper = Flipper::new(); // Can call using universal call syntax using the trait. diff --git a/trait-incrementer/Cargo.toml b/trait-incrementer/Cargo.toml index 0a047617..b07b76ae 100644 --- a/trait-incrementer/Cargo.toml +++ b/trait-incrementer/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "trait-incrementer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } traits = { path = "./traits", default-features = false } diff --git a/trait-incrementer/traits/Cargo.toml b/trait-incrementer/traits/Cargo.toml index 4feb52b3..fa6ea59e 100644 --- a/trait-incrementer/traits/Cargo.toml +++ b/trait-incrementer/traits/Cargo.toml @@ -1,15 +1,14 @@ [package] name = "traits" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } [lib] -name = "traits" path = "lib.rs" crate-type = ["rlib"] diff --git a/upgradeable-contracts/README.md b/upgradeable-contracts/README.md index 8b831082..cbe12587 100644 --- a/upgradeable-contracts/README.md +++ b/upgradeable-contracts/README.md @@ -14,7 +14,7 @@ You can read more about storage compatibility on [use.ink](https://use.ink/basic ## [`set-code-hash`](set-code-hash-migration/) -When upgrading a contract, the new code may have a different storage layout. This example illustrates a method to +When upgrading a contract, the new code may have a different storage layout. This example illustrates a method to migrate the storage from the old layout to the new layout. It does so by using an intermediate `migration` contract which performs the storage upgrade. The workflow is as follows: @@ -22,8 +22,8 @@ which performs the storage upgrade. The workflow is as follows: 1. Upload a `migration` contract with a message `migrate` which performs the storage migration. 2. Set code hash to the `migration` contract. 3. Upload the upgraded version of the original contract. -4. Call `migrate` on the `migration` contract, passing the code hash of the new updated incrementer contract from `3.` -This must happen as a single message, because following the storage migration, the contract will not be able to be +4. Call `migrate` on the `migration` contract, passing the code hash of the new updated incrementer contract from `3.` +This must happen as a single message, because following the storage migration, the contract will not be able to be called again, since it will fail to load the migrated storage. @@ -48,15 +48,3 @@ If the delegated code only modifies `Lazy` or `Mapping` field, the keys must be This is because `Lazy` and `Mapping` interact with the storage directly instead of loading and flushing storage states. If your storage is completely layoutless (it only contains `Lazy` and `Mapping` fields), the order of fields and layout do not need to match for the same reason as mentioned above. - -### Delegate dependency locks - -The `delegator` contract depends upon the contract code to which it delegates. Since code -can be deleted by anybody if there are no instances of the contract on the chain, this -would break the `delegator` contract. To prevent this, the `delegator` contract utilizes -the `lock_delegate_dependency` and `unlock_delegate_dependency` host functions. Calling -`lock_delegate_dependency` will prevent the code at the given hash from being deleted, -until `unlock_delegate_dependency` is called from within the `delegator` contract instance. -Note that these two methods can be called by anybody executing the contract, so it is the -responsibility of the contract developer to ensure correct access control. - diff --git a/upgradeable-contracts/delegator/Cargo.toml b/upgradeable-contracts/delegator/Cargo.toml index 0c6f0514..18888d21 100644 --- a/upgradeable-contracts/delegator/Cargo.toml +++ b/upgradeable-contracts/delegator/Cargo.toml @@ -1,17 +1,17 @@ [package] name = "delegator" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } delegatee = { path = "delegatee", default-features = false, features = ["ink-as-dependency"] } delegatee2 = { path = "delegatee2", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee/Cargo.toml b/upgradeable-contracts/delegator/delegatee/Cargo.toml index 56d26758..034daaab 100644 --- a/upgradeable-contracts/delegator/delegatee/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "delegatee" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee/lib.rs b/upgradeable-contracts/delegator/delegatee/lib.rs index af761b5b..846bdd7a 100644 --- a/upgradeable-contracts/delegator/delegatee/lib.rs +++ b/upgradeable-contracts/delegator/delegatee/lib.rs @@ -2,13 +2,16 @@ #[ink::contract] pub mod delegatee { - use ink::storage::{ - traits::ManualKey, - Mapping, + use ink::{ + storage::{ + traits::ManualKey, + Mapping, + }, + H160, }; #[ink(storage)] pub struct Delegatee { - addresses: Mapping>, + addresses: Mapping>, counter: i32, // Uncommenting below line will break storage compatibility. // flag: bool, @@ -22,9 +25,16 @@ pub mod delegatee { #[allow(clippy::new_without_default)] #[ink(constructor)] pub fn new() -> Self { + /* unreachable!( "Constructors are not called when upgrading using `set_code_hash`." ) + + */ + Self { + addresses: Mapping::default(), + counter: 0, + } } /// Increments the current value. @@ -39,5 +49,14 @@ pub mod delegatee { let caller = self.env().caller(); self.addresses.insert(caller, &self.counter); } + + /// Increments the current value. + /// todo + #[ink(message)] + pub fn code_hash(&self) -> ink::H256 { + self.env() + .code_hash(&self.env().address()) + .expect("no code hash could be found") + } } } diff --git a/upgradeable-contracts/delegator/delegatee2/Cargo.toml b/upgradeable-contracts/delegator/delegatee2/Cargo.toml index cf7c873b..b43a9251 100644 --- a/upgradeable-contracts/delegator/delegatee2/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee2/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "delegatee2" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee2/lib.rs b/upgradeable-contracts/delegator/delegatee2/lib.rs index 447db46e..6640106b 100644 --- a/upgradeable-contracts/delegator/delegatee2/lib.rs +++ b/upgradeable-contracts/delegator/delegatee2/lib.rs @@ -2,13 +2,16 @@ #[ink::contract] pub mod delegatee2 { - use ink::storage::{ - traits::ManualKey, - Mapping, + use ink::{ + storage::{ + traits::ManualKey, + Mapping, + }, + H160, }; #[ink(storage)] pub struct Delegatee2 { - addresses: Mapping>, + addresses: Mapping>, counter: i32, } @@ -16,9 +19,15 @@ pub mod delegatee2 { #[allow(clippy::new_without_default)] #[ink(constructor)] pub fn new() -> Self { + /* unreachable!( "Constructors are not called when upgrading using `set_code_hash`." ) + */ + Self { + addresses: Mapping::default(), + counter: 0, + } } /// Increments the current value. @@ -33,5 +42,14 @@ pub mod delegatee2 { let caller = self.env().caller(); self.addresses.insert(caller, &self.counter); } + + /// Increments the current value. + /// todo + #[ink(message)] + pub fn code_hash(&self) -> ink::H256 { + self.env() + .code_hash(&self.env().address()) + .expect("no code hash could be found") + } } } diff --git a/upgradeable-contracts/delegator/lib.rs b/upgradeable-contracts/delegator/lib.rs index 75b43bb0..faf7d191 100644 --- a/upgradeable-contracts/delegator/lib.rs +++ b/upgradeable-contracts/delegator/lib.rs @@ -12,18 +12,20 @@ pub mod delegator { CallFlags, DefaultEnvironment, }, + primitives::H256, storage::{ traits::ManualKey, Lazy, Mapping, }, + H160, }; #[ink(storage)] pub struct Delegator { - addresses: Mapping>, + addresses: Mapping>, counter: i32, - delegate_to: Lazy, + delegate_to: Lazy<(H256, H160)>, } impl Delegator { @@ -33,15 +35,11 @@ pub mod delegator { /// Additionally, this code hash will be locked to prevent its deletion, since /// this contract depends on it. #[ink(constructor)] - pub fn new(init_value: i32, hash: Hash) -> Self { + pub fn new(init_value: i32, hash: H256, addr: H160) -> Self { let v = Mapping::new(); - // Initialize the hash of the contract to delegate to. - // Adds a delegate dependency lock, ensuring that the delegated to code cannot - // be removed. let mut delegate_to = Lazy::new(); - delegate_to.set(&hash); - Self::env().lock_delegate_dependency(&hash); + delegate_to.set(&(hash, addr)); Self { addresses: v, @@ -56,12 +54,11 @@ pub mod delegator { /// - Adds a new delegate dependency lock, ensuring that the new delegated to code /// cannot be removed. #[ink(message)] - pub fn update_delegate_to(&mut self, hash: Hash) { - if let Some(old_hash) = self.delegate_to.get() { - self.env().unlock_delegate_dependency(&old_hash) + pub fn update_delegate_to(&mut self, hash: H256, addr: H160) { + if let Some(delegate_to) = self.delegate_to.get() { + let _old_hash = delegate_to.0; } - self.env().lock_delegate_dependency(&hash); - self.delegate_to.set(&hash); + self.delegate_to.set(&(hash, addr)); } /// Increment the current value using delegate call. @@ -69,7 +66,7 @@ pub mod delegator { pub fn inc_delegate(&mut self) { let selector = ink::selector_bytes!("inc"); let _ = build_call::() - .delegate(self.delegate_to()) + .delegate(self.delegate_to().1) // We specify `CallFlags::TAIL_CALL` to use the delegatee last memory frame // as the end of the execution cycle. // So any mutations to `Packed` types, made by delegatee, @@ -91,7 +88,7 @@ pub mod delegator { pub fn add_entry_delegate(&mut self) { let selector = ink::selector_bytes!("append_address_value"); let _ = build_call::() - .delegate(self.delegate_to()) + .delegate(self.delegate_to().1) .exec_input(ExecutionInput::new(Selector::new(selector))) .returns::<()>() .try_invoke(); @@ -105,11 +102,11 @@ pub mod delegator { /// Returns the current value of the address. #[ink(message)] - pub fn get_value(&self, address: AccountId) -> (AccountId, Option) { + pub fn get_value(&self, address: H160) -> (H160, Option) { (self.env().caller(), self.addresses.get(address)) } - fn delegate_to(&self) -> Hash { + fn delegate_to(&self) -> (H256, H160) { self.delegate_to .get() .expect("delegate_to always has a value") @@ -119,6 +116,14 @@ pub mod delegator { #[cfg(all(test, feature = "e2e-tests"))] mod e2e_tests { use super::*; + use delegatee::delegatee::{ + Delegatee, + DelegateeRef, + }; + use delegatee2::delegatee2::{ + Delegatee2, + Delegatee2Ref, + }; use ink_e2e::{ ChainBackend, ContractsBackend, @@ -135,14 +140,31 @@ pub mod delegator { .create_and_fund_account(&ink_e2e::alice(), 10_000_000_000_000) .await; + /* let code_hash = client .upload("delegatee", &origin) .submit() .await .expect("upload `delegatee` failed") .code_hash; + */ + + let mut constructor = DelegateeRef::new(); + let contract = client + .instantiate("delegatee", &origin, &mut constructor) + .submit() + .await + .expect("instantiate `delegatee` failed"); + let call_builder = contract.call_builder::(); + let call_delegatee = call_builder.code_hash(); + let result = client + .call(&origin, &call_delegatee) + .dry_run() + .await + .expect("code_hash call failed"); + let code_hash = result.return_value(); - let mut constructor = DelegatorRef::new(0, code_hash); + let mut constructor = DelegatorRef::new(0, code_hash, contract.addr); let contract = client .instantiate("delegator", &origin, &mut constructor) .submit() @@ -187,15 +209,32 @@ pub mod delegator { .create_and_fund_account(&ink_e2e::alice(), 10_000_000_000_000) .await; + /* let code_hash = client .upload("delegatee", &origin) .submit() .await .expect("upload `delegatee` failed") .code_hash; + */ + + let mut constructor = DelegateeRef::new(); + let contract = client + .instantiate("delegatee", &origin, &mut constructor) + .submit() + .await + .expect("instantiate `delegatee` failed"); + let call_builder = contract.call_builder::(); + let call_delegatee = call_builder.code_hash(); + let result = client + .call(&origin, &call_delegatee) + .dry_run() + .await + .expect("code_hash call failed"); + let code_hash = result.return_value(); // given - let mut constructor = DelegatorRef::new(10, code_hash); + let mut constructor = DelegatorRef::new(10, code_hash, contract.addr); let contract = client .instantiate("delegator", &origin, &mut constructor) .submit() @@ -214,7 +253,9 @@ pub mod delegator { // assigned to Alice. let expected_value = 10; // Alice's address - let address = AccountId::from(origin.public_key().to_account_id().0); + // todo + let acc = origin.public_key().to_account_id().0; + let address = ink::primitives::AccountIdMapper::to_address(&acc); let call_get_value = call_builder.get_value(address); let call_get_result = client @@ -242,21 +283,55 @@ pub mod delegator { .create_and_fund_account(&ink_e2e::alice(), 10_000_000_000_000) .await; + /* let code_hash = client .upload("delegatee", &origin) .submit() .await .expect("upload `delegatee` failed") .code_hash; + */ + let mut constructor = DelegateeRef::new(); + let contract = client + .instantiate("delegatee", &origin, &mut constructor) + .submit() + .await + .expect("instantiate `delegatee` failed"); + let call_builder = contract.call_builder::(); + let call_delegatee = call_builder.code_hash(); + let result = client + .call(&origin, &call_delegatee) + .dry_run() + .await + .expect("code_hash call to delegatee failed"); + let code_hash = result.return_value(); + let delegatee_addr = contract.addr; + /* let code_hash2 = client .upload("delegatee2", &origin) .submit() .await .expect("upload `delegatee2` failed") .code_hash; + */ + let mut constructor = Delegatee2Ref::new(); + let contract2 = client + .instantiate("delegatee2", &origin, &mut constructor) + .submit() + .await + .expect("instantiate `delegatee2` failed"); + let call_builder2 = contract.call_builder::(); + let call_delegatee2 = call_builder2.code_hash(); + let result2 = client + .call(&origin, &call_delegatee2) + .dry_run() + .await + .expect("code_hash call to delegatee2 failed"); + let code_hash2 = result2.return_value(); + let delegatee2_addr = contract2.addr; - let mut constructor = DelegatorRef::new(10, code_hash); + let mut constructor = DelegatorRef::new(10, code_hash, delegatee_addr); let contract = client .instantiate("delegator", &origin, &mut constructor) .submit() @@ -265,14 +340,18 @@ pub mod delegator { let mut call_builder = contract.call_builder::(); // when - let call_delegate = call_builder.update_delegate_to(code_hash2); + let call_delegate = + call_builder.update_delegate_to(code_hash2, delegatee2_addr); let result = client.call(&origin, &call_delegate).submit().await; assert!(result.is_ok(), "update_delegate_to failed."); // then + // todo this doesn't work right now, as the contract is still alive and + // thus the code in use. // remove the original delegatee code. // should succeed because the delegate dependency has been removed. + /* let original_code_removed = client.remove_code(&origin, code_hash).submit().await; assert!(original_code_removed.is_ok()); @@ -281,6 +360,7 @@ pub mod delegator { // should fail because of the delegate dependency. let new_code_removed = client.remove_code(&origin, code_hash2).submit().await; assert!(new_code_removed.is_err()); + */ Ok(()) } diff --git a/upgradeable-contracts/set-code-hash-migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/Cargo.toml index be8024bd..e4f86bc0 100644 --- a/upgradeable-contracts/set-code-hash-migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/Cargo.toml @@ -1,18 +1,18 @@ [package] name = "incrementer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } migration = { path = "./migration", default-features = false, features = ["ink-as-dependency"] } updated-incrementer = { path = "./updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/e2e_tests.rs b/upgradeable-contracts/set-code-hash-migration/e2e_tests.rs index dbbd029a..12637b28 100644 --- a/upgradeable-contracts/set-code-hash-migration/e2e_tests.rs +++ b/upgradeable-contracts/set-code-hash-migration/e2e_tests.rs @@ -37,7 +37,6 @@ async fn migration_works(mut client: Client) -> E2EResult<() .await .expect("uploading `updated-incrementer` failed") .code_hash; - let new_code_hash = new_code_hash.as_ref().try_into().unwrap(); // Upload the code for the migration contract. let migration_contract = client @@ -45,7 +44,7 @@ async fn migration_works(mut client: Client) -> E2EResult<() .submit() .await .expect("uploading `migration` failed"); - let migration_code_hash = migration_contract.code_hash.as_ref().try_into().unwrap(); + let migration_code_hash = migration_contract.code_hash; // When diff --git a/upgradeable-contracts/set-code-hash-migration/lib.rs b/upgradeable-contracts/set-code-hash-migration/lib.rs index ea67cf19..7b86c2b7 100644 --- a/upgradeable-contracts/set-code-hash-migration/lib.rs +++ b/upgradeable-contracts/set-code-hash-migration/lib.rs @@ -36,10 +36,13 @@ pub mod incrementer { #[ink(message)] pub fn inc(&mut self) { self.count = self.count.checked_add(1).unwrap(); + /* + // todo ink::env::debug_println!( "The new count is {}, it was modified using the original contract code.", self.count ); + */ } /// Returns the counter value which is stored in this contract's storage. @@ -56,11 +59,12 @@ pub mod incrementer { /// /// In a production contract you would do some authorization here! #[ink(message)] - pub fn set_code(&mut self, code_hash: Hash) { + pub fn set_code(&mut self, code_hash: ink::H256) { self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); - ink::env::debug_println!("Switched code hash to {:?}.", code_hash); + // todo + // ink::env::debug_println!("Switched code hash to {:?}.", code_hash); } } } diff --git a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml index a9d918ec..1df66064 100644 --- a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "migration" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/migration/lib.rs b/upgradeable-contracts/set-code-hash-migration/migration/lib.rs index 93d13cc6..18d84567 100644 --- a/upgradeable-contracts/set-code-hash-migration/migration/lib.rs +++ b/upgradeable-contracts/set-code-hash-migration/migration/lib.rs @@ -49,7 +49,7 @@ pub mod incrementer { /// would be implicitly written to storage following the function execution, /// overwriting the migrated storage. #[ink(message)] - pub fn migrate(&self, inc_by: u8, code_hash: Hash) { + pub fn migrate(&self, inc_by: u8, code_hash: ink::H256) { let incrementer_new = IncrementerNew { count: self.count as u64, inc_by, diff --git a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml index 05590ada..c8129479 100644 --- a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "updated-incrementer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/lib.rs b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/lib.rs index 7ac05c80..4bdfef55 100644 --- a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/lib.rs +++ b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/lib.rs @@ -65,11 +65,12 @@ pub mod incrementer { /// /// In a production contract you would do some authorization here! #[ink(message)] - pub fn set_code(&mut self, code_hash: Hash) { + pub fn set_code(&mut self, code_hash: ink::H256) { self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); - ink::env::debug_println!("Switched code hash to {:?}.", code_hash); + // todo + // ink::env::debug_println!("Switched code hash to {:?}.", code_hash); } } } diff --git a/upgradeable-contracts/set-code-hash/Cargo.toml b/upgradeable-contracts/set-code-hash/Cargo.toml index 705455f2..f1e078b4 100644 --- a/upgradeable-contracts/set-code-hash/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "incrementer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../../crates/e2e" } updated-incrementer = { path = "updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/upgradeable-contracts/set-code-hash/lib.rs b/upgradeable-contracts/set-code-hash/lib.rs index c7f9993b..f41ff1ba 100644 --- a/upgradeable-contracts/set-code-hash/lib.rs +++ b/upgradeable-contracts/set-code-hash/lib.rs @@ -37,10 +37,13 @@ pub mod incrementer { #[ink(message)] pub fn inc(&mut self) { self.count = self.count.checked_add(1).unwrap(); + /* + // todo ink::env::debug_println!( "The new count is {}, it was modified using the original contract code.", self.count ); + */ } /// Returns the counter value which is stored in this contract's storage. @@ -57,11 +60,12 @@ pub mod incrementer { /// /// In a production contract you would do some authorization here! #[ink(message)] - pub fn set_code(&mut self, code_hash: Hash) { + pub fn set_code(&mut self, code_hash: ink::H256) { self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); - ink::env::debug_println!("Switched code hash to {:?}.", code_hash); + // todo + // ink::env::debug_println!("Switched code hash to {:?}.", code_hash); } } @@ -106,7 +110,6 @@ pub mod incrementer { .expect("uploading `updated_incrementer` failed") .code_hash; - let new_code_hash = new_code_hash.as_ref().try_into().unwrap(); let set_code = call_builder.set_code(new_code_hash); let _set_code_result = client diff --git a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml index 05590ada..c8129479 100644 --- a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "updated-incrementer" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../../../crates/ink", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs b/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs index 7741181a..52b041ec 100644 --- a/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs +++ b/upgradeable-contracts/set-code-hash/updated-incrementer/lib.rs @@ -42,7 +42,9 @@ pub mod incrementer { #[ink(message)] pub fn inc(&mut self) { self.count = self.count.checked_add(4).unwrap(); - ink::env::debug_println!("The new count is {}, it was modified using the updated `new_incrementer` code.", self.count); + // todo + // ink::env::debug_println!("The new count is {}, it was modified using the + // updated `new_incrementer` code.", self.count); } /// Returns the counter value which is stored in this contract's storage. @@ -59,11 +61,12 @@ pub mod incrementer { /// /// In a production contract you would do some authorization here! #[ink(message)] - pub fn set_code(&mut self, code_hash: Hash) { + pub fn set_code(&mut self, code_hash: ink::H256) { self.env().set_code_hash(&code_hash).unwrap_or_else(|err| { panic!("Failed to `set_code_hash` to {code_hash:?} due to {err:?}") }); - ink::env::debug_println!("Switched code hash to {:?}.", code_hash); + // todo + // ink::env::debug_println!("Switched code hash to {:?}.", code_hash); } } } diff --git a/wildcard-selector/Cargo.toml b/wildcard-selector/Cargo.toml index b3e9d0bf..817615da 100644 --- a/wildcard-selector/Cargo.toml +++ b/wildcard-selector/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "wildcard-selector" -version = "5.1.0" +version = "6.0.0-alpha" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { path = "../../../crates/ink", default-features = false } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { path = "../../../crates/e2e" } [lib] path = "lib.rs" diff --git a/wildcard-selector/lib.rs b/wildcard-selector/lib.rs index 1e99545b..97951220 100644 --- a/wildcard-selector/lib.rs +++ b/wildcard-selector/lib.rs @@ -7,6 +7,17 @@ pub mod wildcard_selector { #[ink(storage)] pub struct WildcardSelector {} + struct MessageInput([u8; 4], String); + impl ink::env::DecodeDispatch for MessageInput { + fn decode_dispatch(input: &mut &[u8]) -> Result { + // todo improve code here + let mut selector: [u8; 4] = [0u8; 4]; + selector.copy_from_slice(&input[..4]); + let arg: String = ink::scale::Decode::decode(&mut &input[4..]).unwrap(); + Ok(MessageInput(selector, arg)) + } + } + impl WildcardSelector { /// Creates a new wildcard selector smart contract. #[ink(constructor)] @@ -18,19 +29,23 @@ pub mod wildcard_selector { /// Wildcard selector handles messages with any selector. #[ink(message, selector = _)] pub fn wildcard(&mut self) { - let (_selector, _message) = - ink::env::decode_input::<([u8; 4], String)>().unwrap(); + let MessageInput(_selector, _message) = + ink::env::decode_input::().unwrap(); + /* + // todo ink::env::debug_println!( "Wildcard selector: {:?}, message: {}", _selector, _message ); + */ } /// Wildcard complement handles messages with a well-known reserved selector. #[ink(message, selector = @)] pub fn wildcard_complement(&mut self, _message: String) { - ink::env::debug_println!("Wildcard complement message: {}", _message); + // todo + // ink::env::debug_println!("Wildcard complement message: {}", _message); } } @@ -39,26 +54,34 @@ pub mod wildcard_selector { use super::*; use ink_e2e::ContractsBackend; - use ink::env::call::utils::{ - Argument, - ArgumentList, - EmptyArgumentList, + use ink::{ + env::call::utils::{ + Argument, + ArgumentList, + EmptyArgumentList, + }, + primitives::reflect::ScaleEncoding, }; type E2EResult = std::result::Result>; type Environment = ::Env; fn build_message( - account_id: AccountId, + addr: ink::H160, selector: [u8; 4], message: String, ) -> ink_e2e::CallBuilderFinal< Environment, - ArgumentList, EmptyArgumentList>, + ArgumentList< + Argument, + EmptyArgumentList, + ScaleEncoding, + >, (), + ScaleEncoding, > { ink::env::call::build_call::() - .call(account_id) + .call(addr) .exec_input( ink::env::call::ExecutionInput::new(ink::env::call::Selector::new( selector, @@ -79,7 +102,7 @@ pub mod wildcard_selector { .submit() .await .expect("instantiate failed") - .account_id; + .addr; // when const ARBITRARY_SELECTOR: [u8; 4] = [0xF9, 0xF9, 0xF9, 0xF9]; @@ -90,7 +113,7 @@ pub mod wildcard_selector { wildcard_message.clone(), ); - let result = client + let _result = client .call(&ink_e2e::bob(), &wildcard) .submit() .await @@ -104,13 +127,15 @@ pub mod wildcard_selector { wildcard_message2.clone(), ); - let result2 = client + let _result2 = client .call(&ink_e2e::bob(), &wildcard2) .submit() .await .expect("wildcard failed"); // then + /* + // todo assert!(result.debug_message().contains(&format!( "Wildcard selector: {:?}, message: {}", ARBITRARY_SELECTOR, wildcard_message @@ -120,6 +145,7 @@ pub mod wildcard_selector { "Wildcard selector: {:?}, message: {}", ARBITRARY_SELECTOR_2, wildcard_message2 ))); + */ Ok(()) } @@ -135,7 +161,7 @@ pub mod wildcard_selector { .submit() .await .expect("instantiate failed") - .account_id; + .addr; // when let wildcard_complement_message = "WILDCARD COMPLEMENT MESSAGE".to_string(); @@ -145,17 +171,20 @@ pub mod wildcard_selector { wildcard_complement_message.clone(), ); - let result = client + let _result = client .call(&ink_e2e::bob(), &wildcard) .submit() .await .expect("wildcard failed"); // then + /* + // todo assert!(result.debug_message().contains(&format!( "Wildcard complement message: {}", wildcard_complement_message ))); + */ Ok(()) } From 62747ffde65ec4b344a426ae6cea869758275e7b Mon Sep 17 00:00:00 2001 From: Alejandro Martinez <11448715+al3mart@users.noreply.github.com> Date: Thu, 10 Apr 2025 02:46:14 +0200 Subject: [PATCH 2/4] chore: remove relative deps & minor fixes (#74) --- basic-contract-caller/Cargo.toml | 6 +-- basic-contract-caller/lib.rs | 7 +-- .../other-contract/Cargo.toml | 6 +-- call-runtime/Cargo.toml | 4 +- combined-extension/Cargo.toml | 2 +- conditional-compilation/Cargo.toml | 4 +- contract-storage/Cargo.toml | 4 +- contract-terminate/Cargo.toml | 4 +- contract-transfer/Cargo.toml | 5 +-- contract-xcm/Cargo.toml | 4 +- cross-contract-calls/Cargo.toml | 4 +- .../other-contract/Cargo.toml | 4 +- custom-allocator/Cargo.toml | 4 +- custom-environment/Cargo.toml | 4 +- dns/Cargo.toml | 2 +- e2e-call-runtime/Cargo.toml | 4 +- e2e-runtime-only-backend/Cargo.toml | 4 +- e2e-runtime-only-backend/lib.rs | 4 +- erc1155/Cargo.toml | 2 +- erc20/Cargo.toml | 4 +- erc721/Cargo.toml | 2 +- events/Cargo.toml | 4 +- events/event-def-unused/Cargo.toml | 2 +- events/event-def/Cargo.toml | 2 +- events/event-def2/Cargo.toml | 2 +- flipper/Cargo.toml | 4 +- incrementer/Cargo.toml | 2 +- lazyvec/Cargo.toml | 4 +- mapping/Cargo.toml | 4 +- mapping/lib.rs | 5 ++- multi-contract-caller/Cargo.toml | 4 +- multi-contract-caller/accumulator/Cargo.toml | 2 +- multi-contract-caller/adder/Cargo.toml | 2 +- multi-contract-caller/subber/Cargo.toml | 2 +- multisig/Cargo.toml | 2 +- payment-channel/Cargo.toml | 2 +- psp22-extension/Cargo.toml | 2 +- rand-extension/Cargo.toml | 2 +- runtime-call-contract/Cargo.toml | 4 +- static-buffer/Cargo.toml | 4 +- static-buffer/lib.rs | 11 +++-- trait-dyn-cross-contract-calls/Cargo.toml | 4 +- .../contracts/incrementer/Cargo.toml | 2 +- .../traits/Cargo.toml | 2 +- trait-erc20/Cargo.toml | 2 +- trait-flipper/Cargo.toml | 2 +- trait-incrementer/Cargo.toml | 2 +- trait-incrementer/traits/Cargo.toml | 2 +- upgradeable-contracts/delegator/Cargo.toml | 4 +- .../delegator/delegatee/Cargo.toml | 2 +- .../delegator/delegatee2/Cargo.toml | 2 +- .../set-code-hash-migration/Cargo.toml | 4 +- .../migration/Cargo.toml | 2 +- .../updated-incrementer/Cargo.toml | 2 +- .../set-code-hash/Cargo.toml | 4 +- .../updated-incrementer/Cargo.toml | 2 +- vesting/Cargo.toml | 2 +- vesting/lib.rs | 45 ++++++++++--------- wildcard-selector/Cargo.toml | 4 +- workspace-contracts/Cargo.toml | 4 +- 60 files changed, 125 insertions(+), 118 deletions(-) diff --git a/basic-contract-caller/Cargo.toml b/basic-contract-caller/Cargo.toml index feb70f08..41b150bb 100755 --- a/basic-contract-caller/Cargo.toml +++ b/basic-contract-caller/Cargo.toml @@ -1,12 +1,12 @@ [package] name = "basic-contract-caller" -version = "5.1.0" +version = "6.0.0" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } # Note: We **need** to specify the `ink-as-dependency` feature. # @@ -14,7 +14,7 @@ ink = { version = "5.1.0", default-features = false } other-contract = { path = "other-contract", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/basic-contract-caller/lib.rs b/basic-contract-caller/lib.rs index 14df01c2..e58048ad 100755 --- a/basic-contract-caller/lib.rs +++ b/basic-contract-caller/lib.rs @@ -7,6 +7,7 @@ mod basic_contract_caller { /// Note that the other contract must have re-exported it (`pub use /// OtherContractRef`) for us to have access to it. use other_contract::OtherContractRef; + use ink::{H256, U256}; #[ink(storage)] pub struct BasicContractCaller { @@ -19,11 +20,11 @@ mod basic_contract_caller { /// /// To do this we will use the uploaded `code_hash` of `OtherContract`. #[ink(constructor)] - pub fn new(other_contract_code_hash: Hash) -> Self { + pub fn new(other_contract_code_hash: H256) -> Self { let other_contract = OtherContractRef::new(true) .code_hash(other_contract_code_hash) - .endowment(0) - .salt_bytes([0xDE, 0xAD, 0xBE, 0xEF]) + .endowment(U256::from(0)) + .salt_bytes(Some([1;32])) .instantiate(); Self { other_contract } diff --git a/basic-contract-caller/other-contract/Cargo.toml b/basic-contract-caller/other-contract/Cargo.toml index 6eb419bd..3d2c9628 100755 --- a/basic-contract-caller/other-contract/Cargo.toml +++ b/basic-contract-caller/other-contract/Cargo.toml @@ -1,15 +1,15 @@ [package] name = "other-contract" -version = "5.1.0" +version = "6.0.0" authors = ["Use Ink "] edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/call-runtime/Cargo.toml b/call-runtime/Cargo.toml index 565de766..49027a70 100644 --- a/call-runtime/Cargo.toml +++ b/call-runtime/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } # We need to explicitly turn off some of the `sp-io` features, to avoid conflicts @@ -18,7 +18,7 @@ sp-io = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01e sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["disable_target_static_assertions"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/combined-extension/Cargo.toml b/combined-extension/Cargo.toml index 706a840b..64bf1817 100755 --- a/combined-extension/Cargo.toml +++ b/combined-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } psp22_extension = { path = "../psp22-extension", default-features = false, features = ["ink-as-dependency"] } rand_extension = { path = "../rand-extension", default-features = false, features = ["ink-as-dependency"] } diff --git a/conditional-compilation/Cargo.toml b/conditional-compilation/Cargo.toml index 07574803..e7e14775 100755 --- a/conditional-compilation/Cargo.toml +++ b/conditional-compilation/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/contract-storage/Cargo.toml b/contract-storage/Cargo.toml index 2ae79dff..d8eaa400 100755 --- a/contract-storage/Cargo.toml +++ b/contract-storage/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/contract-terminate/Cargo.toml b/contract-terminate/Cargo.toml index 973f2983..9707499d 100644 --- a/contract-terminate/Cargo.toml +++ b/contract-terminate/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/contract-transfer/Cargo.toml b/contract-transfer/Cargo.toml index cf203d62..3b95b57f 100644 --- a/contract-transfer/Cargo.toml +++ b/contract-transfer/Cargo.toml @@ -6,11 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -#ink_e2e = { path = "../../../crates/e2e" } -ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/contract-xcm/Cargo.toml b/contract-xcm/Cargo.toml index 3a4eeff7..2ead0f80 100644 --- a/contract-xcm/Cargo.toml +++ b/contract-xcm/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/cross-contract-calls/Cargo.toml b/cross-contract-calls/Cargo.toml index aade132f..8d5b50f7 100755 --- a/cross-contract-calls/Cargo.toml +++ b/cross-contract-calls/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } # Note: We **need** to specify the `ink-as-dependency` feature. # @@ -15,7 +15,7 @@ other-contract = { path = "other-contract", default-features = false, features = pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/cross-contract-calls/other-contract/Cargo.toml b/cross-contract-calls/other-contract/Cargo.toml index bde6cd88..ac7e79f6 100755 --- a/cross-contract-calls/other-contract/Cargo.toml +++ b/cross-contract-calls/other-contract/Cargo.toml @@ -6,11 +6,11 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/custom-allocator/Cargo.toml b/custom-allocator/Cargo.toml index beb15271..9e997075 100755 --- a/custom-allocator/Cargo.toml +++ b/custom-allocator/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] # We're going to use a different allocator than the one provided by ink!. To do that we # first need to disable the included memory allocator. -ink = { path = "../../../crates/ink", default-features = false, features = ["no-allocator"] } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } # todo #foo = { path = "../../../foo", default-features = false } @@ -17,7 +17,7 @@ ink = { path = "../../../crates/ink", default-features = false, features = ["no- #bumpalo = "3.16.0" [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/custom-environment/Cargo.toml b/custom-environment/Cargo.toml index 3853d653..72cfb986 100644 --- a/custom-environment/Cargo.toml +++ b/custom-environment/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/dns/Cargo.toml b/dns/Cargo.toml index 6779f4ff..fac971f0 100644 --- a/dns/Cargo.toml +++ b/dns/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/e2e-call-runtime/Cargo.toml b/e2e-call-runtime/Cargo.toml index 578ec918..46edefca 100644 --- a/e2e-call-runtime/Cargo.toml +++ b/e2e-call-runtime/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/e2e-runtime-only-backend/Cargo.toml b/e2e-runtime-only-backend/Cargo.toml index 4bb5dcc2..68f86c93 100644 --- a/e2e-runtime-only-backend/Cargo.toml +++ b/e2e-runtime-only-backend/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/e2e-runtime-only-backend/lib.rs b/e2e-runtime-only-backend/lib.rs index 8f190740..fd302e46 100644 --- a/e2e-runtime-only-backend/lib.rs +++ b/e2e-runtime-only-backend/lib.rs @@ -2,6 +2,8 @@ #[ink::contract] pub mod flipper { + use ink::U256; + #[ink(storage)] pub struct Flipper { value: bool, @@ -34,7 +36,7 @@ pub mod flipper { /// Returns the current balance of the Flipper. #[ink(message)] - pub fn get_contract_balance(&self) -> Balance { + pub fn get_contract_balance(&self) -> U256 { self.env().balance() } } diff --git a/erc1155/Cargo.toml b/erc1155/Cargo.toml index e5f495e9..576acbae 100644 --- a/erc1155/Cargo.toml +++ b/erc1155/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/erc20/Cargo.toml b/erc20/Cargo.toml index 550fac7e..b0ef5edd 100644 --- a/erc20/Cargo.toml +++ b/erc20/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/erc721/Cargo.toml b/erc721/Cargo.toml index 75862765..cbcd6c40 100644 --- a/erc721/Cargo.toml +++ b/erc721/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/events/Cargo.toml b/events/Cargo.toml index 39be08c3..cab169d6 100644 --- a/events/Cargo.toml +++ b/events/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } event-def = { path = "event-def", default-features = false } event-def2 = { path = "event-def2", default-features = false } event-def-unused = { path = "event-def-unused", default-features = false } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/events/event-def-unused/Cargo.toml b/events/event-def-unused/Cargo.toml index 0f22aaa8..d32505ca 100644 --- a/events/event-def-unused/Cargo.toml +++ b/events/event-def-unused/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/events/event-def/Cargo.toml b/events/event-def/Cargo.toml index 7c4ec74b..0066ca9d 100644 --- a/events/event-def/Cargo.toml +++ b/events/event-def/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/events/event-def2/Cargo.toml b/events/event-def2/Cargo.toml index ae45732d..ca4f3857 100644 --- a/events/event-def2/Cargo.toml +++ b/events/event-def2/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/flipper/Cargo.toml b/flipper/Cargo.toml index 7f77efce..7a1a5991 100644 --- a/flipper/Cargo.toml +++ b/flipper/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } hex = { version = "0.4.3" } [lib] diff --git a/incrementer/Cargo.toml b/incrementer/Cargo.toml index 7cde84af..718a74a6 100644 --- a/incrementer/Cargo.toml +++ b/incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/lazyvec/Cargo.toml b/lazyvec/Cargo.toml index 70c5d54c..1b6a1115 100755 --- a/lazyvec/Cargo.toml +++ b/lazyvec/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/mapping/Cargo.toml b/mapping/Cargo.toml index 767fe080..793bc044 100755 --- a/mapping/Cargo.toml +++ b/mapping/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/mapping/lib.rs b/mapping/lib.rs index 47caf9b8..1158b632 100755 --- a/mapping/lib.rs +++ b/mapping/lib.rs @@ -5,6 +5,7 @@ #[ink::contract] mod mapping { use ink::{ + H160, prelude::{ string::String, vec::Vec, @@ -23,9 +24,9 @@ mod mapping { #[derive(Default)] pub struct Mappings { /// Mapping from owner to number of owned token. - balances: Mapping, + balances: Mapping, /// Mapping from owner to aliases. - names: Mapping>, + names: Mapping>, } impl Mappings { diff --git a/multi-contract-caller/Cargo.toml b/multi-contract-caller/Cargo.toml index cbd4d85c..8971aec2 100644 --- a/multi-contract-caller/Cargo.toml +++ b/multi-contract-caller/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } adder = { path = "adder", default-features = false, features = ["ink-as-dependency"] } subber = { path = "subber", default-features = false, features = ["ink-as-dependency"] } accumulator = { path = "accumulator", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/multi-contract-caller/accumulator/Cargo.toml b/multi-contract-caller/accumulator/Cargo.toml index 9f75347d..bd1cc14d 100644 --- a/multi-contract-caller/accumulator/Cargo.toml +++ b/multi-contract-caller/accumulator/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/multi-contract-caller/adder/Cargo.toml b/multi-contract-caller/adder/Cargo.toml index a33e5613..d13473c5 100644 --- a/multi-contract-caller/adder/Cargo.toml +++ b/multi-contract-caller/adder/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multi-contract-caller/subber/Cargo.toml b/multi-contract-caller/subber/Cargo.toml index e9c6f1fa..d31e6705 100644 --- a/multi-contract-caller/subber/Cargo.toml +++ b/multi-contract-caller/subber/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index 364b217a..a19950d0 100755 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/payment-channel/Cargo.toml b/payment-channel/Cargo.toml index 51cac5e2..d1cd8213 100755 --- a/payment-channel/Cargo.toml +++ b/payment-channel/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] diff --git a/psp22-extension/Cargo.toml b/psp22-extension/Cargo.toml index 44c39d55..4b58f72a 100755 --- a/psp22-extension/Cargo.toml +++ b/psp22-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/rand-extension/Cargo.toml b/rand-extension/Cargo.toml index eb714463..6a9afc53 100755 --- a/rand-extension/Cargo.toml +++ b/rand-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/runtime-call-contract/Cargo.toml b/runtime-call-contract/Cargo.toml index 0ec0cdb9..d9a89412 100644 --- a/runtime-call-contract/Cargo.toml +++ b/runtime-call-contract/Cargo.toml @@ -28,11 +28,11 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } flipper-traits = { path = "traits", default-features = false } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e", features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } sandbox-runtime = { path = "sandbox-runtime", default-features = false } scale-value = "0.18.0" # can't use workspace dependency because of `cargo-contract` build not diff --git a/static-buffer/Cargo.toml b/static-buffer/Cargo.toml index f88ff65c..a27143ec 100644 --- a/static-buffer/Cargo.toml +++ b/static-buffer/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "5.1.0" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/static-buffer/lib.rs b/static-buffer/lib.rs index 9f813f46..7421bb20 100644 --- a/static-buffer/lib.rs +++ b/static-buffer/lib.rs @@ -2,9 +2,12 @@ #[ink::contract] pub mod static_buffer { - use ink::prelude::{ - string::String, - vec::Vec, + use ink::{ + H160, + prelude::{ + string::String, + vec::Vec, + } }; #[allow(unused_imports)] @@ -30,7 +33,7 @@ pub mod static_buffer { /// Returns the caller of the contract. /// Should panic if the buffer size is less than 32 bytes. #[ink(message)] - pub fn get_caller(&self) -> AccountId { + pub fn get_caller(&self) -> H160 { self.env().caller() } diff --git a/trait-dyn-cross-contract-calls/Cargo.toml b/trait-dyn-cross-contract-calls/Cargo.toml index b33f767b..2f7ba75a 100644 --- a/trait-dyn-cross-contract-calls/Cargo.toml +++ b/trait-dyn-cross-contract-calls/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } dyn-traits = { path = "./traits", default-features = false } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } trait-incrementer = { path = "./contracts/incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml index 088a7a5f..ef564789 100644 --- a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml +++ b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } dyn-traits = { path = "../../traits", default-features = false } diff --git a/trait-dyn-cross-contract-calls/traits/Cargo.toml b/trait-dyn-cross-contract-calls/traits/Cargo.toml index 646ff3c5..9a0855ec 100644 --- a/trait-dyn-cross-contract-calls/traits/Cargo.toml +++ b/trait-dyn-cross-contract-calls/traits/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-erc20/Cargo.toml b/trait-erc20/Cargo.toml index fc0c2f57..917e5be9 100644 --- a/trait-erc20/Cargo.toml +++ b/trait-erc20/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-flipper/Cargo.toml b/trait-flipper/Cargo.toml index d22a706f..8d23fd2e 100644 --- a/trait-flipper/Cargo.toml +++ b/trait-flipper/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-incrementer/Cargo.toml b/trait-incrementer/Cargo.toml index b07b76ae..f73ccecd 100644 --- a/trait-incrementer/Cargo.toml +++ b/trait-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } traits = { path = "./traits", default-features = false } diff --git a/trait-incrementer/traits/Cargo.toml b/trait-incrementer/traits/Cargo.toml index fa6ea59e..830db3cd 100644 --- a/trait-incrementer/traits/Cargo.toml +++ b/trait-incrementer/traits/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/Cargo.toml b/upgradeable-contracts/delegator/Cargo.toml index 18888d21..1bf4f521 100644 --- a/upgradeable-contracts/delegator/Cargo.toml +++ b/upgradeable-contracts/delegator/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } delegatee = { path = "delegatee", default-features = false, features = ["ink-as-dependency"] } delegatee2 = { path = "delegatee2", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { path = "../../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee/Cargo.toml b/upgradeable-contracts/delegator/delegatee/Cargo.toml index 034daaab..624601ee 100644 --- a/upgradeable-contracts/delegator/delegatee/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee2/Cargo.toml b/upgradeable-contracts/delegator/delegatee2/Cargo.toml index b43a9251..ed6c8c23 100644 --- a/upgradeable-contracts/delegator/delegatee2/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee2/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/Cargo.toml index e4f86bc0..af313db7 100644 --- a/upgradeable-contracts/set-code-hash-migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/Cargo.toml @@ -6,13 +6,13 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } migration = { path = "./migration", default-features = false, features = ["ink-as-dependency"] } updated-incrementer = { path = "./updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { path = "../../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml index 1df66064..0f4db4a8 100644 --- a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml index c8129479..5a7d12d7 100644 --- a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash/Cargo.toml b/upgradeable-contracts/set-code-hash/Cargo.toml index f1e078b4..c28d4ad4 100644 --- a/upgradeable-contracts/set-code-hash/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } updated-incrementer = { path = "updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml index c8129479..5a7d12d7 100644 --- a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index 8e9c45a0..790c453f 100755 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "5.1.0", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] diff --git a/vesting/lib.rs b/vesting/lib.rs index 6e8dfdd5..6be5473c 100755 --- a/vesting/lib.rs +++ b/vesting/lib.rs @@ -2,15 +2,16 @@ #[ink::contract] mod vesting_contract { + use ink::{H160, U256}; #[ink(storage)] pub struct VestingContract { - releasable_balance: Balance, - released_balance: Balance, + releasable_balance: U256, + released_balance: U256, duration_time: Timestamp, start_time: Timestamp, - beneficiary: AccountId, - owner: AccountId, + beneficiary: H160, + owner: H160, } /// Error for when the beneficiary is a zero address. @@ -25,8 +26,8 @@ mod vesting_contract { /// To emit events when a release is made. #[ink(event)] pub struct Released { - value: Balance, - to: AccountId, + value: U256, + to: H160, } /// ## This is to set the following during contract deployment: @@ -44,10 +45,10 @@ mod vesting_contract { impl VestingContract { #[ink(constructor, payable)] pub fn new( - beneficiary: AccountId, + beneficiary: H160, duration_time_in_sec: Timestamp, ) -> Result { - if beneficiary == AccountId::from([0x0; 32]) { + if beneficiary == H160::from([0x0; 20]) { return Err(Error::InvalidBeneficiary) } @@ -57,8 +58,8 @@ mod vesting_contract { let start_time = Self::env().block_timestamp(); let owner = Self::env().caller(); - let releasable_balance = 0; - let released_balance = 0; + let releasable_balance = U256::from(0); + let released_balance = U256::from(0); Ok(Self { duration_time, @@ -77,13 +78,13 @@ mod vesting_contract { /// This returns this contract balance. #[ink(message)] - pub fn this_contract_balance(&self) -> Balance { + pub fn this_contract_balance(&self) -> U256 { self.env().balance() } /// This returns the beneficiary wallet addr. #[ink(message)] - pub fn beneficiary(&self) -> AccountId { + pub fn beneficiary(&self) -> H160 { self.beneficiary } @@ -122,15 +123,15 @@ mod vesting_contract { /// This returns the amount of native token that /// has already vested. #[ink(message)] - pub fn released_balance(&self) -> Balance { + pub fn released_balance(&self) -> U256 { self.released_balance } /// This returns the amount of native token that /// is currently available for release. #[ink(message)] - pub fn releasable_balance(&self) -> Balance { - (self.vested_amount() as Balance) + pub fn releasable_balance(&self) -> U256 { + self.vested_amount() .checked_sub(self.released_balance()) .unwrap() } @@ -138,7 +139,7 @@ mod vesting_contract { /// This calculates the amount that has already vested /// but hasn't been released from the contract yet. #[ink(message)] - pub fn vested_amount(&self) -> Balance { + pub fn vested_amount(&self) -> U256 { self.vesting_schedule(self.this_contract_balance(), self.time_now()) } @@ -147,7 +148,7 @@ mod vesting_contract { #[ink(message)] pub fn release(&mut self) -> Result<(), Error> { let releasable = self.releasable_balance(); - if releasable == 0 { + if releasable == U256::from(0) { return Err(Error::ZeroReleasableBalance) } @@ -191,19 +192,19 @@ mod vesting_contract { /// would have vested. pub fn vesting_schedule( &self, - total_allocation: Balance, + total_allocation: U256, current_time: Timestamp, - ) -> Balance { + ) -> U256 { if current_time < self.start_time() { - 0 + U256::from(0) } else if current_time >= self.end_time() { return total_allocation } else { return (total_allocation.checked_mul( - (current_time.checked_sub(self.start_time()).unwrap()) as Balance, + U256::from(current_time.checked_sub(self.start_time()).unwrap()), )) .unwrap() - .checked_div(self.duration_time() as Balance) + .checked_div(U256::from(self.duration_time())) .unwrap() } } diff --git a/wildcard-selector/Cargo.toml b/wildcard-selector/Cargo.toml index 817615da..0e784a42 100644 --- a/wildcard-selector/Cargo.toml +++ b/wildcard-selector/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { path = "../../../crates/ink", default-features = false } +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { path = "../../../crates/e2e" } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/workspace-contracts/Cargo.toml b/workspace-contracts/Cargo.toml index 91f4fd9e..56898516 100644 --- a/workspace-contracts/Cargo.toml +++ b/workspace-contracts/Cargo.toml @@ -4,5 +4,5 @@ exclude = [".cargo", "target"] resolver = "2" [workspace.dependencies] -ink = { version = "5.1.0", default-features = false } -ink_e2e = "5.1.0" +ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } From 06765f7a8792c1a3b3bca3ac82b6499f8cdebc39 Mon Sep 17 00:00:00 2001 From: Alex Bean Date: Mon, 5 May 2025 07:08:31 +0200 Subject: [PATCH 3/4] chore: update dependencies (#75) --- basic-contract-caller/Cargo.toml | 4 ++-- basic-contract-caller/other-contract/Cargo.toml | 4 ++-- call-runtime/Cargo.toml | 4 ++-- combined-extension/Cargo.toml | 2 +- conditional-compilation/Cargo.toml | 4 ++-- contract-storage/Cargo.toml | 4 ++-- contract-terminate/Cargo.toml | 4 ++-- contract-transfer/Cargo.toml | 4 ++-- contract-xcm/Cargo.toml | 4 ++-- cross-contract-calls/Cargo.toml | 4 ++-- cross-contract-calls/other-contract/Cargo.toml | 4 ++-- custom-allocator/Cargo.toml | 4 ++-- custom-environment/Cargo.toml | 4 ++-- dns/Cargo.toml | 2 +- e2e-call-runtime/Cargo.toml | 4 ++-- e2e-runtime-only-backend/Cargo.toml | 4 ++-- erc1155/Cargo.toml | 2 +- erc20/Cargo.toml | 4 ++-- erc721/Cargo.toml | 2 +- events/Cargo.toml | 4 ++-- events/event-def-unused/Cargo.toml | 2 +- events/event-def/Cargo.toml | 2 +- events/event-def2/Cargo.toml | 2 +- flipper/Cargo.toml | 4 ++-- incrementer/Cargo.toml | 2 +- lazyvec/Cargo.toml | 4 ++-- mapping/Cargo.toml | 4 ++-- multi-contract-caller/Cargo.toml | 4 ++-- multi-contract-caller/accumulator/Cargo.toml | 2 +- multi-contract-caller/adder/Cargo.toml | 2 +- multi-contract-caller/subber/Cargo.toml | 2 +- multisig/Cargo.toml | 2 +- payment-channel/Cargo.toml | 2 +- psp22-extension/Cargo.toml | 2 +- rand-extension/Cargo.toml | 2 +- runtime-call-contract/Cargo.toml | 4 ++-- static-buffer/Cargo.toml | 4 ++-- trait-dyn-cross-contract-calls/Cargo.toml | 4 ++-- .../contracts/incrementer/Cargo.toml | 2 +- trait-dyn-cross-contract-calls/traits/Cargo.toml | 2 +- trait-erc20/Cargo.toml | 2 +- trait-flipper/Cargo.toml | 2 +- trait-incrementer/Cargo.toml | 2 +- trait-incrementer/traits/Cargo.toml | 2 +- upgradeable-contracts/delegator/Cargo.toml | 4 ++-- upgradeable-contracts/delegator/delegatee/Cargo.toml | 2 +- upgradeable-contracts/delegator/delegatee2/Cargo.toml | 2 +- upgradeable-contracts/set-code-hash-migration/Cargo.toml | 4 ++-- .../set-code-hash-migration/migration/Cargo.toml | 2 +- .../set-code-hash-migration/updated-incrementer/Cargo.toml | 2 +- upgradeable-contracts/set-code-hash/Cargo.toml | 4 ++-- .../set-code-hash/updated-incrementer/Cargo.toml | 2 +- vesting/Cargo.toml | 2 +- wildcard-selector/Cargo.toml | 4 ++-- workspace-contracts/Cargo.toml | 4 ++-- 55 files changed, 83 insertions(+), 83 deletions(-) diff --git a/basic-contract-caller/Cargo.toml b/basic-contract-caller/Cargo.toml index 41b150bb..b0f35a7a 100755 --- a/basic-contract-caller/Cargo.toml +++ b/basic-contract-caller/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } # Note: We **need** to specify the `ink-as-dependency` feature. # @@ -14,7 +14,7 @@ ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = other-contract = { path = "other-contract", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/basic-contract-caller/other-contract/Cargo.toml b/basic-contract-caller/other-contract/Cargo.toml index 3d2c9628..6d1cc739 100755 --- a/basic-contract-caller/other-contract/Cargo.toml +++ b/basic-contract-caller/other-contract/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/call-runtime/Cargo.toml b/call-runtime/Cargo.toml index 49027a70..4e3a04e5 100644 --- a/call-runtime/Cargo.toml +++ b/call-runtime/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } # We need to explicitly turn off some of the `sp-io` features, to avoid conflicts @@ -18,7 +18,7 @@ sp-io = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01e sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["disable_target_static_assertions"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/combined-extension/Cargo.toml b/combined-extension/Cargo.toml index 64bf1817..957cdb90 100755 --- a/combined-extension/Cargo.toml +++ b/combined-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } psp22_extension = { path = "../psp22-extension", default-features = false, features = ["ink-as-dependency"] } rand_extension = { path = "../rand-extension", default-features = false, features = ["ink-as-dependency"] } diff --git a/conditional-compilation/Cargo.toml b/conditional-compilation/Cargo.toml index e7e14775..9d620737 100755 --- a/conditional-compilation/Cargo.toml +++ b/conditional-compilation/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/contract-storage/Cargo.toml b/contract-storage/Cargo.toml index d8eaa400..e78d0c7a 100755 --- a/contract-storage/Cargo.toml +++ b/contract-storage/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/contract-terminate/Cargo.toml b/contract-terminate/Cargo.toml index 9707499d..71e99826 100644 --- a/contract-terminate/Cargo.toml +++ b/contract-terminate/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/contract-transfer/Cargo.toml b/contract-transfer/Cargo.toml index 3b95b57f..9010dcca 100644 --- a/contract-transfer/Cargo.toml +++ b/contract-transfer/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/contract-xcm/Cargo.toml b/contract-xcm/Cargo.toml index 2ead0f80..5e7d9c67 100644 --- a/contract-xcm/Cargo.toml +++ b/contract-xcm/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/cross-contract-calls/Cargo.toml b/cross-contract-calls/Cargo.toml index 8d5b50f7..29adb40a 100755 --- a/cross-contract-calls/Cargo.toml +++ b/cross-contract-calls/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } # Note: We **need** to specify the `ink-as-dependency` feature. # @@ -15,7 +15,7 @@ other-contract = { path = "other-contract", default-features = false, features = pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/cross-contract-calls/other-contract/Cargo.toml b/cross-contract-calls/other-contract/Cargo.toml index ac7e79f6..001b76b4 100755 --- a/cross-contract-calls/other-contract/Cargo.toml +++ b/cross-contract-calls/other-contract/Cargo.toml @@ -6,11 +6,11 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/custom-allocator/Cargo.toml b/custom-allocator/Cargo.toml index 9e997075..7766e0e3 100755 --- a/custom-allocator/Cargo.toml +++ b/custom-allocator/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] # We're going to use a different allocator than the one provided by ink!. To do that we # first need to disable the included memory allocator. -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } # todo #foo = { path = "../../../foo", default-features = false } @@ -17,7 +17,7 @@ ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = #bumpalo = "3.16.0" [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/custom-environment/Cargo.toml b/custom-environment/Cargo.toml index 72cfb986..29b8d6fa 100644 --- a/custom-environment/Cargo.toml +++ b/custom-environment/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/dns/Cargo.toml b/dns/Cargo.toml index fac971f0..e7ba2728 100644 --- a/dns/Cargo.toml +++ b/dns/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/e2e-call-runtime/Cargo.toml b/e2e-call-runtime/Cargo.toml index 46edefca..3dc93ee0 100644 --- a/e2e-call-runtime/Cargo.toml +++ b/e2e-call-runtime/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/e2e-runtime-only-backend/Cargo.toml b/e2e-runtime-only-backend/Cargo.toml index 68f86c93..65d07527 100644 --- a/e2e-runtime-only-backend/Cargo.toml +++ b/e2e-runtime-only-backend/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/erc1155/Cargo.toml b/erc1155/Cargo.toml index 576acbae..80aaa916 100644 --- a/erc1155/Cargo.toml +++ b/erc1155/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/erc20/Cargo.toml b/erc20/Cargo.toml index b0ef5edd..c981db1a 100644 --- a/erc20/Cargo.toml +++ b/erc20/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/erc721/Cargo.toml b/erc721/Cargo.toml index cbcd6c40..48f19724 100644 --- a/erc721/Cargo.toml +++ b/erc721/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/events/Cargo.toml b/events/Cargo.toml index cab169d6..4de7f6d3 100644 --- a/events/Cargo.toml +++ b/events/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } event-def = { path = "event-def", default-features = false } event-def2 = { path = "event-def2", default-features = false } event-def-unused = { path = "event-def-unused", default-features = false } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/events/event-def-unused/Cargo.toml b/events/event-def-unused/Cargo.toml index d32505ca..cf20e8bc 100644 --- a/events/event-def-unused/Cargo.toml +++ b/events/event-def-unused/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/events/event-def/Cargo.toml b/events/event-def/Cargo.toml index 0066ca9d..4f622cf2 100644 --- a/events/event-def/Cargo.toml +++ b/events/event-def/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/events/event-def2/Cargo.toml b/events/event-def2/Cargo.toml index ca4f3857..a38b6234 100644 --- a/events/event-def2/Cargo.toml +++ b/events/event-def2/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/flipper/Cargo.toml b/flipper/Cargo.toml index 7a1a5991..8017b8cd 100644 --- a/flipper/Cargo.toml +++ b/flipper/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } hex = { version = "0.4.3" } [lib] diff --git a/incrementer/Cargo.toml b/incrementer/Cargo.toml index 718a74a6..2dc6997f 100644 --- a/incrementer/Cargo.toml +++ b/incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/lazyvec/Cargo.toml b/lazyvec/Cargo.toml index 1b6a1115..d17cb4f4 100755 --- a/lazyvec/Cargo.toml +++ b/lazyvec/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/mapping/Cargo.toml b/mapping/Cargo.toml index 793bc044..30834c43 100755 --- a/mapping/Cargo.toml +++ b/mapping/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/multi-contract-caller/Cargo.toml b/multi-contract-caller/Cargo.toml index 8971aec2..2ab9ad13 100644 --- a/multi-contract-caller/Cargo.toml +++ b/multi-contract-caller/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } adder = { path = "adder", default-features = false, features = ["ink-as-dependency"] } subber = { path = "subber", default-features = false, features = ["ink-as-dependency"] } accumulator = { path = "accumulator", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/multi-contract-caller/accumulator/Cargo.toml b/multi-contract-caller/accumulator/Cargo.toml index bd1cc14d..14a2ff8a 100644 --- a/multi-contract-caller/accumulator/Cargo.toml +++ b/multi-contract-caller/accumulator/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/multi-contract-caller/adder/Cargo.toml b/multi-contract-caller/adder/Cargo.toml index d13473c5..1830e9eb 100644 --- a/multi-contract-caller/adder/Cargo.toml +++ b/multi-contract-caller/adder/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multi-contract-caller/subber/Cargo.toml b/multi-contract-caller/subber/Cargo.toml index d31e6705..06fd38be 100644 --- a/multi-contract-caller/subber/Cargo.toml +++ b/multi-contract-caller/subber/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index a19950d0..c89f219c 100755 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/payment-channel/Cargo.toml b/payment-channel/Cargo.toml index d1cd8213..1b1b43d8 100755 --- a/payment-channel/Cargo.toml +++ b/payment-channel/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] diff --git a/psp22-extension/Cargo.toml b/psp22-extension/Cargo.toml index 4b58f72a..ec053c24 100755 --- a/psp22-extension/Cargo.toml +++ b/psp22-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/rand-extension/Cargo.toml b/rand-extension/Cargo.toml index 6a9afc53..dac84ece 100755 --- a/rand-extension/Cargo.toml +++ b/rand-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/runtime-call-contract/Cargo.toml b/runtime-call-contract/Cargo.toml index d9a89412..c31987b4 100644 --- a/runtime-call-contract/Cargo.toml +++ b/runtime-call-contract/Cargo.toml @@ -28,11 +28,11 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } flipper-traits = { path = "traits", default-features = false } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } sandbox-runtime = { path = "sandbox-runtime", default-features = false } scale-value = "0.18.0" # can't use workspace dependency because of `cargo-contract` build not diff --git a/static-buffer/Cargo.toml b/static-buffer/Cargo.toml index a27143ec..ff219fcb 100644 --- a/static-buffer/Cargo.toml +++ b/static-buffer/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/trait-dyn-cross-contract-calls/Cargo.toml b/trait-dyn-cross-contract-calls/Cargo.toml index 2f7ba75a..d28d8780 100644 --- a/trait-dyn-cross-contract-calls/Cargo.toml +++ b/trait-dyn-cross-contract-calls/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } dyn-traits = { path = "./traits", default-features = false } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } trait-incrementer = { path = "./contracts/incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml index ef564789..6f7273e1 100644 --- a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml +++ b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } dyn-traits = { path = "../../traits", default-features = false } diff --git a/trait-dyn-cross-contract-calls/traits/Cargo.toml b/trait-dyn-cross-contract-calls/traits/Cargo.toml index 9a0855ec..985946cc 100644 --- a/trait-dyn-cross-contract-calls/traits/Cargo.toml +++ b/trait-dyn-cross-contract-calls/traits/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-erc20/Cargo.toml b/trait-erc20/Cargo.toml index 917e5be9..56b3690e 100644 --- a/trait-erc20/Cargo.toml +++ b/trait-erc20/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-flipper/Cargo.toml b/trait-flipper/Cargo.toml index 8d23fd2e..696969aa 100644 --- a/trait-flipper/Cargo.toml +++ b/trait-flipper/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-incrementer/Cargo.toml b/trait-incrementer/Cargo.toml index f73ccecd..43a046c9 100644 --- a/trait-incrementer/Cargo.toml +++ b/trait-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } traits = { path = "./traits", default-features = false } diff --git a/trait-incrementer/traits/Cargo.toml b/trait-incrementer/traits/Cargo.toml index 830db3cd..1ca80dfa 100644 --- a/trait-incrementer/traits/Cargo.toml +++ b/trait-incrementer/traits/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/Cargo.toml b/upgradeable-contracts/delegator/Cargo.toml index 1bf4f521..265191e9 100644 --- a/upgradeable-contracts/delegator/Cargo.toml +++ b/upgradeable-contracts/delegator/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } delegatee = { path = "delegatee", default-features = false, features = ["ink-as-dependency"] } delegatee2 = { path = "delegatee2", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee/Cargo.toml b/upgradeable-contracts/delegator/delegatee/Cargo.toml index 624601ee..4de432b3 100644 --- a/upgradeable-contracts/delegator/delegatee/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee2/Cargo.toml b/upgradeable-contracts/delegator/delegatee2/Cargo.toml index ed6c8c23..1e78227a 100644 --- a/upgradeable-contracts/delegator/delegatee2/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee2/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/Cargo.toml index af313db7..1e82bb24 100644 --- a/upgradeable-contracts/set-code-hash-migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/Cargo.toml @@ -6,13 +6,13 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } migration = { path = "./migration", default-features = false, features = ["ink-as-dependency"] } updated-incrementer = { path = "./updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml index 0f4db4a8..bfed27a4 100644 --- a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml index 5a7d12d7..cbdd2fee 100644 --- a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash/Cargo.toml b/upgradeable-contracts/set-code-hash/Cargo.toml index c28d4ad4..7b3e076d 100644 --- a/upgradeable-contracts/set-code-hash/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } updated-incrementer = { path = "updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml index 5a7d12d7..cbdd2fee 100644 --- a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index 790c453f..e84fe807 100755 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] diff --git a/wildcard-selector/Cargo.toml b/wildcard-selector/Cargo.toml index 0e784a42..33569380 100644 --- a/wildcard-selector/Cargo.toml +++ b/wildcard-selector/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink_e2e = { version = "6.0.0-alpha", default-features = false } [lib] path = "lib.rs" diff --git a/workspace-contracts/Cargo.toml b/workspace-contracts/Cargo.toml index 56898516..74d52770 100644 --- a/workspace-contracts/Cargo.toml +++ b/workspace-contracts/Cargo.toml @@ -4,5 +4,5 @@ exclude = [".cargo", "target"] resolver = "2" [workspace.dependencies] -ink = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } -ink_e2e = { git = "https://github.com/use-ink/ink.git", branch = "master", version = "6.0.0-alpha", default-features = false } +ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink_e2e = { version = "6.0.0-alpha", default-features = false } From 10d896ee5058744b006908e82ef40d43b99660e7 Mon Sep 17 00:00:00 2001 From: AlexD10S Date: Wed, 16 Jul 2025 13:29:12 +0200 Subject: [PATCH 4/4] chore: update examples dependencies --- basic-contract-caller/Cargo.toml | 4 ++-- basic-contract-caller/other-contract/Cargo.toml | 4 ++-- call-runtime/Cargo.toml | 4 ++-- combined-extension/Cargo.toml | 2 +- conditional-compilation/Cargo.toml | 4 ++-- contract-storage/Cargo.toml | 4 ++-- contract-terminate/Cargo.toml | 4 ++-- contract-transfer/Cargo.toml | 4 ++-- contract-xcm/Cargo.toml | 4 ++-- cross-contract-calls/Cargo.toml | 4 ++-- cross-contract-calls/other-contract/Cargo.toml | 4 ++-- custom-allocator/Cargo.toml | 4 ++-- custom-environment/Cargo.toml | 4 ++-- dns/Cargo.toml | 2 +- e2e-call-runtime/Cargo.toml | 4 ++-- e2e-runtime-only-backend/Cargo.toml | 4 ++-- erc1155/Cargo.toml | 2 +- erc20/Cargo.toml | 4 ++-- erc721/Cargo.toml | 2 +- events/Cargo.toml | 4 ++-- events/event-def-unused/Cargo.toml | 2 +- events/event-def/Cargo.toml | 2 +- events/event-def2/Cargo.toml | 2 +- flipper/Cargo.toml | 4 ++-- incrementer/Cargo.toml | 2 +- lazyvec/Cargo.toml | 4 ++-- mapping/Cargo.toml | 4 ++-- multi-contract-caller/Cargo.toml | 4 ++-- multi-contract-caller/accumulator/Cargo.toml | 2 +- multi-contract-caller/adder/Cargo.toml | 2 +- multi-contract-caller/subber/Cargo.toml | 2 +- multisig/Cargo.toml | 2 +- payment-channel/Cargo.toml | 2 +- psp22-extension/Cargo.toml | 2 +- rand-extension/Cargo.toml | 2 +- runtime-call-contract/Cargo.toml | 4 ++-- static-buffer/Cargo.toml | 4 ++-- trait-dyn-cross-contract-calls/Cargo.toml | 4 ++-- .../contracts/incrementer/Cargo.toml | 2 +- trait-dyn-cross-contract-calls/traits/Cargo.toml | 2 +- trait-erc20/Cargo.toml | 2 +- trait-flipper/Cargo.toml | 2 +- trait-incrementer/Cargo.toml | 2 +- trait-incrementer/traits/Cargo.toml | 2 +- upgradeable-contracts/delegator/Cargo.toml | 4 ++-- upgradeable-contracts/delegator/delegatee/Cargo.toml | 2 +- upgradeable-contracts/delegator/delegatee2/Cargo.toml | 2 +- upgradeable-contracts/set-code-hash-migration/Cargo.toml | 4 ++-- .../set-code-hash-migration/migration/Cargo.toml | 2 +- .../set-code-hash-migration/updated-incrementer/Cargo.toml | 2 +- upgradeable-contracts/set-code-hash/Cargo.toml | 4 ++-- .../set-code-hash/updated-incrementer/Cargo.toml | 2 +- vesting/Cargo.toml | 2 +- wildcard-selector/Cargo.toml | 4 ++-- workspace-contracts/Cargo.toml | 4 ++-- 55 files changed, 83 insertions(+), 83 deletions(-) diff --git a/basic-contract-caller/Cargo.toml b/basic-contract-caller/Cargo.toml index b0f35a7a..6060ee4d 100755 --- a/basic-contract-caller/Cargo.toml +++ b/basic-contract-caller/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } # Note: We **need** to specify the `ink-as-dependency` feature. # @@ -14,7 +14,7 @@ ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable other-contract = { path = "other-contract", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/basic-contract-caller/other-contract/Cargo.toml b/basic-contract-caller/other-contract/Cargo.toml index 6d1cc739..029f8aa0 100755 --- a/basic-contract-caller/other-contract/Cargo.toml +++ b/basic-contract-caller/other-contract/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/call-runtime/Cargo.toml b/call-runtime/Cargo.toml index 4e3a04e5..b83c5322 100644 --- a/call-runtime/Cargo.toml +++ b/call-runtime/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } # We need to explicitly turn off some of the `sp-io` features, to avoid conflicts @@ -18,7 +18,7 @@ sp-io = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01e sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["disable_target_static_assertions"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/combined-extension/Cargo.toml b/combined-extension/Cargo.toml index 957cdb90..f939306e 100755 --- a/combined-extension/Cargo.toml +++ b/combined-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } psp22_extension = { path = "../psp22-extension", default-features = false, features = ["ink-as-dependency"] } rand_extension = { path = "../rand-extension", default-features = false, features = ["ink-as-dependency"] } diff --git a/conditional-compilation/Cargo.toml b/conditional-compilation/Cargo.toml index 9d620737..7652401e 100755 --- a/conditional-compilation/Cargo.toml +++ b/conditional-compilation/Cargo.toml @@ -5,10 +5,10 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/contract-storage/Cargo.toml b/contract-storage/Cargo.toml index e78d0c7a..e4cf644a 100755 --- a/contract-storage/Cargo.toml +++ b/contract-storage/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/contract-terminate/Cargo.toml b/contract-terminate/Cargo.toml index 71e99826..053ea513 100644 --- a/contract-terminate/Cargo.toml +++ b/contract-terminate/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/contract-transfer/Cargo.toml b/contract-transfer/Cargo.toml index 9010dcca..cf86facc 100644 --- a/contract-transfer/Cargo.toml +++ b/contract-transfer/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/contract-xcm/Cargo.toml b/contract-xcm/Cargo.toml index 5e7d9c67..110c2c89 100644 --- a/contract-xcm/Cargo.toml +++ b/contract-xcm/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } frame-support = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } pallet-balances = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["sandbox"] } [lib] path = "lib.rs" diff --git a/cross-contract-calls/Cargo.toml b/cross-contract-calls/Cargo.toml index 29adb40a..db858dbc 100755 --- a/cross-contract-calls/Cargo.toml +++ b/cross-contract-calls/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } # Note: We **need** to specify the `ink-as-dependency` feature. # @@ -15,7 +15,7 @@ other-contract = { path = "other-contract", default-features = false, features = pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/cross-contract-calls/other-contract/Cargo.toml b/cross-contract-calls/other-contract/Cargo.toml index 001b76b4..8db2e3a0 100755 --- a/cross-contract-calls/other-contract/Cargo.toml +++ b/cross-contract-calls/other-contract/Cargo.toml @@ -6,11 +6,11 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } pallet-revive-uapi = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/custom-allocator/Cargo.toml b/custom-allocator/Cargo.toml index 7766e0e3..cf6e4498 100755 --- a/custom-allocator/Cargo.toml +++ b/custom-allocator/Cargo.toml @@ -8,7 +8,7 @@ publish = false [dependencies] # We're going to use a different allocator than the one provided by ink!. To do that we # first need to disable the included memory allocator. -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } # todo #foo = { path = "../../../foo", default-features = false } @@ -17,7 +17,7 @@ ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable #bumpalo = "3.16.0" [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/custom-environment/Cargo.toml b/custom-environment/Cargo.toml index 29b8d6fa..f41b185a 100644 --- a/custom-environment/Cargo.toml +++ b/custom-environment/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/dns/Cargo.toml b/dns/Cargo.toml index e7ba2728..7397d5f0 100644 --- a/dns/Cargo.toml +++ b/dns/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/e2e-call-runtime/Cargo.toml b/e2e-call-runtime/Cargo.toml index 3dc93ee0..3d69ae18 100644 --- a/e2e-call-runtime/Cargo.toml +++ b/e2e-call-runtime/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/e2e-runtime-only-backend/Cargo.toml b/e2e-runtime-only-backend/Cargo.toml index 65d07527..04899063 100644 --- a/e2e-runtime-only-backend/Cargo.toml +++ b/e2e-runtime-only-backend/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/erc1155/Cargo.toml b/erc1155/Cargo.toml index 80aaa916..5db50b65 100644 --- a/erc1155/Cargo.toml +++ b/erc1155/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/erc20/Cargo.toml b/erc20/Cargo.toml index c981db1a..2c38cbe5 100644 --- a/erc20/Cargo.toml +++ b/erc20/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/erc721/Cargo.toml b/erc721/Cargo.toml index 48f19724..3098843c 100644 --- a/erc721/Cargo.toml +++ b/erc721/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/events/Cargo.toml b/events/Cargo.toml index 4de7f6d3..f40440aa 100644 --- a/events/Cargo.toml +++ b/events/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } event-def = { path = "event-def", default-features = false } event-def2 = { path = "event-def2", default-features = false } event-def-unused = { path = "event-def-unused", default-features = false } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/events/event-def-unused/Cargo.toml b/events/event-def-unused/Cargo.toml index cf20e8bc..97c68e98 100644 --- a/events/event-def-unused/Cargo.toml +++ b/events/event-def-unused/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/events/event-def/Cargo.toml b/events/event-def/Cargo.toml index 4f622cf2..de3c500b 100644 --- a/events/event-def/Cargo.toml +++ b/events/event-def/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/events/event-def2/Cargo.toml b/events/event-def2/Cargo.toml index a38b6234..ca78639f 100644 --- a/events/event-def2/Cargo.toml +++ b/events/event-def2/Cargo.toml @@ -5,7 +5,7 @@ version = "0.1.0" edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "src/lib.rs" diff --git a/flipper/Cargo.toml b/flipper/Cargo.toml index 8017b8cd..f7539320 100644 --- a/flipper/Cargo.toml +++ b/flipper/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["sandbox"] } hex = { version = "0.4.3" } [lib] diff --git a/incrementer/Cargo.toml b/incrementer/Cargo.toml index 2dc6997f..35f30f30 100644 --- a/incrementer/Cargo.toml +++ b/incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/lazyvec/Cargo.toml b/lazyvec/Cargo.toml index d17cb4f4..172306fc 100755 --- a/lazyvec/Cargo.toml +++ b/lazyvec/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/mapping/Cargo.toml b/mapping/Cargo.toml index 30834c43..270f5738 100755 --- a/mapping/Cargo.toml +++ b/mapping/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/multi-contract-caller/Cargo.toml b/multi-contract-caller/Cargo.toml index 2ab9ad13..502f5cba 100644 --- a/multi-contract-caller/Cargo.toml +++ b/multi-contract-caller/Cargo.toml @@ -6,14 +6,14 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } adder = { path = "adder", default-features = false, features = ["ink-as-dependency"] } subber = { path = "subber", default-features = false, features = ["ink-as-dependency"] } accumulator = { path = "accumulator", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/multi-contract-caller/accumulator/Cargo.toml b/multi-contract-caller/accumulator/Cargo.toml index 14a2ff8a..86fca797 100644 --- a/multi-contract-caller/accumulator/Cargo.toml +++ b/multi-contract-caller/accumulator/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/multi-contract-caller/adder/Cargo.toml b/multi-contract-caller/adder/Cargo.toml index 1830e9eb..695c63a6 100644 --- a/multi-contract-caller/adder/Cargo.toml +++ b/multi-contract-caller/adder/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multi-contract-caller/subber/Cargo.toml b/multi-contract-caller/subber/Cargo.toml index 06fd38be..d74f0653 100644 --- a/multi-contract-caller/subber/Cargo.toml +++ b/multi-contract-caller/subber/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } accumulator = { path = "../accumulator", default-features = false, features = ["ink-as-dependency"] } diff --git a/multisig/Cargo.toml b/multisig/Cargo.toml index c89f219c..f6897653 100755 --- a/multisig/Cargo.toml +++ b/multisig/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/payment-channel/Cargo.toml b/payment-channel/Cargo.toml index 1b1b43d8..2bde16d7 100755 --- a/payment-channel/Cargo.toml +++ b/payment-channel/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } sp-core = { git = "https://github.com/paritytech/polkadot-sdk", rev = "f8c90b2a01ec77579bccd21ae17bd6ff2eeffd6a", default-features = false } [dev-dependencies] diff --git a/psp22-extension/Cargo.toml b/psp22-extension/Cargo.toml index ec053c24..65645ef0 100755 --- a/psp22-extension/Cargo.toml +++ b/psp22-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/rand-extension/Cargo.toml b/rand-extension/Cargo.toml index dac84ece..d53a2384 100755 --- a/rand-extension/Cargo.toml +++ b/rand-extension/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/runtime-call-contract/Cargo.toml b/runtime-call-contract/Cargo.toml index c31987b4..aeb54b37 100644 --- a/runtime-call-contract/Cargo.toml +++ b/runtime-call-contract/Cargo.toml @@ -28,11 +28,11 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } flipper-traits = { path = "traits", default-features = false } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false, features = ["sandbox"] } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["sandbox"] } sandbox-runtime = { path = "sandbox-runtime", default-features = false } scale-value = "0.18.0" # can't use workspace dependency because of `cargo-contract` build not diff --git a/static-buffer/Cargo.toml b/static-buffer/Cargo.toml index ff219fcb..2f4f7ee4 100644 --- a/static-buffer/Cargo.toml +++ b/static-buffer/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/trait-dyn-cross-contract-calls/Cargo.toml b/trait-dyn-cross-contract-calls/Cargo.toml index d28d8780..f4ce756e 100644 --- a/trait-dyn-cross-contract-calls/Cargo.toml +++ b/trait-dyn-cross-contract-calls/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } dyn-traits = { path = "./traits", default-features = false } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } trait-incrementer = { path = "./contracts/incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml index 6f7273e1..19618813 100644 --- a/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml +++ b/trait-dyn-cross-contract-calls/contracts/incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } dyn-traits = { path = "../../traits", default-features = false } diff --git a/trait-dyn-cross-contract-calls/traits/Cargo.toml b/trait-dyn-cross-contract-calls/traits/Cargo.toml index 985946cc..ac900d2a 100644 --- a/trait-dyn-cross-contract-calls/traits/Cargo.toml +++ b/trait-dyn-cross-contract-calls/traits/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-erc20/Cargo.toml b/trait-erc20/Cargo.toml index 56b3690e..24caedcc 100644 --- a/trait-erc20/Cargo.toml +++ b/trait-erc20/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-flipper/Cargo.toml b/trait-flipper/Cargo.toml index 696969aa..2bfdfcbe 100644 --- a/trait-flipper/Cargo.toml +++ b/trait-flipper/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/trait-incrementer/Cargo.toml b/trait-incrementer/Cargo.toml index 43a046c9..db09e111 100644 --- a/trait-incrementer/Cargo.toml +++ b/trait-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } traits = { path = "./traits", default-features = false } diff --git a/trait-incrementer/traits/Cargo.toml b/trait-incrementer/traits/Cargo.toml index 1ca80dfa..3a22f295 100644 --- a/trait-incrementer/traits/Cargo.toml +++ b/trait-incrementer/traits/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/Cargo.toml b/upgradeable-contracts/delegator/Cargo.toml index 265191e9..715ca328 100644 --- a/upgradeable-contracts/delegator/Cargo.toml +++ b/upgradeable-contracts/delegator/Cargo.toml @@ -6,12 +6,12 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } delegatee = { path = "delegatee", default-features = false, features = ["ink-as-dependency"] } delegatee2 = { path = "delegatee2", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee/Cargo.toml b/upgradeable-contracts/delegator/delegatee/Cargo.toml index 4de432b3..9370d7b8 100644 --- a/upgradeable-contracts/delegator/delegatee/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/delegator/delegatee2/Cargo.toml b/upgradeable-contracts/delegator/delegatee2/Cargo.toml index 1e78227a..e615d6ed 100644 --- a/upgradeable-contracts/delegator/delegatee2/Cargo.toml +++ b/upgradeable-contracts/delegator/delegatee2/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/Cargo.toml index 1e82bb24..70f2ae71 100644 --- a/upgradeable-contracts/set-code-hash-migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/Cargo.toml @@ -6,13 +6,13 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } migration = { path = "./migration", default-features = false, features = ["ink-as-dependency"] } updated-incrementer = { path = "./updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml index bfed27a4..e99f72e4 100644 --- a/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/migration/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml index cbdd2fee..b9be5e3e 100644 --- a/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash-migration/updated-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/upgradeable-contracts/set-code-hash/Cargo.toml b/upgradeable-contracts/set-code-hash/Cargo.toml index 7b3e076d..b7f7a934 100644 --- a/upgradeable-contracts/set-code-hash/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } updated-incrementer = { path = "updated-incrementer", default-features = false, features = ["ink-as-dependency"] } [lib] diff --git a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml index cbdd2fee..b9be5e3e 100644 --- a/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml +++ b/upgradeable-contracts/set-code-hash/updated-incrementer/Cargo.toml @@ -6,7 +6,7 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [lib] path = "lib.rs" diff --git a/vesting/Cargo.toml b/vesting/Cargo.toml index e84fe807..87de5e17 100755 --- a/vesting/Cargo.toml +++ b/vesting/Cargo.toml @@ -5,7 +5,7 @@ authors = ["Use Ink "] edition = "2021" [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] diff --git a/wildcard-selector/Cargo.toml b/wildcard-selector/Cargo.toml index 33569380..e8b46d39 100644 --- a/wildcard-selector/Cargo.toml +++ b/wildcard-selector/Cargo.toml @@ -6,10 +6,10 @@ edition = "2021" publish = false [dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } [dev-dependencies] -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false } [lib] path = "lib.rs" diff --git a/workspace-contracts/Cargo.toml b/workspace-contracts/Cargo.toml index 74d52770..399da70f 100644 --- a/workspace-contracts/Cargo.toml +++ b/workspace-contracts/Cargo.toml @@ -4,5 +4,5 @@ exclude = [".cargo", "target"] resolver = "2" [workspace.dependencies] -ink = { version = "6.0.0-alpha", default-features = false, features = ["unstable-hostfn"] } -ink_e2e = { version = "6.0.0-alpha", default-features = false } +ink = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false, features = ["unstable-hostfn"] } +ink_e2e = { git = "https://github.com/use-ink/ink", branch = "master", default-features = false }