Skip to content

Commit

Permalink
chore: update contract hashes
Browse files Browse the repository at this point in the history
  • Loading branch information
michael1011 committed Dec 9, 2024
1 parent e64874d commit 85f678e
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 9 deletions.
15 changes: 10 additions & 5 deletions src/context/Web3.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -326,23 +326,28 @@ const Web3SignerProvider = (props: {

const useWeb3Signer = () => useContext(Web3SignerContext);

const etherSwapCodeHash = () => {
const etherSwapCodeHashes = () => {
switch (config.network) {
case "mainnet":
return "0x4d6894da95269c76528b81c6d25425a2f6bba70156cfaf7725064f919647d955";
return [
"0x4d6894da95269c76528b81c6d25425a2f6bba70156cfaf7725064f919647d955",
];

case "testnet":
return "0xd9a282305f30590b3df70c3c1f9338b042a97dff12736794e9de2cdabf8542c1";
return [
"0xd9a282305f30590b3df70c3c1f9338b042a97dff12736794e9de2cdabf8542c1",
"0xb8f6205d7fecc5b7a577519c7ec40af594f929d150c05bf84e1f94b7472dd783",
];

default:
return undefined;
}
};

export {
EtherSwapAbi,
useWeb3Signer,
etherSwapCodeHash,
Web3SignerProvider,
EtherSwapAbi,
etherSwapCodeHashes,
customDerivationPathRdns,
};
8 changes: 4 additions & 4 deletions src/utils/validation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import log from "loglevel";

import { LBTC, RBTC } from "../consts/Assets";
import { Denomination, Side, SwapType } from "../consts/Enums";
import { etherSwapCodeHash } from "../context/Web3";
import { etherSwapCodeHashes } from "../context/Web3";
import { ChainSwapDetails } from "./boltzClient";
import { decodeAddress } from "./compat";
import { formatAmountDenomination } from "./denomination";
Expand All @@ -30,13 +30,13 @@ import { createMusig, tweakMusig } from "./taproot/musig";
type ContractGetter = () => BaseContract;

const validateContract = async (getEtherSwap: ContractGetter) => {
const codeHash = etherSwapCodeHash();
if (codeHash === undefined) {
const codeHashes = etherSwapCodeHashes();
if (codeHashes === undefined) {
return true;
}

const code = await getEtherSwap().getDeployedCode();
return codeHash === ethers.keccak256(code);
return codeHashes.includes(ethers.keccak256(code));
};

const validateAddress = async (
Expand Down

0 comments on commit 85f678e

Please sign in to comment.