mirror of
https://github.com/luxfi/explore.git
synced 2026-09-24 00:28:18 +00:00
Merge pull request #1614 from blockscout/interpretation-validation-fix
fix tx interpretation validation
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user