Skip to content

Commit bcfbca9

Browse files
authored
Improving client config naming now that it is in the models package (#35)
1 parent e7c9902 commit bcfbca9

File tree

11 files changed

+29
-29
lines changed

11 files changed

+29
-29
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ func main() {
6868
// Build the config for the client
6969
config := models.ClientConfig{
7070
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
71-
Web3HttpProviders: []models.Web3ProviderConfig{
71+
Web3HttpProviders: []models.Web3Provider{
7272
{
7373
ChainId: chains.Polygon,
7474
Url: web3providers.Polygon,

client/client.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,8 @@ type Client struct {
4242
OrderbookApi *OrderbookService
4343
}
4444

45-
// NewClient creates and initializes a new Client instance based on the provided Config.
46-
func NewClient(config models.Config) (*Client, error) {
45+
// NewClient creates and initializes a new Client instance based on the provided ClientConfig.
46+
func NewClient(config models.ClientConfig) (*Client, error) {
4747
err := config.Validate()
4848
if err != nil {
4949
return nil, fmt.Errorf("config validation error: %v", err)

client/client_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ import (
1111
"github.com/stretchr/testify/require"
1212
)
1313

14-
var SimpleEthereumConfig = models.Config{
14+
var SimpleEthereumConfig = models.ClientConfig{
1515
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
1616
Web3HttpProviders: []models.Web3Provider{
1717
{
@@ -24,12 +24,12 @@ var SimpleEthereumConfig = models.Config{
2424
func TestNewConfig(t *testing.T) {
2525
testcases := []struct {
2626
description string
27-
config models.Config
27+
config models.ClientConfig
2828
expectedErrorDescription string
2929
}{
3030
{
3131
description: "Success",
32-
config: models.Config{
32+
config: models.ClientConfig{
3333
DevPortalApiKey: "abc123",
3434
Web3HttpProviders: []models.Web3Provider{
3535
{
@@ -42,7 +42,7 @@ func TestNewConfig(t *testing.T) {
4242
},
4343
{
4444
description: "Error - no API key",
45-
config: models.Config{
45+
config: models.ClientConfig{
4646
DevPortalApiKey: "",
4747
Web3HttpProviders: []models.Web3Provider{
4848
{
@@ -55,7 +55,7 @@ func TestNewConfig(t *testing.T) {
5555
},
5656
{
5757
description: "Error - no web3 provider key",
58-
config: models.Config{
58+
config: models.ClientConfig{
5959
DevPortalApiKey: "123",
6060
},
6161
expectedErrorDescription: "config validation error: at least one web3 provider URL is required",

client/client_test_helpers.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ func setup() (*Client, *http.ServeMux, string, func(), error) {
2727
// the base URL of the client will have its destination swapped to use this new test server for requests
2828
server := httptest.NewServer(mux)
2929
c, err := NewClient(
30-
models.Config{
30+
models.ClientConfig{
3131
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
3232
Web3HttpProviders: []models.Web3Provider{
3333
{

client/examples/orderbook/create_order/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import (
1616
func main() {
1717

1818
// Build the config for the client
19-
config := models.Config{
19+
config := models.ClientConfig{
2020
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
2121
Web3HttpProviders: []models.Web3Provider{
2222
{

client/examples/orderbook/get_orders/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
func main() {
1616

1717
// Build the config for the client
18-
config := models.Config{
18+
config := models.ClientConfig{
1919
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
2020
Web3HttpProviders: []models.Web3Provider{
2121
{

client/examples/swap/get_swap/main.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import (
1818
func main() {
1919

2020
// Build the config for the client
21-
config := models.Config{
21+
config := models.ClientConfig{
2222
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
2323
Web3HttpProviders: []models.Web3Provider{
2424
{

client/models/client_types.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package models
22

33
import "fmt"
44

5-
type Config struct {
5+
type ClientConfig struct {
66
DevPortalApiKey string
77
Web3HttpProviders []Web3Provider
88
}
@@ -12,7 +12,7 @@ type Web3Provider struct {
1212
Url string
1313
}
1414

15-
func (c *Config) Validate() error {
15+
func (c *ClientConfig) Validate() error {
1616

1717
if c.DevPortalApiKey == "" {
1818
return fmt.Errorf("API key is required")

client/orderbook_e2e_test.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ func TestCreateOrderE2E(t *testing.T) {
2222

2323
testcases := []struct {
2424
description string
25-
config models.Config
25+
config models.ClientConfig
2626
createOrderParams models.CreateOrderParams
2727
expectedOutput string
2828
}{
2929
{
3030
description: "Arbitrum - Create limit order offering 1 FRAX for 1 DAI",
31-
config: models.Config{
31+
config: models.ClientConfig{
3232
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
3333
Web3HttpProviders: []models.Web3Provider{
3434
{
@@ -51,7 +51,7 @@ func TestCreateOrderE2E(t *testing.T) {
5151
},
5252
{
5353
description: "Polygon - Create limit order offering 1 FRAX for 1 DAI",
54-
config: models.Config{
54+
config: models.ClientConfig{
5555
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
5656
Web3HttpProviders: []models.Web3Provider{
5757
{
@@ -74,7 +74,7 @@ func TestCreateOrderE2E(t *testing.T) {
7474
},
7575
{
7676
description: "Ethereum - Create limit order offering 1 1INCH for 1 DAI",
77-
config: models.Config{
77+
config: models.ClientConfig{
7878
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
7979
Web3HttpProviders: []models.Web3Provider{
8080
{
@@ -98,7 +98,7 @@ func TestCreateOrderE2E(t *testing.T) {
9898
},
9999
{
100100
description: "BSC - Create limit order offering 1 USDC for 1 DAI",
101-
config: models.Config{
101+
config: models.ClientConfig{
102102
DevPortalApiKey: os.Getenv("DEV_PORTAL_TOKEN"),
103103
Web3HttpProviders: []models.Web3Provider{
104104
{

client/orderbook_integration_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ func TestCreateOrderIntegration(t *testing.T) {
5454
},
5555
}
5656

57-
c, err := NewClient(models.Config{
57+
c, err := NewClient(models.ClientConfig{
5858
DevPortalApiKey: helpers.GetenvSafe("DEV_PORTAL_TOKEN"),
5959
Web3HttpProviders: []models.Web3Provider{
6060
{

0 commit comments

Comments
 (0)