@iota/create-dapp 0.4.5 → 0.5.0
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/CHANGELOG.md +31 -0
- package/package.json +5 -5
- package/templates/react-client-dapp/README.md +2 -2
- package/templates/react-client-dapp/index.html +11 -57
- package/templates/react-client-dapp/package.json +29 -35
- package/templates/react-client-dapp/src/App.tsx +15 -34
- package/templates/react-client-dapp/src/OwnedObjects.tsx +34 -35
- package/templates/react-client-dapp/src/WalletStatus.tsx +17 -18
- package/templates/react-client-dapp/src/index.css +9 -0
- package/templates/react-client-dapp/src/main.tsx +18 -21
- package/templates/react-client-dapp/src/networkConfig.ts +7 -8
- package/templates/react-client-dapp/tsconfig.json +20 -21
- package/templates/react-client-dapp/vite.config.ts +4 -3
- package/templates/react-e2e-counter/README.md +4 -4
- package/templates/react-e2e-counter/index.html +11 -57
- package/templates/react-e2e-counter/package.json +29 -36
- package/templates/react-e2e-counter/src/App.tsx +36 -55
- package/templates/react-e2e-counter/src/Counter.tsx +84 -90
- package/templates/react-e2e-counter/src/CreateCounter.tsx +47 -57
- package/templates/react-e2e-counter/src/constants.ts +3 -3
- package/templates/react-e2e-counter/src/index.css +9 -0
- package/templates/react-e2e-counter/src/main.tsx +18 -21
- package/templates/react-e2e-counter/src/networkConfig.ts +20 -21
- package/templates/react-e2e-counter/tsconfig.json +20 -21
- package/templates/react-e2e-counter/vite.config.ts +4 -3
- package/templates/react-client-dapp/eslint.config.js +0 -28
- package/templates/react-client-dapp/prettier.config.cjs +0 -4
- package/templates/react-client-dapp/tsconfig.node.json +0 -10
- package/templates/react-e2e-counter/eslint.config.js +0 -28
- package/templates/react-e2e-counter/prettier.config.cjs +0 -4
- package/templates/react-e2e-counter/tsconfig.node.json +0 -10
|
@@ -1,38 +1,31 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
"eslint-plugin-react-refresh": "^0.4.7",
|
|
32
|
-
"eslint-plugin-react": "^7.37.2",
|
|
33
|
-
"typescript-eslint": "^8.18.0",
|
|
34
|
-
"prettier": "^3.3.2",
|
|
35
|
-
"typescript": "^5.5.3",
|
|
36
|
-
"vite": "^5.4.12"
|
|
37
|
-
}
|
|
2
|
+
"name": "@iota/template-react-e2e-counter",
|
|
3
|
+
"private": true,
|
|
4
|
+
"version": "0.0.0",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"scripts": {
|
|
7
|
+
"dev": "vite",
|
|
8
|
+
"build": "tsc && vite build",
|
|
9
|
+
"lint": "oxlint .",
|
|
10
|
+
"format": "oxfmt --write src/",
|
|
11
|
+
"preview": "vite preview"
|
|
12
|
+
},
|
|
13
|
+
"dependencies": {
|
|
14
|
+
"@iota/dapp-kit": "workspace:*",
|
|
15
|
+
"@iota/iota-sdk": "workspace:*",
|
|
16
|
+
"@tanstack/react-query": "^5.91.2",
|
|
17
|
+
"react": "^18.3.1",
|
|
18
|
+
"react-dom": "^18.3.1"
|
|
19
|
+
},
|
|
20
|
+
"devDependencies": {
|
|
21
|
+
"@tailwindcss/vite": "^4.2.2",
|
|
22
|
+
"@types/react": "^18.3.28",
|
|
23
|
+
"@types/react-dom": "^18.3.7",
|
|
24
|
+
"@vitejs/plugin-react": "^6.0.1",
|
|
25
|
+
"oxfmt": "^0.41.0",
|
|
26
|
+
"oxlint": "^1.56.0",
|
|
27
|
+
"tailwindcss": "^4.2.2",
|
|
28
|
+
"typescript": "^5.9.3",
|
|
29
|
+
"vite": "^8.0.1"
|
|
30
|
+
}
|
|
38
31
|
}
|
|
@@ -1,61 +1,42 @@
|
|
|
1
|
-
import { ConnectButton, useCurrentAccount } from
|
|
2
|
-
import { isValidIotaObjectId } from
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import { CreateCounter } from "./CreateCounter";
|
|
1
|
+
import { ConnectButton, useCurrentAccount } from '@iota/dapp-kit';
|
|
2
|
+
import { isValidIotaObjectId } from '@iota/iota-sdk/utils';
|
|
3
|
+
import { useState } from 'react';
|
|
4
|
+
import { Counter } from './Counter';
|
|
5
|
+
import { CreateCounter } from './CreateCounter';
|
|
7
6
|
|
|
8
7
|
function App() {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
const currentAccount = useCurrentAccount();
|
|
9
|
+
const [counterId, setCounter] = useState(() => {
|
|
10
|
+
const hash = window.location.hash.slice(1);
|
|
11
|
+
return isValidIotaObjectId(hash) ? hash : null;
|
|
12
|
+
});
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
{currentAccount ? (
|
|
42
|
-
counterId ? (
|
|
43
|
-
<Counter id={counterId} />
|
|
44
|
-
) : (
|
|
45
|
-
<CreateCounter
|
|
46
|
-
onCreated={(id) => {
|
|
47
|
-
window.location.hash = id;
|
|
48
|
-
setCounter(id);
|
|
49
|
-
}}
|
|
50
|
-
/>
|
|
51
|
-
)
|
|
52
|
-
) : (
|
|
53
|
-
<Heading>Please connect your wallet</Heading>
|
|
54
|
-
)}
|
|
55
|
-
</Container>
|
|
56
|
-
</Container>
|
|
57
|
-
</>
|
|
58
|
-
);
|
|
14
|
+
return (
|
|
15
|
+
<>
|
|
16
|
+
<div className="sticky top-0 flex px-4 py-2 justify-between items-center border-b border-gray-800 bg-gray-950">
|
|
17
|
+
<h1 className="text-2xl font-bold">dApp Starter Template</h1>
|
|
18
|
+
<ConnectButton />
|
|
19
|
+
</div>
|
|
20
|
+
<div className="max-w-4xl mx-auto">
|
|
21
|
+
<div className="mt-5 pt-2 px-4 bg-gray-900 min-h-[500px] rounded">
|
|
22
|
+
{currentAccount ? (
|
|
23
|
+
counterId ? (
|
|
24
|
+
<Counter id={counterId} />
|
|
25
|
+
) : (
|
|
26
|
+
<CreateCounter
|
|
27
|
+
onCreated={(id) => {
|
|
28
|
+
window.location.hash = id;
|
|
29
|
+
setCounter(id);
|
|
30
|
+
}}
|
|
31
|
+
/>
|
|
32
|
+
)
|
|
33
|
+
) : (
|
|
34
|
+
<h2 className="text-xl font-semibold">Please connect your wallet</h2>
|
|
35
|
+
)}
|
|
36
|
+
</div>
|
|
37
|
+
</div>
|
|
38
|
+
</>
|
|
39
|
+
);
|
|
59
40
|
}
|
|
60
41
|
|
|
61
42
|
export default App;
|
|
@@ -1,108 +1,102 @@
|
|
|
1
1
|
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from
|
|
7
|
-
import type { IotaObjectData } from
|
|
8
|
-
import { Transaction } from
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import { useState } from "react";
|
|
12
|
-
import ClipLoader from "react-spinners/ClipLoader";
|
|
2
|
+
useCurrentAccount,
|
|
3
|
+
useSignAndExecuteTransaction,
|
|
4
|
+
useIotaClient,
|
|
5
|
+
useIotaClientQuery,
|
|
6
|
+
} from '@iota/dapp-kit';
|
|
7
|
+
import type { IotaObjectData } from '@iota/iota-sdk/client';
|
|
8
|
+
import { Transaction } from '@iota/iota-sdk/transactions';
|
|
9
|
+
import { useNetworkVariable } from './networkConfig';
|
|
10
|
+
import { useState } from 'react';
|
|
13
11
|
|
|
14
12
|
export function Counter({ id }: { id: string }) {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
const [waitingForTxn, setWaitingForTxn] = useState("");
|
|
13
|
+
const counterPackageId = useNetworkVariable('counterPackageId');
|
|
14
|
+
const iotaClient = useIotaClient();
|
|
15
|
+
const currentAccount = useCurrentAccount();
|
|
16
|
+
const { mutate: signAndExecute } = useSignAndExecuteTransaction();
|
|
17
|
+
const { data, isPending, error, refetch } = useIotaClientQuery('getObject', {
|
|
18
|
+
id,
|
|
19
|
+
options: {
|
|
20
|
+
showContent: true,
|
|
21
|
+
showOwner: true,
|
|
22
|
+
},
|
|
23
|
+
});
|
|
28
24
|
|
|
29
|
-
|
|
30
|
-
setWaitingForTxn(method);
|
|
25
|
+
const [waitingForTxn, setWaitingForTxn] = useState('');
|
|
31
26
|
|
|
32
|
-
const
|
|
27
|
+
const executeMoveCall = (method: 'increment' | 'reset') => {
|
|
28
|
+
setWaitingForTxn(method);
|
|
33
29
|
|
|
34
|
-
|
|
35
|
-
tx.moveCall({
|
|
36
|
-
arguments: [tx.object(id), tx.pure.u64(0)],
|
|
37
|
-
target: `${counterPackageId}::counter::set_value`,
|
|
38
|
-
});
|
|
39
|
-
} else {
|
|
40
|
-
tx.moveCall({
|
|
41
|
-
arguments: [tx.object(id)],
|
|
42
|
-
target: `${counterPackageId}::counter::increment`,
|
|
43
|
-
});
|
|
44
|
-
}
|
|
30
|
+
const tx = new Transaction();
|
|
45
31
|
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{
|
|
51
|
-
onSuccess: (tx) => {
|
|
52
|
-
iotaClient
|
|
53
|
-
.waitForTransaction({ digest: tx.digest })
|
|
54
|
-
.then(async () => {
|
|
55
|
-
await refetch();
|
|
56
|
-
setWaitingForTxn("");
|
|
32
|
+
if (method === 'reset') {
|
|
33
|
+
tx.moveCall({
|
|
34
|
+
arguments: [tx.object(id), tx.pure.u64(0)],
|
|
35
|
+
target: `${counterPackageId}::counter::set_value`,
|
|
57
36
|
});
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
37
|
+
} else {
|
|
38
|
+
tx.moveCall({
|
|
39
|
+
arguments: [tx.object(id)],
|
|
40
|
+
target: `${counterPackageId}::counter::increment`,
|
|
41
|
+
});
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
signAndExecute(
|
|
45
|
+
{
|
|
46
|
+
transaction: tx,
|
|
47
|
+
},
|
|
48
|
+
{
|
|
49
|
+
onSuccess: (tx) => {
|
|
50
|
+
iotaClient.waitForTransaction({ digest: tx.digest }).then(async () => {
|
|
51
|
+
await refetch();
|
|
52
|
+
setWaitingForTxn('');
|
|
53
|
+
});
|
|
54
|
+
},
|
|
55
|
+
},
|
|
56
|
+
);
|
|
57
|
+
};
|
|
62
58
|
|
|
63
|
-
|
|
59
|
+
if (isPending) return <p className="text-gray-300">Loading...</p>;
|
|
64
60
|
|
|
65
|
-
|
|
61
|
+
if (error) return <p className="text-red-400">Error: {error.message}</p>;
|
|
66
62
|
|
|
67
|
-
|
|
63
|
+
if (!data.data) return <p className="text-gray-300">Not found</p>;
|
|
68
64
|
|
|
69
|
-
|
|
70
|
-
getCounterFields(data.data)?.owner === currentAccount?.address;
|
|
65
|
+
const ownedByCurrentAccount = getCounterFields(data.data)?.owner === currentAccount?.address;
|
|
71
66
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
67
|
+
return (
|
|
68
|
+
<>
|
|
69
|
+
<h3 className="text-lg font-semibold">Counter {id}</h3>
|
|
75
70
|
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
</>
|
|
100
|
-
);
|
|
71
|
+
<div className="flex flex-col gap-2">
|
|
72
|
+
<p className="text-gray-300">Count: {getCounterFields(data.data)?.value}</p>
|
|
73
|
+
<div className="flex flex-row gap-2">
|
|
74
|
+
<button
|
|
75
|
+
className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
|
|
76
|
+
onClick={() => executeMoveCall('increment')}
|
|
77
|
+
disabled={waitingForTxn !== ''}
|
|
78
|
+
>
|
|
79
|
+
{waitingForTxn === 'increment' ? 'Loading...' : 'Increment'}
|
|
80
|
+
</button>
|
|
81
|
+
{ownedByCurrentAccount ? (
|
|
82
|
+
<button
|
|
83
|
+
className="px-4 py-2 bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
|
|
84
|
+
onClick={() => executeMoveCall('reset')}
|
|
85
|
+
disabled={waitingForTxn !== ''}
|
|
86
|
+
>
|
|
87
|
+
{waitingForTxn === 'reset' ? 'Loading...' : 'Reset'}
|
|
88
|
+
</button>
|
|
89
|
+
) : null}
|
|
90
|
+
</div>
|
|
91
|
+
</div>
|
|
92
|
+
</>
|
|
93
|
+
);
|
|
101
94
|
}
|
|
95
|
+
|
|
102
96
|
function getCounterFields(data: IotaObjectData) {
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
97
|
+
if (data.content?.dataType !== 'moveObject') {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
106
100
|
|
|
107
|
-
|
|
101
|
+
return data.content.fields as { value: number; owner: string };
|
|
108
102
|
}
|
|
@@ -1,65 +1,55 @@
|
|
|
1
|
-
import { Transaction } from
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import { useNetworkVariable } from "./networkConfig";
|
|
5
|
-
import ClipLoader from "react-spinners/ClipLoader";
|
|
1
|
+
import { Transaction } from '@iota/iota-sdk/transactions';
|
|
2
|
+
import { useSignAndExecuteTransaction, useIotaClient } from '@iota/dapp-kit';
|
|
3
|
+
import { useNetworkVariable } from './networkConfig';
|
|
6
4
|
|
|
7
|
-
export function CreateCounter({
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
}) {
|
|
12
|
-
const counterPackageId = useNetworkVariable("counterPackageId");
|
|
13
|
-
const iotaClient = useIotaClient();
|
|
14
|
-
const {
|
|
15
|
-
mutate: signAndExecute,
|
|
16
|
-
isSuccess,
|
|
17
|
-
isPending,
|
|
18
|
-
} = useSignAndExecuteTransaction();
|
|
5
|
+
export function CreateCounter({ onCreated }: { onCreated: (id: string) => void }) {
|
|
6
|
+
const counterPackageId = useNetworkVariable('counterPackageId');
|
|
7
|
+
const iotaClient = useIotaClient();
|
|
8
|
+
const { mutate: signAndExecute, isSuccess, isPending } = useSignAndExecuteTransaction();
|
|
19
9
|
|
|
20
|
-
|
|
21
|
-
|
|
10
|
+
function create() {
|
|
11
|
+
const tx = new Transaction();
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
13
|
+
tx.moveCall({
|
|
14
|
+
arguments: [],
|
|
15
|
+
target: `${counterPackageId}::counter::create`,
|
|
16
|
+
});
|
|
27
17
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
onSuccess: async ({ digest }) => {
|
|
34
|
-
const { effects } = await iotaClient.waitForTransaction({
|
|
35
|
-
digest: digest,
|
|
36
|
-
options: {
|
|
37
|
-
showEffects: true,
|
|
18
|
+
signAndExecute(
|
|
19
|
+
{
|
|
20
|
+
transaction: tx,
|
|
38
21
|
},
|
|
39
|
-
|
|
22
|
+
{
|
|
23
|
+
onSuccess: async ({ digest }) => {
|
|
24
|
+
const { effects } = await iotaClient.waitForTransaction({
|
|
25
|
+
digest: digest,
|
|
26
|
+
options: {
|
|
27
|
+
showEffects: true,
|
|
28
|
+
},
|
|
29
|
+
});
|
|
40
30
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
31
|
+
const objectId = effects?.created?.[0]?.reference?.objectId;
|
|
32
|
+
if (objectId) {
|
|
33
|
+
onCreated(objectId);
|
|
34
|
+
} else {
|
|
35
|
+
console.error('Failed to get objectId from transaction effects');
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
},
|
|
39
|
+
);
|
|
40
|
+
}
|
|
51
41
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
42
|
+
return (
|
|
43
|
+
<div>
|
|
44
|
+
<button
|
|
45
|
+
className="px-6 py-3 text-lg bg-blue-600 text-white rounded hover:bg-blue-700 disabled:opacity-50"
|
|
46
|
+
onClick={() => {
|
|
47
|
+
create();
|
|
48
|
+
}}
|
|
49
|
+
disabled={isSuccess || isPending}
|
|
50
|
+
>
|
|
51
|
+
{isSuccess || isPending ? 'Creating...' : 'Create Counter'}
|
|
52
|
+
</button>
|
|
53
|
+
</div>
|
|
54
|
+
);
|
|
65
55
|
}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export const DEVNET_COUNTER_PACKAGE_ID =
|
|
2
|
-
export const TESTNET_COUNTER_PACKAGE_ID =
|
|
3
|
-
export const MAINNET_COUNTER_PACKAGE_ID =
|
|
1
|
+
export const DEVNET_COUNTER_PACKAGE_ID = '0xTODO';
|
|
2
|
+
export const TESTNET_COUNTER_PACKAGE_ID = '0xTODO';
|
|
3
|
+
export const MAINNET_COUNTER_PACKAGE_ID = '0xTODO';
|
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import React from
|
|
2
|
-
import ReactDOM from
|
|
3
|
-
import
|
|
4
|
-
import
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import ReactDOM from 'react-dom/client';
|
|
3
|
+
import '@iota/dapp-kit/dist/index.css';
|
|
4
|
+
import './index.css';
|
|
5
5
|
|
|
6
|
-
import { IotaClientProvider, WalletProvider } from
|
|
7
|
-
import { QueryClient, QueryClientProvider } from
|
|
8
|
-
import
|
|
9
|
-
import
|
|
10
|
-
import { networkConfig } from "./networkConfig.ts";
|
|
6
|
+
import { IotaClientProvider, WalletProvider } from '@iota/dapp-kit';
|
|
7
|
+
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
|
|
8
|
+
import App from './App.tsx';
|
|
9
|
+
import { networkConfig } from './networkConfig.ts';
|
|
11
10
|
|
|
12
11
|
const queryClient = new QueryClient();
|
|
13
12
|
|
|
14
|
-
ReactDOM.createRoot(document.getElementById(
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</
|
|
23
|
-
|
|
24
|
-
</Theme>
|
|
25
|
-
</React.StrictMode>,
|
|
13
|
+
ReactDOM.createRoot(document.getElementById('root')!).render(
|
|
14
|
+
<React.StrictMode>
|
|
15
|
+
<QueryClientProvider client={queryClient}>
|
|
16
|
+
<IotaClientProvider networks={networkConfig} defaultNetwork="testnet">
|
|
17
|
+
<WalletProvider autoConnect>
|
|
18
|
+
<App />
|
|
19
|
+
</WalletProvider>
|
|
20
|
+
</IotaClientProvider>
|
|
21
|
+
</QueryClientProvider>
|
|
22
|
+
</React.StrictMode>,
|
|
26
23
|
);
|
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import { getFullnodeUrl } from
|
|
1
|
+
import { getFullnodeUrl } from '@iota/iota-sdk/client';
|
|
2
2
|
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
} from
|
|
7
|
-
import { createNetworkConfig } from
|
|
3
|
+
DEVNET_COUNTER_PACKAGE_ID,
|
|
4
|
+
TESTNET_COUNTER_PACKAGE_ID,
|
|
5
|
+
MAINNET_COUNTER_PACKAGE_ID,
|
|
6
|
+
} from './constants.ts';
|
|
7
|
+
import { createNetworkConfig } from '@iota/dapp-kit';
|
|
8
8
|
|
|
9
|
-
const { networkConfig, useNetworkVariable, useNetworkVariables } =
|
|
10
|
-
createNetworkConfig({
|
|
9
|
+
const { networkConfig, useNetworkVariable, useNetworkVariables } = createNetworkConfig({
|
|
11
10
|
devnet: {
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
url: getFullnodeUrl('devnet'),
|
|
12
|
+
variables: {
|
|
13
|
+
counterPackageId: DEVNET_COUNTER_PACKAGE_ID,
|
|
14
|
+
},
|
|
16
15
|
},
|
|
17
16
|
testnet: {
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
17
|
+
url: getFullnodeUrl('testnet'),
|
|
18
|
+
variables: {
|
|
19
|
+
counterPackageId: TESTNET_COUNTER_PACKAGE_ID,
|
|
20
|
+
},
|
|
22
21
|
},
|
|
23
22
|
mainnet: {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
url: getFullnodeUrl('mainnet'),
|
|
24
|
+
variables: {
|
|
25
|
+
counterPackageId: MAINNET_COUNTER_PACKAGE_ID,
|
|
26
|
+
},
|
|
28
27
|
},
|
|
29
|
-
|
|
28
|
+
});
|
|
30
29
|
|
|
31
30
|
export { useNetworkVariable, useNetworkVariables, networkConfig };
|
|
@@ -1,25 +1,24 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"target": "ES2022",
|
|
4
|
+
"useDefineForClassFields": true,
|
|
5
|
+
"lib": ["ES2022", "DOM", "DOM.Iterable"],
|
|
6
|
+
"module": "ESNext",
|
|
7
|
+
"skipLibCheck": true,
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
9
|
+
/* Bundler mode */
|
|
10
|
+
"moduleResolution": "bundler",
|
|
11
|
+
"allowImportingTsExtensions": true,
|
|
12
|
+
"resolveJsonModule": true,
|
|
13
|
+
"isolatedModules": true,
|
|
14
|
+
"noEmit": true,
|
|
15
|
+
"jsx": "react-jsx",
|
|
16
16
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
"references": [{ "path": "./tsconfig.node.json" }]
|
|
17
|
+
/* Linting */
|
|
18
|
+
"strict": true,
|
|
19
|
+
"noUnusedLocals": true,
|
|
20
|
+
"noUnusedParameters": true,
|
|
21
|
+
"noFallthroughCasesInSwitch": true
|
|
22
|
+
},
|
|
23
|
+
"include": ["src", "vite.config.ts"]
|
|
25
24
|
}
|