Skip to content

Commit

Permalink
Add mutex for safe global operations
Browse files Browse the repository at this point in the history
  • Loading branch information
perrornet committed Jun 15, 2024
1 parent 359f39f commit 3f3e8f7
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions utils/wallets/safe/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ import (
"omni-balance/utils/safe_api/client/transactions"
"omni-balance/utils/wallets/safe/safe_abi"
"strings"
"sync"
"time"
)

Expand All @@ -44,6 +45,7 @@ var (
constant.Zksync: "safe-transaction-zkevm.safe.global",
constant.Sepolia: "safe-transaction-sepolia.safe.global",
}
safeGlobalLocker sync.Mutex
)

type SafeResp struct {
Expand Down Expand Up @@ -206,6 +208,8 @@ func (s *Safe) nonce(ctx context.Context) (int64, error) {
}

func (s *Safe) proposeTransaction(ctx context.Context, tx *types.LegacyTx) (common.Hash, error) {
safeGlobalLocker.Lock()
defer safeGlobalLocker.Unlock()
nonce, err := s.nonce(ctx)
if err != nil {
return common.Hash{}, errors.Wrap(err, "get nonce error")
Expand Down

0 comments on commit 3f3e8f7

Please sign in to comment.