Skip to content

Commit

Permalink
Merge branch 'main' into xiaodino/refactor-indexer-add-target
Browse files Browse the repository at this point in the history
  • Loading branch information
mask-pp authored Feb 23, 2024
2 parents abd8989 + f7a12b8 commit eb7261e
Show file tree
Hide file tree
Showing 30 changed files with 686 additions and 179 deletions.
2 changes: 1 addition & 1 deletion .release-please-manifest.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages/branding": "0.3.0",
"packages/bridge-ui": "2.9.0",
"packages/bridge-ui": "2.9.1",
"packages/eventindexer": "0.13.0",
"packages/fork-diff": "0.4.0",
"packages/guardian-prover-health-check": "0.1.0",
Expand Down
11 changes: 11 additions & 0 deletions packages/bridge-ui/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# Changelog

## [2.9.1](https://github.com/taikoxyz/taiko-mono/compare/bridge-ui-v2.9.0...bridge-ui-v2.9.1) (2024-02-22)


### Bug Fixes

* **bridge-ui:** add dependency ([#15999](https://github.com/taikoxyz/taiko-mono/issues/15999)) ([14484a0](https://github.com/taikoxyz/taiko-mono/commit/14484a00c1d59332361fba32b74d39db2ae4b864))
* **bridge-ui:** fix wrong balance updates on network switch ([#15980](https://github.com/taikoxyz/taiko-mono/issues/15980)) ([b556e00](https://github.com/taikoxyz/taiko-mono/commit/b556e000b25fc8d5405cba77f3eebb4152dc1497))
* **bridge-ui:** incorrectly detecting bridged tokens ([#16007](https://github.com/taikoxyz/taiko-mono/issues/16007)) ([b151bcb](https://github.com/taikoxyz/taiko-mono/commit/b151bcb2e159ece03da3c2014e35dbbbed7d8410))
* **bridge-ui:** transactions view styling ([#15997](https://github.com/taikoxyz/taiko-mono/issues/15997)) ([620a22d](https://github.com/taikoxyz/taiko-mono/commit/620a22dcb1ce77a9335dff8bbe0546c4c5065b23))
* fix typos in tests and comments ([#15028](https://github.com/taikoxyz/taiko-mono/issues/15028)) ([54bf597](https://github.com/taikoxyz/taiko-mono/commit/54bf597c89a7f22161eeeffd13c20fe0acb4e2d7))

## [2.9.0](https://github.com/taikoxyz/taiko-mono/compare/bridge-ui-v2-v2.8.0...bridge-ui-v2-v2.9.0) (2023-10-18)


Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-ui/config/sample/configuredBridges.example
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"signalServiceAddress": "",
"hops": [
{
"chaind: ,
"chaind": ,
"crossChainSyncAddress": "",
"signalServiceAddress": "",
}
Expand All @@ -55,7 +55,7 @@
"signalServiceAddress": "",
"hops": [
{
"chaind: ,
"chaind": ,
"crossChainSyncAddress": "",
"signalServiceAddress": "",
}
Expand Down
7 changes: 4 additions & 3 deletions packages/bridge-ui/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "bridge-ui",
"version": "2.9.0",
"version": "2.9.1",
"private": true,
"scripts": {
"dev": "vite dev",
Expand Down Expand Up @@ -61,8 +61,9 @@
"dependencies": {
"@wagmi/connectors": "^4.1.14",
"@wagmi/core": "^2.6.5",
"@walletconnect/ethereum-provider": "^2.11.1",
"@web3modal/wagmi": "^4.0.5",
"@walletconnect/ethereum-provider": "^2.11.2",
"@walletconnect/modal": "^2.6.2",
"@web3modal/wagmi": "^4.0.9",
"@zerodevx/svelte-toast": "^0.9.5",
"axios": "^1.6.7",
"buffer": "^6.0.3",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
{:else}
<ActionButton
priority="primary"
class="!max-w-[215px] !min-h-[32px] !f-items-center !py-0"
class="!max-w-[215px] !min-h-[32px] !max-h-[48px] !f-items-center !py-0"
loading={web3modalOpen}
on:click={connectWallet}>
<div class="flex items-center body-regular space-x-2">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import { getTokenAddresses } from '$libs/token/getTokenAddresses';
import { getLogger } from '$libs/util/logger';
import { uid } from '$libs/util/uid';
import { account } from '$stores/account';
import { type Account, account } from '$stores/account';
import { connectedSourceChain } from '$stores/network';
import DialogView from './DialogView.svelte';
Expand Down Expand Up @@ -98,7 +98,10 @@
}
if (tokenInfo.canonical && tokenInfo.bridged) {
// double check we have the correct address for the destination chain and it is not 0x0
if (value?.addresses[destChain.id] !== tokenInfo.canonical?.address) {
if (
value?.addresses[destChain.id] !== tokenInfo.canonical?.address &&
value?.addresses[destChain.id] !== zeroAddress
) {
log('selected token is bridged', value?.addresses[destChain.id]);
$selectedTokenIsBridged = true;
} else {
Expand Down Expand Up @@ -174,10 +177,11 @@
if (srcChain && destChain) updateBalance($account?.address, srcChain.id, destChain.id);
};
const onAccountChange = () => {
const onAccountChange = (newAccount: Account, prevAccount?: Account) => {
const srcChain = $connectedSourceChain;
const destChain = $destNetwork;
if (srcChain && destChain) updateBalance($account?.address, srcChain.id, destChain.id);
if (destChain && srcChain && (newAccount?.chainId === prevAccount?.chainId || !newAccount || !prevAccount))
updateBalance($account?.address, srcChain.id, destChain.id);
};
$: textClass = disabled ? 'text-secondary-content' : 'font-bold ';
Expand Down
41 changes: 21 additions & 20 deletions packages/bridge-ui/src/components/Transactions/Transaction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -92,28 +92,29 @@
<!-- We disable these warnings as we dynamically add the role -->
<!-- svelte-ignore a11y-no-noninteractive-tabindex -->
<!-- svelte-ignore a11y-no-static-element-interactions -->
<div class="flex text-primary-content md:h-[80px] h-[45px] w-full my-[10px] md:my-[0px]">
<div class="flex items-center text-primary-content md:h-[80px] h-[45px] w-full my-[10px] md:my-[0px]">
{#if isDesktopOrLarger}
{#if loading}
<div class="rounded-[10px] w-[50px] h-[50px] bg-neutral flex items-center justify-center">
<Spinner />
</div>
<div class="f-col text-left space-y-1">
<LoadingText mask="&nbsp;" class="min-w-[50px] max-w-[50px] h-4" />
<LoadingText mask="&nbsp;" class="min-w-[90px] max-w-[90px] h-4" />
<LoadingText mask="&nbsp;" class="min-w-[20px] max-w-[20px] h-4" />
</div>
{:else}
<img alt="nft" src={imgUrl} class="rounded-[10px] min-w-[50px] max-w-[50px] bg-neutral self-center" />
<div class="f-col text-left">
<div class="text-sm">{token?.name ? truncateString(token?.name, 15) : ''}</div>
<div class="text-sm text-secondary-content">
{token?.metadata?.name ? truncateString(token?.metadata?.name, 15) : ''}
<div class="flex md:w-3/12 gap-[8px]">
{#if loading}
<div class="rounded-[10px] w-[50px] h-[50px] bg-neutral flex items-center justify-center">
<Spinner />
</div>
<div class="text-sm text-secondary-content">{token?.tokenId}</div>
</div>
{/if}

<div class="f-col text-left space-y-1">
<LoadingText mask="&nbsp;" class="min-w-[50px] max-w-[50px] h-4" />
<LoadingText mask="&nbsp;" class="min-w-[90px] max-w-[90px] h-4" />
<LoadingText mask="&nbsp;" class="min-w-[20px] max-w-[20px] h-4" />
</div>
{:else}
<img alt="nft" src={imgUrl} class="rounded-[10px] min-w-[50px] max-w-[50px] bg-neutral self-center" />
<div class="f-col text-left">
<div class="text-sm">{token?.name ? truncateString(token?.name, 15) : 'No Token Name'}</div>
<div class="text-sm text-secondary-content">
{token?.metadata?.name ? truncateString(token?.metadata?.name, 15) : ''}
</div>
<div class="text-sm text-secondary-content">{token?.tokenId}</div>
</div>
{/if}
</div>
<div class="w-2/12 py-2 flex flex-row">
<ChainSymbolName chainId={item.srcChainId} />
</div>
Expand Down
2 changes: 2 additions & 0 deletions packages/bridge-ui/src/libs/connect/web3modal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ const chainImages = getChainImages();
export const web3modal = createWeb3Modal({
wagmiConfig: config,
projectId,
featuredWalletIds: [],
excludeWalletIds: ['c57ca95b47569778a828d19178114f4db188b89b763c899ba0be274e97267d96'],
// chains,
chainImages,
themeVariables: {
Expand Down
4 changes: 2 additions & 2 deletions packages/bridge-ui/src/libs/wagmi/client.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { walletConnect } from '@wagmi/connectors';
import { injected, walletConnect } from '@wagmi/connectors';
import { createConfig, getPublicClient, http, reconnect } from '@wagmi/core';

import { PUBLIC_WALLETCONNECT_PROJECT_ID } from '$env/static/public';
Expand All @@ -15,7 +15,7 @@ const transports = chains.reduce((acc, { id }) => ({ ...acc, [id]: http() }), {}
export const config = createConfig({
//@ts-ignore
chains: [...chains],
connectors: [walletConnect({ projectId })],
connectors: [walletConnect({ projectId, showQrModal: false }), injected()],
transports,
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,3 @@
</svelte:head>

<Overview />
<p>hiya! this is just a fun test, you can ignore it</p>
14 changes: 9 additions & 5 deletions packages/protocol/contracts/L2/CrossChainOwned.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,27 @@ import "../bridge/IBridge.sol";
/// signals for transaction approval.
/// @dev Notice that when sending the message on the owner chain, the gas limit of the message must
/// not be zero, so on this chain, some EOA can help execute this transaction.
abstract contract CrossChainOwned is EssentialContract {
abstract contract CrossChainOwned is EssentialContract, IMessageInvocable {
uint64 public ownerChainId; // slot 1
uint64 public nextTxId;
uint256[49] private __gap;

event TransactionExecuted(uint64 indexed txId, bytes4 indexed selector);

error XCO_INVALID_TX_ID();
error XCO_INVALID_OWNER_CHAINID();
error XCO_INVALID_TX_ID();
error XCO_PERMISSION_DENIED();
error XCO_TX_REVERTED();

function executeCrossChainTransaction(uint64 txId, bytes calldata txdata) external {
function onMessageInvocation(bytes calldata data)
external
payable
whenNotPaused
onlyFromNamed("bridge")
{
(uint64 txId, bytes memory txdata) = abi.decode(data, (uint64, bytes));
if (txId != nextTxId) revert XCO_INVALID_TX_ID();

if (msg.sender != resolve("bridge", false)) revert XCO_PERMISSION_DENIED();

IBridge.Context memory ctx = IBridge(msg.sender).context();
if (ctx.srcChainId != ownerChainId || ctx.from != owner()) {
revert XCO_PERMISSION_DENIED();
Expand Down
13 changes: 11 additions & 2 deletions packages/protocol/contracts/bridge/Bridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

pragma solidity 0.8.24;

import "@openzeppelin/contracts/utils/Address.sol";
import "../common/EssentialContract.sol";
import "../libs/LibAddress.sol";
import "../signal/ISignalService.sol";
Expand All @@ -24,6 +25,7 @@ import "./IBridge.sol";
/// @notice See the documentation for {IBridge}.
/// @dev The code hash for the same address on L1 and L2 may be different.
contract Bridge is EssentialContract, IBridge {
using Address for address;
using LibAddress for address;
using LibAddress for address payable;

Expand Down Expand Up @@ -528,8 +530,15 @@ contract Bridge is EssentialContract, IBridge {

_storeContext({ msgHash: msgHash, from: message.from, srcChainId: message.srcChainId });

// Perform the message call and capture the success value
(success,) = message.to.call{ value: message.value, gas: gasLimit }(message.data);
if (
message.data.length >= 4 // msg can be empty
&& bytes4(message.data) != IMessageInvocable.onMessageInvocation.selector
&& message.to.isContract()
) {
success = false;
} else {
(success,) = message.to.call{ value: message.value, gas: gasLimit }(message.data);
}

// Reset the context after the message call
_resetContext();
Expand Down
9 changes: 9 additions & 0 deletions packages/protocol/contracts/bridge/IBridge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,12 @@ interface IRecallableSender {
external
payable;
}

/// @title IMessageInvocable
/// @notice An interface that all bridge message receiver shall implement
interface IMessageInvocable {
/// @notice Called when this contract is the bridge target.
/// @param data The data for this contract to interpret.
/// @dev This method should be guarded with `onlyFromNamed("bridge")`.
function onMessageInvocation(bytes calldata data) external payable;
}
16 changes: 9 additions & 7 deletions packages/protocol/contracts/libs/LibTrieProof.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@

pragma solidity ^0.8.24;

import { RLPReader } from "../thirdparty/optimism/rlp/RLPReader.sol";
import { SecureMerkleTrie } from "../thirdparty/optimism/trie/SecureMerkleTrie.sol";
import "../thirdparty/optimism/rlp/RLPReader.sol";
import "../thirdparty/optimism/rlp/RLPWriter.sol";
import "../thirdparty/optimism/trie/SecureMerkleTrie.sol";

/**
* @title LibTrieProof
*/
/// @title LibTrieProof
library LibTrieProof {
// The consensus format representing account is RLP encoded in the
// following order: nonce, balance, storageHash, codeHash.
Expand All @@ -35,7 +34,7 @@ library LibTrieProof {
bytes32 rootHash,
address addr,
bytes32 slot,
bytes memory value,
bytes32 value,
bytes[] memory accountProof,
bytes[] memory storageProof
)
Expand All @@ -58,7 +57,10 @@ library LibTrieProof {
}

bool verified = SecureMerkleTrie.verifyInclusionProof(
bytes.concat(slot), value, storageProof, bytes32(storageRoot)
bytes.concat(slot),
RLPWriter.writeUint(uint256(value)),
storageProof,
bytes32(storageRoot)
);

if (!verified) revert LTP_INVALID_INCLUSION_PROOF();
Expand Down
2 changes: 1 addition & 1 deletion packages/protocol/contracts/signal/SignalService.sol
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ contract SignalService is EssentialContract, ISignalService {
hop.rootHash,
signalService,
getSignalSlot(chainId, app, signal),
bytes.concat(value),
value,
hop.accountProof,
hop.storageProof
);
Expand Down
Loading

0 comments on commit eb7261e

Please sign in to comment.