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

Feat/sui integration euro #470

Merged
merged 4 commits into from
Nov 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
enabled: Boolean(tokenId && input?.salt && deployerAddress),
},
});
const { originalChainName, destinationChainNames } = useMemo(() => {
const { destinationChainNames } = useMemo(() => {
const index = updatedComputed.indexedById;
const originalChainName =
index[input?.sourceChainId ?? chainId]?.chain_name ?? "Unknown";
Expand Down Expand Up @@ -348,6 +348,14 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(
decimals: input.decimals,
});

console.log("deployInterchainToken Params", {
...commonArgs,
initialSupply: input.initialSupply || 0n,
name: input.tokenName,
symbol: input.tokenSymbol,
decimals: input.decimals,
});

if (!input.destinationChainIds.length) {
// early return case, no remote chains
return [deployTxData];
Expand All @@ -356,31 +364,39 @@ export function useDeployAndRegisterRemoteInterchainTokenMutation(

const registerTxData = destinationChainNames.map((destinationChain, i) => {
console.log("destinationChain", destinationChain);
// if (destinationChain === "sui") {
// destinationChain = "sui-test2";
// }
if (destinationChain === "sui") {
destinationChain = "sui-test2";
}
const registerData =
INTERCHAIN_TOKEN_FACTORY_ENCODERS.deployRemoteInterchainToken.data({
...commonArgs,
originalChainName,
originalChainName: "",
destinationChain,
gasValue: input.remoteDeploymentGasFees?.gasFees?.[i].fee ?? 0n,
});
console.log("registerData for", destinationChain, registerData);
console.log("Register Params", {
...commonArgs,
originalChainName: "",
destinationChain,
gasValue: input.remoteDeploymentGasFees?.gasFees?.[i].fee ?? 0n,
});
return registerData;
});
console.log("deployTxData", deployTxData);
console.log("registerTxData", registerTxData);

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

const totalGasFee = input?.remoteDeploymentGasFees?.totalGasFee ?? 0n;
const isMutationReady =
multicallArgs.length > 0 &&
// enable if there are no remote chains or if there are remote chains and the total gas fee is greater than 0
(!destinationChainNames.length || totalGasFee > 0n);
console.log("multicallArgs", [multicallArgs]);
console.log("isMutationReady", isMutationReady);
console.log("multicallArgs", multicallArgs);
console.log("isMutationReady", isMutationReady, totalGasFee);
console.log("chainId", chainId);
const { data: prepareMulticall } = useSimulateInterchainTokenFactoryMulticall(
{
chainId,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -181,9 +181,13 @@ export const Step2: FC = () => {

const balance = useBalance();

const nativeTokenSymbol = getNativeToken(state.sourceChainId);
const nativeTokenSymbol = state.sourceChainId
? getNativeToken(state.sourceChainId)
: undefined;

const hasInsufficientGasBalance = useMemo(() => {
console.log("state.remoteDeploymentGasFees", state.remoteDeploymentGasFees);
console.log("balance", balance);
if (!balance || !state.remoteDeploymentGasFees) {
return false;
}
Expand Down Expand Up @@ -242,6 +246,10 @@ export const Step2: FC = () => {
nativeTokenSymbol,
]);

if (!sourceChain) {
return;
}

const isCTADisabled =
state.isEstimatingGasFees ||
state.hasGasFeesEstimationError ||
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,7 @@ export const interchainTokenFactoryAbi = [
] as const;

export const interchainTokenFactoryAddress =
"0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66" as const;
"0x6Ae8C8498d5FDA930e6ABeB0E15E5A00471702a7" as const;

export const interchainTokenFactoryConfig = {
address: interchainTokenFactoryAddress,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1283,7 +1283,7 @@ export const interchainTokenServiceAbi = [
] as const;

export const interchainTokenServiceAddress =
"0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C" as const;
"0x144c3d7A5f5198EF3B46A8258b35E903cf197A66" as const;

export const interchainTokenServiceConfig = {
address: interchainTokenServiceAddress,
Expand Down
4 changes: 2 additions & 2 deletions apps/maestro/src/lib/contracts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ export const contracts = [
{
name: INTERCHAIN_TOKEN_FACTORY_ABI.contractName,
abi: INTERCHAIN_TOKEN_FACTORY_ABI.abi,
address: "0x83a93500d23Fbc3e82B410aD07A6a9F7A0670D66" as `0x${string}`, // read from .env.local (NEXT_PUBLIC_INTERCHAIN_TOKEN_FACTORY_ADDRESS)
address: "0x6Ae8C8498d5FDA930e6ABeB0E15E5A00471702a7" as `0x${string}`, // read from .env.local (NEXT_PUBLIC_INTERCHAIN_TOKEN_FACTORY_ADDRESS)
},
{
name: INTERCHAIN_TOKEN_SERVICE_ABI.contractName,
abi: INTERCHAIN_TOKEN_SERVICE_ABI.abi,
address: "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C" as `0x${string}`, // read from .env.local (NEXT_PUBLIC_INTERCHAIN_TOKEN_SERVICE_ADDRESS)
address: "0x144c3d7A5f5198EF3B46A8258b35E903cf197A66" as `0x${string}`, // read from .env.local (NEXT_PUBLIC_INTERCHAIN_TOKEN_SERVICE_ADDRESS)
},
{
name: TOKEN_MANAGER_ABI.contractName,
Expand Down
2 changes: 2 additions & 0 deletions apps/maestro/src/lib/hooks/useBalance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ export function useBalance(): BalanceResult | undefined {
);

const balance = useMemo(() => {
console.log("suiBalance", suiBalance);
console.log("wagmiBalance", wagmiBalance);
if (wagmiBalance) {
return wagmiBalance;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const deployPayload = {
method: "searchGMP",
size: 25000,
destinationContractAddress: "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C",
destinationContractAddress: "0x144c3d7A5f5198EF3B46A8258b35E903cf197A66",
contractMethod:
"InterchainTokenDeploymentStarted,TokenManagerDeploymentStarted",
_source: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const deployPayload = {
method: "searchGMP",
size: 25000,
destinationContractAddress: "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C",
destinationContractAddress: "0x144c3d7A5f5198EF3B46A8258b35E903cf197A66",
contractMethod:
"InterchainTokenDeploymentStarted,TokenManagerDeploymentStarted",
_source: {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const payload = {
method: "searchGMP",
size: 25000,
destinationContractAddress: "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C",
destinationContractAddress: "0x144c3d7A5f5198EF3B46A8258b35E903cf197A66",
contractMethod: "InterchainTransfer",
_source: {
includes: [
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const payload = {
method: "searchGMP",
size: 25000,
destinationContractAddress: "0xB5FB4BE02232B1bBA4dC8f81dc24C26980dE9e3C",
destinationContractAddress: "0x144c3d7A5f5198EF3B46A8258b35E903cf197A66",
contractMethod: "InterchainTransfer",
_source: {
includes: [
Expand Down
3 changes: 3 additions & 0 deletions apps/maestro/src/services/axelarjsSDK/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export const client = new AxelarQueryAPI({

async function estimateGasFee(params: EstimateGasFeeInput): Promise<bigint> {
let response;
console.log("params estimateGasFee", params);
// TODO: remove when sdk support for sui is ready
if (params.destinationChainId === "sui") {
response = "20000000000000000";
Expand All @@ -38,6 +39,8 @@ async function estimateGasFee(params: EstimateGasFeeInput): Promise<bigint> {
response.l1ExecutionFeeWithMultiplier +
response.executionFeeWithMultiplier;

console.log("rawFee", rawFee);

return BigInt(rawFee);
}

Expand Down
Loading