Update client sdk (#207)

* Add bitcoin networks

* Refactor client

* Refactor explorer

* Refactor store

* Refactor wallet

* Refactor sdk client

* Refactor wasm & Update examples

* Move common util funcs to internal/utils

* Move to constants for service types

* Add unit tests

* Parallelize tests

* Lint

* Add job to gh action

* go mod tidy

* Fixes

* Fixes

* Fix compose file

* Fixes

* Fixes after review:
* Drop factory pattern
* Drop password from ark client methods
* Make singlekey wallet manage store and wallet store instead of defining WalletStore as extension of Store
* Move constants to arksdk module
* Drop config and expect directory store and wallet as ark client factory args

* Fix

* Add constants for bitcoin/liquid explorer

* Fix test

* Fix wasm

* Rename client.Client to client.ASPClient

* Rename store.Store to store.ConfigStore

* Rename wallet.Wallet to wallet.WalletService

* Renamings

* Lint

* Fixes

* Move everything to internal/utils & move ComputeVtxoTaprootScript to common

* Go mod tidy
This commit is contained in:
Pietralberto Mazza
2024-07-30 16:08:23 +02:00
committed by GitHub
parent e45bff3c70
commit 89df461623
148 changed files with 8497 additions and 6466 deletions

View File

@@ -80,7 +80,9 @@ func (c *Config) Validate() error {
if c.RoundInterval < 2 {
return fmt.Errorf("invalid round interval, must be at least 2 seconds")
}
if c.Network.Name != "liquid" && c.Network.Name != "testnet" && c.Network.Name != "regtest" {
if c.Network.Name != common.Liquid.Name &&
c.Network.Name != common.LiquidTestNet.Name &&
c.Network.Name != common.LiquidRegTest.Name {
return fmt.Errorf("invalid network, must be liquid, testnet or regtest")
}
if len(c.WalletAddr) <= 0 {
@@ -275,9 +277,9 @@ func (c *Config) adminService() error {
func (c *Config) mainChain() network.Network {
switch c.Network.Name {
case "testnet":
case common.LiquidTestNet.Name:
return network.Testnet
case "regtest":
case common.LiquidRegTest.Name:
return network.Regtest
default:
return network.Liquid

View File

@@ -139,12 +139,12 @@ func makeDirectoryIfNotExists(path string) error {
func getNetwork() (common.Network, error) {
switch strings.ToLower(viper.GetString(Network)) {
case "liquid":
case common.Liquid.Name:
return common.Liquid, nil
case "testnet":
return common.TestNet, nil
case "regtest":
return common.RegTest, nil
case common.LiquidTestNet.Name:
return common.LiquidTestNet, nil
case common.LiquidRegTest.Name:
return common.LiquidRegTest, nil
default:
return common.Network{}, fmt.Errorf("unknown network %s", viper.GetString(Network))
}

View File

@@ -436,8 +436,6 @@ func (s *service) finalizeRound() {
return
}
fmt.Printf("%+v\n", *round)
var changes []domain.RoundEvent
defer func() {
if err := s.saveEvents(ctx, round.Id, changes); err != nil {