@varity-labs/sdk 2.0.0-alpha.1

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 (295) hide show
  1. package/LICENSE +31 -0
  2. package/README.md +253 -0
  3. package/dist/analytics/index.d.ts +7 -0
  4. package/dist/analytics/index.d.ts.map +1 -0
  5. package/dist/analytics/index.js +6 -0
  6. package/dist/analytics/tracker.d.ts +128 -0
  7. package/dist/analytics/tracker.d.ts.map +1 -0
  8. package/dist/analytics/tracker.js +203 -0
  9. package/dist/blockchain/BlockchainService.d.ts +100 -0
  10. package/dist/blockchain/BlockchainService.d.ts.map +1 -0
  11. package/dist/blockchain/BlockchainService.js +188 -0
  12. package/dist/blockchain/NFTLicensingService.d.ts +69 -0
  13. package/dist/blockchain/NFTLicensingService.d.ts.map +1 -0
  14. package/dist/blockchain/NFTLicensingService.js +136 -0
  15. package/dist/blockchain/RevenueSplitService.d.ts +71 -0
  16. package/dist/blockchain/RevenueSplitService.d.ts.map +1 -0
  17. package/dist/blockchain/RevenueSplitService.js +111 -0
  18. package/dist/blockchain/index.d.ts +48 -0
  19. package/dist/blockchain/index.d.ts.map +1 -0
  20. package/dist/blockchain/index.js +46 -0
  21. package/dist/blockchain/types.d.ts +63 -0
  22. package/dist/blockchain/types.d.ts.map +1 -0
  23. package/dist/blockchain/types.js +6 -0
  24. package/dist/chains/arbitrum.d.ts +89 -0
  25. package/dist/chains/arbitrum.d.ts.map +1 -0
  26. package/dist/chains/arbitrum.js +134 -0
  27. package/dist/chains/base.d.ts +84 -0
  28. package/dist/chains/base.d.ts.map +1 -0
  29. package/dist/chains/base.js +131 -0
  30. package/dist/chains/index.d.ts +36 -0
  31. package/dist/chains/index.d.ts.map +1 -0
  32. package/dist/chains/index.js +32 -0
  33. package/dist/chains/registry.d.ts +113 -0
  34. package/dist/chains/registry.d.ts.map +1 -0
  35. package/dist/chains/registry.js +201 -0
  36. package/dist/chains/varityL3.d.ts +81 -0
  37. package/dist/chains/varityL3.d.ts.map +1 -0
  38. package/dist/chains/varityL3.js +125 -0
  39. package/dist/cli/commands/clone.d.ts +8 -0
  40. package/dist/cli/commands/clone.d.ts.map +1 -0
  41. package/dist/cli/commands/clone.js +391 -0
  42. package/dist/cli/commands/dev.d.ts +8 -0
  43. package/dist/cli/commands/dev.d.ts.map +1 -0
  44. package/dist/cli/commands/dev.js +40 -0
  45. package/dist/cli/commands/generate.d.ts +8 -0
  46. package/dist/cli/commands/generate.d.ts.map +1 -0
  47. package/dist/cli/commands/generate.js +303 -0
  48. package/dist/cli/commands/init.d.ts +8 -0
  49. package/dist/cli/commands/init.d.ts.map +1 -0
  50. package/dist/cli/commands/init.js +317 -0
  51. package/dist/cli/commands/validate.d.ts +8 -0
  52. package/dist/cli/commands/validate.d.ts.map +1 -0
  53. package/dist/cli/commands/validate.js +69 -0
  54. package/dist/cli/index.d.ts +8 -0
  55. package/dist/cli/index.d.ts.map +1 -0
  56. package/dist/cli/index.js +33 -0
  57. package/dist/cli/utils/logger.d.ts +17 -0
  58. package/dist/cli/utils/logger.d.ts.map +1 -0
  59. package/dist/cli/utils/logger.js +35 -0
  60. package/dist/cli/utils/prompts.d.ts +21 -0
  61. package/dist/cli/utils/prompts.d.ts.map +1 -0
  62. package/dist/cli/utils/prompts.js +103 -0
  63. package/dist/contracts/abis/iso/AccessControlRegistry.json +1468 -0
  64. package/dist/contracts/abis/iso/DataProofRegistry.json +797 -0
  65. package/dist/contracts/abis/iso/MerchantRegistry.json +1237 -0
  66. package/dist/contracts/abis/iso/RepPerformance.json +1351 -0
  67. package/dist/contracts/abis/iso/ResidualCalculator.json +1118 -0
  68. package/dist/contracts/abis/iso/TransactionVault.json +1588 -0
  69. package/dist/contracts/abis/iso/VarityWalletFactory.json +475 -0
  70. package/dist/contracts/addresses.d.ts +88 -0
  71. package/dist/contracts/addresses.d.ts.map +1 -0
  72. package/dist/contracts/addresses.js +94 -0
  73. package/dist/contracts/index.d.ts +7 -0
  74. package/dist/contracts/index.d.ts.map +1 -0
  75. package/dist/contracts/index.js +6 -0
  76. package/dist/core/VaritySDK.d.ts +177 -0
  77. package/dist/core/VaritySDK.d.ts.map +1 -0
  78. package/dist/core/VaritySDK.js +325 -0
  79. package/dist/core/config.d.ts +120 -0
  80. package/dist/core/config.d.ts.map +1 -0
  81. package/dist/core/config.js +187 -0
  82. package/dist/core/credentials-proxy.d.ts +157 -0
  83. package/dist/core/credentials-proxy.d.ts.map +1 -0
  84. package/dist/core/credentials-proxy.js +345 -0
  85. package/dist/core/credentials.d.ts +219 -0
  86. package/dist/core/credentials.d.ts.map +1 -0
  87. package/dist/core/credentials.js +345 -0
  88. package/dist/core/template-loader.d.ts +15 -0
  89. package/dist/core/template-loader.d.ts.map +1 -0
  90. package/dist/core/template-loader.js +380 -0
  91. package/dist/core/template.d.ts +321 -0
  92. package/dist/core/template.d.ts.map +1 -0
  93. package/dist/core/template.js +189 -0
  94. package/dist/core/types.d.ts +572 -0
  95. package/dist/core/types.d.ts.map +1 -0
  96. package/dist/core/types.js +52 -0
  97. package/dist/dev/dev-server.d.ts +16 -0
  98. package/dist/dev/dev-server.d.ts.map +1 -0
  99. package/dist/dev/dev-server.js +119 -0
  100. package/dist/generators/contracts/generator.d.ts +21 -0
  101. package/dist/generators/contracts/generator.d.ts.map +1 -0
  102. package/dist/generators/contracts/generator.js +252 -0
  103. package/dist/generators/tests/generator.d.ts +20 -0
  104. package/dist/generators/tests/generator.d.ts.map +1 -0
  105. package/dist/generators/tests/generator.js +375 -0
  106. package/dist/generators/types/generator.d.ts +19 -0
  107. package/dist/generators/types/generator.d.ts.map +1 -0
  108. package/dist/generators/types/generator.js +165 -0
  109. package/dist/generators/ui/component-generator.d.ts +20 -0
  110. package/dist/generators/ui/component-generator.d.ts.map +1 -0
  111. package/dist/generators/ui/component-generator.js +749 -0
  112. package/dist/generators/ui/dashboard-generator.d.ts +20 -0
  113. package/dist/generators/ui/dashboard-generator.d.ts.map +1 -0
  114. package/dist/generators/ui/dashboard-generator.js +349 -0
  115. package/dist/index.d.ts +61 -0
  116. package/dist/index.d.ts.map +1 -0
  117. package/dist/index.js +74 -0
  118. package/dist/modules/analytics/AnalyticsModule.d.ts +349 -0
  119. package/dist/modules/analytics/AnalyticsModule.d.ts.map +1 -0
  120. package/dist/modules/analytics/AnalyticsModule.js +274 -0
  121. package/dist/modules/analytics/index.d.ts +3 -0
  122. package/dist/modules/analytics/index.d.ts.map +1 -0
  123. package/dist/modules/analytics/index.js +1 -0
  124. package/dist/modules/auth/AccessKeyModule.d.ts +189 -0
  125. package/dist/modules/auth/AccessKeyModule.d.ts.map +1 -0
  126. package/dist/modules/auth/AccessKeyModule.js +322 -0
  127. package/dist/modules/auth/AuthModule.d.ts +133 -0
  128. package/dist/modules/auth/AuthModule.d.ts.map +1 -0
  129. package/dist/modules/auth/AuthModule.js +214 -0
  130. package/dist/modules/auth/index.d.ts +8 -0
  131. package/dist/modules/auth/index.d.ts.map +1 -0
  132. package/dist/modules/auth/index.js +6 -0
  133. package/dist/modules/cache/CacheModule.d.ts +279 -0
  134. package/dist/modules/cache/CacheModule.d.ts.map +1 -0
  135. package/dist/modules/cache/CacheModule.js +493 -0
  136. package/dist/modules/cache/index.d.ts +3 -0
  137. package/dist/modules/cache/index.d.ts.map +1 -0
  138. package/dist/modules/cache/index.js +1 -0
  139. package/dist/modules/compute/ComputeModule.d.ts +226 -0
  140. package/dist/modules/compute/ComputeModule.d.ts.map +1 -0
  141. package/dist/modules/compute/ComputeModule.js +379 -0
  142. package/dist/modules/compute/index.d.ts +6 -0
  143. package/dist/modules/compute/index.d.ts.map +1 -0
  144. package/dist/modules/compute/index.js +4 -0
  145. package/dist/modules/contracts/ContractsModule.d.ts +164 -0
  146. package/dist/modules/contracts/ContractsModule.d.ts.map +1 -0
  147. package/dist/modules/contracts/ContractsModule.js +242 -0
  148. package/dist/modules/contracts/index.d.ts +6 -0
  149. package/dist/modules/contracts/index.d.ts.map +1 -0
  150. package/dist/modules/contracts/index.js +4 -0
  151. package/dist/modules/export/ExportModule.d.ts +346 -0
  152. package/dist/modules/export/ExportModule.d.ts.map +1 -0
  153. package/dist/modules/export/ExportModule.js +432 -0
  154. package/dist/modules/export/index.d.ts +3 -0
  155. package/dist/modules/export/index.d.ts.map +1 -0
  156. package/dist/modules/export/index.js +1 -0
  157. package/dist/modules/forecasting/ForecastingModule.d.ts +579 -0
  158. package/dist/modules/forecasting/ForecastingModule.d.ts.map +1 -0
  159. package/dist/modules/forecasting/ForecastingModule.js +310 -0
  160. package/dist/modules/forecasting/index.d.ts +3 -0
  161. package/dist/modules/forecasting/index.d.ts.map +1 -0
  162. package/dist/modules/forecasting/index.js +1 -0
  163. package/dist/modules/monitoring/MonitoringModule.d.ts +359 -0
  164. package/dist/modules/monitoring/MonitoringModule.d.ts.map +1 -0
  165. package/dist/modules/monitoring/MonitoringModule.js +483 -0
  166. package/dist/modules/monitoring/index.d.ts +3 -0
  167. package/dist/modules/monitoring/index.d.ts.map +1 -0
  168. package/dist/modules/monitoring/index.js +1 -0
  169. package/dist/modules/notifications/NotificationsModule.d.ts +336 -0
  170. package/dist/modules/notifications/NotificationsModule.d.ts.map +1 -0
  171. package/dist/modules/notifications/NotificationsModule.js +418 -0
  172. package/dist/modules/notifications/index.d.ts +3 -0
  173. package/dist/modules/notifications/index.d.ts.map +1 -0
  174. package/dist/modules/notifications/index.js +1 -0
  175. package/dist/modules/oracle/OracleModule.d.ts +110 -0
  176. package/dist/modules/oracle/OracleModule.d.ts.map +1 -0
  177. package/dist/modules/oracle/OracleModule.js +151 -0
  178. package/dist/modules/oracle/index.d.ts +6 -0
  179. package/dist/modules/oracle/index.d.ts.map +1 -0
  180. package/dist/modules/oracle/index.js +4 -0
  181. package/dist/modules/storage/S3Module.d.ts +377 -0
  182. package/dist/modules/storage/S3Module.d.ts.map +1 -0
  183. package/dist/modules/storage/S3Module.js +680 -0
  184. package/dist/modules/storage/StorageModule.d.ts +157 -0
  185. package/dist/modules/storage/StorageModule.d.ts.map +1 -0
  186. package/dist/modules/storage/StorageModule.js +302 -0
  187. package/dist/modules/storage/adapters/AdapterFactory.d.ts +100 -0
  188. package/dist/modules/storage/adapters/AdapterFactory.d.ts.map +1 -0
  189. package/dist/modules/storage/adapters/AdapterFactory.js +209 -0
  190. package/dist/modules/storage/adapters/FilecoinAdapter.d.ts +94 -0
  191. package/dist/modules/storage/adapters/FilecoinAdapter.d.ts.map +1 -0
  192. package/dist/modules/storage/adapters/FilecoinAdapter.js +263 -0
  193. package/dist/modules/storage/adapters/IStorageAdapter.d.ts +287 -0
  194. package/dist/modules/storage/adapters/IStorageAdapter.d.ts.map +1 -0
  195. package/dist/modules/storage/adapters/IStorageAdapter.js +81 -0
  196. package/dist/modules/storage/adapters/MultiTierAdapter.d.ts +187 -0
  197. package/dist/modules/storage/adapters/MultiTierAdapter.d.ts.map +1 -0
  198. package/dist/modules/storage/adapters/MultiTierAdapter.js +430 -0
  199. package/dist/modules/storage/adapters/index.d.ts +12 -0
  200. package/dist/modules/storage/adapters/index.d.ts.map +1 -0
  201. package/dist/modules/storage/adapters/index.js +12 -0
  202. package/dist/modules/storage/index.d.ts +16 -0
  203. package/dist/modules/storage/index.d.ts.map +1 -0
  204. package/dist/modules/storage/index.js +15 -0
  205. package/dist/modules/storage/tiering/AccessAnalyzer.d.ts +227 -0
  206. package/dist/modules/storage/tiering/AccessAnalyzer.d.ts.map +1 -0
  207. package/dist/modules/storage/tiering/AccessAnalyzer.js +367 -0
  208. package/dist/modules/storage/tiering/CostOptimizer.d.ts +248 -0
  209. package/dist/modules/storage/tiering/CostOptimizer.d.ts.map +1 -0
  210. package/dist/modules/storage/tiering/CostOptimizer.js +356 -0
  211. package/dist/modules/storage/tiering/MetadataStore.d.ts +287 -0
  212. package/dist/modules/storage/tiering/MetadataStore.d.ts.map +1 -0
  213. package/dist/modules/storage/tiering/MetadataStore.js +535 -0
  214. package/dist/modules/storage/tiering/TieringEngine.d.ts +237 -0
  215. package/dist/modules/storage/tiering/TieringEngine.d.ts.map +1 -0
  216. package/dist/modules/storage/tiering/TieringEngine.js +419 -0
  217. package/dist/modules/storage/tiering/example.d.ts +8 -0
  218. package/dist/modules/storage/tiering/example.d.ts.map +1 -0
  219. package/dist/modules/storage/tiering/example.js +250 -0
  220. package/dist/modules/storage/tiering/index.d.ts +17 -0
  221. package/dist/modules/storage/tiering/index.d.ts.map +1 -0
  222. package/dist/modules/storage/tiering/index.js +13 -0
  223. package/dist/modules/webhooks/WebhooksModule.d.ts +476 -0
  224. package/dist/modules/webhooks/WebhooksModule.d.ts.map +1 -0
  225. package/dist/modules/webhooks/WebhooksModule.js +359 -0
  226. package/dist/modules/webhooks/index.d.ts +3 -0
  227. package/dist/modules/webhooks/index.d.ts.map +1 -0
  228. package/dist/modules/webhooks/index.js +1 -0
  229. package/dist/modules/zk/ZKModule.d.ts +153 -0
  230. package/dist/modules/zk/ZKModule.d.ts.map +1 -0
  231. package/dist/modules/zk/ZKModule.js +262 -0
  232. package/dist/modules/zk/index.d.ts +7 -0
  233. package/dist/modules/zk/index.d.ts.map +1 -0
  234. package/dist/modules/zk/index.js +4 -0
  235. package/dist/thirdweb/BridgeClient.d.ts +228 -0
  236. package/dist/thirdweb/BridgeClient.d.ts.map +1 -0
  237. package/dist/thirdweb/BridgeClient.js +160 -0
  238. package/dist/thirdweb/EngineClient.d.ts +396 -0
  239. package/dist/thirdweb/EngineClient.d.ts.map +1 -0
  240. package/dist/thirdweb/EngineClient.js +386 -0
  241. package/dist/thirdweb/GatewayClient.d.ts +190 -0
  242. package/dist/thirdweb/GatewayClient.d.ts.map +1 -0
  243. package/dist/thirdweb/GatewayClient.js +257 -0
  244. package/dist/thirdweb/NebulaClient.d.ts +292 -0
  245. package/dist/thirdweb/NebulaClient.d.ts.map +1 -0
  246. package/dist/thirdweb/NebulaClient.js +180 -0
  247. package/dist/thirdweb/StorageClient.d.ts +445 -0
  248. package/dist/thirdweb/StorageClient.d.ts.map +1 -0
  249. package/dist/thirdweb/StorageClient.js +405 -0
  250. package/dist/thirdweb/ThirdwebWrapper.d.ts +236 -0
  251. package/dist/thirdweb/ThirdwebWrapper.d.ts.map +1 -0
  252. package/dist/thirdweb/ThirdwebWrapper.js +332 -0
  253. package/dist/thirdweb/index.d.ts +21 -0
  254. package/dist/thirdweb/index.d.ts.map +1 -0
  255. package/dist/thirdweb/index.js +28 -0
  256. package/dist/thirdweb/varity-chain.d.ts +48 -0
  257. package/dist/thirdweb/varity-chain.d.ts.map +1 -0
  258. package/dist/thirdweb/varity-chain.js +64 -0
  259. package/dist/thirdweb/x402Client.d.ts +319 -0
  260. package/dist/thirdweb/x402Client.d.ts.map +1 -0
  261. package/dist/thirdweb/x402Client.js +223 -0
  262. package/dist/tracking/gasTracker.d.ts +158 -0
  263. package/dist/tracking/gasTracker.d.ts.map +1 -0
  264. package/dist/tracking/gasTracker.js +227 -0
  265. package/dist/tracking/index.d.ts +10 -0
  266. package/dist/tracking/index.d.ts.map +1 -0
  267. package/dist/tracking/index.js +8 -0
  268. package/dist/tracking/types.d.ts +327 -0
  269. package/dist/tracking/types.d.ts.map +1 -0
  270. package/dist/tracking/types.js +8 -0
  271. package/dist/ui/components/ChartWidget.d.ts +36 -0
  272. package/dist/ui/components/ChartWidget.d.ts.map +1 -0
  273. package/dist/ui/components/ChartWidget.js +82 -0
  274. package/dist/ui/components/DashboardLayout.d.ts +41 -0
  275. package/dist/ui/components/DashboardLayout.d.ts.map +1 -0
  276. package/dist/ui/components/DashboardLayout.js +102 -0
  277. package/dist/ui/components/DataTable.d.ts +49 -0
  278. package/dist/ui/components/DataTable.d.ts.map +1 -0
  279. package/dist/ui/components/DataTable.js +96 -0
  280. package/dist/ui/components/EntityForm.d.ts +60 -0
  281. package/dist/ui/components/EntityForm.d.ts.map +1 -0
  282. package/dist/ui/components/EntityForm.js +182 -0
  283. package/dist/ui/components/KPICard.d.ts +29 -0
  284. package/dist/ui/components/KPICard.d.ts.map +1 -0
  285. package/dist/ui/components/KPICard.js +61 -0
  286. package/dist/ui/components/Modal.d.ts +34 -0
  287. package/dist/ui/components/Modal.d.ts.map +1 -0
  288. package/dist/ui/components/Modal.js +30 -0
  289. package/dist/ui/components/index.d.ts +18 -0
  290. package/dist/ui/components/index.d.ts.map +1 -0
  291. package/dist/ui/components/index.js +11 -0
  292. package/dist/validation/template-validator.d.ts +25 -0
  293. package/dist/validation/template-validator.d.ts.map +1 -0
  294. package/dist/validation/template-validator.js +305 -0
  295. package/package.json +102 -0
