Skip to content

Commit

Permalink
Update name for TotalSupplyEvent
Browse files Browse the repository at this point in the history
  • Loading branch information
bitzoic committed Aug 26, 2024
1 parent 5a38aff commit a7098b9
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 36 deletions.
10 changes: 2 additions & 8 deletions examples/src20-native-asset/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
contract;

use standards::src20::{
SetDecimalsEvent,
SetNameEvent,
SetSymbolEvent,
SRC20,
UpdateTotalSupplyEvent,
};
use standards::src20::{SetDecimalsEvent, SetNameEvent, SetSymbolEvent, SRC20, TotalSupplyEvent,};
use std::{hash::Hash, storage::storage_string::*, string::String};

storage {
Expand Down Expand Up @@ -223,7 +217,7 @@ impl SetSRC20Data for Contract {
sender,
});

log(UpdateTotalSupplyEvent {
log(TotalSupplyEvent {
asset,
supply,
sender,
Expand Down
10 changes: 2 additions & 8 deletions examples/src20-native-asset/single_asset/src/single_asset.sw
Original file line number Diff line number Diff line change
@@ -1,12 +1,6 @@
contract;

use standards::src20::{
SetDecimalsEvent,
SetNameEvent,
SetSymbolEvent,
SRC20,
UpdateTotalSupplyEvent,
};
use standards::src20::{SetDecimalsEvent, SetNameEvent, SetSymbolEvent, SRC20, TotalSupplyEvent,};
use std::{auth::msg_sender, string::String};

configurable {
Expand Down Expand Up @@ -200,7 +194,7 @@ impl EmitSRC20Events for Contract {
sender,
});

log(UpdateTotalSupplyEvent {
log(TotalSupplyEvent {
asset,
supply: TOTAL_SUPPLY,
sender,
Expand Down
14 changes: 4 additions & 10 deletions examples/src3-mint-burn/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use standards::{
SetNameEvent,
SetSymbolEvent,
SRC20,
UpdateTotalSupplyEvent,
TotalSupplyEvent,
},
src3::SRC3,
};
Expand Down Expand Up @@ -82,7 +82,7 @@ impl SRC3 for Contract {
let new_supply = amount + asset_supply.unwrap_or(0);
storage.total_supply.insert(asset_id, new_supply);

log(UpdateTotalSupplyEvent {
log(TotalSupplyEvent {
asset: asset_id,
supply: new_supply,
sender: msg_sender().unwrap(),
Expand Down Expand Up @@ -177,12 +177,12 @@ impl SRC20 for Contract {

abi SetSRC20Data {
#[storage(read)]
fn set_src20_data(asset: AssetId, total_supply: u64);
fn set_src20_data(asset: AssetId);
}

impl SetSRC20Data for Contract {
#[storage(read)]
fn set_src20_data(asset: AssetId, supply: u64) {
fn set_src20_data(asset: AssetId) {
// NOTE: There are no checks for if the caller has permissions to update the metadata
// If this asset does not exist, revert
if storage.total_supply.get(asset).try_read().is_none() {
Expand All @@ -207,11 +207,5 @@ impl SetSRC20Data for Contract {
decimals: DECIMALS,
sender,
});

log(UpdateTotalSupplyEvent {
asset,
supply,
sender,
});
}
}
4 changes: 2 additions & 2 deletions examples/src3-mint-burn/single_asset/src/single_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use standards::{
SetNameEvent,
SetSymbolEvent,
SRC20,
UpdateTotalSupplyEvent,
TotalSupplyEvent,
},
src3::SRC3,
};
Expand Down Expand Up @@ -73,7 +73,7 @@ impl SRC3 for Contract {
let new_supply = amount + storage.total_supply.read();
storage.total_supply.write(new_supply);

log(UpdateTotalSupplyEvent {
log(TotalSupplyEvent {
asset: AssetId::new(ContractId::this(), DEFAULT_SUB_ID),
supply: new_supply,
sender: msg_sender().unwrap(),
Expand Down
4 changes: 2 additions & 2 deletions examples/src7-metadata/multi_asset/src/multi_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use standards::{
SetNameEvent,
SetSymbolEvent,
SRC20,
UpdateTotalSupplyEvent,
TotalSupplyEvent,
},
src7::{
Metadata,
Expand Down Expand Up @@ -214,7 +214,7 @@ impl SetSRC20Data for Contract {
sender,
});

log(UpdateTotalSupplyEvent {
log(TotalSupplyEvent {
asset,
supply,
sender,
Expand Down
4 changes: 2 additions & 2 deletions examples/src7-metadata/single_asset/src/single_asset.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ use standards::{
SetNameEvent,
SetSymbolEvent,
SRC20,
UpdateTotalSupplyEvent,
TotalSupplyEvent,
},
src7::{
Metadata,
Expand Down Expand Up @@ -183,7 +183,7 @@ impl EmitSRC20Events for Contract {
sender,
});

log(UpdateTotalSupplyEvent {
log(TotalSupplyEvent {
asset,
supply: TOTAL_SUPPLY,
sender,
Expand Down
8 changes: 4 additions & 4 deletions standards/src/src20.sw
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,12 @@ pub struct SetDecimalsEvent {
pub sender: Identity,
}

/// The event emitted when the total supply is updated.
pub struct UpdateTotalSupplyEvent {
/// The event emitted when the total supply is changed.
pub struct TotalSupplyEvent {
/// The asset for which supply is updated.
pub asset: AssetId,
/// The supply that is set.
/// The new supply of the asset.
pub supply: u64,
/// The caller that modified the supply.
/// The caller that updated the supply.
pub sender: Identity,
}

0 comments on commit a7098b9

Please sign in to comment.