@solana/errors 2.0.0-rc.3 → 2.0.0-rc.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.
@@ -677,6 +677,7 @@ var ORDERED_ERROR_NAMES = [
677
677
  "BuiltinProgramsMustConsumeComputeUnits"
678
678
  ];
679
679
  function getSolanaErrorFromInstructionError(index, instructionError) {
680
+ const numberIndex = Number(index);
680
681
  return getSolanaErrorFromRpcError(
681
682
  {
682
683
  errorCodeBaseOffset: 4615001,
@@ -684,21 +685,21 @@ function getSolanaErrorFromInstructionError(index, instructionError) {
684
685
  if (errorCode === SOLANA_ERROR__INSTRUCTION_ERROR__UNKNOWN) {
685
686
  return {
686
687
  errorName: rpcErrorName,
687
- index,
688
+ index: numberIndex,
688
689
  ...rpcErrorContext !== void 0 ? { instructionErrorContext: rpcErrorContext } : null
689
690
  };
690
691
  } else if (errorCode === SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM) {
691
692
  return {
692
- code: rpcErrorContext,
693
- index
693
+ code: Number(rpcErrorContext),
694
+ index: numberIndex
694
695
  };
695
696
  } else if (errorCode === SOLANA_ERROR__INSTRUCTION_ERROR__BORSH_IO_ERROR) {
696
697
  return {
697
698
  encodedData: rpcErrorContext,
698
- index
699
+ index: numberIndex
699
700
  };
700
701
  }
701
- return { index };
702
+ return { index: numberIndex };
702
703
  },
703
704
  orderedErrorNames: ORDERED_ERROR_NAMES,
704
705
  rpcEnumError: instructionError
@@ -767,11 +768,11 @@ function getSolanaErrorFromTransactionError(transactionError) {
767
768
  };
768
769
  } else if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR__DUPLICATE_INSTRUCTION) {
769
770
  return {
770
- index: rpcErrorContext
771
+ index: Number(rpcErrorContext)
771
772
  };
772
773
  } else if (errorCode === SOLANA_ERROR__TRANSACTION_ERROR__INSUFFICIENT_FUNDS_FOR_RENT || errorCode === SOLANA_ERROR__TRANSACTION_ERROR__PROGRAM_EXECUTION_TEMPORARILY_RESTRICTED) {
773
774
  return {
774
- accountIndex: rpcErrorContext.account_index
775
+ accountIndex: Number(rpcErrorContext.account_index)
775
776
  };
776
777
  }
777
778
  },
@@ -783,8 +784,9 @@ function getSolanaErrorFromTransactionError(transactionError) {
783
784
  }
784
785
 
785
786
  // src/json-rpc-error.ts
786
- function getSolanaErrorFromJsonRpcError({ code, data, message }) {
787
+ function getSolanaErrorFromJsonRpcError({ code: rawCode, data, message }) {
787
788
  let out;
789
+ const code = Number(rawCode);
788
790
  if (code === SOLANA_ERROR__JSON_RPC__SERVER_ERROR_SEND_TRANSACTION_PREFLIGHT_FAILURE) {
789
791
  const { err, ...preflightErrorContext } = data;
790
792
  const causeObject = err ? { cause: getSolanaErrorFromTransactionError(err) } : null;