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

chore: merge staging #378

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
152 commits
Select commit Hold shift + click to select a range
bf2e50b
[m-04] fix record parser readkeyvalue method
mdtanrikulu Jul 5, 2023
8d9b5fb
[M-01] HexUtils.hexStringToBytes32() input control
mdtanrikulu Jul 5, 2023
5d660d7
draft m-07
mdtanrikulu Jul 24, 2023
d85d6e5
remove logs, update sender check
mdtanrikulu Jul 25, 2023
9d9cee0
fix sender check
mdtanrikulu Aug 2, 2023
5365896
decode returnData before return
mdtanrikulu Aug 4, 2023
4d7f470
create addr only dnssec resolver
mdtanrikulu Aug 4, 2023
5b8df46
return empty string in case of invalid cointype
mdtanrikulu Aug 8, 2023
8bd02e6
add deploy script for ExtendedDNSResolver
mdtanrikulu Aug 18, 2023
dedf271
deploy dnssec registrar to sepolia
jefflau Aug 23, 2023
9717775
Deploy extended resolver
jefflau Aug 23, 2023
0e82673
add supportInterface to OffchainDNSResolver
mdtanrikulu Aug 30, 2023
fe06d68
Merge pull request #274 from ensdomains/dnssec-mitigation-deploy
jefflau Sep 6, 2023
a01bba0
Merge branch 'staging' into feature/dnssec-updates
mdtanrikulu Sep 6, 2023
445eb4c
Deploy new DNSSEC registrar to Sepolia
jefflau Sep 29, 2023
601575c
Redeploy
jefflau Oct 9, 2023
590db3d
Deploy dnssec registrar, again!
jefflau Oct 11, 2023
d11cc31
Merge pull request #278 from ensdomains/deploy-dnssec-registrar
jefflau Oct 19, 2023
76768cc
fix offchain-resolver resolution over offchain dns
mdtanrikulu Nov 15, 2023
696f734
feat: universal resolver safe calls + success var return
TateB Nov 30, 2023
f7e93df
httperror on parent
TateB Nov 30, 2023
9a94ebb
testnet deploys
TateB Nov 30, 2023
e08a9b3
Merge pull request #272 from ensdomains/feature/dnssec-updates
LeonmanRolls Nov 30, 2023
5765963
testnets
TateB Nov 30, 2023
6117475
Merge branch 'staging' into feat/universal-resolver-result
TateB Nov 30, 2023
e835fa2
add check in makeCommitment for resolver != address(0) when reverseRe…
lcfr-eth Dec 4, 2023
4654f35
Update IETHRegistrarController.sol
lcfr-eth Dec 4, 2023
5ae0cd7
Merge pull request #294 from lcfr-eth/staging
Arachnid Dec 5, 2023
9ef4bcb
update tests, add universal + dns resolver test
mdtanrikulu Dec 6, 2023
84ecab8
fix test flow
mdtanrikulu Dec 6, 2023
242c27e
Merge pull request #292 from ensdomains/feat/universal-resolver-result
TateB Dec 7, 2023
c8d21e4
feat: universal resolver safe calls + success var return
TateB Nov 30, 2023
8dac4e9
httperror on parent
TateB Nov 30, 2023
aad9096
testnet deploys
TateB Nov 30, 2023
e0473ed
testnets
TateB Nov 30, 2023
4bbfe5c
deploy: UniversalResolver
TateB Dec 12, 2023
6932a6a
v0.2
TateB Dec 12, 2023
349562a
v1.0
TateB Dec 12, 2023
a9174cf
Merge pull request #297 from ensdomains/deploy/ur-v2
TateB Dec 12, 2023
f998239
hotfix deploy
TateB Dec 12, 2023
668bfcb
v1.0.0
TateB Dec 12, 2023
74de256
Merge pull request #296 from ensdomains/mdt/fix-testflow
jefflau Dec 18, 2023
822e4e6
Remove log
jefflau Dec 18, 2023
06d956c
Merge pull request #298 from ensdomains/mdt/fix-testflow
jefflau Dec 18, 2023
67bf365
Merge pull request #291 from ensdomains/mdt/offchain-resolver-fix
mdtanrikulu Dec 18, 2023
00c31e8
fix: propagate httperror on single resolve correctly
TateB Jan 3, 2024
4e73ef9
Redeploy DNSRegistrar to Sepolia
jefflau Jan 3, 2024
87a95a8
added try...catch assertions
TateB Jan 4, 2024
1ba2e23
Setup dependencies to allow BaseRegistrar to have the same address, a…
jefflau Jan 6, 2024
b763c9a
testnets
TateB Jan 8, 2024
d3006c1
mainnet
TateB Jan 8, 2024
caa15a8
Merge pull request #303 from ensdomains/fix/universal-resolver-http-e…
TateB Jan 8, 2024
af627f1
Merge branch 'mainnet' into staging-sync
TateB Jan 8, 2024
6d7b4c9
v1.0.1
TateB Jan 8, 2024
9bf3bdd
Merge pull request #306 from ensdomains/staging-sync
TateB Jan 9, 2024
a146637
release flow updates
LeonmanRolls Jan 11, 2024
8b76224
convert bn to string
mdtanrikulu Jan 11, 2024
fcc06ca
revert bn to string
mdtanrikulu Jan 11, 2024
1a88d61
try different action runner image
mdtanrikulu Jan 13, 2024
656160a
try mac runner
mdtanrikulu Jan 13, 2024
2015531
revert runner os, try different node version
mdtanrikulu Jan 13, 2024
bde22f8
revert node version, add tmate
mdtanrikulu Jan 14, 2024
831e1cf
revert tmate
mdtanrikulu Jan 14, 2024
5cb8128
Merge pull request #307 from ensdomains/release-flow-update
LeonmanRolls Jan 14, 2024
53f64de
Deploy to mainnet
Arachnid Jan 16, 2024
7d091bd
New DNSRegistrar deployment with correct previous version address
Arachnid Jan 17, 2024
03b4775
Use owner instead of isOwner
Arachnid Jan 17, 2024
3d2f538
Use explicit public suffix list
Arachnid Jan 17, 2024
0d99f42
Remove accidentally added contract
Arachnid Jan 17, 2024
160919f
New deployment
Arachnid Jan 17, 2024
e5391f7
Merge pull request #310 from ensdomains/feature/public-suffixes
Arachnid Jan 17, 2024
992dc9d
deploy SimplePublicSuffixList to Sepolia
mdtanrikulu Jan 18, 2024
9fe938e
Merge branch 'staging' into deploy-dnssec-registrar
mdtanrikulu Jan 18, 2024
c5eb51e
remove unused interface "commitments" from IETHRegistrarController
mdtanrikulu Jan 19, 2024
322c326
Merge pull request #312 from ensdomains/mdt/update-IETHRegistrarContr…
Arachnid Jan 22, 2024
02c9e6b
Merge pull request #304 from ensdomains/deploy-dnssec-registrar
mdtanrikulu Jan 23, 2024
0f531be
Merge branch 'staging' into deploy-holesky
jefflau Jan 24, 2024
2eec3a6
Half of the Holesky deployment
jefflau Jan 26, 2024
141eda5
Finish holesky deployment
jefflau Jan 26, 2024
29984e3
Update logs
jefflau Jan 29, 2024
a056492
Add transfer of ownership of UR to owner on deploy
jefflau Jan 30, 2024
8d1c5fd
Merge pull request #317 from ensdomains/deploy-holesky
jefflau Jan 30, 2024
acda649
fix: universalresolver hybrid onchain/offchain handling
TateB Feb 9, 2024
6db6444
Add hexToBytes()
Arachnid Feb 15, 2024
f2bb8db
checkpoint
LeonmanRolls Feb 15, 2024
fac78e2
Revert "add check in makeCommitment for resolver != address(0) when r…
LeonmanRolls Feb 16, 2024
4aecdb3
Merge pull request #325 from ensdomains/staging
LeonmanRolls Feb 16, 2024
9487d48
Merge branch 'staging' into fix/ur-hybrid-calls
TateB Feb 18, 2024
4b222f8
deploy testnet universalresolver
TateB Feb 18, 2024
021ba7d
Merge pull request #324 from ensdomains/fix/ur-hybrid-calls
TateB Feb 19, 2024
545a010
mainnet universalresolver deploy
TateB Feb 19, 2024
e95380c
First version of better parser
Arachnid Feb 19, 2024
ca6a993
proper matching
LeonmanRolls Feb 20, 2024
c321f91
More tests
Arachnid Feb 20, 2024
4472f47
Text record support
Arachnid Feb 20, 2024
23a3d66
Remove console log
Arachnid Feb 20, 2024
911f3bd
remove logs
LeonmanRolls Feb 20, 2024
513fbe1
Add support for easier encoding of EVM chain IDs
Arachnid Feb 21, 2024
c9535ae
Handle multiple spaces between records
Arachnid Feb 21, 2024
6fc58e6
Handle no spaces between quoted records
Arachnid Feb 21, 2024
38407f0
Add comment referencing ensip-11
Arachnid Feb 21, 2024
b2942ee
Merge pull request #330 from ensdomains/staging
LeonmanRolls Feb 28, 2024
eba8d32
Update main.yml
LeonmanRolls Mar 3, 2024
2173691
Merge pull request #333 from ensdomains/wiki-address-check
LeonmanRolls Mar 3, 2024
8dd3f11
unify utility contracts
mdtanrikulu Mar 26, 2024
fc33d3f
add MIT license to some contracts
mkhalesi Mar 28, 2024
63ca27e
Changesx in response to revie
Arachnid Apr 4, 2024
b479cd2
Merge pull request #342 from ensdomains/fix/unify-utility-contracts
mdtanrikulu Apr 4, 2024
c15e4af
Merge pull request #343 from mkhalesi/staging
Arachnid Apr 9, 2024
d3d6b70
Merge branch 'staging' into feature/better-offchain-dns
mdtanrikulu Apr 25, 2024
8e8cf71
Merge pull request #331 from ensdomains/feature/better-offchain-dns
Arachnid May 1, 2024
2b7bae3
experimental changes for better tests
TateB May 22, 2024
657428a
checkpoint
TateB May 23, 2024
8c58736
checkpoint
TateB May 27, 2024
ee67417
dnssec-oracle
TateB May 28, 2024
aeeeefe
dnsregistrar
TateB May 28, 2024
2d34788
wrapper checkpoint
TateB May 29, 2024
e24d592
namewrapper tests...
TateB Jun 13, 2024
45254ab
remove usage of eth-ens-namehash
talentlessguy Jun 13, 2024
71b9885
remove dependency on envfile
talentlessguy Jun 13, 2024
128f77e
fix types import
talentlessguy Jun 13, 2024
29103ab
fix wrong import
talentlessguy Jun 13, 2024
3fbff99
Merge pull request #362 from ensdomains/test-improvements-improvements
TateB Jun 13, 2024
211307a
reenable workflow
TateB Jun 13, 2024
a345020
update patch
TateB Jun 13, 2024
0f60911
wikicheck ts
TateB Jun 13, 2024
7791dd1
deploy scripts
TateB Jun 19, 2024
021ac66
bun v
TateB Jun 19, 2024
65f9b42
install foundry gha
TateB Jun 19, 2024
2b3b995
remove some old tests
TateB Jun 19, 2024
a223ae3
ci early exit
TateB Jun 19, 2024
36c704d
testtestregistrar
TateB Jun 19, 2024
e295d07
bulk renewal contracts
TateB Jun 20, 2024
bd60c39
remove remaining js tests
TateB Jun 20, 2024
261f493
remove unused deps
TateB Jun 20, 2024
dffbfe4
comment on multicall usage
TateB Jul 5, 2024
3c96089
Merge pull request #352 from ensdomains/tateb/test-improvements
talentlessguy Jul 5, 2024
7becdfd
Merge branch 'staging' into mainnet
talentlessguy Jul 19, 2024
e102c56
remove yarn usage
talentlessguy Jul 19, 2024
026adb0
Merge pull request #370 from ensdomains/remove-yarn-stuff
talentlessguy Jul 19, 2024
05f9bd1
Merge branch 'staging' into mainnet
talentlessguy Jul 19, 2024
94a27cb
remove ethers completely
talentlessguy Jul 19, 2024
80e76e2
Merge pull request #371 from ensdomains/update-hh-tasks-to-viem
talentlessguy Jul 19, 2024
238a6d8
Merge branch 'staging' of https://github.com/ensdomains/ens-contracts…
talentlessguy Jul 19, 2024
9724ec5
add a guide on deploying
talentlessguy Jul 31, 2024
91dc6b3
add NODE_OPTIONS
talentlessguy Jul 31, 2024
a449512
Merge pull request #374 from ensdomains/update-readme
talentlessguy Jul 31, 2024
927edf3
Deployment for new ExtendeDNSResolver
Arachnid Jul 31, 2024
2cf6496
Add sepolia deployment
Arachnid Jul 31, 2024
a6139f0
Merge pull request #375 from ensdomains/edns-deployment
Arachnid Aug 2, 2024
7cdaeb6
Merge branch 'staging' into chore/merge-staging-crosschain
TateB Aug 5, 2024
3a8ac8f
fix deploy
TateB Aug 5, 2024
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
47 changes: 31 additions & 16 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,55 @@ name: CI

