Skip to content

Commit

Permalink
Revert version
Browse files Browse the repository at this point in the history
  • Loading branch information
ngdlong91 committed Jun 1, 2022
1 parent 5bf78cb commit cc2cbea
Show file tree
Hide file tree
Showing 18 changed files with 641 additions and 817 deletions.
7 changes: 3 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ module github.com/kardiachain/go-kaiclient
go 1.14

require (
github.com/ethereum/go-ethereum v1.9.15
github.com/golang/snappy v0.0.2-0.20200707131729-196ae77b8a26 // indirect
github.com/kardiachain/go-kardia v1.2.3-0.20210525082104-2913103edf92
github.com/ethereum/go-ethereum v1.9.18
github.com/kardiachain/go-kardia v0.11.0
github.com/shopspring/decimal v1.2.0
github.com/stretchr/testify v1.7.0
github.com/stretchr/testify v1.6.1
go.uber.org/zap v1.16.0
)
80 changes: 80 additions & 0 deletions go.sum

Large diffs are not rendered by default.

76 changes: 0 additions & 76 deletions kardia/block.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ package kardia
import (
"context"

"github.com/kardiachain/go-kardia"
"github.com/kardiachain/go-kardia/lib/common"
kai "github.com/kardiachain/go-kardia/mainchain"
"github.com/kardiachain/go-kardia/types"
)

type IBlock interface {
Expand All @@ -33,11 +30,6 @@ type IBlock interface {
BlockByHeight(ctx context.Context, height uint64) (*Block, error)
BlockHeaderByHash(ctx context.Context, hash string) (*Header, error)
BlockHeaderByNumber(ctx context.Context, number uint64) (*Header, error)

GetValidators(ctx context.Context, height uint64) (*types.ValidatorSet, error)
GetCommit(ctx context.Context, height uint64) (*types.Commit, error)
GetProof(ctx context.Context, address common.Address, storageKeys []string, height uint64) (*kai.AccountResult, error)
FullHeaderByNumber(ctx context.Context, height uint64) (*FullHeader, error)
}

// BlockByHash returns the given full block.
Expand Down Expand Up @@ -86,71 +78,3 @@ func (n *node) getBlockHeader(ctx context.Context, method string, args ...interf
}
return &raw, nil
}

func (n *node) GetValidators(ctx context.Context, height uint64) (*types.ValidatorSet, error) {
var valSet *types.ValidatorSet
err := n.client.CallContext(ctx, &valSet, "kai_getValidatorSet", height)
if err == nil && valSet == nil {
err = kardia.NotFound
}
return valSet, err
}

func (n *node) GetCommit(ctx context.Context, height uint64) (*types.Commit, error) {
var commit *types.Commit
err := n.client.CallContext(ctx, &commit, "kai_getCommit", height)
if err == nil && commit == nil {
err = kardia.NotFound
}
return commit, err
}

func (n *node) GetProof(ctx context.Context, address common.Address, storageKeys []string, height uint64) (*kai.AccountResult, error) {
var accountR *kai.AccountResult
err := n.client.CallContext(ctx, &accountR, "kai_getProof", address, storageKeys, height, false)
if err == nil && accountR == nil {
err = kardia.NotFound
}
return accountR, err
}

type FullHeader struct {
Header *types.Header
Commit *types.Commit
ValidatorSet *types.ValidatorSet
}

func (n *node) FullHeaderByNumber(ctx context.Context, height uint64) (*FullHeader, error) {
header, err := n.BlockHeaderByNumber(ctx, height)
if err != nil {
return nil, err
}
validators, err := n.GetValidators(ctx, height)
if err != nil {
return nil, err
}

commit, err := n.GetCommit(ctx, height-1)
if err != nil {
return nil, err
}
return &FullHeader{
Header: &types.Header{
Height: header.Height,
Time: header.Time,
NumTxs: header.NumTxs,
GasLimit: header.GasLimit,
LastBlockID: *header.LastBlockID,
ProposerAddress: common.HexToAddress(header.ProposerAddress),
LastCommitHash: common.HexToHash(header.CommitHash),
TxHash: common.HexToHash(header.TxHash),
ValidatorsHash: common.HexToHash(header.ValidatorsHash),
NextValidatorsHash: common.HexToHash(header.NextValidatorHash),
ConsensusHash: common.HexToHash(header.ConsensusHash),
AppHash: common.HexToHash(header.AppHash),
EvidenceHash: common.HexToHash(header.EvidenceHash),
},
ValidatorSet: validators,
Commit: commit,
}, nil
}
10 changes: 0 additions & 10 deletions kardia/block_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,3 @@ func TestBlock_BlockByHash(t *testing.T) {
fmt.Println("Block", b)
assert.Equal(t, "0x5f47a97ac4d8454312430b48f1841af0e839a8fc9f7fc6c00efadb89ea3e2133", b.Hash)
}

func TestBlock_FullHeaderByNumber(t *testing.T) {
ctx := context.Background()
node, err := setupTestNodeInterface()
assert.Nil(t, err)
b, err := node.FullHeaderByNumber(ctx, 4)
assert.Nil(t, err)
fmt.Printf("Block %+v\n", b.Header)
//assert.Equal(t, "0x5f47a97ac4d8454312430b48f1841af0e839a8fc9f7fc6c00efadb89ea3e2133", b.Hash)
}
5 changes: 3 additions & 2 deletions kardia/bound_contract_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,15 @@ func TestBoundContract_Deploy(t *testing.T) {
balance, err := node.Balance(context.Background(), fromAddress.String())
assert.Nil(t, err)
fmt.Println("Balance", balance)
gasLimit := uint64(3100000)
gasPrice := big.NewInt(1000000000)
gasLimit := uint64(30000000)
gasPrice := big.NewInt(1)
auth := NewKeyedTransactor(privateKey)
auth.Nonce = nonce
auth.Value = big.NewInt(0) // in wei
auth.GasLimit = gasLimit // in units
auth.GasPrice = gasPrice

//bc := NewBoundContract(node, &abiData, common.HexToAddress(WheelSMCAddr))
smcAddress, txHash, err := node.DeployKRC20(auth)
assert.Nil(t, err)
fmt.Println("SMC Addr", smcAddress.String())
Expand Down
4 changes: 0 additions & 4 deletions kardia/contract.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,3 @@ func NewContract(abi *abi.ABI, addr common.Address) *Contract {
}
return c
}

func (c *Contract) ABI() *abi.ABI {
return c.Abi
}
27 changes: 0 additions & 27 deletions kardia/helpers.go

This file was deleted.

2 changes: 1 addition & 1 deletion kardia/kardia_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import (
"go.uber.org/zap"
)

var url = "https://rpc.kardiachain.io"
var url = "https://dev-1.kardiachain.io"

func setupTestNodeInterface() (Node, error) {
lgr, err := zap.NewDevelopment()
Expand Down
31 changes: 0 additions & 31 deletions kardia/receipt_test.go

This file was deleted.

Loading

0 comments on commit cc2cbea

Please sign in to comment.