Skip to content

Commit

Permalink
merge branch 'main' into chore/fix-notification
Browse files Browse the repository at this point in the history
  • Loading branch information
npty committed Feb 11, 2025
1 parent 00c53cb commit 9918aac
Show file tree
Hide file tree
Showing 26 changed files with 221 additions and 105 deletions.
6 changes: 0 additions & 6 deletions .changeset/clever-bulldogs-teach.md

This file was deleted.

5 changes: 5 additions & 0 deletions .changeset/two-goats-lick.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@axelarjs/maestro": patch
---

change default rpc url for fantom mainnet
9 changes: 9 additions & 0 deletions apps/maestro/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# @axelarjs/maestro

## 0.3.30

### Patch Changes

- [#484](https://github.com/axelarnetwork/axelarjs/pull/484) [`1d05d568cfed5ab89ca19eadd2961bdfffa91a80`](https://github.com/axelarnetwork/axelarjs/commit/1d05d568cfed5ab89ca19eadd2961bdfffa91a80) Thanks [@SGiaccobasso](https://github.com/SGiaccobasso)! - add flow support to portal

- Updated dependencies [[`1d05d568cfed5ab89ca19eadd2961bdfffa91a80`](https://github.com/axelarnetwork/axelarjs/commit/1d05d568cfed5ab89ca19eadd2961bdfffa91a80)]:
- @axelarjs/evm@0.2.8

## 0.3.29

### Patch Changes
Expand Down
2 changes: 1 addition & 1 deletion apps/maestro/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@axelarjs/maestro",
"version": "0.3.29",
"version": "0.3.30",
"private": true,
"publishConfig": {
"access": "restricted"
Expand Down
4 changes: 4 additions & 0 deletions apps/maestro/src/config/env.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,10 @@ export const NEXT_PUBLIC_EXPLORER_URL = Maybe.of(
process.env.NEXT_PUBLIC_EXPLORER_URL
).mapOr("", String);

export const NEXT_PUBLIC_WHITELISTED_DEST_CHAINS_FOR_VM = Maybe.of(
process.env.NEXT_PUBLIC_WHITELISTED_DEST_CHAINS_FOR_VM
).mapOr("", String);

export const NEXT_PUBLIC_FILE_BUG_REPORT_URL = Maybe.of(
process.env.NEXT_PUBLIC_FILE_BUG_REPORT_URL
).mapOr("", String);
Expand Down
5 changes: 4 additions & 1 deletion apps/maestro/src/config/evm-chains.ts
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,10 @@ export const ALL_CHAINS: ExtendedWagmiChainConfig[] = [
},
{
...fantom,
rpcUrls: createRpcUrlConfig(fantom, ["https://fantom.drpc.org"]),
rpcUrls: {
default: { http: ["https://fantom.drpc.org"] },
public: { http: ["https://fantom.drpc.org"] },
},
axelarChainId: "fantom",
axelarChainName: "Fantom",
environment: ENVIRONMENTS.mainnet,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,17 +92,15 @@ function useCanonicalTokenDeploymentState(
},
actions: {
reset: () => {
console.log("reset");
setState((draft) => {
Object.assign(draft, initialState);
});
},
setTokenDetails: (detatils: Partial<TokenDetails>) => {
console.log("setTokenDetails", detatils);
setTokenDetails: (details: Partial<TokenDetails>) => {
setState((draft) => {
draft.tokenDetails = {
...draft.tokenDetails,
...detatils,
...details,
};
});
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,8 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
},
});

const { originalChainName, destinationChainNames } = useMemo(() => {
const { destinationChainNames } = useMemo(() => {
const index = combinedComputed.indexedById;
const originalChainName =
index[input?.sourceChainId ?? chainId]?.chain_name ?? "Unknown";

const destinationChainNames =
input?.destinationChainIds.map(
Expand All @@ -76,14 +74,11 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
) ?? [];

return {
originalChainName,
destinationChainNames,
};
}, [
chainId,
combinedComputed.indexedById,
input?.destinationChainIds,
input?.sourceChainId,
]);

const multicallArgs = useMemo(() => {
Expand All @@ -105,8 +100,8 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
const gasValue = input.remoteDeploymentGasFees[i] ?? 0n;

const args = {
originalChain: originalChainName,
originalTokenAddress: input.tokenAddress as `0x${string}`,
originalChain: "",
originalTokenAddress: input.tokenAddress as `0x{string}`,
destinationChain,
gasValue,
};
Expand All @@ -117,7 +112,7 @@ export function useDeployAndRegisterRemoteCanonicalTokenMutation(
});

return [deployTxData, ...registerTxData];
}, [input, tokenId, destinationChainNames, originalChainName]);
}, [input, tokenId, destinationChainNames]);

const totalGasFee = Maybe.of(input?.remoteDeploymentGasFees).mapOr(
0n,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ export function useStep3ChainSelectionState() {
isDeploying,
totalGasFee,
sourceChainId,
allChains,
chains: allChains,
isEstimatingGasFees: isRemoteDeploymentGasFeeLoading,
hasGasFeesEstimationError: isRemoteDeploymentGasFeeError,
remoteDeploymentGasFees,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import { getNativeToken } from "~/lib/utils/getNativeToken";
import ChainPicker from "~/ui/compounds/ChainPicker";
import { NextButton, TokenNameAlert } from "~/ui/compounds/MultiStepForm";
import { useStep3ChainSelectionState } from "./DeployAndRegister.state";
import { filterEligibleChains } from "~/lib/utils/chains";

export const Step3: FC = () => {
const { state: rootState, actions: rootActions } =
Expand All @@ -31,9 +32,7 @@ export const Step3: FC = () => {
const chainId = useChainId();

// Support both EVM and VM chains
const sourceChain = state.allChains?.find(
(chain) => chain.chain_id === chainId
);
const sourceChain = state.chains?.find((chain) => chain.chain_id === chainId);

const [validDestinationChainIds, erroredDestinationChainIds] = useMemo(
() =>
Expand Down Expand Up @@ -138,9 +137,9 @@ export const Step3: FC = () => {
addTransaction,
]
);
const eligibleChains = state.allChains.filter(
(chain) => chain.chain_id !== chainId
);

const eligibleChains = filterEligibleChains(state.chains, chainId);

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

const balance = useBalance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { NextButton } from "~/ui/compounds/MultiStepForm";
import { useDeployAndRegisterRemoteInterchainTokenMutation } from "../../hooks";
import { useInterchainTokenDeploymentStateContainer } from "../../InterchainTokenDeployment.state";
import { useStep2ChainSelectionState } from "./DeployAndRegister.state";
import { filterEligibleChains } from "~/lib/utils/chains";

export const Step2: FC = () => {
const { state: rootState, actions: rootActions } =
Expand Down Expand Up @@ -171,10 +172,8 @@ export const Step2: FC = () => {
addTransaction,
]
);

const eligibleChains = state.chains.filter(
(chain) => chain.chain_id !== chainId
);

const eligibleChains = filterEligibleChains(state.chains, chainId);

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,8 @@ export default function useRegisterRemoteCanonicalTokens(

return INTERCHAIN_TOKEN_FACTORY_ENCODERS.deployRemoteCanonicalInterchainToken.data(
{
originalTokenAddress: tokenDetails.tokenAddress as `0x${string}`,
originalChain: "",
originalTokenAddress: tokenDetails.tokenAddress as `0x{string}`,
destinationChain: axelarChainId,
gasValue,
}
Expand Down
31 changes: 31 additions & 0 deletions apps/maestro/src/lib/utils/chains.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { ITSChainConfig } from "@axelarjs/api";
import { NEXT_PUBLIC_WHITELISTED_DEST_CHAINS_FOR_VM } from "~/config/env";

export const filterEligibleChains = (
chains: ITSChainConfig[],
currentChainId: number,
): ITSChainConfig[] => {
// Early return if no chains to filter
if (!chains.length) return [];

const currentChain = chains.find((chain) => chain.chain_id === currentChainId);
const isCurrentChainVM = currentChain?.chain_type === 'vm';

const whitelistedChains = NEXT_PUBLIC_WHITELISTED_DEST_CHAINS_FOR_VM.split(',').map(chain => chain.trim());

// Normalize whitelist check
const isAllChainsWhitelisted = whitelistedChains[0] === 'all';

return chains.filter((chain) => {
// Always filter out current chain
if (chain.chain_id === currentChainId) return false;

// For EVM chains, check whitelist
if (isCurrentChainVM && chain.chain_type === 'evm') {
return isAllChainsWhitelisted || whitelistedChains.includes(chain.id);
}

// Non-EVM chains are always included
return true;
});
};
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export const SEARCHGMP_SOURCE = {
"confirm",
"executed",
"callback",
"interchain_token_deployment_started.destinationChain",
"interchain_transfer.destinationChain",
],
excludes: [
"call.transaction",
Expand Down Expand Up @@ -53,33 +55,63 @@ export const getTransactionStatusOnDestinationChains = publicProcedure
});

if (data.length) {
<<<<<<< HEAD
const result = data.reduce(
(acc, gmpData) => {
const { call, status } = gmpData;
const destinationChain =
gmpData.callback?.returnValues.destinationChain.toLowerCase() ||
call.returnValues.destinationChain.toLowerCase();
=======
const pendingResult = data.reduce(
async (acc, gmpData) => {
const {
call,
status: firstHopStatus,
interchain_token_deployment_started: tokenDeployment,
interchain_transfer: tokenTransfer,
} = gmpData;

const chainType = gmpData.call.chain_type;
let secondHopStatus = "pending"

if (gmpData.callback) {
const secondHopMessageId = gmpData.callback.returnValues.messageId;
const secondHopData = await ctx.services.gmp.searchGMP({
txHash: secondHopMessageId,
_source: SEARCHGMP_SOURCE,
});

secondHopStatus = secondHopData[0].status;
}

const destinationChain =
tokenTransfer?.destinationChain?.toLowerCase() ||
tokenDeployment?.destinationChain?.toLowerCase() ||
call.returnValues.destinationChain.toLowerCase();

>>>>>>> 5ee1a720 (feat: fix tx progress for its hub tx (#489))
return {
...acc,
[destinationChain]: {
status,
status: chainType === "evm" ? firstHopStatus : secondHopStatus,
txHash: call.transactionHash,
logIndex: call.logIndex ?? call._logIndex ?? 0,
txId: call.id,
txId: gmpData.message_id,
},
};
},
{} as {
{} as Promise<{
[chainId: string]: {
status: GMPTxStatus;
txHash: string;
txId: string;
logIndex: number;
};
}
}>
);

return result;
return await pendingResult;
}

// If we don't find the transaction, we throw a 404 error
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ export const getTransactionStatusesOnDestinationChains = publicProcedure
.input(INPUT_SCHEMA)
.query(async ({ ctx, input }) => {
try {
// Fetch all first hop transactions
const results = await Promise.all(
input.txHashes.map((txHash) =>
ctx.services.gmp.searchGMP({
Expand All @@ -27,15 +28,52 @@ export const getTransactionStatusesOnDestinationChains = publicProcedure
)
);

return results.flat().reduce(
(acc, { call, status }) => ({
// Process all transactions and their second hops
const processedResults = await Promise.all(
results.flat().map(async (gmpData) => {
const {
call,
status: firstHopStatus,
interchain_token_deployment_started: tokenDeployment,
} = gmpData;

const chainType = gmpData.call.chain_type;
let secondHopStatus = "pending" as GMPTxStatus;

// Check for second hop if callback exists
if (gmpData.callback) {
const secondHopMessageId = gmpData.callback.returnValues.messageId;
const secondHopData = await ctx.services.gmp.searchGMP({
txHash: secondHopMessageId,
_source: SEARCHGMP_SOURCE,
});

if (secondHopData.length > 0) {
secondHopStatus = secondHopData[0].status;
}
}

const destinationChain =
tokenDeployment?.destinationChain?.toLowerCase() ||
call.returnValues.destinationChain.toLowerCase();

return {
destinationChain,
data: {
status: chainType === "evm" ? firstHopStatus : secondHopStatus,
txHash: call.transactionHash,
logIndex: call.logIndex ?? call._logIndex ?? 0,
txId: gmpData.message_id,
},
};
})
);

// Combine all results into a single object
return processedResults.reduce(
(acc, { destinationChain, data }) => ({
...acc,
[call.returnValues.destinationChain.toLowerCase()]: {
status,
txHash: call.transactionHash,
logIndex: call.logIndex ?? call._logIndex ?? 0,
txId: call.id,
},
[destinationChain]: data,
}),
{} as {
[chainId: string]: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export const recoverDeploymentMessageIdByTokenId = protectedProcedure
},
fromTime: fromTime,
toTime: toTime,
size: 1000,
size: 200,
});

const validEntries = deployments.filter(
Expand Down
Loading

0 comments on commit 9918aac

Please sign in to comment.