Skip to content

Commit

Permalink
Remove hardcoded kettle address (#20)
Browse files Browse the repository at this point in the history
  • Loading branch information
ferranbt authored Jan 9, 2024
1 parent 53408e5 commit fcee114
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions framework/framework.go
Original file line number Diff line number Diff line change
Expand Up @@ -158,21 +158,20 @@ func (c *Contract) SendTransaction(method string, args []interface{}, confidenti
}

type Framework struct {
config *Config
rpc *rpc.Client
clt *sdk.Client
config *Config
rpc *rpc.Client
clt *sdk.Client
kettleAddress common.Address
}

type Config struct {
KettleRPC string
KettleAddr common.Address
FundedAccount *PrivKey
}

func DefaultConfig() *Config {
return &Config{
KettleRPC: "http://localhost:8545",
KettleAddr: common.HexToAddress("b5feafbdd752ad52afb7e1bd2e40432a485bbb7f"),
KettleRPC: "http://localhost:8545",

// This account is funded in both devnev networks
// address: 0xBE69d72ca5f88aCba033a063dF5DBe43a4148De0
Expand All @@ -184,12 +183,19 @@ func New() *Framework {
config := DefaultConfig()

rpc, _ := rpc.Dial(config.KettleRPC)
clt := sdk.NewClient(rpc, config.FundedAccount.Priv, config.KettleAddr)

var accounts []common.Address
if err := rpc.Call(&accounts, "eth_kettleAddress"); err != nil {
panic(fmt.Sprintf("failed to get kettle address: %v", err))
}

clt := sdk.NewClient(rpc, config.FundedAccount.Priv, accounts[0])

return &Framework{
config: DefaultConfig(),
rpc: rpc,
clt: clt,
config: config,
kettleAddress: accounts[0],
rpc: rpc,
clt: clt,
}
}

Expand Down Expand Up @@ -228,9 +234,8 @@ func (c *Contract) Ref(acct *PrivKey) *Contract {
}

func (f *Framework) NewClient(acct *PrivKey) *sdk.Client {
cc := DefaultConfig()
rpc, _ := rpc.Dial(cc.KettleRPC)
return sdk.NewClient(rpc, acct.Priv, cc.KettleAddr)
rpc, _ := rpc.Dial(f.config.KettleRPC)
return sdk.NewClient(rpc, acct.Priv, f.kettleAddress)
}

func (f *Framework) SignTx(priv *PrivKey, tx *types.LegacyTx) (*types.Transaction, error) {
Expand Down

0 comments on commit fcee114

Please sign in to comment.