Skip to content

Commit

Permalink
Merge pull request #407 from 0chain/feature/kms-wallet-setup
Browse files Browse the repository at this point in the history
Feature: add automatic kms wallet detection
  • Loading branch information
Jayashsatolia403 authored Dec 10, 2024
2 parents 40768aa + d4893c4 commit e201d4d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 8 deletions.
19 changes: 15 additions & 4 deletions cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"context"
"encoding/json"
"fmt"
"github.com/0chain/gosdk/core/client"
"github.com/0chain/gosdk/core/conf"
"io/ioutil"
"os"
"path/filepath"
"sync"

"github.com/0chain/gosdk/core/client"
"github.com/0chain/gosdk/core/conf"

"github.com/0chain/gosdk/core/zcncrypto"
"github.com/0chain/gosdk/zboxcore/sdk"
"github.com/0chain/gosdk/zcncore"
Expand Down Expand Up @@ -97,6 +98,7 @@ func initZCNCore() {
blockWorker := cfgConfig.GetString("block_worker")
chainID := cfgConfig.GetString("chain_id")
ethereumNodeURL := cfgConfig.GetString("ethereum_node_url")
zauthServer := cfgConfig.GetString("zauth_server")

cfg := conf.Config{
BlockWorker: blockWorker,
Expand All @@ -106,6 +108,7 @@ func initZCNCore() {
MinConfirmation: minCfm,
ConfirmationChainLength: CfmChainLength,
EthereumNode: ethereumNodeURL,
ZauthServer: zauthServer,
}

err := client.Init(context.Background(), cfg)
Expand Down Expand Up @@ -226,7 +229,6 @@ func createWallet() (string, error) {
}

func loadWallet() {

clientBytes, err := ioutil.ReadFile(cfgWallet)
if err != nil {
ExitWithError("Error reading the wallet", err)
Expand All @@ -243,12 +245,21 @@ func loadWallet() {
clientWallet = &wallet

wg := &sync.WaitGroup{}
err = zcncore.SetWalletInfo(clientConfig, signatureScheme, false)
err = zcncore.SetGeneralWalletInfo(clientConfig, signatureScheme)
if err == nil {
wg.Wait()
} else {
ExitWithError(err.Error())
}

if client.GetClient().IsSplit {
cfg, err := conf.GetClientConfig()
if err != nil {
ExitWithError(err.Error())
}

zcncore.RegisterZauthServer(cfg.ZauthServer)
}
}

func getTxnFee() uint64 {
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ go 1.22.0
toolchain go1.22.5

require (
github.com/0chain/gosdk v1.18.0
github.com/0chain/gosdk v1.18.12-0.20241205003726-a738be4e1f20
github.com/ethereum/go-ethereum v1.13.2
github.com/icza/bitio v1.1.0
github.com/olekukonko/tablewriter v0.0.5
Expand Down Expand Up @@ -111,4 +111,4 @@ require (
)

// temporary, for development
//replace github.com/0chain/gosdk => ../gosdk
// replace github.com/0chain/gosdk => ../gosdk
6 changes: 4 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,10 @@ github.com/0chain/common v1.18.3 h1:42dYOv2KyMTSanuS67iDtfv+ErbSRqR8NJ3MG72MwaI=
github.com/0chain/common v1.18.3/go.mod h1:Lapu2Tj7z5Sm4r+X141e7vsz4NDODTEypeElYAP3iSw=
github.com/0chain/errors v1.0.3 h1:QQZPFxTfnMcRdt32DXbzRQIfGWmBsKoEdszKQDb0rRM=
github.com/0chain/errors v1.0.3/go.mod h1:xymD6nVgrbgttWwkpSCfLLEJbFO6iHGQwk/yeSuYkIc=
github.com/0chain/gosdk v1.18.0 h1:6mSiUFb4liT50wdsx59tEWMHKWkKQUlZT91ouQAeKcc=
github.com/0chain/gosdk v1.18.0/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
github.com/0chain/gosdk v1.18.12-0.20241204141302-7029d233e3e0 h1:U4/UR2XB1roUMEjBf26glTDKwJB5o1h33mZDKOE+YfU=
github.com/0chain/gosdk v1.18.12-0.20241204141302-7029d233e3e0/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
github.com/0chain/gosdk v1.18.12-0.20241205003726-a738be4e1f20 h1:wEI5RrWGZAJ5NdPYA2qJGy8Q99igsNr3hS+0+UpGERI=
github.com/0chain/gosdk v1.18.12-0.20241205003726-a738be4e1f20/go.mod h1:8unFy9Dx2YyPKMYPDGR3MFhUEymbAfQcRDm9bobVLGw=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8=
Expand Down

0 comments on commit e201d4d

Please sign in to comment.