Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: mutable self required for dispatchable ink! methods #235

Merged
merged 1 commit into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions pop-api/examples/fungibles/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ mod fungibles {
}

#[ink(message)]
pub fn transfer(&self, id: AssetId, to: AccountId, value: Balance) -> Result<()> {
pub fn transfer(&mut self, id: AssetId, to: AccountId, value: Balance) -> Result<()> {
api::transfer(id, to, value)
}

#[ink(message)]
pub fn transfer_from(
&self,
&mut self,
id: AssetId,
from: AccountId,
to: AccountId,
Expand All @@ -78,13 +78,13 @@ mod fungibles {
}

#[ink(message)]
pub fn approve(&self, id: AssetId, spender: AccountId, value: Balance) -> Result<()> {
pub fn approve(&mut self, id: AssetId, spender: AccountId, value: Balance) -> Result<()> {
api::approve(id, spender, value)
}

#[ink(message)]
pub fn increase_allowance(
&self,
&mut self,
id: AssetId,
spender: AccountId,
value: Balance,
Expand All @@ -94,7 +94,7 @@ mod fungibles {

#[ink(message)]
pub fn decrease_allowance(
&self,
&mut self,
id: AssetId,
spender: AccountId,
value: Balance,
Expand Down
25 changes: 15 additions & 10 deletions pop-api/integration-tests/contracts/fungibles/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -60,13 +60,13 @@ mod fungibles {
}

#[ink(message)]
pub fn transfer(&self, id: AssetId, to: AccountId, value: Balance) -> Result<()> {
pub fn transfer(&mut self, id: AssetId, to: AccountId, value: Balance) -> Result<()> {
api::transfer(id, to, value)
}

#[ink(message)]
pub fn transfer_from(
&self,
&mut self,
id: AssetId,
from: AccountId,
to: AccountId,
Expand All @@ -78,13 +78,13 @@ mod fungibles {
}

#[ink(message)]
pub fn approve(&self, id: AssetId, spender: AccountId, value: Balance) -> Result<()> {
pub fn approve(&mut self, id: AssetId, spender: AccountId, value: Balance) -> Result<()> {
api::approve(id, spender, value)
}

#[ink(message)]
pub fn increase_allowance(
&self,
&mut self,
id: AssetId,
spender: AccountId,
value: Balance,
Expand All @@ -94,7 +94,7 @@ mod fungibles {

#[ink(message)]
pub fn decrease_allowance(
&self,
&mut self,
id: AssetId,
spender: AccountId,
value: Balance,
Expand Down Expand Up @@ -130,18 +130,23 @@ mod fungibles {
/// - asset_exists

#[ink(message)]
pub fn create(&self, id: AssetId, admin: AccountId, min_balance: Balance) -> Result<()> {
pub fn create(
&mut self,
id: AssetId,
admin: AccountId,
min_balance: Balance,
) -> Result<()> {
api::create(id, admin, min_balance)
}

#[ink(message)]
pub fn start_destroy(&self, id: AssetId) -> Result<()> {
pub fn start_destroy(&mut self, id: AssetId) -> Result<()> {
api::start_destroy(id)
}

#[ink(message)]
pub fn set_metadata(
&self,
&mut self,
id: AssetId,
name: Vec<u8>,
symbol: Vec<u8>,
Expand All @@ -165,12 +170,12 @@ mod fungibles {
/// - burn

#[ink(message)]
pub fn mint(&self, id: AssetId, account: AccountId, amount: Balance) -> Result<()> {
pub fn mint(&mut self, id: AssetId, account: AccountId, amount: Balance) -> Result<()> {
api::mint(id, account, amount)
}

#[ink(message)]
pub fn burn(&self, id: AssetId, account: AccountId, amount: Balance) -> Result<()> {
pub fn burn(&mut self, id: AssetId, account: AccountId, amount: Balance) -> Result<()> {
api::burn(id, account, amount)
}
}
Expand Down
Loading