Skip to content

Commit

Permalink
fix postman serialize
Browse files Browse the repository at this point in the history
  • Loading branch information
adraffy committed May 18, 2024
1 parent f0c990f commit 7eb5e0b
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions test/postman.html
Original file line number Diff line number Diff line change
Expand Up @@ -679,6 +679,7 @@ <h1><a target="_blank" href="https://eips.ethereum.org/EIPS/eip-3668">CCIP-Read<
v = v.slice(pos + 1);
} else {
k = v;
v = '';
}
switch (k) {
case TYPE_TEXT:
Expand All @@ -693,7 +694,7 @@ <h1><a target="_blank" href="https://eips.ethereum.org/EIPS/eip-3668">CCIP-Read<
default:
break;
}
} else if (k === 'args') {
} else if (k === 'arg') {
if (!json.args) json.args = [];
json.args.push(v);
} else {
Expand All @@ -706,7 +707,7 @@ <h1><a target="_blank" href="https://eips.ethereum.org/EIPS/eip-3668">CCIP-Read<
let params = new URLSearchParams();
for (let [k, v] of Object.entries(json)) {
if (k === 'fields') {
v.forEach(({type, arg}) => params.append('field', type_has_arg(arg) ? `${type}-${arg}` : type));
v.forEach(({type, arg}) => params.append('field', type_has_arg(type) ? `${type}-${arg}` : type));
} else if (k === 'args') {
v.forEach(x => params.append('arg', x));
} else {
Expand Down Expand Up @@ -781,15 +782,16 @@ <h1><a target="_blank" href="https://eips.ethereum.org/EIPS/eip-3668">CCIP-Read<
}
}
function parse_calldata() {
calldata_btn.disabled = true;
try {
let hex = calldata_ta.value.trim();
if (!/^(0x)[0-9a-f]*$/i.test(hex)) throw new Error('expected 0x-prefixed hex string');
if (hex.length < 10) throw new Error('expected bytes4 selector');
calldata_btn.disabled = false;
if ((hex.length - 10) % 64) throw new Error('expected 32-byte padding');
calldata_status.innerHTML = '';
return hex;
} catch (err) {
calldata_btn.disabled = true;
calldata_status.innerHTML = err.message;
}
}
Expand Down

0 comments on commit 7eb5e0b

Please sign in to comment.