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

[SLT-315] refactor(opbot): use gql api #3260

Merged
merged 47 commits into from
Nov 7, 2024
Merged
Changes from 1 commit
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
dadc913
use gql api
golangisfun123 Oct 9, 2024
dccd638
remove old test
golangisfun123 Oct 9, 2024
c1d21e4
[goreleaser]
golangisfun123 Oct 10, 2024
cd2187a
fix lint[goreleaser]
golangisfun123 Oct 10, 2024
8885dd5
[goreleaser]
golangisfun123 Oct 10, 2024
9dc780d
fix lint [goreleaser]
golangisfun123 Oct 10, 2024
2ef3bbf
explorer UI updated
Defi-Moses Oct 10, 2024
6cf146a
rfq-indexer update
Defi-Moses Oct 10, 2024
451a2d7
explorer backend update
Defi-Moses Oct 10, 2024
6c02517
[goreleaser] trigger explorer version bump
Defi-Moses Oct 10, 2024
a932e29
rfq indexer with the right contracts
Defi-Moses Oct 10, 2024
543fa15
fix logic
golangisfun123 Oct 10, 2024
50c4ecc
[goreleaser]
golangisfun123 Oct 10, 2024
a4cd9aa
fix error msg
golangisfun123 Oct 10, 2024
3e90715
[goreleaser] adding catch
Defi-Moses Oct 10, 2024
a40d79d
Merge branch 'master' of github.com:synapsecns/sanguine into opbot-mi…
golangisfun123 Oct 11, 2024
7c12249
remove function
golangisfun123 Oct 11, 2024
8724af9
Merge branch 'master' into feat/explorer-w
Defi-Moses Oct 12, 2024
9bd0038
response error fixes and wld decimals
Defi-Moses Oct 14, 2024
a7d5072
Merge branch 'master' into feat/explorer-w
Defi-Moses Oct 14, 2024
4f1f04c
origin tx hash
golangisfun123 Oct 14, 2024
1dbcd96
adding address
Defi-Moses Oct 15, 2024
6b4c78e
feat(rfq-indexer): add `request` column to `BridgeRequested` for refu…
golangisfun123 Oct 16, 2024
51d46c5
Merge branch 'master' of github.com:synapsecns/sanguine into opbot-mi…
golangisfun123 Oct 17, 2024
d0867c5
idr
golangisfun123 Oct 17, 2024
7679fde
Merge branch 'feat/explorer-w' of github.com:synapsecns/sanguine into…
golangisfun123 Oct 17, 2024
fce526b
merge
golangisfun123 Oct 17, 2024
146d28d
refund from rfq indexer
golangisfun123 Oct 17, 2024
111d862
add request field
golangisfun123 Oct 17, 2024
54b1391
yarn lcok
golangisfun123 Oct 17, 2024
0dd607d
Revert "yarn lcok"
golangisfun123 Oct 17, 2024
7835278
Revert "add request field"
golangisfun123 Oct 17, 2024
6c7c8f2
Merge branch 'master' of github.com:synapsecns/sanguine into opbot-mi…
golangisfun123 Oct 21, 2024
56bcab9
add new fiedl
golangisfun123 Oct 21, 2024
5e3f0e2
fix retry logic
golangisfun123 Oct 21, 2024
2e85f89
[goreleaser]
golangisfun123 Oct 21, 2024
2829c0f
Merge branch 'master' of github.com:synapsecns/sanguine into opbot-mi…
golangisfun123 Oct 28, 2024
88f9165
max attempt time [goreleaser]
golangisfun123 Oct 28, 2024
643c0dc
fix route [goreleaser]
golangisfun123 Oct 29, 2024
1193c9c
add linea explorer
golangisfun123 Oct 29, 2024
a4997e6
remove slash
golangisfun123 Oct 29, 2024
634144a
add worldchain explorer
golangisfun123 Oct 29, 2024
bc29e4d
fix lint
golangisfun123 Oct 29, 2024
72fa23b
remove 0x [goreleaser]
golangisfun123 Oct 30, 2024
69e03b2
Merge branch 'master' into opbot-migration
golangisfun123 Nov 6, 2024
f6c9020
revert quoter test
golangisfun123 Nov 6, 2024
1fbfbfa
fix lint
golangisfun123 Nov 7, 2024
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
Prev Previous commit
Next Next commit
add new fiedl
golangisfun123 committed Oct 21, 2024
commit 56bcab91c5bf7634dbe8a140b75b7519141f60b3
2 changes: 1 addition & 1 deletion contrib/opbot/botmd/commands.go
Original file line number Diff line number Diff line change
@@ -279,7 +279,7 @@
ctx.Context(),
big.NewInt(int64(rawRequest.Bridge.OriginChainID)),
func(transactor *bind.TransactOpts) (tx *types.Transaction, err error) {
tx, err = fastBridgeContract.Refund(transactor, common.Hex2Bytes(rawRequest.BridgeRequest.Request))
tx, err = fastBridgeContract.Refund(transactor, common.Hex2Bytes(rawRequest.Bridge.Request))
if err != nil {
return nil, fmt.Errorf("error submitting refund: %w", err)
}
@@ -313,7 +313,7 @@
return
}

