@opendatalabs/vana-sdk 3.4.1 → 3.5.1-pr.159.12a6f39

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 (136) hide show
  1. package/README.md +116 -0
  2. package/dist/account/personal-server-lite-owner-binding.cjs +3 -3
  3. package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
  4. package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
  5. package/dist/account/personal-server-lite-owner-binding.js +1 -1
  6. package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
  7. package/dist/direct/access-request-client.cjs +104 -0
  8. package/dist/direct/access-request-client.cjs.map +1 -0
  9. package/dist/direct/access-request-client.d.ts +51 -0
  10. package/dist/direct/access-request-client.js +79 -0
  11. package/dist/direct/access-request-client.js.map +1 -0
  12. package/dist/direct/access-request-client.test.d.ts +1 -0
  13. package/dist/direct/connect-flow.cjs +152 -0
  14. package/dist/direct/connect-flow.cjs.map +1 -0
  15. package/dist/direct/connect-flow.d.ts +85 -0
  16. package/dist/direct/connect-flow.js +128 -0
  17. package/dist/direct/connect-flow.js.map +1 -0
  18. package/dist/direct/connect-flow.test.d.ts +1 -0
  19. package/dist/direct/controller.cjs +129 -0
  20. package/dist/direct/controller.cjs.map +1 -0
  21. package/dist/direct/controller.d.ts +152 -0
  22. package/dist/direct/controller.js +109 -0
  23. package/dist/direct/controller.js.map +1 -0
  24. package/dist/direct/controller.test.d.ts +1 -0
  25. package/dist/direct/endpoints.cjs +45 -0
  26. package/dist/direct/endpoints.cjs.map +1 -0
  27. package/dist/direct/endpoints.d.ts +22 -0
  28. package/dist/direct/endpoints.js +19 -0
  29. package/dist/direct/endpoints.js.map +1 -0
  30. package/dist/direct/errors.cjs +65 -0
  31. package/dist/direct/errors.cjs.map +1 -0
  32. package/dist/direct/errors.d.ts +44 -0
  33. package/dist/direct/errors.js +38 -0
  34. package/dist/direct/errors.js.map +1 -0
  35. package/dist/direct/escrow-payment.cjs +96 -0
  36. package/dist/direct/escrow-payment.cjs.map +1 -0
  37. package/dist/direct/escrow-payment.d.ts +81 -0
  38. package/dist/direct/escrow-payment.js +72 -0
  39. package/dist/direct/escrow-payment.js.map +1 -0
  40. package/dist/direct/escrow-payment.test.d.ts +1 -0
  41. package/dist/direct/personal-server-read.cjs +149 -0
  42. package/dist/direct/personal-server-read.cjs.map +1 -0
  43. package/dist/direct/personal-server-read.d.ts +103 -0
  44. package/dist/direct/personal-server-read.js +124 -0
  45. package/dist/direct/personal-server-read.js.map +1 -0
  46. package/dist/direct/personal-server-read.test.d.ts +1 -0
  47. package/dist/direct/types.cjs +35 -0
  48. package/dist/direct/types.cjs.map +1 -0
  49. package/dist/direct/types.d.ts +205 -0
  50. package/dist/direct/types.js +11 -0
  51. package/dist/direct/types.js.map +1 -0
  52. package/dist/direct/use-direct-vana-connect.cjs +68 -0
  53. package/dist/direct/use-direct-vana-connect.cjs.map +1 -0
  54. package/dist/direct/use-direct-vana-connect.d.ts +45 -0
  55. package/dist/direct/use-direct-vana-connect.js +46 -0
  56. package/dist/direct/use-direct-vana-connect.js.map +1 -0
  57. package/dist/index.browser.d.ts +9 -4
  58. package/dist/index.browser.js +644 -178
  59. package/dist/index.browser.js.map +4 -4
  60. package/dist/index.node.cjs +672 -183
  61. package/dist/index.node.cjs.map +4 -4
  62. package/dist/index.node.d.ts +9 -4
  63. package/dist/index.node.js +644 -178
  64. package/dist/index.node.js.map +4 -4
  65. package/dist/personal-server-lite/owner-binding.cjs +93 -0
  66. package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
  67. package/dist/personal-server-lite/owner-binding.d.ts +44 -0
  68. package/dist/personal-server-lite/owner-binding.js +65 -0
  69. package/dist/personal-server-lite/owner-binding.js.map +1 -0
  70. package/dist/personal-server-lite/owner-binding.test.d.ts +1 -0
  71. package/dist/protocol/data-point-status.cjs +80 -0
  72. package/dist/protocol/data-point-status.cjs.map +1 -0
  73. package/dist/protocol/data-point-status.d.ts +34 -0
  74. package/dist/protocol/data-point-status.js +51 -0
  75. package/dist/protocol/data-point-status.js.map +1 -0
  76. package/dist/protocol/data-point-status.test.d.ts +1 -0
  77. package/dist/protocol/eip712.cjs +53 -31
  78. package/dist/protocol/eip712.cjs.map +1 -1
  79. package/dist/protocol/eip712.d.ts +98 -43
  80. package/dist/protocol/eip712.js +47 -27
  81. package/dist/protocol/eip712.js.map +1 -1
  82. package/dist/protocol/escrow-deposit.cjs +89 -0
  83. package/dist/protocol/escrow-deposit.cjs.map +1 -0
  84. package/dist/protocol/escrow-deposit.d.ts +47 -0
  85. package/dist/protocol/escrow-deposit.js +60 -0
  86. package/dist/protocol/escrow-deposit.js.map +1 -0
  87. package/dist/protocol/escrow-deposit.test.d.ts +1 -0
  88. package/dist/protocol/escrow-flow.test.d.ts +21 -0
  89. package/dist/protocol/escrow.cjs +146 -0
  90. package/dist/protocol/escrow.cjs.map +1 -0
  91. package/dist/protocol/escrow.d.ts +336 -0
  92. package/dist/protocol/escrow.js +118 -0
  93. package/dist/protocol/escrow.js.map +1 -0
  94. package/dist/protocol/escrow.test.d.ts +1 -0
  95. package/dist/protocol/fee-registry.cjs +116 -0
  96. package/dist/protocol/fee-registry.cjs.map +1 -0
  97. package/dist/protocol/fee-registry.d.ts +151 -0
  98. package/dist/protocol/fee-registry.js +89 -0
  99. package/dist/protocol/fee-registry.js.map +1 -0
  100. package/dist/protocol/fee-registry.test.d.ts +1 -0
  101. package/dist/protocol/gateway.cjs +107 -37
  102. package/dist/protocol/gateway.cjs.map +1 -1
  103. package/dist/protocol/gateway.d.ts +223 -57
  104. package/dist/protocol/gateway.js +107 -37
  105. package/dist/protocol/gateway.js.map +1 -1
  106. package/dist/protocol/grants.cjs +27 -64
  107. package/dist/protocol/grants.cjs.map +1 -1
  108. package/dist/protocol/grants.d.ts +6 -13
  109. package/dist/protocol/grants.js +27 -63
  110. package/dist/protocol/grants.js.map +1 -1
  111. package/dist/protocol/personal-server-data.cjs +71 -0
  112. package/dist/protocol/personal-server-data.cjs.map +1 -0
  113. package/dist/protocol/personal-server-data.d.ts +16 -0
  114. package/dist/protocol/personal-server-data.js +47 -0
  115. package/dist/protocol/personal-server-data.js.map +1 -0
  116. package/dist/protocol/personal-server-data.test.d.ts +1 -0
  117. package/dist/protocol/personal-server-registration.cjs +16 -4
  118. package/dist/protocol/personal-server-registration.cjs.map +1 -1
  119. package/dist/protocol/personal-server-registration.d.ts +5 -2
  120. package/dist/protocol/personal-server-registration.js +16 -4
  121. package/dist/protocol/personal-server-registration.js.map +1 -1
  122. package/dist/react.cjs +32 -0
  123. package/dist/react.cjs.map +1 -0
  124. package/dist/react.d.ts +33 -0
  125. package/dist/react.js +11 -0
  126. package/dist/react.js.map +1 -0
  127. package/dist/server.cjs +73 -0
  128. package/dist/server.cjs.map +1 -0
  129. package/dist/server.d.ts +32 -0
  130. package/dist/server.js +55 -0
  131. package/dist/server.js.map +1 -0
  132. package/dist/storage/providers/vana-storage.cjs +75 -17
  133. package/dist/storage/providers/vana-storage.cjs.map +1 -1
  134. package/dist/storage/providers/vana-storage.js +75 -17
  135. package/dist/storage/providers/vana-storage.js.map +1 -1
  136. package/package.json +20 -1
