@opendatalabs/vana-sdk 3.2.0-canary.e3ef84a → 3.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -18,18 +18,14 @@ var __copyProps = (to, from, except, desc) => {
18
18
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
19
  var eip712_exports = {};
20
20
  __export(eip712_exports, {
21
- ADD_DATA_TYPES: () => ADD_DATA_TYPES,
22
21
  BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
22
+ FILE_DELETION_TYPES: () => FILE_DELETION_TYPES,
23
23
  FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
24
- GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
25
24
  GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
26
25
  GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
27
- NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
28
- RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
29
26
  SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
30
27
  builderRegistrationDomain: () => builderRegistrationDomain,
31
- dataRegistryDomain: () => dataRegistryDomain,
32
- escrowPaymentDomain: () => escrowPaymentDomain,
28
+ fileDeletionDomain: () => fileDeletionDomain,
33
29
  fileRegistrationDomain: () => fileRegistrationDomain,
34
30
  grantRegistrationDomain: () => grantRegistrationDomain,
35
31
  grantRevocationDomain: () => grantRevocationDomain,
@@ -38,7 +34,6 @@ __export(eip712_exports, {
38
34
  module.exports = __toCommonJS(eip712_exports);
39
35
  const DOMAIN_NAME = "Vana Data Portability";
40
36
  const DOMAIN_VERSION = "1";
41
- const NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
42
37
  function buildDomain(chainId, verifyingContract) {
43
38
  return {
44
39
  name: DOMAIN_NAME,
@@ -53,7 +48,7 @@ function fileRegistrationDomain(config) {
53
48
  config.contracts.dataRegistry
54
49
  );
55
50
  }
56
- function dataRegistryDomain(config) {
51
+ function fileDeletionDomain(config) {
57
52
  return buildDomain(
58
53
  config.chainId,
59
54
  config.contracts.dataRegistry
@@ -83,12 +78,6 @@ function builderRegistrationDomain(config) {
83
78
  config.contracts.dataPortabilityGrantees
84
79
  );
85
80
  }
86
- function escrowPaymentDomain(config) {
87
- return buildDomain(
88
- config.chainId,
89
- config.contracts.dataPortabilityEscrow
90
- );
91
- }
92
81
  const FILE_REGISTRATION_TYPES = {
93
82
  FileRegistration: [
94
83
  { name: "ownerAddress", type: "address" },
@@ -96,20 +85,24 @@ const FILE_REGISTRATION_TYPES = {
96
85
  { name: "schemaId", type: "bytes32" }
97
86
  ]
98
87
  };
88
+ const FILE_DELETION_TYPES = {
89
+ FileDeletion: [
90
+ { name: "ownerAddress", type: "address" },
91
+ { name: "fileId", type: "bytes32" }
92
+ ]
93
+ };
99
94
  const GRANT_REGISTRATION_TYPES = {
100
95
  GrantRegistration: [
101
96
  { name: "grantorAddress", type: "address" },
102
97
  { name: "granteeId", type: "bytes32" },
103
- { name: "scopes", type: "string[]" },
104
- { name: "grantVersion", type: "uint256" },
105
- { name: "expiresAt", type: "uint256" }
98
+ { name: "grant", type: "string" },
99
+ { name: "fileIds", type: "uint256[]" }
106
100
  ]
107
101
  };
108
102
  const GRANT_REVOCATION_TYPES = {
109
103
  GrantRevocation: [
110
104
  { name: "grantorAddress", type: "address" },
111
- { name: "grantId", type: "bytes32" },
112
- { name: "grantVersion", type: "uint256" }
105
+ { name: "grantId", type: "bytes32" }
113
106
  ]
114
107
  };
115
108
  const SERVER_REGISTRATION_TYPES = {
@@ -128,48 +121,16 @@ const BUILDER_REGISTRATION_TYPES = {
128
121
  { name: "appUrl", type: "string" }
129
122
  ]
130
123
  };
131
- const GENERIC_PAYMENT_TYPES = {
132
- GenericPayment: [
133
- { name: "payerAddress", type: "address" },
134
- { name: "opType", type: "string" },
135
- { name: "opId", type: "bytes32" },
136
- { name: "asset", type: "address" },
137
- { name: "amount", type: "uint256" },
138
- { name: "paymentNonce", type: "uint256" }
139
- ]
140
- };
141
- const ADD_DATA_TYPES = {
142
- AddData: [
143
- { name: "ownerAddress", type: "address" },
144
- { name: "scope", type: "string" },
145
- { name: "dataHash", type: "bytes32" },
146
- { name: "metadataHash", type: "bytes32" },
147
- { name: "expectedVersion", type: "uint256" }
148
- ]
149
- };
150
- const RECORD_DATA_ACCESS_TYPES = {
151
- RecordDataAccess: [
152
- { name: "ownerAddress", type: "address" },
153
- { name: "scope", type: "string" },
154
- { name: "version", type: "uint256" },
155
- { name: "accessor", type: "address" },
156
- { name: "recordId", type: "bytes32" }
157
- ]
158
- };
159
124
  // Annotate the CommonJS export names for ESM import in node:
160
125
  0 && (module.exports = {
161
- ADD_DATA_TYPES,
162
126
  BUILDER_REGISTRATION_TYPES,
127
+ FILE_DELETION_TYPES,
163
128
  FILE_REGISTRATION_TYPES,
164
- GENERIC_PAYMENT_TYPES,
165
129
  GRANT_REGISTRATION_TYPES,
166
130
  GRANT_REVOCATION_TYPES,
167
- NATIVE_VANA_ASSET,
168
- RECORD_DATA_ACCESS_TYPES,
169
131
  SERVER_REGISTRATION_TYPES,
170
132
  builderRegistrationDomain,
171
- dataRegistryDomain,
172
- escrowPaymentDomain,
133
+ fileDeletionDomain,
173
134
  fileRegistrationDomain,
174
135
  grantRegistrationDomain,
175
136
  grantRevocationDomain,
@@ -1 +1 @@
1
- {"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 // DataPortabilityEscrow — verifies GENERIC_PAYMENT_TYPES signatures backing\n // /v1/escrow/pay (the data-access payment path).\n dataPortabilityEscrow: string;\n}\n\n// Native VANA asset sentinel used by /v1/escrow/pay's `asset` field — pay any\n// other ERC-20 by passing its contract address instead.\nexport const NATIVE_VANA_ASSET =\n \"0x0000000000000000000000000000000000000000\" as const;\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\n// Domain for the DataRegistryV2 contract — verifies the AddData and\n// RecordDataAccess EIP-712 signatures. The verifyingContract is the same as\n// `fileRegistrationDomain` (both point at `dataRegistry`); the distinction\n// lives in the primaryType, not the domain. Exported as a separate helper\n// so callers reading data-point flows aren't routed through a name that\n// reads as file-registration-only.\nexport function dataRegistryDomain(\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\n// Domain for the generic-payment EIP-712 signature consumed by\n// /v1/escrow/pay. The verifyingContract is the escrow itself (not the per-op\n// contract), so a single signature debits the payer's escrow balance for any\n// supported op — `grant` today; file/builder/schema in the future.\nexport function escrowPaymentDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityEscrow 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\n// grantVersion is a monotonic uint256 nonce per (grantor, grantee) pair. The\n// gateway rejects any registration whose version is <= the stored value,\n// which is the replay-attack defence now that re-registering the same pair\n// is a permitted override. expiresAt is unix seconds; 0 = no expiry.\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"scopes\", type: \"string[]\" },\n { name: \"grantVersion\", type: \"uint256\" },\n { name: \"expiresAt\", type: \"uint256\" },\n ],\n} as const;\n\n// Revocation shares the (grantor, grantee) monotonic nonce with registration —\n// both events advance the same grantVersion counter so an old revocation sig\n// can't be replayed across a revoke → re-register cycle.\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n { name: \"grantVersion\", type: \"uint256\" },\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\n// Generic payment for the escrow flow. The (opType, opId) pair routes the\n// debit to the right op-row; paymentNonce is per-payer monotonic so the same\n// signed message can't be replayed after a revoke + re-register cycle.\n//\n// Today opType is always 'grant' and opId is the bytes32 grantId.\nexport const GENERIC_PAYMENT_TYPES = {\n GenericPayment: [\n { name: \"payerAddress\", type: \"address\" },\n { name: \"opType\", type: \"string\" },\n { name: \"opId\", type: \"bytes32\" },\n { name: \"asset\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n { name: \"paymentNonce\", type: \"uint256\" },\n ],\n} as const;\n\n// AddData is signed by the data point's owner — registers (scope, dataHash,\n// metadataHash) on DataRegistryV2. expectedVersion is the version the caller\n// believes is current; the contract rejects with a CAS error if it isn't.\n// Used at POST /v1/data.\nexport const ADD_DATA_TYPES = {\n AddData: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"scope\", type: \"string\" },\n { name: \"dataHash\", type: \"bytes32\" },\n { name: \"metadataHash\", type: \"bytes32\" },\n { name: \"expectedVersion\", type: \"uint256\" },\n ],\n} as const;\n\n// RecordDataAccess is signed by a *trusted personal server* of `ownerAddress`\n// — attests that (scope, version) was served to `accessor`. recordId is a\n// per-event bytes32 the contract pins in `_usedRecordIds` to prevent replay.\n// Used as the optional `accessRecord` on POST /v1/escrow/pay.\nexport const RECORD_DATA_ACCESS_TYPES = {\n RecordDataAccess: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"scope\", type: \"string\" },\n { name: \"version\", type: \"uint256\" },\n { name: \"accessor\", type: \"address\" },\n { name: \"recordId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n scopes: string[];\n grantVersion: bigint;\n expiresAt: bigint;\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n grantVersion: bigint;\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\nexport interface GenericPaymentMessage {\n payerAddress: `0x${string}`;\n // 'grant' today — extensible to 'file' | 'builder' | 'schema' as those\n // op-types become payable. Sent verbatim over the wire and into the\n // typed-data string field, so callers must match the gateway's spelling.\n opType: string;\n opId: `0x${string}`;\n // NATIVE_VANA_ASSET for native VANA; an ERC-20 contract address otherwise.\n asset: `0x${string}`;\n amount: bigint;\n paymentNonce: bigint;\n}\n\nexport interface AddDataMessage {\n ownerAddress: `0x${string}`;\n scope: string;\n dataHash: `0x${string}`;\n metadataHash: `0x${string}`;\n expectedVersion: bigint;\n}\n\nexport interface RecordDataAccessMessage {\n ownerAddress: `0x${string}`;\n scope: string;\n version: bigint;\n accessor: `0x${string}`;\n recordId: `0x${string}`;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAchB,MAAM,oBACX;AAOF,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;AAQO,SAAS,mBACd,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pC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;","names":[]}
1
+ {"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,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,OAAO,MAAM,SAAS;AAAA,IAC9B,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;AAEO,MAAM,sBAAsB;AAAA,EACjC,cAAc;AAAA,IACZ,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,EACpC;AACF;AAEO,MAAM,2BAA2B;AAAA,EACtC,mBAAmB;AAAA,IACjB,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,IACrC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,EACvC;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,IACf,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,EACrC;AACF;AAEO,MAAM,4BAA4B;AAAA,EACvC,oBAAoB;AAAA,IAClB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,iBAAiB,MAAM,UAAU;AAAA,IACzC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,EACtC;AACF;AAEO,MAAM,6BAA6B;AAAA,EACxC,qBAAqB;AAAA,IACnB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,EACnC;AACF;","names":[]}
@@ -12,20 +12,17 @@ export interface DataPortabilityContracts {
12
12
  dataPortabilityPermissions: string;
13
13
  dataPortabilityServer: string;
14
14
  dataPortabilityGrantees: string;
15
- dataPortabilityEscrow: string;
16
15
  }
17
- export declare const NATIVE_VANA_ASSET: "0x0000000000000000000000000000000000000000";
18
16
  export interface DataPortabilityGatewayConfig {
19
17
  chainId: number;
20
18
  contracts: DataPortabilityContracts;
21
19
  }
22
20
  export declare function fileRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
23
- export declare function dataRegistryDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
21
+ export declare function fileDeletionDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
24
22
  export declare function grantRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
25
23
  export declare function grantRevocationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
26
24
  export declare function serverRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
27
25
  export declare function builderRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
28
- export declare function escrowPaymentDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
29
26
  export declare const FILE_REGISTRATION_TYPES: {
30
27
  readonly FileRegistration: readonly [{
31
28
  readonly name: "ownerAddress";
@@ -38,6 +35,15 @@ export declare const FILE_REGISTRATION_TYPES: {
38
35
  readonly type: "bytes32";
39
36
  }];
40
37
  };
38
+ export declare const FILE_DELETION_TYPES: {
39
+ readonly FileDeletion: readonly [{
40
+ readonly name: "ownerAddress";
41
+ readonly type: "address";
42
+ }, {
43
+ readonly name: "fileId";
44
+ readonly type: "bytes32";
45
+ }];
46
+ };
41
47
  export declare const GRANT_REGISTRATION_TYPES: {
42
48
  readonly GrantRegistration: readonly [{
43
49
  readonly name: "grantorAddress";
@@ -46,14 +52,11 @@ export declare const GRANT_REGISTRATION_TYPES: {
46
52
  readonly name: "granteeId";
47
53
  readonly type: "bytes32";
48
54
  }, {
49
- readonly name: "scopes";
50
- readonly type: "string[]";
51
- }, {
52
- readonly name: "grantVersion";
53
- readonly type: "uint256";
55
+ readonly name: "grant";
56
+ readonly type: "string";
54
57
  }, {
55
- readonly name: "expiresAt";
56
- readonly type: "uint256";
58
+ readonly name: "fileIds";
59
+ readonly type: "uint256[]";
57
60
  }];
58
61
  };
59
62
  export declare const GRANT_REVOCATION_TYPES: {
@@ -63,9 +66,6 @@ export declare const GRANT_REVOCATION_TYPES: {
63
66
  }, {
64
67
  readonly name: "grantId";
65
68
  readonly type: "bytes32";
66
- }, {
67
- readonly name: "grantVersion";
68
- readonly type: "uint256";
69
69
  }];
70
70
  };
71
71
  export declare const SERVER_REGISTRATION_TYPES: {
@@ -98,79 +98,29 @@ export declare const BUILDER_REGISTRATION_TYPES: {
98
98
  readonly type: "string";
99
99
  }];
100
100
  };
101
- export declare const GENERIC_PAYMENT_TYPES: {
102
- readonly GenericPayment: readonly [{
103
- readonly name: "payerAddress";
104
- readonly type: "address";
105
- }, {
106
- readonly name: "opType";
107
- readonly type: "string";
108
- }, {
109
- readonly name: "opId";
110
- readonly type: "bytes32";
111
- }, {
112
- readonly name: "asset";
113
- readonly type: "address";
114
- }, {
115
- readonly name: "amount";
116
- readonly type: "uint256";
117
- }, {
118
- readonly name: "paymentNonce";
119
- readonly type: "uint256";
120
- }];
121
- };
122
- export declare const ADD_DATA_TYPES: {
123
- readonly AddData: readonly [{
124
- readonly name: "ownerAddress";
125
- readonly type: "address";
126
- }, {
127
- readonly name: "scope";
128
- readonly type: "string";
129
- }, {
130
- readonly name: "dataHash";
131
- readonly type: "bytes32";
132
- }, {
133
- readonly name: "metadataHash";
134
- readonly type: "bytes32";
135
- }, {
136
- readonly name: "expectedVersion";
137
- readonly type: "uint256";
138
- }];
139
- };
140
- export declare const RECORD_DATA_ACCESS_TYPES: {
141
- readonly RecordDataAccess: readonly [{
142
- readonly name: "ownerAddress";
143
- readonly type: "address";
144
- }, {
145
- readonly name: "scope";
146
- readonly type: "string";
147
- }, {
148
- readonly name: "version";
149
- readonly type: "uint256";
150
- }, {
151
- readonly name: "accessor";
152
- readonly type: "address";
153
- }, {
154
- readonly name: "recordId";
155
- readonly type: "bytes32";
156
- }];
157
- };
158
101
  export interface FileRegistrationMessage {
159
102
  ownerAddress: `0x${string}`;
160
103
  url: string;
161
104
  schemaId: `0x${string}`;
162
105
  }
106
+ export interface FileDeletionMessage {
107
+ ownerAddress: `0x${string}`;
108
+ /**
109
+ * Off-chain gateway file ID — bytes32, as returned by `GET /v1/files`. This is NOT the on-chain
110
+ * uint256 DataRegistry file ID; consumers (e.g. the PS delete cascade) must source it from the
111
+ * gateway, not derive it from a numeric on-chain ID.
112
+ */
113
+ fileId: `0x${string}`;
114
+ }
163
115
  export interface GrantRegistrationMessage {
164
116
  grantorAddress: `0x${string}`;
165
117
  granteeId: `0x${string}`;
166
- scopes: string[];
167
- grantVersion: bigint;
168
- expiresAt: bigint;
118
+ grant: string;
119
+ fileIds: bigint[];
169
120
  }
170
121
  export interface GrantRevocationMessage {
171
122
  grantorAddress: `0x${string}`;
172
123
  grantId: `0x${string}`;
173
- grantVersion: bigint;
174
124
  }
175
125
  export interface ServerRegistrationMessage {
176
126
  ownerAddress: `0x${string}`;
@@ -184,25 +134,3 @@ export interface BuilderRegistrationMessage {
184
134
  publicKey: string;
185
135
  appUrl: string;
186
136
  }
187
- export interface GenericPaymentMessage {
188
- payerAddress: `0x${string}`;
189
- opType: string;
190
- opId: `0x${string}`;
191
- asset: `0x${string}`;
192
- amount: bigint;
193
- paymentNonce: bigint;
194
- }
195
- export interface AddDataMessage {
196
- ownerAddress: `0x${string}`;
197
- scope: string;
198
- dataHash: `0x${string}`;
199
- metadataHash: `0x${string}`;
200
- expectedVersion: bigint;
201
- }
202
- export interface RecordDataAccessMessage {
203
- ownerAddress: `0x${string}`;
204
- scope: string;
205
- version: bigint;
206
- accessor: `0x${string}`;
207
- recordId: `0x${string}`;
208
- }
@@ -1,6 +1,5 @@
1
1
  const DOMAIN_NAME = "Vana Data Portability";
2
2
  const DOMAIN_VERSION = "1";
3
- const NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
4
3
  function buildDomain(chainId, verifyingContract) {
5
4
  return {
6
5
  name: DOMAIN_NAME,
@@ -15,7 +14,7 @@ function fileRegistrationDomain(config) {
15
14
  config.contracts.dataRegistry
16
15
  );
17
16
  }
18
- function dataRegistryDomain(config) {
17
+ function fileDeletionDomain(config) {
19
18
  return buildDomain(
20
19
  config.chainId,
21
20
  config.contracts.dataRegistry
@@ -45,12 +44,6 @@ function builderRegistrationDomain(config) {
45
44
  config.contracts.dataPortabilityGrantees
46
45
  );
47
46
  }
48
- function escrowPaymentDomain(config) {
49
- return buildDomain(
50
- config.chainId,
51
- config.contracts.dataPortabilityEscrow
52
- );
53
- }
54
47
  const FILE_REGISTRATION_TYPES = {
55
48
  FileRegistration: [
56
49
  { name: "ownerAddress", type: "address" },
@@ -58,20 +51,24 @@ const FILE_REGISTRATION_TYPES = {
58
51
  { name: "schemaId", type: "bytes32" }
59
52
  ]
60
53
  };
54
+ const FILE_DELETION_TYPES = {
55
+ FileDeletion: [
56
+ { name: "ownerAddress", type: "address" },
57
+ { name: "fileId", type: "bytes32" }
58
+ ]
59
+ };
61
60
  const GRANT_REGISTRATION_TYPES = {
62
61
  GrantRegistration: [
63
62
  { name: "grantorAddress", type: "address" },
64
63
  { name: "granteeId", type: "bytes32" },
65
- { name: "scopes", type: "string[]" },
66
- { name: "grantVersion", type: "uint256" },
67
- { name: "expiresAt", type: "uint256" }
64
+ { name: "grant", type: "string" },
65
+ { name: "fileIds", type: "uint256[]" }
68
66
  ]
69
67
  };
70
68
  const GRANT_REVOCATION_TYPES = {
71
69
  GrantRevocation: [
72
70
  { name: "grantorAddress", type: "address" },
73
- { name: "grantId", type: "bytes32" },
74
- { name: "grantVersion", type: "uint256" }
71
+ { name: "grantId", type: "bytes32" }
75
72
  ]
76
73
  };
77
74
  const SERVER_REGISTRATION_TYPES = {
@@ -90,47 +87,15 @@ const BUILDER_REGISTRATION_TYPES = {
90
87
  { name: "appUrl", type: "string" }
91
88
  ]
92
89
  };
93
- const GENERIC_PAYMENT_TYPES = {
94
- GenericPayment: [
95
- { name: "payerAddress", type: "address" },
96
- { name: "opType", type: "string" },
97
- { name: "opId", type: "bytes32" },
98
- { name: "asset", type: "address" },
99
- { name: "amount", type: "uint256" },
100
- { name: "paymentNonce", type: "uint256" }
101
- ]
102
- };
103
- const ADD_DATA_TYPES = {
104
- AddData: [
105
- { name: "ownerAddress", type: "address" },
106
- { name: "scope", type: "string" },
107
- { name: "dataHash", type: "bytes32" },
108
- { name: "metadataHash", type: "bytes32" },
109
- { name: "expectedVersion", type: "uint256" }
110
- ]
111
- };
112
- const RECORD_DATA_ACCESS_TYPES = {
113
- RecordDataAccess: [
114
- { name: "ownerAddress", type: "address" },
115
- { name: "scope", type: "string" },
116
- { name: "version", type: "uint256" },
117
- { name: "accessor", type: "address" },
118
- { name: "recordId", type: "bytes32" }
119
- ]
120
- };
121
90
  export {
122
- ADD_DATA_TYPES,
123
91
  BUILDER_REGISTRATION_TYPES,
92
+ FILE_DELETION_TYPES,
124
93
  FILE_REGISTRATION_TYPES,
125
- GENERIC_PAYMENT_TYPES,
126
94
  GRANT_REGISTRATION_TYPES,
127
95
  GRANT_REVOCATION_TYPES,
128
- NATIVE_VANA_ASSET,
129
- RECORD_DATA_ACCESS_TYPES,
130
96
  SERVER_REGISTRATION_TYPES,
131
97
  builderRegistrationDomain,
132
- dataRegistryDomain,
133
- escrowPaymentDomain,
98
+ fileDeletionDomain,
134
99
  fileRegistrationDomain,
135
100
  grantRegistrationDomain,
136
101
  grantRevocationDomain,
@@ -1 +1 @@
1
- {"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 // DataPortabilityEscrow — verifies GENERIC_PAYMENT_TYPES signatures backing\n // /v1/escrow/pay (the data-access payment path).\n dataPortabilityEscrow: string;\n}\n\n// Native VANA asset sentinel used by /v1/escrow/pay's `asset` field — pay any\n// other ERC-20 by passing its contract address instead.\nexport const NATIVE_VANA_ASSET =\n \"0x0000000000000000000000000000000000000000\" as const;\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\n// Domain for the DataRegistryV2 contract — verifies the AddData and\n// RecordDataAccess EIP-712 signatures. The verifyingContract is the same as\n// `fileRegistrationDomain` (both point at `dataRegistry`); the distinction\n// lives in the primaryType, not the domain. Exported as a separate helper\n// so callers reading data-point flows aren't routed through a name that\n// reads as file-registration-only.\nexport function dataRegistryDomain(\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\n// Domain for the generic-payment EIP-712 signature consumed by\n// /v1/escrow/pay. The verifyingContract is the escrow itself (not the per-op\n// contract), so a single signature debits the payer's escrow balance for any\n// supported op — `grant` today; file/builder/schema in the future.\nexport function escrowPaymentDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityEscrow 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\n// grantVersion is a monotonic uint256 nonce per (grantor, grantee) pair. The\n// gateway rejects any registration whose version is <= the stored value,\n// which is the replay-attack defence now that re-registering the same pair\n// is a permitted override. expiresAt is unix seconds; 0 = no expiry.\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"scopes\", type: \"string[]\" },\n { name: \"grantVersion\", type: \"uint256\" },\n { name: \"expiresAt\", type: \"uint256\" },\n ],\n} as const;\n\n// Revocation shares the (grantor, grantee) monotonic nonce with registration —\n// both events advance the same grantVersion counter so an old revocation sig\n// can't be replayed across a revoke → re-register cycle.\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n { name: \"grantVersion\", type: \"uint256\" },\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\n// Generic payment for the escrow flow. The (opType, opId) pair routes the\n// debit to the right op-row; paymentNonce is per-payer monotonic so the same\n// signed message can't be replayed after a revoke + re-register cycle.\n//\n// Today opType is always 'grant' and opId is the bytes32 grantId.\nexport const GENERIC_PAYMENT_TYPES = {\n GenericPayment: [\n { name: \"payerAddress\", type: \"address\" },\n { name: \"opType\", type: \"string\" },\n { name: \"opId\", type: \"bytes32\" },\n { name: \"asset\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n { name: \"paymentNonce\", type: \"uint256\" },\n ],\n} as const;\n\n// AddData is signed by the data point's owner — registers (scope, dataHash,\n// metadataHash) on DataRegistryV2. expectedVersion is the version the caller\n// believes is current; the contract rejects with a CAS error if it isn't.\n// Used at POST /v1/data.\nexport const ADD_DATA_TYPES = {\n AddData: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"scope\", type: \"string\" },\n { name: \"dataHash\", type: \"bytes32\" },\n { name: \"metadataHash\", type: \"bytes32\" },\n { name: \"expectedVersion\", type: \"uint256\" },\n ],\n} as const;\n\n// RecordDataAccess is signed by a *trusted personal server* of `ownerAddress`\n// — attests that (scope, version) was served to `accessor`. recordId is a\n// per-event bytes32 the contract pins in `_usedRecordIds` to prevent replay.\n// Used as the optional `accessRecord` on POST /v1/escrow/pay.\nexport const RECORD_DATA_ACCESS_TYPES = {\n RecordDataAccess: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"scope\", type: \"string\" },\n { name: \"version\", type: \"uint256\" },\n { name: \"accessor\", type: \"address\" },\n { name: \"recordId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n scopes: string[];\n grantVersion: bigint;\n expiresAt: bigint;\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n grantVersion: bigint;\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\nexport interface GenericPaymentMessage {\n payerAddress: `0x${string}`;\n // 'grant' today — extensible to 'file' | 'builder' | 'schema' as those\n // op-types become payable. Sent verbatim over the wire and into the\n // typed-data string field, so callers must match the gateway's spelling.\n opType: string;\n opId: `0x${string}`;\n // NATIVE_VANA_ASSET for native VANA; an ERC-20 contract address otherwise.\n asset: `0x${string}`;\n amount: bigint;\n paymentNonce: bigint;\n}\n\nexport interface AddDataMessage {\n ownerAddress: `0x${string}`;\n scope: string;\n dataHash: `0x${string}`;\n metadataHash: `0x${string}`;\n expectedVersion: bigint;\n}\n\nexport interface RecordDataAccessMessage {\n ownerAddress: `0x${string}`;\n scope: string;\n version: bigint;\n accessor: `0x${string}`;\n recordId: `0x${string}`;\n}\n"],"mappings":"AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAchB,MAAM,oBACX;AAOF,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;AAQO,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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AqB;AAAA,IACnB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,EACnC;AACF;AAOO,MAAM,wBAAwB;AAAA,EACnC,gBAAgB;AAAA,IACd,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,IACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IAChC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,IACjC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,IAClC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,EAC1C;AACF;AAMO,MAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,IACP,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,mBAAmB,MAAM,UAAU;AAAA,EAC7C;AACF;AAMO,MAAM,2BAA2B;AAAA,EACtC,kBAAkB;AAAA,IAChB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACnC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;","names":[]}
1
+ {"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":"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,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,OAAO,MAAM,SAAS;AAAA,IAC9B,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;AAEO,MAAM,sBAAsB;AAAA,EACjC,cAAc;AAAA,IACZ,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,EACpC;AACF;AAEO,MAAM,2BAA2B;AAAA,EACtC,mBAAmB;AAAA,IACjB,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,IACrC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,YAAY;AAAA,EACvC;AACF;AAEO,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,IACf,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,EACrC;AACF;AAEO,MAAM,4BAA4B;AAAA,EACvC,oBAAoB;AAAA,IAClB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,iBAAiB,MAAM,UAAU;AAAA,IACzC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,EACtC;AACF;AAEO,MAAM,6BAA6B;AAAA,EACxC,qBAAqB;AAAA,IACnB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,EACnC;AACF;","names":[]}
@@ -146,68 +146,6 @@ function createGatewayClient(baseUrl) {
146
146
  alreadyRegistered: false
147
147
  };
148
148
  },
149
- async registerBuilder(params) {
150
- const res = await fetch(`${base}/v1/builders`, {
151
- method: "POST",
152
- headers: {
153
- "Content-Type": "application/json",
154
- Authorization: `Web3Signed ${params.signature}`
155
- },
156
- body: JSON.stringify({
157
- ownerAddress: params.ownerAddress,
158
- granteeAddress: params.granteeAddress,
159
- publicKey: params.publicKey,
160
- appUrl: params.appUrl
161
- })
162
- });
163
- if (res.status === 409) {
164
- const body2 = await res.json().catch(() => ({}));
165
- return {
166
- builderId: getMutationId(
167
- body2,
168
- "builderId"
169
- ),
170
- alreadyRegistered: true
171
- };
172
- }
173
- if (!res.ok) {
174
- throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
175
- }
176
- const body = await res.json().catch(() => ({}));
177
- return {
178
- builderId: getMutationId(body, "builderId"),
179
- alreadyRegistered: false
180
- };
181
- },
182
- async registerDataPoint(params) {
183
- const res = await fetch(`${base}/v1/data`, {
184
- method: "POST",
185
- headers: {
186
- "Content-Type": "application/json",
187
- Authorization: `Web3Signed ${params.signature}`
188
- },
189
- body: JSON.stringify({
190
- ownerAddress: params.ownerAddress,
191
- scope: params.scope,
192
- dataHash: params.dataHash,
193
- metadataHash: params.metadataHash,
194
- expectedVersion: params.expectedVersion
195
- })
196
- });
197
- if (!res.ok) {
198
- const body2 = await res.json().catch(() => ({}));
199
- const detail = body2.error ?? res.statusText;
200
- throw new Error(`Gateway error: ${res.status} ${detail}`);
201
- }
202
- const body = await res.json().catch(() => ({}));
203
- return {
204
- dataPointId: getMutationId(
205
- body,
206
- "dataPointId"
207
- ),
208
- expectedVersion: body.expectedVersion
209
- };
210
- },
211
149
  async registerFile(params) {
212
150
  const res = await fetch(`${base}/v1/files`, {
213
151
  method: "POST",
@@ -245,9 +183,8 @@ function createGatewayClient(baseUrl) {
245
183
  body: JSON.stringify({
246
184
  grantorAddress: params.grantorAddress,
247
185
  granteeId: params.granteeId,
248
- scopes: params.scopes,
249
- grantVersion: params.grantVersion,
250
- expiresAt: params.expiresAt
186
+ grant: params.grant,
187
+ fileIds: params.fileIds
251
188
  })
252
189
  });
253
190
  if (res.status === 409) {
@@ -272,8 +209,7 @@ function createGatewayClient(baseUrl) {
272
209
  Authorization: `Web3Signed ${params.signature}`
273
210
  },
274
211
  body: JSON.stringify({
275
- grantorAddress: params.grantorAddress,
276
- grantVersion: params.grantVersion
212
+ grantorAddress: params.grantorAddress
277
213
  })
278
214
  });
279
215
  if (res.status === 409) return;
@@ -281,62 +217,21 @@ function createGatewayClient(baseUrl) {
281
217
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
282
218
  }
283
219
  },
284
- async getEscrowBalance(account) {
285
- const res = await fetch(`${base}/v1/escrow/balance?account=${account}`);
286
- if (!res.ok) {
287
- throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
288
- }
289
- return await res.json();
290
- },
291
- async submitEscrowDeposit(params) {
292
- const res = await fetch(`${base}/v1/escrow/deposit`, {
293
- method: "POST",
294
- headers: { "Content-Type": "application/json" },
295
- body: JSON.stringify({ txHash: params.txHash })
296
- });
297
- if (res.status !== 200 && res.status !== 202) {
298
- throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
299
- }
300
- return await res.json();
301
- },
302
- async payForOperation(params) {
303
- const body = {
304
- payerAddress: params.payerAddress,
305
- opType: params.opType,
306
- opId: params.opId,
307
- asset: params.asset,
308
- amount: params.amount,
309
- paymentNonce: params.paymentNonce
310
- };
311
- if (params.accessRecord) {
312
- body["accessRecord"] = params.accessRecord;
313
- }
314
- const res = await fetch(`${base}/v1/escrow/pay`, {
315
- method: "POST",
220
+ async deleteFile(params) {
221
+ const res = await fetch(`${base}/v1/files/${params.fileId}`, {
222
+ method: "DELETE",
316
223
  headers: {
317
224
  "Content-Type": "application/json",
318
225
  Authorization: `Web3Signed ${params.signature}`
319
226
  },
320
- body: JSON.stringify(body)
321
- });
322
- if (!res.ok) {
323
- throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
324
- }
325
- return await res.json();
326
- },
327
- async settle(params) {
328
- const res = await fetch(`${base}/v1/settle`, {
329
- method: "POST",
330
- headers: { "Content-Type": "application/json" },
331
- // The gateway accepts an empty body; only `limit` is recognised.
332
- // Always send a JSON body so the gateway's req.body shape parse
333
- // doesn't have to deal with an undefined.
334
- body: JSON.stringify(params ?? {})
227
+ body: JSON.stringify({
228
+ ownerAddress: params.ownerAddress
229
+ })
335
230
  });
231
+ if (res.status === 409) return;
336
232
  if (!res.ok) {
337
233
  throw new Error(`Gateway error: ${res.status} ${res.statusText}`);
338
234
  }
339
- return await res.json();
340
235
  }
341
236
  };
342
237
  }