Commit 623f414c authored by Igor Stuev's avatar Igor Stuev Committed by GitHub

Merge pull request #1614 from blockscout/interpretation-validation-fix

fix tx interpretation validation
parents 75b0bbed a4aa1e29
......@@ -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);
});
......@@ -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;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment