Skip to content

Commit

Permalink
fix smart contract error checking
Browse files Browse the repository at this point in the history
  • Loading branch information
quaisx committed Jun 15, 2024
1 parent 7981699 commit ae61c83
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
12 changes: 9 additions & 3 deletions src/query/compute.ts
Original file line number Diff line number Diff line change
Expand Up @@ -209,11 +209,17 @@ export class ComputeQuerier {
return JSON.parse(fromUtf8(fromBase64(fromUtf8(decryptedBase64Result))));
} catch (err) {
try {
const errorMessageRgx =
const errorMessageRgx1 =
/encrypted: (.+?): (?:instantiate|execute|query|reply to|migrate) contract failed/g;
const rgxMatches = errorMessageRgx.exec(err.message);
const errorMessageRgx2 =
/(?:instantiate|execute|query|reply to|migrate) contract failed: encrypted: ([\w+\/=]+)/g;

let rgxMatches = errorMessageRgx1.exec(err.message);
if (rgxMatches == null || rgxMatches?.length != 2) {
throw err;
rgxMatches = errorMessageRgx2.exec(err.message);
if (rgxMatches == null || rgxMatches?.length != 2) {
throw err;
}
}

const encryptedError = fromBase64(rgxMatches[1]);
Expand Down
8 changes: 4 additions & 4 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,10 +32,10 @@ export type Account = {

export const accounts: Account[] = [];

export const chain1LCD = "http://localhost:1317";
export const chain1LCD = "http://20.84.98.207:1316";
export const chain2LCD = "http://localhost:2317";

export const chain1RPC = "http://localhost:26657";
export const chain1RPC = "http://20.84.98.207:26657";
export const chain2RPC = "http://localhost:36657";

// Initialize genesis accounts
Expand Down Expand Up @@ -405,9 +405,9 @@ export async function waitForChainToStart({
break;
}
} catch (e) {
// console.error(e);
console.warn("Chain is not ready:" + e.message);
}
await sleep(250);
await sleep(1000);
}
}

Expand Down

0 comments on commit ae61c83

Please sign in to comment.