Skip to content

Commit

Permalink
Merge branch 'dev' into fuzd
Browse files Browse the repository at this point in the history
  • Loading branch information
wighawag committed Nov 23, 2023
2 parents 014f7cc + 84704d0 commit 45b2105
Show file tree
Hide file tree
Showing 23 changed files with 1,046 additions and 419 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ipfs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ jobs:
- uses: actions/checkout@v3
- uses: pnpm/action-setup@v2
with:
version: 7
version: 8
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
Expand Down
38 changes: 31 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,36 @@
# Jolly-Roger
<h1 align="center"> Jolly Roger </h1>

A template to develop decentralised applications
<p align="center">
<a href="https://jolly-roger.eth.limo">
<img src="docs/public/icon.svg" alt="Jolly-Roger Logo" width="300">
</a>
</p>

## How to use?
<p align="center">
<a href="https://twitter.com/jollyroger_eth">
<img alt="Twitter" src="https://img.shields.io/badge/Twitter-1DA1F2?logo=twitter&logoColor=white" />
</a>

<a href="https://github.com/wighawag/jolly-roger/commits">
<img alt="GitHub commit activity" src="https://img.shields.io/github/commit-activity/m/wighawag/jolly-roger">
</a>

<a href="https://github.com/wighawag/jolly-roger/issues">
<img alt="open issues" src="https://isitmaintained.com/badge/open/wighawag/jolly-roger.svg">
</a>
</p>

---

# Build and Deploy for Eternity

Jolly Roger is a production-ready template for decentralised applications.

# How to use?

We are assuming here that you already setup your env as specified in the [initial setup section](#initial-setup)

### install dependencies
## install dependencies

Note here that while you can use `pnpm i`, we recommend you follow the instruction here so you can have everything setup with your own project's name.

Expand All @@ -22,7 +46,7 @@ You can also manually set the name yourself :
pnpm set-name [<new name>] && pnpm i
```

### start!
## start!

Then Assuming you have [zellij](https://zellij.dev/) installed

Expand Down Expand Up @@ -64,7 +88,7 @@ pnpm indexer:dev
pnpm web:dev
```

## Deploying to a network
# Deploying to a network

Just execute the following

Expand All @@ -84,7 +108,7 @@ Then you can deploy your contract
pnpm contracts:deploy <network>
```

## Initial Setup
# Initial Setup

You need to have these installed

Expand Down
6 changes: 3 additions & 3 deletions common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,9 @@
},
"devDependencies": {
"ldenv": "^0.3.7",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
"typescript": "^5.2.2"
"prettier": "^3.1.0",
"tsup": "^8.0.1",
"typescript": "^5.3.2"
},
"scripts": {
"build": "tsup src/index.ts --dts --format esm,cjs",
Expand Down
12 changes: 7 additions & 5 deletions contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@
"@nomicfoundation/hardhat-network-helpers": "^1.0.9",
"as-soon": "^0.0.4",
"eip-1193": "^0.4.7",
"hardhat": "^2.19.0",
"hardhat": "^2.19.1",
"hardhat-rocketh": "^0.6.30",
"jolly-roger-common": "workspace:*",
"ldenv": "^0.3.7",
"prettier": "^3.0.3",
"prettier": "^3.1.0",
"prettier-plugin-solidity": "^1.2.0",
"rocketh": "^0.6.20",
"rocketh-deploy-proxy": "^0.6.26",
Expand All @@ -21,9 +21,10 @@
"rocketh-verifier": "^0.6.24",
"set-defaults": "^0.0.2",
"solidity-coverage": "^0.8.5",
"solidity-proxy": "^0.2.3",
"typescript": "^5.2.2",
"viem": "^1.19.0",
"solidity-proxy": "^0.2.4",
"tsx": "^4.2.0",
"typescript": "^5.3.2",
"viem": "^1.19.6",
"viem-chai-matchers": "^0.0.3",
"vitest": "^0.34.6",
"vitest-solidity-coverage": "^0.1.4"
Expand All @@ -34,6 +35,7 @@
"local_node": "rm -Rf deployments/localhost && hardhat node",
"compile": "hardhat compile",
"compile:watch": "as-soon -w src pnpm compile",
"execute": "ROCKETH_SKIP_ESBUILD=true ldenv -n HARDHAT_NETWORK -m localhost tsx @@",
"deploy": "ldenv hardhat --network @@MODE deploy @@",
"deploy:watch": "as-soon -w generated -w deploy pnpm run deploy",
"test": "vitest",
Expand Down
10 changes: 5 additions & 5 deletions contracts/scripts/readMessage.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import {Deployment, loadEnvironment} from 'rocketh';
import {context} from '../deploy/_context';
import {network} from 'hardhat';
import hre from 'hardhat';
import {EIP1193ProviderWithoutEvents} from 'eip-1193';
import {contract} from './viem';
import {fetchContract} from '../utils/connection';

async function main() {
const env = await loadEnvironment(
{
provider: network.provider as EIP1193ProviderWithoutEvents,
networkName: network.name,
provider: hre.network.provider as EIP1193ProviderWithoutEvents,
networkName: hre.network.name,
},
context,
);

const args = process.argv.slice(2);
const account = (args[0] || process.env.ACCOUNT) as `0x${string}`;
const Registry = env.deployments.Registry as Deployment<typeof context.artifacts.GreetingsRegistry.abi>;
const RegistryContract = contract(Registry);
const RegistryContract = await fetchContract(Registry);
const message = await RegistryContract.read.messages([account]);

console.log({account, message});
Expand Down
12 changes: 7 additions & 5 deletions contracts/scripts/setMessage.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,26 @@
import {Deployment, loadEnvironment} from 'rocketh';
import {context} from '../deploy/_context';
import {network} from 'hardhat';
import hre from 'hardhat';
import {EIP1193ProviderWithoutEvents} from 'eip-1193';
import {contract, walletClient} from './viem';
import {fetchContract, getConnection} from '../utils/connection';

async function main() {
const env = await loadEnvironment(
{
provider: network.provider as EIP1193ProviderWithoutEvents,
networkName: network.name,
provider: hre.network.provider as EIP1193ProviderWithoutEvents,
networkName: hre.network.name,
},
context,
);

const {walletClient} = await getConnection();

const args = process.argv.slice(2);
const message = (args[0] || process.env.MESSAGE) as `0x${string}`;

const [address] = await walletClient.getAddresses();
const Registry = env.deployments.Registry as Deployment<typeof context.artifacts.GreetingsRegistry.abi>;
const RegistryContract = contract(Registry);
const RegistryContract = await fetchContract(Registry);
const hash = await RegistryContract.write.setMessage([message, 1], {account: address});

console.log({hash, account: address});
Expand Down
27 changes: 0 additions & 27 deletions contracts/scripts/viem.ts

This file was deleted.

2 changes: 1 addition & 1 deletion contracts/test/GreetingsRegistry.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {loadFixture} from '@nomicfoundation/hardhat-network-helpers';
import {prefix_str} from 'jolly-roger-common';
import {Deployment, loadAndExecuteDeployments} from 'rocketh';

import {getConnection, fetchContract} from './connection';
import {getConnection, fetchContract} from '../utils/connection';

import artifacts from '../generated/artifacts';
import {network} from 'hardhat';
Expand Down
31 changes: 25 additions & 6 deletions contracts/test/connection.ts → contracts/utils/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,17 @@ import {
createPublicClient,
createWalletClient,
custom,
defineChain,
getContract,
} from 'viem';

import hre from 'hardhat';
import type {EIP1193ProviderWithoutEvents} from 'eip-1193';

import {hardhat} from 'viem/chains';
import {Chain} from 'viem';

export type Connection = {
walletClient: WalletClient<CustomTransport, typeof hardhat>;
publicClient: PublicClient<CustomTransport, typeof hardhat>;
walletClient: WalletClient<CustomTransport, Chain>;
publicClient: PublicClient<CustomTransport, Chain>;
accounts: `0x${string}`[];
provider: EIP1193ProviderWithoutEvents;
};
Expand All @@ -28,12 +28,29 @@ export async function getConnection(): Promise<Connection> {
}
const provider = hre.network.provider as EIP1193ProviderWithoutEvents;

const chainIdAsHex = await provider.request({method: 'eth_chainId'});
const chainIdAsNumber = parseInt(chainIdAsHex.slice(2), 16);
const chain = defineChain({
id: chainIdAsNumber,
name: hre.network.name,
network: hre.network.name,
nativeCurrency: {
decimals: 18,
name: 'Ether',
symbol: 'ETH',
},
rpcUrls: {
default: {http: []},
public: {http: []},
},
} as const);

const walletClient = createWalletClient({
chain: hardhat,
chain,
transport: custom(provider),
});
const publicClient = createPublicClient({
chain: hardhat,
chain,
transport: custom(provider),
});
return (cache.connection = {
Expand All @@ -52,3 +69,5 @@ export async function fetchContract<TAbi extends Abi>(contractInfo: {address: `0
publicClient,
});
}

export type ContractWithViemClient<TAbi extends Abi> = Awaited<ReturnType<typeof fetchContract<TAbi>>>;
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 3 additions & 3 deletions wezterm.lua → dev/wezterm.lua
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ wezterm.on('gui-startup', function(cmd)


}
tab:set_title 'jolly-roger'
window:set_title 'jolly-roger'
tab:set_title 'stratagems'
window:set_title 'stratagems'

local pane_indexer = pane:split {
local pane_indexer = pane:split {
args = {'bash', '-i', '-c', 'cd '.. cmd.args[1] .. '; sleep 1; pnpm indexer:dev; bash'},
direction = 'Bottom'
}
Expand Down
6 changes: 3 additions & 3 deletions zellij-attach.kdl → dev/zellij-attach.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ layout {
pane {
pane {}
pane split_direction="vertical" {
pane command="bash" {
pane name="INDEXER" command="bash" {
args "-c" "pnpm indexer:dev; cd indexer; ${SHELL-bash}"
}
pane command="bash" {
pane name="COMMON" command="bash" {
args "-c" "pnpm common:dev; cd common; ${SHELL-bash}"
}
pane command="bash" {
pane name="WEB" command="bash" {
args "-c" "pnpm web:dev; cd web; ${SHELL-bash}"
}
}
Expand Down
10 changes: 5 additions & 5 deletions zellij-remote.kdl → dev/zellij-remote.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,21 @@ layout {
pane {
pane {}
pane split_direction="vertical" {
pane command="bash" {
pane name="COMPILE" command="bash" {
args "-c" "pnpm contracts:compile:watch; cd contracts; ${SHELL-bash}"
}
pane command="bash" {
pane name="DEPLOY" command="bash" {
args "-c" "pnpm contracts:deploy:watch ${MODE}; cd contracts; ${SHELL-bash}"
}
}
pane split_direction="vertical" {
pane command="bash" {
pane name="INDEXER" command="bash" {
args "-c" "pnpm indexer:dev; cd indexer; ${SHELL-bash}"
}
pane command="bash" {
pane name="COMMON" command="bash" {
args "-c" "pnpm common:dev; cd common; ${SHELL-bash}"
}
pane command="bash" {
pane name="WEB" command="bash" {
args "-c" "pnpm web:dev; cd web; ${SHELL-bash}"
}
}
Expand Down
20 changes: 9 additions & 11 deletions zellij.kdl → dev/zellij.kdl
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,24 @@ layout {
pane {
pane {}
pane split_direction="vertical" {
pane command="bash" {
pane name="NODE" command="bash" {
args "-c" "pnpm local_node; ${SHELL-bash}"
}
pane {
pane command="bash" {
args "-c" "pnpm contracts:compile:watch; cd contracts; ${SHELL-bash}"
}
pane command="bash" {
args "-c" "pnpm contracts:deploy:watch; cd contracts; ${SHELL-bash}"
}
pane name="COMPILE" command="bash" {
args "-c" "pnpm contracts:compile:watch; cd contracts; ${SHELL-bash}"
}
pane name="DEPLOY" command="bash" {
args "-c" "pnpm contracts:deploy:watch; cd contracts; ${SHELL-bash}"
}
}
pane split_direction="vertical" {
pane command="bash" {
pane name="INDEXER" command="bash" {
args "-c" "pnpm indexer:dev; cd indexer; ${SHELL-bash}"
}
pane command="bash" {
pane name="COMMON" command="bash" {
args "-c" "pnpm common:dev; cd common; ${SHELL-bash}"
}
pane command="bash" {
pane name="WEB" command="bash" {
args "-c" "pnpm web:dev; cd web; ${SHELL-bash}"
}
}
Expand Down
8 changes: 4 additions & 4 deletions indexer/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
"devDependencies": {
"ethereum-indexer-server": "^0.6.16",
"ldenv": "^0.3.7",
"prettier": "^3.0.3",
"tsup": "^7.2.0",
"typescript": "^5.2.2",
"wait-on": "^7.1.0"
"prettier": "^3.1.0",
"tsup": "^8.0.1",
"typescript": "^5.3.2",
"wait-on": "^7.2.0"
},
"scripts": {
"eis": "eis",
Expand Down
Loading

0 comments on commit 45b2105

Please sign in to comment.