From c544f3d86d257576e59f9cc454c620963a951622 Mon Sep 17 00:00:00 2001 From: dan Date: Wed, 27 May 2026 23:54:53 +1200 Subject: [PATCH] fix(wasmbinding): set top-level Metadata.Decimals in SetTokenMetadata translation The bank precompile reads metadata.Decimals when serving decimals() to auto-deployed ERC20 wrappers, but the wasm-binding translation built the Metadata struct without setting that field. Adapter-wrapped denoms whose metadata is set via wasm bindings end up with decimals()==0. Sets Metadata.Decimals = mt.Decimals so the precompile and the second DenomUnit.Exponent agree. Fixes #37 --- CHANGELOG.md | 4 ++++ injective-chain/wasmbinding/message_plugin.go | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ddb2500e..94d65096 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -36,6 +36,10 @@ Ref: https://keepachangelog.com/en/1.1.0/ ## [Unreleased] +### Bug Fixes + +- (wasmbinding) Set top-level `Metadata.Decimals` in `SetTokenMetadata` translation so the bank precompile and auto-deployed ERC20 wrappers report correct `decimals()` for tokenfactory denoms whose metadata is set via wasm bindings (e.g., CW20 Adapter `UpdateMetadata`). + ## [v1.19.0](https://github.com/InjectiveFoundation/injective-core/releases/tag/v1.19.0) - 2026-XX-XX ### Features diff --git a/injective-chain/wasmbinding/message_plugin.go b/injective-chain/wasmbinding/message_plugin.go index 7296e1e0..5dc30863 100644 --- a/injective-chain/wasmbinding/message_plugin.go +++ b/injective-chain/wasmbinding/message_plugin.go @@ -142,10 +142,11 @@ func (m *CustomMessenger) DispatchMsg(ctx sdk.Context, contractAddr sdk.AccAddre sdkMsg = &tokenfactorytypes.MsgSetDenomMetadata{ Sender: contractAddr.String(), Metadata: banktypes.Metadata{ - Base: mt.Denom, - Display: mt.Symbol, - Name: mt.Name, - Symbol: mt.Symbol, + Base: mt.Denom, + Display: mt.Symbol, + Name: mt.Name, + Symbol: mt.Symbol, + Decimals: mt.Decimals, DenomUnits: []*banktypes.DenomUnit{ { Denom: mt.Denom,