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

fix(bridge-ui): fix relayer #13548

Merged
merged 3 commits into from
Apr 6, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
9 changes: 1 addition & 8 deletions packages/bridge-ui/src/App.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,7 @@
const apiTxs = await $relayerApi.getAllBridgeTransactionByAddress(
userAddress,
);

const blockInfoMap = await $relayerApi.getBlockInfo();
relayerBlockInfoMap.set(blockInfoMap);

Expand All @@ -110,14 +111,6 @@
return !hashToApiTxsMap.has(tx.hash.toLowerCase());
});

// const updatedStorageTxs: BridgeTransaction[] = txs.filter((tx) => {
// const blockInfo = blockInfoMap.get(tx.fromChainId);
// if (blockInfo?.latestProcessedBlock >= tx.receipt?.blockNumber) {
// return false;
// }
// return true;
// });

$transactioner.updateStorageByAddress(userAddress, updatedStorageTxs);

transactions.set([...updatedStorageTxs, ...apiTxs]);
Expand Down
2 changes: 1 addition & 1 deletion packages/bridge-ui/src/components/ChainDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
await switchNetwork({
chainId: chain.id,
});
const provider = new ethers.providers.Web3Provider(window.ethereum);
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');
await provider.send('eth_requestAccounts', []);

fromChain.set(chain);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</tr>
</thead>
<tbody class="text-sm md:text-base">
{#each $transactions as transaction}
{#each $transactions as transaction (transaction.hash)}
<Transaction
on:claimNotice={({ detail }) => noticeModal.open(detail)}
on:tooltipStatus={() => (showMessageStatusTooltip = true)}
Expand Down
5 changes: 4 additions & 1 deletion packages/bridge-ui/src/components/form/SelectChain.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@
await switchNetwork({
chainId: chain.id,
});
const provider = new ethers.providers.Web3Provider(window.ethereum);
const provider = new ethers.providers.Web3Provider(
window.ethereum,
'any',
);
await provider.send('eth_requestAccounts', []);

fromChain.set(chain);
Expand Down
8 changes: 4 additions & 4 deletions packages/bridge-ui/src/domain/relayerApi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export type TransactionData = {
Memo: string;
Owner: Address;
Sender: Address;
GasLimit: number;
CallValue: number;
DepositValue: number;
ProcessingFee: number;
GasLimit: string;
CallValue: string;
DepositValue: string;
ProcessingFee: string;
RefundAddress: Address;
Data: string;
};
Expand Down
23 changes: 19 additions & 4 deletions packages/bridge-ui/src/relayer-api/RelayerAPIService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,17 @@ export class RelayerAPIService implements RelayerAPI {
return [];
}

apiTxs.items.map((t, i) => {
apiTxs.items.map((tx, j) => {
if (
tx.data.Raw.transactionHash === t.data.Raw.transactionHash &&
i !== j
) {
apiTxs.items = apiTxs.items.filter((_, index) => index !== j);
}
});
});

const txs = apiTxs.items.map((tx: APIResponseTransaction) => {
let data = tx.data.Message.Data;
if (data === '') {
Expand Down Expand Up @@ -93,12 +104,16 @@ export class RelayerAPIService implements RelayerAPI {
memo: tx.data.Message.Memo,
owner: tx.data.Message.Owner,
sender: tx.data.Message.Sender,
gasLimit: BigNumber.from(tx.data.Message.GasLimit),
callValue: BigNumber.from(tx.data.Message.CallValue),
gasLimit: BigNumber.from(tx.data.Message.GasLimit.toString()),
callValue: BigNumber.from(tx.data.Message.CallValue.toString()),
srcChainId: tx.data.Message.SrcChainId,
destChainId: tx.data.Message.DestChainId,
depositValue: BigNumber.from(`${tx.data.Message.DepositValue}`),
processingFee: BigNumber.from(`${tx.data.Message.ProcessingFee}`),
depositValue: BigNumber.from(
`${tx.data.Message.DepositValue.toString()}`,
),
processingFee: BigNumber.from(
`${tx.data.Message.ProcessingFee.toString()}`,
),
refundAddress: tx.data.Message.RefundAddress,
},
};
Expand Down
5 changes: 4 additions & 1 deletion packages/bridge-ui/src/utils/switchChainAndSetSigner.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ export async function switchChainAndSetSigner(chain: Chain) {

await switchNetwork({ chainId });

const provider = new ethers.providers.Web3Provider(globalThis.ethereum);
const provider = new ethers.providers.Web3Provider(
globalThis.ethereum,
'any',
);
await provider.send('eth_requestAccounts', []);

fromChain.set(chain);
Expand Down
8 changes: 4 additions & 4 deletions packages/starter-dapp/src/components/ChainDropdown.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
await switchNetwork({
chainId: chain.id,
});
const provider = new ethers.providers.Web3Provider(window.ethereum);
const provider = new ethers.providers.Web3Provider(window.ethereum, "any");
await provider.send("eth_requestAccounts", []);

fromChain.set(chain);
Expand All @@ -31,13 +31,13 @@
<svelte:component this={$fromChain.icon} />
<span class="ml-2 hidden md:inline-block">{$fromChain.name}</span>
{:else}
<span class="ml-2 flex items-center">
<ExclamationTriangle class='mr-2' size='20' />
<span class="ml-2 flex items-center">
<ExclamationTriangle class="mr-2" size="20" />
<span class="hidden md:block">Invalid Chain</span>
</span>
{/if}
</span>
<ChevronDown size='20' />
<ChevronDown size="20" />
</label>
<ul
tabindex="0"
Expand Down