Some checks failed
Docs Deploy / build_and_deploy (push) Has been cancelled
Generate Docs / cli (push) Has been cancelled
Generate Config Doc / cli (push) Has been cancelled
Go formatting / go-formatting (push) Has been cancelled
Check links / markdown-link-check (push) Has been cancelled
Integration / pre-test (push) Has been cancelled
Integration / test on (push) Has been cancelled
Integration / status (push) Has been cancelled
Lint / Lint Go code (push) Has been cancelled
Test / test (ubuntu-latest) (push) Has been cancelled
41 lines
1 KiB
Go
41 lines
1 KiB
Go
package cosmosclient
|
|
|
|
import (
|
|
"context"
|
|
|
|
sdk "github.com/cosmos/cosmos-sdk/types"
|
|
"github.com/cosmos/cosmos-sdk/types/query"
|
|
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"
|
|
|
|
"git.cw.tr/mukan-network/mukan-ignite/ignite/pkg/cosmosaccount"
|
|
)
|
|
|
|
func (c Client) BankBalances(ctx context.Context, address string, pagination *query.PageRequest) (sdk.Coins, error) {
|
|
defer c.lockBech32Prefix()()
|
|
|
|
req := &banktypes.QueryAllBalancesRequest{
|
|
Address: address,
|
|
Pagination: pagination,
|
|
}
|
|
|
|
resp, err := c.bankQueryClient.AllBalances(ctx, req)
|
|
if err != nil {
|
|
return nil, rpcError(c.nodeAddress, err)
|
|
}
|
|
return resp.Balances, nil
|
|
}
|
|
|
|
func (c Client) BankSendTx(ctx context.Context, fromAccount cosmosaccount.Account, toAddress string, amount sdk.Coins) (TxService, error) {
|
|
addr, err := fromAccount.Address(c.bech32Prefix)
|
|
if err != nil {
|
|
return TxService{}, err
|
|
}
|
|
|
|
msg := &banktypes.MsgSend{
|
|
FromAddress: addr,
|
|
ToAddress: toAddress,
|
|
Amount: amount,
|
|
}
|
|
|
|
return c.CreateTx(ctx, fromAccount, msg)
|
|
}
|