create-dubhe 0.0.7 → 0.0.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-dubhe",
3
- "version": "0.0.7",
3
+ "version": "0.0.8",
4
4
  "type": "module",
5
5
  "license": "MIT",
6
6
  "author": "team@obelisk.build",
@@ -39,6 +39,7 @@
39
39
  "react-dom": "18.1.0",
40
40
  "react-select": "^5.4.0",
41
41
  "swiper": "^9.2.4",
42
+ "sonner": "^1.5.0",
42
43
  "chalk": "^4.1.2"
43
44
  },
44
45
  "devDependencies": {
@@ -24,8 +24,10 @@ async function generateAccount() {
24
24
  export const ACCOUNT = '${keypair.getRoochAddress().toHexAddress()}';
25
25
  `,
26
26
  );
27
-
28
- console.log(`Using existing Account: ${keypair.getRoochAddress().toHexAddress()}`);
27
+ console.log(`Using existing account:`);
28
+ console.log(`Rooch Bech32 address: ${keypair.getRoochAddress().toStr()}`);
29
+ console.log(`Rooch Hex address: ${keypair.getRoochAddress().toHexAddress()}`);
30
+ console.log(`Bitcoin address: ${keypair.getBitcoinAddress().toStr()}`);
29
31
  return;
30
32
  }
31
33
  } catch (error) {
@@ -49,7 +51,10 @@ export const ACCOUNT = '${keypair.getRoochAddress().toHexAddress()}';
49
51
  `,
50
52
  );
51
53
 
52
- console.log(`Generate new Account: ${keypair.getRoochAddress().toHexAddress()}`);
54
+ console.log(`Generate new Account:`);
55
+ console.log(`Rooch Bech32 address: ${keypair.getRoochAddress().toStr()}`);
56
+ console.log(`Rooch Hex address: ${keypair.getRoochAddress().toHexAddress()}`);
57
+ console.log(`Bitcoin address: ${keypair.getBitcoinAddress().toStr()}`);
53
58
  }
54
59
 
55
60
  generateAccount();
@@ -1,9 +1,15 @@
1
1
  import 'tailwindcss/tailwind.css';
2
2
  import '../css/font-awesome.css';
3
3
  import type { AppProps } from 'next/app';
4
+ import { Toaster } from 'sonner';
4
5
 
5
6
  function MyApp({ Component, pageProps }: AppProps) {
6
- return <Component {...pageProps} />;
7
+ return (
8
+ <>
9
+ <Toaster />
10
+ <Component {...pageProps} />
11
+ </>
12
+ );
7
13
  }
8
14
 
9
15
  export default MyApp;
@@ -1,10 +1,11 @@
1
- import { loadMetadata, Dubhe, Transaction } from '@0xobelisk/rooch-client';
1
+ import { loadMetadata, Dubhe, Transaction, NetworkType } from '@0xobelisk/rooch-client';
2
2
  import { useEffect, useState } from 'react';
3
3
  import { useAtom } from 'jotai';
4
4
  import { Value } from '../../jotai';
5
5
  import { useRouter } from 'next/router';
6
6
  import { NETWORK, PACKAGE_ID } from '../../chain/config';
7
7
  import { PRIVATEKEY } from '../../chain/key';
8
+ import { toast } from 'sonner';
8
9
 
9
10
  const Home = () => {
10
11
  const router = useRouter();
@@ -43,10 +44,18 @@ const Home = () => {
43
44
  if (response.execution_info.status.type == 'executed') {
44
45
  setTimeout(async () => {
45
46
  await query_counter_value();
47
+ toast('Transfer Successful', {
48
+ description: new Date().toUTCString(),
49
+ action: {
50
+ label: 'Check in Explorer',
51
+ onClick: () => window.open(`https://roochscan.io/tx/${response.execution_info.tx_hash}`, '_blank'),
52
+ },
53
+ });
46
54
  setLoading(false);
47
55
  }, 200);
48
56
  }
49
57
  } catch (error) {
58
+ toast.error('Transaction failed. Please try again.');
50
59
  setLoading(false);
51
60
  console.error(error);
52
61
  }
@@ -41,6 +41,7 @@
41
41
  "react-dom": "18.1.0",
42
42
  "react-select": "^5.4.0",
43
43
  "swiper": "^9.2.4",
44
+ "sonner": "^1.5.0",
44
45
  "chalk": "^4.1.2"
45
46
  },