on:
push:
branches: [master]
branches: [staging, mainnet]
pull_request:

jobs:
wiki_address_check:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Use Bun 1.1.13
uses: oven-sh/setup-bun@v1
with:
bun-version: 1.1.13

- run: bun install --frozen-lockfile

- name: Run wikiCheck
run: bun run wikiCheck
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
- name: Use Bun 1.1.13
uses: oven-sh/setup-bun@v1
with:
node-version: 16
cache: 'yarn'
bun-version: 1.1.13

- run: yarn install --frozen-lockfile
- run: bun install --frozen-lockfile

- name: Run test
run: yarn test
- name: Run tests
run: bun run test:parallel

deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/checkout@v4

- name: Use Node.js 16
uses: actions/setup-node@v3
- name: Use Bun 1.1.13
uses: oven-sh/setup-bun@v1
with:
node-version: 16
cache: 'yarn'
bun-version: 1.1.13

- run: bun install --frozen-lockfile

- run: yarn install --frozen-lockfile
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1

- name: Run deploy
run: yarn test:deploy
run: bun run test:deploy
env:
BATCH_GATEWAY_URLS: '["https://universal-offchain-unwrapper.ens-cf.workers.dev/"]'
2 changes: 1 addition & 1 deletion .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/usr/bin/env sh
. "$(dirname -- "$0")/_/husky.sh"

