Skip to content

Commit

Permalink
Add Lukso/ Celo support (#3410)
Browse files Browse the repository at this point in the history
* added celo lukso

add to common

wip

wip

smol fix for build/test fixes for manager

add lukso celo

add lukso celo

everything is custom now

add chains to mr

rm: lit is optional (#3414)

* rm: lit is optional

* add chains to mr

* fix application

---------

Co-authored-by: 0xKurt <[email protected]>

rm unused imports

rm celo

fix tests

added type

add tokens

rm comment

remove redundancy

fix

fix

address update

hide encryption switch

* remove sei and era testnet

---------

Co-authored-by: 0xKurt <[email protected]>
Co-authored-by: Aditya Anand M C <[email protected]>
  • Loading branch information
3 people authored May 13, 2024
1 parent d44273e commit e410416
Show file tree
Hide file tree
Showing 54 changed files with 37,644 additions and 127 deletions.
4 changes: 2 additions & 2 deletions packages/builder/src/actions/roundApplication.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,15 +134,15 @@ const dispatchAndLogApplicationError = (
dispatch(applicationError(roundAddress, error, step));
};

export function chainIdToChainName(chainId: number): string {
export function chainIdToChainName(chainId: number): string | undefined {
// eslint-disable-next-line no-restricted-syntax
for (const name in LitJsSdk.LIT_CHAINS) {
if (LitJsSdk.LIT_CHAINS[name].chainId === chainId) {
return name;
}
}

throw new Error(`couldn't find LIT chain name for chainId ${chainId}`);
return undefined;
}

const applyToRound =
Expand Down
16 changes: 16 additions & 0 deletions packages/builder/src/contracts/deployments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ export const chains = {
8453: "base",
534352: "scroll",
713715: "seiDevnet",
42: "lukso",
4201: "luksoTestnet",
42220: "celo",
44787: "celoAlfajores",
} as const;

export type ChainName = (typeof chains)[keyof typeof chains];
Expand Down Expand Up @@ -104,6 +108,18 @@ export const addresses: DeploymentAddressesMap = {
seiDevnet: {
projectRegistry: "0x5B47c6aFE27b0F5C8319366C6b8FbC0E02104b98",
},
luksoTestnet: {
projectRegistry: "0x", // v1 not supported
},
lukso: {
projectRegistry: "0x", // v1 not supported
},
celo: {
projectRegistry: "0x", // v1 not supported
},
celoAlfajores: {
projectRegistry: "0x", // v1 not supported
},
};

export const addressesByChainID = (chainId: ChainId): DeploymentAddresses => {
Expand Down
23 changes: 13 additions & 10 deletions packages/builder/src/utils/RoundApplicationBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,31 +14,34 @@ export default class RoundApplicationBuilder {

private roundAddress: string;

private chainName: string;

private lit: Lit;
private lit?: Lit;

constructor(
enableEncryption: boolean,
project: Project,
ram: RoundApplicationMetadata,
roundAddress: string,
chainName: string
chainName?: string
) {
this.enableEncryption = enableEncryption;
this.project = project;
this.ram = ram;
this.roundAddress = roundAddress;
this.chainName = chainName;
const litInit = {
chain: chainName,
contract: this.roundAddress,
};

this.lit = new Lit(litInit);
if (chainName) {
const litInit = {
chain: chainName,
contract: this.roundAddress,
};
this.lit = new Lit(litInit);
}
}

async encryptAnswer(answer: string) {
if (!this.lit) {
throw new Error("lit not initialized");
}

if (!this.enableEncryption) {
return {
ciphertext: answer,
Expand Down
14 changes: 14 additions & 0 deletions packages/builder/src/utils/chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,10 @@ import {
sepolia,
scroll,
seiDevnet,
customCelo as celo,
customCeloAlfajores as celoAlfajores,
customLukso as lukso,
customLuksoTestnet as luksoTestnet,
} from "common/src/chains";
import { getConfig } from "common/src/config";
import { polygonMumbai } from "@wagmi/core/chains";
Expand All @@ -32,6 +36,8 @@ const availableChains: { [key: string]: Chain } = {
fantom,
optimism: customOptimism,
pgn,
celo,
celoAlfajores,
arbitrum,
avalanche,
polygon: customPolygon,
Expand All @@ -46,6 +52,8 @@ const availableChains: { [key: string]: Chain } = {
zkSyncEraTestnet,
sepolia,
seiDevnet,
lukso,
luksoTestnet,
};

const stagingChains = [
Expand All @@ -69,6 +77,10 @@ const stagingChains = [
zkSyncEraTestnet,
sepolia,
seiDevnet,
celo,
celoAlfajores,
lukso,
luksoTestnet,
];

const productionChains = [
Expand All @@ -83,6 +95,8 @@ const productionChains = [
base,
scroll,
seiDevnet,
celo,
lukso,
];

export function getEnabledChainsAndProviders() {
Expand Down
14 changes: 14 additions & 0 deletions packages/builder/src/utils/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ import AVAXIcon from "common/src/icons/AVAX.svg";
import POLIcon from "common/src/icons/pol-logo.svg";
import ZkSyncIcon from "common/src/icons/zksync-logo.svg";
import ScrollIcon from "common/src/icons/scroll-logo.svg";
import LuksoIcon from "common/src/icons/lukso-logo.svg";
import CeloIcon from "common/src/icons/celo-logo.svg";
import FantomFTMLogo from "common/src/assets/fantom-ftm-logo.png";
import { SeiIcon } from "common/src/chains";
import {
Expand Down Expand Up @@ -53,6 +55,10 @@ export const networkPrettyNames: { [key in ChainName]: string } = {
scroll: "Scroll",
sepolia: "sepolia",
seiDevnet: "SEI Devnet",
lukso: "Lukso",
luksoTestnet: "Lukso Testnet",
celo: "Celo",
celoAlfajores: "Celo Alfajores",
};

export const networkIcon: { [key in ChainName]: string } = {
Expand All @@ -77,6 +83,10 @@ export const networkIcon: { [key in ChainName]: string } = {
scroll: ScrollIcon,
sepolia: EthDiamondGlyph,
seiDevnet: SeiIcon,
lukso: LuksoIcon,
luksoTestnet: LuksoIcon,
celo: CeloIcon,
celoAlfajores: CeloIcon,
};

export const payoutIcon: { [key in ChainName]: string } = {
Expand All @@ -101,6 +111,10 @@ export const payoutIcon: { [key in ChainName]: string } = {
scroll: ScrollIcon,
sepolia: EthDiamondGlyph,
seiDevnet: SeiIcon,
lukso: LuksoIcon,
luksoTestnet: LuksoIcon,
celo: CeloIcon,
celoAlfajores: CeloIcon,
};

export function getNetworkIcon(chainId: ChainId): string {
Expand Down
2 changes: 1 addition & 1 deletion packages/common/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"test:watch": "vitest watch"
},
"dependencies": {
"@allo-team/allo-v2-sdk": "1.0.67",
"@allo-team/allo-v2-sdk": "^1.0.71",
"@ethersproject/abstract-signer": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@gitcoinco/passport-sdk-types": "^0.2.0",
Expand Down
28 changes: 28 additions & 0 deletions packages/common/src/allo/addresses/allo-v1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export const projectRegistryMap: ChainIdToStringMap = {
[ChainId.SEPOLIA]: "0x2420EABfA2C0e6f77E435B0B7615c848bF4963AF",
[ChainId.SCROLL]: "0xDF9BF58Aa1A1B73F0e214d79C652a7dd37a6074e",
[ChainId.SEI_DEVNET]: "0x",
[ChainId.LUKSO_TESTNET]: "0x",
[ChainId.LUKSO]: "0x",
[ChainId.CELO_ALFAJORES]: "0x",
[ChainId.CELO]: "0x",
};

export const programFactoryMap: ChainIdToStringMap = {
Expand Down Expand Up @@ -60,6 +64,10 @@ export const programFactoryMap: ChainIdToStringMap = {
[ChainId.SEPOLIA]: "0x79Ba35cb31620db1b5b101A9A13A1b0A82B5BC9e",
[ChainId.SCROLL]: "0x545B282A50EaeA01A619914d44105437036CbB36",
[ChainId.SEI_DEVNET]: "0x",
[ChainId.LUKSO_TESTNET]: "0x",
[ChainId.LUKSO]: "0x",
[ChainId.CELO_ALFAJORES]: "0x",
[ChainId.CELO]: "0x",
};

export const roundFactoryMap: ChainIdToStringMap = {
Expand Down Expand Up @@ -88,6 +96,10 @@ export const roundFactoryMap: ChainIdToStringMap = {
[ChainId.SEPOLIA]: "0xF1d4F5f21746bCD75fD71eB18992443f4F0edb6f",
[ChainId.SCROLL]: "0x29aAF7D4E83A778DAee08Fe04B0712c4C2989AD1",
[ChainId.SEI_DEVNET]: "0x",
[ChainId.LUKSO_TESTNET]: "0x",
[ChainId.LUKSO]: "0x",
[ChainId.CELO_ALFAJORES]: "0x",
[ChainId.CELO]: "0x",
};

export const qfVotingStrategyFactoryMap: ChainIdToStringMap = {
Expand Down Expand Up @@ -116,6 +128,10 @@ export const qfVotingStrategyFactoryMap: ChainIdToStringMap = {
[ChainId.SEPOLIA]: "0xf5D111B57de221774866AC32c4435841F5c141D5",
[ChainId.SCROLL]: "0x5b55728e41154562ee80027C1247B13382692e5C",
[ChainId.SEI_DEVNET]: "0x",
[ChainId.LUKSO_TESTNET]: "0x",
[ChainId.LUKSO]: "0x",
[ChainId.CELO_ALFAJORES]: "0x",
[ChainId.CELO]: "0x",
};

export const dgVotingStrategyDummyContractMap: ChainIdToStringMap = {
Expand Down Expand Up @@ -144,6 +160,10 @@ export const dgVotingStrategyDummyContractMap: ChainIdToStringMap = {
[ChainId.SEPOLIA]: "0xB9dDcd73278C7f472867bf3D844E2Cc53a3d3D90",
[ChainId.SCROLL]: "0x1525370A2B92FB5e8D0a44F3A9833f0E9F1a54b5",
[ChainId.SEI_DEVNET]: "0x",
[ChainId.LUKSO_TESTNET]: "0x",
[ChainId.LUKSO]: "0x",
[ChainId.CELO_ALFAJORES]: "0x",
[ChainId.CELO]: "0x",
};

export const merklePayoutStrategyFactoryMap: ChainIdToStringMap = {
Expand Down Expand Up @@ -172,6 +192,10 @@ export const merklePayoutStrategyFactoryMap: ChainIdToStringMap = {
[ChainId.SEPOLIA]: "0xB5CF3fFD3BDfC6A124aa9dD96fE14118Ed8083e5",
[ChainId.SCROLL]: "0x7ac74Be34b1A27E48a2525259719F877a57B2Aa4",
[ChainId.SEI_DEVNET]: "0x",
[ChainId.LUKSO_TESTNET]: "0x",
[ChainId.LUKSO]: "0x",
[ChainId.CELO_ALFAJORES]: "0x",
[ChainId.CELO]: "0x",
};

export const directPayoutStrategyFactoryContractMap: ChainIdToStringMap = {
Expand Down Expand Up @@ -200,4 +224,8 @@ export const directPayoutStrategyFactoryContractMap: ChainIdToStringMap = {
[ChainId.SEPOLIA]: "0xC2B0d8dAdB88100d8509534BB8B5778d1901037d",
[ChainId.SCROLL]: "0xc7722909fEBf7880E15e67d563E2736D9Bb9c1Ab",
[ChainId.SEI_DEVNET]: "0x",
[ChainId.LUKSO_TESTNET]: "0x",
[ChainId.LUKSO]: "0x",
[ChainId.CELO_ALFAJORES]: "0x",
[ChainId.CELO]: "0x",
};
6 changes: 5 additions & 1 deletion packages/common/src/allo/addresses/mrc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,9 @@ export const MRC_CONTRACTS: Record<ChainId, Hex> = {
[ChainId.BASE]: "0x7C24f3494CC958CF268a92b45D7e54310d161794",
[ChainId.SEPOLIA]: "0xa54A0c7Bcd37745f7F5817e06b07E2563a07E309",
[ChainId.SCROLL]: "0x8Bd6Bc246FAF14B767954997fF3966CD1c0Bf0f5",
[ChainId.SEI_DEVNET]: "0x710172b2C0aCc629A3FD23D436c347807dD5C412",
[ChainId.SEI_DEVNET]: "0x313eC6CA225C40Bc670d8cd4b063734BD22ad1ab",
[ChainId.LUKSO_TESTNET]: "0xC1087157eF2aaeBcaDB913251EA5B82c678424F7",
[ChainId.LUKSO]: "0x029dFAf686DfA0efdace5132ba422e9279D50b5b",
[ChainId.CELO_ALFAJORES]: "0x8Ad0a1111B3d8453Ea9C444cA7d708A65BF81Def",
[ChainId.CELO]: "0xb1481E4Bb2a018670aAbF68952F73BE45bdAD62D",
};
21 changes: 19 additions & 2 deletions packages/common/src/allo/backends/allo-v2.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,13 @@ function getStrategyAddress(strategy: RoundCategory, chainId: ChainId): string {
let strategyAddresses;
switch (chainId) {
case ChainId.ZKSYNC_ERA_MAINNET_CHAIN_ID:
throw new Error("ZkSync era mainnet is not supported");
strategyAddresses = {
[RoundCategory.QuadraticFunding]:
"0x61E288cf14f196CF8a6104ec421ae17c7f16a749",
[RoundCategory.Direct]: "0x0000000000000000000000000000000000000000",
};
break;

case ChainId.ZKSYNC_ERA_TESTNET_CHAIN_ID:
throw new Error("ZkSync era testnet is not supported");

Expand All @@ -63,6 +69,15 @@ function getStrategyAddress(strategy: RoundCategory, chainId: ChainId): string {
};
break;

case ChainId.LUKSO:
case ChainId.LUKSO_TESTNET:
strategyAddresses = {
[RoundCategory.QuadraticFunding]:
"0x91b5eeE385D8e0cfd49FD94D4C7aE15e1F17e0A2",
[RoundCategory.Direct]: "0x0000000000000000000000000000000000000000",
};
break;

default:
strategyAddresses = {
[RoundCategory.QuadraticFunding]:
Expand Down Expand Up @@ -507,7 +522,9 @@ export class AlloV2 implements Allo {
token,
amount: 0n, // we send 0 tokens to the pool, we fund it later
metadata: { protocol: 1n, pointer: roundIpfsResult.value },
managers: args.roundData.roundOperators ?? [],
managers: (args.roundData.roundOperators ?? []).map((operator) =>
getAddress(operator)
),
};

const txData = this.allo.createPool(createPoolArgs);
Expand Down
8 changes: 8 additions & 0 deletions packages/common/src/chain-ids.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,13 @@ export enum ChainId {
DEV2 = 313372,
SEPOLIA = 11155111,
SEI_DEVNET = 713715,
LUKSO = 42,
LUKSO_TESTNET = 4201,
CELO = 42220,
CELO_ALFAJORES = 44787,
}

// see: https://github.com/redstone-finance/redstone-node/blob/main/src/config/tokens.json
export const RedstoneTokenIds = {
FTM: "FTM",
USDC: "USDC",
Expand All @@ -40,4 +45,7 @@ export const RedstoneTokenIds = {
USDGLO: "USDGLO",
SEI: "SEI",
OP: "OP",
LYX: "LYX",
CELO: "CELO",
CUSD: "CUSD",
} as const;
Loading

0 comments on commit e410416

Please sign in to comment.