@aastar/sdk 0.16.6 → 0.16.11

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 (662) hide show
  1. package/.github/workflows/gas-analytics-daily.yml +52 -0
  2. package/CHANGELOG.md +43 -0
  3. package/README.md +39 -139
  4. package/backup/run_sdk_regression.sh +135 -0
  5. package/config.anvil.json +1 -1
  6. package/config.sepolia.json +19 -1
  7. package/docs/API_REFERENCE.md +9 -169
  8. package/docs/L4_Manual_Test_CheatSheet.md +22 -65
  9. package/docs/Reputation-to-Credit_Mapping_Whitepaper.md +242 -0
  10. package/docs/TESTER_GUIDE_GASLESS.md +23 -277
  11. package/docs/api/@aastar/account/README.md +15 -0
  12. package/docs/api/@aastar/account/classes/UserOpClient.md +87 -0
  13. package/docs/api/@aastar/account/functions/createEOAWalletClient.md +21 -0
  14. package/docs/api/@aastar/account/functions/getUserOpHash.md +23 -0
  15. package/docs/api/@aastar/account/functions/packUserOpLimits.md +19 -0
  16. package/docs/api/@aastar/account/functions/toSimpleSmartAccount.md +83 -0
  17. package/docs/api/@aastar/account/type-aliases/EOAWalletClient.md +37 -0
  18. package/docs/api/@aastar/account/type-aliases/SimpleSmartAccount.md +39 -0
  19. package/docs/api/@aastar/core/README.md +211 -0
  20. package/docs/api/@aastar/core/classes/BLSSigner.md +147 -0
  21. package/docs/api/@aastar/core/classes/BaseClient.md +9657 -0
  22. package/docs/api/@aastar/core/classes/ContractConfigManager.md +25 -0
  23. package/docs/api/@aastar/core/classes/RequirementChecker.md +1837 -0
  24. package/docs/api/@aastar/core/classes/SepoliaFaucetAPI.md +13661 -0
  25. package/docs/api/@aastar/core/classes/StateValidator.md +133 -0
  26. package/docs/api/@aastar/core/enumerations/EntryPointVersion.md +17 -0
  27. package/docs/api/@aastar/core/enumerations/NodeType.md +33 -0
  28. package/docs/api/@aastar/core/enumerations/RolePermissionLevel.md +43 -0
  29. package/docs/api/@aastar/core/functions/accountActions.md +2720 -0
  30. package/docs/api/@aastar/core/functions/accountFactoryActions.md +2720 -0
  31. package/docs/api/@aastar/core/functions/aggregatorActions.md +2720 -0
  32. package/docs/api/@aastar/core/functions/createAAStarPublicClient.md +3105 -0
  33. package/docs/api/@aastar/core/functions/dvtActions.md +2720 -0
  34. package/docs/api/@aastar/core/functions/entryPointActions.md +2724 -0
  35. package/docs/api/@aastar/core/functions/gTokenActions.md +2714 -0
  36. package/docs/api/@aastar/core/functions/gTokenExtendedActions.md +2720 -0
  37. package/docs/api/@aastar/core/functions/getAddressUrl.md +32 -0
  38. package/docs/api/@aastar/core/functions/getAllCommunityConfigs.md +9 -0
  39. package/docs/api/@aastar/core/functions/getAllV2Contracts.md +20 -0
  40. package/docs/api/@aastar/core/functions/getBlockExplorer.md +26 -0
  41. package/docs/api/@aastar/core/functions/getChainId.md +26 -0
  42. package/docs/api/@aastar/core/functions/getCommunities.md +76 -0
  43. package/docs/api/@aastar/core/functions/getCommunity.md +32 -0
  44. package/docs/api/@aastar/core/functions/getCommunityConfig.md +15 -0
  45. package/docs/api/@aastar/core/functions/getContract.md +37 -0
  46. package/docs/api/@aastar/core/functions/getContractNetworks.md +18 -0
  47. package/docs/api/@aastar/core/functions/getContracts.md +194 -0
  48. package/docs/api/@aastar/core/functions/getCoreContracts.md +71 -0
  49. package/docs/api/@aastar/core/functions/getDeploymentDate.md +32 -0
  50. package/docs/api/@aastar/core/functions/getEntryPoint.md +25 -0
  51. package/docs/api/@aastar/core/functions/getNetwork.md +26 -0
  52. package/docs/api/@aastar/core/functions/getPaymasterV4_1.md +25 -0
  53. package/docs/api/@aastar/core/functions/getRoleName.md +15 -0
  54. package/docs/api/@aastar/core/functions/getRpcUrl.md +25 -0
  55. package/docs/api/@aastar/core/functions/getSimpleAccountFactory.md +25 -0
  56. package/docs/api/@aastar/core/functions/getSuperPaymasterV2.md +25 -0
  57. package/docs/api/@aastar/core/functions/getTestAccounts.md +30 -0
  58. package/docs/api/@aastar/core/functions/getTestTokenContracts.md +38 -0
  59. package/docs/api/@aastar/core/functions/getTokenContracts.md +31 -0
  60. package/docs/api/@aastar/core/functions/getTxUrl.md +32 -0
  61. package/docs/api/@aastar/core/functions/getV2ContractByAddress.md +28 -0
  62. package/docs/api/@aastar/core/functions/getV2ContractByName.md +28 -0
  63. package/docs/api/@aastar/core/functions/getV2ContractsByDate.md +26 -0
  64. package/docs/api/@aastar/core/functions/isContractNetworkSupported.md +27 -0
  65. package/docs/api/@aastar/core/functions/isRegisteredCommunity.md +15 -0
  66. package/docs/api/@aastar/core/functions/isV2Contract.md +27 -0
  67. package/docs/api/@aastar/core/functions/paymasterActions.md +2720 -0
  68. package/docs/api/@aastar/core/functions/paymasterFactoryActions.md +2720 -0
  69. package/docs/api/@aastar/core/functions/registryActions.md +2720 -0
  70. package/docs/api/@aastar/core/functions/reputationActions.md +2720 -0
  71. package/docs/api/@aastar/core/functions/sbtActions.md +2720 -0
  72. package/docs/api/@aastar/core/functions/stakingActions.md +2720 -0
  73. package/docs/api/@aastar/core/functions/superPaymasterActions.md +2720 -0
  74. package/docs/api/@aastar/core/functions/tokenActions.md +2714 -0
  75. package/docs/api/@aastar/core/functions/xPNTsFactoryActions.md +2720 -0
  76. package/docs/api/@aastar/core/interfaces/AccountBalance.md +41 -0
  77. package/docs/api/@aastar/core/interfaces/BalanceValidationParams.md +51 -0
  78. package/docs/api/@aastar/core/interfaces/ClientConfig.md +4841 -0
  79. package/docs/api/@aastar/core/interfaces/CommunityConfig.md +81 -0
  80. package/docs/api/@aastar/core/interfaces/ContractVersion.md +63 -0
  81. package/docs/api/@aastar/core/interfaces/DeploymentValidationParams.md +39 -0
  82. package/docs/api/@aastar/core/interfaces/RoleConfig.md +83 -0
  83. package/docs/api/@aastar/core/interfaces/RoleRequirement.md +43 -0
  84. package/docs/api/@aastar/core/interfaces/RoleValidationParams.md +55 -0
  85. package/docs/api/@aastar/core/interfaces/SuperPaymasterConfig.md +57 -0
  86. package/docs/api/@aastar/core/interfaces/TokenBalanceValidationParams.md +63 -0
  87. package/docs/api/@aastar/core/interfaces/TransactionOptions.md +24 -0
  88. package/docs/api/@aastar/core/interfaces/ValidationParams.md +25 -0
  89. package/docs/api/@aastar/core/interfaces/ValidationResult.md +25 -0
  90. package/docs/api/@aastar/core/type-aliases/AccountActions.md +151 -0
  91. package/docs/api/@aastar/core/type-aliases/AccountFactoryActions.md +55 -0
  92. package/docs/api/@aastar/core/type-aliases/AggregatorActions.md +471 -0
  93. package/docs/api/@aastar/core/type-aliases/BusinessResult.md +12 -0
  94. package/docs/api/@aastar/core/type-aliases/ContractCategory.md +5 -0
  95. package/docs/api/@aastar/core/type-aliases/ContractNetwork.md +5 -0
  96. package/docs/api/@aastar/core/type-aliases/DVTActions.md +319 -0
  97. package/docs/api/@aastar/core/type-aliases/EntryPointActions.md +103 -0
  98. package/docs/api/@aastar/core/type-aliases/GTokenExtendedActions.md +239 -0
  99. package/docs/api/@aastar/core/type-aliases/NetworkContracts.md +5 -0
  100. package/docs/api/@aastar/core/type-aliases/PaymasterActions.md +1087 -0
  101. package/docs/api/@aastar/core/type-aliases/PaymasterFactoryActions.md +263 -0
  102. package/docs/api/@aastar/core/type-aliases/RegistryActions.md +1543 -0
  103. package/docs/api/@aastar/core/type-aliases/ReputationActions.md +811 -0
  104. package/docs/api/@aastar/core/type-aliases/SBTActions.md +1199 -0
  105. package/docs/api/@aastar/core/type-aliases/StakingActions.md +703 -0
  106. package/docs/api/@aastar/core/type-aliases/SuperPaymasterActions.md +1311 -0
  107. package/docs/api/@aastar/core/type-aliases/SupportedNetwork.md +3 -0
  108. package/docs/api/@aastar/core/type-aliases/TokenActions.md +1227 -0
  109. package/docs/api/@aastar/core/type-aliases/XPNTsFactoryActions.md +395 -0
  110. package/docs/api/@aastar/core/variables/AASTAR_COMMUNITY.md +8 -0
  111. package/docs/api/@aastar/core/variables/ALL_ADDRESSES.md +75 -0
  112. package/docs/api/@aastar/core/variables/ALL_ROLES.md +5 -0
  113. package/docs/api/@aastar/core/variables/APNTS_ADDRESS.md +3 -0
  114. package/docs/api/@aastar/core/variables/BLSAggregatorABI.md +3 -0
  115. package/docs/api/@aastar/core/variables/BLSAggregatorArtifact.md +13 -0
  116. package/docs/api/@aastar/core/variables/BLSHelpers.md +101 -0
  117. package/docs/api/@aastar/core/variables/BLSValidatorABI.md +3 -0
  118. package/docs/api/@aastar/core/variables/BLSValidatorArtifact.md +13 -0
  119. package/docs/api/@aastar/core/variables/BLS_AGGREGATOR_ADDRESS.md +3 -0
  120. package/docs/api/@aastar/core/variables/BLS_VALIDATOR_ADDRESS.md +3 -0
  121. package/docs/api/@aastar/core/variables/BPS_DENOMINATOR.md +5 -0
  122. package/docs/api/@aastar/core/variables/BRANDING.md +67 -0
  123. package/docs/api/@aastar/core/variables/BREAD_COMMUNITY.md +8 -0
  124. package/docs/api/@aastar/core/variables/CHAIN_MAINNET.md +3 -0
  125. package/docs/api/@aastar/core/variables/CHAIN_SEPOLIA.md +5 -0
  126. package/docs/api/@aastar/core/variables/COMMUNITIES.md +5 -0
  127. package/docs/api/@aastar/core/variables/COMMUNITY_OWNERS.md +15 -0
  128. package/docs/api/@aastar/core/variables/CONTRACTS.md +179 -0
  129. package/docs/api/@aastar/core/variables/CONTRACT_METADATA.md +67 -0
  130. package/docs/api/@aastar/core/variables/CONTRACT_SRC_HASH.md +5 -0
  131. package/docs/api/@aastar/core/variables/CORE_ADDRESSES.md +51 -0
  132. package/docs/api/@aastar/core/variables/DEFAULT_ADMIN_ROLE.md +17 -0
  133. package/docs/api/@aastar/core/variables/DEFAULT_APNTS_PRICE_USD.md +5 -0
  134. package/docs/api/@aastar/core/variables/DEFAULT_CALL_GAS_LIMIT.md +3 -0
  135. package/docs/api/@aastar/core/variables/DEFAULT_GAS_TOKEN_MINT_AMOUNT.md +5 -0
  136. package/docs/api/@aastar/core/variables/DEFAULT_PRE_VERIFICATION_GAS.md +3 -0
  137. package/docs/api/@aastar/core/variables/DEFAULT_TIMEOUT_MS.md +5 -0
  138. package/docs/api/@aastar/core/variables/DEFAULT_TOKEN_NAME.md +3 -0
  139. package/docs/api/@aastar/core/variables/DEFAULT_TOKEN_SYMBOL.md +5 -0
  140. package/docs/api/@aastar/core/variables/DEFAULT_USDT_MINT_AMOUNT.md +5 -0
  141. package/docs/api/@aastar/core/variables/DEFAULT_VERIFICATION_GAS_LIMIT.md +5 -0
  142. package/docs/api/@aastar/core/variables/DVTValidatorABI.md +3 -0
  143. package/docs/api/@aastar/core/variables/DVTValidatorArtifact.md +13 -0
  144. package/docs/api/@aastar/core/variables/DVT_VALIDATOR_ADDRESS.md +3 -0
  145. package/docs/api/@aastar/core/variables/ENTRY_POINT_0_8_ADDRESS.md +3 -0
  146. package/docs/api/@aastar/core/variables/ENTRY_POINT_0_9_ADDRESS.md +3 -0
  147. package/docs/api/@aastar/core/variables/ENTRY_POINT_ADDRESS.md +3 -0
  148. package/docs/api/@aastar/core/variables/EntryPointABI.md +3 -0
  149. package/docs/api/@aastar/core/variables/EntryPointArtifact.md +13 -0
  150. package/docs/api/@aastar/core/variables/FAUCET_API_URL.md +5 -0
  151. package/docs/api/@aastar/core/variables/GTOKEN_ADDRESS.md +3 -0
  152. package/docs/api/@aastar/core/variables/GTOKEN_STAKING_ADDRESS.md +3 -0
  153. package/docs/api/@aastar/core/variables/GTokenABI.md +3 -0
  154. package/docs/api/@aastar/core/variables/GTokenArtifact.md +13 -0
  155. package/docs/api/@aastar/core/variables/GTokenStakingABI.md +3 -0
  156. package/docs/api/@aastar/core/variables/GTokenStakingArtifact.md +13 -0
  157. package/docs/api/@aastar/core/variables/INITIAL_ROLE_STAKES.md +13 -0
  158. package/docs/api/@aastar/core/variables/LINKS.md +33 -0
  159. package/docs/api/@aastar/core/variables/MAX_SERVICE_FEE.md +5 -0
  160. package/docs/api/@aastar/core/variables/MONITORING_ADDRESSES.md +15 -0
  161. package/docs/api/@aastar/core/variables/MySBTABI.md +3 -0
  162. package/docs/api/@aastar/core/variables/MySBTArtifact.md +13 -0
  163. package/docs/api/@aastar/core/variables/NETWORKS.md +79 -0
  164. package/docs/api/@aastar/core/variables/NODE_STAKE_AMOUNTS.md +31 -0
  165. package/docs/api/@aastar/core/variables/OFFICIAL_ADDRESSES.md +11 -0
  166. package/docs/api/@aastar/core/variables/PAYMASTER_ADDRESSES.md +15 -0
  167. package/docs/api/@aastar/core/variables/PAYMASTER_FACTORY_ADDRESS.md +3 -0
  168. package/docs/api/@aastar/core/variables/PAYMASTER_V4_IMPL_ADDRESS.md +3 -0
  169. package/docs/api/@aastar/core/variables/PaymasterABI.md +3 -0
  170. package/docs/api/@aastar/core/variables/PaymasterArtifact.md +13 -0
  171. package/docs/api/@aastar/core/variables/PaymasterFactoryABI.md +3 -0
  172. package/docs/api/@aastar/core/variables/PaymasterFactoryArtifact.md +13 -0
  173. package/docs/api/@aastar/core/variables/PaymasterV4ABI.md +3 -0
  174. package/docs/api/@aastar/core/variables/PaymasterV4Artifact.md +13 -0
  175. package/docs/api/@aastar/core/variables/REGISTRY_ADDRESS.md +3 -0
  176. package/docs/api/@aastar/core/variables/REPUTATION_SYSTEM_ADDRESS.md +3 -0
  177. package/docs/api/@aastar/core/variables/ROLE_ANODE.md +29 -0
  178. package/docs/api/@aastar/core/variables/ROLE_COMMUNITY.md +29 -0
  179. package/docs/api/@aastar/core/variables/ROLE_DVT.md +29 -0
  180. package/docs/api/@aastar/core/variables/ROLE_ENDUSER.md +33 -0
  181. package/docs/api/@aastar/core/variables/ROLE_KMS.md +29 -0
  182. package/docs/api/@aastar/core/variables/ROLE_NAMES.md +3 -0
  183. package/docs/api/@aastar/core/variables/ROLE_PAYMASTER_AOA.md +29 -0
  184. package/docs/api/@aastar/core/variables/ROLE_PAYMASTER_SUPER.md +33 -0
  185. package/docs/api/@aastar/core/variables/ROLE_PERMISSION_LEVELS.md +3 -0
  186. package/docs/api/@aastar/core/variables/RegistryABI.md +3 -0
  187. package/docs/api/@aastar/core/variables/RegistryArtifact.md +13 -0
  188. package/docs/api/@aastar/core/variables/ReputationSystemABI.md +3 -0
  189. package/docs/api/@aastar/core/variables/ReputationSystemArtifact.md +13 -0
  190. package/docs/api/@aastar/core/variables/SBT_ADDRESS.md +3 -0
  191. package/docs/api/@aastar/core/variables/SEPOLIA_CONTRACTS.md +175 -0
  192. package/docs/api/@aastar/core/variables/SEPOLIA_V2_VERSIONS.md +67 -0
  193. package/docs/api/@aastar/core/variables/SERVICE_FEE_RATE.md +5 -0
  194. package/docs/api/@aastar/core/variables/SUPER_PAYMASTER_ADDRESS.md +3 -0
  195. package/docs/api/@aastar/core/variables/SimpleAccountABI.md +3 -0
  196. package/docs/api/@aastar/core/variables/SimpleAccountArtifact.md +13 -0
  197. package/docs/api/@aastar/core/variables/SimpleAccountFactoryABI.md +3 -0
  198. package/docs/api/@aastar/core/variables/SimpleAccountFactoryArtifact.md +13 -0
  199. package/docs/api/@aastar/core/variables/SuperPaymasterABI.md +3 -0
  200. package/docs/api/@aastar/core/variables/SuperPaymasterArtifact.md +13 -0
  201. package/docs/api/@aastar/core/variables/TEST_ACCOUNT_ADDRESSES.md +11 -0
  202. package/docs/api/@aastar/core/variables/TEST_ACCOUNT_POOL_SIZE.md +5 -0
  203. package/docs/api/@aastar/core/variables/TEST_COMMUNITIES.md +19 -0
  204. package/docs/api/@aastar/core/variables/TEST_TOKEN_ADDRESSES.md +19 -0
  205. package/docs/api/@aastar/core/variables/TOKEN_ADDRESSES.md +11 -0
  206. package/docs/api/@aastar/core/variables/V2_SUMMARY.md +39 -0
  207. package/docs/api/@aastar/core/variables/XPNTS_FACTORY_ADDRESS.md +3 -0
  208. package/docs/api/@aastar/core/variables/xPNTsFactoryABI.md +3 -0
  209. package/docs/api/@aastar/core/variables/xPNTsFactoryArtifact.md +13 -0
  210. package/docs/api/@aastar/core/variables/xPNTsTokenABI.md +3 -0
  211. package/docs/api/@aastar/core/variables/xPNTsTokenArtifact.md +13 -0
  212. package/docs/api/@aastar/paymaster/README.md +23 -0
  213. package/docs/api/@aastar/paymaster/classes/PaymasterClient.md +388 -0
  214. package/docs/api/@aastar/paymaster/classes/PaymasterOperator.md +451 -0
  215. package/docs/api/@aastar/paymaster/classes/SuperPaymasterAdminClient.md +189 -0
  216. package/docs/api/@aastar/paymaster/classes/SuperPaymasterClient.md +55 -0
  217. package/docs/api/@aastar/paymaster/functions/buildPaymasterData.md +34 -0
  218. package/docs/api/@aastar/paymaster/functions/buildSuperPaymasterData.md +30 -0
  219. package/docs/api/@aastar/paymaster/functions/checkEligibility.md +28 -0
  220. package/docs/api/@aastar/paymaster/functions/formatUserOpV07.md +15 -0
  221. package/docs/api/@aastar/paymaster/functions/getPaymasterV4Middleware.md +32 -0
  222. package/docs/api/@aastar/paymaster/functions/getSuperPaymasterMiddleware.md +32 -0
  223. package/docs/api/@aastar/paymaster/functions/getUserOpHashV07.md +21 -0
  224. package/docs/api/@aastar/paymaster/type-aliases/GaslessReadinessReport.md +55 -0
  225. package/docs/api/@aastar/paymaster/type-aliases/GaslessTransactionConfig.md +59 -0
  226. package/docs/api/@aastar/paymaster/type-aliases/PaymasterConfig.md +43 -0
  227. package/docs/api/@aastar/paymaster/type-aliases/PaymasterV4MiddlewareConfig.md +35 -0
  228. package/docs/api/@aastar/tokens/README.md +3 -0
  229. package/docs/api/@aastar/tokens/classes/FinanceClient.md +10385 -0
  230. package/docs/api/README.md +4 -8
  231. package/env.template +3 -5
  232. package/examples/l1-api-demo.ts +196 -107
  233. package/examples/l2-clients-demo.ts +70 -73
  234. package/examples/l3-community-launch.ts +49 -0
  235. package/examples/l3-user-onboarding.ts +36 -54
  236. package/examples/prepare-gasless.ts +1 -1
  237. package/examples/simple-gasless-demo.ts +55 -26
  238. package/examples/simple-superpaymaster-demo.ts +2 -2
  239. package/ext/aastar-shared-config/generate-comparison-table.sh +0 -0
  240. package/ext/aastar-shared-config/sync-abis.sh +0 -0
  241. package/ext/aastar-shared-config/sync-versions.mjs +0 -0
  242. package/ext/aastar-shared-config/verify-all.sh +0 -0
  243. package/ext/aastar-shared-config/verify-contracts.sh +0 -0
  244. package/l4-setup.sh +1 -11
  245. package/lib/shared-config/generate-comparison-table.sh +0 -0
  246. package/lib/shared-config/sync-abis.sh +0 -0
  247. package/lib/shared-config/sync-versions.mjs +0 -0
  248. package/lib/shared-config/verify-all.sh +0 -0
  249. package/lib/shared-config/verify-contracts.sh +0 -0
  250. package/package.json +36 -32
  251. package/packages/account/__tests__/index.test.ts +9 -0
  252. package/packages/account/node_modules/.bin/tsc +21 -0
  253. package/packages/account/node_modules/.bin/tsserver +21 -0
  254. package/packages/account/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  255. package/packages/account/package.json +3 -5
  256. package/packages/account/src/eoa.ts +2 -4
  257. package/packages/account/tsconfig.json +2 -1
  258. package/packages/analytics/README.md +68 -0
  259. package/packages/analytics/__tests__/index.test.ts +25 -0
  260. package/packages/analytics/data/attribution_dataset.csv +29 -0
  261. package/packages/analytics/data/complete_dataset.csv +29 -0
  262. package/packages/analytics/data/eth_price_cache.json +4 -0
  263. package/packages/analytics/data/full_dataset.csv +11 -0
  264. package/packages/analytics/data/full_dataset.json +134 -0
  265. package/packages/analytics/data/parsed_transactions.csv +29 -0
  266. package/packages/analytics/node_modules/.bin/tsc +21 -0
  267. package/packages/analytics/node_modules/.bin/tsserver +21 -0
  268. package/packages/analytics/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  269. package/packages/analytics/package.json +2 -5
  270. package/packages/analytics/reports/full/attribution_analysis_20260119.md +42 -0
  271. package/packages/analytics/reports/full/attribution_analysis_fresh_20260119.md +67 -0
  272. package/packages/analytics/reports/full/competitive_analysis_20260119.md +103 -0
  273. package/packages/analytics/reports/full/comprehensive_analysis_20260119.md +107 -0
  274. package/packages/analytics/reports/full/comprehensive_analysis_v4_1_20260119.md +74 -0
  275. package/packages/analytics/reports/full/economic_audit_v4_2_20260119.md +74 -0
  276. package/packages/analytics/reports/full/profit_audit_v4_3_20260119.md +74 -0
  277. package/packages/analytics/reports/full/profit_audit_v4_4_20260119.md +74 -0
  278. package/packages/analytics/reports/full/profit_audit_v4_5_20260119.md +74 -0
  279. package/packages/analytics/reports/full/profit_audit_v4_6_20260119.md +74 -0
  280. package/packages/analytics/reports/full/profit_audit_v4_final_20260119.md +74 -0
  281. package/packages/analytics/reports/full/profit_audit_v4_final_v2_20260119.md +74 -0
  282. package/packages/analytics/reports/full/profit_audit_v4_final_v3_20260119.md +74 -0
  283. package/packages/analytics/reports/full/profit_audit_v4_final_v4_20260119.md +75 -0
  284. package/packages/analytics/reports/full/profit_audit_v4_final_v5_20260119.md +76 -0
  285. package/packages/analytics/reports/full/two_layer_analysis_20260119.md +81 -0
  286. package/packages/analytics/reports/full/two_layer_analysis_academic_20260119.md +81 -0
  287. package/packages/analytics/reports/full/two_layer_analysis_dynamic_20260119.md +81 -0
  288. package/packages/analytics/reports/full/two_layer_analysis_final_20260119.md +81 -0
  289. package/packages/analytics/reports/full/two_layer_analysis_final_fixed_20260119.md +81 -0
  290. package/packages/analytics/reports/full/two_layer_analysis_fixed_20260119.md +52 -0
  291. package/packages/analytics/reports/full/two_layer_analysis_normalized_20260119.md +81 -0
  292. package/packages/analytics/reports/full/tx_0xc30cfcbb.md +39 -0
  293. package/packages/analytics/src/analyzers/AttributionAnalyzer.ts +124 -0
  294. package/packages/analytics/src/analyzers/ComparisonAnalyzer.ts +89 -0
  295. package/packages/analytics/src/analyzers/TransactionAnalyzer.ts +111 -0
  296. package/packages/analytics/src/analyzers/TrendAnalyzer.ts +107 -0
  297. package/packages/analytics/src/cli-analyze-tx.ts +45 -0
  298. package/packages/analytics/src/cli.ts +39 -0
  299. package/packages/analytics/src/core/BenchmarkLoader.ts +163 -0
  300. package/packages/analytics/src/core/CostCalculator.ts +202 -0
  301. package/packages/analytics/src/core/DataCollector.ts +245 -0
  302. package/packages/analytics/src/gas-analyzer-v4.ts +118 -0
  303. package/packages/analytics/src/gas-analyzer.ts +184 -0
  304. package/packages/analytics/src/test-logparser.ts +63 -0
  305. package/packages/analytics/src/utils/EventDecoder.ts +152 -0
  306. package/packages/analytics/src/utils/LogParser.ts +220 -0
  307. package/packages/analytics/src/utils/PriceOracle.ts +117 -0
  308. package/packages/analytics/test/AttributionAnalyzer.test.ts +42 -0
  309. package/packages/analytics/test/CostCalculator.test.ts +75 -0
  310. package/packages/analytics/tsconfig.json +2 -1
  311. package/packages/community/__tests__/index.test.ts +9 -0
  312. package/packages/community/node_modules/.bin/tsc +21 -0
  313. package/packages/community/node_modules/.bin/tsserver +21 -0
  314. package/packages/community/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  315. package/packages/community/package.json +27 -0
  316. package/packages/community/src/index.ts +326 -0
  317. package/packages/community/tsconfig.json +8 -0
  318. package/packages/core/__tests__/actions/account-comprehensive.test.ts +92 -0
  319. package/packages/core/__tests__/actions/aggregator.test.ts +62 -0
  320. package/packages/core/__tests__/actions/comprehensive-batch1.test.ts +86 -0
  321. package/packages/core/__tests__/actions/comprehensive-batch2.test.ts +39 -0
  322. package/packages/core/__tests__/actions/comprehensive-batch3.test.ts +35 -0
  323. package/packages/core/__tests__/actions/comprehensive-error.test.ts +115 -0
  324. package/packages/core/__tests__/actions/dvt.test.ts +39 -0
  325. package/packages/core/__tests__/actions/edge-cases.test.ts +39 -0
  326. package/packages/core/__tests__/actions/error-paths.test.ts +82 -0
  327. package/packages/core/__tests__/actions/factory.test.ts +81 -0
  328. package/packages/core/__tests__/actions/faucet.test.ts +131 -0
  329. package/packages/core/__tests__/actions/paymaster.test.ts +116 -0
  330. package/packages/core/__tests__/actions/registry.test.ts +81 -0
  331. package/packages/core/__tests__/actions/reputation.test.ts +43 -0
  332. package/packages/core/__tests__/actions/sbt.test.ts +145 -0
  333. package/packages/core/__tests__/actions/staking.test.ts +30 -0
  334. package/packages/core/__tests__/actions/superPaymaster.test.ts +158 -0
  335. package/packages/core/__tests__/actions/tokens-extended.test.ts +18 -0
  336. package/packages/core/__tests__/actions/tokens.test.ts +122 -0
  337. package/packages/core/__tests__/clients.test.ts +77 -0
  338. package/packages/core/__tests__/contracts-config.test.ts +69 -0
  339. package/packages/core/__tests__/index.test.ts +9 -0
  340. package/packages/core/__tests__/mocks/client.ts +40 -0
  341. package/packages/core/node_modules/.bin/tsc +21 -0
  342. package/packages/core/node_modules/.bin/tsserver +21 -0
  343. package/packages/core/node_modules/.bin/tsx +21 -0
  344. package/packages/core/node_modules/.bin/vite +21 -0
  345. package/packages/core/node_modules/.bin/vitest +21 -0
  346. package/packages/core/node_modules/.bin/yaml +21 -0
  347. package/packages/core/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  348. package/packages/core/package.json +5 -12
  349. package/packages/core/src/abis/SuperPaymaster.json +1 -1
  350. package/packages/core/src/abis/aPNTs.json +1160 -0
  351. package/packages/core/src/abis/abi.config.json +3 -3
  352. package/packages/core/src/abis/index.ts +37 -50
  353. package/packages/core/src/actions/account.ts +137 -126
  354. package/packages/core/src/actions/aggregator.ts +363 -33
  355. package/packages/core/src/actions/dvt.ts +261 -45
  356. package/packages/core/src/actions/entryPoint.ts +56 -233
  357. package/packages/core/src/actions/factory.ts +671 -552
  358. package/packages/core/src/actions/faucet.ts +181 -322
  359. package/packages/core/src/actions/index.ts +2 -5
  360. package/packages/core/src/actions/paymaster.ts +780 -0
  361. package/packages/core/src/actions/registry.ts +926 -825
  362. package/packages/core/src/actions/reputation.ts +568 -278
  363. package/packages/core/src/actions/sbt.ts +867 -632
  364. package/packages/core/src/actions/staking.ts +440 -285
  365. package/packages/core/src/actions/superPaymaster.ts +1058 -793
  366. package/packages/core/src/actions/tokens.ts +468 -514
  367. package/packages/core/src/clients/BaseClient.ts +3 -3
  368. package/packages/core/src/clients/BundlerClient.ts +132 -0
  369. package/packages/core/src/communities.ts +2 -2
  370. package/packages/core/src/constants.ts +1 -32
  371. package/packages/core/src/contract-addresses.ts +3 -10
  372. package/packages/core/src/contract-versions.ts +374 -0
  373. package/packages/core/src/contracts.ts +2 -2
  374. package/packages/core/src/errors/index.ts +173 -0
  375. package/packages/core/src/index.ts +2 -1
  376. package/packages/core/src/requirementChecker.ts +39 -1
  377. package/packages/core/src/roles.ts +50 -61
  378. package/packages/core/src/validators/index.ts +88 -0
  379. package/packages/core/tsconfig.json +2 -1
  380. package/packages/dapp/__tests__/index.test.ts +9 -0
  381. package/packages/dapp/node_modules/.bin/tsc +21 -0
  382. package/packages/dapp/node_modules/.bin/tsserver +21 -0
  383. package/packages/dapp/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  384. package/packages/dapp/package.json +3 -5
  385. package/packages/dapp/tsconfig.json +2 -1
  386. package/packages/enduser/__tests__/CommunityClient.test.ts +205 -0
  387. package/packages/enduser/__tests__/UserClient.test.ts +294 -0
  388. package/packages/enduser/__tests__/index.test.ts +16 -0
  389. package/packages/enduser/__tests__/mocks/client.ts +22 -0
  390. package/packages/enduser/node_modules/.bin/tsc +21 -0
  391. package/packages/enduser/node_modules/.bin/tsserver +21 -0
  392. package/packages/enduser/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  393. package/packages/enduser/package.json +26 -0
  394. package/packages/enduser/src/CommunityClient.ts +235 -0
  395. package/packages/enduser/src/UserClient.ts +447 -0
  396. package/packages/enduser/src/index.ts +2 -0
  397. package/packages/enduser/src/testAccountManager.ts +374 -0
  398. package/packages/enduser/tsconfig.json +10 -0
  399. package/packages/identity/__tests__/index.test.ts +9 -0
  400. package/packages/identity/node_modules/.bin/tsc +21 -0
  401. package/packages/identity/node_modules/.bin/tsserver +21 -0
  402. package/packages/identity/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  403. package/packages/identity/package.json +3 -5
  404. package/packages/identity/tsconfig.json +2 -1
  405. package/packages/operator/__tests__/PaymasterOperatorClient.test.ts +258 -0
  406. package/packages/operator/__tests__/ProtocolClient.test.ts +135 -0
  407. package/packages/operator/__tests__/index.test.ts +16 -0
  408. package/packages/operator/__tests__/mocks/client.ts +22 -0
  409. package/packages/operator/node_modules/.bin/tsc +21 -0
  410. package/packages/operator/node_modules/.bin/tsserver +21 -0
  411. package/packages/operator/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  412. package/packages/operator/package.json +26 -0
  413. package/packages/operator/src/PaymasterOperatorClient.ts +454 -0
  414. package/packages/operator/src/ProtocolClient.ts +154 -0
  415. package/packages/operator/src/index.ts +2 -0
  416. package/packages/operator/tsconfig.json +10 -0
  417. package/packages/patterns/node_modules/.bin/tsc +21 -0
  418. package/packages/patterns/node_modules/.bin/tsserver +21 -0
  419. package/packages/paymaster/__tests__/PaymasterOperator.test.ts +123 -0
  420. package/packages/paymaster/__tests__/index.test.ts +9 -0
  421. package/packages/paymaster/node_modules/.bin/tsc +21 -0
  422. package/packages/paymaster/node_modules/.bin/tsserver +21 -0
  423. package/packages/paymaster/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  424. package/packages/paymaster/package.json +4 -6
  425. package/packages/paymaster/src/V4/BundlerCompat.ts +47 -0
  426. package/packages/paymaster/src/V4/PaymasterClient.ts +122 -17
  427. package/packages/paymaster/src/V4/PaymasterUtils.ts +37 -23
  428. package/packages/paymaster/src/V4/SuperPaymasterClient.ts +17 -11
  429. package/packages/paymaster/tsconfig.json +8 -3
  430. package/packages/sdk/README.md +21 -0
  431. package/packages/sdk/__tests__/index.test.ts +9 -0
  432. package/packages/sdk/aastar/package.json +1 -1
  433. package/packages/sdk/aastar/tsconfig.json +2 -1
  434. package/packages/sdk/node_modules/.bin/tsc +21 -0
  435. package/packages/sdk/node_modules/.bin/tsserver +21 -0
  436. package/packages/sdk/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  437. package/packages/sdk/package.json +4 -14
  438. package/packages/sdk/src/clients/admin.ts +10 -108
  439. package/packages/sdk/src/clients/community.ts +242 -176
  440. package/packages/sdk/src/clients/endUser.ts +168 -291
  441. package/packages/sdk/src/clients/operator.ts +87 -162
  442. package/packages/sdk/src/errors/decoder.ts +41 -84
  443. package/packages/sdk/src/index.ts +10 -9
  444. package/packages/sdk/src/utils/keys.ts +0 -15
  445. package/packages/sdk/src/utils/roleData.ts +26 -15
  446. package/packages/sdk/src/utils/testScenarios.ts +2 -2
  447. package/packages/sdk/src/utils/userOp.ts +3 -11
  448. package/packages/sdk/tsconfig.json +2 -1
  449. package/packages/tokens/__tests__/index.test.ts +9 -0
  450. package/packages/tokens/node_modules/.bin/tsc +21 -0
  451. package/packages/tokens/node_modules/.bin/tsserver +21 -0
  452. package/packages/tokens/node_modules/.vite/vitest/da39a3ee5e6b4b0d3255bfef95601890afd80709/results.json +1 -0
  453. package/packages/tokens/package.json +3 -5
  454. package/packages/tokens/src/index.ts +0 -15
  455. package/packages/tokens/tsconfig.json +2 -1
  456. package/publish.sh +30 -0
  457. package/run_l4_gasless_regression.sh +35 -5
  458. package/run_sdk_regression.sh +3 -9
  459. package/scripts/01_prepare_all.ts +198 -149
  460. package/scripts/02_test_eoa.ts +24 -27
  461. package/scripts/03_test_standard_aa.ts +153 -48
  462. package/scripts/04_test_paymaster_v4.ts +198 -41
  463. package/scripts/05_test_superpaymaster.ts +362 -40
  464. package/scripts/11_test_core_flows_full.ts +197 -75
  465. package/scripts/18_test_dvt_sdk_flow.ts +1 -1
  466. package/scripts/19_sdk_experiment_runner.ts +135 -42
  467. package/scripts/20_sdk_full_capability.ts +77 -75
  468. package/scripts/analyze_abi_coverage.ts +4 -4
  469. package/scripts/analyze_missing_functions.ts +136 -0
  470. package/scripts/canary-bundler.ts +47 -0
  471. package/scripts/check-chainlink.ts +28 -0
  472. package/scripts/check-jason-status.ts +61 -160
  473. package/scripts/check-roles.ts +1 -1
  474. package/scripts/complete-jack-superpaymaster.ts +1 -1
  475. package/scripts/deploy_and_init_v3.sh +0 -0
  476. package/scripts/deploy_jason_pm.ts +114 -0
  477. package/scripts/dev_tools/extract_abis.sh +0 -0
  478. package/scripts/dev_tools/extract_addresses_to_env.sh +0 -0
  479. package/scripts/extract-docs.sh +9 -78
  480. package/scripts/l4-debug-bob.ts +62 -0
  481. package/scripts/l4-paymasterv4-transfer-test.ts +12 -20
  482. package/scripts/l4-setup.ts +1235 -341
  483. package/scripts/l4-state.json +16 -14
  484. package/scripts/manual-update-price.ts +39 -0
  485. package/scripts/phase1_verify_contracts.ts +1 -1
  486. package/scripts/publish_all.sh +0 -0
  487. package/scripts/query-jack-token.ts +1 -1
  488. package/scripts/run_automated_experiment.sh +0 -0
  489. package/scripts/run_full_regression.sh +38 -0
  490. package/scripts/run_l4_gasless_regression.sh +0 -0
  491. package/scripts/run_sdk_experiment.sh +0 -0
  492. package/scripts/run_sdk_regression-v2.sh +0 -0
  493. package/scripts/sdk_regression_v2.ts +20 -34
  494. package/scripts/security_audit.sh +0 -0
  495. package/scripts/setup-bbq-community.ts +2 -2
  496. package/scripts/setup-dancing-community.ts +3 -3
  497. package/scripts/test-brown-v4-deploy.ts +2 -2
  498. package/scripts/test-faucet-and-gasless.ts +119 -139
  499. package/scripts/test-jack-gasless.ts +1 -1
  500. package/scripts/test-jack-registration.ts +2 -2
  501. package/scripts/test-jack-superpaymaster-api.ts +2 -2
  502. package/scripts/test-kms-gasless.ts +307 -93
  503. package/scripts/update-price-dvt.ts +53 -0
  504. package/scripts/v2_regression/01_setup_and_fund.ts +1 -1
  505. package/scripts/v2_regression/02_operator_onboarding.ts +140 -14
  506. package/scripts/v2_regression/03_community_registry.ts +58 -24
  507. package/scripts/v2_regression/04_enduser_flow.ts +49 -16
  508. package/scripts/v2_regression/05_admin_audit.ts +1 -1
  509. package/scripts/verify-bob-token.ts +41 -0
  510. package/sdk-abi-coverage.sh +1 -0
  511. package/sdk-build-and-test.sh +1 -0
  512. package/sdk-test-coverage.sh +1 -0
  513. package/simple-test-paymaster.sh +1 -1
  514. package/simple-test-superpaymaster.sh +3 -1
  515. package/tests/check-aa-balance.ts +31 -0
  516. package/tests/l1-regression.test.ts +13 -34
  517. package/tests/l4-test-anni-gasless.ts +497 -85
  518. package/tests/l4-test-jason1-gasless.ts +29 -21
  519. package/tests/l4-test-jason2-gasless.ts +21 -15
  520. package/tests/l4-test-pmv4-deposit.ts +2 -2
  521. package/tests/l4-test-pmv4-gasless.ts +2 -2
  522. package/tests/l4-test-pmv4-submit.ts +2 -2
  523. package/tests/regression/config.ts +4 -2
  524. package/tests/regression/index.ts +0 -0
  525. package/tests/regression/l1-tests.ts +16 -35
  526. package/tests/regression/l2-tests.ts +149 -93
  527. package/tests/regression/l3-tests.ts +16 -113
  528. package/tests/regression/l4-comprehensive-gasless.ts +478 -0
  529. package/tests/regression/l4-gasless.ts +115 -13
  530. package/tests/regression/l4-reputation-tiers.ts +102 -0
  531. package/tests/test-bundler-compat.ts +132 -0
  532. package/tests/test-candide-bundler.ts +117 -0
  533. package/tests/test-candide-paymaster.ts +101 -0
  534. package/tests/test-candide-sdk.ts +116 -0
  535. package/tests/test-candide-simple.ts +204 -0
  536. package/tests/test-pimlico-complete.ts +134 -0
  537. package/tests/utils/contractVerifier.ts +3 -3
  538. package/tsconfig.build.json +23 -0
  539. package/tsconfig.json +5 -19
  540. package/typedoc.json +5 -39
  541. package/update-version.sh +20 -0
  542. package/vitest.config.ts +6 -5
  543. package/.eslintrc.cjs +0 -30
  544. package/docs/ABI_Change_Tracking_Workflow.md +0 -41
  545. package/docs/Faucet_Gasless_Plan.md +0 -56
  546. package/docs/api/@aastar/account.md +0 -235
  547. package/docs/api/@aastar/analytics.md +0 -219
  548. package/docs/api/@aastar/core.md +0 -26830
  549. package/docs/api/@aastar/dapp.md +0 -130
  550. package/docs/api/@aastar/identity.md +0 -482
  551. package/docs/api/@aastar/paymaster.md +0 -1387
  552. package/docs/api/@aastar/sdk/README.md +0 -155
  553. package/docs/api/@aastar/sdk/node.md +0 -4044
  554. package/docs/api/@aastar/tokens.md +0 -1971
  555. package/docs/changelog.md +0 -99
  556. package/docs/examples/README.md +0 -18
  557. package/docs/guide/concepts/account-abstraction.md +0 -95
  558. package/docs/guide/concepts/rainbow-bridge.md +0 -68
  559. package/docs/guide/concepts/reputation.md +0 -95
  560. package/docs/guide/concepts/superpaymaster.md +0 -141
  561. package/docs/guide/use-cases/community-management.md +0 -141
  562. package/docs/guide/use-cases/gasless-transactions.md +0 -71
  563. package/docs/guide/use-cases/operator-staking.md +0 -84
  564. package/docs/guide/use-cases/yop.md +0 -72
  565. package/docs/refactor/2026-01-13-221242-trae-refactor.md +0 -224
  566. package/docs/refactor/2026-01-13-audit-analysis.md +0 -96
  567. package/docs/refactor/2026-01-13-audit-report-v0.16.2.md +0 -76
  568. package/docs/refactor/2026-01-13-audit-report-v0.17.0.md +0 -74
  569. package/docs/refactor/2026-01-13-cursor-refactor.md +0 -511
  570. package/docs/refactor/2026-01-13-refactor-plan.md +0 -88
  571. package/docs/refactor/2026-01-13-refactor-response-plan.md +0 -77
  572. package/docs/refactor/2026-01-13-refactor-review.md +0 -39
  573. package/docs/refactor/2026-01-13-sdk-enhancement-plan.md +0 -120
  574. package/docs/refactor/2026-01-14-audit-response.md +0 -242
  575. package/docs/refactor/2026-01-14-audit-summary.md +0 -133
  576. package/docs/refactor/cursor-2026-01-13-14-00-audit-report.md +0 -267
  577. package/packages/account/src/accounts/simple.test.ts +0 -93
  578. package/packages/account/src/eoa.test.ts +0 -37
  579. package/packages/account/src/index.test.ts +0 -34
  580. package/packages/core/scripts/audit-abi-coverage.ts +0 -165
  581. package/packages/core/scripts/debug-regex.ts +0 -36
  582. package/packages/core/src/abis/.abi-hashes.json +0 -26
  583. package/packages/core/src/actions/StateValidator.test.ts +0 -175
  584. package/packages/core/src/actions/account.test.ts +0 -155
  585. package/packages/core/src/actions/aggregator.test.ts +0 -88
  586. package/packages/core/src/actions/dvt.test.ts +0 -124
  587. package/packages/core/src/actions/entryPoint.test.ts +0 -176
  588. package/packages/core/src/actions/factory.test.ts +0 -250
  589. package/packages/core/src/actions/faucet.test.ts +0 -202
  590. package/packages/core/src/actions/gtokenExtended.test.ts +0 -162
  591. package/packages/core/src/actions/gtokenExtended.ts +0 -153
  592. package/packages/core/src/actions/paymasterV4.test.ts +0 -209
  593. package/packages/core/src/actions/paymasterV4.ts +0 -455
  594. package/packages/core/src/actions/registry.test.ts +0 -443
  595. package/packages/core/src/actions/reputation.test.ts +0 -225
  596. package/packages/core/src/actions/sbt.test.ts +0 -322
  597. package/packages/core/src/actions/staking.test.ts +0 -273
  598. package/packages/core/src/actions/superPaymaster.test.ts +0 -356
  599. package/packages/core/src/actions/tokens.test.ts +0 -60
  600. package/packages/core/src/actions/validators.test.ts +0 -239
  601. package/packages/core/src/actions/validators.ts +0 -590
  602. package/packages/core/src/contracts.test.ts +0 -58
  603. package/packages/core/src/requirementChecker.test.ts +0 -71
  604. package/packages/core/src/roles.test.ts +0 -34
  605. package/packages/core/src/utils/validation.test.ts +0 -50
  606. package/packages/core/src/utils/validation.ts +0 -66
  607. package/packages/core/vitest.config.ts +0 -14
  608. package/packages/paymaster/src/V4/PaymasterClient.test.ts +0 -114
  609. package/packages/paymaster/src/V4/PaymasterOperator.test.ts +0 -80
  610. package/packages/paymaster/src/V4/PaymasterUtils.test.ts +0 -54
  611. package/packages/paymaster/src/V4/SuperPaymasterClient.test.ts +0 -79
  612. package/packages/sdk/coverage_output.txt +0 -393
  613. package/packages/sdk/coverage_output_final.txt +0 -739
  614. package/packages/sdk/coverage_output_final_v2.txt +0 -722
  615. package/packages/sdk/coverage_output_final_v3.txt +0 -722
  616. package/packages/sdk/src/clients/ExperimentClient.test.ts +0 -65
  617. package/packages/sdk/src/clients/admin.test.ts +0 -98
  618. package/packages/sdk/src/clients/clients.test.ts +0 -104
  619. package/packages/sdk/src/clients/community.test.ts +0 -118
  620. package/packages/sdk/src/clients/endUser.test.ts +0 -221
  621. package/packages/sdk/src/clients/operator.test.ts +0 -162
  622. package/packages/sdk/src/errors/AAStarError.test.ts +0 -92
  623. package/packages/sdk/src/errors/AAStarError.ts +0 -70
  624. package/packages/sdk/src/errors/decoder.test.ts +0 -107
  625. package/packages/sdk/src/node/index.ts +0 -8
  626. package/packages/sdk/src/types/result.ts +0 -29
  627. package/packages/sdk/src/utils/errorHandler.test.ts +0 -102
  628. package/packages/sdk/src/utils/eventDecoder.test.ts +0 -56
  629. package/packages/sdk/src/utils/eventDecoder.ts +0 -66
  630. package/packages/sdk/src/utils/funding.test.ts +0 -117
  631. package/packages/sdk/src/utils/keys.test.ts +0 -105
  632. package/packages/sdk/src/utils/roleData.test.ts +0 -85
  633. package/packages/sdk/src/utils/testScenarios.test.ts +0 -79
  634. package/packages/sdk/src/utils/userOp.test.ts +0 -190
  635. package/scripts/debug-addr.ts +0 -43
  636. package/scripts/debug-community-registration.ts +0 -92
  637. package/scripts/debug-deploy-v4.ts +0 -116
  638. package/scripts/debug-paymaster.ts +0 -127
  639. package/scripts/debug-register-role.ts +0 -101
  640. package/scripts/debug-version.ts +0 -71
  641. package/scripts/debug_account_c.ts +0 -43
  642. package/scripts/debug_bls.ts +0 -58
  643. package/scripts/debug_config_v036.ts +0 -13
  644. package/scripts/debug_contracts.ts +0 -2
  645. package/scripts/debug_env.ts +0 -69
  646. package/scripts/debug_find_paymaster.ts +0 -98
  647. package/scripts/debug_isolated_registration.ts +0 -256
  648. package/scripts/debug_paymaster_config.ts +0 -19
  649. package/scripts/debug_pim_addr.ts +0 -23
  650. package/scripts/debug_pm_status.ts +0 -51
  651. package/scripts/debug_registry.ts +0 -39
  652. package/scripts/debug_registry_setup.ts +0 -129
  653. package/scripts/debug_sanity.ts +0 -32
  654. package/scripts/debug_shared_config.ts +0 -10
  655. package/scripts/debug_token_compat.ts +0 -51
  656. package/scripts/debug_tokens.ts +0 -41
  657. package/scripts/debug_vcheck.ts +0 -33
  658. package/scripts/test_groups.ts +0 -138
  659. package/scripts/test_multi_community_anvil.ts +0 -276
  660. package/scripts/test_new_sdk_apis_sepolia.ts +0 -193
  661. package/scripts/test_sdk_join_idempotent.ts +0 -233
  662. package/scripts/test_simple_sepolia.ts +0 -44
