Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

deps: Use gsrpc dynamic extrinsic #142

Merged
merged 1 commit into from
Jul 29, 2024
Merged
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
27 changes: 15 additions & 12 deletions chains/substrate/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ package substrate
import (
"fmt"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/extrinsic"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/extrinsic/extensions"
"sync"

utils "github.com/ChainSafe/ChainBridge/shared/substrate"
Expand Down Expand Up @@ -97,7 +99,7 @@ func (c *Connection) SubmitTx(method utils.Method, args ...interface{}) error {
if err != nil {
return fmt.Errorf("failed to construct call: %w", err)
}
ext := types.NewExtrinsic(call)
ext := extrinsic.NewDynamicExtrinsic(&call)

// Get latest runtime version
rv, err := c.api.RPC.State.GetRuntimeVersionLatest()
Expand All @@ -116,24 +118,25 @@ func (c *Connection) SubmitTx(method utils.Method, args ...interface{}) error {
}

// Sign the extrinsic
o := types.SignatureOptions{
BlockHash: c.genesisHash,
Era: types.ExtrinsicEra{IsMortalEra: false},
GenesisHash: c.genesisHash,
Nonce: types.NewUCompactFromUInt(uint64(c.nonce)),
SpecVersion: rv.SpecVersion,
Tip: types.NewUCompactFromUInt(0),
TransactionVersion: rv.TransactionVersion,
}
err = ext.Sign(
*c.key,
&meta,
extrinsic.WithEra(types.ExtrinsicEra{IsImmortalEra: true}, c.genesisHash),
extrinsic.WithNonce(types.NewUCompactFromUInt(uint64(c.nonce))),
extrinsic.WithTip(types.NewUCompactFromUInt(0)),
extrinsic.WithSpecVersion(rv.SpecVersion),
extrinsic.WithTransactionVersion(rv.TransactionVersion),
extrinsic.WithGenesisHash(c.genesisHash),
extrinsic.WithMetadataMode(extensions.CheckMetadataModeDisabled, extensions.CheckMetadataHash{Hash: types.NewEmptyOption[types.H256]()}),
)

err = ext.Sign(*c.key, o)
if err != nil {
c.nonceLock.Unlock()
return err
}

// Submit and watch the extrinsic
sub, err := c.api.RPC.Author.SubmitAndWatchExtrinsic(ext)
sub, err := c.api.RPC.Author.SubmitAndWatchDynamicExtrinsic(ext)
c.nonce++
c.nonceLock.Unlock()
if err != nil {
Expand Down
11 changes: 5 additions & 6 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
module github.com/ChainSafe/ChainBridge

go 1.18
go 1.21

// NOTE - this is a specific branch - https://github.com/centrifuge/go-substrate-rpc-client/tree/remove-claims-event,
// that does not have the `Claims_Claimed` event since it is colliding with the one that we have in the claims pallet
// of Centrifuge chain.
require github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.17-0.20230713095918-d6e1d43a5270
toolchain go1.22.4

require github.com/centrifuge/go-substrate-rpc-client/v4 v4.2.2-0.20240724202640-8bafff8c25ea

require (
github.com/ChainSafe/log15 v1.0.0
Expand Down Expand Up @@ -55,7 +54,7 @@ require (
github.com/stretchr/objx v0.1.1 // indirect
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/vedhavyas/go-subkey v1.0.4 // indirect
github.com/vedhavyas/go-subkey/v2 v2.0.0 // indirect
github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 // indirect
golang.org/x/sys v0.6.0 // indirect
golang.org/x/term v0.6.0 // indirect
Expand Down
Loading
Loading