(_bytes)
| 21 | * Encodes the Bytes32-encoded %%bytes%% into a string. |
| 22 | */ |
| 23 | export function decodeBytes32String(_bytes) { |
| 24 | const data = getBytes(_bytes, "bytes"); |
| 25 | // Must be 32 bytes with a null-termination |
| 26 | if (data.length !== 32) { |
| 27 | throw new Error("invalid bytes32 - not 32 bytes long"); |
| 28 | } |
| 29 | if (data[31] !== 0) { |
| 30 | throw new Error("invalid bytes32 string - no null terminator"); |
| 31 | } |
| 32 | // Find the null termination |
| 33 | let length = 31; |
| 34 | while (data[length - 1] === 0) { |
| 35 | length--; |
| 36 | } |
| 37 | // Determine the string value |
| 38 | return toUtf8String(data.slice(0, length)); |
| 39 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…