@@ -1,613 +1,732 @@
1
1
  import { type Address, type PublicClient, type WalletClient, type Hex, type Hash, type Account, parseEther } from 'viem';
2
2
  import { xPNTsFactoryABI, PaymasterFactoryABI } from '../abis/index.js';
3
+ import { validateAddress, validateRequired, validateAmount } from '../validators/index.js';
4
+ import { AAStarError } from '../errors/index.js';
3
5
 
4
6
  // xPNTs Factory Actions (基于地址调用的通用接口)
5
7
  export type XPNTsFactoryActions = {
6
8
  // Token 部署
9
+ deployxPNTsToken: (args: { name: string, symbol: string, communityName: string, communityENS: string, exchangeRate: bigint, paymasterAOA: Address, account?: Account | Address }) => Promise<Hash>;
7
10
  createToken: (args: { name: string, symbol: string, community: Address, account?: Account | Address }) => Promise<Hash>;
8
11
  deployForCommunity: (args: { community: Address, account?: Account | Address }) => Promise<Hash>;
9
12
 
10
13
  // 查询
11
14
  getTokenAddress: (args: { community: Address }) => Promise<Address>;
12
15
  predictAddress: (args: { community: Address, salt?: bigint }) => Promise<Address>;
16
+ hasToken: (args: { community: Address }) => Promise<boolean>;
13
17
  isTokenDeployed: (args: { community: Address }) => Promise<boolean>;
14
18
  getCommunityByToken: (args: { token: Address }) => Promise<Address>;
15
19
  getAllTokens: () => Promise<Address[]>;
20
+ getDeployedCount: () => Promise<bigint>;
16
21
  getTokenCount: () => Promise<bigint>;
17
22
  deployedTokens: (args: { index: bigint }) => Promise<Address>;
18
23
  communityToToken: (args: { community: Address }) => Promise<Address>;
19
24
 
20
25
  // 配置
21
26
  setRegistry: (args: { registry: Address, account?: Account | Address }) => Promise<Hash>;
27
+ setSuperPaymasterAddress: (args: { paymaster: Address, account?: Account | Address }) => Promise<Hash>;
22
28
  setSuperPaymaster: (args: { paymaster: Address, account?: Account | Address }) => Promise<Hash>;
23
29
  setImplementation: (args: { impl: Address, account?: Account | Address }) => Promise<Hash>;
24
30
  getImplementation: () => Promise<Address>;
25
31
 
26
32
  // 常量
27
33
  REGISTRY: () => Promise<Address>;
34
+ SUPERPAYMASTER: () => Promise<Address>;
28
35
  SUPER_PAYMASTER: () => Promise<Address>;
29
36
  tokenImplementation: () => Promise<Address>;
30
37
 
31
38
  // Ownership
32
- xPNTsFactoryOwner: () => Promise<Address>;
33
- transferXPNTsFactoryOwnership: (args: { newOwner: Address, account?: Account | Address }) => Promise<Hash>;
34
- renounceXPNTsFactoryOwnership: (args: { account?: Account | Address }) => Promise<Hash>;
35
-
36
- // Aliases
37
- deployxPNTsToken: (args: { name: string, symbol: string, community: Address, account?: Account | Address }) => Promise<Hash>; // Alias
38
-
39
- // Prediction & Economics
40
- predictDepositAmount: (args: { community: Address, userCount: bigint }) => Promise<bigint>;
41
- getPredictionParams: (args: { community: Address }) => Promise<any>;
42
- getDepositBreakdown: (args: { community: Address }) => Promise<any>;
43
- getAPNTsPrice: () => Promise<bigint>;
44
- aPNTsPriceUSD: () => Promise<bigint>;
45
-
46
- // Admin & Config
47
- setIndustryMultiplier: (args: { industry: string, multiplier: bigint, account?: Account | Address }) => Promise<Hash>;
48
- setSuperPaymasterAddress: (args: { paymaster: Address, account?: Account | Address }) => Promise<Hash>;
49
- updateAPNTsPrice: (args: { newPrice: bigint, account?: Account | Address }) => Promise<Hash>;
50
- updatePrediction: (args: { community: Address, userCount: bigint, account?: Account | Address }) => Promise<Hash>;
51
- updatePredictionCustom: (args: { community: Address, params: any, account?: Account | Address }) => Promise<Hash>;
52
-
53
- // Views
54
- hasToken: (args: { token: Address }) => Promise<boolean>;
55
- getDeployedCount: () => Promise<bigint>;
56
- industryMultipliers: (args: { industry: string }) => Promise<bigint>;
57
- getIndustryMultiplier: (args: { industry: string }) => Promise<bigint>;
58
- predictions: (args: { community: Address }) => Promise<any>;
59
-
60
- // Constants
61
- MIN_SUGGESTED_AMOUNT: () => Promise<bigint>;
62
- DEFAULT_SAFETY_FACTOR: () => Promise<bigint>;
63
- SUPERPAYMASTER: () => Promise<Address>; // Alias for SUPER_PAYMASTER due to ABI naming
39
+ owner: () => Promise<Address>;
40
+ transferOwnership: (args: { newOwner: Address, account?: Account | Address }) => Promise<Hash>;
41
+ renounceOwnership: (args: { account?: Account | Address }) => Promise<Hash>;
64
42
 
65
43
  // Version
66
- xPNTsFactoryVersion: () => Promise<string>;
44
+ version: () => Promise<string>;
67
45
  };
