Skip to content

Commit b076f0b

Browse files
committed
fix: Workaround bug in ethers-decode-error
1 parent 624c6b2 commit b076f0b

File tree

2 files changed

+15
-7
lines changed

2 files changed

+15
-7
lines changed

javascript/engine-js/src/wallet/EthersAdapter.ts

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -102,11 +102,19 @@ export class EthersAdapter implements IWalletAdapter {
102102
if (EthersAdapter.isTransactionRejection(e))
103103
return false;
104104

105-
const errDecoder = ErrorDecoder.create(errorAbi)
106-
const decodedError = await errDecoder.decode(e);
107105
console.error(e);
108-
console.log("Decoded error: ", decodedError);
109-
if (decodedError.type != ErrorType.EmptyError && decodedError.type != ErrorType.UnknownError) {
106+
107+
let decodedError;
108+
109+
try {
110+
const errDecoder = ErrorDecoder.create(errorAbi)
111+
decodedError = await errDecoder.decode(e);
112+
console.log("Decoded error: ", decodedError);
113+
} catch (e: any){
114+
console.error("Failed to decode error: ", e);
115+
}
116+
117+
if (decodedError && decodedError.type != ErrorType.EmptyError && decodedError.type != ErrorType.UnknownError) {
110118

111119
let decodedMessage;
112120

javascript/tokenscript-viewer/src/components/viewers/util/showTransactionNotification.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ export const handleTransactionError = (e: any, showToast: EventEmitter<ShowToast
4040

4141
console.error(e);
4242

43-
let message = e.message;
43+
let message = e.shortMessage ?? e.message;
4444

4545
const revertMatch = message.match(/reverted with reason string '(.*)'/);
4646

@@ -81,8 +81,8 @@ export const handleTransactionError = (e: any, showToast: EventEmitter<ShowToast
8181
borderRadius: "5px",
8282
fontWeight: "500"
8383
}}
84-
onClick={() => navigator.clipboard.writeText(e.message)}>
85-
<copy-icon style={{paddingLeft: "0 !important"}} height={"20px"} copyText={e.message}/>
84+
onClick={() => navigator.clipboard.writeText(JSON.stringify(e))}>
85+
<copy-icon style={{paddingLeft: "0 !important"}} height={"20px"} copyText={JSON.stringify(e)}/>
8686
Copy Error
8787
</button>
8888
</div>

0 commit comments

Comments
 (0)