Commit c057e86
authored
Buy credits (#506)
* Create Auto-Drive Treasury Contracts (Buy Credits PR #1) (#485)
* Create auto drive treasury contracts
* Refactor AutoDriveTreasury contract to use msg.sender instead of tx.origin for fund transfers
* Add receive function to CounterTest contract for handling incoming Ether
* Remove references to Counter contract
* Implement treasury target instead of withdrawing functionality
* Add Pausable functionality to AutoDriveCreditsReceiver contract
* Add AutoDriveCreditsReceiver contract with deposit and treasury management functionality
* Rename Deposit event to IntentPaymentReceived in AutoDriveCreditsReceiver contract for clarity
* Move contracts docs to package root
* Add treasure address to SweptToTreasury event
* Rename deposit function to payIntent in AutoDriveCreditsReceiver contract and add validation for positive payment amounts.
* Init contract state in constructor
* Update AutoDriveCreditsReceiver tests to include treasury address in constructor and remove redundant initializations
* Add minimum balance feature to AutoDriveCreditsReceiver contract and update tests accordingly
* Refactor error handling in AutoDriveCreditsReceiver contract to use custom errors for validation checks and update tests accordingly
* Make contract doc the package README
* Add treasury receivable validation
* Rename testDeposit function to testPayIntent in AutoDriveCreditsReceiver test for clarity
* Remove references to deposit
* Refactor constructor in AutoDriveCreditsReceiver to use setTreasury function for treasury initialization
* Update AutoDriveCreditsReceiver to set a default minimum balance and simplify constructor parameters; adjust tests accordingly.
* Update readme with correct events & methods interface
* Buy credits backend (Buy Credits PR #2) (#486)
* feat: enable admins to update granularity
* feat: add intent model with schema validation and export in user module
* feat: implement intents management with creation, updating, and confirmation logic in user module
* feat: filter logs by contract address in payment manager
* feat: normalize deposit amount in payment manager transaction confirmation
* feat: add price retrieval endpoint and integrate price per MB configuration
* feat: implement payments management with intent creation, confirmation, and credit allocation logic
* fix: update intent credits retrieval and normalize deposit amount in payment manager
* feat: add tests for adding credits to OneOff subscriptions and handling errors for non-OneOff subscriptions
* feat: enhance intent management by adding price per MB handling in tests, database, and business logic
* chore: remove console log
* fix: correct error message for incomplete intent status
* refactor: re-enable task manager and object mapping archiver event listeners in frontendWorker
* feat: add price per MB to intent creation in database schema
* refactor: remove intent expiration handling from API and backend logic
* refactor: remove expires_at field from intents table and update related query
* test: enhance folder upload tests with additional rabbitMock expectations
* fix: handle errors when watching transactions in payment manager
* refactor: update deposit event ABI and related payment handling in payment manager
* refactor: rename deposit_amount to payment_amount in intents schema and related logic
* refactor: remove intentId from task parameters and related intent handling
* fix: update intent price per mb
* refactor: update getIntent function to include user validation and adjust related intent retrieval logic
* refactor: change payment_amount type from VARCHAR to numeric in intents table
* feat: dynamic price fixing using current transaction byte price
* feat: add premium percentage configuration and adjust price calculation in intents
* refactor: rename premiumPct to priceMultiplier and update price calculation in intents
* refactor: update priceMultiplier configuration to use CREDITS_PRICE_MULTIPLIER environment variable
* feat: implement buy credits into frontend (Buy Credits PR #3) (#495)
* feat: enable admins to update granularity
* feat: add intent model with schema validation and export in user module
* feat: implement intents management with creation, updating, and confirmation logic in user module
* feat: filter logs by contract address in payment manager
* feat: normalize deposit amount in payment manager transaction confirmation
* feat: add price retrieval endpoint and integrate price per MB configuration
* feat: implement payments management with intent creation, confirmation, and credit allocation logic
* fix: update intent credits retrieval and normalize deposit amount in payment manager
* feat: add tests for adding credits to OneOff subscriptions and handling errors for non-OneOff subscriptions
* feat: enhance intent management by adding price per MB handling in tests, database, and business logic
* chore: remove console log
* fix: correct error message for incomplete intent status
* refactor: re-enable task manager and object mapping archiver event listeners in frontendWorker
* feat: add price per MB to intent creation in database schema
* refactor: remove intent expiration handling from API and backend logic
* refactor: remove expires_at field from intents table and update related query
* test: enhance folder upload tests with additional rabbitMock expectations
* fix: handle errors when watching transactions in payment manager
* refactor: update deposit event ABI and related payment handling in payment manager
* refactor: rename deposit_amount to payment_amount in intents schema and related logic
* refactor: remove intentId from task parameters and related intent handling
* fix: update intent price per mb
* refactor: update getIntent function to include user validation and adjust related intent retrieval logic
* refactor: change payment_amount type from VARCHAR to numeric in intents table
* feat: dynamic price fixing using current transaction byte price
* feat: add premium percentage configuration and adjust price calculation in intents
* refactor: rename premiumPct to priceMultiplier and update price calculation in intents
* refactor: update priceMultiplier configuration to use CREDITS_PRICE_MULTIPLIER environment variable
* feat: purchase credits flow with new components, steps, and price handling
* refactor: update price formatting functions to handle credits in MB and adjust related components
* refactor: replace deposit hook with payment intent hook and update transaction handling in Step3_TransferTokens component
* refactor: update price fetching logic to use kraken's API
* Update local network configuration to use Chronos Testnet with new chain ID and native currency details
* Enhance PurchaseStep3TransferTokens component by adding formatCreditsInMbAsValue function for improved credit formatting and updating payment intent handling. Added error logging for payment intent failures.
* Update to new contract interface
* Map BigInt to serializable values
* Remove unused case for TAURUS in FilePreview component's network ID handling
* Refactor price calculation in usePrices hook to use fixed-point arithmetic for improved precision in byte-to-value conversions.
* Update PurchaseStep4Success component to remove unused network context and display storage size in MB instead of a fixed value.
* Add BuyMoreCreditsButton component for purchasing credits with network context integration
* Update native currency details in evm.ts to reflect new currency name and symbol
* Update paymentReceiverContractsByNetworkId to include TODOs for removing TAURUS and deploying the MAINNET contract
* Enhance AccountInformation and PurchaseStep2ConnectWallet components by improving byte formatting with decimal precision and adding a utility function for truncating numbers with decimals.
* Extract to hook purchase credits confirmation
* Extract to hook deposit awaiting logic and added to `usePayIntent` minimum confirmations constant
* Refactor byte formatting in AccountInformation component to use truncateBytes utility for improved readability and consistency.
* Buy credits feature flagging (#5) (#501)
* Refactor former services param for features flags
* refactor: restructure feature flags configuration
- Move feature flags under 'flags' property for better organization
- Add buyCredits feature flag with employeeOnly option
- Add employeeDomains configuration
- Move taskManagerMaxRetries to params section
- Update feature flags structure for better maintainability
* feat: add feature flags controller and business logic
- Create featuresController with GET /features endpoint
- Add FeatureFlagsUseCases with user-based feature flag logic
- Implement employee domain checking for feature access
- Add authentication-aware feature flag resolution
* refactor: replace inline features endpoint with controller
- Remove inline /features endpoints from download and frontend APIs
- Add featuresController to both API servers
- Centralize feature flags logic in dedicated controller
* refactor: update worker to use new feature flags structure
- Update frontendWorker to use config.featureFlags.flags
- Move taskManagerMaxRetries reference to config.params
- Maintain backward compatibility with existing functionality
* feat: add frontend feature flags support
- Add features state to user store
- Add getFeatures API method with authentication
- Implement feature flags fetching in SessionEnsurer
- Support for user-specific feature flag resolution
* feat: add conditional buy credits UI based on feature flags
- Create AskForCreditsButton component for non-employee users
- Update SideNavBar to conditionally show BuyMoreCreditsButton or AskForCreditsButton
- Implement feature flag-based UI rendering for credit purchasing
* feat: integrate feature flags fetching in SessionEnsurer
- Add setFeatures to SessionEnsurer component
- Fetch and store feature flags on component mount
- Enable feature flag-based UI rendering throughout the app
* feat: implement feature flag middleware and enhance features controller
- Add featureFlagMiddleware to conditionally enable routes based on feature flags
- Update intentsController to use feature flag for 'buyCredits' feature
- Refactor featuresController to fetch feature flags and respond accordingly
- Introduce getFeatureFlags function for user-specific feature flag retrieval
* Rename employee to staff
* Separate domain allowlist & usernames allowlist
* fix: update feature flag retrieval to check for authorization header
- Modify getFeatureFlags function to ensure user authentication by checking for the presence of the authorization header in the request.
* Update staff naming in FeatureFlag model
* fix: normalize username case in staff username validation
* fix: normalize case for staff usernames and domains in configuration
* fix: improve error handling in getFeatures API method
* fix: update buyCredits feature flag condition to include staffOnly flag
- Modify the condition to start the payment manager to check for both buyCredits and staffOnly feature flags.
* Add mainnet's contract address (#505)
* fix: errors during branch merge
* Update .env.test to include EVM_CHAIN_ENDPOINT variable
* Update .env.test to include EVM_CHAIN_CONTRACT_ADDRESS variable1 parent bd76f9c commit c057e86
File tree
70 files changed
+5573
-2316
lines changed- apps
- backend
- __tests__
- e2e
- uploads
- users
- unit/useCases
- migrations
- sqls
- src
- app
- apis
- controllers
- servers
- core
- featureFlags
- users
- infrastructure
- eventRouter
- processors
- repositories/users
- services/paymentManager
- frontend
- src
- app/[chain]/drive/purchase
- components
- atoms
- molecules/AccountInformation
- views
- AdminPanel
- PurchaseCredits
- atoms
- molecules
- steps
- contexts
- globalStates
- hooks
- services
- utils
- packages
- contracts
- .github/workflows
- lib
- src
- test
- models/src/users
- ui
- src
- constants
- utils
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
70 files changed
+5573
-2316
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
6 | 6 | | |
7 | 7 | | |
8 | 8 | | |
9 | | - | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
300 | 300 | | |
301 | 301 | | |
302 | 302 | | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
303 | 319 | | |
304 | 320 | | |
305 | 321 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
2 | 6 | | |
3 | 7 | | |
4 | 8 | | |
| |||
8 | 12 | | |
9 | 13 | | |
10 | 14 | | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
11 | 18 | | |
12 | 19 | | |
13 | 20 | | |
| |||
67 | 74 | | |
68 | 75 | | |
69 | 76 | | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
70 | 124 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| 219 | + | |
| 220 | + | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
0 commit comments