68
46
 
69
47
  // Paymaster Factory Actions
70
48
  export type PaymasterFactoryActions = {
71
49
  // Deployment
72
- // Deployment
73
- deployPaymaster: (args: { owner: Address, version?: string, initData?: Hex, account?: Account | Address }) => Promise<Hash>; // initData 支持
74
- deployPaymasterDeterministic: (args: { owner: Address, version?: string, initData?: Hex, salt: Hex, account?: Account | Address }) => Promise<Hash>;
75
- predictPaymasterAddress: (args: { owner: Address, salt: Hex }) => Promise<Address>;
50
+ deployPaymaster: (args: { version?: string, initData?: Hex, account?: Account | Address }) => Promise<Hash>;
51
+ deployPaymasterDeterministic: (args: { version: string, salt: Hex, initData: Hex, account?: Account | Address }) => Promise<Hash>;
76
52
 
77
53
  // Query
78
54
  calculateAddress: (args: { owner: Address }) => Promise<Address>;
79
- getPaymaster: (args: { owner: Address }) => Promise<Address>; // 使用 msg.sender mapping,不支持 salt
55
+ getPaymaster: (args: { owner: Address }) => Promise<Address>;
56
+ getPaymasterByOperator: (args: { operator: Address }) => Promise<Address>;
57
+ getOperatorByPaymaster: (args: { paymaster: Address }) => Promise<Address>;
80
58
  getPaymasterCount: () => Promise<bigint>;
81
59
  getAllPaymasters: () => Promise<Address[]>;
82
- isPaymasterDeployed: (args: { owner: Address }) => Promise<boolean>;
83
-
84
60
  hasPaymaster: (args: { owner: Address }) => Promise<boolean>;
85
- getPaymasterList: (args: { offset: bigint, limit: bigint }) => Promise<Address[]>;
86
- paymasterList: (args: { index: bigint }) => Promise<Address>;
87
- totalDeployed: () => Promise<bigint>;
88
-
89
- getOperatorByPaymaster: (args: { paymaster: Address }) => Promise<Address>;
90
- operatorByPaymaster: (args: { paymaster: Address }) => Promise<Address>;
91
- getPaymasterByOperator: (args: { operator: Address }) => Promise<Address>;
92
- paymasterByOperator: (args: { operator: Address }) => Promise<Address>;
93
- getPaymasterInfo: (args: { paymaster: Address }) => Promise<any>;
94
-
95
- hasImplementation: (args: { version: string }) => Promise<boolean>;
96
- implementations: (args: { version: string }) => Promise<Address>;
61
+ isPaymasterDeployed: (args: { owner: Address }) => Promise<boolean>;
97
62
 
98
63
  // Config
64
+ addImplementation: (args: { version: string, impl: Address, account?: Account | Address }) => Promise<Hash>;
65
+ upgradeImplementation: (args: { version: string, impl: Address, account?: Account | Address }) => Promise<Hash>;
66
+ setDefaultVersion: (args: { version: string, account?: Account | Address }) => Promise<Hash>;
99
67
  setImplementationV4: (args: { impl: Address, account?: Account | Address }) => Promise<Hash>;
68
+ getImplementation: (args: { version: string }) => Promise<Address>;
100
69
  getImplementationV4: () => Promise<Address>;
101
70
  setRegistry: (args: { registry: Address, account?: Account | Address }) => Promise<Hash>;
102
71
 
103
- addImplementation: (args: { version: string, implementation: Address, account?: Account | Address }) => Promise<Hash>;
104
- upgradeImplementation: (args: { version: string, newImplementation: Address, account?: Account | Address }) => Promise<Hash>;
105
- setDefaultVersion: (args: { version: string, account?: Account | Address }) => Promise<Hash>;
106
-
107
72
  // Constants
108
73
  REGISTRY: () => Promise<Address>;
109
74
  ENTRY_POINT: () => Promise<Address>;
110
75
 
111
76
  // Ownership
112
- paymasterFactoryOwner: () => Promise<Address>;
113
- transferPaymasterFactoryOwnership: (args: { newOwner: Address, account?: Account | Address }) => Promise<Hash>;
114
- renouncePaymasterFactoryOwnership: (args: { account?: Account | Address }) => Promise<Hash>;
77
+ owner: () => Promise<Address>;
78
+ transferOwnership: (args: { newOwner: Address, account?: Account | Address }) => Promise<Hash>;
115
79
 
116
80
  // Version
117
81
  defaultVersion: () => Promise<string>;
118
- paymasterFactoryVersion: () => Promise<string>;
82
+ totalDeployed: () => Promise<bigint>;
83
+ version: () => Promise<string>;
119
84
  };
