@0xsequence/hooks 5.4.8 → 6.0.0-beta.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 +39 -317
- package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.d.ts +2 -2
- package/dist/cjs/hooks/Indexer/useGetTransactionHistorySummary.js +2 -2
- package/dist/cjs/hooks/Indexer/useIndexerClient.d.ts +1 -1
- package/dist/cjs/hooks/Indexer/useIndexerClient.js +1 -1
- package/dist/esm/hooks/Indexer/useGetTransactionHistorySummary.d.ts +2 -2
- package/dist/esm/hooks/Indexer/useGetTransactionHistorySummary.js +2 -2
- package/dist/esm/hooks/Indexer/useIndexerClient.d.ts +1 -1
- package/dist/esm/hooks/Indexer/useIndexerClient.js +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -1,333 +1,55 @@
|
|
|
1
|
-
# @0xsequence/hooks
|
|
2
1
|
|
|
3
|
-
|
|
2
|
+
# Sequence Hooks SDK
|
|
4
3
|
|
|
5
|
-
|
|
4
|
+
Use [@0xsequence/hooks](https://www.npmjs.com/package/@0xsequence/hooks/v/0.0.0-20250924112110) to query coin prices, swap routes, swap quotes, balances, transaction history, token information and more by leveraging the Sequence API and Indexer.
|
|
6
5
|
|
|
7
|
-
|
|
8
|
-
<SequenceHooksProvider
|
|
9
|
-
config={{
|
|
10
|
-
projectAccessKey: 'your-project-access-key',
|
|
11
|
-
env: {
|
|
12
|
-
indexerGatewayUrl: 'your-indexer-gateway-url',
|
|
13
|
-
metadataUrl: 'your-metadata-url',
|
|
14
|
-
apiUrl: 'your-api-url',
|
|
15
|
-
indexerUrl: 'your-indexer-url',
|
|
16
|
-
imageProxyUrl: 'your-image-proxy-url',
|
|
17
|
-
builderUrl: 'your-builder-api-url'
|
|
18
|
-
}
|
|
19
|
-
}}
|
|
20
|
-
>
|
|
21
|
-
<App />
|
|
22
|
-
</SequenceHooksProvider>
|
|
23
|
-
```
|
|
24
|
-
|
|
25
|
-
## Hooks:
|
|
26
|
-
|
|
27
|
-
Sequence hooks are grouped into 5 categories, based on the sequence service they interact with:
|
|
28
|
-
|
|
29
|
-
### API
|
|
30
|
-
|
|
31
|
-
- useGetCoinPrices
|
|
32
|
-
- useGetCollectiblePrices
|
|
33
|
-
- useGetExchangeRate
|
|
34
|
-
|
|
35
|
-
### Indexer
|
|
36
|
-
|
|
37
|
-
- useGetTransactionHistory
|
|
38
|
-
- useGetTransactionHistorySummary
|
|
39
|
-
|
|
40
|
-
### Indexer Gateway
|
|
41
|
-
|
|
42
|
-
- useGetNativeTokenBalance
|
|
43
|
-
- useGetTokenBalancesSummary
|
|
44
|
-
- useGetTokenBalancesDetails
|
|
45
|
-
- useGetTokenBalancesByContract
|
|
46
|
-
- useGetSingleTokenBalance
|
|
47
|
-
|
|
48
|
-
### Metadata
|
|
49
|
-
|
|
50
|
-
- useGetContractInfo
|
|
51
|
-
- useGetMultipleContractInfo
|
|
52
|
-
- useGetTokenMetadata
|
|
53
|
-
|
|
54
|
-
### Combination
|
|
55
|
-
|
|
56
|
-
- useGetSwapQuote
|
|
57
|
-
|
|
58
|
-
## Usage
|
|
59
|
-
|
|
60
|
-
### useGetCoinPrices
|
|
6
|
+
## Key Features
|
|
61
7
|
|
|
62
|
-
|
|
63
|
-
|
|
8
|
+
- Coin prices
|
|
9
|
+
- Cross chain swap routes and quotes
|
|
10
|
+
- Multichain balances
|
|
11
|
+
- Transaction history
|
|
12
|
+
- Query multiple contracts at once
|
|
13
|
+
- Get current active wallet status and information
|
|
14
|
+
- Get NFT and token metadata
|
|
15
|
+
- Multiple filtering options
|
|
64
16
|
|
|
65
|
-
|
|
66
|
-
[
|
|
67
|
-
{
|
|
68
|
-
chainId: 1,
|
|
69
|
-
contractAddress: '0x0123456789012345678901234567890123456789'
|
|
70
|
-
}
|
|
71
|
-
],
|
|
72
|
-
{
|
|
73
|
-
// options param is optional and default values are below
|
|
74
|
-
disabled: false
|
|
75
|
-
}
|
|
76
|
-
)
|
|
77
|
-
```
|
|
78
|
-
|
|
79
|
-
### useGetCollectiblePrices
|
|
80
|
-
|
|
81
|
-
```tsx
|
|
82
|
-
import { useGetCollectiblePrices } from '@0xsequence/hooks'
|
|
83
|
-
|
|
84
|
-
const { data, isLoading, error } = useGetCollectiblePrices(
|
|
85
|
-
[
|
|
86
|
-
{
|
|
87
|
-
chainId: 1,
|
|
88
|
-
contractAddress: '0x0123456789012345678901234567890123456789',
|
|
89
|
-
tokenId: '1'
|
|
90
|
-
}
|
|
91
|
-
],
|
|
92
|
-
{
|
|
93
|
-
// options param is optional and default values are below
|
|
94
|
-
disabled: false
|
|
95
|
-
}
|
|
96
|
-
)
|
|
97
|
-
```
|
|
98
|
-
|
|
99
|
-
### useGetExchangeRate
|
|
17
|
+
# Quickstart
|
|
100
18
|
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
### useGetTransactionHistory
|
|
111
|
-
|
|
112
|
-
```tsx
|
|
113
|
-
import { useGetTransactionHistory } from '@0xsequence/hooks'
|
|
114
|
-
|
|
115
|
-
const { data, isLoading, fetchNextPage, hasNextPage, isFetchingNextPage, error } = useGetTransactionHistory({
|
|
116
|
-
accountAddresses: ['0x0123456789012345678901234567890123456789'],
|
|
117
|
-
contractAddresses: ['0x0123456789012345678901234567890123456789'], // optional
|
|
118
|
-
tokenId: '1', // optional
|
|
119
|
-
chainId: 1, // optional
|
|
120
|
-
page: { // optional
|
|
121
|
-
pageSize: 10,
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
// options param is optional and default values are below
|
|
125
|
-
disabled: false,
|
|
126
|
-
}
|
|
127
|
-
})
|
|
19
|
+
1. Install the package:
|
|
20
|
+
```bash
|
|
21
|
+
npm install @0xsequence/hooks
|
|
22
|
+
# or
|
|
23
|
+
pnpm install @0xsequence/hooks
|
|
24
|
+
# or
|
|
25
|
+
yarn add @0xsequence/hooks
|
|
128
26
|
```
|
|
129
27
|
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
```tsx
|
|
133
|
-
import { useGetTransactionHistorySummary } from '@0xsequence/hooks'
|
|
134
|
-
|
|
135
|
-
const { data, isLoading, error } = useGetTransactionHistorySummary(
|
|
136
|
-
{
|
|
137
|
-
accountAddresses: ['0x0123456789012345678901234567890123456789'],
|
|
138
|
-
chainIds: [1]
|
|
139
|
-
},
|
|
140
|
-
{
|
|
141
|
-
// options param is optional and default values are below
|
|
142
|
-
disabled: false
|
|
143
|
-
}
|
|
144
|
-
)
|
|
145
|
-
```
|
|
28
|
+
2. Wrap your app with the SequenceHooksProvider.
|
|
146
29
|
|
|
147
|
-
|
|
30
|
+
```typescript [main.tsx]
|
|
31
|
+
import React from "react";
|
|
32
|
+
import ReactDOM from "react-dom/client";
|
|
33
|
+
import "./index.css";
|
|
148
34
|
|
|
149
|
-
|
|
150
|
-
import {
|
|
35
|
+
import App from "./App";
|
|
36
|
+
import { SequenceHooksProvider } from "@0xsequence/hooks";
|
|
151
37
|
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
{
|
|
159
|
-
// options param is optional and default values are below
|
|
160
|
-
disabled: false
|
|
161
|
-
}
|
|
162
|
-
)
|
|
163
|
-
```
|
|
164
|
-
|
|
165
|
-
### useGetTokenBalancesSummary
|
|
166
|
-
|
|
167
|
-
```tsx
|
|
168
|
-
import { ContractVerificationStatus } from '@0xsequence/indexer'
|
|
169
|
-
import { useGetTokenBalancesSummary } from '@0xsequence/hooks'
|
|
170
|
-
|
|
171
|
-
const { data, isLoading, fetchNextPage, hasNextPage, isFetchingNextPage, error } = useGetTokenBalancesSummary(
|
|
172
|
-
{
|
|
173
|
-
chainIds: [1], // either use chainIds or networks name
|
|
174
|
-
networks: ['mainnet'],
|
|
175
|
-
filter: {
|
|
176
|
-
accountAddresses: ['0x0123456789012345678901234567890123456789'],
|
|
177
|
-
contractWhitelist: ['0x0123456789012345678901234567890123456789'],
|
|
178
|
-
contractBlacklist: ['0x0000000000000000000000000000000000000000'],
|
|
179
|
-
contractStatus: ContractVerificationStatus.VERIFIED,
|
|
180
|
-
omitNativeBalances: false
|
|
181
|
-
},
|
|
182
|
-
omitMetadata: false, // optional
|
|
183
|
-
page: {
|
|
184
|
-
// optional
|
|
185
|
-
pageSize: 10
|
|
186
|
-
}
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
// options param is optional and default values are below
|
|
190
|
-
disabled: false
|
|
191
|
-
}
|
|
192
|
-
)
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### useGetTokenBalancesDetails
|
|
196
|
-
|
|
197
|
-
```tsx
|
|
198
|
-
import { ContractVerificationStatus } from '@0xsequence/indexer'
|
|
199
|
-
import { useGetTokenBalancesDetails } from '@0xsequence/hooks'
|
|
200
|
-
|
|
201
|
-
const { data, isLoading, fetchNextPage, hasNextPage, isFetchingNextPage, error } = useGetTokenBalancesDetails(
|
|
202
|
-
{
|
|
203
|
-
chainIds: [1], // either use chainIds or networks name
|
|
204
|
-
networks: ['mainnet'],
|
|
205
|
-
filter: {
|
|
206
|
-
accountAddresses: ['0x0123456789012345678901234567890123456789'],
|
|
207
|
-
contractWhitelist: ['0x0123456789012345678901234567890123456789'],
|
|
208
|
-
contractBlacklist: ['0x0000000000000000000000000000000000000000'],
|
|
209
|
-
contractStatus: ContractVerificationStatus.VERIFIED,
|
|
210
|
-
omitNativeBalances: false
|
|
211
|
-
},
|
|
212
|
-
omitMetadata: false, // optional
|
|
213
|
-
page: {
|
|
214
|
-
// optional
|
|
215
|
-
pageSize: 10
|
|
38
|
+
function Dapp() {
|
|
39
|
+
return (
|
|
40
|
+
<SequenceHooksProvider config={{ projectAccessKey: "AQAAAAAAAABtDHG1It7lxRF_9bbxw4diip8" }}>
|
|
41
|
+
<App />
|
|
42
|
+
</SequenceHooksProvider>
|
|
43
|
+
);
|
|
216
44
|
}
|
|
217
|
-
},
|
|
218
|
-
{
|
|
219
|
-
// options param is optional and default values are below
|
|
220
|
-
disabled: false
|
|
221
|
-
}
|
|
222
|
-
)
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### useGetTokenBalancesByContract
|
|
226
|
-
|
|
227
|
-
```tsx
|
|
228
|
-
import { ContractVerificationStatus } from '@0xsequence/indexer'
|
|
229
|
-
import { useGetTokenBalancesByContract } from '@0xsequence/hooks'
|
|
230
45
|
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
accountAddresses: ['0x0123456789012345678901234567890123456789'],
|
|
237
|
-
contractWhitelist: ['0x0123456789012345678901234567890123456789'],
|
|
238
|
-
contractBlacklist: ['0x0000000000000000000000000000000000000000'],
|
|
239
|
-
contractStatus: ContractVerificationStatus.VERIFIED,
|
|
240
|
-
omitNativeBalances: false
|
|
241
|
-
},
|
|
242
|
-
omitMetadata: false, // optional
|
|
243
|
-
page: {
|
|
244
|
-
// optional
|
|
245
|
-
pageSize: 10
|
|
246
|
-
}
|
|
247
|
-
},
|
|
248
|
-
{
|
|
249
|
-
// options param is optional and default values are below
|
|
250
|
-
disabled: false
|
|
251
|
-
}
|
|
252
|
-
)
|
|
46
|
+
ReactDOM.createRoot(document.getElementById("root")!).render(
|
|
47
|
+
<React.StrictMode>
|
|
48
|
+
<Dapp />
|
|
49
|
+
</React.StrictMode>
|
|
50
|
+
);
|
|
253
51
|
```
|
|
254
52
|
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
```tsx
|
|
258
|
-
import { useGetSingleTokenBalance } from '@0xsequence/hooks'
|
|
259
|
-
|
|
260
|
-
const { data, isLoading, error } = useGetSingleTokenBalance({
|
|
261
|
-
chainId: 1,
|
|
262
|
-
accountAddress: '0x9876543210987654321098765432109876543210',
|
|
263
|
-
contractAddress: '0x0123456789012345678901234567890123456789'
|
|
264
|
-
})
|
|
265
|
-
```
|
|
53
|
+
3. Start using the hooks in your app.
|
|
266
54
|
|
|
267
|
-
###
|
|
268
|
-
|
|
269
|
-
```tsx
|
|
270
|
-
import { useGetContractInfo } from '@0xsequence/hooks'
|
|
271
|
-
|
|
272
|
-
const { data, isLoading, error } = useGetContractInfo(
|
|
273
|
-
{
|
|
274
|
-
chainId: 1,
|
|
275
|
-
contractAddress: '0x0123456789012345678901234567890123456789'
|
|
276
|
-
},
|
|
277
|
-
{
|
|
278
|
-
// options param is optional and default values are below
|
|
279
|
-
disabled: false
|
|
280
|
-
}
|
|
281
|
-
)
|
|
282
|
-
```
|
|
283
|
-
|
|
284
|
-
### useGetMultipleContractInfo
|
|
285
|
-
|
|
286
|
-
```tsx
|
|
287
|
-
import { useGetMultipleContractInfo } from '@0xsequence/hooks'
|
|
288
|
-
|
|
289
|
-
const { data, isLoading, error } = useGetMultipleContractInfo(
|
|
290
|
-
[
|
|
291
|
-
{ chainId: 1, contractAddress: '0x0123456789012345678901234567890123456789' },
|
|
292
|
-
{ chainId: 1, contractAddress: '0x0123456789012345678901234567890123456789' }
|
|
293
|
-
],
|
|
294
|
-
{
|
|
295
|
-
// options param is optional and default values are below
|
|
296
|
-
disabled: false
|
|
297
|
-
}
|
|
298
|
-
)
|
|
299
|
-
```
|
|
300
|
-
|
|
301
|
-
### useGetTokenMetadata
|
|
302
|
-
|
|
303
|
-
```tsx
|
|
304
|
-
import { useGetTokenMetadata } from '@0xsequence/hooks'
|
|
305
|
-
|
|
306
|
-
const { data, isLoading, error } = useGetTokenMetadata(
|
|
307
|
-
{
|
|
308
|
-
chainId: '1',
|
|
309
|
-
contractAddress: '0x0123456789012345678901234567890123456789',
|
|
310
|
-
tokenIds: ['1']
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
// options param is optional and default values are below
|
|
314
|
-
disabled: false
|
|
315
|
-
}
|
|
316
|
-
)
|
|
317
|
-
```
|
|
318
|
-
|
|
319
|
-
### useGetSwapQuote
|
|
320
|
-
|
|
321
|
-
```tsx
|
|
322
|
-
import { useGetSwapQuote } from '@0xsequence/hooks'
|
|
323
|
-
|
|
324
|
-
const { data, isLoading, error } = useGetSwapQuote({
|
|
325
|
-
userAddress: '0x9876543210987654321098765432109876543210',
|
|
326
|
-
buyCurrencyAddress: '0x0123456789012345678901234567890123456789',
|
|
327
|
-
sellCurrencyAddress: '0x0123456789012345678901234567890123456789',
|
|
328
|
-
buyAmount: '1',
|
|
329
|
-
chainId: 1,
|
|
330
|
-
includeApprove: true,
|
|
331
|
-
slippagePercentage: 5 // optional
|
|
332
|
-
})
|
|
333
|
-
```
|
|
55
|
+
### For more information, please visit the [Hooks SDK documentation](https://docs.sequence.xyz/sdk/web/hooks-sdk/getting-started).
|
|
@@ -36,11 +36,11 @@ export interface GetTransactionHistorySummaryArgs {
|
|
|
36
36
|
* @example
|
|
37
37
|
* ```tsx
|
|
38
38
|
* import { useGetTransactionHistorySummary } from '@0xsequence/hooks'
|
|
39
|
-
* import {
|
|
39
|
+
* import { useConnection } from 'wagmi'
|
|
40
40
|
*
|
|
41
41
|
* // Basic usage in a component
|
|
42
42
|
* const TransactionHistory = () => {
|
|
43
|
-
* const { address: accountAddress } =
|
|
43
|
+
* const { address: accountAddress } = useConnection()
|
|
44
44
|
* const {
|
|
45
45
|
* data: transactionHistory = [],
|
|
46
46
|
* isLoading: isLoadingTransactionHistory
|
|
@@ -60,11 +60,11 @@ const getTransactionHistorySummary = async (indexerClients, { accountAddresses }
|
|
|
60
60
|
* @example
|
|
61
61
|
* ```tsx
|
|
62
62
|
* import { useGetTransactionHistorySummary } from '@0xsequence/hooks'
|
|
63
|
-
* import {
|
|
63
|
+
* import { useConnection } from 'wagmi'
|
|
64
64
|
*
|
|
65
65
|
* // Basic usage in a component
|
|
66
66
|
* const TransactionHistory = () => {
|
|
67
|
-
* const { address: accountAddress } =
|
|
67
|
+
* const { address: accountAddress } = useConnection()
|
|
68
68
|
* const {
|
|
69
69
|
* data: transactionHistory = [],
|
|
70
70
|
* isLoading: isLoadingTransactionHistory
|
|
@@ -23,7 +23,7 @@ import { ChainId } from '@0xsequence/network';
|
|
|
23
23
|
* const TokenBalanceChecker = () => {
|
|
24
24
|
* const chainId = useChainId()
|
|
25
25
|
* const indexerClient = useIndexerClient(chainId)
|
|
26
|
-
* const { address } =
|
|
26
|
+
* const { address } = useConnection()
|
|
27
27
|
*
|
|
28
28
|
* const checkBalance = async () => {
|
|
29
29
|
* // Get native token balance
|
|
@@ -30,7 +30,7 @@ const useNetwork_js_1 = require("../useNetwork.js");
|
|
|
30
30
|
* const TokenBalanceChecker = () => {
|
|
31
31
|
* const chainId = useChainId()
|
|
32
32
|
* const indexerClient = useIndexerClient(chainId)
|
|
33
|
-
* const { address } =
|
|
33
|
+
* const { address } = useConnection()
|
|
34
34
|
*
|
|
35
35
|
* const checkBalance = async () => {
|
|
36
36
|
* // Get native token balance
|
|
@@ -36,11 +36,11 @@ export interface GetTransactionHistorySummaryArgs {
|
|
|
36
36
|
* @example
|
|
37
37
|
* ```tsx
|
|
38
38
|
* import { useGetTransactionHistorySummary } from '@0xsequence/hooks'
|
|
39
|
-
* import {
|
|
39
|
+
* import { useConnection } from 'wagmi'
|
|
40
40
|
*
|
|
41
41
|
* // Basic usage in a component
|
|
42
42
|
* const TransactionHistory = () => {
|
|
43
|
-
* const { address: accountAddress } =
|
|
43
|
+
* const { address: accountAddress } = useConnection()
|
|
44
44
|
* const {
|
|
45
45
|
* data: transactionHistory = [],
|
|
46
46
|
* isLoading: isLoadingTransactionHistory
|
|
@@ -57,11 +57,11 @@ const getTransactionHistorySummary = async (indexerClients, { accountAddresses }
|
|
|
57
57
|
* @example
|
|
58
58
|
* ```tsx
|
|
59
59
|
* import { useGetTransactionHistorySummary } from '@0xsequence/hooks'
|
|
60
|
-
* import {
|
|
60
|
+
* import { useConnection } from 'wagmi'
|
|
61
61
|
*
|
|
62
62
|
* // Basic usage in a component
|
|
63
63
|
* const TransactionHistory = () => {
|
|
64
|
-
* const { address: accountAddress } =
|
|
64
|
+
* const { address: accountAddress } = useConnection()
|
|
65
65
|
* const {
|
|
66
66
|
* data: transactionHistory = [],
|
|
67
67
|
* isLoading: isLoadingTransactionHistory
|
|
@@ -23,7 +23,7 @@ import { ChainId } from '@0xsequence/network';
|
|
|
23
23
|
* const TokenBalanceChecker = () => {
|
|
24
24
|
* const chainId = useChainId()
|
|
25
25
|
* const indexerClient = useIndexerClient(chainId)
|
|
26
|
-
* const { address } =
|
|
26
|
+
* const { address } = useConnection()
|
|
27
27
|
*
|
|
28
28
|
* const checkBalance = async () => {
|
|
29
29
|
* // Get native token balance
|
|
@@ -27,7 +27,7 @@ import { useNetwork } from '../useNetwork.js';
|
|
|
27
27
|
* const TokenBalanceChecker = () => {
|
|
28
28
|
* const chainId = useChainId()
|
|
29
29
|
* const indexerClient = useIndexerClient(chainId)
|
|
30
|
-
* const { address } =
|
|
30
|
+
* const { address } = useConnection()
|
|
31
31
|
*
|
|
32
32
|
* const checkBalance = async () => {
|
|
33
33
|
* // Get native token balance
|
package/package.json
CHANGED