@depthhq/sdk 0.1.5 → 0.1.7

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.
@@ -17,6 +17,9 @@ function randomBytes(length) {
17
17
  }
18
18
 
19
19
  // src/operation/error.ts
20
+ import { AnchorError, ProgramError } from "@anchor-lang/core";
21
+ import { SendTransactionError } from "@solana/web3.js";
22
+
20
23
  class DepthError extends Error {
21
24
  code;
22
25
  stage;
@@ -34,6 +37,17 @@ class DepthError extends Error {
34
37
  }
35
38
  }
36
39
  function submissionError(operationId, cause) {
40
+ if (cause instanceof DepthError)
41
+ throw cause;
42
+ const message = cause instanceof Error ? cause.message : String(cause);
43
+ const code = cause && typeof cause === "object" && "code" in cause ? cause.code : undefined;
44
+ if (code === 4001 && !(cause instanceof ProgramError) || /user rejected|user denied|approval rejected|request rejected by the user/i.test(message)) {
45
+ throw new DepthError("WALLET_REJECTED", "submission", "Wallet approval declined", true, "Check the existing flow before retrying with the same client nonce", operationId, { cause });
46
+ }
47
+ const rejection = cause instanceof AnchorError ? cause.error.errorMessage : cause instanceof ProgramError ? cause.msg : cause instanceof SendTransactionError ? cause.transactionError.message : undefined;
48
+ if (rejection) {
49
+ throw new DepthError("SUBMISSION_REJECTED", "submission", `Transaction rejected: ${rejection}`, true, "Check the existing flow and resolve the rejection before retrying", operationId, { cause });
50
+ }
37
51
  throw new DepthError("SUBMISSION_UNCONFIRMED", "submission", "Submission was not confirmed; reconcile the saved operation before retrying", true, "Read the operation using the saved client nonce; do not create a new nonce", operationId, { cause });
38
52
  }
39
53
 
package/dist/index.d.ts CHANGED
@@ -34,3 +34,4 @@ export { DepthProvider } from "./chain/provider.js";
34
34
  export { authenticateManifest, captureDeployment, manifestBytes, verifyDeployment, } from "./chain/manifest.js";
35
35
  export type { DeploymentManifest, SignedManifest, DeploymentPolicy, } from "./chain/manifest.js";
36
36
  export { ViewSession } from "./view/session.js";
37
+ export { HttpConnection } from "./chain/connection.js";
package/dist/index.js CHANGED
@@ -44598,6 +44598,9 @@ import { DEPTH_PROGRAM_ID as DEPTH_PROGRAM_ID2 } from "@depthhq/bindings";
44598
44598
  import { PublicKey as PublicKey3 } from "@solana/web3.js";
44599
44599
 
44600
44600
  // src/operation/error.ts
44601
+ import { AnchorError, ProgramError } from "@anchor-lang/core";
44602
+ import { SendTransactionError } from "@solana/web3.js";
44603
+
44601
44604
  class DepthError extends Error {
44602
44605
  code;
44603
44606
  stage;
@@ -44615,6 +44618,17 @@ class DepthError extends Error {
44615
44618
  }
44616
44619
  }
44617
44620
  function submissionError(operationId, cause) {
44621
+ if (cause instanceof DepthError)
44622
+ throw cause;
44623
+ const message = cause instanceof Error ? cause.message : String(cause);
44624
+ const code2 = cause && typeof cause === "object" && "code" in cause ? cause.code : undefined;
44625
+ if (code2 === 4001 && !(cause instanceof ProgramError) || /user rejected|user denied|approval rejected|request rejected by the user/i.test(message)) {
44626
+ throw new DepthError("WALLET_REJECTED", "submission", "Wallet approval declined", true, "Check the existing flow before retrying with the same client nonce", operationId, { cause });
44627
+ }
44628
+ const rejection = cause instanceof AnchorError ? cause.error.errorMessage : cause instanceof ProgramError ? cause.msg : cause instanceof SendTransactionError ? cause.transactionError.message : undefined;
44629
+ if (rejection) {
44630
+ throw new DepthError("SUBMISSION_REJECTED", "submission", `Transaction rejected: ${rejection}`, true, "Check the existing flow and resolve the rejection before retrying", operationId, { cause });
44631
+ }
44618
44632
  throw new DepthError("SUBMISSION_UNCONFIRMED", "submission", "Submission was not confirmed; reconcile the saved operation before retrying", true, "Read the operation using the saved client nonce; do not create a new nonce", operationId, { cause });
44619
44633
  }
44620
44634
 
@@ -44737,7 +44751,7 @@ import * as anchor3 from "@anchor-lang/core";
44737
44751
  import { DEPTH_IDL as DEPTH_IDL2, DEPTH_PROGRAM_ID as DEPTH_PROGRAM_ID3 } from "@depthhq/bindings";
44738
44752
  import {
44739
44753
  ComputeBudgetProgram,
44740
- SendTransactionError,
44754
+ SendTransactionError as SendTransactionError2,
44741
44755
  PublicKey as PublicKey4,
44742
44756
  Transaction
44743
44757
  } from "@solana/web3.js";
@@ -44841,7 +44855,7 @@ class DepthProvider extends anchor3.AnchorProvider {
44841
44855
  });
44842
44856
  if (!failed?.meta?.err)
44843
44857
  throw error;
44844
- throw new SendTransactionError({
44858
+ throw new SendTransactionError2({
44845
44859
  action: "send",
44846
44860
  signature,
44847
44861
  transactionMessage: JSON.stringify(failed.meta.err),
@@ -48085,6 +48099,7 @@ export {
48085
48099
  TradeFlow,
48086
48100
  MarketData,
48087
48101
  MarketCatalog,
48102
+ HttpConnection,
48088
48103
  FundingDiscovery,
48089
48104
  FundingClient,
48090
48105
  ExecutionHistory,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@depthhq/sdk",
3
- "version": "0.1.5",
3
+ "version": "0.1.7",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -45,7 +45,7 @@
45
45
  "@solana/web3.js": "1.99.0",
46
46
  "buffer": "6.0.3",
47
47
  "@depthhq/schema": "0.1.2",
48
- "@depthhq/bindings": "0.1.2"
48
+ "@depthhq/bindings": "0.1.3"
49
49
  },
50
50
  "devDependencies": {
51
51
  "fake-indexeddb": "6.2.4"