Skip to content

Commit

Permalink
chore: rename to TokenFactoryMsg (match osmosis)
Browse files Browse the repository at this point in the history
  • Loading branch information
Reecepbcups committed Aug 22, 2023
1 parent f3618c3 commit 92e5ce2
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 18 deletions.
28 changes: 14 additions & 14 deletions x/tokenfactory/bindings/custom_msg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ func TestCreateDenomMsg(t *testing.T) {
reflectAmount := sdk.NewCoins(sdk.NewCoin(types.DefaultParams().DenomCreationFee[0].Denom, types.DefaultParams().DenomCreationFee[0].Amount.MulRaw(100)))
fundAccount(t, ctx, junoapp, reflect, reflectAmount)

msg := bindings.TokenMsg{CreateDenom: &bindings.CreateDenom{
msg := bindings.TokenFactoryMsg{CreateDenom: &bindings.CreateDenom{
Subdenom: "SUN",
}}
err := executeCustom(t, ctx, junoapp, reflect, lucky, msg, sdk.Coin{})
Expand Down Expand Up @@ -64,7 +64,7 @@ func TestMintMsg(t *testing.T) {
require.Empty(t, balances)

// Create denom for minting
msg := bindings.TokenMsg{CreateDenom: &bindings.CreateDenom{
msg := bindings.TokenFactoryMsg{CreateDenom: &bindings.CreateDenom{
Subdenom: "SUN",
}}
err := executeCustom(t, ctx, junoapp, reflect, lucky, msg, sdk.Coin{})
Expand All @@ -73,7 +73,7 @@ func TestMintMsg(t *testing.T) {

amount, ok := sdk.NewIntFromString("808010808")
require.True(t, ok)
msg = bindings.TokenMsg{MintTokens: &bindings.MintTokens{
msg = bindings.TokenFactoryMsg{MintTokens: &bindings.MintTokens{
Denom: sunDenom,
Amount: amount,
MintToAddress: lucky.String(),
Expand Down Expand Up @@ -123,15 +123,15 @@ func TestMintMsg(t *testing.T) {

// now mint another amount / denom
// create it first
msg = bindings.TokenMsg{CreateDenom: &bindings.CreateDenom{
msg = bindings.TokenFactoryMsg{CreateDenom: &bindings.CreateDenom{
Subdenom: "MOON",
}}
err = executeCustom(t, ctx, junoapp, reflect, lucky, msg, sdk.Coin{})
require.NoError(t, err)
moonDenom := fmt.Sprintf("factory/%s/%s", reflect.String(), msg.CreateDenom.Subdenom)

amount = amount.SubRaw(1)
msg = bindings.TokenMsg{MintTokens: &bindings.MintTokens{
msg = bindings.TokenFactoryMsg{MintTokens: &bindings.MintTokens{
Denom: moonDenom,
Amount: amount,
MintToAddress: lucky.String(),
Expand Down Expand Up @@ -193,7 +193,7 @@ func TestForceTransfer(t *testing.T) {
require.Empty(t, balances)

// Create denom for minting
msg := bindings.TokenMsg{CreateDenom: &bindings.CreateDenom{
msg := bindings.TokenFactoryMsg{CreateDenom: &bindings.CreateDenom{
Subdenom: "SUN",
}}
err := executeCustom(t, ctx, junoapp, reflect, lucky, msg, sdk.Coin{})
Expand All @@ -204,7 +204,7 @@ func TestForceTransfer(t *testing.T) {
require.True(t, ok)

// Mint new tokens to lucky
msg = bindings.TokenMsg{MintTokens: &bindings.MintTokens{
msg = bindings.TokenFactoryMsg{MintTokens: &bindings.MintTokens{
Denom: sunDenom,
Amount: amount,
MintToAddress: lucky.String(),
Expand All @@ -213,7 +213,7 @@ func TestForceTransfer(t *testing.T) {
require.NoError(t, err)

// Force move 100 tokens from lucky to rcpt
msg = bindings.TokenMsg{ForceTransfer: &bindings.ForceTransfer{
msg = bindings.TokenFactoryMsg{ForceTransfer: &bindings.ForceTransfer{
Denom: sunDenom,
Amount: sdk.NewInt(100),
FromAddress: lucky.String(),
Expand Down Expand Up @@ -246,7 +246,7 @@ func TestBurnMsg(t *testing.T) {
require.Empty(t, balances)

// Create denom for minting
msg := bindings.TokenMsg{CreateDenom: &bindings.CreateDenom{
msg := bindings.TokenFactoryMsg{CreateDenom: &bindings.CreateDenom{
Subdenom: "SUN",
}}
err := executeCustom(t, ctx, junoapp, reflect, lucky, msg, sdk.Coin{})
Expand All @@ -256,7 +256,7 @@ func TestBurnMsg(t *testing.T) {
amount, ok := sdk.NewIntFromString("808010809")
require.True(t, ok)

msg = bindings.TokenMsg{MintTokens: &bindings.MintTokens{
msg = bindings.TokenFactoryMsg{MintTokens: &bindings.MintTokens{
Denom: sunDenom,
Amount: amount,
MintToAddress: lucky.String(),
Expand All @@ -267,7 +267,7 @@ func TestBurnMsg(t *testing.T) {
// can burn from different address with burnFrom
amt, ok := sdk.NewIntFromString("1")
require.True(t, ok)
msg = bindings.TokenMsg{BurnTokens: &bindings.BurnTokens{
msg = bindings.TokenFactoryMsg{BurnTokens: &bindings.BurnTokens{
Denom: sunDenom,
Amount: amt,
BurnFromAddress: lucky.String(),
Expand All @@ -280,7 +280,7 @@ func TestBurnMsg(t *testing.T) {
err = junoapp.AppKeepers.BankKeeper.SendCoins(ctx, lucky, reflect, luckyBalance)
require.NoError(t, err)

msg = bindings.TokenMsg{BurnTokens: &bindings.BurnTokens{
msg = bindings.TokenFactoryMsg{BurnTokens: &bindings.BurnTokens{
Denom: sunDenom,
Amount: amount.Abs().Sub(sdk.NewInt(1)),
BurnFromAddress: reflect.String(),
Expand All @@ -302,8 +302,8 @@ type ReflectSubMsgs struct {
Msgs []wasmvmtypes.SubMsg `json:"msgs"`
}

func executeCustom(t *testing.T, ctx sdk.Context, junoapp *app.App, contract sdk.AccAddress, sender sdk.AccAddress, msg bindings.TokenMsg, funds sdk.Coin) error { //nolint:unparam // funds is always nil but could change in the future.
wrapped := bindings.TokenFactoryMsg{
func executeCustom(t *testing.T, ctx sdk.Context, junoapp *app.App, contract sdk.AccAddress, sender sdk.AccAddress, msg bindings.TokenFactoryMsg, funds sdk.Coin) error { //nolint:unparam // funds is always nil but could change in the future.
wrapped := bindings.TokenMsg{
Token: &msg,
}
customBz, err := json.Marshal(wrapped)
Expand Down
2 changes: 1 addition & 1 deletion x/tokenfactory/bindings/message_plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre
if msg.Custom != nil {
// only handle the happy path where this is really creating / minting / swapping ...
// leave everything else for the wrapped version
var contractMsg bindingstypes.TokenFactoryMsg
var contractMsg bindingstypes.TokenMsg
if err := json.Unmarshal(msg.Custom, &contractMsg); err != nil {
return nil, nil, errorsmod.Wrap(err, "token factory msg")
}
Expand Down
6 changes: 3 additions & 3 deletions x/tokenfactory/bindings/types/msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package types

import "cosmossdk.io/math"

type TokenFactoryMsg struct {
Token *TokenMsg `json:"token,omitempty"`
type TokenMsg struct {
Token *TokenFactoryMsg `json:"token,omitempty"`
}

type TokenMsg struct {
type TokenFactoryMsg struct {
/// Contracts can create denoms, namespaced under the contract's address.
/// A contract may create any number of independent sub-denoms.
CreateDenom *CreateDenom `json:"create_denom,omitempty"`
Expand Down

0 comments on commit 92e5ce2

Please sign in to comment.