Skip to content

Commit

Permalink
chore: pass ctx to thorchain funcs
Browse files Browse the repository at this point in the history
  • Loading branch information
jtieri committed Oct 1, 2024
1 parent 048309d commit 024e307
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions examples/thorchain/features/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func PollForPool(ctx context.Context, thorchain *tc.Thorchain, deltaBlocks int64
return fmt.Errorf("failed to get height: %w", err)
}
doPoll := func(ctx context.Context, height int64) (any, error) {
pool, err := thorchain.APIGetPool(nil, asset)
pool, err := thorchain.APIGetPool(ctx, asset)
if err != nil {
time.Sleep(time.Second) // rate limit
return nil, err
Expand Down Expand Up @@ -143,7 +143,7 @@ func PollSwapCompleted(ctx context.Context, thorchain *tc.Thorchain, deltaBlocks
return tc.Saver{}, fmt.Errorf("failed to get height: %w", err)
}
doPoll := func(ctx context.Context, height int64) (any, error) {
stages, err := thorchain.APIGetTxStages(nil, txHash)
stages, err := thorchain.APIGetTxStages(ctx, txHash)
if err != nil {
time.Sleep(time.Second) // rate limit
return nil, err
Expand All @@ -167,7 +167,7 @@ func PollOutboundSigned(ctx context.Context, thorchain *tc.Thorchain, deltaBlock
return tc.Saver{}, fmt.Errorf("failed to get height: %w", err)
}
doPoll := func(ctx context.Context, height int64) (any, error) {
stages, err := thorchain.APIGetTxStages(nil, txHash)
stages, err := thorchain.APIGetTxStages(ctx, txHash)
if err != nil {
time.Sleep(time.Second) // rate limit
return nil, err
Expand Down Expand Up @@ -215,7 +215,7 @@ func PollForPoolSuspended(ctx context.Context, thorchain *tc.Thorchain, deltaBlo
return fmt.Errorf("failed to get height: %w", err)
}
doPoll := func(ctx context.Context, height int64) (any, error) {
pool, err := thorchain.APIGetPool(nil, exoAsset)
pool, err := thorchain.APIGetPool(ctx, exoAsset)
if err != nil {
time.Sleep(time.Second) // rate limit
return nil, err
Expand Down
2 changes: 1 addition & 1 deletion examples/thorchain/features/ragnarok.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ func Ragnarok(
}
exoAsset := exoChainType.GetGasAsset()

_, err = thorchain.APIGetPool(nil, exoAsset)
_, err = thorchain.APIGetPool(ctx, exoAsset)
if err != nil {
return fmt.Errorf("pool (%s) not found to ragnarok, %w", exoChain.Config().Name, err)
}
Expand Down
8 changes: 4 additions & 4 deletions examples/thorchain/features/saver_eject.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func SaverEject(

// Reset mimirs
mimirLock.Lock()
mimirs, err := thorchain.APIGetMimirs(nil)
mimirs, err := thorchain.APIGetMimirs(ctx)
if err != nil {
mimirLock.Unlock()
return exoUser, err
Expand Down Expand Up @@ -65,15 +65,15 @@ func SaverEject(
}
exoAsset := exoChainType.GetGasAsset()

pool, err := thorchain.APIGetPool(nil, exoAsset)
pool, err := thorchain.APIGetPool(ctx, exoAsset)
if err != nil {
mimirLock.Unlock()
return exoUser, err
}
saveAmount := sdkmath.NewUintFromString(pool.BalanceAsset).
MulUint64(2000).QuoUint64(10_000)

saverQuote, err := thorchain.APIGetSaverDepositQuote(nil, exoAsset, saveAmount)
saverQuote, err := thorchain.APIGetSaverDepositQuote(ctx, exoAsset, saveAmount)
if err != nil {
mimirLock.Unlock()
return exoUser, err
Expand Down Expand Up @@ -150,7 +150,7 @@ func SaverEject(
}
}

mimirs, err = thorchain.APIGetMimirs(nil)
mimirs, err = thorchain.APIGetMimirs(ctx)
if err != nil {
mimirLock.Unlock()
return exoUser, err
Expand Down
4 changes: 2 additions & 2 deletions examples/thorchain/features/savers.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,14 +32,14 @@ func Saver(
}
exoAsset := exoChainType.GetGasAsset()

pool, err := thorchain.APIGetPool(nil, exoAsset)
pool, err := thorchain.APIGetPool(ctx, exoAsset)
if err != nil {
return exoUser, err
}
saveAmount := sdkmath.NewUintFromString(pool.BalanceAsset).
MulUint64(500).QuoUint64(10_000)

saverQuote, err := thorchain.APIGetSaverDepositQuote(nil, exoAsset, saveAmount)
saverQuote, err := thorchain.APIGetSaverDepositQuote(ctx, exoAsset, saveAmount)
if err != nil {
return exoUser, err
}
Expand Down

0 comments on commit 024e307

Please sign in to comment.