Skip to content

Commit

Permalink
added website to register token instruction and fix cmd
Browse files Browse the repository at this point in the history
  • Loading branch information
billettc committed Nov 27, 2020
1 parent c666803 commit a519599
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
3 changes: 2 additions & 1 deletion cmd/slnc/cmd/token_registry_list.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ var tokenRegistryListCmd = &cobra.Command{
return fmt.Errorf("unable to retrieve entries: %w", err)
}

out := []string{"Is Initialized | Mint Address | Registration Authority | Logo | Name | Symbol"}
out := []string{"Is Initialized | Mint Address | Registration Authority | Logo | Name | Symbol | Website"}

for _, e := range entries {
initalized := "false"
Expand All @@ -52,6 +52,7 @@ var tokenRegistryListCmd = &cobra.Command{
e.Logo.String(),
e.Name.String(),
e.Symbol.String(),
e.Website.String(),
}
out = append(out, strings.Join(line, " | "))
}
Expand Down
8 changes: 6 additions & 2 deletions cmd/slnc/cmd/token_registry_register.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import (
)

var tokenRegistryRegisterCmd = &cobra.Command{
Use: "register {token-address} {name} {symbol} {logo}",
Use: "register {token-address} {name} {symbol} {logo} {website}",
Short: "register meta data for a token",
Args: cobra.ExactArgs(4),
RunE: func(cmd *cobra.Command, args []string) (err error) {
Expand All @@ -44,6 +44,7 @@ var tokenRegistryRegisterCmd = &cobra.Command{
var logo tokenregistry.Logo
var name tokenregistry.Name
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)
Expand All @@ -54,6 +55,9 @@ var tokenRegistryRegisterCmd = &cobra.Command{
if symbol, err = tokenregistry.SymbolFromString(args[3]); err != nil {
return fmt.Errorf("invalid symbol %q: %w", args[3], err)
}
if website, err = tokenregistry.WebsiteFromString(args[4]); err != nil {
return fmt.Errorf("invalid website %q: %w", args[4], err)
}

pkeyStr := viper.GetString("token-registry-register-cmd-registrar")
if pkeyStr == "" {
Expand Down Expand Up @@ -91,7 +95,7 @@ var tokenRegistryRegisterCmd = &cobra.Command{
tokenRegistryProgramID := tokenregistry.ProgramID()

createAccountInstruction := system.NewCreateAccountInstruction(uint64(lamport), tokenregistry.TOKEN_META_SIZE, tokenRegistryProgramID, registrarPubKey, tokenMetaAccount.PublicKey())
registerTokenInstruction := tokenregistry.NewRegisterTokenInstruction(logo, name, symbol, tokenMetaAccount.PublicKey(), registrarPubKey, tokenAddress)
registerTokenInstruction := tokenregistry.NewRegisterTokenInstruction(logo, name, symbol, website, tokenMetaAccount.PublicKey(), registrarPubKey, tokenAddress)

trx, err := solana.TransactionWithInstructions([]solana.TransactionInstruction{createAccountInstruction, registerTokenInstruction}, blockHashResult.Value.Blockhash, &solana.Options{
Payer: registrarPubKey,
Expand Down
9 changes: 5 additions & 4 deletions programs/tokenregistry/instruction.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,14 +39,15 @@ func DecodeInstruction(accounts []*solana.AccountMeta, compiledInstruction *sola
return &inst, nil
}

func NewRegisterTokenInstruction(logo Logo, name Name, symbol Symbol, tokenMetaKey, ownerKey, tokenKey solana.PublicKey) *Instruction {
func NewRegisterTokenInstruction(logo Logo, name Name, symbol Symbol, website Website, tokenMetaKey, ownerKey, tokenKey solana.PublicKey) *Instruction {
return &Instruction{
BaseVariant: bin.BaseVariant{
TypeID: 0,
Impl: &RegisterToken{
Logo: logo,
Name: name,
Symbol: symbol,
Logo: logo,
Name: name,
Website: website,
Symbol: symbol,
Accounts: &RegisterTokenAccounts{
TokenMeta: &solana.AccountMeta{tokenMetaKey, false, true},
Owner: &solana.AccountMeta{ownerKey, true, false},
Expand Down

0 comments on commit a519599

Please sign in to comment.