File tree Expand file tree Collapse file tree 4 files changed +59
-0
lines changed
contract/AElf.Contracts.MultiToken
test/AElf.Contracts.MultiToken.Tests Expand file tree Collapse file tree 4 files changed +59
-0
lines changed Original file line number Diff line number Diff line change @@ -691,6 +691,35 @@ public override Int32Value GetMaxBatchApproveCount(Empty input)
691691 } ;
692692 }
693693
694+ public override Empty ExtendSeedExpirationTime ( ExtendSeedExpirationTimeInput input )
695+ {
696+ var tokenInfo = GetTokenInfo ( input . Symbol ) ;
697+ if ( tokenInfo == null )
698+ {
699+ throw new AssertionException ( "Seed NFT does not exist." ) ;
700+ }
701+
702+ Assert ( tokenInfo . Owner == Context . Sender , "Sender is not Seed NFT owner." ) ;
703+ var oldExpireTimeLong = 0L ;
704+ if ( tokenInfo . ExternalInfo . Value . TryGetValue ( TokenContractConstants . SeedExpireTimeExternalInfoKey ,
705+ out var oldExpireTime ) )
706+ {
707+ long . TryParse ( oldExpireTime , out oldExpireTimeLong ) ;
708+ }
709+
710+ tokenInfo . ExternalInfo . Value [ TokenContractConstants . SeedExpireTimeExternalInfoKey ] =
711+ input . ExpirationTime . ToString ( ) ;
712+ State . TokenInfos [ input . Symbol ] = tokenInfo ;
713+ Context . Fire ( new SeedExpirationTimeUpdated
714+ {
715+ ChainId = tokenInfo . IssueChainId ,
716+ Symbol = input . Symbol ,
717+ OldExpirationTime = oldExpireTimeLong ,
718+ NewExpirationTime = input . ExpirationTime
719+ } ) ;
720+ return new Empty ( ) ;
721+ }
722+
694723 private int GetMaxBatchApproveCount ( )
695724 {
696725 return State . MaxBatchApproveCount . Value == 0
Original file line number Diff line number Diff line change @@ -182,6 +182,9 @@ service TokenContractImpl {
182182 rpc GetMaxBatchApproveCount (google .protobuf .Empty ) returns (google .protobuf .Int32Value ) {
183183
184184 }
185+
186+ rpc ExtendSeedExpirationTime (ExtendSeedExpirationTimeInput ) returns (google .protobuf .Empty ) {
187+ }
185188}
186189
187190message AdvanceResourceTokenInput {
@@ -444,4 +447,17 @@ message ModifyTokenIssuerAndOwnerInput {
444447
445448message SetTokenIssuerAndOwnerModificationEnabledInput {
446449 bool enabled = 1 ;
450+ }
451+
452+ message ExtendSeedExpirationTimeInput {
453+ string symbol = 1 ;
454+ int64 expiration_time = 2 ;
455+ }
456+
457+ message SeedExpirationTimeUpdated {
458+ option (aelf.is_event ) = true ;
459+ int32 chain_id = 1 ;
460+ string symbol = 2 ;
461+ int64 old_expiration_time = 3 ;
462+ int64 new_expiration_time = 4 ;
447463}
Original file line number Diff line number Diff line change @@ -1893,4 +1893,15 @@ public async Task TokenIssuerAndOwnerModification_Test()
18931893 result . TransactionResult . Error . ShouldContain ( "Set token issuer and owner disabled." ) ;
18941894
18951895 }
1896+
1897+ [ Theory ]
1898+ [ InlineData ( "SEED-0" , 1731927992000 ) ]
1899+ public async Task ExtendSeedExpirationTime_Test ( string symbol , long expirationTime )
1900+ {
1901+ ExtendSeedExpirationTimeInput input = new ExtendSeedExpirationTimeInput ( ) ;
1902+ input . Symbol = symbol ;
1903+ input . ExpirationTime = expirationTime ;
1904+
1905+ await TokenContractStub . ExtendSeedExpirationTime . CallAsync ( input ) ;
1906+ }
18961907}
Original file line number Diff line number Diff line change @@ -240,4 +240,7 @@ internal async Task<IExecutionResult<Empty>> CreateMutiTokenWithExceptionAsync(
240240 await CreateSeedNftAsync ( stub , createInput ) ;
241241 return await stub . Create . SendWithExceptionAsync ( createInput ) ;
242242 }
243+
244+
245+
243246}
You can’t perform that action at this time.
0 commit comments