@opendatalabs/vana-sdk 3.5.1 → 3.6.1

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 (116) hide show
  1. package/README.md +116 -0
  2. package/dist/direct/access-request-client.cjs +149 -0
  3. package/dist/direct/access-request-client.cjs.map +1 -0
  4. package/dist/direct/access-request-client.d.ts +66 -0
  5. package/dist/direct/access-request-client.js +123 -0
  6. package/dist/direct/access-request-client.js.map +1 -0
  7. package/dist/direct/access-request-client.test.d.ts +1 -0
  8. package/dist/direct/connect-flow.cjs +152 -0
  9. package/dist/direct/connect-flow.cjs.map +1 -0
  10. package/dist/direct/connect-flow.d.ts +85 -0
  11. package/dist/direct/connect-flow.js +128 -0
  12. package/dist/direct/connect-flow.js.map +1 -0
  13. package/dist/direct/connect-flow.test.d.ts +1 -0
  14. package/dist/direct/controller.cjs +131 -0
  15. package/dist/direct/controller.cjs.map +1 -0
  16. package/dist/direct/controller.d.ts +152 -0
  17. package/dist/direct/controller.js +111 -0
  18. package/dist/direct/controller.js.map +1 -0
  19. package/dist/direct/controller.test.d.ts +1 -0
  20. package/dist/direct/endpoints.cjs +45 -0
  21. package/dist/direct/endpoints.cjs.map +1 -0
  22. package/dist/direct/endpoints.d.ts +22 -0
  23. package/dist/direct/endpoints.js +19 -0
  24. package/dist/direct/endpoints.js.map +1 -0
  25. package/dist/direct/errors.cjs +65 -0
  26. package/dist/direct/errors.cjs.map +1 -0
  27. package/dist/direct/errors.d.ts +44 -0
  28. package/dist/direct/errors.js +38 -0
  29. package/dist/direct/errors.js.map +1 -0
  30. package/dist/direct/escrow-payment.cjs +96 -0
  31. package/dist/direct/escrow-payment.cjs.map +1 -0
  32. package/dist/direct/escrow-payment.d.ts +81 -0
  33. package/dist/direct/escrow-payment.js +72 -0
  34. package/dist/direct/escrow-payment.js.map +1 -0
  35. package/dist/direct/escrow-payment.test.d.ts +1 -0
  36. package/dist/direct/personal-server-read.cjs +149 -0
  37. package/dist/direct/personal-server-read.cjs.map +1 -0
  38. package/dist/direct/personal-server-read.d.ts +103 -0
  39. package/dist/direct/personal-server-read.js +124 -0
  40. package/dist/direct/personal-server-read.js.map +1 -0
  41. package/dist/direct/personal-server-read.test.d.ts +1 -0
  42. package/dist/direct/types.cjs +35 -0
  43. package/dist/direct/types.cjs.map +1 -0
  44. package/dist/direct/types.d.ts +205 -0
  45. package/dist/direct/types.js +11 -0
  46. package/dist/direct/types.js.map +1 -0
  47. package/dist/direct/use-direct-vana-connect.cjs +68 -0
  48. package/dist/direct/use-direct-vana-connect.cjs.map +1 -0
  49. package/dist/direct/use-direct-vana-connect.d.ts +45 -0
  50. package/dist/direct/use-direct-vana-connect.js +46 -0
  51. package/dist/direct/use-direct-vana-connect.js.map +1 -0
  52. package/dist/index.browser.d.ts +7 -3
  53. package/dist/index.browser.js +438 -157
  54. package/dist/index.browser.js.map +4 -4
  55. package/dist/index.node.cjs +461 -162
  56. package/dist/index.node.cjs.map +4 -4
  57. package/dist/index.node.d.ts +7 -3
  58. package/dist/index.node.js +438 -157
  59. package/dist/index.node.js.map +4 -4
  60. package/dist/protocol/data-point-status.cjs +80 -0
  61. package/dist/protocol/data-point-status.cjs.map +1 -0
  62. package/dist/protocol/data-point-status.d.ts +34 -0
  63. package/dist/protocol/data-point-status.js +51 -0
  64. package/dist/protocol/data-point-status.js.map +1 -0
  65. package/dist/protocol/data-point-status.test.d.ts +1 -0
  66. package/dist/protocol/eip712.cjs +53 -31
  67. package/dist/protocol/eip712.cjs.map +1 -1
  68. package/dist/protocol/eip712.d.ts +98 -43
  69. package/dist/protocol/eip712.js +47 -27
  70. package/dist/protocol/eip712.js.map +1 -1
  71. package/dist/protocol/escrow-deposit.cjs +89 -0
  72. package/dist/protocol/escrow-deposit.cjs.map +1 -0
  73. package/dist/protocol/escrow-deposit.d.ts +47 -0
  74. package/dist/protocol/escrow-deposit.js +60 -0
  75. package/dist/protocol/escrow-deposit.js.map +1 -0
  76. package/dist/protocol/escrow-deposit.test.d.ts +1 -0
  77. package/dist/protocol/escrow-flow.test.d.ts +21 -0
  78. package/dist/protocol/fee-registry.cjs +116 -0
  79. package/dist/protocol/fee-registry.cjs.map +1 -0
  80. package/dist/protocol/fee-registry.d.ts +151 -0
  81. package/dist/protocol/fee-registry.js +89 -0
  82. package/dist/protocol/fee-registry.js.map +1 -0
  83. package/dist/protocol/fee-registry.test.d.ts +1 -0
  84. package/dist/protocol/gateway.cjs +107 -37
  85. package/dist/protocol/gateway.cjs.map +1 -1
  86. package/dist/protocol/gateway.d.ts +223 -57
  87. package/dist/protocol/gateway.js +107 -37
  88. package/dist/protocol/gateway.js.map +1 -1
  89. package/dist/protocol/grants.cjs +27 -64
  90. package/dist/protocol/grants.cjs.map +1 -1
  91. package/dist/protocol/grants.d.ts +6 -13
  92. package/dist/protocol/grants.js +27 -63
  93. package/dist/protocol/grants.js.map +1 -1
  94. package/dist/protocol/personal-server-data.cjs +71 -0
  95. package/dist/protocol/personal-server-data.cjs.map +1 -0
  96. package/dist/protocol/personal-server-data.d.ts +16 -0
  97. package/dist/protocol/personal-server-data.js +47 -0
  98. package/dist/protocol/personal-server-data.js.map +1 -0
  99. package/dist/protocol/personal-server-data.test.d.ts +1 -0
  100. package/dist/protocol/personal-server-lite-owner-binding.cjs +93 -0
  101. package/dist/protocol/personal-server-lite-owner-binding.cjs.map +1 -0
  102. package/dist/protocol/personal-server-lite-owner-binding.d.ts +44 -0
  103. package/dist/protocol/personal-server-lite-owner-binding.js +65 -0
  104. package/dist/protocol/personal-server-lite-owner-binding.js.map +1 -0
  105. package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +1 -0
  106. package/dist/react.cjs +32 -0
  107. package/dist/react.cjs.map +1 -0
  108. package/dist/react.d.ts +33 -0
  109. package/dist/react.js +11 -0
  110. package/dist/react.js.map +1 -0
  111. package/dist/server.cjs +73 -0
  112. package/dist/server.cjs.map +1 -0
  113. package/dist/server.d.ts +32 -0
  114. package/dist/server.js +55 -0
  115. package/dist/server.js.map +1 -0
  116. package/package.json +20 -1
