@bigmi/react 0.0.0-preview-aab0339
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 +207 -0
- package/LICENSE.md +21 -0
- package/README.md +471 -0
- package/dist/cjs/context.d.ts +15 -0
- package/dist/cjs/context.js +16 -0
- package/dist/cjs/context.js.map +1 -0
- package/dist/cjs/errors/context.d.ts +13 -0
- package/dist/cjs/errors/context.js +13 -0
- package/dist/cjs/errors/context.js.map +1 -0
- package/dist/cjs/hooks/useAccount.d.ts +11 -0
- package/dist/cjs/hooks/useAccount.js +26 -0
- package/dist/cjs/hooks/useAccount.js.map +1 -0
- package/dist/cjs/hooks/useConfig.d.ts +13 -0
- package/dist/cjs/hooks/useConfig.js +15 -0
- package/dist/cjs/hooks/useConfig.js.map +1 -0
- package/dist/cjs/hooks/useConnect.d.ts +20 -0
- package/dist/cjs/hooks/useConnect.js +32 -0
- package/dist/cjs/hooks/useConnect.js.map +1 -0
- package/dist/cjs/hooks/useConnectors.d.ts +11 -0
- package/dist/cjs/hooks/useConnectors.js +15 -0
- package/dist/cjs/hooks/useConnectors.js.map +1 -0
- package/dist/cjs/hooks/useReconnect.d.ts +7 -0
- package/dist/cjs/hooks/useReconnect.js +14 -0
- package/dist/cjs/hooks/useReconnect.js.map +1 -0
- package/dist/cjs/hooks/useSyncExternalStoreWithTracked.d.ts +5 -0
- package/dist/cjs/hooks/useSyncExternalStoreWithTracked.js +41 -0
- package/dist/cjs/hooks/useSyncExternalStoreWithTracked.js.map +1 -0
- package/dist/cjs/hydrate.d.ts +21 -0
- package/dist/cjs/hydrate.js +45 -0
- package/dist/cjs/hydrate.js.map +1 -0
- package/dist/cjs/index.d.ts +6 -0
- package/dist/cjs/index.js +12 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/types.d.ts +12 -0
- package/dist/cjs/types.js +0 -0
- package/dist/cjs/utils/query.d.ts +9 -0
- package/dist/cjs/utils/query.js +1 -0
- package/dist/cjs/version.d.ts +6 -0
- package/dist/cjs/version.js +9 -0
- package/dist/cjs/version.js.map +1 -0
- package/dist/esm/context.d.ts +15 -0
- package/dist/esm/context.d.ts.map +1 -0
- package/dist/esm/context.js +14 -0
- package/dist/esm/context.js.map +1 -0
- package/dist/esm/errors/context.d.ts +13 -0
- package/dist/esm/errors/context.d.ts.map +1 -0
- package/dist/esm/errors/context.js +12 -0
- package/dist/esm/errors/context.js.map +1 -0
- package/dist/esm/hooks/useAccount.d.ts +11 -0
- package/dist/esm/hooks/useAccount.d.ts.map +1 -0
- package/dist/esm/hooks/useAccount.js +25 -0
- package/dist/esm/hooks/useAccount.js.map +1 -0
- package/dist/esm/hooks/useConfig.d.ts +13 -0
- package/dist/esm/hooks/useConfig.d.ts.map +1 -0
- package/dist/esm/hooks/useConfig.js +14 -0
- package/dist/esm/hooks/useConfig.js.map +1 -0
- package/dist/esm/hooks/useConnect.d.ts +20 -0
- package/dist/esm/hooks/useConnect.d.ts.map +1 -0
- package/dist/esm/hooks/useConnect.js +31 -0
- package/dist/esm/hooks/useConnect.js.map +1 -0
- package/dist/esm/hooks/useConnectors.d.ts +11 -0
- package/dist/esm/hooks/useConnectors.d.ts.map +1 -0
- package/dist/esm/hooks/useConnectors.js +14 -0
- package/dist/esm/hooks/useConnectors.js.map +1 -0
- package/dist/esm/hooks/useReconnect.d.ts +7 -0
- package/dist/esm/hooks/useReconnect.d.ts.map +1 -0
- package/dist/esm/hooks/useReconnect.js +13 -0
- package/dist/esm/hooks/useReconnect.js.map +1 -0
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.d.ts +5 -0
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.d.ts.map +1 -0
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.js +40 -0
- package/dist/esm/hooks/useSyncExternalStoreWithTracked.js.map +1 -0
- package/dist/esm/hydrate.d.ts +21 -0
- package/dist/esm/hydrate.d.ts.map +1 -0
- package/dist/esm/hydrate.js +43 -0
- package/dist/esm/hydrate.js.map +1 -0
- package/dist/esm/index.d.ts +6 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/types.d.ts +12 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +1 -0
- package/dist/esm/utils/query.d.ts +9 -0
- package/dist/esm/utils/query.d.ts.map +1 -0
- package/dist/esm/utils/query.js +2 -0
- package/dist/esm/version.d.ts +6 -0
- package/dist/esm/version.d.ts.map +1 -0
- package/dist/esm/version.js +7 -0
- package/dist/esm/version.js.map +1 -0
- package/package.json +58 -0
- package/src/context.ts +33 -0
- package/src/errors/context.ts +11 -0
- package/src/hooks/useAccount.ts +43 -0
- package/src/hooks/useConfig.ts +27 -0
- package/src/hooks/useConnect.ts +90 -0
- package/src/hooks/useConnectors.ts +33 -0
- package/src/hooks/useReconnect.ts +11 -0
- package/src/hooks/useSyncExternalStoreWithTracked.ts +76 -0
- package/src/hydrate.ts +86 -0
- package/src/index.ts +6 -0
- package/src/types.ts +9 -0
- package/src/utils/query.ts +31 -0
- package/src/version.ts +2 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,207 @@
|
|
|
1
|
+
# @bigmi/react
|
|
2
|
+
|
|
3
|
+
## 0.0.0-preview-aab0339
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`aab0339`](https://github.com/lifinance/bigmi/commit/aab0339402b4a20b70f969ae801e89503b045a9d)]:
|
|
8
|
+
- @bigmi/client@0.0.0-preview-aab0339
|
|
9
|
+
|
|
10
|
+
## 0.8.1
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies [[`767fb0c`](https://github.com/lifinance/bigmi/commit/767fb0cba233decea140daf1b562c104f027a261)]:
|
|
15
|
+
- @bigmi/core@0.8.1
|
|
16
|
+
- @bigmi/client@0.8.1
|
|
17
|
+
|
|
18
|
+
> **Pre-Changesets history (aggregated, repo-wide).** The entries below are
|
|
19
|
+
> inherited verbatim from the repository root `CHANGELOG.md`, which aggregated
|
|
20
|
+
> releases across all packages of this monorepo before the Changesets cutover.
|
|
21
|
+
> Many entries reference packages other than `@bigmi/react`; per-package release
|
|
22
|
+
> notes (attributed by Changesets) appear above this section as future releases
|
|
23
|
+
> ship.
|
|
24
|
+
|
|
25
|
+
All notable changes to this project, up to `0.8.0`, were documented in this file
|
|
26
|
+
using [standard-version](https://github.com/conventional-changelog/standard-version)
|
|
27
|
+
commit guidelines.
|
|
28
|
+
|
|
29
|
+
## [0.8.0](https://github.com/lifinance/bigmi/compare/v0.7.1...v0.8.0) (2026-03-25)
|
|
30
|
+
|
|
31
|
+
### ⚠ BREAKING CHANGES
|
|
32
|
+
|
|
33
|
+
- migrate build pipeline from tsc to tsdown (#51)
|
|
34
|
+
|
|
35
|
+
### Bug Fixes
|
|
36
|
+
|
|
37
|
+
- **react:** resolve useSyncExternalStore SSR infinite loop in useAccount and useConnectors ([#50](https://github.com/lifinance/bigmi/issues/50)) ([691b26c](https://github.com/lifinance/bigmi/commit/691b26c45c1de91ae3a1aaac93b675b40c1d8e5f))
|
|
38
|
+
|
|
39
|
+
- migrate build pipeline from tsc to tsdown ([#51](https://github.com/lifinance/bigmi/issues/51)) ([0c4defb](https://github.com/lifinance/bigmi/commit/0c4defb4d4611fe09fddf01fed1a312de0344c1e))
|
|
40
|
+
|
|
41
|
+
### [0.7.1](https://github.com/lifinance/bigmi/compare/v0.7.0...v0.7.1) (2026-03-12)
|
|
42
|
+
|
|
43
|
+
### Bug Fixes
|
|
44
|
+
|
|
45
|
+
- **core:** add missing jsonrpc and id fields to RPC request body ([#48](https://github.com/lifinance/bigmi/issues/48)) ([9896c7c](https://github.com/lifinance/bigmi/commit/9896c7c6f1498f54c29ae78be8a74008bad3a98a))
|
|
46
|
+
|
|
47
|
+
## [0.7.0](https://github.com/lifinance/bigmi/compare/v0.6.5...v0.7.0) (2026-02-05)
|
|
48
|
+
|
|
49
|
+
### ⚠ BREAKING CHANGES
|
|
50
|
+
|
|
51
|
+
- **client:** add unhosted wallet support (#46)
|
|
52
|
+
|
|
53
|
+
### Features
|
|
54
|
+
|
|
55
|
+
- add reown support ([#44](https://github.com/lifinance/bigmi/issues/44)) ([657cae6](https://github.com/lifinance/bigmi/commit/657cae6615965ec5be6b1c079abc10c34cdc572d))
|
|
56
|
+
- **client:** add unhosted wallet support ([#46](https://github.com/lifinance/bigmi/issues/46)) ([b3537b7](https://github.com/lifinance/bigmi/commit/b3537b77cc8a6322868330f5c6528834d86a5d99))
|
|
57
|
+
|
|
58
|
+
### [0.6.5](https://github.com/lifinance/bigmi/compare/v0.6.4...v0.6.5) (2026-01-08)
|
|
59
|
+
|
|
60
|
+
### Bug Fixes
|
|
61
|
+
|
|
62
|
+
- **blockchair-getXpubAddresses:** return empty data when api returns empty data with 200 ([#43](https://github.com/lifinance/bigmi/issues/43)) ([d2e9b5b](https://github.com/lifinance/bigmi/commit/d2e9b5ba85eff202bfdafa5b6bf9041589e994c8))
|
|
63
|
+
|
|
64
|
+
### [0.6.4](https://github.com/lifinance/bigmi/compare/v0.6.3...v0.6.4) (2025-12-17)
|
|
65
|
+
|
|
66
|
+
### Features
|
|
67
|
+
|
|
68
|
+
- add getXPubAddresses action ([#41](https://github.com/lifinance/bigmi/issues/41)) ([2aa3216](https://github.com/lifinance/bigmi/commit/2aa321602e83fc5642d7b86c8d114a0e0d38c13b))
|
|
69
|
+
|
|
70
|
+
### [0.6.3](https://github.com/lifinance/bigmi/compare/v0.6.2...v0.6.3) (2025-11-26)
|
|
71
|
+
|
|
72
|
+
### [0.6.2](https://github.com/lifinance/bigmi/compare/v0.6.1...v0.6.2) (2025-11-13)
|
|
73
|
+
|
|
74
|
+
### Bug Fixes
|
|
75
|
+
|
|
76
|
+
- **leather-wallet:** cache wallet connection with daily expiry and improve wallet reconnection reliability ([#36](https://github.com/lifinance/bigmi/issues/36)) ([fcff06e](https://github.com/lifinance/bigmi/commit/fcff06e19426154750b775f7a1b83f5c6db038dd))
|
|
77
|
+
|
|
78
|
+
### [0.6.1](https://github.com/lifinance/bigmi/compare/v0.6.0...v0.6.1) (2025-10-29)
|
|
79
|
+
|
|
80
|
+
## [0.6.0](https://github.com/lifinance/bigmi/compare/v0.5.4...v0.6.0) (2025-10-06)
|
|
81
|
+
|
|
82
|
+
### ⚠ BREAKING CHANGES
|
|
83
|
+
|
|
84
|
+
- bump packages
|
|
85
|
+
|
|
86
|
+
- bump packages ([3576fa5](https://github.com/lifinance/bigmi/commit/3576fa55cd7ed3492f29f96a8cff6274313477ff))
|
|
87
|
+
|
|
88
|
+
### [0.5.4](https://github.com/lifinance/bigmi/compare/v0.5.3...v0.5.4) (2025-09-29)
|
|
89
|
+
|
|
90
|
+
### Bug Fixes
|
|
91
|
+
|
|
92
|
+
- **blockchair:** handle zero balance addresses edge case ([#35](https://github.com/lifinance/bigmi/issues/35)) ([a57c5fd](https://github.com/lifinance/bigmi/commit/a57c5fd49ec22df2dd6165725ce2750d81f3267e))
|
|
93
|
+
|
|
94
|
+
### [0.5.3](https://github.com/lifinance/bigmi/compare/v0.5.2...v0.5.3) (2025-09-22)
|
|
95
|
+
|
|
96
|
+
### [0.5.2](https://github.com/lifinance/bigmi/compare/v0.5.1...v0.5.2) (2025-08-28)
|
|
97
|
+
|
|
98
|
+
### Bug Fixes
|
|
99
|
+
|
|
100
|
+
- imports ([6b26572](https://github.com/lifinance/bigmi/commit/6b265727d74bd84d326543a61ab52d4fb0c58ae0))
|
|
101
|
+
|
|
102
|
+
### [0.5.1](https://github.com/lifinance/bigmi/compare/v0.5.0...v0.5.1) (2025-08-28)
|
|
103
|
+
|
|
104
|
+
### Bug Fixes
|
|
105
|
+
|
|
106
|
+
- update connectors to determine chain id based on address ([#33](https://github.com/lifinance/bigmi/issues/33)) ([ae969c9](https://github.com/lifinance/bigmi/commit/ae969c909f6ca4376e4e2468152309251a983910))
|
|
107
|
+
|
|
108
|
+
## [0.5.0](https://github.com/lifinance/bigmi/compare/v0.4.5...v0.5.0) (2025-08-28)
|
|
109
|
+
|
|
110
|
+
### ⚠ BREAKING CHANGES
|
|
111
|
+
|
|
112
|
+
- change chainId to enum (#31)
|
|
113
|
+
|
|
114
|
+
- change chainId to enum ([#31](https://github.com/lifinance/bigmi/issues/31)) ([4e93517](https://github.com/lifinance/bigmi/commit/4e93517e50353ffe949c7fd7cebd3313a9d2d69e))
|
|
115
|
+
|
|
116
|
+
### [0.4.5](https://github.com/lifinance/bigmi/compare/v0.4.4...v0.4.5) (2025-08-27)
|
|
117
|
+
|
|
118
|
+
### [0.4.4](https://github.com/lifinance/bigmi/compare/v0.4.3...v0.4.4) (2025-08-18)
|
|
119
|
+
|
|
120
|
+
### [0.4.3](https://github.com/lifinance/bigmi/compare/v0.4.2...v0.4.3) (2025-07-31)
|
|
121
|
+
|
|
122
|
+
### Bug Fixes
|
|
123
|
+
|
|
124
|
+
- **connectors:** remove retry logic when checking if app isAuthorized ([#30](https://github.com/lifinance/bigmi/issues/30)) ([7709d68](https://github.com/lifinance/bigmi/commit/7709d68f67b19880940d68e288ac061ec4f074f8))
|
|
125
|
+
|
|
126
|
+
### [0.4.2](https://github.com/lifinance/bigmi/compare/v0.4.1...v0.4.2) (2025-07-17)
|
|
127
|
+
|
|
128
|
+
### [0.4.1](https://github.com/lifinance/bigmi/compare/v0.4.0...v0.4.1) (2025-07-02)
|
|
129
|
+
|
|
130
|
+
### Bug Fixes
|
|
131
|
+
|
|
132
|
+
- unisat wallet connector ([#24](https://github.com/lifinance/bigmi/issues/24)) ([6466bc5](https://github.com/lifinance/bigmi/commit/6466bc543719b1b26b1cdf990f2dc667659042a4))
|
|
133
|
+
|
|
134
|
+
## [0.4.0](https://github.com/lifinance/bigmi/compare/v0.4.0-beta.2...v0.4.0) (2025-07-01)
|
|
135
|
+
|
|
136
|
+
### Bug Fixes
|
|
137
|
+
|
|
138
|
+
- **client:** update ctrl wallet signPSBT() signature ([#23](https://github.com/lifinance/bigmi/issues/23)) ([f502b92](https://github.com/lifinance/bigmi/commit/f502b924cdc4412f551c39333ae6bab800904975))
|
|
139
|
+
|
|
140
|
+
### [0.3.1](https://github.com/lifinance/bigmi/compare/v0.3.0...v0.3.1) (2025-05-30)
|
|
141
|
+
|
|
142
|
+
### Features
|
|
143
|
+
|
|
144
|
+
- add more connectors (oyl, binance, magicEden & bitget) ([#17](https://github.com/lifinance/bigmi/issues/17)) ([18ad09a](https://github.com/lifinance/bigmi/commit/18ad09acd07726d25bd6422b0ecedd37745be335))
|
|
145
|
+
|
|
146
|
+
## [0.3.0](https://github.com/lifinance/bigmi/compare/v0.2.1...v0.3.0) (2025-05-28)
|
|
147
|
+
|
|
148
|
+
### ⚠ BREAKING CHANGES
|
|
149
|
+
|
|
150
|
+
- add getUTXOs action (#16)
|
|
151
|
+
|
|
152
|
+
### Features
|
|
153
|
+
|
|
154
|
+
- add getUTXOs action ([#16](https://github.com/lifinance/bigmi/issues/16)) ([e884c02](https://github.com/lifinance/bigmi/commit/e884c02ad902123a9daf2edaeea2ab777c315925))
|
|
155
|
+
|
|
156
|
+
### [0.2.1](https://github.com/lifinance/bigmi/compare/v0.2.0...v0.2.1) (2025-05-14)
|
|
157
|
+
|
|
158
|
+
### Bug Fixes
|
|
159
|
+
|
|
160
|
+
- optimize usage of supported methods by RPC and API transports ([#15](https://github.com/lifinance/bigmi/issues/15)) ([ff20e08](https://github.com/lifinance/bigmi/commit/ff20e089286bdc5f6f9d12ed2362f95d3c276fd9))
|
|
161
|
+
|
|
162
|
+
## [0.2.0](https://github.com/lifinance/bigmi/compare/v0.1.1...v0.2.0) (2025-05-14)
|
|
163
|
+
|
|
164
|
+
### ⚠ BREAKING CHANGES
|
|
165
|
+
|
|
166
|
+
- remove viem dependencies (#14)
|
|
167
|
+
|
|
168
|
+
- remove viem dependencies ([#14](https://github.com/lifinance/bigmi/issues/14)) ([3c3461f](https://github.com/lifinance/bigmi/commit/3c3461f8b646253df0c1614706f4dd5027d53930))
|
|
169
|
+
|
|
170
|
+
### [0.1.1](https://github.com/lifinance/bigmi/compare/v0.0.8...v0.1.1) (2025-02-04)
|
|
171
|
+
|
|
172
|
+
### [0.0.8](https://github.com/lifinance/bigmi/compare/v0.0.7...v0.0.8) (2024-12-30)
|
|
173
|
+
|
|
174
|
+
### Features
|
|
175
|
+
|
|
176
|
+
- add Leather and OneKey wallets ([#7](https://github.com/lifinance/bigmi/issues/7)) ([ac93f66](https://github.com/lifinance/bigmi/commit/ac93f665c8baa24752fd0ad4e2c513b72587060f))
|
|
177
|
+
|
|
178
|
+
### [0.0.7](https://github.com/lifinance/bigmi/compare/v0.0.6...v0.0.7) (2024-12-20)
|
|
179
|
+
|
|
180
|
+
### Features
|
|
181
|
+
|
|
182
|
+
- improve peer dependencies ([#6](https://github.com/lifinance/bigmi/issues/6)) ([a9359d1](https://github.com/lifinance/bigmi/commit/a9359d1f72d5089652bad9311d8cd0ee67c909d4))
|
|
183
|
+
|
|
184
|
+
### [0.0.6](https://github.com/lifinance/bigmi/compare/v0.0.5...v0.0.6) (2024-12-13)
|
|
185
|
+
|
|
186
|
+
### [0.0.5](https://github.com/lifinance/bigmi/compare/v0.0.4...v0.0.5) (2024-12-05)
|
|
187
|
+
|
|
188
|
+
### [0.0.4](https://github.com/lifinance/bigmi/compare/v0.0.3...v0.0.4) (2024-10-28)
|
|
189
|
+
|
|
190
|
+
### Features
|
|
191
|
+
|
|
192
|
+
- add okx wallet ([58b93b5](https://github.com/lifinance/bigmi/commit/58b93b5f8839bbbb0340ff7ac77f03617325c506))
|
|
193
|
+
|
|
194
|
+
### [0.0.3](https://github.com/lifinance/bigmi/compare/v0.0.2...v0.0.3) (2024-10-23)
|
|
195
|
+
|
|
196
|
+
### 0.0.2 (2024-10-17)
|
|
197
|
+
|
|
198
|
+
### Bug Fixes
|
|
199
|
+
|
|
200
|
+
- add createConfig export ([dec450a](https://github.com/lifinance/bigmi/commit/dec450a7e5a071e67e259be78c0b9a8b616c7183))
|
|
201
|
+
|
|
202
|
+
### 0.0.1 (2024-10-15)
|
|
203
|
+
|
|
204
|
+
### Bug Fixes
|
|
205
|
+
|
|
206
|
+
- biome checks ([bc348fa](https://github.com/lifinance/bigmi/commit/bc348faad5cec9ddada1a0c82f4d34e68b85c1c4))
|
|
207
|
+
- tsconfig ([bf6ccea](https://github.com/lifinance/bigmi/commit/bf6cceae3a1602b99b4825ee3695b367d5935226))
|
package/LICENSE.md
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024 Bigmi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,471 @@
|
|
|
1
|
+
<div align="center">
|
|
2
|
+
|
|
3
|
+
<h1 align="center">Bigmi</h1>
|
|
4
|
+
<p align="center"><strong>TypeScript library and reactive primitives for Bitcoin apps.</strong></p>
|
|
5
|
+
|
|
6
|
+
[](/LICENSE.md)
|
|
7
|
+
[](https://www.npmjs.com/package/@bigmi/core)
|
|
8
|
+
[](https://www.npmjs.com/package/@bigmi/core)
|
|
9
|
+
|
|
10
|
+
</div>
|
|
11
|
+
|
|
12
|
+
**Bigmi** (short for *Bitcoin Is Gonna Make It*) is a TypeScript library that provides reactive primitives for building Bitcoin applications. Bigmi simplifies Bitcoin app development by offering:
|
|
13
|
+
|
|
14
|
+
- Abstractions over the [Bitcoin JSON-RPC API](https://developer.bitcoin.org/reference/rpc/)
|
|
15
|
+
- First-class APIs for interacting with the [Bitcoin](https://bitcoin.design/) network, including sending transactions and tracking with [Replace-By-Fee (RBF)](https://github.com/bitcoin/bips/blob/master/bip-0125.mediawiki) support
|
|
16
|
+
- Connectors for popular Bitcoin wallet extensions
|
|
17
|
+
- TypeScript support
|
|
18
|
+
|
|
19
|
+
Whether you're building a Node.js application or a client-side app, Bigmi provides the tools you need to interact with the Bitcoin.
|
|
20
|
+
|
|
21
|
+
### Packages
|
|
22
|
+
|
|
23
|
+
Bigmi is modularized into several packages, each suited to different use cases:
|
|
24
|
+
|
|
25
|
+
- [@bigmi/core](https://www.npmjs.com/package/@bigmi/core) - Actions, transports, utilities, and other core primitives for Node.js or client-side applications.
|
|
26
|
+
- [@bigmi/react](https://www.npmjs.com/package/@bigmi/react) - Hooks, providers, and other useful primitives for React applications.
|
|
27
|
+
- [@bigmi/client](https://www.npmjs.com/package/@bigmi/client) - Wallet connectors and other tools to connect wallet extensions with Bitcoin applications.
|
|
28
|
+
|
|
29
|
+
## Installation
|
|
30
|
+
|
|
31
|
+
```sh
|
|
32
|
+
pnpm add @bigmi/react
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+
```sh
|
|
36
|
+
pnpm add @bigmi/core
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
```sh
|
|
40
|
+
pnpm add @bigmi/client
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
## Getting Started
|
|
44
|
+
|
|
45
|
+
### Node.js
|
|
46
|
+
|
|
47
|
+
How to setup Bigmi on the backend with Node.js:
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
// main.ts
|
|
51
|
+
import {
|
|
52
|
+
createClient,
|
|
53
|
+
bitcoin,
|
|
54
|
+
blockchair,
|
|
55
|
+
sendUTXOTransaction,
|
|
56
|
+
waitForTransaction,
|
|
57
|
+
getBalance,
|
|
58
|
+
} from '@bigmi/core'
|
|
59
|
+
|
|
60
|
+
// Create a client for Bitcoin mainnet
|
|
61
|
+
const publicClient = createClient({
|
|
62
|
+
chain: bitcoin,
|
|
63
|
+
rpcSchema: rpcSchema<UTXOSchema>(),
|
|
64
|
+
transport: fallback([
|
|
65
|
+
blockchair(),
|
|
66
|
+
ankr({apiKey: 'YOUR_ANKR_API_KEY'}),
|
|
67
|
+
blockcypher(),
|
|
68
|
+
mempool(),
|
|
69
|
+
]),
|
|
70
|
+
})
|
|
71
|
+
|
|
72
|
+
// Define the Bitcoin address you're working with
|
|
73
|
+
const address = 'BITCOIN_ADDRESS';
|
|
74
|
+
|
|
75
|
+
// Fetch the balance of the address
|
|
76
|
+
const balance = await getBalance(publicClient, { address });
|
|
77
|
+
console.log(`Balance for ${address}:`, balance);
|
|
78
|
+
|
|
79
|
+
// Fetch the current block count (height)
|
|
80
|
+
const blockCount = await getBlockCount(publicClient);
|
|
81
|
+
console.log('Current block count:', blockCount);
|
|
82
|
+
|
|
83
|
+
// Prepare the transaction hex (as a string)
|
|
84
|
+
const txHex = 'TRANSACTION_HEX';
|
|
85
|
+
|
|
86
|
+
// Send the transaction to the network
|
|
87
|
+
const txId = await sendUTXOTransaction(publicClient, { hex: txHex });
|
|
88
|
+
console.log('Transaction sent with ID:', txId);
|
|
89
|
+
|
|
90
|
+
// Wait for the transaction to be confirmed
|
|
91
|
+
const transaction = await waitForTransaction(publicClient, {
|
|
92
|
+
txId,
|
|
93
|
+
txHex,
|
|
94
|
+
senderAddress: address,
|
|
95
|
+
onReplaced: (response) => {
|
|
96
|
+
console.log('Transaction replaced due to:', response.reason);
|
|
97
|
+
},
|
|
98
|
+
});
|
|
99
|
+
|
|
100
|
+
console.log('Transaction confirmed:', transaction);
|
|
101
|
+
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
### React
|
|
105
|
+
|
|
106
|
+
Simple bigmi setup with a react app:
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
// App.tsx
|
|
110
|
+
|
|
111
|
+
import { bitcoin, http, createClient } from '@bigmi/core'
|
|
112
|
+
import { BigmiProvider, createConfig } from '@bigmi/react'
|
|
113
|
+
import { binance, xverse, phantom } from '@bigmi/client'
|
|
114
|
+
|
|
115
|
+
// Create bigmi config object
|
|
116
|
+
const config = createConfig({
|
|
117
|
+
chains: [bitcoin],
|
|
118
|
+
connectors: [binance(), xverse(), phantom()],
|
|
119
|
+
client: ({ chain }) => createClient({ chain, transport: http() }),
|
|
120
|
+
ssr: true // If using Next.js or SSR
|
|
121
|
+
})
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
function App() {
|
|
125
|
+
return (
|
|
126
|
+
// Wrap your application with the necessary providers:
|
|
127
|
+
<BigmiProvider config={config}>
|
|
128
|
+
<YourApp />
|
|
129
|
+
</BigmiProvider>
|
|
130
|
+
)
|
|
131
|
+
}
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
```typescript
|
|
135
|
+
// YourApp.tsx
|
|
136
|
+
|
|
137
|
+
// Import the hooks from bigmi/react library
|
|
138
|
+
import { useAccount, useBalance, useConnect } from '@bigmi/react'
|
|
139
|
+
|
|
140
|
+
const { address, isConnected } = useAccount()
|
|
141
|
+
const { balance } = useBalance()
|
|
142
|
+
const { connect } = useConnect()
|
|
143
|
+
|
|
144
|
+
function YourApp() {
|
|
145
|
+
return (
|
|
146
|
+
<div>
|
|
147
|
+
{isConnected ? (
|
|
148
|
+
<p>Connected: {address}: {balance}BTC</p>
|
|
149
|
+
) : (
|
|
150
|
+
<button onClick={connect}>Connect Wallet</button>
|
|
151
|
+
)}
|
|
152
|
+
</div>
|
|
153
|
+
)
|
|
154
|
+
}
|
|
155
|
+
```
|
|
156
|
+
|
|
157
|
+
## Creating Bitcoin Transactions
|
|
158
|
+
|
|
159
|
+
While Bigmi excels at blockchain data retrieval and transaction broadcasting, it doesn't include transaction creation functions. For generating valid transaction hex, we recommend using **bitcoinjs-lib** (which Bigmi already depends on).
|
|
160
|
+
|
|
161
|
+
### Basic Transaction Creation
|
|
162
|
+
|
|
163
|
+
Here's how to create a Bitcoin transaction using bitcoinjs-lib with Bigmi:
|
|
164
|
+
|
|
165
|
+
```typescript
|
|
166
|
+
import * as bitcoin from 'bitcoinjs-lib';
|
|
167
|
+
import {
|
|
168
|
+
createClient,
|
|
169
|
+
getUTXOs,
|
|
170
|
+
sendUTXOTransaction,
|
|
171
|
+
waitForTransaction,
|
|
172
|
+
getBlockStats,
|
|
173
|
+
getBlockCount
|
|
174
|
+
} from '@bigmi/core';
|
|
175
|
+
|
|
176
|
+
async function createAndSendTransaction(
|
|
177
|
+
client: Client,
|
|
178
|
+
fromAddress: string,
|
|
179
|
+
toAddress: string,
|
|
180
|
+
amount: number, // in satoshis
|
|
181
|
+
privateKey: Buffer
|
|
182
|
+
) {
|
|
183
|
+
// 1. Get UTXOs for the address using Bigmi
|
|
184
|
+
const utxos = await getUTXOs(client, { address: fromAddress });
|
|
185
|
+
|
|
186
|
+
// 2. Create a new transaction using bitcoinjs-lib
|
|
187
|
+
const psbt = new bitcoin.Psbt();
|
|
188
|
+
|
|
189
|
+
// 3. Add inputs from UTXOs
|
|
190
|
+
let inputValue = 0;
|
|
191
|
+
const estimatedFee = 1000; // You should calculate this properly
|
|
192
|
+
|
|
193
|
+
for (const utxo of utxos) {
|
|
194
|
+
psbt.addInput({
|
|
195
|
+
hash: utxo.txId,
|
|
196
|
+
index: utxo.vout,
|
|
197
|
+
witnessUtxo: {
|
|
198
|
+
script: Buffer.from(utxo.scriptHex, 'hex'),
|
|
199
|
+
value: utxo.value,
|
|
200
|
+
},
|
|
201
|
+
});
|
|
202
|
+
inputValue += utxo.value;
|
|
203
|
+
if (inputValue >= amount + estimatedFee) break;
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
// 4. Add recipient output
|
|
207
|
+
psbt.addOutput({
|
|
208
|
+
address: toAddress,
|
|
209
|
+
value: amount,
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
// 5. Add change output if needed
|
|
213
|
+
const change = inputValue - amount - estimatedFee;
|
|
214
|
+
if (change > 546) { // Dust threshold
|
|
215
|
+
psbt.addOutput({
|
|
216
|
+
address: fromAddress,
|
|
217
|
+
value: change,
|
|
218
|
+
});
|
|
219
|
+
}
|
|
220
|
+
|
|
221
|
+
// 6. Sign the transaction
|
|
222
|
+
const keyPair = bitcoin.ECPair.fromPrivateKey(privateKey);
|
|
223
|
+
psbt.signAllInputs(keyPair);
|
|
224
|
+
psbt.finalizeAllInputs();
|
|
225
|
+
|
|
226
|
+
// 7. Get the raw transaction hex
|
|
227
|
+
const rawTx = psbt.extractTransaction().toHex();
|
|
228
|
+
|
|
229
|
+
// 8. Broadcast using Bigmi
|
|
230
|
+
const txId = await sendUTXOTransaction(client, { hex: rawTx });
|
|
231
|
+
|
|
232
|
+
// 9. Wait for confirmation using Bigmi
|
|
233
|
+
const confirmedTx = await waitForTransaction(client, {
|
|
234
|
+
txId,
|
|
235
|
+
txHex: rawTx,
|
|
236
|
+
senderAddress: fromAddress,
|
|
237
|
+
confirmations: 1,
|
|
238
|
+
});
|
|
239
|
+
|
|
240
|
+
return confirmedTx;
|
|
241
|
+
}
|
|
242
|
+
```
|
|
243
|
+
|
|
244
|
+
### Fee Estimation
|
|
245
|
+
|
|
246
|
+
Proper fee estimation is crucial for transaction confirmation:
|
|
247
|
+
|
|
248
|
+
```typescript
|
|
249
|
+
async function estimateFee(
|
|
250
|
+
client: Client,
|
|
251
|
+
numInputs: number,
|
|
252
|
+
numOutputs: number
|
|
253
|
+
): Promise<number> {
|
|
254
|
+
// Get recent block stats for fee estimation
|
|
255
|
+
const blockHeight = await getBlockCount(client);
|
|
256
|
+
const blockStats = await getBlockStats(client, {
|
|
257
|
+
blockNumber: blockHeight,
|
|
258
|
+
stats: ['avgfeerate']
|
|
259
|
+
});
|
|
260
|
+
|
|
261
|
+
// Estimate transaction size
|
|
262
|
+
// P2WPKH: ~68 bytes per input, ~31 bytes per output, ~10 bytes overhead
|
|
263
|
+
const estimatedSize = (numInputs * 68) + (numOutputs * 31) + 10;
|
|
264
|
+
|
|
265
|
+
// Calculate fee (satoshis per byte * size)
|
|
266
|
+
const feeRate = blockStats.avgfeerate || 1; // fallback to 1 sat/byte
|
|
267
|
+
return Math.ceil(feeRate * estimatedSize);
|
|
268
|
+
}
|
|
269
|
+
```
|
|
270
|
+
|
|
271
|
+
### Complete Example with Error Handling
|
|
272
|
+
|
|
273
|
+
```typescript
|
|
274
|
+
import * as bitcoin from 'bitcoinjs-lib';
|
|
275
|
+
import { createClient, getBalance, getUTXOs, sendUTXOTransaction, waitForTransaction } from '@bigmi/core';
|
|
276
|
+
|
|
277
|
+
async function safeSendBitcoin(
|
|
278
|
+
client: Client,
|
|
279
|
+
fromAddress: string,
|
|
280
|
+
toAddress: string,
|
|
281
|
+
amount: number,
|
|
282
|
+
privateKey: Buffer
|
|
283
|
+
) {
|
|
284
|
+
try {
|
|
285
|
+
// Check balance
|
|
286
|
+
const balance = await getBalance(client, { address: fromAddress });
|
|
287
|
+
if (balance < amount + 1000) {
|
|
288
|
+
throw new Error('Insufficient balance');
|
|
289
|
+
}
|
|
290
|
+
|
|
291
|
+
// Get UTXOs
|
|
292
|
+
const utxos = await getUTXOs(client, {
|
|
293
|
+
address: fromAddress,
|
|
294
|
+
minValue: amount + 1000,
|
|
295
|
+
});
|
|
296
|
+
|
|
297
|
+
if (utxos.length === 0) {
|
|
298
|
+
throw new Error('No UTXOs available');
|
|
299
|
+
}
|
|
300
|
+
|
|
301
|
+
// Create transaction
|
|
302
|
+
const psbt = new bitcoin.Psbt();
|
|
303
|
+
|
|
304
|
+
let totalInput = 0;
|
|
305
|
+
for (const utxo of utxos) {
|
|
306
|
+
psbt.addInput({
|
|
307
|
+
hash: utxo.txId,
|
|
308
|
+
index: utxo.vout,
|
|
309
|
+
witnessUtxo: {
|
|
310
|
+
script: Buffer.from(utxo.scriptHex, 'hex'),
|
|
311
|
+
value: utxo.value,
|
|
312
|
+
},
|
|
313
|
+
});
|
|
314
|
+
totalInput += utxo.value;
|
|
315
|
+
}
|
|
316
|
+
|
|
317
|
+
// Add outputs
|
|
318
|
+
psbt.addOutput({
|
|
319
|
+
address: toAddress,
|
|
320
|
+
value: amount,
|
|
321
|
+
});
|
|
322
|
+
|
|
323
|
+
// Calculate fee and change
|
|
324
|
+
const fee = await estimateFee(client, utxos.length, 2);
|
|
325
|
+
const change = totalInput - amount - fee;
|
|
326
|
+
|
|
327
|
+
if (change < 0) {
|
|
328
|
+
throw new Error('Insufficient funds for fee');
|
|
329
|
+
}
|
|
330
|
+
|
|
331
|
+
if (change > 546) { // Dust threshold
|
|
332
|
+
psbt.addOutput({
|
|
333
|
+
address: fromAddress,
|
|
334
|
+
value: change,
|
|
335
|
+
});
|
|
336
|
+
}
|
|
337
|
+
|
|
338
|
+
// Sign and finalize
|
|
339
|
+
const keyPair = bitcoin.ECPair.fromPrivateKey(privateKey);
|
|
340
|
+
psbt.signAllInputs(keyPair);
|
|
341
|
+
psbt.finalizeAllInputs();
|
|
342
|
+
|
|
343
|
+
// Get transaction hex
|
|
344
|
+
const txHex = psbt.extractTransaction().toHex();
|
|
345
|
+
|
|
346
|
+
// Broadcast with Bigmi
|
|
347
|
+
const txId = await sendUTXOTransaction(client, { hex: txHex });
|
|
348
|
+
|
|
349
|
+
// Wait for confirmation
|
|
350
|
+
const confirmed = await waitForTransaction(client, {
|
|
351
|
+
txId,
|
|
352
|
+
txHex,
|
|
353
|
+
senderAddress: fromAddress,
|
|
354
|
+
confirmations: 1,
|
|
355
|
+
});
|
|
356
|
+
|
|
357
|
+
return {
|
|
358
|
+
txId,
|
|
359
|
+
fee,
|
|
360
|
+
confirmed,
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
} catch (error) {
|
|
364
|
+
console.error('Transaction failed:', error);
|
|
365
|
+
throw error;
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
```
|
|
369
|
+
|
|
370
|
+
### Working with Different Address Types
|
|
371
|
+
|
|
372
|
+
```typescript
|
|
373
|
+
import { getAddressInfo } from '@bigmi/core';
|
|
374
|
+
|
|
375
|
+
function createInputForUTXO(utxo: UTXO, addressInfo: AddressInfo) {
|
|
376
|
+
const input: any = {
|
|
377
|
+
hash: utxo.txId,
|
|
378
|
+
index: utxo.vout,
|
|
379
|
+
};
|
|
380
|
+
|
|
381
|
+
switch (addressInfo.type) {
|
|
382
|
+
case 'p2wpkh':
|
|
383
|
+
case 'p2wsh':
|
|
384
|
+
// Witness UTXOs for SegWit
|
|
385
|
+
input.witnessUtxo = {
|
|
386
|
+
script: Buffer.from(utxo.scriptHex, 'hex'),
|
|
387
|
+
value: utxo.value,
|
|
388
|
+
};
|
|
389
|
+
break;
|
|
390
|
+
case 'p2pkh':
|
|
391
|
+
case 'p2sh':
|
|
392
|
+
// Need full transaction for legacy
|
|
393
|
+
input.nonWitnessUtxo = Buffer.from(fullTransactionHex, 'hex');
|
|
394
|
+
break;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
return input;
|
|
398
|
+
}
|
|
399
|
+
```
|
|
400
|
+
|
|
401
|
+
### RBF (Replace-By-Fee) Support
|
|
402
|
+
|
|
403
|
+
Create transactions with RBF enabled for fee bumping:
|
|
404
|
+
|
|
405
|
+
```typescript
|
|
406
|
+
const psbt = new bitcoin.Psbt();
|
|
407
|
+
|
|
408
|
+
// Add inputs with RBF sequence
|
|
409
|
+
for (const utxo of utxos) {
|
|
410
|
+
psbt.addInput({
|
|
411
|
+
hash: utxo.txId,
|
|
412
|
+
index: utxo.vout,
|
|
413
|
+
sequence: 0xfffffffd, // RBF enabled
|
|
414
|
+
witnessUtxo: {
|
|
415
|
+
script: Buffer.from(utxo.scriptHex, 'hex'),
|
|
416
|
+
value: utxo.value,
|
|
417
|
+
},
|
|
418
|
+
});
|
|
419
|
+
}
|
|
420
|
+
```
|
|
421
|
+
|
|
422
|
+
### Alternative Libraries
|
|
423
|
+
|
|
424
|
+
While we recommend bitcoinjs-lib, you can also use:
|
|
425
|
+
- **@scure/btc-signer** - Modern, audited Bitcoin transaction library
|
|
426
|
+
- **bitcore-lib** - Alternative to bitcoinjs-lib
|
|
427
|
+
- **bcoin** - Full Bitcoin implementation
|
|
428
|
+
|
|
429
|
+
### Security Best Practices
|
|
430
|
+
|
|
431
|
+
1. **Never expose private keys** in client-side code
|
|
432
|
+
2. **Use hardware wallets** for production applications
|
|
433
|
+
3. **Validate all inputs** before creating transactions
|
|
434
|
+
4. **Test on testnet** before mainnet deployment
|
|
435
|
+
5. **Implement proper error handling** for all edge cases
|
|
436
|
+
|
|
437
|
+
## Examples
|
|
438
|
+
|
|
439
|
+
- [See Node.js examples](./docs/core/examples.md)
|
|
440
|
+
- [See React examples](./docs/react/examples.md)
|
|
441
|
+
|
|
442
|
+
You can explore the [LI.FI Widget](https://github.com/lifinance/widget) and [LI.FI SDK](https://github.com/lifinance/sdk) for detailed production examples.
|
|
443
|
+
|
|
444
|
+
## Documentation
|
|
445
|
+
|
|
446
|
+
- [Learn more about Configuration](./docs/core/config.md)
|
|
447
|
+
- [See Core Docs](./docs/core/index.md)
|
|
448
|
+
- [See Client Docs](./docs/client/index.md)
|
|
449
|
+
- [See React Docs](./docs/react/index.md)
|
|
450
|
+
|
|
451
|
+
- [Want to add support for your wallet?](./docs/client/connectors.md)
|
|
452
|
+
|
|
453
|
+
## Support
|
|
454
|
+
|
|
455
|
+
If you encounter any issues or have questions, please open an issue.
|
|
456
|
+
|
|
457
|
+
## Contributing
|
|
458
|
+
|
|
459
|
+
We welcome contributions from the community!
|
|
460
|
+
|
|
461
|
+
## Changelog
|
|
462
|
+
|
|
463
|
+
The [changelog](/CHANGELOG.md) is regularly updated to reflect what's changed in each new release.
|
|
464
|
+
|
|
465
|
+
## License
|
|
466
|
+
|
|
467
|
+
This project is licensed under the terms of the [MIT License](/LICENSE.md).
|
|
468
|
+
|
|
469
|
+
## Acknowledgments
|
|
470
|
+
|
|
471
|
+
Bigmi is inspired by the [wevm](https://github.com/wevm) stack. We appreciate the open-source community's contributions to advancing blockchain development.
|