From 506496c66a06de2f91de99cbf48154e3c5c122ee Mon Sep 17 00:00:00 2001 From: Vova Lando Date: Thu, 10 Oct 2024 11:10:36 +0300 Subject: [PATCH 1/5] docs: database structure --- docs/DATABASE.md | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 docs/DATABASE.md diff --git a/docs/DATABASE.md b/docs/DATABASE.md new file mode 100644 index 0000000..5006ba5 --- /dev/null +++ b/docs/DATABASE.md @@ -0,0 +1,32 @@ +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. + +## Tables +### Orders (`orders`) +- order - String: order identifier provided by the frontend +- payment_status - Enum: (pending|paid|timed_out). +- withdrawal_status - Enum: (waiting|failed|completed|none). +- amount - Float: Order amount +- currency - String: Currency ticker ("DOT"|"USDC"|...). +- callback: String: Callback url for frontend order status update +- payment_account: Derived address for this order. +- recipient: Address that will receive the payout once the order is fulfilled. +- death: Expiry timestamp for the order. + +### Transactions (`transactions`) +- order - String: order id to link transaction to order +- chain - String: identifier for the chain where transaction occured +- block_nmber - Integer: Block number where the transaction is recorded. +- position_in_block - Integer: Position of the transaction within the block. +- 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 +- status - Enum: Transaction status (pending|finalized|failed). + +### 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 From c69aa99b6747242f1a30f2348185c35d147486d8 Mon Sep 17 00:00:00 2001 From: Vova Lando Date: Thu, 10 Oct 2024 21:42:55 +0300 Subject: [PATCH 2/5] chore: Additional state for withdrawal, more fields from the API spec --- docs/DATABASE.md | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/docs/DATABASE.md b/docs/DATABASE.md index 5006ba5..3e664aa 100644 --- a/docs/DATABASE.md +++ b/docs/DATABASE.md @@ -8,14 +8,17 @@ Plan is to update the database scheme in a way that it will support the requirem - amount - Float: Order amount - currency - String: Currency ticker ("DOT"|"USDC"|...). - callback: String: Callback url for frontend order status update -- payment_account: Derived address for this order. -- recipient: Address that will receive the payout once the order is fulfilled. -- death: Expiry timestamp for the order. +- payment_account: String: Derived address for this order. +- recipient: String: 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: Timestamp: Expiry timestamp for the order. ### Transactions (`transactions`) - order - String: order id to link transaction to order -- chain - String: identifier for the chain where transaction occured -- block_nmber - Integer: Block number where the transaction is recorded. +- 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. - timestamp - Timestamp: Timestamp of the transaction. - transaction_bytes - String: Raw transaction data. From 8f16f106683802d7258d53a1cf104ab0b6ba94fa Mon Sep 17 00:00:00 2001 From: Vova Lando Date: Thu, 10 Oct 2024 21:56:19 +0300 Subject: [PATCH 3/5] chore: missing state for failed withdrawal --- docs/DATABASE.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/DATABASE.md b/docs/DATABASE.md index 3e664aa..7adc5ad 100644 --- a/docs/DATABASE.md +++ b/docs/DATABASE.md @@ -4,7 +4,7 @@ Plan is to update the database scheme in a way that it will support the requirem ### Orders (`orders`) - order - String: order identifier provided by the frontend - payment_status - Enum: (pending|paid|timed_out). -- withdrawal_status - Enum: (waiting|failed|completed|none). +- withdrawal_status - Enum: (waiting|failed|completed|forced|none). - amount - Float: Order amount - currency - String: Currency ticker ("DOT"|"USDC"|...). - callback: String: Callback url for frontend order status update From 23bed58b0719015b03c1b0d9c45ad20c20891393 Mon Sep 17 00:00:00 2001 From: Vova Lando Date: Mon, 21 Oct 2024 13:46:40 +0300 Subject: [PATCH 4/5] chore: Apply suggestions from code review --- docs/DATABASE.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/DATABASE.md b/docs/DATABASE.md index 7adc5ad..2c9c352 100644 --- a/docs/DATABASE.md +++ b/docs/DATABASE.md @@ -5,15 +5,15 @@ Plan is to update the database scheme in a way that it will support the requirem - order - String: order identifier provided by the frontend - payment_status - Enum: (pending|paid|timed_out). - withdrawal_status - Enum: (waiting|failed|completed|forced|none). -- amount - Float: Order amount +- amount - u128: Order amount - currency - String: Currency ticker ("DOT"|"USDC"|...). - callback: String: Callback url for frontend order status update -- payment_account: String: Derived address for this order. -- recipient: String: Address that will receive the payout once the order is fulfilled. +- 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: Timestamp: Expiry timestamp for the order. +- death: u32: Expiry timestamp for the order. ### Transactions (`transactions`) - order - String: order id to link transaction to order From a99e0019d9e8958f41e2a29eed681ec22971620d Mon Sep 17 00:00:00 2001 From: Vova Lando Date: Tue, 22 Oct 2024 12:52:42 +0300 Subject: [PATCH 5/5] Apply suggestions from code review --- docs/DATABASE.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/docs/DATABASE.md b/docs/DATABASE.md index 2c9c352..00bac1d 100644 --- a/docs/DATABASE.md +++ b/docs/DATABASE.md @@ -16,6 +16,7 @@ Plan is to update the database scheme in a way that it will support the requirem - 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 - chain - String: identifier for the chain where transaction occurred - block_number - Integer: Block number where the transaction is recorded. @@ -26,6 +27,7 @@ Plan is to update the database scheme in a way that it will support the requirem - 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). ### Instance Metadata (`instance_info`)