Skip to content
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.

EIP712 doesn't support optional parameters #1247

Closed
facs95 opened this issue Aug 12, 2022 · 0 comments · Fixed by #1305
Closed

EIP712 doesn't support optional parameters #1247

facs95 opened this issue Aug 12, 2022 · 0 comments · Fixed by #1305
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@facs95
Copy link
Contributor

facs95 commented Aug 12, 2022

There are some message like editValidator that should accept nil values. If we send nil with eip712 it will error with

failed to pack and hash typedData primary type: provided data '<nil>' doesn't match type 'string'

To replicate a simple test can be created on app/ante/utils_tests.go

func (suite *AnteTestSuite) CreateTestEIP712MsgEditValidator(from sdk.AccAddress, priv cryptotypes.PrivKey, chainId string, gas uint64, gasAmount sdk.Coins) client.TxBuilder {
	valAddr := sdk.ValAddress(from.Bytes())
	msgEdit := types3.NewMsgEditValidator(
		valAddr,
		types3.NewDescription("moniker", "identity", "website", "security_contract", "details"),
		nil,
		nil,
	)
	return suite.CreateTestEIP712CosmosTxBuilder(from, priv, chainId, gas, gasAmount, msgEdit)
}

And call the function in app/ante/ante_test.go inside the TestAnteHandler function

		{
			"success- DeliverTx EIP712 edit validator",
			func() sdk.Tx {
				from := acc.GetAddress()
				coinAmount := sdk.NewCoin(evmtypes.DefaultEVMDenom, sdk.NewInt(20))
				amount := sdk.NewCoins(coinAmount)
				gas := uint64(200000)
				txBuilder := suite.CreateTestEIP712MsgEditValidator(from, privKey, "ethermint_9000-1", gas, amount)
				return txBuilder.GetTx()
			}, false, false, true,
		},
@facs95 facs95 added enhancement New feature or request API breaking labels Aug 12, 2022
@facs95 facs95 linked a pull request Aug 19, 2022 that will close this issue
11 tasks
@fedekunze fedekunze added this to the v0.20.x milestone Aug 19, 2022
@ramacarlucho ramacarlucho mentioned this issue Aug 26, 2022
11 tasks
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
No open projects
Status: Done
Development

Successfully merging a pull request may close this issue.

4 participants