@opendatalabs/vana-sdk 3.4.0 → 3.4.1-canary.ba2cfd7

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.
Files changed (37) hide show
  1. package/dist/index.browser.d.ts +5 -3
  2. package/dist/index.browser.js +353 -73
  3. package/dist/index.browser.js.map +3 -3
  4. package/dist/index.node.cjs +369 -74
  5. package/dist/index.node.cjs.map +4 -4
  6. package/dist/index.node.d.ts +5 -3
  7. package/dist/index.node.js +353 -73
  8. package/dist/index.node.js.map +3 -3
  9. package/dist/protocol/eip712.cjs +58 -3
  10. package/dist/protocol/eip712.cjs.map +1 -1
  11. package/dist/protocol/eip712.d.ts +98 -6
  12. package/dist/protocol/eip712.js +52 -3
  13. package/dist/protocol/eip712.js.map +1 -1
  14. package/dist/protocol/escrow-deposit.cjs +89 -0
  15. package/dist/protocol/escrow-deposit.cjs.map +1 -0
  16. package/dist/protocol/escrow-deposit.d.ts +47 -0
  17. package/dist/protocol/escrow-deposit.js +60 -0
  18. package/dist/protocol/escrow-deposit.js.map +1 -0
  19. package/dist/protocol/escrow-deposit.test.d.ts +1 -0
  20. package/dist/protocol/escrow-flow.test.d.ts +21 -0
  21. package/dist/protocol/fee-registry.cjs +116 -0
  22. package/dist/protocol/fee-registry.cjs.map +1 -0
  23. package/dist/protocol/fee-registry.d.ts +151 -0
  24. package/dist/protocol/fee-registry.js +89 -0
  25. package/dist/protocol/fee-registry.js.map +1 -0
  26. package/dist/protocol/fee-registry.test.d.ts +1 -0
  27. package/dist/protocol/gateway.cjs +130 -7
  28. package/dist/protocol/gateway.cjs.map +1 -1
  29. package/dist/protocol/gateway.d.ts +213 -16
  30. package/dist/protocol/gateway.js +130 -7
  31. package/dist/protocol/gateway.js.map +1 -1
  32. package/dist/protocol/grants.cjs +24 -64
  33. package/dist/protocol/grants.cjs.map +1 -1
  34. package/dist/protocol/grants.d.ts +6 -13
  35. package/dist/protocol/grants.js +24 -63
  36. package/dist/protocol/grants.js.map +1 -1
  37. package/package.json +3 -2
@@ -18,13 +18,19 @@ 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,
21
22
  BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
22
23
  FILE_DELETION_TYPES: () => FILE_DELETION_TYPES,
23
24
  FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
25
+ GENERIC_PAYMENT_TYPES: () => GENERIC_PAYMENT_TYPES,
24
26
  GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
25
27
  GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
28
+ NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
29
+ RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
26
30
  SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
27
31
  builderRegistrationDomain: () => builderRegistrationDomain,
32
+ dataRegistryDomain: () => dataRegistryDomain,
33
+ escrowPaymentDomain: () => escrowPaymentDomain,
28
34
  fileDeletionDomain: () => fileDeletionDomain,
29
35
  fileRegistrationDomain: () => fileRegistrationDomain,
30
36
  grantRegistrationDomain: () => grantRegistrationDomain,
@@ -34,6 +40,7 @@ __export(eip712_exports, {
34
40
  module.exports = __toCommonJS(eip712_exports);
35
41
  const DOMAIN_NAME = "Vana Data Portability";
36
42
  const DOMAIN_VERSION = "1";
43
+ const NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
37
44
  function buildDomain(chainId, verifyingContract) {
38
45
  return {
39
46
  name: DOMAIN_NAME,
@@ -48,6 +55,12 @@ function fileRegistrationDomain(config) {
48
55
  config.contracts.dataRegistry
49
56
  );
50
57
  }
58
+ function dataRegistryDomain(config) {
59
+ return buildDomain(
60
+ config.chainId,
61
+ config.contracts.dataRegistry
62
+ );
63
+ }
51
64
  function fileDeletionDomain(config) {
52
65
  return buildDomain(
53
66
  config.chainId,
@@ -78,6 +91,12 @@ function builderRegistrationDomain(config) {
78
91
  config.contracts.dataPortabilityGrantees
79
92
  );
80
93
  }
94
+ function escrowPaymentDomain(config) {
95
+ return buildDomain(
96
+ config.chainId,
97
+ config.contracts.dataPortabilityEscrow
98
+ );
99
+ }
81
100
  const FILE_REGISTRATION_TYPES = {
82
101
  FileRegistration: [
83
102
  { name: "ownerAddress", type: "address" },
@@ -95,14 +114,16 @@ const GRANT_REGISTRATION_TYPES = {
95
114
  GrantRegistration: [
96
115
  { name: "grantorAddress", type: "address" },
97
116
  { name: "granteeId", type: "bytes32" },
98
- { name: "grant", type: "string" },
99
- { name: "fileIds", type: "uint256[]" }
117
+ { name: "scopes", type: "string[]" },
118
+ { name: "grantVersion", type: "uint256" },
119
+ { name: "expiresAt", type: "uint256" }
100
120
  ]
101
121
  };
102
122
  const GRANT_REVOCATION_TYPES = {
103
123
  GrantRevocation: [
104
124
  { name: "grantorAddress", type: "address" },
105
- { name: "grantId", type: "bytes32" }
125
+ { name: "grantId", type: "bytes32" },
126
+ { name: "grantVersion", type: "uint256" }
106
127
  ]
107
128
  };
108
129
  const SERVER_REGISTRATION_TYPES = {
@@ -121,15 +142,49 @@ const BUILDER_REGISTRATION_TYPES = {
121
142
  { name: "appUrl", type: "string" }
122
143
  ]
123
144
  };
145
+ const GENERIC_PAYMENT_TYPES = {
146
+ GenericPayment: [
147
+ { name: "payerAddress", type: "address" },
148
+ { name: "opType", type: "string" },
149
+ { name: "opId", type: "bytes32" },
150
+ { name: "asset", type: "address" },
151
+ { name: "amount", type: "uint256" },
152
+ { name: "paymentNonce", type: "uint256" }
153
+ ]
154
+ };
155
+ const ADD_DATA_TYPES = {
156
+ AddData: [
157
+ { name: "ownerAddress", type: "address" },
158
+ { name: "scope", type: "string" },
159
+ { name: "dataHash", type: "bytes32" },
160
+ { name: "metadataHash", type: "bytes32" },
161
+ { name: "expectedVersion", type: "uint256" }
162
+ ]
163
+ };
164
+ const RECORD_DATA_ACCESS_TYPES = {
165
+ RecordDataAccess: [
166
+ { name: "ownerAddress", type: "address" },
167
+ { name: "scope", type: "string" },
168
+ { name: "version", type: "uint256" },
169
+ { name: "accessor", type: "address" },
170
+ { name: "recordId", type: "bytes32" }
171
+ ]
172
+ };
124
173
  // Annotate the CommonJS export names for ESM import in node:
125
174
  0 && (module.exports = {
175
+ ADD_DATA_TYPES,
126
176
  BUILDER_REGISTRATION_TYPES,
127
177
  FILE_DELETION_TYPES,
128
178
  FILE_REGISTRATION_TYPES,
179
+ GENERIC_PAYMENT_TYPES,
129
180
  GRANT_REGISTRATION_TYPES,
130
181
  GRANT_REVOCATION_TYPES,
182
+ NATIVE_VANA_ASSET,
183
+ RECORD_DATA_ACCESS_TYPES,
131
184
  SERVER_REGISTRATION_TYPES,
132
185
  builderRegistrationDomain,
186
+ dataRegistryDomain,
187
+ escrowPaymentDomain,
133
188
  fileDeletionDomain,
134
189
  fileRegistrationDomain,
135
190
  grantRegistrationDomain,
@@ -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}\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;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ACF;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":[]}
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 // FeeRegistry — per-operation `{amount, asset, payee, enabled}` records\n // keyed on `keccak256(name)`. The gateway re-resolves fees against this\n // contract on every /v1/escrow/pay so the SDK has to read the same\n // source of truth to size payment amounts.\n feeRegistry: 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,\n// RecordDataAccess, and FileDeletion EIP-712 signatures. The\n// verifyingContract is the same as `fileRegistrationDomain` (both point at\n// `dataRegistry`); the distinction lives in the primaryType, not the\n// domain. Three names alias the same domain for caller ergonomics:\n// `dataRegistryDomain` reads naturally for data-point flows,\n// `fileDeletionDomain` for the file-deletion flow, both behave identically.\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 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\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\nexport const FILE_DELETION_TYPES = {\n FileDeletion: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"fileId\", 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 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 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;AAAA;AAAA;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAmBhB,MAAM,oBACX;AAOF,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN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,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":[]}
@@ -12,17 +12,22 @@ export interface DataPortabilityContracts {
12
12
  dataPortabilityPermissions: string;
13
13
  dataPortabilityServer: string;
14
14
  dataPortabilityGrantees: string;
15
+ dataPortabilityEscrow: string;
16
+ feeRegistry: string;
15
17
  }
18
+ export declare const NATIVE_VANA_ASSET: "0x0000000000000000000000000000000000000000";
16
19
  export interface DataPortabilityGatewayConfig {
17
20
  chainId: number;
18
21
  contracts: DataPortabilityContracts;
19
22
  }
20
23
  export declare function fileRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
24
+ export declare function dataRegistryDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
21
25
  export declare function fileDeletionDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
22
26
  export declare function grantRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
23
27
  export declare function grantRevocationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
24
28
  export declare function serverRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
25
29
  export declare function builderRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
30
+ export declare function escrowPaymentDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
26
31
  export declare const FILE_REGISTRATION_TYPES: {
27
32
  readonly FileRegistration: readonly [{
28
33
  readonly name: "ownerAddress";
@@ -52,11 +57,14 @@ export declare const GRANT_REGISTRATION_TYPES: {
52
57
  readonly name: "granteeId";
53
58
  readonly type: "bytes32";
54
59
  }, {
55
- readonly name: "grant";
56
- readonly type: "string";
60
+ readonly name: "scopes";
61
+ readonly type: "string[]";
62
+ }, {
63
+ readonly name: "grantVersion";
64
+ readonly type: "uint256";
57
65
  }, {
58
- readonly name: "fileIds";
59
- readonly type: "uint256[]";
66
+ readonly name: "expiresAt";
67
+ readonly type: "uint256";
60
68
  }];
61
69
  };
62
70
  export declare const GRANT_REVOCATION_TYPES: {
@@ -66,6 +74,9 @@ export declare const GRANT_REVOCATION_TYPES: {
66
74
  }, {
67
75
  readonly name: "grantId";
68
76
  readonly type: "bytes32";
77
+ }, {
78
+ readonly name: "grantVersion";
79
+ readonly type: "uint256";
69
80
  }];
70
81
  };
71
82
  export declare const SERVER_REGISTRATION_TYPES: {
@@ -98,6 +109,63 @@ export declare const BUILDER_REGISTRATION_TYPES: {
98
109
  readonly type: "string";
99
110
  }];
100
111
  };
112
+ export declare const GENERIC_PAYMENT_TYPES: {
113
+ readonly GenericPayment: readonly [{
114
+ readonly name: "payerAddress";
115
+ readonly type: "address";
116
+ }, {
117
+ readonly name: "opType";
118
+ readonly type: "string";
119
+ }, {
120
+ readonly name: "opId";
121
+ readonly type: "bytes32";
122
+ }, {
123
+ readonly name: "asset";
124
+ readonly type: "address";
125
+ }, {
126
+ readonly name: "amount";
127
+ readonly type: "uint256";
128
+ }, {
129
+ readonly name: "paymentNonce";
130
+ readonly type: "uint256";
131
+ }];
132
+ };
133
+ export declare const ADD_DATA_TYPES: {
134
+ readonly AddData: readonly [{
135
+ readonly name: "ownerAddress";
136
+ readonly type: "address";
137
+ }, {
138
+ readonly name: "scope";
139
+ readonly type: "string";
140
+ }, {
141
+ readonly name: "dataHash";
142
+ readonly type: "bytes32";
143
+ }, {
144
+ readonly name: "metadataHash";
145
+ readonly type: "bytes32";
146
+ }, {
147
+ readonly name: "expectedVersion";
148
+ readonly type: "uint256";
149
+ }];
150
+ };
151
+ export declare const RECORD_DATA_ACCESS_TYPES: {
152
+ readonly RecordDataAccess: readonly [{
153
+ readonly name: "ownerAddress";
154
+ readonly type: "address";
155
+ }, {
156
+ readonly name: "scope";
157
+ readonly type: "string";
158
+ }, {
159
+ readonly name: "version";
160
+ readonly type: "uint256";
161
+ }, {
162
+ readonly name: "accessor";
163
+ readonly type: "address";
164
+ }, {
165
+ readonly name: "recordId";
166
+ readonly type: "bytes32";
167
+ }];
168
+ };
101
169
  export interface FileRegistrationMessage {
102
170
  ownerAddress: `0x${string}`;
103
171
  url: string;
@@ -115,12 +183,14 @@ export interface FileDeletionMessage {
115
183
  export interface GrantRegistrationMessage {
116
184
  grantorAddress: `0x${string}`;
117
185
  granteeId: `0x${string}`;
118
- grant: string;
119
- fileIds: bigint[];
186
+ scopes: string[];
187
+ grantVersion: bigint;
188
+ expiresAt: bigint;
120
189
  }
121
190
  export interface GrantRevocationMessage {
122
191
  grantorAddress: `0x${string}`;
123
192
  grantId: `0x${string}`;
193
+ grantVersion: bigint;
124
194
  }
125
195
  export interface ServerRegistrationMessage {
126
196
  ownerAddress: `0x${string}`;
@@ -134,3 +204,25 @@ export interface BuilderRegistrationMessage {
134
204
  publicKey: string;
135
205
  appUrl: string;
136
206
  }
207
+ export interface GenericPaymentMessage {
208
+ payerAddress: `0x${string}`;
209
+ opType: string;
210
+ opId: `0x${string}`;
211
+ asset: `0x${string}`;
212
+ amount: bigint;
213
+ paymentNonce: bigint;
214
+ }
215
+ export interface AddDataMessage {
216
+ ownerAddress: `0x${string}`;
217
+ scope: string;
218
+ dataHash: `0x${string}`;
219
+ metadataHash: `0x${string}`;
220
+ expectedVersion: bigint;
221
+ }
222
+ export interface RecordDataAccessMessage {
223
+ ownerAddress: `0x${string}`;
224
+ scope: string;
225
+ version: bigint;
226
+ accessor: `0x${string}`;
227
+ recordId: `0x${string}`;
228
+ }
@@ -1,5 +1,6 @@
1
1
  const DOMAIN_NAME = "Vana Data Portability";
2
2
  const DOMAIN_VERSION = "1";
3
+ const NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
3
4
  function buildDomain(chainId, verifyingContract) {
4
5
  return {
5
6
  name: DOMAIN_NAME,
@@ -14,6 +15,12 @@ function fileRegistrationDomain(config) {
14
15
  config.contracts.dataRegistry
15
16
  );
16
17
  }
18
+ function dataRegistryDomain(config) {
19
+ return buildDomain(
20
+ config.chainId,
21
+ config.contracts.dataRegistry
22
+ );
23
+ }
17
24
  function fileDeletionDomain(config) {
18
25
  return buildDomain(
19
26
  config.chainId,
@@ -44,6 +51,12 @@ function builderRegistrationDomain(config) {
44
51
  config.contracts.dataPortabilityGrantees
45
52
  );
46
53
  }
54
+ function escrowPaymentDomain(config) {
55
+ return buildDomain(
56
+ config.chainId,
57
+ config.contracts.dataPortabilityEscrow
58
+ );
59
+ }
47
60
  const FILE_REGISTRATION_TYPES = {
48
61
  FileRegistration: [
49
62
  { name: "ownerAddress", type: "address" },
@@ -61,14 +74,16 @@ const GRANT_REGISTRATION_TYPES = {
61
74
  GrantRegistration: [
62
75
  { name: "grantorAddress", type: "address" },
63
76
  { name: "granteeId", type: "bytes32" },
64
- { name: "grant", type: "string" },
65
- { name: "fileIds", type: "uint256[]" }
77
+ { name: "scopes", type: "string[]" },
78
+ { name: "grantVersion", type: "uint256" },
79
+ { name: "expiresAt", type: "uint256" }
66
80
  ]
67
81
  };
68
82
  const GRANT_REVOCATION_TYPES = {
69
83
  GrantRevocation: [
70
84
  { name: "grantorAddress", type: "address" },
71
- { name: "grantId", type: "bytes32" }
85
+ { name: "grantId", type: "bytes32" },
86
+ { name: "grantVersion", type: "uint256" }
72
87
  ]
73
88
  };
74
89
  const SERVER_REGISTRATION_TYPES = {
@@ -87,14 +102,48 @@ const BUILDER_REGISTRATION_TYPES = {
87
102
  { name: "appUrl", type: "string" }
88
103
  ]
89
104
  };
105
+ const GENERIC_PAYMENT_TYPES = {
106
+ GenericPayment: [
107
+ { name: "payerAddress", type: "address" },
108
+ { name: "opType", type: "string" },
109
+ { name: "opId", type: "bytes32" },
110
+ { name: "asset", type: "address" },
111
+ { name: "amount", type: "uint256" },
112
+ { name: "paymentNonce", type: "uint256" }
113
+ ]
114
+ };
115
+ const ADD_DATA_TYPES = {
116
+ AddData: [
117
+ { name: "ownerAddress", type: "address" },
118
+ { name: "scope", type: "string" },
119
+ { name: "dataHash", type: "bytes32" },
120
+ { name: "metadataHash", type: "bytes32" },
121
+ { name: "expectedVersion", type: "uint256" }
122
+ ]
123
+ };
124
+ const RECORD_DATA_ACCESS_TYPES = {
125
+ RecordDataAccess: [
126
+ { name: "ownerAddress", type: "address" },
127
+ { name: "scope", type: "string" },
128
+ { name: "version", type: "uint256" },
129
+ { name: "accessor", type: "address" },
130
+ { name: "recordId", type: "bytes32" }
131
+ ]
132
+ };
90
133
  export {
134
+ ADD_DATA_TYPES,
91
135
  BUILDER_REGISTRATION_TYPES,
92
136
  FILE_DELETION_TYPES,
93
137
  FILE_REGISTRATION_TYPES,
138
+ GENERIC_PAYMENT_TYPES,
94
139
  GRANT_REGISTRATION_TYPES,
95
140
  GRANT_REVOCATION_TYPES,
141
+ NATIVE_VANA_ASSET,
142
+ RECORD_DATA_ACCESS_TYPES,
96
143
  SERVER_REGISTRATION_TYPES,
97
144
  builderRegistrationDomain,
145
+ dataRegistryDomain,
146
+ escrowPaymentDomain,
98
147
  fileDeletionDomain,
99
148
  fileRegistrationDomain,
100
149
  grantRegistrationDomain,
@@ -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}\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,SAA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AAyB;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":[]}
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 // FeeRegistry — per-operation `{amount, asset, payee, enabled}` records\n // keyed on `keccak256(name)`. The gateway re-resolves fees against this\n // contract on every /v1/escrow/pay so the SDK has to read the same\n // source of truth to size payment amounts.\n feeRegistry: 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,\n// RecordDataAccess, and FileDeletion EIP-712 signatures. The\n// verifyingContract is the same as `fileRegistrationDomain` (both point at\n// `dataRegistry`); the distinction lives in the primaryType, not the\n// domain. Three names alias the same domain for caller ergonomics:\n// `dataRegistryDomain` reads naturally for data-point flows,\n// `fileDeletionDomain` for the file-deletion flow, both behave identically.\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 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\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\nexport const FILE_DELETION_TYPES = {\n FileDeletion: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"fileId\", 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 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 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;AAmBhB,MAAM,oBACX;AAOF,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IAC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AChC,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":[]}
@@ -0,0 +1,89 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+ var escrow_deposit_exports = {};
20
+ __export(escrow_deposit_exports, {
21
+ ESCROW_DEPOSIT_ABI: () => ESCROW_DEPOSIT_ABI,
22
+ buildDepositNativeRequest: () => buildDepositNativeRequest,
23
+ buildDepositTokenRequest: () => buildDepositTokenRequest,
24
+ encodeDepositNativeData: () => encodeDepositNativeData,
25
+ encodeDepositTokenData: () => encodeDepositTokenData,
26
+ escrowContractAddress: () => escrowContractAddress
27
+ });
28
+ module.exports = __toCommonJS(escrow_deposit_exports);
29
+ var import_viem = require("viem");
30
+ const ESCROW_DEPOSIT_ABI = [
31
+ {
32
+ type: "function",
33
+ name: "depositNative",
34
+ stateMutability: "payable",
35
+ inputs: [{ name: "account", type: "address" }],
36
+ outputs: []
37
+ },
38
+ {
39
+ type: "function",
40
+ name: "depositToken",
41
+ stateMutability: "nonpayable",
42
+ inputs: [
43
+ { name: "account", type: "address" },
44
+ { name: "token", type: "address" },
45
+ { name: "amount", type: "uint256" }
46
+ ],
47
+ outputs: []
48
+ }
49
+ ];
50
+ function escrowContractAddress(config) {
51
+ return config.contracts.dataPortabilityEscrow;
52
+ }
53
+ function encodeDepositNativeData(input) {
54
+ return (0, import_viem.encodeFunctionData)({
55
+ abi: ESCROW_DEPOSIT_ABI,
56
+ functionName: "depositNative",
57
+ args: [input.account]
58
+ });
59
+ }
60
+ function encodeDepositTokenData(input) {
61
+ return (0, import_viem.encodeFunctionData)({
62
+ abi: ESCROW_DEPOSIT_ABI,
63
+ functionName: "depositToken",
64
+ args: [input.account, input.token, input.amount]
65
+ });
66
+ }
67
+ function buildDepositNativeRequest(config, input) {
68
+ return {
69
+ to: escrowContractAddress(config),
70
+ data: encodeDepositNativeData({ account: input.account }),
71
+ value: input.amount
72
+ };
73
+ }
74
+ function buildDepositTokenRequest(config, input) {
75
+ return {
76
+ to: escrowContractAddress(config),
77
+ data: encodeDepositTokenData(input)
78
+ };
79
+ }
80
+ // Annotate the CommonJS export names for ESM import in node:
81
+ 0 && (module.exports = {
82
+ ESCROW_DEPOSIT_ABI,
83
+ buildDepositNativeRequest,
84
+ buildDepositTokenRequest,
85
+ encodeDepositNativeData,
86
+ encodeDepositTokenData,
87
+ escrowContractAddress
88
+ });
89
+ //# sourceMappingURL=escrow-deposit.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/protocol/escrow-deposit.ts"],"sourcesContent":["/**\n * On-chain deposit primitives for the DataPortabilityEscrow contract.\n *\n * The escrow holds the finalized balance that `/v1/escrow/pay` debits against.\n * A payer credits their balance by sending one of two function calls to the\n * escrow contract — depositNative (native VANA, amount via `msg.value`) or\n * depositToken (ERC-20, caller must `approve` the escrow first). The credited\n * `account` need not equal `msg.sender`, so a third party can fund someone\n * else's escrow.\n *\n * Once the on-chain tx lands, call `GatewayClient.submitEscrowDeposit({txHash})`\n * to announce it; the gateway reconciles it into the balance and surfaces it\n * under `getEscrowBalance(account).deposits.finalized`.\n *\n * These helpers are signer/transport-agnostic — they return the raw\n * `{to, data, value?}` request object so callers can feed it to any wallet\n * stack (viem `sendTransaction`/`writeContract`, ethers, wallet-rpc, MPC,\n * Safe transactions, etc.).\n *\n * @category Protocol\n */\nimport { encodeFunctionData } from \"viem\";\nimport type { DataPortabilityGatewayConfig } from \"./eip712\";\n\n// ABI for the two deposit entry points on DataPortabilityEscrow. Same shape\n// the gateway uses to decode pending/mined tx calldata at\n// /v1/escrow/deposit time (data-gateway/lib/escrow.ts:39).\nexport const ESCROW_DEPOSIT_ABI = [\n {\n type: \"function\",\n name: \"depositNative\",\n stateMutability: \"payable\",\n inputs: [{ name: \"account\", type: \"address\" }],\n outputs: [],\n },\n {\n type: \"function\",\n name: \"depositToken\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"account\", type: \"address\" },\n { name: \"token\", type: \"address\" },\n { name: \"amount\", type: \"uint256\" },\n ],\n outputs: [],\n },\n] as const;\n\nexport function escrowContractAddress(\n config: DataPortabilityGatewayConfig,\n): `0x${string}` {\n return config.contracts.dataPortabilityEscrow as `0x${string}`;\n}\n\nexport interface DepositNativeInput {\n // Address credited inside the escrow. Often the same as the wallet sending\n // the tx, but third-party funding is supported.\n account: `0x${string}`;\n amount: bigint;\n}\n\nexport interface DepositTokenInput {\n account: `0x${string}`;\n // ERC-20 contract address.\n token: `0x${string}`;\n amount: bigint;\n}\n\n// Shape compatible with viem's `sendTransaction` / `writeContract` request\n// objects. `value` is omitted on the ERC-20 path because the amount lives in\n// the token contract, not `msg.value`.\nexport interface DepositTransactionRequest {\n to: `0x${string}`;\n data: `0x${string}`;\n value?: bigint;\n}\n\nexport function encodeDepositNativeData(input: {\n account: `0x${string}`;\n}): `0x${string}` {\n return encodeFunctionData({\n abi: ESCROW_DEPOSIT_ABI,\n functionName: \"depositNative\",\n args: [input.account],\n });\n}\n\nexport function encodeDepositTokenData(\n input: DepositTokenInput,\n): `0x${string}` {\n return encodeFunctionData({\n abi: ESCROW_DEPOSIT_ABI,\n functionName: \"depositToken\",\n args: [input.account, input.token, input.amount],\n });\n}\n\n// Build the full tx request for a native-VANA deposit. Feed it straight to\n// `walletClient.sendTransaction({...req, account, chain})`. ERC-20 needs a\n// prior `approve(escrow, amount)` on the token — use viem's built-in\n// `erc20Abi` for that; the SDK doesn't bundle one to avoid the import surface.\nexport function buildDepositNativeRequest(\n config: DataPortabilityGatewayConfig,\n input: DepositNativeInput,\n): DepositTransactionRequest {\n return {\n to: escrowContractAddress(config),\n data: encodeDepositNativeData({ account: input.account }),\n value: input.amount,\n };\n}\n\nexport function buildDepositTokenRequest(\n config: DataPortabilityGatewayConfig,\n input: DepositTokenInput,\n): DepositTransactionRequest {\n return {\n to: escrowContractAddress(config),\n data: encodeDepositTokenData(input),\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAqBA,kBAAmC;AAM5B,MAAM,qBAAqB;AAAA,EAChC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ,CAAC,EAAE,MAAM,WAAW,MAAM,UAAU,CAAC;AAAA,IAC7C,SAAS,CAAC;AAAA,EACZ;AAAA,EACA;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,MACnC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,MACjC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,IACpC;AAAA,IACA,SAAS,CAAC;AAAA,EACZ;AACF;AAEO,SAAS,sBACd,QACe;AACf,SAAO,OAAO,UAAU;AAC1B;AAyBO,SAAS,wBAAwB,OAEtB;AAChB,aAAO,gCAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM,OAAO;AAAA,EACtB,CAAC;AACH;AAEO,SAAS,uBACd,OACe;AACf,aAAO,gCAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM,SAAS,MAAM,OAAO,MAAM,MAAM;AAAA,EACjD,CAAC;AACH;AAMO,SAAS,0BACd,QACA,OAC2B;AAC3B,SAAO;AAAA,IACL,IAAI,sBAAsB,MAAM;AAAA,IAChC,MAAM,wBAAwB,EAAE,SAAS,MAAM,QAAQ,CAAC;AAAA,IACxD,OAAO,MAAM;AAAA,EACf;AACF;AAEO,SAAS,yBACd,QACA,OAC2B;AAC3B,SAAO;AAAA,IACL,IAAI,sBAAsB,MAAM;AAAA,IAChC,MAAM,uBAAuB,KAAK;AAAA,EACpC;AACF;","names":[]}
@@ -0,0 +1,47 @@
1
+ import type { DataPortabilityGatewayConfig } from "./eip712";
2
+ export declare const ESCROW_DEPOSIT_ABI: readonly [{
3
+ readonly type: "function";
4
+ readonly name: "depositNative";
5
+ readonly stateMutability: "payable";
6
+ readonly inputs: readonly [{
7
+ readonly name: "account";
8
+ readonly type: "address";
9
+ }];
10
+ readonly outputs: readonly [];
11
+ }, {
12
+ readonly type: "function";
13
+ readonly name: "depositToken";
14
+ readonly stateMutability: "nonpayable";
15
+ readonly inputs: readonly [{
16
+ readonly name: "account";
17
+ readonly type: "address";
18
+ }, {
19
+ readonly name: "token";
20
+ readonly type: "address";
21
+ }, {
22
+ readonly name: "amount";
23
+ readonly type: "uint256";
24
+ }];
25
+ readonly outputs: readonly [];
26
+ }];
27
+ export declare function escrowContractAddress(config: DataPortabilityGatewayConfig): `0x${string}`;
28
+ export interface DepositNativeInput {
29
+ account: `0x${string}`;
30
+ amount: bigint;
31
+ }
32
+ export interface DepositTokenInput {
33
+ account: `0x${string}`;
34
+ token: `0x${string}`;
35
+ amount: bigint;
36
+ }
37
+ export interface DepositTransactionRequest {
38
+ to: `0x${string}`;
39
+ data: `0x${string}`;
40
+ value?: bigint;
41
+ }
42
+ export declare function encodeDepositNativeData(input: {
43
+ account: `0x${string}`;
44
+ }): `0x${string}`;
45
+ export declare function encodeDepositTokenData(input: DepositTokenInput): `0x${string}`;
46
+ export declare function buildDepositNativeRequest(config: DataPortabilityGatewayConfig, input: DepositNativeInput): DepositTransactionRequest;
47
+ export declare function buildDepositTokenRequest(config: DataPortabilityGatewayConfig, input: DepositTokenInput): DepositTransactionRequest;