-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for
sendTransaction
error fetching (#59)
* Add support for error fetching in sendTransaction * Bump patch version * Add support for broadcast type selection * Add support for typed errors * Add error ID and log to unknown error message
- Loading branch information
1 parent
4c314cb
commit cf2928b
Showing
12 changed files
with
508 additions
and
33 deletions.
There are no files selected for viewing
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
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,160 @@ | ||
import { | ||
GasOverflowErrorMessage, | ||
InsufficientCoinsErrorMessage, | ||
InsufficientFeeErrorMessage, | ||
InsufficientFundsErrorMessage, | ||
InternalErrorMessage, | ||
InvalidAddressErrorMessage, | ||
InvalidCoinsErrorMessage, | ||
InvalidGasWantedErrorMessage, | ||
InvalidPubKeyErrorMessage, | ||
InvalidSequenceErrorMessage, | ||
MemoTooLargeErrorMessage, | ||
NoSignaturesErrorMessage, | ||
OutOfGasErrorMessage, | ||
TooManySignaturesErrorMessage, | ||
TxDecodeErrorMessage, | ||
UnauthorizedErrorMessage, | ||
UnknownAddressErrorMessage, | ||
UnknownRequestErrorMessage, | ||
} from './messages'; | ||
|
||
class TM2Error extends Error { | ||
public log?: string; | ||
|
||
constructor(message: string, log?: string) { | ||
super(message); | ||
|
||
this.log = log; | ||
} | ||
} | ||
|
||
class InternalError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InternalErrorMessage, log); | ||
} | ||
} | ||
|
||
class TxDecodeError extends TM2Error { | ||
constructor(log?: string) { | ||
super(TxDecodeErrorMessage, log); | ||
} | ||
} | ||
|
||
class InvalidSequenceError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InvalidSequenceErrorMessage, log); | ||
} | ||
} | ||
|
||
class UnauthorizedError extends TM2Error { | ||
constructor(log?: string) { | ||
super(UnauthorizedErrorMessage, log); | ||
} | ||
} | ||
|
||
class InsufficientFundsError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InsufficientFundsErrorMessage, log); | ||
} | ||
} | ||
|
||
class UnknownRequestError extends TM2Error { | ||
constructor(log?: string) { | ||
super(UnknownRequestErrorMessage, log); | ||
} | ||
} | ||
|
||
class InvalidAddressError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InvalidAddressErrorMessage, log); | ||
} | ||
} | ||
|
||
class UnknownAddressError extends TM2Error { | ||
constructor(log?: string) { | ||
super(UnknownAddressErrorMessage, log); | ||
} | ||
} | ||
|
||
class InvalidPubKeyError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InvalidPubKeyErrorMessage, log); | ||
} | ||
} | ||
|
||
class InsufficientCoinsError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InsufficientCoinsErrorMessage, log); | ||
} | ||
} | ||
|
||
class InvalidCoinsError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InvalidCoinsErrorMessage, log); | ||
} | ||
} | ||
|
||
class InvalidGasWantedError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InvalidGasWantedErrorMessage, log); | ||
} | ||
} | ||
|
||
class OutOfGasError extends TM2Error { | ||
constructor(log?: string) { | ||
super(OutOfGasErrorMessage, log); | ||
} | ||
} | ||
|
||
class MemoTooLargeError extends TM2Error { | ||
constructor(log?: string) { | ||
super(MemoTooLargeErrorMessage, log); | ||
} | ||
} | ||
|
||
class InsufficientFeeError extends TM2Error { | ||
constructor(log?: string) { | ||
super(InsufficientFeeErrorMessage, log); | ||
} | ||
} | ||
|
||
class TooManySignaturesError extends TM2Error { | ||
constructor(log?: string) { | ||
super(TooManySignaturesErrorMessage, log); | ||
} | ||
} | ||
|
||
class NoSignaturesError extends TM2Error { | ||
constructor(log?: string) { | ||
super(NoSignaturesErrorMessage, log); | ||
} | ||
} | ||
|
||
class GasOverflowError extends TM2Error { | ||
constructor(log?: string) { | ||
super(GasOverflowErrorMessage, log); | ||
} | ||
} | ||
|
||
export { | ||
TM2Error, | ||
InternalError, | ||
TxDecodeError, | ||
InvalidSequenceError, | ||
UnauthorizedError, | ||
InsufficientFundsError, | ||
UnknownRequestError, | ||
InvalidAddressError, | ||
UnknownAddressError, | ||
InvalidPubKeyError, | ||
InsufficientCoinsError, | ||
InvalidCoinsError, | ||
InvalidGasWantedError, | ||
OutOfGasError, | ||
MemoTooLargeError, | ||
InsufficientFeeError, | ||
TooManySignaturesError, | ||
NoSignaturesError, | ||
GasOverflowError, | ||
}; |
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 @@ | ||
export * from './errors'; |
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,42 @@ | ||
// Errors constructed from: | ||
// https://github.com/gnolang/gno/blob/master/tm2/pkg/std/errors.go | ||
|
||
const InternalErrorMessage = 'internal error encountered'; | ||
const TxDecodeErrorMessage = 'unable to decode tx'; | ||
const InvalidSequenceErrorMessage = 'invalid sequence'; | ||
const UnauthorizedErrorMessage = 'signature is unauthorized'; | ||
const InsufficientFundsErrorMessage = 'insufficient funds'; | ||
const UnknownRequestErrorMessage = 'unknown request'; | ||
const InvalidAddressErrorMessage = 'invalid address'; | ||
const UnknownAddressErrorMessage = 'unknown address'; | ||
const InvalidPubKeyErrorMessage = 'invalid pubkey'; | ||
const InsufficientCoinsErrorMessage = 'insufficient coins'; | ||
const InvalidCoinsErrorMessage = 'invalid coins'; | ||
const InvalidGasWantedErrorMessage = 'invalid gas wanted'; | ||
const OutOfGasErrorMessage = 'out of gas'; | ||
const MemoTooLargeErrorMessage = 'memo too large'; | ||
const InsufficientFeeErrorMessage = 'insufficient fee'; | ||
const TooManySignaturesErrorMessage = 'too many signatures'; | ||
const NoSignaturesErrorMessage = 'no signatures'; | ||
const GasOverflowErrorMessage = 'gas overflow'; | ||
|
||
export { | ||
InternalErrorMessage, | ||
TxDecodeErrorMessage, | ||
InvalidSequenceErrorMessage, | ||
UnauthorizedErrorMessage, | ||
InsufficientFundsErrorMessage, | ||
UnknownRequestErrorMessage, | ||
InvalidAddressErrorMessage, | ||
UnknownAddressErrorMessage, | ||
InvalidPubKeyErrorMessage, | ||
InsufficientCoinsErrorMessage, | ||
InvalidCoinsErrorMessage, | ||
InvalidGasWantedErrorMessage, | ||
OutOfGasErrorMessage, | ||
MemoTooLargeErrorMessage, | ||
InsufficientFeeErrorMessage, | ||
TooManySignaturesErrorMessage, | ||
NoSignaturesErrorMessage, | ||
GasOverflowErrorMessage, | ||
}; |
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
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
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
Oops, something went wrong.