git.delta.rocks / unique-network / refs/commits / d228734b6986

difftreelog

feat(pallet-refungible) events for repartition method

Grigoriy Simonov2022-07-22parent: #f779788.patch.diff
in: master

1 file changed

modifiedpallets/refungible/src/lib.rsdiffbeforeafterboth
1152 <Balance<T>>::insert((collection.id, token, owner), amount);1152 <Balance<T>>::insert((collection.id, token, owner), amount);
1153 <TotalSupply<T>>::insert((collection.id, token), amount);1153 <TotalSupply<T>>::insert((collection.id, token), amount);
1154
1155 if amount > total_pieces {
1156 let mint_amount = amount - total_pieces;
1157 <PalletEvm<T>>::deposit_log(
1158 ERC20Events::Transfer {
1159 from: H160::default(),
1160 to: *owner.as_eth(),
1161 value: mint_amount.into(),
1162 }
1163 .to_log(T::EvmTokenAddressMapping::token_to_address(
1164 collection.id,
1165 token,
1166 )),
1167 );
1168 <PalletCommon<T>>::deposit_event(CommonEvent::ItemCreated(
1169 collection.id,
1170 token,
1171 owner.clone(),
1172 mint_amount,
1173 ));
1174 } else if total_pieces > amount {
1175 let burn_amount = total_pieces - amount;
1176 <PalletEvm<T>>::deposit_log(
1177 ERC20Events::Transfer {
1178 from: *owner.as_eth(),
1179 to: H160::default(),
1180 value: burn_amount.into(),
1181 }
1182 .to_log(T::EvmTokenAddressMapping::token_to_address(
1183 collection.id,
1184 token,
1185 )),
1186 );
1187 <PalletCommon<T>>::deposit_event(CommonEvent::ItemDestroyed(
1188 collection.id,
1189 token,
1190 owner.clone(),
1191 burn_amount,
1192 ));
1193 }
1194
1154 Ok(())1195 Ok(())
1155 }1196 }