(source *common.ZeroCopySource)
| 112 | } |
| 113 | |
| 114 | func DecodeValue(source *common.ZeroCopySource) (interface{}, error) { |
| 115 | ty, eof := source.NextByte() |
| 116 | if eof { |
| 117 | return nil, ERROR_PARAM_FORMAT |
| 118 | } |
| 119 | |
| 120 | switch ty { |
| 121 | case ByteArrayType: |
| 122 | size, eof := source.NextUint32() |
| 123 | if eof { |
| 124 | return nil, ERROR_PARAM_FORMAT |
| 125 | } |
| 126 | |
| 127 | buf, eof := source.NextBytes(uint64(size)) |
| 128 | if eof { |
| 129 | return nil, ERROR_PARAM_FORMAT |
| 130 | } |
| 131 | |
| 132 | return buf, nil |
| 133 | case StringType: |
| 134 | size, eof := source.NextUint32() |
| 135 | if eof { |
| 136 | return nil, ERROR_PARAM_FORMAT |
| 137 | } |
| 138 | |
| 139 | buf, eof := source.NextBytes(uint64(size)) |
| 140 | if eof { |
| 141 | return nil, ERROR_PARAM_FORMAT |
| 142 | } |
| 143 | |
| 144 | return string(buf), nil |
| 145 | case AddressType: |
| 146 | addr, eof := source.NextAddress() |
| 147 | if eof { |
| 148 | return nil, ERROR_PARAM_FORMAT |
| 149 | } |
| 150 | |
| 151 | return addr, nil |
| 152 | case BooleanType: |
| 153 | by, irr, eof := source.NextBool() |
| 154 | if eof { |
| 155 | return nil, ERROR_PARAM_FORMAT |
| 156 | } |
| 157 | |
| 158 | if irr { |
| 159 | return nil, ERROR_PARAM_FORMAT |
| 160 | } |
| 161 | |
| 162 | return by, nil |
| 163 | case IntType: |
| 164 | val, eof := source.NextI128() |
| 165 | if eof { |
| 166 | return nil, ERROR_PARAM_FORMAT |
| 167 | } |
| 168 | |
| 169 | return val.ToBigInt(), nil |
| 170 | case H256Type: |
| 171 | hash, eof := source.NextHash() |
no test coverage detected