voucher-data #138

Merged
lash merged 18 commits from voucher-data into master 2024-10-31 13:44:19 +01:00
Member
  • Store the voucher contract address and decimals, ahead of send vouchers update
- Store the voucher contract address and decimals, ahead of send vouchers update
Alfred-mk added 2 commits 2024-10-25 16:39:19 +02:00
Alfred-mk added 1 commit 2024-10-28 09:08:34 +01:00
Alfred-mk added 1 commit 2024-10-28 09:20:13 +01:00
Alfred-mk added 4 commits 2024-10-28 14:31:05 +01:00
Alfred-mk changed title from WIP: voucher-data to voucher-data 2024-10-28 14:31:42 +01:00
Alfred-mk requested review from lash 2024-10-28 16:27:38 +01:00
Alfred-mk changed title from voucher-data to WIP: voucher-data 2024-10-28 16:34:36 +01:00
Alfred-mk added 1 commit 2024-10-28 16:40:51 +01:00
Alfred-mk changed title from WIP: voucher-data to voucher-data 2024-10-28 16:41:26 +01:00
lash requested changes 2024-10-29 12:56:17 +01:00
@ -59,2 +59,4 @@
}
// VoucherMetadata helps organize voucher data fields
type VoucherMetadata struct {
Owner

Should we use ussd-data-service/pkg/api/api.go TokenHoldings instead?

Should we use ussd-data-service/pkg/api/api.go TokenHoldings instead?
Author
Member

This is actually a struct for the strings that are returned as formatted values, to be stored in the subPrefixDb

For example
data := VoucherMetadata{
Symbols: "1:SRF\n2:MILO",
Balances: "1:100\n2:200",
Decimals: "1:6\n2:4",
Addresses: "1:0xd4c288865Ce\n2:0x41c188d63Qa",
}

This is actually a struct for the strings that are returned as formatted values, to be stored in the subPrefixDb For example data := VoucherMetadata{ Symbols: "1:SRF\n2:MILO", Balances: "1:100\n2:200", Decimals: "1:6\n2:4", Addresses: "1:0xd4c288865Ce\n2:0x41c188d63Qa", }
Alfred-mk marked this conversation as resolved
@ -1126,2 +1140,3 @@
func ProcessVouchers(holdings []struct {
// processVouchers converts holdings into formatted strings
func processVouchers(holdings []struct {
ContractAddress string `json:"contractAddress"`
Owner

this is now the same struct as VoucherMetadata can we consolidate please?

this is now the same struct as `VoucherMetadata` can we consolidate please?
Alfred-mk marked this conversation as resolved
@ -1222,2 +1217,2 @@
symbols := strings.Split(voucherSymbols, "\n")
balances := strings.Split(voucherBalances, "\n")
// getVoucherData retrieves and matches voucher data
func getVoucherData(ctx context.Context, db storage.PrefixDb, input string) (*VoucherMetadata, error) {
Owner

This file is getting long. SHould we extract the voucher related methods to a separate file?

This file is getting long. SHould we extract the voucher related methods to a separate file?
Alfred-mk marked this conversation as resolved
Alfred-mk added 2 commits 2024-10-29 22:53:23 +01:00
Alfred-mk changed title from voucher-data to WIP: voucher-data 2024-10-30 12:13:15 +01:00
Alfred-mk added 1 commit 2024-10-30 12:13:59 +01:00
Alfred-mk added 2 commits 2024-10-30 16:31:01 +01:00
Alfred-mk added 1 commit 2024-10-30 16:40:08 +01:00
Alfred-mk added 1 commit 2024-10-30 16:46:31 +01:00
Alfred-mk changed title from WIP: voucher-data to voucher-data 2024-10-30 16:46:49 +01:00
Alfred-mk requested review from lash 2024-10-30 16:46:54 +01:00
lash reviewed 2024-10-30 19:37:56 +01:00
@ -0,0 +77,4 @@
for i, sym := range symList {
parts := strings.SplitN(sym, ":", 2)
if len(parts) != 2 {
Owner

When will this condition occur?

When will this condition occur?
Author
Member

It will only occur if the string is not well formatted in the "1:SRF" format, such as it being "1SRF" or "1 SRF"

Ideally, this will not be encountered but I added this as an edge case in the unlikely event that it does

It will only occur if the string is not well formatted in the "1:SRF" format, such as it being "1SRF" or "1 SRF" Ideally, this will not be encountered but I added this as an edge case in the unlikely event that it does
Owner

but shouldnt that raise an error, as it should never happen?

but shouldnt that raise an error, as it should never happen?
Author
Member

On further assessment, I see it best to remove the code as the condition would never occur.

The data being matched comes from the db, and for this condition to occur means an issue lies with the functions that process and store the data

On further assessment, I see it best to remove the code as the condition would never occur. The data being matched comes from the db, and for this condition to occur means an issue lies with the functions that process and store the data
Alfred-mk marked this conversation as resolved
@ -0,0 +154,4 @@
}
// Clear temporary voucher data entries
tempEntries := map[DataTyp][]byte{
Owner

Do we need to clear them here? Can't we just overwrite later?

Do we need to clear them here? Can't we just overwrite later?
Author
Member

They can be left and overwritten with any new temporary data

I wanted to work on this functionality on a different PR, where we'll make use of a single temporary data row

They can be left and overwritten with any new temporary data I wanted to work on this functionality on a different PR, where we'll make use of a single temporary data row
Owner

ok just drop the lines then?

ok just drop the lines then?
Alfred-mk marked this conversation as resolved
Alfred-mk added 1 commit 2024-10-31 12:26:34 +01:00
Alfred-mk added 1 commit 2024-10-31 12:44:48 +01:00
lash merged commit 074345fcf9 into master 2024-10-31 13:44:19 +01:00
Sign in to join this conversation.
No reviewers
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: urdt/ussd#138
No description provided.