@iota/create-dapp 0.1.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.
Files changed (37) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/LICENSE +201 -0
  3. package/README.md +33 -0
  4. package/bin/index.js +7 -0
  5. package/dist/index.d.ts +1 -0
  6. package/dist/index.js +103 -0
  7. package/dist/index.js.map +1 -0
  8. package/package.json +44 -0
  9. package/src/index.ts +131 -0
  10. package/templates/react-client-dapp/README.md +35 -0
  11. package/templates/react-client-dapp/index.html +59 -0
  12. package/templates/react-client-dapp/package.json +35 -0
  13. package/templates/react-client-dapp/prettier.config.cjs +4 -0
  14. package/templates/react-client-dapp/src/App.tsx +39 -0
  15. package/templates/react-client-dapp/src/OwnedObjects.tsx +42 -0
  16. package/templates/react-client-dapp/src/WalletStatus.tsx +23 -0
  17. package/templates/react-client-dapp/src/main.tsx +40 -0
  18. package/templates/react-client-dapp/src/vite-env.d.ts +1 -0
  19. package/templates/react-client-dapp/tsconfig.json +25 -0
  20. package/templates/react-client-dapp/tsconfig.node.json +10 -0
  21. package/templates/react-client-dapp/vite.config.ts +7 -0
  22. package/templates/react-e2e-counter/README.md +100 -0
  23. package/templates/react-e2e-counter/index.html +59 -0
  24. package/templates/react-e2e-counter/move/counter/Move.toml +9 -0
  25. package/templates/react-e2e-counter/move/counter/sources/counter.move +54 -0
  26. package/templates/react-e2e-counter/package.json +35 -0
  27. package/templates/react-e2e-counter/prettier.config.cjs +4 -0
  28. package/templates/react-e2e-counter/src/App.tsx +64 -0
  29. package/templates/react-e2e-counter/src/Counter.tsx +94 -0
  30. package/templates/react-e2e-counter/src/CreateCounter.tsx +67 -0
  31. package/templates/react-e2e-counter/src/constants.ts +2 -0
  32. package/templates/react-e2e-counter/src/main.tsx +26 -0
  33. package/templates/react-e2e-counter/src/networkConfig.ts +27 -0
  34. package/templates/react-e2e-counter/src/vite-env.d.ts +1 -0
  35. package/templates/react-e2e-counter/tsconfig.json +25 -0
  36. package/templates/react-e2e-counter/tsconfig.node.json +10 -0
  37. package/templates/react-e2e-counter/vite.config.ts +7 -0
