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

Add functions to create and handle UMA invoices. #39

Merged
merged 1 commit into from
Jul 16, 2024

Conversation

zhenlu
Copy link
Contributor

@zhenlu zhenlu commented Jul 15, 2024

No description provided.

@zhenlu zhenlu requested review from jklein24 and shreyav July 15, 2024 22:14
@zhenlu zhenlu force-pushed the 07-15-add_functions_to_create_and_handle_uma_invoices branch from d4edaee to 03bd8e0 Compare July 15, 2024 22:15
uma/uma.go Outdated
invoiceLimit *uint64,
senderUma *string,
signingPrivateKey []byte,
) (string, error) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we be returning a string here or the invoice object directly?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed to object

@@ -1011,3 +1020,64 @@ func VerifyPostTransactionCallbackSignature(
}
return verifySignature(*signablePayload, *callback.Signature, otherVaspPubKeyResponse)
}

func CreateUmaInvoice(
Copy link
Collaborator

Choose a reason for hiding this comment

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

I know we did things this way elsewhere in the uma go SDK, but I'm wondering if there are better object creation conventions in Go (I didn't really know Go well when I was making this sdk). For example, I've noticed that most libraries use the New* naming convention, like NewUmaInvoice. I'm also wondering if it would make sense to have an options struct for the optional args, kind of like this article suggests. Totally optional suggestions, but figured it'd be good to see if we can do better this time from the start. I kind of regret how verbose and ugly some parts the go uma sdk are :-/... soooo many params lol.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one has to create an unsigned invoice and sign it. So I think we should stick with this method. However for other objects, we could utilize New

return protocol.FromBech32String(invoice)
}

func VerifyUmaInvoiceSignature(invoice protocol.UmaInvoice, otherVaspPubKeyResponse protocol.PubKeyResponse) error {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be a function on the invoice object instead? Might make it easier for folks to find the method.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think for now I'm going to to the verification here as it creates another object to get the unsigned payload. Also this follows the patter for other signature validation in this file.

@zhenlu zhenlu force-pushed the 07-15-add_functions_to_create_and_handle_uma_invoices branch from 03bd8e0 to 3090bce Compare July 16, 2024 04:43
@zhenlu zhenlu requested a review from jklein24 July 16, 2024 04:44
@zhenlu zhenlu force-pushed the 07-15-add_functions_to_create_and_handle_uma_invoices branch from 3090bce to b7be542 Compare July 16, 2024 04:48
@zhenlu
Copy link
Contributor Author

zhenlu commented Jul 16, 2024

Also bumped go-ethereum to newest version for lint and dep bot

@zhenlu zhenlu force-pushed the 07-15-add_functions_to_create_and_handle_uma_invoices branch 2 times, most recently from f9aba5b to d189933 Compare July 16, 2024 05:06
@zhenlu zhenlu force-pushed the 07-15-add_functions_to_create_and_handle_uma_invoices branch from d189933 to 895c295 Compare July 16, 2024 05:10
@zhenlu zhenlu merged commit 0d6057d into main Jul 16, 2024
2 checks passed
@zhenlu zhenlu deleted the 07-15-add_functions_to_create_and_handle_uma_invoices branch July 16, 2024 05:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants