Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

env/devnet-amplifier #472

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
6169188
chore: account session hooks
SGiaccobasso Oct 7, 2024
cce10e4
chore: refactor use custom useAccount and useDisconnect everywhere
SGiaccobasso Oct 8, 2024
9c59557
chore: next-auth session
SGiaccobasso Oct 9, 2024
ee38d40
chore: merge main
SGiaccobasso Oct 9, 2024
3b88349
chore: useEffect to fix interactivity issue
SGiaccobasso Oct 10, 2024
e86fac1
chore: interactivity issue
SGiaccobasso Oct 10, 2024
60d62de
chore: fix session issue
SGiaccobasso Oct 10, 2024
d51a336
chore: add sui logo
SGiaccobasso Oct 10, 2024
167a7f3
chore: fix login modal
SGiaccobasso Oct 10, 2024
f7e5da6
chore: fix main page style issue
SGiaccobasso Oct 10, 2024
0d9307c
chore: useChainId custom hook refactor
SGiaccobasso Oct 14, 2024
9ed314f
chore: useBalance refactor
SGiaccobasso Oct 14, 2024
9f73393
chore: lockfile update
SGiaccobasso Oct 14, 2024
7436461
chore: wip useSwitchChain
SGiaccobasso Oct 23, 2024
c432834
chore: wip deploy token sui
SGiaccobasso Oct 25, 2024
6a94acc
chore: return undefined chain if no wallet connected in useAccount
SGiaccobasso Oct 29, 2024
30f4915
chore: sign and execute deploy tx
SGiaccobasso Oct 29, 2024
4400e78
chore: all sui deploy token txs working
SGiaccobasso Oct 30, 2024
c8fcf4a
chore: db migration to accept sui types
SGiaccobasso Nov 6, 2024
9599020
chore: register deployed token in db
SGiaccobasso Nov 19, 2024
96553d7
chore: testing remote deploy
SGiaccobasso Nov 25, 2024
f51a3ca
Feat/sui integration euro (#470)
SGiaccobasso Nov 27, 2024
ae5e8b8
chore: prevent error after deploying remote token
SGiaccobasso Nov 28, 2024
1677d4b
feat: support deployment from sui to evm (#471)
npty Nov 28, 2024
bbc5c4b
chore: use contract addresses from env file
SGiaccobasso Nov 28, 2024
4034723
chore: sui client to use env network
SGiaccobasso Nov 28, 2024
0b65bd3
chore: remove logs
SGiaccobasso Nov 28, 2024
8593f94
feat: support devnet amplifier (#473)
npty Dec 2, 2024
135ab42
chore: wip token details
SGiaccobasso Dec 10, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion apps/maestro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,13 +34,18 @@
"release": "tsx scripts/release.ts"
},
"dependencies": {
"@axelar-network/axelarjs-sdk": "0.15.0",
"@axelar-network/axelar-cgp-sui": "0.0.0-snapshot.424bc13",
"@axelar-network/axelarjs-sdk": "0.17.1-alpha.5",
"@axelarjs/api": "workspace:*",
"@axelarjs/core": "workspace:*",
"@axelarjs/evm": "workspace:*",
"@axelarjs/ui": "workspace:*",
"@axelarjs/utils": "workspace:*",
"@hookform/resolvers": "^3.3.4",
"@mysten/bcs": "^1.1.0",
"@mysten/dapp-kit": "^0.14.39",
"@mysten/sui": "^1.11.0",
"@mysten/sui.js": "^0.54.1",
"@sentry/nextjs": "^7.108.0",
"@tanstack/react-query": "^5.28.6",
"@trpc/client": "11.0.0-next.320",
Expand All @@ -51,6 +56,7 @@
"@vercel/postgres": "^0.7.2",
"@web3modal/wagmi": "^4.1.1",
"drizzle-orm": "^0.29.5",
"hardhat": "^2.22.13",
"lucide-react": "^0.265.0",
"next": "^14.1.4",
"nextjs-cors": "^2.2.0",
Expand Down
3 changes: 3 additions & 0 deletions apps/maestro/public/logos/chains/sui.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion apps/maestro/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export const NEXT_PUBLIC_WALLET_CONNECT_PROJECT_ID = Maybe.of(

export const NEXT_PUBLIC_NETWORK_ENV = String(
process.env.NEXT_PUBLIC_NETWORK_ENV ?? "testnet"
) as "mainnet" | "testnet";
) as "mainnet" | "testnet" | "devnet-amplifier";

export const NEXT_PUBLIC_AXELAR_CONFIGS_URL = Maybe.of(
process.env.NEXT_PUBLIC_AXELAR_CONFIGS_URL
Expand Down
90 changes: 89 additions & 1 deletion apps/maestro/src/config/evm-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ import { NEXT_PUBLIC_NETWORK_ENV } from "./env";
export interface ExtendedWagmiChainConfig extends Chain {
axelarChainId: string;
axelarChainName: string;
environment: "mainnet" | "testnet";
environment: "mainnet" | "testnet" | "devnet-amplifier";
}

const ENVIRONMENTS = {
mainnet: "mainnet",
devnet: "devnet-amplifier",
testnet: "testnet",
} as const;

Expand All @@ -76,8 +77,71 @@ export const ALL_CHAINS: ExtendedWagmiChainConfig[] = [
axelarChainName: "ethereum",
environment: ENVIRONMENTS.mainnet,
},
// TODO: correct this
{
id: 101,
axelarChainId: "sui",
axelarChainName: "sui",
environment: ENVIRONMENTS.mainnet,
name: "Sui",
nativeCurrency: {
name: "SUI",
symbol: "SUI",
decimals: 9,
},
rpcUrls: {
default: { http: ["https://sui-rpc.publicnode.com"] },
public: { http: ["https://sui-rpc.publicnode.com"] },
},
blockExplorers: {
default: { name: "Sui Explorer", url: "https://suiexplorer.com/" },
},
},
{
id: 103,
axelarChainId: "sui",
axelarChainName: "sui",
environment: ENVIRONMENTS.devnet,
name: "Sui Testnet",
nativeCurrency: {
name: "SUI",
symbol: "SUI",
decimals: 9,
},
rpcUrls: {
default: { http: ["https://fullnode.testnet.sui.io:443"] },
public: { http: ["https://fullnode.testnet.sui.io:443"] },
},
blockExplorers: {
default: { name: "Sui Explorer", url: "https://suiscan.xyz/testnet" },
},
},
//TODO: check if this is ok
{
id: 103,
axelarChainId: "sui",
axelarChainName: "sui",
environment: ENVIRONMENTS.testnet,
name: "Sui Testnet",
nativeCurrency: {
name: "SUI",
symbol: "SUI",
decimals: 9,
},
rpcUrls: {
default: { http: ["https://fullnode.testnet.sui.io:443"] },
public: { http: ["https://fullnode.testnet.sui.io:443"] },
},
blockExplorers: {
default: { name: "Sui Explorer", url: "https://suiscan.xyz/testnet" },
},
},
{
...sepolia,
rpcUrls: {
default: { http: ["https://rpc-sepolia.rockx.com"] },
public: { http: ["https://rpc-sepolia.rockx.com"] },
},
axelarChainId: "ethereum-sepolia",
axelarChainName: "ethereum-sepolia",
environment: ENVIRONMENTS.testnet,
Expand Down Expand Up @@ -348,6 +412,30 @@ export const ALL_CHAINS: ExtendedWagmiChainConfig[] = [
axelarChainName: "blast-sepolia",
environment: ENVIRONMENTS.testnet,
},
{
...blastSepolia,
axelarChainId: "blast-sepolia",
axelarChainName: "blast-sepolia",
environment: ENVIRONMENTS.testnet,
},
{
...avalancheFuji,
axelarChainId: "avalanche-fuji",
axelarChainName: "avalanche-fuji",
environment: ENVIRONMENTS.devnet,
},
{
...optimismSepolia,
axelarChainId: "optimism-sepolia",
axelarChainName: "optimism-sepolia",
environment: ENVIRONMENTS.devnet,
},
{
...sepolia,
axelarChainId: "eth-sepolia",
axelarChainName: "eth-sepolia",
environment: ENVIRONMENTS.devnet,
},
] as const;

export const WAGMI_CHAIN_CONFIGS = ALL_CHAINS.filter(
Expand Down
37 changes: 23 additions & 14 deletions apps/maestro/src/config/next-auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@ import { Maybe } from "@axelarjs/utils";
import type { NextAuthOptions } from "next-auth";
import CredentialsProvider from "next-auth/providers/credentials";

import { verifyPersonalMessageSignature } from "@mysten/sui/verify";
import { kv } from "@vercel/kv";
import { getAddress, verifyMessage } from "viem";
import { verifyMessage } from "viem";

import db from "~/lib/drizzle/client";
import { getSignInMessage } from "~/server/routers/auth/createSignInMessage";
Expand Down Expand Up @@ -43,15 +44,14 @@ export const NEXT_AUTH_OPTIONS: NextAuthOptions = {
async authorize(credentials, req) {
if (
!credentials?.address ||
!getAddress(credentials?.address) ||
// !getAddress(credentials?.address) ||
!credentials?.signature
) {
return null;
}

const address = getAddress(credentials.address);
//TODO: revert
const address = credentials.address as `0x${string}`;
const signature = credentials.signature as `0x${string}`;

const [accountNonce, accountStatus] = await Promise.all([
kvClient.getAccountNonce(address),
kvClient.getAccountStatus(address),
Expand Down Expand Up @@ -79,21 +79,30 @@ export const NEXT_AUTH_OPTIONS: NextAuthOptions = {
}
return null;
}

let isMessageSigned;
const message = getSignInMessage(accountNonce ?? 0);

const isMessageSigned = await verifyMessage({
message,
signature,
address,
});
// is SUI address
if (address.length === 66) {
const suiPublicKey = await verifyPersonalMessageSignature(
new TextEncoder().encode(message),
signature
);
isMessageSigned = suiPublicKey.toSuiAddress() === address;
}
// is EVM address
else if (address.length === 42) {
isMessageSigned = await verifyMessage({
message,
signature,
address,
});
}

if (!isMessageSigned) {
return null;
}

// increment nonce

await kvClient.incrementAccountNonce(address);

return {
Expand All @@ -110,7 +119,7 @@ export const NEXT_AUTH_OPTIONS: NextAuthOptions = {
},
callbacks: {
async session({ session, token }) {
const address = getAddress(token.sub ?? "");
const address = token.sub as `0x${string}`;

session.address = address;
session.accountStatus = await kvClient
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { useCallback, useEffect, useMemo, useState } from "react";

import { reduce } from "rambda";
import type { TransactionReceipt } from "viem";
import { useAccount, useChainId, useWaitForTransactionReceipt } from "wagmi";
import { useWaitForTransactionReceipt } from "wagmi";

import {
useReadInterchainTokenFactoryCanonicalInterchainTokenId,
Expand All @@ -15,6 +15,7 @@ import {
decodeDeploymentMessageId,
type DeploymentMessageId,
} from "~/lib/drizzle/schema";
import { useAccount, useChainId } from "~/lib/hooks";
import { trpc } from "~/lib/trpc";
import { isValidEVMAddress } from "~/lib/utils/validation";
import { RecordInterchainTokenDeploymentInput } from "~/server/routers/interchainToken/recordInterchainTokenDeployment";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@ import type { EVMChainConfig } from "@axelarjs/api/axelarscan";
import { useEffect, useState } from "react";

import { formatEther } from "viem";
import { useChainId } from "wagmi";

import {
NEXT_PUBLIC_INTERCHAIN_DEPLOYMENT_EXECUTE_DATA,
NEXT_PUBLIC_INTERCHAIN_DEPLOYMENT_GAS_LIMIT,
} from "~/config/env";
import { useChainId } from "~/lib/hooks";
import { useEstimateGasFeeMultipleChainsQuery } from "~/services/axelarjsSDK/hooks";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useCanonicalTokenDeploymentStateContainer } from "../../CanonicalTokenDeployment.state";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import React, {
} from "react";

import { parseUnits } from "viem";
import { useAccount, useBalance, useChainId } from "wagmi";

import { useCanonicalTokenDeploymentStateContainer } from "~/features/CanonicalTokenDeployment/CanonicalTokenDeployment.state";
import { useDeployAndRegisterRemoteCanonicalTokenMutation } from "~/features/CanonicalTokenDeployment/hooks";
import { useTransactionsContainer } from "~/features/Transactions";
import { useBalance, useChainId } from "~/lib/hooks";
import { handleTransactionResult } from "~/lib/transactions/handlers";
import { getNativeToken } from "~/lib/utils/getNativeToken";
import ChainPicker from "~/ui/compounds/ChainPicker";
Expand Down Expand Up @@ -143,9 +143,7 @@ export const Step3: FC = () => {

const formSubmitRef = useRef<ComponentRef<"button">>(null);

const { address } = useAccount();

const { data: balance } = useBalance({ address });
const balance = useBalance();

const nativeTokenSymbol = getNativeToken(state.sourceChainId);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@ import { maskAddress, Maybe } from "@axelarjs/utils";
import { useCallback, useEffect, useState, type FC } from "react";
import { useRouter } from "next/router";

import { useAccount } from "wagmi";

import { useChainFromRoute } from "~/lib/hooks";
import { useAccount, useChainFromRoute } from "~/lib/hooks";
import { useEVMChainConfigsQuery } from "~/services/axelarscan/hooks";
import { useInterchainTokensQuery } from "~/services/gmp/hooks";
import GMPTxStatusMonitor from "~/ui/compounds/GMPTxStatusMonitor";
Expand Down Expand Up @@ -47,7 +45,7 @@ const Review: FC = () => {
chain.id,
state.txState.txHash,
state.selectedChains.map(
(axelarChainId) => computed.indexedById[axelarChainId].chain_id
(axelarChainId) => computed.indexedById[axelarChainId]?.chain_id
)
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ import { useForm } from "react-hook-form";

import { zodResolver } from "@hookform/resolvers/zod";
import { uniq, without } from "rambda";
import { useAccount } from "wagmi";
import { z } from "zod";

import { useAccount } from "~/lib/hooks";
import { logger } from "~/lib/logger";
import {
hex64Literal,
Expand Down
Loading
Loading