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

Funding page #318

Merged
merged 28 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
c5cac2d
enhancement: implemented card design for on-ramps section
dafuga Dec 18, 2024
a9ad016
enhancement: polished the exchanges section
dafuga Dec 18, 2024
0d3446a
chore: localizing page metadata
dafuga Dec 18, 2024
19e0de0
fix: making the on ramp provider card look more presentable on bigger…
dafuga Dec 18, 2024
bffe910
chore: adjusted coinbase on ramp service details
dafuga Dec 18, 2024
484742a
fix: fixed typo
dafuga Dec 18, 2024
47d16b6
fix: adjusted styling and wording of coinbase details
dafuga Dec 18, 2024
fff0076
enhancement: using a more descriptive seo description
dafuga Dec 18, 2024
249786d
using h2 tag
dafuga Dec 18, 2024
ab8adeb
using h2 tag
dafuga Dec 18, 2024
35f0fdb
removing unused text-gray class
dafuga Dec 18, 2024
0570edb
using grid place-items-center
dafuga Dec 18, 2024
46257cb
removed punctuation from translation file
dafuga Dec 18, 2024
3f83933
Merge remote-tracking branch 'origin/dev' into funding-page
dafuga Dec 19, 2024
f6605c0
refactor: using Grid component
dafuga Dec 19, 2024
e1c0103
cleanup: code cleanup
dafuga Dec 19, 2024
ae12db6
refactor: using the DescriptionList component
dafuga Dec 19, 2024
ab2991b
revert: removing unused action classList config for now
dafuga Dec 19, 2024
7044993
refactor: moved the fund page assets to lib/assets
dafuga Dec 19, 2024
0522fac
cleanup: code cleanup
dafuga Dec 19, 2024
78466e2
enhancement: using enhanced:img tag
dafuga Dec 19, 2024
f40f015
fix: fixed the exchanges image styling
dafuga Dec 19, 2024
8a52e9d
refactor: multicard component to take tag name
deansallinen Dec 19, 2024
619cce5
style: updates
deansallinen Dec 19, 2024
e5748fa
refactor: dd to take classes
deansallinen Dec 19, 2024
d705d0b
refactor: use multiple dd instead of ul
deansallinen Dec 19, 2024
e9db6cd
style: revert wide cards
deansallinen Dec 19, 2024
9d3fa4f
Merge pull request #322 from greymass/funding-page-dean
aaroncox Dec 19, 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
Binary file modified bun.lockb
Binary file not shown.
20 changes: 19 additions & 1 deletion messages/en.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
{
"$schema": "https://inlang.com/schema/inlang-message-format",
"_500_per_day": "$500/day",
"account_page": "Account Page",
"accounts_using_public_key": "Associated Accounts",
"active_session": "Active Session",
"block_height_numbered": "Block #{height}",
"block_height_numbered_description": "Block #{height} was produced by {producer} on {timestamp}, which included {transactions} transactions performing {actions} actions.",
"buy_eos_with_coinbase": "Buy EOS with Coinbase",
"buy_or_transfer_crypto": "Buy or transfer EOS",
"coinbase_service_unavailable": "Coinbase service is currently unavailable.",
"common_about_something": "About {thing}",
"common_action": "Action",
"common_amount_exceeds_balance": "Amount exceeds available balance.",
Expand Down Expand Up @@ -90,17 +94,26 @@
"contract_tables_view_title": "Table: {table}",
"contract_view_description": "An overview of the {contract} smart contract on the {network} network. This contract contains {actions} actions, {tables} tables, and {structs} structs.",
"contract_view_title": "Contract: {contract} | {network}",
"debit_and_credit_cards_supported": "Debit and credit cards supported",
"delegation_metadata_refund_description": "Claim previously delegated {network} tokens.",
"delegation_metadata_refund_title": "Refund Delegated {network} Tokens",
"details": "Details",
"error_loading_accounts": "Error loading accounts: {error}",
"exchanges": "Exchanges",
"form_validation_insufficient_balance": "Insufficient {unit} balance. Please enter a smaller amount.",
"form_validation_invalid_number_decimals": "Invalid number, too many decimal places.",
"fund_account": "Fund Account",
"fund_account_description": "Purchase EOS tokens to fund your account",
"key_page_description": "A public key associated with {accounts} account(s) on the {network} network.",
"key_page_subtitle": "The {accounts} account(s) associated with this public key",
"key_page_title": "Public Key",
"legacy_key": "Legacy Key",
"limits": "Limits",
"loading_accounts": "Loading accounts...",
"must_be_logged_in_for_feature": "You must be logged in with an account to use this feature.",
"no_accounts_found": "No accounts found",
"no_supported_funding_methods": "No supported funding methods for this blockchain.",
"processing_fees": "Processing fees",
"ram_available_balance": "RAM Available",
"ram_form_buy_amount": "Amount of RAM to buy:",
"ram_metadata_buy_description": "Exchange {token} for RAM on the {network} network using an {network} compatible wallet.",
Expand All @@ -114,6 +127,7 @@
"ram_to_purchase": "RAM to be bought",
"ram_to_sell": "RAM to be sold",
"search_view_type": "View {type}",
"select_provider": "Select provider",
"send_amount_to_send": "Amount to send",
"send_enter_amount": "Enter the amount of {token} to send",
"send_memo_placeholder": "Specify a public memo for this transfer (optional)",
Expand Down Expand Up @@ -148,5 +162,9 @@
"staking_network_title": "{network} Network Staking",
"staking_withdraw_timeframe": "Withdrawable in 21 days",
"test_locale_string": "This is a test",
"total_proceeds": "Total Proceeds"
"tokens_purchase_providers": "Tokens can be purchased directly through the following providers:",
"total_proceeds": "Total Proceeds",
"where_eos_can_be_purchased": "EOS can be purchased through a number of platforms, depending on the users needs and location.\n\tBelow are some of the most popular options available.",
"fund_account_seo_description": "Learn how to fund your account with EOS tokens through various methods including cryptocurrency exchanges and on-ramp providers.",
"token_purchase_providers": "Token Purchase Providers"
}
Binary file added src/lib/assets/exchanges/binance.webp
Binary file not shown.
Binary file added src/lib/assets/exchanges/coinbase-icon.webp
Binary file not shown.
11 changes: 11 additions & 0 deletions src/lib/assets/exchanges/coinbase.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added src/lib/assets/exchanges/gate-io.webp
Binary file not shown.
Binary file added src/lib/assets/exchanges/huobi.webp
Binary file not shown.
Binary file added src/lib/assets/exchanges/kraken.webp
Binary file not shown.
Binary file added src/lib/assets/exchanges/kucoin.webp
Binary file not shown.
Binary file added src/lib/assets/exchanges/okx.webp
Binary file not shown.
Binary file added src/lib/assets/exchanges/upbit.webp
Binary file not shown.
6 changes: 5 additions & 1 deletion src/lib/components/descriptionlist/dd.svelte
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
<script lang="ts">
import { cn } from '$lib/utils/style';

let props = $props();
</script>

<dd class="grow text-balance break-all text-right tabular-nums">{@render props.children()}</dd>
<dd class={cn('grow text-balance break-all text-right tabular-nums', props.class)}>
{@render props.children()}
</dd>
6 changes: 4 additions & 2 deletions src/lib/components/layout/page/multicard.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import type { HTMLAttributes } from 'svelte/elements';

interface Props extends HTMLAttributes<HTMLDivElement> {
tag?: string;
children: Snippet;
class?: string;
}
Expand All @@ -13,8 +14,9 @@

<!-- What we really need here is `grid-template-rows: masonry` which is still in draft spec -->
<!-- https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_grid_layout/Masonry_layout -->
<div
<svelte:element
this={props.tag || 'div'}
class={cn('gap-6 *:mb-6 *:w-full *:break-inside-avoid last:*:mb-0 @2xl:columns-2', props.class)}
>
{@render props.children()}
</div>
</svelte:element>
214 changes: 172 additions & 42 deletions src/routes/[network]/(account)/fund/+page.svelte
Original file line number Diff line number Diff line change
@@ -1,15 +1,91 @@
<script lang="ts">
import { getContext } from 'svelte';
import Card from '$lib/components/layout/box/card.svelte';
import Code from '$lib/components/code.svelte';
import binanceLogo from '$lib/assets/exchanges/binance.webp?enhanced';
import coinbaseIconLogo from '$lib/assets/exchanges/coinbase-icon.webp?enhanced';
import krakenLogo from '$lib/assets/exchanges/kraken.webp?enhanced';
import okxLogo from '$lib/assets/exchanges/okx.webp?enhanced';
import huobiLogo from '$lib/assets/exchanges/huobi.webp?enhanced';
import gateioLogo from '$lib/assets/exchanges/gate-io.webp?enhanced';
import upbitLogo from '$lib/assets/exchanges/upbit.webp?enhanced';
import kucoinLogo from '$lib/assets/exchanges/kucoin.webp?enhanced';
import type { UnicoveContext } from '$lib/state/client.svelte';
import { getContext } from 'svelte';
import { initOnRamp, type CBPayInstanceType, type InitOnRampParams } from '@coinbase/cbpay-js';
import Button from '$lib/components/button/button.svelte';
import { env } from '$env/dynamic/public';
import * as m from '$lib/paraglide/messages';
import Grid from '$lib/components/layout/grid.svelte';
import { DL, DLRow, DD } from '$lib/components/descriptionlist';
import coinbaseLogo from '$lib/assets/exchanges/coinbase.svg';
import Stack from '$lib/components/layout/stack.svelte';
import MultiCard from '$lib/components/layout/page/multicard.svelte';
import Cluster from '$lib/components/layout/cluster.svelte';

const ON_RAMP_PROVIDERS = [
{
id: 'coinbase',
logo: coinbaseLogo,
fees: {
range: '1.49% - 3.99%'
},
limits: {
daily: m._500_per_day()
},
details: [m.buy_or_transfer_crypto(), m.debit_and_credit_cards_supported()],
action: {
text: m.buy_eos_with_coinbase(),
handler: 'coinbase'
}
}
] as const;

const EXCHANGES = [
{
name: 'Binance',
logo: binanceLogo,
url: 'https://www.binance.com'
},
{
name: 'Coinbase',
logo: coinbaseIconLogo,
url: 'https://www.coinbase.com'
},
{
name: 'Kraken',
logo: krakenLogo,
url: 'https://www.kraken.com'
},
{
name: 'OKX',
logo: okxLogo,
url: 'https://www.okx.com'
},
{
name: 'Huobi Global',
logo: huobiLogo,
url: 'https://global-aws.huobi.com'
},
{
name: 'Gate.io',
logo: gateioLogo,
url: 'https://www.gate.io'
},
{
name: 'Upbit',
logo: upbitLogo,
url: 'https://upbit.com'
},
{
name: 'Kucoin',
logo: kucoinLogo,
url: 'https://kucoin.com'
}
] as const;

const context = getContext<UnicoveContext>('state');

const options: InitOnRampParams | undefined = $derived.by(() => {
const coinbaseOptions: InitOnRampParams | undefined = $derived.by(() => {
let appId = '';
let asset = '';
switch (String(context.network)) {
Expand All @@ -20,7 +96,6 @@
}
break;
default:
// return undefined for an unsupported network
return;
}
return {
Expand All @@ -44,8 +119,8 @@
let coinbaseInstance: CBPayInstanceType | null = $state(null);

$effect(() => {
if (options && context.account?.name) {
initOnRamp(options, (error, instance) => {
if (coinbaseOptions && context.account?.name) {
initOnRamp(coinbaseOptions, (error, instance) => {
if (error) {
console.error(error);
return;
Expand All @@ -59,50 +134,105 @@
}
});

function coinbase() {
function handleCoinbaseOnRamp() {
if (coinbaseInstance) {
coinbaseInstance.open();
} else {
console.error('Coinbase instance not found');
alert(m.coinbase_service_unavailable());
}
}

function handleOnRamp(service: (typeof ON_RAMP_PROVIDERS)[number]['id']) {
if (!context.account) {
return;
}
if (service === 'coinbase') {
return handleCoinbaseOnRamp();
}
throw new Error(`${service} on-ramp has not been implemented`);
}
</script>

<h2 class="h2">Onramps</h2>
<p>
After logging in with your EOS account, EOS tokens can be purchased directly from the following
platforms and the tokens will immediately be sent to your on-chain account.
</p>
{#if !context.account}
<p>You must be logged in with an account to use this feature.</p>
{:else if !coinbaseInstance}
<p>No supported funding methods for this blockchain.</p>
{:else}
<Button onclick={coinbase}>Buy EOS with Coinbase</Button>
{/if}
<Stack class="gap-12">
<Stack>
<h2 class="h4">{m.token_purchase_providers()}</h2>

<Cluster tag="ul">
{#each ON_RAMP_PROVIDERS as service}
<Card tag="li" class="max-w-sm p-6">
<div>
<div class="mb-4 flex items-center justify-center">
<img src={service.logo} alt={service.id} class="h-24 w-3/5 object-contain" />
</div>
<DL>
<DLRow title={m.processing_fees()}>
<DD>
<p class="text-white">{service.fees.range}</p>
</DD>
</DLRow>
<DLRow title={m.limits()}>
<DD>
<p class="text-white">{service.limits.daily}</p>
</DD>
</DLRow>
<DLRow title={m.details()}>
{#each service.details as detail}
<DD class="text-white">{detail}</DD>
{/each}
</DLRow>
</DL>
</div>

<div class="mt-6">
{#if !context.account}
<p class="text-sm">{m.must_be_logged_in_for_feature()}</p>
{:else}
<Button variant="secondary" class="w-full" onclick={() => handleOnRamp(service.id)}
>{service.action.text}</Button
>
{/if}
</div>
</Card>
{/each}
</Cluster>
</Stack>

<h2 class="h2">Exchanges</h2>
<p>
EOS can be purchased through a number of platforms, depending on the users needs and location.
Below are some of the most popular options available.
</p>
<ul>
<li><a href="https://www.binance.com">https://www.binance.com</a></li>
<li><a href="https://www.coinbase.com">https://www.coinbase.com</a></li>
<li><a href="https://www.kraken.com">https://www.kraken.com</a></li>
<li><a href="https://www.okx.com">https://www.okx.com</a></li>
<li><a href="https://global-aws.huobi.com">https://global-aws.huobi.com</a></li>
<li><a href="https://www.gate.io">https://www.gate.io</a></li>
<li><a href="https://upbit.com">https://upbit.com</a></li>
<li><a href="https://kucoin.com">https://kucoin.com</a></li>
</ul>
<Stack class="gap-4">
<h2 class="h4">{m.exchanges()}</h2>

{#if context.settings.data.debugMode}
<h3 class="h3">{m.common_debugging()}</h3>
<p>{m.where_eos_can_be_purchased()}</p>

<Code>
{JSON.stringify(options, null, 2)}
</Code>
<Grid tag="ul" itemWidth="10rem" class="">
{#each EXCHANGES as exchange}
<Card tag="li" class="">
<a
href={exchange.url}
target="_blank"
rel="noopener noreferrer"
class="block h-full transition-all hover:scale-105"
>
<div class="mb-4 grid aspect-square rounded-lg bg-mineShaft-900 p-4">
<enhanced:img
src={exchange.logo}
alt="{exchange.name} logo"
class="h-full object-cover"
/>
</div>
<h3 class="text-center text-lg font-medium">{exchange.name}</h3>
</a>
</Card>
{/each}
</Grid>
</Stack>

<Code>
{JSON.stringify(coinbaseInstance, null, 2)}
</Code>
{/if}
{#if context.settings.data.debugMode}
<h3 class="h3">{m.common_debugging()}</h3>
<Code>
{JSON.stringify(coinbaseOptions, null, 2)}
</Code>
<Code>
{JSON.stringify(coinbaseInstance, null, 2)}
</Code>
{/if}
</Stack>
9 changes: 5 additions & 4 deletions src/routes/[network]/(account)/fund/+page.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
import type { PageLoad } from './$types';
import * as m from '$lib/paraglide/messages';

export const load: PageLoad = async () => {
return {
title: 'Fund Account',
subtitle: 'Purchase EOS tokens to fund your account',
title: m.fund_account(),
subtitle: m.fund_account_description(),
pageMetaTags: {
title: 'Fund Account',
description: 'Purchase EOS tokens to fund your account'
title: m.fund_account(),
description: m.fund_account_seo_description()
}
};
};
Loading