github.com/InjectiveLabs/sdk-go@v1.53.0/examples/exchange/accounts/5_SubaccountHistory/example.go (about)

     1  package main
     2  
     3  import (
     4  	"context"
     5  	"encoding/json"
     6  	"fmt"
     7  
     8  	"github.com/InjectiveLabs/sdk-go/client/common"
     9  	exchangeclient "github.com/InjectiveLabs/sdk-go/client/exchange"
    10  	accountPB "github.com/InjectiveLabs/sdk-go/exchange/accounts_rpc/pb"
    11  )
    12  
    13  func main() {
    14  	network := common.LoadNetwork("testnet", "lb")
    15  	exchangeClient, err := exchangeclient.NewExchangeClient(network)
    16  	if err != nil {
    17  		panic(err)
    18  	}
    19  
    20  	ctx := context.Background()
    21  	denom := "inj"
    22  	subaccountId := "0xaf79152ac5df276d9a8e1e2e22822f9713474902000000000000000000000000"
    23  	transferTypes := []string{"deposit"}
    24  	skip := uint64(0)
    25  	limit := int32(10)
    26  
    27  	req := accountPB.SubaccountHistoryRequest{
    28  		Denom:         denom,
    29  		SubaccountId:  subaccountId,
    30  		TransferTypes: transferTypes,
    31  		Skip:          skip,
    32  		Limit:         limit,
    33  	}
    34  
    35  	res, err := exchangeClient.GetSubaccountHistory(ctx, &req)
    36  	if err != nil {
    37  		fmt.Println(err)
    38  	}
    39  
    40  	str, _ := json.MarshalIndent(res, "", " ")
    41  	fmt.Print(string(str))
    42  }