mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 15:25:18 +00:00
address issues from audit (#793)
This commit is contained in:
parent
be498c72f5
commit
3d6e730368
@ -136,9 +136,7 @@ func (k Keeper) UnblockAddress(ctx sdk.Context, denom string, owner, addr sdk.Ac
|
|||||||
}
|
}
|
||||||
blocked, i := k.checkBlockedAddress(asset, addr)
|
blocked, i := k.checkBlockedAddress(asset, addr)
|
||||||
if !blocked {
|
if !blocked {
|
||||||
if blocked {
|
return sdkerrors.Wrapf(types.ErrAccountAlreadyUnblocked, "address: %s", addr)
|
||||||
return sdkerrors.Wrapf(types.ErrAccountAlreadyUnblocked, "address: %s", addr)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
blockedAddrs := k.removeBlockedAddress(asset.BlockedAddresses, i)
|
blockedAddrs := k.removeBlockedAddress(asset.BlockedAddresses, i)
|
||||||
|
@ -56,17 +56,22 @@ func (k Keeper) UpdateTimeBasedSupplyLimits(ctx sdk.Context) {
|
|||||||
if !found {
|
if !found {
|
||||||
supply = k.CreateNewAssetSupply(ctx, asset.Denom)
|
supply = k.CreateNewAssetSupply(ctx, asset.Denom)
|
||||||
}
|
}
|
||||||
if asset.RateLimit.Active {
|
if !asset.RateLimit.Active {
|
||||||
if asset.RateLimit.TimePeriod <= supply.TimeElapsed+timeElapsed {
|
// rate limiting is not active, reset supply
|
||||||
supply.TimeElapsed = time.Duration(0)
|
|
||||||
supply.CurrentSupply = sdk.NewCoin(asset.Denom, sdk.ZeroInt())
|
|
||||||
} else {
|
|
||||||
supply.TimeElapsed = supply.TimeElapsed + timeElapsed
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
supply.CurrentSupply = sdk.NewCoin(asset.Denom, sdk.ZeroInt())
|
supply.CurrentSupply = sdk.NewCoin(asset.Denom, sdk.ZeroInt())
|
||||||
supply.TimeElapsed = time.Duration(0)
|
supply.TimeElapsed = time.Duration(0)
|
||||||
|
k.SetAssetSupply(ctx, supply, asset.Denom)
|
||||||
|
continue
|
||||||
}
|
}
|
||||||
|
if asset.RateLimit.TimePeriod > supply.TimeElapsed+timeElapsed {
|
||||||
|
// rate limiting is active, the rate-limiting period has not expired
|
||||||
|
supply.TimeElapsed = supply.TimeElapsed + timeElapsed
|
||||||
|
k.SetAssetSupply(ctx, supply, asset.Denom)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
// rate limiting is active, the rate-limiting period has expired, and is now reset
|
||||||
|
supply.TimeElapsed = time.Duration(0)
|
||||||
|
supply.CurrentSupply = sdk.NewCoin(asset.Denom, sdk.ZeroInt())
|
||||||
k.SetAssetSupply(ctx, supply, asset.Denom)
|
k.SetAssetSupply(ctx, supply, asset.Denom)
|
||||||
}
|
}
|
||||||
k.SetPreviousBlockTime(ctx, ctx.BlockTime())
|
k.SetPreviousBlockTime(ctx, ctx.BlockTime())
|
||||||
|
@ -114,7 +114,7 @@ func (a Asset) String() string {
|
|||||||
a.Owner, a.Paused, a.Denom, a.BlockedAddresses, a.RateLimit)
|
a.Owner, a.Paused, a.Denom, a.BlockedAddresses, a.RateLimit)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assets array of Asset
|
// Assets slice of Asset
|
||||||
type Assets []Asset
|
type Assets []Asset
|
||||||
|
|
||||||
// Validate checks if all assets are valid and there are no duplicate entries
|
// Validate checks if all assets are valid and there are no duplicate entries
|
||||||
|
Loading…
Reference in New Issue
Block a user