@0xslots/sdk 0.2.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 +200 -0
- package/dist/index.d.ts +2166 -0
- package/dist/index.js +449 -0
- package/dist/index.js.map +1 -0
- package/package.json +43 -0
package/README.md
ADDED
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
# @0xslots/sdk
|
|
2
|
+
|
|
3
|
+
Type-safe SDK for querying 0xSlots subgraph data with full TypeScript support.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- 🔒 **Fully typed** - Generated from GraphQL schema with complete type safety
|
|
8
|
+
- 🚀 **Chain support** - Easy chain selection (Base Sepolia, more coming)
|
|
9
|
+
- 📦 **Tree-shakeable** - ESM exports with optimized bundle size
|
|
10
|
+
- 🎯 **Easy to use** - Simple, intuitive API
|
|
11
|
+
|
|
12
|
+
## Installation
|
|
13
|
+
|
|
14
|
+
```bash
|
|
15
|
+
npm install @0xslots/sdk
|
|
16
|
+
# or
|
|
17
|
+
pnpm add @0xslots/sdk
|
|
18
|
+
# or
|
|
19
|
+
yarn add @0xslots/sdk
|
|
20
|
+
```
|
|
21
|
+
|
|
22
|
+
## Quick Start
|
|
23
|
+
|
|
24
|
+
```typescript
|
|
25
|
+
import { createSlotsClient, SlotsChain } from '@0xslots/sdk';
|
|
26
|
+
|
|
27
|
+
// Create a client for Base Sepolia
|
|
28
|
+
const client = createSlotsClient({
|
|
29
|
+
chainId: SlotsChain.BASE_SEPOLIA,
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
// Query the hub
|
|
33
|
+
const hub = await client.getHub({
|
|
34
|
+
id: '0x268cfaB9ddDdF6A326458Ae79d55592516f382eF',
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
console.log('Hub slot price:', hub.hub?.slotPrice);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## Usage Examples
|
|
41
|
+
|
|
42
|
+
### Query Lands
|
|
43
|
+
|
|
44
|
+
```typescript
|
|
45
|
+
// Get all lands
|
|
46
|
+
const { lands } = await client.getLands({
|
|
47
|
+
first: 10,
|
|
48
|
+
orderBy: 'createdAt',
|
|
49
|
+
orderDirection: 'desc',
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
// Get lands by owner
|
|
53
|
+
const { lands: myLands } = await client.getLandsByOwner({
|
|
54
|
+
owner: '0x...',
|
|
55
|
+
first: 100,
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Get a specific land with slots
|
|
59
|
+
const { land } = await client.getLand({
|
|
60
|
+
id: '0x...',
|
|
61
|
+
});
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
### Query Slots
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
// Get all active slots
|
|
68
|
+
const { slots } = await client.getSlots({
|
|
69
|
+
where: { active: true },
|
|
70
|
+
first: 50,
|
|
71
|
+
orderBy: 'price',
|
|
72
|
+
orderDirection: 'asc',
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
// Get available (vacant) slots
|
|
76
|
+
const { slots: available } = await client.getAvailableSlots({
|
|
77
|
+
first: 20,
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
// Get slots owned by an address
|
|
81
|
+
const { slots: mySlots } = await client.getSlotsByOccupant({
|
|
82
|
+
occupant: '0x...',
|
|
83
|
+
});
|
|
84
|
+
|
|
85
|
+
// Get slot details with history
|
|
86
|
+
const { slot } = await client.getSlot({
|
|
87
|
+
id: '0x...-0',
|
|
88
|
+
});
|
|
89
|
+
|
|
90
|
+
console.log('Price history:', slot?.priceHistory);
|
|
91
|
+
console.log('Tax updates:', slot?.taxUpdates);
|
|
92
|
+
```
|
|
93
|
+
|
|
94
|
+
### Query Events
|
|
95
|
+
|
|
96
|
+
```typescript
|
|
97
|
+
// Get recent slot purchases
|
|
98
|
+
const { slotPurchases } = await client.getSlotPurchases({
|
|
99
|
+
first: 50,
|
|
100
|
+
orderBy: 'timestamp',
|
|
101
|
+
orderDirection: 'desc',
|
|
102
|
+
});
|
|
103
|
+
|
|
104
|
+
// Get land creation events
|
|
105
|
+
const { landOpenedEvents } = await client.getLandOpenedEvents({
|
|
106
|
+
first: 10,
|
|
107
|
+
orderBy: 'timestamp',
|
|
108
|
+
orderDirection: 'desc',
|
|
109
|
+
});
|
|
110
|
+
|
|
111
|
+
// Get flow changes (Superfluid streams)
|
|
112
|
+
const { flowChanges } = await client.getFlowChanges({
|
|
113
|
+
where: { from: '0x...' },
|
|
114
|
+
first: 100,
|
|
115
|
+
});
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Advanced Usage
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
// Use custom subgraph URL
|
|
122
|
+
const client = createSlotsClient({
|
|
123
|
+
chainId: SlotsChain.BASE_SEPOLIA,
|
|
124
|
+
subgraphUrl: 'https://your-custom-endpoint.com/graphql',
|
|
125
|
+
});
|
|
126
|
+
|
|
127
|
+
// Access the underlying SDK for more control
|
|
128
|
+
const sdk = client.getSdk();
|
|
129
|
+
|
|
130
|
+
// Access the GraphQL client directly
|
|
131
|
+
const graphqlClient = client.getClient();
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
## Supported Chains
|
|
135
|
+
|
|
136
|
+
| Chain | Chain ID | Status |
|
|
137
|
+
|-------|----------|--------|
|
|
138
|
+
| Base Sepolia | 84532 | ✅ Live |
|
|
139
|
+
|
|
140
|
+
More chains coming soon!
|
|
141
|
+
|
|
142
|
+
## Type Safety
|
|
143
|
+
|
|
144
|
+
All queries return fully typed responses:
|
|
145
|
+
|
|
146
|
+
```typescript
|
|
147
|
+
import type { GetSlotQuery, Slot } from '@0xslots/sdk';
|
|
148
|
+
|
|
149
|
+
// Response types are automatically inferred
|
|
150
|
+
const response: GetSlotQuery = await client.getSlot({ id: '0x...' });
|
|
151
|
+
|
|
152
|
+
// Extract specific types
|
|
153
|
+
const slot: Slot | null = response.slot;
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
## API Reference
|
|
157
|
+
|
|
158
|
+
### SlotsClient
|
|
159
|
+
|
|
160
|
+
#### Hub Queries
|
|
161
|
+
- `getHub(params)` - Get hub configuration
|
|
162
|
+
- `getAllowedModules(params)` - Get allowed modules
|
|
163
|
+
- `getAllowedCurrencies(params)` - Get allowed currencies
|
|
164
|
+
|
|
165
|
+
#### Land Queries
|
|
166
|
+
- `getLands(params)` - Get all lands with pagination
|
|
167
|
+
- `getLand(params)` - Get a specific land by ID
|
|
168
|
+
- `getLandsByOwner(params)` - Get lands owned by an address
|
|
169
|
+
|
|
170
|
+
#### Slot Queries
|
|
171
|
+
- `getSlots(params)` - Get all slots with filters
|
|
172
|
+
- `getSlot(params)` - Get a specific slot with history
|
|
173
|
+
- `getSlotsByOccupant(params)` - Get slots held by an address
|
|
174
|
+
- `getAvailableSlots(params)` - Get vacant slots
|
|
175
|
+
|
|
176
|
+
#### Event Queries
|
|
177
|
+
- `getSlotPurchases(params)` - Get slot purchase events
|
|
178
|
+
- `getLandOpenedEvents(params)` - Get land creation events
|
|
179
|
+
- `getSlotCreatedEvents(params)` - Get slot creation events
|
|
180
|
+
- `getFlowChanges(params)` - Get Superfluid flow changes
|
|
181
|
+
|
|
182
|
+
## Development
|
|
183
|
+
|
|
184
|
+
```bash
|
|
185
|
+
# Install dependencies
|
|
186
|
+
pnpm install
|
|
187
|
+
|
|
188
|
+
# Generate types from GraphQL schema
|
|
189
|
+
pnpm codegen
|
|
190
|
+
|
|
191
|
+
# Build the SDK
|
|
192
|
+
pnpm build
|
|
193
|
+
|
|
194
|
+
# Watch mode for development
|
|
195
|
+
pnpm dev
|
|
196
|
+
```
|
|
197
|
+
|
|
198
|
+
## License
|
|
199
|
+
|
|
200
|
+
MIT
|