@opendatalabs/vana-sdk 3.4.1-canary.e9d0aad → 3.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/account/personal-server-lite-owner-binding.cjs +3 -3
- package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
- package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
- package/dist/account/personal-server-lite-owner-binding.js +1 -1
- package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
- package/dist/index.browser.d.ts +5 -8
- package/dist/index.browser.js +250 -416
- package/dist/index.browser.js.map +4 -4
- package/dist/index.node.cjs +258 -439
- package/dist/index.node.cjs.map +4 -4
- package/dist/index.node.d.ts +5 -8
- package/dist/index.node.js +250 -416
- package/dist/index.node.js.map +4 -4
- package/dist/{protocol/personal-server-lite-owner-binding.cjs → personal-server-lite/owner-binding.cjs} +5 -5
- package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
- package/dist/{protocol/personal-server-lite-owner-binding.d.ts → personal-server-lite/owner-binding.d.ts} +3 -3
- package/dist/{protocol/personal-server-lite-owner-binding.js → personal-server-lite/owner-binding.js} +2 -2
- package/dist/personal-server-lite/owner-binding.js.map +1 -0
- package/dist/protocol/eip712.cjs +31 -53
- package/dist/protocol/eip712.cjs.map +1 -1
- package/dist/protocol/eip712.d.ts +43 -98
- package/dist/protocol/eip712.js +27 -47
- package/dist/protocol/eip712.js.map +1 -1
- package/dist/protocol/escrow.cjs +146 -0
- package/dist/protocol/escrow.cjs.map +1 -0
- package/dist/protocol/escrow.d.ts +336 -0
- package/dist/protocol/escrow.js +118 -0
- package/dist/protocol/escrow.js.map +1 -0
- package/dist/protocol/gateway.cjs +37 -107
- package/dist/protocol/gateway.cjs.map +1 -1
- package/dist/protocol/gateway.d.ts +57 -223
- package/dist/protocol/gateway.js +37 -107
- package/dist/protocol/gateway.js.map +1 -1
- package/dist/protocol/grants.cjs +64 -27
- package/dist/protocol/grants.cjs.map +1 -1
- package/dist/protocol/grants.d.ts +13 -6
- package/dist/protocol/grants.js +63 -27
- package/dist/protocol/grants.js.map +1 -1
- package/dist/protocol/personal-server-registration.cjs +16 -4
- package/dist/protocol/personal-server-registration.cjs.map +1 -1
- package/dist/protocol/personal-server-registration.d.ts +5 -2
- package/dist/protocol/personal-server-registration.js +16 -4
- package/dist/protocol/personal-server-registration.js.map +1 -1
- package/package.json +2 -3
- package/dist/protocol/data-point-status.cjs +0 -80
- package/dist/protocol/data-point-status.cjs.map +0 -1
- package/dist/protocol/data-point-status.d.ts +0 -34
- package/dist/protocol/data-point-status.js +0 -51
- package/dist/protocol/data-point-status.js.map +0 -1
- package/dist/protocol/escrow-deposit.cjs +0 -89
- package/dist/protocol/escrow-deposit.cjs.map +0 -1
- package/dist/protocol/escrow-deposit.d.ts +0 -47
- package/dist/protocol/escrow-deposit.js +0 -60
- package/dist/protocol/escrow-deposit.js.map +0 -1
- package/dist/protocol/escrow-flow.test.d.ts +0 -21
- package/dist/protocol/fee-registry.cjs +0 -116
- package/dist/protocol/fee-registry.cjs.map +0 -1
- package/dist/protocol/fee-registry.d.ts +0 -151
- package/dist/protocol/fee-registry.js +0 -89
- package/dist/protocol/fee-registry.js.map +0 -1
- package/dist/protocol/fee-registry.test.d.ts +0 -1
- package/dist/protocol/personal-server-data.cjs +0 -71
- package/dist/protocol/personal-server-data.cjs.map +0 -1
- package/dist/protocol/personal-server-data.d.ts +0 -16
- package/dist/protocol/personal-server-data.js +0 -47
- package/dist/protocol/personal-server-data.js.map +0 -1
- package/dist/protocol/personal-server-data.test.d.ts +0 -1
- package/dist/protocol/personal-server-lite-owner-binding.cjs.map +0 -1
- package/dist/protocol/personal-server-lite-owner-binding.js.map +0 -1
- package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +0 -1
- /package/dist/{protocol/data-point-status.test.d.ts → personal-server-lite/owner-binding.test.d.ts} +0 -0
- /package/dist/protocol/{escrow-deposit.test.d.ts → escrow.test.d.ts} +0 -0
|
@@ -16,8 +16,8 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
-
var
|
|
20
|
-
__export(
|
|
19
|
+
var owner_binding_exports = {};
|
|
20
|
+
__export(owner_binding_exports, {
|
|
21
21
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX: () => PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX,
|
|
22
22
|
PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE: () => PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,
|
|
23
23
|
PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION: () => PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION,
|
|
@@ -26,9 +26,9 @@ __export(personal_server_lite_owner_binding_exports, {
|
|
|
26
26
|
createViemPersonalServerLiteOwnerBindingSigner: () => createViemPersonalServerLiteOwnerBindingSigner,
|
|
27
27
|
signPersonalServerLiteOwnerBinding: () => signPersonalServerLiteOwnerBinding
|
|
28
28
|
});
|
|
29
|
-
module.exports = __toCommonJS(
|
|
29
|
+
module.exports = __toCommonJS(owner_binding_exports);
|
|
30
30
|
var import_viem = require("viem");
|
|
31
|
-
const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.
|
|
31
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
32
32
|
const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
33
33
|
const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
34
34
|
function assertAddress(value, name) {
|
|
@@ -90,4 +90,4 @@ const signPersonalServerLiteOwnerBinding = buildPersonalServerLiteOwnerBindingSi
|
|
|
90
90
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
91
91
|
signPersonalServerLiteOwnerBinding
|
|
92
92
|
});
|
|
93
|
-
//# sourceMappingURL=
|
|
93
|
+
//# sourceMappingURL=owner-binding.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/personal-server-lite/owner-binding.ts"],"sourcesContent":["/**\n * PS Lite owner-binding message and signing helpers.\n *\n * PS Lite uses this replayable personal-sign message as a wallet-owned input\n * for opening the user's local encrypted runtime. This is intentionally\n * separate from Personal Server registration, which is EIP-712 typed data.\n *\n * @category Personal Server Lite\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type SignableMessage,\n} from \"viem\";\n\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION =\n \"vana.ps-lite.owner-binding.v1\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = \"ps-lite-owner\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX =\n `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:` as const;\n\nexport type PersonalServerLiteOwnerBindingPurpose =\n typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE;\n\nexport type PersonalServerLiteOwnerBindingMessage =\n `${typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${Lowercase<Address>}`;\n\nexport interface PersonalServerLiteOwnerBindingSigner {\n address: Address;\n signMessage(input: {\n message: PersonalServerLiteOwnerBindingMessage;\n }): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerLiteOwnerBindingWalletClient {\n account?: Account | Address | null;\n signMessage(input: {\n account?: Account | Address;\n message: SignableMessage;\n }): Promise<Hex>;\n}\n\nexport type ViemPersonalServerLiteOwnerBindingSignerSource =\n | PersonalServerLiteOwnerBindingSigner\n | ViemPersonalServerLiteOwnerBindingWalletClient;\n\nexport interface BuildPersonalServerLiteOwnerBindingSignatureInput {\n signer: PersonalServerLiteOwnerBindingSigner;\n}\n\nexport interface PersonalServerLiteOwnerBindingSignature {\n signature: Hex;\n signerAddress: Address;\n message: PersonalServerLiteOwnerBindingMessage;\n purpose: PersonalServerLiteOwnerBindingPurpose;\n}\n\nfunction assertAddress(value: Address, name: string): void {\n if (!isAddress(value)) {\n throw new Error(`${name} must be a valid EVM address`);\n }\n}\n\nfunction getAccountAddress(\n account: Account | Address | null | undefined,\n): Address | undefined {\n if (!account) {\n return undefined;\n }\n\n return typeof account === \"string\" ? account : account.address;\n}\n\nfunction isPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n): source is PersonalServerLiteOwnerBindingSigner {\n return \"address\" in source && typeof source.signMessage === \"function\";\n}\n\nexport function buildPersonalServerLiteOwnerBindingMessage(\n ownerAddress: Address,\n): PersonalServerLiteOwnerBindingMessage {\n assertAddress(ownerAddress, \"ownerAddress\");\n return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}` as PersonalServerLiteOwnerBindingMessage;\n}\n\nexport function createViemPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerLiteOwnerBindingSigner {\n if (isPersonalServerLiteOwnerBindingSigner(source)) {\n return source;\n }\n\n const accountAddress =\n getAccountAddress(options.account) ?? getAccountAddress(source.account);\n\n if (accountAddress) {\n return {\n address: accountAddress,\n signMessage: ({ message }) =>\n source.signMessage({\n account: options.account ?? source.account ?? accountAddress,\n message,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport async function buildPersonalServerLiteOwnerBindingSignature(\n input: BuildPersonalServerLiteOwnerBindingSignatureInput,\n): Promise<PersonalServerLiteOwnerBindingSignature> {\n const message = buildPersonalServerLiteOwnerBindingMessage(\n input.signer.address,\n );\n const signature = await input.signer.signMessage({ message });\n\n return {\n signature,\n signerAddress: input.signer.address,\n message,\n purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,\n };\n}\n\nexport const signPersonalServerLiteOwnerBinding =\n buildPersonalServerLiteOwnerBindingSignature;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kBAMO;AAEA,MAAM,6CACX;AACK,MAAM,6CAA6C;AACnD,MAAM,4CACX,GAAG,0CAA0C,IAAI,0CAA0C;AAsC7F,SAAS,cAAc,OAAgB,MAAoB;AACzD,MAAI,KAAC,uBAAU,KAAK,GAAG;AACrB,UAAM,IAAI,MAAM,GAAG,IAAI,8BAA8B;AAAA,EACvD;AACF;AAEA,SAAS,kBACP,SACqB;AACrB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ;AACzD;AAEA,SAAS,uCACP,QACgD;AAChD,SAAO,aAAa,UAAU,OAAO,OAAO,gBAAgB;AAC9D;AAEO,SAAS,2CACd,cACuC;AACvC,gBAAc,cAAc,cAAc;AAC1C,SAAO,GAAG,yCAAyC,GAAG,aAAa,YAAY,CAAC;AAClF;AAEO,SAAS,+CACd,QACA,UAA2C,CAAC,GACN;AACtC,MAAI,uCAAuC,MAAM,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa,CAAC,EAAE,QAAQ,MACtB,OAAO,YAAY;AAAA,QACjB,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,QAC9C;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEA,eAAsB,6CACpB,OACkD;AAClD,QAAM,UAAU;AAAA,IACd,MAAM,OAAO;AAAA,EACf;AACA,QAAM,YAAY,MAAM,MAAM,OAAO,YAAY,EAAE,QAAQ,CAAC;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAEO,MAAM,qCACX;","names":[]}
|
|
@@ -5,12 +5,12 @@
|
|
|
5
5
|
* for opening the user's local encrypted runtime. This is intentionally
|
|
6
6
|
* separate from Personal Server registration, which is EIP-712 typed data.
|
|
7
7
|
*
|
|
8
|
-
* @category
|
|
8
|
+
* @category Personal Server Lite
|
|
9
9
|
*/
|
|
10
10
|
import { type Account, type Address, type Hex, type SignableMessage } from "viem";
|
|
11
|
-
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.
|
|
11
|
+
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
12
12
|
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
13
|
-
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX: "vana.
|
|
13
|
+
export declare const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX: "vana.ps-lite.owner-binding.v1:ps-lite-owner:";
|
|
14
14
|
export type PersonalServerLiteOwnerBindingPurpose = typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE;
|
|
15
15
|
export type PersonalServerLiteOwnerBindingMessage = `${typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${Lowercase<Address>}`;
|
|
16
16
|
export interface PersonalServerLiteOwnerBindingSigner {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import {
|
|
2
2
|
isAddress
|
|
3
3
|
} from "viem";
|
|
4
|
-
const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.
|
|
4
|
+
const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION = "vana.ps-lite.owner-binding.v1";
|
|
5
5
|
const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = "ps-lite-owner";
|
|
6
6
|
const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX = `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:`;
|
|
7
7
|
function assertAddress(value, name) {
|
|
@@ -62,4 +62,4 @@ export {
|
|
|
62
62
|
createViemPersonalServerLiteOwnerBindingSigner,
|
|
63
63
|
signPersonalServerLiteOwnerBinding
|
|
64
64
|
};
|
|
65
|
-
//# sourceMappingURL=
|
|
65
|
+
//# sourceMappingURL=owner-binding.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../../src/personal-server-lite/owner-binding.ts"],"sourcesContent":["/**\n * PS Lite owner-binding message and signing helpers.\n *\n * PS Lite uses this replayable personal-sign message as a wallet-owned input\n * for opening the user's local encrypted runtime. This is intentionally\n * separate from Personal Server registration, which is EIP-712 typed data.\n *\n * @category Personal Server Lite\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type SignableMessage,\n} from \"viem\";\n\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION =\n \"vana.ps-lite.owner-binding.v1\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE = \"ps-lite-owner\";\nexport const PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX =\n `${PERSONAL_SERVER_LITE_OWNER_BINDING_VERSION}:${PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE}:` as const;\n\nexport type PersonalServerLiteOwnerBindingPurpose =\n typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE;\n\nexport type PersonalServerLiteOwnerBindingMessage =\n `${typeof PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${Lowercase<Address>}`;\n\nexport interface PersonalServerLiteOwnerBindingSigner {\n address: Address;\n signMessage(input: {\n message: PersonalServerLiteOwnerBindingMessage;\n }): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerLiteOwnerBindingWalletClient {\n account?: Account | Address | null;\n signMessage(input: {\n account?: Account | Address;\n message: SignableMessage;\n }): Promise<Hex>;\n}\n\nexport type ViemPersonalServerLiteOwnerBindingSignerSource =\n | PersonalServerLiteOwnerBindingSigner\n | ViemPersonalServerLiteOwnerBindingWalletClient;\n\nexport interface BuildPersonalServerLiteOwnerBindingSignatureInput {\n signer: PersonalServerLiteOwnerBindingSigner;\n}\n\nexport interface PersonalServerLiteOwnerBindingSignature {\n signature: Hex;\n signerAddress: Address;\n message: PersonalServerLiteOwnerBindingMessage;\n purpose: PersonalServerLiteOwnerBindingPurpose;\n}\n\nfunction assertAddress(value: Address, name: string): void {\n if (!isAddress(value)) {\n throw new Error(`${name} must be a valid EVM address`);\n }\n}\n\nfunction getAccountAddress(\n account: Account | Address | null | undefined,\n): Address | undefined {\n if (!account) {\n return undefined;\n }\n\n return typeof account === \"string\" ? account : account.address;\n}\n\nfunction isPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n): source is PersonalServerLiteOwnerBindingSigner {\n return \"address\" in source && typeof source.signMessage === \"function\";\n}\n\nexport function buildPersonalServerLiteOwnerBindingMessage(\n ownerAddress: Address,\n): PersonalServerLiteOwnerBindingMessage {\n assertAddress(ownerAddress, \"ownerAddress\");\n return `${PERSONAL_SERVER_LITE_OWNER_BINDING_PREFIX}${ownerAddress.toLowerCase()}` as PersonalServerLiteOwnerBindingMessage;\n}\n\nexport function createViemPersonalServerLiteOwnerBindingSigner(\n source: ViemPersonalServerLiteOwnerBindingSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerLiteOwnerBindingSigner {\n if (isPersonalServerLiteOwnerBindingSigner(source)) {\n return source;\n }\n\n const accountAddress =\n getAccountAddress(options.account) ?? getAccountAddress(source.account);\n\n if (accountAddress) {\n return {\n address: accountAddress,\n signMessage: ({ message }) =>\n source.signMessage({\n account: options.account ?? source.account ?? accountAddress,\n message,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport async function buildPersonalServerLiteOwnerBindingSignature(\n input: BuildPersonalServerLiteOwnerBindingSignatureInput,\n): Promise<PersonalServerLiteOwnerBindingSignature> {\n const message = buildPersonalServerLiteOwnerBindingMessage(\n input.signer.address,\n );\n const signature = await input.signer.signMessage({ message });\n\n return {\n signature,\n signerAddress: input.signer.address,\n message,\n purpose: PERSONAL_SERVER_LITE_OWNER_BINDING_PURPOSE,\n };\n}\n\nexport const signPersonalServerLiteOwnerBinding =\n buildPersonalServerLiteOwnerBindingSignature;\n"],"mappings":"AAUA;AAAA,EACE;AAAA,OAKK;AAEA,MAAM,6CACX;AACK,MAAM,6CAA6C;AACnD,MAAM,4CACX,GAAG,0CAA0C,IAAI,0CAA0C;AAsC7F,SAAS,cAAc,OAAgB,MAAoB;AACzD,MAAI,CAAC,UAAU,KAAK,GAAG;AACrB,UAAM,IAAI,MAAM,GAAG,IAAI,8BAA8B;AAAA,EACvD;AACF;AAEA,SAAS,kBACP,SACqB;AACrB,MAAI,CAAC,SAAS;AACZ,WAAO;AAAA,EACT;AAEA,SAAO,OAAO,YAAY,WAAW,UAAU,QAAQ;AACzD;AAEA,SAAS,uCACP,QACgD;AAChD,SAAO,aAAa,UAAU,OAAO,OAAO,gBAAgB;AAC9D;AAEO,SAAS,2CACd,cACuC;AACvC,gBAAc,cAAc,cAAc;AAC1C,SAAO,GAAG,yCAAyC,GAAG,aAAa,YAAY,CAAC;AAClF;AAEO,SAAS,+CACd,QACA,UAA2C,CAAC,GACN;AACtC,MAAI,uCAAuC,MAAM,GAAG;AAClD,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,aAAa,CAAC,EAAE,QAAQ,MACtB,OAAO,YAAY;AAAA,QACjB,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,QAC9C;AAAA,MACF,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEA,eAAsB,6CACpB,OACkD;AAClD,QAAM,UAAU;AAAA,IACd,MAAM,OAAO;AAAA,EACf;AACA,QAAM,YAAY,MAAM,MAAM,OAAO,YAAY,EAAE,QAAQ,CAAC;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,IACA,SAAS;AAAA,EACX;AACF;AAEO,MAAM,qCACX;","names":[]}
|
package/dist/protocol/eip712.cjs
CHANGED
|
@@ -18,17 +18,15 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
18
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
19
|
var eip712_exports = {};
|
|
20
20
|
__export(eip712_exports, {
|
|
21
|
-
ADD_DATA_TYPES: () => ADD_DATA_TYPES,
|
|
22
21
|
BUILDER_REGISTRATION_TYPES: () => BUILDER_REGISTRATION_TYPES,
|
|
23
|
-
|
|
22
|
+
FILE_DELETION_TYPES: () => FILE_DELETION_TYPES,
|
|
23
|
+
FILE_REGISTRATION_TYPES: () => FILE_REGISTRATION_TYPES,
|
|
24
24
|
GRANT_REGISTRATION_TYPES: () => GRANT_REGISTRATION_TYPES,
|
|
25
25
|
GRANT_REVOCATION_TYPES: () => GRANT_REVOCATION_TYPES,
|
|
26
|
-
NATIVE_VANA_ASSET: () => NATIVE_VANA_ASSET,
|
|
27
|
-
RECORD_DATA_ACCESS_TYPES: () => RECORD_DATA_ACCESS_TYPES,
|
|
28
26
|
SERVER_REGISTRATION_TYPES: () => SERVER_REGISTRATION_TYPES,
|
|
29
27
|
builderRegistrationDomain: () => builderRegistrationDomain,
|
|
30
|
-
|
|
31
|
-
|
|
28
|
+
fileDeletionDomain: () => fileDeletionDomain,
|
|
29
|
+
fileRegistrationDomain: () => fileRegistrationDomain,
|
|
32
30
|
grantRegistrationDomain: () => grantRegistrationDomain,
|
|
33
31
|
grantRevocationDomain: () => grantRevocationDomain,
|
|
34
32
|
serverRegistrationDomain: () => serverRegistrationDomain
|
|
@@ -36,7 +34,6 @@ __export(eip712_exports, {
|
|
|
36
34
|
module.exports = __toCommonJS(eip712_exports);
|
|
37
35
|
const DOMAIN_NAME = "Vana Data Portability";
|
|
38
36
|
const DOMAIN_VERSION = "1";
|
|
39
|
-
const NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
40
37
|
function buildDomain(chainId, verifyingContract) {
|
|
41
38
|
return {
|
|
42
39
|
name: DOMAIN_NAME,
|
|
@@ -45,7 +42,13 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
45
42
|
verifyingContract
|
|
46
43
|
};
|
|
47
44
|
}
|
|
48
|
-
function
|
|
45
|
+
function fileRegistrationDomain(config) {
|
|
46
|
+
return buildDomain(
|
|
47
|
+
config.chainId,
|
|
48
|
+
config.contracts.dataRegistry
|
|
49
|
+
);
|
|
50
|
+
}
|
|
51
|
+
function fileDeletionDomain(config) {
|
|
49
52
|
return buildDomain(
|
|
50
53
|
config.chainId,
|
|
51
54
|
config.contracts.dataRegistry
|
|
@@ -75,26 +78,31 @@ function builderRegistrationDomain(config) {
|
|
|
75
78
|
config.contracts.dataPortabilityGrantees
|
|
76
79
|
);
|
|
77
80
|
}
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
81
|
+
const FILE_REGISTRATION_TYPES = {
|
|
82
|
+
FileRegistration: [
|
|
83
|
+
{ name: "ownerAddress", type: "address" },
|
|
84
|
+
{ name: "url", type: "string" },
|
|
85
|
+
{ name: "schemaId", type: "bytes32" }
|
|
86
|
+
]
|
|
87
|
+
};
|
|
88
|
+
const FILE_DELETION_TYPES = {
|
|
89
|
+
FileDeletion: [
|
|
90
|
+
{ name: "ownerAddress", type: "address" },
|
|
91
|
+
{ name: "fileId", type: "bytes32" }
|
|
92
|
+
]
|
|
93
|
+
};
|
|
84
94
|
const GRANT_REGISTRATION_TYPES = {
|
|
85
95
|
GrantRegistration: [
|
|
86
96
|
{ name: "grantorAddress", type: "address" },
|
|
87
97
|
{ name: "granteeId", type: "bytes32" },
|
|
88
|
-
{ name: "
|
|
89
|
-
{ name: "
|
|
90
|
-
{ name: "expiresAt", type: "uint256" }
|
|
98
|
+
{ name: "grant", type: "string" },
|
|
99
|
+
{ name: "fileIds", type: "uint256[]" }
|
|
91
100
|
]
|
|
92
101
|
};
|
|
93
102
|
const GRANT_REVOCATION_TYPES = {
|
|
94
103
|
GrantRevocation: [
|
|
95
104
|
{ name: "grantorAddress", type: "address" },
|
|
96
|
-
{ name: "grantId", type: "bytes32" }
|
|
97
|
-
{ name: "grantVersion", type: "uint256" }
|
|
105
|
+
{ name: "grantId", type: "bytes32" }
|
|
98
106
|
]
|
|
99
107
|
};
|
|
100
108
|
const SERVER_REGISTRATION_TYPES = {
|
|
@@ -113,47 +121,17 @@ const BUILDER_REGISTRATION_TYPES = {
|
|
|
113
121
|
{ name: "appUrl", type: "string" }
|
|
114
122
|
]
|
|
115
123
|
};
|
|
116
|
-
const GENERIC_PAYMENT_TYPES = {
|
|
117
|
-
GenericPayment: [
|
|
118
|
-
{ name: "payerAddress", type: "address" },
|
|
119
|
-
{ name: "opType", type: "string" },
|
|
120
|
-
{ name: "opId", type: "bytes32" },
|
|
121
|
-
{ name: "asset", type: "address" },
|
|
122
|
-
{ name: "amount", type: "uint256" },
|
|
123
|
-
{ name: "paymentNonce", type: "uint256" }
|
|
124
|
-
]
|
|
125
|
-
};
|
|
126
|
-
const ADD_DATA_TYPES = {
|
|
127
|
-
AddData: [
|
|
128
|
-
{ name: "ownerAddress", type: "address" },
|
|
129
|
-
{ name: "scope", type: "string" },
|
|
130
|
-
{ name: "dataHash", type: "bytes32" },
|
|
131
|
-
{ name: "metadataHash", type: "bytes32" },
|
|
132
|
-
{ name: "expectedVersion", type: "uint256" }
|
|
133
|
-
]
|
|
134
|
-
};
|
|
135
|
-
const RECORD_DATA_ACCESS_TYPES = {
|
|
136
|
-
RecordDataAccess: [
|
|
137
|
-
{ name: "ownerAddress", type: "address" },
|
|
138
|
-
{ name: "scope", type: "string" },
|
|
139
|
-
{ name: "version", type: "uint256" },
|
|
140
|
-
{ name: "accessor", type: "address" },
|
|
141
|
-
{ name: "recordId", type: "bytes32" }
|
|
142
|
-
]
|
|
143
|
-
};
|
|
144
124
|
// Annotate the CommonJS export names for ESM import in node:
|
|
145
125
|
0 && (module.exports = {
|
|
146
|
-
ADD_DATA_TYPES,
|
|
147
126
|
BUILDER_REGISTRATION_TYPES,
|
|
148
|
-
|
|
127
|
+
FILE_DELETION_TYPES,
|
|
128
|
+
FILE_REGISTRATION_TYPES,
|
|
149
129
|
GRANT_REGISTRATION_TYPES,
|
|
150
130
|
GRANT_REVOCATION_TYPES,
|
|
151
|
-
NATIVE_VANA_ASSET,
|
|
152
|
-
RECORD_DATA_ACCESS_TYPES,
|
|
153
131
|
SERVER_REGISTRATION_TYPES,
|
|
154
132
|
builderRegistrationDomain,
|
|
155
|
-
|
|
156
|
-
|
|
133
|
+
fileDeletionDomain,
|
|
134
|
+
fileRegistrationDomain,
|
|
157
135
|
grantRegistrationDomain,
|
|
158
136
|
grantRevocationDomain,
|
|
159
137
|
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 // 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":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAmBhB,MAAM,oBACX;AAOF,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,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;AAA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M,UAAU,MAAM,SAAS;AAAA,IACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IAChC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,IACjC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,IAClC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,EAC1C;AACF;AAMO,MAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,IACP,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,mBAAmB,MAAM,UAAU;AAAA,EAC7C;AACF;AAMO,MAAM,2BAA2B;AAAA,EACtC,kBAAkB;AAAA,IAChB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACnC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/eip712.ts"],"sourcesContent":["/**\n * EIP-712 domain and type builders for Data Portability protocol writes.\n *\n * These helpers are shared primitives only. Personal Server runtimes own when\n * to sign and submit these payloads.\n *\n * @category Protocol\n */\n\nimport type { TypedDataDomain } from \"viem\";\n\nconst DOMAIN_NAME = \"Vana Data Portability\";\nconst DOMAIN_VERSION = \"1\";\n\nexport interface DataPortabilityContracts {\n dataRegistry: string;\n dataPortabilityPermissions: string;\n dataPortabilityServer: string;\n dataPortabilityGrantees: string;\n}\n\nexport interface DataPortabilityGatewayConfig {\n chainId: number;\n contracts: DataPortabilityContracts;\n}\n\nfunction buildDomain(\n chainId: number,\n verifyingContract: `0x${string}`,\n): TypedDataDomain {\n return {\n name: DOMAIN_NAME,\n version: DOMAIN_VERSION,\n chainId,\n verifyingContract,\n };\n}\n\nexport function fileRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function fileDeletionDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function grantRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function grantRevocationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function serverRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityServer as `0x${string}`,\n );\n}\n\nexport function builderRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityGrantees as `0x${string}`,\n );\n}\n\nexport const FILE_REGISTRATION_TYPES = {\n FileRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"url\", type: \"string\" },\n { name: \"schemaId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const FILE_DELETION_TYPES = {\n FileDeletion: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"fileId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"grant\", type: \"string\" },\n { name: \"fileIds\", type: \"uint256[]\" },\n ],\n} as const;\n\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const SERVER_REGISTRATION_TYPES = {\n ServerRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"serverAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"serverUrl\", type: \"string\" },\n ],\n} as const;\n\nexport const BUILDER_REGISTRATION_TYPES = {\n BuilderRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"granteeAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"appUrl\", type: \"string\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface FileDeletionMessage {\n ownerAddress: `0x${string}`;\n /**\n * Off-chain gateway file ID — bytes32, as returned by `GET /v1/files`. This is NOT the on-chain\n * uint256 DataRegistry file ID; consumers (e.g. the PS delete cascade) must source it from the\n * gateway, not derive it from a numeric on-chain ID.\n */\n fileId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n grant: string;\n fileIds: bigint[];\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n}\n\nexport interface ServerRegistrationMessage {\n ownerAddress: `0x${string}`;\n serverAddress: `0x${string}`;\n publicKey: string;\n serverUrl: string;\n}\n\nexport interface BuilderRegistrationMessage {\n ownerAddress: `0x${string}`;\n granteeAddress: `0x${string}`;\n publicKey: string;\n appUrl: string;\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAcvB,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAA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;AAAA,IAC1C,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,EACrC;AACF;AAEO,MAAM,4BAA4B;AAAA,EACvC,oBAAoB;AAAA,IAClB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,iBAAiB,MAAM,UAAU;AAAA,IACzC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,EACtC;AACF;AAEO,MAAM,6BAA6B;AAAA,EACxC,qBAAqB;AAAA,IACnB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,kBAAkB,MAAM,UAAU;AAAA,IAC1C,EAAE,MAAM,aAAa,MAAM,SAAS;AAAA,IACpC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,EACnC;AACF;","names":[]}
|
|
@@ -12,20 +12,38 @@ export interface DataPortabilityContracts {
|
|
|
12
12
|
dataPortabilityPermissions: string;
|
|
13
13
|
dataPortabilityServer: string;
|
|
14
14
|
dataPortabilityGrantees: string;
|
|
15
|
-
dataPortabilityEscrow: string;
|
|
16
|
-
feeRegistry: string;
|
|
17
15
|
}
|
|
18
|
-
export declare const NATIVE_VANA_ASSET: "0x0000000000000000000000000000000000000000";
|
|
19
16
|
export interface DataPortabilityGatewayConfig {
|
|
20
17
|
chainId: number;
|
|
21
18
|
contracts: DataPortabilityContracts;
|
|
22
19
|
}
|
|
23
|
-
export declare function
|
|
20
|
+
export declare function fileRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
|
|
21
|
+
export declare function fileDeletionDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
|
|
24
22
|
export declare function grantRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
|
|
25
23
|
export declare function grantRevocationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
|
|
26
24
|
export declare function serverRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
|
|
27
25
|
export declare function builderRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
|
|
28
|
-
export declare
|
|
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
|
+
};
|
|
29
47
|
export declare const GRANT_REGISTRATION_TYPES: {
|
|
30
48
|
readonly GrantRegistration: readonly [{
|
|
31
49
|
readonly name: "grantorAddress";
|
|
@@ -34,14 +52,11 @@ export declare const GRANT_REGISTRATION_TYPES: {
|
|
|
34
52
|
readonly name: "granteeId";
|
|
35
53
|
readonly type: "bytes32";
|
|
36
54
|
}, {
|
|
37
|
-
readonly name: "
|
|
38
|
-
readonly type: "string
|
|
39
|
-
}, {
|
|
40
|
-
readonly name: "grantVersion";
|
|
41
|
-
readonly type: "uint256";
|
|
55
|
+
readonly name: "grant";
|
|
56
|
+
readonly type: "string";
|
|
42
57
|
}, {
|
|
43
|
-
readonly name: "
|
|
44
|
-
readonly type: "uint256";
|
|
58
|
+
readonly name: "fileIds";
|
|
59
|
+
readonly type: "uint256[]";
|
|
45
60
|
}];
|
|
46
61
|
};
|
|
47
62
|
export declare const GRANT_REVOCATION_TYPES: {
|
|
@@ -51,9 +66,6 @@ export declare const GRANT_REVOCATION_TYPES: {
|
|
|
51
66
|
}, {
|
|
52
67
|
readonly name: "grantId";
|
|
53
68
|
readonly type: "bytes32";
|
|
54
|
-
}, {
|
|
55
|
-
readonly name: "grantVersion";
|
|
56
|
-
readonly type: "uint256";
|
|
57
69
|
}];
|
|
58
70
|
};
|
|
59
71
|
export declare const SERVER_REGISTRATION_TYPES: {
|
|
@@ -86,74 +98,29 @@ export declare const BUILDER_REGISTRATION_TYPES: {
|
|
|
86
98
|
readonly type: "string";
|
|
87
99
|
}];
|
|
88
100
|
};
|
|
89
|
-
export
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
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
|
-
};
|
|
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
|
+
}
|
|
146
115
|
export interface GrantRegistrationMessage {
|
|
147
116
|
grantorAddress: `0x${string}`;
|
|
148
117
|
granteeId: `0x${string}`;
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
expiresAt: bigint;
|
|
118
|
+
grant: string;
|
|
119
|
+
fileIds: bigint[];
|
|
152
120
|
}
|
|
153
121
|
export interface GrantRevocationMessage {
|
|
154
122
|
grantorAddress: `0x${string}`;
|
|
155
123
|
grantId: `0x${string}`;
|
|
156
|
-
grantVersion: bigint;
|
|
157
124
|
}
|
|
158
125
|
export interface ServerRegistrationMessage {
|
|
159
126
|
ownerAddress: `0x${string}`;
|
|
@@ -167,25 +134,3 @@ export interface BuilderRegistrationMessage {
|
|
|
167
134
|
publicKey: string;
|
|
168
135
|
appUrl: string;
|
|
169
136
|
}
|
|
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
|
-
}
|
package/dist/protocol/eip712.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
const DOMAIN_NAME = "Vana Data Portability";
|
|
2
2
|
const DOMAIN_VERSION = "1";
|
|
3
|
-
const NATIVE_VANA_ASSET = "0x0000000000000000000000000000000000000000";
|
|
4
3
|
function buildDomain(chainId, verifyingContract) {
|
|
5
4
|
return {
|
|
6
5
|
name: DOMAIN_NAME,
|
|
@@ -9,7 +8,13 @@ function buildDomain(chainId, verifyingContract) {
|
|
|
9
8
|
verifyingContract
|
|
10
9
|
};
|
|
11
10
|
}
|
|
12
|
-
function
|
|
11
|
+
function fileRegistrationDomain(config) {
|
|
12
|
+
return buildDomain(
|
|
13
|
+
config.chainId,
|
|
14
|
+
config.contracts.dataRegistry
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
function fileDeletionDomain(config) {
|
|
13
18
|
return buildDomain(
|
|
14
19
|
config.chainId,
|
|
15
20
|
config.contracts.dataRegistry
|
|
@@ -39,26 +44,31 @@ function builderRegistrationDomain(config) {
|
|
|
39
44
|
config.contracts.dataPortabilityGrantees
|
|
40
45
|
);
|
|
41
46
|
}
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
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
|
+
};
|
|
48
60
|
const GRANT_REGISTRATION_TYPES = {
|
|
49
61
|
GrantRegistration: [
|
|
50
62
|
{ name: "grantorAddress", type: "address" },
|
|
51
63
|
{ name: "granteeId", type: "bytes32" },
|
|
52
|
-
{ name: "
|
|
53
|
-
{ name: "
|
|
54
|
-
{ name: "expiresAt", type: "uint256" }
|
|
64
|
+
{ name: "grant", type: "string" },
|
|
65
|
+
{ name: "fileIds", type: "uint256[]" }
|
|
55
66
|
]
|
|
56
67
|
};
|
|
57
68
|
const GRANT_REVOCATION_TYPES = {
|
|
58
69
|
GrantRevocation: [
|
|
59
70
|
{ name: "grantorAddress", type: "address" },
|
|
60
|
-
{ name: "grantId", type: "bytes32" }
|
|
61
|
-
{ name: "grantVersion", type: "uint256" }
|
|
71
|
+
{ name: "grantId", type: "bytes32" }
|
|
62
72
|
]
|
|
63
73
|
};
|
|
64
74
|
const SERVER_REGISTRATION_TYPES = {
|
|
@@ -77,46 +87,16 @@ const BUILDER_REGISTRATION_TYPES = {
|
|
|
77
87
|
{ name: "appUrl", type: "string" }
|
|
78
88
|
]
|
|
79
89
|
};
|
|
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
|
-
};
|
|
108
90
|
export {
|
|
109
|
-
ADD_DATA_TYPES,
|
|
110
91
|
BUILDER_REGISTRATION_TYPES,
|
|
111
|
-
|
|
92
|
+
FILE_DELETION_TYPES,
|
|
93
|
+
FILE_REGISTRATION_TYPES,
|
|
112
94
|
GRANT_REGISTRATION_TYPES,
|
|
113
95
|
GRANT_REVOCATION_TYPES,
|
|
114
|
-
NATIVE_VANA_ASSET,
|
|
115
|
-
RECORD_DATA_ACCESS_TYPES,
|
|
116
96
|
SERVER_REGISTRATION_TYPES,
|
|
117
97
|
builderRegistrationDomain,
|
|
118
|
-
|
|
119
|
-
|
|
98
|
+
fileDeletionDomain,
|
|
99
|
+
fileRegistrationDomain,
|
|
120
100
|
grantRegistrationDomain,
|
|
121
101
|
grantRevocationDomain,
|
|
122
102
|
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 // 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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E,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,UAAU,MAAM,SAAS;AAAA,IACjC,EAAE,MAAM,QAAQ,MAAM,UAAU;AAAA,IAChC,EAAE,MAAM,SAAS,MAAM,UAAU;AAAA,IACjC,EAAE,MAAM,UAAU,MAAM,UAAU;AAAA,IAClC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,EAC1C;AACF;AAMO,MAAM,iBAAiB;AAAA,EAC5B,SAAS;AAAA,IACP,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,mBAAmB,MAAM,UAAU;AAAA,EAC7C;AACF;AAMO,MAAM,2BAA2B;AAAA,EACtC,kBAAkB;AAAA,IAChB,EAAE,MAAM,gBAAgB,MAAM,UAAU;AAAA,IACxC,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,IAChC,EAAE,MAAM,WAAW,MAAM,UAAU;AAAA,IACnC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,IACpC,EAAE,MAAM,YAAY,MAAM,UAAU;AAAA,EACtC;AACF;","names":[]}
|
|
1
|
+
{"version":3,"sources":["../../src/protocol/eip712.ts"],"sourcesContent":["/**\n * EIP-712 domain and type builders for Data Portability protocol writes.\n *\n * These helpers are shared primitives only. Personal Server runtimes own when\n * to sign and submit these payloads.\n *\n * @category Protocol\n */\n\nimport type { TypedDataDomain } from \"viem\";\n\nconst DOMAIN_NAME = \"Vana Data Portability\";\nconst DOMAIN_VERSION = \"1\";\n\nexport interface DataPortabilityContracts {\n dataRegistry: string;\n dataPortabilityPermissions: string;\n dataPortabilityServer: string;\n dataPortabilityGrantees: string;\n}\n\nexport interface DataPortabilityGatewayConfig {\n chainId: number;\n contracts: DataPortabilityContracts;\n}\n\nfunction buildDomain(\n chainId: number,\n verifyingContract: `0x${string}`,\n): TypedDataDomain {\n return {\n name: DOMAIN_NAME,\n version: DOMAIN_VERSION,\n chainId,\n verifyingContract,\n };\n}\n\nexport function fileRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function fileDeletionDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataRegistry as `0x${string}`,\n );\n}\n\nexport function grantRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function grantRevocationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityPermissions as `0x${string}`,\n );\n}\n\nexport function serverRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityServer as `0x${string}`,\n );\n}\n\nexport function builderRegistrationDomain(\n config: DataPortabilityGatewayConfig,\n): TypedDataDomain {\n return buildDomain(\n config.chainId,\n config.contracts.dataPortabilityGrantees as `0x${string}`,\n );\n}\n\nexport const FILE_REGISTRATION_TYPES = {\n FileRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"url\", type: \"string\" },\n { name: \"schemaId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const FILE_DELETION_TYPES = {\n FileDeletion: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"fileId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const GRANT_REGISTRATION_TYPES = {\n GrantRegistration: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"granteeId\", type: \"bytes32\" },\n { name: \"grant\", type: \"string\" },\n { name: \"fileIds\", type: \"uint256[]\" },\n ],\n} as const;\n\nexport const GRANT_REVOCATION_TYPES = {\n GrantRevocation: [\n { name: \"grantorAddress\", type: \"address\" },\n { name: \"grantId\", type: \"bytes32\" },\n ],\n} as const;\n\nexport const SERVER_REGISTRATION_TYPES = {\n ServerRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"serverAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"serverUrl\", type: \"string\" },\n ],\n} as const;\n\nexport const BUILDER_REGISTRATION_TYPES = {\n BuilderRegistration: [\n { name: \"ownerAddress\", type: \"address\" },\n { name: \"granteeAddress\", type: \"address\" },\n { name: \"publicKey\", type: \"string\" },\n { name: \"appUrl\", type: \"string\" },\n ],\n} as const;\n\nexport interface FileRegistrationMessage {\n ownerAddress: `0x${string}`;\n url: string;\n schemaId: `0x${string}`;\n}\n\nexport interface FileDeletionMessage {\n ownerAddress: `0x${string}`;\n /**\n * Off-chain gateway file ID — bytes32, as returned by `GET /v1/files`. This is NOT the on-chain\n * uint256 DataRegistry file ID; consumers (e.g. the PS delete cascade) must source it from the\n * gateway, not derive it from a numeric on-chain ID.\n */\n fileId: `0x${string}`;\n}\n\nexport interface GrantRegistrationMessage {\n grantorAddress: `0x${string}`;\n granteeId: `0x${string}`;\n grant: string;\n fileIds: bigint[];\n}\n\nexport interface GrantRevocationMessage {\n grantorAddress: `0x${string}`;\n grantId: `0x${string}`;\n}\n\nexport interface ServerRegistrationMessage {\n ownerAddress: `0x${string}`;\n serverAddress: `0x${string}`;\n publicKey: string;\n serverUrl: string;\n}\n\nexport interface BuilderRegistrationMessage {\n ownerAddress: `0x${string}`;\n granteeAddress: `0x${string}`;\n publicKey: string;\n appUrl: string;\n}\n"],"mappings":"AAWA,MAAM,cAAc;AACpB,MAAM,iBAAiB;AAcvB,SAAS,YACP,SACA,mBACiB;AACjB,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,uBACd,QACiB;AACjB,SA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