Skip to content

Commit

Permalink
fix: some issue
Browse files Browse the repository at this point in the history
  • Loading branch information
oriole-pub committed Mar 29, 2023
1 parent 860e072 commit 6e6fcad
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 23 deletions.
44 changes: 23 additions & 21 deletions src/content/courses/basic-operation/chapter_1/ConnectWallet.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Component, Show } from 'solid-js';
import { Component, createEffect, on, Show } from 'solid-js';
import { useWalletContext } from '~/components/CKBCore/WalletContext';
import { MetaMaskInstallError } from '~/components/CKBCore/WalletProvider';
import { useToast } from '~/components/Toast/ToastContext';
Expand All @@ -11,27 +11,30 @@ export const ConnectWallet: Component = () => {
const toast = useToast();

const connectWallet = () => {
wallet
.connect()
.then(() => {
course.finishChapter();
})
.catch((err: Error) => {
if (err instanceof MetaMaskInstallError) {
toast.error({
title: 'Error',
description:
'Please make sure that the MetaMask browser extension is installed before attempting to reconnect.',
});
} else {
toast.error({
title: 'Error',
description: `${err.message}`,
});
}
});
wallet.connect().catch((err: Error) => {
if (err instanceof MetaMaskInstallError) {
toast.error({
title: 'Error',
description:
'Please make sure that the MetaMask browser extension is installed before attempting to reconnect.',
});
} else {
toast.error({
title: 'Error',
description: `${err.message}`,
});
}
});
};

createEffect(
on(wallet.connected, (connected) => {
if (connected) {
course.finishChapter();
}
}),
);

return (
<div class="not-prose">
<Show
Expand All @@ -52,7 +55,6 @@ export const ConnectWallet: Component = () => {
</span>
<div class="text-xs flex flex-col pt-2">
<span class="font-medium">CKB Address:</span>
<span class="break-all">{wallet.provider()?.ethAddress}</span>
<span class="break-all">{wallet.provider()?.ckbAddress}</span>
</div>
</div>
Expand Down
4 changes: 2 additions & 2 deletions src/content/courses/basic-operation/chapter_1/chapter_1.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { WalletReady } from "~/content/components/WalletReady.tsx";

# Connected wallet

Throughout the practical operation course, we will use the testing chain of CKB for all on-chain operations. As a starting point, the first thing we need to do is to connect to the MetaMask wallet.
Throughout the practical operation course, we will use [CKB testnet](https://pudge.explorer.nervos.org) for all on-chain operations. As a starting point, the first thing we need to do is to connect to the MetaMask wallet.

> In order to ensure the smooth progress of the course, after successfully connecting to the wallet, we will assign 10 `Cells` with a `Capacity` of `100 CKB` to your account.
Expand All @@ -32,7 +32,7 @@ When we say that a wallet has a certain amount of CKB (the native token), we are

# Block

Each block below represents a block, displaying the latest nine blocks on the test chain. The noteworthy information in each block is the transactions displayed in the lower half.
Each square below represents a block, displaying the latest nine blocks on the CKB testnet. The noteworthy information in each block is the transactions displayed in the lower half.

<WalletReady>
<ShowBlocks />
Expand Down

0 comments on commit 6e6fcad

Please sign in to comment.