Exemplo n.º 1
0
func (args *NewSigArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}

	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	// Check for sufficient params
	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	from, ok := obj[0].(string)
	if !ok {
		return shared.NewInvalidTypeError("from", "not a string")
	}
	args.From = from

	if len(args.From) == 0 {
		return shared.NewValidationError("from", "is required")
	}

	data, ok := obj[1].(string)
	if !ok {
		return shared.NewInvalidTypeError("data", "not a string")
	}
	args.Data = data

	if len(args.Data) == 0 {
		return shared.NewValidationError("data", "is required")
	}

	return nil
}
Exemplo n.º 2
0
func (args *DbHexArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 2 {
		return shared.NewInsufficientParamsError(len(obj), 2)
	}

	var objstr string
	var ok bool

	if objstr, ok = obj[0].(string); !ok {
		return shared.NewInvalidTypeError("database", "not a string")
	}
	args.Database = objstr

	if objstr, ok = obj[1].(string); !ok {
		return shared.NewInvalidTypeError("key", "not a string")
	}
	args.Key = objstr

	if len(obj) > 2 {
		objstr, ok = obj[2].(string)
		if !ok {
			return shared.NewInvalidTypeError("value", "not a string")
		}

		args.Value = common.FromHex(objstr)
	}

	return nil
}
Exemplo n.º 3
0
func (args *GetStorageArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	addstr, ok := obj[0].(string)
	if !ok {
		return shared.NewInvalidTypeError("address", "not a string")
	}
	args.Address = addstr

	if len(obj) > 1 {
		if err := blockHeight(obj[1], &args.BlockNumber); err != nil {
			return err
		}
	} else {
		args.BlockNumber = -1
	}

	return nil
}
Exemplo n.º 4
0
func (args *HttpGetArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if len(obj) >= 1 {
		if uri, ok := obj[0].(string); ok {
			args.Uri = uri
		} else {
			return shared.NewInvalidTypeError("Uri", "not a string")
		}
	}

	if len(obj) >= 2 && obj[1] != nil {
		if path, ok := obj[1].(string); ok {
			args.Path = path
		} else {
			return shared.NewInvalidTypeError("Path", "not a string")
		}
	}

	return nil
}
Exemplo n.º 5
0
func (args *UnlockAccountArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	args.Duration = 0

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if addrstr, ok := obj[0].(string); ok {
		args.Address = addrstr
	} else {
		return shared.NewInvalidTypeError("address", "not a string")
	}

	if len(obj) >= 2 && obj[1] != nil {
		if passphrasestr, ok := obj[1].(string); ok {
			args.Passphrase = passphrasestr
		} else {
			return shared.NewInvalidTypeError("passphrase", "not a string")
		}
	}

	if len(obj) >= 3 && obj[2] != nil {
		if duration, ok := obj[2].(float64); ok {
			args.Duration = int(duration)
		}
	}

	return nil
}
Exemplo n.º 6
0
func (args *WhisperMessageArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []struct {
		Payload  string
		To       string
		From     string
		Topics   []string
		Priority interface{}
		Ttl      interface{}
	}

	if err = json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}
	args.Payload = obj[0].Payload
	args.To = obj[0].To
	args.From = obj[0].From
	args.Topics = obj[0].Topics

	var num *big.Int
	if num, err = numString(obj[0].Priority); err != nil {
		return err
	}
	args.Priority = uint32(num.Int64())

	if num, err = numString(obj[0].Ttl); err != nil {
		return err
	}
	args.Ttl = uint32(num.Int64())

	return nil
}
Exemplo n.º 7
0
func (args *SaveInfoArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 2 {
		return shared.NewInsufficientParamsError(len(obj), 2)
	}

	if jsonraw, err := json.Marshal(obj[0]); err == nil {
		if err = json.Unmarshal(jsonraw, &args.ContractInfo); err != nil {
			return err
		}
	} else {
		return err
	}

	if filename, ok := obj[1].(string); ok {
		args.Filename = filename
	} else {
		return shared.NewInvalidTypeError("Filename", "not a string")
	}

	return nil
}
Exemplo n.º 8
0
func (args *SubmitHashRateArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 2 {
		return shared.NewInsufficientParamsError(len(obj), 2)
	}

	arg0, ok := obj[0].(string)
	if !ok {
		return shared.NewInvalidTypeError("hash", "not a string")
	}
	args.Id = arg0

	arg1, ok := obj[1].(string)
	if !ok {
		return shared.NewInvalidTypeError("rate", "not a string")
	}

	args.Rate = common.String2Big(arg1).Uint64()

	return nil
}
Exemplo n.º 9
0
func (args *ListTransactionsArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	other, ok := obj[0].([]interface{})
	if !ok {
		other = obj
		ok = true
	}

	if ok {
		args.Accounts = make([]string, len(other))
		for i, acct := range other {
			if args.Accounts[i], ok = acct.(string); !ok {
				return shared.NewInvalidTypeError("accounts", "not a string array2")
			}
		}
		return nil
	}

	return shared.NewInvalidTypeError("accounts", "not a string array1")
}
Exemplo n.º 10
0
func (args *SubmitWorkArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err = json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 3 {
		return shared.NewInsufficientParamsError(len(obj), 3)
	}

	var objstr string
	var ok bool
	if objstr, ok = obj[0].(string); !ok {
		return shared.NewInvalidTypeError("nonce", "not a string")
	}

	args.Nonce = common.String2Big(objstr).Uint64()
	if objstr, ok = obj[1].(string); !ok {
		return shared.NewInvalidTypeError("header", "not a string")
	}

	args.Header = objstr

	if objstr, ok = obj[2].(string); !ok {
		return shared.NewInvalidTypeError("digest", "not a string")
	}

	args.Digest = objstr

	return nil
}
Exemplo n.º 11
0
func (args *ResendArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err = json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	data, err := json.Marshal(obj[0])
	if err != nil {
		return shared.NewDecodeParamError("Unable to parse transaction object")
	}

	trans := new(tx)
	err = json.Unmarshal(data, trans)
	if err != nil {
		return shared.NewDecodeParamError("Unable to parse transaction object")
	}

	if trans == nil || trans.tx == nil {
		return shared.NewDecodeParamError("Unable to parse transaction object")
	}

	gasLimit, gasPrice := trans.GasLimit, trans.GasPrice

	if len(obj) > 1 && obj[1] != nil {
		if gp, ok := obj[1].(string); ok {
			gasPrice = gp
		} else {
			return shared.NewInvalidTypeError("gasPrice", "not a string")
		}
	}
	if len(obj) > 2 && obj[2] != nil {
		if gl, ok := obj[2].(string); ok {
			gasLimit = gl
		} else {
			return shared.NewInvalidTypeError("gasLimit", "not a string")
		}
	}

	args.Tx = trans
	args.GasPrice = gasPrice
	args.GasLimit = gasLimit

	return nil
}
Exemplo n.º 12
0
func (args *BlockNumArg) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if err := blockHeight(obj[0], &args.BlockNumber); err != nil {
		return err
	}

	return nil
}
Exemplo n.º 13
0
func (args *NewAccountArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if passhrase, ok := obj[0].(string); ok {
		args.Passphrase = passhrase
		return nil
	}

	return shared.NewInvalidTypeError("passhrase", "not a string")
}
Exemplo n.º 14
0
func (args *GasPriceArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if pricestr, ok := obj[0].(string); ok {
		args.Price = pricestr
		return nil
	}

	return shared.NewInvalidTypeError("Price", "not a string")
}
Exemplo n.º 15
0
func (args *CompileArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}
	argstr, ok := obj[0].(string)
	if !ok {
		return shared.NewInvalidTypeError("arg0", "is not a string")
	}
	args.Source = argstr

	return nil
}
Exemplo n.º 16
0
func (args *FilterIdArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	var num *big.Int
	if num, err = numString(obj[0]); err != nil {
		return err
	}
	args.Id = int(num.Int64())

	return nil
}
Exemplo n.º 17
0
func (args *GetBlockByNumberArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 2 {
		return shared.NewInsufficientParamsError(len(obj), 2)
	}

	if err := blockHeight(obj[0], &args.BlockNumber); err != nil {
		return err
	}

	args.IncludeTxs = obj[1].(bool)

	return nil
}
Exemplo n.º 18
0
func (args *IsAccountLockedArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if addrstr, ok := obj[0].(string); ok {
		args.Address = addrstr
	} else {
		return shared.NewInvalidTypeError("address", "not a string")
	}

	return nil
}
Exemplo n.º 19
0
func (args *SleepArgs) UnmarshalJSON(b []byte) (err error) {

	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}
	if len(obj) >= 1 {
		if obj[0] != nil {
			if n, err := numString(obj[0]); err == nil {
				args.S = int(n.Int64())
			} else {
				return shared.NewInvalidTypeError("N", "not an integer: "+err.Error())
			}
		} else {
			return shared.NewInsufficientParamsError(0, 1)
		}
	}
	return nil
}
Exemplo n.º 20
0
func (args *SetEtherbaseArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if addr, ok := obj[0].(string); ok {
		args.Etherbase = common.HexToAddress(addr)
		if (args.Etherbase == common.Address{}) {
			return shared.NewInvalidTypeError("Shiftbase", "not a valid address")
		}
		return nil
	}

	return shared.NewInvalidTypeError("Shiftbase", "not a string")
}
Exemplo n.º 21
0
func (args *GetContractInfoArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	if len(obj) >= 1 {
		if contract, ok := obj[0].(string); ok {
			args.Contract = contract
		} else {
			return shared.NewInvalidTypeError("Contract", "not a string")
		}
	}

	return nil
}
Exemplo n.º 22
0
func (args *GetBlockByHashArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}

	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 2 {
		return shared.NewInsufficientParamsError(len(obj), 2)
	}

	argstr, ok := obj[0].(string)
	if !ok {
		return shared.NewInvalidTypeError("blockHash", "not a string")
	}
	args.BlockHash = argstr

	args.IncludeTxs = obj[1].(bool)

	return nil
}
Exemplo n.º 23
0
func (args *BlockNumIndexArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 2 {
		return shared.NewInsufficientParamsError(len(obj), 2)
	}

	if err := blockHeight(obj[0], &args.BlockNumber); err != nil {
		return err
	}

	var arg1 *big.Int
	if arg1, err = numString(obj[1]); err != nil {
		return err
	}
	args.Index = arg1.Int64()

	return nil
}
Exemplo n.º 24
0
func (args *DeleteAccountArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 2 {
		return shared.NewInsufficientParamsError(len(obj), 2)
	}

	if addr, ok := obj[0].(string); ok {
		args.Address = addr
	} else {
		return shared.NewInvalidTypeError("address", "not a string")
	}

	if passhrase, ok := obj[1].(string); ok {
		args.Passphrase = passhrase
	} else {
		return shared.NewInvalidTypeError("passhrase", "not a string")
	}

	return nil
}
Exemplo n.º 25
0
func (args *RegisterArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 3 {
		return shared.NewInsufficientParamsError(len(obj), 3)
	}

	if len(obj) >= 1 {
		if sender, ok := obj[0].(string); ok {
			args.Sender = sender
		} else {
			return shared.NewInvalidTypeError("Sender", "not a string")
		}
	}

	if len(obj) >= 2 {
		if address, ok := obj[1].(string); ok {
			args.Address = address
		} else {
			return shared.NewInvalidTypeError("Address", "not a string")
		}
	}

	if len(obj) >= 3 {
		if hex, ok := obj[2].(string); ok {
			args.ContentHashHex = hex
		} else {
			return shared.NewInvalidTypeError("ContentHashHex", "not a string")
		}
	}

	return nil
}
Exemplo n.º 26
0
func (args *FilterStringArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []interface{}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	var argstr string
	argstr, ok := obj[0].(string)
	if !ok {
		return shared.NewInvalidTypeError("filter", "not a string")
	}
	switch argstr {
	case "latest", "pending":
		break
	default:
		return shared.NewValidationError("Word", "Must be `latest` or `pending`")
	}
	args.Word = argstr
	return nil
}
Exemplo n.º 27
0
func (args *CallArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []json.RawMessage
	var ext struct {
		From     string
		To       string
		Value    interface{}
		Gas      interface{}
		GasPrice interface{}
		Data     string
	}

	// Decode byte slice to array of RawMessages
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	// Check for sufficient params
	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	// Decode 0th RawMessage to temporary struct
	if err := json.Unmarshal(obj[0], &ext); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	args.From = ext.From
	args.To = ext.To

	var num *big.Int
	if ext.Value == nil {
		num = big.NewInt(0)
	} else {
		if num, err = numString(ext.Value); err != nil {
			return err
		}
	}
	args.Value = num

	if ext.Gas != nil {
		if num, err = numString(ext.Gas); err != nil {
			return err
		}
	} else {
		num = nil
	}
	args.Gas = num

	if ext.GasPrice != nil {
		if num, err = numString(ext.GasPrice); err != nil {
			return err
		}
	} else {
		num = nil
	}
	args.GasPrice = num

	args.Data = ext.Data

	// Check for optional BlockNumber param
	if len(obj) > 1 {
		if err := blockHeightFromJson(obj[1], &args.BlockNumber); err != nil {
			return err
		}
	} else {
		args.BlockNumber = -1
	}

	return nil
}
Exemplo n.º 28
0
func (args *BlockFilterArgs) UnmarshalJSON(b []byte) (err error) {
	var obj []struct {
		FromBlock interface{} `json:"fromBlock"`
		ToBlock   interface{} `json:"toBlock"`
		Limit     interface{} `json:"limit"`
		Offset    interface{} `json:"offset"`
		Address   interface{} `json:"address"`
		Topics    interface{} `json:"topics"`
	}

	if err = json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}

	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}

	// args.Earliest, err = toNumber(obj[0].ToBlock)
	// if err != nil {
	// 	return shared.NewDecodeParamError(fmt.Sprintf("FromBlock %v", err))
	// }
	// args.Latest, err = toNumber(obj[0].FromBlock)
	// if err != nil {
	// 	return shared.NewDecodeParamError(fmt.Sprintf("ToBlock %v", err))

	var num int64
	var numBig *big.Int

	// if blank then latest
	if obj[0].FromBlock == nil {
		num = -1
	} else {
		if err := blockHeight(obj[0].FromBlock, &num); err != nil {
			return err
		}
	}
	// if -2 or other "silly" number, use latest
	if num < 0 {
		args.Earliest = -1 //latest block
	} else {
		args.Earliest = num
	}

	// if blank than latest
	if obj[0].ToBlock == nil {
		num = -1
	} else {
		if err := blockHeight(obj[0].ToBlock, &num); err != nil {
			return err
		}
	}
	args.Latest = num

	if obj[0].Limit == nil {
		numBig = big.NewInt(defaultLogLimit)
	} else {
		if numBig, err = numString(obj[0].Limit); err != nil {
			return err
		}
	}
	args.Max = int(numBig.Int64())

	if obj[0].Offset == nil {
		numBig = big.NewInt(defaultLogOffset)
	} else {
		if numBig, err = numString(obj[0].Offset); err != nil {
			return err
		}
	}
	args.Skip = int(numBig.Int64())

	if obj[0].Address != nil {
		marg, ok := obj[0].Address.([]interface{})
		if ok {
			v := make([]string, len(marg))
			for i, arg := range marg {
				argstr, ok := arg.(string)
				if !ok {
					return shared.NewInvalidTypeError(fmt.Sprintf("address[%d]", i), "is not a string")
				}
				v[i] = argstr
			}
			args.Address = v
		} else {
			argstr, ok := obj[0].Address.(string)
			if ok {
				v := make([]string, 1)
				v[0] = argstr
				args.Address = v
			} else {
				return shared.NewInvalidTypeError("address", "is not a string or array")
			}
		}
	}

	if obj[0].Topics != nil {
		other, ok := obj[0].Topics.([]interface{})
		if ok {
			topicdbl := make([][]string, len(other))
			for i, iv := range other {
				if argstr, ok := iv.(string); ok {
					// Found a string, push into first element of array
					topicsgl := make([]string, 1)
					topicsgl[0] = argstr
					topicdbl[i] = topicsgl
				} else if argarray, ok := iv.([]interface{}); ok {
					// Found an array of other
					topicdbl[i] = make([]string, len(argarray))
					for j, jv := range argarray {
						if v, ok := jv.(string); ok {
							topicdbl[i][j] = v
						} else if jv == nil {
							topicdbl[i][j] = ""
						} else {
							return shared.NewInvalidTypeError(fmt.Sprintf("topic[%d][%d]", i, j), "is not a string")
						}
					}
				} else if iv == nil {
					topicdbl[i] = []string{""}
				} else {
					return shared.NewInvalidTypeError(fmt.Sprintf("topic[%d]", i), "not a string or array")
				}
			}
			args.Topics = topicdbl
			return nil
		} else {
			return shared.NewInvalidTypeError("topic", "is not a string or array")
		}
	}

	return nil
}
Exemplo n.º 29
0
// UnmarshalJSON implements the json.Unmarshaler interface, invoked to convert a
// JSON message blob into a WhisperFilterArgs structure.
func (args *WhisperFilterArgs) UnmarshalJSON(b []byte) (err error) {
	// Unmarshal the JSON message and sanity check
	var obj []struct {
		To     interface{} `json:"to"`
		From   interface{} `json:"from"`
		Topics interface{} `json:"topics"`
	}
	if err := json.Unmarshal(b, &obj); err != nil {
		return shared.NewDecodeParamError(err.Error())
	}
	if len(obj) < 1 {
		return shared.NewInsufficientParamsError(len(obj), 1)
	}
	// Retrieve the simple data contents of the filter arguments
	if obj[0].To == nil {
		args.To = ""
	} else {
		argstr, ok := obj[0].To.(string)
		if !ok {
			return shared.NewInvalidTypeError("to", "is not a string")
		}
		args.To = argstr
	}
	if obj[0].From == nil {
		args.From = ""
	} else {
		argstr, ok := obj[0].From.(string)
		if !ok {
			return shared.NewInvalidTypeError("from", "is not a string")
		}
		args.From = argstr
	}
	// Construct the nested topic array
	if obj[0].Topics != nil {
		// Make sure we have an actual topic array
		list, ok := obj[0].Topics.([]interface{})
		if !ok {
			return shared.NewInvalidTypeError("topics", "is not an array")
		}
		// Iterate over each topic and handle nil, string or array
		topics := make([][]string, len(list))
		for idx, field := range list {
			switch value := field.(type) {
			case nil:
				topics[idx] = []string{}

			case string:
				topics[idx] = []string{value}

			case []interface{}:
				topics[idx] = make([]string, len(value))
				for i, nested := range value {
					switch value := nested.(type) {
					case nil:
						topics[idx][i] = ""

					case string:
						topics[idx][i] = value

					default:
						return shared.NewInvalidTypeError(fmt.Sprintf("topic[%d][%d]", idx, i), "is not a string")
					}
				}
			default:
				return shared.NewInvalidTypeError(fmt.Sprintf("topic[%d]", idx), "not a string or array")
			}
		}
		args.Topics = topics
	}
	return nil
}