@vela-ventures/aosync-sdk-react 1.0.1 → 1.0.3
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/README.md +25 -88
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,100 +1,37 @@
|
|
|
1
|
-
#
|
|
1
|
+
# aosync-react-sdk
|
|
2
2
|
|
|
3
|
-
A
|
|
4
|
-
|
|
5
|
-
## Features
|
|
6
|
-
|
|
7
|
-
- Easily manage wallet connections.
|
|
8
|
-
- Send AR transactions.
|
|
9
|
-
- Sign messages and transactions.
|
|
10
|
-
- Retrieve wallet addresses.
|
|
11
|
-
|
|
12
|
-
## Installation
|
|
13
|
-
|
|
14
|
-
Install the package via npm:
|
|
15
|
-
|
|
16
|
-
```bash
|
|
17
|
-
npm install @vela-ventures/ao-sync-sdk
|
|
18
|
-
```
|
|
3
|
+
A simple react implementation of the ao-sync protocol.
|
|
19
4
|
|
|
20
5
|
## Usage
|
|
21
6
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
```javascript
|
|
25
|
-
import React from "react";
|
|
26
|
-
import { WalletProvider } from "@vela-ventures/ao-sync-sdk";
|
|
7
|
+
```js
|
|
8
|
+
import { AOSyncProvider, useWallet } from "@vela-ventures/aosync-react-sdk";
|
|
27
9
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
<YourApp />
|
|
32
|
-
</WalletProvider>
|
|
33
|
-
);
|
|
34
|
-
};
|
|
35
|
-
```
|
|
36
|
-
### 2. Use the useWallet Hook
|
|
37
|
-
Access wallet functionality in any component with the useWallet hook:
|
|
38
|
-
```javascript
|
|
39
|
-
import React from "react";
|
|
40
|
-
import { useWallet } from "@vela-ventures/ao-sync-sdk";
|
|
10
|
+
function WalletView() {
|
|
11
|
+
const wallet = useWallet();
|
|
12
|
+
const [address, setAddress] = useAddress<string>()
|
|
41
13
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
connect,
|
|
46
|
-
disconnect,
|
|
47
|
-
getAddress,
|
|
48
|
-
sendAR,
|
|
49
|
-
} = useWallet();
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
setAddress(wallet.getAddress())
|
|
16
|
+
}, [wallet.isConnected])
|
|
50
17
|
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
18
|
+
if (wallet.isConnected) {
|
|
19
|
+
return(
|
|
20
|
+
<>
|
|
21
|
+
<h1>Connected to: {address}</h1>
|
|
22
|
+
<Button onClick={wallet.disconnect}>Disconnect Wallet</Button>
|
|
23
|
+
</>
|
|
24
|
+
)
|
|
25
|
+
}
|
|
56
26
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
await sendAR("recipient-address", "1000000"); // 1 AR (in winstons)
|
|
60
|
-
console.log("AR sent successfully!");
|
|
61
|
-
} catch (error) {
|
|
62
|
-
console.error("Error sending AR:", error);
|
|
63
|
-
}
|
|
64
|
-
};
|
|
27
|
+
return <Button onClick={wallet.connect}>Connect Wallet</Button>
|
|
28
|
+
}
|
|
65
29
|
|
|
30
|
+
function App() {
|
|
66
31
|
return (
|
|
67
|
-
<
|
|
68
|
-
<
|
|
69
|
-
|
|
70
|
-
<button onClick={handleConnect}>Connect Wallet</button>
|
|
71
|
-
) : (
|
|
72
|
-
<button onClick={disconnect}>Disconnect Wallet</button>
|
|
73
|
-
)}
|
|
74
|
-
{isConnected && <button onClick={handleSendAR}>Send AR</button>}
|
|
75
|
-
</div>
|
|
32
|
+
<AOSyncProvider arweaveHost='arweave.net' muUrl='https://mu.ao-testnet.xyz'>
|
|
33
|
+
<WalletView />
|
|
34
|
+
</AOSyncProvider>
|
|
76
35
|
);
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
export default WalletComponent;
|
|
36
|
+
}
|
|
80
37
|
```
|
|
81
|
-
## API
|
|
82
|
-
|
|
83
|
-
### `useWallet`
|
|
84
|
-
|
|
85
|
-
The `useWallet` hook provides the following methods and properties:
|
|
86
|
-
|
|
87
|
-
| Method/Property | Description |
|
|
88
|
-
|--------------------------|-----------------------------------------------------------------------------|
|
|
89
|
-
| `isConnected` | Boolean indicating if the wallet is connected. |
|
|
90
|
-
| `connect()` | Connects to the wallet. |
|
|
91
|
-
| `disconnect()` | Disconnects from the wallet. |
|
|
92
|
-
| `getAddress()` | Returns the currently active wallet address. |
|
|
93
|
-
| `getAllAddresses()` | Returns all wallet addresses. |
|
|
94
|
-
| `sendAR(recipient, quantity)` | Sends AR to the specified address. |
|
|
95
|
-
| `sign(transaction)` | Signs a transaction using the wallet. |
|
|
96
|
-
| `signAOMessage(target, recipient, quantity)` | Signs a custom AO message. |
|
|
97
|
-
|
|
98
|
-
## License
|
|
99
|
-
|
|
100
|
-
MIT License © 2025 Vela Ventures
|