Skip to content

Commit b84e098

Browse files
authored
Merge pull request #5 from ProvableHQ/wip/puzzle
Wip/puzzle
2 parents 8b9668f + 6d48030 commit b84e098

53 files changed

Lines changed: 4084 additions & 1082 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cursor/scratchpad.md

Lines changed: 626 additions & 0 deletions
Large diffs are not rendered by default.

.eslintrc.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,4 @@ module.exports = {
2727
browser: true,
2828
node: true,
2929
},
30-
};
30+
};

.prettierrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,4 +5,4 @@
55
"printWidth": 100,
66
"tabWidth": 2,
77
"arrowParens": "avoid"
8-
}
8+
}

.vscode/settings.json

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
{
2+
"editor.formatOnSave": true,
3+
"editor.codeActionsOnSave": {
4+
"source.fixAll.eslint": "explicit"
5+
},
6+
"editor.defaultFormatter": "esbenp.prettier-vscode",
7+
"[javascript]": {
8+
"editor.defaultFormatter": "esbenp.prettier-vscode"
9+
},
10+
"[typescript]": {
11+
"editor.defaultFormatter": "esbenp.prettier-vscode"
12+
},
13+
"[typescriptreact]": {
14+
"editor.defaultFormatter": "esbenp.prettier-vscode"
15+
},
16+
"eslint.validate": [
17+
"javascript",
18+
"javascriptreact",
19+
"typescript",
20+
"typescriptreact"
21+
]
22+
}

