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