120
85
 
121
- export const xPNTsFactoryActions = (address: Address) => (client: PublicClient | WalletClient): XPNTsFactoryActions => ({
122
- async createToken({ name, symbol, community, account }) {
123
- // Map to deployxPNTsToken
124
- // Args: name, symbol, communityName, communityENS, exchangeRate, paymasterAOA
125
- // We use name/symbol as community name/ens placeholder if not provided
126
- // We assume msg.sender (account) is the community owner
127
- return (client as any).writeContract({
128
- address,
129
- abi: xPNTsFactoryABI,
130
- functionName: 'deployxPNTsToken',
131
- args: [
132
- name,
133
- symbol,
134
- name, // communityName
135
- symbol, // communityENS
136
- parseEther('1'), // exchangeRate: 1:1 with 18 decimals (1e18)
137
- '0x0000000000000000000000000000000000000000' // paymasterAOA
138
- ],
139
- account: account as any,
140
- chain: (client as any).chain
141
- });
142
- },
143
-
144
- async deployForCommunity({ community, account }) {
145
- return (client as any).writeContract({
146
- address,
147
- abi: xPNTsFactoryABI,
148
- functionName: 'deployForCommunity',
149
- args: [community],
150
- account: account as any,
151
- chain: (client as any).chain
152
- });
153
- },
154
-
155
- async getTokenAddress({ community }) {
156
- return (client as PublicClient).readContract({
157
- address,
158
- abi: xPNTsFactoryABI,
159
- functionName: 'getTokenAddress',
160
- args: [community]
161
- }) as Promise<Address>;
162
- },
163
-
164
- async predictAddress({ community, salt }) {
165
- return (client as PublicClient).readContract({
166
- address,
167
- abi: xPNTsFactoryABI,
168
- functionName: 'predictAddress',
169
- args: salt !== undefined ? [community, salt] : [community]
170
- }) as Promise<Address>;
171
- },
172
-
173
- async isTokenDeployed({ community }) {
174
- return (client as PublicClient).readContract({
175
- address,
176
- abi: xPNTsFactoryABI,
177
- functionName: 'isTokenDeployed',
178
- args: [community]
179
- }) as Promise<boolean>;
180
- },
181
-
182
- async getCommunityByToken({ token }) {
183
- return (client as PublicClient).readContract({
184
- address,
185
- abi: xPNTsFactoryABI,
186
- functionName: 'getCommunityByToken',
187
- args: [token]
188
- }) as Promise<Address>;
189
- },
190
-
191
- async getAllTokens() {
192
- return (client as PublicClient).readContract({
193
- address,
194
- abi: xPNTsFactoryABI,
195
- functionName: 'getAllTokens',
196
- args: []
197
- }) as Promise<Address[]>;
198
- },
199
-
200
- async getTokenCount() {
201
- return (client as PublicClient).readContract({
202
- address,
203
- abi: xPNTsFactoryABI,
204
- functionName: 'getTokenCount',
205
- args: []
206
- }) as Promise<bigint>;
207
- },
208
-
209
- async deployedTokens({ index }) {
210
- return (client as PublicClient).readContract({
211
- address,
212
- abi: xPNTsFactoryABI,
213
- functionName: 'deployedTokens',
214
- args: [index]
215
- }) as Promise<Address>;
216
- },
217
-
218
- async communityToToken({ community }) {
219
- return (client as PublicClient).readContract({
220
- address,
221
- abi: xPNTsFactoryABI,
222
- functionName: 'communityToToken',
223
- args: [community]
224
- }) as Promise<Address>;
225
- },
226
-
227
- async setRegistry({ registry, account }) {
228
- return (client as any).writeContract({
229
- address,
230
- abi: xPNTsFactoryABI,
231
- functionName: 'setRegistry',
232
- args: [registry],
233
- account: account as any,
234
- chain: (client as any).chain
235
- });
236
- },
237
-
238
- async setSuperPaymaster({ paymaster, account }) {
239
- return (client as any).writeContract({
240
- address,
241
- abi: xPNTsFactoryABI,
242
- functionName: 'setSuperPaymaster',
243
- args: [paymaster],
244
- account: account as any,
245
- chain: (client as any).chain
246
- });
247
- },
248
-
249
- async setImplementation({ impl, account }) {
250
- return (client as any).writeContract({
251
- address,
252
- abi: xPNTsFactoryABI,
253
- functionName: 'setImplementation',
254
- args: [impl],
255
- account: account as any,
256
- chain: (client as any).chain
257
- });
258
- },
259
-
260
- async getImplementation() {
261
- return (client as PublicClient).readContract({
262
- address,
263
- abi: xPNTsFactoryABI,
264
- functionName: 'getImplementation',
265
- args: []
266
- }) as Promise<Address>;
267
- },
268
-
269
- async REGISTRY() {
270
- return (client as PublicClient).readContract({
271
- address,
272
- abi: xPNTsFactoryABI,
273
- functionName: 'REGISTRY',
274
- args: []
275
- }) as Promise<Address>;
276
- },
277
-
278
-
279
-
280
- async tokenImplementation() {
281
- return (client as PublicClient).readContract({
282
- address,
283
- abi: xPNTsFactoryABI,
284
- functionName: 'tokenImplementation',
285
- args: []
286
- }) as Promise<Address>;
287
- },
288
-
289
- async xPNTsFactoryOwner() {
290
- return (client as PublicClient).readContract({
291
- address,
292
- abi: xPNTsFactoryABI,
293
- functionName: 'owner',
294
- args: []
295
- }) as Promise<Address>;
296
- },
297
-
298
- async transferXPNTsFactoryOwnership({ newOwner, account }) {
299
- return (client as any).writeContract({
300
- address,
301
- abi: xPNTsFactoryABI,
302
- functionName: 'transferOwnership',
303
- args: [newOwner],
304
- account: account as any,
305
- chain: (client as any).chain
306
- });
307
- },
308
-
309
- async renounceXPNTsFactoryOwnership({ account }) {
310
- return (client as any).writeContract({
311
- address,
312
- abi: xPNTsFactoryABI,
313
- functionName: 'renounceOwnership',
314
- args: [],
315
- account: account as any,
316
- chain: (client as any).chain
317
- });
318
- },
319
-
320
- async deployxPNTsToken(args) {
321
- return this.createToken(args);
322
- },
323
-
324
- // Prediction & Economics
325
- async predictDepositAmount({ community, userCount }) {
326
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'predictDepositAmount', args: [community, userCount] }) as Promise<bigint>;
327
- },
328
- async getPredictionParams({ community }) {
329
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'getPredictionParams', args: [community] });
330
- },
331
- async getDepositBreakdown({ community }) {
332
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'getDepositBreakdown', args: [community] });
333
- },
334
- async getAPNTsPrice() {
335
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'getAPNTsPrice', args: [] }) as Promise<bigint>;
336
- },
337
- async aPNTsPriceUSD() {
338
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'aPNTsPriceUSD', args: [] }) as Promise<bigint>;
339
- },
340
- async SUPER_PAYMASTER() {
341
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'SUPER_PAYMASTER', args: [] }) as Promise<Address>;
342
- },
343
-
344
- async SUPERPAYMASTER() {
345
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'SUPERPAYMASTER', args: [] }) as Promise<Address>;
346
- },
347
-
348
- // Admin & Config
349
- async setIndustryMultiplier({ industry, multiplier, account }) {
350
- return (client as any).writeContract({ address, abi: xPNTsFactoryABI, functionName: 'setIndustryMultiplier', args: [industry, multiplier], account: account as any, chain: (client as any).chain });
351
- },
352
- async setSuperPaymasterAddress({ paymaster, account }) {
353
- return (client as any).writeContract({ address, abi: xPNTsFactoryABI, functionName: 'setSuperPaymasterAddress', args: [paymaster], account: account as any, chain: (client as any).chain });
354
- },
355
- async updateAPNTsPrice({ newPrice, account }) {
356
- return (client as any).writeContract({ address, abi: xPNTsFactoryABI, functionName: 'updateAPNTsPrice', args: [newPrice], account: account as any, chain: (client as any).chain });
357
- },
358
- async updatePrediction({ community, userCount, account }) {
359
- return (client as any).writeContract({ address, abi: xPNTsFactoryABI, functionName: 'updatePrediction', args: [community, userCount], account: account as any, chain: (client as any).chain });
360
- },
361
- async updatePredictionCustom({ community, params, account }) {
362
- return (client as any).writeContract({ address, abi: xPNTsFactoryABI, functionName: 'updatePredictionCustom', args: [community, params], account: account as any, chain: (client as any).chain });
363
- },
364
-
365
- // Views
366
- async hasToken({ token }) {
367
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'hasToken', args: [token] }) as Promise<boolean>;
368
- },
369
- async getDeployedCount() {
370
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'getDeployedCount', args: [] }) as Promise<bigint>;
371
- },
372
- async industryMultipliers({ industry }) {
373
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'industryMultipliers', args: [industry] }) as Promise<bigint>;
374
- },
375
- async getIndustryMultiplier({ industry }) {
376
- return this.industryMultipliers({ industry });
377
- },
378
- async predictions({ community }) {
379
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'predictions', args: [community] });
380
- },
86
+ export const xPNTsFactoryActions = (address: Address) => (client: PublicClient | WalletClient): XPNTsFactoryActions => {
87
+ const actions: XPNTsFactoryActions = {
88
+ async deployxPNTsToken({ name, symbol, communityName, communityENS, exchangeRate, paymasterAOA, account }) {
89
+ try {
90
+ validateRequired(name, 'name');
91
+ validateRequired(symbol, 'symbol');
92
+ validateRequired(communityName, 'communityName');
93
+ validateRequired(communityENS, 'communityENS');
94
+ validateAmount(exchangeRate, 'exchangeRate');
95
+ validateAddress(paymasterAOA, 'paymasterAOA');
96
+ return await (client as any).writeContract({
97
+ address,
98
+ abi: xPNTsFactoryABI,
99
+ functionName: 'deployxPNTsToken',
100
+ args: [name, symbol, communityName, communityENS, exchangeRate, paymasterAOA],
101
+ account: account as any,
102
+ chain: (client as any).chain
103
+ });
104
+ } catch (error) {
105
+ throw AAStarError.fromViemError(error as Error, 'deployxPNTsToken');
106
+ }
107
+ },
108
+
109
+ async createToken({ name, symbol, community, account }) {
110
+ return this.deployxPNTsToken({
111
+ name,
112
+ symbol,
113
+ communityName: name,
114
+ communityENS: symbol,
115
+ exchangeRate: parseEther('1'),
116
+ paymasterAOA: '0x0000000000000000000000000000000000000000',
117
+ account
118
+ });
119
+ },
120
+
121
+ async deployForCommunity({ community, account }) {
122
+ try {
123
+ validateAddress(community, 'community');
124
+ return await (client as any).writeContract({
125
+ address,
126
+ abi: xPNTsFactoryABI,
127
+ functionName: 'deployForCommunity',
128
+ args: [community],
129
+ account: account as any,
130
+ chain: (client as any).chain
131
+ });
132
+ } catch (error) {
133
+ throw AAStarError.fromViemError(error as Error, 'deployForCommunity');
134
+ }
135
+ },
136
+
137
+ async getTokenAddress({ community }) {
138
+ try {
139
+ validateAddress(community, 'community');
140
+ return await (client as PublicClient).readContract({
141
+ address,
142
+ abi: xPNTsFactoryABI,
143
+ functionName: 'getTokenAddress',
144
+ args: [community]
145
+ }) as Address;
146
+ } catch (error) {
147
+ throw AAStarError.fromViemError(error as Error, 'getTokenAddress');
148
+ }
149
+ },
150
+
151
+ async predictAddress({ community, salt }) {
152
+ try {
153
+ validateAddress(community, 'community');
154
+ return await (client as PublicClient).readContract({
155
+ address,
156
+ abi: xPNTsFactoryABI,
157
+ functionName: 'predictAddress',
158
+ args: salt !== undefined ? [community, salt] : [community]
159
+ }) as Address;
160
+ } catch (error) {
161
+ throw AAStarError.fromViemError(error as Error, 'predictAddress');
162
+ }
163
+ },
164
+
165
+ async hasToken({ community }) {
166
+ try {
167
+ validateAddress(community, 'community');
168
+ return await (client as PublicClient).readContract({
169
+ address,
170
+ abi: xPNTsFactoryABI,
171
+ functionName: 'hasToken',
172
+ args: [community]
173
+ }) as boolean;
174
+ } catch (error) {
175
+ throw AAStarError.fromViemError(error as Error, 'hasToken');
176
+ }
177
+ },
178
+
179
+ async isTokenDeployed({ community }) {
180
+ return this.hasToken({ community });
181
+ },
182
+
183
+ async getCommunityByToken({ token }) {
184
+ try {
185
+ validateAddress(token, 'token');
186
+ return await (client as PublicClient).readContract({
187
+ address,
188
+ abi: xPNTsFactoryABI,
189
+ functionName: 'getCommunityByToken',
190
+ args: [token]
191
+ }) as Address;
192
+ } catch (error) {
193
+ throw AAStarError.fromViemError(error as Error, 'getCommunityByToken');
194
+ }
195
+ },
196
+
197
+ async getAllTokens() {
198
+ try {
199
+ return await (client as PublicClient).readContract({
200
+ address,
201
+ abi: xPNTsFactoryABI,
202
+ functionName: 'getAllTokens',
203
+ args: []
204
+ }) as Address[];
205
+ } catch (error) {
206
+ throw AAStarError.fromViemError(error as Error, 'getAllTokens');
207
+ }
208
+ },
209
+
210
+ async getDeployedCount() {
211
+ try {
212
+ return await (client as PublicClient).readContract({
213
+ address,
214
+ abi: xPNTsFactoryABI,
215
+ functionName: 'getDeployedCount',
216
+ args: []
217
+ }) as bigint;
218
+ } catch (error) {
219
+ throw AAStarError.fromViemError(error as Error, 'getDeployedCount');
220
+ }
221
+ },
222
+
223
+ async getTokenCount() {
224
+ return this.getDeployedCount();
225
+ },
226
+
227
+ async deployedTokens({ index }) {
228
+ try {
229
+ return await (client as PublicClient).readContract({
230
+ address,
231
+ abi: xPNTsFactoryABI,
232
+ functionName: 'deployedTokens',
233
+ args: [index]
234
+ }) as Address;
235
+ } catch (error) {
236
+ throw AAStarError.fromViemError(error as Error, 'deployedTokens');
237
+ }
238
+ },
239
+
240
+ async communityToToken({ community }) {
241
+ try {
242
+ validateAddress(community, 'community');
243
+ return await (client as PublicClient).readContract({
244
+ address,
245
+ abi: xPNTsFactoryABI,
246
+ functionName: 'communityToToken',
247
+ args: [community]
248
+ }) as Address;
249
+ } catch (error) {
250
+ throw AAStarError.fromViemError(error as Error, 'communityToToken');
251
+ }
252
+ },
253
+
254
+ async setRegistry({ registry, account }) {
255
+ try {
256
+ validateAddress(registry, 'registry');
257
+ return await (client as any).writeContract({
258
+ address,
259
+ abi: xPNTsFactoryABI,
260
+ functionName: 'setRegistry',
261
+ args: [registry],
262
+ account: account as any,
263
+ chain: (client as any).chain
264
+ });
265
+ } catch (error) {
266
+ throw AAStarError.fromViemError(error as Error, 'setRegistry');
267
+ }
268
+ },
269
+
270
+ async setSuperPaymasterAddress({ paymaster, account }) {
271
+ try {
272
+ validateAddress(paymaster, 'paymaster');
273
+ return await (client as any).writeContract({
274
+ address,
275
+ abi: xPNTsFactoryABI,
276
+ functionName: 'setSuperPaymasterAddress',
277
+ args: [paymaster],
278
+ account: account as any,
279
+ chain: (client as any).chain
280
+ });
281
+ } catch (error) {
282
+ throw AAStarError.fromViemError(error as Error, 'setSuperPaymasterAddress');
283
+ }
284
+ },
285
+
286
+ async setSuperPaymaster({ paymaster, account }) {
287
+ return this.setSuperPaymasterAddress({ paymaster, account });
288
+ },
289
+
290
+ async setImplementation({ impl, account }) {
291
+ try {
292
+ validateAddress(impl, 'impl');
293
+ return await (client as any).writeContract({
294
+ address,
295
+ abi: xPNTsFactoryABI,
296
+ functionName: 'setImplementation',
297
+ args: [impl],
298
+ account: account as any,
299
+ chain: (client as any).chain
300
+ });
301
+ } catch (error) {
302
+ throw AAStarError.fromViemError(error as Error, 'setImplementation');
303
+ }
304
+ },
305
+
306
+ async getImplementation() {
307
+ try {
308
+ return await (client as PublicClient).readContract({
309
+ address,
310
+ abi: xPNTsFactoryABI,
311
+ functionName: 'getImplementation',
312
+ args: []
313
+ }) as Address;
314
+ } catch (error) {
315
+ throw AAStarError.fromViemError(error as Error, 'getImplementation');
316
+ }
317
+ },
318
+
319
+ async REGISTRY() {
320
+ try {
321
+ return await (client as PublicClient).readContract({
322
+ address,
323
+ abi: xPNTsFactoryABI,
324
+ functionName: 'REGISTRY',
325
+ args: []
326
+ }) as Address;
327
+ } catch (error) {
328
+ throw AAStarError.fromViemError(error as Error, 'REGISTRY');
329
+ }
330
+ },
331
+
332
+ async SUPERPAYMASTER() {
333
+ try {
334
+ return await (client as PublicClient).readContract({
335
+ address,
336
+ abi: xPNTsFactoryABI,
337
+ functionName: 'SUPERPAYMASTER',
338
+ args: []
339
+ }) as Address;
340
+ } catch (error) {
341
+ throw AAStarError.fromViemError(error as Error, 'SUPERPAYMASTER');
342
+ }
343
+ },
344
+
345
+ async SUPER_PAYMASTER() {
346
+ return this.SUPERPAYMASTER();
347
+ },
348
+
349
+ async tokenImplementation() {
350
+ try {
351
+ return await (client as PublicClient).readContract({
352
+ address,
353
+ abi: xPNTsFactoryABI,
354
+ functionName: 'tokenImplementation',
355
+ args: []
356
+ }) as Address;
357
+ } catch (error) {
358
+ throw AAStarError.fromViemError(error as Error, 'tokenImplementation');
359
+ }
360
+ },
361
+
362
+ async owner() {
363
+ try {
364
+ return await (client as PublicClient).readContract({
365
+ address,
366
+ abi: xPNTsFactoryABI,
367
+ functionName: 'owner',
368
+ args: []
369
+ }) as Address;
370
+ } catch (error) {
371
+ throw AAStarError.fromViemError(error as Error, 'owner');
372
+ }
373
+ },
374
+
375
+ async transferOwnership({ newOwner, account }) {
376
+ try {
377
+ validateAddress(newOwner, 'newOwner');
378
+ return await (client as any).writeContract({
379
+ address,
380
+ abi: xPNTsFactoryABI,
381
+ functionName: 'transferOwnership',
382
+ args: [newOwner],
383
+ account: account as any,
384
+ chain: (client as any).chain
385
+ });
386
+ } catch (error) {
387
+ throw AAStarError.fromViemError(error as Error, 'transferOwnership');
388
+ }
389
+ },
390
+
391
+ async renounceOwnership({ account }) {
392
+ try {
393
+ return await (client as any).writeContract({
394
+ address,
395
+ abi: xPNTsFactoryABI,
396
+ functionName: 'renounceOwnership',
397
+ args: [],
398
+ account: account as any,
399
+ chain: (client as any).chain
400
+ });
401
+ } catch (error) {
402
+ throw AAStarError.fromViemError(error as Error, 'renounceOwnership');
403
+ }
404
+ },
405
+
406
+ async version() {
407
+ try {
408
+ return await (client as PublicClient).readContract({
409
+ address,
410
+ abi: xPNTsFactoryABI,
411
+ functionName: 'version',
412
+ args: []
413
+ }) as string;
414
+ } catch (error) {
415
+ throw AAStarError.fromViemError(error as Error, 'version');
416
+ }
417
+ }
418
+ };
419
+ return actions;
420
+ };
381
421
 
