Skip to content

Commit

Permalink
Cleanup: lint
Browse files Browse the repository at this point in the history
  • Loading branch information
dwasse committed Dec 30, 2024
1 parent df72ef2 commit 0aaf37e
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 18 deletions.
2 changes: 1 addition & 1 deletion services/rfq/contracts/fastbridgev2/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ func NewParser(fastBridgeAddress common.Address) (Parser, error) {
func (p parserImpl) ParseEvent(log ethTypes.Log) (_ EventType, event interface{}, ok bool) {
// return an unknown event to avoid cases where user failed to check the event type
// make it high enough to make it obvious (we start iotas at +1, see uber style guide for details)
noOpEvent := EventType(len(topicMap()) + 2)
noOpEvent := EventType(len(topicMap()) + 2) //nolint:gosec // Acceptable conversion

if len(log.Topics) == 0 {
return noOpEvent, nil, false
Expand Down
12 changes: 6 additions & 6 deletions services/rfq/e2e/rfq_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ func (i *IntegrationSuite) TestUSDCtoUSDC() {
_, originFastBridge := i.manager.GetFastBridgeV2(i.GetTestContext(), i.originBackend)
auth := i.originBackend.GetTxContext(i.GetTestContext(), i.userWallet.AddressPtr())
tx, err = originFastBridge.Bridge(auth.TransactOpts, fastbridgev2.IFastBridgeBridgeParams{
DstChainId: uint32(i.destBackend.GetChainID()),
DstChainId: uint32(i.destBackend.GetChainID()), //nolint:gosec // Acceptable conversion
Sender: i.userWallet.Address(),
To: i.userWallet.Address(),
OriginToken: originUSDC.Address(),
Expand Down Expand Up @@ -327,7 +327,7 @@ func (i *IntegrationSuite) TestETHtoETH() {
auth.TransactOpts.Value = realWantAmount
// we want 499 ETH for 500 requested within a day
tx, err := originFastBridge.Bridge(auth.TransactOpts, fastbridgev2.IFastBridgeBridgeParams{
DstChainId: uint32(i.destBackend.GetChainID()),
DstChainId: uint32(i.destBackend.GetChainID()), //nolint:gosec // Acceptable conversion
Sender: i.userWallet.Address(),
To: i.userWallet.Address(),
OriginToken: util.EthAddress,
Expand Down Expand Up @@ -468,7 +468,7 @@ func (i *IntegrationSuite) TestZap() {
_, destRecipient := i.manager.GetRecipientMock(i.GetTestContext(), i.destBackend)
auth := i.originBackend.GetTxContext(i.GetTestContext(), i.userWallet.AddressPtr())
params := fastbridgev2.IFastBridgeBridgeParams{
DstChainId: uint32(i.destBackend.GetChainID()),
DstChainId: uint32(i.destBackend.GetChainID()), //nolint:gosec // Acceptable conversion
Sender: i.userWallet.Address(),
To: destRecipient.Address(),
OriginToken: originUSDC.Address(),
Expand Down Expand Up @@ -558,7 +558,7 @@ func (i *IntegrationSuite) TestDisputeV1() {
auth := i.originBackend.GetTxContext(i.GetTestContext(), i.userWallet.AddressPtr())
// we want 499 usdc for 500 requested within a day
tx, err = originFastBridge.Bridge(auth.TransactOpts, fastbridge.IFastBridgeBridgeParams{
DstChainId: uint32(i.destBackend.GetChainID()),
DstChainId: uint32(i.destBackend.GetChainID()), //nolint:gosec // Acceptable conversion
Sender: i.userWallet.Address(),
To: i.userWallet.Address(),
OriginToken: originUSDC.Address(),
Expand Down Expand Up @@ -655,7 +655,7 @@ func (i *IntegrationSuite) TestDisputeV2() {
auth := i.originBackend.GetTxContext(i.GetTestContext(), i.userWallet.AddressPtr())
// we want 499 usdc for 500 requested within a day
tx, err = originFastBridge.Bridge(auth.TransactOpts, fastbridgev2.IFastBridgeBridgeParams{
DstChainId: uint32(i.destBackend.GetChainID()),
DstChainId: uint32(i.destBackend.GetChainID()), //nolint:gosec // Acceptable conversion
Sender: i.userWallet.Address(),
To: i.userWallet.Address(),
OriginToken: originUSDC.Address(),
Expand Down Expand Up @@ -785,7 +785,7 @@ func (i *IntegrationSuite) TestConcurrentBridges() {
auth.TransactOpts.Nonce = nonce
defer txMux.Unlock()
tx, err = originFastBridge.Bridge(auth.TransactOpts, fastbridgev2.IFastBridgeBridgeParams{
DstChainId: uint32(i.destBackend.GetChainID()),
DstChainId: uint32(i.destBackend.GetChainID()), //nolint:gosec // Acceptable conversion
Sender: i.userWallet.Address(),
To: i.userWallet.Address(),
OriginToken: originUSDC.Address(),
Expand Down
11 changes: 5 additions & 6 deletions services/rfq/e2e/setup_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ func (i *IntegrationSuite) Approve(backend backends.SimulatedTestBackend, token
err := i.waitForContractDeployment(i.GetTestContext(), backend, token.Address())
i.Require().NoError(err, "Failed to wait for contract deployment")

erc20, err := ierc20.NewIERC20(token.Address(), backend)
erc20, err := ierc20.NewIerc20Ref(common.HexToAddress(token.Address().String()), backend)
i.Require().NoError(err, "Failed to get erc20")

// approve fastbridgev1
Expand Down Expand Up @@ -400,9 +400,12 @@ func (i *IntegrationSuite) setupRelayer() {
txContextV1 := backend.GetTxContext(i.GetTestContext(), metadataV1.OwnerPtr())

relayerRole, err := rfqContractV1.RELAYERROLE(&bind.CallOpts{Context: i.GetTestContext()})
if err != nil {
return fmt.Errorf("failed to get relayer role: %w", err)
}
proverRole, err := rfqContractV1.RELAYERROLE(&bind.CallOpts{Context: i.GetTestContext()})
if err != nil {
return fmt.Errorf("could not get prover role: %w", err)
return fmt.Errorf("failed to get relayer role: %w", err)
}
tx, err := rfqContractV1.GrantRole(txContextV1.TransactOpts, relayerRole, i.relayerWallet.Address())
if err != nil {
Expand All @@ -413,10 +416,6 @@ func (i *IntegrationSuite) setupRelayer() {
metadataV2, rfqContractV2 := i.manager.GetFastBridgeV2(i.GetTestContext(), backend)
txContextV2 := backend.GetTxContext(i.GetTestContext(), metadataV2.OwnerPtr())

proverRole, err = rfqContractV2.PROVERROLE(&bind.CallOpts{Context: i.GetTestContext()})
if err != nil {
return fmt.Errorf("could not get prover role: %w", err)
}
tx, err = rfqContractV2.GrantRole(txContextV2.TransactOpts, proverRole, i.relayerWallet.Address())
if err != nil {
return fmt.Errorf("could not grant prover role: %w", err)
Expand Down
10 changes: 6 additions & 4 deletions services/rfq/guard/service/guard.go
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,8 @@ func NewGuard(ctx context.Context, metricHandler metrics.Handler, cfg guardconfi
if err != nil {
return nil, fmt.Errorf("could not get deploy block: %w", err)
}
chainListener, err := listener.NewChainListener(chainClient, store, common.HexToAddress(*rfqAddrV1), uint64(startBlock.Int64()), metricHandler, listener.WithName("guard"))
chainListener, err := listener.NewChainListener(chainClient, store, common.HexToAddress(*rfqAddrV1), uint64(startBlock.Int64()), //nolint:gosec // Acceptable conversion
metricHandler, listener.WithName("guard"))
if err != nil {
return nil, fmt.Errorf("could not get chain listener: %w", err)
}
Expand All @@ -107,7 +108,8 @@ func NewGuard(ctx context.Context, metricHandler metrics.Handler, cfg guardconfi
if err != nil {
return nil, fmt.Errorf("could not get deploy block: %w", err)
}
chainListener, err := listener.NewChainListener(chainClient, store, common.HexToAddress(rfqAddrV2), uint64(startBlock.Int64()), metricHandler, listener.WithName("guardV2"))
chainListener, err := listener.NewChainListener(chainClient, store, common.HexToAddress(rfqAddrV2), uint64(startBlock.Int64()), //nolint:gosec // Acceptable conversion
metricHandler, listener.WithName("guardV2"))
if err != nil {
return nil, fmt.Errorf("could not get chain listener: %w", err)
}
Expand Down Expand Up @@ -257,7 +259,7 @@ func (g Guard) runChainIndexerV1(ctx context.Context, chainID int, chainListener
attribute.Int(metrics.Origin, chainID),
attribute.String(metrics.Contract, log.Address.String()),
attribute.String("block_hash", log.BlockHash.String()),
attribute.Int64("block_number", int64(log.BlockNumber)),
attribute.Int64("block_number", int64(log.BlockNumber)), //nolint:gosec // Acceptable conversion
))

defer func() {
Expand Down Expand Up @@ -335,7 +337,7 @@ func (g Guard) runChainIndexerV2(ctx context.Context, chainID int, chainListener
attribute.Int(metrics.Origin, chainID),
attribute.String(metrics.Contract, log.Address.String()),
attribute.String("block_hash", log.BlockHash.String()),
attribute.Int64("block_number", int64(log.BlockNumber)),
attribute.Int64("block_number", int64(log.BlockNumber)), //nolint:gosec // Acceptable conversion
))

defer func() {
Expand Down
3 changes: 2 additions & 1 deletion services/rfq/relayer/quoter/quoter.go
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ func (m *Manager) getAmountWithOffset(ctx context.Context, chainID uint32, token
func (m *Manager) SubmitAllQuotes(ctx context.Context) (err error) {
ctx, span := m.metricsHandler.Tracer().Start(ctx, "SubmitAllQuotes")
defer func() {
span.SetAttributes(attribute.Bool("relay_paused", m.relayPaused.Load()))
metrics.EndSpanWithErr(span, err)
}()

Expand Down Expand Up @@ -325,7 +326,7 @@ func (m *Manager) SubscribeActiveRFQ(ctx context.Context) (err error) {
for {
select {
case <-ctx.Done():
return ctx.Err()
return fmt.Errorf("context error: %w", ctx.Err())
case msg, ok := <-respChan:
if !ok {
return errors.New("ws channel closed")
Expand Down

0 comments on commit 0aaf37e

Please sign in to comment.