@kleo-protocol/kleo-sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +269 -0
- package/dist/src/client.d.ts +36 -0
- package/dist/src/client.d.ts.map +1 -0
- package/dist/src/client.js +156 -0
- package/dist/src/client.js.map +1 -0
- package/dist/src/dedot.client.d.ts +11 -0
- package/dist/src/dedot.client.d.ts.map +1 -0
- package/dist/src/dedot.client.js +28 -0
- package/dist/src/dedot.client.js.map +1 -0
- package/dist/src/index.d.ts +7 -0
- package/dist/src/index.d.ts.map +1 -0
- package/dist/src/index.js +25 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/interfaces/backed-position.d.ts +8 -0
- package/dist/src/interfaces/backed-position.d.ts.map +1 -0
- package/dist/src/interfaces/backed-position.js +3 -0
- package/dist/src/interfaces/backed-position.js.map +1 -0
- package/dist/src/interfaces/borrower-info.d.ts +11 -0
- package/dist/src/interfaces/borrower-info.d.ts.map +1 -0
- package/dist/src/interfaces/borrower-info.js +3 -0
- package/dist/src/interfaces/borrower-info.js.map +1 -0
- package/dist/src/interfaces/index.d.ts +5 -0
- package/dist/src/interfaces/index.d.ts.map +1 -0
- package/dist/src/interfaces/index.js +21 -0
- package/dist/src/interfaces/index.js.map +1 -0
- package/dist/src/interfaces/loan.d.ts +5 -0
- package/dist/src/interfaces/loan.d.ts.map +1 -0
- package/dist/src/interfaces/loan.js +3 -0
- package/dist/src/interfaces/loan.js.map +1 -0
- package/dist/src/interfaces/vouch-info.d.ts +8 -0
- package/dist/src/interfaces/vouch-info.d.ts.map +1 -0
- package/dist/src/interfaces/vouch-info.js +3 -0
- package/dist/src/interfaces/vouch-info.js.map +1 -0
- package/dist/src/services/index.d.ts +6 -0
- package/dist/src/services/index.d.ts.map +1 -0
- package/dist/src/services/index.js +22 -0
- package/dist/src/services/index.js.map +1 -0
- package/dist/src/services/lending.service.d.ts +5 -0
- package/dist/src/services/lending.service.d.ts.map +1 -0
- package/dist/src/services/lending.service.js +26 -0
- package/dist/src/services/lending.service.js.map +1 -0
- package/dist/src/services/pool.service.d.ts +19 -0
- package/dist/src/services/pool.service.d.ts.map +1 -0
- package/dist/src/services/pool.service.js +63 -0
- package/dist/src/services/pool.service.js.map +1 -0
- package/dist/src/services/profile.service.d.ts +5 -0
- package/dist/src/services/profile.service.d.ts.map +1 -0
- package/dist/src/services/profile.service.js +25 -0
- package/dist/src/services/profile.service.js.map +1 -0
- package/dist/src/services/reputation.service.d.ts +13 -0
- package/dist/src/services/reputation.service.d.ts.map +1 -0
- package/dist/src/services/reputation.service.js +97 -0
- package/dist/src/services/reputation.service.js.map +1 -0
- package/dist/src/services/vouch.service.d.ts +7 -0
- package/dist/src/services/vouch.service.d.ts.map +1 -0
- package/dist/src/services/vouch.service.js +74 -0
- package/dist/src/services/vouch.service.js.map +1 -0
- package/dist/src/supabase.client.d.ts +3 -0
- package/dist/src/supabase.client.d.ts.map +1 -0
- package/dist/src/supabase.client.js +6 -0
- package/dist/src/supabase.client.js.map +1 -0
- package/dist/src/types.d.ts +19 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +3 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/contract-helpers.d.ts +24 -0
- package/dist/src/utils/contract-helpers.d.ts.map +1 -0
- package/dist/src/utils/contract-helpers.js +20 -0
- package/dist/src/utils/contract-helpers.js.map +1 -0
- package/dist/src/utils/index.d.ts +2 -0
- package/dist/src/utils/index.d.ts.map +1 -0
- package/dist/src/utils/index.js +18 -0
- package/dist/src/utils/index.js.map +1 -0
- package/dist/types/types.d.ts +19 -0
- package/dist/types/types.d.ts.map +1 -0
- package/dist/types/types.js +3 -0
- package/dist/types/types.js.map +1 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Kleo Protocol
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
# Kleo SDK
|
|
2
|
+
|
|
3
|
+
A TypeScript SDK for interacting with the Kleo Protocol on Polkadot Asset Hub. This SDK provides a unified interface for managing lending pools, reputation systems, and vouch relationships.
|
|
4
|
+
|
|
5
|
+
## Features
|
|
6
|
+
|
|
7
|
+
- **Blockchain Integration** - Connect to Polkadot Asset Hub via WebSocket
|
|
8
|
+
- **Lending Pool Management** - Query pool states and user deposits
|
|
9
|
+
- **Reputation System** - Track lender exposure and borrower reputation
|
|
10
|
+
- **Vouch System** - Manage vouch relationships between users
|
|
11
|
+
- **Profile Management** - Create and update user profiles
|
|
12
|
+
- **Supabase Integration** - Hybrid on-chain/off-chain data fetching
|
|
13
|
+
|
|
14
|
+
## Installation
|
|
15
|
+
|
|
16
|
+
```bash
|
|
17
|
+
npm install @kleo-protocol/kleo-sdk
|
|
18
|
+
```
|
|
19
|
+
|
|
20
|
+
## Quick Start
|
|
21
|
+
|
|
22
|
+
```typescript
|
|
23
|
+
import { KleoClient } from '@kleo-protocol/kleo-sdk';
|
|
24
|
+
|
|
25
|
+
// Import contract metadata (generated from your contracts)
|
|
26
|
+
import configMetadata from './metadata/config.json';
|
|
27
|
+
import lendingPoolMetadata from './metadata/lending-pool.json';
|
|
28
|
+
import reputationMetadata from './metadata/reputation.json';
|
|
29
|
+
import vouchMetadata from './metadata/vouch.json';
|
|
30
|
+
|
|
31
|
+
// Initialize the client
|
|
32
|
+
const client = new KleoClient(
|
|
33
|
+
{
|
|
34
|
+
endpoint: 'wss://polkadot-asset-hub-rpc.polkadot.io', // Optional, this is the default
|
|
35
|
+
timeout: 30000, // Optional, default is 30000ms
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
config: configMetadata,
|
|
39
|
+
lendingPool: lendingPoolMetadata,
|
|
40
|
+
reputation: reputationMetadata,
|
|
41
|
+
vouch: vouchMetadata,
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
|
|
45
|
+
// Use the client
|
|
46
|
+
async function main() {
|
|
47
|
+
try {
|
|
48
|
+
// Get all pools
|
|
49
|
+
const pools = await client.getPools();
|
|
50
|
+
console.log('Available pools:', pools);
|
|
51
|
+
|
|
52
|
+
// Get user deposit in a pool
|
|
53
|
+
const deposit = await client.getUserDeposit('pool-id', 'user-address');
|
|
54
|
+
console.log('User deposit:', deposit);
|
|
55
|
+
|
|
56
|
+
// Get borrower information
|
|
57
|
+
const borrowerInfo = await client.getBorrowerInfo('pool-id', 'borrower-address');
|
|
58
|
+
console.log('Borrower info:', borrowerInfo);
|
|
59
|
+
|
|
60
|
+
// Disconnect when done
|
|
61
|
+
await client.disconnect();
|
|
62
|
+
} catch (error) {
|
|
63
|
+
console.error('Error:', error);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Configuration Options
|
|
69
|
+
|
|
70
|
+
| Option | Type | Default | Description |
|
|
71
|
+
|--------|------|---------|-------------|
|
|
72
|
+
| `endpoint` | `string` | `wss://polkadot-asset-hub-rpc.polkadot.io` | WebSocket endpoint for blockchain connection |
|
|
73
|
+
| `timeout` | `number` | `30000` | Request timeout in milliseconds |
|
|
74
|
+
|
|
75
|
+
## API Reference
|
|
76
|
+
|
|
77
|
+
### Pool Methods
|
|
78
|
+
|
|
79
|
+
| Method | Description |
|
|
80
|
+
|--------|-------------|
|
|
81
|
+
| `getPools()` | Get all available lending pools |
|
|
82
|
+
| `getPool(poolId)` | Get a specific pool by ID |
|
|
83
|
+
| `getPoolState(poolId, defaultCaller?)` | Get the current state of a pool |
|
|
84
|
+
|
|
85
|
+
### Profile Methods
|
|
86
|
+
|
|
87
|
+
| Method | Description |
|
|
88
|
+
|--------|-------------|
|
|
89
|
+
| `getProfile(userAddress)` | Get a user's profile |
|
|
90
|
+
| `insertProfile(userAddress, name)` | Create a new user profile |
|
|
91
|
+
| `updateProfile(userAddress, name)` | Update an existing profile |
|
|
92
|
+
|
|
93
|
+
### Lending Methods
|
|
94
|
+
|
|
95
|
+
| Method | Description |
|
|
96
|
+
|--------|-------------|
|
|
97
|
+
| `getUserDeposit(poolId, userAddress)` | Get a user's deposit amount in a pool |
|
|
98
|
+
|
|
99
|
+
### Reputation Methods
|
|
100
|
+
|
|
101
|
+
| Method | Description |
|
|
102
|
+
|--------|-------------|
|
|
103
|
+
| `getLenderExposure(poolId, userAddress)` | Get lender's reputation exposure (stars) |
|
|
104
|
+
| `getBorrowerInfo(poolId, userAddress)` | Get comprehensive borrower information |
|
|
105
|
+
| `getUserLoans(poolId, userAddress)` | Get a user's loan history |
|
|
106
|
+
|
|
107
|
+
### Vouch Methods
|
|
108
|
+
|
|
109
|
+
| Method | Description |
|
|
110
|
+
|--------|-------------|
|
|
111
|
+
| `getVouchRelationship(poolId, voucherAddress, borrowerAddress)` | Get a specific vouch relationship |
|
|
112
|
+
| `getBorrowerVouches(poolId, borrowerAddress)` | Get all vouches for a borrower |
|
|
113
|
+
|
|
114
|
+
### Connection Methods
|
|
115
|
+
|
|
116
|
+
| Method | Description |
|
|
117
|
+
|--------|-------------|
|
|
118
|
+
| `connect()` | Connect to the blockchain |
|
|
119
|
+
| `disconnect()` | Disconnect from the blockchain |
|
|
120
|
+
| `getDedotClient()` | Get the underlying Dedot client |
|
|
121
|
+
| `getSupabaseClient()` | Get the underlying Supabase client |
|
|
122
|
+
| `ensureAccountMapped(caller)` | Ensure account is mapped on-chain |
|
|
123
|
+
|
|
124
|
+
## Interfaces
|
|
125
|
+
|
|
126
|
+
### BackedPosition
|
|
127
|
+
|
|
128
|
+
```typescript
|
|
129
|
+
interface BackedPosition {
|
|
130
|
+
borrower: string;
|
|
131
|
+
stakedStars: number;
|
|
132
|
+
stakedCapital: string;
|
|
133
|
+
createdAt: string;
|
|
134
|
+
status: 'Active' | 'Fulfilled' | 'Defaulted';
|
|
135
|
+
}
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
### BorrowerInfo
|
|
139
|
+
|
|
140
|
+
```typescript
|
|
141
|
+
interface BorrowerInfo {
|
|
142
|
+
stars: number;
|
|
143
|
+
starsAtStake: number;
|
|
144
|
+
canVouch: boolean;
|
|
145
|
+
banned: boolean;
|
|
146
|
+
creationTime: string;
|
|
147
|
+
loanHistoryCount: number;
|
|
148
|
+
vouchHistoryCount: number;
|
|
149
|
+
totalExposure: string;
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### VouchInfo
|
|
154
|
+
|
|
155
|
+
```typescript
|
|
156
|
+
interface VouchInfo {
|
|
157
|
+
voucher: string;
|
|
158
|
+
stakedStars: number;
|
|
159
|
+
stakedCapital: string;
|
|
160
|
+
createdAt: string;
|
|
161
|
+
status: 'Active' | 'Fulfilled' | 'Defaulted';
|
|
162
|
+
}
|
|
163
|
+
```
|
|
164
|
+
|
|
165
|
+
### Loan
|
|
166
|
+
|
|
167
|
+
```typescript
|
|
168
|
+
interface Loan {
|
|
169
|
+
amount: string;
|
|
170
|
+
repaid: boolean;
|
|
171
|
+
}
|
|
172
|
+
```
|
|
173
|
+
|
|
174
|
+
## Project Structure
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
kleo-sdk/
|
|
178
|
+
├── src/
|
|
179
|
+
│ ├── index.ts # Main entry point
|
|
180
|
+
│ ├── client.ts # KleoClient implementation
|
|
181
|
+
│ ├── dedot.client.ts # Dedot blockchain client
|
|
182
|
+
│ ├── supabase.client.ts # Supabase client
|
|
183
|
+
│ ├── types.ts # TypeScript type definitions
|
|
184
|
+
│ ├── interfaces/ # Data interfaces
|
|
185
|
+
│ │ ├── backed-position.ts
|
|
186
|
+
│ │ ├── borrower-info.ts
|
|
187
|
+
│ │ ├── loan.ts
|
|
188
|
+
│ │ └── vouch-info.ts
|
|
189
|
+
│ ├── services/ # Service modules
|
|
190
|
+
│ │ ├── lending.service.ts
|
|
191
|
+
│ │ ├── pool.service.ts
|
|
192
|
+
│ │ ├── profile.service.ts
|
|
193
|
+
│ │ ├── reputation.service.ts
|
|
194
|
+
│ │ └── vouch.service.ts
|
|
195
|
+
│ └── utils/ # Utility functions
|
|
196
|
+
│ └── contract-helpers.ts
|
|
197
|
+
├── types/ # Contract type definitions
|
|
198
|
+
│ ├── config/
|
|
199
|
+
│ ├── lending-pool/
|
|
200
|
+
│ ├── loan-manager/
|
|
201
|
+
│ ├── reputation/
|
|
202
|
+
│ └── vouch/
|
|
203
|
+
├── dist/ # Compiled output (generated)
|
|
204
|
+
├── package.json
|
|
205
|
+
├── tsconfig.json
|
|
206
|
+
└── README.md
|
|
207
|
+
```
|
|
208
|
+
|
|
209
|
+
## Development
|
|
210
|
+
|
|
211
|
+
### Prerequisites
|
|
212
|
+
|
|
213
|
+
- Node.js >= 16.0.0
|
|
214
|
+
- npm or yarn
|
|
215
|
+
|
|
216
|
+
### Setup
|
|
217
|
+
|
|
218
|
+
1. **Install dependencies:**
|
|
219
|
+
```bash
|
|
220
|
+
npm install
|
|
221
|
+
```
|
|
222
|
+
|
|
223
|
+
2. **Build the project:**
|
|
224
|
+
```bash
|
|
225
|
+
npm run build
|
|
226
|
+
```
|
|
227
|
+
|
|
228
|
+
3. **Watch mode for development:**
|
|
229
|
+
```bash
|
|
230
|
+
npm run build:watch
|
|
231
|
+
```
|
|
232
|
+
|
|
233
|
+
### Scripts
|
|
234
|
+
|
|
235
|
+
| Script | Description |
|
|
236
|
+
|--------|-------------|
|
|
237
|
+
| `npm run build` | Compile TypeScript to JavaScript |
|
|
238
|
+
| `npm run build:watch` | Watch mode for development |
|
|
239
|
+
| `npm run clean` | Remove build artifacts |
|
|
240
|
+
| `npm run lint` | Run ESLint |
|
|
241
|
+
| `npm run format` | Format code with Prettier |
|
|
242
|
+
| `npm test` | Run tests |
|
|
243
|
+
|
|
244
|
+
### Building
|
|
245
|
+
|
|
246
|
+
```bash
|
|
247
|
+
npm run build
|
|
248
|
+
```
|
|
249
|
+
|
|
250
|
+
### Linting
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
npm run lint
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Formatting
|
|
257
|
+
|
|
258
|
+
```bash
|
|
259
|
+
npm run format
|
|
260
|
+
```
|
|
261
|
+
|
|
262
|
+
## Dependencies
|
|
263
|
+
|
|
264
|
+
- **[dedot](https://github.com/nicolo-ribaudo/dedot)** - Polkadot.js alternative for blockchain interaction
|
|
265
|
+
- **[@supabase/supabase-js](https://supabase.com/docs/reference/javascript)** - Supabase client for off-chain data
|
|
266
|
+
|
|
267
|
+
## License
|
|
268
|
+
|
|
269
|
+
MIT
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { DedotClient } from 'dedot';
|
|
2
|
+
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
3
|
+
import { SupabaseClient } from '@supabase/supabase-js';
|
|
4
|
+
import { KleoConfig } from '../types/types';
|
|
5
|
+
import { ensureAccountMapped } from './dedot.client';
|
|
6
|
+
import { ReputationUserReputation } from '../types/reputation/index.js';
|
|
7
|
+
import { ContractMetadata } from './utils/contract-helpers';
|
|
8
|
+
import { BackedPosition, VouchInfo, BorrowerInfo, Loan } from './interfaces';
|
|
9
|
+
export { BackedPosition, VouchInfo, BorrowerInfo, Loan } from './interfaces';
|
|
10
|
+
import * as PoolService from './services/pool.service';
|
|
11
|
+
export { PoolState } from './services/pool.service';
|
|
12
|
+
export declare class KleoClient {
|
|
13
|
+
private dedotClient;
|
|
14
|
+
private supabaseClient;
|
|
15
|
+
private config;
|
|
16
|
+
private metadata;
|
|
17
|
+
constructor(config?: KleoConfig, metadata?: ContractMetadata);
|
|
18
|
+
connect(): Promise<DedotClient<PolkadotApi>>;
|
|
19
|
+
getDedotClient(): DedotClient<PolkadotApi> | null;
|
|
20
|
+
getSupabaseClient(): SupabaseClient | null;
|
|
21
|
+
ensureAccountMapped(caller: Parameters<typeof ensureAccountMapped>[1]): Promise<boolean>;
|
|
22
|
+
disconnect(): Promise<void>;
|
|
23
|
+
getPools(): Promise<any[]>;
|
|
24
|
+
getPool(poolId: string): Promise<any[]>;
|
|
25
|
+
getPoolState(poolId: string, defaultCaller?: string): Promise<PoolService.PoolState>;
|
|
26
|
+
getProfile(userAddress: string): Promise<any[]>;
|
|
27
|
+
insertProfile(userAddress: string, name: string): Promise<void>;
|
|
28
|
+
updateProfile(userAddress: string, name: string): Promise<void>;
|
|
29
|
+
getUserDeposit(poolId: string, userAddress: string): Promise<string | undefined>;
|
|
30
|
+
getLenderExposure(poolId: string, userAddress: string): Promise<ReputationUserReputation | undefined>;
|
|
31
|
+
getBorrowerInfo(poolId: string, userAddress: string): Promise<BorrowerInfo | undefined>;
|
|
32
|
+
getUserLoans(poolId: string, userAddress: string): Promise<Loan[]>;
|
|
33
|
+
getVouchRelationship(poolId: string, voucherAddress: string, borrowerAddress: string): Promise<BackedPosition | undefined>;
|
|
34
|
+
getBorrowerVouches(poolId: string, borrowerAddress: string): Promise<VouchInfo[]>;
|
|
35
|
+
}
|
|
36
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,MAAM,OAAO,CAAC;AACpC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAC;AAC5C,OAAO,EAAqB,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EAAE,wBAAwB,EAAE,MAAM,8BAA8B,CAAC;AACxE,OAAO,EAAE,gBAAgB,EAAE,MAAM,0BAA0B,CAAC;AAC5D,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,EAAE,cAAc,EAAE,SAAS,EAAE,YAAY,EAAE,IAAI,EAAE,MAAM,cAAc,CAAC;AAG7E,OAAO,KAAK,WAAW,MAAM,yBAAyB,CAAC;AAOvD,OAAO,EAAE,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAKpD,qBAAa,UAAU;IACrB,OAAO,CAAC,WAAW,CAAyC;IAC5D,OAAO,CAAC,cAAc,CAA6B;IACnD,OAAO,CAAC,MAAM,CAAwC;IACtD,OAAO,CAAC,QAAQ,CAAmB;gBAOvB,MAAM,GAAE,UAAe,EAAE,QAAQ,CAAC,EAAE,gBAAgB;IAkB1D,OAAO,IAAI,OAAO,CAAC,WAAW,CAAC,WAAW,CAAC,CAAC;IAUlD,cAAc,IAAI,WAAW,CAAC,WAAW,CAAC,GAAG,I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C;IAehC,kBAAkB,CACtB,MAAM,EAAE,MAAM,EACd,eAAe,EAAE,MAAM,GACtB,OAAO,CAAC,SAAS,EAAE,CAAC;CAaxB"}
|
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
+
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
+
}) : function(o, v) {
|
|
16
|
+
o["default"] = v;
|
|
17
|
+
});
|
|
18
|
+
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
+
var ownKeys = function(o) {
|
|
20
|
+
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
+
var ar = [];
|
|
22
|
+
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
+
return ar;
|
|
24
|
+
};
|
|
25
|
+
return ownKeys(o);
|
|
26
|
+
};
|
|
27
|
+
return function (mod) {
|
|
28
|
+
if (mod && mod.__esModule) return mod;
|
|
29
|
+
var result = {};
|
|
30
|
+
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
+
__setModuleDefault(result, mod);
|
|
32
|
+
return result;
|
|
33
|
+
};
|
|
34
|
+
})();
|
|
35
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
+
};
|
|
38
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
+
exports.KleoClient = void 0;
|
|
40
|
+
const dedot_client_1 = require("./dedot.client");
|
|
41
|
+
const supabase_client_1 = __importDefault(require("./supabase.client"));
|
|
42
|
+
const PoolService = __importStar(require("./services/pool.service"));
|
|
43
|
+
const ProfileService = __importStar(require("./services/profile.service"));
|
|
44
|
+
const LendingService = __importStar(require("./services/lending.service"));
|
|
45
|
+
const VouchService = __importStar(require("./services/vouch.service"));
|
|
46
|
+
const ReputationService = __importStar(require("./services/reputation.service"));
|
|
47
|
+
class KleoClient {
|
|
48
|
+
constructor(config = {}, metadata) {
|
|
49
|
+
this.dedotClient = null;
|
|
50
|
+
this.supabaseClient = supabase_client_1.default;
|
|
51
|
+
this.config = {
|
|
52
|
+
endpoint: config.endpoint || 'wss://polkadot-asset-hub-rpc.polkadot.io',
|
|
53
|
+
timeout: config.timeout || 30000,
|
|
54
|
+
};
|
|
55
|
+
this.metadata = {
|
|
56
|
+
config: metadata?.config,
|
|
57
|
+
lendingPool: metadata?.lendingPool,
|
|
58
|
+
reputation: metadata?.reputation,
|
|
59
|
+
vouch: metadata?.vouch,
|
|
60
|
+
};
|
|
61
|
+
this.connect();
|
|
62
|
+
this.supabaseClient = supabase_client_1.default;
|
|
63
|
+
}
|
|
64
|
+
async connect() {
|
|
65
|
+
if (!this.dedotClient) {
|
|
66
|
+
this.dedotClient = await (0, dedot_client_1.createDedotClient)(this.config.endpoint);
|
|
67
|
+
}
|
|
68
|
+
return this.dedotClient;
|
|
69
|
+
}
|
|
70
|
+
getDedotClient() {
|
|
71
|
+
return this.dedotClient;
|
|
72
|
+
}
|
|
73
|
+
getSupabaseClient() {
|
|
74
|
+
return this.supabaseClient;
|
|
75
|
+
}
|
|
76
|
+
async ensureAccountMapped(caller) {
|
|
77
|
+
const client = await this.connect();
|
|
78
|
+
return (0, dedot_client_1.ensureAccountMapped)(client, caller);
|
|
79
|
+
}
|
|
80
|
+
async disconnect() {
|
|
81
|
+
if (this.dedotClient) {
|
|
82
|
+
await this.dedotClient.disconnect();
|
|
83
|
+
this.dedotClient = null;
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
async getPools() {
|
|
87
|
+
return PoolService.getPools(this.supabaseClient);
|
|
88
|
+
}
|
|
89
|
+
async getPool(poolId) {
|
|
90
|
+
return PoolService.getPool(this.supabaseClient, poolId);
|
|
91
|
+
}
|
|
92
|
+
async getPoolState(poolId, defaultCaller) {
|
|
93
|
+
if (!this.metadata.config) {
|
|
94
|
+
throw new Error('Config metadata not provided. Pass it to the KleoClient constructor.');
|
|
95
|
+
}
|
|
96
|
+
const client = await this.connect();
|
|
97
|
+
return PoolService.getPoolState(this.supabaseClient, client, this.metadata.config, poolId, defaultCaller);
|
|
98
|
+
}
|
|
99
|
+
async getProfile(userAddress) {
|
|
100
|
+
return ProfileService.getProfile(this.supabaseClient, userAddress);
|
|
101
|
+
}
|
|
102
|
+
async insertProfile(userAddress, name) {
|
|
103
|
+
return ProfileService.insertProfile(this.supabaseClient, userAddress, name);
|
|
104
|
+
}
|
|
105
|
+
async updateProfile(userAddress, name) {
|
|
106
|
+
return ProfileService.updateProfile(this.supabaseClient, userAddress, name);
|
|
107
|
+
}
|
|
108
|
+
async getUserDeposit(poolId, userAddress) {
|
|
109
|
+
if (!this.metadata.lendingPool) {
|
|
110
|
+
throw new Error('LendingPool metadata not provided. Pass it to the KleoClient constructor.');
|
|
111
|
+
}
|
|
112
|
+
const client = await this.connect();
|
|
113
|
+
return LendingService.getUserDeposit(this.supabaseClient, client, this.metadata.lendingPool, poolId, userAddress);
|
|
114
|
+
}
|
|
115
|
+
async getLenderExposure(poolId, userAddress) {
|
|
116
|
+
if (!this.metadata.reputation) {
|
|
117
|
+
throw new Error('Reputation metadata not provided. Pass it to the KleoClient constructor.');
|
|
118
|
+
}
|
|
119
|
+
const client = await this.connect();
|
|
120
|
+
return ReputationService.getLenderExposure(this.supabaseClient, client, this.metadata.reputation, poolId, userAddress);
|
|
121
|
+
}
|
|
122
|
+
async getBorrowerInfo(poolId, userAddress) {
|
|
123
|
+
if (!this.metadata.reputation || !this.metadata.vouch || !this.metadata.config) {
|
|
124
|
+
throw new Error('Required metadata not provided. Pass all metadata to the KleoClient constructor.');
|
|
125
|
+
}
|
|
126
|
+
const client = await this.connect();
|
|
127
|
+
return ReputationService.getBorrowerInfo(this.supabaseClient, client, {
|
|
128
|
+
config: this.metadata.config,
|
|
129
|
+
reputation: this.metadata.reputation,
|
|
130
|
+
vouch: this.metadata.vouch,
|
|
131
|
+
}, poolId, userAddress);
|
|
132
|
+
}
|
|
133
|
+
async getUserLoans(poolId, userAddress) {
|
|
134
|
+
if (!this.metadata.reputation) {
|
|
135
|
+
throw new Error('Reputation metadata not provided. Pass it to the KleoClient constructor.');
|
|
136
|
+
}
|
|
137
|
+
const client = await this.connect();
|
|
138
|
+
return ReputationService.getUserLoans(this.supabaseClient, client, this.metadata.reputation, poolId, userAddress);
|
|
139
|
+
}
|
|
140
|
+
async getVouchRelationship(poolId, voucherAddress, borrowerAddress) {
|
|
141
|
+
if (!this.metadata.vouch) {
|
|
142
|
+
throw new Error('Vouch metadata not provided. Pass it to the KleoClient constructor.');
|
|
143
|
+
}
|
|
144
|
+
const client = await this.connect();
|
|
145
|
+
return VouchService.getVouchRelationship(this.supabaseClient, client, this.metadata.vouch, poolId, voucherAddress, borrowerAddress);
|
|
146
|
+
}
|
|
147
|
+
async getBorrowerVouches(poolId, borrowerAddress) {
|
|
148
|
+
if (!this.metadata.vouch) {
|
|
149
|
+
throw new Error('Vouch metadata not provided. Pass it to the KleoClient constructor.');
|
|
150
|
+
}
|
|
151
|
+
const client = await this.connect();
|
|
152
|
+
return VouchService.getBorrowerVouches(this.supabaseClient, client, this.metadata.vouch, poolId, borrowerAddress);
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
exports.KleoClient = KleoClient;
|
|
156
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAIA,iDAAwE;AACxE,wEAAyC;AASzC,qEAAuD;AACvD,2EAA6D;AAC7D,2EAA6D;AAC7D,uEAAyD;AACzD,iFAAmE;AAQnE,MAAa,UAAU;IAWrB,YAAY,SAAqB,EAAE,EAAE,QAA2B;QAVxD,gBAAW,GAAoC,IAAI,CAAC;QACpD,mBAAc,GAAoB,yBAAQ,CAAC;QAUjD,IAAI,CAAC,MAAM,GAAG;YACZ,QAAQ,EAAE,MAAM,CAAC,QAAQ,IAAI,0CAA0C;YACvE,OAAO,EAAE,MAAM,CAAC,OAAO,IAAI,KAAK;SACjC,CAAC;QACF,IAAI,CAAC,QAAQ,GAAG;YACd,MAAM,EAAE,QAAQ,EAAE,MAAM;YACxB,WAAW,EAAE,QAAQ,EAAE,WAAW;YAClC,UAAU,EAAE,QAAQ,EAAE,UAAU;YAChC,KAAK,EAAE,QAAQ,EAAE,KAAK;SACvB,CAAC;QACF,IAAI,CAAC,OAAO,EAAE,CAAC;QACf,IAAI,CAAC,cAAc,GAAG,yBAAQ,CAAC;IACjC,CAAC;IAKD,KAAK,CAAC,OAAO;QACX,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,IAAI,CAAC,WAAW,GAAG,MAAM,IAAA,gCAAiB,EAAC,IAAI,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACnE,CAAC;QACD,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAKD,cAAc;QACZ,OAAO,IAAI,CAAC,WAAW,CAAC;IAC1B,CAAC;IAKD,iBAAiB;QACf,OAAO,IAAI,CAAC,cAAc,CAAC;IAC7B,CAAC;IAKD,KAAK,C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AqE,CAAC,CAAC;QACzF,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,EAAE,CAAC;QACpC,OAAO,YAAY,CAAC,kBAAkB,CACpC,IAAI,CAAC,cAAc,EACnB,MAAM,EACN,IAAI,CAAC,QAAQ,CAAC,KAAK,EACnB,MAAM,EACN,eAAe,CAChB,CAAC;IACJ,CAAC;CACF;AAxND,gCAwNC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { DedotClient } from 'dedot';
|
|
2
|
+
import type { PolkadotApi } from '@dedot/chaintypes';
|
|
3
|
+
export declare function createDedotClient(endpoint?: string): Promise<DedotClient<PolkadotApi>>;
|
|
4
|
+
export type SignerAccount = string | {
|
|
5
|
+
address: string;
|
|
6
|
+
addressRaw: Uint8Array;
|
|
7
|
+
publicKey: Uint8Array;
|
|
8
|
+
sign: (data: Uint8Array) => Uint8Array;
|
|
9
|
+
};
|
|
10
|
+
export declare function ensureAccountMapped(client: DedotClient<PolkadotApi>, caller: SignerAccount): Promise<boolean>;
|
|
11
|
+
//# sourceMappingURL=dedot.client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedot.client.d.ts","sourceRoot":"","sources":["../../src/dedot.client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAc,MAAM,OAAO,CAAC;AAEhD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAErD,wBAAsB,iBAAiB,CAAC,QAAQ,GAAE,MAAmD,qCAIpG;AAMD,MAAM,MAAM,aAAa,GAAG,MAAM,GAAG;IACnC,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,UAAU,CAAC;IACvB,SAAS,EAAE,UAAU,CAAC;IACtB,IAAI,EAAE,CAAC,IAAI,EAAE,UAAU,KAAK,UAAU,CAAC;CACxC,CAAC;AAQF,wBAAsB,mBAAmB,CACvC,MAAM,EAAE,WAAW,CAAC,WAAW,CAAC,EAChC,MAAM,EAAE,aAAa,GACpB,OAAO,CAAC,OAAO,CAAC,CAmBlB"}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createDedotClient = createDedotClient;
|
|
4
|
+
exports.ensureAccountMapped = ensureAccountMapped;
|
|
5
|
+
const dedot_1 = require("dedot");
|
|
6
|
+
const contracts_1 = require("dedot/contracts");
|
|
7
|
+
async function createDedotClient(endpoint = 'wss://polkadot-asset-hub-rpc.polkadot.io') {
|
|
8
|
+
const provider = new dedot_1.WsProvider(endpoint);
|
|
9
|
+
const client = await dedot_1.DedotClient.new(provider);
|
|
10
|
+
return client;
|
|
11
|
+
}
|
|
12
|
+
async function ensureAccountMapped(client, caller) {
|
|
13
|
+
const callerAddress = typeof caller === 'string' ? caller : caller.address;
|
|
14
|
+
const mappedAccount = await client.query.revive.originalAccount((0, contracts_1.toEvmAddress)(callerAddress));
|
|
15
|
+
if (mappedAccount) {
|
|
16
|
+
console.log('Address has already been mapped!');
|
|
17
|
+
return true;
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
console.log('Address not mapped yet, map it now!');
|
|
21
|
+
await client.tx.revive
|
|
22
|
+
.mapAccount()
|
|
23
|
+
.signAndSend(caller, ({ status }) => console.log(status.type))
|
|
24
|
+
.untilFinalized();
|
|
25
|
+
return false;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
//# sourceMappingURL=dedot.client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"dedot.client.js","sourceRoot":"","sources":["../../src/dedot.client.ts"],"names":[],"mappings":";;AAIA,8CAIC;AAmBD,kDAsBC;AAjDD,iCAAgD;AAChD,+CAA+C;AAGxC,KAAK,UAAU,iBAAiB,CAAC,WAAmB,0CAA0C;IACnG,MAAM,QAAQ,GAAG,IAAI,kBAAU,CAAC,QAAQ,CAAC,CAAC;IAC1C,MAAM,MAAM,GAAG,MAAM,mBAAW,CAAC,GAAG,CAAc,QAAQ,CAAC,CAAC;IAC5D,OAAO,MAAM,CAAC;AAChB,CAAC;AAmBM,KAAK,UAAU,mBAAmB,CACvC,MAAgC,EAChC,MAAqB;IAErB,MAAM,aAAa,GAAG,OAAO,MAAM,KAAK,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC;IAG3E,MAAM,aAAa,GAAG,MAAM,MAAM,CAAC,KAAK,CAAC,MAAM,CAAC,eAAe,CAAC,IAAA,wBAAY,EAAC,aAAa,CAAC,CAAC,CAAC;IAE7F,IAAI,aAAa,EAAE,CAAC;QAClB,OAAO,CAAC,GAAG,CAAC,kCAAkC,CAAC,CAAC;QAChD,OAAO,IAAI,CAAC;IACd,CAAC;SAAM,CAAC;QACN,OAAO,CAAC,GAAG,CAAC,qCAAqC,CAAC,CAAC;QAEnD,MAAM,MAAM,CAAC,EAAE,CAAC,MAAM;aACnB,UAAU,EAAE;aACZ,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,MAAM,EAAgC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;aAC3F,cAAc,EAAE,CAAC;QAEpB,OAAO,KAAK,CAAC;IACf,CAAC;AACH,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AAGtC,cAAc,cAAc,CAAC;AAG7B,cAAc,YAAY,CAAC;AAG3B,cAAc,SAAS,CAAC;AAGxB,cAAc,gBAAgB,CAAC;AAG/B,eAAO,MAAM,OAAO,UAAU,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
exports.VERSION = exports.KleoClient = void 0;
|
|
18
|
+
var client_1 = require("./client");
|
|
19
|
+
Object.defineProperty(exports, "KleoClient", { enumerable: true, get: function () { return client_1.KleoClient; } });
|
|
20
|
+
__exportStar(require("./interfaces"), exports);
|
|
21
|
+
__exportStar(require("./services"), exports);
|
|
22
|
+
__exportStar(require("./utils"), exports);
|
|
23
|
+
__exportStar(require("../types/types"), exports);
|
|
24
|
+
exports.VERSION = '0.1.0';
|
|
25
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AACA,mCAAsC;AAA7B,oGAAA,UAAU,OAAA;AAGnB,+CAA6B;AAG7B,6CAA2B;AAG3B,0CAAwB;AAGxB,iDAA+B;AAGlB,QAAA,OAAO,GAAG,OAAO,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backed-position.d.ts","sourceRoot":"","sources":["../../../src/interfaces/backed-position.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,cAAc;IAC7B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,EAAE,QAAQ,GAAG,WAAW,GAAG,WAAW,CAAC;CAC9C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"backed-position.js","sourceRoot":"","sources":["../../../src/interfaces/backed-position.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface BorrowerInfo {
|
|
2
|
+
stars: number;
|
|
3
|
+
starsAtStake: number;
|
|
4
|
+
canVouch: boolean;
|
|
5
|
+
banned: boolean;
|
|
6
|
+
creationTime: string;
|
|
7
|
+
loanHistoryCount: number;
|
|
8
|
+
vouchHistoryCount: number;
|
|
9
|
+
totalExposure: string;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=borrower-info.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"borrower-info.d.ts","sourceRoot":"","sources":["../../../src/interfaces/borrower-info.ts"],"names":[],"mappings":"AAGA,MAAM,WAAW,YAAY;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,YAAY,EAAE,MAAM,CAAC;IACrB,QAAQ,EAAE,OAAO,CAAC;IAClB,MAAM,EAAE,OAAO,CAAC;IAChB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;IACzB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,aAAa,EAAE,MAAM,CAAC;CACvB"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"borrower-info.js","sourceRoot":"","sources":["../../../src/interfaces/borrower-info.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,cAAc,CAAC;AAC7B,cAAc,iBAAiB,CAAC;AAChC,cAAc,QAAQ,CAAC"}
|