Unmarshal data with interface type then pass it to countBytesOfData.
- Count data in string or integer types.
package service
import (
+ "encoding/json"
"math/big"
"github.com/icon-project/goloop/common"
@@ -83,16 +84,20 @@ func (th *transactionHandler) Execute(wc WorldContext) (Receipt, error) {
th.cc.Setup(wc)
// Calculate common steps
+ var status module.Status
var stepUsed *big.Int
- status := module.Status(module.StatusSuccess)
+ var addr module.Address
+ var iData interface{}
+ if err := json.Unmarshal(th.data, &iData); err == nil {
+ status = module.StatusSuccess
+
if !th.handler.ApplySteps(wc, StepTypeDefault, 1) ||
- !th.handler.ApplySteps(wc, StepTypeInput, th.countBytesOfData(th.data)) {
+ !th.handler.ApplySteps(wc, StepTypeInput, th.countBytesOfData(iData)) {
status = module.StatusNotPayable
stepUsed = th.handler.StepLimit()
}
// Execute
- var addr module.Address
if status == module.StatusSuccess {
status, stepUsed, _, addr = th.cc.Call(th.handler)
@@ -104,6 +109,10 @@ func (th *transactionHandler) Execute(wc WorldContext) (Receipt, error) {
wc.Reset(wcs)
}
}
+ } else {
+ status = module.StatusSystemError
+ stepUsed = th.stepLimit
+ }
// Try to charge fee
stepPrice := wc.StepPrice()
