Skip to content

Commit

Permalink
fix: merge
Browse files Browse the repository at this point in the history
  • Loading branch information
logicalangel committed Apr 2, 2024
2 parents 4b96854 + 489224d commit 95ee4c7
Show file tree
Hide file tree
Showing 9 changed files with 120 additions and 34 deletions.
8 changes: 0 additions & 8 deletions .idea/.gitignore

This file was deleted.

8 changes: 0 additions & 8 deletions .idea/modules.xml

This file was deleted.

9 changes: 0 additions & 9 deletions .idea/unchained.iml

This file was deleted.

6 changes: 0 additions & 6 deletions .idea/vcs.xml

This file was deleted.

2 changes: 2 additions & 0 deletions Readme.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
<img height="128px" src="https://kenshi.io/images/products/unchained.g100.svg" alt="Unchained">

# Kenshi Unchained

[![Release](https://shields.io/github/v/release/kenshitech/unchained)](https://github.com/KenshiTech/unchained/releases)
Expand Down
2 changes: 0 additions & 2 deletions docker/compose.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
version: "3.9"

services:
#unchained_broker:
# image: ghcr.io/kenshitech/unchained:latest
Expand Down
2 changes: 1 addition & 1 deletion internal/scheduler/correctness/correctness.go
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ func SaveSignatures(args SaveSignatureArgs) {
)).
Only(ctx)

if err != nil {
if err != nil && !ent.IsNotFound(err) {
panic(err)
}

Expand Down
29 changes: 29 additions & 0 deletions src/config/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
package config_test

import (
"os"
"testing"

"github.com/KenshiTech/unchained/config"
"github.com/KenshiTech/unchained/constants"
"github.com/stretchr/testify/assert"
)

var s = config.Secret{
Address: "n1",
EvmWallet: "n2",
SecretKey: "n3",
PublicKey: "n4",
}

func TestSaveSecret(t *testing.T) {
err := s.Save()
assert.Equal(t, constants.ErrCantWriteSecret, err, "Should return error because path of secret is not defined")

config.SecretFilePath = "./secret.yaml"
err = s.Save()
assert.Nil(t, err, "Should write successfully")

err = os.Remove(config.SecretFilePath)
assert.Nil(t, err, "Should delete successfully")
}
88 changes: 88 additions & 0 deletions src/config/model.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
package config

import (
"time"
)

type System struct {
Name string `env:"SYSTEM_NAME" env-default:"Unchained" yaml:"name"`
Log string `env:"SYSTEM_LOG" env-default:"info" yaml:"log"`
}

type RPC struct {
Name string `yaml:"name"`
Nodes []string `yaml:"nodes"`
}

type Uniswap struct {
Schedule map[string]time.Duration `yaml:"schedule"`
Tokens []Token `yaml:"tokens"`
Correctness []string `yaml:"correctness"`
}

type EthLog struct {
Schedule map[string]time.Duration `yaml:"schedule"`
Events []Event `yaml:"events"`
Correctness []string `yaml:"correctness"`
}

type Plugins struct {
EthLog *EthLog `yaml:"logs"`
Uniswap *Uniswap `yaml:"uniswap"`
}

type Event struct {
Name string `yaml:"name"`
Chain string `yaml:"chain"`
Abi string `yaml:"abi"`
Event string `yaml:"event"`
Address string `yaml:"address"`
From *uint64 `yaml:"from"`
Step uint64 `yaml:"step"`
Confirmations uint64 `yaml:"confirmations"`
Store bool `yaml:"store"`
Send bool `yaml:"send"`
}

type Token struct {
Name string `yaml:"name"`
Pair string `yaml:"pair"`
Chain string `yaml:"chain"`
Delta int64 `yaml:"delta"`
Invert bool `yaml:"invert"`
Unit string `yaml:"unit"`
Send bool `yaml:"send"`
Store bool `yaml:"store"`
}

type ProofOfStack struct {
Chain string `env:"POS_CHAIN" env-default:"arbitrum_sepolia" yaml:"chain"`
Address string `env:"POS_ADDRESS" env-default:"0x965e364987356785b7E89e2Fe7B70f5E5107332d" yaml:"address"`
Base int64 `env:"POS_BASE" env-default:"1" yaml:"base"`
}

type Broker struct {
Bind string `env:"BROKER_BIND" env-default:"0.0.0.0:9123" yaml:"bind"`
URI string `env:"BROKER_URI" env-default:"wss://shinobi.brokers.kenshi.io" yaml:"uri"`
}

type Postgres struct {
URL string `env:"DATABASE_URL" yaml:"url"`
}

type Secret struct {
Address string `env:"ADDRESS" yaml:"address"`
EvmWallet string `env:"ENM_WALLET" yaml:"evm-wallet"`
SecretKey string `env:"SECRET_KEY" yaml:"secret-key"`
PublicKey string `env:"PUBLIC_KEY" yaml:"public-key"`
}

type Config struct {
System System `yaml:"system"`
Broker Broker `yaml:"broker"`
RPC []RPC `yaml:"rpc"`
Postgres Postgres `yaml:"postgres"`
ProofOfStack ProofOfStack `yaml:"pos"`
Plugins Plugins `yaml:"plugins"`
Secret Secret `yaml:"secret"`
}

0 comments on commit 95ee4c7

Please sign in to comment.