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: handle feegrant module #276

Merged
merged 50 commits into from
Dec 13, 2021
Merged
Changes from 1 commit
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
6465956
register feegrant module
MonikaCat Nov 26, 2021
64f0a12
Add feegrant types
MonikaCat Nov 26, 2021
44b7d37
Create table
MonikaCat Nov 26, 2021
65af9dc
Add hadle msg
MonikaCat Nov 26, 2021
6d76d08
Updated handle msg
MonikaCat Nov 26, 2021
011b840
Updated fee grant types
MonikaCat Nov 26, 2021
7a7e6ac
Merge branch 'v2/cosmos/v0.44.x' of https://github.com/forbole/bdjuno…
MonikaCat Dec 2, 2021
eec9a8e
Updated feegrant schema
MonikaCat Dec 2, 2021
3013022
add fix cmd for feegrant allowance
huichiaotsou Dec 2, 2021
447ffd2
Update schema
MonikaCat Dec 2, 2021
fb9311c
Updated error msgs
MonikaCat Dec 2, 2021
0fe3080
Update comment
MonikaCat Dec 2, 2021
10cdda6
Update comment
MonikaCat Dec 2, 2021
29ecb69
Updated methods name
MonikaCat Dec 2, 2021
826f83c
rm space
MonikaCat Dec 2, 2021
196bf16
Update database/schema/12-feegrant.sql
MonikaCat Dec 3, 2021
daef885
Update database/feegrant.go
MonikaCat Dec 3, 2021
cd195ed
Store accounts before processing allowances
MonikaCat Dec 3, 2021
ec95dcd
Add feegrant types
MonikaCat Dec 3, 2021
7addbdf
Update methods with new feegrant types
MonikaCat Dec 3, 2021
0b0b33e
Updated hasura metadata
MonikaCat Dec 3, 2021
f80b807
Add block module
MonikaCat Dec 3, 2021
8053139
Updated go.mod
MonikaCat Dec 3, 2021
7cfb123
Updated feegrant.sql
MonikaCat Dec 7, 2021
ac894d3
Updated feegrant hasura metadata
MonikaCat Dec 7, 2021
2335982
Updated FeeGrant struct type to feegrant.Grant
MonikaCat Dec 7, 2021
3d5fc20
Update height param in removeExpiredFeeGrantAllowances method
MonikaCat Dec 7, 2021
b2874ff
lint
MonikaCat Dec 7, 2021
761e6fb
Add unit test
MonikaCat Dec 7, 2021
3bcb65f
Update feegrant.sql
MonikaCat Dec 7, 2021
038fd3d
Fix typo
MonikaCat Dec 7, 2021
43b577d
Update feegrant.sql
MonikaCat Dec 7, 2021
8b0d439
update address wrapper
MonikaCat Dec 7, 2021
a5ff508
.
MonikaCat Dec 8, 2021
a9b030d
Update test.go
MonikaCat Dec 8, 2021
f9b3cea
Rm unused import
MonikaCat Dec 8, 2021
d6df1ec
fixed tests and lint
RiccardoM Dec 8, 2021
972f8b2
Update modules/feegrant/handle_block.go
MonikaCat Dec 8, 2021
068d9a5
Update modules/feegrant/handle_block.go
MonikaCat Dec 8, 2021
1e14577
Update modules/feegrant/handle_msg.go
MonikaCat Dec 8, 2021
e0249a6
Update modules/feegrant/handle_msg.go
MonikaCat Dec 8, 2021
648f8dc
Update modules/feegrant/handle_msg.go
MonikaCat Dec 8, 2021
cab657e
Update modules/feegrant/handle_msg.go
MonikaCat Dec 8, 2021
c8a926f
Update modules/feegrant/module.go
MonikaCat Dec 8, 2021
67a9ac3
Update makefile
MonikaCat Dec 8, 2021
2ab49df
Merge branch 'm/feegrant-v0.44.x' of https://github.com/forbole/bdjun…
MonikaCat Dec 8, 2021
2eeac5a
Update feegrant tx parsing in cmd fix
MonikaCat Dec 9, 2021
b57f85a
Update cmd/fix/feegrant/allowance.go
MonikaCat Dec 10, 2021
a241136
Fix lint
MonikaCat Dec 10, 2021
ec8427d
removed unused QueryBlock method
RiccardoM Dec 13, 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
Update cmd/fix/feegrant/allowance.go
Co-authored-by: Riccardo Montagnin <[email protected]>
  • Loading branch information
