Skip to content

Commit

Permalink
feat: Add SendGridInbox method to CosmosClient
Browse files Browse the repository at this point in the history
  • Loading branch information
ZeneDeLuca committed Jul 7, 2024
1 parent e39cc97 commit dc7fd1b
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions hypergrid-aide/tools/cosmos.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ func (c *CosmosClient) SendGridBlockFees(account cosmosaccount.Account, gridId s
}
println("Account: ", address)

txResp := &cosmosclient.Response{}
items := []*types.GridBlockFeeItem{}
for _, block := range blocks {
item := types.GridBlockFeeItem{
Expand All @@ -57,6 +56,7 @@ func (c *CosmosClient) SendGridBlockFees(account cosmosaccount.Account, gridId s
items = append(items, &item)
}

txResp := cosmosclient.Response{}
if len(items) > 0 {
// Define a message to create a post
msg := &types.MsgCreateGridBlockFee{
Expand All @@ -75,7 +75,37 @@ func (c *CosmosClient) SendGridBlockFees(account cosmosaccount.Account, gridId s
fmt.Print("MsgCreateGridTxFee:\n\n")
fmt.Println(txResp)
}
return txResp, nil
return &txResp, nil
}

func (c *CosmosClient) SendGridInbox(account cosmosaccount.Account, gridId string, data_account string, block SolanaBlock) (*cosmosclient.Response, error) {
address, err := account.Address("cosmos")
if err != nil {
log.Fatal(err)
}
println("Account: ", address)

// Define a message to create a grid inbox
msg := types.MsgCreateGridInbox{
Creator: address,
Grid: gridId,
Account: data_account,
Slot: strconv.FormatUint(block.Slot, 10),
Hash: block.Blockhash,
}

// Broadcast a transaction from account `alice` with the message
// to create a post store response in txResp
txResp, err := c.Client.BroadcastTx(c.Context, account, &msg)
if err != nil {
log.Fatal(err)
return nil, err
}
// Print response from broadcasting a transaction
fmt.Print("MsgCreateGridTxFee:\n\n")
fmt.Println(txResp)

return &txResp, nil
}

func (c *CosmosClient) QueryAllGridBlockFees() (*types.QueryAllGridBlockFeeResponse, error) {
Expand Down

0 comments on commit dc7fd1b

Please sign in to comment.