Skip to content

Commit

Permalink
chore (pkg/scale) integrate scale pkg into dot/rpc (#1678)
Browse files Browse the repository at this point in the history
* integrate scale into dot/sync

* integrate scale into dot/rpc

* scale into epoch

* integrate scale into pruner

* integrate scale pkg into dot/state

* WIP/Fix digest encoding errors

* remove changes in dot/state to include in separate PR
  • Loading branch information
jimjbrettj committed Jul 8, 2021
1 parent 1916f86 commit 6d38d76
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
7 changes: 4 additions & 3 deletions dot/rpc/modules/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/runtime"
"github.com/ChainSafe/gossamer/lib/scale"
"github.com/ChainSafe/gossamer/pkg/scale"
)

// StateCallRequest holds json fields
Expand Down Expand Up @@ -272,8 +272,9 @@ func (sm *StateModule) GetMetadata(r *http.Request, req *StateRuntimeMetadataQue
return err
}

decoded, err := scale.Decode(metadata, []byte{})
*res = StateMetadataResponse(common.BytesToHex(decoded.([]byte)))
var decoded []byte
err = scale.Unmarshal(metadata, &decoded)
*res = StateMetadataResponse(common.BytesToHex(decoded))
return err
}

Expand Down
7 changes: 4 additions & 3 deletions dot/rpc/modules/system.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

"github.com/ChainSafe/gossamer/lib/common"
"github.com/ChainSafe/gossamer/lib/crypto"
"github.com/ChainSafe/gossamer/lib/scale"
"github.com/ChainSafe/gossamer/pkg/scale"
ctypes "github.com/centrifuge/go-substrate-rpc-client/v3/types"
)

Expand Down Expand Up @@ -196,12 +196,13 @@ func (sm *SystemModule) AccountNextIndex(r *http.Request, req *StringRequest, re
if err != nil {
return err
}
sdMeta, err := scale.Decode(rawMeta, []byte{})
var sdMeta []byte
err = scale.Unmarshal(rawMeta, &sdMeta)
if err != nil {
return err
}
var metadata ctypes.Metadata
err = ctypes.DecodeFromBytes(sdMeta.([]byte), &metadata)
err = ctypes.DecodeFromBytes(sdMeta, &metadata)
if err != nil {
return err
}
Expand Down

0 comments on commit 6d38d76

Please sign in to comment.