From c10f15c18cc666d966c5472f716476b46e3ccbae Mon Sep 17 00:00:00 2001
From: chungquantin <56880684+chungquantin@users.noreply.github.com>
Date: Mon, 26 Aug 2024 19:51:58 +0700
Subject: [PATCH] fix: add mutable to self in dispatchable methods in ink!
 examples

---
 pop-api/examples/fungibles/lib.rs             | 10 ++++----
 .../contracts/fungibles/lib.rs                | 25 +++++++++++--------
 2 files changed, 20 insertions(+), 15 deletions(-)

diff --git a/pop-api/examples/fungibles/lib.rs b/pop-api/examples/fungibles/lib.rs
index 1b42fec4..a6328c37 100755
--- a/pop-api/examples/fungibles/lib.rs
+++ b/pop-api/examples/fungibles/lib.rs
@@ -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,
@@ -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,
@@ -94,7 +94,7 @@ mod fungibles {
 
 		#[ink(message)]
 		pub fn decrease_allowance(
-			&self,
+			&mut self,
 			id: AssetId,
 			spender: AccountId,
 			value: Balance,
diff --git a/pop-api/integration-tests/contracts/fungibles/lib.rs b/pop-api/integration-tests/contracts/fungibles/lib.rs
index 239d3a2d..2b33ce04 100755
--- a/pop-api/integration-tests/contracts/fungibles/lib.rs
+++ b/pop-api/integration-tests/contracts/fungibles/lib.rs
@@ -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,
@@ -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,
@@ -94,7 +94,7 @@ mod fungibles {
 
 		#[ink(message)]
 		pub fn decrease_allowance(
-			&self,
+			&mut self,
 			id: AssetId,
 			spender: AccountId,
 			value: Balance,
@@ -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>,
@@ -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)
 		}
 	}