@@ -12,38 +12,20 @@ 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
- export declare function fileRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
21
- export declare function fileDeletionDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
23
+ export declare function dataRegistryDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
22
24
  export declare function grantRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
23
25
  export declare function grantRevocationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
24
26
  export declare function serverRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
25
27
  export declare function builderRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
26
- export declare const FILE_REGISTRATION_TYPES: {
27
- readonly FileRegistration: readonly [{
28
- readonly name: "ownerAddress";
29
- readonly type: "address";
30
- }, {
31
- readonly name: "url";
32
- readonly type: "string";
33
- }, {
34
- readonly name: "schemaId";
35
- readonly type: "bytes32";
36
- }];
37
- };
38
- export declare const FILE_DELETION_TYPES: {
39
- readonly FileDeletion: readonly [{
40
- readonly name: "ownerAddress";
41
- readonly type: "address";
42
- }, {
43
- readonly name: "fileId";
44
- readonly type: "bytes32";
45
- }];
46
- };
28
+ export declare function escrowPaymentDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
47
29
  export declare const GRANT_REGISTRATION_TYPES: {
48
30
  readonly GrantRegistration: readonly [{
49
31
  readonly name: "grantorAddress";
@@ -52,11 +34,14 @@ export declare const GRANT_REGISTRATION_TYPES: {
52
34
  readonly name: "granteeId";
53
35
  readonly type: "bytes32";
54
36
  }, {
55
- readonly name: "grant";
56
- readonly type: "string";
37
+ readonly name: "scopes";
38
+ readonly type: "string[]";
57
39
  }, {
58
- readonly name: "fileIds";
59
- readonly type: "uint256[]";
40
+ readonly name: "grantVersion";
41
+ readonly type: "uint256";
42
+ }, {
43
+ readonly name: "expiresAt";
44
+ readonly type: "uint256";
60
45
  }];
61
46
  };
62
47
  export declare const GRANT_REVOCATION_TYPES: {
@@ -66,6 +51,9 @@ export declare const GRANT_REVOCATION_TYPES: {
66
51
  }, {
67
52
  readonly name: "grantId";
68
53
  readonly type: "bytes32";
54
+ }, {
55
+ readonly name: "grantVersion";
56
+ readonly type: "uint256";
69
57
  }];
70
58
  };
