Skip to content

Commit

Permalink
Merge branch 'main' into xiaodino/add-balance-monitor
Browse files Browse the repository at this point in the history
  • Loading branch information
davidtaikocha authored May 17, 2024
2 parents ccbb102 + 3875f45 commit 781ead2
Show file tree
Hide file tree
Showing 43 changed files with 2,512 additions and 300 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/eventindexer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
flags: eventindexer

push-eventindexer-docker-image:
if: ${{ github.event == 'push' }}
if: ${{ github.event_name == 'pull_request' }}
name: Build and push docker image
runs-on: [taiko-runner]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/guardian-prover-health-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
flags: guardian-prover-health-check

push-guardian-prover-health-check-docker-image:
if: ${{ github.event == 'push' }}
if: ${{ github.event_name == 'pull_request' }}
name: Build and push docker image
runs-on: [taiko-runner]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/relayer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ jobs:
flags: relayer

push-relayer-docker-image:
if: ${{ github.event == 'push' }}
if: ${{ github.event_name == 'pull_request' }}
name: Build and push docker image
runs-on: [taiko-runner]

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/supplementary-contracts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:

- name: Format solidity && update contract layout table
working-directory: ./packages/supplementary-contracts
run: pnpm layout && forge fmt
run: pnpm layout && pnpm lint:sol

- name: Commit contract layout table
uses: stefanzweifel/git-auto-commit-action@v5
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,30 @@
"type": "string"
},
"logoURI": {
"type": "string"
},
"mintable": {
"type": "boolean"
"type": ["string", "null"]
},
"wrapped": {
"type": "boolean"
"attributes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"wrapped": {
"type": "boolean"
},
"supported": {
"type": "boolean"
},
"stablecoin": {
"type": "boolean"
},
"mintable": {
"type": "boolean"
}
},
"additionalProperties": false
}
}
},
"required": ["name", "addresses", "symbol", "decimals", "type", "logoURI"]
"required": ["name", "addresses", "symbol", "decimals", "type"]
}
}
25 changes: 23 additions & 2 deletions packages/bridge-ui/scripts/utils/validateJson.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/* eslint-disable no-console */
import Ajv, { type Schema } from 'ajv';

import { type NFT, type Token, TokenAttributeKey } from '../../src/libs/token/types';
import { PluginLogger } from './PluginLogger';

const ajv = new Ajv({ strict: false });
Expand All @@ -9,17 +10,37 @@ type SchemaWithId = Schema & { $id?: string };

const logger = new PluginLogger('json-validator');

