@lightconexyz/lightcone-sdk 0.2.3 → 0.2.4
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 +25 -14
- package/dist/auth/client.d.ts.map +1 -1
- package/dist/auth/client.js +3 -7
- package/dist/auth/client.js.map +1 -1
- package/dist/auth/index.d.ts +3 -0
- package/dist/auth/index.d.ts.map +1 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/client.d.ts +17 -5
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +36 -10
- package/dist/client.js.map +1 -1
- package/dist/context.d.ts +14 -0
- package/dist/context.d.ts.map +1 -0
- package/dist/context.js +10 -0
- package/dist/context.js.map +1 -0
- package/dist/domain/admin/client.d.ts +15 -5
- package/dist/domain/admin/client.d.ts.map +1 -1
- package/dist/domain/admin/client.js +39 -0
- package/dist/domain/admin/client.js.map +1 -1
- package/dist/domain/index.d.ts +0 -1
- package/dist/domain/index.d.ts.map +1 -1
- package/dist/domain/index.js +1 -2
- package/dist/domain/index.js.map +1 -1
- package/dist/domain/market/client.d.ts +11 -5
- package/dist/domain/market/client.d.ts.map +1 -1
- package/dist/domain/market/client.js +76 -0
- package/dist/domain/market/client.js.map +1 -1
- package/dist/domain/order/client.d.ts +21 -5
- package/dist/domain/order/client.d.ts.map +1 -1
- package/dist/domain/order/client.js +89 -0
- package/dist/domain/order/client.js.map +1 -1
- package/dist/domain/order/index.d.ts +8 -2
- package/dist/domain/order/index.d.ts.map +1 -1
- package/dist/domain/order/index.js +23 -0
- package/dist/domain/order/index.js.map +1 -1
- package/dist/domain/orderbook/client.d.ts +7 -12
- package/dist/domain/orderbook/client.d.ts.map +1 -1
- package/dist/domain/orderbook/client.js +24 -4
- package/dist/domain/orderbook/client.js.map +1 -1
- package/dist/domain/orderbook/state.d.ts +2 -0
- package/dist/domain/orderbook/state.d.ts.map +1 -1
- package/dist/domain/orderbook/state.js +25 -2
- package/dist/domain/orderbook/state.js.map +1 -1
- package/dist/domain/position/client.d.ts +11 -5
- package/dist/domain/position/client.d.ts.map +1 -1
- package/dist/domain/position/client.js +38 -0
- package/dist/domain/position/client.js.map +1 -1
- package/dist/domain/position/index.d.ts +4 -1
- package/dist/domain/position/index.d.ts.map +1 -1
- package/dist/domain/position/index.js +20 -0
- package/dist/domain/position/index.js.map +1 -1
- package/dist/domain/position/wire.d.ts +6 -0
- package/dist/domain/position/wire.d.ts.map +1 -1
- package/dist/domain/position/wire.js.map +1 -1
- package/dist/domain/price_history/client.d.ts +14 -1
- package/dist/domain/price_history/client.d.ts.map +1 -1
- package/dist/domain/price_history/client.js +53 -0
- package/dist/domain/price_history/client.js.map +1 -1
- package/dist/domain/price_history/index.d.ts +4 -0
- package/dist/domain/price_history/index.d.ts.map +1 -1
- package/dist/domain/price_history/index.js.map +1 -1
- package/dist/domain/price_history/state.d.ts +16 -0
- package/dist/domain/price_history/state.d.ts.map +1 -1
- package/dist/domain/price_history/state.js +42 -1
- package/dist/domain/price_history/state.js.map +1 -1
- package/dist/domain/price_history/wire.d.ts +34 -0
- package/dist/domain/price_history/wire.d.ts.map +1 -1
- package/dist/domain/price_history/wire.js.map +1 -1
- package/dist/http/client.d.ts.map +1 -1
- package/dist/http/client.js +17 -36
- package/dist/http/client.js.map +1 -1
- package/dist/index.d.ts +4 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +5 -1
- package/dist/index.js.map +1 -1
- package/dist/prelude.d.ts +5 -6
- package/dist/prelude.d.ts.map +1 -1
- package/dist/prelude.js +4 -5
- package/dist/prelude.js.map +1 -1
- package/dist/privy/client.d.ts +1 -0
- package/dist/privy/client.d.ts.map +1 -1
- package/dist/privy/client.js +10 -0
- package/dist/privy/client.js.map +1 -1
- package/dist/program/accounts.d.ts +2 -1
- package/dist/program/accounts.d.ts.map +1 -1
- package/dist/program/accounts.js +2 -1
- package/dist/program/accounts.js.map +1 -1
- package/dist/program/index.d.ts +1 -2
- package/dist/program/index.d.ts.map +1 -1
- package/dist/program/index.js +8 -6
- package/dist/program/index.js.map +1 -1
- package/dist/program/instructions.d.ts +1 -1
- package/dist/program/instructions.d.ts.map +1 -1
- package/dist/program/instructions.js +3 -3
- package/dist/program/instructions.js.map +1 -1
- package/dist/program/orders.d.ts +13 -1
- package/dist/program/orders.d.ts.map +1 -1
- package/dist/program/orders.js +53 -3
- package/dist/program/orders.js.map +1 -1
- package/dist/rpc.d.ts +19 -0
- package/dist/rpc.d.ts.map +1 -0
- package/dist/rpc.js +51 -0
- package/dist/rpc.js.map +1 -0
- package/dist/shared/fmt/decimal.d.ts +1 -1
- package/dist/shared/fmt/decimal.d.ts.map +1 -1
- package/dist/shared/fmt/decimal.js +2 -2
- package/dist/shared/fmt/decimal.js.map +1 -1
- package/dist/shared/index.d.ts +1 -1
- package/dist/shared/index.d.ts.map +1 -1
- package/dist/shared/index.js +2 -1
- package/dist/shared/index.js.map +1 -1
- package/dist/shared/scaling.d.ts.map +1 -1
- package/dist/shared/scaling.js +7 -3
- package/dist/shared/scaling.js.map +1 -1
- package/dist/shared/types.d.ts +1 -0
- package/dist/shared/types.d.ts.map +1 -1
- package/dist/shared/types.js +9 -1
- package/dist/shared/types.js.map +1 -1
- package/dist/ws/client.browser.d.ts +2 -0
- package/dist/ws/client.browser.d.ts.map +1 -1
- package/dist/ws/client.browser.js +43 -6
- package/dist/ws/client.browser.js.map +1 -1
- package/dist/ws/client.node.d.ts +2 -0
- package/dist/ws/client.node.d.ts.map +1 -1
- package/dist/ws/client.node.js +43 -6
- package/dist/ws/client.node.js.map +1 -1
- package/dist/ws/index.d.ts +1 -2
- package/dist/ws/index.d.ts.map +1 -1
- package/dist/ws/index.js.map +1 -1
- package/dist/ws/types.d.ts +2 -0
- package/dist/ws/types.d.ts.map +1 -1
- package/dist/ws/types.js.map +1 -1
- package/package.json +1 -1
- package/dist/domain/deposit_price/client.d.ts +0 -21
- package/dist/domain/deposit_price/client.d.ts.map +0 -1
- package/dist/domain/deposit_price/client.js +0 -68
- package/dist/domain/deposit_price/client.js.map +0 -1
- package/dist/domain/deposit_price/index.d.ts +0 -9
- package/dist/domain/deposit_price/index.d.ts.map +0 -1
- package/dist/domain/deposit_price/index.js +0 -20
- package/dist/domain/deposit_price/index.js.map +0 -1
- package/dist/domain/deposit_price/state.d.ts +0 -17
- package/dist/domain/deposit_price/state.d.ts.map +0 -1
- package/dist/domain/deposit_price/state.js +0 -45
- package/dist/domain/deposit_price/state.js.map +0 -1
- package/dist/domain/deposit_price/wire.d.ts +0 -36
- package/dist/domain/deposit_price/wire.d.ts.map +0 -1
- package/dist/domain/deposit_price/wire.js +0 -3
- package/dist/domain/deposit_price/wire.js.map +0 -1
- package/dist/program/client.d.ts +0 -96
- package/dist/program/client.d.ts.map +0 -1
- package/dist/program/client.js +0 -372
- package/dist/program/client.js.map +0 -1
package/README.md
CHANGED
|
@@ -31,12 +31,12 @@ import {
|
|
|
31
31
|
LightconeClient,
|
|
32
32
|
LimitOrderEnvelope,
|
|
33
33
|
auth,
|
|
34
|
-
program,
|
|
35
34
|
} from "@lightconexyz/lightcone-sdk";
|
|
36
35
|
|
|
37
36
|
async function main() {
|
|
38
|
-
const client = LightconeClient.builder()
|
|
39
|
-
|
|
37
|
+
const client = LightconeClient.builder()
|
|
38
|
+
.rpcUrl("https://api.devnet.solana.com")
|
|
39
|
+
.build();
|
|
40
40
|
const keypair = Keypair.generate();
|
|
41
41
|
|
|
42
42
|
// 1. Authenticate
|
|
@@ -51,7 +51,8 @@ async function main() {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// 2. Find a market
|
|
54
|
-
const
|
|
54
|
+
const { markets } = await client.markets().get();
|
|
55
|
+
const market = markets[0];
|
|
55
56
|
const orderbook = market.orderbookPairs[0];
|
|
56
57
|
|
|
57
58
|
// 3. Get orderbook decimals for price scaling
|
|
@@ -65,7 +66,7 @@ async function main() {
|
|
|
65
66
|
};
|
|
66
67
|
|
|
67
68
|
// 4. Build, sign, and submit a limit order
|
|
68
|
-
const nonce = await
|
|
69
|
+
const nonce = await client.orders().currentNonce(keypair.publicKey);
|
|
69
70
|
const request = LimitOrderEnvelope.new()
|
|
70
71
|
.maker(keypair.publicKey)
|
|
71
72
|
.market(new PublicKey(market.pubkey))
|
|
@@ -96,7 +97,7 @@ main().catch(console.error);
|
|
|
96
97
|
import * as fs from "fs";
|
|
97
98
|
import * as path from "path";
|
|
98
99
|
import { Keypair, PublicKey } from "@solana/web3.js";
|
|
99
|
-
import { LightconeClient
|
|
100
|
+
import { LightconeClient } from "@lightconexyz/lightcone-sdk";
|
|
100
101
|
|
|
101
102
|
function readKeypairFile(filePath: string): Keypair {
|
|
102
103
|
const resolved = filePath.startsWith("~")
|
|
@@ -106,15 +107,17 @@ function readKeypairFile(filePath: string): Keypair {
|
|
|
106
107
|
return Keypair.fromSecretKey(Uint8Array.from(secret));
|
|
107
108
|
}
|
|
108
109
|
|
|
109
|
-
const client = LightconeClient.builder()
|
|
110
|
-
|
|
110
|
+
const client = LightconeClient.builder()
|
|
111
|
+
.rpcUrl("https://api.devnet.solana.com")
|
|
112
|
+
.build();
|
|
111
113
|
const keypair = readKeypairFile("~/.config/solana/id.json");
|
|
112
114
|
```
|
|
113
115
|
|
|
114
116
|
### Step 1: Find a Market
|
|
115
117
|
|
|
116
118
|
```typescript
|
|
117
|
-
const
|
|
119
|
+
const { markets } = await client.markets().get();
|
|
120
|
+
const market = markets[0];
|
|
118
121
|
const orderbook =
|
|
119
122
|
market.orderbookPairs.find((pair) => pair.active) ?? market.orderbookPairs[0];
|
|
120
123
|
```
|
|
@@ -122,10 +125,12 @@ const orderbook =
|
|
|
122
125
|
### Step 2: Deposit Collateral
|
|
123
126
|
|
|
124
127
|
```typescript
|
|
128
|
+
import { Transaction } from "@solana/web3.js";
|
|
129
|
+
|
|
125
130
|
const marketPubkey = new PublicKey(market.pubkey);
|
|
126
131
|
const depositMint = new PublicKey(market.depositAssets[0].pubkey);
|
|
127
132
|
const numOutcomes = market.outcomes.length;
|
|
128
|
-
const
|
|
133
|
+
const mintIx = client.markets().mintCompleteSetIx(
|
|
129
134
|
{
|
|
130
135
|
user: keypair.publicKey,
|
|
131
136
|
market: marketPubkey,
|
|
@@ -134,7 +139,10 @@ const mintResult = await rpc.mintCompleteSet(
|
|
|
134
139
|
},
|
|
135
140
|
numOutcomes
|
|
136
141
|
);
|
|
137
|
-
|
|
142
|
+
const tx = new Transaction().add(mintIx);
|
|
143
|
+
tx.feePayer = keypair.publicKey;
|
|
144
|
+
tx.recentBlockhash = (await client.rpc().getLatestBlockhash()).blockhash;
|
|
145
|
+
tx.sign(keypair);
|
|
138
146
|
```
|
|
139
147
|
|
|
140
148
|
### Step 3: Place an Order
|
|
@@ -158,7 +166,7 @@ const request = LimitOrderEnvelope.new()
|
|
|
158
166
|
.bid()
|
|
159
167
|
.price("0.55")
|
|
160
168
|
.size("1")
|
|
161
|
-
.nonce(await
|
|
169
|
+
.nonce(await client.orders().currentNonce(keypair.publicKey))
|
|
162
170
|
.applyScaling(scales)
|
|
163
171
|
.sign(keypair, orderbook.orderbookId);
|
|
164
172
|
const order = await client.orders().submit(request);
|
|
@@ -197,7 +205,7 @@ await client.orders().cancel({
|
|
|
197
205
|
### Step 6: Exit a Position
|
|
198
206
|
|
|
199
207
|
```typescript
|
|
200
|
-
const
|
|
208
|
+
const mergeIx = client.markets().mergeCompleteSetIx(
|
|
201
209
|
{
|
|
202
210
|
user: keypair.publicKey,
|
|
203
211
|
market: new PublicKey(market.pubkey),
|
|
@@ -206,7 +214,10 @@ const mergeResult = await rpc.mergeCompleteSet(
|
|
|
206
214
|
},
|
|
207
215
|
numOutcomes
|
|
208
216
|
);
|
|
209
|
-
|
|
217
|
+
const mergeTx = new Transaction().add(mergeIx);
|
|
218
|
+
mergeTx.feePayer = keypair.publicKey;
|
|
219
|
+
mergeTx.recentBlockhash = (await client.rpc().getLatestBlockhash()).blockhash;
|
|
220
|
+
mergeTx.sign(keypair);
|
|
210
221
|
```
|
|
211
222
|
|
|
212
223
|
## Authentication
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/auth/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAA0D,IAAI,EAAE,MAAM,SAAS,CAAC;AAE7G,UAAU,SAAS;IACjB,cAAc,IAAI,eAAe,GAAG,SAAS,CAAC;IAC9C,cAAc,CAAC,WAAW,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/D,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,qBAAa,IAAI;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAM3B,gBAAgB,CACpB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,UAAU,EACvB,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/auth/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAe,KAAK,aAAa,EAAE,MAAM,SAAS,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAA0D,IAAI,EAAE,MAAM,SAAS,CAAC;AAE7G,UAAU,SAAS;IACjB,cAAc,IAAI,eAAe,GAAG,SAAS,CAAC;IAC9C,cAAc,CAAC,WAAW,EAAE,eAAe,GAAG,SAAS,GAAG,IAAI,CAAC;IAC/D,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC9B;AAED,UAAU,aAAa;IACrB,IAAI,EAAE,aAAa,CAAC;IACpB,SAAS,EAAE,SAAS,CAAC;CACtB;AAED,qBAAa,IAAI;IACH,OAAO,CAAC,QAAQ,CAAC,MAAM;gBAAN,MAAM,EAAE,aAAa;IAE5C,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;IAM3B,gBAAgB,CACpB,OAAO,EAAE,MAAM,EACf,aAAa,EAAE,MAAM,EACrB,WAAW,EAAE,UAAU,EACvB,iBAAiB,CAAC,EAAE,OAAO,GAC1B,OAAO,CAAC,IAAI,CAAC;IAuCV,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IA8B7B,MAAM,IAAI,OAAO,CAAC,IAAI,CAAC;IAavB,WAAW,IAAI,OAAO,CAAC,IAAI,CAAC;IAK5B,QAAQ,CACZ,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,YAAY,CAAC,EAAE,MAAM,GACpB,OAAO,CAAC,IAAI,CAAC;IAahB,WAAW,IAAI,eAAe,GAAG,SAAS;IAI1C,eAAe,IAAI,OAAO;CAO3B"}
|
package/dist/auth/client.js
CHANGED
|
@@ -22,13 +22,7 @@ class Auth {
|
|
|
22
22
|
pubkey_bytes: Array.from(pubkeyBytes),
|
|
23
23
|
use_embedded_wallet: useEmbeddedWallet,
|
|
24
24
|
};
|
|
25
|
-
|
|
26
|
-
try {
|
|
27
|
-
response = await this.client.http.post(url, body, http_1.RetryPolicy.None);
|
|
28
|
-
}
|
|
29
|
-
catch (error) {
|
|
30
|
-
throw error_1.SdkError.from(new error_1.AuthError("LoginFailed", error instanceof Error ? error.message : String(error)));
|
|
31
|
-
}
|
|
25
|
+
const response = await this.client.http.post(url, body, http_1.RetryPolicy.None);
|
|
32
26
|
if (response.token) {
|
|
33
27
|
await this.client.http.setAuthToken(response.token);
|
|
34
28
|
}
|
|
@@ -47,6 +41,7 @@ class Auth {
|
|
|
47
41
|
x_username: response.x_username,
|
|
48
42
|
x_user_id: response.x_user_id,
|
|
49
43
|
x_display_name: response.x_display_name,
|
|
44
|
+
google_email: response.google_email,
|
|
50
45
|
};
|
|
51
46
|
}
|
|
52
47
|
async checkSession() {
|
|
@@ -73,6 +68,7 @@ class Auth {
|
|
|
73
68
|
x_username: response.x_username,
|
|
74
69
|
x_user_id: response.x_user_id,
|
|
75
70
|
x_display_name: response.x_display_name,
|
|
71
|
+
google_email: response.google_email,
|
|
76
72
|
};
|
|
77
73
|
}
|
|
78
74
|
async logout() {
|
package/dist/auth/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/auth/client.ts"],"names":[],"mappings":";;;AAAA,
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/auth/client.ts"],"names":[],"mappings":";;;AAAA,oCAAoC;AACpC,kCAA0D;AAC1D,sCAAwC;AAcxC,MAAa,IAAI;IACc;IAA7B,YAA6B,MAAqB;QAArB,WAAM,GAAN,MAAM,CAAe;IAAG,CAAC;IAEtD,KAAK,CAAC,QAAQ;QACZ,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,iBAAiB,CAAC;QAC3D,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAgB,GAAG,EAAE,kBAAW,CAAC,IAAI,CAAC,CAAC;QAClF,OAAO,QAAQ,CAAC,KAAK,CAAC;IACxB,CAAC;IAED,KAAK,CAAC,gBAAgB,CACpB,OAAe,EACf,aAAqB,EACrB,WAAuB,EACvB,iBAA2B;QAE3B,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,0CAA0C,CAAC;QACpF,MAAM,IAAI,GAAiB;YACzB,OAAO;YACP,cAAc,EAAE,aAAa;YAC7B,YAAY,EAAE,KAAK,CAAC,IAAI,CAAC,WAAW,CAAC;YACrC,mBAAmB,EAAE,iBAAiB;SACvC,CAAC;QAEF,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,MAAM,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AAC,WAAW;QACf,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,wBAAwB,CAAC;QAClE,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CAA8C,GAAG,EAAE,EAAE,EAAE,kBAAW,CAAC,IAAI,CAAC,CAAC;IACtG,CAAC;IAED,KAAK,CAAC,QAAQ,CACZ,OAAe,EACf,SAAiB,EACjB,YAAqB;QAErB,MAAM,GAAG,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,qBAAqB,CAAC;QAC/D,MAAM,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,IAAI,CACzB,GAAG,EACH;YACE,SAAS,EAAE,OAAO;YAClB,UAAU,EAAE,SAAS;YACrB,cAAc,EAAE,YAAY;SAC7B,EACD,kBAAW,CAAC,IAAI,CACjB,CAAC;IACJ,CAAC;IAED,WAAW;QACT,OAAO,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,cAAc,EAAE,CAAC;IAChD,CAAC;IAED,eAAe;QACb,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;QACvC,IAAI,CAAC,WAAW,EAAE,CAAC;YACjB,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;IACvD,CAAC;CACF;AAjID,oBAiIC;AAED,SAAS,WAAW,CAAC,SAAiB;IACpC,IAAI,SAAS,GAAG,iBAAiB,EAAE,CAAC;QAClC,OAAO,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC;IAC7B,CAAC;IACD,OAAO,IAAI,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,CAAC;AACpC,CAAC","sourcesContent":["import { SdkError } from \"../error\";\nimport { RetryPolicy, type LightconeHttp } from \"../http\";\nimport { asPubkeyStr } from \"../shared\";\nimport type { AuthCredentials, LoginRequest, LoginResponse, MeResponse, NonceResponse, User } from \"./index\";\n\ninterface AuthState {\n getCredentials(): AuthCredentials | undefined;\n setCredentials(credentials: AuthCredentials | undefined): void;\n clearCaches(): Promise<void>;\n}\n\ninterface ClientContext {\n http: LightconeHttp;\n authState: AuthState;\n}\n\nexport class Auth {\n constructor(private readonly client: ClientContext) {}\n\n async getNonce(): Promise<string> {\n const url = `${this.client.http.baseUrl()}/api/auth/nonce`;\n const response = await this.client.http.get<NonceResponse>(url, RetryPolicy.None);\n return response.nonce;\n }\n\n async loginWithMessage(\n message: string,\n signatureBs58: string,\n pubkeyBytes: Uint8Array,\n useEmbeddedWallet?: boolean\n ): Promise<User> {\n const url = `${this.client.http.baseUrl()}/api/auth/login_or_register_with_message`;\n const body: LoginRequest = {\n message,\n signature_bs58: signatureBs58,\n pubkey_bytes: Array.from(pubkeyBytes),\n use_embedded_wallet: useEmbeddedWallet,\n };\n\n const response = await this.client.http.post<LoginResponse, LoginRequest>(\n url,\n body,\n RetryPolicy.None\n );\n\n if (response.token) {\n await this.client.http.setAuthToken(response.token);\n }\n\n const credentials: AuthCredentials = {\n user_id: response.user_id,\n wallet_address: asPubkeyStr(response.wallet_address),\n expires_at: parseExpiry(response.expires_at),\n };\n this.client.authState.setCredentials(credentials);\n\n return {\n id: response.user_id,\n wallet_address: response.wallet_address,\n linked_account: response.linked_account,\n privy_id: response.privy_id,\n embedded_wallet: response.embedded_wallet,\n x_username: response.x_username,\n x_user_id: response.x_user_id,\n x_display_name: response.x_display_name,\n google_email: response.google_email,\n };\n }\n\n async checkSession(): Promise<User> {\n const url = `${this.client.http.baseUrl()}/api/auth/me`;\n\n let response: MeResponse;\n try {\n response = await this.client.http.get<MeResponse>(url, RetryPolicy.Idempotent);\n } catch (error) {\n this.client.authState.setCredentials(undefined);\n throw SdkError.from(error);\n }\n\n this.client.authState.setCredentials({\n user_id: response.user_id,\n wallet_address: asPubkeyStr(response.wallet_address),\n expires_at: parseExpiry(response.expires_at),\n });\n\n return {\n id: response.user_id,\n wallet_address: response.wallet_address,\n linked_account: response.linked_account,\n privy_id: response.privy_id,\n embedded_wallet: response.embedded_wallet,\n x_username: response.x_username,\n x_user_id: response.x_user_id,\n x_display_name: response.x_display_name,\n google_email: response.google_email,\n };\n }\n\n async logout(): Promise<void> {\n const url = `${this.client.http.baseUrl()}/api/auth/logout`;\n try {\n await this.client.http.post<{ success: boolean }, Record<string, never>>(url, {}, RetryPolicy.None);\n } catch {\n // Backend cookie clear can fail in local/dev setups; still clear local state.\n }\n\n await this.client.http.clearAuthToken();\n this.client.authState.setCredentials(undefined);\n await this.client.authState.clearCaches();\n }\n\n async disconnectX(): Promise<void> {\n const url = `${this.client.http.baseUrl()}/api/auth/disconnect_x`;\n await this.client.http.post<{ success: boolean }, Record<string, never>>(url, {}, RetryPolicy.None);\n }\n\n async connectX(\n xUserId: string,\n xUsername: string,\n xDisplayName?: string\n ): Promise<void> {\n const url = `${this.client.http.baseUrl()}/api/auth/connect_x`;\n await this.client.http.post<{ success: boolean }, { x_user_id: string; x_username: string; x_display_name?: string }>(\n url,\n {\n x_user_id: xUserId,\n x_username: xUsername,\n x_display_name: xDisplayName,\n },\n RetryPolicy.None\n );\n }\n\n credentials(): AuthCredentials | undefined {\n return this.client.authState.getCredentials();\n }\n\n isAuthenticated(): boolean {\n const credentials = this.credentials();\n if (!credentials) {\n return false;\n }\n return Date.now() < credentials.expires_at.getTime();\n }\n}\n\nfunction parseExpiry(timestamp: number): Date {\n if (timestamp > 1_000_000_000_000) {\n return new Date(timestamp);\n }\n return new Date(timestamp * 1000);\n}\n"]}
|
package/dist/auth/index.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export interface User {
|
|
|
10
10
|
x_username?: string;
|
|
11
11
|
x_user_id?: string;
|
|
12
12
|
x_display_name?: string;
|
|
13
|
+
google_email?: string;
|
|
13
14
|
}
|
|
14
15
|
export interface LinkedAccount {
|
|
15
16
|
id: string;
|
|
@@ -55,6 +56,7 @@ export interface LoginResponse {
|
|
|
55
56
|
x_username?: string;
|
|
56
57
|
x_user_id?: string;
|
|
57
58
|
x_display_name?: string;
|
|
59
|
+
google_email?: string;
|
|
58
60
|
}
|
|
59
61
|
export interface MeResponse {
|
|
60
62
|
user_id: string;
|
|
@@ -65,6 +67,7 @@ export interface MeResponse {
|
|
|
65
67
|
x_username?: string;
|
|
66
68
|
x_user_id?: string;
|
|
67
69
|
x_display_name?: string;
|
|
70
|
+
google_email?: string;
|
|
68
71
|
expires_at: number;
|
|
69
72
|
}
|
|
70
73
|
export interface NonceResponse {
|
package/dist/auth/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,WAAW,CAAC;AAE3C,cAAc,UAAU,CAAC;AACzB,cAAc,UAAU,CAAC;AAEzB,MAAM,WAAW,IAAI;IACnB,EAAE,EAAE,MAAM,CAAC;IACX,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EA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B,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,cAAc,EAAE,MAAM,CAAC;IACvB,cAAc,EAAE,aAAa,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,eAAe,CAAC,EAAE,cAAc,CAAC;IACjC,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,cAAc,CAAC,EAAE,MAAM,CAAC;IACxB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,UAAU,EAAE,MAAM,CAAC;CACpB;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;CACf"}
|
package/dist/auth/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/auth/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AA+CA,0CAKC;AAED,sDAEC;AAtDD,2CAAyB;AACzB,2CAAyB;AAqBzB,IAAY,iBAIX;AAJD,WAAY,iBAAiB;IAC3B,sCAAiB,CAAA;IACjB,mDAA8B,CAAA;IAC9B,iDAA4B,CAAA;AAC9B,CAAC,EAJW,iBAAiB,iCAAjB,iBAAiB,QAI5B;AAED,IAAY,SAGX;AAHD,WAAY,SAAS;IACnB,8BAAiB,CAAA;IACjB,kCAAqB,CAAA;AACvB,CAAC,EAHW,SAAS,yBAAT,SAAS,QAGpB;AAcD,SAAgB,eAAe,CAAC,WAA6B;IAC3D,IAAI,CAAC,WAAW,EAAE,CAAC;QACjB,OAAO,KAAK,CAAC;IACf,CAAC;IACD,OAAO,IAAI,CAAC,GAAG,EAAE,GAAG,WAAW,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;AACvD,CAAC;AAED,SAAgB,qBAAqB,CAAC,KAAa;IACjD,OAAO,IAAI,WAAW,EAAE,CAAC,MAAM,CAAC,gCAAgC,KAAK,EAAE,CAAC,CAAC;AAC3E,CAAC","sourcesContent":["import type { PubkeyStr } from \"../shared\";\n\nexport * from \"./client\";\nexport * from \"./native\";\n\nexport interface User {\n id: string;\n wallet_address: string;\n linked_account: LinkedAccount;\n privy_id?: string;\n embedded_wallet?: EmbeddedWallet;\n x_username?: string;\n x_user_id?: string;\n x_display_name?: string;\n google_email?: string;\n}\n\nexport interface LinkedAccount {\n id: string;\n type: LinkedAccountType;\n chain?: ChainType;\n address: string;\n}\n\nexport enum LinkedAccountType {\n Wallet = \"wallet\",\n TwitterOauth = \"twitter_oauth\",\n GoogleOauth = \"google_oauth\",\n}\n\nexport enum ChainType {\n Solana = \"solana\",\n Ethereum = \"ethereum\",\n}\n\nexport interface EmbeddedWallet {\n privy_id: string;\n chain: ChainType;\n address: string;\n}\n\nexport interface AuthCredentials {\n user_id: string;\n wallet_address: PubkeyStr;\n expires_at: Date;\n}\n\nexport function isAuthenticated(credentials?: AuthCredentials): boolean {\n if (!credentials) {\n return false;\n }\n return Date.now() < credentials.expires_at.getTime();\n}\n\nexport function generateSigninMessage(nonce: string): Uint8Array {\n return new TextEncoder().encode(`Sign in to Lightcone\\nNonce: ${nonce}`);\n}\n\nexport interface LoginRequest {\n message: string;\n signature_bs58: string;\n pubkey_bytes: number[];\n use_embedded_wallet?: boolean;\n}\n\nexport interface LoginResponse {\n token: string;\n user_id: string;\n wallet_address: string;\n expires_at: number;\n linked_account: LinkedAccount;\n privy_id?: string;\n embedded_wallet?: EmbeddedWallet;\n x_username?: string;\n x_user_id?: string;\n x_display_name?: string;\n google_email?: string;\n}\n\nexport interface MeResponse {\n user_id: string;\n wallet_address: string;\n linked_account: LinkedAccount;\n privy_id?: string;\n embedded_wallet?: EmbeddedWallet;\n x_username?: string;\n x_user_id?: string;\n x_display_name?: string;\n google_email?: string;\n expires_at: number;\n}\n\nexport interface NonceResponse {\n nonce: string;\n}\n"]}
|
package/dist/client.d.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
|
+
import { Connection, PublicKey } from "@solana/web3.js";
|
|
1
2
|
import { Auth, type AuthCredentials } from "./auth";
|
|
3
|
+
import type { ClientContext, DecimalsCache } from "./context";
|
|
2
4
|
import { Admin } from "./domain/admin";
|
|
3
5
|
import { Markets } from "./domain/market";
|
|
4
6
|
import { Notifications } from "./domain/notification";
|
|
@@ -6,14 +8,14 @@ import { Orders } from "./domain/order";
|
|
|
6
8
|
import { Orderbooks } from "./domain/orderbook";
|
|
7
9
|
import type { DecimalsResponse } from "./domain/orderbook";
|
|
8
10
|
import { Positions } from "./domain/position";
|
|
9
|
-
import { DepositPriceClient } from "./domain/deposit_price";
|
|
10
11
|
import { PriceHistoryClient } from "./domain/price_history";
|
|
11
12
|
import { Referrals } from "./domain/referral";
|
|
12
13
|
import { Trades } from "./domain/trade";
|
|
13
14
|
import { LightconeHttp } from "./http";
|
|
14
15
|
import { Privy } from "./privy";
|
|
16
|
+
import { Rpc } from "./rpc";
|
|
15
17
|
import { WsClient, type WsConfig } from "./ws";
|
|
16
|
-
declare class DecimalsCache {
|
|
18
|
+
declare class DecimalsCacheImpl implements DecimalsCache {
|
|
17
19
|
private readonly map;
|
|
18
20
|
get(orderbookId: string): DecimalsResponse | undefined;
|
|
19
21
|
set(orderbookId: string, response: DecimalsResponse): void;
|
|
@@ -27,31 +29,37 @@ declare class AuthState {
|
|
|
27
29
|
setCredentials(credentials: AuthCredentials | undefined): void;
|
|
28
30
|
clearCaches(): Promise<void>;
|
|
29
31
|
}
|
|
30
|
-
export declare class LightconeClient {
|
|
32
|
+
export declare class LightconeClient implements ClientContext {
|
|
31
33
|
readonly http: LightconeHttp;
|
|
34
|
+
readonly programId: PublicKey;
|
|
35
|
+
readonly connection?: Connection;
|
|
32
36
|
private readonly wsConfigValue;
|
|
33
37
|
private readonly decimalsCacheStore;
|
|
34
38
|
private readonly authStateStore;
|
|
35
39
|
constructor(params: {
|
|
36
40
|
http: LightconeHttp;
|
|
37
41
|
wsConfig: WsConfig;
|
|
42
|
+
programId?: PublicKey;
|
|
43
|
+
connection?: Connection;
|
|
38
44
|
authCredentials?: AuthCredentials;
|
|
39
|
-
decimalsCache?:
|
|
45
|
+
decimalsCache?: DecimalsCacheImpl;
|
|
40
46
|
authState?: AuthState;
|
|
41
47
|
});
|
|
42
48
|
static builder(): LightconeClientBuilder;
|
|
49
|
+
/** Decimals cache accessor for sub-clients. */
|
|
50
|
+
get decimalsCache(): DecimalsCache;
|
|
43
51
|
markets(): Markets;
|
|
44
52
|
orderbooks(): Orderbooks;
|
|
45
53
|
orders(): Orders;
|
|
46
54
|
positions(): Positions;
|
|
47
55
|
trades(): Trades;
|
|
48
56
|
priceHistory(): PriceHistoryClient;
|
|
49
|
-
depositPrice(): DepositPriceClient;
|
|
50
57
|
notifications(): Notifications;
|
|
51
58
|
admin(): Admin;
|
|
52
59
|
auth(): Auth;
|
|
53
60
|
privy(): Privy;
|
|
54
61
|
referrals(): Referrals;
|
|
62
|
+
rpc(): Rpc;
|
|
55
63
|
wsConfig(): WsConfig;
|
|
56
64
|
ws(): WsClient;
|
|
57
65
|
clearDecimalsCache(): Promise<void>;
|
|
@@ -61,12 +69,16 @@ export declare class LightconeClientBuilder {
|
|
|
61
69
|
private baseUrlValue;
|
|
62
70
|
private wsUrlValue;
|
|
63
71
|
private authCredentials?;
|
|
72
|
+
private programIdValue;
|
|
73
|
+
private rpcUrlValue?;
|
|
64
74
|
baseUrl(url: string): LightconeClientBuilder;
|
|
65
75
|
withBaseUrl(url: string): LightconeClientBuilder;
|
|
66
76
|
wsUrl(url: string): LightconeClientBuilder;
|
|
67
77
|
withWsUrl(url: string): LightconeClientBuilder;
|
|
68
78
|
auth(credentials: AuthCredentials): LightconeClientBuilder;
|
|
69
79
|
withAuth(credentials: AuthCredentials): LightconeClientBuilder;
|
|
80
|
+
programId(id: PublicKey): LightconeClientBuilder;
|
|
81
|
+
rpcUrl(url: string): LightconeClientBuilder;
|
|
70
82
|
build(): LightconeClient;
|
|
71
83
|
}
|
|
72
84
|
export {};
|
package/dist/client.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAAM,iBAAiB,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,uBAAuB,CAAC;AACtD,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAChD,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AACxD,OAAO,EAAE,IAAI,EAAE,KAAK,eAAe,EAAE,MAAM,QAAQ,CAAC;AACpD,OAAO,KAAK,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC9D,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACvC,OAAO,EAAE,OAAO,EAAE,MAA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c,CAAyB;IAC/C,OAAO,CAAC,WAAW,CAAC,CAAS;IAE7B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAI5C,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAKhD,KAAK,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAI1C,SAAS,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAK9C,IAAI,CAAC,WAAW,EAAE,eAAe,GAAG,sBAAsB;IAI1D,QAAQ,CAAC,WAAW,EAAE,eAAe,GAAG,sBAAsB;IAK9D,SAAS,CAAC,EAAE,EAAE,SAAS,GAAG,sBAAsB;IAKhD,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,sBAAsB;IAK3C,KAAK,IAAI,eAAe;CAkBzB"}
|
package/dist/client.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LightconeClientBuilder = exports.LightconeClient = void 0;
|
|
4
|
+
const web3_js_1 = require("@solana/web3.js");
|
|
4
5
|
const auth_1 = require("./auth");
|
|
5
6
|
const admin_1 = require("./domain/admin");
|
|
6
7
|
const market_1 = require("./domain/market");
|
|
@@ -8,15 +9,16 @@ const notification_1 = require("./domain/notification");
|
|
|
8
9
|
const order_1 = require("./domain/order");
|
|
9
10
|
const orderbook_1 = require("./domain/orderbook");
|
|
10
11
|
const position_1 = require("./domain/position");
|
|
11
|
-
const deposit_price_1 = require("./domain/deposit_price");
|
|
12
12
|
const price_history_1 = require("./domain/price_history");
|
|
13
13
|
const referral_1 = require("./domain/referral");
|
|
14
14
|
const trade_1 = require("./domain/trade");
|
|
15
15
|
const http_1 = require("./http");
|
|
16
16
|
const network_1 = require("./network");
|
|
17
17
|
const privy_1 = require("./privy");
|
|
18
|
+
const constants_1 = require("./program/constants");
|
|
19
|
+
const rpc_1 = require("./rpc");
|
|
18
20
|
const ws_1 = require("./ws");
|
|
19
|
-
class
|
|
21
|
+
class DecimalsCacheImpl {
|
|
20
22
|
map = new Map();
|
|
21
23
|
get(orderbookId) {
|
|
22
24
|
return this.map.get(orderbookId);
|
|
@@ -47,13 +49,17 @@ class AuthState {
|
|
|
47
49
|
}
|
|
48
50
|
class LightconeClient {
|
|
49
51
|
http;
|
|
52
|
+
programId;
|
|
53
|
+
connection;
|
|
50
54
|
wsConfigValue;
|
|
51
55
|
decimalsCacheStore;
|
|
52
56
|
authStateStore;
|
|
53
57
|
constructor(params) {
|
|
54
58
|
this.http = params.http;
|
|
59
|
+
this.programId = params.programId ?? constants_1.PROGRAM_ID;
|
|
60
|
+
this.connection = params.connection;
|
|
55
61
|
this.wsConfigValue = params.wsConfig;
|
|
56
|
-
this.decimalsCacheStore = params.decimalsCache ?? new
|
|
62
|
+
this.decimalsCacheStore = params.decimalsCache ?? new DecimalsCacheImpl();
|
|
57
63
|
this.authStateStore =
|
|
58
64
|
params.authState ??
|
|
59
65
|
new AuthState(async () => this.clearDecimalsCache(), params.authCredentials);
|
|
@@ -61,14 +67,16 @@ class LightconeClient {
|
|
|
61
67
|
static builder() {
|
|
62
68
|
return new LightconeClientBuilder();
|
|
63
69
|
}
|
|
70
|
+
/** Decimals cache accessor for sub-clients. */
|
|
71
|
+
get decimalsCache() {
|
|
72
|
+
return this.decimalsCacheStore;
|
|
73
|
+
}
|
|
74
|
+
// ── Sub-client accessors ─────────────────────────────────────────────
|
|
64
75
|
markets() {
|
|
65
76
|
return new market_1.Markets(this);
|
|
66
77
|
}
|
|
67
78
|
orderbooks() {
|
|
68
|
-
return new orderbook_1.Orderbooks(
|
|
69
|
-
http: this.http,
|
|
70
|
-
decimalsCache: this.decimalsCacheStore,
|
|
71
|
-
});
|
|
79
|
+
return new orderbook_1.Orderbooks(this, this.decimalsCacheStore);
|
|
72
80
|
}
|
|
73
81
|
orders() {
|
|
74
82
|
return new order_1.Orders(this);
|
|
@@ -82,9 +90,6 @@ class LightconeClient {
|
|
|
82
90
|
priceHistory() {
|
|
83
91
|
return new price_history_1.PriceHistoryClient(this);
|
|
84
92
|
}
|
|
85
|
-
depositPrice() {
|
|
86
|
-
return new deposit_price_1.DepositPriceClient(this);
|
|
87
|
-
}
|
|
88
93
|
notifications() {
|
|
89
94
|
return new notification_1.Notifications(this);
|
|
90
95
|
}
|
|
@@ -103,6 +108,9 @@ class LightconeClient {
|
|
|
103
108
|
referrals() {
|
|
104
109
|
return new referral_1.Referrals(this);
|
|
105
110
|
}
|
|
111
|
+
rpc() {
|
|
112
|
+
return new rpc_1.Rpc(this);
|
|
113
|
+
}
|
|
106
114
|
wsConfig() {
|
|
107
115
|
return this.wsConfigValue;
|
|
108
116
|
}
|
|
@@ -116,6 +124,10 @@ class LightconeClient {
|
|
|
116
124
|
return new LightconeClient({
|
|
117
125
|
http: this.http,
|
|
118
126
|
wsConfig: { ...this.wsConfigValue },
|
|
127
|
+
programId: this.programId,
|
|
128
|
+
connection: this.connection
|
|
129
|
+
? new web3_js_1.Connection(this.connection.rpcEndpoint)
|
|
130
|
+
: undefined,
|
|
119
131
|
decimalsCache: this.decimalsCacheStore,
|
|
120
132
|
authState: this.authStateStore,
|
|
121
133
|
});
|
|
@@ -126,6 +138,8 @@ class LightconeClientBuilder {
|
|
|
126
138
|
baseUrlValue = network_1.DEFAULT_API_URL;
|
|
127
139
|
wsUrlValue = network_1.DEFAULT_WS_URL;
|
|
128
140
|
authCredentials;
|
|
141
|
+
programIdValue = constants_1.PROGRAM_ID;
|
|
142
|
+
rpcUrlValue;
|
|
129
143
|
baseUrl(url) {
|
|
130
144
|
return this.withBaseUrl(url);
|
|
131
145
|
}
|
|
@@ -147,6 +161,14 @@ class LightconeClientBuilder {
|
|
|
147
161
|
this.authCredentials = credentials;
|
|
148
162
|
return this;
|
|
149
163
|
}
|
|
164
|
+
programId(id) {
|
|
165
|
+
this.programIdValue = id;
|
|
166
|
+
return this;
|
|
167
|
+
}
|
|
168
|
+
rpcUrl(url) {
|
|
169
|
+
this.rpcUrlValue = url;
|
|
170
|
+
return this;
|
|
171
|
+
}
|
|
150
172
|
build() {
|
|
151
173
|
return new LightconeClient({
|
|
152
174
|
http: new http_1.LightconeHttp(this.baseUrlValue),
|
|
@@ -158,6 +180,10 @@ class LightconeClientBuilder {
|
|
|
158
180
|
pingIntervalMs: 30_000,
|
|
159
181
|
pongTimeoutMs: 1_000,
|
|
160
182
|
},
|
|
183
|
+
programId: this.programIdValue,
|
|
184
|
+
connection: this.rpcUrlValue
|
|
185
|
+
? new web3_js_1.Connection(this.rpcUrlValue)
|
|
186
|
+
: undefined,
|
|
161
187
|
authCredentials: this.authCredentials,
|
|
162
188
|
});
|
|
163
189
|
}
|
package/dist/client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";;;AAAA,iCAAoD;AACpD,0CAAuC;AACvC,4CAA0C;AAC1C,wDAAsD;AACtD,0CAAwC;AACxC,kDAAgD;AAEhD,gDAA8C;AAC9C,0DAA4D;AAC5D,0DAA4D;AAC5D,gDAA8C;AAC9C,0CAAwC;AACxC,iCAAuC;AACvC,uCAA4D;AAC5D,mCAAgC;AAChC,6BAA+C;AAE/C,MAAM,aAAa;IACA,GAAG,GAAG,IAAI,GAAG,EAA4B,CAAC;IAE3D,GAAG,CAAC,WAAmB;QACrB,OAAO,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACnC,CAAC;IAED,GAAG,CAAC,WAAmB,EAAE,QAA0B;QACjD,IAAI,CAAC,GAAG,CAAC,GAAG,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;IACtC,CAAC;IAED,KAAK;QACH,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,CAAC;IACnB,CAAC;CACF;AAED,MAAM,SAAS;IAIM;IAHX,gBAAgB,CAA8B;IAEtD,YACmB,aAAkC,EACnD,OAAyB;QADR,kBAAa,GAAb,aAAa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B;IAE1C,OAAO,CAAC,GAAW;QACjB,OAAO,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC/B,CAAC;IAED,WAAW,CAAC,GAAW;QACrB,IAAI,CAAC,YAAY,GAAG,GAAG,CAAC;QACxB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK,CAAC,GAAW;QACf,OAAO,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;IAED,SAAS,CAAC,GAAW;QACnB,IAAI,CAAC,UAAU,GAAG,GAAG,CAAC;QACtB,OAAO,IAAI,CAAC;IACd,CAAC;IAED,IAAI,CAAC,WAA4B;QAC/B,OAAO,IAAI,CAAC,QAAQ,CAAC,WAAW,CAAC,CAAC;IACpC,CAAC;IAED,QAAQ,CAAC,WAA4B;QACnC,IAAI,CAAC,eAAe,GAAG,WAAW,CAAC;QACnC,OAAO,IAAI,CAAC;IACd,CAAC;IAED,KAAK;QACH,OAAO,IAAI,eAAe,CAAC;YACzB,IAAI,EAAE,IAAI,oBAAa,CAAC,IAAI,CAAC,YAAY,CAAC;YAC1C,QAAQ,EAAE;gBACR,GAAG,EAAE,IAAI,CAAC,UAAU;gBACpB,SAAS,EAAE,IAAI;gBACf,oBAAoB,EAAE,EAAE;gBACxB,oBAAoB,EAAE,KAAK;gBAC3B,cAAc,EAAE,MAAM;gBACtB,aAAa,EAAE,KAAK;aACrB;YACD,eAAe,EAAE,IAAI,CAAC,eAAe;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AA9CD,wDA8CC","sourcesContent":["import { Auth, type AuthCredentials } from \"./auth\";\nimport { Admin } from \"./domain/admin\";\nimport { Markets } from \"./domain/market\";\nimport { Notifications } from \"./domain/notification\";\nimport { Orders } from \"./domain/order\";\nimport { Orderbooks } from \"./domain/orderbook\";\nimport type { DecimalsResponse } from \"./domain/orderbook\";\nimport { Positions } from \"./domain/position\";\nimport { DepositPriceClient } from \"./domain/deposit_price\";\nimport { PriceHistoryClient } from \"./domain/price_history\";\nimport { Referrals } from \"./domain/referral\";\nimport { Trades } from \"./domain/trade\";\nimport { LightconeHttp } from \"./http\";\nimport { DEFAULT_API_URL, DEFAULT_WS_URL } from \"./network\";\nimport { Privy } from \"./privy\";\nimport { WsClient, type WsConfig } from \"./ws\";\n\nclass DecimalsCache {\n private readonly map = new Map<string, DecimalsResponse>();\n\n get(orderbookId: string): DecimalsResponse | undefined {\n return this.map.get(orderbookId);\n }\n\n set(orderbookId: string, response: DecimalsResponse): void {\n this.map.set(orderbookId, response);\n }\n\n clear(): void {\n this.map.clear();\n }\n}\n\nclass AuthState {\n private credentialsValue: AuthCredentials | undefined;\n\n constructor(\n private readonly clearCachesFn: () => Promise<void>,\n initial?: AuthCredentials\n ) {\n this.credentialsValue = initial;\n }\n\n getCredentials(): AuthCredentials | undefined {\n return this.credentialsValue;\n }\n\n setCredentials(credentials: AuthCredentials | undefined): void {\n this.credentialsValue = credentials;\n }\n\n async clearCaches(): Promise<void> {\n await this.clearCachesFn();\n }\n}\n\nexport class LightconeClient {\n readonly http: LightconeHttp;\n private readonly wsConfigValue: WsConfig;\n private readonly decimalsCacheStore: DecimalsCache;\n private readonly authStateStore: AuthState;\n\n constructor(params: {\n http: LightconeHttp;\n wsConfig: WsConfig;\n authCredentials?: AuthCredentials;\n decimalsCache?: DecimalsCache;\n authState?: AuthState;\n }) {\n this.http = params.http;\n this.wsConfigValue = params.wsConfig;\n this.decimalsCacheStore = params.decimalsCache ?? new DecimalsCache();\n this.authStateStore =\n params.authState ??\n new AuthState(async () => this.clearDecimalsCache(), params.authCredentials);\n }\n\n static builder(): LightconeClientBuilder {\n return new LightconeClientBuilder();\n }\n\n markets(): Markets {\n return new Markets(this);\n }\n\n orderbooks(): Orderbooks {\n return new Orderbooks({\n http: this.http,\n decimalsCache: this.decimalsCacheStore,\n });\n }\n\n orders(): Orders {\n return new Orders(this);\n }\n\n positions(): Positions {\n return new Positions(this);\n }\n\n trades(): Trades {\n return new Trades(this);\n }\n\n priceHistory(): PriceHistoryClient {\n return new PriceHistoryClient(this);\n }\n\n depositPrice(): DepositPriceClient {\n return new DepositPriceClient(this);\n }\n\n notifications(): Notifications {\n return new Notifications(this);\n }\n\n admin(): Admin {\n return new Admin(this);\n }\n\n auth(): Auth {\n return new Auth({\n http: this.http,\n authState: this.authStateStore,\n });\n }\n\n privy(): Privy {\n return new Privy(this);\n }\n\n referrals(): Referrals {\n return new Referrals(this);\n }\n\n wsConfig(): WsConfig {\n return this.wsConfigValue;\n }\n\n ws(): WsClient {\n return new WsClient(this.wsConfigValue, this.http.authTokenRef());\n }\n\n async clearDecimalsCache(): Promise<void> {\n this.decimalsCacheStore.clear();\n }\n\n clone(): LightconeClient {\n return new LightconeClient({\n http: this.http,\n wsConfig: { ...this.wsConfigValue },\n decimalsCache: this.decimalsCacheStore,\n authState: this.authStateStore,\n });\n }\n}\n\nexport class LightconeClientBuilder {\n private baseUrlValue: string = DEFAULT_API_URL;\n private wsUrlValue: string = DEFAULT_WS_URL;\n private authCredentials?: AuthCredentials;\n\n baseUrl(url: string): LightconeClientBuilder {\n return this.withBaseUrl(url);\n }\n\n withBaseUrl(url: string): LightconeClientBuilder {\n this.baseUrlValue = url;\n return this;\n }\n\n wsUrl(url: string): LightconeClientBuilder {\n return this.withWsUrl(url);\n }\n\n withWsUrl(url: string): LightconeClientBuilder {\n this.wsUrlValue = url;\n return this;\n }\n\n auth(credentials: AuthCredentials): LightconeClientBuilder {\n return this.withAuth(credentials);\n }\n\n withAuth(credentials: AuthCredentials): LightconeClientBuilder {\n this.authCredentials = credentials;\n return this;\n }\n\n build(): LightconeClient {\n return new LightconeClient({\n http: new LightconeHttp(this.baseUrlValue),\n wsConfig: {\n url: this.wsUrlValue,\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 1_000,\n },\n authCredentials: this.authCredentials,\n });\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"client.js","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;SACtC,CAAC,CAAC;IACL,CAAC;CACF;AA9DD,wDA8DC","sourcesContent":["import { Connection, PublicKey } from \"@solana/web3.js\";\nimport { Auth, type AuthCredentials } from \"./auth\";\nimport type { ClientContext, DecimalsCache } from \"./context\";\nimport { Admin } from \"./domain/admin\";\nimport { Markets } from \"./domain/market\";\nimport { Notifications } from \"./domain/notification\";\nimport { Orders } from \"./domain/order\";\nimport { Orderbooks } from \"./domain/orderbook\";\nimport type { DecimalsResponse } from \"./domain/orderbook\";\nimport { Positions } from \"./domain/position\";\nimport { PriceHistoryClient } from \"./domain/price_history\";\nimport { Referrals } from \"./domain/referral\";\nimport { Trades } from \"./domain/trade\";\nimport { LightconeHttp } from \"./http\";\nimport { DEFAULT_API_URL, DEFAULT_WS_URL } from \"./network\";\nimport { Privy } from \"./privy\";\nimport { PROGRAM_ID } from \"./program/constants\";\nimport { Rpc } from \"./rpc\";\nimport { WsClient, type WsConfig } from \"./ws\";\n\nclass DecimalsCacheImpl implements DecimalsCache {\n private readonly map = new Map<string, DecimalsResponse>();\n\n get(orderbookId: string): DecimalsResponse | undefined {\n return this.map.get(orderbookId);\n }\n\n set(orderbookId: string, response: DecimalsResponse): void {\n this.map.set(orderbookId, response);\n }\n\n clear(): void {\n this.map.clear();\n }\n}\n\nclass AuthState {\n private credentialsValue: AuthCredentials | undefined;\n\n constructor(\n private readonly clearCachesFn: () => Promise<void>,\n initial?: AuthCredentials\n ) {\n this.credentialsValue = initial;\n }\n\n getCredentials(): AuthCredentials | undefined {\n return this.credentialsValue;\n }\n\n setCredentials(credentials: AuthCredentials | undefined): void {\n this.credentialsValue = credentials;\n }\n\n async clearCaches(): Promise<void> {\n await this.clearCachesFn();\n }\n}\n\nexport class LightconeClient implements ClientContext {\n readonly http: LightconeHttp;\n readonly programId: PublicKey;\n readonly connection?: Connection;\n private readonly wsConfigValue: WsConfig;\n private readonly decimalsCacheStore: DecimalsCacheImpl;\n private readonly authStateStore: AuthState;\n\n constructor(params: {\n http: LightconeHttp;\n wsConfig: WsConfig;\n programId?: PublicKey;\n connection?: Connection;\n authCredentials?: AuthCredentials;\n decimalsCache?: DecimalsCacheImpl;\n authState?: AuthState;\n }) {\n this.http = params.http;\n this.programId = params.programId ?? PROGRAM_ID;\n this.connection = params.connection;\n this.wsConfigValue = params.wsConfig;\n this.decimalsCacheStore = params.decimalsCache ?? new DecimalsCacheImpl();\n this.authStateStore =\n params.authState ??\n new AuthState(async () => this.clearDecimalsCache(), params.authCredentials);\n }\n\n static builder(): LightconeClientBuilder {\n return new LightconeClientBuilder();\n }\n\n /** Decimals cache accessor for sub-clients. */\n get decimalsCache(): DecimalsCache {\n return this.decimalsCacheStore;\n }\n\n // ── Sub-client accessors ─────────────────────────────────────────────\n\n markets(): Markets {\n return new Markets(this);\n }\n\n orderbooks(): Orderbooks {\n return new Orderbooks(this, this.decimalsCacheStore);\n }\n\n orders(): Orders {\n return new Orders(this);\n }\n\n positions(): Positions {\n return new Positions(this);\n }\n\n trades(): Trades {\n return new Trades(this);\n }\n\n priceHistory(): PriceHistoryClient {\n return new PriceHistoryClient(this);\n }\n\n notifications(): Notifications {\n return new Notifications(this);\n }\n\n admin(): Admin {\n return new Admin(this);\n }\n\n auth(): Auth {\n return new Auth({\n http: this.http,\n authState: this.authStateStore,\n });\n }\n\n privy(): Privy {\n return new Privy(this);\n }\n\n referrals(): Referrals {\n return new Referrals(this);\n }\n\n rpc(): Rpc {\n return new Rpc(this);\n }\n\n wsConfig(): WsConfig {\n return this.wsConfigValue;\n }\n\n ws(): WsClient {\n return new WsClient(this.wsConfigValue, this.http.authTokenRef());\n }\n\n async clearDecimalsCache(): Promise<void> {\n this.decimalsCacheStore.clear();\n }\n\n clone(): LightconeClient {\n return new LightconeClient({\n http: this.http,\n wsConfig: { ...this.wsConfigValue },\n programId: this.programId,\n connection: this.connection\n ? new Connection(this.connection.rpcEndpoint)\n : undefined,\n decimalsCache: this.decimalsCacheStore,\n authState: this.authStateStore,\n });\n }\n}\n\nexport class LightconeClientBuilder {\n private baseUrlValue: string = DEFAULT_API_URL;\n private wsUrlValue: string = DEFAULT_WS_URL;\n private authCredentials?: AuthCredentials;\n private programIdValue: PublicKey = PROGRAM_ID;\n private rpcUrlValue?: string;\n\n baseUrl(url: string): LightconeClientBuilder {\n return this.withBaseUrl(url);\n }\n\n withBaseUrl(url: string): LightconeClientBuilder {\n this.baseUrlValue = url;\n return this;\n }\n\n wsUrl(url: string): LightconeClientBuilder {\n return this.withWsUrl(url);\n }\n\n withWsUrl(url: string): LightconeClientBuilder {\n this.wsUrlValue = url;\n return this;\n }\n\n auth(credentials: AuthCredentials): LightconeClientBuilder {\n return this.withAuth(credentials);\n }\n\n withAuth(credentials: AuthCredentials): LightconeClientBuilder {\n this.authCredentials = credentials;\n return this;\n }\n\n programId(id: PublicKey): LightconeClientBuilder {\n this.programIdValue = id;\n return this;\n }\n\n rpcUrl(url: string): LightconeClientBuilder {\n this.rpcUrlValue = url;\n return this;\n }\n\n build(): LightconeClient {\n return new LightconeClient({\n http: new LightconeHttp(this.baseUrlValue),\n wsConfig: {\n url: this.wsUrlValue,\n reconnect: true,\n maxReconnectAttempts: 10,\n baseReconnectDelayMs: 1_000,\n pingIntervalMs: 30_000,\n pongTimeoutMs: 1_000,\n },\n programId: this.programIdValue,\n connection: this.rpcUrlValue\n ? new Connection(this.rpcUrlValue)\n : undefined,\n authCredentials: this.authCredentials,\n });\n }\n}\n"]}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { Connection, PublicKey } from "@solana/web3.js";
|
|
2
|
+
import type { LightconeHttp } from "./http";
|
|
3
|
+
export interface ClientContext {
|
|
4
|
+
readonly http: LightconeHttp;
|
|
5
|
+
readonly programId: PublicKey;
|
|
6
|
+
readonly connection?: Connection;
|
|
7
|
+
}
|
|
8
|
+
export interface DecimalsCache {
|
|
9
|
+
get(orderbookId: string): unknown;
|
|
10
|
+
set(orderbookId: string, response: unknown): void;
|
|
11
|
+
clear(): void;
|
|
12
|
+
}
|
|
13
|
+
export declare function requireConnection(ctx: ClientContext): Connection;
|
|
14
|
+
//# sourceMappingURL=context.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.d.ts","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC7D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,QAAQ,CAAC;AAE5C,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,IAAI,EAAE,aAAa,CAAC;IAC7B,QAAQ,CAAC,SAAS,EAAE,SAAS,CAAC;IAC9B,QAAQ,CAAC,UAAU,CAAC,EAAE,UAAU,CAAC;CAClC;AAED,MAAM,WAAW,aAAa;IAC5B,GAAG,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC;IAClC,GAAG,CAAC,WAAW,EAAE,MAAM,EAAE,QAAQ,EAAE,OAAO,GAAG,IAAI,CAAC;IAClD,KAAK,IAAI,IAAI,CAAC;CACf;AAED,wBAAgB,iBAAiB,CAAC,GAAG,EAAE,aAAa,GAAG,UAAU,CAOhE"}
|
package/dist/context.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.requireConnection = requireConnection;
|
|
4
|
+
function requireConnection(ctx) {
|
|
5
|
+
if (!ctx.connection) {
|
|
6
|
+
throw new Error("RPC client not configured — use .rpcUrl() on the builder");
|
|
7
|
+
}
|
|
8
|
+
return ctx.connection;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=context.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"context.js","sourceRoot":"","sources":["../src/context.ts"],"names":[],"mappings":";;AAeA,8CAOC;AAPD,SAAgB,iBAAiB,CAAC,GAAkB;IAClD,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,0DAA0D,CAC3D,CAAC;IACJ,CAAC;IACD,OAAO,GAAG,CAAC,UAAU,CAAC;AACxB,CAAC","sourcesContent":["import type { Connection, PublicKey } from \"@solana/web3.js\";\nimport type { LightconeHttp } from \"./http\";\n\nexport interface ClientContext {\n readonly http: LightconeHttp;\n readonly programId: PublicKey;\n readonly connection?: Connection;\n}\n\nexport interface DecimalsCache {\n get(orderbookId: string): unknown;\n set(orderbookId: string, response: unknown): void;\n clear(): void;\n}\n\nexport function requireConnection(ctx: ClientContext): Connection {\n if (!ctx.connection) {\n throw new Error(\n \"RPC client not configured — use .rpcUrl() on the builder\"\n );\n }\n return ctx.connection;\n}\n"]}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
+
import type { ClientContext } from "../../context";
|
|
3
|
+
import type { CreateMarketParams, AddDepositMintParams, ActivateMarketParams, SettleMarketParams, SetAuthorityParams, WhitelistDepositTokenParams, CreateOrderbookParams, MatchOrdersMultiParams, DepositAndSwapParams } from "../../program/types";
|
|
2
4
|
import type { AdminEnvelope } from "./index";
|
|
3
5
|
import type { AllocateCodesRequest, AllocateCodesResponse, CreateNotificationRequest, CreateNotificationResponse, DismissNotificationRequest, DismissNotificationResponse, RevokeRequest, RevokeResponse, UnifiedMetadataRequest, UnifiedMetadataResponse, UnrevokeRequest, UnrevokeResponse, WhitelistRequest, WhitelistResponse } from "./wire";
|
|
4
|
-
interface ClientContext {
|
|
5
|
-
http: LightconeHttp;
|
|
6
|
-
}
|
|
7
6
|
export declare class Admin {
|
|
8
7
|
private readonly client;
|
|
9
8
|
constructor(client: ClientContext);
|
|
@@ -14,6 +13,17 @@ export declare class Admin {
|
|
|
14
13
|
unrevoke(envelope: AdminEnvelope<UnrevokeRequest>): Promise<UnrevokeResponse>;
|
|
15
14
|
createNotification(envelope: AdminEnvelope<CreateNotificationRequest>): Promise<CreateNotificationResponse>;
|
|
16
15
|
dismissNotification(envelope: AdminEnvelope<DismissNotificationRequest>): Promise<DismissNotificationResponse>;
|
|
16
|
+
initializeIx(authority: PublicKey): TransactionInstruction;
|
|
17
|
+
createMarketIx(params: CreateMarketParams, marketId: bigint): TransactionInstruction;
|
|
18
|
+
addDepositMintIx(params: AddDepositMintParams, market: PublicKey, numOutcomes: number): TransactionInstruction;
|
|
19
|
+
activateMarketIx(params: ActivateMarketParams): TransactionInstruction;
|
|
20
|
+
settleMarketIx(params: SettleMarketParams): TransactionInstruction;
|
|
21
|
+
setPausedIx(authority: PublicKey, paused: boolean): TransactionInstruction;
|
|
22
|
+
setOperatorIx(authority: PublicKey, newOperator: PublicKey): TransactionInstruction;
|
|
23
|
+
setAuthorityIx(params: SetAuthorityParams): TransactionInstruction;
|
|
24
|
+
whitelistDepositTokenIx(params: WhitelistDepositTokenParams): TransactionInstruction;
|
|
25
|
+
createOrderbookIx(params: CreateOrderbookParams): TransactionInstruction;
|
|
26
|
+
matchOrdersMultiIx(params: MatchOrdersMultiParams): TransactionInstruction;
|
|
27
|
+
depositAndSwapIx(params: DepositAndSwapParams): TransactionInstruction;
|
|
17
28
|
}
|
|
18
|
-
export {};
|
|
19
29
|
//# sourceMappingURL=client.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/domain/admin/client.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../../src/domain/admin/client.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAgBnD,OAAO,KAAK,EACV,kBAAkB,EAClB,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,kBAAkB,EAClB,2BAA2B,EA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