@@ -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,
@@ -8,13 +9,7 @@ function buildDomain(chainId, verifyingContract) {
8
9
  verifyingContract
9
10
  };
10
11
  }
11
- function fileRegistrationDomain(config) {
12
- return buildDomain(
13
- config.chainId,
14
- config.contracts.dataRegistry
15
- );
16
- }
17
- function fileDeletionDomain(config) {
12
+ function dataRegistryDomain(config) {
18
13
  return buildDomain(
19
14
  config.chainId,
20
15
  config.contracts.dataRegistry
@@ -44,31 +39,26 @@ function builderRegistrationDomain(config) {
44
39
  config.contracts.dataPortabilityGrantees
45
40
  );
46
41
  }
47
- const FILE_REGISTRATION_TYPES = {
48
- FileRegistration: [
49
- { name: "ownerAddress", type: "address" },
50
- { name: "url", type: "string" },
51
- { name: "schemaId", type: "bytes32" }
52
- ]
53
- };
54
- const FILE_DELETION_TYPES = {
55
- FileDeletion: [
56
- { name: "ownerAddress", type: "address" },
57
- { name: "fileId", type: "bytes32" }
58
- ]
59
- };
42
+ function escrowPaymentDomain(config) {
43
+ return buildDomain(
44
+ config.chainId,
45
+ config.contracts.dataPortabilityEscrow
46
+ );
47
+ }
60
48
  const GRANT_REGISTRATION_TYPES = {
61
49
  GrantRegistration: [
62
50
  { name: "grantorAddress", type: "address" },
63
51
  { name: "granteeId", type: "bytes32" },
64
- { name: "grant", type: "string" },
65
- { name: "fileIds", type: "uint256[]" }
52
+ { name: "scopes", type: "string[]" },
53
+ { name: "grantVersion", type: "uint256" },
54
+ { name: "expiresAt", type: "uint256" }
66
55
  ]
67
56
  };
68
57
  const GRANT_REVOCATION_TYPES = {
69
58
  GrantRevocation: [
70
59
  { name: "grantorAddress", type: "address" },
71
- { name: "grantId", type: "bytes32" }
60
+ { name: "grantId", type: "bytes32" },
61
+ { name: "grantVersion", type: "uint256" }
72
62
  ]
73
63
  };
74
64
  const SERVER_REGISTRATION_TYPES = {
@@ -87,16 +77,46 @@ const BUILDER_REGISTRATION_TYPES = {
87
77
  { name: "appUrl", type: "string" }
88
78
  ]
89
79
  };
80
+ const GENERIC_PAYMENT_TYPES = {
81
+ GenericPayment: [
82
+ { name: "payerAddress", type: "address" },
83
+ { name: "opType", type: "string" },
84
+ { name: "opId", type: "bytes32" },
85
+ { name: "asset", type: "address" },
86
+ { name: "amount", type: "uint256" },
87
+ { name: "paymentNonce", type: "uint256" }
88
+ ]
89
+ };
90
+ const ADD_DATA_TYPES = {
91
+ AddData: [
92
+ { name: "ownerAddress", type: "address" },
93
+ { name: "scope", type: "string" },
94
+ { name: "dataHash", type: "bytes32" },
95
+ { name: "metadataHash", type: "bytes32" },
96
+ { name: "expectedVersion", type: "uint256" }
97
+ ]
98
+ };
99
+ const RECORD_DATA_ACCESS_TYPES = {
100
+ RecordDataAccess: [
101
+ { name: "ownerAddress", type: "address" },
102
+ { name: "scope", type: "string" },
103
+ { name: "version", type: "uint256" },
104
+ { name: "accessor", type: "address" },
105
+ { name: "recordId", type: "bytes32" }
106
+ ]
107
+ };
90
108
  export {
109
+ ADD_DATA_TYPES,
91
110
  BUILDER_REGISTRATION_TYPES,
92
- FILE_DELETION_TYPES,
93
- FILE_REGISTRATION_TYPES,
111
+ GENERIC_PAYMENT_TYPES,
94
112
  GRANT_REGISTRATION_TYPES,
95
113
  GRANT_REVOCATION_TYPES,
114
+ NATIVE_VANA_ASSET,
115
+ RECORD_DATA_ACCESS_TYPES,
96
116
  SERVER_REGISTRATION_TYPES,
97
117
  builderRegistrationDomain,
98
- fileDeletionDomain,
99
- fileRegistrationDomain,
118
+ dataRegistryDomain,
119
+ escrowPaymentDomain,
100
120
  grantRegistrationDomain,
101
121
  grantRevocationDomain,
102
122
  serverRegistrationDomain
@@ -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,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":[]}
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\n// Domain for the DataRegistryV2 contract — verifies the AddData and\n// RecordDataAccess EIP-712 signatures. The v2 contract dropped the file\n// concept entirely in favor of versioned data points keyed on (owner,\n// scope); the primaryType distinguishes the two flows.\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\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 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,IACA;AAAA,EACF;AACF;AAMO,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;AAMO,SAAS,oBACd,QACiB;AACjB,SAAO;AAAA,IACL,OAAO;AAAA,IACP,OAAO,UAAU;AAAA,EACnB;AACF;AAMO,MAAM,2BAA2B;AAAA,EACtC,mBAAmB;AAAA,IACjB,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,IACrC,EAAE,MAAM,UAAU,MAAM,WAAW;AAAA,IACnC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,aAAa,MAAM,UAAU;AAAA,EACvC;AACF;AAKO,MAAM,yBAAyB;AAAA,EACpC,iBAAiB;AAAA,IACf,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACnC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,EAC1C;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;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":[]}
@@ -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;
@@ -0,0 +1,60 @@
1
+ import { encodeFunctionData } from "viem";
2
+ const ESCROW_DEPOSIT_ABI = [
3
+ {
4
+ type: "function",
5
+ name: "depositNative",
6
+ stateMutability: "payable",
7
+ inputs: [{ name: "account", type: "address" }],
8
+ outputs: []
9
+ },
10
+ {
11
+ type: "function",
12
+ name: "depositToken",
13
+ stateMutability: "nonpayable",
14
+ inputs: [
15
+ { name: "account", type: "address" },
16
+ { name: "token", type: "address" },
17
+ { name: "amount", type: "uint256" }
18
+ ],
19
+ outputs: []
20
+ }
21
+ ];
22
+ function escrowContractAddress(config) {
23
+ return config.contracts.dataPortabilityEscrow;
24
+ }
25
+ function encodeDepositNativeData(input) {
26
+ return encodeFunctionData({
27
+ abi: ESCROW_DEPOSIT_ABI,
28
+ functionName: "depositNative",
29
+ args: [input.account]
30
+ });
31
+ }
32
+ function encodeDepositTokenData(input) {
33
+ return encodeFunctionData({
34
+ abi: ESCROW_DEPOSIT_ABI,
35
+ functionName: "depositToken",
36
+ args: [input.account, input.token, input.amount]
37
+ });
38
+ }
39
+ function buildDepositNativeRequest(config, input) {
40
+ return {
41
+ to: escrowContractAddress(config),
42
+ data: encodeDepositNativeData({ account: input.account }),
43
+ value: input.amount
44
+ };
45
+ }
46
+ function buildDepositTokenRequest(config, input) {
47
+ return {
48
+ to: escrowContractAddress(config),
49
+ data: encodeDepositTokenData(input)
50
+ };
51
+ }
52
+ export {
53
+ ESCROW_DEPOSIT_ABI,
54
+ buildDepositNativeRequest,
55
+ buildDepositTokenRequest,
56
+ encodeDepositNativeData,
57
+ encodeDepositTokenData,
58
+ escrowContractAddress
59
+ };
60
+ //# sourceMappingURL=escrow-deposit.js.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":"AAqBA,SAAS,0BAA0B;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,SAAO,mBAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM,OAAO;AAAA,EACtB,CAAC;AACH;AAEO,SAAS,uBACd,OACe;AACf,SAAO,mBAAmB;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 @@
1
+ export {};
@@ -0,0 +1,21 @@
1
+ /**
2
+ * End-to-end test of the deposit + payment flow.
3
+ *
4
+ * The SDK is signer- and transport-agnostic. To prove the helpers compose
5
+ * correctly we wire them through:
6
+ *
7
+ * - A real viem `WalletClient` against an in-memory L1 (a custom RPC
8
+ * transport routes JSON-RPC calls to a Map-backed chain). The wallet
9
+ * genuinely signs an EIP-1559 transaction with the depositNative
10
+ * calldata produced by buildDepositNativeRequest.
11
+ *
12
+ * - A fetch-mocked gateway that decodes that same calldata via
13
+ * ESCROW_DEPOSIT_ABI, credits a balance, and later recovers the
14
+ * GenericPayment EIP-712 signer with viem's recoverTypedDataAddress —
15
+ * same cryptographic checks the real gateway runs.
16
+ *
17
+ * Anything weaker than this (hand-rolled sendTx, hand-rolled sig recovery)
18
+ * would let the SDK's encoder or domain helpers drift silently. Going through
19
+ * viem's real wallet + sign paths is what makes this a useful e2e.
20
+ */
21
+ export {};
@@ -0,0 +1,116 @@
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 fee_registry_exports = {};
20
+ __export(fee_registry_exports, {
21
+ FEE_REGISTRY_ABI: () => FEE_REGISTRY_ABI,
22
+ REGISTRATION_KIND_FOR_OP: () => REGISTRATION_KIND_FOR_OP,
23
+ getFee: () => getFee,
24
+ getOpFee: () => getOpFee
25
+ });
26
+ module.exports = __toCommonJS(fee_registry_exports);
27
+ var import_viem = require("viem");
28
+ const FEE_REGISTRY_ABI = (0, import_viem.parseAbi)([
29
+ "struct Fee { uint256 amount; address asset; address payee; bool enabled; }",
30
+ "function fees(bytes32 operation) view returns (Fee)",
31
+ "function operationKey(string name) pure returns (bytes32)"
32
+ ]);
33
+ const REGISTRATION_KIND_FOR_OP = {
34
+ grant: "grant_registration",
35
+ data: "data_registration",
36
+ server: "server_registration",
37
+ builder: "builder_registration"
38
+ };
39
+ function operationNameFor(kind, opts) {
40
+ switch (kind) {
41
+ case "grant_registration":
42
+ return opts?.grantRegistrationOpName ?? "grant_registration";
43
+ case "data_access":
44
+ return opts?.dataAccessOpName ?? "data_access";
45
+ case "data_registration":
46
+ return opts?.dataRegistrationOpName ?? "data_registration";
47
+ case "server_registration":
48
+ return opts?.serverRegistrationOpName ?? "server_registration";
49
+ case "builder_registration":
50
+ return opts?.builderRegistrationOpName ?? "builder_registration";
51
+ }
52
+ }
53
+ const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
54
+ async function getFee(client, config, kind, opts) {
55
+ const address = config.contracts.feeRegistry;
56
+ const opName = operationNameFor(kind, opts);
57
+ const opKey = await client.readContract({
58
+ address,
59
+ abi: FEE_REGISTRY_ABI,
60
+ functionName: "operationKey",
61
+ args: [opName]
62
+ });
63
+ const fee = await client.readContract({
64
+ address,
65
+ abi: FEE_REGISTRY_ABI,
66
+ functionName: "fees",
67
+ args: [opKey]
68
+ });
69
+ if (fee.enabled && fee.payee === ZERO_ADDRESS) {
70
+ throw new Error(
71
+ `FeeRegistry: enabled operation "${opName}" has zero-address payee \u2014 contract pre-flight rejects payouts to 0x0`
72
+ );
73
+ }
74
+ return fee;
75
+ }
76
+ async function getOpFee(client, config, opType, opts) {
77
+ const registrationKind = REGISTRATION_KIND_FOR_OP[opType];
78
+ if (!registrationKind) {
79
+ throw new Error(
80
+ `getOpFee: unknown opType "${opType}" \u2014 supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(", ")}`
81
+ );
82
+ }
83
+ const includeDataAccess = opType === "grant";
84
+ const [registration, dataAccess] = await Promise.all([
85
+ getFee(client, config, registrationKind, opts),
86
+ includeDataAccess ? getFee(client, config, "data_access", opts) : Promise.resolve({
87
+ amount: 0n,
88
+ asset: ZERO_ADDRESS,
89
+ payee: ZERO_ADDRESS,
90
+ enabled: false
91
+ })
92
+ ]);
93
+ if (registration.enabled && dataAccess.enabled && registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()) {
94
+ throw new Error(
95
+ `FeeRegistry asset mismatch for "${opType}": registration=${registration.asset} vs data_access=${dataAccess.asset}. The gateway requires both kinds to settle in the same asset when both are enabled.`
96
+ );
97
+ }
98
+ const asset = registration.enabled ? registration.asset : dataAccess.enabled ? dataAccess.asset : ZERO_ADDRESS;
99
+ return {
100
+ asset,
101
+ registrationFee: registration.enabled ? registration.amount : 0n,
102
+ dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,
103
+ registrationEnabled: registration.enabled,
104
+ dataAccessEnabled: dataAccess.enabled,
105
+ registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,
106
+ dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS
107
+ };
108
+ }
109
+ // Annotate the CommonJS export names for ESM import in node:
110
+ 0 && (module.exports = {
111
+ FEE_REGISTRY_ABI,
112
+ REGISTRATION_KIND_FOR_OP,
113
+ getFee,
114
+ getOpFee
115
+ });
116
+ //# sourceMappingURL=fee-registry.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../src/protocol/fee-registry.ts"],"sourcesContent":["/**\n * Adapter for the on-chain FeeRegistry contract — the source of truth the\n * gateway re-reads on every /v1/escrow/pay to size the payment amount.\n *\n * The registry stores per-operation `{amount, asset, payee, enabled}`\n * records keyed on `keccak256(name)`. SDK consumers (builders sizing\n * payments) MUST read fees from this contract rather than hardcoding\n * them, or the signed `amount` won't match the gateway's expected total\n * and /v1/escrow/pay returns 400.\n *\n * Five operation kinds are wired up; each kind's name matches the\n * corresponding `payments.kind` column value on the gateway:\n *\n * - 'grant_registration' — one-time fee when a grant is first registered\n * (POST /v1/grants).\n * - 'data_access' — per-access surcharge on grant payments\n * (every accessRecord posted against a grant).\n * - 'data_registration' — one-time fee for registering a data point\n * (POST /v1/data → addDataWithSignature).\n * - 'server_registration' — one-time fee for registering a personal server\n * (POST /v1/servers).\n * - 'builder_registration' — one-time fee for registering a builder\n * (POST /v1/builders; gateway-only, no on-chain\n * submission).\n *\n * Disabled or unregistered fees skip enforcement: the corresponding\n * operation settles WITHOUT requiring a payment from escrow. `getFee`\n * surfaces this via `enabled: false` rather than throwing — the gateway\n * itself treats a disabled fee as a steady state, not a misconfig.\n *\n * Deployers can override the on-chain operation strings via\n * `FEE_REGISTRY_<KIND>_OP` env vars on the gateway side; the matching\n * SDK escape hatch is the `opts.<kind>OpName` arguments.\n *\n * This module is signer/transport-agnostic — callers pass in their own\n * `PublicClient` for the contract reads. No caching here; long-running\n * service consumers should wrap with their own TTL. Mirrors\n * data-gateway/lib/fee-registry.ts byte-for-byte.\n *\n * @category Protocol\n */\nimport { parseAbi, type Address, type Hex, type PublicClient } from \"viem\";\nimport type { DataPortabilityGatewayConfig } from \"./eip712\";\n\nexport const FEE_REGISTRY_ABI = parseAbi([\n \"struct Fee { uint256 amount; address asset; address payee; bool enabled; }\",\n \"function fees(bytes32 operation) view returns (Fee)\",\n \"function operationKey(string name) pure returns (bytes32)\",\n]);\n\nexport type FeeKind =\n | \"grant_registration\"\n | \"data_access\"\n | \"data_registration\"\n | \"server_registration\"\n | \"builder_registration\";\n\n/**\n * Map from a user-facing opType (POST /v1/escrow/pay body field, matches\n * the gateway's `payments.op_type` column) to the FeeKind that gates its\n * one-time registration fee.\n *\n * Data access is a per-call surcharge on grants only — it's not a\n * registration fee for any op, so it lives outside this map.\n */\nexport const REGISTRATION_KIND_FOR_OP: Record<string, FeeKind> = {\n grant: \"grant_registration\",\n data: \"data_registration\",\n server: \"server_registration\",\n builder: \"builder_registration\",\n};\n\nexport interface FeeEntry {\n amount: bigint;\n // Asset the fee is denominated in. 0x0000…0000 = native VANA; anything\n // else is an ERC-20 contract address.\n asset: Address;\n // The recipient the on-chain settle pass routes the fee to. Only\n // meaningful when `enabled` — disabled fees never land as a SettleOp `to`.\n payee: Address;\n enabled: boolean;\n}\n\n/**\n * Compound fee schedule for one op type, mirroring the gateway's\n * lib/op-fees.ts `OpFee`. For ANY op type, `registrationFee` is the\n * one-time fee charged at registration. For `'grant'` only, `dataAccessFee`\n * is the per-access surcharge — for any other op type it's always 0n with\n * `dataAccessEnabled: false`.\n *\n * `xxxEnabled` reflects the on-chain `Fee.enabled` flag. When OFF, the\n * corresponding amount is 0 and the pay handler should NOT require\n * payment for that kind. When both are off (for a grant) or registration\n * is off (for any other op type), the entire payment flow is skipped —\n * the op settles directly via the no-payment path.\n */\nexport interface OpFee {\n // Asset for whichever components are enabled. Falls back to native VANA\n // (0x0) when both components are disabled. The pay handler enforces that\n // the payer's `asset` matches.\n asset: Address;\n registrationFee: bigint;\n dataAccessFee: bigint;\n registrationEnabled: boolean;\n dataAccessEnabled: boolean;\n // Surfaced for the SDK's on-chain log-filter use case; the gateway's\n // OpFee type doesn't include these but the SDK keeps them since callers\n // sizing on-chain assertions need to know where the fee lands. Equal to\n // the zero address when the corresponding kind is disabled.\n registrationPayee: Address;\n dataAccessPayee: Address;\n}\n\nexport interface FeeRegistryOptions {\n grantRegistrationOpName?: string;\n dataAccessOpName?: string;\n dataRegistrationOpName?: string;\n serverRegistrationOpName?: string;\n builderRegistrationOpName?: string;\n}\n\nfunction operationNameFor(\n kind: FeeKind,\n opts: FeeRegistryOptions | undefined,\n): string {\n switch (kind) {\n case \"grant_registration\":\n return opts?.grantRegistrationOpName ?? \"grant_registration\";\n case \"data_access\":\n return opts?.dataAccessOpName ?? \"data_access\";\n case \"data_registration\":\n return opts?.dataRegistrationOpName ?? \"data_registration\";\n case \"server_registration\":\n return opts?.serverRegistrationOpName ?? \"server_registration\";\n case \"builder_registration\":\n return opts?.builderRegistrationOpName ?? \"builder_registration\";\n }\n}\n\nconst ZERO_ADDRESS = \"0x0000000000000000000000000000000000000000\" as Address;\n\n/**\n * Reads one fee kind from the FeeRegistry. Calls the contract's\n * `operationKey(name)` first to derive the bytes32 key — matches the\n * gateway's approach exactly (could compute locally via keccak256, but\n * going through the contract eliminates any chance of encoding drift).\n *\n * Returns `{enabled: false}` entries WITHOUT throwing — disabled is a\n * valid steady state on the gateway. The only validation is the\n * zero-payee check, and that only fires when the fee is enabled\n * (a disabled fee never lands as a SettleOp `to`).\n */\nexport async function getFee(\n client: PublicClient,\n config: DataPortabilityGatewayConfig,\n kind: FeeKind,\n opts?: FeeRegistryOptions,\n): Promise<FeeEntry> {\n const address = config.contracts.feeRegistry as Address;\n const opName = operationNameFor(kind, opts);\n\n const opKey = (await client.readContract({\n address,\n abi: FEE_REGISTRY_ABI,\n functionName: \"operationKey\",\n args: [opName],\n })) as Hex;\n\n const fee = (await client.readContract({\n address,\n abi: FEE_REGISTRY_ABI,\n functionName: \"fees\",\n args: [opKey],\n })) as FeeEntry;\n\n if (fee.enabled && fee.payee === ZERO_ADDRESS) {\n throw new Error(\n `FeeRegistry: enabled operation \"${opName}\" has zero-address payee — contract pre-flight rejects payouts to 0x0`,\n );\n }\n\n return fee;\n}\n\n/**\n * Convenience: combine the FeeRegistry reads for one op type into the\n * compound shape the pay handler validates against.\n *\n * For 'grant' opType the result includes both registration + data_access\n * components; for other op types data_access is always disabled with\n * amount=0. Disabled components contribute 0 to the signed total —\n * callers compute `amount = registrationFee + dataAccessFee` and the pay\n * handler accepts (or short-circuits with 'Payment not required' when\n * both are 0).\n *\n * Throws on asset mismatch ONLY when both components are enabled — a\n * disabled fee never lands as a SettleOp, so its asset is moot.\n */\nexport async function getOpFee(\n client: PublicClient,\n config: DataPortabilityGatewayConfig,\n opType: string,\n opts?: FeeRegistryOptions,\n): Promise<OpFee> {\n const registrationKind = REGISTRATION_KIND_FOR_OP[opType];\n if (!registrationKind) {\n throw new Error(\n `getOpFee: unknown opType \"${opType}\" — supported types are ${Object.keys(REGISTRATION_KIND_FOR_OP).join(\", \")}`,\n );\n }\n\n const includeDataAccess = opType === \"grant\";\n const [registration, dataAccess] = await Promise.all([\n getFee(client, config, registrationKind, opts),\n includeDataAccess\n ? getFee(client, config, \"data_access\", opts)\n : Promise.resolve<FeeEntry>({\n amount: 0n,\n asset: ZERO_ADDRESS,\n payee: ZERO_ADDRESS,\n enabled: false,\n }),\n ]);\n\n if (\n registration.enabled &&\n dataAccess.enabled &&\n registration.asset.toLowerCase() !== dataAccess.asset.toLowerCase()\n ) {\n throw new Error(\n `FeeRegistry asset mismatch for \"${opType}\": registration=${registration.asset} vs data_access=${dataAccess.asset}. The gateway requires both kinds to settle in the same asset when both are enabled.`,\n );\n }\n\n const asset = registration.enabled\n ? registration.asset\n : dataAccess.enabled\n ? dataAccess.asset\n : ZERO_ADDRESS;\n\n return {\n asset,\n registrationFee: registration.enabled ? registration.amount : 0n,\n dataAccessFee: dataAccess.enabled ? dataAccess.amount : 0n,\n registrationEnabled: registration.enabled,\n dataAccessEnabled: dataAccess.enabled,\n registrationPayee: registration.enabled ? registration.payee : ZERO_ADDRESS,\n dataAccessPayee: dataAccess.enabled ? dataAccess.payee : ZERO_ADDRESS,\n };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAyCA,kBAAoE;AAG7D,MAAM,uBAAmB,sBAAS;AAAA,EACvC;AAAA,EACA;AAAA,EACA;AACF,CAAC;AAiBM,MAAM,2BAAoD;AAAA,EAC/D,OAAO;AAAA,EACP,MAAM;AAAA,EACN,QAAQ;AAAA,EACR,SAAS;AACX;AAmDA,SAAS,iBACP,MACA,MACQ;AACR,UAAQ,MAAM;AAAA,IACZ,KAAK;AACH,aAAO,MAAM,2BAA2B;AAAA,IAC1C,KAAK;AACH,aAAO,MAAM,oBAAoB;AAAA,IACnC,KAAK;AACH,aAAO,MAAM,0BAA0B;AAAA,IACzC,KAAK;AACH,aAAO,MAAM,4BAA4B;AAAA,IAC3C,KAAK;AACH,aAAO,MAAM,6BAA6B;AAAA,EAC9C;AACF;AAEA,MAAM,eAAe;AAarB,eAAsB,OACpB,QACA,QACA,MACA,MACmB;AACnB,QAAM,UAAU,OAAO,UAAU;AACjC,QAAM,SAAS,iBAAiB,MAAM,IAAI;AAE1C,QAAM,QAAS,MAAM,OAAO,aAAa;AAAA,IACvC;AAAA,IACA,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM;AAAA,EACf,CAAC;AAED,QAAM,MAAO,MAAM,OAAO,aAAa;AAAA,IACrC;AAAA,IACA,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,KAAK;AAAA,EACd,CAAC;AAED,MAAI,IAAI,WAAW,IAAI,UAAU,cAAc;AAC7C,UAAM,IAAI;AAAA,MACR,mCAAmC,MAAM;AAAA,IAC3C;AAAA,EACF;AAEA,SAAO;AACT;AAgBA,eAAsB,SACpB,QACA,QACA,QACA,MACgB;AAChB,QAAM,mBAAmB,yBAAyB,MAAM;AACxD,MAAI,CAAC,kBAAkB;AACrB,UAAM,IAAI;AAAA,MACR,6BAA6B,MAAM,gCAA2B,OAAO,KAAK,wBAAwB,EAAE,KAAK,IAAI,CAAC;AAAA,IAChH;AAAA,EACF;AAEA,QAAM,oBAAoB,WAAW;AACrC,QAAM,CAAC,cAAc,UAAU,IAAI,MAAM,QAAQ,IAAI;AAAA,IACnD,OAAO,QAAQ,QAAQ,kBAAkB,IAAI;AAAA,IAC7C,oBACI,OAAO,QAAQ,QAAQ,eAAe,IAAI,IAC1C,QAAQ,QAAkB;AAAA,MACxB,QAAQ;AAAA,MACR,OAAO;AAAA,MACP,OAAO;AAAA,MACP,SAAS;AAAA,IACX,CAAC;AAAA,EACP,CAAC;AAED,MACE,aAAa,WACb,WAAW,WACX,aAAa,MAAM,YAAY,MAAM,WAAW,MAAM,YAAY,GAClE;AACA,UAAM,IAAI;AAAA,MACR,mCAAmC,MAAM,mBAAmB,aAAa,KAAK,mBAAmB,WAAW,KAAK;AAAA,IACnH;AAAA,EACF;AAEA,QAAM,QAAQ,aAAa,UACvB,aAAa,QACb,WAAW,UACT,WAAW,QACX;AAEN,SAAO;AAAA,IACL;AAAA,IACA,iBAAiB,aAAa,UAAU,aAAa,SAAS;AAAA,IAC9D,eAAe,WAAW,UAAU,WAAW,SAAS;AAAA,IACxD,qBAAqB,aAAa;AAAA,IAClC,mBAAmB,WAAW;AAAA,IAC9B,mBAAmB,aAAa,UAAU,aAAa,QAAQ;AAAA,IAC/D,iBAAiB,WAAW,UAAU,WAAW,QAAQ;AAAA,EAC3D;AACF;","names":[]}