@depthhq/sdk 0.1.4 → 0.1.5
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/dist/index.js +23 -4
- package/package.json +3 -3
package/dist/index.js
CHANGED
|
@@ -47378,7 +47378,20 @@ class DepthClient {
|
|
|
47378
47378
|
return new DepthOperation(id, undefined, this.program, this.options.connection, (order) => this.requestFillView(order));
|
|
47379
47379
|
}
|
|
47380
47380
|
async requestQuoteView(quote) {
|
|
47381
|
-
|
|
47381
|
+
const record = await this.read("QuoteRecord", quote);
|
|
47382
|
+
if (!record.maker.equals(this.options.wallet.publicKey) || !record.market.equals(this.marketAddress) || !["active", "closing"].includes(enumName2(record.status)))
|
|
47383
|
+
throw new Error("Active quote does not belong to this wallet and market");
|
|
47384
|
+
const viewNonce = nonce();
|
|
47385
|
+
const view = pda([
|
|
47386
|
+
Buffer2.from("quote-view"),
|
|
47387
|
+
quote.toBuffer(),
|
|
47388
|
+
this.options.wallet.publicKey.toBuffer(),
|
|
47389
|
+
viewNonce.toArrayLike(Buffer2, "le", 8)
|
|
47390
|
+
]);
|
|
47391
|
+
return this.requestView("quote", view, viewNonce, {
|
|
47392
|
+
market: this.marketAddress,
|
|
47393
|
+
quote
|
|
47394
|
+
});
|
|
47382
47395
|
}
|
|
47383
47396
|
async requestBalanceView() {
|
|
47384
47397
|
const owner = this.options.wallet.publicKey;
|
|
@@ -47427,7 +47440,7 @@ class DepthClient {
|
|
|
47427
47440
|
return this.requestView("fill", view, viewNonce, { order });
|
|
47428
47441
|
}
|
|
47429
47442
|
async requestView(kind, view, viewNonce, accounts2) {
|
|
47430
|
-
const source = accounts2.balance ?? accounts2.marketAccount ?? accounts2.order;
|
|
47443
|
+
const source = accounts2.balance ?? accounts2.marketAccount ?? accounts2.order ?? accounts2.quote;
|
|
47431
47444
|
if (this.options.viewAuthorization === "session" || this.options.viewAuthorization !== "wallet" && this.options.privateViews === "device" && this.options.serviceUrl)
|
|
47432
47445
|
return this.views.request(kind, source);
|
|
47433
47446
|
const mxePublicKey = await getMXEPublicKey(this.provider, DEPTH_PROGRAM_ID8);
|
|
@@ -47436,8 +47449,8 @@ class DepthClient {
|
|
|
47436
47449
|
const secret = x25519.utils.randomSecretKey();
|
|
47437
47450
|
const publicKey = x25519.getPublicKey(secret);
|
|
47438
47451
|
const offset2 = nonce();
|
|
47439
|
-
const queue = await this.queue(kind === "balance" ? "view_balance" : kind === "market" ? "view_market" : "view_fill", offset2);
|
|
47440
|
-
const builder = kind === "balance" ? this.program.methods.requestBalanceView : kind === "market" ? this.program.methods.requestMarketView : this.program.methods.requestFillView;
|
|
47452
|
+
const queue = await this.queue(kind === "balance" ? "view_balance" : kind === "market" ? "view_market" : kind === "fill" ? "view_fill" : "view_quote", offset2);
|
|
47453
|
+
const builder = kind === "balance" ? this.program.methods.requestBalanceView : kind === "market" ? this.program.methods.requestMarketView : kind === "fill" ? this.program.methods.requestFillView : this.program.methods.requestQuoteView;
|
|
47441
47454
|
const signature = await builder(offset2, viewNonce, Array.from(publicKey)).accountsPartial({
|
|
47442
47455
|
...queue,
|
|
47443
47456
|
payer: this.options.wallet.publicKey,
|
|
@@ -47662,6 +47675,12 @@ class DepthClient {
|
|
|
47662
47675
|
}
|
|
47663
47676
|
async deferViewClose(kind, id) {
|
|
47664
47677
|
const view = new PublicKey11(id);
|
|
47678
|
+
const info = await this.options.connection.getAccountInfo(view, "confirmed");
|
|
47679
|
+
if (!info?.owner.equals(DEPTH_PROGRAM_ID8))
|
|
47680
|
+
return;
|
|
47681
|
+
const receipt = this.program.coder.accounts.decode(kind === "balance" ? "balanceView" : "marketView", info.data);
|
|
47682
|
+
if (!receipt.owner.equals(this.options.wallet.publicKey) || "pending" in receipt.status)
|
|
47683
|
+
return;
|
|
47665
47684
|
const method = kind === "balance" ? this.program.methods.closeBalanceView : this.program.methods.closeMarketView;
|
|
47666
47685
|
this.provider.deferClose(view, await method().accountsPartial({
|
|
47667
47686
|
owner: this.options.wallet.publicKey,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@depthhq/sdk",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.5",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
"@noble/hashes": "1.8.0",
|
|
45
45
|
"@solana/web3.js": "1.99.0",
|
|
46
46
|
"buffer": "6.0.3",
|
|
47
|
-
"@depthhq/
|
|
48
|
-
"@depthhq/
|
|
47
|
+
"@depthhq/schema": "0.1.2",
|
|
48
|
+
"@depthhq/bindings": "0.1.2"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"fake-indexeddb": "6.2.4"
|