Skip to content

Commit

Permalink
Polkadot update v0.9.43 (#366)
Browse files Browse the repository at this point in the history
* types: Update AccountInfo

* tests: Update tests

* client: Add CallContext to Client interface

* deps: Update go version, polkadot docker image

* lint: Obey

* deps: Update subkey to v2

* address: Return account ID creation error
  • Loading branch information
cdamian authored Dec 5, 2023
1 parent 0a28e8b commit a608e41
Show file tree
Hide file tree
Showing 13 changed files with 97 additions and 54 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.18
FROM golang:1.21

RUN apt-get -y update && apt-get -y upgrade && apt-get -y install wget && apt-get install ca-certificates -y

Expand Down
34 changes: 29 additions & 5 deletions client/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,20 @@ type Client interface {
// args must be encoded in the format RPC understands
Call(result interface{}, method string, args ...interface{}) error

Subscribe(ctx context.Context, namespace, subscribeMethodSuffix, unsubscribeMethodSuffix,
notificationMethodSuffix string, channel interface{}, args ...interface{}) (
*gethrpc.ClientSubscription, error)
CallContext(
ctx context.Context,
result interface{},
method string,
args ...interface{},
) error

Subscribe(
ctx context.Context,
namespace, subscribeMethodSuffix, unsubscribeMethodSuffix,
notificationMethodSuffix string,
channel interface{},
args ...interface{},
) (*gethrpc.ClientSubscription, error)

URL() string

Expand Down Expand Up @@ -73,8 +84,21 @@ func Connect(url string) (Client, error) {
}

func CallWithBlockHash(c Client, target interface{}, method string, blockHash *types.Hash, args ...interface{}) error {
ctx := context.Background()

return CallWithBlockHashContext(ctx, c, target, method, blockHash, args...)
}

func CallWithBlockHashContext(
ctx context.Context,
c Client,
target interface{},
method string,
blockHash *types.Hash,
args ...interface{},
) error {
if blockHash == nil {
err := c.Call(target, method, args...)
err := c.CallContext(ctx, target, method, args...)
if err != nil {
return err
}
Expand All @@ -85,7 +109,7 @@ func CallWithBlockHash(c Client, target interface{}, method string, blockHash *t
return err
}
args = append(args, hexHash)
err = c.Call(target, method, args...)
err = c.CallContext(ctx, target, method, args...)
if err != nil {
return err
}
Expand Down
17 changes: 17 additions & 0 deletions client/mocks/Client.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ version: '2'
services:
substrate:
container_name: substrate
image: parity/polkadot:v0.9.21
image: parity/polkadot:v0.9.43
ports:
- 9933:9933
- 9944:9944
- 30333:30333
command: --dev --rpc-external --ws-external --rpc-methods Unsafe --offchain-worker Always
command: --dev --rpc-external --rpc-methods Unsafe --offchain-worker Always
gsrpc-test:
image: gsrpc-test
build: .
Expand Down
4 changes: 2 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/centrifuge/go-substrate-rpc-client/v4

go 1.18
go 1.21

require (
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
Expand All @@ -12,7 +12,7 @@ require (
github.com/pierrec/xxHash v0.1.5
github.com/rs/cors v1.8.2
github.com/stretchr/testify v1.7.2
github.com/vedhavyas/go-subkey v1.0.4
github.com/vedhavyas/go-subkey/v2 v2.0.0
golang.org/x/crypto v0.7.0
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
)
Expand Down
8 changes: 5 additions & 3 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@ github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo=
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ=
Expand All @@ -29,6 +30,7 @@ github.com/decred/base58 v1.0.4/go.mod h1:jJswKPEdvpFpvf7dsDvFZyLT22xZ9lWqEByX38
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
github.com/ethereum/go-ethereum v1.10.20 h1:75IW830ClSS40yrQC1ZCMZCt5I+zU16oqId2SiQwdQ4=
github.com/ethereum/go-ethereum v1.10.20/go.mod h1:LWUN82TCHGpxB3En5HVmLLzPD7YSrEUFmFfN1nKkVN0=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
Expand Down Expand Up @@ -75,8 +77,8 @@ github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
github.com/vedhavyas/go-subkey v1.0.4 h1:QwjBZx4w7qXC2lmqol2jJfhaNXPI9BsgLZiMiCwqGDU=
github.com/vedhavyas/go-subkey v1.0.4/go.mod h1:aOIil/KS9hJlnr9ZSQKSoXdu/MbnkCxG4x9IOlLsMtI=
github.com/vedhavyas/go-subkey/v2 v2.0.0 h1:LemDIsrVtRSOkp0FA8HxP6ynfKjeOj3BY2U9UNfeDMA=
github.com/vedhavyas/go-subkey/v2 v2.0.0/go.mod h1:95aZ+XDCWAUUynjlmi7BtPExjXgXxByE0WfBwbmIRH4=
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
Expand Down
2 changes: 1 addition & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ func Example_simpleConnect() {
}

fmt.Printf("You are connected to chain %v using %v v%v\n", chain, nodeName, nodeVersion)
// Output: You are connected to chain Development using Parity Polkadot v0.9.21-56cbe45f6c9
// Output: You are connected to chain Development using Parity Polkadot v0.9.43-ba42b9ce51d
}

func Example_listenToNewBlocks() {
Expand Down
12 changes: 6 additions & 6 deletions registry/factory_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,6 @@ func TestFactory_CreateCallRegistry_Overrides(t *testing.T) {

f = NewFactory(fieldOverride).(*factory)

assert.Equal(t, f.fieldStorage[targetLookupIndex], &ValueDecoder[types.I64]{})

_, err = f.CreateCallRegistry(&meta)
assert.NoError(t, err)

Expand Down Expand Up @@ -541,8 +539,6 @@ func TestFactory_CreateEventRegistry_Overrides(t *testing.T) {

f := NewFactory(fieldOverride).(*factory)

assert.Equal(t, f.fieldStorage[targetLookupIndex], &ValueDecoder[types.DispatchInfo]{})

_, err = f.CreateEventRegistry(&meta)
assert.NoError(t, err)

Expand Down Expand Up @@ -723,6 +719,7 @@ func TestFactory_getTypeFields(t *testing.T) {
}

factory := NewFactory().(*factory)
factory.resetStorages()

res, err := factory.getTypeFields(testMeta, testFields)
assert.NoError(t, err)
Expand Down Expand Up @@ -776,6 +773,7 @@ func TestFactory_getTypeFields_FieldDecoderRetrievalError(t *testing.T) {
}

factory := NewFactory().(*factory)
factory.resetStorages()

res, err := factory.getTypeFields(testMeta, testFields)
assert.ErrorIs(t, err, ErrFieldDecoderRetrieval)
Expand Down Expand Up @@ -948,6 +946,7 @@ func TestFactory_getFieldDecoder_Composite(t *testing.T) {
}

factory := NewFactory().(*factory)
factory.resetStorages()

res, err := factory.getFieldDecoder(testMeta, testFieldName, testFieldTypeDef)
assert.NoError(t, err)
Expand Down Expand Up @@ -1016,6 +1015,7 @@ func TestFactory_getFieldDecoder_Composite_FieldError(t *testing.T) {
}

factory := NewFactory().(*factory)
factory.resetStorages()

res, err := factory.getFieldDecoder(testMeta, testFieldName, testFieldTypeDef)
assert.ErrorIs(t, err, ErrCompositeTypeFieldsRetrieval)
Expand Down Expand Up @@ -1074,6 +1074,7 @@ func TestFactory_getFieldDecoder_Variant(t *testing.T) {
}

factory := NewFactory().(*factory)
factory.resetStorages()

res, err := factory.getFieldDecoder(testMeta, testFieldName, testFieldTypeDef)
assert.NoError(t, err)
Expand Down Expand Up @@ -1638,6 +1639,7 @@ func TestFactory_getVariantFieldType_CompositeVariantTypeFieldError(t *testing.T
}

factory := NewFactory().(*factory)
factory.resetStorages()

res, err := factory.getVariantFieldDecoder(testMeta, testFieldTypeDef)
assert.ErrorIs(t, err, ErrVariantTypeFieldsRetrieval)
Expand Down Expand Up @@ -2071,8 +2073,6 @@ func TestFactory_Overrides(t *testing.T) {

f := NewFactory(fieldOverride).(*factory)

assert.Equal(t, f.fieldStorage[targetLookupIndex], &ValueDecoder[types.DispatchInfo]{})

reg, err := f.CreateEventRegistry(&meta)
assert.NoError(t, err)

Expand Down
3 changes: 1 addition & 2 deletions rpc/author/submit_and_watch_extrinsic_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package author_test

import (
"fmt"
"testing"

gsrpc "github.com/centrifuge/go-substrate-rpc-client/v4"
Expand Down Expand Up @@ -57,7 +56,7 @@ func TestAuthor_SubmitAndWatchExtrinsic(t *testing.T) {
TransactionVersion: rv.TransactionVersion,
}

fmt.Printf("Sending %v from %#x to %#x with nonce %v\n", amount, signature.TestKeyringPairAlice.PublicKey, bob.AsID, nonce)
t.Logf("Sending %v from %#x to %#x with nonce %v\n", amount, signature.TestKeyringPairAlice.PublicKey, bob.AsID, nonce)

// Sign the transaction using Alice's default account
err = ext.Sign(signature.TestKeyringPairAlice, o)
Expand Down
Loading

0 comments on commit a608e41

Please sign in to comment.