@gardenfi/react-hooks 2.5.2 → 2.5.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 +84 -0
- package/package.json +4 -4
package/README.md
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
# @gardenfi/react-hooks
|
|
2
|
+
|
|
3
|
+
The `@gardenfi/react-hooks` package provides React hooks and context providers for integrating cross-chain atomic swap functionality into React applications. It includes a global context provider for state management and hooks that offer a unified interface for retrieving quotes and executing atomic swaps. The package automatically manages subscription cleanup and delivers real-time updates on order status changes.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
yarn add @gardenfi/react-hooks
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Setup
|
|
12
|
+
|
|
13
|
+
### Vite
|
|
14
|
+
|
|
15
|
+
Install the vite plugins:
|
|
16
|
+
|
|
17
|
+
```
|
|
18
|
+
npm install vite-plugin-wasm vite-plugin-top-level-await vite-plugin-node-polyfills --save-dev
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
and update your `vite.config.ts` as follows:
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { defineConfig } from 'vite';
|
|
25
|
+
import wasm from 'vite-plugin-wasm';
|
|
26
|
+
import { nodePolyfills } from 'vite-plugin-node-polyfills';
|
|
27
|
+
import topLevelAwait from 'vite-plugin-top-level-await';
|
|
28
|
+
|
|
29
|
+
export default defineConfig({
|
|
30
|
+
plugins: [
|
|
31
|
+
nodePolyfills(),
|
|
32
|
+
wasm(),
|
|
33
|
+
topLevelAwait(),
|
|
34
|
+
//other plugins
|
|
35
|
+
],
|
|
36
|
+
//other settings
|
|
37
|
+
});
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Webpack
|
|
41
|
+
|
|
42
|
+
If you're using webpack with a framework like next, then in your webpack config, (if you're using NextJS, this can be found in `next.config.js` ) add support for wasm as shown below:
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
/** @type {import('next').NextConfig} */
|
|
46
|
+
const nextConfig = {
|
|
47
|
+
//other nextConfig options
|
|
48
|
+
webpack: function (config, options) {
|
|
49
|
+
//other webpack config options
|
|
50
|
+
config.experiments = {
|
|
51
|
+
...config.experiments,
|
|
52
|
+
asyncWebAssembly: true,
|
|
53
|
+
};
|
|
54
|
+
return config;
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
module.exports = nextConfig;
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Usage
|
|
61
|
+
|
|
62
|
+
### Setup GardenProvider
|
|
63
|
+
|
|
64
|
+
```tsx
|
|
65
|
+
import { GardenProvider } from '@gardenfi/react-hooks';
|
|
66
|
+
|
|
67
|
+
const gardenConfig = {
|
|
68
|
+
environment: 'testnet',
|
|
69
|
+
wallets: {
|
|
70
|
+
evm: {
|
|
71
|
+
// EVM wallet configuration
|
|
72
|
+
},
|
|
73
|
+
// Additional wallet configurations (bitcoin, starknet, solana) can be added as needed
|
|
74
|
+
},
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
function App() {
|
|
78
|
+
return (
|
|
79
|
+
<GardenProvider config={gardenConfig}>
|
|
80
|
+
<YourApp />
|
|
81
|
+
</GardenProvider>
|
|
82
|
+
);
|
|
83
|
+
}
|
|
84
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gardenfi/react-hooks",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "./dist/index.cjs",
|
|
6
6
|
"module": "./dist/index.js",
|
|
@@ -27,9 +27,9 @@
|
|
|
27
27
|
"registry": "https://registry.npmjs.org/"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@gardenfi/core": "2.5.
|
|
31
|
-
"@gardenfi/orderbook": "2.5.
|
|
32
|
-
"@gardenfi/utils": "2.5.
|
|
30
|
+
"@gardenfi/core": "2.5.3",
|
|
31
|
+
"@gardenfi/orderbook": "2.5.3",
|
|
32
|
+
"@gardenfi/utils": "2.5.3",
|
|
33
33
|
"react": "^18.3.1",
|
|
34
34
|
"starknet": "7.6.4"
|
|
35
35
|
},
|