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: update contract hashes #770

Merged
merged 4 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
1,823 changes: 984 additions & 839 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,35 +23,35 @@
},
"devDependencies": {
"@babel/core": "^7.26.0",
"@babel/plugin-transform-modules-commonjs": "^7.25.9",
"@babel/plugin-transform-modules-commonjs": "^7.26.3",
"@babel/preset-env": "^7.26.0",
"@babel/preset-typescript": "^7.26.0",
"@eslint/js": "^9.15.0",
"@playwright/test": "^1.49.0",
"@eslint/js": "^9.16.0",
"@playwright/test": "^1.49.1",
"@solidjs/testing-library": "^0.8.10",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/user-event": "^14.5.2",
"@trivago/prettier-plugin-sort-imports": "^4.3.0",
"@trivago/prettier-plugin-sort-imports": "^5.2.0",
"@types/jest": "^29.5.14",
"@webbtc/webln-types": "^3.0.0",
"babel-jest": "^29.7.0",
"babel-plugin-transform-import-meta": "^2.2.1",
"babel-plugin-transform-vite-meta-env": "^1.0.3",
"babel-preset-jest": "^29.6.3",
"babel-preset-solid": "1.8.19",
"eslint": "^9.15.0",
"eslint-plugin-solid": "^0.14.4",
"eslint": "^9.16.0",
"eslint-plugin-solid": "^0.14.5",
"eventsource": "^2.0.2",
"git-cliff": "^2.7.0",
"globals": "^15.12.0",
"globals": "^15.13.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"jsdom": "^25.0.1",
"prettier": "^3.4.1",
"sass-embedded": "^1.81.0",
"prettier": "^3.4.2",
"sass-embedded": "^1.82.0",
"solid-jest": "^0.2.0",
"typescript": "^5.7.2",
"typescript-eslint": "^8.16.0",
"typescript-eslint": "^8.18.0",
"vite": "^5.4.10",
"vite-plugin-mkcert": "^1.17.6",
"vite-plugin-node-polyfills": "^0.22.0",
Expand All @@ -71,13 +71,13 @@
"@solid-primitives/i18n": "^2.1.1",
"@solid-primitives/storage": "^4.2.1",
"@solidjs/router": "^0.15.1",
"@trezor/connect-web": "^9.4.4",
"@trezor/connect-web": "^9.4.6",
"@vulpemventures/secp256k1-zkp": "^3.2.1",
"bignumber.js": "^9.1.2 ",
"bitcoinjs-lib": "^6.1.6",
"bitcoinjs-lib": "^6.1.7",
"bolt11": "^1.4.1",
"boltz-bolt12": "^0.1.3",
"boltz-core": "^2.1.3",
"boltz-core": "^2.2.1",
"buffer": "^6.0.3",
"create-hmac": "^1.1.7",
"ecpair": "^2.1.0",
Expand Down
2 changes: 1 addition & 1 deletion regtest
4 changes: 3 additions & 1 deletion src/components/RefundButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ export const RefundEvm = (props: {
props.timeoutBlockHeight <
(await signer().provider.getBlockNumber())
) {
tx = await contract.refund(
tx = await contract[
"refund(bytes32,uint256,address,uint256)"
](
prefix0x(props.preimageHash),
satoshiToWei(props.amount),
props.claimAddress,
Expand Down
5 changes: 4 additions & 1 deletion src/components/SwapChecker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,10 @@ export const SwapChecker = () => {
log.warn(msg, e);
notify("error", msg);
}
} else if (data.status === swapStatusPending.TransactionClaimPending) {
} else if (
currentSwap.type === SwapType.Submarine &&
data.status === swapStatusPending.TransactionClaimPending
) {
try {
await createSubmarineSignature(currentSwap as SubmarineSwap);
notify(
Expand Down
14 changes: 12 additions & 2 deletions src/components/WalletConnect.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,21 @@ export const WalletConnect = () => {
useWeb3Signer();

const [createdKit] = createResource(async () => {
const projectId = import.meta.env.VITE_WALLETCONNECT_PROJECT_ID;
if (projectId === undefined) {
log.warn("WalletConnect project id not set");
return undefined;
}

const configRsk = config.assets[RBTC];

const { appKit, EthersAdapter } = await loader.get();
const created = appKit.createAppKit({
projectId,
themeMode: "dark",
enableEIP6963: false,
enableInjected: false,
adapters: [new EthersAdapter()],
projectId: import.meta.env.VITE_WALLETCONNECT_PROJECT_ID as string,
networks: [
{
id: configRsk.network.chainId,
Expand Down Expand Up @@ -84,7 +90,11 @@ export const WalletConnect = () => {
// eslint-disable-next-line solid/reactivity
createEffect(async () => {
if (openWalletConnectModal()) {
await createdKit().open();
const kit = createdKit();

if (kit !== undefined) {
await kit.open();
}
}
});

Expand Down
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
Loading