@lit-protocol/vincent-e2e-test-utils 3.0.0 → 3.0.2-alpha.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 (258) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/CHANGELOG.md +20 -0
  3. package/dist/package.json +3 -7
  4. package/dist/src/index.d.ts +3 -2
  5. package/dist/src/index.d.ts.map +1 -1
  6. package/dist/src/index.js +8 -16
  7. package/dist/src/index.js.map +1 -1
  8. package/dist/src/lib/setup/app-registration/areAbilitiesAndPoliciesEqual.d.ts +3 -0
  9. package/dist/src/lib/setup/app-registration/areAbilitiesAndPoliciesEqual.d.ts.map +1 -0
  10. package/dist/src/lib/setup/app-registration/areAbilitiesAndPoliciesEqual.js +32 -0
  11. package/dist/src/lib/setup/app-registration/areAbilitiesAndPoliciesEqual.js.map +1 -0
  12. package/dist/src/lib/setup/app-registration/handleAppRegistration.d.ts +14 -0
  13. package/dist/src/lib/setup/app-registration/handleAppRegistration.d.ts.map +1 -0
  14. package/dist/src/lib/setup/app-registration/handleAppRegistration.js +43 -0
  15. package/dist/src/lib/setup/app-registration/handleAppRegistration.js.map +1 -0
  16. package/dist/src/lib/setup/app-registration/registerNewApp.d.ts +17 -0
  17. package/dist/src/lib/setup/app-registration/registerNewApp.d.ts.map +1 -0
  18. package/dist/src/lib/setup/app-registration/registerNewApp.js +46 -0
  19. package/dist/src/lib/setup/app-registration/registerNewApp.js.map +1 -0
  20. package/dist/src/lib/setup/app-registration/registerNewAppVersion.d.ts +16 -0
  21. package/dist/src/lib/setup/app-registration/registerNewAppVersion.d.ts.map +1 -0
  22. package/dist/src/lib/setup/app-registration/registerNewAppVersion.js +68 -0
  23. package/dist/src/lib/setup/app-registration/registerNewAppVersion.js.map +1 -0
  24. package/dist/src/lib/setup/app-setup.d.ts +19 -0
  25. package/dist/src/lib/setup/app-setup.d.ts.map +1 -0
  26. package/dist/src/lib/setup/app-setup.js +37 -0
  27. package/dist/src/lib/setup/app-setup.js.map +1 -0
  28. package/dist/src/lib/setup/blockchain/installAppUsingUserEoa.d.ts +10 -0
  29. package/dist/src/lib/setup/blockchain/installAppUsingUserEoa.d.ts.map +1 -0
  30. package/dist/src/lib/setup/blockchain/installAppUsingUserEoa.js +17 -0
  31. package/dist/src/lib/setup/blockchain/installAppUsingUserEoa.js.map +1 -0
  32. package/dist/src/lib/setup/blockchain/registerNewAppVersionOnChain.d.ts +12 -0
  33. package/dist/src/lib/setup/blockchain/registerNewAppVersionOnChain.d.ts.map +1 -0
  34. package/dist/src/lib/setup/blockchain/registerNewAppVersionOnChain.js +23 -0
  35. package/dist/src/lib/setup/blockchain/registerNewAppVersionOnChain.js.map +1 -0
  36. package/dist/src/lib/setup/getEnv.d.ts +2 -0
  37. package/dist/src/lib/setup/getEnv.d.ts.map +1 -0
  38. package/dist/src/lib/setup/getEnv.js +16 -0
  39. package/dist/src/lib/setup/getEnv.js.map +1 -0
  40. package/dist/src/lib/setup/index.d.ts +9 -0
  41. package/dist/src/lib/setup/index.d.ts.map +1 -0
  42. package/dist/src/lib/setup/index.js +18 -0
  43. package/dist/src/lib/setup/index.js.map +1 -0
  44. package/dist/src/lib/setup/setupAgentSmartAccount.d.ts +19 -0
  45. package/dist/src/lib/setup/setupAgentSmartAccount.d.ts.map +1 -0
  46. package/dist/src/lib/setup/setupAgentSmartAccount.js +100 -0
  47. package/dist/src/lib/setup/setupAgentSmartAccount.js.map +1 -0
  48. package/dist/src/lib/setup/smart-account/createPermissionApproval.d.ts +11 -0
  49. package/dist/src/lib/setup/smart-account/createPermissionApproval.d.ts.map +1 -0
  50. package/dist/src/lib/setup/smart-account/createPermissionApproval.js +45 -0
  51. package/dist/src/lib/setup/smart-account/createPermissionApproval.js.map +1 -0
  52. package/dist/src/lib/setup/smart-account/deploySmartAccountToChain.d.ts +16 -0
  53. package/dist/src/lib/setup/smart-account/deploySmartAccountToChain.d.ts.map +1 -0
  54. package/dist/src/lib/setup/smart-account/deploySmartAccountToChain.js +128 -0
  55. package/dist/src/lib/setup/smart-account/deploySmartAccountToChain.js.map +1 -0
  56. package/dist/src/lib/setup/smart-account/deriveAgentAddress.d.ts +23 -0
  57. package/dist/src/lib/setup/smart-account/deriveAgentAddress.d.ts.map +1 -0
  58. package/dist/src/lib/setup/smart-account/deriveAgentAddress.js +36 -0
  59. package/dist/src/lib/setup/smart-account/deriveAgentAddress.js.map +1 -0
  60. package/dist/src/lib/setup/smart-account/vincentViemPkpSigner.d.ts +12 -0
  61. package/dist/src/lib/setup/smart-account/vincentViemPkpSigner.d.ts.map +1 -0
  62. package/dist/src/lib/setup/smart-account/vincentViemPkpSigner.js +82 -0
  63. package/dist/src/lib/setup/smart-account/vincentViemPkpSigner.js.map +1 -0
  64. package/dist/src/lib/setup/smart-account/wrapKernelAccountWithUserOpCapture.d.ts +10 -0
  65. package/dist/src/lib/setup/smart-account/wrapKernelAccountWithUserOpCapture.d.ts.map +1 -0
  66. package/dist/src/lib/setup/smart-account/wrapKernelAccountWithUserOpCapture.js +34 -0
  67. package/dist/src/lib/setup/smart-account/wrapKernelAccountWithUserOpCapture.js.map +1 -0
  68. package/dist/src/lib/setup/types.d.ts +92 -0
  69. package/dist/src/lib/setup/types.d.ts.map +1 -0
  70. package/dist/src/lib/{types.js.map → setup/types.js.map} +1 -1
  71. package/dist/src/lib/setup/vincent-api/completeAppInstallationViaVincentApi.d.ts +32 -0
  72. package/dist/src/lib/setup/vincent-api/completeAppInstallationViaVincentApi.d.ts.map +1 -0
  73. package/dist/src/lib/setup/vincent-api/completeAppInstallationViaVincentApi.js +58 -0
  74. package/dist/src/lib/setup/vincent-api/completeAppInstallationViaVincentApi.js.map +1 -0
  75. package/dist/src/lib/setup/vincent-api/generateAppManagerJwt.d.ts +4 -0
  76. package/dist/src/lib/setup/vincent-api/generateAppManagerJwt.d.ts.map +1 -0
  77. package/dist/src/lib/setup/vincent-api/generateAppManagerJwt.js +28 -0
  78. package/dist/src/lib/setup/vincent-api/generateAppManagerJwt.js.map +1 -0
  79. package/dist/src/lib/setup/vincent-api/installAppViaVincentApi.d.ts +31 -0
  80. package/dist/src/lib/setup/vincent-api/installAppViaVincentApi.d.ts.map +1 -0
  81. package/dist/src/lib/setup/vincent-api/installAppViaVincentApi.js +31 -0
  82. package/dist/src/lib/setup/vincent-api/installAppViaVincentApi.js.map +1 -0
  83. package/dist/src/lib/setup/vincent-api/registerAppVersionWithVincentApi.d.ts +9 -0
  84. package/dist/src/lib/setup/vincent-api/registerAppVersionWithVincentApi.d.ts.map +1 -0
  85. package/dist/src/lib/setup/vincent-api/registerAppVersionWithVincentApi.js +27 -0
  86. package/dist/src/lib/setup/vincent-api/registerAppVersionWithVincentApi.js.map +1 -0
  87. package/dist/src/lib/setup/vincent-api/registerAppWithVincentApi.d.ts +8 -0
  88. package/dist/src/lib/setup/vincent-api/registerAppWithVincentApi.d.ts.map +1 -0
  89. package/dist/src/lib/setup/vincent-api/registerAppWithVincentApi.js +30 -0
  90. package/dist/src/lib/setup/vincent-api/registerAppWithVincentApi.js.map +1 -0
  91. package/dist/src/lib/setup/vincent-api/setActiveVersionWithVincentApi.d.ts +7 -0
  92. package/dist/src/lib/setup/vincent-api/setActiveVersionWithVincentApi.d.ts.map +1 -0
  93. package/dist/src/lib/setup/vincent-api/setActiveVersionWithVincentApi.js +25 -0
  94. package/dist/src/lib/setup/vincent-api/setActiveVersionWithVincentApi.js.map +1 -0
  95. package/dist/src/lib/setup/wallets/ensureWalletHasTokens.d.ts +14 -0
  96. package/dist/src/lib/setup/wallets/ensureWalletHasTokens.d.ts.map +1 -0
  97. package/dist/src/lib/setup/wallets/ensureWalletHasTokens.js +27 -0
  98. package/dist/src/lib/setup/wallets/ensureWalletHasTokens.js.map +1 -0
  99. package/dist/src/lib/setup/wallets/ensureWalletHasUnexpiredCapacityCredit.d.ts +15 -0
  100. package/dist/src/lib/setup/wallets/ensureWalletHasUnexpiredCapacityCredit.d.ts.map +1 -0
  101. package/dist/src/lib/setup/wallets/ensureWalletHasUnexpiredCapacityCredit.js +63 -0
  102. package/dist/src/lib/setup/wallets/ensureWalletHasUnexpiredCapacityCredit.js.map +1 -0
  103. package/dist/src/lib/setup/wallets/setupWallets.d.ts +48 -0
  104. package/dist/src/lib/setup/wallets/setupWallets.d.ts.map +1 -0
  105. package/dist/src/lib/setup/wallets/setupWallets.js +159 -0
  106. package/dist/src/lib/setup/wallets/setupWallets.js.map +1 -0
  107. package/dist/src/lib/setupVincentDevelopmentEnv.d.ts +3 -0
  108. package/dist/src/lib/setupVincentDevelopmentEnv.d.ts.map +1 -0
  109. package/dist/src/lib/setupVincentDevelopmentEnv.js +64 -0
  110. package/dist/src/lib/setupVincentDevelopmentEnv.js.map +1 -0
  111. package/package.json +4 -8
  112. package/dist/src/lib/appManager/ensure-funded.d.ts +0 -2
  113. package/dist/src/lib/appManager/ensure-funded.d.ts.map +0 -1
  114. package/dist/src/lib/appManager/ensure-funded.js +0 -11
  115. package/dist/src/lib/appManager/ensure-funded.js.map +0 -1
  116. package/dist/src/lib/appManager/index.d.ts +0 -5
  117. package/dist/src/lib/appManager/index.d.ts.map +0 -1
  118. package/dist/src/lib/appManager/index.js +0 -12
  119. package/dist/src/lib/appManager/index.js.map +0 -1
  120. package/dist/src/lib/appManager/register-new-app-version.d.ts +0 -28
  121. package/dist/src/lib/appManager/register-new-app-version.d.ts.map +0 -1
  122. package/dist/src/lib/appManager/register-new-app-version.js +0 -82
  123. package/dist/src/lib/appManager/register-new-app-version.js.map +0 -1
  124. package/dist/src/lib/appManager/register-new-app.d.ts +0 -13
  125. package/dist/src/lib/appManager/register-new-app.d.ts.map +0 -1
  126. package/dist/src/lib/appManager/register-new-app.js +0 -25
  127. package/dist/src/lib/appManager/register-new-app.js.map +0 -1
  128. package/dist/src/lib/appManager/remove-delegatee-from-app.d.ts +0 -7
  129. package/dist/src/lib/appManager/remove-delegatee-from-app.d.ts.map +0 -1
  130. package/dist/src/lib/appManager/remove-delegatee-from-app.js +0 -26
  131. package/dist/src/lib/appManager/remove-delegatee-from-app.js.map +0 -1
  132. package/dist/src/lib/chain.d.ts +0 -13
  133. package/dist/src/lib/chain.d.ts.map +0 -1
  134. package/dist/src/lib/chain.js +0 -30
  135. package/dist/src/lib/chain.js.map +0 -1
  136. package/dist/src/lib/create-random-vincent-wallets.d.ts +0 -7
  137. package/dist/src/lib/create-random-vincent-wallets.d.ts.map +0 -1
  138. package/dist/src/lib/create-random-vincent-wallets.js +0 -12
  139. package/dist/src/lib/create-random-vincent-wallets.js.map +0 -1
  140. package/dist/src/lib/delegatee/ensure-funded.d.ts +0 -2
  141. package/dist/src/lib/delegatee/ensure-funded.d.ts.map +0 -1
  142. package/dist/src/lib/delegatee/ensure-funded.js +0 -11
  143. package/dist/src/lib/delegatee/ensure-funded.js.map +0 -1
  144. package/dist/src/lib/delegatee/get-app-info.d.ts +0 -5
  145. package/dist/src/lib/delegatee/get-app-info.d.ts.map +0 -1
  146. package/dist/src/lib/delegatee/get-app-info.js +0 -19
  147. package/dist/src/lib/delegatee/get-app-info.js.map +0 -1
  148. package/dist/src/lib/delegatee/index.d.ts +0 -3
  149. package/dist/src/lib/delegatee/index.d.ts.map +0 -1
  150. package/dist/src/lib/delegatee/index.js +0 -8
  151. package/dist/src/lib/delegatee/index.js.map +0 -1
  152. package/dist/src/lib/delegator/add-permission-for-abilities.d.ts +0 -4
  153. package/dist/src/lib/delegator/add-permission-for-abilities.d.ts.map +0 -1
  154. package/dist/src/lib/delegator/add-permission-for-abilities.js +0 -21
  155. package/dist/src/lib/delegator/add-permission-for-abilities.js.map +0 -1
  156. package/dist/src/lib/delegator/agent-pkp.d.ts +0 -20
  157. package/dist/src/lib/delegator/agent-pkp.d.ts.map +0 -1
  158. package/dist/src/lib/delegator/agent-pkp.js +0 -96
  159. package/dist/src/lib/delegator/agent-pkp.js.map +0 -1
  160. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts +0 -8
  161. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.d.ts.map +0 -1
  162. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js +0 -77
  163. package/dist/src/lib/delegator/get-platform-user-pkp-wallet.js.map +0 -1
  164. package/dist/src/lib/delegator/index.d.ts +0 -7
  165. package/dist/src/lib/delegator/index.d.ts.map +0 -1
  166. package/dist/src/lib/delegator/index.js +0 -20
  167. package/dist/src/lib/delegator/index.js.map +0 -1
  168. package/dist/src/lib/delegator/permit-vincent-app-version.d.ts +0 -19
  169. package/dist/src/lib/delegator/permit-vincent-app-version.d.ts.map +0 -1
  170. package/dist/src/lib/delegator/permit-vincent-app-version.js +0 -45
  171. package/dist/src/lib/delegator/permit-vincent-app-version.js.map +0 -1
  172. package/dist/src/lib/delegator/platform-user-pkp.d.ts +0 -10
  173. package/dist/src/lib/delegator/platform-user-pkp.d.ts.map +0 -1
  174. package/dist/src/lib/delegator/platform-user-pkp.js +0 -48
  175. package/dist/src/lib/delegator/platform-user-pkp.js.map +0 -1
  176. package/dist/src/lib/ensure-capacity-credit.d.ts +0 -4
  177. package/dist/src/lib/ensure-capacity-credit.d.ts.map +0 -1
  178. package/dist/src/lib/ensure-capacity-credit.js +0 -57
  179. package/dist/src/lib/ensure-capacity-credit.js.map +0 -1
  180. package/dist/src/lib/env.d.ts +0 -30
  181. package/dist/src/lib/env.d.ts.map +0 -1
  182. package/dist/src/lib/env.js +0 -58
  183. package/dist/src/lib/env.js.map +0 -1
  184. package/dist/src/lib/environment/crossmint.d.ts +0 -3
  185. package/dist/src/lib/environment/crossmint.d.ts.map +0 -1
  186. package/dist/src/lib/environment/crossmint.js +0 -23
  187. package/dist/src/lib/environment/crossmint.js.map +0 -1
  188. package/dist/src/lib/environment/safe.d.ts +0 -567
  189. package/dist/src/lib/environment/safe.d.ts.map +0 -1
  190. package/dist/src/lib/environment/safe.js +0 -41
  191. package/dist/src/lib/environment/safe.js.map +0 -1
  192. package/dist/src/lib/environment/zerodev.d.ts +0 -49
  193. package/dist/src/lib/environment/zerodev.d.ts.map +0 -1
  194. package/dist/src/lib/environment/zerodev.js +0 -32
  195. package/dist/src/lib/environment/zerodev.js.map +0 -1
  196. package/dist/src/lib/funder/check-funder-balance.d.ts +0 -3
  197. package/dist/src/lib/funder/check-funder-balance.d.ts.map +0 -1
  198. package/dist/src/lib/funder/check-funder-balance.js +0 -19
  199. package/dist/src/lib/funder/check-funder-balance.js.map +0 -1
  200. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts +0 -5
  201. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.d.ts.map +0 -1
  202. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js +0 -35
  203. package/dist/src/lib/funder/ensure-wallet-has-test-tokens.js.map +0 -1
  204. package/dist/src/lib/funder/index.d.ts +0 -5
  205. package/dist/src/lib/funder/index.d.ts.map +0 -1
  206. package/dist/src/lib/funder/index.js +0 -10
  207. package/dist/src/lib/funder/index.js.map +0 -1
  208. package/dist/src/lib/index.d.ts +0 -18
  209. package/dist/src/lib/index.d.ts.map +0 -1
  210. package/dist/src/lib/index.js +0 -31
  211. package/dist/src/lib/index.js.map +0 -1
  212. package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts +0 -14
  213. package/dist/src/lib/litContractsClient/LitContractsInstance.d.ts.map +0 -1
  214. package/dist/src/lib/litContractsClient/LitContractsInstance.js +0 -48
  215. package/dist/src/lib/litContractsClient/LitContractsInstance.js.map +0 -1
  216. package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts +0 -7
  217. package/dist/src/lib/litContractsClient/get-lit-contract-client.d.ts.map +0 -1
  218. package/dist/src/lib/litContractsClient/get-lit-contract-client.js +0 -19
  219. package/dist/src/lib/litContractsClient/get-lit-contract-client.js.map +0 -1
  220. package/dist/src/lib/litContractsClient/index.d.ts +0 -3
  221. package/dist/src/lib/litContractsClient/index.d.ts.map +0 -1
  222. package/dist/src/lib/litContractsClient/index.js +0 -8
  223. package/dist/src/lib/litContractsClient/index.js.map +0 -1
  224. package/dist/src/lib/mint-new-pkp.d.ts +0 -16
  225. package/dist/src/lib/mint-new-pkp.d.ts.map +0 -1
  226. package/dist/src/lib/mint-new-pkp.js +0 -40
  227. package/dist/src/lib/mint-new-pkp.js.map +0 -1
  228. package/dist/src/lib/setup-vincent-development-environment.d.ts +0 -81
  229. package/dist/src/lib/setup-vincent-development-environment.d.ts.map +0 -1
  230. package/dist/src/lib/setup-vincent-development-environment.js +0 -185
  231. package/dist/src/lib/setup-vincent-development-environment.js.map +0 -1
  232. package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.d.ts +0 -3
  233. package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.d.ts.map +0 -1
  234. package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js +0 -96
  235. package/dist/src/lib/smartAccount/crossmint/setup-crossmint-account.js.map +0 -1
  236. package/dist/src/lib/smartAccount/index.d.ts +0 -5
  237. package/dist/src/lib/smartAccount/index.d.ts.map +0 -1
  238. package/dist/src/lib/smartAccount/index.js +0 -10
  239. package/dist/src/lib/smartAccount/index.js.map +0 -1
  240. package/dist/src/lib/smartAccount/safe/setup-safe-account.d.ts +0 -15
  241. package/dist/src/lib/smartAccount/safe/setup-safe-account.d.ts.map +0 -1
  242. package/dist/src/lib/smartAccount/safe/setup-safe-account.js +0 -92
  243. package/dist/src/lib/smartAccount/safe/setup-safe-account.js.map +0 -1
  244. package/dist/src/lib/smartAccount/types.d.ts +0 -30
  245. package/dist/src/lib/smartAccount/types.d.ts.map +0 -1
  246. package/dist/src/lib/smartAccount/types.js.map +0 -1
  247. package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.d.ts +0 -3
  248. package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.d.ts.map +0 -1
  249. package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.js +0 -24
  250. package/dist/src/lib/smartAccount/zerodev/get-permission-empty-validator.js.map +0 -1
  251. package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.d.ts +0 -18
  252. package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.d.ts.map +0 -1
  253. package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.js +0 -112
  254. package/dist/src/lib/smartAccount/zerodev/setup-zerodev-account.js.map +0 -1
  255. package/dist/src/lib/types.d.ts +0 -17
  256. package/dist/src/lib/types.d.ts.map +0 -1
  257. package/dist/src/lib/types.js +0 -3
  258. /package/dist/src/lib/{smartAccount → setup}/types.js +0 -0
@@ -0,0 +1,92 @@
1
+ import type { Address, Chain, PrivateKeyAccount, PublicClient } from 'viem';
2
+ import type { Wallet } from 'ethers';
3
+ /**
4
+ * App metadata for Vincent registry
5
+ */
6
+ export interface AppMetadata {
7
+ name: string;
8
+ description: string;
9
+ contactEmail: string;
10
+ appUrl: string;
11
+ logo?: string;
12
+ deploymentStatus?: 'dev' | 'test' | 'prod';
13
+ }
14
+ interface FundingConfig {
15
+ funder?: {
16
+ minAmountVincentRegistryChain?: bigint;
17
+ minAmountChronicleYellowstone?: bigint;
18
+ };
19
+ appManagerMinAmount?: {
20
+ minAmountVincentRegistryChain?: bigint;
21
+ };
22
+ userEoaMinAmount?: {
23
+ minAmountVincentRegistryChain?: bigint;
24
+ };
25
+ appDelegateeMinAmount?: {
26
+ minAmountChronicleYellowstone?: bigint;
27
+ };
28
+ }
29
+ /**
30
+ * Configuration for the development environment setup
31
+ */
32
+ export interface SetupConfig {
33
+ vincentRegistryRpcUrl: string;
34
+ vincentRegistryChain: Chain;
35
+ vincentApiUrl: string;
36
+ privateKeys: {
37
+ appManager: `0x${string}`;
38
+ appDelegatee: `0x${string}`;
39
+ userEoa: `0x${string}`;
40
+ funder: `0x${string}`;
41
+ };
42
+ appMetadata: AppMetadata;
43
+ abilityIpfsCids: string[];
44
+ abilityPolicies: string[][];
45
+ zerodevProjectId: string;
46
+ setupUserSmartAccount?: boolean;
47
+ smartAccountFundAmountBeforeDeployment?: bigint;
48
+ sponsorGasForAppInstallation?: boolean;
49
+ funding?: FundingConfig;
50
+ }
51
+ /**
52
+ * Result type for the development environment setup
53
+ */
54
+ export interface VincentDevEnvironment {
55
+ vincentRegistryRpcUrl: string;
56
+ vincentRegistryChain: Chain;
57
+ appId: number;
58
+ appVersion: number;
59
+ accountIndexHash?: string;
60
+ accounts: {
61
+ funder: PrivateKeyAccount;
62
+ appManager: PrivateKeyAccount;
63
+ appDelegatee: PrivateKeyAccount;
64
+ userEoa: PrivateKeyAccount;
65
+ };
66
+ ethersWallets: {
67
+ funder: Wallet;
68
+ appManager: Wallet;
69
+ appDelegatee: Wallet;
70
+ userEoa: Wallet;
71
+ };
72
+ clients: {
73
+ vincentRegistryPublicClient: PublicClient;
74
+ chronicleYellowstonePublicClient: PublicClient;
75
+ };
76
+ agentSmartAccount?: {
77
+ address: Address;
78
+ agentSignerAddress: Address;
79
+ deploymentTxHash?: `0x${string}`;
80
+ };
81
+ }
82
+ /**
83
+ * Result from on-chain app registration
84
+ */
85
+ export interface RegisterAppResult {
86
+ hash: string;
87
+ appId: bigint;
88
+ accountIndexHash: string;
89
+ appVersion: bigint;
90
+ }
91
+ export {};
92
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/setup/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,iBAAiB,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAC5E,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAErC;;GAEG;AACH,MAAM,WAAW,WAAW;IAC1B,IAAI,EAAE,MAAM,CAAC;IACb,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,gBAAgB,CAAC,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAAC;CAC5C;AAED,UAAU,aAAa;IACrB,MAAM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,EAAE,iBAAiB,CAAC;QAC9B,YAAY,EAAE,iBAAiB,CAAC;QAChC,OAAO,EAAE,iBAAiB,CAAC;KAC5B,CAAC;IACF,aAAa,EAAE;QACb,MAAM,EAAE,MAAM,CAAC;QACf,UAAU,EAAE,MAAM,CAAC;QACnB,YAAY,EAAE,MAAM,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC;KACjB,CAAC;IACF,OAAO,EAAE;QACP,2BAA2B,EAAE,YAAY,CAAC;QAC1C,gCAAgC,EAAE,YAAY,CAAC;KAChD,CAAC;IACF,iBAAiB,CAAC,EAAE;QAClB,OAAO,EAAE,OAAO,CAAC;QACjB,kBAAkB,EAAE,OAAO,CAAC;QAC5B,gBAAgB,CAAC,EAAE,KAAK,MAAM,EAAE,CAAC;KAClC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,UAAU,EAAE,MAAM,CAAC;CACpB"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/lib/types.ts"],"names":[],"mappings":""}
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/setup/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,32 @@
1
+ /**
2
+ * Complete app installation by signing and submitting the permit transaction.
3
+ *
4
+ * This function:
5
+ * 1. Signs the EIP-712 typed data with the user's private key
6
+ * 2. Submits the signature to the Vincent API
7
+ * 3. The API relays the permitAppVersion call to the Vincent contract via Gelato
8
+ *
9
+ * This establishes the agent (smart account) <-> app relationship in the Vincent contract.
10
+ *
11
+ * @param params - Installation completion parameters
12
+ * @returns Transaction hash of the permitAppVersion transaction
13
+ *
14
+ * @example
15
+ * ```typescript
16
+ * const txHash = await completeAppInstallationViaVincentApi({
17
+ * vincentApiUrl: 'https://api.heyvincent.ai',
18
+ * userEoaPrivateKey: '0x...',
19
+ * appId: 1,
20
+ * appInstallationDataToSign: installData.appInstallationDataToSign,
21
+ * });
22
+ *
23
+ * console.log('Permit transaction hash:', txHash);
24
+ * ```
25
+ */
26
+ export declare function completeAppInstallationViaVincentApi({ vincentApiUrl, userEoaPrivateKey, appId, appInstallationDataToSign, }: {
27
+ vincentApiUrl: string;
28
+ userEoaPrivateKey: string;
29
+ appId: number;
30
+ appInstallationDataToSign: any;
31
+ }): Promise<string>;
32
+ //# sourceMappingURL=completeAppInstallationViaVincentApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completeAppInstallationViaVincentApi.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/completeAppInstallationViaVincentApi.ts"],"names":[],"mappings":"AAEA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,wBAAsB,oCAAoC,CAAC,EACzD,aAAa,EACb,iBAAiB,EACjB,KAAK,EACL,yBAAyB,GAC1B,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,KAAK,EAAE,MAAM,CAAC;IACd,yBAAyB,EAAE,GAAG,CAAC;CAChC,GAAG,OAAO,CAAC,MAAM,CAAC,CAwClB"}
@@ -0,0 +1,58 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.completeAppInstallationViaVincentApi = completeAppInstallationViaVincentApi;
4
+ const ethers_1 = require("ethers");
5
+ /**
6
+ * Complete app installation by signing and submitting the permit transaction.
7
+ *
8
+ * This function:
9
+ * 1. Signs the EIP-712 typed data with the user's private key
10
+ * 2. Submits the signature to the Vincent API
11
+ * 3. The API relays the permitAppVersion call to the Vincent contract via Gelato
12
+ *
13
+ * This establishes the agent (smart account) <-> app relationship in the Vincent contract.
14
+ *
15
+ * @param params - Installation completion parameters
16
+ * @returns Transaction hash of the permitAppVersion transaction
17
+ *
18
+ * @example
19
+ * ```typescript
20
+ * const txHash = await completeAppInstallationViaVincentApi({
21
+ * vincentApiUrl: 'https://api.heyvincent.ai',
22
+ * userEoaPrivateKey: '0x...',
23
+ * appId: 1,
24
+ * appInstallationDataToSign: installData.appInstallationDataToSign,
25
+ * });
26
+ *
27
+ * console.log('Permit transaction hash:', txHash);
28
+ * ```
29
+ */
30
+ async function completeAppInstallationViaVincentApi({ vincentApiUrl, userEoaPrivateKey, appId, appInstallationDataToSign, }) {
31
+ console.log('=== Completing app installation via Vincent API (gas-sponsored) ===');
32
+ // Sign the EIP-712 typed data
33
+ const wallet = new ethers_1.Wallet(userEoaPrivateKey);
34
+ const typedData = appInstallationDataToSign.typedData;
35
+ // Remove EIP712Domain from types as ethers.js doesn't expect it
36
+ // (it's automatically added by ethers based on the domain object)
37
+ const { EIP712Domain, ...typesWithoutDomain } = typedData.types;
38
+ // EIP-712 signing: sign the typed data structure
39
+ const signature = await wallet._signTypedData(typedData.domain, typesWithoutDomain, typedData.message);
40
+ // Submit to Vincent API to complete installation (this relays the permitAppVersion call)
41
+ const response = await fetch(`${vincentApiUrl}/user/${appId}/complete-installation`, {
42
+ method: 'POST',
43
+ headers: {
44
+ 'Content-Type': 'application/json',
45
+ },
46
+ body: JSON.stringify({
47
+ typedDataSignature: signature,
48
+ appInstallationDataToSign,
49
+ }),
50
+ });
51
+ if (!response.ok) {
52
+ const errorText = await response.text();
53
+ throw new Error(`Complete app installation via Vincent API failed: ${response.status} ${response.statusText} - ${errorText}`);
54
+ }
55
+ const data = (await response.json());
56
+ return data.transactionHash;
57
+ }
58
+ //# sourceMappingURL=completeAppInstallationViaVincentApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"completeAppInstallationViaVincentApi.js","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/completeAppInstallationViaVincentApi.ts"],"names":[],"mappings":";;AA2BA,oFAkDC;AA7ED,mCAAgC;AAEhC;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACI,KAAK,UAAU,oCAAoC,CAAC,EACzD,aAAa,EACb,i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MappingURL=generateAppManagerJwt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateAppManagerJwt.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/generateAppManagerJwt.ts"],"names":[],"mappings":"AAIA,wBAAsB,qBAAqB,CAAC,EAC1C,oBAAoB,GACrB,EAAE;IACD,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;CACrC,GAAG,OAAO,CAAC,MAAM,CAAC,CAuBlB"}
@@ -0,0 +1,28 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.generateAppManagerJwt = generateAppManagerJwt;
4
+ const jwt_1 = require("@lit-protocol/vincent-app-sdk/jwt");
5
+ const ethers_1 = require("ethers");
6
+ async function generateAppManagerJwt({ appManagerPrivateKey, }) {
7
+ const wallet = new ethers_1.Wallet(appManagerPrivateKey);
8
+ const address = await wallet.getAddress();
9
+ const jwt = await (0, jwt_1.createPlatformUserJWT)({
10
+ pkpWallet: wallet,
11
+ pkpInfo: {
12
+ tokenId: '0', // Not used for app manager auth
13
+ publicKey: wallet.publicKey,
14
+ ethAddress: address,
15
+ },
16
+ payload: {
17
+ name: 'Vincent App Manager',
18
+ },
19
+ expiresInMinutes: 2,
20
+ audience: 'registry.heyvincent.ai',
21
+ authentication: {
22
+ type: 'wallet',
23
+ value: address,
24
+ },
25
+ });
26
+ return jwt;
27
+ }
28
+ //# sourceMappingURL=generateAppManagerJwt.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"generateAppManagerJwt.js","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/generateAppManagerJwt.ts"],"names":[],"mappings":";;AAIA,sDA2BC;AA9BD,2DAA0E;AAC1E,mCAAgC;AAEzB,KAAK,UAAU,qBAAqB,CAAC,EAC1C,oBAAoB,GAGrB;IACC,MAAM,MAAM,GAAG,IAAI,eAAM,CAAC,oBAAoB,CAAC,CAAC;IAChD,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAE1C,MAAM,GAAG,GAAG,MAAM,IAAA,2BAAqB,EAAC;QACtC,SAAS,EAAE,MAAoC;QAC/C,OAAO,EAAE;YACP,OAAO,EAAE,GAAG,EAAE,gCAAgC;YAC9C,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,UAAU,EAAE,OAAO;SACpB;QACD,OAAO,EAAE;YACP,IAAI,EAAE,qBAAqB;SAC5B;QACD,gBAAgB,EAAE,CAAC;QACnB,QAAQ,EAAE,wBAAwB;QAClC,cAAc,EAAE;YACd,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,OAAO;SACf;KACF,CAAC,CAAC;IAEH,OAAO,GAAG,CAAC;AACb,CAAC"}
@@ -0,0 +1,31 @@
1
+ export interface InstallAppResponseSponsored {
2
+ agentSignerAddress: string;
3
+ agentSmartAccountAddress: string;
4
+ appInstallationDataToSign: {
5
+ typedData: any;
6
+ };
7
+ alreadyInstalled?: boolean;
8
+ }
9
+ export interface InstallAppResponseDirect {
10
+ agentSignerAddress: string;
11
+ agentSmartAccountAddress: string;
12
+ rawTransaction: {
13
+ to: string;
14
+ data: string;
15
+ };
16
+ alreadyInstalled?: boolean;
17
+ }
18
+ export interface InstallAppResponseAlreadyInstalled {
19
+ agentSignerAddress: string;
20
+ agentSmartAccountAddress: string;
21
+ alreadyInstalled: true;
22
+ }
23
+ export type InstallAppResponse = InstallAppResponseSponsored | InstallAppResponseDirect | InstallAppResponseAlreadyInstalled;
24
+ export declare function isInstallAppResponseSponsored(response: InstallAppResponse): response is InstallAppResponseSponsored;
25
+ export declare function installAppViaVincentApi({ vincentApiUrl, appId, userEoaAddress, sponsorGas, }: {
26
+ vincentApiUrl: string;
27
+ appId: number;
28
+ userEoaAddress: string;
29
+ sponsorGas?: boolean;
30
+ }): Promise<InstallAppResponse>;
31
+ //# sourceMappingURL=installAppViaVincentApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installAppViaVincentApi.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/installAppViaVincentApi.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,2BAA2B;IAC1C,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,yBAAyB,EAAE;QACzB,SAAS,EAAE,GAAG,CAAC;KAChB,CAAC;IACF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,wBAAwB;IACvC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,cAAc,EAAE;QACd,EAAE,EAAE,MAAM,CAAC;QACX,IAAI,EAAE,MAAM,CAAC;KACd,CAAC;IACF,gBAAgB,CAAC,EAAE,OAAO,CAAC;CAC5B;AAED,MAAM,WAAW,kCAAkC;IACjD,kBAAkB,EAAE,MAAM,CAAC;IAC3B,wBAAwB,EAAE,MAAM,CAAC;IACjC,gBAAgB,EAAE,IAAI,CAAC;CACxB;AAED,MAAM,MAAM,kBAAkB,GAC1B,2BAA2B,GAC3B,wBAAwB,GACxB,kCAAkC,CAAC;AAEvC,wBAAgB,6BAA6B,CAC3C,QAAQ,EAAE,kBAAkB,GAC3B,QAAQ,IAAI,2BAA2B,CAEzC;AAED,wBAAsB,uBAAuB,CAAC,EAC5C,aAAa,EACb,KAAK,EACL,cAAc,EACd,UAAkB,GACnB,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,cAAc,EAAE,MAAM,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;CACtB,GAAG,OAAO,CAAC,kBAAkB,CAAC,CA6B9B"}
@@ -0,0 +1,31 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.isInstallAppResponseSponsored = isInstallAppResponseSponsored;
4
+ exports.installAppViaVincentApi = installAppViaVincentApi;
5
+ function isInstallAppResponseSponsored(response) {
6
+ return 'appInstallationDataToSign' in response;
7
+ }
8
+ async function installAppViaVincentApi({ vincentApiUrl, appId, userEoaAddress, sponsorGas = false, }) {
9
+ console.log('=== Installing app via Vincent API ===');
10
+ const response = await fetch(`${vincentApiUrl}/user/${appId}/install-app`, {
11
+ method: 'POST',
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ },
15
+ body: JSON.stringify({
16
+ userControllerAddress: userEoaAddress,
17
+ sponsorGas,
18
+ }),
19
+ });
20
+ if (!response.ok) {
21
+ const errorText = await response.text();
22
+ throw new Error(`Install app via Vincent API failed: ${response.status} ${response.statusText} - ${errorText}`);
23
+ }
24
+ const data = (await response.json());
25
+ console.table({
26
+ 'Agent Signer Address': data.agentSignerAddress,
27
+ 'Agent Smart Account Address': data.agentSmartAccountAddress,
28
+ });
29
+ return data;
30
+ }
31
+ //# sourceMappingURL=installAppViaVincentApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"installAppViaVincentApi.js","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/installAppViaVincentApi.ts"],"names":[],"mappings":";;AA8BA,sEAIC;AAED,0DAuCC;AA7CD,SAAgB,6BAA6B,CAC3C,QAA4B;IAE5B,OAAO,2BAA2B,IAAI,QAAQ,CAAC;AACjD,CAAC;AAEM,KAAK,UAAU,uBAAuB,CAAC,EAC5C,aAAa,EACb,KAAK,EACL,cAAc,EACd,UAAU,GAAG,KAAK,GAMnB;IACC,OAAO,CAAC,GAAG,CAAC,wCAAwC,CAAC,CAAC;IAEtD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,aAAa,SAAS,KAAK,cAAc,EAAE;QACzE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;SACnC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,qBAAqB,EAAE,cAAc;YACrC,UAAU;SACX,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,uCAAuC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CAC/F,CAAC;IACJ,CAAC;IAED,MAAM,IAAI,GAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAuB,CAAC;IAE3D,OAAO,CAAC,KAAK,CAAC;QACZ,sBAAsB,EAAE,IAAI,CAAC,kBAAkB;QAC/C,6BAA6B,EAAE,IAAI,CAAC,wBAAwB;KAC7D,CAAC,CAAC;IAEH,OAAO,IAAI,CAAC;AACd,CAAC"}
@@ -0,0 +1,9 @@
1
+ export declare function registerAppVersionWithVincentApi({ vincentApiUrl, appManagerPrivateKey, appId, whatChanged, }: {
2
+ vincentApiUrl: string;
3
+ appManagerPrivateKey: `0x${string}`;
4
+ appId: number;
5
+ whatChanged: string;
6
+ }): Promise<{
7
+ newAppVersion: number;
8
+ }>;
9
+ //# sourceMappingURL=registerAppVersionWithVincentApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerAppVersionWithVincentApi.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/registerAppVersionWithVincentApi.ts"],"names":[],"mappings":"AAEA,wBAAsB,gCAAgC,CAAC,EACrD,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,WAAW,GACZ,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC;IAAE,aAAa,EAAE,MAAM,CAAA;CAAE,CAAC,CA0BrC"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerAppVersionWithVincentApi = registerAppVersionWithVincentApi;
4
+ const generateAppManagerJwt_1 = require("./generateAppManagerJwt");
5
+ async function registerAppVersionWithVincentApi({ vincentApiUrl, appManagerPrivateKey, appId, whatChanged, }) {
6
+ const jwtToken = await (0, generateAppManagerJwt_1.generateAppManagerJwt)({
7
+ appManagerPrivateKey,
8
+ });
9
+ const response = await fetch(`${vincentApiUrl}/app/${appId}/version`, {
10
+ method: 'POST',
11
+ headers: {
12
+ 'Content-Type': 'application/json',
13
+ Authorization: `Bearer ${jwtToken}`,
14
+ },
15
+ body: JSON.stringify({
16
+ changes: whatChanged,
17
+ }),
18
+ });
19
+ if (!response.ok) {
20
+ const errorText = await response.text();
21
+ throw new Error(`Register app version with vincent api failed: ${response.status} ${response.statusText} - ${errorText}`);
22
+ }
23
+ return {
24
+ newAppVersion: (await response.json()).version,
25
+ };
26
+ }
27
+ //# sourceMappingURL=registerAppVersionWithVincentApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerAppVersionWithVincentApi.js","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/registerAppVersionWithVincentApi.ts"],"names":[],"mappings":";;AAEA,4EAoCC;AAtCD,mEAAgE;AAEzD,KAAK,UAAU,gCAAgC,CAAC,EACrD,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,WAAW,GAMZ;IACC,MAAM,QAAQ,GAAG,MAAM,IAAA,6CAAqB,EAAC;QAC3C,oBAAoB;KACrB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,aAAa,QAAQ,KAAK,UAAU,EAAE;QACpE,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,QAAQ,EAAE;SACpC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,OAAO,EAAE,WAAW;SACrB,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,iDAAiD,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACzG,CAAC;IACJ,CAAC;IAED,OAAO;QACL,aAAa,EAAG,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAyB,CAAC,OAAO;KACxE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,8 @@
1
+ import type { AppMetadata } from '../types';
2
+ export declare function registerAppWithVincentApi({ vincentApiUrl, appManagerPrivateKey, appId, appMetadata, }: {
3
+ vincentApiUrl: string;
4
+ appManagerPrivateKey: `0x${string}`;
5
+ appId: number;
6
+ appMetadata: AppMetadata;
7
+ }): Promise<void>;
8
+ //# sourceMappingURL=registerAppWithVincentApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerAppWithVincentApi.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/registerAppWithVincentApi.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAE5C,wBAAsB,yBAAyB,CAAC,EAC9C,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,WAAW,GACZ,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,EAAE,WAAW,CAAC;CAC1B,GAAG,OAAO,CAAC,IAAI,CAAC,CA4BhB"}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.registerAppWithVincentApi = registerAppWithVincentApi;
4
+ const generateAppManagerJwt_1 = require("./generateAppManagerJwt");
5
+ async function registerAppWithVincentApi({ vincentApiUrl, appManagerPrivateKey, appId, appMetadata, }) {
6
+ const jwtToken = await (0, generateAppManagerJwt_1.generateAppManagerJwt)({
7
+ appManagerPrivateKey,
8
+ });
9
+ const response = await fetch(`${vincentApiUrl}/app`, {
10
+ method: 'POST',
11
+ headers: {
12
+ 'Content-Type': 'application/json',
13
+ Authorization: `Bearer ${jwtToken}`,
14
+ },
15
+ body: JSON.stringify({
16
+ appId,
17
+ name: appMetadata.name,
18
+ description: appMetadata.description,
19
+ contactEmail: appMetadata.contactEmail,
20
+ appUrl: appMetadata.appUrl,
21
+ logo: appMetadata.logo,
22
+ deploymentStatus: appMetadata.deploymentStatus || 'dev',
23
+ }),
24
+ });
25
+ if (!response.ok) {
26
+ const errorText = await response.text();
27
+ throw new Error(`Register app with Vincent API failed: ${response.status} ${response.statusText} - ${errorText}`);
28
+ }
29
+ }
30
+ //# sourceMappingURL=registerAppWithVincentApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registerAppWithVincentApi.js","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/registerAppWithVincentApi.ts"],"names":[],"mappings":";;AAGA,8DAsCC;AAzCD,mEAAgE;AAGzD,KAAK,UAAU,yBAAyB,CAAC,EAC9C,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,WAAW,GAMZ;IACC,MAAM,QAAQ,GAAG,MAAM,IAAA,6CAAqB,EAAC;QAC3C,oBAAoB;KACrB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,aAAa,MAAM,EAAE;QACnD,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,QAAQ,EAAE;SACpC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,KAAK;YACL,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,WAAW,EAAE,WAAW,CAAC,WAAW;YACpC,YAAY,EAAE,WAAW,CAAC,YAAY;YACtC,MAAM,EAAE,WAAW,CAAC,MAAM;YAC1B,IAAI,EAAE,WAAW,CAAC,IAAI;YACtB,gBAAgB,EAAE,WAAW,CAAC,gBAAgB,IAAI,KAAK;SACxD,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,yCAAyC,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACjG,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,7 @@
1
+ export declare function setActiveVersionWithVincentApi({ vincentApiUrl, appManagerPrivateKey, appId, activeVersion, }: {
2
+ vincentApiUrl: string;
3
+ appManagerPrivateKey: `0x${string}`;
4
+ appId: number;
5
+ activeVersion: number;
6
+ }): Promise<void>;
7
+ //# sourceMappingURL=setActiveVersionWithVincentApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setActiveVersionWithVincentApi.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/setActiveVersionWithVincentApi.ts"],"names":[],"mappings":"AAEA,wBAAsB,8BAA8B,CAAC,EACnD,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,aAAa,GACd,EAAE;IACD,aAAa,EAAE,MAAM,CAAC;IACtB,oBAAoB,EAAE,KAAK,MAAM,EAAE,CAAC;IACpC,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,EAAE,MAAM,CAAC;CACvB,GAAG,OAAO,CAAC,IAAI,CAAC,CAwBhB"}
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.setActiveVersionWithVincentApi = setActiveVersionWithVincentApi;
4
+ const generateAppManagerJwt_1 = require("./generateAppManagerJwt");
5
+ async function setActiveVersionWithVincentApi({ vincentApiUrl, appManagerPrivateKey, appId, activeVersion, }) {
6
+ console.log('=== Setting active version with Vincent API ===');
7
+ const jwtToken = await (0, generateAppManagerJwt_1.generateAppManagerJwt)({
8
+ appManagerPrivateKey,
9
+ });
10
+ const response = await fetch(`${vincentApiUrl}/app/${appId}/setActiveVersion`, {
11
+ method: 'POST',
12
+ headers: {
13
+ 'Content-Type': 'application/json',
14
+ Authorization: `Bearer ${jwtToken}`,
15
+ },
16
+ body: JSON.stringify({
17
+ activeVersion,
18
+ }),
19
+ });
20
+ if (!response.ok) {
21
+ const errorText = await response.text();
22
+ throw new Error(`Set active version with Vincent API failed: ${response.status} ${response.statusText} - ${errorText}`);
23
+ }
24
+ }
25
+ //# sourceMappingURL=setActiveVersionWithVincentApi.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"setActiveVersionWithVincentApi.js","sourceRoot":"","sources":["../../../../../src/lib/setup/vincent-api/setActiveVersionWithVincentApi.ts"],"names":[],"mappings":";;AAEA,wEAkCC;AApCD,mEAAgE;AAEzD,KAAK,UAAU,8BAA8B,CAAC,EACnD,aAAa,EACb,oBAAoB,EACpB,KAAK,EACL,aAAa,GAMd;IACC,OAAO,CAAC,GAAG,CAAC,iDAAiD,CAAC,CAAC;IAE/D,MAAM,QAAQ,GAAG,MAAM,IAAA,6CAAqB,EAAC;QAC3C,oBAAoB;KACrB,CAAC,CAAC;IAEH,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,GAAG,aAAa,QAAQ,KAAK,mBAAmB,EAAE;QAC7E,MAAM,EAAE,MAAM;QACd,OAAO,EAAE;YACP,cAAc,EAAE,kBAAkB;YAClC,aAAa,EAAE,UAAU,QAAQ,EAAE;SACpC;QACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;YACnB,aAAa;SACd,CAAC;KACH,CAAC,CAAC;IAEH,IAAI,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;QACjB,MAAM,SAAS,GAAG,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC;QACxC,MAAM,IAAI,KAAK,CACb,+CAA+C,QAAQ,CAAC,MAAM,IAAI,QAAQ,CAAC,UAAU,MAAM,SAAS,EAAE,CACvG,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,14 @@
1
+ import { type PublicClient, type WalletClient, type Account } from 'viem';
2
+ import { type Address } from 'viem/accounts';
3
+ export declare function ensureWalletHasTokens({ address, funderWalletClient, publicClient, minAmount, dontFund, numberOfConfirmations, }: {
4
+ address: Address;
5
+ funderWalletClient: WalletClient<any, any, Account>;
6
+ publicClient: PublicClient;
7
+ minAmount: bigint;
8
+ dontFund?: boolean;
9
+ numberOfConfirmations?: number;
10
+ }): Promise<{
11
+ currentBalance: bigint;
12
+ fundingTxHash?: `0x${string}`;
13
+ }>;
14
+ //# sourceMappingURL=ensureWalletHasTokens.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureWalletHasTokens.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/wallets/ensureWalletHasTokens.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,YAAY,EAAE,KAAK,YAAY,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAC1E,OAAO,EAAE,KAAK,OAAO,EAAE,MAAM,eAAe,CAAC;AAE7C,wBAAsB,qBAAqB,CAAC,EAC1C,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,QAAgB,EAChB,qBAAyB,GAC1B,EAAE;IACD,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,YAAY,CAAC,GAAG,EAAE,GAAG,EAAE,OAAO,CAAC,CAAC;IACpD,YAAY,EAAE,YAAY,CAAC;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,qBAAqB,CAAC,EAAE,MAAM,CAAC;CAChC,GAAG,OAAO,CAAC;IAAE,cAAc,EAAE,MAAM,CAAC;IAAC,aAAa,CAAC,EAAE,KAAK,MAAM,EAAE,CAAA;CAAE,CAAC,CA0BrE"}
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureWalletHasTokens = ensureWalletHasTokens;
4
+ async function ensureWalletHasTokens({ address, funderWalletClient, publicClient, minAmount, dontFund = false, numberOfConfirmations = 2, }) {
5
+ const walletBalance = await publicClient.getBalance({ address });
6
+ if (walletBalance >= minAmount || dontFund)
7
+ return { currentBalance: walletBalance };
8
+ const fundAmount = minAmount - walletBalance;
9
+ const txHash = await funderWalletClient.sendTransaction({
10
+ to: address,
11
+ value: fundAmount,
12
+ chain: funderWalletClient.chain,
13
+ });
14
+ const txReceipt = await publicClient.waitForTransactionReceipt({ hash: txHash });
15
+ if (txReceipt.status !== 'success') {
16
+ throw new Error(`Transaction failed. Tx hash: ${txHash}`);
17
+ }
18
+ if (numberOfConfirmations > 0) {
19
+ console.log('Waiting for funding transaction confirmations...');
20
+ await publicClient.waitForTransactionReceipt({
21
+ hash: txHash,
22
+ confirmations: numberOfConfirmations,
23
+ });
24
+ }
25
+ return { currentBalance: walletBalance + fundAmount, fundingTxHash: txHash };
26
+ }
27
+ //# sourceMappingURL=ensureWalletHasTokens.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureWalletHasTokens.js","sourceRoot":"","sources":["../../../../../src/lib/setup/wallets/ensureWalletHasTokens.ts"],"names":[],"mappings":";;AAGA,sDAwCC;AAxCM,KAAK,UAAU,qBAAqB,CAAC,EAC1C,OAAO,EACP,kBAAkB,EAClB,YAAY,EACZ,SAAS,EACT,QAAQ,GAAG,KAAK,EAChB,qBAAqB,GAAG,CAAC,GAQ1B;IACC,MAAM,aAAa,GAAG,MAAM,YAAY,CAAC,UAAU,CAAC,EAAE,OAAO,EAAE,CAAC,CAAC;IAEjE,IAAI,aAAa,IAAI,SAAS,IAAI,QAAQ;QAAE,OAAO,EAAE,cAAc,EAAE,aAAa,EAAE,CAAC;IAErF,MAAM,UAAU,GAAG,SAAS,GAAG,aAAa,CAAC;IAC7C,MAAM,MAAM,GAAG,MAAM,kBAAkB,CAAC,eAAe,CAAC;QACtD,EAAE,EAAE,OAAO;QACX,KAAK,EAAE,UAAU;QACjB,KAAK,EAAE,kBAAkB,CAAC,KAAK;KAChC,CAAC,CAAC;IAEH,MAAM,SAAS,GAAG,MAAM,YAAY,CAAC,yBAAyB,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;IACjF,IAAI,SAAS,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACnC,MAAM,IAAI,KAAK,CAAC,gCAAgC,MAAM,EAAE,CAAC,CAAC;IAC5D,CAAC;IAED,IAAI,qBAAqB,GAAG,CAAC,EAAE,CAAC;QAC9B,OAAO,CAAC,GAAG,CAAC,kDAAkD,CAAC,CAAC;QAChE,MAAM,YAAY,CAAC,yBAAyB,CAAC;YAC3C,IAAI,EAAE,MAAM;YACZ,aAAa,EAAE,qBAAqB;SACrC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,cAAc,EAAE,aAAa,GAAG,UAAU,EAAE,aAAa,EAAE,MAAM,EAAE,CAAC;AAC/E,CAAC"}
@@ -0,0 +1,15 @@
1
+ export type NewCapacityCreditInfo = {
2
+ capacityTokenIdStr: string;
3
+ capacityTokenId: string;
4
+ requestsPerKilosecond: number;
5
+ daysUntilUTCMidnightExpiration: number;
6
+ mintedAtUtc: string;
7
+ expiresAt: string;
8
+ };
9
+ export declare function ensureWalletHasUnexpiredCapacityCredit({ privateKey, }: {
10
+ privateKey: `0x${string}`;
11
+ }): Promise<{
12
+ mintedNewCapacityCredit: boolean;
13
+ newCapacityCreditInfo?: NewCapacityCreditInfo;
14
+ }>;
15
+ //# sourceMappingURL=ensureWalletHasUnexpiredCapacityCredit.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureWalletHasUnexpiredCapacityCredit.d.ts","sourceRoot":"","sources":["../../../../../src/lib/setup/wallets/ensureWalletHasUnexpiredCapacityCredit.ts"],"names":[],"mappings":"AAQA,MAAM,MAAM,qBAAqB,GAAG;IAClC,kBAAkB,EAAE,MAAM,CAAC;IAC3B,eAAe,EAAE,MAAM,CAAC;IACxB,qBAAqB,EAAE,MAAM,CAAC;IAC9B,8BAA8B,EAAE,MAAM,CAAC;IACvC,WAAW,EAAE,MAAM,CAAC;IACpB,SAAS,EAAE,MAAM,CAAC;CACnB,CAAC;AAKF,wBAAsB,sCAAsC,CAAC,EAC3D,UAAU,GACX,EAAE;IACD,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;CAC3B,GAAG,OAAO,CAAC;IACV,uBAAuB,EAAE,OAAO,CAAC;IACjC,qBAAqB,CAAC,EAAE,qBAAqB,CAAC;CAC/C,CAAC,CAmFD"}
@@ -0,0 +1,63 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ensureWalletHasUnexpiredCapacityCredit = ensureWalletHasUnexpiredCapacityCredit;
4
+ const ethers_1 = require("ethers");
5
+ const contracts_sdk_1 = require("@lit-protocol/contracts-sdk");
6
+ const DATIL_NETWORK = 'datil';
7
+ const YELLOWSTONE_RPC_URL = 'https://yellowstone-rpc.litprotocol.com/';
8
+ async function ensureWalletHasUnexpiredCapacityCredit({ privateKey, }) {
9
+ // Create ethers provider and wallet for LitContracts SDK
10
+ const yellowstoneProvider = new ethers_1.providers.JsonRpcProvider(YELLOWSTONE_RPC_URL);
11
+ const ethersWallet = new ethers_1.Wallet(privateKey, yellowstoneProvider);
12
+ const litContractClient = new contracts_sdk_1.LitContracts({
13
+ debug: false,
14
+ network: DATIL_NETWORK,
15
+ signer: ethersWallet,
16
+ provider: yellowstoneProvider,
17
+ });
18
+ await litContractClient.connect();
19
+ const existingTokens = await litContractClient.rateLimitNftContractUtils.read.getTokensByOwnerAddress(ethersWallet.address);
20
+ if (existingTokens.length > 0 && existingTokens.some((token) => !token.isExpired)) {
21
+ return { mintedNewCapacityCredit: false };
22
+ }
23
+ const daysUntilUTCMidnightExpiration = 3;
24
+ const requestsPerKilosecond = 1000;
25
+ const now = new Date();
26
+ const expirationDate = new Date(Date.UTC(now.getUTCFullYear(), now.getUTCMonth(), now.getUTCDate() + daysUntilUTCMidnightExpiration, 0, 0, 0, 0));
27
+ const expiresAt = Math.floor(expirationDate.getTime() / 1000); // Convert to Unix timestamp
28
+ const mintCost = await litContractClient.rateLimitNftContract.read.calculateCost(requestsPerKilosecond, expiresAt);
29
+ const balance = await ethersWallet.provider.getBalance(ethersWallet.address);
30
+ // Convert both to bigint for comparison
31
+ const mintCostBigInt = BigInt(mintCost.toString());
32
+ const balanceBigInt = BigInt(balance.toString());
33
+ if (balanceBigInt < mintCostBigInt) {
34
+ throw new Error(`${ethersWallet.address} has insufficient balance to mint capacity credit: ${balance.toString()} < ${mintCost.toString()}. Please fund this wallet with Lit tokens at https://chronicle-yellowstone-faucet.getlit.dev/`);
35
+ }
36
+ const mintedCapacityCreditReponse = await litContractClient.mintCapacityCreditsNFT({
37
+ requestsPerKilosecond,
38
+ daysUntilUTCMidnightExpiration,
39
+ });
40
+ // Prune expired tokens if there are too many (performance optimization)
41
+ if (existingTokens.filter((token) => token.isExpired).length > 10) {
42
+ console.log('Pruning expired capacity credit tokens...');
43
+ try {
44
+ await litContractClient.rateLimitNftContractUtils.write.pruneExpired(ethersWallet.address);
45
+ console.log('Expired tokens pruned');
46
+ }
47
+ catch (error) {
48
+ console.log('⚠️ Failed to purge expired tokens:', error?.message || String(error));
49
+ }
50
+ }
51
+ return {
52
+ mintedNewCapacityCredit: true,
53
+ newCapacityCreditInfo: {
54
+ capacityTokenIdStr: mintedCapacityCreditReponse.capacityTokenIdStr,
55
+ capacityTokenId: mintedCapacityCreditReponse.capacityTokenId,
56
+ requestsPerKilosecond,
57
+ daysUntilUTCMidnightExpiration,
58
+ mintedAtUtc: new Date().toISOString(),
59
+ expiresAt: expirationDate.toISOString(),
60
+ },
61
+ };
62
+ }
63
+ //# sourceMappingURL=ensureWalletHasUnexpiredCapacityCredit.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ensureWalletHasUnexpiredCapacityCredit.js","sourceRoot":"","sources":["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