diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5be424330..796ebdb87 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -56,10 +56,10 @@ jobs: with: node-version: '16.x' - uses: actions/checkout@v3 - - name: Yarn install dependencies + - name: NPM install dependencies run: | - yarn - yarn add ts-node + npm i + npm i ts-node - name: Cache rust artifacts id: cache-rust-artifacts @@ -81,7 +81,7 @@ jobs: run: | chown -R root . chmod -R a+rwx . - yarn build:release + npm run build:release caching-artifacts: concurrency: group: caching-artifacts-${{ github.ref }} @@ -144,10 +144,10 @@ jobs: with: ref: main - - name: Yarn install dependencies for destination branch + - name: NPM install dependencies for destination branch run: | - yarn - yarn add ts-node + npm i + npm i ts-node - name: Cache rust artifacts for destination branch id: cache-rust-artifacts-destination @@ -162,7 +162,7 @@ jobs: run: | chown -R root . chmod -R a+rwx . - yarn build:release + npm run build:release - name: Find contract data destination branch id: find-data-destination @@ -216,10 +216,10 @@ jobs: with: node-version: '16.x' - uses: actions/checkout@v3 - - name: Yarn install dependencies + - name: NPM install dependencies run: | - yarn - yarn add ts-node + npm i + npm i ts-node - name: Cache contract artifacts id: cache-contract-artifacts @@ -230,7 +230,7 @@ jobs: - name: Generate Typechain code run: - yarn build:release:no-compile + npm run build:release:no-compile - name: Run Test Mocha run: | @@ -240,13 +240,13 @@ jobs: do substrate-contracts-node --tmp --dev & P1=$!; set +e; - output=$(yarn test:mocha-single ./$test || true); + output=$(npm run test:mocha-single ./$test || true); set -e; if echo $output | grep -q 'For async tests and hooks, ensure "done()" is called'; then echo $output; has_timeout=true else - yarn test:mocha-single ./$test + npm run test:mocha-single ./$test has_timeout=false fi kill $P1; diff --git a/Cargo.toml b/Cargo.toml index 63e451811..5806dc835 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ exclude = [ [package] name = "openbrush" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2018" @@ -27,12 +27,12 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs"] [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } -openbrush_contracts = { version = "~3.0.0-beta", path = "contracts", default-features = false } -openbrush_lang = { version = "~3.0.0-beta", path = "lang", default-features = false } +openbrush_contracts = { version = "~3.0.0-beta.1", path = "contracts", default-features = false } +openbrush_lang = { version = "~3.0.0-beta.1", path = "lang", default-features = false } [lib] name = "openbrush" diff --git a/README.md b/README.md index d17fe29df..fe9aab57e 100644 --- a/README.md +++ b/README.md @@ -203,7 +203,7 @@ You can run unit tests by `RUSTFLAGS="-D warnings" cargo +nightly test --workspa To run integration test you need to start the node with contract-pallet. - [Setup and start the node with contract-pallet](https://github.com/paritytech/substrate-contracts-node) -After you can run tests by `yarn run test` command. It will build all contracts required for integration tests and run them. +After you can run tests by `npm run test` command. It will build all contracts required for integration tests and run them. ## FAQ diff --git a/contracts/Cargo.toml b/contracts/Cargo.toml index f4a60bc6a..143fd8a3c 100644 --- a/contracts/Cargo.toml +++ b/contracts/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openbrush_contracts" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" @@ -15,13 +15,13 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs"] [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } -openbrush = { version = "~3.0.0-beta", package = "openbrush_lang", path = "../lang", default-features = false } +openbrush = { version = "~3.0.0-beta.1", package = "openbrush_lang", path = "../lang", default-features = false } -pallet-assets-chain-extension = { git = "https://github.com/727-ventures/pallet-assets-chain-extension", tag = "3.0.0-beta", default-features = false, features = ["ink-lang"] } +pallet-assets-chain-extension = { git = "https://github.com/727-ventures/pallet-assets-chain-extension", branch = "ink-4-beta", default-features = false, features = ["ink-lang"] } [lib] name = "openbrush_contracts" diff --git a/contracts/src/access/ownable/mod.rs b/contracts/src/access/ownable/mod.rs index c70fd12fd..79f02c1f1 100644 --- a/contracts/src/access/ownable/mod.rs +++ b/contracts/src/access/ownable/mod.rs @@ -37,13 +37,22 @@ pub use ownable::Internal as _; pub const STORAGE_KEY: u32 = openbrush::storage_unique_key!(Data); -#[derive(Default, Debug)] +#[derive(Debug)] #[openbrush::upgradeable_storage(STORAGE_KEY)] pub struct Data { pub owner: AccountId, pub _reserved: Option<()>, } +impl Default for Data { + fn default() -> Self { + Self { + owner: ZERO_ADDRESS.into(), + _reserved: Default::default(), + } + } +} + /// Throws if called by any account other than the owner. #[modifier_definition] pub fn only_owner(instance: &mut T, body: F) -> Result diff --git a/contracts/src/governance/timelock_controller/mod.rs b/contracts/src/governance/timelock_controller/mod.rs index 6c9b501e5..7616efd77 100644 --- a/contracts/src/governance/timelock_controller/mod.rs +++ b/contracts/src/governance/timelock_controller/mod.rs @@ -445,21 +445,20 @@ where self.flush(); let result = build_call::() .call_type( - Call::new() - .callee(transaction.callee) + Call::new(transaction.callee) .gas_limit(transaction.gas_limit) .transferred_value(transaction.transferred_value), ) .exec_input(ExecutionInput::new(transaction.selector.into()).push_arg(CallInput(&transaction.input))) .returns::<()>() .call_flags(CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .map_err(|_| TimelockControllerError::UnderlyingTransactionReverted); // Load the sate of the contract after the cross call. self.load(); - result?; + result?.unwrap(); self._emit_call_executed_event(id, i, transaction); Ok(()) } diff --git a/contracts/src/token/psp22/extensions/flashmint.rs b/contracts/src/token/psp22/extensions/flashmint.rs index 5793223a0..ed7a6c62e 100644 --- a/contracts/src/token/psp22/extensions/flashmint.rs +++ b/contracts/src/token/psp22/extensions/flashmint.rs @@ -111,7 +111,7 @@ impl> Internal for T { let builder = FlashBorrowerRef::on_flashloan_builder(&receiver_account, Self::env().caller(), token, amount, fee, data) .call_flags(CallFlags::default().set_allow_reentry(true)); - let result = match builder.fire() { + let result = match builder.try_invoke() { Ok(Ok(Ok(_))) => Ok(()), Ok(Ok(Err(FlashBorrowerError::FlashloanRejected(message)))) => { Err(FlashLenderError::BorrowerRejected(message)) diff --git a/contracts/src/token/psp22/extensions/wrapper.rs b/contracts/src/token/psp22/extensions/wrapper.rs index 5157456d4..2b2c329d1 100644 --- a/contracts/src/token/psp22/extensions/wrapper.rs +++ b/contracts/src/token/psp22/extensions/wrapper.rs @@ -35,19 +35,29 @@ use openbrush::traits::{ AccountId, Balance, Storage, + ZERO_ADDRESS, }; pub use psp22::Internal as _; pub use wrapper::Internal as _; pub const STORAGE_KEY: u32 = openbrush::storage_unique_key!(Data); -#[derive(Default, Debug)] +#[derive(Debug)] #[openbrush::upgradeable_storage(STORAGE_KEY)] pub struct Data { pub underlying: AccountId, pub _reserved: Option<()>, } +impl Default for Data { + fn default() -> Self { + Self { + underlying: ZERO_ADDRESS.into(), + _reserved: Default::default(), + } + } +} + impl + Storage> PSP22Wrapper for T { default fn deposit_for(&mut self, account: AccountId, amount: Balance) -> Result<(), PSP22Error> { self._deposit(amount)?; @@ -94,7 +104,7 @@ impl + Storage> Internal for T { self._underlying() .transfer_from_builder(Self::env().caller(), Self::env().account_id(), amount, Vec::::new()) .call_flags(CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap() .unwrap() } @@ -103,7 +113,7 @@ impl + Storage> Internal for T { self._underlying() .transfer_builder(account, amount, Vec::::new()) .call_flags(CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap() .unwrap() } diff --git a/contracts/src/token/psp22/psp22.rs b/contracts/src/token/psp22/psp22.rs index 2c1d9fe00..dbd4b7919 100644 --- a/contracts/src/token/psp22/psp22.rs +++ b/contracts/src/token/psp22/psp22.rs @@ -183,7 +183,7 @@ impl> Internal for T { data.clone(), ) .call_flags(CallFlags::default().set_allow_reentry(true)); - let result = match builder.fire() { + let result = match builder.try_invoke() { Ok(Ok(Ok(_))) => Ok(()), Ok(Ok(Err(e))) => Err(e.into()), // Means unknown method diff --git a/contracts/src/token/psp22/utils/token_timelock.rs b/contracts/src/token/psp22/utils/token_timelock.rs index f4a6697d4..b03f29970 100644 --- a/contracts/src/token/psp22/utils/token_timelock.rs +++ b/contracts/src/token/psp22/utils/token_timelock.rs @@ -37,13 +37,14 @@ use openbrush::traits::{ Balance, Storage, Timestamp, + ZERO_ADDRESS, }; pub use psp22::Internal as _; pub use token_timelock::Internal as _; pub const STORAGE_KEY: u32 = openbrush::storage_unique_key!(Data); -#[derive(Default, Debug)] +#[derive(Debug)] #[openbrush::upgradeable_storage(STORAGE_KEY)] pub struct Data { token: AccountId, @@ -51,6 +52,16 @@ pub struct Data { release_time: Timestamp, } +impl Default for Data { + fn default() -> Self { + Self { + token: ZERO_ADDRESS.into(), + beneficiary: ZERO_ADDRESS.into(), + release_time: Default::default(), + } + } +} + impl> PSP22TokenTimelock for T { /// Returns the token address default fn token(&self) -> AccountId { @@ -101,11 +112,11 @@ pub trait Internal { impl> Internal for T { default fn _withdraw(&mut self, amount: Balance) -> Result<(), PSP22TokenTimelockError> { - let beneficairy = self.beneficiary(); + let beneficiary = self.beneficiary(); self._token() - .transfer_builder(beneficairy, amount, Vec::::new()) + .transfer_builder(beneficiary, amount, Vec::::new()) .call_flags(CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap() .unwrap()?; Ok(()) diff --git a/contracts/src/token/psp34/psp34.rs b/contracts/src/token/psp34/psp34.rs index 762c02d54..a65a5c17d 100644 --- a/contracts/src/token/psp34/psp34.rs +++ b/contracts/src/token/psp34/psp34.rs @@ -232,7 +232,7 @@ where let builder = PSP34ReceiverRef::before_received_builder(to, operator.clone(), from.clone(), id.clone(), data.clone()) .call_flags(CallFlags::default().set_allow_reentry(true)); - let b = builder.fire(); + let b = builder.try_invoke(); let result = match b { Ok(Ok(Ok(_))) => Ok(()), Ok(Ok(Err(e))) => Err(e.into()), diff --git a/contracts/src/token/psp37/psp37.rs b/contracts/src/token/psp37/psp37.rs index 8a4983741..6cd190164 100644 --- a/contracts/src/token/psp37/psp37.rs +++ b/contracts/src/token/psp37/psp37.rs @@ -396,7 +396,7 @@ where data.clone(), ) .call_flags(CallFlags::default().set_allow_reentry(true)); - let result = match builder.fire() { + let result = match builder.try_invoke() { Ok(Ok(Ok(_))) => Ok(()), Ok(Ok(Err(e))) => Err(e.into()), // `NotCallable` means that the receiver is not a contract. diff --git a/contracts/src/traits/timelock_controller/mod.rs b/contracts/src/traits/timelock_controller/mod.rs index f1722c2c1..958c0ec17 100644 --- a/contracts/src/traits/timelock_controller/mod.rs +++ b/contracts/src/traits/timelock_controller/mod.rs @@ -29,12 +29,13 @@ use openbrush::traits::{ Balance, Hash, Timestamp, + ZERO_ADDRESS, }; pub type OperationId = Hash; /// A Transaction is what can be executed by `executor` -#[derive(Default, Debug, Clone, PartialEq, scale::Encode, scale::Decode)] +#[derive(Debug, Clone, PartialEq, scale::Encode, scale::Decode)] #[cfg_attr(feature = "std", derive(scale_info::TypeInfo))] pub struct Transaction { /// The `AccountId` of the contract that is called in this transaction. @@ -49,6 +50,18 @@ pub struct Transaction { pub gas_limit: u64, } +impl Default for Transaction { + fn default() -> Self { + Self { + callee: ZERO_ADDRESS.into(), + selector: Default::default(), + input: Default::default(), + transferred_value: Default::default(), + gas_limit: Default::default(), + } + } +} + /// TimelockController is AccessControl itself, so creating wrapper for both traits #[openbrush::wrapper] pub type TimelockControllerRef = dyn TimelockController + AccessControl; diff --git a/contracts/src/upgradeability/diamond/diamond.rs b/contracts/src/upgradeability/diamond/diamond.rs index 1b60c99d1..ef772e40b 100644 --- a/contracts/src/upgradeability/diamond/diamond.rs +++ b/contracts/src/upgradeability/diamond/diamond.rs @@ -35,7 +35,6 @@ pub use ownable::Internal as _; use ink::{ env::call::{ - DelegateCall, ExecutionInput, Selector as InkSelector, }, @@ -180,7 +179,7 @@ where } ink::env::call::build_call::() - .call_type(DelegateCall::new().code_hash(delegate_code.unwrap())) + .delegate(delegate_code.unwrap()) .call_flags( ink::env::CallFlags::default() // We don't plan to use the input data after the delegated call, so the @@ -190,21 +189,21 @@ where // marked delegated call as "tail", to end the execution of the contract. .set_tail_call(true), ) - .fire() + .try_invoke() .unwrap_or_else(|err| panic!("delegate call to {:?} failed due to {:?}", delegate_code, err)); unreachable!("the _fallback call will never return since `tail_call` was set"); } default fn _init_call(&self, call: InitCall) -> ! { ink::env::call::build_call::() - .call_type(DelegateCall::new().code_hash(call.hash)) + .delegate(call.hash) .exec_input(ExecutionInput::new(InkSelector::new(call.selector)).push_arg(call.input)) .call_flags(ink::env::CallFlags::default() // We don't plan to return back to that contract after execution, so we // marked delegated call as "tail", to end the execution of the contract. .set_tail_call(true)) .returns::<()>() - .fire() + .try_invoke() .unwrap_or_else(|err| panic!("init call failed due to {:?}", err)); unreachable!("the _init_call call will never return since `tail_call` was set"); } diff --git a/contracts/src/upgradeability/proxy/mod.rs b/contracts/src/upgradeability/proxy/mod.rs index 008bfb057..edeeb0be5 100644 --- a/contracts/src/upgradeability/proxy/mod.rs +++ b/contracts/src/upgradeability/proxy/mod.rs @@ -33,7 +33,6 @@ pub use crate::{ pub use ownable::Internal as _; pub use proxy::Internal as _; -use ink::env::call::DelegateCall; use openbrush::{ modifiers, traits::{ @@ -82,7 +81,7 @@ impl> Internal for T { default fn _fallback(&self) -> ! { ink::env::call::build_call::() - .call_type(DelegateCall::new().code_hash(self.data().forward_to.clone())) + .delegate(self.data().forward_to.clone()) .call_flags( ink::env::CallFlags::default() // We don't plan to use the input data after the delegated call, so the @@ -92,7 +91,7 @@ impl> Internal for T { // marked delegated call as "tail", to end the execution of the contract. .set_tail_call(true), ) - .fire() + .try_invoke() .unwrap_or_else(|err| { panic!( "delegate call to {:?} failed due to {:?}", diff --git a/docs/docs/smart-contracts/example/contract.md b/docs/docs/smart-contracts/example/contract.md index b49248dc6..bdaaca921 100644 --- a/docs/docs/smart-contracts/example/contract.md +++ b/docs/docs/smart-contracts/example/contract.md @@ -16,7 +16,7 @@ implementation of `Lending` and `LendingPermissioned` traits defined in the `len ```toml [package] name = "lending_contract" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" @@ -29,7 +29,7 @@ scale-info = { version = "2.3", default-features = false, features = ["derive"], shares_contract = { path = "../shares", default-features = false, features = ["ink-as-dependency"] } loan_contract = { path = "../loan", default-features = false, features = ["ink-as-dependency"] } lending_project = { path = "../..", default-features = false } -openbrush = { version = "~3.0.0-beta", default-features = false, features = ["pausable", "access_control"] } +openbrush = { version = "~3.0.0-beta.1", default-features = false, features = ["pausable", "access_control"] } [lib] name = "lending_contract" diff --git a/docs/docs/smart-contracts/example/implementation.md b/docs/docs/smart-contracts/example/implementation.md index 0482a13cd..b3437f5c0 100644 --- a/docs/docs/smart-contracts/example/implementation.md +++ b/docs/docs/smart-contracts/example/implementation.md @@ -137,7 +137,7 @@ default fn lend_assets(&mut self, asset_address: AccountId, amount: Balance) -> // transfer the assets from user to the contract| PSP22Ref::transfer_from_builder(&asset_address, lender, contract, amount, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap()?; // if no assets were deposited yet we will mint the same amount of shares as deposited `amount` let new_shares = if total_asset == 0 { @@ -228,7 +228,7 @@ default fn borrow_assets( // we will transfer the collateral to the contract PSP22Ref::transfer_from_builder(&collateral_address, borrower, contract, amount, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap()?; // create loan info let loan_info = LoanInfo { diff --git a/docs/docs/smart-contracts/example/impls.md b/docs/docs/smart-contracts/example/impls.md index 111b93b3b..14147c3f4 100644 --- a/docs/docs/smart-contracts/example/impls.md +++ b/docs/docs/smart-contracts/example/impls.md @@ -594,7 +594,7 @@ impl + Storage> Lending for T { // transfer the assets from user to the contract| PSP22Ref::transfer_from_builder(&asset_address, lender, contract, amount, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap()?; // if no assets were deposited yet we will mint the same amount of shares as deposited `amount` let new_shares = if total_asset == 0 { @@ -650,7 +650,7 @@ impl + Storage> Lending for T { // we will transfer the collateral to the contract PSP22Ref::transfer_from_builder(&collateral_address, borrower, contract, amount, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap()?; // create loan info let loan_info = LoanInfo { @@ -704,7 +704,7 @@ impl + Storage> Lending for T { if repay_amount >= to_repay { PSP22Ref::transfer_from_builder(&loan_info.borrow_token, initiator, contract, to_repay, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap()?; PSP22Ref::transfer( &loan_info.collateral_token, @@ -723,7 +723,7 @@ impl + Storage> Lending for T { Vec::::new(), ) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap()?; let to_return = (repay_amount * loan_info.collateral_amount) / to_repay; PSP22Ref::transfer(&loan_info.collateral_token, initiator, to_return, Vec::::new())?; diff --git a/docs/docs/smart-contracts/overview.md b/docs/docs/smart-contracts/overview.md index c6f7afd1f..bc559341f 100644 --- a/docs/docs/smart-contracts/overview.md +++ b/docs/docs/smart-contracts/overview.md @@ -18,13 +18,13 @@ It doesn't contain [versioning](https://github.com/supercolony-net/openbrush-con ```toml [dependencies] # Import ink! -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } # Brush dependency -openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta", default-features = false } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta.1", default-features = false } [features] default = ["std"] @@ -73,17 +73,17 @@ The name of the feature is the same as the name of the module. For example: To enable `psp22`: ```toml -openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta", default-features = false, features = ["psp22"] } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta.1", default-features = false, features = ["psp22"] } ``` To enable `ownable`: ```toml -openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta", default-features = false, features = ["ownable"] } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta.1", default-features = false, features = ["ownable"] } ``` To enable both: ```toml -openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta", default-features = false, features = ["psp22, ownable"] } +openbrush = { git = "https://github.com/727-Ventures/openbrush-contracts", version = "~3.0.0-beta.1", default-features = false, features = ["psp22, ownable"] } ``` After enabling the feature and importing the corresponding module, you need to embed the module diff --git a/docs/docs/smart-contracts/upgradeable.md b/docs/docs/smart-contracts/upgradeable.md index 35fb6ed6c..27458ca43 100644 --- a/docs/docs/smart-contracts/upgradeable.md +++ b/docs/docs/smart-contracts/upgradeable.md @@ -208,7 +208,7 @@ pub struct Data { ### Disclaimer -The following information describes `Proxy` and `Diamond` patterns of upgradeable storage, which currently don't work in ink! 4 due to `DelegateCall`, but we will leave it here for the future updates of this feature (and also for the OpenBrush versions before `3.0.0-beta`). +The following information describes `Proxy` and `Diamond` patterns of upgradeable storage, which currently don't work in ink! 4 due to `DelegateCall`, but we will leave it here for the future updates of this feature (and also for the OpenBrush versions before `3.0.0-beta.1`). Uploading your contract on the blockchain with `contract-pallet` has two phases: - Deploy - deploys source code to the blockchain. After deploying, the network uses the hash of the source code as an identifier for future instantiation of the contract. Now anyone can instantiate the contract by source code hash. @@ -546,7 +546,7 @@ pub mod facet_b { // It needs to allow reentrancy if it wants to execute itself. PSP22Ref::balance_of_builder(&address_of_current_contract, owner) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap(); } diff --git a/example_project_structure/Cargo.toml b/example_project_structure/Cargo.toml index fd0833223..6c49a529a 100644 --- a/example_project_structure/Cargo.toml +++ b/example_project_structure/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "lending_project" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/example_project_structure/contracts/lending/Cargo.toml b/example_project_structure/contracts/lending/Cargo.toml index bc17a319d..9bec3f7f3 100644 --- a/example_project_structure/contracts/lending/Cargo.toml +++ b/example_project_structure/contracts/lending/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "lending_contract" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/example_project_structure/contracts/lending/lib.rs b/example_project_structure/contracts/lending/lib.rs index 8d5218a73..921cadb0f 100644 --- a/example_project_structure/contracts/lending/lib.rs +++ b/example_project_structure/contracts/lending/lib.rs @@ -87,8 +87,7 @@ pub mod my_lending { .endowment(0) .code_hash(code_hash) .salt_bytes(&hash[..4]) - .instantiate() - .unwrap(); + .instantiate(); contract.to_account_id() } } @@ -107,8 +106,7 @@ pub mod my_lending { .endowment(0) .code_hash(loan_hash) .salt_bytes(&[0xDE, 0xAD, 0xBE, 0xEF]) - .instantiate() - .unwrap(); + .instantiate(); instance.lending.loan_account = nft.to_account_id(); instance diff --git a/example_project_structure/contracts/loan/Cargo.toml b/example_project_structure/contracts/loan/Cargo.toml index 6eead1bfd..782819567 100644 --- a/example_project_structure/contracts/loan/Cargo.toml +++ b/example_project_structure/contracts/loan/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "loan_contract" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/example_project_structure/contracts/shares/Cargo.toml b/example_project_structure/contracts/shares/Cargo.toml index 38a840cae..67f32f89b 100644 --- a/example_project_structure/contracts/shares/Cargo.toml +++ b/example_project_structure/contracts/shares/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "shares_contract" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/example_project_structure/contracts/stable_coin/Cargo.toml b/example_project_structure/contracts/stable_coin/Cargo.toml index d635c1480..069d7c386 100644 --- a/example_project_structure/contracts/stable_coin/Cargo.toml +++ b/example_project_structure/contracts/stable_coin/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "stable_coin_contract" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/example_project_structure/impls/lending/data.rs b/example_project_structure/impls/lending/data.rs index 7c32a99ac..afd4e9636 100644 --- a/example_project_structure/impls/lending/data.rs +++ b/example_project_structure/impls/lending/data.rs @@ -17,7 +17,7 @@ use openbrush::traits::Storage; pub const STORAGE_KEY: u32 = openbrush::storage_unique_key!(Data); -#[derive(Default, Debug)] +#[derive(Debug)] #[openbrush::upgradeable_storage(STORAGE_KEY)] /// define the struct with the data that our smart contract will be using /// this will isolate the logic of our smart contract from its storage @@ -49,6 +49,20 @@ pub struct Data { pub loan_account: AccountId, } +impl Default for Data { + fn default() -> Self { + Self { + assets_lended: Default::default(), + asset_shares: Default::default(), + shares_asset: Default::default(), + collateral_accepted: Default::default(), + asset_price: Default::default(), + shares_contract_code_hash: Hash::default(), + loan_account: [0u8; 32].into(), + } + } +} + pub struct AssetPriceKey; impl<'a> TypeGuard<'a> for AssetPriceKey { diff --git a/example_project_structure/impls/lending/lending.rs b/example_project_structure/impls/lending/lending.rs index b9925a376..c8e2d95b5 100644 --- a/example_project_structure/impls/lending/lending.rs +++ b/example_project_structure/impls/lending/lending.rs @@ -117,7 +117,7 @@ impl + Storage> Lending for T { // transfer the assets from user to the contract| PSP22Ref::transfer_from_builder(&asset_address, lender, contract, amount, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap() .unwrap()?; // if no assets were deposited yet we will mint the same amount of shares as deposited `amount` @@ -174,7 +174,7 @@ impl + Storage> Lending for T { // we will transfer the collateral to the contract PSP22Ref::transfer_from_builder(&collateral_address, borrower, contract, amount, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap() .unwrap()?; // create loan info @@ -229,7 +229,7 @@ impl + Storage> Lending for T { if repay_amount >= to_repay { PSP22Ref::transfer_from_builder(&loan_info.borrow_token, initiator, contract, to_repay, Vec::::new()) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap() .unwrap()?; PSP22Ref::transfer( @@ -249,7 +249,7 @@ impl + Storage> Lending for T { Vec::::new(), ) .call_flags(ink::env::CallFlags::default().set_allow_reentry(true)) - .fire() + .try_invoke() .unwrap() .unwrap()?; let to_return = (repay_amount * loan_info.collateral_amount) / to_repay; diff --git a/example_project_structure/traits/loan.rs b/example_project_structure/traits/loan.rs index 466f2a3ec..a882fe3e2 100644 --- a/example_project_structure/traits/loan.rs +++ b/example_project_structure/traits/loan.rs @@ -16,7 +16,7 @@ use openbrush::{ #[cfg(feature = "std")] use ink::storage::traits::StorageLayout; -#[derive(Default, Debug, Clone, scale::Encode, scale::Decode)] +#[derive(Debug, Clone, scale::Encode, scale::Decode)] #[cfg_attr(feature = "std", derive(StorageLayout, scale_info::TypeInfo))] pub struct LoanInfo { pub borrower: AccountId, @@ -29,6 +29,21 @@ pub struct LoanInfo { pub liquidated: bool, } +impl Default for LoanInfo { + fn default() -> Self { + Self { + borrower: [0u8; 32].into(), + collateral_token: [0u8; 32].into(), + collateral_amount: Balance::default(), + borrow_token: [0u8; 32].into(), + borrow_amount: Balance::default(), + liquidation_price: Balance::default(), + timestamp: Timestamp::default(), + liquidated: false, + } + } +} + #[openbrush::wrapper] pub type LoanRef = dyn Loan + PSP34 + PSP34Metadata + Ownable; diff --git a/examples/access_control/Cargo.toml b/examples/access_control/Cargo.toml index bb796857c..e498a8970 100644 --- a/examples/access_control/Cargo.toml +++ b/examples/access_control/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_access_control" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/access_control_extensions/enumerable/Cargo.toml b/examples/access_control_extensions/enumerable/Cargo.toml index 122dff142..3a2fdb158 100644 --- a/examples/access_control_extensions/enumerable/Cargo.toml +++ b/examples/access_control_extensions/enumerable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_access_control_enumerable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/alternatives/diamond/ink/Cargo.toml b/examples/alternatives/diamond/ink/Cargo.toml index d273c238f..f8bc2a34b 100644 --- a/examples/alternatives/diamond/ink/Cargo.toml +++ b/examples/alternatives/diamond/ink/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "ink_diamond" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/alternatives/diamond/rust/Cargo.toml b/examples/alternatives/diamond/rust/Cargo.toml index ac5aeee4d..116d68178 100644 --- a/examples/alternatives/diamond/rust/Cargo.toml +++ b/examples/alternatives/diamond/rust/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "rust_diamond" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/diamond/Cargo.toml b/examples/diamond/Cargo.toml index 5033bfed4..65a8803e8 100644 --- a/examples/diamond/Cargo.toml +++ b/examples/diamond/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_diamond" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/diamond/diamond_caller/Cargo.toml b/examples/diamond/diamond_caller/Cargo.toml index e509cc75a..c2bcf5199 100644 --- a/examples/diamond/diamond_caller/Cargo.toml +++ b/examples/diamond/diamond_caller/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "diamond_caller" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/diamond/psp22_facet_v1/Cargo.toml b/examples/diamond/psp22_facet_v1/Cargo.toml index 5661b119e..3d1d6ea72 100644 --- a/examples/diamond/psp22_facet_v1/Cargo.toml +++ b/examples/diamond/psp22_facet_v1/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_facet_v1" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/diamond/psp22_facet_v2/Cargo.toml b/examples/diamond/psp22_facet_v2/Cargo.toml index 36950b2f0..af2c41efe 100644 --- a/examples/diamond/psp22_facet_v2/Cargo.toml +++ b/examples/diamond/psp22_facet_v2/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_facet_v2" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/diamond/psp22_metadata_facet/Cargo.toml b/examples/diamond/psp22_metadata_facet/Cargo.toml index 42e5ef2f4..09182a6c3 100644 --- a/examples/diamond/psp22_metadata_facet/Cargo.toml +++ b/examples/diamond/psp22_metadata_facet/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_metadata_facet" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/ownable/Cargo.toml b/examples/ownable/Cargo.toml index e1b2581a7..1d7b5764f 100644 --- a/examples/ownable/Cargo.toml +++ b/examples/ownable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_ownable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/pausable/Cargo.toml b/examples/pausable/Cargo.toml index 3caf2269e..b0925582c 100644 --- a/examples/pausable/Cargo.toml +++ b/examples/pausable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_pausable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/payment_splitter/Cargo.toml b/examples/payment_splitter/Cargo.toml index 7055aeeaf..a2ab5e976 100644 --- a/examples/payment_splitter/Cargo.toml +++ b/examples/payment_splitter/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_payment_splitter" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/proxy/Cargo.toml b/examples/proxy/Cargo.toml index 33cc09792..11802da56 100644 --- a/examples/proxy/Cargo.toml +++ b/examples/proxy/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_proxy" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/proxy/psp22_metadata_upgradeable/Cargo.toml b/examples/proxy/psp22_metadata_upgradeable/Cargo.toml index 210406341..a2d0a8c69 100644 --- a/examples/proxy/psp22_metadata_upgradeable/Cargo.toml +++ b/examples/proxy/psp22_metadata_upgradeable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_metadata_upgradeable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/proxy/psp22_upgradeable/Cargo.toml b/examples/proxy/psp22_upgradeable/Cargo.toml index df86bbef9..7c8e114fe 100644 --- a/examples/proxy/psp22_upgradeable/Cargo.toml +++ b/examples/proxy/psp22_upgradeable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_upgradeable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22/Cargo.toml b/examples/psp22/Cargo.toml index 4de60d0cb..b444275c3 100644 --- a/examples/psp22/Cargo.toml +++ b/examples/psp22/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22/lib.rs b/examples/psp22/lib.rs index dc6586393..a9f63b7ec 100644 --- a/examples/psp22/lib.rs +++ b/examples/psp22/lib.rs @@ -12,7 +12,7 @@ pub mod my_psp22 { }; #[ink(storage)] - #[derive(Default, Storage)] + #[derive(Storage)] pub struct Contract { #[storage_field] psp22: psp22::Data, @@ -40,7 +40,10 @@ pub mod my_psp22 { impl Contract { #[ink(constructor)] pub fn new(total_supply: Balance) -> Self { - let mut instance = Self::default(); + let mut instance = Self { + psp22: Default::default(), + hated_account: [0u8; 32].into(), + }; instance ._mint_to(Self::env().caller(), total_supply) diff --git a/examples/psp22_extensions/burnable/Cargo.toml b/examples/psp22_extensions/burnable/Cargo.toml index c6610a8b9..05cc9c6ad 100644 --- a/examples/psp22_extensions/burnable/Cargo.toml +++ b/examples/psp22_extensions/burnable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_burnable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_extensions/capped/Cargo.toml b/examples/psp22_extensions/capped/Cargo.toml index 4cabc6681..ed7f61d56 100644 --- a/examples/psp22_extensions/capped/Cargo.toml +++ b/examples/psp22_extensions/capped/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_capped" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_extensions/flashmint/Cargo.toml b/examples/psp22_extensions/flashmint/Cargo.toml index 1e85ebd8f..0d4b664b8 100644 --- a/examples/psp22_extensions/flashmint/Cargo.toml +++ b/examples/psp22_extensions/flashmint/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_flashmint" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_extensions/metadata/Cargo.toml b/examples/psp22_extensions/metadata/Cargo.toml index e5070c0e3..4b7ea467b 100644 --- a/examples/psp22_extensions/metadata/Cargo.toml +++ b/examples/psp22_extensions/metadata/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_metadata" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_extensions/mintable/Cargo.toml b/examples/psp22_extensions/mintable/Cargo.toml index 71b9f3db1..2dc7a0f5a 100644 --- a/examples/psp22_extensions/mintable/Cargo.toml +++ b/examples/psp22_extensions/mintable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_mintable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_extensions/pausable/Cargo.toml b/examples/psp22_extensions/pausable/Cargo.toml index 24fe99118..b15689945 100644 --- a/examples/psp22_extensions/pausable/Cargo.toml +++ b/examples/psp22_extensions/pausable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_pausable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_extensions/wrapper/Cargo.toml b/examples/psp22_extensions/wrapper/Cargo.toml index f71a1b925..7ef33e610 100644 --- a/examples/psp22_extensions/wrapper/Cargo.toml +++ b/examples/psp22_extensions/wrapper/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_wrapper" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_pallet/Cargo.toml b/examples/psp22_pallet/Cargo.toml index 3d6f642fb..6dfc682d7 100644 --- a/examples/psp22_pallet/Cargo.toml +++ b/examples/psp22_pallet/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_pallet" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_pallet_extensions/burnable/Cargo.toml b/examples/psp22_pallet_extensions/burnable/Cargo.toml index 266ac58a8..95f615fc7 100644 --- a/examples/psp22_pallet_extensions/burnable/Cargo.toml +++ b/examples/psp22_pallet_extensions/burnable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_pallet_burnable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_pallet_extensions/metadata/Cargo.toml b/examples/psp22_pallet_extensions/metadata/Cargo.toml index 307184c18..d63c04593 100644 --- a/examples/psp22_pallet_extensions/metadata/Cargo.toml +++ b/examples/psp22_pallet_extensions/metadata/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_pallet_metadata" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_pallet_extensions/mintable/Cargo.toml b/examples/psp22_pallet_extensions/mintable/Cargo.toml index edb3abdbe..ee744c5ce 100644 --- a/examples/psp22_pallet_extensions/mintable/Cargo.toml +++ b/examples/psp22_pallet_extensions/mintable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_pallet_mintable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp22_utils/token_timelock/Cargo.toml b/examples/psp22_utils/token_timelock/Cargo.toml index 4b8ed549b..6c237f372 100644 --- a/examples/psp22_utils/token_timelock/Cargo.toml +++ b/examples/psp22_utils/token_timelock/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp22_token_timelock" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp34/Cargo.toml b/examples/psp34/Cargo.toml index 86f835741..ee17a8c43 100644 --- a/examples/psp34/Cargo.toml +++ b/examples/psp34/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp34" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp34_extensions/burnable/Cargo.toml b/examples/psp34_extensions/burnable/Cargo.toml index c23624aae..f810d0e85 100644 --- a/examples/psp34_extensions/burnable/Cargo.toml +++ b/examples/psp34_extensions/burnable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp34_burnable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp34_extensions/enumerable/Cargo.toml b/examples/psp34_extensions/enumerable/Cargo.toml index ec3fc30b0..739238967 100644 --- a/examples/psp34_extensions/enumerable/Cargo.toml +++ b/examples/psp34_extensions/enumerable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp34_enumerable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp34_extensions/metadata/Cargo.toml b/examples/psp34_extensions/metadata/Cargo.toml index 7f78ea1ae..7589d1d81 100644 --- a/examples/psp34_extensions/metadata/Cargo.toml +++ b/examples/psp34_extensions/metadata/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp34_metadata" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp34_extensions/mintable/Cargo.toml b/examples/psp34_extensions/mintable/Cargo.toml index 20c595b4a..4e245343e 100644 --- a/examples/psp34_extensions/mintable/Cargo.toml +++ b/examples/psp34_extensions/mintable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp34_mintable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp37/Cargo.toml b/examples/psp37/Cargo.toml index e7c216070..7fe9680e2 100644 --- a/examples/psp37/Cargo.toml +++ b/examples/psp37/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp37" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp37_extensions/batch/Cargo.toml b/examples/psp37_extensions/batch/Cargo.toml index 4cedd1538..3ac50a068 100644 --- a/examples/psp37_extensions/batch/Cargo.toml +++ b/examples/psp37_extensions/batch/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp37_batch" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp37_extensions/burnable/Cargo.toml b/examples/psp37_extensions/burnable/Cargo.toml index 8ed0d0baa..d78b9c95f 100644 --- a/examples/psp37_extensions/burnable/Cargo.toml +++ b/examples/psp37_extensions/burnable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp37_burnable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp37_extensions/enumerable/Cargo.toml b/examples/psp37_extensions/enumerable/Cargo.toml index 1418cb69f..ce7183158 100644 --- a/examples/psp37_extensions/enumerable/Cargo.toml +++ b/examples/psp37_extensions/enumerable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp37_enumerable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp37_extensions/metadata/Cargo.toml b/examples/psp37_extensions/metadata/Cargo.toml index 2cf943fdb..5356c54a1 100644 --- a/examples/psp37_extensions/metadata/Cargo.toml +++ b/examples/psp37_extensions/metadata/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp37_metadata" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/psp37_extensions/mintable/Cargo.toml b/examples/psp37_extensions/mintable/Cargo.toml index 9f4883b1d..012921244 100644 --- a/examples/psp37_extensions/mintable/Cargo.toml +++ b/examples/psp37_extensions/mintable/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_psp37_mintable" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/reentrancy_guard/Cargo.toml b/examples/reentrancy_guard/Cargo.toml index 7366aab2a..0b4768f1b 100644 --- a/examples/reentrancy_guard/Cargo.toml +++ b/examples/reentrancy_guard/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "flipper" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/reentrancy_guard/contracts/flip_on_me/Cargo.toml b/examples/reentrancy_guard/contracts/flip_on_me/Cargo.toml index 241260d99..b5ecab257 100644 --- a/examples/reentrancy_guard/contracts/flip_on_me/Cargo.toml +++ b/examples/reentrancy_guard/contracts/flip_on_me/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "flip_on_me" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/reentrancy_guard/contracts/flipper/Cargo.toml b/examples/reentrancy_guard/contracts/flipper/Cargo.toml index 50ca76433..7e556aa06 100644 --- a/examples/reentrancy_guard/contracts/flipper/Cargo.toml +++ b/examples/reentrancy_guard/contracts/flipper/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_flipper_guard" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/examples/timelock_controller/Cargo.toml b/examples/timelock_controller/Cargo.toml index d90660395..5c5139333 100644 --- a/examples/timelock_controller/Cargo.toml +++ b/examples/timelock_controller/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "my_timelock_controller" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/lang/Cargo.toml b/lang/Cargo.toml index 6ccb800ba..39c92e7d0 100644 --- a/lang/Cargo.toml +++ b/lang/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openbrush_lang" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" @@ -14,9 +14,9 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs"] [dependencies] -openbrush_lang_macro = { version = "~3.0.0-beta", path = "macro", default-features = false } +openbrush_lang_macro = { version = "~3.0.0-beta.1", path = "macro", default-features = false } -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"] } diff --git a/lang/codegen/Cargo.toml b/lang/codegen/Cargo.toml index 229b50958..6398f13c9 100644 --- a/lang/codegen/Cargo.toml +++ b/lang/codegen/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openbrush_lang_codegen" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" diff --git a/lang/codegen/src/trait_definition.rs b/lang/codegen/src/trait_definition.rs index 22e7c7f68..b8885e6b0 100644 --- a/lang/codegen/src/trait_definition.rs +++ b/lang/codegen/src/trait_definition.rs @@ -191,10 +191,6 @@ fn generate_wrapper(ink_trait: ItemTrait) -> proc_macro2::TokenStream { syn::ReturnType::Type(_, return_type) => quote! { #return_type }, }; - let return_ty = quote! { - ::ink::MessageResult<#output_ty> - }; - let selector_string = format!("{}::{}", trait_ident, message_ident); let selector_bytes = ::ink_ir::Selector::compute(&selector_string.into_bytes()).hex_lits(); let input_bindings = method @@ -253,7 +249,7 @@ fn generate_wrapper(ink_trait: ItemTrait) -> proc_macro2::TokenStream { ::ink::env::DefaultEnvironment, ::ink::env::call::utils::Set< ::ink::env::call::Call< ::ink::env::DefaultEnvironment > >, ::ink::env::call::utils::Set< ::ink::env::call::ExecutionInput<#arg_list> >, - ::ink::env::call::utils::Set<::ink::env::call::utils::ReturnType<#return_ty>>, + ::ink::env::call::utils::Set<::ink::env::call::utils::ReturnType<#output_ty>>, >; }); @@ -264,7 +260,7 @@ fn generate_wrapper(ink_trait: ItemTrait) -> proc_macro2::TokenStream { #( , #input_bindings : #input_types )* ) -> #output_ty { Self::#message_builder_ident(self #( , #input_bindings)*) - .fire() + .try_invoke() .unwrap_or_else(|err| ::core::panic!("{}: {:?}", #panic_str, err)) .unwrap_or_else(|err| ::core::panic!("Can't decode ::ink::LangErr: {:?}", err)) } @@ -277,12 +273,11 @@ fn generate_wrapper(ink_trait: ItemTrait) -> proc_macro2::TokenStream { ::ink::env::DefaultEnvironment, ::ink::env::call::utils::Set< ::ink::env::call::Call< ::ink::env::DefaultEnvironment > >, ::ink::env::call::utils::Set< ::ink::env::call::ExecutionInput<#arg_list> >, - ::ink::env::call::utils::Set<::ink::env::call::utils::ReturnType<#return_ty>>, + ::ink::env::call::utils::Set<::ink::env::call::utils::ReturnType<#output_ty>>, > { ::ink::env::call::build_call::<::ink::env::DefaultEnvironment>() .call_type( - ::ink::env::call::Call::new() - .callee(self.clone())) + ::ink::env::call::Call::new(self.clone())) .exec_input( ::ink::env::call::ExecutionInput::new( ::ink::env::call::Selector::new([ #( #selector_bytes ),* ]) @@ -291,7 +286,7 @@ fn generate_wrapper(ink_trait: ItemTrait) -> proc_macro2::TokenStream { .push_arg(#input_bindings) )* ) - .returns::<#return_ty>() + .returns::<#output_ty>() } }); }); diff --git a/lang/macro/Cargo.toml b/lang/macro/Cargo.toml index 465fa7782..7dd0697f7 100644 --- a/lang/macro/Cargo.toml +++ b/lang/macro/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "openbrush_lang_macro" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" @@ -14,13 +14,13 @@ categories = ["no-std", "embedded"] include = ["Cargo.toml", "src/**/*.rs"] [dependencies] -openbrush_lang_codegen = { version = "~3.0.0-beta", path = "../codegen", default-features = false } +openbrush_lang_codegen = { version = "~3.0.0-beta.1", path = "../codegen", default-features = false } syn = "1" proc-macro2 = "1" synstructure = "0.12" [dev-dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"] } diff --git a/lang/macro/src/lib.rs b/lang/macro/src/lib.rs index 4684abe8e..ba2ab2700 100644 --- a/lang/macro/src/lib.rs +++ b/lang/macro/src/lib.rs @@ -143,13 +143,22 @@ pub fn contract(_attrs: TokenStream, ink_module: TokenStream) -> TokenStream { /// } /// /// #[ink(storage)] -/// #[derive(Default, Storage)] +/// #[derive(Storage)] /// pub struct PSP22Struct { /// #[storage_field] /// example: Data, /// hated_account: AccountId, /// } /// +/// impl Default for PSP22Struct { +/// fn default() -> Self { +/// Self { +/// example: Data::default(), +/// hated_account: AccountId::from([0x0; 32]), +/// } +/// } +/// } +/// /// impl PSP22Example for PSP22Struct { /// // Let's override method to reject transactions to bad account /// fn _transfer_from_to(&mut self, from: AccountId, to: AccountId, amount: Balance) { @@ -310,12 +319,20 @@ pub fn modifier_definition(_attrs: TokenStream, _input: TokenStream) -> TokenStr /// #[openbrush::contract] /// mod example { /// #[ink(storage)] -/// #[derive(Default)] /// pub struct Contract { /// initialized: bool, /// owner: AccountId, /// } /// +/// impl Default for Contract { +/// fn default() -> Self { +/// Self { +/// initialized: false, +/// owner: [0u8; 32].into(), +/// } +/// } +/// } +/// /// #[openbrush::modifier_definition] /// fn once(instance: &mut Contract, body: impl FnOnce(&mut Contract)) { /// assert!(!instance.initialized, "Contract is already initialized"); @@ -398,7 +415,7 @@ pub fn modifiers(_attrs: TokenStream, method: TokenStream) -> TokenStream { /// // Example how to get ink! call builder /// let to: AccountId = [0; 32].into(); /// let builder_for_foo: ::ink::env::call::CallBuilder<_, _, _, _> = Trait1and2Ref::foo_builder(&to); -/// let ink_result: Result = builder_for_foo.fire().unwrap(); +/// let ink_result: Result = builder_for_foo.try_invoke().unwrap(); /// } /// ``` #[proc_macro_attribute] diff --git a/lang/src/test_utils.rs b/lang/src/test_utils.rs index 96a9ceaf3..7081bd1a0 100644 --- a/lang/src/test_utils.rs +++ b/lang/src/test_utils.rs @@ -40,7 +40,7 @@ pub fn encoded_into_hash(entity: &T) -> Hash where T: scale::Encode, { - let mut result = Hash::clear(); + let mut result = Hash::CLEAR_HASH; let len_result = result.as_ref().len(); let encoded = entity.encode(); let len_encoded = encoded.len(); diff --git a/mock/flash-borrower/Cargo.toml b/mock/flash-borrower/Cargo.toml index 1c064fce0..de8b9ba05 100644 --- a/mock/flash-borrower/Cargo.toml +++ b/mock/flash-borrower/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "flash_borrower" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/mock/psp22-receiver/Cargo.toml b/mock/psp22-receiver/Cargo.toml index 819c3f660..ac5faa9ab 100644 --- a/mock/psp22-receiver/Cargo.toml +++ b/mock/psp22-receiver/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "psp22_receiver" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/mock/psp34-receiver/Cargo.toml b/mock/psp34-receiver/Cargo.toml index a3bc1282a..80401b0bd 100644 --- a/mock/psp34-receiver/Cargo.toml +++ b/mock/psp34-receiver/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "psp34_receiver" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/mock/psp37-receiver/Cargo.toml b/mock/psp37-receiver/Cargo.toml index 9458637b6..90dd34abe 100644 --- a/mock/psp37-receiver/Cargo.toml +++ b/mock/psp37-receiver/Cargo.toml @@ -1,11 +1,11 @@ [package] name = "psp37_receiver" -version = "3.0.0-beta" +version = "3.0.0-beta.1" authors = ["Brushfam "] edition = "2021" [dependencies] -ink = { git = "https://github.com/paritytech/ink", rev = "4655a8b4413cb50cbc38d1b7c173ad426ab06cde", default-features = false} +ink = { version = "~4.0.0-rc", default-features = false} scale = { package = "parity-scale-codec", version = "3", default-features = false, features = ["derive"] } scale-info = { version = "2.3", default-features = false, features = ["derive"], optional = true } diff --git a/package.json b/package.json index 3452ca59e..286fb4f8a 100644 --- a/package.json +++ b/package.json @@ -7,15 +7,15 @@ "@babel/plugin-transform-runtime": "^7.14.2", "@babel/preset-env": "^7.7.4", "@babel/register": "^7.7.4", - "@727-ventures/typechain-compiler": "^0.5.10", - "@727-ventures/typechain-types": "^0.0.21", + "@727-ventures/typechain-compiler": "^0.5.13", + "@727-ventures/typechain-types": "^0.0.22", "@types/chai": "^4.3.0", "@types/chai-as-promised": "^7.1.5", "@types/mocha": "^8.0.3", "@typescript-eslint/eslint-plugin": "^4.8.2", "@typescript-eslint/parser": "^4.8.2", - "@polkadot/api": "9.10.3", - "@polkadot/api-contract": "9.10.3", + "@polkadot/api": "9.13.4", + "@polkadot/api-contract": "9.13.4", "chai": "^4.3.6", "chai-as-promised": "^7.1.1", "deasync": "^0.1.28",