Skip to content

Commit

Permalink
Fix: bridge unlock balances
Browse files Browse the repository at this point in the history
  • Loading branch information
aopoltorzhicky committed Sep 18, 2024
1 parent f141454 commit f5a7eb6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pkg/indexer/decode/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import (
"time"

astria "buf.build/gen/go/astria/protocol-apis/protocolbuffers/go/astria/protocol/transactions/v1alpha1"
"github.com/celenium-io/astria-indexer/internal/currency"
"github.com/celenium-io/astria-indexer/internal/storage"
storageTypes "github.com/celenium-io/astria-indexer/internal/storage/types"
"github.com/celenium-io/astria-indexer/pkg/types"
Expand Down Expand Up @@ -665,9 +664,10 @@ func parseBridgeUnlock(body *astria.Action_BridgeUnlockAction, from string, heig
amount := uint128ToString(body.BridgeUnlockAction.GetAmount())
toAddress := body.BridgeUnlockAction.GetTo().GetBech32M()
bridge := body.BridgeUnlockAction.GetBridgeAddress().GetBech32M()
feeAsset := body.BridgeUnlockAction.GetFeeAsset()

action.Data["to"] = toAddress
action.Data["fee_asset"] = body.BridgeUnlockAction.GetFeeAsset()
action.Data["fee_asset"] = feeAsset
action.Data["amount"] = amount
if memo := body.BridgeUnlockAction.GetMemo(); len(memo) > 0 {
action.Data["memo"] = hex.EncodeToString(memo)
Expand Down Expand Up @@ -707,13 +707,13 @@ func parseBridgeUnlock(body *astria.Action_BridgeUnlockAction, from string, heig
storage.BalanceUpdate{
Address: toAddr,
Height: action.Height,
Currency: currency.DefaultCurrency,
Currency: feeAsset,
Update: decAmount,
},
storage.BalanceUpdate{
Address: fromAddr,
Height: action.Height,
Currency: currency.DefaultCurrency,
Currency: feeAsset,
Update: decAmount.Neg(),
},
)
Expand Down
4 changes: 2 additions & 2 deletions pkg/indexer/decode/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -718,13 +718,13 @@ func TestDecodeActions(t *testing.T) {
{
Address: toModel,
Update: toModel.Balance[0].Total,
Currency: toModel.Balance[0].Currency,
Currency: feeAssetId,
Height: 1000,
},
{
Address: fromModel,
Update: fromModel.Balance[0].Total,
Currency: fromModel.Balance[0].Currency,
Currency: feeAssetId,
Height: 1000,
},
},
Expand Down

0 comments on commit f5a7eb6

Please sign in to comment.