Skip to content

Commit

Permalink
remove mint command (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
sambukowski authored Jun 10, 2024
1 parent ad17017 commit 30efe51
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 157 deletions.
67 changes: 0 additions & 67 deletions cmd/sequencer/sudo/mint.go

This file was deleted.

90 changes: 0 additions & 90 deletions internal/sequencer/sequencer.go
Original file line number Diff line number Diff line change
Expand Up @@ -736,96 +736,6 @@ func RemoveIBCRelayer(opts IBCRelayerOpts) (*IBCRelayerResponse, error) {
return tr, nil
}

// Mint tokens to an account.
func Mint(opts MintOpts) (*MintResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

log.Debugf("Mint Opts: %v", opts)

// client
opts.SequencerURL = addPortToURL(opts.SequencerURL)
log.Debug("Creating CometBFT client with url: ", opts.SequencerURL)
c, err := client.NewClient(opts.SequencerURL)
if err != nil {
log.WithError(err).Error("Error creating sequencer client")
return &MintResponse{}, err
}

// create signer
from, err := privateKeyFromText(opts.FromKey)
if err != nil {
log.WithError(err).Error("Error decoding private key")
return &MintResponse{}, err
}
signer := client.NewSigner(from)

// Get current address nonce
fromAddr := signer.Address()
nonce, err := c.GetNonce(ctx, fromAddr)
if err != nil {
log.WithError(err).Error("Error getting nonce")
return &MintResponse{}, err
}

to, err := addressFromText(opts.ToAddress)
if err != nil {
log.WithError(err).Errorf("Error decoding hex encoded 'to' address %v", opts.ToAddress)
return &MintResponse{}, err
}

amount, err := convertToUint128(opts.Amount)
if err != nil {
log.WithError(err).Error("Error converting amount to Uint128 proto")
return &MintResponse{}, err
}

tx := &txproto.UnsignedTransaction{
Params: &txproto.TransactionParams{
ChainId: opts.SequencerChainID,
Nonce: nonce,
},
Actions: []*txproto.Action{
{
Value: &txproto.Action_MintAction{
MintAction: &txproto.MintAction{
To: to,
Amount: amount,
},
},
},
},
}

// sign transaction
signed, err := signer.SignTransaction(tx)
if err != nil {
log.WithError(err).Error("Error signing transaction")
return &MintResponse{}, err
}

// broadcast tx
resp, err := c.BroadcastTxSync(ctx, signed)
if err != nil {
log.WithError(err).Error("Error broadcasting transaction")
return &MintResponse{}, err
}
log.Debugf("Broadcast response: %v", resp)

// response
hash := hex.EncodeToString(resp.Hash)
tr := &MintResponse{
From: hex.EncodeToString(fromAddr[:]),
Nonce: nonce,
To: opts.ToAddress,
Amount: opts.Amount,
TxHash: hash,
}

log.Debugf("Mint TX hash: %v", hash)
return tr, nil
}

// ChangeSudoAddress changes the sudo address.
func ChangeSudoAddress(opts ChangeSudoAddressOpts) (*ChangeSudoAddressResponse, error) {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
Expand Down

0 comments on commit 30efe51

Please sign in to comment.