{"version":3,"sources":["../../src/protocol/eip712.ts"],"sourcesContent":["/**\n * EIP-712 domain and type builders for Data Portability protocol writes.\n *\n * These helpers are shared primitives only. Personal Server runtimes own when\n * to sign and submit these payloads.\n *\n * @category Protocol\n */\n\nimport type { TypedDataDomain } from \"viem\";\n\nconst DOMAIN_NAME = \"Vana Data Portability\";\nconst DOMAIN_VERSION = \"1\";\n\nexport interface DataPortabilityContracts {\n  dataRegistry: string;\n  dataPortabilityPermissions: string;\n  dataPortabilityServer: string;\n  dataPortabilityGrantees: string;\n}\n\nexport interface DataPortabilityGatewayConfig {\n  chainId: number;\n  contracts: DataPortabilityContracts;\n}\n\nfunction buildDomain(\n  chainId: number,\n  verifyingContract: `0x${string}`,\n): TypedDataDomain {\n  return {\n    name: DOMAIN_NAME,\n    version: DOMAIN_VERSION,\n    chainId,\n    verifyingContract,\n  };\n}\n\nexport function fileRegistrationDomain(\n  config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n  return buildDomain(\n    config.chainId,\n    config.contracts.dataRegistry as `0x${string}`,\n  );\n}\n\nexport function fileDeletionDomain(\n  config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n  return buildDomain(\n    config.chainId,\n    config.contracts.dataRegistry as `0x${string}`,\n  );\n}\n\nexport function grantRegistrationDomain(\n  config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n  return buildDomain(\n    config.chainId,\n    config.contracts.dataPortabilityPermissions as `0x${string}`,\n  );\n}\n\nexport function grantRevocationDomain(\n  config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n  return buildDomain(\n    config.chainId,\n    config.contracts.dataPortabilityPermissions as `0x${string}`,\n  );\n}\n\nexport function serverRegistrationDomain(\n  config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n  return buildDomain(\n    config.chainId,\n    config.contracts.dataPortabilityServer as `0x${string}`,\n  );\n}\n\nexport function builderRegistrationDomain(\n  config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n  return buildDomain(\n    config.chainId,\n    config.contracts.dataPortabilityGrantees as `0x${string}`,\n  );\n}\n\nexport const FILE_REGISTRATION_TYPES = {\n  FileRegistration: [\n    { name: \"ownerAddress\", type: \"address\" },\n    { name: \"url\", type: \"string\" },\n    { name: \"schemaId\", type: \"bytes32\" },\n  ],\n} as const;\n\nexport const FILE_DELETION_TYPES = {\n  FileDeletion: [\n    { name: \"ownerAddress\", type: \"address\" },\n    { name: \"fileId\", type: \"bytes32\" },\n  ],\n} as const;\n\nexport const GRANT_REGISTRATION_TYPES = {\n  GrantRegistration: [\n    { name: \"grantorAddress\", type: \"address\" },\n    { name: \"granteeId\", type: \"bytes32\" },\n    { name: \"grant\", type: \"string\" },\n    { name: \"fileIds\", type: \"uint256[]\" },\n  ],\n} as const;\n\nexport const GRANT_REVOCATION_TYPES = {\n  GrantRevocation: [\n    { name: \"grantorAddress\", type: \"address\" },\n    { name: \"grantId\", type: \"bytes32\" },\n  ],\n} as const;\n\nexport const SERVER_REGISTRATION_TYPES = {\n  ServerRegistration: [\n    { name: \"ownerAddress\", type: \"address\" },\n    { name: \"serverAddress\", type: \"address\" },\n    { name: \"publicKey\", type: \"string\" },\n    { name: \"serverUrl\", type: \"string\" },\n  ],\n} as const;\n\nexport const BUILDER_REGISTRATION_TYPES = {\n  BuilderRegistration: [\n    { name: \"ownerAddress\", type: \"address\" },\n    { name: \"granteeAddress\", type: \"address\" },\n    { name: \"publicKey\", type: \"string\" },\n    { name: \"appUrl\", type: \"string\" },\n  ],\n} as const;\n\nexport interface FileRegistrationMessage {\n  ownerAddress: `0x${string}`;\n  url: string;\n  schemaId: `0x${string}`;\n}\n\nexport interface FileDeletionMessage {\n  ownerAddress: `0x${string}`;\n  /**\n   * Off-chain gateway file ID — bytes32, as returned by `GET /v1/files`. This is NOT the on-chain\n   * uint256 DataRegistry file ID; consumers (e.g. the PS delete cascade) must source it from the\n   * gateway, not derive it from a numeric on-chain ID.\n   */\n  fileId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n  grantorAddress: `0x${string}`;\n  granteeId: `0x${string}`;\n  grant: string;\n  fileIds: bigint[];\n}\n\nexport interface GrantRevocationMessage {\n  grantorAddress: `0x${string}`;\n  grantId: `0x${string}`;\n}\n\nexport interface ServerRegistrationMessage {\n  ownerAddress: `0x${string}`;\n  serverAddress: `0x${string}`;\n  publicKey: string;\n  serverUrl: string;\n}\n\nexport interface BuilderRegistrationMessage {\n  ownerAddress: `0x${string}`;\n  granteeAddress: `0x${string}`;\n  publicKey: string;\n  appUrl: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAcvB,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,uBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,mBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,wBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,sBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,yBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,SAAS,0BACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAEO,MAAM,0BAA0B;AAAA,EACrC,kBAAkB;AAAA,IAChB,EAAE,MAAM,gB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