Skip to content

Commit

Permalink
use context metadat field
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexNi245 committed Jul 27, 2023
1 parent e5b1cbb commit 443b2aa
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 8 deletions.
4 changes: 2 additions & 2 deletions contracts/verifier/optimism-bedrock/BedrockCcipVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,15 @@ contract BedrockCcipVerifier is CcipResponseVerifier {
* @return coinType Resolvers coin type (60 for Ethereum)
* @return graphqlUrl The GraphQL URL used by the resolver
* @return storageType Storage Type (0 for EVM)
* @return encodedData Encoded data representing the resolver ("CCIP RESOLVER")
* @return context can be l2 resolver contract address for evm chain but can be any l2 storage identifier for non evm chain
*/
function metadata(bytes calldata name) external view override returns (string memory, uint256, string memory, uint8, bytes memory) {
return (
string("Optimism Goerli"), //The name of the resolver
convertEVMChainIdToCoinType(420), //CoinType Accoridng to ENSIP-11 for Chain Id 420
this.graphqlUrl(), //The GraphQl Url
uint8(0), //Storage Type 0 => EVM
abi.encodePacked("Optimism Goerli")
abi.encodePacked(target) //Context => L2 Resolver Address
);
}
}
4 changes: 2 additions & 2 deletions contracts/verifier/signature/SignatureCcipVerifier.sol
Original file line number Diff line number Diff line change
Expand Up @@ -84,13 +84,13 @@ contract SignatureCcipVerifier is CcipResponseVerifier {
* @return coinType Resolvers coin type (60 for Ethereum)
* @return graphqlUrl The GraphQL URL used by the resolver
* @return storageType Storage Type (0 for EVM)
* @return encodedData Encoded data representing the resolver ("CCIP RESOLVER")
* @return context can be l2 resolver contract address for evm chain but can be any l2 storage identifier for non evm chain
*/
function metadata(
bytes calldata domainName
) external view override returns (string memory, uint256, string memory, uint8, bytes memory) {
return (
string(name), //The name of the resolver
name, //The name of the resolver
convertEVMChainIdToCoinType(60), //Resolvers coin type => Etheruem
this.graphqlUrl(), //The GraphQl Url
uint8(1), //Storage Type 0 => Offchain Databas
Expand Down
4 changes: 2 additions & 2 deletions test/contracts/BedrockCcipVerifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,12 +119,12 @@ describe("Bedrock CcipVerifier", () => {
.connect(owner)
.deploy(owner.address, "http://localhost:8080/graphql", bedrockProofVerifier.address, resolver.address);

const [name, coinType, graphqlUrl, storageType, encodedData] = await bedrockCcipVerifier.metadata(dnsEncode("alice.eth"));
const [name, coinType, graphqlUrl, storageType, context] = await bedrockCcipVerifier.metadata(dnsEncode("alice.eth"));
expect(name).to.equal("Optimism Goerli");
expect(convertCoinTypeToEVMChainId(BigNumber.from(coinType).toNumber())).to.equal(420);
expect(graphqlUrl).to.equal("http://localhost:8080/graphql");
expect(storageType).to.equal(storageType);
expect(ethers.utils.toUtf8String(encodedData)).to.equal("Optimism Goerli");
expect(ethers.utils.getAddress(context)).to.equal(resolver.address);
});
});
});
5 changes: 3 additions & 2 deletions test/contracts/CcipResolver.test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FakeContract, smock } from "@defi-wonderland/smock";
import { asL2Provider } from "@eth-optimism/sdk";
import { SignerWithAddress } from "@nomiclabs/hardhat-ethers/signers";
import { expect } from "chai";
import { BigNumber, ethers } from "ethers";
Expand Down Expand Up @@ -432,12 +433,12 @@ describe("CCIpResolver Test", () => {
.setVerifierForDomain(ethers.utils.namehash("alice.eth"), bedrockCcipVerifier.address, [
"http://localhost:8080/{sender}/{data}",
]);
const [name, coinType, graphqlUrl, storageType, encodedData] = await ccipResolver.metadata(dnsEncode("alice.eth"));
const [name, coinType, graphqlUrl, storageType, context] = await ccipResolver.metadata(dnsEncode("alice.eth"));
expect(name).to.equal("Optimism Goerli");
expect(convertCoinTypeToEVMChainId(BigNumber.from(coinType).toNumber())).to.equal(420);
expect(graphqlUrl).to.equal("http://localhost:8081/graphql");
expect(storageType).to.equal(storageType);
expect(ethers.utils.toUtf8String(encodedData)).to.equal("Optimism Goerli");
expect(ethers.utils.getAddress(context)).to.equal("0x5FbDB2315678afecb367f032d93F642f64180aa3");
});
});
});

0 comments on commit 443b2aa

Please sign in to comment.