Is there any way to call ink! smart contract function in substrate custom pallet?
We've found this answer where bare_call
function is based on older version of contract_pallet
.
// This ends up calling our contract!
pallet_contracts::Pallet::<T>::bare_call(
who,
dest.clone(),
value,
gas_limit,
data,
debug,
)
.result?;
Now in updated version bare_call
function is like this,
pub fn bare_call(
origin: T::AccountId,
dest: T::AccountId,
value: BalanceOf<T>,
gas_limit: Weight,
storage_deposit_limit: Option<BalanceOf<T>>,
data: Vec<u8>,
debug: DebugInfo,
collect_events: CollectEvents,
determinism: Determinism,
) -> ContractExecResult<BalanceOf<T>, EventRecordOf<T>> {}
This is our github repo and right now we are getting this error,
ganesholi@Ganeshs-MacBook-Air MarketplaceMVP_Substrate % cargo build --release
Compiling node-template-runtime v4.0.0-dev (/Users/ganesholi/xcav/MarketplaceMVP_Substrate/runtime)
Compiling pallet-community-loan-pool v4.0.0-dev (/Users/ganesholi/xcav/MarketplaceMVP_Substrate/pallets/community-loan-pool)
warning: unused import: `frame_support::traits::tokens::Balance`
--> pallets/community-loan-pool/src/lib.rs:58:6
|
58 | use frame_support::traits::tokens::Balance;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0308]: arguments to this function are incorrect
--> pallets/community-loan-pool/src/lib.rs:264:4
|
264 | pallet_contracts::Pallet::<T>::bare_call(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
268 | gas_limit,
| --------- expected struct `Weight`, found integer
|
note: expected pallet_contracts::Config::Currency, found pallet::Config::Currency
--> pallets/community-loan-pool/src/lib.rs:267:5
|
267 | value,
| ^^^^^
= note: expected associated type `<<T as pallet_contracts::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance`
found associated type `<<T as pallet::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance`
note: expected pallet_contracts::Config::Currency, found pallet::Config::Currency
--> pallets/community-loan-pool/src/lib.rs:269:5
|
269 | storage_deposit_limit,
| ^^^^^^^^^^^^^^^^^^^^^
= note: expected enum `std::option::Option<<<T as pallet_contracts::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance>`
found enum `std::option::Option<<<T as pallet::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance>`
note: associated function defined here
--> /Users/ganesholi/.cargo/git/checkouts/substrate-7e08433d4c370a21/98f2e34/frame/contracts/src/lib.rs:1160:9
|
1160 | pub fn bare_call(
| ^^^^^^^^^
help: call `Into::into` on this expression to convert `{integer}` into `Weight`
|
268 | gas_limit.into(),
| +++++++
For more information about this error, try `rustc --explain E0308`.
warning: `pallet-community-loan-pool` (lib) generated 1 warning
error: could not compile `pallet-community-loan-pool` due to previous error; 1 warning emitted
warning: build failed, waiting for other jobs to finish...
error: failed to run custom build command for `node-template-runtime v4.0.0-dev (/Users/ganesholi/xcav/MarketplaceMVP_Substrate/runtime)`
Caused by:
process didn't exit successfully: `/Users/ganesholi/xcav/MarketplaceMVP_Substrate/target/release/build/node-template-runtime-666e594096483e01/build-script-build` (exit status: 1)
--- stdout
Information that should be included in a bug report.
Executing build command: RUSTFLAGS="-C link-arg=--export-table -Clink-arg=--export=__heap_base -C link-arg=--import-memory " SKIP_WASM_BUILD="" "/Users/ganesholi/.rustup/toolchains/nightly-2023-01-01-aarch64-apple-darwin/bin/cargo" "rustc" "--target=wasm32-unknown-unknown" "--manifest-path=/Users/ganesholi/xcav/MarketplaceMVP_Substrate/target/release/wbuild/node-template-runtime/Cargo.toml" "--color=always" "--profile" "release"
Using rustc version: rustc 1.68.0-nightly (574b64a97 2022-12-31)
--- stderr
Compiling pallet-community-loan-pool v4.0.0-dev (/Users/ganesholi/xcav/MarketplaceMVP_Substrate/pallets/community-loan-pool)
warning: unused import: `frame_support::traits::tokens::Balance`
--> /Users/ganesholi/xcav/MarketplaceMVP_Substrate/pallets/community-loan-pool/src/lib.rs:58:6
|
58 | use frame_support::traits::tokens::Balance;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `#[warn(unused_imports)]` on by default
error[E0308]: arguments to this function are incorrect
--> /Users/ganesholi/xcav/MarketplaceMVP_Substrate/pallets/community-loan-pool/src/lib.rs:264:4
|
264 | pallet_contracts::Pallet::<T>::bare_call(
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
...
268 | gas_limit,
| --------- expected struct `Weight`, found integer
|
note: expected pallet_contracts::Config::Currency, found pallet::Config::Currency
--> /Users/ganesholi/xcav/MarketplaceMVP_Substrate/pallets/community-loan-pool/src/lib.rs:267:5
|
267 | value,
| ^^^^^
= note: expected associated type `<<T as pallet_contracts::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance`
found associated type `<<T as pallet::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance`
note: expected pallet_contracts::Config::Currency, found pallet::Config::Currency
--> /Users/ganesholi/xcav/MarketplaceMVP_Substrate/pallets/community-loan-pool/src/lib.rs:269:5
|
269 | storage_deposit_limit,
| ^^^^^^^^^^^^^^^^^^^^^
= note: expected enum `Option<<<T as pallet_contracts::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance>`
found enum `Option<<<T as pallet::Config>::Currency as frame_support::traits::Currency<<T as SysConfig>::AccountId>>::Balance>`
note: associated function defined here
--> /Users/ganesholi/.cargo/git/checkouts/substrate-7e08433d4c370a21/98f2e34/frame/contracts/src/lib.rs:1160:9
|
1160 | pub fn bare_call(
| ^^^^^^^^^
For more information about this error, try `rustc --explain E0308`.
warning: `pallet-community-loan-pool` (lib) generated 1 warning
error: could not compile `pallet-community-loan-pool` due to previous error; 1 warning emitted
ganesholi@Ganeshs-MacBook-Air MarketplaceMVP_Substrate %
pallet_contracts::Config
to yourConfig
(tight coupling).expected pallet_contracts::Config::Currency, found pallet::Config::Currency