Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: database structure #80

Merged
merged 6 commits into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions docs/DATABASE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
Plan is to update the database scheme in a way that it will support the requirements we have as for the API specs and additional improvements of the deamon.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are these things derived from API? Please indicate if something is different from types defined there, ideally these should be as similar as possible, but deviations are ok where they make sense

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Addressed in c69aa99


## Tables
### Orders (`orders`)
- order - String: order identifier provided by the frontend
- payment_status - Enum: (pending|paid|timed_out).
- withdrawal_status - Enum: (waiting|failed|completed|forced|none).
- amount - u128: Order amount
- currency - String: Currency ticker ("DOT"|"USDC"|...).
- callback: String: Callback url for frontend order status update
- payment_account: [u8; 32]: Derived address for this order.
- recipient: [u8; 32]: Address that will receive the payout once the order is fulfilled.
- message: String|null: Optional parameter for failed orders.
- payment_page: String|null: Optional parameter for the frontend to redirect to a payment page.
- redirect_url: String|null: Optional parameter for the frontend to redirect once the order is repaid.
- death: u32: Expiry timestamp for the order.

### Transactions (`transactions`)
- transaction_id - unique id generated by us to allow linking transaction to order
- order - String: order id to link transaction to order
Vovke marked this conversation as resolved.
Show resolved Hide resolved
- chain - String: identifier for the chain where transaction occurred
- block_number - Integer: Block number where the transaction is recorded.
- position_in_block - Integer: Position of the transaction within the block.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we might also (later?) want to store the block for which transaction was submitted. It is included into saved transaction bytes though, so maybe not

- timestamp - Timestamp: Timestamp of the transaction.
- transaction_bytes - String: Raw transaction data.
- sender - String: Address sending the transaction.
- recipient - String: Address receiving the transaction.
- amount - Float: transaction amount
- currency: String: Transaction currency
- type - Enum: Transaction type (payment|withdrawal) to distinguish between internal (withdrawal) and external (payment) transactions
- status - Enum: Transaction status (pending|finalized|failed).
Vovke marked this conversation as resolved.
Show resolved Hide resolved

### Instance Metadata (`instance_info`)
- instance_id - String: instance id randomly generated, happy-octopus or similar shit
- version - String: daemon version (storing it just for consistency with ServerInfo struct)
- debug - String: Debug toggle
- kalatori_remark: String: Environment specific something, can be used for whatever
Loading