Skip to content

Commit

Permalink
support ibc token
Browse files Browse the repository at this point in the history
  • Loading branch information
dreamer-zq committed Apr 29, 2024
1 parent 0b60ff3 commit 95a033f
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion modules/token/types/v1/msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ var (
_ sdk.Msg = &MsgSwapToERC20{}
_ sdk.Msg = &MsgUpgradeERC20{}

regexpERC20Fmt = fmt.Sprintf("^[a-z][a-z0-9/]{%d,%d}$", tokentypes.MinimumSymbolLen-1, tokentypes.MaximumSymbolLen-1)
regexpERC20Fmt = fmt.Sprintf("^[a-z][a-zA-Z0-9/]{%d,%d}$", tokentypes.MinimumSymbolLen-1, 100)
regexpERC20 = regexp.MustCompile(regexpERC20Fmt).MatchString
)

Expand Down
32 changes: 32 additions & 0 deletions modules/token/types/v1/msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -259,3 +259,35 @@ func TestMsgTransferTokenOwnerValidation(t *testing.T) {
}
}
}

func TestMsgDeployERC20(t *testing.T) {
testData := []struct {
symbol string
name string
scale uint32
minUnit string
authority string
expectPass bool
}{
{symbol: "btc", name: "BTC TOKEN", scale: 18, minUnit: "staoshi", authority: addr1, expectPass: true},
{symbol: "BTC", name: "BTC TOKEN", scale: 18, minUnit: "staoshi", authority: addr1, expectPass: false},
{symbol: "bTC", name: "BTC TOKEN", scale: 18, minUnit: "staoshi", authority: addr1, expectPass: true},
{symbol: "stake", name: "Stake Token", scale: 18, minUnit: "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", authority: addr1, expectPass: true},
{symbol: "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", name: "Stake Token", scale: 18, minUnit: "ibc/3C3D7B3BE4ECC85A0E5B52A3AEC3B7DFC2AA9CA47C37821E57020D6807043BE9", authority: addr1, expectPass: true},
}

for _, td := range testData {
msg := MsgDeployERC20{
Symbol: td.symbol,
Name: td.name,
Scale: td.scale,
MinUnit: td.minUnit,
Authority: td.authority,
}
if td.expectPass {
require.Nil(t, msg.ValidateBasic(), "test: %v", td.name)
} else {
require.NotNil(t, msg.ValidateBasic(), "test: %v", td.name)
}
}
}

0 comments on commit 95a033f

Please sign in to comment.