Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: sudo and withdrawer is equal signer address #30

Merged
merged 1 commit into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions pkg/indexer/decode/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,7 +383,9 @@ func parseInitBridgeAccount(body *astria.Action_InitBridgeAccountAction, from st
})
bridge.Sudo = addr
}
} else {
}

if bridge.Sudo == nil {
bridge.Sudo = bridge.Address
}

Expand All @@ -400,7 +402,9 @@ func parseInitBridgeAccount(body *astria.Action_InitBridgeAccountAction, from st
})
bridge.Withdrawer = addr
}
} else {
}

if bridge.Withdrawer == nil {
bridge.Withdrawer = bridge.Address
}

Expand Down
44 changes: 44 additions & 0 deletions pkg/indexer/decode/actions_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -814,6 +814,50 @@ func TestDecodeActions(t *testing.T) {
require.Equal(t, wantAction, action)
})

t.Run("init bridge account: the same address", func(t *testing.T) {
decodeContext := NewContext()

rollupId := testsuite.RandomHash(10)
from := testsuite.RandomAddress()
message := &astria.Action_InitBridgeAccountAction{
InitBridgeAccountAction: &astria.InitBridgeAccountAction{
RollupId: &primitivev1.RollupId{Inner: rollupId},
FeeAsset: feeAssetId,
Asset: assetId,
SudoAddress: &primitivev1.Address{Bech32M: from},
WithdrawerAddress: &primitivev1.Address{Bech32M: from},
},
}

wantAction := storage.Action{
Height: 1000,
Type: types.ActionTypeInitBridgeAccount,
Data: map[string]any{
"rollup_id": rollupId,
"asset": assetId,
"fee_asset": feeAssetId,
"sudo": from,
"withdrawer": from,
},
RollupAction: &storage.RollupAction{
Height: 1000,
Rollup: &storage.Rollup{
AstriaId: message.InitBridgeAccountAction.GetRollupId().GetInner(),
FirstHeight: 1000,
ActionsCount: 1,
},
},
}
wantAction.RollupAction.Action = &wantAction

action := storage.Action{
Height: 1000,
}
err := parseInitBridgeAccount(message, from, 1000, &decodeContext, &action)
require.NoError(t, err)
require.Equal(t, wantAction, action)
})

t.Run("ibc relayer change: addition", func(t *testing.T) {
decodeContext := NewContext()

Expand Down
Loading