(writer: Writer, _value: BigNumberish | Typed)
| 33 | } |
| 34 | |
| 35 | encode(writer: Writer, _value: BigNumberish | Typed): number { |
| 36 | let value = getBigInt(Typed.dereference(_value, this.type)); |
| 37 | |
| 38 | // Check bounds are safe for encoding |
| 39 | let maxUintValue = mask(BN_MAX_UINT256, WordSize * 8); |
| 40 | if (this.signed) { |
| 41 | let bounds = mask(maxUintValue, (this.size * 8) - 1); |
| 42 | if (value > bounds || value < -(bounds + BN_1)) { |
| 43 | this._throwError("value out-of-bounds", _value); |
| 44 | } |
| 45 | value = toTwos(value, 8 * WordSize); |
| 46 | } else if (value < BN_0 || value > mask(maxUintValue, this.size * 8)) { |
| 47 | this._throwError("value out-of-bounds", _value); |
| 48 | } |
| 49 | |
| 50 | return writer.writeValue(value); |
| 51 | } |
| 52 | |
| 53 | decode(reader: Reader): any { |
| 54 | let value = mask(reader.readValue(), this.size * 8); |
nothing calls this directly
no test coverage detected