-
Notifications
You must be signed in to change notification settings - Fork 61
Add support for SEP-0007 payment requests #1179
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
Closed
Closed
Changes from 16 commits
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
3ce61a1
Add '@stellarguard/stellar-uri' dependency
ebma 9dd12c4
Save settings to localStorage in web build
ebma 1116cbb
Add transactionRequest context
ebma 9e31652
Add TransactionRequestHandler
ebma 3d83dc0
Add VerifyTrustedServiceDialog
ebma fac8b02
Add PaymentAccountSelectionDialog
ebma 09c84b1
Add transaction-request.json to i18n translations
ebma fcd49b7
Support filling in payment form from search params
ebma daf8479
Go to payment form on payment account selection
ebma 776cffb
Only show accounts which have trustline for asset
ebma c262505
Add proper backnavigation from payment dialog
ebma c5a0579
Enable trusted services by default
ebma 714943d
Disable form fields if preselected params exist
ebma 66bf4e5
Show error when no account is selectable
ebma 77d5a45
Remove colons and change warning text
ebma ebf347e
Some small-ish UI changes affecting the tx request review dialog
andywer 1adf3f2
Change wording of warning message
ebma b106196
Show dismiss button if onCancel prop present
ebma 90f3e3c
Add 'selectedAccount' prop to AccountSelectionList
ebma 2c107d0
Add NoAccountsDialog
ebma d6dff65
Move components
ebma f6b3c67
Refactor PaymentAccountSelectionDialog
ebma abc70ab
Change key of i18n strings
ebma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| { | ||
| "payment-account-selection": { | ||
| "account-selector": "Select the account to use", | ||
| "action": { | ||
| "dismiss": "Dismiss", | ||
| "select": "Select" | ||
| }, | ||
| "error": { | ||
| "no-activated-accounts": "No activated accounts found.", | ||
| "no-accounts-with-trustline": "No accounts with matching trustline found." | ||
| }, | ||
| "header": { | ||
| "origin-domain": "The following transaction has been proposed by <1>{{originDomain}}<3>", | ||
| "no-origin-domain": "You opened the following payment request from an unknown origin." | ||
| }, | ||
| "uri-content": { | ||
| "any": "Any", | ||
| "pay": "Pay", | ||
| "to": "To", | ||
| "memo": "Memo", | ||
| "message": "Message" | ||
| }, | ||
| "title": "Transaction proposed", | ||
| "warning": "This request did not include a signature! Make sure that you trust the source of this link!" | ||
| }, | ||
| "verify-trusted-service": { | ||
| "action": { | ||
| "trust": "Trust", | ||
| "cancel": "Cancel" | ||
| }, | ||
| "title": "Verify Trusted Service", | ||
| "info": { | ||
| "1": "You opened a Stellar URI originating from an unknown origin", | ||
| "2": "If you trust this domain you can add this service to your list of trusted services.", | ||
| "3": "You can view and edit your list of trusted services anytime in the application settings." | ||
| } | ||
| } | ||
| } | ||
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,6 @@ | ||
| interface TrustedService { | ||
| domain: string | ||
| signingKey: string | ||
| signingKey?: string | ||
| } | ||
|
|
||
| declare namespace Platform { | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| import React from "react" | ||
| import { StellarUri, StellarUriType } from "@stellarguard/stellar-uri" | ||
| import { CustomError } from "~Generic/lib/errors" | ||
| import { subscribeToDeepLinkURLs } from "~Platform/protocol-handler" | ||
| import { verifyTransactionRequest } from "~Transaction/lib/stellar-uri" | ||
| import { trackError } from "./notifications" | ||
|
|
||
| const allowUnsafeTestnetURIs = Boolean(process.env.ALLOW_UNSAFE_TESTNET_URIS) | ||
|
|
||
| interface Props { | ||
| children: React.ReactNode | ||
| } | ||
|
|
||
| interface ContextType { | ||
| uri: StellarUri | null | ||
| clearURI: () => void | ||
| } | ||
|
|
||
| const initialValues: ContextType = { | ||
| uri: null, | ||
| clearURI: () => undefined | ||
| } | ||
|
|
||
| const TransactionRequestContext = React.createContext<ContextType>(initialValues) | ||
|
|
||
| export function TransactionRequestProvider(props: Props) { | ||
| const [uri, setURI] = React.useState<StellarUri | null>(null) | ||
|
|
||
| const clearURI = React.useCallback(() => setURI(null), []) | ||
|
|
||
| const verifyStellarURI = React.useCallback(async (incomingURI: string) => { | ||
| try { | ||
| const parsedURI = await verifyTransactionRequest(incomingURI, { allowUnsafeTestnetURIs }) | ||
| setURI(parsedURI) | ||
| } catch (error) { | ||
| trackError(error) | ||
| } | ||
| }, []) | ||
|
|
||
| React.useEffect(() => { | ||
| const unsubscribe = subscribeToDeepLinkURLs(async incomingURI => { | ||
| const url = new URL(incomingURI) | ||
| switch (url.pathname) { | ||
| case StellarUriType.Transaction: | ||
| case StellarUriType.Pay: | ||
| verifyStellarURI(incomingURI) | ||
| break | ||
| default: | ||
| trackError( | ||
| CustomError( | ||
| "UnexpectedStellarUriTypeError", | ||
| `Incoming uri ${incomingURI} does not match any expected type.`, | ||
| { incomingURI } | ||
| ) | ||
| ) | ||
| break | ||
| } | ||
| }) | ||
| return unsubscribe | ||
| }, [verifyStellarURI]) | ||
|
|
||
| return ( | ||
| <TransactionRequestContext.Provider value={{ uri, clearURI }}>{props.children}</TransactionRequestContext.Provider> | ||
| ) | ||
| } | ||
|
|
||
| export { ContextType as TransactionRequestContextType, TransactionRequestContext } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.