Skip to content

Commit

Permalink
Merge branch 'master' into fix-wrong-offchain-pending-vp
Browse files Browse the repository at this point in the history
  • Loading branch information
wa0x6e committed Dec 2, 2024
2 parents bb984a6 + 43dfcb2 commit 9f4f9d2
Show file tree
Hide file tree
Showing 127 changed files with 1,597 additions and 895 deletions.
5 changes: 0 additions & 5 deletions .changeset/eight-icons-explain.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/gentle-peas-nail.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/late-trees-compete.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/neat-falcons-pay.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/smooth-moose-smell.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/strange-ducks-shake.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/sweet-papayas-provide.md

This file was deleted.

5 changes: 0 additions & 5 deletions .changeset/twenty-cups-hope.md

This file was deleted.

4 changes: 2 additions & 2 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ jobs:
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Setup Node.js 16
- name: Setup Node.js 22
uses: actions/setup-node@v3
with:
node-version: 18
node-version: 22
- name: Install Dependencies
run: yarn
- name: Create Release Pull Request or Publish to npm
Expand Down
19 changes: 17 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,34 @@ name: CI

on: [push]

env:
STARKNET_DEVNET_VERSION: 0.2.3

jobs:
lint-build-test:
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Setup Node.js
- name: Setup Node.js 22
uses: actions/setup-node@v2
with:
node-version: "18.x"
node-version: 22
cache: "yarn"
- name: Setup Rust Toolchain
uses: dtolnay/rust-toolchain@stable
- name: Restore Cargo
uses: actions/cache@v4
with:
path: ~/.cargo
key: ${{ runner.os }}-cargo-${{ env.STARKNET_DEVNET_VERSION }}
- name: Install Starknet Devnet
run: cargo install starknet-devnet@${{ env.STARKNET_DEVNET_VERSION }}
- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
- run: yarn --frozen-lockfile
- run: yarn build
- run: yarn typecheck
- run: yarn lint
- run: yarn test
- run: yarn test:integration
39 changes: 36 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,16 @@ yarn

### Compiles and hot-reloads for development

#### UI only

```sh
yarn dev

# if you want to run full stack (including backend services)
yarn dev:full
```

#### UI with backend services

[See here.](./README.md#running-local-services)

### Compiles and minifies for production

```
Expand All @@ -50,6 +53,36 @@ yarn test
yarn typecheck
```

## Running local services

You can run all local services (api, subgraph-api, mana, ui) with single command assuming you have all necessary environment variables set up.
Local APIs will only be used for Ethereum Sepolia and Starknet Sepolia.

```
yarn dev:full
```

### Setup

You need to have Docker running on your machine.

In `apps/api` and `apps/mana` copy `.env.example` to `.env` files.

In `apps/mana/.env` you need to fill in following empty variables:

- `STARKNET_MNEMONIC` and `ETH_MNEMONIC` - if you want to use it as relayer.
- `HERODOTUS_API_KEY` and `HERODOTUS_LEGACY_API_KEY` - if you want to use L1<->L2 messaging (voting with strategies that use L1 proofs)

### Getting it running faster

If you run `yarn dev:full` it will take long time to sync all the blocks for the first time. To mitigate it you can just change starting block
for indexing here:

- https://github.com/snapshot-labs/sx-monorepo/blob/0f767b8c69d6986d06c70eb4a1ed7cb33e235b5a/apps/api/src/overrrides.ts#L50 (for Starknet)
- https://github.com/snapshot-labs/sx-monorepo/blob/0f767b8c69d6986d06c70eb4a1ed7cb33e235b5a/apps/subgraph-api/networks.json#L12-L21 (for Ethereum)

If you do that make sure to create a new space, because spaces created before the new starting block you picked won't be available.

## Versioning packages

Packages are versioned using [`changesets`](https://github.com/changesets/changesets).
Expand Down
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"@ethersproject/providers": "^5.7.2",
"@ethersproject/units": "^5.6.1",
"@faker-js/faker": "^7.4.0",
"@snapshot-labs/checkpoint": "^0.1.0-beta.39",
"@snapshot-labs/checkpoint": "^0.1.0-beta.44",
"@snapshot-labs/sx": "^0.1.0",
"@types/bn.js": "^5.1.0",
"@types/mysql": "^2.15.21",
Expand Down
4 changes: 2 additions & 2 deletions apps/api/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,10 @@ export async function handleExecutionStrategy(
const [l1Destination] = payload;
if (!l1Destination)
throw new Error('Invalid payload for EthRelayer execution strategy');
destinationAddress = l1Destination;
destinationAddress = formatAddress('Ethereum', l1Destination);

const SimpleQuorumExecutionStrategyContract = new EthContract(
l1Destination,
destinationAddress,
SimpleQuorumExecutionStrategyAbi,
ethProvider
);
Expand Down
7 changes: 7 additions & 0 deletions apps/mana/src/db.ts
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,10 @@ export async function markProposalProcessed(id: string) {
export async function getProposal(id: string) {
return knex(REGISTERED_PROPOSALS).select('*').where({ id }).first();
}

export async function getDataByMessageHash(hash: string) {
return knex(REGISTERED_TRANSACTIONS)
.select(['sender', 'type', 'data', 'hash', 'network'])
.where({ hash })
.first();
}
4 changes: 1 addition & 3 deletions apps/mana/src/eth/rpc.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import {
clients,
evmArbitrum,
evmLineaGoerli,
evmMainnet,
EvmNetworkConfig,
evmOptimism,
Expand All @@ -18,8 +17,7 @@ export const NETWORKS = new Map<number, EvmNetworkConfig>([
[137, evmPolygon],
[42161, evmArbitrum],
[1, evmMainnet],
[11155111, evmSepolia],
[59140, evmLineaGoerli]
[11155111, evmSepolia]
]);

export const createNetworkHandler = (chainId: number) => {
Expand Down
3 changes: 2 additions & 1 deletion apps/mana/src/stark/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ const jsonRpcRequestSchema = z.object({
'send',
'execute',
'registerTransaction',
'registerProposal'
'registerProposal',
'getDataByMessageHash'
]),
params: z.any()
});
Expand Down
16 changes: 15 additions & 1 deletion apps/mana/src/stark/rpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,11 +137,25 @@ export const createNetworkHandler = (chainId: string) => {
}
}

async function getDataByMessageHash(id: number, params: any, res: Response) {
try {
const { hash } = params;

const transaction = await db.getDataByMessageHash(hash);

return rpcSuccess(res, transaction, id);
} catch (e) {
console.log('Failed', e);
return rpcError(res, 500, e, id);
}
}

return {
send,
execute,
registerTransaction,
registerProposal,
getAccount
getAccount,
getDataByMessageHash
};
};
10 changes: 0 additions & 10 deletions apps/subgraph-api/networks.json
Original file line number Diff line number Diff line change
Expand Up @@ -48,15 +48,5 @@
"address": "0x0000000000021210000000000000000000000000",
"startBlock": 157825417
}
},
"linea-testnet": {
"ProxyFactory": {
"address": "0x12A1FfFFfd70677939D61d641eA043bc9060c718",
"startBlock": 858097
},
"L1AvatarExecutionStrategyFactory": {
"address": "0x0000000000021210000000000000000000000000",
"startBlock": 858097
}
}
}
3 changes: 1 addition & 2 deletions apps/subgraph-api/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "api-subgraph",
"private": true,
"version": "0.0.42",
"version": "0.0.43",
"scripts": {
"test": "graph test",
"codegen": "graph codegen",
Expand All @@ -11,7 +11,6 @@
"create-local": "graph create --node http://localhost:8020/ snapshot-labs/sx-subgraph",
"remove-local": "graph remove --node http://localhost:8020/ snapshot-labs/sx-subgraph",
"deploy-local": "yarn create-local && graph deploy --node http://localhost:8020/ --network sepolia -l `LC_ALL=C tr -dc a-z0-9 </dev/urandom | head -c 32` snapshot-labs/sx-subgraph",
"deploy-linea-testnet": "graph deploy --network linea-testnet --studio sx-linea-testnet",
"deploy-studio": "graph deploy --studio -l v${npm_package_version}",
"deploy-studio-mainnet": "yarn deploy-studio --network mainnet sx",
"deploy-studio-sepolia": "yarn deploy-studio --network sepolia sx-sepolia",
Expand Down
1 change: 0 additions & 1 deletion apps/subgraph-api/src/mapping.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ CHAIN_IDS.set('sepolia', 11155111)
CHAIN_IDS.set('optimism', 10)
CHAIN_IDS.set('matic', 137)
CHAIN_IDS.set('arbitrum-one', 42161)
CHAIN_IDS.set('linea-testnet', 59140)

export function handleProxyDeployed(event: ProxyDeployed): void {
let network = dataSource.network()
Expand Down
2 changes: 1 addition & 1 deletion apps/ui/.env
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ VITE_ENABLED_NETWORKS=
VITE_METADATA_NETWORK=
VITE_MANA_URL=https://mana.box
VITE_HIGHLIGHT_URL=https://testnet.highlight.red
VITE_IPFS_GATEWAY=snapshot.4everland.link
VITE_IPFS_GATEWAY=ipfs.snapshot.box
VITE_INFURA_API_KEY=46a5dd9727bf48d4a132672d3f376146
VITE_ALCHEMY_API_KEY=ombBQyf580z-jx2EVQgJu4eTjePU-a2z
VITE_OPENSEA_API_KEY=dad1ec57d9024a1d9cb72e6d82c2d015
Expand Down
4 changes: 2 additions & 2 deletions apps/ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
"@openzeppelin/merkle-tree": "^1.0.5",
"@snapshot-labs/eslint-config-vue": "^0.1.0-beta.18",
"@snapshot-labs/highlight": "^0.1.0-beta.2",
"@snapshot-labs/lock": "^0.2.8",
"@snapshot-labs/lock": "^0.2.10",
"@snapshot-labs/pineapple": "^1.1.0",
"@snapshot-labs/prettier-config": "^0.1.0-beta.18",
"@snapshot-labs/snapshot.js": "^0.12.28",
"@snapshot-labs/snapshot.js": "^0.12.33",
"@snapshot-labs/sx": "^0.1.0",
"@vueuse/core": "^10.4.1",
"@walletconnect/core": "^2.11.0",
Expand Down
3 changes: 1 addition & 2 deletions apps/ui/src/App.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
<script setup lang="ts">
import defaultRoutes from '@/routes/default';
import whiteLabelRoutes from '@/routes/whiteLabel';
import { startIntercom } from './helpers/intercom';
const route = useRoute();
const router = useRouter();
Expand Down Expand Up @@ -31,7 +30,6 @@ watch(
resolved => {
if (!resolved) return;
if (!isWhiteLabel.value) startIntercom();
if (isCustomDomain.value && !whiteLabelFailed.value) {
mountCustomDomainRoutes();
}
Expand All @@ -48,4 +46,5 @@ onMounted(() => {
<LayoutSplashScreen v-if="!whiteLabelResolved" />
<LayoutSite v-else-if="routeName === 'site'" />
<LayoutApp v-else />
<Messenger />
</template>
4 changes: 4 additions & 0 deletions apps/ui/src/components/App/Topnav.vue
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ watch(
searchQuery => (searchValue.value = searchQuery),
{ immediate: true }
);
onUnmounted(() => {
resetAccountModal();
});
</script>

<template>
Expand Down
16 changes: 14 additions & 2 deletions apps/ui/src/components/AppLink.vue
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
<script lang="ts" setup>
import { RouteLocationRaw, RouterLinkProps } from 'vue-router';
const props = defineProps<RouterLinkProps>();
const props = defineProps<
Omit<RouterLinkProps, 'to'> & { to?: RouteLocationRaw }
>();
const { isWhiteLabel } = useWhiteLabel();
function isExternalLink(to: RouteLocationRaw | undefined): to is string {
return typeof to === 'string' && to.startsWith('http');
}
function normalize(to: RouteLocationRaw) {
if (
!isWhiteLabel.value ||
Expand Down Expand Up @@ -32,7 +38,13 @@ function normalize(to: RouteLocationRaw) {
</script>

<template>
<router-link :to="normalize(props.to)">
<a v-if="isExternalLink(props.to)" :href="props.to" target="_blank">
<slot />
</a>
<router-link v-else-if="props.to" :to="normalize(props.to)">
<slot />
</router-link>
<div v-else>
<slot />
</div>
</template>
Loading

0 comments on commit 9f4f9d2

Please sign in to comment.