Skip to content

Commit

Permalink
made changes to gsrpc
Browse files Browse the repository at this point in the history
  • Loading branch information
chandiniv1 committed Aug 23, 2023
1 parent 0ef7867 commit 97763a8
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 22 deletions.
22 changes: 13 additions & 9 deletions da/avail/avail.go
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,6 @@ func (c *DataAvailabilityLayerClient) CheckBlockAvailability(ctx context.Context
//RetrieveBlocks gets the block from DA layer.

func (c *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, dataLayerHeight uint64) da.ResultRetrieveBlocks {

blocks := []*types.Block{}

blockNumber := dataLayerHeight
Expand All @@ -169,6 +168,7 @@ func (c *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, dataLa
}
}
responseData, err := ioutil.ReadAll(response.Body)

if err != nil {
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Expand All @@ -177,17 +177,21 @@ func (c *DataAvailabilityLayerClient) RetrieveBlocks(ctx context.Context, dataLa
},
}
}

var appDataObject AppData
err = json.Unmarshal(responseData, &appDataObject)
if err != nil {
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Code: da.StatusError,
Message: err.Error(),
},

if !(string(responseData) != "Not found") {
err = json.Unmarshal(responseData, &appDataObject)
if err != nil {
return da.ResultRetrieveBlocks{
BaseResult: da.BaseResult{
Code: da.StatusError,
Message: err.Error(),
},
}
}
}

}
txnsByteArray := []byte{}
for _, extrinsic := range appDataObject.Extrinsics {
txnsByteArray = append(txnsByteArray, []byte(extrinsic)...)
Expand Down
22 changes: 9 additions & 13 deletions da/avail/datasubmit/submitdata.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package datasubmit

import (
//"errors"
"errors"

gsrpc "github.com/centrifuge/go-substrate-rpc-client/v4"
"github.com/centrifuge/go-substrate-rpc-client/v4/signature"
Expand All @@ -21,7 +21,7 @@ func SubmitData(apiURL string, seed string, appID int, data []byte) (types.Hash,
}

//if app id is greater than 0 then it must be created before submitting data
//err = errors.New("AppID can be 0")
err = errors.New("AppID can be 0")
if appID == 0 {
return types.Hash{}, err
}
Expand Down Expand Up @@ -62,17 +62,13 @@ func SubmitData(apiURL string, seed string, appID int, data []byte) (types.Hash,

nonce := uint32(accountInfo.Nonce)
o := types.SignatureOptions{
BlockHash: genesisHash,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: genesisHash,
Nonce: types.NewUCompactFromUInt(uint64(nonce)),
SpecVersion: rv.SpecVersion,
Tip: types.NewUCompactFromUInt(0),
//AppID: types.NewUCompactFromUInt(uint64(appID)),
AppID: types.NewU32(uint32(appID)),
//AppID: types.U32(types.NewI16(int16(appID))),
//AppID: types.U32(uint32(appID)),
//AppID: types.U32(types.NewU16(uint16(appID))),
BlockHash: genesisHash,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: genesisHash,
Nonce: types.NewUCompactFromUInt(uint64(nonce)),
SpecVersion: rv.SpecVersion,
Tip: types.NewUCompactFromUInt(0),
AppID: types.NewUCompactFromUInt(uint64(appID)),
TransactionVersion: rv.TransactionVersion,
}

Expand Down
2 changes: 2 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -198,9 +198,11 @@ require (
)

replace (
//github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/chandiniv1/go-substrate-rpc-client/v4 v4.0.0-avail-alpha4-129b2558ae448cdb1c74ae94c512b5b82673e6d5
github.com/centrifuge/go-substrate-rpc-client/v4 => /home/chandini/go/src/github.com/chandiniv1/go-substrate-rpc-client
//github.com/centrifuge/go-substrate-rpc-client/v4 => github.com/chandiniv1/go-substrate-rpc-client/v4 v4.0.12-avail-1.5.0-4eb55aaa492.0.20230719142342-dfd1152c8eca
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.2-alpha.regen.4

// github.com/tendermint/tendermint => github.com/celestiaorg/tendermint v0.34.22-0.20221202214355-3605c597500d
github.com/tendermint/tendermint => github.com/rollkit/cometbft v0.0.0-20230524013001-2968c8b8b121
google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down

0 comments on commit 97763a8

Please sign in to comment.