382
- // Constants
383
- async DEFAULT_SAFETY_FACTOR() {
384
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'DEFAULT_SAFETY_FACTOR', args: [] }) as Promise<bigint>;
385
- },
386
- async MIN_SUGGESTED_AMOUNT() {
387
- return (client as PublicClient).readContract({ address, abi: xPNTsFactoryABI, functionName: 'MIN_SUGGESTED_AMOUNT', args: [] }) as Promise<bigint>;
388
- },
389
-
390
- async xPNTsFactoryVersion() {
391
- return (client as PublicClient).readContract({
392
- address,
393
- abi: xPNTsFactoryABI,
394
- functionName: 'version',
395
- args: []
396
- }) as Promise<string>;
397
- }
398
- });
399
-
400
- export const paymasterFactoryActions = (address: Address) => (client: PublicClient | WalletClient): PaymasterFactoryActions => ({
401
- async deployPaymaster({ owner, version, initData, account }: { owner: Address, version?: string, initData?: Hex, account?: Account | Address }) {
402
- // Factory.deployPaymaster(version, initData)
403
- const defaultVer = 'v4.2'; // 当前标准版本
404
- const useVer = version || defaultVer;
405
-
406
- return (client as any).writeContract({
407
- address,
408
- abi: PaymasterFactoryABI,
409
- functionName: 'deployPaymaster',
410
- args: [useVer, initData || '0x'],
411
- account: account as any,
412
- chain: (client as any).chain
413
- });
414
- },
415
-
416
- async deployPaymasterDeterministic({ owner, version, initData, salt, account }) {
417
- return (client as any).writeContract({ address, abi: PaymasterFactoryABI, functionName: 'deployPaymasterDeterministic', args: [version || 'v4.2', initData || '0x', salt], account: account as any, chain: (client as any).chain });
418
- },
419
-
420
- async predictPaymasterAddress({ owner, salt }) {
421
- // Note: Contract might not have this function exposed directly or it is separate logic
422
- // But ABI says it's missing, so let's try calling it if it exists in ABI
423
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'predictPaymasterAddress', args: [owner, salt] }) as Promise<Address>;
424
- },
425
-
426
- async calculateAddress({ owner }) {
427
- // This function doesn't exist in V4 factory for non-deterministic deploy
428
- // We throw to avoid misleading usage
429
- throw new Error('Predicting address not supported for standard deploy. Use getPaymaster after deploy.');
430
- },
431
-
432
- async getPaymaster({ owner }) {
433
- // 使用 paymasterByOperator mapping(不支持 salt)
434
- return (client as PublicClient).readContract({
435
- address,
436
- abi: PaymasterFactoryABI,
437
- functionName: 'paymasterByOperator',
438
- args: [owner]
439
- }) as Promise<Address>;
440
- },
441
-
442
- async getPaymasterCount() {
443
- return (client as PublicClient).readContract({
444
- address,
445
- abi: PaymasterFactoryABI,
446
- functionName: 'getPaymasterCount',
447
- args: []
448
- }) as Promise<bigint>;
449
- },
450
-
451
- async getAllPaymasters() {
452
- // Not directly supported by contract as single call (it has list + pagination), using pagination shim
453
- const count = await (client as PublicClient).readContract({
454
- address, abi: PaymasterFactoryABI, functionName: 'getPaymasterCount', args: []
455
- }) as bigint;
456
-
457
- return (client as PublicClient).readContract({
458
- address,
459
- abi: PaymasterFactoryABI,
460
- functionName: 'getPaymasterList',
461
- args: [0n, count]
462
- }) as Promise<Address[]>;
463
- },
464
-
465
- async isPaymasterDeployed({ owner }) {
466
- return (client as PublicClient).readContract({
467
- address,
468
- abi: PaymasterFactoryABI,
469
- functionName: 'hasPaymaster', // Corrected from isPaymasterDeployed
470
- args: [owner]
471
- }) as Promise<boolean>;
472
- },
473
-
474
- async hasPaymaster({ owner }) { return this.isPaymasterDeployed({ owner }); },
475
- async getPaymasterList({ offset, limit }) {
476
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'getPaymasterList', args: [offset, limit] }) as Promise<Address[]>;
477
- },
478
- async paymasterList({ index }) {
479
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'paymasterList', args: [index] }) as Promise<Address>;
480
- },
481
- async totalDeployed() {
482
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'totalDeployed', args: [] }) as Promise<bigint>;
483
- },
484
-
485
- async getOperatorByPaymaster({ paymaster }) {
486
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'getOperatorByPaymaster', args: [paymaster] }) as Promise<Address>;
487
- },
488
- async operatorByPaymaster({ paymaster }) { return this.getOperatorByPaymaster({ paymaster }); },
489
-
490
- async getPaymasterByOperator({ operator }) {
491
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'getPaymasterByOperator', args: [operator] }) as Promise<Address>;
492
- },
493
- async paymasterByOperator({ operator }) { return this.getPaymasterByOperator({ operator }); },
494
-
495
- async getPaymasterInfo({ paymaster }) {
496
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'getPaymasterInfo', args: [paymaster] });
497
- },
498
-
499
- async hasImplementation({ version }) {
500
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'hasImplementation', args: [version] }) as Promise<boolean>;
501
- },
502
- async implementations({ version }) {
503
- return (client as PublicClient).readContract({ address, abi: PaymasterFactoryABI, functionName: 'implementations', args: [version] }) as Promise<Address>;
504
- },
505
-
506
- async setImplementationV4({ impl, account }) {
507
- return (client as any).writeContract({
508
- address,
509
- abi: PaymasterFactoryABI,
510
- functionName: 'setImplementationV4',
511
- args: [impl],
512
- account: account as any,
513
- chain: (client as any).chain
514
- });
515
- },
516
-
517
- async getImplementationV4() {
518
- return (client as PublicClient).readContract({
519
- address,
520
- abi: PaymasterFactoryABI,
521
- functionName: 'getImplementationV4',
522
- args: []
523
- }) as Promise<Address>;
524
- },
525
-
526
- async setRegistry({ registry, account }) {
527
- return (client as any).writeContract({
528
- address,
529
- abi: PaymasterFactoryABI,
530
- functionName: 'setRegistry',
531
- args: [registry],
532
- account: account as any,
533
- chain: (client as any).chain
534
- });
535
- },
536
-
537
- async addImplementation({ version, implementation, account }) {
538
- return (client as any).writeContract({ address, abi: PaymasterFactoryABI, functionName: 'addImplementation', args: [version, implementation], account: account as any, chain: (client as any).chain });
539
- },
540
- async upgradeImplementation({ version, newImplementation, account }) {
541
- return (client as any).writeContract({ address, abi: PaymasterFactoryABI, functionName: 'upgradeImplementation', args: [version, newImplementation], account: account as any, chain: (client as any).chain });
542
- },
543
- async setDefaultVersion({ version, account }) {
544
- return (client as any).writeContract({ address, abi: PaymasterFactoryABI, functionName: 'setDefaultVersion', args: [version], account: account as any, chain: (client as any).chain });
545
- },
546
-
547
- async REGISTRY() {
548
- return (client as PublicClient).readContract({
549
- address,
550
- abi: PaymasterFactoryABI,
551
- functionName: 'REGISTRY',
552
- args: []
553
- }) as Promise<Address>;
554
- },
555
-
556
- async ENTRY_POINT() {
557
- return (client as PublicClient).readContract({
558
- address,
559
- abi: PaymasterFactoryABI,
560
- functionName: 'ENTRY_POINT',
561
- args: []
562
- }) as Promise<Address>;
563
- },
564
-
565
- async paymasterFactoryOwner() {
566
- return (client as PublicClient).readContract({
567
- address,
568
- abi: PaymasterFactoryABI,
569
- functionName: 'owner',
570
- args: []
571
- }) as Promise<Address>;
572
- },
573
-
574
- async transferPaymasterFactoryOwnership({ newOwner, account }) {
575
- return (client as any).writeContract({
576
- address,
577
- abi: PaymasterFactoryABI,
578
- functionName: 'transferOwnership',
579
- args: [newOwner],
580
- account: account as any,
581
- chain: (client as any).chain
582
- });
583
- },
584
-
585
- async renouncePaymasterFactoryOwnership({ account }) {
586
- return (client as any).writeContract({
587
- address,
588
- abi: PaymasterFactoryABI,
589
- functionName: 'renounceOwnership',
590
- args: [],
591
- account: account as any,
592
- chain: (client as any).chain
593
- });
594
- },
595
-
596
- async defaultVersion() {
597
- return (client as PublicClient).readContract({
598
- address,
599
- abi: PaymasterFactoryABI,
600
- functionName: 'defaultVersion',
601
- args: []
602
- }) as Promise<string>;
603
- },
604
-
605
- async paymasterFactoryVersion() {
606
- return (client as PublicClient).readContract({
607
- address,
608
- abi: PaymasterFactoryABI,
609
- functionName: 'version',
610
- args: []
611
- }) as Promise<string>;
612
- }
613
- });
422
+ export const paymasterFactoryActions = (address: Address) => (client: PublicClient | WalletClient): PaymasterFactoryActions => {
423
+ const actions: PaymasterFactoryActions = {
424
+ async deployPaymaster({ version, initData, account }) {
425
+ try {
426
+ const defaultVer = 'v4.2';
427
+ const useVer = version || defaultVer;
428
+
429
+ return await (client as any).writeContract({
430
+ address,
431
+ abi: PaymasterFactoryABI,
432
+ functionName: 'deployPaymaster',
433
+ args: [useVer, initData || '0x'],
434
+ account: account as any,
435
+ chain: (client as any).chain
436
+ });
437
+ } catch (error) {
438
+ throw AAStarError.fromViemError(error as Error, 'deployPaymaster');
439
+ }
440
+ },
441
+
442
+ async deployPaymasterDeterministic({ version, salt, initData, account }) {
443
+ try {
444
+ validateRequired(version, 'version');
445
+ validateRequired(salt, 'salt');
446
+ return await (client as any).writeContract({
447
+ address,
448
+ abi: PaymasterFactoryABI,
449
+ functionName: 'deployPaymasterDeterministic',
450
+ args: [version, salt, initData || '0x'],
451
+ account: account as any,
452
+ chain: (client as any).chain
453
+ });
454
+ } catch (error) {
455
+ throw AAStarError.fromViemError(error as Error, 'deployPaymasterDeterministic');
456
+ }
457
+ },
458
+
459
+ async calculateAddress({ owner }) {
460
+ throw new Error('Predicting address not supported for standard deploy. Use getPaymaster after deploy.');
461
+ },
462
+
463
+ async getPaymaster({ owner }) {
464
+ return this.getPaymasterByOperator({ operator: owner });
465
+ },
466
+
467
+ async getPaymasterByOperator({ operator }) {
468
+ try {
469
+ validateAddress(operator, 'operator');
470
+ return await (client as PublicClient).readContract({
471
+ address,
472
+ abi: PaymasterFactoryABI,
473
+ functionName: 'getPaymasterByOperator',
474
+ args: [operator]
475
+ }) as Address;
476
+ } catch (error) {
477
+ throw AAStarError.fromViemError(error as Error, 'getPaymasterByOperator');
478
+ }
479
+ },
480
+
481
+ async getOperatorByPaymaster({ paymaster }) {
482
+ try {
483
+ validateAddress(paymaster, 'paymaster');
484
+ return await (client as PublicClient).readContract({
485
+ address,
486
+ abi: PaymasterFactoryABI,
487
+ functionName: 'getOperatorByPaymaster',
488
+ args: [paymaster]
489
+ }) as Address;
490
+ } catch (error) {
491
+ throw AAStarError.fromViemError(error as Error, 'getOperatorByPaymaster');
492
+ }
493
+ },
494
+
495
+ async getPaymasterCount() {
496
+ try {
497
+ return await (client as PublicClient).readContract({
498
+ address,
499
+ abi: PaymasterFactoryABI,
500
+ functionName: 'getPaymasterCount',
501
+ args: []
502
+ }) as bigint;
503
+ } catch (error) {
504
+ throw AAStarError.fromViemError(error as Error, 'getPaymasterCount');
505
+ }
506
+ },
507
+
508
+ async getAllPaymasters() {
509
+ try {
510
+ const count = await this.getPaymasterCount();
511
+ return await (client as PublicClient).readContract({
512
+ address,
513
+ abi: PaymasterFactoryABI,
514
+ functionName: 'getPaymasterList',
515
+ args: [0n, count]
516
+ }) as Address[];
517
+ } catch (error) {
518
+ throw AAStarError.fromViemError(error as Error, 'getAllPaymasters');
519
+ }
520
+ },
521
+
522
+ async hasPaymaster({ owner }) {
523
+ try {
524
+ validateAddress(owner, 'owner');
525
+ return await (client as PublicClient).readContract({
526
+ address,
527
+ abi: PaymasterFactoryABI,
528
+ functionName: 'hasPaymaster',
529
+ args: [owner]
530
+ }) as boolean;
531
+ } catch (error) {
532
+ throw AAStarError.fromViemError(error as Error, 'hasPaymaster');
533
+ }
534
+ },
535
+
536
+ async isPaymasterDeployed({ owner }) {
537
+ return this.hasPaymaster({ owner });
538
+ },
539
+
540
+ async addImplementation({ version, impl, account }) {
541
+ try {
542
+ validateRequired(version, 'version');
543
+ validateAddress(impl, 'impl');
544
+ return await (client as any).writeContract({
545
+ address,
546
+ abi: PaymasterFactoryABI,
547
+ functionName: 'addImplementation',
548
+ args: [version, impl],
549
+ account: account as any,
550
+ chain: (client as any).chain
551
+ });
552
+ } catch (error) {
553
+ throw AAStarError.fromViemError(error as Error, 'addImplementation');
554
+ }
555
+ },
556
+
557
+ async upgradeImplementation({ version, impl, account }) {
558
+ try {
559
+ validateRequired(version, 'version');
560
+ validateAddress(impl, 'impl');
561
+ return await (client as any).writeContract({
562
+ address,
563
+ abi: PaymasterFactoryABI,
564
+ functionName: 'upgradeImplementation',
565
+ args: [version, impl],
566
+ account: account as any,
567
+ chain: (client as any).chain
568
+ });
569
+ } catch (error) {
570
+ throw AAStarError.fromViemError(error as Error, 'upgradeImplementation');
571
+ }
572
+ },
573
+
574
+ async setDefaultVersion({ version, account }) {
575
+ try {
576
+ validateRequired(version, 'version');
577
+ return await (client as any).writeContract({
578
+ address,
579
+ abi: PaymasterFactoryABI,
580
+ functionName: 'setDefaultVersion',
581
+ args: [version],
582
+ account: account as any,
583
+ chain: (client as any).chain
584
+ });
585
+ } catch (error) {
586
+ throw AAStarError.fromViemError(error as Error, 'setDefaultVersion');
587
+ }
588
+ },
589
+
590
+ async getImplementation({ version }) {
591
+ try {
592
+ validateRequired(version, 'version');
593
+ return await (client as PublicClient).readContract({
594
+ address,
595
+ abi: PaymasterFactoryABI,
596
+ functionName: 'getImplementation',
597
+ args: [version]
598
+ }) as Address;
599
+ } catch (error) {
600
+ throw AAStarError.fromViemError(error as Error, 'getImplementation');
601
+ }
602
+ },
603
+
604
+ async setImplementationV4({ impl, account }) {
605
+ return this.upgradeImplementation({ version: 'v4', impl, account });
606
+ },
607
+
608
+ async getImplementationV4() {
609
+ try {
610
+ return await (client as PublicClient).readContract({
611
+ address,
612
+ abi: PaymasterFactoryABI,
613
+ functionName: 'getImplementation',
614
+ args: ['v4']
615
+ }) as Address;
616
+ } catch (error) {
617
+ throw AAStarError.fromViemError(error as Error, 'getImplementationV4');
618
+ }
619
+ },
620
+
621
+ async setRegistry({ registry, account }) {
622
+ try {
623
+ validateAddress(registry, 'registry');
624
+ return await (client as any).writeContract({
625
+ address,
626
+ abi: PaymasterFactoryABI,
627
+ functionName: 'setRegistry',
628
+ args: [registry],
629
+ account: account as any,
630
+ chain: (client as any).chain
631
+ });
632
+ } catch (error) {
633
+ throw AAStarError.fromViemError(error as Error, 'setRegistry');
634
+ }
635
+ },
636
+
637
+ async REGISTRY() {
638
+ try {
639
+ return await (client as PublicClient).readContract({
640
+ address,
641
+ abi: PaymasterFactoryABI,
642
+ functionName: 'REGISTRY',
643
+ args: []
644
+ }) as Address;
645
+ } catch (error) {
646
+ throw AAStarError.fromViemError(error as Error, 'REGISTRY');
647
+ }
648
+ },
649
+
650
+ async ENTRY_POINT() {
651
+ try {
652
+ return await (client as PublicClient).readContract({
653
+ address,
654
+ abi: PaymasterFactoryABI,
655
+ functionName: 'ENTRY_POINT',
656
+ args: []
657
+ }) as Address;
658
+ } catch (error) {
659
+ throw AAStarError.fromViemError(error as Error, 'ENTRY_POINT');
660
+ }
661
+ },
662
+
663
+ async owner() {
664
+ try {
665
+ return await (client as PublicClient).readContract({
666
+ address,
667
+ abi: PaymasterFactoryABI,
668
+ functionName: 'owner',
669
+ args: []
670
+ }) as Address;
671
+ } catch (error) {
672
+ throw AAStarError.fromViemError(error as Error, 'owner');
673
+ }
674
+ },
675
+
676
+ async transferOwnership({ newOwner, account }) {
677
+ try {
678
+ validateAddress(newOwner, 'newOwner');
679
+ return await (client as any).writeContract({
680
+ address,
681
+ abi: PaymasterFactoryABI,
682
+ functionName: 'transferOwnership',
683
+ args: [newOwner],
684
+ account: account as any,
685
+ chain: (client as any).chain
686
+ });
687
+ } catch (error) {
688
+ throw AAStarError.fromViemError(error as Error, 'transferOwnership');
689
+ }
690
+ },
691
+
692
+ async defaultVersion() {
693
+ try {
694
+ return await (client as PublicClient).readContract({
695
+ address,
696
+ abi: PaymasterFactoryABI,
697
+ functionName: 'defaultVersion',
698
+ args: []
699
+ }) as string;
700
+ } catch (error) {
701
+ throw AAStarError.fromViemError(error as Error, 'defaultVersion');
702
+ }
703
+ },
704
+
705
+ async totalDeployed() {
706
+ try {
707
+ return await (client as PublicClient).readContract({
708
+ address,
709
+ abi: PaymasterFactoryABI,
710
+ functionName: 'totalDeployed',
711
+ args: []
712
+ }) as bigint;
713
+ } catch (error) {
714
+ throw AAStarError.fromViemError(error as Error, 'totalDeployed');
715
+ }
716
+ },
717
+
718
+ async version() {
719
+ try {
720
+ return await (client as PublicClient).readContract({
721
+ address,
722
+ abi: PaymasterFactoryABI,
723
+ functionName: 'version',
724
+ args: []
725
+ }) as string;
726
+ } catch (error) {
727
+ throw AAStarError.fromViemError(error as Error, 'version');
728
+ }
729
+ }
730
+ };
731
+ return actions;
732
+ };