Skip to content

Commit

Permalink
extend seed expiration time
Browse files Browse the repository at this point in the history
  • Loading branch information
JimAelf committed Nov 12, 2024
1 parent 88d4e10 commit 8626f56
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
10 changes: 10 additions & 0 deletions contract/AElf.Contracts.MultiToken/TokenContract_Actions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -691,6 +691,16 @@ public override Int32Value GetMaxBatchApproveCount(Empty input)
};
}

public override Empty ExtendSeedExpirationTime(ExtendSeedExpirationTimeInput input)
{
var tokenInfo = GetTokenInfo(input.Symbol);
Assert(tokenInfo != null, "Seed NFT does not exist.");
Assert(tokenInfo.Owner == Context.Sender, "Sender is not Seed NFT owner.");

tokenInfo.ExternalInfo.Value["__seed_exp_time"] = input.ExpirationTime;
return base.ExtendSeedExpirationTime(input);
}

private int GetMaxBatchApproveCount()
{
return State.MaxBatchApproveCount.Value == 0
Expand Down
8 changes: 8 additions & 0 deletions protobuf/token_contract_impl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,9 @@ service TokenContractImpl {
rpc GetMaxBatchApproveCount (google.protobuf.Empty) returns (google.protobuf.Int32Value) {

}

rpc ExtendSeedExpirationTime (ExtendSeedExpirationTimeInput) returns (google.protobuf.Empty) {
}
}

message AdvanceResourceTokenInput {
Expand Down Expand Up @@ -444,4 +447,9 @@ message ModifyTokenIssuerAndOwnerInput {

message SetTokenIssuerAndOwnerModificationEnabledInput{
bool enabled = 1;
}

message ExtendSeedExpirationTimeInput {
string symbol = 1;
int64 expiration_time = 2;
}
11 changes: 11 additions & 0 deletions test/AElf.Contracts.MultiToken.Tests/BVT/TokenApplicationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1893,4 +1893,15 @@ public async Task TokenIssuerAndOwnerModification_Test()
result.TransactionResult.Error.ShouldContain("Set token issuer and owner disabled.");

}

[Theory]
[InlineData("SEED-0", 1731927992000)]
public async Task ExtendSeedExpirationTime_Test(string symbol, long expirationTime)
{
ExtendSeedExpirationTimeInput input = new ExtendSeedExpirationTimeInput();
input.Symbol = symbol;
input.ExpirationTime = expirationTime;

await TokenContractStub.ExtendSeedExpirationTime.CallAsync(input);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -240,4 +240,7 @@ internal async Task<IExecutionResult<Empty>> CreateMutiTokenWithExceptionAsync(
await CreateSeedNftAsync(stub, createInput);
return await stub.Create.SendWithExceptionAsync(createInput);
}



}

0 comments on commit 8626f56

Please sign in to comment.