@@ -0,0 +1,67 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { TransactionBlock } from "@iota/iota-sdk/transactions";
5
+ import { Button, Container } from "@radix-ui/themes";
6
+ import {
7
+ useSignAndExecuteTransactionBlock,
8
+ useIotaClient,
9
+ } from "@iota/dapp-kit";
10
+ import { useNetworkVariable } from "./networkConfig";
11
+
12
+ export function CreateCounter({
13
+ onCreated,
14
+ }: {
15
+ onCreated: (id: string) => void;
16
+ }) {
17
+ const client = useIotaClient();
18
+ const counterPackageId = useNetworkVariable("counterPackageId");
19
+ const { mutate: signAndExecute } = useSignAndExecuteTransactionBlock();
20
+
21
+ return (
22
+ <Container>
23
+ <Button
24
+ size="3"
25
+ onClick={() => {
26
+ create();
27
+ }}
28
+ >
29
+ Create Counter
30
+ </Button>
31
+ </Container>
32
+ );
33
+
34
+ function create() {
35
+ const txb = new TransactionBlock();
36
+
37
+ txb.moveCall({
38
+ arguments: [],
39
+ target: `${counterPackageId}::counter::create`,
40
+ });
41
+
42
+ signAndExecute(
43
+ {
44
+ transactionBlock: txb,
45
+ options: {
46
+ showEffects: true,
47
+ showObjectChanges: true,
48
+ },
49
+ },
50
+ {
51
+ onSuccess: (tx) => {
52
+ client
53
+ .waitForTransactionBlock({
54
+ digest: tx.digest,
55
+ })
56
+ .then(() => {
57
+ const objectId = tx.effects?.created?.[0]?.reference?.objectId;
58
+
59
+ if (objectId) {
60
+ onCreated(objectId);
61
+ }
62
+ });
63
+ },
64
+ },
65
+ );
66
+ }
67
+ }
@@ -0,0 +1,2 @@
1
+ export const DEVNET_COUNTER_PACKAGE_ID = "0xTODO";
2
+ export const MAINNET_COUNTER_PACKAGE_ID = "0xTODO";
@@ -0,0 +1,26 @@
1
+ import React from "react";
2
+ import ReactDOM from "react-dom/client";
3
+ import "@iota/dapp-kit/dist/index.css";
4
+ import "@radix-ui/themes/styles.css";
5
+
6
+ import { IotaClientProvider, WalletProvider } from "@iota/dapp-kit";
7
+ import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
8
+ import { Theme } from "@radix-ui/themes";
9
+ import App from "./App.tsx";
10
+ import { networkConfig } from "./networkConfig.ts";
11
+
12
+ const queryClient = new QueryClient();
13
+
14
+ ReactDOM.createRoot(document.getElementById("root")!).render(
15
+ <React.StrictMode>
16
+ <Theme appearance="dark">
17
+ <QueryClientProvider client={queryClient}>
18
+ <IotaClientProvider networks={networkConfig} defaultNetwork="devnet">
19
+ <WalletProvider autoConnect>
20
+ <App />
21
+ </WalletProvider>
22
+ </IotaClientProvider>
23
+ </QueryClientProvider>
24
+ </Theme>
25
+ </React.StrictMode>,
26
+ );
@@ -0,0 +1,27 @@
1
+ // Copyright (c) 2024 IOTA Stiftung
2
+ // SPDX-License-Identifier: Apache-2.0
3
+
4
+ import { getFullnodeUrl } from "@iota/iota-sdk/client";
5
+ import {
6
+ DEVNET_COUNTER_PACKAGE_ID,
7
+ MAINNET_COUNTER_PACKAGE_ID,
8
+ } from "./constants.ts";
9
+ import { createNetworkConfig } from "@iota/dapp-kit";
10
+
11
+ const { networkConfig, useNetworkVariable, useNetworkVariables } =
12
+ createNetworkConfig({
13
+ devnet: {
14
+ url: getFullnodeUrl("devnet"),
15
+ variables: {
16
+ counterPackageId: DEVNET_COUNTER_PACKAGE_ID,
17
+ },
18
+ },
19
+ mainnet: {
20
+ url: getFullnodeUrl("mainnet"),
21
+ variables: {
22
+ counterPackageId: MAINNET_COUNTER_PACKAGE_ID,
23
+ },
24
+ },
25
+ });
26
+
27
+ export { useNetworkVariable, useNetworkVariables, networkConfig };
@@ -0,0 +1 @@
1
+ /// <reference types="vite/client" />
@@ -0,0 +1,25 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "ES2020",
4
+ "useDefineForClassFields": true,
5
+ "lib": ["ES2020", "DOM", "DOM.Iterable"],
6
+ "module": "ESNext",
7
+ "skipLibCheck": true,
8
+
9
+ /* Bundler mode */
10
+ "moduleResolution": "bundler",
11
+ "allowImportingTsExtensions": true,
12
+ "resolveJsonModule": true,
13
+ "isolatedModules": true,
14
+ "noEmit": true,
15
+ "jsx": "react-jsx",
16
+
17
+ /* Linting */
18
+ "strict": true,
19
+ "noUnusedLocals": true,
20
+ "noUnusedParameters": true,
21
+ "noFallthroughCasesInSwitch": true
22
+ },
23
+ "include": ["src"],
24
+ "references": [{ "path": "./tsconfig.node.json" }]
25
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "skipLibCheck": true,
5
+ "module": "ESNext",
6
+ "moduleResolution": "bundler",
7
+ "allowSyntheticDefaultImports": true
8
+ },
9
+ "include": ["vite.config.ts"]
10
+ }
@@ -0,0 +1,7 @@
1
+ import { defineConfig } from "vite";
2
+ import react from "@vitejs/plugin-react-swc";
3
+
4
+ // https://vitejs.dev/config/
5
+ export default defineConfig({
6
+ plugins: [react()],
7
+ });