@opendatalabs/vana-sdk
Version:
A TypeScript library for interacting with Vana Network smart contracts.
137 lines (136 loc) • 4.33 kB
TypeScript
/**
* EIP-712 domain and type builders for Data Portability protocol writes.
*
* These helpers are shared primitives only. Personal Server runtimes own when
* to sign and submit these payloads.
*
* @category Protocol
*/
import type { TypedDataDomain } from "viem";
export interface DataPortabilityContracts {
dataRegistry: string;
dataPortabilityPermissions: string;
dataPortabilityServer: string;
dataPortabilityGrantees: string;
}
export interface DataPortabilityGatewayConfig {
chainId: number;
contracts: DataPortabilityContracts;
}
export declare function fileRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
export declare function fileDeletionDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
export declare function grantRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
export declare function grantRevocationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
export declare function serverRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
export declare function builderRegistrationDomain(config: DataPortabilityGatewayConfig): TypedDataDomain;
export declare const FILE_REGISTRATION_TYPES: {
readonly FileRegistration: readonly [{
readonly name: "ownerAddress";
readonly type: "address";
}, {
readonly name: "url";
readonly type: "string";
}, {
readonly name: "schemaId";
readonly type: "bytes32";
}];
};
export declare const FILE_DELETION_TYPES: {
readonly FileDeletion: readonly [{
readonly name: "ownerAddress";
readonly type: "address";
}, {
readonly name: "fileId";
readonly type: "bytes32";
}];
};
export declare const GRANT_REGISTRATION_TYPES: {
readonly GrantRegistration: readonly [{
readonly name: "grantorAddress";
readonly type: "address";
}, {
readonly name: "granteeId";
readonly type: "bytes32";
}, {
readonly name: "grant";
readonly type: "string";
}, {
readonly name: "fileIds";
readonly type: "uint256[]";
}];
};
export declare const GRANT_REVOCATION_TYPES: {
readonly GrantRevocation: readonly [{
readonly name: "grantorAddress";
readonly type: "address";
}, {
readonly name: "grantId";
readonly type: "bytes32";
}];
};
export declare const SERVER_REGISTRATION_TYPES: {
readonly ServerRegistration: readonly [{
readonly name: "ownerAddress";
readonly type: "address";
}, {
readonly name: "serverAddress";
readonly type: "address";
}, {
readonly name: "publicKey";
readonly type: "string";
}, {
readonly name: "serverUrl";
readonly type: "string";
}];
};
export declare const BUILDER_REGISTRATION_TYPES: {
readonly BuilderRegistration: readonly [{
readonly name: "ownerAddress";
readonly type: "address";
}, {
readonly name: "granteeAddress";
readonly type: "address";
}, {
readonly name: "publicKey";
readonly type: "string";
}, {
readonly name: "appUrl";
readonly type: "string";
}];
};
export interface FileRegistrationMessage {
ownerAddress: `0x${string}`;
url: string;
schemaId: `0x${string}`;
}
export interface FileDeletionMessage {
ownerAddress: `0x${string}`;
/**
* Off-chain gateway file ID — bytes32, as returned by `GET /v1/files`. This is NOT the on-chain
* uint256 DataRegistry file ID; consumers (e.g. the PS delete cascade) must source it from the
* gateway, not derive it from a numeric on-chain ID.
*/
fileId: `0x${string}`;
}
export interface GrantRegistrationMessage {
grantorAddress: `0x${string}`;
granteeId: `0x${string}`;
grant: string;
fileIds: bigint[];
}
export interface GrantRevocationMessage {
grantorAddress: `0x${string}`;
grantId: `0x${string}`;
}
export interface ServerRegistrationMessage {
ownerAddress: `0x${string}`;
serverAddress: `0x${string}`;
publicKey: string;
serverUrl: string;
}
export interface BuilderRegistrationMessage {
ownerAddress: `0x${string}`;
granteeAddress: `0x${string}`;
publicKey: string;
appUrl: string;
}