Skip to content

Commit

Permalink
feat: scaling ethereum hackathon updates (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
dionysuzx authored Mar 10, 2023
1 parent ab569c0 commit de78c5e
Show file tree
Hide file tree
Showing 19 changed files with 794 additions and 391 deletions.
3 changes: 1 addition & 2 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,5 @@ export MNEMONIC=
# RPCs
export BASE=https://goerli.base.org
export FOUNDRY=http://localhost:8545
export GOERLI=https://rpc.goerli.dev
export SEPOLIA=https://rpc.sepolia.dev
export TAIKO=
export TAIKO=https://l2rpc.hackathon.taiko.xyz
5 changes: 5 additions & 0 deletions README_HACKATHON.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Lets 👏 get 👏 hacking 👏

## Steps

1. [Receive Ether on the Taiko testnet](https://l2faucet.hackathon.taiko.xyz/)
2 changes: 1 addition & 1 deletion packages/app/.env.example
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# This file is meant to compatible with multiple shells, including:
# bash, zsh and fish. For this reason, use this syntax:
# export VARNAME=value
export VITE_WEB3MODAL_PROJECT_ID="YOUR_PROJECT_ID_HERE"
export VITE_WEB3MODAL_PROJECT_ID="YOUR_PROJECT_ID_HERE"
12 changes: 7 additions & 5 deletions packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
{
"name": "app",
"version": "0.1.0",
"private": true,
"type": "module",
"engines": {
"node": ">=16.0.0"
},
"scripts": {
"dev": "vite dev",
"build": "vite build",
Expand All @@ -19,6 +21,7 @@
"@typescript-eslint/eslint-plugin": "^5.54.1",
"@typescript-eslint/parser": "^5.54.1",
"@wagmi/cli": "^0.1.11",
"abitype": "^0.6.7",
"eslint": "^8.35.0",
"eslint-config-prettier": "^8.7.0",
"eslint-plugin-svelte3": "^4.0.0",
Expand All @@ -33,10 +36,9 @@
},
"dependencies": {
"@picocss/pico": "^1.5.7",
"@wagmi/core": "0.9.6",
"@web3modal/ethereum": "^2.1.3",
"@web3modal/html": "^2.1.3",
"buffer": "^6.0.3",
"@wagmi/core": "0.10.1",
"@web3modal/ethereum": "^2.2.0",
"@web3modal/html": "^2.2.0",
"ethers": "^5.7.2"
}
}
53 changes: 53 additions & 0 deletions packages/app/src/abi/HeaderSync.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
export const headerSyncABI = [
{
anonymous: false,
inputs: [
{
indexed: true,
internalType: "uint256",
name: "srcHeight",
type: "uint256",
},
{
indexed: false,
internalType: "bytes32",
name: "srcHash",
type: "bytes32",
},
],
name: "HeaderSynced",
type: "event",
},
{
inputs: [],
name: "getLatestSyncedHeader",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32",
},
],
stateMutability: "view",
type: "function",
},
{
inputs: [
{
internalType: "uint256",
name: "number",
type: "uint256",
},
],
name: "getSyncedHeader",
outputs: [
{
internalType: "bytes32",
name: "",
type: "bytes32",
},
],
stateMutability: "view",
type: "function",
},
];
117 changes: 117 additions & 0 deletions packages/app/src/abi/SignalService.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
export const signalServiceABI = [
{
type: "function",
stateMutability: "view",
outputs: [{ type: "address", name: "", internalType: "address" }],
name: "addressManager",
inputs: [],
},
{
type: "function",
stateMutability: "pure",
outputs: [{ type: "bytes32", name: "", internalType: "bytes32" }],
name: "getSignalSlot",
inputs: [
{ type: "address", name: "app", internalType: "address" },
{ type: "bytes32", name: "signal", internalType: "bytes32" },
],
},
{
type: "function",
stateMutability: "nonpayable",
outputs: [],
name: "init",
inputs: [{ type: "address", name: "_addressManager", internalType: "address" }],
},
{
type: "function",
stateMutability: "view",
outputs: [{ type: "bool", name: "", internalType: "bool" }],
name: "isSignalReceived",
inputs: [
{ type: "uint256", name: "srcChainId", internalType: "uint256" },
{ type: "address", name: "app", internalType: "address" },
{ type: "bytes32", name: "signal", internalType: "bytes32" },
{ type: "bytes", name: "proof", internalType: "bytes" },
],
},
{
type: "function",
stateMutability: "view",
outputs: [{ type: "bool", name: "", internalType: "bool" }],
name: "isSignalSent",
inputs: [
{ type: "address", name: "app", internalType: "address" },
{ type: "bytes32", name: "signal", internalType: "bytes32" },
],
},
{
type: "function",
stateMutability: "view",
outputs: [{ type: "address", name: "", internalType: "address" }],
name: "owner",
inputs: [],
},
{
type: "function",
stateMutability: "nonpayable",
outputs: [],
name: "renounceOwnership",
inputs: [],
},
{
type: "function",
stateMutability: "view",
outputs: [{ type: "address", name: "", internalType: "address payable" }],
name: "resolve",
inputs: [
{ type: "string", name: "name", internalType: "string" },
{ type: "bool", name: "allowZeroAddress", internalType: "bool" },
],
},
{
type: "function",
stateMutability: "view",
outputs: [{ type: "address", name: "", internalType: "address payable" }],
name: "resolve",
inputs: [
{ type: "uint256", name: "chainId", internalType: "uint256" },
{ type: "string", name: "name", internalType: "string" },
{ type: "bool", name: "allowZeroAddress", internalType: "bool" },
],
},
{
type: "function",
stateMutability: "nonpayable",
outputs: [{ type: "bytes32", name: "storageSlot", internalType: "bytes32" }],
name: "sendSignal",
inputs: [{ type: "bytes32", name: "signal", internalType: "bytes32" }],
},
{
type: "function",
stateMutability: "nonpayable",
outputs: [],
name: "transferOwnership",
inputs: [{ type: "address", name: "newOwner", internalType: "address" }],
},
{
type: "event",
name: "Initialized",
inputs: [{ type: "uint8", name: "version", indexed: false }],
anonymous: false,
},
{
type: "event",
name: "OwnershipTransferred",
inputs: [
{ type: "address", name: "previousOwner", indexed: true },
{ type: "address", name: "newOwner", indexed: true },
],
anonymous: false,
},
{ type: "error", name: "B_NULL_APP_ADDR", inputs: [] },
{ type: "error", name: "B_WRONG_CHAIN_ID", inputs: [] },
{ type: "error", name: "B_ZERO_SIGNAL", inputs: [] },
{ type: "error", name: "RESOLVER_DENIED", inputs: [] },
{ type: "error", name: "RESOLVER_INVALID_ADDR", inputs: [] },
];
2 changes: 2 additions & 0 deletions packages/app/src/abi/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { signalServiceABI } from "./SignalService";
export { headerSyncABI } from "./HeaderSync";
11 changes: 6 additions & 5 deletions packages/app/src/components/ContractInteraction.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@
import { readContract, prepareWriteContract, writeContract } from "@wagmi/core";
import { onMount } from "svelte";
import { fooABI, fooAddress } from "../generated";
import { foundry } from "@wagmi/core/chains";
// variables
let inputMessage = "";
let messageFromContract = "placeholder";
let messageFromContract = "";
// functions
async function readMessage() {
const data = await readContract({
address: fooAddress[31337],
address: fooAddress[foundry.id],
abi: fooABI,
functionName: "myString",
});
Expand All @@ -20,19 +21,19 @@
async function writeMessage() {
const config = await prepareWriteContract({
address: fooAddress[31337],
address: fooAddress[foundry.id],
abi: fooABI,
functionName: "setMyString",
args: [inputMessage],
});
await writeContract(config);
readMessage();
}
onMount(readMessage);
</script>

<section>Note: Must be connected to local foundry (anvil) network.</section>
<section>
<input type="submit" value="Read message" on:click={readMessage} />
<div style="text-align: center">Message from contract: {messageFromContract}</div>
</section>
<section>
Expand Down
Loading

1 comment on commit de78c5e

@vercel
Copy link

@vercel vercel bot commented on de78c5e Mar 10, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

dapp-slaps – ./

dapp-slaps-git-main-d1onys1us.vercel.app
dapp-slaps-d1onys1us.vercel.app
dapp-slaps.vercel.app

Please sign in to comment.