@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.
Files changed (72) hide show
  1. package/dist/account/personal-server-lite-owner-binding.cjs +3 -3
  2. package/dist/account/personal-server-lite-owner-binding.cjs.map +1 -1
  3. package/dist/account/personal-server-lite-owner-binding.d.ts +2 -2
  4. package/dist/account/personal-server-lite-owner-binding.js +1 -1
  5. package/dist/account/personal-server-lite-owner-binding.js.map +1 -1
  6. package/dist/index.browser.d.ts +5 -8
  7. package/dist/index.browser.js +250 -416
  8. package/dist/index.browser.js.map +4 -4
  9. package/dist/index.node.cjs +258 -439
  10. package/dist/index.node.cjs.map +4 -4
  11. package/dist/index.node.d.ts +5 -8
  12. package/dist/index.node.js +250 -416
  13. package/dist/index.node.js.map +4 -4
  14. package/dist/{protocol/personal-server-lite-owner-binding.cjs → personal-server-lite/owner-binding.cjs} +5 -5
  15. package/dist/personal-server-lite/owner-binding.cjs.map +1 -0
  16. package/dist/{protocol/personal-server-lite-owner-binding.d.ts → personal-server-lite/owner-binding.d.ts} +3 -3
  17. package/dist/{protocol/personal-server-lite-owner-binding.js → personal-server-lite/owner-binding.js} +2 -2
  18. package/dist/personal-server-lite/owner-binding.js.map +1 -0
  19. package/dist/protocol/eip712.cjs +31 -53
  20. package/dist/protocol/eip712.cjs.map +1 -1
  21. package/dist/protocol/eip712.d.ts +43 -98
  22. package/dist/protocol/eip712.js +27 -47
  23. package/dist/protocol/eip712.js.map +1 -1
  24. package/dist/protocol/escrow.cjs +146 -0
  25. package/dist/protocol/escrow.cjs.map +1 -0
  26. package/dist/protocol/escrow.d.ts +336 -0
  27. package/dist/protocol/escrow.js +118 -0
  28. package/dist/protocol/escrow.js.map +1 -0
  29. package/dist/protocol/gateway.cjs +37 -107
  30. package/dist/protocol/gateway.cjs.map +1 -1
  31. package/dist/protocol/gateway.d.ts +57 -223
  32. package/dist/protocol/gateway.js +37 -107
  33. package/dist/protocol/gateway.js.map +1 -1
  34. package/dist/protocol/grants.cjs +64 -27
  35. package/dist/protocol/grants.cjs.map +1 -1
  36. package/dist/protocol/grants.d.ts +13 -6
  37. package/dist/protocol/grants.js +63 -27
  38. package/dist/protocol/grants.js.map +1 -1
  39. package/dist/protocol/personal-server-registration.cjs +16 -4
  40. package/dist/protocol/personal-server-registration.cjs.map +1 -1
  41. package/dist/protocol/personal-server-registration.d.ts +5 -2
  42. package/dist/protocol/personal-server-registration.js +16 -4
  43. package/dist/protocol/personal-server-registration.js.map +1 -1
  44. package/package.json +2 -3
  45. package/dist/protocol/data-point-status.cjs +0 -80
  46. package/dist/protocol/data-point-status.cjs.map +0 -1
  47. package/dist/protocol/data-point-status.d.ts +0 -34
  48. package/dist/protocol/data-point-status.js +0 -51
  49. package/dist/protocol/data-point-status.js.map +0 -1
  50. package/dist/protocol/escrow-deposit.cjs +0 -89
  51. package/dist/protocol/escrow-deposit.cjs.map +0 -1
  52. package/dist/protocol/escrow-deposit.d.ts +0 -47
  53. package/dist/protocol/escrow-deposit.js +0 -60
  54. package/dist/protocol/escrow-deposit.js.map +0 -1
  55. package/dist/protocol/escrow-flow.test.d.ts +0 -21
  56. package/dist/protocol/fee-registry.cjs +0 -116
  57. package/dist/protocol/fee-registry.cjs.map +0 -1
  58. package/dist/protocol/fee-registry.d.ts +0 -151
  59. package/dist/protocol/fee-registry.js +0 -89
  60. package/dist/protocol/fee-registry.js.map +0 -1
  61. package/dist/protocol/fee-registry.test.d.ts +0 -1
  62. package/dist/protocol/personal-server-data.cjs +0 -71
  63. package/dist/protocol/personal-server-data.cjs.map +0 -1
  64. package/dist/protocol/personal-server-data.d.ts +0 -16
  65. package/dist/protocol/personal-server-data.js +0 -47
  66. package/dist/protocol/personal-server-data.js.map +0 -1
  67. package/dist/protocol/personal-server-data.test.d.ts +0 -1
  68. package/dist/protocol/personal-server-lite-owner-binding.cjs.map +0 -1
  69. package/dist/protocol/personal-server-lite-owner-binding.js.map +0 -1
  70. package/dist/protocol/personal-server-lite-owner-binding.test.d.ts +0 -1
  71. /package/dist/{protocol/data-point-status.test.d.ts → personal-server-lite/owner-binding.test.d.ts} +0 -0
  72. /package/dist/protocol/{escrow-deposit.test.d.ts → escrow.test.d.ts} +0 -0
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/protocol/personal-server-registration.ts"],"sourcesContent":["/**\n * Personal Server registration typed-data and signing helpers.\n *\n * These helpers are protocol-owned and runtime-neutral. Apps can sign with\n * viem local accounts, wallet clients, Account products, or any equivalent\n * signer by adapting to {@link PersonalServerRegistrationSigner}.\n *\n * @category Protocol\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type TypedDataDomain,\n type TypedDataDefinition,\n} from \"viem\";\nimport {\n SERVER_REGISTRATION_TYPES,\n serverRegistrationDomain,\n type DataPortabilityGatewayConfig,\n type ServerRegistrationMessage,\n} from \"./eip712\";\n\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT =\n \"0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c\" as const;\n\nexport type PersonalServerRegistrationTypedData = TypedDataDefinition<\n typeof SERVER_REGISTRATION_TYPES,\n \"ServerRegistration\"\n> & {\n message: ServerRegistrationMessage;\n};\n\nexport interface PersonalServerRegistrationSigner {\n address: Address;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData,\n ): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerRegistrationWalletClient {\n account?: Account | Address | null;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData & {\n account?: Account | Address;\n },\n ): Promise<Hex>;\n}\n\nexport type ViemPersonalServerRegistrationSignerSource =\n | PersonalServerRegistrationSigner\n | ViemPersonalServerRegistrationWalletClient;\n\nexport interface BuildPersonalServerRegistrationTypedDataInput {\n ownerAddress: Address;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface BuildPersonalServerRegistrationSignatureInput {\n signer: PersonalServerRegistrationSigner;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface PersonalServerRegistrationSignature {\n signature: Hex;\n signerAddress: Address;\n typedData: PersonalServerRegistrationTypedData;\n}\n\nexport interface PersonalServerRegistrationDomainInput {\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\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 isPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n): source is PersonalServerRegistrationSigner {\n return \"address\" in source && typeof source.signTypedData === \"function\";\n}\n\nexport function createViemPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerRegistrationSigner {\n if (isPersonalServerRegistrationSigner(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 signTypedData: (typedData) =>\n source.signTypedData({\n ...typedData,\n account: options.account ?? source.account ?? accountAddress,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport function personalServerRegistrationDomain(\n input: PersonalServerRegistrationDomainInput = {},\n): TypedDataDomain {\n if (input.config) {\n return serverRegistrationDomain(input.config);\n }\n\n const verifyingContract =\n input.verifyingContract ??\n PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;\n assertAddress(verifyingContract, \"verifyingContract\");\n\n return {\n name: \"Vana Data Portability\",\n version: \"1\",\n chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,\n verifyingContract,\n };\n}\n\nexport function buildPersonalServerRegistrationTypedData(\n input: BuildPersonalServerRegistrationTypedDataInput,\n): PersonalServerRegistrationTypedData {\n assertAddress(input.ownerAddress, \"ownerAddress\");\n assertAddress(input.serverAddress, \"serverAddress\");\n\n return {\n domain: personalServerRegistrationDomain(input),\n types: SERVER_REGISTRATION_TYPES,\n primaryType: \"ServerRegistration\",\n message: {\n ownerAddress: input.ownerAddress,\n serverAddress: input.serverAddress,\n publicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n },\n };\n}\n\nexport async function buildPersonalServerRegistrationSignature(\n input: BuildPersonalServerRegistrationSignatureInput,\n): Promise<PersonalServerRegistrationSignature> {\n const typedData = buildPersonalServerRegistrationTypedData({\n ownerAddress: input.signer.address,\n serverAddress: input.serverAddress,\n serverPublicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n config: input.config,\n chainId: input.chainId,\n verifyingContract: input.verifyingContract,\n });\n const signature = await input.signer.signTypedData(typedData);\n\n return {\n signature,\n signerAddress: input.signer.address,\n typedData,\n };\n}\n\nexport const registerPersonalServerSignature =\n buildPersonalServerRegistrationSignature;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kBAOO;AACP,oBAKO;AAEA,MAAM,gDAAgD;AACtD,MAAM,0DACX;AA6DF,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,mCACP,QAC4C;AAC5C,SAAO,aAAa,UAAU,OAAO,OAAO,kBAAkB;AAChE;AAEO,SAAS,2CACd,QACA,UAA2C,CAAC,GACV;AAClC,MAAI,mCAAmC,MAAM,GAAG;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,eAAe,CAAC,cACd,OAAO,cAAc;AAAA,QACnB,GAAG;AAAA,QACH,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,MAChD,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,iCACd,QAA+C,CAAC,GAC/B;AACjB,MAAI,MAAM,QAAQ;AAChB,eAAO,wCAAyB,MAAM,MAAM;AAAA,EAC9C;AAEA,QAAM,oBACJ,MAAM,qBACN;AACF,gBAAc,mBAAmB,mBAAmB;AAEpD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,MAAM,WAAW;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,SAAS,yCACd,OACqC;AACrC,gBAAc,MAAM,cAAc,cAAc;AAChD,gBAAc,MAAM,eAAe,eAAe;AAElD,SAAO;AAAA,IACL,QAAQ,iCAAiC,KAAK;AAAA,IAC9C,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS;AAAA,MACP,cAAc,MAAM;AAAA,MACpB,eAAe,MAAM;AAAA,MACrB,WAAW,MAAM;AAAA,MACjB,WAAW,MAAM;AAAA,IACnB;AAAA,EACF;AACF;AAEA,eAAsB,yCACpB,OAC8C;AAC9C,QAAM,YAAY,yCAAyC;AAAA,IACzD,cAAc,MAAM,OAAO;AAAA,IAC3B,eAAe,MAAM;AAAA,IACrB,iBAAiB,MAAM;AAAA,IACvB,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM;AAAA,IACd,SAAS,MAAM;AAAA,IACf,mBAAmB,MAAM;AAAA,EAC3B,CAAC;AACD,QAAM,YAAY,MAAM,MAAM,OAAO,cAAc,SAAS;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,EACF;AACF;AAEO,MAAM,kCACX;","names":[]}
1
+ {"version":3,"sources":["../../src/protocol/personal-server-registration.ts"],"sourcesContent":["/**\n * Personal Server registration typed-data and signing helpers.\n *\n * These helpers are protocol-owned and runtime-neutral. Apps can sign with\n * viem local accounts, wallet clients, Account products, or any equivalent\n * signer by adapting to {@link PersonalServerRegistrationSigner}.\n *\n * @category Protocol\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type TypedDataDomain,\n type TypedDataDefinition,\n} from \"viem\";\nimport {\n SERVER_REGISTRATION_TYPES,\n serverRegistrationDomain,\n type DataPortabilityGatewayConfig,\n type ServerRegistrationMessage,\n} from \"./eip712\";\nimport { vanaMainnet } from \"../chains/definitions\";\nimport { getContractAddress } from \"../generated/addresses\";\n\ntype SupportedContractAddressChainId = Parameters<typeof getContractAddress>[0];\n\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID =\n vanaMainnet.id as SupportedContractAddressChainId;\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT =\n getContractAddress(\n PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,\n \"DataPortabilityServers\",\n );\n\nexport type PersonalServerRegistrationTypedData = TypedDataDefinition<\n typeof SERVER_REGISTRATION_TYPES,\n \"ServerRegistration\"\n> & {\n message: ServerRegistrationMessage;\n};\n\nexport interface PersonalServerRegistrationSigner {\n address: Address;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData,\n ): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerRegistrationWalletClient {\n account?: Account | Address | null;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData & {\n account?: Account | Address;\n },\n ): Promise<Hex>;\n}\n\nexport type ViemPersonalServerRegistrationSignerSource =\n | PersonalServerRegistrationSigner\n | ViemPersonalServerRegistrationWalletClient;\n\nexport interface BuildPersonalServerRegistrationTypedDataInput {\n ownerAddress: Address;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface BuildPersonalServerRegistrationSignatureInput {\n signer: PersonalServerRegistrationSigner;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface PersonalServerRegistrationSignature {\n signature: Hex;\n signerAddress: Address;\n typedData: PersonalServerRegistrationTypedData;\n}\n\nexport interface PersonalServerRegistrationDomainInput {\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\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 isPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n): source is PersonalServerRegistrationSigner {\n return \"address\" in source && typeof source.signTypedData === \"function\";\n}\n\nfunction getDefaultServerRegistrationContract(chainId: number): Address {\n return getContractAddress(\n chainId as SupportedContractAddressChainId,\n \"DataPortabilityServers\",\n );\n}\n\nexport function createViemPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerRegistrationSigner {\n if (isPersonalServerRegistrationSigner(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 signTypedData: (typedData) =>\n source.signTypedData({\n ...typedData,\n account: options.account ?? source.account ?? accountAddress,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport function personalServerRegistrationDomain(\n input: PersonalServerRegistrationDomainInput = {},\n): TypedDataDomain {\n if (input.config) {\n return serverRegistrationDomain(input.config);\n }\n\n const chainId =\n input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID;\n const verifyingContract =\n input.verifyingContract ?? getDefaultServerRegistrationContract(chainId);\n assertAddress(verifyingContract, \"verifyingContract\");\n\n return {\n name: \"Vana Data Portability\",\n version: \"1\",\n chainId,\n verifyingContract,\n };\n}\n\nexport function buildPersonalServerRegistrationTypedData(\n input: BuildPersonalServerRegistrationTypedDataInput,\n): PersonalServerRegistrationTypedData {\n assertAddress(input.ownerAddress, \"ownerAddress\");\n assertAddress(input.serverAddress, \"serverAddress\");\n\n return {\n domain: personalServerRegistrationDomain(input),\n types: SERVER_REGISTRATION_TYPES,\n primaryType: \"ServerRegistration\",\n message: {\n ownerAddress: input.ownerAddress,\n serverAddress: input.serverAddress,\n publicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n },\n };\n}\n\nexport async function buildPersonalServerRegistrationSignature(\n input: BuildPersonalServerRegistrationSignatureInput,\n): Promise<PersonalServerRegistrationSignature> {\n const typedData = buildPersonalServerRegistrationTypedData({\n ownerAddress: input.signer.address,\n serverAddress: input.serverAddress,\n serverPublicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n config: input.config,\n chainId: input.chainId,\n verifyingContract: input.verifyingContract,\n });\n const signature = await input.signer.signTypedData(typedData);\n\n return {\n signature,\n signerAddress: input.signer.address,\n typedData,\n };\n}\n\nexport const registerPersonalServerSignature =\n buildPersonalServerRegistrationSignature;\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAUA,kBAOO;AACP,oBAKO;AACP,yBAA4B;AAC5B,uBAAmC;AAI5B,MAAM,gDACX,+BAAY;AACP,MAAM,8DACX;AAAA,EACE;AAAA,EACA;AACF;AA6DF,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,mCACP,QAC4C;AAC5C,SAAO,aAAa,UAAU,OAAO,OAAO,kBAAkB;AAChE;AAEA,SAAS,qCAAqC,SAA0B;AACtE,aAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2CACd,QACA,UAA2C,CAAC,GACV;AAClC,MAAI,mCAAmC,MAAM,GAAG;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,eAAe,CAAC,cACd,OAAO,cAAc;AAAA,QACnB,GAAG;AAAA,QACH,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,MAChD,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,iCACd,QAA+C,CAAC,GAC/B;AACjB,MAAI,MAAM,QAAQ;AAChB,eAAO,wCAAyB,MAAM,MAAM;AAAA,EAC9C;AAEA,QAAM,UACJ,MAAM,WAAW;AACnB,QAAM,oBACJ,MAAM,qBAAqB,qCAAqC,OAAO;AACzE,gBAAc,mBAAmB,mBAAmB;AAEpD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,yCACd,OACqC;AACrC,gBAAc,MAAM,cAAc,cAAc;AAChD,gBAAc,MAAM,eAAe,eAAe;AAElD,SAAO;AAAA,IACL,QAAQ,iCAAiC,KAAK;AAAA,IAC9C,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS;AAAA,MACP,cAAc,MAAM;AAAA,MACpB,eAAe,MAAM;AAAA,MACrB,WAAW,MAAM;AAAA,MACjB,WAAW,MAAM;AAAA,IACnB;AAAA,EACF;AACF;AAEA,eAAsB,yCACpB,OAC8C;AAC9C,QAAM,YAAY,yCAAyC;AAAA,IACzD,cAAc,MAAM,OAAO;AAAA,IAC3B,eAAe,MAAM;AAAA,IACrB,iBAAiB,MAAM;AAAA,IACvB,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM;AAAA,IACd,SAAS,MAAM;AAAA,IACf,mBAAmB,MAAM;AAAA,EAC3B,CAAC;AACD,QAAM,YAAY,MAAM,MAAM,OAAO,cAAc,SAAS;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,EACF;AACF;AAEO,MAAM,kCACX;","names":[]}
@@ -9,8 +9,10 @@
9
9
  */
10
10
  import { type Account, type Address, type Hex, type TypedDataDomain, type TypedDataDefinition } from "viem";
11
11
  import { SERVER_REGISTRATION_TYPES, type DataPortabilityGatewayConfig, type ServerRegistrationMessage } from "./eip712";
12
- export declare const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
13
- export declare const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT: "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
12
+ import { getContractAddress } from "../generated/addresses";
13
+ type SupportedContractAddressChainId = Parameters<typeof getContractAddress>[0];
14
+ export declare const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID: SupportedContractAddressChainId;
15
+ export declare const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT: `0x${string}`;
14
16
  export type PersonalServerRegistrationTypedData = TypedDataDefinition<typeof SERVER_REGISTRATION_TYPES, "ServerRegistration"> & {
15
17
  message: ServerRegistrationMessage;
16
18
  };
@@ -60,3 +62,4 @@ export declare function personalServerRegistrationDomain(input?: PersonalServerR
60
62
  export declare function buildPersonalServerRegistrationTypedData(input: BuildPersonalServerRegistrationTypedDataInput): PersonalServerRegistrationTypedData;
61
63
  export declare function buildPersonalServerRegistrationSignature(input: BuildPersonalServerRegistrationSignatureInput): Promise<PersonalServerRegistrationSignature>;
62
64
  export declare const registerPersonalServerSignature: typeof buildPersonalServerRegistrationSignature;
65
+ export {};
@@ -5,8 +5,13 @@ import {
5
5
  SERVER_REGISTRATION_TYPES,
6
6
  serverRegistrationDomain
7
7
  } from "./eip712.js";
8
- const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;
9
- const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = "0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c";
8
+ import { vanaMainnet } from "../chains/definitions.js";
9
+ import { getContractAddress } from "../generated/addresses.js";
10
+ const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = vanaMainnet.id;
11
+ const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT = getContractAddress(
12
+ PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
13
+ "DataPortabilityServers"
14
+ );
10
15
  function assertAddress(value, name) {
11
16
  if (!isAddress(value)) {
12
17
  throw new Error(`${name} must be a valid EVM address`);
@@ -21,6 +26,12 @@ function getAccountAddress(account) {
21
26
  function isPersonalServerRegistrationSigner(source) {
22
27
  return "address" in source && typeof source.signTypedData === "function";
23
28
  }
29
+ function getDefaultServerRegistrationContract(chainId) {
30
+ return getContractAddress(
31
+ chainId,
32
+ "DataPortabilityServers"
33
+ );
34
+ }
24
35
  function createViemPersonalServerRegistrationSigner(source, options = {}) {
25
36
  if (isPersonalServerRegistrationSigner(source)) {
26
37
  return source;
@@ -43,12 +54,13 @@ function personalServerRegistrationDomain(input = {}) {
43
54
  if (input.config) {
44
55
  return serverRegistrationDomain(input.config);
45
56
  }
46
- const verifyingContract = input.verifyingContract ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;
57
+ const chainId = input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID;
58
+ const verifyingContract = input.verifyingContract ?? getDefaultServerRegistrationContract(chainId);
47
59
  assertAddress(verifyingContract, "verifyingContract");
48
60
  return {
49
61
  name: "Vana Data Portability",
50
62
  version: "1",
51
- chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,
63
+ chainId,
52
64
  verifyingContract
53
65
  };
54
66
  }
@@ -1 +1 @@
1
- {"version":3,"sources":["../../src/protocol/personal-server-registration.ts"],"sourcesContent":["/**\n * Personal Server registration typed-data and signing helpers.\n *\n * These helpers are protocol-owned and runtime-neutral. Apps can sign with\n * viem local accounts, wallet clients, Account products, or any equivalent\n * signer by adapting to {@link PersonalServerRegistrationSigner}.\n *\n * @category Protocol\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type TypedDataDomain,\n type TypedDataDefinition,\n} from \"viem\";\nimport {\n SERVER_REGISTRATION_TYPES,\n serverRegistrationDomain,\n type DataPortabilityGatewayConfig,\n type ServerRegistrationMessage,\n} from \"./eip712\";\n\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID = 1480;\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT =\n \"0x1483B1F634DBA75AeaE60da7f01A679aabd5ee2c\" as const;\n\nexport type PersonalServerRegistrationTypedData = TypedDataDefinition<\n typeof SERVER_REGISTRATION_TYPES,\n \"ServerRegistration\"\n> & {\n message: ServerRegistrationMessage;\n};\n\nexport interface PersonalServerRegistrationSigner {\n address: Address;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData,\n ): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerRegistrationWalletClient {\n account?: Account | Address | null;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData & {\n account?: Account | Address;\n },\n ): Promise<Hex>;\n}\n\nexport type ViemPersonalServerRegistrationSignerSource =\n | PersonalServerRegistrationSigner\n | ViemPersonalServerRegistrationWalletClient;\n\nexport interface BuildPersonalServerRegistrationTypedDataInput {\n ownerAddress: Address;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface BuildPersonalServerRegistrationSignatureInput {\n signer: PersonalServerRegistrationSigner;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface PersonalServerRegistrationSignature {\n signature: Hex;\n signerAddress: Address;\n typedData: PersonalServerRegistrationTypedData;\n}\n\nexport interface PersonalServerRegistrationDomainInput {\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\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 isPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n): source is PersonalServerRegistrationSigner {\n return \"address\" in source && typeof source.signTypedData === \"function\";\n}\n\nexport function createViemPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerRegistrationSigner {\n if (isPersonalServerRegistrationSigner(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 signTypedData: (typedData) =>\n source.signTypedData({\n ...typedData,\n account: options.account ?? source.account ?? accountAddress,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport function personalServerRegistrationDomain(\n input: PersonalServerRegistrationDomainInput = {},\n): TypedDataDomain {\n if (input.config) {\n return serverRegistrationDomain(input.config);\n }\n\n const verifyingContract =\n input.verifyingContract ??\n PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT;\n assertAddress(verifyingContract, \"verifyingContract\");\n\n return {\n name: \"Vana Data Portability\",\n version: \"1\",\n chainId: input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,\n verifyingContract,\n };\n}\n\nexport function buildPersonalServerRegistrationTypedData(\n input: BuildPersonalServerRegistrationTypedDataInput,\n): PersonalServerRegistrationTypedData {\n assertAddress(input.ownerAddress, \"ownerAddress\");\n assertAddress(input.serverAddress, \"serverAddress\");\n\n return {\n domain: personalServerRegistrationDomain(input),\n types: SERVER_REGISTRATION_TYPES,\n primaryType: \"ServerRegistration\",\n message: {\n ownerAddress: input.ownerAddress,\n serverAddress: input.serverAddress,\n publicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n },\n };\n}\n\nexport async function buildPersonalServerRegistrationSignature(\n input: BuildPersonalServerRegistrationSignatureInput,\n): Promise<PersonalServerRegistrationSignature> {\n const typedData = buildPersonalServerRegistrationTypedData({\n ownerAddress: input.signer.address,\n serverAddress: input.serverAddress,\n serverPublicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n config: input.config,\n chainId: input.chainId,\n verifyingContract: input.verifyingContract,\n });\n const signature = await input.signer.signTypedData(typedData);\n\n return {\n signature,\n signerAddress: input.signer.address,\n typedData,\n };\n}\n\nexport const registerPersonalServerSignature =\n buildPersonalServerRegistrationSignature;\n"],"mappings":"AAUA;AAAA,EACE;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AAEA,MAAM,gDAAgD;AACtD,MAAM,0DACX;AA6DF,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,mCACP,QAC4C;AAC5C,SAAO,aAAa,UAAU,OAAO,OAAO,kBAAkB;AAChE;AAEO,SAAS,2CACd,QACA,UAA2C,CAAC,GACV;AAClC,MAAI,mCAAmC,MAAM,GAAG;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,eAAe,CAAC,cACd,OAAO,cAAc;AAAA,QACnB,GAAG;AAAA,QACH,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,MAChD,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,iCACd,QAA+C,CAAC,GAC/B;AACjB,MAAI,MAAM,QAAQ;AAChB,WAAO,yBAAyB,MAAM,MAAM;AAAA,EAC9C;AAEA,QAAM,oBACJ,MAAM,qBACN;AACF,gBAAc,mBAAmB,mBAAmB;AAEpD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT,SAAS,MAAM,WAAW;AAAA,IAC1B;AAAA,EACF;AACF;AAEO,SAAS,yCACd,OACqC;AACrC,gBAAc,MAAM,cAAc,cAAc;AAChD,gBAAc,MAAM,eAAe,eAAe;AAElD,SAAO;AAAA,IACL,QAAQ,iCAAiC,KAAK;AAAA,IAC9C,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS;AAAA,MACP,cAAc,MAAM;AAAA,MACpB,eAAe,MAAM;AAAA,MACrB,WAAW,MAAM;AAAA,MACjB,WAAW,MAAM;AAAA,IACnB;AAAA,EACF;AACF;AAEA,eAAsB,yCACpB,OAC8C;AAC9C,QAAM,YAAY,yCAAyC;AAAA,IACzD,cAAc,MAAM,OAAO;AAAA,IAC3B,eAAe,MAAM;AAAA,IACrB,iBAAiB,MAAM;AAAA,IACvB,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM;AAAA,IACd,SAAS,MAAM;AAAA,IACf,mBAAmB,MAAM;AAAA,EAC3B,CAAC;AACD,QAAM,YAAY,MAAM,MAAM,OAAO,cAAc,SAAS;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,EACF;AACF;AAEO,MAAM,kCACX;","names":[]}
1
+ {"version":3,"sources":["../../src/protocol/personal-server-registration.ts"],"sourcesContent":["/**\n * Personal Server registration typed-data and signing helpers.\n *\n * These helpers are protocol-owned and runtime-neutral. Apps can sign with\n * viem local accounts, wallet clients, Account products, or any equivalent\n * signer by adapting to {@link PersonalServerRegistrationSigner}.\n *\n * @category Protocol\n */\n\nimport {\n isAddress,\n type Account,\n type Address,\n type Hex,\n type TypedDataDomain,\n type TypedDataDefinition,\n} from \"viem\";\nimport {\n SERVER_REGISTRATION_TYPES,\n serverRegistrationDomain,\n type DataPortabilityGatewayConfig,\n type ServerRegistrationMessage,\n} from \"./eip712\";\nimport { vanaMainnet } from \"../chains/definitions\";\nimport { getContractAddress } from \"../generated/addresses\";\n\ntype SupportedContractAddressChainId = Parameters<typeof getContractAddress>[0];\n\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID =\n vanaMainnet.id as SupportedContractAddressChainId;\nexport const PERSONAL_SERVER_REGISTRATION_DEFAULT_VERIFYING_CONTRACT =\n getContractAddress(\n PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID,\n \"DataPortabilityServers\",\n );\n\nexport type PersonalServerRegistrationTypedData = TypedDataDefinition<\n typeof SERVER_REGISTRATION_TYPES,\n \"ServerRegistration\"\n> & {\n message: ServerRegistrationMessage;\n};\n\nexport interface PersonalServerRegistrationSigner {\n address: Address;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData,\n ): Promise<Hex> | Hex;\n}\n\nexport interface ViemPersonalServerRegistrationWalletClient {\n account?: Account | Address | null;\n signTypedData(\n typedData: PersonalServerRegistrationTypedData & {\n account?: Account | Address;\n },\n ): Promise<Hex>;\n}\n\nexport type ViemPersonalServerRegistrationSignerSource =\n | PersonalServerRegistrationSigner\n | ViemPersonalServerRegistrationWalletClient;\n\nexport interface BuildPersonalServerRegistrationTypedDataInput {\n ownerAddress: Address;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface BuildPersonalServerRegistrationSignatureInput {\n signer: PersonalServerRegistrationSigner;\n serverAddress: Address;\n serverPublicKey: string;\n serverUrl: string;\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\n}\n\nexport interface PersonalServerRegistrationSignature {\n signature: Hex;\n signerAddress: Address;\n typedData: PersonalServerRegistrationTypedData;\n}\n\nexport interface PersonalServerRegistrationDomainInput {\n config?: DataPortabilityGatewayConfig;\n chainId?: number;\n verifyingContract?: Address;\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 isPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n): source is PersonalServerRegistrationSigner {\n return \"address\" in source && typeof source.signTypedData === \"function\";\n}\n\nfunction getDefaultServerRegistrationContract(chainId: number): Address {\n return getContractAddress(\n chainId as SupportedContractAddressChainId,\n \"DataPortabilityServers\",\n );\n}\n\nexport function createViemPersonalServerRegistrationSigner(\n source: ViemPersonalServerRegistrationSignerSource,\n options: { account?: Account | Address } = {},\n): PersonalServerRegistrationSigner {\n if (isPersonalServerRegistrationSigner(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 signTypedData: (typedData) =>\n source.signTypedData({\n ...typedData,\n account: options.account ?? source.account ?? accountAddress,\n }),\n };\n }\n\n throw new Error(\n \"Viem wallet client requires an account option or account property\",\n );\n}\n\nexport function personalServerRegistrationDomain(\n input: PersonalServerRegistrationDomainInput = {},\n): TypedDataDomain {\n if (input.config) {\n return serverRegistrationDomain(input.config);\n }\n\n const chainId =\n input.chainId ?? PERSONAL_SERVER_REGISTRATION_DEFAULT_CHAIN_ID;\n const verifyingContract =\n input.verifyingContract ?? getDefaultServerRegistrationContract(chainId);\n assertAddress(verifyingContract, \"verifyingContract\");\n\n return {\n name: \"Vana Data Portability\",\n version: \"1\",\n chainId,\n verifyingContract,\n };\n}\n\nexport function buildPersonalServerRegistrationTypedData(\n input: BuildPersonalServerRegistrationTypedDataInput,\n): PersonalServerRegistrationTypedData {\n assertAddress(input.ownerAddress, \"ownerAddress\");\n assertAddress(input.serverAddress, \"serverAddress\");\n\n return {\n domain: personalServerRegistrationDomain(input),\n types: SERVER_REGISTRATION_TYPES,\n primaryType: \"ServerRegistration\",\n message: {\n ownerAddress: input.ownerAddress,\n serverAddress: input.serverAddress,\n publicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n },\n };\n}\n\nexport async function buildPersonalServerRegistrationSignature(\n input: BuildPersonalServerRegistrationSignatureInput,\n): Promise<PersonalServerRegistrationSignature> {\n const typedData = buildPersonalServerRegistrationTypedData({\n ownerAddress: input.signer.address,\n serverAddress: input.serverAddress,\n serverPublicKey: input.serverPublicKey,\n serverUrl: input.serverUrl,\n config: input.config,\n chainId: input.chainId,\n verifyingContract: input.verifyingContract,\n });\n const signature = await input.signer.signTypedData(typedData);\n\n return {\n signature,\n signerAddress: input.signer.address,\n typedData,\n };\n}\n\nexport const registerPersonalServerSignature =\n buildPersonalServerRegistrationSignature;\n"],"mappings":"AAUA;AAAA,EACE;AAAA,OAMK;AACP;AAAA,EACE;AAAA,EACA;AAAA,OAGK;AACP,SAAS,mBAAmB;AAC5B,SAAS,0BAA0B;AAI5B,MAAM,gDACX,YAAY;AACP,MAAM,0DACX;AAAA,EACE;AAAA,EACA;AACF;AA6DF,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,mCACP,QAC4C;AAC5C,SAAO,aAAa,UAAU,OAAO,OAAO,kBAAkB;AAChE;AAEA,SAAS,qCAAqC,SAA0B;AACtE,SAAO;AAAA,IACL;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,2CACd,QACA,UAA2C,CAAC,GACV;AAClC,MAAI,mCAAmC,MAAM,GAAG;AAC9C,WAAO;AAAA,EACT;AAEA,QAAM,iBACJ,kBAAkB,QAAQ,OAAO,KAAK,kBAAkB,OAAO,OAAO;AAExE,MAAI,gBAAgB;AAClB,WAAO;AAAA,MACL,SAAS;AAAA,MACT,eAAe,CAAC,cACd,OAAO,cAAc;AAAA,QACnB,GAAG;AAAA,QACH,SAAS,QAAQ,WAAW,OAAO,WAAW;AAAA,MAChD,CAAC;AAAA,IACL;AAAA,EACF;AAEA,QAAM,IAAI;AAAA,IACR;AAAA,EACF;AACF;AAEO,SAAS,iCACd,QAA+C,CAAC,GAC/B;AACjB,MAAI,MAAM,QAAQ;AAChB,WAAO,yBAAyB,MAAM,MAAM;AAAA,EAC9C;AAEA,QAAM,UACJ,MAAM,WAAW;AACnB,QAAM,oBACJ,MAAM,qBAAqB,qCAAqC,OAAO;AACzE,gBAAc,mBAAmB,mBAAmB;AAEpD,SAAO;AAAA,IACL,MAAM;AAAA,IACN,SAAS;AAAA,IACT;AAAA,IACA;AAAA,EACF;AACF;AAEO,SAAS,yCACd,OACqC;AACrC,gBAAc,MAAM,cAAc,cAAc;AAChD,gBAAc,MAAM,eAAe,eAAe;AAElD,SAAO;AAAA,IACL,QAAQ,iCAAiC,KAAK;AAAA,IAC9C,OAAO;AAAA,IACP,aAAa;AAAA,IACb,SAAS;AAAA,MACP,cAAc,MAAM;AAAA,MACpB,eAAe,MAAM;AAAA,MACrB,WAAW,MAAM;AAAA,MACjB,WAAW,MAAM;AAAA,IACnB;AAAA,EACF;AACF;AAEA,eAAsB,yCACpB,OAC8C;AAC9C,QAAM,YAAY,yCAAyC;AAAA,IACzD,cAAc,MAAM,OAAO;AAAA,IAC3B,eAAe,MAAM;AAAA,IACrB,iBAAiB,MAAM;AAAA,IACvB,WAAW,MAAM;AAAA,IACjB,QAAQ,MAAM;AAAA,IACd,SAAS,MAAM;AAAA,IACf,mBAAmB,MAAM;AAAA,EAC3B,CAAC;AACD,QAAM,YAAY,MAAM,MAAM,OAAO,cAAc,SAAS;AAE5D,SAAO;AAAA,IACL;AAAA,IACA,eAAe,MAAM,OAAO;AAAA,IAC5B;AAAA,EACF;AACF;AAEO,MAAM,kCACX;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@opendatalabs/vana-sdk",
3
- "version": "3.4.1-canary.e9d0aad",
3
+ "version": "3.5.0",
4
4
  "description": "A TypeScript library for interacting with Vana Network smart contracts.",
5
5
  "publishConfig": {
6
6
  "access": "public"
@@ -101,8 +101,7 @@
101
101
  "test:coverage:verbose": "vitest run --coverage --reporter=verbose --coverage.reporter=text",
102
102
  "discover-addresses": "tsx scripts/discover-addresses.ts",
103
103
  "fetch-abis": "tsx scripts/fetch-abis.ts",
104
- "generate": "npm run discover-addresses && npm run fetch-abis",
105
- "e2e:deposit": "tsx scripts/e2e-escrow-deposit.ts"
104
+ "generate": "npm run discover-addresses && npm run fetch-abis"
106
105
  },
107
106
  "keywords": [
108
107
  "vana",
@@ -1,80 +0,0 @@
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 data_point_status_exports = {};
20
- __export(data_point_status_exports, {
21
- DATA_REGISTRY_STATUS_ABI: () => DATA_REGISTRY_STATUS_ABI,
22
- DataPointStatus: () => DataPointStatus,
23
- buildMarkDataPointUnavailableRequest: () => buildMarkDataPointUnavailableRequest,
24
- buildSetDataPointStatusRequest: () => buildSetDataPointStatusRequest,
25
- dataRegistryContractAddress: () => dataRegistryContractAddress,
26
- encodeSetDataPointStatusData: () => encodeSetDataPointStatusData
27
- });
28
- module.exports = __toCommonJS(data_point_status_exports);
29
- var import_viem = require("viem");
30
- var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
31
- DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
32
- DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
33
- DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
34
- DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
35
- return DataPointStatus2;
36
- })(DataPointStatus || {});
37
- const DATA_REGISTRY_STATUS_ABI = [
38
- {
39
- type: "function",
40
- name: "setStatus",
41
- stateMutability: "nonpayable",
42
- inputs: [
43
- { name: "scope", type: "string" },
44
- { name: "newStatus", type: "uint8" }
45
- ],
46
- outputs: []
47
- }
48
- ];
49
- function dataRegistryContractAddress(config) {
50
- return config.contracts.dataRegistry;
51
- }
52
- function encodeSetDataPointStatusData(input) {
53
- return (0, import_viem.encodeFunctionData)({
54
- abi: DATA_REGISTRY_STATUS_ABI,
55
- functionName: "setStatus",
56
- args: [input.scope, input.status]
57
- });
58
- }
59
- function buildSetDataPointStatusRequest(config, input) {
60
- return {
61
- to: dataRegistryContractAddress(config),
62
- data: encodeSetDataPointStatusData(input)
63
- };
64
- }
65
- function buildMarkDataPointUnavailableRequest(config, input) {
66
- return buildSetDataPointStatusRequest(config, {
67
- scope: input.scope,
68
- status: 3 /* Unavailable */
69
- });
70
- }
71
- // Annotate the CommonJS export names for ESM import in node:
72
- 0 && (module.exports = {
73
- DATA_REGISTRY_STATUS_ABI,
74
- DataPointStatus,
75
- buildMarkDataPointUnavailableRequest,
76
- buildSetDataPointStatusRequest,
77
- dataRegistryContractAddress,
78
- encodeSetDataPointStatusData
79
- });
80
- //# sourceMappingURL=data-point-status.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/protocol/data-point-status.ts"],"sourcesContent":["/**\n * On-chain status mutation primitives for DataRegistryV2 data points.\n *\n * The v2 contract drops the file concept in favor of versioned data points\n * keyed on (owner, scope). Each data point has a lifecycle Status that the\n * owner can change directly — there's no EIP-712 signature flow and no\n * gateway endpoint that mediates this, because the contract enforces\n * `msg.sender == owner` for `setStatus`. The owner therefore has to sign\n * and broadcast the tx from their own wallet.\n *\n * These helpers are signer/transport-agnostic — they return the raw\n * `{to, data}` request object so callers can feed it to any wallet stack\n * (viem `sendTransaction`/`writeContract`, ethers, wallet-rpc, MPC,\n * Safe transactions, etc.). Mirrors the shape used by `escrow-deposit.ts`.\n *\n * @category Protocol\n */\nimport { encodeFunctionData } from \"viem\";\nimport type { DataPortabilityGatewayConfig } from \"./eip712\";\n\n// Lifecycle states from IDataRegistryV2.Status. Wire encoding is uint8.\n// - None: no data point exists for this (owner, scope).\n// - Active: has data, served on /v1/escrow/pay's recordDataAccess path.\n// - Inactive: owner-paused — refuses new versions until re-activated.\n// `addData` (or addDataWithSignature) auto-revives Inactive → Active.\n// - Unavailable: terminal soft-delete — `addData` and recordDataAccess both\n// revert. The owner can still resurrect by calling setStatus(Active), but\n// that signals intent to bring the data point back online; a downstream\n// client treating Unavailable as a delete tombstone should re-fetch after\n// any DataPointStatusChanged event.\nexport enum DataPointStatus {\n None = 0,\n Active = 1,\n Inactive = 2,\n Unavailable = 3,\n}\n\n// Minimal ABI fragment for the owner-only `setStatus(scope, newStatus)`\n// entry point. Kept inline so callers don't have to load the full contract\n// ABI just to change a status.\nexport const DATA_REGISTRY_STATUS_ABI = [\n {\n type: \"function\",\n name: \"setStatus\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"scope\", type: \"string\" },\n { name: \"newStatus\", type: \"uint8\" },\n ],\n outputs: [],\n },\n] as const;\n\nexport function dataRegistryContractAddress(\n config: DataPortabilityGatewayConfig,\n): `0x${string}` {\n return config.contracts.dataRegistry as `0x${string}`;\n}\n\nexport interface SetDataPointStatusInput {\n scope: string;\n status: DataPointStatus;\n}\n\n// Shape compatible with viem's `sendTransaction` / `writeContract` request\n// objects. No `value` — `setStatus` is non-payable.\nexport interface DataPointStatusTransactionRequest {\n to: `0x${string}`;\n data: `0x${string}`;\n}\n\nexport function encodeSetDataPointStatusData(\n input: SetDataPointStatusInput,\n): `0x${string}` {\n return encodeFunctionData({\n abi: DATA_REGISTRY_STATUS_ABI,\n functionName: \"setStatus\",\n args: [input.scope, input.status],\n });\n}\n\n// Build the full tx request for a status change. Feed straight to\n// `walletClient.sendTransaction({...req, account, chain})`. The caller's\n// `account` MUST equal the data point's owner — the contract reverts\n// otherwise.\nexport function buildSetDataPointStatusRequest(\n config: DataPortabilityGatewayConfig,\n input: SetDataPointStatusInput,\n): DataPointStatusTransactionRequest {\n return {\n to: dataRegistryContractAddress(config),\n data: encodeSetDataPointStatusData(input),\n };\n}\n\n// Convenience for the \"remove this data point\" intent — the v2 equivalent\n// of the old DELETE /v1/files/:id flow. Sets the status to Unavailable so\n// downstream readers (recordDataAccess, future addData) revert. Callers\n// that want the data point pausable rather than tombstoned should use\n// `buildSetDataPointStatusRequest` with `DataPointStatus.Inactive`.\nexport function buildMarkDataPointUnavailableRequest(\n config: DataPortabilityGatewayConfig,\n input: { scope: string },\n): DataPointStatusTransactionRequest {\n return buildSetDataPointStatusRequest(config, {\n scope: input.scope,\n status: DataPointStatus.Unavailable,\n });\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiBA,kBAAmC;AAa5B,IAAK,kBAAL,kBAAKA,qBAAL;AACL,EAAAA,kCAAA,UAAO,KAAP;AACA,EAAAA,kCAAA,YAAS,KAAT;AACA,EAAAA,kCAAA,cAAW,KAAX;AACA,EAAAA,kCAAA,iBAAc,KAAd;AAJU,SAAAA;AAAA,GAAA;AAUL,MAAM,2BAA2B;AAAA,EACtC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,MAChC,EAAE,MAAM,aAAa,MAAM,QAAQ;AAAA,IACrC;AAAA,IACA,SAAS,CAAC;AAAA,EACZ;AACF;AAEO,SAAS,4BACd,QACe;AACf,SAAO,OAAO,UAAU;AAC1B;AAcO,SAAS,6BACd,OACe;AACf,aAAO,gCAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM,OAAO,MAAM,MAAM;AAAA,EAClC,CAAC;AACH;AAMO,SAAS,+BACd,QACA,OACmC;AACnC,SAAO;AAAA,IACL,IAAI,4BAA4B,MAAM;AAAA,IACtC,MAAM,6BAA6B,KAAK;AAAA,EAC1C;AACF;AAOO,SAAS,qCACd,QACA,OACmC;AACnC,SAAO,+BAA+B,QAAQ;AAAA,IAC5C,OAAO,MAAM;AAAA,IACb,QAAQ;AAAA,EACV,CAAC;AACH;","names":["DataPointStatus"]}
@@ -1,34 +0,0 @@
1
- import type { DataPortabilityGatewayConfig } from "./eip712";
2
- export declare enum DataPointStatus {
3
- None = 0,
4
- Active = 1,
5
- Inactive = 2,
6
- Unavailable = 3
7
- }
8
- export declare const DATA_REGISTRY_STATUS_ABI: readonly [{
9
- readonly type: "function";
10
- readonly name: "setStatus";
11
- readonly stateMutability: "nonpayable";
12
- readonly inputs: readonly [{
13
- readonly name: "scope";
14
- readonly type: "string";
15
- }, {
16
- readonly name: "newStatus";
17
- readonly type: "uint8";
18
- }];
19
- readonly outputs: readonly [];
20
- }];
21
- export declare function dataRegistryContractAddress(config: DataPortabilityGatewayConfig): `0x${string}`;
22
- export interface SetDataPointStatusInput {
23
- scope: string;
24
- status: DataPointStatus;
25
- }
26
- export interface DataPointStatusTransactionRequest {
27
- to: `0x${string}`;
28
- data: `0x${string}`;
29
- }
30
- export declare function encodeSetDataPointStatusData(input: SetDataPointStatusInput): `0x${string}`;
31
- export declare function buildSetDataPointStatusRequest(config: DataPortabilityGatewayConfig, input: SetDataPointStatusInput): DataPointStatusTransactionRequest;
32
- export declare function buildMarkDataPointUnavailableRequest(config: DataPortabilityGatewayConfig, input: {
33
- scope: string;
34
- }): DataPointStatusTransactionRequest;
@@ -1,51 +0,0 @@
1
- import { encodeFunctionData } from "viem";
2
- var DataPointStatus = /* @__PURE__ */ ((DataPointStatus2) => {
3
- DataPointStatus2[DataPointStatus2["None"] = 0] = "None";
4
- DataPointStatus2[DataPointStatus2["Active"] = 1] = "Active";
5
- DataPointStatus2[DataPointStatus2["Inactive"] = 2] = "Inactive";
6
- DataPointStatus2[DataPointStatus2["Unavailable"] = 3] = "Unavailable";
7
- return DataPointStatus2;
8
- })(DataPointStatus || {});
9
- const DATA_REGISTRY_STATUS_ABI = [
10
- {
11
- type: "function",
12
- name: "setStatus",
13
- stateMutability: "nonpayable",
14
- inputs: [
15
- { name: "scope", type: "string" },
16
- { name: "newStatus", type: "uint8" }
17
- ],
18
- outputs: []
19
- }
20
- ];
21
- function dataRegistryContractAddress(config) {
22
- return config.contracts.dataRegistry;
23
- }
24
- function encodeSetDataPointStatusData(input) {
25
- return encodeFunctionData({
26
- abi: DATA_REGISTRY_STATUS_ABI,
27
- functionName: "setStatus",
28
- args: [input.scope, input.status]
29
- });
30
- }
31
- function buildSetDataPointStatusRequest(config, input) {
32
- return {
33
- to: dataRegistryContractAddress(config),
34
- data: encodeSetDataPointStatusData(input)
35
- };
36
- }
37
- function buildMarkDataPointUnavailableRequest(config, input) {
38
- return buildSetDataPointStatusRequest(config, {
39
- scope: input.scope,
40
- status: 3 /* Unavailable */
41
- });
42
- }
43
- export {
44
- DATA_REGISTRY_STATUS_ABI,
45
- DataPointStatus,
46
- buildMarkDataPointUnavailableRequest,
47
- buildSetDataPointStatusRequest,
48
- dataRegistryContractAddress,
49
- encodeSetDataPointStatusData
50
- };
51
- //# sourceMappingURL=data-point-status.js.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../../src/protocol/data-point-status.ts"],"sourcesContent":["/**\n * On-chain status mutation primitives for DataRegistryV2 data points.\n *\n * The v2 contract drops the file concept in favor of versioned data points\n * keyed on (owner, scope). Each data point has a lifecycle Status that the\n * owner can change directly — there's no EIP-712 signature flow and no\n * gateway endpoint that mediates this, because the contract enforces\n * `msg.sender == owner` for `setStatus`. The owner therefore has to sign\n * and broadcast the tx from their own wallet.\n *\n * These helpers are signer/transport-agnostic — they return the raw\n * `{to, data}` request object so callers can feed it to any wallet stack\n * (viem `sendTransaction`/`writeContract`, ethers, wallet-rpc, MPC,\n * Safe transactions, etc.). Mirrors the shape used by `escrow-deposit.ts`.\n *\n * @category Protocol\n */\nimport { encodeFunctionData } from \"viem\";\nimport type { DataPortabilityGatewayConfig } from \"./eip712\";\n\n// Lifecycle states from IDataRegistryV2.Status. Wire encoding is uint8.\n// - None: no data point exists for this (owner, scope).\n// - Active: has data, served on /v1/escrow/pay's recordDataAccess path.\n// - Inactive: owner-paused — refuses new versions until re-activated.\n// `addData` (or addDataWithSignature) auto-revives Inactive → Active.\n// - Unavailable: terminal soft-delete — `addData` and recordDataAccess both\n// revert. The owner can still resurrect by calling setStatus(Active), but\n// that signals intent to bring the data point back online; a downstream\n// client treating Unavailable as a delete tombstone should re-fetch after\n// any DataPointStatusChanged event.\nexport enum DataPointStatus {\n None = 0,\n Active = 1,\n Inactive = 2,\n Unavailable = 3,\n}\n\n// Minimal ABI fragment for the owner-only `setStatus(scope, newStatus)`\n// entry point. Kept inline so callers don't have to load the full contract\n// ABI just to change a status.\nexport const DATA_REGISTRY_STATUS_ABI = [\n {\n type: \"function\",\n name: \"setStatus\",\n stateMutability: \"nonpayable\",\n inputs: [\n { name: \"scope\", type: \"string\" },\n { name: \"newStatus\", type: \"uint8\" },\n ],\n outputs: [],\n },\n] as const;\n\nexport function dataRegistryContractAddress(\n config: DataPortabilityGatewayConfig,\n): `0x${string}` {\n return config.contracts.dataRegistry as `0x${string}`;\n}\n\nexport interface SetDataPointStatusInput {\n scope: string;\n status: DataPointStatus;\n}\n\n// Shape compatible with viem's `sendTransaction` / `writeContract` request\n// objects. No `value` — `setStatus` is non-payable.\nexport interface DataPointStatusTransactionRequest {\n to: `0x${string}`;\n data: `0x${string}`;\n}\n\nexport function encodeSetDataPointStatusData(\n input: SetDataPointStatusInput,\n): `0x${string}` {\n return encodeFunctionData({\n abi: DATA_REGISTRY_STATUS_ABI,\n functionName: \"setStatus\",\n args: [input.scope, input.status],\n });\n}\n\n// Build the full tx request for a status change. Feed straight to\n// `walletClient.sendTransaction({...req, account, chain})`. The caller's\n// `account` MUST equal the data point's owner — the contract reverts\n// otherwise.\nexport function buildSetDataPointStatusRequest(\n config: DataPortabilityGatewayConfig,\n input: SetDataPointStatusInput,\n): DataPointStatusTransactionRequest {\n return {\n to: dataRegistryContractAddress(config),\n data: encodeSetDataPointStatusData(input),\n };\n}\n\n// Convenience for the \"remove this data point\" intent — the v2 equivalent\n// of the old DELETE /v1/files/:id flow. Sets the status to Unavailable so\n// downstream readers (recordDataAccess, future addData) revert. Callers\n// that want the data point pausable rather than tombstoned should use\n// `buildSetDataPointStatusRequest` with `DataPointStatus.Inactive`.\nexport function buildMarkDataPointUnavailableRequest(\n config: DataPortabilityGatewayConfig,\n input: { scope: string },\n): DataPointStatusTransactionRequest {\n return buildSetDataPointStatusRequest(config, {\n scope: input.scope,\n status: DataPointStatus.Unavailable,\n });\n}\n"],"mappings":"AAiBA,SAAS,0BAA0B;AAa5B,IAAK,kBAAL,kBAAKA,qBAAL;AACL,EAAAA,kCAAA,UAAO,KAAP;AACA,EAAAA,kCAAA,YAAS,KAAT;AACA,EAAAA,kCAAA,cAAW,KAAX;AACA,EAAAA,kCAAA,iBAAc,KAAd;AAJU,SAAAA;AAAA,GAAA;AAUL,MAAM,2BAA2B;AAAA,EACtC;AAAA,IACE,MAAM;AAAA,IACN,MAAM;AAAA,IACN,iBAAiB;AAAA,IACjB,QAAQ;AAAA,MACN,EAAE,MAAM,SAAS,MAAM,SAAS;AAAA,MAChC,EAAE,MAAM,aAAa,MAAM,QAAQ;AAAA,IACrC;AAAA,IACA,SAAS,CAAC;AAAA,EACZ;AACF;AAEO,SAAS,4BACd,QACe;AACf,SAAO,OAAO,UAAU;AAC1B;AAcO,SAAS,6BACd,OACe;AACf,SAAO,mBAAmB;AAAA,IACxB,KAAK;AAAA,IACL,cAAc;AAAA,IACd,MAAM,CAAC,MAAM,OAAO,MAAM,MAAM;AAAA,EAClC,CAAC;AACH;AAMO,SAAS,+BACd,QACA,OACmC;AACnC,SAAO;AAAA,IACL,IAAI,4BAA4B,MAAM;AAAA,IACtC,MAAM,6BAA6B,KAAK;AAAA,EAC1C;AACF;AAOO,SAAS,qCACd,QACA,OACmC;AACnC,SAAO,+BAA+B,QAAQ;AAAA,IAC5C,OAAO,MAAM;AAAA,IACb,QAAQ;AAAA,EACV,CAAC;AACH;","names":["DataPointStatus"]}
@@ -1,89 +0,0 @@
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
@@ -1 +0,0 @@
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":[]}
@@ -1,47 +0,0 @@
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;
@@ -1,60 +0,0 @@
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
@@ -1 +0,0 @@
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":[]}
@@ -1,21 +0,0 @@
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 {};