Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"context"
"log"

"github.com/centrifuge/go-substrate-rpc-client/v2/config"
gethrpc "github.com/centrifuge/go-substrate-rpc-client/v2/gethrpc"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/config"
gethrpc "github.com/snowfork/go-substrate-rpc-client/v2/gethrpc"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

type Client interface {
Expand Down
8 changes: 4 additions & 4 deletions doc.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,15 @@ In order to sign extrinsics, you need to have [subkey](https://github.com/parity

Types

The package [types](https://godoc.org/github.com/centrifuge/go-substrate-rpc-client/v2/types/) exports a number
The package [types](https://godoc.org/github.com/snowfork/go-substrate-rpc-client/v2/types/) exports a number
of useful basic types including functions for encoding and decoding them.

To use your own custom types, you can simply create structs and arrays composing those basic types. Here are some
examples using composition of a mix of these basic and builtin Go types:

1. Vectors, lists, series, sets, arrays, slices: https://godoc.org/github.com/centrifuge/go-substrate-rpc-client/v2/types/#example_Vec_simple
1. Vectors, lists, series, sets, arrays, slices: https://godoc.org/github.com/snowfork/go-substrate-rpc-client/v2/types/#example_Vec_simple

2. Structs: https://godoc.org/github.com/centrifuge/go-substrate-rpc-client/v2/types/#example_Struct_simple
2. Structs: https://godoc.org/github.com/snowfork/go-substrate-rpc-client/v2/types/#example_Struct_simple

There are some caveats though that you should be aware of:

Expand All @@ -56,6 +56,6 @@ methods that implement the Encodeable/Decodeable interfaces. Examples for that a
types, you can find reference implementations of those here: types/enum_test.go , types/tuple_test.go and
types/vec_any_test.go

For more information about the types sub-package, see https://godoc.org/github.com/centrifuge/go-substrate-rpc-client/v2/types
For more information about the types sub-package, see https://godoc.org/github.com/snowfork/go-substrate-rpc-client/v2/types
*/
package gsrpc
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module github.com/centrifuge/go-substrate-rpc-client/v2
module github.com/snowfork/go-substrate-rpc-client/v2

go 1.15

Expand Down
1 change: 1 addition & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/rs/cors v1.6.0 h1:G9tHG9lebljV9mfp9SNPDL36nCDxmo3zTlAf1YgvzmI=
github.com/rs/cors v1.6.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU=
github.com/stretchr/objx v0.1.0 h1:4G4v2dO3VZwixGIRoQ5Lfboy6nUhCyYzaqnIAPPhYs4=
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
github.com/stretchr/testify v1.3.0 h1:TivCn/peBQ7UY8ooIcPgZFpTNSz0Q2U6UrFlUfqbe0Q=
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
Expand Down
4 changes: 2 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package gsrpc

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/client"
"github.com/centrifuge/go-substrate-rpc-client/v2/rpc"
"github.com/snowfork/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/rpc"
)

type SubstrateAPI struct {
Expand Down
32 changes: 16 additions & 16 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
"math/big"
"time"

gsrpc "github.com/centrifuge/go-substrate-rpc-client/v2"
"github.com/centrifuge/go-substrate-rpc-client/v2/config"
"github.com/centrifuge/go-substrate-rpc-client/v2/signature"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
gsrpc "github.com/snowfork/go-substrate-rpc-client/v2"
"github.com/snowfork/go-substrate-rpc-client/v2/config"
"github.com/snowfork/go-substrate-rpc-client/v2/signature"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

func Example_simpleConnect() {
Expand Down Expand Up @@ -235,12 +235,12 @@ func Example_makeASimpleTransfer() {
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),
BlockHash: genesisHash,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: genesisHash,
Nonce: types.NewUCompactFromUInt(uint64(nonce)),
SpecVersion: rv.SpecVersion,
Tip: types.NewUCompactFromUInt(0),
TransactionVersion: rv.TransactionVersion,
}

Expand Down Expand Up @@ -449,12 +449,12 @@ func Example_transactionWithEvents() {
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),
BlockHash: genesisHash,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: genesisHash,
Nonce: types.NewUCompactFromUInt(uint64(nonce)),
SpecVersion: rv.SpecVersion,
Tip: types.NewUCompactFromUInt(0),
TransactionVersion: rv.TransactionVersion,
}

Expand Down
2 changes: 1 addition & 1 deletion rpc/author/author.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package author

import "github.com/centrifuge/go-substrate-rpc-client/v2/client"
import "github.com/snowfork/go-substrate-rpc-client/v2/client"

// Author exposes methods for authoring of network items
type Author struct {
Expand Down
4 changes: 2 additions & 2 deletions rpc/author/author_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ import (
"os"
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v2/client"
"github.com/centrifuge/go-substrate-rpc-client/v2/rpcmocksrv"
"github.com/snowfork/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/rpcmocksrv"
)

var author *Author
Expand Down
2 changes: 1 addition & 1 deletion rpc/author/pending_extrinsics.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package author

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// PendingExtrinsics returns all pending extrinsics, potentially grouped by sender
Expand Down
2 changes: 1 addition & 1 deletion rpc/author/pending_extrinsics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package author
import (
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
"github.com/stretchr/testify/assert"
)

Expand Down
6 changes: 3 additions & 3 deletions rpc/author/submit_and_watch_extrinsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"context"
"sync"

"github.com/centrifuge/go-substrate-rpc-client/v2/config"
gethrpc "github.com/centrifuge/go-substrate-rpc-client/v2/gethrpc"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/config"
gethrpc "github.com/snowfork/go-substrate-rpc-client/v2/gethrpc"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// ExtrinsicStatusSubscription is a subscription established through one of the Client's subscribe methods.
Expand Down
2 changes: 1 addition & 1 deletion rpc/author/submit_extrinsic.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@

package author

import "github.com/centrifuge/go-substrate-rpc-client/v2/types"
import "github.com/snowfork/go-substrate-rpc-client/v2/types"

// SubmitExtrinsic will submit a fully formatted extrinsic for block inclusion
func (a *Author) SubmitExtrinsic(xt types.Extrinsic) (types.Hash, error) {
Expand Down
2 changes: 1 addition & 1 deletion rpc/author/submit_extrinsic_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package author
import (
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion rpc/chain/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package chain

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/client"
)

// Chain exposes methods for retrieval of chain data
Expand Down
6 changes: 3 additions & 3 deletions rpc/chain/chain_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"os"
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v2/client"
"github.com/centrifuge/go-substrate-rpc-client/v2/rpcmocksrv"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/rpcmocksrv"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

var chain *Chain
Expand Down
4 changes: 2 additions & 2 deletions rpc/chain/get_block.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package chain

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/client"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// GetBlock returns the header and body of the relay chain block with the given hash
Expand Down
2 changes: 1 addition & 1 deletion rpc/chain/get_block_hash.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package chain

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// GetBlockHash returns the block hash for a specific block height
Expand Down
2 changes: 1 addition & 1 deletion rpc/chain/get_block_hash_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package chain
import (
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
"github.com/stretchr/testify/assert"
)

Expand Down
2 changes: 1 addition & 1 deletion rpc/chain/get_finalized_head.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
package chain

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// GetFinalizedHead returns the hash of the last finalized block in the canon chain
Expand Down
2 changes: 1 addition & 1 deletion rpc/chain/get_finalized_head_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ package chain
import (
"testing"

"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
"github.com/stretchr/testify/assert"
)

Expand Down
4 changes: 2 additions & 2 deletions rpc/chain/get_header.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
package chain

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/client"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// GetHeader retrieves the header for the specific block
Expand Down
6 changes: 3 additions & 3 deletions rpc/chain/subscribe_finalized_heads.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"context"
"sync"

"github.com/centrifuge/go-substrate-rpc-client/v2/config"
gethrpc "github.com/centrifuge/go-substrate-rpc-client/v2/gethrpc"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/config"
gethrpc "github.com/snowfork/go-substrate-rpc-client/v2/gethrpc"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// FinalizedHeadsSubscription is a subscription established through one of the Client's subscribe methods.
Expand Down
6 changes: 3 additions & 3 deletions rpc/chain/subscribe_new_heads.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ import (
"context"
"sync"

"github.com/centrifuge/go-substrate-rpc-client/v2/config"
gethrpc "github.com/centrifuge/go-substrate-rpc-client/v2/gethrpc"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/config"
gethrpc "github.com/snowfork/go-substrate-rpc-client/v2/gethrpc"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// NewHeadsSubscription is a subscription established through one of the Client's subscribe methods.
Expand Down
38 changes: 22 additions & 16 deletions rpc/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +17,24 @@
package rpc

import (
"github.com/centrifuge/go-substrate-rpc-client/v2/client"
"github.com/centrifuge/go-substrate-rpc-client/v2/rpc/author"
"github.com/centrifuge/go-substrate-rpc-client/v2/rpc/chain"
"github.com/centrifuge/go-substrate-rpc-client/v2/rpc/state"
"github.com/centrifuge/go-substrate-rpc-client/v2/rpc/system"
"github.com/centrifuge/go-substrate-rpc-client/v2/types"
"github.com/snowfork/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/rpc/author"
"github.com/snowfork/go-substrate-rpc-client/v2/rpc/chain"
"github.com/snowfork/go-substrate-rpc-client/v2/rpc/mmr"
"github.com/snowfork/go-substrate-rpc-client/v2/rpc/offchain"
"github.com/snowfork/go-substrate-rpc-client/v2/rpc/state"
"github.com/snowfork/go-substrate-rpc-client/v2/rpc/system"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

type RPC struct {
Author *author.Author
Chain *chain.Chain
State *state.State
System *system.System
client client.Client
Author *author.Author
Chain *chain.Chain
MMR *mmr.MMR
Offchain *offchain.Offchain
State *state.State
System *system.System
client client.Client
}

func NewRPC(cl client.Client) (*RPC, error) {
Expand All @@ -44,10 +48,12 @@ func NewRPC(cl client.Client) (*RPC, error) {
types.SetSerDeOptions(opts)

return &RPC{
Author: author.NewAuthor(cl),
Chain: chain.NewChain(cl),
State: st,
System: system.NewSystem(cl),
client: cl,
Author: author.NewAuthor(cl),
Chain: chain.NewChain(cl),
MMR: mmr.NewMMR(cl),
Offchain: offchain.NewOffchain(cl),
State: st,
System: system.NewSystem(cl),
client: cl,
}, nil
}
27 changes: 27 additions & 0 deletions rpc/mmr/generate_proof.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package mmr

import (
"github.com/snowfork/go-substrate-rpc-client/v2/client"
"github.com/snowfork/go-substrate-rpc-client/v2/types"
)

// GenerateProof retrieves a MMR proof and leaf for the specified leave index, at the given blockHash (useful to query a
// proof at an earlier block, likely with antoher MMR root)
func (c *MMR) GenerateProof(leafIndex uint64, blockHash types.Hash) (types.GenerateMMRProofResponse, error) {
return c.generateProof(leafIndex, &blockHash)
}

// GenerateProofLatest retrieves the latest MMR proof and leaf for the specified leave index
func (c *MMR) GenerateProofLatest(leafIndex uint64) (types.GenerateMMRProofResponse, error) {
return c.generateProof(leafIndex, nil)
}

func (c *MMR) generateProof(leafIndex uint64, blockHash *types.Hash) (types.GenerateMMRProofResponse, error) {
var res types.GenerateMMRProofResponse
err := client.CallWithBlockHash(c.client, &res, "mmr_generateProof", blockHash, leafIndex)
if err != nil {
return types.GenerateMMRProofResponse{}, err
}

return res, nil
}
13 changes: 13 additions & 0 deletions rpc/mmr/mmr.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package mmr

import "github.com/snowfork/go-substrate-rpc-client/v2/client"

// MMR exposes methods for retrieval of MMR data
type MMR struct {
client client.Client
}

// NewMMR creates a new MMR struct
func NewMMR(c client.Client) *MMR {
return &MMR{client: c}
}
Loading