46
47
  "devDependencies": {
@@ -1,9 +1,15 @@
1
1
  import 'tailwindcss/tailwind.css';
2
2
  import '../css/font-awesome.css';
3
3
  import type { AppProps } from 'next/app';
4
+ import { Toaster } from 'sonner';
4
5
 
5
6
  function MyApp({ Component, pageProps }: AppProps) {
6
- return <Component {...pageProps} />;
7
+ return (
8
+ <>
9
+ <Toaster />
10
+ <Component {...pageProps} />
11
+ </>
12
+ );
7
13
  }
8
14
 
9
15
  export default MyApp;
@@ -1,10 +1,31 @@
1
- import { loadMetadata, Dubhe, Transaction, TransactionResult, DevInspectResults } from '@0xobelisk/sui-client';
1
+ import {
2
+ loadMetadata,
3
+ Dubhe,
4
+ Transaction,
5
+ TransactionResult,
6
+ DevInspectResults,
7
+ NetworkType,
8
+ } from '@0xobelisk/sui-client';
2
9
  import { useEffect, useState } from 'react';
3
10
  import { useAtom } from 'jotai';
4
11
  import { Value } from '../../jotai';
5
12
  import { useRouter } from 'next/router';
6
13
  import { Counter_Object_Id, NETWORK, PACKAGE_ID } from '../../chain/config';
7
14
  import { PRIVATEKEY } from '../../chain/key';
15
+ import { toast } from 'sonner';
16
+
17
+ function getExplorerUrl(network: NetworkType, digest: string) {
18
+ switch (network) {
19
+ case 'testnet':
20
+ return `https://explorer.polymedia.app/txblock/${digest}?network=${network}`;
21
+ case 'mainnet':
22
+ return `https://suiscan.xyz/tx/${digest}`;
23
+ case 'devnet':
24
+ return `https://explorer.polymedia.app/txblock/${digest}?network=${network}`;
25
+ case 'localnet':
26
+ return `https://explorer.polymedia.app/txblock/${digest}?network=local`;
27
+ }
28
+ }
8
29
 
9
30
  const Home = () => {
10
31
  const router = useRouter();
@@ -19,11 +40,10 @@ const Home = () => {
19
40
  metadata: metadata,
20
41
  });
21
42
  const tx = new Transaction();
22
- console.log('counterObjectId:', Counter_Object_Id);
23
43
  const query_value = (await dubhe.query.counter_schema.get_value(tx, [
24
44
  tx.object(Counter_Object_Id),
25
45
  ])) as DevInspectResults;
26
- console.log(dubhe.view(query_value)[0]);
46
+ console.log('Counter value:', dubhe.view(query_value)[0]);
27
47
  setValue(dubhe.view(query_value)[0]);
28
48
  };
29
49
 
@@ -43,10 +63,20 @@ const Home = () => {
43
63
  if (response.effects.status.status == 'success') {
44
64
  setTimeout(async () => {
45
65
  await query_counter_value();
66
+ console.log(response);
67
+ console.log(response.digest);
68
+ toast('Transfer Successful', {
69
+ description: new Date().toUTCString(),
70
+ action: {
71
+ label: 'Check in Explorer',
72
+ onClick: () => window.open(getExplorerUrl(NETWORK, response.digest), '_blank'),
73
+ },
74
+ });
46
75
  setLoading(false);
47
76
  }, 200);
48
77
  }
49
78
  } catch (error) {
79
+ toast.error('Transaction failed. Please try again.');
50
80
  setLoading(false);
51
81
  console.error(error);
52
82
  }
@@ -1,14 +1,12 @@
1
1
  import type { NextPage } from 'next';
2
- import Home from "./home";
2
+ import Home from './home';
3
3
 
4
4
  const IndexPage: NextPage = () => {
5
5
  return (
6
- <main>
7
- <Home/>
8
- </main>
9
- )
10
- }
11
-
12
- export default IndexPage
13
-
6
+ <main>
7
+ <Home />
8
+ </main>
9
+ );
10
+ };
14
11
 
12
+ export default IndexPage;
@@ -43,6 +43,7 @@
43
43
  "react-dom": "18.1.0",
44
44
  "react-select": "^5.4.0",
45
45
  "swiper": "^9.2.4",
46
+ "sonner": "^1.5.0",
46
47
  "chalk": "^4.1.2"