71
59
  export declare const SERVER_REGISTRATION_TYPES: {
@@ -98,29 +86,74 @@ export declare const BUILDER_REGISTRATION_TYPES: {
98
86
  readonly type: "string";
99
87
  }];
100
88
  };
101
- export interface FileRegistrationMessage {
102
- ownerAddress: `0x${string}`;
103
- url: string;
104
- schemaId: `0x${string}`;
105
- }
106
- export interface FileDeletionMessage {
107
- ownerAddress: `0x${string}`;
108
- /**
109
- * Off-chain gateway file ID — bytes32, as returned by `GET /v1/files`. This is NOT the on-chain
110
- * uint256 DataRegistry file ID; consumers (e.g. the PS delete cascade) must source it from the
111
- * gateway, not derive it from a numeric on-chain ID.
112
- */
113
- fileId: `0x${string}`;
114
- }
89
+ export declare const GENERIC_PAYMENT_TYPES: {
90
+ readonly GenericPayment: readonly [{
91
+ readonly name: "payerAddress";
92
+ readonly type: "address";
93
+ }, {
94
+ readonly name: "opType";
95
+ readonly type: "string";
96
+ }, {
97
+ readonly name: "opId";
98
+ readonly type: "bytes32";
99
+ }, {
100
+ readonly name: "asset";
101
+ readonly type: "address";
102
+ }, {
103
+ readonly name: "amount";
104
+ readonly type: "uint256";
105
+ }, {
106
+ readonly name: "paymentNonce";
107
+ readonly type: "uint256";
108
+ }];
109
+ };
110
+ export declare const ADD_DATA_TYPES: {
111
+ readonly AddData: readonly [{
112
+ readonly name: "ownerAddress";
113
+ readonly type: "address";
114
+ }, {
115
+ readonly name: "scope";
116
+ readonly type: "string";
117
+ }, {
118
+ readonly name: "dataHash";
119
+ readonly type: "bytes32";
120
+ }, {
121
+ readonly name: "metadataHash";
122
+ readonly type: "bytes32";
123
+ }, {
124
+ readonly name: "expectedVersion";
125
+ readonly type: "uint256";
126
+ }];
127
+ };
128
+ export declare const RECORD_DATA_ACCESS_TYPES: {
129
+ readonly RecordDataAccess: readonly [{
130
+ readonly name: "ownerAddress";
131
+ readonly type: "address";
132
+ }, {
133
+ readonly name: "scope";
134
+ readonly type: "string";
135
+ }, {
136
+ readonly name: "version";
137
+ readonly type: "uint256";
138
+ }, {
139
+ readonly name: "accessor";
140
+ readonly type: "address";
141
+ }, {
142
+ readonly name: "recordId";
143
+ readonly type: "bytes32";
144
+ }];
145
+ };
115
146
  export interface GrantRegistrationMessage {
116
147
  grantorAddress: `0x${string}`;
117
148
  granteeId: `0x${string}`;
118
- grant: string;
119
- fileIds: bigint[];
149
+ scopes: string[];
150
+ grantVersion: bigint;
151
+ expiresAt: bigint;
120
152
  }
