itering / scale.go

Golang polkadot substrate scale codec
http://subscan.io
Apache License 2.0
63 stars 36 forks source link

Call indexes migth not start from 0 #71

Closed ioannist closed 2 years ago

ioannist commented 2 years ago

It looks like the library assumes call indexes always start from zero https://github.com/itering/scale.go/blob/105604dd710f7e758d589dbb0ef566c01c9542e6/types/v14.go#L74

However, this is not the case with all modules, see https://calamari.subscan.io/runtime/ParachainStaking?version=3410

Also, it seems that substrate does not enforce starting from 0 so the assumption is risky https://paritytech.github.io/substrate/master/frame_support/attr.pallet.html#palletcall_indexidx

This causes the library to error out when it tries to decode an extrinsic method that is out of index Not find Extrinsic Lookup 301a, please check metadata info

freehere107 commented 2 years ago

@ioannist Hi, this issue has been fixed in this commit https://github.com/itering/scale.go/commit/4b8a7d40f840d0abb966720f5e3901c14f61641b

modulesType[k].Calls this a arrays , Lookup call index use this https://github.com/itering/scale.go/blob/105604dd710f7e758d589dbb0ef566c01c9542e6/types/v14.go#L75