47
48
  },
48
49
  "devDependencies": {
@@ -2,6 +2,7 @@ import 'tailwindcss/tailwind.css';
2
2
  import type { AppProps } from 'next/app';
3
3
  import '../css/font-awesome.css';
4
4
  import '@mysten/dapp-kit/dist/index.css';
5
+ import { Toaster } from 'sonner';
5
6
 
6
7
  import { createNetworkConfig, SuiClientProvider, WalletProvider } from '@mysten/dapp-kit';
7
8
  import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
@@ -15,6 +16,7 @@ const { networkConfig } = createNetworkConfig({
15
16
  testnet: { url: getFullnodeUrl('testnet') },
16
17
  mainnet: { url: getFullnodeUrl('mainnet') },
17
18
  });
19
+
18
20
  const queryClient = new QueryClient();
19
21
 
20
22
  function MyApp({ Component, pageProps }: AppProps) {
@@ -22,6 +24,7 @@ function MyApp({ Component, pageProps }: AppProps) {
22
24
  <QueryClientProvider client={queryClient}>
23
25
  <SuiClientProvider networks={networkConfig} defaultNetwork={NETWORK}>
24
26
  <WalletProvider>
27
+ <Toaster />
25
28
  <Component {...pageProps} />
26
29
  </WalletProvider>
27
30
  </SuiClientProvider>
@@ -1,11 +1,24 @@
1
- import { loadMetadata, Dubhe, Transaction, DevInspectResults } from '@0xobelisk/sui-client';
1
+ import { loadMetadata, Dubhe, Transaction, DevInspectResults, NetworkType } from '@0xobelisk/sui-client';
2
2
  import { useEffect, useState } from 'react';
3
3
  import { useAtom } from 'jotai';
4
4
  import { Value } from '../../jotai';
5
5
  import { useRouter } from 'next/router';
6
6
  import { Counter_Object_Id, NETWORK, PACKAGE_ID } from '../../chain/config';
7
7
  import { ConnectButton, useCurrentWallet, useSignAndExecuteTransaction, useCurrentAccount } from '@mysten/dapp-kit';
8
+ import { toast } from 'sonner';
8
9
 
10
+ function getExplorerUrl(network: NetworkType, digest: string) {
11
+ switch (network) {
12
+ case 'testnet':
13
+ return `https://explorer.polymedia.app/txblock/${digest}?network=${network}`;
14
+ case 'mainnet':
15
+ return `https://suiscan.xyz/tx/${digest}`;
16
+ case 'devnet':
17
+ return `https://explorer.polymedia.app/txblock/${digest}?network=${network}`;
18
+ case 'localnet':
19
+ return `https://explorer.polymedia.app/txblock/${digest}?network=local`;
20
+ }
21
+ }
9
22
  /**
10
23
  * Home component for the counter application
11
24
  * Manages the counter state, user balance, and interactions with the Sui blockchain
@@ -32,7 +45,6 @@ const Home: React.FC = () => {
32
45
  metadata: metadata,
33
46
  });
34
47
  const tx = new Transaction();
35
- console.log('Counter Object ID:', Counter_Object_Id);
36
48
  const queryValue = (await dubhe.query.counter_schema.get_value(tx, [
37
49
  tx.object(Counter_Object_Id),
38
50
  ])) as DevInspectResults;
@@ -77,16 +89,24 @@ const Home: React.FC = () => {
77
89
  chain: `sui:${NETWORK}`,
78
90
  },
79
91
  {
80
- onSuccess: async () => {
92
+ onSuccess: async result => {
81
93
  // Wait for a short period before querying the latest data
82
94
  setTimeout(async () => {
83
95
  await queryCounter();
84
96
  await getBalance();
97
+ toast('Transfer Successful', {
98
+ description: new Date().toUTCString(),
99
+ action: {
100
+ label: 'Check in Explorer',
101
+ onClick: () => window.open(getExplorerUrl(NETWORK, result.digest), '_blank'),
102
+ },
103
+ });
85
104
  setLoading(false);
86
105
  }, 2000); // Wait for 2 seconds before querying, adjust as needed
87
106
  },
88
107
  onError: error => {
89
108
  console.error('Transaction failed:', error);
109
+ toast.error('Transaction failed. Please try again.');
90
110
  setLoading(false);
91
111
  },
92
112
  },