README.md

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@ pnpm publish-packages
7272
```
7373

7474
This will:
75+
7576
1. Build all packages
7677
2. Run linters and tests
7778
3. Apply changesets to update versions
@@ -106,28 +107,28 @@ aleo-dev-toolkit/ (Monorepo Root)
106107
### Key Components
107108

108109
1. **`@provablehq/aleo-types`**
109-
Common types for the Aleo ecosystem, including Account, Transaction, and Network.
110+
Common types for the Aleo ecosystem, including Account, Transaction, and Network.
110111

111112
2. **`@provablehq/aleo-wallet-standard`**
112-
Defines the standard interfaces and types for Aleo wallet integration, including chain constants, wallet interfaces, and feature definitions.
113+
Defines the standard interfaces and types for Aleo wallet integration, including chain constants, wallet interfaces, and feature definitions.
113114

114115
3. **`@provablehq/aleo-wallet-adaptor-core`**
115-
Provides core wallet adapter logic, including base classes, error handling, and transaction utilities.
116+
Provides core wallet adapter logic, including base classes, error handling, and transaction utilities.
116117

117118
4. **`@provablehq/aleo-wallet-adaptor-leo`**
118-
Implements the wallet adapter for LeoWallet, handling wallet-specific logic such as connection and transaction requests.
119+
Implements the wallet adapter for LeoWallet, handling wallet-specific logic such as connection and transaction requests.
119120

120121
5. **`@provablehq/aleo-wallet-adaptor-react`**
121-
Offers React integration for the wallet adapter, including context providers and hooks for managing wallet state.
122+
Offers React integration for the wallet adapter, including context providers and hooks for managing wallet state.
122123

123124
6. **`@provablehq/aleo-wallet-adaptor-react-ui`**
124-
Contains reusable UI components for wallet integration, such as connect buttons and modals.
125+
Contains reusable UI components for wallet integration, such as connect buttons and modals.
125126

126127
7. **`@provablehq/aleo-hooks`**
127-
Provides React hooks for accessing and managing Aleo chain data and state.
128+
Provides React hooks for accessing and managing Aleo chain data and state.
128129

129130
8. **`examples/`**
130-
Example projects demonstrating how to use the toolkit in real-world applications.
131+
Example projects demonstrating how to use the toolkit in real-world applications.
131132

132133
9. **`docs/`**
133-
Documentation and specifications, including the Aleo Wallet Standard specification.
134+
Documentation and specifications, including the Aleo Wallet Standard specification.

examples/react-app/package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,10 @@
1111
},
1212
"dependencies": {
1313
"@provablehq/aleo-wallet-adaptor-core": "workspace:*",
14+
"@provablehq/aleo-wallet-adaptor-puzzle": "workspace:*",
1415
"@provablehq/aleo-wallet-adaptor-react": "workspace:*",
1516
"@provablehq/aleo-wallet-adaptor-react-ui": "workspace:*",
16-
"@provablehq/aleo-wallet-adaptor-leo": "workspace:*",
17+
"@puzzlehq/sdk": "^0.2.0",
1718
"react": "^18.2.0",
1819
"react-dom": "^18.2.0"
1920
},
@@ -29,4 +30,4 @@
2930
"typescript": "^5.3.3",
3031
"vite": "^5.0.8"
3132
}
32-
}
33+
}

examples/react-app/src/App.tsx

Lines changed: 83 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,108 @@
1-
import { useState } from 'react';
2-
import { WalletProvider } from '@provablehq/aleo-wallet-adaptor-react';
3-
import { WalletMultiButton } from '@provablehq/aleo-wallet-adaptor-react-ui';
4-
import { LeoWalletAdapter } from '@provablehq/aleo-wallet-adaptor-leo';
1+
import React, { useMemo } from 'react';
2+
import { AleoWalletProvider } from '@provablehq/aleo-wallet-adaptor-react';
3+
import { WalletConnectButton } from '@provablehq/aleo-wallet-adaptor-react-ui';
4+
import { PuzzleWalletAdapter } from '@provablehq/aleo-wallet-adaptor-puzzle';
55
import { useWallet } from '@provablehq/aleo-wallet-adaptor-react';
66
import './App.css';
77

88
// Component to display wallet information
99
const WalletInfo = () => {
1010
const { wallet, account } = useWallet();
11-
11+
1212
if (!wallet || !account) {
1313
return <p>Please connect your wallet first.</p>;
1414
}
15-
15+
1616
return (
1717
<div className="wallet-info">
1818
<h2>Wallet Connected</h2>
19-
<p><strong>Wallet Name:</strong> {wallet.name}</p>
20-
<p><strong>Address:</strong> {account.address}</p>
19+
<p>
20+
<strong>Wallet Name:</strong> {wallet.name}
21+
</p>
22+
<p>
23+
<strong>Address:</strong> {account.address}
24+
</p>
2125
</div>
2226
);
2327
};
2428

2529
// Example transaction component
26-
const ExecuteTransaction = () => {
27-
const { executeTransaction, connected } = useWallet();
28-
const [txId, setTxId] = useState<string | null>(null);
29-
const [loading, setLoading] = useState(false);
30-
31-
const handleExecute = async () => {
32-
if (!connected) return;
33-
34-
try {
35-
setLoading(true);
36-
37-
// This is just an example - you would need a real program and function to call
38-
const tx = await executeTransaction({
39-
program: 'hello_world.aleo',
40-
function: 'main',
41-
inputs: [],
42-
});
43-
44-
setTxId(tx.id);
45-
} catch (error) {
46-
console.error('Transaction failed', error);
47-
} finally {
48-
setLoading(false);
49-
}
50-
};
51-
52-
if (!connected) {
53-
return null;
54-
}
55-
56-
return (
57-
<div className="transaction">
58-
<button
59-
onClick={handleExecute}
60-
disabled={loading}
61-
>
62-
{loading ? 'Executing...' : 'Execute Transaction'}
63-
</button>
64-
65-
{txId && (
66-
<div className="tx-result">
67-
<p>Transaction ID: {txId}</p>
68-
</div>
69-
)}
70-
</div>
71-
);
72-
};
30+
// const ExecuteTransaction = () => {
31+
// const { executeTransaction, connected } = useWallet();
32+
// const [txId, setTxId] = useState<string | null>(null);
33+
// const [loading, setLoading] = useState(false);
34+
35+
// const handleExecute = async () => {
36+
// if (!connected) return;
7337

74-
function App() {
75-
// Initialize wallet adapters
76-
const wallets = [
77-
new LeoWalletAdapter(),
78-
];
38+
// try {
39+
// setLoading(true);
40+
41+
// // This is just an example - you would need a real program and function to call
42+
// const tx = await executeTransaction({
43+
// program: 'hello_world.aleo',
44+
// function: 'main',
45+
// inputs: [],
46+
// });
47+
48+
// setTxId(tx.id);
49+
// } catch (error) {
50+
// console.error('Transaction failed', error);
51+
// } finally {
52+
// setLoading(false);
53+
// }
54+
// };
55+
56+
// if (!connected) {
57+
// return null;
58+
// }
59+
60+
// return (
61+
// <div className="transaction">
62+
// <button
63+
// onClick={handleExecute}
64+
// disabled={loading}
65+
// >
66+
// {loading ? 'Executing...' : 'Execute Transaction'}
67+
// </button>
68+
69+
// {txId && (
70+
// <div className="tx-result">
71+
// <p>Transaction ID: {txId}</p>
72+
// </div>
73+
// )}
74+
// </div>
75+
// );
76+
// };
77+
78+
export function App() {
79+
// memoize to avoid re‑instantiating adapters on each render
80+
const wallets = useMemo(
81+
() => [
82+
new PuzzleWalletAdapter({
83+
appName: 'Aleo Wallet Example',
84+
appDescription: 'Example application for Puzzle wallet',
85+
programIdPermissions: {
86+
AleoTestnet: ['hello_world.aleo'], // Example program IDs
87+
},
88+
}),
89+
],
90+
[],
91+
);
7992

8093
return (
81-
<WalletProvider wallets={wallets} autoConnect>
82-
<div className="app">
83-
<h1>Aleo Wallet Example</h1>
84-
85-
<div className="card">
86-
<WalletMultiButton />
87-
94+
<AleoWalletProvider wallets={wallets} autoConnect>
95+
<header>
96+
<div className="app">
97+
<h1>Aleo Wallet Example</h1>
98+
<WalletConnectButton />
99+
88100
<WalletInfo />
89-
90-
<ExecuteTransaction />
91101
</div>
92-
</div>
93-
</WalletProvider>
102+
</header>
103+
<main>{/* your DApp's components */}</main>
104+
</AleoWalletProvider>
94105
);
95106
}
96107

97-
export default App;
108+
export default App;

examples/react-app/src/main.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,4 @@ ReactDOM.createRoot(document.getElementById('root')!).render(
77
<React.StrictMode>
88
<App />
99
</React.StrictMode>,
10-
);
10+
);

examples/react-app/vite.config.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ import react from '@vitejs/plugin-react';
44
// https://vitejs.dev/config/
55
export default defineConfig({
66
plugins: [react()],
7-
});
7+
});

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
"build": "turbo run build",
1010
"clean": "turbo run clean",
1111
"dev": "turbo run dev",
12+
"dev:example": "pnpm --filter react-app-example dev",
1213
"lint": "turbo run lint",
1314
"format": "prettier --write \"**/*.{ts,tsx,md}\"",
1415
"publish-packages": "turbo run build lint test && changeset publish"

0 commit comments

Comments
 (0)