MCPcopy Create free account
hub / github.com/api3dao/airnode / castString32

Function castString32

packages/airnode-adapter/src/response-processing/casting.ts:82–88  ·  view source on GitHub ↗
(value: unknown)

Source from the content-addressed store, hash-verified

80}
81
82function castString32(value: unknown) {
83 assertValueIsNotArrayOrObject(value);
84
85 const strValue = String(value);
86 // We can't encode strings longer than 31 characters to bytes32. Ethers needs to keep room for null termination
87 return ethers.utils.formatBytes32String(strValue.length > 31 ? strValue.substring(0, 31) : strValue);
88}
89
90function createTimestamp() {
91 return new BigNumber(Math.floor(Date.now() / 1000)).toString();

Callers 1

castValueFunction · 0.85

Calls 1

Tested by

no test coverage detected