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

Feat/solana onramp #2525

Merged
merged 52 commits into from
Sep 11, 2024
Merged
Show file tree
Hide file tree
Changes from 51 commits
Commits
Show all changes
52 commits
Select commit Hold shift + click to select a range
3aeffbe
feat: added meld io onramp widget
phoenixVS Jul 1, 2024
a1f390b
feat!: init onramp provider, icon
phoenixVS Jul 8, 2024
ba887df
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 9, 2024
5b0c49e
feat: added melt provider popup
phoenixVS Jul 9, 2024
a3cf4b9
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 9, 2024
23cd2a8
fix: chain dependant providers
phoenixVS Jul 10, 2024
723ead0
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 10, 2024
53e9b5f
feat: chain and wallet address passed to meld io
phoenixVS Jul 10, 2024
8221521
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 10, 2024
4307c0a
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 11, 2024
f7850e5
fix: removed redundant component
phoenixVS Jul 11, 2024
83e69ea
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 15, 2024
b21fd80
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 15, 2024
8075b78
fix: extra import
phoenixVS Jul 15, 2024
03b2fc8
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 16, 2024
105207b
fix: secure private key
phoenixVS Jul 17, 2024
8062392
fix: vite env
phoenixVS Jul 17, 2024
e8a0f25
fix: removed public key from dotenv
phoenixVS Jul 18, 2024
1e804b5
feat: added dev and prod pub keys
phoenixVS Jul 19, 2024
daf2b48
chore: removed .env.prod
phoenixVS Jul 19, 2024
67dd6a8
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 19, 2024
d503aa5
fix: prettier
phoenixVS Jul 19, 2024
e27ba3c
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 19, 2024
fcf1884
fix: removed package-lock, pnpm migration
phoenixVS Jul 23, 2024
0770532
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 23, 2024
5610703
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 23, 2024
fbe6c2c
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 23, 2024
7020881
fix: search params refactoring
phoenixVS Jul 23, 2024
4131464
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 23, 2024
87be669
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 23, 2024
fcbdd06
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 24, 2024
8d3a0f9
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 26, 2024
55eadd9
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 29, 2024
d07b8d5
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 29, 2024
4d4cbac
Merge branch 'main' into feat/solana-onramp
enesozturk Jul 29, 2024
7416f0d
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 29, 2024
0c8a027
Merge branch 'main' into feat/solana-onramp
phoenixVS Jul 30, 2024
27f3059
chore: remove solana condition for onramp button
enesozturk Aug 2, 2024
42fc49b
Merge branch 'main' into feat/solana-onramp
phoenixVS Aug 2, 2024
fb05c65
Merge branch 'main' into feat/solana-onramp
phoenixVS Aug 4, 2024
a43c008
Merge branch 'main' into feat/solana-onramp
valentyn-solana Aug 5, 2024
b137c64
Merge branch 'main' into feat/solana-onramp
valentyn-solana Aug 6, 2024
2d125b4
Merge branch 'main' into feat/solana-onramp
phoenixVS Aug 8, 2024
8205603
Merge branch 'main' into feat/solana-onramp
phoenixVS Aug 9, 2024
9a5450b
Merge branch 'main' into feat/solana-onramp
valentyn-solana Aug 12, 2024
8b43d74
Merge branch 'main' into feat/solana-onramp
phoenixVS Aug 12, 2024
b3acabb
Merge branch 'main' into feat/solana-onramp
zoruka Aug 27, 2024
ccf6628
Merge branch 'main' into feat/solana-onramp
zoruka Aug 29, 2024
e20faf7
Merge branch 'main' into feat/solana-onramp
zoruka Sep 2, 2024
b5645ef
Merge branch 'main' into feat/solana-onramp
zoruka Sep 4, 2024
6d36744
Merge branch 'main' into feat/solana-onramp
zoruka Sep 11, 2024
b859dc8
test: expect onramp button also for solana
zoruka Sep 11, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions packages/core/src/controllers/OnRampController.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,26 @@
import { subscribeKey as subKey } from 'valtio/vanilla/utils'
import { proxy, subscribe as sub } from 'valtio/vanilla'
import { ONRAMP_PROVIDERS } from '../utils/ConstantsUtil.js'
import {
ONRAMP_PROVIDERS,
MELD_DEV_PUBLIC_KEY,
MELD_PROD_PUBLIC_KEY
} from '../utils/ConstantsUtil.js'
import type { PurchaseCurrency, PaymentCurrency } from '../utils/TypeUtil.js'
import { BlockchainApiController } from './BlockchainApiController.js'
import { ApiController } from './ApiController.js'
import { ChainController } from './ChainController.js'
import { AccountController } from './AccountController.js'
import { ConstantsUtil } from '@web3modal/common'

// -- Types --------------------------------------------- //
export type OnRampProviderOption = 'coinbase' | 'moonpay' | 'stripe' | 'paypal'
export type OnRampProviderOption = 'coinbase' | 'moonpay' | 'stripe' | 'paypal' | 'meld'

export type OnRampProvider = {
label: string
name: OnRampProviderOption
feeRange: string
url: string
supportedChains: string[]
}

export interface OnRampControllerState {
Expand Down Expand Up @@ -93,6 +101,18 @@ export const OnRampController = {
},

setSelectedProvider(provider: OnRampProvider | null) {
if (provider && provider.name === 'meld') {
const pubKey =
process.env['NODE_ENV'] === 'production' ? MELD_PROD_PUBLIC_KEY : MELD_DEV_PUBLIC_KEY
const currency =
ChainController.state.activeChain === ConstantsUtil.CHAIN.SOLANA ? 'SOL' : 'USDC'
const address = AccountController.state.address ?? ''
const url = new URL(provider.url)
url.searchParams.append('publicKey', pubKey)
url.searchParams.append('destinationCurrencyCode', currency)
url.searchParams.append('walletAddress', address)
provider.url = url.toString()
}
state.selectedProvider = provider
},

Expand Down
13 changes: 12 additions & 1 deletion packages/core/src/utils/ConstantsUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@ export const ONRAMP_PROVIDERS = [
label: 'Coinbase',
name: 'coinbase',
feeRange: '1-2%',
url: ''
url: '',
supportedChains: ['evm']
},
{
label: 'Meld.io',
name: 'meld',
feeRange: '1-2%',
url: 'https://meldcrypto.com',
supportedChains: ['evm', 'solana']
}
]

export const MELD_DEV_PUBLIC_KEY = 'WXETMsajb7XcQBm7mcxAab:q3MtzJpiEMtXVNXsqYkAnAaBkgStybGVtZ'
export const MELD_PROD_PUBLIC_KEY = 'WXETMuFUQmqqybHuRkSgxv:25B8LJHSfpG6LVjR2ytU5Cwh7Z4Sch2ocoU'

export const ConstantsUtil = {
FOUR_MINUTES_MS: 240_000,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,9 +107,8 @@ export class W3mAccountDefaultWidget extends LitElement {
// -- Private ------------------------------------------- //
private onrampTemplate() {
const { enableOnramp } = OptionsController.state
const isSolana = ChainController.state.activeChain === ConstantsUtil.CHAIN.SOLANA

if (!enableOnramp || isSolana) {
if (!enableOnramp) {
return null
}

Expand Down
33 changes: 19 additions & 14 deletions packages/scaffold-ui/src/views/w3m-onramp-providers-view/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ import {
RouterController,
NetworkController,
BlockchainApiController,
EventsController
EventsController,
ChainController
} from '@web3modal/core'
import { customElement } from '@web3modal/ui'
import { LitElement, html } from 'lit'
Expand Down Expand Up @@ -61,19 +62,23 @@ export class W3mOnRampProvidersView extends LitElement {

// -- Private ------------------------------------------- //
private onRampProvidersTemplate() {
return this.providers.map(
provider => html`
<w3m-onramp-provider-item
label=${provider.label}
name=${provider.name}
feeRange=${provider.feeRange}
@click=${() => {
this.onClickProvider(provider)
}}
?disabled=${!provider.url}
></w3m-onramp-provider-item>
`
)
return this.providers
.filter(provider =>
provider.supportedChains.includes(ChainController.state.activeChain ?? 'evm')
)
.map(
provider => html`
<w3m-onramp-provider-item
label=${provider.label}
name=${provider.name}
feeRange=${provider.feeRange}
@click=${() => {
this.onClickProvider(provider)
}}
?disabled=${!provider.url}
></w3m-onramp-provider-item>
`
)
}

private onClickProvider(provider: OnRampProvider) {
Expand Down
31 changes: 31 additions & 0 deletions packages/ui/src/assets/visual/meld.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { svg } from 'lit'
export const meldSvg = svg`<svg width="40" height="42" viewBox="0 0 40 42" fill="none">
<path opacity="0.7" d="M19.9526 41.9076L7.3877 34.655V26.1226L19.9526 33.3751V41.9076Z" fill="url(#paint0_linear_2113_32117)"/>
<path opacity="0.7" d="M19.9521 41.9076L32.5171 34.655V26.1226L19.9521 33.3751V41.9076Z" fill="url(#paint1_linear_2113_32117)"/>
<path opacity="0.7" d="M39.9095 7.34521V21.8562L32.5166 26.1225V11.6114L39.9095 7.34521Z" fill="url(#paint2_linear_2113_32117)"/>
<path d="M39.9099 7.34536L27.345 0.0927734L19.9521 4.359L32.5171 11.6116L39.9099 7.34536Z" fill="url(#paint3_linear_2113_32117)"/>
<path d="M0 7.34536L12.5649 0.0927734L19.9519 4.359L7.387 11.6116L0 7.34536Z" fill="#F969D3"/>
<path opacity="0.7" d="M0 7.34521V21.8562L7.387 26.1225V11.6114L0 7.34521Z" fill="url(#paint4_linear_2113_32117)"/>
<defs>
<linearGradient id="paint0_linear_2113_32117" x1="18.6099" y1="41.8335" x2="7.73529" y2="8.31842" gradientUnits="userSpaceOnUse">
<stop stop-color="#E98ADA"/>
<stop offset="1" stop-color="#7E4DBD"/>
</linearGradient>
<linearGradient id="paint1_linear_2113_32117" x1="26.2346" y1="26.1226" x2="26.2346" y2="41.9076" gradientUnits="userSpaceOnUse">
<stop stop-color="#719DED"/>
<stop offset="1" stop-color="#2545BE"/>
</linearGradient>
<linearGradient id="paint2_linear_2113_32117" x1="36.213" y1="7.34521" x2="36.213" y2="26.1225" gradientUnits="userSpaceOnUse">
<stop stop-color="#93EBFF"/>
<stop offset="1" stop-color="#197DDB"/>
</linearGradient>
<linearGradient id="paint3_linear_2113_32117" x1="29.931" y1="0.0927734" x2="38.2156" y2="14.8448" gradientUnits="userSpaceOnUse">
<stop stop-color="#F969D3"/>
<stop offset="1" stop-color="#4F51C0"/>
</linearGradient>
<linearGradient id="paint4_linear_2113_32117" x1="18.1251" y1="44.2539" x2="-7.06792" y2="15.2763" gradientUnits="userSpaceOnUse">
<stop stop-color="#E98ADA"/>
<stop offset="1" stop-color="#7E4DBD"/>
</linearGradient>
</defs>
</svg>`
3 changes: 3 additions & 0 deletions packages/ui/src/components/wui-visual/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ import { onrampCardSvg } from '../../assets/visual/onramp-card.js'
import { googleSvg } from '../../assets/visual/google.js'
import { pencilSvg } from '../../assets/visual/pencil.js'
import { lightbulbSvg } from '../../assets/visual/lightbulb.js'
import { meldSvg } from '../../assets/visual/meld.js'

import styles from './styles.js'

// -- Svg's-------------------------------- //
Expand All @@ -43,6 +45,7 @@ const svgOptions: Record<VisualType, TemplateResult<2>> = {
profile: profileSvg,
system: systemSvg,
coinbase: coinbaseSvg,
meld: meldSvg,
onrampCard: onrampCardSvg,
moonpay: moonpaySvg,
stripe: stripeSvg,
Expand Down
1 change: 1 addition & 0 deletions packages/ui/src/utils/TypeUtil.ts
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,7 @@ export type IconType =

export type VisualType =
| 'browser'
| 'meld'
| 'coinbase'
| 'dao'
| 'defi'
Expand Down
Loading