-
Notifications
You must be signed in to change notification settings - Fork 258
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 Kado OTC provider #5373
base: develop
Are you sure you want to change the base?
Add Kado OTC provider #5373
Conversation
7be7437
to
c589a0b
Compare
c589a0b
to
cffc402
Compare
@@ -1364,6 +1365,10 @@ | |||
"bank_transfer_reference": "Reference", | |||
"sepa_form_title": "Enter Bank Info", | |||
"sepa_transfer_prompt_s": "Your order %1$s has been submitted!\n\nPlease save the order details below for your records and instruct your bank to make the payment with the information in the Payment Details section.", | |||
"otc_enter_email_to_buy": "Please enter your email to be contacted by one of our exchange partners to coordinate an OTC (Over the Counter) purchase.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These string changes belong in the next commit, not this one.
import { View } from 'react-native' | ||
|
||
import { styled } from '../hoc/styled' | ||
|
||
export const SceneContainer = styled(View)(theme => ({ | ||
padding: theme.rem(0.5) | ||
})) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
I spot-checked some scenes, and I did notice a lot of <View style={styles.container}>
components between the SceneWrapper
and the UI elements, so it seems like the need is real. Since this is a SceneContainer
specifically, and not a Space
, we can tie it in with the SceneWrapper
component, such as by understanding the undoInsetStyles
or whatever (but this simple version is fine for today).
I think you need to either have a sidebar with Jon, or bring this up at the Monday meeting, so we're all on board with putting this between the SceneWrapper
and the contents. We need to get broad adoption across the codebase, so this can start making a positive impact.
const handleChange = useHandler(text => { | ||
setValue(text) | ||
}) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please remove this useFormFieldState
abstraction. It is creating cognitive overhead and without providing any real value.
There is no need to wrap setValue
with a no-op useHandler
. You can pass setValue
straight to the onChangeText
prop. Once you do that, it's just as simple to use useState
directly, and not even bother with this useFormFieldState
thing.
const CHAIN_ID_TO_PLUGIN_MAP: { [chainId: string]: string } = Object.entries(PLUGIN_TO_CHAIN_ID_MAP).reduce( | ||
(out: { [chainId: string]: string }, [pluginId, chainId]) => { | ||
out[chainId] = pluginId | ||
return out | ||
}, | ||
{} | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since you are mutating out
anyhow, please use a for
loop to make it clear that this is imperative code:
const CHAIN_ID_TO_PLUGIN_MAP: { [chainId: string]: string } = {}
for (const [pluginId, chainId] of Object.entries(PLUGIN_TO_CHAIN_ID_MAP) {
CHAIN_ID_TO_PLUGIN_MAP[chainId] = pluginId
}
There is a time & place for reduce
and other functional tools, but building an object is not rarely a good fit - it can only be done with mutations, because of the way JavaScript works, so a for
loop is usually going to be cleaner and faster.
buy: { | ||
ach: true, | ||
applepay: true, | ||
colombiabank: true, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really? The Kado OTC desk accepts Colombian bank transfers and all these other weird international options?
if (address.startsWith('0x')) { | ||
// For EVM tokens only, lowercase and remove 0x | ||
tokenId = address.toLowerCase().replace('0x', '') | ||
} else { | ||
tokenId = address | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Matthew recently added an EdgeCurrencyConfig.getTokenId
method that goes from contract address to tokenId. That seems more stable than hard-coding these rules.
|
||
// These parameters are only to get a quote exchange rate: | ||
const queryParams: GetQuoteParams = { | ||
// All OTC rates are quoted at an volume amount |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"at an volume amount"? Not sure what that means.
await submitOrder(userEmail) | ||
|
||
async function submitOrder(userEmail: string): Promise<void> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why even make a submitOrder
function, since it's pretty much an IIFE?
I could see this making sense if you move submitOrder
out of this scope, maybe putting it as a standalone utility at the bottom of the file. It would need to take showUi
as an argument, but then the structure would make much more sense.
const { params } = route | ||
const { onClose, onSubmit } = params | ||
|
||
const emailField = useFormFieldState() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
const [email, setEmail] = React.useState('')
<SceneContainer> | ||
<SceneHeaderUi4 title="Enter Email" /> | ||
{params.message == null ? null : <Paragraph>{params.message}</Paragraph>} | ||
<GuiFormField fieldType="text" autofocus label={lstrings.form_field_title_email_address} {...emailField} /> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value={email} onChangeText={setEmail}
CHANGELOG
Does this branch warrant an entry to the CHANGELOG?
Dependencies
noneRequirements
If you have made any visual changes to the GUI. Make sure you have: