mirror of
https://github.com/eosswedenorg/thalos
synced 2026-07-03 11:53:41 +02:00
internal/ship/contract_row.go: adding DecodeContractRow that actually decodes data from abi
This commit is contained in:
parent
a892b40cde
commit
6d7d004b2b
1 changed files with 16 additions and 0 deletions
|
|
@ -1,6 +1,9 @@
|
||||||
package ship
|
package ship
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"bytes"
|
||||||
|
|
||||||
|
"github.com/eosswedenorg/thalos/internal/abi"
|
||||||
"github.com/mitchellh/mapstructure"
|
"github.com/mitchellh/mapstructure"
|
||||||
"github.com/shufflingpixels/antelope-go/chain"
|
"github.com/shufflingpixels/antelope-go/chain"
|
||||||
)
|
)
|
||||||
|
|
@ -19,3 +22,16 @@ func ParseContractRow(v map[string]interface{}) (*ContractRow, error) {
|
||||||
err := mapstructure.WeakDecode(v, out)
|
err := mapstructure.WeakDecode(v, out)
|
||||||
return out, err
|
return out, err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func DecodeContractRow(manager *abi.AbiManager, data map[string]any) (any, error) {
|
||||||
|
row, err := ParseContractRow(data)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
|
||||||
|
abi, err := manager.GetAbi(row.Code)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return abi.DecodeTable(bytes.NewReader(row.Value), row.Table)
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue