Skip to content

Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.

1.5 KB
Raw Blame
const { capitalize, mapValues } = require('../../helpers');

const typeDescr = ({ type, size = 0, memory = false }) => {
  memory |= size > 0;

  const name = [type == 'uint256' ? 'Uint' : capitalize(type), size].filter(Boolean).join('x');
  const base = size ? type : undefined;
  const typeFull = size ? `${type}[${size}]` : type;
  const typeLoc = memory ? `${typeFull} memory` : typeFull;
  return { name, type: typeFull, typeLoc, base, size, memory };
};

const toSetTypeDescr = value => ({
  name: value.name + 'Set',
  value,
});

const toMapTypeDescr = ({ key, value }) => ({
  name: `${key.name}To${value.name}Map`,
  keySet: toSetTypeDescr(key),
  key,
  value,
});

const SET_TYPES = [
  { type: 'bytes32' },
  { type: 'bytes4' },
  { type: 'address' },
  { type: 'uint256' },
  { type: 'string', memory: true },
  { type: 'bytes', memory: true },
]
  .map(typeDescr)
  .map(toSetTypeDescr);

const MAP_TYPES = []
  .concat(
    // value type maps
    ['uint256', 'address', 'bytes32']
      .flatMap((keyType, _, array) => array.map(valueType => ({ key: { type: keyType }, value: { type: valueType } })))
      .slice(0, -1), // remove bytes32 → bytes32 (last one) that is already defined
    // other value type maps
    { key: { type: 'bytes4' }, value: { type: 'address' } },
    // non-value type maps
    { key: { type: 'bytes', memory: true }, value: { type: 'bytes', memory: true } },
  )
  .map(entry => mapValues(entry, typeDescr))
  .map(toMapTypeDescr);

module.exports = {
  SET_TYPES,
  MAP_TYPES,
  typeDescr,
  toSetTypeDescr,
  toMapTypeDescr,
};