@ape.swap/bonds-sdk 7.0.0-test.5 → 7.0.0-test.6
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 +59 -31
- package/dist/components/ApeBondSDK/index.d.ts +13 -0
- package/dist/components/ApeBondSDK/index.js +20 -0
- package/dist/components/ApeBondSDK/index.js.map +1 -0
- package/dist/main.d.ts +4 -4
- package/dist/main.js +4 -4
- package/dist/main.js.map +1 -1
- package/dist/providers/index.d.ts +3 -0
- package/dist/providers/index.js +7 -3
- package/dist/providers/index.js.map +1 -1
- package/dist/state/chainAccount/useChainAccount.d.ts +5 -1
- package/dist/state/chainAccount/useChainAccount.js +19 -1
- package/dist/state/chainAccount/useChainAccount.js.map +1 -1
- package/dist/state/useSDKConfig.d.ts +12 -1
- package/dist/state/useSDKConfig.js +76 -56
- package/dist/state/useSDKConfig.js.map +1 -1
- package/dist/views/Bonds/index.d.ts +1 -3
- package/dist/views/Bonds/index.js +1 -5
- package/dist/views/Bonds/index.js.map +1 -1
- package/dist/views/BuyBond/index.d.ts +1 -4
- package/dist/views/BuyBond/index.js +1 -5
- package/dist/views/BuyBond/index.js.map +1 -1
- package/dist/views/FullBondsView/index.d.ts +1 -3
- package/dist/views/FullBondsView/index.js +1 -5
- package/dist/views/FullBondsView/index.js.map +1 -1
- package/dist/views/ProjectView/index.d.ts +1 -4
- package/dist/views/ProjectView/index.js +1 -5
- package/dist/views/ProjectView/index.js.map +1 -1
- package/dist/views/SingleBond/index.d.ts +1 -4
- package/dist/views/SingleBond/index.js +1 -5
- package/dist/views/SingleBond/index.js.map +1 -1
- package/dist/views/YourBonds/index.d.ts +1 -3
- package/dist/views/YourBonds/index.js +1 -5
- package/dist/views/YourBonds/index.js.map +1 -1
- package/package.json +5 -5
package/README.md
CHANGED
|
@@ -7,17 +7,18 @@ The `@ape.swap/bonds-sdk` package provides embeddable React components to show,
|
|
|
7
7
|
## Key Features
|
|
8
8
|
|
|
9
9
|
- Ready-made bond views: `<FullBondsView />`, `<Bonds />`, `<YourBonds />`, `<SingleBond />`, `<ProjectView />` and `<BuyBondModal />`.
|
|
10
|
+
- One `<ApeBondSDK />` component configures the SDK for your whole app; the views and hooks just work below it.
|
|
10
11
|
- **Chain adapters:** install and bundle only the chain families you use (EVM, Solana, Sui, Aptos), plus an optional LiFi cross-chain bridge.
|
|
11
12
|
- Works with your existing wallet setup (wagmi, Solana wallet adapter, Sui dapp-kit, Aptos wallet adapter) and your own wallet-connect modal.
|
|
12
13
|
- Prebuilt, scoped styles that never leak into your app, with stable classnames for overrides.
|
|
13
14
|
|
|
14
|
-
> **Upgrading from v6?** v7 requires the new `adapters` prop. See [Upgrading from v6](#upgrading-from-v6).
|
|
15
|
+
> **Upgrading from v6?** v7 is configured once with `<ApeBondSDK />` and requires the new `adapters` prop. See [Upgrading from v6](#upgrading-from-v6).
|
|
15
16
|
|
|
16
17
|
---
|
|
17
18
|
|
|
18
19
|
## How it works: chain adapters
|
|
19
20
|
|
|
20
|
-
Since v7, every chain family is an **adapter** that you import and pass to the
|
|
21
|
+
Since v7, every chain family is an **adapter** that you import and pass to [`<ApeBondSDK />`](#configure-the-sdk):
|
|
21
22
|
|
|
22
23
|
| Adapter | Import | Chains |
|
|
23
24
|
|---|---|---|
|
|
@@ -68,6 +69,16 @@ Notes:
|
|
|
68
69
|
|
|
69
70
|
## Basic Usage
|
|
70
71
|
|
|
72
|
+
Configure the SDK once with `<ApeBondSDK />`, then render the views wherever you need them.
|
|
73
|
+
|
|
74
|
+
### Configure the SDK
|
|
75
|
+
|
|
76
|
+
`<ApeBondSDK />` (`@ape.swap/bonds-sdk/components/ApeBondSDK`) takes your whole config (see [Configuration](#configuration)): `referenceId`, `chains`, `adapters`, wallet openers, custom RPCs… Mount it **once**, inside your providers (`QueryClientProvider` and the wallet providers of your adapters). The views and hooks read the config from it, so they take no config props.
|
|
77
|
+
|
|
78
|
+
It also keeps the SDK connected to your wallets app-wide: the views and the SDK hooks (e.g. `useUserTokensBalance` on your own pages) always see the connected accounts, including connects, disconnects and wallet switches. It renders nothing.
|
|
79
|
+
|
|
80
|
+
A view rendered without `<ApeBondSDK />` shows no bonds and logs a console error.
|
|
81
|
+
|
|
71
82
|
### EVM only
|
|
72
83
|
|
|
73
84
|
```tsx
|
|
@@ -76,6 +87,7 @@ import { QueryClient, QueryClientProvider } from '@tanstack/react-query'
|
|
|
76
87
|
import { WagmiProvider, createConfig, http } from 'wagmi'
|
|
77
88
|
import { bsc, mainnet } from 'wagmi/chains'
|
|
78
89
|
import { ChainId } from '@ape.swap/apeswap-lists'
|
|
90
|
+
import ApeBondSDK from '@ape.swap/bonds-sdk/components/ApeBondSDK'
|
|
79
91
|
import FullBondsView from '@ape.swap/bonds-sdk/views/FullBondsView'
|
|
80
92
|
import { evmAdapter } from '@ape.swap/bonds-sdk/adapters/evm'
|
|
81
93
|
import '@ape.swap/bonds-sdk/styles.css'
|
|
@@ -89,43 +101,53 @@ const queryClient = new QueryClient()
|
|
|
89
101
|
export const App = () => (
|
|
90
102
|
<WagmiProvider config={wagmiConfig}>
|
|
91
103
|
<QueryClientProvider client={queryClient}>
|
|
92
|
-
<
|
|
104
|
+
<ApeBondSDK
|
|
93
105
|
referenceId="yourProjectId" // provided by the ApeBond team
|
|
94
106
|
chains={[ChainId.MAINNET, ChainId.BSC]}
|
|
95
107
|
adapters={[evmAdapter]}
|
|
96
108
|
openWalletConnectors={{ evm: openYourWalletModal }} // e.g. RainbowKit's openConnectModal
|
|
97
109
|
/>
|
|
110
|
+
<FullBondsView />
|
|
98
111
|
</QueryClientProvider>
|
|
99
112
|
</WagmiProvider>
|
|
100
113
|
)
|
|
101
114
|
```
|
|
102
115
|
|
|
103
|
-
### Several chain families (EVM + Solana + the LiFi bridge)
|
|
116
|
+
### Several chain families (EVM + Solana + the LiFi bridge), with routes
|
|
104
117
|
|
|
105
118
|
```tsx
|
|
106
119
|
import { ConnectionProvider, WalletProvider } from '@solana/wallet-adapter-react'
|
|
120
|
+
import ApeBondSDK, { type SDKPropsDTO } from '@ape.swap/bonds-sdk/components/ApeBondSDK'
|
|
107
121
|
import FullBondsView from '@ape.swap/bonds-sdk/views/FullBondsView'
|
|
122
|
+
import ProjectView from '@ape.swap/bonds-sdk/views/ProjectView'
|
|
108
123
|
import { evmAdapter } from '@ape.swap/bonds-sdk/adapters/evm'
|
|
109
124
|
import { solanaAdapter } from '@ape.swap/bonds-sdk/adapters/solana'
|
|
110
125
|
import { lifiAdapter } from '@ape.swap/bonds-sdk/adapters/lifi'
|
|
111
126
|
|
|
112
127
|
const SOLANA_RPC = 'https://mainnet.helius-rpc.com/?api-key=YOUR_KEY'
|
|
113
128
|
|
|
129
|
+
const sdkConfig: SDKPropsDTO = {
|
|
130
|
+
referenceId: 'yourProjectId',
|
|
131
|
+
chains: [ChainId.MAINNET, ChainId.BSC, ChainId.SOL],
|
|
132
|
+
adapters: [evmAdapter, solanaAdapter, lifiAdapter],
|
|
133
|
+
customRPCS: { [ChainId.SOL]: [SOLANA_RPC] },
|
|
134
|
+
openWalletConnectors: {
|
|
135
|
+
evm: openYourEvmWalletModal,
|
|
136
|
+
sol: () => setSolanaWalletModalVisible(true), // e.g. useWalletModal() from @solana/wallet-adapter-react-ui
|
|
137
|
+
},
|
|
138
|
+
}
|
|
139
|
+
|
|
114
140
|
export const App = () => (
|
|
115
141
|
<WagmiProvider config={wagmiConfig}>
|
|
116
142
|
<QueryClientProvider client={queryClient}>
|
|
117
143
|
<ConnectionProvider endpoint={SOLANA_RPC}>
|
|
118
144
|
<WalletProvider wallets={[]} autoConnect>
|
|
119
|
-
<
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
evm: openYourEvmWalletModal,
|
|
126
|
-
sol: () => setSolanaWalletModalVisible(true), // e.g. useWalletModal() from @solana/wallet-adapter-react-ui
|
|
127
|
-
}}
|
|
128
|
-
/>
|
|
145
|
+
<ApeBondSDK {...sdkConfig} />
|
|
146
|
+
<Routes>
|
|
147
|
+
<Route path="/bonds" element={<FullBondsView />} />
|
|
148
|
+
<Route path="/bonds/:chain/:address" element={<BondPage />} /> {/* renders <ProjectView /> */}
|
|
149
|
+
<Route path="/staking" element={<StakingPage />} /> {/* uses useUserTokensBalance */}
|
|
150
|
+
</Routes>
|
|
129
151
|
</WalletProvider>
|
|
130
152
|
</ConnectionProvider>
|
|
131
153
|
</QueryClientProvider>
|
|
@@ -142,26 +164,31 @@ import { suiAdapter } from '@ape.swap/bonds-sdk/adapters/sui'
|
|
|
142
164
|
import { aptosAdapter } from '@ape.swap/bonds-sdk/adapters/aptos'
|
|
143
165
|
import { lifiAdapter } from '@ape.swap/bonds-sdk/adapters/lifi'
|
|
144
166
|
|
|
145
|
-
<
|
|
167
|
+
<ApeBondSDK
|
|
146
168
|
referenceId="yourProjectId"
|
|
147
169
|
chains={chains}
|
|
148
170
|
adapters={[evmAdapter, solanaAdapter, suiAdapter, aptosAdapter, lifiAdapter]}
|
|
149
171
|
/>
|
|
150
172
|
```
|
|
151
173
|
|
|
152
|
-
|
|
174
|
+
This needs every family's libraries and wallet providers, like v6 did.
|
|
153
175
|
|
|
154
|
-
|
|
176
|
+
### Views
|
|
177
|
+
|
|
178
|
+
The views only take their own props; everything else comes from `<ApeBondSDK />`.
|
|
155
179
|
|
|
156
180
|
```tsx
|
|
157
|
-
import
|
|
158
|
-
import
|
|
159
|
-
import
|
|
160
|
-
import
|
|
161
|
-
import
|
|
181
|
+
import FullBondsView from '@ape.swap/bonds-sdk/views/FullBondsView' // market + your bonds
|
|
182
|
+
import Bonds from '@ape.swap/bonds-sdk/views/Bonds' // market
|
|
183
|
+
import YourBonds from '@ape.swap/bonds-sdk/views/YourBonds' // the user's bonds
|
|
184
|
+
import SingleBond from '@ape.swap/bonds-sdk/views/SingleBond' // tokenSymbol={['XYZ']}
|
|
185
|
+
import ProjectView from '@ape.swap/bonds-sdk/views/ProjectView' // bondAddress, bondChain
|
|
186
|
+
import BuyBondModal from '@ape.swap/bonds-sdk/views/BuyBondModal' // bondAddress, bondChain, onDismiss
|
|
162
187
|
```
|
|
163
188
|
|
|
164
|
-
Hooks and helpers
|
|
189
|
+
### Hooks and helpers
|
|
190
|
+
|
|
191
|
+
`@ape.swap/bonds-sdk/hooks/useBondsData`, `/hooks/useTokenPrices`, `/hooks/useCurrencyBalance`, `/hooks/useUserTokensBalance`, `/hooks/useApproval` (EVM; needs the EVM libraries), `/components/TokenImage`, `/utils/generateImageFromTemplate`, `/constants/chains`. The hooks need `<ApeBondSDK />` mounted, like the views.
|
|
165
192
|
|
|
166
193
|
The root import (`import { Bonds } from '@ape.swap/bonds-sdk'`) still works but is deprecated. It re-exports `useApproval`, so it requires the EVM libraries: apps without EVM must use the subpath imports above.
|
|
167
194
|
|
|
@@ -186,7 +213,7 @@ Without an opener, that family's "Connect" button is disabled.
|
|
|
186
213
|
|
|
187
214
|
## Configuration
|
|
188
215
|
|
|
189
|
-
Props
|
|
216
|
+
Props of [`<ApeBondSDK />`](#configure-the-sdk) (type `SDKPropsDTO`, exported by the same module):
|
|
190
217
|
|
|
191
218
|
| Property | Type | Description |
|
|
192
219
|
|---|---|---|
|
|
@@ -203,7 +230,7 @@ Props accepted by every view:
|
|
|
203
230
|
| `bondPartner` | `string` | Filters the bonds to show to those of a certain bondPartner. |
|
|
204
231
|
| `highlightedBond` | `string` | Token symbol to feature in the "buy again" highlighted row. |
|
|
205
232
|
|
|
206
|
-
|
|
233
|
+
View props: `tokenSymbol` (`string[]`, `<SingleBond />`; one token is supported), `bondAddress` + `bondChain` (`<ProjectView />`, `<BuyBondModal />`), `onDismiss` (`<BuyBondModal />`).
|
|
207
234
|
|
|
208
235
|
The `theme` prop was removed in v7; see [Styling & Overrides](#styling--overrides).
|
|
209
236
|
|
|
@@ -216,7 +243,7 @@ By default the SDK uses public RPC endpoints for each supported chain. If you ha
|
|
|
216
243
|
```tsx
|
|
217
244
|
import { ChainId } from '@ape.swap/apeswap-lists'
|
|
218
245
|
|
|
219
|
-
<
|
|
246
|
+
<ApeBondSDK
|
|
220
247
|
referenceId="yourProjectId"
|
|
221
248
|
chains={[ChainId.BSC, ChainId.MAINNET, ChainId.SOL]}
|
|
222
249
|
adapters={[evmAdapter, solanaAdapter]}
|
|
@@ -243,11 +270,12 @@ The list is updated regularly, so make sure to use the latest version of the SDK
|
|
|
243
270
|
|
|
244
271
|
## Upgrading from v6
|
|
245
272
|
|
|
246
|
-
1. **
|
|
247
|
-
2. **
|
|
248
|
-
3. **
|
|
249
|
-
4. **
|
|
250
|
-
5.
|
|
273
|
+
1. **Configure the SDK with [`<ApeBondSDK />`](#configure-the-sdk)**, mounted once inside your providers, and move the config props you passed to the views there; the views now only take their own props (`bondAddress`, `tokenSymbol`…). The `useSDKConfig` hook export is removed.
|
|
274
|
+
2. **Pass `adapters`** to it with the families you show, e.g. `adapters={[evmAdapter]}` for an EVM-only app, or every adapter for the v6 behaviour (see [Every chain family](#every-chain-family-the-v6-setup)). Without it no chains are shown (the console says so).
|
|
275
|
+
3. **Install what your adapters need** (see [Installation](#installation)). Chain libraries are now optional peer dependencies, so npm no longer installs them automatically. If you register every adapter, keep everything you had in v6; otherwise you can remove the libraries of the families you don't use (e.g. an EVM-only app can remove `@solana/*`, `@mysten/*`, `@aptos-labs/*`, `@lifi/widget`, `@bigmi/react`).
|
|
276
|
+
4. **Mount only the wallet providers of your adapters.** An app without `evmAdapter` no longer needs a `WagmiProvider`.
|
|
277
|
+
5. **Import styles from `@ape.swap/bonds-sdk/styles.css`**, and drop the `theme` prop if you used it (see [Styling & Overrides](#styling--overrides)).
|
|
278
|
+
6. If you use the root import (`from '@ape.swap/bonds-sdk'`) in an app without EVM, switch to the subpath imports.
|
|
251
279
|
|
|
252
280
|
---
|
|
253
281
|
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { SDKPropsDTO } from '../../state/useSDKConfig';
|
|
2
|
+
export type { SDKPropsDTO, OpenWalletConnectorsDTO } from '../../state/useSDKConfig';
|
|
3
|
+
/**
|
|
4
|
+
* Configures the SDK for the whole app; the views and hooks need it. Mount it once inside your providers
|
|
5
|
+
* (QueryClient, wagmi, wallet providers).
|
|
6
|
+
*
|
|
7
|
+
* Besides setting the config, it keeps every registered adapter's `AccountBridge` mounted, so the views and the SDK
|
|
8
|
+
* hooks (e.g. `useUserTokensBalance`) always see the connected wallets.
|
|
9
|
+
*
|
|
10
|
+
* Renders nothing and holds no React context: the config and accounts live in the query cache.
|
|
11
|
+
*/
|
|
12
|
+
declare const ApeBondSDK: (props: SDKPropsDTO) => import("react/jsx-runtime").JSX.Element;
|
|
13
|
+
export default ApeBondSDK;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { jsx, Fragment } from 'react/jsx-runtime';
|
|
2
|
+
import { useConfigureSDK } from '../../state/useSDKConfig.js';
|
|
3
|
+
import { getRegisteredAdapters } from '../../adapters/registry.js';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* Configures the SDK for the whole app; the views and hooks need it. Mount it once inside your providers
|
|
7
|
+
* (QueryClient, wagmi, wallet providers).
|
|
8
|
+
*
|
|
9
|
+
* Besides setting the config, it keeps every registered adapter's `AccountBridge` mounted, so the views and the SDK
|
|
10
|
+
* hooks (e.g. `useUserTokensBalance`) always see the connected wallets.
|
|
11
|
+
*
|
|
12
|
+
* Renders nothing and holds no React context: the config and accounts live in the query cache.
|
|
13
|
+
*/
|
|
14
|
+
const ApeBondSDK = (props) => {
|
|
15
|
+
useConfigureSDK(props);
|
|
16
|
+
return (jsx(Fragment, { children: getRegisteredAdapters().map((adapter) => (jsx(adapter.AccountBridge, {}, adapter.ecosystem))) }));
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export { ApeBondSDK as default };
|
|
20
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/components/ApeBondSDK/index.tsx"],"sourcesContent":["import React from 'react'\nimport { SDKPropsDTO, useConfigureSDK } from '../../state/useSDKConfig'\nimport { getRegisteredAdapters } from '../../adapters/registry'\n\nexport type { SDKPropsDTO, OpenWalletConnectorsDTO } from '../../state/useSDKConfig'\n\n/**\n * Configures the SDK for the whole app; the views and hooks need it. Mount it once inside your providers\n * (QueryClient, wagmi, wallet providers).\n *\n * Besides setting the config, it keeps every registered adapter's `AccountBridge` mounted, so the views and the SDK\n * hooks (e.g. `useUserTokensBalance`) always see the connected wallets.\n *\n * Renders nothing and holds no React context: the config and accounts live in the query cache.\n */\nconst ApeBondSDK = (props: SDKPropsDTO) => {\n useConfigureSDK(props)\n return (\n <>\n {getRegisteredAdapters().map((adapter) => (\n <adapter.AccountBridge key={adapter.ecosystem} />\n ))}\n </>\n )\n}\n\nexport default ApeBondSDK\n"],"names":["_jsx","_Fragment"],"mappings":";;;;AAMA;;;;;;;;AAQG;AACH,MAAM,UAAU,GAAG,CAAC,KAAkB,KAAI;IACxC,eAAe,CAAC,KAAK,CAAC;IACtB,QACEA,GAAA,CAAAC,QAAA,EAAA,EAAA,QAAA,EACG,qBAAqB,EAAE,CAAC,GAAG,CAAC,CAAC,OAAO,MACnCD,IAAC,OAAO,CAAC,aAAa,EAAA,EAAA,EAAM,OAAO,CAAC,SAAS,CAAI,CAClD,CAAC,EAAA,CACD;AAEP;;;;"}
|
package/dist/main.d.ts
CHANGED
|
@@ -30,11 +30,11 @@ import { generateImageFromTemplate } from './views/YourBondsModal/components/Lin
|
|
|
30
30
|
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
31
31
|
import SingleBond from './views/SingleBond';
|
|
32
32
|
import useTokenPrices from './state/tokenPrices/useTokenPrices';
|
|
33
|
-
import { useSDKConfig } from './state/useSDKConfig';
|
|
34
33
|
import { BLOCK_EXPLORER } from './config/constants/chains';
|
|
35
34
|
import useCurrencyBalance from './state/balance/useCurrencyBalance';
|
|
36
35
|
import useUserTokensBalance from './state/balance/useUserTokensBalance';
|
|
37
36
|
import TokenImage from './components/uikit-sdk/TokenImage';
|
|
37
|
+
import ApeBondSDK from './components/ApeBondSDK';
|
|
38
38
|
import { useApproval } from './adapters/evm/state/useAllowance';
|
|
39
39
|
import useBondsData from './state/bonds/useBondsData';
|
|
40
40
|
/** @deprecated Use granular import: `import Bonds from '@ape.swap/bonds-sdk/views/Bonds'` */
|
|
@@ -57,8 +57,6 @@ declare const _SingleBond: typeof SingleBond;
|
|
|
57
57
|
declare const _useTokenPrices: typeof useTokenPrices;
|
|
58
58
|
/** @deprecated Use granular import: `import useBondsData from '@ape.swap/bonds-sdk/hooks/useBondsData'` */
|
|
59
59
|
declare const _useBondsData: typeof useBondsData;
|
|
60
|
-
/** @deprecated Use granular import: `import { useSDKConfig } from '@ape.swap/bonds-sdk/hooks/useSDKConfig'` */
|
|
61
|
-
declare const _useSDKConfig: typeof useSDKConfig;
|
|
62
60
|
/** @deprecated Use granular import: `import { BLOCK_EXPLORER } from '@ape.swap/bonds-sdk/constants/chains'` */
|
|
63
61
|
declare const _BLOCK_EXPLORER: typeof BLOCK_EXPLORER;
|
|
64
62
|
/** @deprecated Use granular import: `import useCurrencyBalance from '@ape.swap/bonds-sdk/hooks/useCurrencyBalance'` */
|
|
@@ -69,4 +67,6 @@ declare const _useUserTokensBalance: typeof useUserTokensBalance;
|
|
|
69
67
|
declare const _TokenImage: typeof TokenImage;
|
|
70
68
|
/** @deprecated Use granular import: `import { useApproval } from '@ape.swap/bonds-sdk/hooks/useApproval'` */
|
|
71
69
|
declare const _useApproval: typeof useApproval;
|
|
72
|
-
|
|
70
|
+
/** @deprecated Use granular import: `import ApeBondSDK from '@ape.swap/bonds-sdk/components/ApeBondSDK'` */
|
|
71
|
+
declare const _ApeBondSDK: typeof ApeBondSDK;
|
|
72
|
+
export { _Bonds as Bonds, _BuyBondModal as BuyBondModal, _YourBonds as YourBonds, _FullBondsView as FullBondsView, _ProjectView as ProjectView, _generateImageFromTemplate as generateImageFromTemplate, _ChainId as ChainId, _SingleBond as SingleBond, _useTokenPrices as useTokenPrices, _useBondsData as useBondsData, _BLOCK_EXPLORER as BLOCK_EXPLORER, _useCurrencyBalance as useCurrencyBalance, _useUserTokensBalance as useUserTokensBalance, _TokenImage as TokenImage, _useApproval as useApproval, _ApeBondSDK as ApeBondSDK, };
|
package/dist/main.js
CHANGED
|
@@ -7,11 +7,11 @@ import { generateImageFromTemplate } from './views/YourBondsModal/components/Lin
|
|
|
7
7
|
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
8
8
|
import SingleBondWithProviders from './views/SingleBond/index.js';
|
|
9
9
|
import useTokenPrices from './state/tokenPrices/useTokenPrices.js';
|
|
10
|
-
import { useSDKConfig } from './state/useSDKConfig.js';
|
|
11
10
|
import { BLOCK_EXPLORER } from './config/constants/chains.js';
|
|
12
11
|
import useCurrencyBalance from './state/balance/useCurrencyBalance.js';
|
|
13
12
|
import useUserTokensBalance from './state/balance/useUserTokensBalance.js';
|
|
14
13
|
import TokenImage from './components/uikit-sdk/TokenImage/index.js';
|
|
14
|
+
import ApeBondSDK from './components/ApeBondSDK/index.js';
|
|
15
15
|
import { useApproval } from './adapters/evm/state/useAllowance.js';
|
|
16
16
|
import useBondsData from './state/bonds/useBondsData.js';
|
|
17
17
|
|
|
@@ -59,8 +59,6 @@ const _SingleBond = SingleBondWithProviders;
|
|
|
59
59
|
const _useTokenPrices = useTokenPrices;
|
|
60
60
|
/** @deprecated Use granular import: `import useBondsData from '@ape.swap/bonds-sdk/hooks/useBondsData'` */
|
|
61
61
|
const _useBondsData = useBondsData;
|
|
62
|
-
/** @deprecated Use granular import: `import { useSDKConfig } from '@ape.swap/bonds-sdk/hooks/useSDKConfig'` */
|
|
63
|
-
const _useSDKConfig = useSDKConfig;
|
|
64
62
|
/** @deprecated Use granular import: `import { BLOCK_EXPLORER } from '@ape.swap/bonds-sdk/constants/chains'` */
|
|
65
63
|
const _BLOCK_EXPLORER = BLOCK_EXPLORER;
|
|
66
64
|
/** @deprecated Use granular import: `import useCurrencyBalance from '@ape.swap/bonds-sdk/hooks/useCurrencyBalance'` */
|
|
@@ -71,6 +69,8 @@ const _useUserTokensBalance = useUserTokensBalance;
|
|
|
71
69
|
const _TokenImage = TokenImage;
|
|
72
70
|
/** @deprecated Use granular import: `import { useApproval } from '@ape.swap/bonds-sdk/hooks/useApproval'` */
|
|
73
71
|
const _useApproval = useApproval;
|
|
72
|
+
/** @deprecated Use granular import: `import ApeBondSDK from '@ape.swap/bonds-sdk/components/ApeBondSDK'` */
|
|
73
|
+
const _ApeBondSDK = ApeBondSDK;
|
|
74
74
|
|
|
75
|
-
export { _BLOCK_EXPLORER as BLOCK_EXPLORER, _Bonds as Bonds, _BuyBondModal as BuyBondModal, _ChainId as ChainId, _FullBondsView as FullBondsView, _ProjectView as ProjectView, _SingleBond as SingleBond, _TokenImage as TokenImage, _YourBonds as YourBonds, _generateImageFromTemplate as generateImageFromTemplate, _useApproval as useApproval, _useBondsData as useBondsData, _useCurrencyBalance as useCurrencyBalance,
|
|
75
|
+
export { _ApeBondSDK as ApeBondSDK, _BLOCK_EXPLORER as BLOCK_EXPLORER, _Bonds as Bonds, _BuyBondModal as BuyBondModal, _ChainId as ChainId, _FullBondsView as FullBondsView, _ProjectView as ProjectView, _SingleBond as SingleBond, _TokenImage as TokenImage, _YourBonds as YourBonds, _generateImageFromTemplate as generateImageFromTemplate, _useApproval as useApproval, _useBondsData as useBondsData, _useCurrencyBalance as useCurrencyBalance, _useTokenPrices as useTokenPrices, _useUserTokensBalance as useUserTokensBalance };
|
|
76
76
|
//# sourceMappingURL=main.js.map
|
package/dist/main.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"main.js","sources":["../src/main.ts"],"sourcesContent":["/**\n * @ape.swap/bonds-sdk - Main Entry Point\n *\n * This barrel export provides backward compatibility.\n * For optimal bundle size, use granular imports:\n *\n * @example Tree-shakeable imports (RECOMMENDED for bundle optimization)\n * ```typescript\n * // Import only what you need - reduces bundle by ~90%\n * import Bonds from '@ape.swap/bonds-sdk/views/Bonds'\n * import TokenImage from '@ape.swap/bonds-sdk/components/TokenImage'\n * import { useTokenPrices } from '@ape.swap/bonds-sdk/hooks/useTokenPrices'\n * ```\n *\n * @example Barrel imports (backward compatible, larger bundle)\n * ```typescript\n * // Works but includes more code in bundle\n * import { Bonds, TokenImage, useTokenPrices } from '@ape.swap/bonds-sdk'\n * ```\n *\n * @see https://vercel.com/docs/concepts/functions/edge-functions/best-practices\n * Rule: bundle-barrel-imports - Avoid barrel imports for optimal tree-shaking\n */\n\n// Components\nimport Bonds from './views/Bonds'\nimport YourBonds from './views/YourBonds'\nimport BuyBondModal from './views/BuyBond'\nimport FullBondsView from './views/FullBondsView'\nimport ProjectView from './views/ProjectView'\nimport { generateImageFromTemplate } from './views/YourBondsModal/components/LinkShare/utils'\nimport { ChainId } from '@ape.swap/apeswap-lists'\nimport SingleBond from './views/SingleBond'\nimport useTokenPrices from './state/tokenPrices/useTokenPrices'\nimport {
|
|
1
|
+
{"version":3,"file":"main.js","sources":["../src/main.ts"],"sourcesContent":["/**\n * @ape.swap/bonds-sdk - Main Entry Point\n *\n * This barrel export provides backward compatibility.\n * For optimal bundle size, use granular imports:\n *\n * @example Tree-shakeable imports (RECOMMENDED for bundle optimization)\n * ```typescript\n * // Import only what you need - reduces bundle by ~90%\n * import Bonds from '@ape.swap/bonds-sdk/views/Bonds'\n * import TokenImage from '@ape.swap/bonds-sdk/components/TokenImage'\n * import { useTokenPrices } from '@ape.swap/bonds-sdk/hooks/useTokenPrices'\n * ```\n *\n * @example Barrel imports (backward compatible, larger bundle)\n * ```typescript\n * // Works but includes more code in bundle\n * import { Bonds, TokenImage, useTokenPrices } from '@ape.swap/bonds-sdk'\n * ```\n *\n * @see https://vercel.com/docs/concepts/functions/edge-functions/best-practices\n * Rule: bundle-barrel-imports - Avoid barrel imports for optimal tree-shaking\n */\n\n// Components\nimport Bonds from './views/Bonds'\nimport YourBonds from './views/YourBonds'\nimport BuyBondModal from './views/BuyBond'\nimport FullBondsView from './views/FullBondsView'\nimport ProjectView from './views/ProjectView'\nimport { generateImageFromTemplate } from './views/YourBondsModal/components/LinkShare/utils'\nimport { ChainId } from '@ape.swap/apeswap-lists'\nimport SingleBond from './views/SingleBond'\nimport useTokenPrices from './state/tokenPrices/useTokenPrices'\nimport { BLOCK_EXPLORER } from './config/constants/chains'\nimport useCurrencyBalance from './state/balance/useCurrencyBalance'\nimport useUserTokensBalance from './state/balance/useUserTokensBalance'\nimport TokenImage from './components/uikit-sdk/TokenImage'\nimport ApeBondSDK from './components/ApeBondSDK'\n// The legacy barrel keeps re-exporting useApproval, so it requires the EVM peers (wagmi, viem); partners without EVM\n// use the subpath imports instead. See docs/PLAN_CHAIN_ADAPTERS.md, section 3.7.\n// eslint-disable-next-line no-restricted-imports\nimport { useApproval } from './adapters/evm/state/useAllowance'\nimport useBondsData from './state/bonds/useBondsData'\n\n/** @deprecated Use granular import: `import Bonds from '@ape.swap/bonds-sdk/views/Bonds'` */\nconst _Bonds: typeof Bonds = Bonds\n/** @deprecated Use granular import: `import BuyBondModal from '@ape.swap/bonds-sdk/views/BuyBondModal'` */\nconst _BuyBondModal: typeof BuyBondModal = BuyBondModal\n/** @deprecated Use granular import: `import YourBonds from '@ape.swap/bonds-sdk/views/YourBonds'` */\nconst _YourBonds: typeof YourBonds = YourBonds\n/** @deprecated Use granular import: `import FullBondsView from '@ape.swap/bonds-sdk/views/FullBondsView'` */\nconst _FullBondsView: typeof FullBondsView = FullBondsView\n/** @deprecated Use granular import: `import ProjectView from '@ape.swap/bonds-sdk/views/ProjectView'` */\nconst _ProjectView: typeof ProjectView = ProjectView\n/** @deprecated Use granular import: `import { generateImageFromTemplate } from '@ape.swap/bonds-sdk/utils/generateImageFromTemplate'` */\nconst _generateImageFromTemplate: typeof generateImageFromTemplate = generateImageFromTemplate\n/** @deprecated Use granular import: `import { ChainId } from '@ape.swap/apeswap-lists'` */\nconst _ChainId: typeof ChainId = ChainId\n/** @deprecated Use granular import: `import SingleBond from '@ape.swap/bonds-sdk/views/SingleBond'` */\nconst _SingleBond: typeof SingleBond = SingleBond\n/** @deprecated Use granular import: `import useTokenPrices from '@ape.swap/bonds-sdk/hooks/useTokenPrices'` */\nconst _useTokenPrices: typeof useTokenPrices = useTokenPrices\n/** @deprecated Use granular import: `import useBondsData from '@ape.swap/bonds-sdk/hooks/useBondsData'` */\nconst _useBondsData: typeof useBondsData = useBondsData\n/** @deprecated Use granular import: `import { BLOCK_EXPLORER } from '@ape.swap/bonds-sdk/constants/chains'` */\nconst _BLOCK_EXPLORER: typeof BLOCK_EXPLORER = BLOCK_EXPLORER\n/** @deprecated Use granular import: `import useCurrencyBalance from '@ape.swap/bonds-sdk/hooks/useCurrencyBalance'` */\nconst _useCurrencyBalance: typeof useCurrencyBalance = useCurrencyBalance\n/** @deprecated Use granular import: `import useUserTokensBalance from '@ape.swap/bonds-sdk/hooks/useUserTokensBalance'` */\nconst _useUserTokensBalance: typeof useUserTokensBalance = useUserTokensBalance\n/** @deprecated Use granular import: `import TokenImage from '@ape.swap/bonds-sdk/components/TokenImage'` */\nconst _TokenImage: typeof TokenImage = TokenImage\n/** @deprecated Use granular import: `import { useApproval } from '@ape.swap/bonds-sdk/hooks/useApproval'` */\nconst _useApproval: typeof useApproval = useApproval\n/** @deprecated Use granular import: `import ApeBondSDK from '@ape.swap/bonds-sdk/components/ApeBondSDK'` */\nconst _ApeBondSDK: typeof ApeBondSDK = ApeBondSDK\n\nexport {\n _Bonds as Bonds,\n _BuyBondModal as BuyBondModal,\n _YourBonds as YourBonds,\n _FullBondsView as FullBondsView,\n _ProjectView as ProjectView,\n _generateImageFromTemplate as generateImageFromTemplate,\n _ChainId as ChainId,\n _SingleBond as SingleBond,\n _useTokenPrices as useTokenPrices,\n _useBondsData as useBondsData,\n _BLOCK_EXPLORER as BLOCK_EXPLORER,\n _useCurrencyBalance as useCurrencyBalance,\n _useUserTokensBalance as useUserTokensBalance,\n _TokenImage as TokenImage,\n _useApproval as useApproval,\n _ApeBondSDK as ApeBondSDK,\n}\n"],"names":["Bonds","BuyBondModal","YourBonds","FullBondsView","ProjectView","SingleBond"],"mappings":";;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;;;;AAsBG;AAEH;AAqBA;AACA,MAAM,MAAM,GAAiBA;AAC7B;AACA,MAAM,aAAa,GAAwBC;AAC3C;AACA,MAAM,UAAU,GAAqBC;AACrC;AACA,MAAM,cAAc,GAAyBC;AAC7C;AACA,MAAM,YAAY,GAAuBC;AACzC;AACA,MAAM,0BAA0B,GAAqC;AACrE;AACA,MAAM,QAAQ,GAAmB;AACjC;AACA,MAAM,WAAW,GAAsBC;AACvC;AACA,MAAM,eAAe,GAA0B;AAC/C;AACA,MAAM,aAAa,GAAwB;AAC3C;AACA,MAAM,eAAe,GAA0B;AAC/C;AACA,MAAM,mBAAmB,GAA8B;AACvD;AACA,MAAM,qBAAqB,GAAgC;AAC3D;AACA,MAAM,WAAW,GAAsB;AACvC;AACA,MAAM,YAAY,GAAuB;AACzC;AACA,MAAM,WAAW,GAAsB;;;;"}
|
|
@@ -9,6 +9,9 @@ import React from 'react';
|
|
|
9
9
|
* The components exported from the src/main.ts file are all wrapped with this Provider component. Though the FullBondsView
|
|
10
10
|
* component that imports the Bonds and YourBonds views, does NOT import the Bonds and YourBonds with providers, it imports
|
|
11
11
|
* the component directly without providers. This is important to understand.
|
|
12
|
+
*
|
|
13
|
+
* The config and the adapters' AccountBridges come from <ApeBondSDK /> (components/ApeBondSDK), which consumers mount
|
|
14
|
+
* once at the app root; the views don't mount bridges themselves.
|
|
12
15
|
*/
|
|
13
16
|
declare const Providers: ({ children }: {
|
|
14
17
|
children: React.ReactNode;
|
package/dist/providers/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import ModalProvider from '../contexts/ModalContext.js';
|
|
3
3
|
import Popups from '../contexts/Popups.js';
|
|
4
|
-
import {
|
|
4
|
+
import { useWarnIfNotConfigured } from '../state/useSDKConfig.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* This is the list of local providers that will be used internally by the SDK
|
|
@@ -13,9 +13,13 @@ import { getRegisteredAdapters } from '../adapters/registry.js';
|
|
|
13
13
|
* The components exported from the src/main.ts file are all wrapped with this Provider component. Though the FullBondsView
|
|
14
14
|
* component that imports the Bonds and YourBonds views, does NOT import the Bonds and YourBonds with providers, it imports
|
|
15
15
|
* the component directly without providers. This is important to understand.
|
|
16
|
+
*
|
|
17
|
+
* The config and the adapters' AccountBridges come from <ApeBondSDK /> (components/ApeBondSDK), which consumers mount
|
|
18
|
+
* once at the app root; the views don't mount bridges themselves.
|
|
16
19
|
*/
|
|
17
20
|
const Providers = ({ children }) => {
|
|
18
|
-
|
|
21
|
+
useWarnIfNotConfigured();
|
|
22
|
+
return (jsx("div", { className: "ape-root", children: jsx(ModalProvider, { children: jsx(Popups, { children: children }) }) }));
|
|
19
23
|
};
|
|
20
24
|
|
|
21
25
|
export { Providers as default };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../src/providers/index.tsx"],"sourcesContent":["import React from 'react'\nimport ModalProvider from '../contexts/ModalContext'\nimport Popups from '../contexts/Popups'\nimport {
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../src/providers/index.tsx"],"sourcesContent":["import React from 'react'\nimport ModalProvider from '../contexts/ModalContext'\nimport Popups from '../contexts/Popups'\nimport { useWarnIfNotConfigured } from '../state/useSDKConfig'\n\n/**\n * This is the list of local providers that will be used internally by the SDK\n *\n * It is important to understand the difference between this component and the one located on the dev directory,\n * which aims to simulate the providers required to be installed by the consumer of the SDK.\n *\n * Finally, it is important to note that this Providers component should NOT be used multiple times, so for instance:\n * The components exported from the src/main.ts file are all wrapped with this Provider component. Though the FullBondsView\n * component that imports the Bonds and YourBonds views, does NOT import the Bonds and YourBonds with providers, it imports\n * the component directly without providers. This is important to understand.\n *\n * The config and the adapters' AccountBridges come from <ApeBondSDK /> (components/ApeBondSDK), which consumers mount\n * once at the app root; the views don't mount bridges themselves.\n */\n\nconst Providers = ({ children }: { children: React.ReactNode }) => {\n useWarnIfNotConfigured()\n return (\n <div className=\"ape-root\">\n <ModalProvider>\n <Popups>{children}</Popups>\n </ModalProvider>\n </div>\n )\n}\n\nexport default Providers\n"],"names":["_jsx"],"mappings":";;;;;AAKA;;;;;;;;;;;;;AAaG;AAEH,MAAM,SAAS,GAAG,CAAC,EAAE,QAAQ,EAAiC,KAAI;AAChE,IAAA,sBAAsB,EAAE;AACxB,IAAA,QACEA,GAAA,CAAA,KAAA,EAAA,EAAK,SAAS,EAAC,UAAU,YACvBA,GAAA,CAAC,aAAa,EAAA,EAAA,QAAA,EACZA,GAAA,CAAC,MAAM,EAAA,EAAA,QAAA,EAAE,QAAQ,GAAU,EAAA,CACb,EAAA,CACZ;AAEV;;;;"}
|
|
@@ -9,5 +9,9 @@ export interface ChainAccount {
|
|
|
9
9
|
* disconnected account when the family's adapter isn't registered. Chain-agnostic: safe to call from core code.
|
|
10
10
|
*/
|
|
11
11
|
export default function useChainAccount(ecosystem: Ecosystem): ChainAccount;
|
|
12
|
-
/**
|
|
12
|
+
/**
|
|
13
|
+
* For adapter `AccountBridge`s: keeps the family's account in the query cache in sync with its wallet library. When
|
|
14
|
+
* the family's last bridge unmounts, the account is reset to disconnected: nothing would keep it in sync anymore, so
|
|
15
|
+
* keeping the last address would show stale (or another wallet's) data after a disconnect or wallet switch.
|
|
16
|
+
*/
|
|
13
17
|
export declare const usePublishChainAccount: (ecosystem: Ecosystem, { address, connected, chainId }: ChainAccount) => void;
|
|
@@ -18,12 +18,30 @@ function useChainAccount(ecosystem) {
|
|
|
18
18
|
});
|
|
19
19
|
return data;
|
|
20
20
|
}
|
|
21
|
-
|
|
21
|
+
// Mounted AccountBridges per family. <ApeBondSDK /> normally mounts one per family, but more can be mounted at once
|
|
22
|
+
// (e.g. two <ApeBondSDK /> while one unmounts); they read the same wallet, so they publish the same account.
|
|
23
|
+
const mountedBridges = new WeakMap();
|
|
24
|
+
/**
|
|
25
|
+
* For adapter `AccountBridge`s: keeps the family's account in the query cache in sync with its wallet library. When
|
|
26
|
+
* the family's last bridge unmounts, the account is reset to disconnected: nothing would keep it in sync anymore, so
|
|
27
|
+
* keeping the last address would show stale (or another wallet's) data after a disconnect or wallet switch.
|
|
28
|
+
*/
|
|
22
29
|
const usePublishChainAccount = (ecosystem, { address, connected, chainId }) => {
|
|
23
30
|
const queryClient = useQueryClient();
|
|
24
31
|
useEffect(() => {
|
|
25
32
|
queryClient.setQueryData(chainAccountQueryKey(ecosystem), { address, connected, chainId });
|
|
26
33
|
}, [queryClient, ecosystem, address, connected, chainId]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const counts = mountedBridges.get(queryClient) ?? new Map();
|
|
36
|
+
mountedBridges.set(queryClient, counts);
|
|
37
|
+
counts.set(ecosystem, (counts.get(ecosystem) ?? 0) + 1);
|
|
38
|
+
return () => {
|
|
39
|
+
const left = (counts.get(ecosystem) ?? 1) - 1;
|
|
40
|
+
counts.set(ecosystem, left);
|
|
41
|
+
if (left === 0)
|
|
42
|
+
queryClient.setQueryData(chainAccountQueryKey(ecosystem), DISCONNECTED);
|
|
43
|
+
};
|
|
44
|
+
}, [queryClient, ecosystem]);
|
|
27
45
|
};
|
|
28
46
|
|
|
29
47
|
export { useChainAccount as default, usePublishChainAccount };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useChainAccount.js","sources":["../../../src/state/chainAccount/useChainAccount.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../../config/constants/queryKeys'\nimport type { Ecosystem } from '../../adapters/types'\n\nexport interface ChainAccount {\n address: string | null\n connected: boolean\n chainId?: number\n}\n\nconst DISCONNECTED: ChainAccount = { address: null, connected: false }\n\nconst chainAccountQueryKey = (ecosystem: Ecosystem) => [QUERY_KEYS.CHAIN_ACCOUNT, ecosystem]\n\n/**\n * The connected account of a chain family, as published by that family's adapter `AccountBridge`. Returns a\n * disconnected account when the family's adapter isn't registered. Chain-agnostic: safe to call from core code.\n */\nexport default function useChainAccount(ecosystem: Ecosystem): ChainAccount {\n const { data } = useQuery({\n queryKey: chainAccountQueryKey(ecosystem),\n // Written by usePublishChainAccount; the query is only used as a store.\n queryFn: ({ client }) => client.getQueryData<ChainAccount>(chainAccountQueryKey(ecosystem)) ?? DISCONNECTED,\n initialData: DISCONNECTED,\n staleTime: Infinity,\n })\n return data\n}\n\n
|
|
1
|
+
{"version":3,"file":"useChainAccount.js","sources":["../../../src/state/chainAccount/useChainAccount.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { QueryClient, useQuery, useQueryClient } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../../config/constants/queryKeys'\nimport type { Ecosystem } from '../../adapters/types'\n\nexport interface ChainAccount {\n address: string | null\n connected: boolean\n chainId?: number\n}\n\nconst DISCONNECTED: ChainAccount = { address: null, connected: false }\n\nconst chainAccountQueryKey = (ecosystem: Ecosystem) => [QUERY_KEYS.CHAIN_ACCOUNT, ecosystem]\n\n/**\n * The connected account of a chain family, as published by that family's adapter `AccountBridge`. Returns a\n * disconnected account when the family's adapter isn't registered. Chain-agnostic: safe to call from core code.\n */\nexport default function useChainAccount(ecosystem: Ecosystem): ChainAccount {\n const { data } = useQuery({\n queryKey: chainAccountQueryKey(ecosystem),\n // Written by usePublishChainAccount; the query is only used as a store.\n queryFn: ({ client }) => client.getQueryData<ChainAccount>(chainAccountQueryKey(ecosystem)) ?? DISCONNECTED,\n initialData: DISCONNECTED,\n staleTime: Infinity,\n })\n return data\n}\n\n// Mounted AccountBridges per family. <ApeBondSDK /> normally mounts one per family, but more can be mounted at once\n// (e.g. two <ApeBondSDK /> while one unmounts); they read the same wallet, so they publish the same account.\nconst mountedBridges = new WeakMap<QueryClient, Map<Ecosystem, number>>()\n\n/**\n * For adapter `AccountBridge`s: keeps the family's account in the query cache in sync with its wallet library. When\n * the family's last bridge unmounts, the account is reset to disconnected: nothing would keep it in sync anymore, so\n * keeping the last address would show stale (or another wallet's) data after a disconnect or wallet switch.\n */\nexport const usePublishChainAccount = (ecosystem: Ecosystem, { address, connected, chainId }: ChainAccount) => {\n const queryClient = useQueryClient()\n\n useEffect(() => {\n queryClient.setQueryData<ChainAccount>(chainAccountQueryKey(ecosystem), { address, connected, chainId })\n }, [queryClient, ecosystem, address, connected, chainId])\n\n useEffect(() => {\n const counts = mountedBridges.get(queryClient) ?? new Map<Ecosystem, number>()\n mountedBridges.set(queryClient, counts)\n counts.set(ecosystem, (counts.get(ecosystem) ?? 0) + 1)\n return () => {\n const left = (counts.get(ecosystem) ?? 1) - 1\n counts.set(ecosystem, left)\n if (left === 0) queryClient.setQueryData<ChainAccount>(chainAccountQueryKey(ecosystem), DISCONNECTED)\n }\n }, [queryClient, ecosystem])\n}\n"],"names":[],"mappings":";;;;AAWA,MAAM,YAAY,GAAiB,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE,KAAK,EAAE;AAEtE,MAAM,oBAAoB,GAAG,CAAC,SAAoB,KAAK,CAAC,UAAU,CAAC,aAAa,EAAE,SAAS,CAAC;AAE5F;;;AAGG;AACW,SAAU,eAAe,CAAC,SAAoB,EAAA;AAC1D,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;AACxB,QAAA,QAAQ,EAAE,oBAAoB,CAAC,SAAS,CAAC;;AAEzC,QAAA,OAAO,EAAE,CAAC,EAAE,MAAM,EAAE,KAAK,MAAM,CAAC,YAAY,CAAe,oBAAoB,CAAC,SAAS,CAAC,CAAC,IAAI,YAAY;AAC3G,QAAA,WAAW,EAAE,YAAY;AACzB,QAAA,SAAS,EAAE,QAAQ;AACpB,KAAA,CAAC;AACF,IAAA,OAAO,IAAI;AACb;AAEA;AACA;AACA,MAAM,cAAc,GAAG,IAAI,OAAO,EAAuC;AAEzE;;;;AAIG;AACI,MAAM,sBAAsB,GAAG,CAAC,SAAoB,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAgB,KAAI;AAC5G,IAAA,MAAM,WAAW,GAAG,cAAc,EAAE;IAEpC,SAAS,CAAC,MAAK;AACb,QAAA,WAAW,CAAC,YAAY,CAAe,oBAAoB,CAAC,SAAS,CAAC,EAAE,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC;AAC1G,IAAA,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,EAAE,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;IAEzD,SAAS,CAAC,MAAK;AACb,QAAA,MAAM,MAAM,GAAG,cAAc,CAAC,GAAG,CAAC,WAAW,CAAC,IAAI,IAAI,GAAG,EAAqB;AAC9E,QAAA,cAAc,CAAC,GAAG,CAAC,WAAW,EAAE,MAAM,CAAC;AACvC,QAAA,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACvD,QAAA,OAAO,MAAK;AACV,YAAA,MAAM,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC;AAC7C,YAAA,MAAM,CAAC,GAAG,CAAC,SAAS,EAAE,IAAI,CAAC;YAC3B,IAAI,IAAI,KAAK,CAAC;gBAAE,WAAW,CAAC,YAAY,CAAe,oBAAoB,CAAC,SAAS,CAAC,EAAE,YAAY,CAAC;AACvG,QAAA,CAAC;AACH,IAAA,CAAC,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,CAAC;AAC9B;;;;"}
|
|
@@ -57,6 +57,17 @@ export interface SDKProps {
|
|
|
57
57
|
customBranch?: string;
|
|
58
58
|
highlightedBond?: string;
|
|
59
59
|
}
|
|
60
|
-
|
|
60
|
+
/**
|
|
61
|
+
* Reads the SDK config set by <ApeBondSDK />. Reading never stores anything, so <ApeBondSDK /> wins whenever it
|
|
62
|
+
* renders, even after the components that read the config.
|
|
63
|
+
*/
|
|
64
|
+
export declare const useSDKConfig: () => SDKProps;
|
|
65
|
+
/**
|
|
66
|
+
* Sets the SDK config. Only <ApeBondSDK /> calls it. The config is stored the first time (later prop changes don't
|
|
67
|
+
* rewrite it); the registries (custom RPCs, adapters, wallet openers) follow the props.
|
|
68
|
+
*/
|
|
69
|
+
export declare const useConfigureSDK: (config: SDKPropsDTO) => void;
|
|
70
|
+
/** For the views: logs once if they render without <ApeBondSDK /> (they'd show no bonds). */
|
|
71
|
+
export declare const useWarnIfNotConfigured: () => void;
|
|
61
72
|
export type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl';
|
|
62
73
|
export declare const useURLByEnvironment: (key: URLKeys) => string;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { useEffect } from 'react';
|
|
2
|
-
import { useQuery } from '@tanstack/react-query';
|
|
2
|
+
import { useQuery, useQueryClient } from '@tanstack/react-query';
|
|
3
3
|
import { QUERY_KEYS } from '../config/constants/queryKeys.js';
|
|
4
4
|
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
5
5
|
import { setCustomRPCS } from '../config/constants/networks.js';
|
|
@@ -38,8 +38,8 @@ const logOnce = (message) => {
|
|
|
38
38
|
const getSupportedChains = (chains) => {
|
|
39
39
|
if (getRegisteredAdapters().length === 0) {
|
|
40
40
|
logOnce('[ApeBond SDK] No chain adapters registered, so no chains are shown. Since v7, pass the adapters of the chain ' +
|
|
41
|
-
'families you use
|
|
42
|
-
'("Upgrading from v6").');
|
|
41
|
+
'families you use to <ApeBondSDK />, e.g. adapters={[evmAdapter]} from "@ape.swap/bonds-sdk/adapters/evm". ' +
|
|
42
|
+
'See the README ("Upgrading from v6").');
|
|
43
43
|
return [];
|
|
44
44
|
}
|
|
45
45
|
const missing = new Map();
|
|
@@ -53,76 +53,96 @@ const getSupportedChains = (chains) => {
|
|
|
53
53
|
missing.forEach((chainIds, hint) => logOnce(`[ApeBond SDK] Chains ${chainIds.join(', ')} are configured but not supported without ${hint}; they're hidden.`));
|
|
54
54
|
return supported;
|
|
55
55
|
};
|
|
56
|
-
const
|
|
57
|
-
|
|
56
|
+
const urlsByEnvironment = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls;
|
|
57
|
+
const configQueryKey = [QUERY_KEYS.SDK_CONFIG];
|
|
58
|
+
// The config query is only a store: <ApeBondSDK /> fills it through `initialData`, and it is never fetched.
|
|
59
|
+
const noFetch = () => {
|
|
60
|
+
throw new Error('[ApeBond SDK] The SDK config is set by <ApeBondSDK />, never fetched');
|
|
61
|
+
};
|
|
62
|
+
// What readers get before <ApeBondSDK /> has configured the SDK. Not stored, so it can't shadow the real config.
|
|
63
|
+
const UNCONFIGURED = {
|
|
64
|
+
referenceId: '',
|
|
65
|
+
chains: [],
|
|
66
|
+
hotBondChains: [ChainId.BSC, ChainId.MATIC],
|
|
67
|
+
openWalletConnectors: { evm: false, sol: false, sui: false, aptos: false },
|
|
68
|
+
useHotBonds: true,
|
|
69
|
+
useTiers: false,
|
|
70
|
+
useTGEBonds: false,
|
|
71
|
+
showLowValueBonds: false,
|
|
72
|
+
namingPreference: 'Bonus',
|
|
73
|
+
useCardsView: false,
|
|
74
|
+
blockSales: false,
|
|
75
|
+
customBranch: '',
|
|
76
|
+
urls: urlsByEnvironment,
|
|
77
|
+
highestCompatibleVersion: '2.2.0',
|
|
78
|
+
};
|
|
79
|
+
/**
|
|
80
|
+
* Reads the SDK config set by <ApeBondSDK />. Reading never stores anything, so <ApeBondSDK /> wins whenever it
|
|
81
|
+
* renders, even after the components that read the config.
|
|
82
|
+
*/
|
|
83
|
+
const useSDKConfig = () => {
|
|
84
|
+
const { data } = useQuery({ queryKey: configQueryKey, queryFn: noFetch, enabled: false, staleTime: Infinity });
|
|
85
|
+
return data ?? UNCONFIGURED;
|
|
86
|
+
};
|
|
87
|
+
/**
|
|
88
|
+
* Sets the SDK config. Only <ApeBondSDK /> calls it. The config is stored the first time (later prop changes don't
|
|
89
|
+
* rewrite it); the registries (custom RPCs, adapters, wallet openers) follow the props.
|
|
90
|
+
*/
|
|
91
|
+
const useConfigureSDK = (config) => {
|
|
58
92
|
// Adapters hold components and functions, so they live in the adapter registry, not in the cached config.
|
|
59
|
-
const { adapters, ...configProps } =
|
|
60
|
-
const hasConfig = config !== undefined;
|
|
61
|
-
const customRPCS = config?.customRPCS;
|
|
93
|
+
const { adapters, ...configProps } = config;
|
|
62
94
|
// Registries read by query functions are filled synchronously during render, not in an effect, so the first
|
|
63
|
-
// render and the first queries already see them. Both calls are idempotent.
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
registerAdapters(adapters);
|
|
69
|
-
}
|
|
95
|
+
// render and the first queries already see them. Both calls are idempotent.
|
|
96
|
+
if (config.customRPCS)
|
|
97
|
+
setCustomRPCS(config.customRPCS);
|
|
98
|
+
if (adapters)
|
|
99
|
+
registerAdapters(adapters);
|
|
70
100
|
const initialData = {
|
|
71
|
-
|
|
72
|
-
hotBondChains: [ChainId.BSC, ChainId.MATIC],
|
|
73
|
-
useHotBonds: true,
|
|
74
|
-
useTGEBonds: false,
|
|
75
|
-
showLowValueBonds: false,
|
|
101
|
+
...UNCONFIGURED,
|
|
76
102
|
bondPartner: undefined,
|
|
77
|
-
namingPreference: 'Bonus',
|
|
78
|
-
useCardsView: false,
|
|
79
|
-
blockSales: false,
|
|
80
|
-
customBranch: '',
|
|
81
103
|
...configProps,
|
|
82
104
|
// Chains without a registered adapter are unsupported: drop them (with a console error) instead of rendering
|
|
83
105
|
// empty sections.
|
|
84
|
-
chains:
|
|
106
|
+
chains: getSupportedChains(config.chains ?? []),
|
|
85
107
|
openWalletConnectors: {
|
|
86
|
-
evm: !!config
|
|
87
|
-
sol: !!config
|
|
88
|
-
sui: !!config
|
|
89
|
-
aptos: !!config
|
|
108
|
+
evm: !!config.openWalletConnectors?.evm,
|
|
109
|
+
sol: !!config.openWalletConnectors?.sol,
|
|
110
|
+
sui: !!config.openWalletConnectors?.sui,
|
|
111
|
+
aptos: !!config.openWalletConnectors?.aptos,
|
|
90
112
|
},
|
|
91
|
-
useTiers: config
|
|
92
|
-
urls: { ...
|
|
113
|
+
useTiers: config.namingPreference === 'Discount' ? false : (config.useTiers ?? false), // for the time being we'll assume discount preference does not want to useTiers
|
|
114
|
+
urls: { ...urlsByEnvironment, ...config.urls },
|
|
93
115
|
highestCompatibleVersion: '2.2.0',
|
|
94
116
|
};
|
|
95
|
-
const
|
|
96
|
-
const solConnectorOpener = config?.openWalletConnectors?.sol;
|
|
97
|
-
const suiConnectorOpener = config?.openWalletConnectors?.sui;
|
|
98
|
-
const aptosConnectorOpener = config?.openWalletConnectors?.aptos;
|
|
117
|
+
const { evm, sol, sui, aptos } = config.openWalletConnectors ?? {};
|
|
99
118
|
useEffect(() => {
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
119
|
+
if (evm)
|
|
120
|
+
setWalletConnectorOpener('evm', evm);
|
|
121
|
+
if (sol)
|
|
122
|
+
setWalletConnectorOpener('sol', sol);
|
|
123
|
+
if (sui)
|
|
124
|
+
setWalletConnectorOpener('sui', sui);
|
|
125
|
+
if (aptos)
|
|
126
|
+
setWalletConnectorOpener('aptos', aptos);
|
|
127
|
+
}, [evm, sol, sui, aptos]);
|
|
128
|
+
// Also fills the query when a reader created it first (without data).
|
|
129
|
+
useQuery({ queryKey: configQueryKey, queryFn: noFetch, enabled: false, staleTime: Infinity, initialData });
|
|
130
|
+
};
|
|
131
|
+
/** For the views: logs once if they render without <ApeBondSDK /> (they'd show no bonds). */
|
|
132
|
+
const useWarnIfNotConfigured = () => {
|
|
133
|
+
const queryClient = useQueryClient();
|
|
134
|
+
useEffect(() => {
|
|
135
|
+
// In an effect: <ApeBondSDK /> may render after the view in the same commit.
|
|
136
|
+
if (queryClient.getQueryData(configQueryKey) === undefined) {
|
|
137
|
+
logOnce('[ApeBond SDK] The SDK views need <ApeBondSDK /> (@ape.swap/bonds-sdk/components/ApeBondSDK) mounted with your ' +
|
|
138
|
+
'config (referenceId, chains, adapters…); without it components and hooks will not work properly');
|
|
103
139
|
}
|
|
104
|
-
|
|
105
|
-
setWalletConnectorOpener('evm', evmConnectorOpener);
|
|
106
|
-
if (solConnectorOpener)
|
|
107
|
-
setWalletConnectorOpener('sol', solConnectorOpener);
|
|
108
|
-
if (suiConnectorOpener)
|
|
109
|
-
setWalletConnectorOpener('sui', suiConnectorOpener);
|
|
110
|
-
if (aptosConnectorOpener)
|
|
111
|
-
setWalletConnectorOpener('aptos', aptosConnectorOpener);
|
|
112
|
-
}, [hasConfig, evmConnectorOpener, solConnectorOpener, suiConnectorOpener, aptosConnectorOpener]);
|
|
113
|
-
const { data } = useQuery({
|
|
114
|
-
queryKey: [QUERY_KEYS.SDK_CONFIG],
|
|
115
|
-
queryFn: () => {
|
|
116
|
-
throw new Error('Just a hotfix for latest versions of react-query that make queryFn a required prop');
|
|
117
|
-
},
|
|
118
|
-
initialData,
|
|
119
|
-
});
|
|
120
|
-
return data;
|
|
140
|
+
}, [queryClient]);
|
|
121
141
|
};
|
|
122
142
|
const useURLByEnvironment = (key) => {
|
|
123
143
|
const config = useSDKConfig();
|
|
124
144
|
return config?.urls?.[key];
|
|
125
145
|
};
|
|
126
146
|
|
|
127
|
-
export { useSDKConfig, useURLByEnvironment };
|
|
147
|
+
export { useConfigureSDK, useSDKConfig, useURLByEnvironment, useWarnIfNotConfigured };
|
|
128
148
|
//# sourceMappingURL=useSDKConfig.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useSDKConfig.js","sources":["../../src/state/useSDKConfig.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { useQuery } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../config/constants/queryKeys'\nimport { ChainId } from '@ape.swap/apeswap-lists'\nimport { setCustomRPCS } from '../config/constants/networks'\nimport { setWalletConnectorOpener } from '../config/constants/walletConnectors'\nimport { getAdapterForChain, getRegisteredAdapters, registerAdapters } from '../adapters/registry'\nimport type { SDKAdapter } from '../adapters/types'\n\n// Prod URLS. Do not make changes here\nconst defaultUrls = {\n apiV2: 'https://api.ape.bond',\n realTimeApi: 'https://realtime-api.ape.bond',\n mainUrl: 'https://ape.bond',\n}\n\n// Staging URLS.\nconst stagingUrls = {\n apiV2: 'https://staging-api.ape.bond',\n realTimeApi: 'https://realtime-api-staging.ape.bond',\n mainUrl: 'https://staging.ape.bond',\n}\n\nexport interface OpenWalletConnectorsDTO {\n evm?: () => void\n sol?: () => void\n sui?: () => void\n aptos?: () => void\n}\n\nexport interface SDKPropsDTO {\n referenceId: string\n chains: number[]\n hotBondChains?: number[]\n useHotBonds?: boolean\n useTiers?: boolean\n useTGEBonds?: boolean\n useCardsView?: boolean\n showLowValueBonds?: boolean\n bondPartner?: string\n namingPreference?: 'Discount' | 'Bonus'\n urls?: Partial<Record<URLKeys, string>>\n highestCompatibleVersion?: string\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n customRPCS?: Partial<Record<ChainId, string[]>>\n openWalletConnectors?: OpenWalletConnectorsDTO\n aptosAddress?: string\n suiAddress?: string\n suiTreasuryAddresses?: string[]\n /** Chain-family adapters (and optionally a bridge adapter) to enable. Required since v7; see the README. */\n adapters?: SDKAdapter[]\n}\n\nexport interface SDKProps {\n referenceId: string\n chains: number[]\n hotBondChains: number[]\n openWalletConnectors?: {\n evm?: boolean\n sol?: boolean\n sui?: boolean\n aptos?: boolean\n }\n useHotBonds: boolean\n useTiers: boolean\n useTGEBonds: boolean\n showLowValueBonds: boolean\n bondPartner?: string\n namingPreference: 'Discount' | 'Bonus'\n urls: Record<URLKeys, string>\n highestCompatibleVersion?: string\n evmAddress?: string\n solAddress?: string\n aptosAddress?: string\n suiAddress?: string\n useCardsView?: boolean\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n}\n\n// Adapter each chain family needs, for the \"unsupported chain\" error message.\nconst adapterHint = (chainId: number) =>\n chainId === ChainId.SOL\n ? 'solanaAdapter (@ape.swap/bonds-sdk/adapters/solana)'\n : chainId === ChainId.APTOS\n ? 'aptosAdapter (@ape.swap/bonds-sdk/adapters/aptos)'\n : chainId === ChainId.SUI\n ? 'suiAdapter (@ape.swap/bonds-sdk/adapters/sui)'\n : 'evmAdapter (@ape.swap/bonds-sdk/adapters/evm)'\n\n// Each message is logged once per page load, not on every render.\nconst loggedErrors = new Set<string>()\nconst logOnce = (message: string) => {\n if (loggedErrors.has(message)) return\n loggedErrors.add(message)\n console.error(message)\n}\n\n/** Keeps the configured chains that have a registered adapter; the others are unsupported, and logged once. */\nconst getSupportedChains = (chains: number[]): number[] => {\n if (getRegisteredAdapters().length === 0) {\n logOnce(\n '[ApeBond SDK] No chain adapters registered, so no chains are shown. Since v7, pass the adapters of the chain ' +\n 'families you use, e.g. adapters={[evmAdapter]} from \"@ape.swap/bonds-sdk/adapters/evm\". See the README ' +\n '(\"Upgrading from v6\").',\n )\n return []\n }\n const missing = new Map<string, number[]>()\n const supported = chains.filter((chainId) => {\n if (getAdapterForChain(chainId)) return true\n const hint = adapterHint(chainId)\n missing.set(hint, [...(missing.get(hint) ?? []), chainId])\n return false\n })\n missing.forEach((chainIds, hint) =>\n logOnce(`[ApeBond SDK] Chains ${chainIds.join(', ')} are configured but not supported without ${hint}; they're hidden.`),\n )\n return supported\n}\n\nexport const useSDKConfig = (config?: SDKPropsDTO): SDKProps => {\n const urls = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls\n // Adapters hold components and functions, so they live in the adapter registry, not in the cached config.\n const { adapters, ...configProps } = (config ?? {}) as Partial<SDKPropsDTO>\n\n const hasConfig = config !== undefined\n const customRPCS = config?.customRPCS\n\n // Registries read by query functions are filled synchronously during render, not in an effect, so the first\n // render and the first queries already see them. Both calls are idempotent. Calls without config only read\n // shared settings and must not overwrite the registries.\n if (hasConfig) {\n setCustomRPCS(customRPCS ?? {})\n if (adapters) registerAdapters(adapters)\n }\n\n const initialData: SDKProps = {\n referenceId: '',\n hotBondChains: [ChainId.BSC, ChainId.MATIC],\n useHotBonds: true,\n useTGEBonds: false,\n showLowValueBonds: false,\n bondPartner: undefined,\n namingPreference: 'Bonus',\n useCardsView: false,\n blockSales: false,\n customBranch: '',\n ...configProps,\n // Chains without a registered adapter are unsupported: drop them (with a console error) instead of rendering\n // empty sections.\n chains: hasConfig ? getSupportedChains(config.chains ?? []) : [],\n openWalletConnectors: {\n evm: !!config?.openWalletConnectors?.evm,\n sol: !!config?.openWalletConnectors?.sol,\n sui: !!config?.openWalletConnectors?.sui,\n aptos: !!config?.openWalletConnectors?.aptos,\n },\n useTiers: config?.namingPreference === 'Discount' ? false : (config?.useTiers ?? false), // for the time being we'll assume discount preference does not want to useTiers\n urls: { ...urls, ...config?.urls },\n highestCompatibleVersion: '2.2.0',\n }\n\n\n const evmConnectorOpener = config?.openWalletConnectors?.evm\n const solConnectorOpener = config?.openWalletConnectors?.sol\n const suiConnectorOpener = config?.openWalletConnectors?.sui\n const aptosConnectorOpener = config?.openWalletConnectors?.aptos\n\n useEffect(() => {\n // Calls without config only read shared settings and must not overwrite their registries.\n if (!hasConfig) {\n return\n }\n if (evmConnectorOpener) setWalletConnectorOpener('evm', evmConnectorOpener)\n if (solConnectorOpener) setWalletConnectorOpener('sol', solConnectorOpener)\n if (suiConnectorOpener) setWalletConnectorOpener('sui', suiConnectorOpener)\n if (aptosConnectorOpener) setWalletConnectorOpener('aptos', aptosConnectorOpener)\n }, [hasConfig, evmConnectorOpener, solConnectorOpener, suiConnectorOpener, aptosConnectorOpener])\n\n const { data } = useQuery({\n queryKey: [QUERY_KEYS.SDK_CONFIG],\n queryFn: () => {\n throw new Error('Just a hotfix for latest versions of react-query that make queryFn a required prop')\n },\n initialData,\n })\n return data as SDKProps\n}\n\nexport type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl'\n\nexport const useURLByEnvironment = (key: URLKeys) => {\n const config = useSDKConfig()\n return config?.urls?.[key] as string\n}\n"],"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,OAAO,EAAE,oBAAoB,CAAC;AACnF,IAAA,CAAC,EAAE,CAAC,SAAS,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,oBAAoB,CAAC,CAAC;AAEjG,IAAA,MAAM,EAAE,IAAI,EAAE,GAAG,QAAQ,CAAC;AACxB,QAAA,QAAQ,EAAE,CAAC,UAAU,CAAC,UAAU,CAAC;QACjC,OAAO,EAAE,MAAK;AACZ,YAAA,MAAM,IAAI,KAAK,CAAC,oFAAoF,CAAC;QACvG,CAAC;QACD,WAAW;AACZ,KAAA,CAAC;AACF,IAAA,OAAO,IAAgB;AACzB;AAIO,MAAM,mBAAmB,GAAG,CAAC,GAAY,KAAI;AAClD,IAAA,MAAM,MAAM,GAAG,YAAY,EAAE;AAC7B,IAAA,OAAO,MAAM,EAAE,IAAI,GAAG,GAAG,CAAW;AACtC;;;;"}
|
|
1
|
+
{"version":3,"file":"useSDKConfig.js","sources":["../../src/state/useSDKConfig.ts"],"sourcesContent":["import { useEffect } from 'react'\nimport { useQuery, useQueryClient } from '@tanstack/react-query'\nimport { QUERY_KEYS } from '../config/constants/queryKeys'\nimport { ChainId } from '@ape.swap/apeswap-lists'\nimport { setCustomRPCS } from '../config/constants/networks'\nimport { setWalletConnectorOpener } from '../config/constants/walletConnectors'\nimport { getAdapterForChain, getRegisteredAdapters, registerAdapters } from '../adapters/registry'\nimport type { SDKAdapter } from '../adapters/types'\n\n// Prod URLS. Do not make changes here\nconst defaultUrls = {\n apiV2: 'https://api.ape.bond',\n realTimeApi: 'https://realtime-api.ape.bond',\n mainUrl: 'https://ape.bond',\n}\n\n// Staging URLS.\nconst stagingUrls = {\n apiV2: 'https://staging-api.ape.bond',\n realTimeApi: 'https://realtime-api-staging.ape.bond',\n mainUrl: 'https://staging.ape.bond',\n}\n\nexport interface OpenWalletConnectorsDTO {\n evm?: () => void\n sol?: () => void\n sui?: () => void\n aptos?: () => void\n}\n\nexport interface SDKPropsDTO {\n referenceId: string\n chains: number[]\n hotBondChains?: number[]\n useHotBonds?: boolean\n useTiers?: boolean\n useTGEBonds?: boolean\n useCardsView?: boolean\n showLowValueBonds?: boolean\n bondPartner?: string\n namingPreference?: 'Discount' | 'Bonus'\n urls?: Partial<Record<URLKeys, string>>\n highestCompatibleVersion?: string\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n customRPCS?: Partial<Record<ChainId, string[]>>\n openWalletConnectors?: OpenWalletConnectorsDTO\n aptosAddress?: string\n suiAddress?: string\n suiTreasuryAddresses?: string[]\n /** Chain-family adapters (and optionally a bridge adapter) to enable. Required since v7; see the README. */\n adapters?: SDKAdapter[]\n}\n\nexport interface SDKProps {\n referenceId: string\n chains: number[]\n hotBondChains: number[]\n openWalletConnectors?: {\n evm?: boolean\n sol?: boolean\n sui?: boolean\n aptos?: boolean\n }\n useHotBonds: boolean\n useTiers: boolean\n useTGEBonds: boolean\n showLowValueBonds: boolean\n bondPartner?: string\n namingPreference: 'Discount' | 'Bonus'\n urls: Record<URLKeys, string>\n highestCompatibleVersion?: string\n evmAddress?: string\n solAddress?: string\n aptosAddress?: string\n suiAddress?: string\n useCardsView?: boolean\n blockSales?: boolean\n customBranch?: string\n highlightedBond?: string\n}\n\n// Adapter each chain family needs, for the \"unsupported chain\" error message.\nconst adapterHint = (chainId: number) =>\n chainId === ChainId.SOL\n ? 'solanaAdapter (@ape.swap/bonds-sdk/adapters/solana)'\n : chainId === ChainId.APTOS\n ? 'aptosAdapter (@ape.swap/bonds-sdk/adapters/aptos)'\n : chainId === ChainId.SUI\n ? 'suiAdapter (@ape.swap/bonds-sdk/adapters/sui)'\n : 'evmAdapter (@ape.swap/bonds-sdk/adapters/evm)'\n\n// Each message is logged once per page load, not on every render.\nconst loggedErrors = new Set<string>()\nconst logOnce = (message: string) => {\n if (loggedErrors.has(message)) return\n loggedErrors.add(message)\n console.error(message)\n}\n\n/** Keeps the configured chains that have a registered adapter; the others are unsupported, and logged once. */\nconst getSupportedChains = (chains: number[]): number[] => {\n if (getRegisteredAdapters().length === 0) {\n logOnce(\n '[ApeBond SDK] No chain adapters registered, so no chains are shown. Since v7, pass the adapters of the chain ' +\n 'families you use to <ApeBondSDK />, e.g. adapters={[evmAdapter]} from \"@ape.swap/bonds-sdk/adapters/evm\". ' +\n 'See the README (\"Upgrading from v6\").',\n )\n return []\n }\n const missing = new Map<string, number[]>()\n const supported = chains.filter((chainId) => {\n if (getAdapterForChain(chainId)) return true\n const hint = adapterHint(chainId)\n missing.set(hint, [...(missing.get(hint) ?? []), chainId])\n return false\n })\n missing.forEach((chainIds, hint) =>\n logOnce(\n `[ApeBond SDK] Chains ${chainIds.join(', ')} are configured but not supported without ${hint}; they're hidden.`,\n ),\n )\n return supported\n}\n\nconst urlsByEnvironment = process.env.NODE_ENV === 'production' ? defaultUrls : stagingUrls\n\nconst configQueryKey = [QUERY_KEYS.SDK_CONFIG]\n\n// The config query is only a store: <ApeBondSDK /> fills it through `initialData`, and it is never fetched.\nconst noFetch = (): SDKProps => {\n throw new Error('[ApeBond SDK] The SDK config is set by <ApeBondSDK />, never fetched')\n}\n\n// What readers get before <ApeBondSDK /> has configured the SDK. Not stored, so it can't shadow the real config.\nconst UNCONFIGURED: SDKProps = {\n referenceId: '',\n chains: [],\n hotBondChains: [ChainId.BSC, ChainId.MATIC],\n openWalletConnectors: { evm: false, sol: false, sui: false, aptos: false },\n useHotBonds: true,\n useTiers: false,\n useTGEBonds: false,\n showLowValueBonds: false,\n namingPreference: 'Bonus',\n useCardsView: false,\n blockSales: false,\n customBranch: '',\n urls: urlsByEnvironment,\n highestCompatibleVersion: '2.2.0',\n}\n\n/**\n * Reads the SDK config set by <ApeBondSDK />. Reading never stores anything, so <ApeBondSDK /> wins whenever it\n * renders, even after the components that read the config.\n */\nexport const useSDKConfig = (): SDKProps => {\n const { data } = useQuery({ queryKey: configQueryKey, queryFn: noFetch, enabled: false, staleTime: Infinity })\n return data ?? UNCONFIGURED\n}\n\n/**\n * Sets the SDK config. Only <ApeBondSDK /> calls it. The config is stored the first time (later prop changes don't\n * rewrite it); the registries (custom RPCs, adapters, wallet openers) follow the props.\n */\nexport const useConfigureSDK = (config: SDKPropsDTO): void => {\n // Adapters hold components and functions, so they live in the adapter registry, not in the cached config.\n const { adapters, ...configProps } = config\n\n // Registries read by query functions are filled synchronously during render, not in an effect, so the first\n // render and the first queries already see them. Both calls are idempotent.\n if (config.customRPCS) setCustomRPCS(config.customRPCS)\n if (adapters) registerAdapters(adapters)\n\n const initialData: SDKProps = {\n ...UNCONFIGURED,\n bondPartner: undefined,\n ...configProps,\n // Chains without a registered adapter are unsupported: drop them (with a console error) instead of rendering\n // empty sections.\n chains: getSupportedChains(config.chains ?? []),\n openWalletConnectors: {\n evm: !!config.openWalletConnectors?.evm,\n sol: !!config.openWalletConnectors?.sol,\n sui: !!config.openWalletConnectors?.sui,\n aptos: !!config.openWalletConnectors?.aptos,\n },\n useTiers: config.namingPreference === 'Discount' ? false : (config.useTiers ?? false), // for the time being we'll assume discount preference does not want to useTiers\n urls: { ...urlsByEnvironment, ...config.urls },\n highestCompatibleVersion: '2.2.0',\n }\n\n const { evm, sol, sui, aptos } = config.openWalletConnectors ?? {}\n useEffect(() => {\n if (evm) setWalletConnectorOpener('evm', evm)\n if (sol) setWalletConnectorOpener('sol', sol)\n if (sui) setWalletConnectorOpener('sui', sui)\n if (aptos) setWalletConnectorOpener('aptos', aptos)\n }, [evm, sol, sui, aptos])\n\n // Also fills the query when a reader created it first (without data).\n useQuery({ queryKey: configQueryKey, queryFn: noFetch, enabled: false, staleTime: Infinity, initialData })\n}\n\n/** For the views: logs once if they render without <ApeBondSDK /> (they'd show no bonds). */\nexport const useWarnIfNotConfigured = () => {\n const queryClient = useQueryClient()\n useEffect(() => {\n // In an effect: <ApeBondSDK /> may render after the view in the same commit.\n if (queryClient.getQueryData(configQueryKey) === undefined) {\n logOnce(\n '[ApeBond SDK] The SDK views need <ApeBondSDK /> (@ape.swap/bonds-sdk/components/ApeBondSDK) mounted with your ' +\n 'config (referenceId, chains, adapters…); without it components and hooks will not work properly',\n )\n }\n }, [queryClient])\n}\n\nexport type URLKeys = 'apiV2' | 'realTimeApi' | 'mainUrl'\n\nexport const useURLByEnvironment = (key: URLKeys) => {\n const config = useSDKConfig()\n return config?.urls?.[key] as string\n}\n"],"names":[],"mappings":";;;;;;;;AASA;AACA,MAAM,WAAW,GAAG;AAClB,IAAA,KAAK,EAAE,sBAAsB;AAC7B,IAAA,WAAW,EAAE,+BAA+B;AAC5C,IAAA,OAAO,EAAE,kBAAkB;CAC5B;AAED;AACA,MAAM,WAAW,GAAG;AAClB,IAAA,KAAK,EAAE,8BAA8B;AACrC,IAAA,WAAW,EAAE,uCAAuC;AACpD,IAAA,OAAO,EAAE,0BAA0B;CACpC;AA8DD;AACA,MAAM,WAAW,GAAG,CAAC,OAAe,KAClC,OAAO,KAAK,OAAO,CAAC;AAClB,MAAE;AACF,MAAE,OAAO,KAAK,OAAO,CAAC;AACpB,UAAE;AACF,UAAE,OAAO,KAAK,OAAO,CAAC;AACpB,cAAE;cACA,+CAA+C;AAEzD;AACA,MAAM,YAAY,GAAG,IAAI,GAAG,EAAU;AACtC,MAAM,OAAO,GAAG,CAAC,OAAe,KAAI;AAClC,IAAA,IAAI,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC;QAAE;AAC/B,IAAA,YAAY,CAAC,GAAG,CAAC,OAAO,CAAC;AACzB,IAAA,OAAO,CAAC,KAAK,CAAC,OAAO,CAAC;AACxB,CAAC;AAED;AACA,MAAM,kBAAkB,GAAG,CAAC,MAAgB,KAAc;AACxD,IAAA,IAAI,qBAAqB,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE;AACxC,QAAA,OAAO,CACL,+GAA+G;YAC7G,4GAA4G;AAC5G,YAAA,uCAAuC,CAC1C;AACD,QAAA,OAAO,EAAE;IACX;AACA,IAAA,MAAM,OAAO,GAAG,IAAI,GAAG,EAAoB;IAC3C,MAAM,SAAS,GAAG,MAAM,CAAC,MAAM,CAAC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
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Providers from '../../providers/index.js';
|
|
3
3
|
import Bonds from './Bonds.js';
|
|
4
|
-
import { useSDKConfig } from '../../state/useSDKConfig.js';
|
|
5
4
|
|
|
6
|
-
const BondsWithProviders = (
|
|
7
|
-
useSDKConfig(props);
|
|
8
|
-
return (jsx(Providers, { children: jsx(Bonds, {}) }));
|
|
9
|
-
};
|
|
5
|
+
const BondsWithProviders = () => (jsx(Providers, { children: jsx(Bonds, {}) }));
|
|
10
6
|
|
|
11
7
|
export { BondsWithProviders as default };
|
|
12
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/views/Bonds/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport Bonds from './Bonds'\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/views/Bonds/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport Bonds from './Bonds'\n\nconst BondsWithProviders = () => (\n <Providers>\n <Bonds />\n </Providers>\n)\n\nexport default BondsWithProviders\n"],"names":["_jsx"],"mappings":";;;;AAIA,MAAM,kBAAkB,GAAG,OACzBA,GAAA,CAAC,SAAS,EAAA,EAAA,QAAA,EACRA,GAAA,CAAC,KAAK,EAAA,EAAA,CAAG,EAAA,CACC;;;;"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import type { ChainBuyComponentProps } from '../../adapters/types';
|
|
3
|
-
|
|
4
|
-
interface Props extends SDKPropsDTO, ChainBuyComponentProps {
|
|
5
|
-
}
|
|
6
|
-
declare const BuyBondModalWithProviders: React.FC<Props>;
|
|
3
|
+
declare const BuyBondModalWithProviders: React.FC<ChainBuyComponentProps>;
|
|
7
4
|
export default BuyBondModalWithProviders;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Providers from '../../providers/index.js';
|
|
3
|
-
import { useSDKConfig } from '../../state/useSDKConfig.js';
|
|
4
3
|
import BuyBondModal from './BuyBondModal.js';
|
|
5
4
|
|
|
6
|
-
const BuyBondModalWithProviders = (props) => {
|
|
7
|
-
useSDKConfig(props);
|
|
8
|
-
return (jsx(Providers, { children: jsx(BuyBondModal, { ...props }) }));
|
|
9
|
-
};
|
|
5
|
+
const BuyBondModalWithProviders = (props) => (jsx(Providers, { children: jsx(BuyBondModal, { ...props }) }));
|
|
10
6
|
|
|
11
7
|
export { BuyBondModalWithProviders as default };
|
|
12
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/views/BuyBond/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport type { ChainBuyComponentProps } from '../../adapters/types'\nimport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/views/BuyBond/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport type { ChainBuyComponentProps } from '../../adapters/types'\nimport BuyBondModal from './BuyBondModal'\n\nconst BuyBondModalWithProviders: React.FC<ChainBuyComponentProps> = (props) => (\n <Providers>\n <BuyBondModal {...props} />\n </Providers>\n)\n\nexport default BuyBondModalWithProviders\n"],"names":["_jsx"],"mappings":";;;;AAKA,MAAM,yBAAyB,GAAqC,CAAC,KAAK,MACxEA,GAAA,CAAC,SAAS,EAAA,EAAA,QAAA,EACRA,IAAC,YAAY,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CACjB;;;;"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { SDKPropsDTO } from '../../state/useSDKConfig';
|
|
3
|
-
declare const FullBondsViewWithProviders: React.FC<SDKPropsDTO>;
|
|
1
|
+
declare const FullBondsViewWithProviders: () => import("react/jsx-runtime").JSX.Element;
|
|
4
2
|
export default FullBondsViewWithProviders;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Providers from '../../providers/index.js';
|
|
3
3
|
import FullBondsView from './FullBondsView.js';
|
|
4
|
-
import { useSDKConfig } from '../../state/useSDKConfig.js';
|
|
5
4
|
|
|
6
|
-
const FullBondsViewWithProviders = (
|
|
7
|
-
useSDKConfig(props);
|
|
8
|
-
return (jsx(Providers, { children: jsx(FullBondsView, {}) }));
|
|
9
|
-
};
|
|
5
|
+
const FullBondsViewWithProviders = () => (jsx(Providers, { children: jsx(FullBondsView, {}) }));
|
|
10
6
|
|
|
11
7
|
export { FullBondsViewWithProviders as default };
|
|
12
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/views/FullBondsView/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport FullBondsView from './FullBondsView'\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/views/FullBondsView/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport FullBondsView from './FullBondsView'\n\nconst FullBondsViewWithProviders = () => (\n <Providers>\n <FullBondsView />\n </Providers>\n)\n\nexport default FullBondsViewWithProviders\n"],"names":["_jsx"],"mappings":";;;;AAIA,MAAM,0BAA0B,GAAG,OACjCA,GAAA,CAAC,SAAS,EAAA,EAAA,QAAA,EACRA,GAAA,CAAC,aAAa,EAAA,EAAA,CAAG,EAAA,CACP;;;;"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SDKPropsDTO } from '../../state/useSDKConfig';
|
|
3
2
|
import { ProjectViewProps } from './ProjectView';
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const ProjectViewWithProviders: React.FC<Props>;
|
|
3
|
+
declare const ProjectViewWithProviders: React.FC<ProjectViewProps>;
|
|
7
4
|
export default ProjectViewWithProviders;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Providers from '../../providers/index.js';
|
|
3
|
-
import { useSDKConfig } from '../../state/useSDKConfig.js';
|
|
4
3
|
import ProjectView from './ProjectView.js';
|
|
5
4
|
|
|
6
|
-
const ProjectViewWithProviders = (props) => {
|
|
7
|
-
useSDKConfig(props);
|
|
8
|
-
return (jsx(Providers, { children: jsx(ProjectView, { ...props }) }));
|
|
9
|
-
};
|
|
5
|
+
const ProjectViewWithProviders = (props) => (jsx(Providers, { children: jsx(ProjectView, { ...props }) }));
|
|
10
6
|
|
|
11
7
|
export { ProjectViewWithProviders as default };
|
|
12
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/views/ProjectView/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/views/ProjectView/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport ProjectView, { ProjectViewProps } from './ProjectView'\n\nconst ProjectViewWithProviders: React.FC<ProjectViewProps> = (props) => (\n <Providers>\n <ProjectView {...props} />\n </Providers>\n)\n\nexport default ProjectViewWithProviders\n"],"names":["_jsx"],"mappings":";;;;AAIA,MAAM,wBAAwB,GAA+B,CAAC,KAAK,MACjEA,GAAA,CAAC,SAAS,EAAA,EAAA,QAAA,EACRA,IAAC,WAAW,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CAChB;;;;"}
|
|
@@ -1,7 +1,4 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { SDKPropsDTO } from '../../state/useSDKConfig';
|
|
3
2
|
import { SingleBondProps } from './SingleBond';
|
|
4
|
-
|
|
5
|
-
}
|
|
6
|
-
declare const SingleBondWithProviders: React.FC<Props>;
|
|
3
|
+
declare const SingleBondWithProviders: React.FC<SingleBondProps>;
|
|
7
4
|
export default SingleBondWithProviders;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Providers from '../../providers/index.js';
|
|
3
|
-
import { useSDKConfig } from '../../state/useSDKConfig.js';
|
|
4
3
|
import SingleBond from './SingleBond.js';
|
|
5
4
|
|
|
6
|
-
const SingleBondWithProviders = (props) => {
|
|
7
|
-
useSDKConfig(props);
|
|
8
|
-
return (jsx(Providers, { children: jsx(SingleBond, { ...props }) }));
|
|
9
|
-
};
|
|
5
|
+
const SingleBondWithProviders = (props) => (jsx(Providers, { children: jsx(SingleBond, { ...props }) }));
|
|
10
6
|
|
|
11
7
|
export { SingleBondWithProviders as default };
|
|
12
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/views/SingleBond/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/views/SingleBond/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport SingleBond, { SingleBondProps } from './SingleBond'\n\nconst SingleBondWithProviders: React.FC<SingleBondProps> = (props) => (\n <Providers>\n <SingleBond {...props} />\n </Providers>\n)\n\nexport default SingleBondWithProviders\n"],"names":["_jsx"],"mappings":";;;;AAIA,MAAM,uBAAuB,GAA8B,CAAC,KAAK,MAC/DA,GAAA,CAAC,SAAS,EAAA,EAAA,QAAA,EACRA,IAAC,UAAU,EAAA,EAAA,GAAK,KAAK,EAAA,CAAI,EAAA,CACf;;;;"}
|
|
@@ -1,4 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
import { SDKPropsDTO } from '../../state/useSDKConfig';
|
|
3
|
-
declare const YourBondsWithProviders: React.FC<SDKPropsDTO>;
|
|
1
|
+
declare const YourBondsWithProviders: () => import("react/jsx-runtime").JSX.Element;
|
|
4
2
|
export default YourBondsWithProviders;
|
|
@@ -1,12 +1,8 @@
|
|
|
1
1
|
import { jsx } from 'react/jsx-runtime';
|
|
2
2
|
import Providers from '../../providers/index.js';
|
|
3
3
|
import YourBonds from './YourBonds.js';
|
|
4
|
-
import { useSDKConfig } from '../../state/useSDKConfig.js';
|
|
5
4
|
|
|
6
|
-
const YourBondsWithProviders = (
|
|
7
|
-
useSDKConfig(props);
|
|
8
|
-
return (jsx(Providers, { children: jsx(YourBonds, {}) }));
|
|
9
|
-
};
|
|
5
|
+
const YourBondsWithProviders = () => (jsx(Providers, { children: jsx(YourBonds, {}) }));
|
|
10
6
|
|
|
11
7
|
export { YourBondsWithProviders as default };
|
|
12
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sources":["../../../src/views/YourBonds/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport YourBonds from './YourBonds'\
|
|
1
|
+
{"version":3,"file":"index.js","sources":["../../../src/views/YourBonds/index.tsx"],"sourcesContent":["import React from 'react'\nimport Providers from '../../providers'\nimport YourBonds from './YourBonds'\n\nconst YourBondsWithProviders = () => (\n <Providers>\n <YourBonds />\n </Providers>\n)\n\nexport default YourBondsWithProviders\n"],"names":["_jsx"],"mappings":";;;;AAIA,MAAM,sBAAsB,GAAG,OAC7BA,GAAA,CAAC,SAAS,EAAA,EAAA,QAAA,EACRA,GAAA,CAAC,SAAS,EAAA,EAAA,CAAG,EAAA,CACH;;;;"}
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"description": "Ape Bond SDK",
|
|
4
4
|
"author": "Ape Bond",
|
|
5
5
|
"license": "MIT",
|
|
6
|
-
"version": "7.0.0-test.
|
|
6
|
+
"version": "7.0.0-test.6",
|
|
7
7
|
"module": "dist/main.js",
|
|
8
8
|
"type": "module",
|
|
9
9
|
"types": "dist/main.d.ts",
|
|
@@ -37,6 +37,10 @@
|
|
|
37
37
|
"types": "./dist/views/SingleBond/index.d.ts",
|
|
38
38
|
"import": "./dist/views/SingleBond/index.js"
|
|
39
39
|
},
|
|
40
|
+
"./components/ApeBondSDK": {
|
|
41
|
+
"types": "./dist/components/ApeBondSDK/index.d.ts",
|
|
42
|
+
"import": "./dist/components/ApeBondSDK/index.js"
|
|
43
|
+
},
|
|
40
44
|
"./components/TokenImage": {
|
|
41
45
|
"types": "./dist/components/uikit-sdk/TokenImage/index.d.ts",
|
|
42
46
|
"import": "./dist/components/uikit-sdk/TokenImage/index.js"
|
|
@@ -49,10 +53,6 @@
|
|
|
49
53
|
"types": "./dist/state/bonds/useBondsData.d.ts",
|
|
50
54
|
"import": "./dist/state/bonds/useBondsData.js"
|
|
51
55
|
},
|
|
52
|
-
"./hooks/useSDKConfig": {
|
|
53
|
-
"types": "./dist/state/useSDKConfig.d.ts",
|
|
54
|
-
"import": "./dist/state/useSDKConfig.js"
|
|
55
|
-
},
|
|
56
56
|
"./hooks/useCurrencyBalance": {
|
|
57
57
|
"types": "./dist/state/balance/useCurrencyBalance.d.ts",
|
|
58
58
|
"import": "./dist/state/balance/useCurrencyBalance.js"
|