-
Notifications
You must be signed in to change notification settings - Fork 199
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'fix/wallet-package-deps' into dev
- Loading branch information
Showing
26 changed files
with
265 additions
and
254 deletions.
There are no files selected for viewing
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { GrpcUnaryRequestException } from './GrpcUnaryRequestException' | ||
import { HttpRequestException } from './HttpRequestException' | ||
import { Web3Exception } from './Web3Exception' | ||
import { GeneralException } from './GeneralException' | ||
import { LedgerException } from './LedgerException' | ||
import { LedgerCosmosException } from './LedgerCosmosException' | ||
import { MetamaskException } from './MetamaskException' | ||
import { TrustWalletException } from './TrustWalletException' | ||
import { OkxWalletException } from './OkxWalletException' | ||
import { TrezorException } from './TrezorException' | ||
import { CosmosWalletException } from './CosmosWalletException' | ||
import { TransactionException } from './TransactionException' | ||
import { WalletException } from './WalletException' | ||
import { BitGetException } from './BitGetException' | ||
|
||
export { | ||
Web3Exception, | ||
LedgerException, | ||
TrezorException, | ||
WalletException, | ||
GeneralException, | ||
BitGetException, | ||
MetamaskException, | ||
TransactionException, | ||
TrustWalletException, | ||
OkxWalletException, | ||
HttpRequestException, | ||
LedgerCosmosException, | ||
CosmosWalletException, | ||
GrpcUnaryRequestException, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,78 +1,3 @@ | ||
import { GrpcUnaryRequestException } from './GrpcUnaryRequestException' | ||
import { HttpRequestException } from './HttpRequestException' | ||
import { Web3Exception } from './Web3Exception' | ||
import { GeneralException } from './GeneralException' | ||
import { LedgerException } from './LedgerException' | ||
import { LedgerCosmosException } from './LedgerCosmosException' | ||
import { MetamaskException } from './MetamaskException' | ||
import { TrustWalletException } from './TrustWalletException' | ||
import { OkxWalletException } from './OkxWalletException' | ||
import { TrezorException } from './TrezorException' | ||
import { CosmosWalletException } from './CosmosWalletException' | ||
import { TransactionException } from './TransactionException' | ||
import { WalletException } from './WalletException' | ||
import { Exception } from '../types' | ||
import { ConcreteException } from '../exception' | ||
import { BitGetException } from './BitGetException' | ||
|
||
export type ThrownException = | ||
| GrpcUnaryRequestException | ||
| HttpRequestException | ||
| Web3Exception | ||
| GeneralException | ||
| LedgerException | ||
| MetamaskException | ||
| TrustWalletException | ||
| OkxWalletException | ||
| TrezorException | ||
| CosmosWalletException | ||
| TransactionException | ||
| WalletException | ||
| LedgerCosmosException | ||
| BitGetException | ||
|
||
export const isThrownException = (exception: Error | Exception): boolean => { | ||
if (exception instanceof ConcreteException) { | ||
return true | ||
} | ||
|
||
if ( | ||
[ | ||
'GrpcUnaryRequestException', | ||
'HttpRequestException', | ||
'Web3Exception', | ||
'GeneralException', | ||
'LedgerException', | ||
'LedgerCosmosException', | ||
'MetamaskException', | ||
'TrezorException', | ||
'CosmosWalletException', | ||
'TransactionException', | ||
'WalletException', | ||
'TrustWalletException', | ||
'OkxWalletException', | ||
'BitGetException', | ||
].includes(exception.constructor.name) | ||
) { | ||
return true | ||
} | ||
|
||
return false | ||
} | ||
|
||
export { | ||
Web3Exception, | ||
LedgerException, | ||
TrezorException, | ||
WalletException, | ||
GeneralException, | ||
BitGetException, | ||
MetamaskException, | ||
TransactionException, | ||
TrustWalletException, | ||
OkxWalletException, | ||
HttpRequestException, | ||
LedgerCosmosException, | ||
CosmosWalletException, | ||
GrpcUnaryRequestException, | ||
} | ||
export * from './exceptions' | ||
export * from './types' | ||
export * from './utils' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { | ||
Web3Exception, | ||
WalletException, | ||
TrezorException, | ||
BitGetException, | ||
LedgerException, | ||
GeneralException, | ||
MetamaskException, | ||
OkxWalletException, | ||
HttpRequestException, | ||
LedgerCosmosException, | ||
TrustWalletException, | ||
CosmosWalletException, | ||
TransactionException, | ||
GrpcUnaryRequestException, | ||
} from './exceptions' | ||
|
||
export type ThrownException = | ||
| GrpcUnaryRequestException | ||
| HttpRequestException | ||
| Web3Exception | ||
| GeneralException | ||
| LedgerException | ||
| MetamaskException | ||
| TrustWalletException | ||
| OkxWalletException | ||
| TrezorException | ||
| CosmosWalletException | ||
| TransactionException | ||
| WalletException | ||
| LedgerCosmosException | ||
| BitGetException |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
import { ConcreteException } from "../exception" | ||
import { Exception } from "../types" | ||
|
||
export const isThrownException = (exception: Error | Exception): boolean => { | ||
if (exception instanceof ConcreteException) { | ||
return true | ||
} | ||
|
||
if ( | ||
[ | ||
'GrpcUnaryRequestException', | ||
'HttpRequestException', | ||
'Web3Exception', | ||
'GeneralException', | ||
'LedgerException', | ||
'LedgerCosmosException', | ||
'MetamaskException', | ||
'TrezorException', | ||
'CosmosWalletException', | ||
'TransactionException', | ||
'WalletException', | ||
'TrustWalletException', | ||
'OkxWalletException', | ||
'BitGetException', | ||
].includes(exception.constructor.name) | ||
) { | ||
return true | ||
} | ||
|
||
return false | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import { ErrorCode, ErrorContextCode } from './codes' | ||
|
||
export enum HttpRequestMethod { | ||
Get = 'GET', | ||
Post = 'POST', | ||
Options = 'OPTIONS', | ||
} | ||
|
||
export enum ErrorType { | ||
Unspecified = 'unspecified', | ||
ChainError = 'chain-error', | ||
ExecutionError = 'execution-error', | ||
NotFoundError = 'not-found-error', | ||
ValidationError = 'validation-error', | ||
WalletError = 'wallet-error', | ||
WalletNotInstalledError = 'wallet-not-installed-error', | ||
GrpcUnaryRequest = 'grpc-unary-request', | ||
HttpRequest = 'http-request', | ||
Web3 = 'web3', | ||
Web3Gateway = 'web3-gateway', | ||
} | ||
|
||
export interface ErrorContext { | ||
code?: ErrorCode | ||
type?: ErrorType | ||
|
||
/** | ||
* Additional context needed for the exception | ||
*/ | ||
context?: string | ||
|
||
/** | ||
* Where is the exception thrown | ||
*/ | ||
contextModule?: string | ||
|
||
/** | ||
* Needed when we get a code error from a Http/Grpc Request | ||
* and we need to specify the error code for the particular message | ||
* for example why the transaction has failed | ||
* */ | ||
contextCode?: ErrorContextCode | ||
} | ||
|
||
export interface Exception { | ||
/** | ||
* The type of the Error | ||
*/ | ||
type: ErrorType | ||
|
||
/** | ||
* Error specific code (HttpStatus, GrpcStatus, etc) | ||
*/ | ||
code: ErrorCode | ||
|
||
/** | ||
* The name of the error (the name of the instance of the Exception) | ||
*/ | ||
name: string | ||
|
||
/** | ||
* Providing more context as to where the exception was thrown | ||
* (ex: on-chain module, etc) | ||
*/ | ||
contextModule?: string | ||
|
||
/** | ||
* Providing more context as to why the exception was thrown | ||
* (ex: on-chain error code, etc) | ||
*/ | ||
contextCode?: ErrorContextCode | ||
|
||
/** | ||
* Parsed message of the exception | ||
*/ | ||
message: string | ||
|
||
/** | ||
* The original stack of the error | ||
*/ | ||
stack?: string | ||
|
||
/** | ||
* The original message of the error | ||
*/ | ||
originalMessage: string | ||
|
||
parse?(): void | ||
|
||
parseError(error: Error): void | ||
|
||
parseContext(context?: ErrorContext): void | ||
|
||
setType(type: ErrorType): void | ||
|
||
setCode(code: ErrorCode): void | ||
|
||
setStack(stack: string): void | ||
|
||
setName(name: string): void | ||
|
||
setMessage(message: string): void | ||
|
||
setContextModule(contextModule: string): void | ||
|
||
toOriginalError(): Error | ||
|
||
toError(): Error | ||
|
||
toString(): string | ||
} |
Oops, something went wrong.