-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
8,134 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Logs | ||
logs | ||
*.log | ||
npm-debug.log* | ||
yarn-debug.log* | ||
yarn-error.log* | ||
pnpm-debug.log* | ||
lerna-debug.log* | ||
|
||
node_modules | ||
dist | ||
dist-ssr | ||
*.local | ||
|
||
# Editor directories and files | ||
.vscode/* | ||
!.vscode/extensions.json | ||
.idea | ||
.DS_Store | ||
*.suo | ||
*.ntvs* | ||
*.njsproj | ||
*.sln | ||
*.sw? |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<link rel="icon" type="image/svg+xml" href="/vite.svg" /> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0" /> | ||
<title>Artizen Recovery</title> | ||
</head> | ||
<body> | ||
<div id="app"></div> | ||
<script type="module" src="/main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
import './style.css' | ||
import { createConfig, http, connect, switchChain, writeContract, waitForTransactionReceipt } from '@wagmi/core' | ||
import { mainnet } from '@wagmi/core/chains' | ||
import { injected } from '@wagmi/connectors' | ||
import { parseAbi } from 'viem' | ||
|
||
const currentTerminal = `0x1d9619E10086FdC1065B114298384aAe3F680CC0` | ||
const artizenProjectId = 587n; | ||
const recoveryTerminal = `0x0000000000000000000000000000000000000000` | ||
|
||
document.querySelector('#app').innerHTML = ` | ||
<h1>Artizen Recovery</h1> | ||
<div class="card"> | ||
<button id="connect">1. Connect</button> | ||
<button id="migrate">2. Migrate</button> | ||
<button id="payout">3. Payout</button> | ||
</div> | ||
<p id="statusText"></p> | ||
` | ||
|
||
const config = createConfig({ | ||
chains: [mainnet], | ||
connectors: [injected()], | ||
transports: { | ||
[mainnet.id]: http(), | ||
}, | ||
}) | ||
|
||
const connectButton = document.getElementById("connect") | ||
const statusText = document.getElementById("statusText") | ||
|
||
let result; | ||
connectButton.onclick = async () => { | ||
connectButton.innerText = "Connecting..." | ||
result = await connect(config, {connector: injected()}) | ||
connectButton.innerText = "Connected" | ||
statusText.innerText += `\nConnected to ${result.accounts[0]}.` | ||
|
||
if (result.chainId !== 1) { | ||
statusText.innerText += `\nWallet connected to wrong network. Switching to Ethereum mainnet...` | ||
await switchChain(config, { chainId: 1 }) | ||
statusText.innerText += `\nSwitched to Ethereum mainnet.` | ||
} | ||
} | ||
|
||
const migrateButton = document.getElementById("migrate") | ||
migrateButton.onclick = async () => { | ||
if (!result.accounts[0]) { | ||
statusText.innerText += `\nConnect wallet first.` | ||
return | ||
} | ||
|
||
statusText.innerText += `\nWaiting for migration transaction approval...` | ||
const migrateTxHash = await writeContract(config, { | ||
abi: parseAbi(["function migrate(uint256,address) returns (uint256)"]), | ||
address: currentTerminal, | ||
functionName: "migrate", | ||
args: [artizenProjectId, recoveryTerminal], | ||
}) | ||
statusText.innerText += `\nMigrating...` | ||
const migrateReceipt = await waitForTransactionReceipt(config, { | ||
hash: migrateTxHash | ||
}) | ||
|
||
statusText.innerText += `\nMigration successful. Hash: ${migrateReceipt.transactionHash}` | ||
} | ||
|
||
const payoutButton = document.getElementById("payout") | ||
payoutButton.onclick = async () => { | ||
if (!result.accounts[0]) { | ||
statusText.innerText += `\nConnect wallet first.` | ||
return | ||
} | ||
|
||
statusText.innerText += `\nWaiting for payout transaction approval...` | ||
const payoutTxHash = await writeContract(config, { | ||
abi: parseAbi(["function distributePayoutsOf(uint256,uint256,uint256,address,uint256,bytes) returns (uint256)"]), | ||
address: recoveryTerminal, | ||
functionName: "distributePayoutsOf", | ||
args: [artizenProjectId, 0n, 0n, "0x0000000000000000000000000000000000000000", 0n, "0x00"], | ||
}) | ||
statusText.innerText += `\nSending payouts...` | ||
const payoutReceipt = await waitForTransactionReceipt(config, { | ||
hash: payoutTxHash | ||
}) | ||
statusText.innerText += `\nPayout successful. Hash: ${payoutReceipt.transactionHash}` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
"name": "frontend", | ||
"private": true, | ||
"version": "0.0.0", | ||
"type": "module", | ||
"scripts": { | ||
"dev": "vite", | ||
"build": "vite build", | ||
"preview": "vite preview" | ||
}, | ||
"devDependencies": { | ||
"vite": "^5.1.0" | ||
}, | ||
"dependencies": { | ||
"@wagmi/connectors": "^4.1.13", | ||
"@wagmi/core": "^2.6.4", | ||
"viem": "^2.7.8" | ||
} | ||
} |
Oops, something went wrong.