@@ -0,0 +1,332 @@
1
+ /**
2
+ * Thirdweb Wrapper for Varity SDK
3
+ *
4
+ * This wrapper provides Thirdweb SDK v5 functionality while maintaining
5
+ * 100% backwards compatibility with existing ethers.js v6 implementation.
6
+ *
7
+ * Pattern: Optional enhancement layer - does NOT break existing functionality
8
+ */
9
+ import { createThirdwebClient, getContract as getThirdwebContract } from 'thirdweb';
10
+ import { deployContract as deployThirdwebContract } from 'thirdweb/deploys';
11
+ import { upload, download } from 'thirdweb/storage';
12
+ import { privateKeyToAccount } from 'thirdweb/wallets';
13
+ import { ethers } from 'ethers';
14
+ import { VARITY_TESTNET_RPC } from './varity-chain';
15
+ import { ChainRegistry, varityL3Testnet } from '../chains';
16
+ /**
17
+ * ThirdwebWrapper Class
18
+ *
19
+ * Provides Thirdweb SDK capabilities with ethers.js fallback.
20
+ * All existing ethers.js functionality is preserved.
21
+ */
22
+ export class ThirdwebWrapper {
23
+ constructor(config) {
24
+ // Determine chain
25
+ if (config.chain) {
26
+ if (typeof config.chain === 'number') {
27
+ // Chain ID provided - look up in registry
28
+ this.chain = ChainRegistry.getChain(config.chain);
29
+ this.chainId = config.chain;
30
+ }
31
+ else {
32
+ // Chain object provided directly
33
+ this.chain = config.chain;
34
+ this.chainId = config.chain.id;
35
+ }
36
+ }
37
+ else if (config.chainId) {
38
+ // Legacy chainId parameter (deprecated but supported)
39
+ console.warn('ThirdwebWrapper: chainId parameter is deprecated. Use chain parameter instead.');
40
+ this.chain = ChainRegistry.getChain(config.chainId);
41
+ this.chainId = config.chainId;
42
+ }
43
+ else {
44
+ // Default to Varity L3 Testnet
45
+ this.chain = varityL3Testnet;
46
+ this.chainId = varityL3Testnet.id;
47
+ }
48
+ // Initialize Thirdweb Client
49
+ const clientId = config.clientId || process.env.VARITY_THIRDWEB_CLIENT_ID || process.env.THIRDWEB_CLIENT_ID;
50
+ if (!clientId) {
51
+ throw new Error('Thirdweb Client ID required. Set VARITY_THIRDWEB_CLIENT_ID environment variable or pass clientId in config.');
52
+ }
53
+ this.client = createThirdwebClient({
54
+ clientId,
55
+ });
56
+ // Initialize account if private key provided
57
+ if (config.privateKey) {
58
+ this.account = privateKeyToAccount({
59
+ client: this.client,
60
+ privateKey: config.privateKey,
61
+ });
62
+ }
63
+ // Preserve ethers.js fallback with RPC from config or chain default
64
+ const rpcUrl = config.rpcUrl || this.chain.rpc || VARITY_TESTNET_RPC;
65
+ this.ethersProvider = new ethers.JsonRpcProvider(rpcUrl);
66
+ }
67
+ // ===== NEW: Thirdweb Methods =====
68
+ /**
69
+ * Get a contract instance using Thirdweb
70
+ * @param address Contract address
71
+ * @returns Thirdweb contract instance
72
+ */
73
+ async getContract(address) {
74
+ return getThirdwebContract({
75
+ client: this.client,
76
+ chain: this.chain,
77
+ address,
78
+ });
79
+ }
80
+ /**
81
+ * Deploy a contract using Thirdweb
82
+ * @param params Deployment parameters
83
+ * @returns Deployed contract address
84
+ */
85
+ async deployContract(params) {
86
+ if (!this.account) {
87
+ throw new Error('Account required for contract deployment. Provide privateKey in config.');
88
+ }
89
+ const address = await deployThirdwebContract({
90
+ client: this.client,
91
+ chain: this.chain,
92
+ account: this.account,
93
+ abi: params.abi, // Type cast to satisfy Thirdweb's strict typing
94
+ bytecode: params.bytecode,
95
+ constructorParams: params.constructorArgs || [],
96
+ });
97
+ return {
98
+ address,
99
+ deployed: true,
100
+ method: 'thirdweb',
101
+ transactionHash: address, // Thirdweb v5 returns address directly
102
+ };
103
+ }
104
+ /**
105
+ * Upload data to IPFS using Thirdweb Storage
106
+ * @param data Data to upload (can be JSON, File, or any supported type)
107
+ * @returns IPFS URI
108
+ */
109
+ async uploadToIPFS(data) {
110
+ const uri = await upload({
111
+ client: this.client,
112
+ files: [data],
113
+ });
114
+ return uri;
115
+ }
116
+ /**
117
+ * Download data from IPFS using Thirdweb Storage
118
+ * @param uri IPFS URI
119
+ * @returns Downloaded data
120
+ */
121
+ async downloadFromIPFS(uri) {
122
+ const data = await download({
123
+ client: this.client,
124
+ uri,
125
+ });
126
+ return data;
127
+ }
128
+ // ===== PRESERVED: Ethers.js Fallback Methods =====
129
+ /**
130
+ * Get the ethers.js provider (backwards compatibility)
131
+ * @returns Ethers JsonRpcProvider
132
+ */
133
+ getEthersProvider() {
134
+ return this.ethersProvider;
135
+ }
136
+ /**
137
+ * Get a contract instance using ethers.js (backwards compatibility)
138
+ * @param address Contract address
139
+ * @param abi Contract ABI
140
+ * @returns Ethers Contract instance
141
+ */
142
+ async getContractWithEthers(address, abi) {
143
+ return new ethers.Contract(address, abi, this.ethersProvider);
144
+ }
145
+ /**
146
+ * Deploy a contract using ethers.js (backwards compatibility)
147
+ * @param params Deployment parameters
148
+ * @returns Deployment result
149
+ */
150
+ async deployContractWithEthers(params) {
151
+ if (!this.account) {
152
+ throw new Error('Account required for contract deployment. Provide privateKey in config.');
153
+ }
154
+ const wallet = new ethers.Wallet(this.account.address, this.ethersProvider);
155
+ const factory = new ethers.ContractFactory(params.abi, params.bytecode, wallet);
156
+ const contract = await factory.deploy(...(params.constructorArgs || []));
157
+ await contract.waitForDeployment();
158
+ return {
159
+ address: await contract.getAddress(),
160
+ deployed: true,
161
+ method: 'ethers',
162
+ transactionHash: contract.deploymentTransaction()?.hash,
163
+ };
164
+ }
165
+ // ===== UTILITY METHODS =====
166
+ /**
167
+ * Get the Thirdweb client instance
168
+ * @returns Thirdweb client
169
+ */
170
+ getClient() {
171
+ return this.client;
172
+ }
173
+ /**
174
+ * Get the Thirdweb account (if configured)
175
+ * @returns Thirdweb account or undefined
176
+ */
177
+ getAccount() {
178
+ return this.account;
179
+ }
180
+ /**
181
+ * Get the chain configuration
182
+ * @returns Varity chain definition
183
+ */
184
+ getChain() {
185
+ return this.chain;
186
+ }
187
+ /**
188
+ * Get the chain ID
189
+ * @returns Chain ID (33529)
190
+ */
191
+ getChainId() {
192
+ return this.chainId;
193
+ }
194
+ /**
195
+ * Check if Thirdweb account is configured
196
+ * @returns True if account is available
197
+ */
198
+ hasAccount() {
199
+ return !!this.account;
200
+ }
201
+ // ===== HYBRID METHODS: Try Thirdweb, fallback to Ethers =====
202
+ /**
203
+ * Deploy contract with automatic fallback
204
+ * Tries Thirdweb first, falls back to ethers.js on error
205
+ * @param params Deployment parameters
206
+ * @returns Deployment result
207
+ */
208
+ async deployWithFallback(params) {
209
+ try {
210
+ return await this.deployContract(params);
211
+ }
212
+ catch (error) {
213
+ console.warn('Thirdweb deployment failed, falling back to ethers.js:', error);
214
+ return await this.deployContractWithEthers(params);
215
+ }
216
+ }
217
+ // ===== BLOCKCHAIN QUERY METHODS (using ethers.js) =====
218
+ /**
219
+ * Get contract events
220
+ * @param params Event query parameters
221
+ * @returns Contract events
222
+ */
223
+ async getContractEvents(params) {
224
+ // Use ethers.js to query events
225
+ const provider = this.ethersProvider;
226
+ const filter = {
227
+ address: params.contract.address,
228
+ fromBlock: params.fromBlock || 0,
229
+ toBlock: params.toBlock || 'latest',
230
+ };
231
+ const logs = await provider.getLogs(filter);
232
+ return logs;
233
+ }
234
+ /**
235
+ * Get block information
236
+ * @param blockNumber Block number or 'latest'
237
+ * @returns Block information
238
+ */
239
+ async getBlock(blockNumber) {
240
+ return await this.ethersProvider.getBlock(blockNumber);
241
+ }
242
+ /**
243
+ * Get transaction information
244
+ * @param hash Transaction hash
245
+ * @returns Transaction information
246
+ */
247
+ async getTransaction(hash) {
248
+ return await this.ethersProvider.getTransaction(hash);
249
+ }
250
+ /**
251
+ * Get current gas price
252
+ * @returns Gas price in wei
253
+ */
254
+ async getGasPrice() {
255
+ const feeData = await this.ethersProvider.getFeeData();
256
+ return feeData.gasPrice;
257
+ }
258
+ /**
259
+ * Get wallet balance
260
+ * @param address Wallet address
261
+ * @returns Balance in wei
262
+ */
263
+ async getBalance(address) {
264
+ return await this.ethersProvider.getBalance(address);
265
+ }
266
+ /**
267
+ * Get NFTs for a wallet
268
+ * @param address Wallet address
269
+ * @param options Query options
270
+ * @returns NFT list
271
+ */
272
+ async getNFTs(address, options) {
273
+ // TODO: Implement NFT querying using Thirdweb SDK or external API
274
+ // For now, return empty array as placeholder
275
+ console.warn('getNFTs not yet implemented, returning empty array');
276
+ return [];
277
+ }
278
+ /**
279
+ * Get transaction history for a wallet
280
+ * @param address Wallet address
281
+ * @param options Query options
282
+ * @returns Transaction history
283
+ */
284
+ async getTransactionHistory(address, options) {
285
+ // TODO: Implement transaction history using block explorer API
286
+ // For now, return empty array as placeholder
287
+ console.warn('getTransactionHistory not yet implemented, returning empty array');
288
+ return [];
289
+ }
290
+ /**
291
+ * Get token balances for a wallet
292
+ * @param address Wallet address
293
+ * @returns Token balances
294
+ */
295
+ async getTokenBalances(address) {
296
+ // TODO: Implement token balance querying using Thirdweb SDK or external API
297
+ // For now, return empty array as placeholder
298
+ console.warn('getTokenBalances not yet implemented, returning empty array');
299
+ return [];
300
+ }
301
+ /**
302
+ * Send transaction
303
+ * @param params Transaction parameters
304
+ * @returns Transaction result
305
+ */
306
+ async sendTransaction(params) {
307
+ if (!this.account) {
308
+ throw new Error('Account required for sending transactions. Provide privateKey in config.');
309
+ }
310
+ // Use ethers.js to send transaction
311
+ const wallet = new ethers.Wallet(this.account.address, this.ethersProvider);
312
+ const tx = await wallet.sendTransaction({
313
+ to: params.to,
314
+ value: ethers.parseEther(params.amount),
315
+ });
316
+ await tx.wait();
317
+ return {
318
+ transactionHash: tx.hash,
319
+ from: params.from,
320
+ to: params.to,
321
+ amount: params.amount,
322
+ };
323
+ }
324
+ }
325
+ /**
326
+ * Factory function to create ThirdwebWrapper instance
327
+ * @param config Configuration options
328
+ * @returns ThirdwebWrapper instance
329
+ */
330
+ export function createThirdwebWrapper(config) {
331
+ return new ThirdwebWrapper(config);
332
+ }
@@ -0,0 +1,21 @@
1
+ /**
2
+ * Varity SDK - thirdweb Integration Module
3
+ *
4
+ * Complete thirdweb v5 integration including:
5
+ * - ThirdwebWrapper for contract operations
6
+ * - Engine for production transaction management
7
+ * - Nebula AI for natural language blockchain
8
+ * - Storage for IPFS/Arweave
9
+ * - Bridge for cross-chain transfers
10
+ * - Gateway for RPC infrastructure
11
+ * - x402 for API monetization
12
+ */
13
+ export { ThirdwebWrapper, createThirdwebWrapper, type ThirdwebWrapperConfig, type DeployContractParams, } from './ThirdwebWrapper';
14
+ export { EngineClient, createEngineClient, parseEngineWebhook, verifyEngineWebhook, type EngineConfig, type EngineTransactionParams, type EngineTransactionStatus, type EngineTransactionResult, type EngineDeployParams, type EngineWebhookPayload, } from './EngineClient';
15
+ export { NebulaClient, createNebulaClient, type NebulaConfig, type GenerateContractOptions, type GeneratedContract, type QueryChainOptions, type QueryResult, type ExplainTransactionOptions, type TransactionExplanation, type GenerateCodeOptions, type GeneratedCode, type AnalyzeContractOptions, type ContractAnalysis, } from './NebulaClient';
16
+ export { StorageClient, createStorageClient, type StorageConfig, type ThirdwebUploadResult, type NFTMetadata, type BatchUploadItem, type BatchUploadResult, type ThirdwebDownloadOptions, type ImageOptimizationOptions, } from './StorageClient';
17
+ export { BridgeClient, createBridgeClient, type BridgeConfig, type AssetType, type BridgeRoute, type BridgeAssetParams, type BridgeStatus, type BridgeTransactionResult, type BridgeQuote, type BridgeHistoryEntry, } from './BridgeClient';
18
+ export { GatewayClient, createGatewayClient, type GatewayConfig, type RPCRequestOptions, type RPCResponse, type GatewayStats, type WebSocketOptions, } from './GatewayClient';
19
+ export { x402Client, createx402Client, x402Middleware, type x402Config, type PaymentEndpointConfig, type PaymentStats, type UsageRecord, type SubscriptionPlan, type Subscription, } from './x402Client';
20
+ export { varietyTestnet, getVarityChain, isVarityChain, VARITY_TESTNET_RPC, VARITY_CHAIN_METADATA, } from './varity-chain';
21
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/thirdweb/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAGH,OAAO,EACL,eAAe,EACf,qBAAqB,EACrB,KAAK,qBAAqB,EAC1B,KAAK,oBAAoB,GAC1B,MAAM,mBAAmB,CAAC;AAG3B,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,kBAAkB,EAClB,mBAAmB,EACnB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,uBAAuB,EAC5B,KAAK,kBAAkB,EACvB,KAAK,oBAAoB,GAC1B,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,iBAAiB,EACtB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,yBAAyB,EAC9B,KAAK,sBAAsB,EAC3B,KAAK,mBAAmB,EACxB,KAAK,aAAa,EAClB,KAAK,sBAAsB,EAC3B,KAAK,gBAAgB,GACtB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,uBAAuB,EAC5B,KAAK,wBAAwB,GAC9B,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,YAAY,EACZ,kBAAkB,EAClB,KAAK,YAAY,EACjB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,YAAY,EACjB,KAAK,uBAAuB,EAC5B,KAAK,WAAW,EAChB,KAAK,kBAAkB,GACxB,MAAM,gBAAgB,CAAC;AAGxB,OAAO,EACL,aAAa,EACb,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,iBAAiB,EACtB,KAAK,WAAW,EAChB,KAAK,YAAY,EACjB,KAAK,gBAAgB,GACtB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,KAAK,UAAU,EACf,KAAK,qBAAqB,EAC1B,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,gBAAgB,EACrB,KAAK,YAAY,GAClB,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,cAAc,EACd,cAAc,EACd,aAAa,EACb,kBAAkB,EAClB,qBAAqB,GACtB,MAAM,gBAAgB,CAAC"}
@@ -0,0 +1,28 @@
1
+ /**
2
+ * Varity SDK - thirdweb Integration Module
3
+ *
4
+ * Complete thirdweb v5 integration including:
5
+ * - ThirdwebWrapper for contract operations
6
+ * - Engine for production transaction management
7
+ * - Nebula AI for natural language blockchain
8
+ * - Storage for IPFS/Arweave
9
+ * - Bridge for cross-chain transfers
10
+ * - Gateway for RPC infrastructure
11
+ * - x402 for API monetization
12
+ */
13
+ // ThirdwebWrapper
14
+ export { ThirdwebWrapper, createThirdwebWrapper, } from './ThirdwebWrapper';
15
+ // Engine Client
16
+ export { EngineClient, createEngineClient, parseEngineWebhook, verifyEngineWebhook, } from './EngineClient';
17
+ // Nebula AI Client
18
+ export { NebulaClient, createNebulaClient, } from './NebulaClient';
19
+ // Storage Client
20
+ export { StorageClient, createStorageClient, } from './StorageClient';
21
+ // Bridge Client
22
+ export { BridgeClient, createBridgeClient, } from './BridgeClient';
23
+ // Gateway Client
24
+ export { GatewayClient, createGatewayClient, } from './GatewayClient';
25
+ // x402 Payment Protocol Client
26
+ export { x402Client, createx402Client, x402Middleware, } from './x402Client';
27
+ // Legacy chain export (backwards compatibility)
28
+ export { varietyTestnet, getVarityChain, isVarityChain, VARITY_TESTNET_RPC, VARITY_CHAIN_METADATA, } from './varity-chain';
@@ -0,0 +1,48 @@
1
+ /**
2
+ * Varity L3 Chain Definition for Thirdweb SDK v5
3
+ *
4
+ * Chain ID: 33529
5
+ * RPC: https://rpc-varity-testnet-rroe52pwjp.t.conduit.xyz
6
+ * Explorer: https://explorer-varity-testnet-rroe52pwjp.t.conduit.xyz
7
+ *
8
+ * CRITICAL: Native token is USDC with 6 decimals (NOT 18!)
9
+ */
10
+ /**
11
+ * Varity Testnet L3 Chain Configuration
12
+ * Built on Arbitrum Orbit framework
13
+ */
14
+ export declare const varietyTestnet: Readonly<import("thirdweb/chains").ChainOptions & {
15
+ rpc: string;
16
+ }>;
17
+ /**
18
+ * Varity Testnet RPC Configuration
19
+ */
20
+ export declare const VARITY_TESTNET_RPC = "https://rpc-varity-testnet-rroe52pwjp.t.conduit.xyz";
21
+ /**
22
+ * Varity Chain Metadata
23
+ */
24
+ export declare const VARITY_CHAIN_METADATA: {
25
+ chainId: number;
26
+ chainName: string;
27
+ rpcUrl: string;
28
+ explorerUrl: string;
29
+ nativeToken: {
30
+ name: string;
31
+ symbol: string;
32
+ decimals: number;
33
+ };
34
+ isTestnet: boolean;
35
+ l1Chain: string;
36
+ framework: string;
37
+ };
38
+ /**
39
+ * Helper function to get chain configuration
40
+ */
41
+ export declare function getVarityChain(): Readonly<import("thirdweb/chains").ChainOptions & {
42
+ rpc: string;
43
+ }>;
44
+ /**
45
+ * Helper function to validate chain ID
46
+ */
47
+ export declare function isVarityChain(chainId: number): boolean;
48
+ //# sourceMappingURL=varity-chain.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"varity-chain.d.ts","sourceRoot":"","sources":["../../src/thirdweb/varity-chain.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAIH;;;GAGG;AACH,eAAO,MAAM,cAAc;;EAgBzB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB,wDAAwD,CAAC;AAExF;;GAEG;AACH,eAAO,MAAM,qBAAqB;;;;;;;;;;;;;CAajC,CAAC;AAEF;;GAEG;AACH,wBAAgB,cAAc;;GAE7B;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAEtD"}
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Varity L3 Chain Definition for Thirdweb SDK v5
3
+ *
4
+ * Chain ID: 33529
5
+ * RPC: https://rpc-varity-testnet-rroe52pwjp.t.conduit.xyz
6
+ * Explorer: https://explorer-varity-testnet-rroe52pwjp.t.conduit.xyz
7
+ *
8
+ * CRITICAL: Native token is USDC with 6 decimals (NOT 18!)
9
+ */
10
+ import { defineChain } from 'thirdweb/chains';
11
+ /**
12
+ * Varity Testnet L3 Chain Configuration
13
+ * Built on Arbitrum Orbit framework
14
+ */
15
+ export const varietyTestnet = defineChain({
16
+ id: 33529,
17
+ name: 'Varity Testnet',
18
+ nativeCurrency: {
19
+ name: 'USDC',
20
+ symbol: 'USDC',
21
+ decimals: 6, // CRITICAL: 6 decimals, not 18!
22
+ },
23
+ blockExplorers: [
24
+ {
25
+ name: 'Varity Explorer',
26
+ url: 'https://explorer-varity-testnet-rroe52pwjp.t.conduit.xyz',
27
+ apiUrl: 'https://explorer-varity-testnet-rroe52pwjp.t.conduit.xyz/api',
28
+ },
29
+ ],
30
+ testnet: true,
31
+ });
32
+ /**
33
+ * Varity Testnet RPC Configuration
34
+ */
35
+ export const VARITY_TESTNET_RPC = 'https://rpc-varity-testnet-rroe52pwjp.t.conduit.xyz';
36
+ /**
37
+ * Varity Chain Metadata
38
+ */
39
+ export const VARITY_CHAIN_METADATA = {
40
+ chainId: 33529,
41
+ chainName: 'Varity Testnet',
42
+ rpcUrl: VARITY_TESTNET_RPC,
43
+ explorerUrl: 'https://explorer-varity-testnet-rroe52pwjp.t.conduit.xyz',
44
+ nativeToken: {
45
+ name: 'USDC',
46
+ symbol: 'USDC',
47
+ decimals: 6,
48
+ },
49
+ isTestnet: true,
50
+ l1Chain: 'Arbitrum One',
51
+ framework: 'Arbitrum Orbit',
52
+ };
53
+ /**
54
+ * Helper function to get chain configuration
55
+ */
56
+ export function getVarityChain() {
57
+ return varietyTestnet;
58
+ }
59
+ /**
60
+ * Helper function to validate chain ID
61
+ */
62
+ export function isVarityChain(chainId) {
63
+ return chainId === 33529;
64
+ }