Skip to content

Commit

Permalink
Fix regex for extracting error message from rawLog
Browse files Browse the repository at this point in the history
It didn't catch this rawLog because we assumed `diaptch: submessages:` repeats but that's not true:
```
failed to execute message; message index: 0: dispatch: submessages: dispatch: submessages: submessages: submessages: submessages: encrypted: phcntUTSX2HHaFB14yKMPW3sg6ZN/VH7tXsaJzthoF9gwF78XAnYduHa0OsENc914UNYq+jbAkAdPLNcD3KLP3GdzTMbZouQziGkGaYaZ86CbH4SttBuob5C5gAtudk7mnMyEGY7a2yxjyKT: reply to contract failed: reply to contract failed: reply to contract failed: reply to contract failed
```
  • Loading branch information
assafmo committed Jun 9, 2023
1 parent 7a1df5f commit 0cba196
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/query/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export class ComputeQuerier {
} catch (err) {
try {
const errorMessageRgx =
/encrypted: (.+?): (?:instantiate|execute|query) contract failed/g;
/encrypted: (.+?): (?:instantiate|execute|query|reply to) contract failed/g;
const rgxMatches = errorMessageRgx.exec(err.message);
if (rgxMatches == null || rgxMatches?.length != 2) {
throw err;
Expand Down
2 changes: 1 addition & 1 deletion src/secret_network_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1242,7 +1242,7 @@ export class SecretNetworkClient {
} else if (txResp.code !== 0 && rawLog !== "") {
try {
const errorMessageRgx =
/; message index: (\d+):(?: dispatch: submessages:)* encrypted: (.+?): (?:instantiate|execute|query|reply to) contract failed/g;
/; message index: (\d+):.+?encrypted: (.+?): (?:instantiate|execute|query|reply to) contract failed/;
const rgxMatches = errorMessageRgx.exec(rawLog);
if (rgxMatches?.length === 3) {
const encryptedError = fromBase64(rgxMatches[2]);
Expand Down

0 comments on commit 0cba196

Please sign in to comment.