Skip to content

Commit

Permalink
feat(bridge-ui-v2): manual NFT import step (#14842)
Browse files Browse the repository at this point in the history
  • Loading branch information
KorbinianK committed Oct 6, 2023
1 parent 9cc4db3 commit c85e162
Show file tree
Hide file tree
Showing 21 changed files with 835 additions and 156 deletions.
4 changes: 4 additions & 0 deletions packages/bridge-ui-v2/__mocks__/@wagmi/core.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ export const getContract = vi.fn();

export const fetchBalance = vi.fn();

export const fetchToken = vi.fn();

export const readContract = vi.fn();

export const configureChains = vi.fn(() => {
return { publicClient: 'mockPublicClient' };
});
Expand Down
4 changes: 4 additions & 0 deletions packages/bridge-ui-v2/src/app.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@ export const recommentProcessingFee = {
ethGasLimit: BigInt(900_000),
erc20NotDeployedGasLimit: BigInt(3_100_000),
erc20DeployedGasLimit: BigInt(1_100_000),
erc721NotDeployedGasLimit: BigInt(3_400_000),
erc721DeployedGasLimit: BigInt(1_100_000),
erc1155NotDeployedGasLimit: BigInt(4_000_000),
erc1155DeployedGasLimit: BigInt(1_100_000),
};

export const processingFeeComponent = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,33 @@
import { Icon } from '$components/Icon';
import { uid } from '$libs/util/uid';
enum State {
Valid = 'valid',
Invalid = 'invalid',
TooShort = 'too_short',
}
import { AddressInputState as State } from './state';
export let ethereumAddress: Address | string = '';
export let labelText = $t('inputs.address_input.label.default');
export let isDisabled = false;
export let quiet = false;
export let state: State = State.Default;
export const validateAddress = () => {
validateEthereumAddress(ethereumAddress);
};
export const clearAddress = () => {
if (input) input.value = '';
validateEthereumAddress('');
};
export const focus = () => input.focus();
let input: HTMLInputElement;
let inputId = `input-${uid()}`;
let state: State;
export let ethereumAddress: Address | string = '';
const dispatch = createEventDispatcher();
const validateEthereumAddress = (address: string | EventTarget | null) => {
let addr: string;
if (!address) return;
if (address && address instanceof EventTarget) {
addr = (address as HTMLInputElement).value;
Expand All @@ -49,41 +60,37 @@
};
$: validateEthereumAddress(ethereumAddress);
export const clear = () => {
input.value = '';
validateEthereumAddress('');
};
export const focus = () => input.focus();
</script>

<div class="f-col space-y-2">
<div class="f-between-center text-secondary-content">
<label class="body-regular" for={inputId}>{$t('inputs.address_input.label')}</label>
<label class="body-regular" for={inputId}>{labelText}</label>
</div>
<div class="relative f-items-center">
<input
bind:this={input}
id={inputId}
disabled={isDisabled}
type="string"
placeholder="0x1B77..."
bind:value={ethereumAddress}
on:input={(e) => validateEthereumAddress(e.target)}
class="w-full input-box withValdiation py-6 pr-16 px-[26px] title-subsection-bold placeholder:text-tertiary-content
{state === State.Valid ? 'success' : ethereumAddress ? 'error' : ''}
class="w-full input-box withValdiation py-6 pr-16 px-[26px] title-subsection-bold placeholder:text-tertiary-content {$$props.class}
{state === State.Valid ? 'success' : ethereumAddress && state !== State.Validating ? 'error' : ''}
" />
<button class="absolute right-6 uppercase body-bold text-secondary-content" on:click={clear}>
<button class="absolute right-6 uppercase body-bold text-secondary-content" on:click={clearAddress}>
<Icon type="x-close-circle" fillClass="fill-primary-icon" size={24} />
</button>
</div>
</div>
<div class="mt-5 min-h-[20px]">
{#if state === State.Invalid && ethereumAddress}
<FlatAlert type="error" forceColumnFlow message={$t('inputs.address_input.errors.invalid')} />
{:else if state === State.TooShort && ethereumAddress}
<FlatAlert type="warning" forceColumnFlow message={$t('inputs.address_input.errors.too_short')} />
{:else if state === State.Valid}
<FlatAlert type="success" forceColumnFlow message={$t('inputs.address_input.success')} />
{/if}
</div>

{#if !quiet}
<div class="min-h-[20px] !mt-3">
{#if state === State.Invalid && ethereumAddress}
<FlatAlert type="error" forceColumnFlow message={$t('inputs.address_input.errors.invalid')} />
{:else if state === State.TooShort && ethereumAddress}
<FlatAlert type="warning" forceColumnFlow message={$t('inputs.address_input.errors.too_short')} />
{:else if state === State.Valid}
<FlatAlert type="success" forceColumnFlow message={$t('inputs.address_input.success')} />
{/if}
</div>
{/if}
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
export enum AddressInputState {
Default = 'default',
Valid = 'valid',
Invalid = 'invalid',
TooShort = 'too_short',
Validating = 'validating',
}
2 changes: 1 addition & 1 deletion packages/bridge-ui-v2/src/components/Bridge/Amount.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
// Public API
export function clearAmount() {
inputBox.clear();
inputBox?.clear();
$enteredAmount = BigInt(0);
}
Expand Down
Loading

1 comment on commit c85e162

@vercel
Copy link

@vercel vercel bot commented on c85e162 Oct 6, 2023

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

bridge-ui-v2-internal – ./packages/bridge-ui-v2

bridge-ui-v2-internal.vercel.app
bridge-ui-v2-internal-git-main-taikoxyz.vercel.app
bridge-ui-v2-internal-taikoxyz.vercel.app

Please sign in to comment.