Skip to content

Commit a608e41

Browse files
authored
Polkadot update v0.9.43 (#366)
* 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
1 parent 0a28e8b commit a608e41

13 files changed

Lines changed: 97 additions & 54 deletions

File tree

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM golang:1.18
1+
FROM golang:1.21
22

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

client/client.go

Lines changed: 29 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,9 +33,20 @@ type Client interface {
3333
// args must be encoded in the format RPC understands
3434
Call(result interface{}, method string, args ...interface{}) error
3535

36-
Subscribe(ctx context.Context, namespace, subscribeMethodSuffix, unsubscribeMethodSuffix,
37-
notificationMethodSuffix string, channel interface{}, args ...interface{}) (
38-
*gethrpc.ClientSubscription, error)
36+
CallContext(
37+
ctx context.Context,
38+
result interface{},
39+
method string,
40+
args ...interface{},
41+
) error
42+
43+
Subscribe(
44+
ctx context.Context,
45+
namespace, subscribeMethodSuffix, unsubscribeMethodSuffix,
46+
notificationMethodSuffix string,
47+
channel interface{},
48+
args ...interface{},
49+
) (*gethrpc.ClientSubscription, error)
3950

4051
URL() string
4152

@@ -73,8 +84,21 @@ func Connect(url string) (Client, error) {
7384
}
7485

7586
func CallWithBlockHash(c Client, target interface{}, method string, blockHash *types.Hash, args ...interface{}) error {
87+
ctx := context.Background()
88+
89+
return CallWithBlockHashContext(ctx, c, target, method, blockHash, args...)
90+
}
91+
92+
func CallWithBlockHashContext(
93+
ctx context.Context,
94+
c Client,
95+
target interface{},
96+
method string,
97+
blockHash *types.Hash,
98+
args ...interface{},
99+
) error {
76100
if blockHash == nil {
77-
err := c.Call(target, method, args...)
101+
err := c.CallContext(ctx, target, method, args...)
78102
if err != nil {
79103
return err
80104
}
@@ -85,7 +109,7 @@ func CallWithBlockHash(c Client, target interface{}, method string, blockHash *t
85109
return err
86110
}
87111
args = append(args, hexHash)
88-
err = c.Call(target, method, args...)
112+
err = c.CallContext(ctx, target, method, args...)
89113
if err != nil {
90114
return err
91115
}

client/mocks/Client.go

Lines changed: 17 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,12 @@ version: '2'
33
services:
44
substrate:
55
container_name: substrate
6-
image: parity/polkadot:v0.9.21
6+
image: parity/polkadot:v0.9.43
77
ports:
88
- 9933:9933
99
- 9944:9944
1010
- 30333:30333
11-
command: --dev --rpc-external --ws-external --rpc-methods Unsafe --offchain-worker Always
11+
command: --dev --rpc-external --rpc-methods Unsafe --offchain-worker Always
1212
gsrpc-test:
1313
image: gsrpc-test
1414
build: .

go.mod

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
module github.com/centrifuge/go-substrate-rpc-client/v4
22

3-
go 1.18
3+
go 1.21
44

55
require (
66
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce
@@ -12,7 +12,7 @@ require (
1212
github.com/pierrec/xxHash v0.1.5
1313
github.com/rs/cors v1.8.2
1414
github.com/stretchr/testify v1.7.2
15-
github.com/vedhavyas/go-subkey v1.0.4
15+
github.com/vedhavyas/go-subkey/v2 v2.0.0
1616
golang.org/x/crypto v0.7.0
1717
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce
1818
)

go.sum

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ github.com/ChainSafe/go-schnorrkel v1.0.0/go.mod h1:dpzHYVxLZcp8pjlV+O+UR8K0Hp/z
33
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8=
44
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg=
55
github.com/aead/siphash v1.0.1/go.mod h1:Nywa3cDsYNNK3gaciGTWPwHt0wlpNV15vwmswBAUSII=
6+
github.com/btcsuite/btcd v0.20.1-beta h1:Ik4hyJqN8Jfyv3S4AGBOmyouMsYE3EdYODkMbQjwPGw=
67
github.com/btcsuite/btcd v0.20.1-beta/go.mod h1:wVuoA8VJLEcwgqHBwHmzLRazpKxTv13Px/pDuV7OomQ=
7-
github.com/btcsuite/btcd v0.22.0-beta h1:LTDpDKUM5EeOFBPM8IXpinEcmZ6FWfNZbE3lfrfdnWo=
88
github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k=
9+
github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU=
910
github.com/btcsuite/btclog v0.0.0-20170628155309-84c8d2346e9f/go.mod h1:TdznJufoqS23FtqVCzL0ZqgP5MqXbb4fg/WgDys70nA=
1011
github.com/btcsuite/btcutil v0.0.0-20190425235716-9e5f4b9a998d/go.mod h1:+5NJ2+qvTyV9exUAL/rxXi3DcLg2Ts+ymUAY5y4NvMg=
1112
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ=
@@ -29,6 +30,7 @@ github.com/decred/base58 v1.0.4/go.mod h1:jJswKPEdvpFpvf7dsDvFZyLT22xZ9lWqEByX38
2930
github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0=
3031
github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc=
3132
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1 h1:YLtO71vCjJRCBcrPMtQ9nqBsqpA1m5sE92cU+pd5Mcc=
33+
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1/go.mod h1:hyedUtir6IdtD/7lIxGeCxkaw7y45JueMRL4DIyJDKs=
3234
github.com/ethereum/go-ethereum v1.10.20 h1:75IW830ClSS40yrQC1ZCMZCt5I+zU16oqId2SiQwdQ4=
3335
github.com/ethereum/go-ethereum v1.10.20/go.mod h1:LWUN82TCHGpxB3En5HVmLLzPD7YSrEUFmFfN1nKkVN0=
3436
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
@@ -75,8 +77,8 @@ github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp
7577
github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI=
7678
github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA=
7779
github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM=
78-
github.com/vedhavyas/go-subkey v1.0.4 h1:QwjBZx4w7qXC2lmqol2jJfhaNXPI9BsgLZiMiCwqGDU=
79-
github.com/vedhavyas/go-subkey v1.0.4/go.mod h1:aOIil/KS9hJlnr9ZSQKSoXdu/MbnkCxG4x9IOlLsMtI=
80+
github.com/vedhavyas/go-subkey/v2 v2.0.0 h1:LemDIsrVtRSOkp0FA8HxP6ynfKjeOj3BY2U9UNfeDMA=
81+
github.com/vedhavyas/go-subkey/v2 v2.0.0/go.mod h1:95aZ+XDCWAUUynjlmi7BtPExjXgXxByE0WfBwbmIRH4=
8082
golang.org/x/crypto v0.0.0-20170930174604-9419663f5a44/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
8183
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
8284
golang.org/x/crypto v0.0.0-20191206172530-e9b2fee46413/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=

main_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ func Example_simpleConnect() {
5050
}
5151

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

5656
func Example_listenToNewBlocks() {

registry/factory_test.go

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -316,8 +316,6 @@ func TestFactory_CreateCallRegistry_Overrides(t *testing.T) {
316316

317317
f = NewFactory(fieldOverride).(*factory)
318318

319-
assert.Equal(t, f.fieldStorage[targetLookupIndex], &ValueDecoder[types.I64]{})
320-
321319
_, err = f.CreateCallRegistry(&meta)
322320
assert.NoError(t, err)
323321

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

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

544-
assert.Equal(t, f.fieldStorage[targetLookupIndex], &ValueDecoder[types.DispatchInfo]{})
545-
546542
_, err = f.CreateEventRegistry(&meta)
547543
assert.NoError(t, err)
548544

@@ -723,6 +719,7 @@ func TestFactory_getTypeFields(t *testing.T) {
723719
}
724720

725721
factory := NewFactory().(*factory)
722+
factory.resetStorages()
726723

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

778775
factory := NewFactory().(*factory)
776+
factory.resetStorages()
779777

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

950948
factory := NewFactory().(*factory)
949+
factory.resetStorages()
951950

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

10181017
factory := NewFactory().(*factory)
1018+
factory.resetStorages()
10191019

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

10761076
factory := NewFactory().(*factory)
1077+
factory.resetStorages()
10771078

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

16401641
factory := NewFactory().(*factory)
1642+
factory.resetStorages()
16411643

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

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

2074-
assert.Equal(t, f.fieldStorage[targetLookupIndex], &ValueDecoder[types.DispatchInfo]{})
2075-
20762076
reg, err := f.CreateEventRegistry(&meta)
20772077
assert.NoError(t, err)
20782078

rpc/author/submit_and_watch_extrinsic_test.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
package author_test
22

33
import (
4-
"fmt"
54
"testing"
65

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

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

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

0 commit comments

Comments
 (0)