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