Skip to content

Conversation

@dssei
Copy link
Contributor

@dssei dssei commented Aug 8, 2025

Describe your changes and provide context

At the moment if key is recovered, EVM address is empty e.g.

seid keys add test --recover
> Enter your bip39 mnemonic
<mnemonic>

- name: test2
  type: local
  address: sei1m03lu5rkjexf7yq8uy5fup6v6tcc9pv7ma62t6
  evm_address: ""
  pubkey: '{"@type":"/cosmos.crypto.secp256k1.PubKey","key":"Aim6C9yBKJOnm8TvA23mzOXu5BHIMsiF0/bFp1yGBhAe"}'
  mnemonic: ""

It appears PopulateEvmAddrIfApplicable method can not handle Info interface implementation pointers. E.g. those are passed from sei-chain code. This will result in empty EVM addresses in command output cause type assertion will fail on pointer in PopulateEvmAddrIfApplicable.

func PopulateEvmAddrIfApplicable(info Info, o KeyOutput) (KeyOutput, error) {
	localInfo, ok := info.(LocalInfo)
	if ok {
		// Only works with secp256k1 algo
		priv, err := legacy.PrivKeyFromBytes([]byte(localInfo.PrivKeyArmor))
		if err != nil {
			return o, err
		}
		privHex := hex.EncodeToString(priv.Bytes())
		privKey, err := crypto.HexToECDSA(privHex)
		if err != nil {
			return o, err
		}
		o.EvmAddress = crypto.PubkeyToAddress(privKey.PublicKey).Hex()
	} else {
	}
	return o, nil
}

Also have fixed JSON part of the command to populate EVM address

Testing performed to validate your change

  • Unit tests
  • Functional test with modified seid

@dssei dssei self-assigned this Aug 8, 2025
@dssei dssei added the bug Something isn't working label Aug 8, 2025
@codecov
Copy link

codecov bot commented Aug 8, 2025

Codecov Report

❌ Patch coverage is 86.36364% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 54.40%. Comparing base (080aec5) to head (12cfdad).

Files with missing lines Patch % Lines
crypto/keyring/output.go 83.33% 2 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main     #595      +/-   ##
==========================================
+ Coverage   54.36%   54.40%   +0.04%     
==========================================
  Files         634      634              
  Lines       55600    55607       +7     
==========================================
+ Hits        30226    30255      +29     
+ Misses      23210    23185      -25     
- Partials     2164     2167       +3     
Files with missing lines Coverage Δ
client/keys/add.go 71.11% <100.00%> (+3.69%) ⬆️
crypto/keyring/output.go 47.61% <83.33%> (+25.95%) ⬆️

... and 1 file with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@dssei dssei requested a review from codchen August 8, 2025 18:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants