Initial commit
This commit is contained in:
29
docs/zagros/deposit/collection-fee.md
Normal file
29
docs/zagros/deposit/collection-fee.md
Normal file
@@ -0,0 +1,29 @@
|
||||
# Blockchain Collection fee
|
||||
[please read first](daemon.md)
|
||||
|
||||
### files:
|
||||
- {$Dena_path}/app/workers/daemons/deposit.rb
|
||||
- {$Dena_path}/app/services/wallet_service.rb
|
||||
|
||||
### implementation
|
||||
during blockchain deposit daemon, WalletService asks its Adapter (by passing The relevant deposit wallet) that the `prepare_deposit_collection!` method was implemented or not.<br />
|
||||
if not, the daemon kept continues its process, but if that method existed in the coin Adapter, the deposit daemon call the `collect_fee` method on the deposit DB record.<br />
|
||||
|
||||
#### collect_fee function
|
||||
1. Check the spread column of the deposit to find was filled or not. if not call `spread_between_wallets!` from the Deposit model.
|
||||
2. Active relevant fee wallet will be found from DB. if not found, we will back to the deposit daemon process.
|
||||
3. Create WalletService object by passing active fee wallet and run `deposit_collection_fees!` method on the deposit record.
|
||||
4. `deposit_collection_fees` method, run `prepare_deposit_collection`
|
||||
5. `prepare_deposit_collection` method will have a unique implementation for each coin (blockchain),but eventually, the output must be a transaction that in addition to sending into the relevant blockchain, also will be saved in the local DB.
|
||||
6. Change the state column of the deposit record from `processing` to `fee_processing`
|
||||
|
||||
```mermaid
|
||||
graph TD
|
||||
A((Depoist Daemon)) -->|deposit record| B[WalletService ]
|
||||
B --> |the Depoist Wallet Record| C{Adapter}
|
||||
C --> |`prepare_deposit_collection` is not impelemented |A
|
||||
C --> |`prepare_deposit_collection` is impelemented| E(WalletService)
|
||||
E --> |the Fee Wallet Record| C
|
||||
C --> D(`deposit_collection_fees!`)
|
||||
D --> |change state to fee_processing|A
|
||||
```
|
||||
Reference in New Issue
Block a user