mirror of
https://github.com/0glabs/0g-chain.git
synced 2024-12-24 23:35:19 +00:00
Fix Periodic Vesting Account JSON for Trust Wallet (#630)
* massage vesting account json to match cosmos-sdk/Account json for trust wallet * remove comment
This commit is contained in:
parent
e14466547d
commit
60d7f522e2
@ -239,6 +239,7 @@ func makeCodecV03() *codec.Codec {
|
|||||||
v0_3valvesting.RegisterCodec(v0_3Codec)
|
v0_3valvesting.RegisterCodec(v0_3Codec)
|
||||||
return v0_3Codec
|
return v0_3Codec
|
||||||
}
|
}
|
||||||
|
|
||||||
func rollbackAccountType(newAccount authexported.Account) v18de63auth.Account {
|
func rollbackAccountType(newAccount authexported.Account) v18de63auth.Account {
|
||||||
switch acc := newAccount.(type) {
|
switch acc := newAccount.(type) {
|
||||||
|
|
||||||
|
@ -1,6 +1,12 @@
|
|||||||
package v18de63
|
package v18de63
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"strconv"
|
||||||
|
|
||||||
|
"github.com/tendermint/tendermint/crypto"
|
||||||
|
|
||||||
|
"github.com/cosmos/cosmos-sdk/codec"
|
||||||
sdk "github.com/cosmos/cosmos-sdk/types"
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -31,6 +37,52 @@ type PeriodicVestingAccount struct {
|
|||||||
VestingPeriods Periods `json:"vesting_periods" yaml:"vesting_periods"` // the vesting schedule
|
VestingPeriods Periods `json:"vesting_periods" yaml:"vesting_periods"` // the vesting schedule
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type prettyPublicKey struct {
|
||||||
|
PubKey crypto.PubKey
|
||||||
|
}
|
||||||
|
|
||||||
|
func (p prettyPublicKey) MarshalJSON() ([]byte, error) {
|
||||||
|
cdc := codec.New()
|
||||||
|
codec.RegisterCrypto(cdc)
|
||||||
|
return cdc.MarshalJSON(p.PubKey)
|
||||||
|
}
|
||||||
|
|
||||||
|
type vestingAccountPretty struct {
|
||||||
|
Address sdk.AccAddress `json:"address" yaml:"address"`
|
||||||
|
Coins sdk.Coins `json:"coins" yaml:"coins"`
|
||||||
|
PubKey prettyPublicKey `json:"public_key" yaml:"public_key"`
|
||||||
|
AccountNumber string `json:"account_number" yaml:"account_number"`
|
||||||
|
Sequence string `json:"sequence" yaml:"sequence"`
|
||||||
|
OriginalVesting sdk.Coins `json:"original_vesting" yaml:"original_vesting"`
|
||||||
|
DelegatedFree sdk.Coins `json:"delegated_free" yaml:"delegated_free"`
|
||||||
|
DelegatedVesting sdk.Coins `json:"delegated_vesting" yaml:"delegated_vesting"`
|
||||||
|
EndTime int64 `json:"end_time" yaml:"end_time"`
|
||||||
|
|
||||||
|
// custom fields based on concrete vesting type which can be omitted
|
||||||
|
StartTime int64 `json:"start_time,omitempty" yaml:"start_time,omitempty"`
|
||||||
|
VestingPeriods Periods `json:"vesting_periods,omitempty" yaml:"vesting_periods,omitempty"`
|
||||||
|
}
|
||||||
|
|
||||||
|
func (pva PeriodicVestingAccount) MarshalJSON() ([]byte, error) {
|
||||||
|
pubKey := prettyPublicKey{PubKey: pva.PubKey}
|
||||||
|
|
||||||
|
alias := vestingAccountPretty{
|
||||||
|
Address: pva.Address,
|
||||||
|
Coins: pva.Coins,
|
||||||
|
PubKey: pubKey,
|
||||||
|
AccountNumber: strconv.FormatUint(pva.AccountNumber, 10),
|
||||||
|
Sequence: strconv.FormatUint(pva.Sequence, 10),
|
||||||
|
OriginalVesting: pva.OriginalVesting,
|
||||||
|
DelegatedFree: pva.DelegatedFree,
|
||||||
|
DelegatedVesting: pva.DelegatedVesting,
|
||||||
|
EndTime: pva.EndTime,
|
||||||
|
StartTime: pva.StartTime,
|
||||||
|
VestingPeriods: pva.VestingPeriods,
|
||||||
|
}
|
||||||
|
|
||||||
|
return json.Marshal(alias)
|
||||||
|
}
|
||||||
|
|
||||||
// DelayedVestingAccount implements the VestingAccount interface. It vests all
|
// DelayedVestingAccount implements the VestingAccount interface. It vests all
|
||||||
// coins after a specific time, but non prior. In other words, it keeps them
|
// coins after a specific time, but non prior. In other words, it keeps them
|
||||||
// locked until a specified time.
|
// locked until a specified time.
|
||||||
|
Loading…
Reference in New Issue
Block a user