Skip to content

Commit

Permalink
fix: crosschain with origin token (#884)
Browse files Browse the repository at this point in the history
Co-authored-by: nulnut <[email protected]>
  • Loading branch information
zakir-code and nulnut authored Jan 9, 2025
1 parent 730035c commit 212046f
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion x/crosschain/keeper/bridge_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ func (k Keeper) AddBridgeTokenExecuted(ctx sdk.Context, claim *types.MsgBridgeTo
return types.ErrInvalid.Wrapf("%s denom decimals not match %d, expect %d",
fxtypes.DefaultDenom, claim.Decimals, fxtypes.DenomUnit)
}
return k.erc20Keeper.AddBridgeToken(ctx, claim.Symbol, k.moduleName, claim.TokenContract, true)
return k.erc20Keeper.AddBridgeToken(ctx, claim.Symbol, k.moduleName, claim.TokenContract, false)
}

return k.erc20Keeper.AddBridgeToken(ctx, strings.ToLower(claim.Symbol), k.moduleName, claim.TokenContract, false)
Expand Down
4 changes: 3 additions & 1 deletion x/crosschain/keeper/many_to_one.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ func (k Keeper) BaseCoinToBridgeToken(ctx context.Context, holder sdk.AccAddress
if err != nil {
return bridgeToken, err
}

if bridgeToken.IsOrigin() {
return bridgeToken, nil
}
baseCoins := sdk.NewCoins(baseCoin)
if err = k.bankKeeper.SendCoinsFromAccountToModule(ctx, holder, types.ModuleName, baseCoins); err != nil {
return bridgeToken, err
Expand Down
10 changes: 5 additions & 5 deletions x/erc20/keeper/bridge_token.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ import (
"github.com/pundiai/fx-core/v8/x/erc20/types"
)

func (k Keeper) HasToken(ctx context.Context, denom string) (bool, error) {
return k.DenomIndex.Has(ctx, denom)
func (k Keeper) HasToken(ctx context.Context, index string) (bool, error) {
return k.DenomIndex.Has(ctx, index)
}

func (k Keeper) GetBaseDenom(ctx context.Context, token string) (string, error) {
return k.DenomIndex.Get(ctx, token)
func (k Keeper) GetBaseDenom(ctx context.Context, index string) (string, error) {
return k.DenomIndex.Get(ctx, index)
}

func (k Keeper) GetBridgeToken(ctx context.Context, chainName, baseDenom string) (types.BridgeToken, error) {
Expand Down Expand Up @@ -58,5 +58,5 @@ func (k Keeper) AddBridgeToken(ctx context.Context, baseDenom, chainName, contra
if err = k.BridgeToken.Set(ctx, key, bridgeToken); err != nil {
return err
}
return k.DenomIndex.Set(ctx, bridgeToken.BridgeDenom(), baseDenom)
return k.DenomIndex.Set(ctx, types.NewBridgeDenom(chainName, contract), baseDenom)
}

0 comments on commit 212046f

Please sign in to comment.