@bze/bze-ui-kit 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.
package/README.md ADDED
@@ -0,0 +1,212 @@
1
+ # @bze/bze-ui-kit
2
+
3
+ Shared utilities, hooks, query clients, and services for BZE ecosystem frontend apps.
4
+
5
+ ## Installation
6
+
7
+ ```sh
8
+ npm install @bze/bze-ui-kit
9
+ ```
10
+
11
+ ### Peer dependencies
12
+
13
+ The consuming app must have these installed (they are **not** bundled):
14
+
15
+ ```sh
16
+ npm install @bze/bzejs @cosmjs/stargate bignumber.js chain-registry \
17
+ @chain-registry/types @chain-registry/utils @chain-registry/v2 \
18
+ @interchain-kit/core @interchain-kit/react @interchainjs/encoding \
19
+ react react-dom
20
+ ```
21
+
22
+ ## Usage
23
+
24
+ ```ts
25
+ import {
26
+ // Configuration — call these early in your app
27
+ setStorageKeyVersion,
28
+ setDefaultTxMemo,
29
+
30
+ // Utils
31
+ toBigNumber, prettyAmount, createMarketId, formatUsdAmount,
32
+
33
+ // Query clients
34
+ getMarkets, getLiquidityPools, getAddressBalances, getBZEUSDPrice,
35
+
36
+ // Hooks
37
+ useAssets, useBalances, useMarkets, useLiquidityPools,
38
+
39
+ // Context (provide your own AssetsProvider)
40
+ AssetsContext,
41
+
42
+ // Types
43
+ type Asset, type Market, type Balance,
44
+ } from '@bze/bze-ui-kit';
45
+ ```
46
+
47
+ ### App initialization
48
+
49
+ Each app must configure the library at startup:
50
+
51
+ ```ts
52
+ // In your app's entry point (e.g., layout.tsx or _app.tsx)
53
+ import { setStorageKeyVersion, setDefaultTxMemo } from '@bze/bze-ui-kit';
54
+
55
+ // Set a unique storage prefix to avoid localStorage collisions between apps
56
+ setStorageKeyVersion('3'); // dex uses '3', burner uses '2'
57
+
58
+ // Set the default transaction memo
59
+ setDefaultTxMemo('dex.getbze.com');
60
+ ```
61
+
62
+ ### AssetsProvider
63
+
64
+ The library exports the `AssetsContext` and `AssetsContextType` but each app must implement its own `AssetsProvider`. This is because the dex and burner have different app-specific state on top of the shared base.
65
+
66
+ ## What's included
67
+
68
+ | Module | Description |
69
+ |--------|-------------|
70
+ | `types/` | TypeScript interfaces for assets, balances, markets, pools, staking, IBC, events, settings |
71
+ | `utils/` | Pure functions: amount math, denom helpers, formatting, address validation, staking APR, chart periods |
72
+ | `constants/` | Chain config, RPC/REST endpoints, asset lists, keplr fallbacks, testnet definitions |
73
+ | `storage/` | localStorage wrapper with TTL + app settings persistence |
74
+ | `service/` | AmmRouter (Dijkstra swap routing), BlockchainEventManager (pub-sub), assets_factory, keplr suggest chain |
75
+ | `query/` | REST clients for bank, staking, markets, liquidity pools, epochs, IBC, burner, rewards, aggregator, prices |
76
+ | `hooks/` | React hooks: useAssets, useBalances, useMarkets, useLiquidityPools, usePrices, useEpochs, useSigningClient, useSettings, useFeeTokens, useAssetsValue, useConnectionType |
77
+ | `contexts/` | Base `AssetsContextType` interface + `AssetsContext` React context |
78
+
79
+ ## Required environment variables
80
+
81
+ The library reads these `NEXT_PUBLIC_*` env vars at build time (inlined by Next.js). The consuming app must define them in its `.env` file.
82
+
83
+ ### Chain configuration
84
+
85
+ | Env var | Default | Description |
86
+ |---------|---------|-------------|
87
+ | `NEXT_PUBLIC_CHAIN_ID` | `beezee-1` | Chain ID |
88
+ | `NEXT_PUBLIC_CHAIN_NAME` | `beezee` | Chain name (must match chain-registry) |
89
+ | `NEXT_PUBLIC_CHAIN_IS_TESTNET` | `false` | Set to `true` or `1` for testnet |
90
+ | `NEXT_PUBLIC_CHAIN_ADDRESS_PREFIX` | `bze` | Bech32 address prefix |
91
+ | `NEXT_PUBLIC_CHAIN_NATIVE_ASSET_DENOM` | `ubze` | Native staking/fee denom |
92
+ | `NEXT_PUBLIC_USDC_IBC_DENOM` | _(empty)_ | IBC denom for USDC on BZE chain |
93
+ | `NEXT_PUBLIC_EXPLORER_URL` | `https://explorer.chaintools.tech` | Block explorer base URL |
94
+ | `NEXT_PUBLIC_WALLET_CHAINS_NAMES` | _(auto)_ | Comma-separated chain names for wallet connection |
95
+ | `NEXT_PUBLIC_LOCKER_ADDRESS` | `bze1pc5zjcvhx3e8l305zjl72grytfa30r5mdypmw4` | Locker module address (used by dex for locked balances) |
96
+ | `NEXT_PUBLIC_APP_NAME` | `BZE` | Display name shown in settings UI |
97
+
98
+ ### BZE endpoints
99
+
100
+ | Env var | Default | Description |
101
+ |---------|---------|-------------|
102
+ | `NEXT_PUBLIC_REST_URL` | _(empty)_ | Default BZE REST endpoint |
103
+ | `NEXT_PUBLIC_RPC_URL` | _(empty)_ | Default BZE RPC endpoint |
104
+ | `NEXT_PUBLIC_REST_ENDPOINT` | _(empty)_ | User-configurable REST endpoint (settings default) |
105
+ | `NEXT_PUBLIC_RPC_ENDPOINT` | _(empty)_ | User-configurable RPC endpoint (settings default) |
106
+ | `NEXT_PUBLIC_AGG_API_HOST` | `https://getbze.com` | Aggregator API host for prices/tickers |
107
+
108
+ ### IBC chain endpoints
109
+
110
+ | Env var | Description |
111
+ |---------|-------------|
112
+ | `NEXT_PUBLIC_RPC_URL_ARCHWAY` | Archway RPC |
113
+ | `NEXT_PUBLIC_RPC_URL_OSMOSIS` | Osmosis RPC |
114
+ | `NEXT_PUBLIC_RPC_URL_NOBLE` | Noble RPC |
115
+ | `NEXT_PUBLIC_RPC_URL_JACKAL` | Jackal RPC |
116
+ | `NEXT_PUBLIC_RPC_URL_FLIX` | OmniFlix RPC |
117
+ | `NEXT_PUBLIC_RPC_URL_ATOMONE` | AtomOne RPC |
118
+ | `NEXT_PUBLIC_REST_URL_ARCHWAY` | Archway REST |
119
+ | `NEXT_PUBLIC_REST_URL_OSMOSIS` | Osmosis REST |
120
+ | `NEXT_PUBLIC_REST_URL_NOBLE` | Noble REST |
121
+ | `NEXT_PUBLIC_REST_URL_JACKAL` | Jackal REST |
122
+ | `NEXT_PUBLIC_REST_URL_FLIX` | OmniFlix REST |
123
+ | `NEXT_PUBLIC_REST_URL_ATOMONE` | AtomOne REST |
124
+
125
+ ### AtomOne validator (dex-only)
126
+
127
+ | Env var | Default | Description |
128
+ |---------|---------|-------------|
129
+ | `NEXT_PUBLIC_ATONE_VALIDATOR_SUPPORTED_DENOMS` | _(empty)_ | Comma-separated denoms supported by BZE validator |
130
+ | `NEXT_PUBLIC_ATONE_VALIDATOR_PAGE_URL` | _(empty)_ | URL to the validator page |
131
+
132
+ ## What stays app-specific
133
+
134
+ These are **not** in the library — each app keeps its own:
135
+
136
+ - **useToast / useTx** — depend on app-specific Chakra UI toaster component
137
+ - **useBlockchainListener** — different WebSocket event subscriptions per app
138
+ - **useNavigation** — completely different route structures
139
+ - **AssetsProvider** — each app composes the shared base with app-specific state
140
+ - **Burner-only**: raffle queries, burn history hooks, block queries
141
+ - **Dex-only**: locked liquidity hook, native staking data hook, rewards staking data hook
142
+
143
+ ## Development
144
+
145
+ ```sh
146
+ # Install dependencies
147
+ npm install
148
+
149
+ # Build (CJS + ESM + type declarations)
150
+ npm run build
151
+
152
+ # Watch mode for development
153
+ npm run dev
154
+
155
+ # Type-check without emitting
156
+ npm run lint
157
+ ```
158
+
159
+ ## Build & Publish to npm
160
+
161
+ ### Prerequisites
162
+
163
+ 1. Make sure you are logged in to npm:
164
+ ```sh
165
+ npm login
166
+ ```
167
+
168
+ 2. Verify you have publish access to the `@bze` scope:
169
+ ```sh
170
+ npm access list packages @bze
171
+ ```
172
+
173
+ ### Steps
174
+
175
+ ```sh
176
+ # 1. Make sure you're on a clean state
177
+ git status
178
+
179
+ # 2. Update the version in package.json
180
+ # For a patch release:
181
+ npm version patch
182
+ # For a minor release:
183
+ npm version minor
184
+ # For a major release:
185
+ npm version major
186
+
187
+ # 3. Build the library
188
+ npm run build
189
+
190
+ # 4. Verify the build output looks correct
191
+ ls -la dist/
192
+ # Should contain: index.js, index.mjs, index.d.ts, index.d.mts, and source maps
193
+
194
+ # 5. Do a dry run to see what would be published
195
+ npm publish --dry-run
196
+
197
+ # 6. Publish to npm
198
+ npm publish
199
+
200
+ # 7. Verify the published package
201
+ npm view @bze/bze-ui-kit
202
+ ```
203
+
204
+ ### Quick one-liner
205
+
206
+ ```sh
207
+ npm version patch && npm run build && npm publish
208
+ ```
209
+
210
+ ## License
211
+
212
+ MIT