Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add vesting account handling #232

Merged
merged 41 commits into from
Oct 20, 2021
Merged
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
97698d5
x/ditr handleMsg add go routines for refreching rewards and commision
huichiaotsou Oct 7, 2021
9a5283e
Merge branch 'v2/cosmos/stargate' into v2/aaron/update_rewards_commis…
huichiaotsou Oct 7, 2021
8e43f3f
merge
huichiaotsou Oct 8, 2021
91176e8
Merge branch 'v2/aaron/update_rewards_commission' of https://github.c…
huichiaotsou Oct 8, 2021
cece5af
move interval check to handle_block
huichiaotsou Oct 9, 2021
371b1a9
update comment
huichiaotsou Oct 9, 2021
4e6ff33
make shouldUpdateDelegatorRewardsAmounts a function
huichiaotsou Oct 12, 2021
ba35512
remove uneccessary update/refresh in handle msg
huichiaotsou Oct 12, 2021
8758b7f
fix no return value for shouldUpdateDelegatorRewardsAmounts
huichiaotsou Oct 12, 2021
30f23c5
add schema vesting_account
huichiaotsou Oct 13, 2021
c1a3588
schema
huichiaotsou Oct 15, 2021
6354fab
Merge branch 'v2/cosmos/stargate' into v2/aaron/vesting_account
huichiaotsou Oct 15, 2021
d600690
add structure in auth/handle_genesis.go
huichiaotsou Oct 15, 2021
e85ecf0
add types for JSON handling and for auth types/auth
huichiaotsou Oct 15, 2021
73719ad
add get genesis vesting accounts method in auth_accounts.go
huichiaotsou Oct 15, 2021
0616f38
add db.SaveVestingAccounts
huichiaotsou Oct 15, 2021
1f9f209
fix schema
huichiaotsou Oct 15, 2021
cc055ba
add schema(move create type COIN to auth.sql)
huichiaotsou Oct 19, 2021
e0e4f64
implement GetGenesisVestingAccounts and use in HandleGenesis
huichiaotsou Oct 19, 2021
6a53241
implement SaveVestingAccounts and the storing of 3 diff. vesting acco…
huichiaotsou Oct 19, 2021
91bdf17
add structs in types/auth.go: ContinuousVestingAccount/ DelayedVestin…
huichiaotsou Oct 19, 2021
563f8ea
modify sql comments
huichiaotsou Oct 19, 2021
7a5d81a
Merge remote-tracking branch 'remotes/origin/v2/aaron/vesting_account…
huichiaotsou Oct 19, 2021
31efda6
delete GetGenesisVestingAccounts from auth_accounts.go
huichiaotsou Oct 19, 2021
918ba27
modif comments GetGenesisVestingAccounts
huichiaotsou Oct 19, 2021
6fcac22
comment modif: Build vestingAccounts Array
huichiaotsou Oct 19, 2021
1b31894
linter issue: vestingAccountId -> vestingAccountID
huichiaotsou Oct 19, 2021
c006195
add unit test
huichiaotsou Oct 19, 2021
d655091
linter: Id -> ID
huichiaotsou Oct 19, 2021
71eb9f2
lint
MonikaCat Oct 19, 2021
600230c
remove fmt.Println
huichiaotsou Oct 20, 2021
39fc74d
fix comments, remove redundant store-to-db methods
huichiaotsou Oct 20, 2021
9be3448
rm unit test for save vesting account ftm
huichiaotsou Oct 20, 2021
234f23b
schema: length TEXT -> BIGINT
huichiaotsou Oct 20, 2021
4df7892
fix go.mod
huichiaotsou Oct 20, 2021
ace57db
rm custom row types from database/types/auth.go
huichiaotsou Oct 20, 2021
2dcdeaf
merge 2 cases(continuous and deleyed vesting account; move storeVesti…
huichiaotsou Oct 20, 2021
decd364
correctly merge 2 cases
huichiaotsou Oct 20, 2021
4d7e1ec
revert DBG to prev. version
huichiaotsou Oct 20, 2021
83c661a
Updated SaveVestingAccounts
MonikaCat Oct 20, 2021
2d39fd4
Merge branch 'v2/cosmos/stargate' into v2/aaron/vesting_account
mergify[bot] Oct 20, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
merge 2 cases(continuous and deleyed vesting account; move storeVesti…
…ngPeriods to SaveVestingAccounts
  • Loading branch information
huichiaotsou committed Oct 20, 2021
commit 2dcdeaf96b5ec119598106ab8e60418b0a578259
26 changes: 9 additions & 17 deletions database/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,31 +65,27 @@ func (db *Db) SaveVestingAccounts(vestingAccounts []exported.VestingAccount) err
}

for _, account := range vestingAccounts {
switch account.(type) {
switch vestingAccount := account.(type) {
case *vestingtypes.ContinuousVestingAccount:
err := db.storeVestingAccount(account)
if err != nil {
return fmt.Errorf("error while storing Continuous Vesting Account: %s", err)
}

case *vestingtypes.DelayedVestingAccount:
err := db.storeVestingAccount(account)
_, err := db.storeVestingAccount(account)
if err != nil {
return fmt.Errorf("error while storing Delayed Vesting Account: %s", err)
return err
}

case *vestingtypes.PeriodicVestingAccount:
err := db.storeVestingAccount(account)
vestingAccountRowID, err := db.storeVestingAccount(account)
if err != nil {
return fmt.Errorf("error while storing Periodic Vesting Account: %s", err)
return err
}
db.storeVestingPeriods(vestingAccountRowID, vestingAccount.VestingPeriods)
}
}

return nil
}

func (db *Db) storeVestingAccount(account exported.VestingAccount) error {
func (db *Db) storeVestingAccount(account exported.VestingAccount) (int, error) {
stmt := `
INSERT INTO vesting_account (type, address, original_vesting, end_time, start_time)
VALUES ($1, $2, $3, $4, $5)
Expand All @@ -109,14 +105,10 @@ func (db *Db) storeVestingAccount(account exported.VestingAccount) error {
).Scan(&vestingAccountRowID)

if err != nil {
return fmt.Errorf("error while saving Vesting Account: %s", err)
return vestingAccountRowID, fmt.Errorf("error while saving Vesting Account of type %v: %s", proto.MessageName(account), err)
}

if periodicVestingAccount, ok := account.(*vestingtypes.PeriodicVestingAccount); ok {
return db.storeVestingPeriods(vestingAccountRowID, periodicVestingAccount.VestingPeriods)
}

return nil
return vestingAccountRowID, nil
}

// storeVestingPeriods handles storing the vesting periods of PeriodicVestingAccount type
Expand Down