export const validateJsonAgainstSchema = (json: JSON, schema: SchemaWithId): boolean => {
const validateJsonAgainstSchema = (json: JSON, schema: SchemaWithId): boolean => {
logger.info(`Validating ${schema.$id}`);
const validate = ajv.compile(schema);

const valid = validate(json);

if (!valid) {
logger.error('Validation failed.');
console.error('Error details:', ajv.errors);
console.error('Error details:', validate.errors);
return false;
}

// Additional validation for attributes against TokenAttributeKey enum
if (Array.isArray(json)) {
json.forEach((token: Token | NFT) => {
if (token.attributes) {
token.attributes.forEach((attribute: Record<string, unknown>) => {
Object.keys(attribute).forEach((key) => {
if (!Object.values(TokenAttributeKey).includes(key as TokenAttributeKey)) {
logger.error(`Invalid attribute key: ${key}`);
console.error(`Invalid attribute key: ${key}`);
throw new Error(`Invalid attribute key: ${key}`);
}
});
});
}
});
}

logger.info(`Validation of ${schema.$id} succeeded.`);
return true;
};

export { validateJsonAgainstSchema };
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
let hasEnoughEth: boolean = false;
let bridgingStatus: BridgingStatus;
let needsManualConfirmation: boolean;
const handleTransactionDetailsClick = () => (activeStep = BridgeSteps.RECIPIENT);
const handleBackClick = () => (activeStep = BridgeSteps.IMPORT);
Expand Down Expand Up @@ -51,6 +53,7 @@
<ReviewStep
on:editTransactionDetails={handleTransactionDetailsClick}
on:goBack={handleBackClick}
bind:needsManualConfirmation
bind:hasEnoughEth />
{:else if activeStep === BridgeSteps.RECIPIENT}
<!-- RECIPIENT STEP -->
Expand All @@ -60,7 +63,7 @@
<ConfirmationStep bind:bridgingStatus />
{/if}
<!-- NAVIGATION -->
<StepNavigation bind:activeStep {bridgingStatus} />
<StepNavigation bind:activeStep {bridgingStatus} bind:needsManualConfirmation />
</div>
</Card>
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,11 @@
import { destNetwork as destChain, enteredAmount, selectedToken } from '$components/Bridge/state';
import { PUBLIC_SLOW_L1_BRIDGING_WARNING } from '$env/static/public';
import { LayerType } from '$libs/chain';
import { isWrapped, type Token } from '$libs/token';
import { isStablecoin, isSupported, isWrapped, type Token } from '$libs/token';
import { connectedSourceChain } from '$stores/network';
export let hasEnoughEth: boolean = false;
export let needsManualConfirmation = false;
let recipientComponent: Recipient;
let processingFeeComponent: ProcessingFee;
Expand All @@ -24,8 +25,19 @@
$: wrapped = $selectedToken !== null && isWrapped($selectedToken as Token);
$: unsupportedStableCoin =
$selectedToken !== null && !isSupported($selectedToken as Token) && isStablecoin($selectedToken as Token);
$: wrappedAssetWarning = $t('bridge.alerts.wrapped_eth');
$: stableCoinWarning = $t('bridge.alerts.stable_coin');
$: if (wrapped || unsupportedStableCoin) {
needsManualConfirmation = true;
} else {
needsManualConfirmation = false;
}
const dispatch = createEventDispatcher();
const editTransactionDetails = () => {
Expand Down Expand Up @@ -69,11 +81,6 @@
<Alert type="warning">{$t('bridge.alerts.slow_bridging')}</Alert>
{/if}

{#if wrapped}
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<Alert type="warning">{@html wrappedAssetWarning}</Alert>
{/if}

<div class="h-sep" />
<!--
Recipient & Processing Fee
Expand All @@ -88,3 +95,13 @@ Recipient & Processing Fee
</div>

<div class="h-sep" />

{#if wrapped}
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<Alert type="warning">{@html wrappedAssetWarning}</Alert>
{/if}

{#if unsupportedStableCoin}
<!-- eslint-disable-next-line svelte/no-at-html-tags -->
<Alert type="warning">{@html stableCoinWarning}</Alert>
{/if}
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@
import { importDone } from '$components/Bridge/state';
import { BridgeSteps, BridgingStatus } from '$components/Bridge/types';
import { ActionButton } from '$components/Button';
import { Icon } from '$components/Icon';
import { StepBack } from '$components/Stepper';
import { account } from '$stores/account';
export let activeStep: BridgeSteps = BridgeSteps.IMPORT;
export let validatingImport = false;
export let needsManualConfirmation: boolean;
export let bridgingStatus: BridgingStatus;
let nextStepButtonText: string;
let manuallyConfirmed = false;
const getStepText = () => {
if (activeStep === BridgeSteps.REVIEW) {
return $t('common.confirm');
Expand Down Expand Up @@ -45,55 +49,68 @@
} else if (activeStep === BridgeSteps.RECIPIENT) {
activeStep = BridgeSteps.REVIEW;
}
reset();
};
$: disabled = !$account || !$account.isConnected;
const reset = () => {
manuallyConfirmed = false;
};
$: showStepNavigation = true;
$: disabled = !$account || !$account.isConnected;
$: {
nextStepButtonText = getStepText();
}
$: needsConfirmation = needsManualConfirmation && !manuallyConfirmed;
</script>

{#if showStepNavigation}
<div class="f-col w-full justify-content-center gap-4">
{#if activeStep === BridgeSteps.IMPORT}
<div class="h-sep mt-0" />
<ActionButton
priority="primary"
disabled={!$importDone || disabled}
loading={validatingImport}
on:click={() => handleNextStep()}>
<span class="body-bold">{nextStepButtonText}</span>
<div class="f-col w-full justify-content-center gap-4">
{#if activeStep === BridgeSteps.IMPORT}
<div class="h-sep mt-0" />
<ActionButton
priority="primary"
disabled={!$importDone || disabled}
loading={validatingImport}
on:click={() => handleNextStep()}>
<span class="body-bold">{nextStepButtonText}</span>
</ActionButton>
{/if}
{#if activeStep === BridgeSteps.REVIEW}
{#if needsManualConfirmation}
<ActionButton priority="primary" disabled={manuallyConfirmed} on:click={() => (manuallyConfirmed = true)}>
{#if needsConfirmation}
{$t('bridge.actions.acknowledge')}
{:else}
<Icon type="check" />{$t('common.confirmed')}
{/if}
</ActionButton>
{/if}
{#if activeStep === BridgeSteps.REVIEW}
<ActionButton priority="primary" {disabled} on:click={() => handleNextStep()}>
<span class="body-bold">{nextStepButtonText}</span>
</ActionButton>

<StepBack on:click={() => handlePreviousStep()}>
{$t('common.back')}
</StepBack>
{/if}
<ActionButton priority="primary" disabled={disabled || needsConfirmation} on:click={() => handleNextStep()}>
<span class="body-bold">{nextStepButtonText}</span>
</ActionButton>

<StepBack on:click={() => handlePreviousStep()}>
{$t('common.back')}
</StepBack>
{/if}

{#if activeStep === BridgeSteps.RECIPIENT}
{#if activeStep === BridgeSteps.RECIPIENT}
<ActionButton {disabled} priority="primary" on:click={() => handleNextStep()}>
<span class="body-bold">{nextStepButtonText}</span>
</ActionButton>
{/if}

{#if activeStep === BridgeSteps.CONFIRM}
{#if bridgingStatus === BridgingStatus.DONE}
<ActionButton {disabled} priority="primary" on:click={() => handleNextStep()}>
<span class="body-bold">{nextStepButtonText}</span>
</ActionButton>
{:else}
<StepBack on:click={() => handlePreviousStep()}>
{$t('common.back')}
</StepBack>
{/if}

{#if activeStep === BridgeSteps.CONFIRM}
{#if bridgingStatus === BridgingStatus.DONE}
<ActionButton {disabled} priority="primary" on:click={() => handleNextStep()}>
<span class="body-bold">{nextStepButtonText}</span>
</ActionButton>
{:else}
<StepBack on:click={() => handlePreviousStep()}>
{$t('common.back')}
</StepBack>
{/if}
{/if}
</div>
{/if}
{/if}
</div>
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
export let loading = false;
export let activeStep: RetrySteps = INITIAL_STEP;
const log = getLogger('RetryDialog');
const dispatch = createEventDispatcher();
const dialogId = `dialog-${uid()}`;
export let activeStep: RetrySteps = INITIAL_STEP;
let canContinue = false;
let retrying: boolean;
let retryDone = false;
Expand Down
Loading

0 comments on commit 781ead2

Please sign in to comment.