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 Kado OTC provider #5373

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open

Add Kado OTC provider #5373

wants to merge 2 commits into from

Conversation

samholmes
Copy link
Contributor

@samholmes samholmes commented Nov 26, 2024

CHANGELOG

Does this branch warrant an entry to the CHANGELOG?

  • Yes
  • No

Dependencies

none

Requirements

If you have made any visual changes to the GUI. Make sure you have:

  • Tested on iOS device
  • Tested on Android device
  • Tested on small-screen device (iPod Touch)
  • Tested on large-screen device (tablet)

@@ -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.",
Copy link
Contributor

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.

Comment on lines +1 to +7
import { View } from 'react-native'

import { styled } from '../hoc/styled'

export const SceneContainer = styled(View)(theme => ({
padding: theme.rem(0.5)
}))
Copy link
Contributor

@swansontec swansontec Nov 28, 2024

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.

Comment on lines +12 to +14
const handleChange = useHandler(text => {
setValue(text)
})
Copy link
Contributor

@swansontec swansontec Nov 28, 2024

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.

Comment on lines +61 to +67
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
},
{}
)
Copy link
Contributor

@swansontec swansontec Nov 28, 2024

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,
Copy link
Contributor

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?

Comment on lines +275 to +280
if (address.startsWith('0x')) {
// For EVM tokens only, lowercase and remove 0x
tokenId = address.toLowerCase().replace('0x', '')
} else {
tokenId = address
}
Copy link
Contributor

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
Copy link
Contributor

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.

Comment on lines +398 to +400
await submitOrder(userEmail)

async function submitOrder(userEmail: string): Promise<void> {
Copy link
Contributor

@swansontec swansontec Nov 28, 2024

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()
Copy link
Contributor

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} />
Copy link
Contributor

Choose a reason for hiding this comment

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

value={email} onChangeText={setEmail}

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