Skip to content

Commit

Permalink
fix program entry
Browse files Browse the repository at this point in the history
  • Loading branch information
jubeless committed Nov 27, 2020
1 parent a519599 commit ea1c459
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
9 changes: 8 additions & 1 deletion cmd/slnc/cmd/get_program_accounts.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,9 @@ import (
"context"
"encoding/json"
"fmt"
"os"

"github.com/dfuse-io/solana-go/text"

"github.com/dfuse-io/solana-go"

Expand All @@ -43,7 +46,6 @@ var getProgramAccountsCmd = &cobra.Command{

for _, keyedAcct := range resp {
acct := keyedAcct.Account
//fmt.Println("Data len:", len(acct.Data), keyedAcct.Pubkey)

obj, err := decode(acct.Owner, acct.Data)
if err != nil {
Expand All @@ -56,6 +58,11 @@ var getProgramAccountsCmd = &cobra.Command{
return err
}
fmt.Printf("Data %T: %s\n", obj, string(cnt))
return nil
}

if err := text.NewEncoder(os.Stdout).Encode(acct, nil); err != nil {
return fmt.Errorf("unable to text encode account: %w", err)
}
}

Expand Down
8 changes: 6 additions & 2 deletions cmd/slnc/cmd/token_list_mints.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,13 @@ var tokenListMintsCmd = &cobra.Command{
if err != nil {
return fmt.Errorf("unable to retrieve mints: %w", err)
}
out := []string{"Supply | Decimals | Token Authority | Freeze Authority"}
out := []string{"Mint | Decimals | Supply | Token Authority | Freeze Authority"}
for _, m := range mints {
line := []string{fmt.Sprintf("%d", m.Supply), fmt.Sprintf("%d", m.Decimals)}
line := []string{
fmt.Sprintf("%d", m),
fmt.Sprintf("%d", m.Supply),
fmt.Sprintf("%d", m.Decimals),
}
if m.MintAuthorityOption != 0 {
line = append(line, fmt.Sprintf("%s", m.MintAuthority))
} else {
Expand Down
17 changes: 10 additions & 7 deletions cmd/slnc/cmd/token_registry_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
var tokenRegistryRegisterCmd = &cobra.Command{
Use: "register {token-address} {name} {symbol} {logo} {website}",
Short: "register meta data for a token",
Args: cobra.ExactArgs(4),
Args: cobra.ExactArgs(5),
RunE: func(cmd *cobra.Command, args []string) (err error) {
vault := mustGetWallet()
client := getClient()
Expand All @@ -46,15 +46,18 @@ var tokenRegistryRegisterCmd = &cobra.Command{
var symbol tokenregistry.Symbol
var website tokenregistry.Website

if logo, err = tokenregistry.LogoFromString(args[1]); err != nil {
return fmt.Errorf("invalid logo %q: %w", args[1], err)
if name, err = tokenregistry.NameFromString(args[1]); err != nil {
return fmt.Errorf("invalid name %q: %w", args[1], err)
}
if name, err = tokenregistry.NameFromString(args[2]); err != nil {
return fmt.Errorf("invalid name %q: %w", args[2], err)

if symbol, err = tokenregistry.SymbolFromString(args[2]); err != nil {
return fmt.Errorf("invalid symbol %q: %w", args[2], err)
}
if symbol, err = tokenregistry.SymbolFromString(args[3]); err != nil {
return fmt.Errorf("invalid symbol %q: %w", args[3], err)

if logo, err = tokenregistry.LogoFromString(args[3]); err != nil {
return fmt.Errorf("invalid logo %q: %w", args[3], err)
}

if website, err = tokenregistry.WebsiteFromString(args[4]); err != nil {
return fmt.Errorf("invalid website %q: %w", args[4], err)
}
Expand Down

0 comments on commit ea1c459

Please sign in to comment.