Skip to content

Commit

Permalink
fix js bugs
Browse files Browse the repository at this point in the history
  • Loading branch information
simke9445 committed Nov 27, 2023
1 parent c1e49fb commit 0e323fa
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/condition.ts
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ export class Condition {
public resolveExprBool(ref: string, vars: warp_resolver.Variable[]): Promise<boolean> {
const v = this.variable(ref, vars);

return this.resolveVariable(v, (val) => Boolean(val));
return this.resolveVariable(v, (val) => (val === 'true' ? true : false));
}

public async resolveVariable<T>(variable: warp_resolver.Variable, cast: (val: string) => T): Promise<T> {
Expand Down Expand Up @@ -250,15 +250,15 @@ export class Condition {
>(this.wallet.lcd, this.contracts.resolver, { simulate_query: { query: query.init_fn.query } });
const extracted = JSONPath({ path: query.init_fn.selector, json: JSON.parse(resp.response) });

if (extracted[0] == null) {
if (extracted[0] === null) {
return null;
} else {
return String(extracted[0]);
}
}

public resolveStringOp = async (left: string, right: string, op: warp_resolver.StringOp): Promise<boolean> => {
if (left == null || right == null) {
if (left === null || right === null) {
return false;
}

Expand All @@ -277,7 +277,7 @@ export class Condition {
};

public resolveNumOp = async (left: Big, right: Big, op: warp_resolver.NumOp): Promise<boolean> => {
if (left == null || right == null) {
if (left === null || right === null) {
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion src/variables.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ export const resolveExternalVariable = async (external: warp_resolver.ExternalVa
const resp = await axios.request({ ...options, responseType: 'json' });
const extracted = JSONPath({ path: selector, json: resp.data });

if (extracted[0] == null) {
if (extracted[0] === null) {
return null;
} else {
const v = extracted[0];
Expand Down

0 comments on commit 0e323fa

Please sign in to comment.