Skip to content

Commit

Permalink
Merge branch 'main' into add-and-fix-links
Browse files Browse the repository at this point in the history
  • Loading branch information
Alex Johnson authored Jul 10, 2024
2 parents d684456 + 59ece94 commit b1a4297
Show file tree
Hide file tree
Showing 12 changed files with 42 additions and 17 deletions.
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
[![GoDoc](https://img.shields.io/badge/godoc-reference-blue?style=flat-square&logo=go)](https://godoc.org/github.com/skip-mev/slinky)
[![Go Report Card](https://goreportcard.com/badge/github.com/skip-mev/slinky?style=flat-square)](https://goreportcard.com/report/github.com/skip-mev/slinky)
[![Version](https://img.shields.io/github/tag/skip-mev/slinky.svg?style=flat-square)](https://github.com/skip-mev/slinky/releases/latest)
[![License: Apache-2.0](https://img.shields.io/github/license/skip-mev/slinky.svg?style=flat-square)](https://github.com/skip-mev/slinky/blob/main/LICENSE)
[![Lines Of Code](https://img.shields.io/tokei/lines/github/skip-mev/slinky?style=flat-square)](https://github.com/skip-mev/slinky)

A general purpose price oracle leveraging ABCI++. Please visit our [docs](https://docs.skip.money/slinky/overview) page for more information!
Expand All @@ -16,6 +15,9 @@ Slinky uses Vote Extensions to create an hyperperformant, extremely secure mecha
many of the highest-performance decentralized applications today. If you would like to integrate Slinky to power your use case, please contact us on our
[discord](https://discord.gg/PeBGE9jrbu).

> [!NOTE]
> Slinky is **business-licensed software** under BSL, meaning it requires a license to use or reference. It is source viewable, but [**reach out to us on Discord**](https://skip.money/discord) if you are interested in integrating! We are limiting the number of chains we work with to seven in 2024. We apologize if we run out of capacity.
## Install

```shell
Expand Down
3 changes: 2 additions & 1 deletion cmd/client/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,12 @@ import (
"syscall"
"time"

slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"
"github.com/spf13/cobra"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"

"github.com/skip-mev/slinky/service/servers/oracle/types"
)

Expand Down
3 changes: 2 additions & 1 deletion providers/apis/bitstamp/api_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/skip-mev/slinky/oracle/types"
"github.com/skip-mev/slinky/providers/apis/bitstamp"
"github.com/skip-mev/slinky/providers/base/testutils"
providertypes "github.com/skip-mev/slinky/providers/types"
"github.com/stretchr/testify/require"
)

var (
Expand Down
3 changes: 2 additions & 1 deletion providers/apis/coinmarketcap/api_handler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,12 @@ import (
"testing"
"time"

"github.com/stretchr/testify/require"

"github.com/skip-mev/slinky/oracle/types"
"github.com/skip-mev/slinky/providers/apis/coinmarketcap"
"github.com/skip-mev/slinky/providers/base/testutils"
providertypes "github.com/skip-mev/slinky/providers/types"
"github.com/stretchr/testify/require"
)

var (
Expand Down
7 changes: 4 additions & 3 deletions providers/apis/dydx/switch_over_fetcher_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ import (
"testing"
"time"

"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.uber.org/zap"

"github.com/skip-mev/slinky/oracle/config"
"github.com/skip-mev/slinky/providers/apis/dydx"
"github.com/skip-mev/slinky/providers/apis/marketmap"
Expand All @@ -17,9 +21,6 @@ import (
providertypes "github.com/skip-mev/slinky/providers/types"
mmclient "github.com/skip-mev/slinky/service/clients/marketmap/types"
mmtypes "github.com/skip-mev/slinky/x/marketmap/types"
"github.com/stretchr/testify/mock"
"github.com/stretchr/testify/require"
"go.uber.org/zap"
)

func TestDefaultSwitchOverProvider(t *testing.T) {
Expand Down
3 changes: 2 additions & 1 deletion providers/apis/marketmap/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ import (
"fmt"
"time"

slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"

slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"

"github.com/skip-mev/slinky/oracle/config"
"github.com/skip-mev/slinky/providers/base/api/metrics"
mmtypes "github.com/skip-mev/slinky/x/marketmap/types"
Expand Down
3 changes: 2 additions & 1 deletion service/clients/oracle/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,12 @@ import (
"time"

"cosmossdk.io/log"
slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"
"google.golang.org/grpc"
"google.golang.org/grpc/connectivity"
"google.golang.org/grpc/credentials/insecure"

slinkygrpc "github.com/skip-mev/slinky/pkg/grpc"

"github.com/skip-mev/slinky/oracle/config"
"github.com/skip-mev/slinky/service/metrics"
"github.com/skip-mev/slinky/service/servers/oracle/types"
Expand Down
6 changes: 4 additions & 2 deletions x/marketmap/keeper/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,10 @@ func (k *Keeper) InitGenesis(ctx sdk.Context, gs types.GenesisState) {
panic(err)
}

if err := k.hooks.AfterMarketGenesis(ctx, gs.MarketMap.Markets); err != nil {
panic(err)
if k.hooks != nil {
if err := k.hooks.AfterMarketGenesis(ctx, gs.MarketMap.Markets); err != nil {
panic(err)
}
}
}

Expand Down
6 changes: 1 addition & 5 deletions x/marketmap/keeper/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
func (k *Keeper) Hooks() types.MarketMapHooks {
if k.hooks == nil {
// return a no-op implementation if no hooks are set
return types.MultiMarketMapHooks{}
return &types.NoopMarketMapHooks{}
}

return k.hooks
Expand All @@ -17,9 +17,5 @@ func (k *Keeper) Hooks() types.MarketMapHooks {
// SetHooks sets the x/marketmap hooks. In contrast to other receivers, this method must take a pointer due to nature
// of the hooks interface and SDK start up sequence.
func (k *Keeper) SetHooks(mmh types.MarketMapHooks) {
if k.hooks != nil {
panic("cannot set marketmap hooks twice")
}

k.hooks = mmh
}
1 change: 1 addition & 0 deletions x/marketmap/keeper/keeper.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ func NewKeeper(ss store.KVStoreService, cdc codec.BinaryCodec, authority sdk.Acc
markets: collections.NewMap(sb, types.MarketsPrefix, "markets", types.TickersCodec, codec.CollValue[types.Market](cdc)),
lastUpdated: collections.NewItem[uint64](sb, types.LastUpdatedPrefix, "last_updated", types.LastUpdatedCodec),
params: params,
hooks: &types.NoopMarketMapHooks{},
}
}

Expand Down
17 changes: 17 additions & 0 deletions x/marketmap/types/hooks.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,3 +56,20 @@ func (mh MultiMarketMapHooks) AfterMarketGenesis(ctx sdk.Context, markets map[st

// MarketMapHooksWrapper is a wrapper for modules to inject MarketMapHooks using depinject.
type MarketMapHooksWrapper struct{ MarketMapHooks }

var _ MarketMapHooks = &NoopMarketMapHooks{}

// NoopMarketMapHooks defines market map hooks that are a no-op.
type NoopMarketMapHooks struct{}

func (n *NoopMarketMapHooks) AfterMarketCreated(_ sdk.Context, _ Market) error {
return nil
}

func (n *NoopMarketMapHooks) AfterMarketUpdated(_ sdk.Context, _ Market) error {
return nil
}

func (n *NoopMarketMapHooks) AfterMarketGenesis(_ sdk.Context, _ map[string]Market) error {
return nil
}
3 changes: 2 additions & 1 deletion x/marketmap/types/mocks/MarketMapHooks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit b1a4297

Please sign in to comment.