Skip to content

Commit

Permalink
fix interpretation checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ArminaAiren committed Feb 14, 2024
1 parent 75b0bbe commit c2dcc91
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
4 changes: 2 additions & 2 deletions ui/tx/interpretation/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@ it('split string without capturing variables', () => {
});

it('checks that summary is valid', () => {
const result = checkSummary('{foo} {bar}', { foo: { type: 'string', value: 'foo' }, bar: { type: 'string', value: 'bar' } });
const result = checkSummary('{foo} {native} {bar}', { foo: { type: 'string', value: 'foo' }, bar: { type: 'string', value: 'bar' } });
expect(result).toBe(true);
});

it('checks that summary is invalid', () => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
// @ts-ignore:
const result = checkSummary('{foo} {bar}', { foo: { type: 'string', value: null }, bar: { type: 'string', value: 'bar' } });
const result = checkSummary('{foo} {native} {bar}', { foo: { type: 'string', value: null }, bar: { type: 'string', value: 'bar' } });
expect(result).toBe(false);
});
3 changes: 3 additions & 0 deletions ui/tx/interpretation/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@ export function checkSummary(template: string, variables: Record<string, TxInter
const variablesNames = extractVariables(template);
let result = true;
for (const name of variablesNames) {
if (name === NATIVE_COIN_SYMBOL_VAR_NAME) {
continue;
}
if (!variables[name] || variables[name].value === undefined || variables[name].value === null) {
result = false;
break;
Expand Down

0 comments on commit c2dcc91

Please sign in to comment.