Skip to content

Commit 7aeb479

Browse files
committed
feat: add batch add/remove methods for transfer blacklist
1 parent 6a8674d commit 7aeb479

File tree

3 files changed

+371
-22
lines changed

3 files changed

+371
-22
lines changed

contract/AElf.Contracts.MultiToken/TokenContract_Actions.cs

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -859,11 +859,53 @@ public override Empty AddToTransferBlackList(Address input)
859859
return new Empty();
860860
}
861861

862+
public override Empty BatchAddToTransferBlackList(BatchAddToTransferBlackListInput input)
863+
{
864+
AssertControllerForTransferBlackList();
865+
Assert(input != null && input.Addresses != null && input.Addresses.Count > 0, "Invalid input.");
866+
867+
// Validate all addresses first
868+
foreach (var address in input.Addresses)
869+
{
870+
Assert(address != null && !address.Value.IsNullOrEmpty(), "Invalid address.");
871+
}
872+
873+
// Remove duplicates and add to blacklist
874+
var uniqueAddresses = input.Addresses.Distinct().ToList();
875+
foreach (var address in uniqueAddresses)
876+
{
877+
State.TransferBlackList[address] = true;
878+
}
879+
880+
return new Empty();
881+
}
882+
862883
public override Empty RemoveFromTransferBlackList(Address input)
863884
{
864885
AssertSenderAddressWith(GetDefaultParliamentController().OwnerAddress);
865886
Assert(input != null && !input.Value.IsNullOrEmpty(), "Invalid address.");
866887
State.TransferBlackList[input] = false;
867888
return new Empty();
868889
}
890+
891+
public override Empty BatchRemoveFromTransferBlackList(BatchRemoveFromTransferBlackListInput input)
892+
{
893+
AssertSenderAddressWith(GetDefaultParliamentController().OwnerAddress);
894+
Assert(input != null && input.Addresses != null && input.Addresses.Count > 0, "Invalid input.");
895+
896+
// Validate all addresses first
897+
foreach (var address in input.Addresses)
898+
{
899+
Assert(address != null && !address.Value.IsNullOrEmpty(), "Invalid address.");
900+
}
901+
902+
// Remove duplicates and remove from blacklist
903+
var uniqueAddresses = input.Addresses.Distinct().ToList();
904+
foreach (var address in uniqueAddresses)
905+
{
906+
State.TransferBlackList[address] = false;
907+
}
908+
909+
return new Empty();
910+
}
869911
}

protobuf/token_contract_impl.proto

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,19 @@ service TokenContractImpl {
198198
// Add an address to the transfer blacklist.
199199
rpc AddToTransferBlackList (aelf.Address) returns (google.protobuf.Empty) {
200200
}
201+
202+
// Add multiple addresses to the transfer blacklist.
203+
rpc BatchAddToTransferBlackList (BatchAddToTransferBlackListInput) returns (google.protobuf.Empty) {
204+
}
205+
201206
// Remove an address from the transfer blacklist. Only parliament owner can call this method.
202207
rpc RemoveFromTransferBlackList (aelf.Address) returns (google.protobuf.Empty) {
203208
}
209+
210+
// Remove multiple addresses from the transfer blacklist. Only parliament owner can call this method.
211+
rpc BatchRemoveFromTransferBlackList (BatchRemoveFromTransferBlackListInput) returns (google.protobuf.Empty) {
212+
}
213+
204214
// Check if an address is in the transfer blacklist.
205215
rpc IsInTransferBlackList (aelf.Address) returns (google.protobuf.BoolValue) {
206216
option (aelf.is_view) = true;
@@ -480,4 +490,12 @@ message SeedExpirationTimeUpdated {
480490
string symbol = 2;
481491
int64 old_expiration_time = 3;
482492
int64 new_expiration_time = 4;
493+
}
494+
495+
message BatchAddToTransferBlackListInput {
496+
repeated aelf.Address addresses = 1;
497+
}
498+
499+
message BatchRemoveFromTransferBlackListInput {
500+
repeated aelf.Address addresses = 1;
483501
}

0 commit comments

Comments
 (0)