yarn format && git add .
bun run format && git add .
38 changes: 29 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,19 +152,19 @@ This repo runs a husky precommit to prettify all contract files to keep them con
```
git clone https://github.com/ensdomains/ens-contracts
cd ens-contracts
yarn
bun i
```

### How to run tests

```
yarn test
bun run test
```

### How to publish

```
yarn pub
bun run pub
```

## How to deploy l2 contracts
Expand Down Expand Up @@ -202,6 +202,16 @@ const l2resolverAddress = await l2Factory.predictAddress(ETH_ADDRESS)

## Release flow

### Deployment

```
NODE_OPTIONS='--experimental-loader ts-node/esm/transpile-only' bun run hardhat --network <network_name> deploy
```

Full list of available networks for deployment is [here](hardhat.config.cts#L38).

### Release flow

1. Create a `feature` branch from `staging` branch
2. Make code updates
3. Ensure you are synced up with `staging`
Expand All @@ -210,11 +220,20 @@ const l2resolverAddress = await l2Factory.predictAddress(ETH_ADDRESS)
6. Have the tagged commit audited if necessary
7. If changes are required, make the changes and then once ready for review create another GitHub release with an incremented RC value `v1.2.3-RC0` -> `v.1.2.3-RC1`. Repeat as necessary.
8. Deploy to testnet. Open a pull request to merge the deploy artifacts into
the `feature` branch. Get someone to review and approve the deployment and then merge. You now MUST merge this branch into `staging` branch.
9. Create GitHub release of the form `v1.2.3-testnet` from the commit that has the new deployment artifacts.
the `feature` branch. Create GitHub release of the form `v1.2.3-testnet` from the commit that has the new deployment artifacts.
9. Get someone to review and approve the deployment and then merge. You now MUST merge this branch into `staging` branch.
10. If any further changes are needed, you can either make them on the existing feature branch that is in sync or create a new branch, and follow steps 1 -> 9. Repeat as necessary.
11. Make Deployment to mainnet from `staging`. Commit build artifacts. You now MUST merge this branch into `main`.
12. Create GitHub release of the form `v1.2.3-mainnet` from the commit that has the new deployment artifacts.
11. Make a deployment to ethereum mainnet from `staging`. Create a GitHub release of the form `v1.2.3` from the commit that has the new deployment artifacts.
12. Open a PR to merge into `main`. Have it reviewed and merged.

### Cherry-picked release flow

Certain changes can be released in isolation via cherry-picking, although ideally we would always release from `staging`.

1. Create a new branch from `mainnet`.
2. Cherry-pick from `staging` into new branch.
3. Deploy to ethereum mainnet, tag the commit that has deployment artifacts and create a release.
4. Merge into `mainnet`.

### Emergency release process

Expand All @@ -224,7 +243,8 @@ const l2resolverAddress = await l2Factory.predictAddress(ETH_ADDRESS)

### Notes

- `staging` branch and `main` branch should start off in sync
- Deployed code should always match source code in mainnet releases. This may not be the case for `staging`.
- `staging` branch and `main` branch should start in sync
- `staging` is intended to be a practice `main`. Only code that is intended to be released to `main` can be merged to `staging`. Consequently:
- Feature branches will be long-lived
- Feature branches must be kept in sync with `staging`
Expand All @@ -233,4 +253,4 @@ const l2resolverAddress = await l2Factory.predictAddress(ETH_ADDRESS)
- It is preferable to not edit the same file on different feature branches.
- Code on `staging` and `main` will always be a subset of what is deployed, as smart contracts cannot be undeployed.
- Release candidates, `staging` and `main` branch are subject to our bug bounty
- Releases follow semantic versioning and should contain a description of changes with developers being the intended audience
- Releases follow semantic versioning and releases should contain a description of changes with developers being the intended audience
Binary file added bun.lockb
Binary file not shown.
2 changes: 1 addition & 1 deletion contracts/dnsregistrar/DNSClaimChecker.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
pragma solidity ^0.8.4;

import "../dnssec-oracle/DNSSEC.sol";
import "../dnssec-oracle/BytesUtils.sol";
import "../dnssec-oracle/RRUtils.sol";
import "../utils/BytesUtils.sol";
import "../utils/HexUtils.sol";
import "@ensdomains/buffer/contracts/Buffer.sol";

Expand Down
2 changes: 1 addition & 1 deletion contracts/dnsregistrar/DNSRegistrar.sol
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ pragma solidity ^0.8.4;

import "@openzeppelin/contracts/utils/introspection/IERC165.sol";
import "@ensdomains/buffer/contracts/Buffer.sol";
import "../dnssec-oracle/BytesUtils.sol";
import "../dnssec-oracle/DNSSEC.sol";
import "../dnssec-oracle/RRUtils.sol";
import "../registry/ENSRegistry.sol";
import "../root/Root.sol";
import "../resolvers/profiles/AddrResolver.sol";
import "../utils/BytesUtils.sol";
import "./DNSClaimChecker.sol";
import "./PublicSuffixList.sol";
import "./IDNSRegistrar.sol";
Expand Down
144 changes: 127 additions & 17 deletions contracts/dnsregistrar/OffchainDNSResolver.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,16 @@ import "../../contracts/resolvers/profiles/IAddrResolver.sol";
import "../../contracts/resolvers/profiles/IExtendedResolver.sol";
import "../../contracts/resolvers/profiles/IExtendedDNSResolver.sol";
import "@openzeppelin/contracts/utils/introspection/ERC165.sol";
import "../dnssec-oracle/BytesUtils.sol";
import "../dnssec-oracle/DNSSEC.sol";
import "../dnssec-oracle/RRUtils.sol";
import "../registry/ENSRegistry.sol";
import "../utils/HexUtils.sol";
import "../utils/BytesUtils.sol";

import {Address} from "@openzeppelin/contracts/utils/Address.sol";
import {LowLevelCallUtils} from "../utils/LowLevelCallUtils.sol";

error InvalidOperation();
error OffchainLookup(
address sender,
string[] urls,
Expand All @@ -29,8 +33,9 @@ interface IDNSGateway {
uint16 constant CLASS_INET = 1;
uint16 constant TYPE_TXT = 16;

contract OffchainDNSResolver is IExtendedResolver {
contract OffchainDNSResolver is IExtendedResolver, IERC165 {
using RRUtils for *;
using Address for address;
using BytesUtils for bytes;
using HexUtils for bytes;

Expand All @@ -46,30 +51,46 @@ contract OffchainDNSResolver is IExtendedResolver {
gatewayURL = _gatewayURL;
}

function supportsInterface(
bytes4 interfaceId
) external pure override returns (bool) {
return interfaceId == type(IExtendedResolver).interfaceId;
}

function resolve(
bytes calldata name,
bytes calldata data
) external view returns (bytes memory) {
string[] memory urls = new string[](1);
urls[0] = gatewayURL;

revert OffchainLookup(
address(this),
urls,
abi.encodeCall(IDNSGateway.resolve, (name, TYPE_TXT)),
OffchainDNSResolver.resolveCallback.selector,
abi.encode(name, data)
);
revertWithDefaultOffchainLookup(name, data);
}

function resolveCallback(
bytes calldata response,
bytes calldata extraData
) external view returns (bytes memory) {
(bytes memory name, bytes memory query) = abi.decode(
(bytes memory name, bytes memory query, bytes4 selector) = abi.decode(
extraData,
(bytes, bytes)
(bytes, bytes, bytes4)
);

if (selector != bytes4(0)) {
(bytes memory targetData, address targetResolver) = abi.decode(
query,
(bytes, address)
);
return
callWithOffchainLookupPropagation(
targetResolver,
name,
query,
abi.encodeWithSelector(
selector,
response,
abi.encode(targetData, address(this))
)
);
}

DNSSEC.RRSetWithSignature[] memory rrsets = abi.decode(
response,
(DNSSEC.RRSetWithSignature[])
Expand Down Expand Up @@ -106,17 +127,30 @@ contract OffchainDNSResolver is IExtendedResolver {
)
) {
return
IExtendedDNSResolver(dnsresolver).resolve(
callWithOffchainLookupPropagation(
dnsresolver,
name,
query,
context
abi.encodeCall(
IExtendedDNSResolver.resolve,
(name, query, context)
)
);
} else if (
IERC165(dnsresolver).supportsInterface(
IExtendedResolver.resolve.selector
)
) {
return IExtendedResolver(dnsresolver).resolve(name, query);
return
callWithOffchainLookupPropagation(
dnsresolver,
name,
query,
abi.encodeCall(
IExtendedResolver.resolve,
(name, query)
)
);
} else {
(bool ok, bytes memory ret) = address(dnsresolver)
.staticcall(query);
Expand Down Expand Up @@ -223,4 +257,80 @@ contract OffchainDNSResolver is IExtendedResolver {
abi.encodePacked(parentNode, name.keccak(idx, separator - idx))
);
}

function callWithOffchainLookupPropagation(
address target,
bytes memory name,
bytes memory innerdata,
bytes memory data
) internal view returns (bytes memory) {
if (!target.isContract()) {
revertWithDefaultOffchainLookup(name, innerdata);
}

bool result = LowLevelCallUtils.functionStaticCall(
address(target),
data
);
uint256 size = LowLevelCallUtils.returnDataSize();
if (result) {
bytes memory returnData = LowLevelCallUtils.readReturnData(0, size);
return abi.decode(returnData, (bytes));
}
// Failure
if (size >= 4) {
bytes memory errorId = LowLevelCallUtils.readReturnData(0, 4);
if (bytes4(errorId) == OffchainLookup.selector) {
// Offchain lookup. Decode the revert message and create our own that nests it.
bytes memory revertData = LowLevelCallUtils.readReturnData(
4,
size - 4
);
handleOffchainLookupError(revertData, target, name);
}
}
LowLevelCallUtils.propagateRevert();
}

function revertWithDefaultOffchainLookup(
bytes memory name,
bytes memory data
) internal view {
string[] memory urls = new string[](1);
urls[0] = gatewayURL;

revert OffchainLookup(
address(this),
urls,
abi.encodeCall(IDNSGateway.resolve, (name, TYPE_TXT)),
OffchainDNSResolver.resolveCallback.selector,
abi.encode(name, data, bytes4(0))
);
}

function handleOffchainLookupError(
bytes memory returnData,
address target,
bytes memory name
) internal view {
(
address sender,
string[] memory urls,
bytes memory callData,
bytes4 innerCallbackFunction,
bytes memory extraData
) = abi.decode(returnData, (address, string[], bytes, bytes4, bytes));

if (sender != target) {
revert InvalidOperation();
}

revert OffchainLookup(
address(this),
urls,
callData,
OffchainDNSResolver.resolveCallback.selector,
abi.encode(name, extraData, innerCallbackFunction)
);
}
}
Loading