_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted: %s", toTXSlackLink(status.TxHash().String(), uint32(rawRequest.Bridge.OriginChainID))))

Check failure on line 316 in contrib/opbot/botmd/commands.go

GitHub Actions / Lint (contrib/opbot)

G115: integer overflow conversion int -> uint32 (gosec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use safe chain ID conversion in toTXSlackLink call.

Similar to previous occurrences, direct conversion of chain ID to uint32 could cause integer overflow.

Apply this diff:

-_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted: %s", toTXSlackLink(status.TxHash().String(), uint32(rawRequest.Bridge.OriginChainID))))
+_, err = ctx.Response().Reply(fmt.Sprintf("refund submitted: %s", toTXSlackLink(status.TxHash().String(), safeChainIDToUint32(rawRequest.Bridge.OriginChainID))))

Committable suggestion was skipped due to low confidence.

🧰 Tools
🪛 GitHub Check: Lint (contrib/opbot)

[failure] 316-316:
G115: integer overflow conversion int -> uint32 (gosec)

if err != nil {
log.Println(err)
}
@@ -332,12 +332,12 @@
return nil, fmt.Errorf("error fetching rfq contracts: %w", err)
}

chainClient, err := b.rpcClient.GetChainClient(ctx, int(req.Bridge.OriginChainID))

Check failure on line 335 in contrib/opbot/botmd/commands.go

GitHub Actions / Lint (contrib/opbot)

unnecessary conversion (unconvert)
if err != nil {
return nil, fmt.Errorf("error getting chain client: %w", err)
}

contractAddress, ok := contracts.Contracts[uint32(req.Bridge.OriginChainID)]

Check failure on line 340 in contrib/opbot/botmd/commands.go

GitHub Actions / Lint (contrib/opbot)

G115: integer overflow conversion int -> uint32 (gosec)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Potential integer overflow when accessing contract address

The conversion of req.Bridge.OriginChainID to uint32 could lead to an integer overflow if the chain ID exceeds the maximum value of uint32 (4,294,967,295).

Consider using a safe conversion function similar to the one suggested earlier:

- contractAddress, ok := contracts.Contracts[uint32(req.Bridge.OriginChainID)]
+ contractAddress, ok := contracts.Contracts[safeUint32(req.Bridge.OriginChainID)]

Where safeUint32 is defined as:

func safeUint32(v int) uint32 {
    if v < 0 || v > math.MaxUint32 {
        // Handle error or return a default value
        return 0
    }
    return uint32(v)
}
🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 340-340: contrib/opbot/botmd/commands.go#L340
Added line #L340 was not covered by tests

🪛 GitHub Check: Lint (contrib/opbot)

[failure] 340-340:
G115: integer overflow conversion int -> uint32 (gosec)

if !ok {
return nil, errors.New("contract address not found")
}
2 changes: 1 addition & 1 deletion contrib/opbot/internal/model.go
Original file line number Diff line number Diff line change
@@ -22,14 +22,14 @@ type Bridge struct {
DestAmountFormatted string `json:"destAmountFormatted"`
Sender string `json:"sender"`
SendChainGas int `json:"sendChainGas"`
Request string `json:"request"`
}

// BridgeRequest contains the bridge request information.
type BridgeRequest struct {
BlockNumber string `json:"blockNumber"`
BlockTimestamp int64 `json:"blockTimestamp"`
TransactionHash string `json:"transactionHash"`
Request string `json:"request"`
}

// BridgeRelay contains the bridge relay information.