Working tree is now the canonical repo. Off-chain play-money + trustless on-chain (FPMM AMM + CLOB via UMA settlement), AI market factory, creator/social/distribution, mobile shell + push, one-command demo + deploy-kit. Secrets excluded (see ENV-AND-KEYS.md). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
31 lines
648 B
JavaScript
31 lines
648 B
JavaScript
function toBytes32 (type, value) {
|
|
switch (type) {
|
|
case 'bytes32':
|
|
return value;
|
|
case 'uint256':
|
|
return `bytes32(${value})`;
|
|
case 'address':
|
|
return `bytes32(uint256(uint160(${value})))`;
|
|
default:
|
|
throw new Error(`Conversion from ${type} to bytes32 not supported`);
|
|
}
|
|
}
|
|
|
|
function fromBytes32 (type, value) {
|
|
switch (type) {
|
|
case 'bytes32':
|
|
return value;
|
|
case 'uint256':
|
|
return `uint256(${value})`;
|
|
case 'address':
|
|
return `address(uint160(uint256(${value})))`;
|
|
default:
|
|
throw new Error(`Conversion from bytes32 to ${type} not supported`);
|
|
}
|
|
}
|
|
|
|
module.exports = {
|
|
toBytes32,
|
|
fromBytes32,
|
|
};
|