121
153
  export interface GrantRevocationMessage {
122
154
  grantorAddress: `0x${string}`;
123
155
  grantId: `0x${string}`;
156
+ grantVersion: bigint;
124
157
  }
125
158
  export interface ServerRegistrationMessage {
126
159
  ownerAddress: `0x${string}`;
@@ -134,3 +167,25 @@ export interface BuilderRegistrationMessage {
134
167
  publicKey: string;
135
168
  appUrl: string;
136
169
  }
170
+ export interface GenericPaymentMessage {
171
+ payerAddress: `0x${string}`;
172
+ opType: string;
173
+ opId: `0x${string}`;
174
+ asset: `0x${string}`;
175
+ amount: bigint;
176
+ paymentNonce: bigint;
177
+ }
178
+ export interface AddDataMessage {
179
+ ownerAddress: `0x${string}`;
180
+ scope: string;
181
+ dataHash: `0x${string}`;
182
+ metadataHash: `0x${string}`;
183
+ expectedVersion: bigint;
184
+ }
185
+ export interface RecordDataAccessMessage {
186
+ ownerAddress: `0x${string}`;
187
+ scope: string;
188
+ version: bigint;
189
+ accessor: `0x${string}`;
190
+ recordId: `0x${string}`;
191
+ }
@@ -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;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E,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"],"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AAA,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 {};