MonikaCat and RiccardoM authored Dec 10, 2021
commit b57f85aebbd14ff4df0ba684dbc120e204b70a00
83 changes: 31 additions & 52 deletions cmd/fix/feegrant/allowance.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,74 +38,53 @@ func allowanceCmd(parseConfig *parse.Config) *cobra.Command {
feegrantModule := feegrant.NewModule(parseCtx.EncodingConfig.Marshaler, db)

// Get the accounts
addresses, err := db.GetAccounts()
// Collect all the transactions
var txs []*tmctypes.ResultTx

// Get all the MsgGrantAllowance txs
query := fmt.Sprintf("message.action='%s'", feegranttypes.EventTypeSetFeeGrant)
grantAllowanceTxs, err := utils.QueryTxs(parseCtx.Node, query)
if err != nil {
return err
}
txs = append(txs, grantAllowanceTxs...)

for _, address := range addresses {
// Collect all the transactions
var txs []*tmctypes.ResultTx

// Get all the MsgGrantAllowance txs
query := fmt.Sprintf("set_feegrant.granter='%s'", address)
grantAllowanceTxs, err := utils.QueryTxs(parseCtx.Node, query)
if err != nil {
return err
}
txs = append(txs, grantAllowanceTxs...)

query = fmt.Sprintf("set_feegrant.grantee='%s'", address)
grantAllowanceTxs, err = utils.QueryTxs(parseCtx.Node, query)
if err != nil {
return err
}
txs = append(txs, grantAllowanceTxs...)
// Get all the MsgRevokeAllowance txs
query = fmt.Sprintf("message.action='%s'", feegranttypes.EventTypeRevokeFeeGrant)
revokeAllowanceTxs, err := utils.QueryTxs(parseCtx.Node, query)
if err != nil {
return err
}
txs = append(txs, revokeAllowanceTxs...)

// Get all the MsgRevokeAllowance txs
query = fmt.Sprintf("revoke_feegrant.granter='%s'", address)
revokeAllowanceTxs, err := utils.QueryTxs(parseCtx.Node, query)
if err != nil {
return err
}
txs = append(txs, revokeAllowanceTxs...)
// Sort the txs based on their ascending height
sort.Slice(txs, func(i, j int) bool {
return txs[i].Height < txs[j].Height
})

query = fmt.Sprintf("revoke_feegrant.grantee='%s'", address)
revokeAllowanceTxs, err = utils.QueryTxs(parseCtx.Node, query)
for _, tx := range txs {
log.Debug().Int64("height", tx.Height).Msg("parsing transaction")
transaction, err := parseCtx.Node.Tx(hex.EncodeToString(tx.Tx.Hash()))
if err != nil {
return err
}
txs = append(txs, revokeAllowanceTxs...)

// Sort the txs based on their ascending height
sort.Slice(txs, func(i, j int) bool {
return txs[i].Height < txs[j].Height
})
// Handle only the MsgGrantAllowance and MsgRevokeAllowance instances
for index, msg := range transaction.GetMsgs() {
_, isMsgGrantAllowance := msg.(*feegranttypes.MsgGrantAllowance)
_, isMsgRevokeAllowance := msg.(*feegranttypes.MsgRevokeAllowance)

for _, tx := range txs {
log.Debug().Int64("height", tx.Height).Msg("parsing transaction")

transaction, err := parseCtx.Node.Tx(hex.EncodeToString(tx.Tx.Hash()))
if err != nil {
return err
if !isMsgGrantAllowance && !isMsgRevokeAllowance {
continue
}

// Handle only the MsgGrantAllowance and MsgRevokeAllowance instances
for index, msg := range transaction.GetMsgs() {
_, isMsgGrantAllowance := msg.(*feegranttypes.MsgGrantAllowance)
_, isMsgRevokeAllowance := msg.(*feegranttypes.MsgRevokeAllowance)

if !isMsgGrantAllowance && !isMsgRevokeAllowance {
continue
}

err = feegrantModule.HandleMsg(index, msg, transaction)
if err != nil {
return fmt.Errorf("error while handling feegrant module message: %s", err)
}
err = feegrantModule.HandleMsg(index, msg, transaction)
if err != nil {
return fmt.Errorf("error while handling feegrant module message: %s", err)
}
}
}
}

return nil
},
Expand Down