Skip to content

Commit

Permalink
Merge pull request #99 from centrifuge/update-gsrpc-lib-to-8350785ebd6f
Browse files Browse the repository at this point in the history
deps: Update gsrpc lib to 8350785ebd6f
  • Loading branch information
cdamian authored Oct 1, 2022
2 parents ffc5c16 + 5392e80 commit 3e4e4c0
Show file tree
Hide file tree
Showing 11 changed files with 104 additions and 38 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# Copyright 2020 ChainSafe Systems
# SPDX-License-Identifier: LGPL-3.0-only

FROM golang:1.17-stretch AS builder
FROM golang:1.18-stretch AS builder
ADD . /src
WORKDIR /src
RUN go mod download
Expand Down
3 changes: 2 additions & 1 deletion chains/substrate/connection.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package substrate

import (
"fmt"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"sync"

utils "github.com/ChainSafe/ChainBridge/shared/substrate"
Expand Down Expand Up @@ -185,7 +186,7 @@ func getConst(meta *types.Metadata, prefix, name string, res interface{}) error
if string(mod.Name) == prefix {
for _, cons := range mod.Constants {
if string(cons.Name) == name {
return types.Decode(cons.Value, res)
return codec.Decode(cons.Value, res)
}
}
}
Expand Down
19 changes: 13 additions & 6 deletions chains/substrate/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package substrate

import (
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"math/big"

"github.com/centrifuge/chainbridge-utils/msg"
Expand Down Expand Up @@ -52,7 +53,7 @@ type proposal struct {

// encode takes only nonce and call and encodes them for storage queries
func (p *proposal) encode() ([]byte, error) {
return types.Encode(struct {
return codec.Encode(struct {
types.U64
types.Call
}{p.depositNonce, p.call})
Expand All @@ -61,7 +62,10 @@ func (p *proposal) encode() ([]byte, error) {
func (w *writer) createFungibleProposal(m msg.Message) (*proposal, error) {
bigAmt := big.NewInt(0).SetBytes(m.Payload[0].([]byte))
amount := types.NewU128(*bigAmt)
recipient := types.NewAccountID(m.Payload[1].([]byte))
recipient, err := types.NewAccountID(m.Payload[1].([]byte))
if err != nil {
return nil, err
}
depositNonce := types.U64(m.DepositNonce)

meta := w.conn.getMetadata()
Expand All @@ -79,7 +83,7 @@ func (w *writer) createFungibleProposal(m msg.Message) (*proposal, error) {
return nil, err
}
if w.extendCall {
eRID, err := types.Encode(m.ResourceId)
eRID, err := codec.Encode(m.ResourceId)
if err != nil {
return nil, err
}
Expand All @@ -97,7 +101,10 @@ func (w *writer) createFungibleProposal(m msg.Message) (*proposal, error) {

func (w *writer) createNonFungibleProposal(m msg.Message) (*proposal, error) {
tokenId := types.NewU256(*big.NewInt(0).SetBytes(m.Payload[0].([]byte)))
recipient := types.NewAccountID(m.Payload[1].([]byte))
recipient, err := types.NewAccountID(m.Payload[1].([]byte))
if err != nil {
return nil, err
}
metadata := types.Bytes(m.Payload[2].([]byte))
depositNonce := types.U64(m.DepositNonce)

Expand All @@ -118,7 +125,7 @@ func (w *writer) createNonFungibleProposal(m msg.Message) (*proposal, error) {
return nil, err
}
if w.extendCall {
eRID, err := types.Encode(m.ResourceId)
eRID, err := codec.Encode(m.ResourceId)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -150,7 +157,7 @@ func (w *writer) createGenericProposal(m msg.Message) (*proposal, error) {
return nil, err
}
if w.extendCall {
eRID, err := types.Encode(m.ResourceId)
eRID, err := codec.Encode(m.ResourceId)
if err != nil {
return nil, err
}
Expand Down
11 changes: 8 additions & 3 deletions chains/substrate/writer.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"bytes"
"errors"
"fmt"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"time"

"github.com/centrifuge/chainbridge-utils/core"
Expand Down Expand Up @@ -112,7 +113,7 @@ func (w *writer) resolveResourceId(id [32]byte) (string, error) {
// has not voted, it will return true. Otherwise, it will return false with a reason string.
func (w *writer) proposalValid(prop *proposal) (bool, string, error) {
var voteRes voteState
srcId, err := types.Encode(prop.sourceId)
srcId, err := codec.Encode(prop.sourceId)
if err != nil {
return false, "", err
}
Expand All @@ -128,8 +129,12 @@ func (w *writer) proposalValid(prop *proposal) (bool, string, error) {
if !exists {
return true, "", nil
} else if voteRes.Status.IsActive {
if containsVote(voteRes.VotesFor, types.NewAccountID(w.conn.key.PublicKey)) ||
containsVote(voteRes.VotesAgainst, types.NewAccountID(w.conn.key.PublicKey)) {
accountID, err := types.NewAccountID(w.conn.key.PublicKey)
if err != nil {
return false, "", err
}
if containsVote(voteRes.VotesFor, *accountID) ||
containsVote(voteRes.VotesAgainst, *accountID) {
return false, "already voted", nil
} else {
return true, "", nil
Expand Down
23 changes: 17 additions & 6 deletions e2e/substrate/substrate.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ package substrate

import (
"fmt"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"golang.org/x/crypto/blake2b"
"os"
"testing"
"time"
Expand All @@ -30,9 +32,18 @@ var DaveKp = keystore.TestKeyRing.SubstrateKeys[keystore.DaveKey]
var EveKp = keystore.TestKeyRing.SubstrateKeys[keystore.EveKey]

var RelayerSet = []types.AccountID{
types.NewAccountID(BobKp.AsKeyringPair().PublicKey),
types.NewAccountID(CharlieKp.AsKeyringPair().PublicKey),
types.NewAccountID(DaveKp.AsKeyringPair().PublicKey),
*MustRetrieveAccountID(BobKp.AsKeyringPair().PublicKey),
*MustRetrieveAccountID(CharlieKp.AsKeyringPair().PublicKey),
*MustRetrieveAccountID(DaveKp.AsKeyringPair().PublicKey),
}

func MustRetrieveAccountID(pubKey []byte) *types.AccountID {
accID, err := types.NewAccountID(pubKey)
if err != nil {
panic(fmt.Errorf("couldn't create new account ID: %w", err))
}

return accID
}

func CreateConfig(key string, chain msg.ChainId) *core.ChainConfig {
Expand Down Expand Up @@ -68,7 +79,7 @@ func WaitForProposalSuccessOrFail(t *testing.T, client *utils.Client, nonce type
t.Fatalf("Timed out waiting for proposal success/fail event")
case set := <-sub.Chan():
for _, chng := range set.Changes {
if !types.Eq(chng.StorageKey, key) || !chng.HasStorageData {
if !codec.Eq(chng.StorageKey, key) || !chng.HasStorageData {
// skip, we are only interested in events with content
continue
}
Expand Down Expand Up @@ -104,9 +115,9 @@ func WaitForProposalSuccessOrFail(t *testing.T, client *utils.Client, nonce type
}

func HashInt(i int) types.Hash {
hash, err := types.GetHash(types.NewI64(int64(i)))
bytes, err := codec.Encode(types.NewI64(int64(i)))
if err != nil {
panic(err)
}
return hash
return blake2b.Sum256(bytes)
}
9 changes: 4 additions & 5 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,25 +5,25 @@ go 1.18
// 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.5-0.20220804161806-770d7e202e80
require github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.8-0.20220930212708-8350785ebd6f

require (
github.com/ChainSafe/log15 v1.0.0
github.com/centrifuge/chain-custom-types v0.0.0-20220323235722-1cdf9a3ad7f1
github.com/centrifuge/chainbridge-substrate-events v0.0.0-20220215222726-8c1d3a5cad10
github.com/centrifuge/chainbridge-utils v1.1.0
github.com/centrifuge/chainbridge-utils v1.1.1-0.20221001051926-ecac2af5cb68
github.com/ethereum/go-ethereum v1.10.17
github.com/prometheus/client_golang v1.4.1
github.com/stretchr/testify v1.7.0
github.com/urfave/cli/v2 v2.3.0
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be
)

require (
github.com/ChainSafe/go-schnorrkel v1.0.0 // indirect
github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/btcsuite/btcd/btcec/v2 v2.1.2 // indirect
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 // indirect
github.com/cespare/xxhash/v2 v2.1.1 // indirect
github.com/cosmos/go-bip39 v1.0.0 // indirect
github.com/cpuguy83/go-md2man/v2 v2.0.0-20190314233015-f79a8a8ca69d // indirect
Expand Down Expand Up @@ -56,8 +56,7 @@ require (
github.com/tklauser/go-sysconf v0.3.5 // indirect
github.com/tklauser/numcpus v0.2.2 // indirect
github.com/vedhavyas/go-subkey v1.0.3 // indirect
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 // indirect
golang.org/x/sys v0.0.0-20220913175220-63ea55921009 // indirect
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec // indirect
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 // indirect
google.golang.org/protobuf v1.23.0 // indirect
gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect
Expand Down
20 changes: 10 additions & 10 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -56,22 +56,22 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
github.com/bmizerany/pat v0.0.0-20170815010413-6226ea591a40/go.mod h1:8rLXio+WjiTceGBHIoTvn60HIbs7Hm7bcHjyrSqYB9c=
github.com/boltdb/bolt v1.3.1/go.mod h1:clJnj/oiGkjum5o1McbSZDSLxVThjynRyGBgiAx27Ps=
github.com/btcsuite/btcd v0.22.1 h1:CnwP9LM/M9xuRrGSCGeMVs9iv09uMqwsVX7EeIpgV2c=
github.com/btcsuite/btcd/btcec/v2 v2.1.2 h1:YoYoC9J0jwfukodSBMzZYUVQ8PTiYg4BnOWiJVzTmLs=
github.com/btcsuite/btcd/btcec/v2 v2.1.2/go.mod h1:ctjw4H1kknNJmRN4iP1R7bTQ+v3GJkZBd6mui8ZsAZE=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0 h1:MSskdM4/xJYcFzy0altH/C/xHopifpWzHUi1JeVI34Q=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.0/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U=
github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc=
github.com/btcsuite/btcutil v1.0.3-0.20201208143702-a53e38424cce h1:YtWJF7RHm2pYCvA5t0RPmAaLUhREsKuKd+SLhxFbFeQ=
github.com/c-bata/go-prompt v0.2.2/go.mod h1:VzqtzE2ksDBcdln8G7mk2RX9QyGjH+OVqOCSiVIqS34=
github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU=
github.com/centrifuge/chain-custom-types v0.0.0-20220323235722-1cdf9a3ad7f1 h1:i72MKnaZ//Nw9T1bJT4PdpfXGfKGckzkHHf97FKyRDI=
github.com/centrifuge/chain-custom-types v0.0.0-20220323235722-1cdf9a3ad7f1/go.mod h1:E+MHt0riACBcD/pPctnW6h6BLNa5BRWF49uz31yFUfQ=
github.com/centrifuge/chainbridge-substrate-events v0.0.0-20220215222726-8c1d3a5cad10 h1:KNpThzo0t8/jpOiY3b2IWSpvksev0XKIR+8mxbNU0zY=
github.com/centrifuge/chainbridge-substrate-events v0.0.0-20220215222726-8c1d3a5cad10/go.mod h1:e5ffvnL405ZXm5n2inQQqDeIWpa6o7FNRwx1QQC8mWo=
github.com/centrifuge/chainbridge-utils v1.1.0 h1:YfzGEPf4ClT2x2gftDErhKb0NYM6isxUQM/kY3QTNLs=
github.com/centrifuge/chainbridge-utils v1.1.0/go.mod h1:2T2eFtxy3pDZhk+QlpwV4a5lV+lDzwazAWr8hFmKyaE=
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.5-0.20220804161806-770d7e202e80 h1:tycAEX8nz8Xf1LcjGQVeivtM4GOz5zy3ZuW9OLyuRQk=
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.5-0.20220804161806-770d7e202e80/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE=
github.com/centrifuge/chainbridge-utils v1.1.1-0.20221001051926-ecac2af5cb68 h1:DAm8uyQPQnk8DrV0/BHzzPGiOcK3tL1RRHaX9eqY54U=
github.com/centrifuge/chainbridge-utils v1.1.1-0.20221001051926-ecac2af5cb68/go.mod h1:j5KH69eOiNMy9HCTLj8qABZ4/Lx4SIP29JcPtyA1Neo=
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.8-0.20220930212708-8350785ebd6f h1:ViqBO7wRWBLsBHQlDwohHFDPetUUGsGk8KujnnqPzNo=
github.com/centrifuge/go-substrate-rpc-client/v4 v4.0.8-0.20220930212708-8350785ebd6f/go.mod h1:5g1oM4Zu3BOaLpsKQ+O8PAv2kNuq+kPcA1VzFbsSqxE=
github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk=
github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s=
github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc=
Expand Down Expand Up @@ -430,8 +430,8 @@ golang.org/x/crypto v0.0.0-20200728195943-123391ffb6de/go.mod h1:LzIPMQfyMNhhGPh
golang.org/x/crypto v0.0.0-20200820211705-5c72a883971a/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
golang.org/x/crypto v0.0.0-20201221181555-eec23a3978ad/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I=
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2/go.mod h1:T9bdIzuCu7OtxOm1hfPfRQxPLYneinmdGuTeoZ9dtd4=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90 h1:Y/gsMcFOcR+6S6f3YeMKl5g+dZMEWqcz5Czj/GWYbkM=
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be h1:fmw3UbQh+nxngCAHrDCCztao/kbYFnWjoqop8dHx05A=
golang.org/x/crypto v0.0.0-20220926161630-eccd6366d1be/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA=
Expand Down Expand Up @@ -538,8 +538,8 @@ golang.org/x/sys v0.0.0-20210324051608-47abb6519492/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20210420205809-ac73e9fd8988/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210816183151-1e6c022a8912/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220913175220-63ea55921009 h1:PuvuRMeLWqsf/ZdT1UUZz0syhioyv1mzuFZsXs4fvhw=
golang.org/x/sys v0.0.0-20220913175220-63ea55921009/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec h1:BkDtF2Ih9xZ7le9ndzTA7KJow28VbQW3odyk/8drmuI=
golang.org/x/sys v0.0.0-20220928140112-f11e5e49a4ec/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/term v0.0.0-20210503060354-a79de5458b56 h1:b8jxX3zqjpqb2LklXPzKSGJhzyxCOZSz8ncv8Nv+y7w=
Expand Down
11 changes: 8 additions & 3 deletions shared/substrate/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package utils

import (
"fmt"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"math/big"

"github.com/ChainSafe/log15"
Expand Down Expand Up @@ -141,12 +142,16 @@ func (c *Client) LatestBlock() (uint64, error) {

func (c *Client) MintErc721(tokenId *big.Int, metadata []byte, recipient *signature.KeyringPair) error {
fmt.Printf("Mint info: account %x amount: %x meta: %x\n", recipient.PublicKey, types.NewU256(*tokenId), types.Bytes(metadata))
return SubmitSudoTx(c, Erc721MintMethod, types.NewAccountID(recipient.PublicKey), types.NewU256(*tokenId), types.Bytes(metadata))
accID, err := types.NewAccountID(recipient.PublicKey)
if err != nil {
return fmt.Errorf("couldn't create account id: %w", err)
}
return SubmitSudoTx(c, Erc721MintMethod, accID, types.NewU256(*tokenId), types.Bytes(metadata))
}

func (c *Client) OwnerOf(tokenId *big.Int) (types.AccountID, error) {
var owner types.AccountID
tokenIdBz, err := types.Encode(types.NewU256(*tokenId))
tokenIdBz, err := codec.Encode(types.NewU256(*tokenId))
if err != nil {
return types.AccountID{}, err
}
Expand All @@ -163,7 +168,7 @@ func (c *Client) OwnerOf(tokenId *big.Int) (types.AccountID, error) {

func (c *Client) GetDepositNonce(chain msg.ChainId) (uint64, error) {
var count types.U64
chainId, err := types.Encode(types.U8(chain))
chainId, err := codec.Encode(types.U8(chain))
if err != nil {
return 0, err
}
Expand Down
36 changes: 36 additions & 0 deletions shared/substrate/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,38 @@ type EventRegistryTmp struct {
Topics []types.Hash
}

// EventFeesFeeChanged is emitted when a new fee has been set for a key
type EventFeesFeeChanged struct {
Phase types.Phase
Key types.U8
Fee types.U128
Topics []types.Hash
}

// EventFeesFeeToAuthor is emitted when a fee has been sent to the block author
type EventFeesFeeToAuthor struct {
Phase types.Phase
From types.AccountID
Balance types.U128
Topics []types.Hash
}

// EventFeesFeeToBurn is emitted when a fee has been burnt
type EventFeesFeeToBurn struct {
Phase types.Phase
From types.AccountID
Balance types.U128
Topics []types.Hash
}

// EventFeesFeeToTreasury is emitted when a fee has been sent to the treasury
type EventFeesFeeToTreasury struct {
Phase types.Phase
From types.AccountID
Balance types.U128
Topics []types.Hash
}

type cEvents = centEvents.Events
type Events struct {
types.EventRecords
Expand All @@ -182,4 +214,8 @@ type Events struct {
Registry_Mint []EventRegistryMint //nolint:stylecheck,golint
Registry_RegistryCreated []EventRegistryRegistryCreated //nolint:stylecheck,golint
Registry_RegistryTmp []EventRegistryTmp //nolint:stylecheck,golint
Fees_FeeChanged []EventFeesFeeChanged //nolint:stylecheck,golint
Fees_FeeToAuthor []EventFeesFeeToAuthor //nolint:stylecheck,golint
Fees_FeeToBurn []EventFeesFeeToBurn //nolint:stylecheck,golint
Fees_FeeToTreasury []EventFeesFeeToTreasury //nolint:stylecheck,golint
}
5 changes: 3 additions & 2 deletions shared/substrate/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package utils

import (
"fmt"
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"math/big"

"github.com/centrifuge/go-substrate-rpc-client/v4/types"
Expand All @@ -24,7 +25,7 @@ func getConst(meta *types.Metadata, prefix, name string, res interface{}) error
if string(mod.Name) == prefix {
for _, cons := range mod.Constants {
if string(cons.Name) == name {
return types.Decode(cons.Value, res)
return codec.Decode(cons.Value, res)
}
}
}
Expand Down Expand Up @@ -56,7 +57,7 @@ func BalanceOf(client *Client, publicKey []byte) (*big.Int, error) {

func GetErc721Token(client *Client, id types.U256) (*Erc721Token, error) {
var res Erc721Token
tokenIdBz, err := types.Encode(id)
tokenIdBz, err := codec.Encode(id)
if err != nil {
return nil, err
}
Expand Down
3 changes: 2 additions & 1 deletion shared/substrate/testing/events.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package subtest

import (
"github.com/centrifuge/go-substrate-rpc-client/v4/types/codec"
"testing"
"time"

Expand Down Expand Up @@ -32,7 +33,7 @@ func WaitForRemarkEvent(t *testing.T, client *utils.Client, hash types.Hash) {
t.Fatalf("Timed out waiting for proposal success/fail event")
case set := <-sub.Chan():
for _, chng := range set.Changes {
if !types.Eq(chng.StorageKey, key) || !chng.HasStorageData {
if !codec.Eq(chng.StorageKey, key) || !chng.HasStorageData {
// skip, we are only interested in events with content
continue
}
Expand Down

0 comments on commit 3e4e4c0

Please sign in to comment.