Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: universal resolver http error #303

Merged
merged 4 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions contracts/utils/UniversalResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -594,11 +594,10 @@ contract UniversalResolver is ERC165, Ownable {
function _checkResolveSingle(Result memory result) internal pure {
if (!result.success) {
if (bytes4(result.returnData) == HttpError.selector) {
(, HttpErrorItem[] memory errors) = abi.decode(
result.returnData,
(bytes4, HttpErrorItem[])
);
revert HttpError(errors);
bytes memory returnData = result.returnData;
assembly {
revert(add(returnData, 32), mload(returnData))
}
}
revert ResolverError(result.returnData);
}
Expand Down
39 changes: 39 additions & 0 deletions test/utils/TestUniversalResolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,45 @@ contract('UniversalResolver', function (accounts) {
)
expect(addrRet).to.equal(dummyOffchainResolver.address)
})
it('should propagate HttpError', async () => {
const urWithHttpErrorAbi = new ethers.Contract(
universalResolver.address,
[
...universalResolver.interface.fragments,
'error HttpError((uint16,string)[])',
],
ethers.provider,
)
const errorData = urWithHttpErrorAbi.interface.encodeErrorResult(
'HttpError',
[[[404, 'Not Found']]],
)
const extraData = ethers.utils.defaultAbiCoder.encode(
['bool', 'address', 'string[]', 'bytes', '(bytes4,bytes)[]'],
[
false,
dummyOffchainResolver.address,
['http://universal-offchain-resolver.local/'],
'0x',
[[resolveCallbackSig, errorData]],
],
)
const responses = batchGateway.encodeFunctionResult('query', [
[true],
[errorData],
])

try {
await urWithHttpErrorAbi.callStatic.resolveSingleCallback(
responses,
extraData,
)
expect(false).to.be.true
TateB marked this conversation as resolved.
Show resolved Hide resolved
} catch (e) {
expect(e.errorName).to.equal('HttpError')
expect(e.errorArgs).to.deep.equal([[[404, 'Not Found']]])
}
})
})
describe('resolveCallback', () => {
it('should resolve records via a callback from offchain lookup', async () => {
Expand Down