Skip to content
This repository has been archived by the owner on Feb 23, 2024. It is now read-only.

Commit

Permalink
Upgrade to beta-4 compatible sdk
Browse files Browse the repository at this point in the history
  • Loading branch information
sdankel committed Sep 21, 2023
1 parent 2a51c38 commit 9161f93
Show file tree
Hide file tree
Showing 12 changed files with 591 additions and 69 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -95,6 +95,6 @@
}
},
"dependencies": {
"fuels": "0.35.0"
"fuels": "^0.57.0"
}
}
6 changes: 3 additions & 3 deletions packages/app/package.json
Expand Up @@ -26,8 +26,8 @@
"@fuel-ts/wallet-manager": "0.35.0",
"@fuel-ui/css": "^0.12.0",
"@fuel-ui/react": "^0.12.0",
"@fuel-wallet/sdk": "0.7.1",
"@fuel-wallet/types": "0.7.1",
"@fuel-wallet/sdk": "^0.12.3",
"@fuel-wallet/types": "^0.12.3",
"@headlessui/react": "^1.7.10",
"@radix-ui/react-accordion": "^1.1.0",
"@radix-ui/react-alert-dialog": "^1.0.2",
Expand Down Expand Up @@ -56,7 +56,7 @@
"decimal.js": "^10.4.3",
"ethers": "^6.0.2",
"framer-motion": "^9.0.1",
"fuels": "0.35.0",
"fuels": "^0.57.0",
"graphql": "^16.6.0",
"graphql-request": "^5.1.0",
"jotai": "^2.0.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/systems/Core/hooks/useTokensMethods.ts
Expand Up @@ -25,7 +25,7 @@ export function useTokenMethods(tokenId: string) {
});
},
async getMintAmount() {
const { value: mintAmount } = await contract.functions.get_mint_amount().get();
const { value: mintAmount } = await contract.functions.get_mint_amount().call();
return mintAmount;
},
async mint() {
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/systems/Core/utils/coins.ts
@@ -1,10 +1,10 @@
import type { CoinQuantity } from 'fuels';
import { NativeAssetId } from 'fuels';
import { BaseAssetId } from 'fuels';

export const getCoin = (coinsQuantity: Array<CoinQuantity>, assetId?: string) => {
return coinsQuantity.find((cq) => cq.assetId === assetId);
};

export const getCoinETH = (coinsQuantity: Array<CoinQuantity>) => {
return coinsQuantity.find((cq) => cq.assetId === NativeAssetId);
return coinsQuantity.find((cq) => cq.assetId === BaseAssetId);
};
6 changes: 3 additions & 3 deletions packages/app/src/systems/Core/utils/feedback.tsx
@@ -1,5 +1,5 @@
/* eslint-disable @typescript-eslint/no-explicit-any */
import type { TransactionResult } from "fuels";
import { TransactionStatus, type TransactionResult } from "fuels";
import toast from "react-hot-toast";

import { BLOCK_EXPLORER_URL } from "~/config";
Expand Down Expand Up @@ -31,12 +31,12 @@ export function txFeedback(
onSuccess?: (data: TransactionResult<any>) => void | Promise<void>
) {
return async (data: Maybe<TransactionResult<any>>) => {
const txLink = <TxLink id={data?.transactionId} />;
const txLink = <TxLink id={data?.id} />; // TODO: is this correct?

/**
* Show a toast success message if status.type === 'success'
*/
if (data?.status.type === "success") {
if (data?.status === TransactionStatus.success) {
await onSuccess?.(data);
toast.success(
<>
Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/systems/Pool/hooks/usePoolInfo.ts
Expand Up @@ -8,9 +8,9 @@ export function usePoolInfo() {
const contract = useContract();
return useQuery('PoolPage-poolInfo', async () => {
if (!contract) return;
const { value: poolInfo } = await contract.functions.get_pool_info().get({
fundTransaction: false,
});
const { value: poolInfo } = await contract.functions
.get_pool_info() // TODO: do we need the parameter?
.call();
return poolInfo;
});
}
Expand All @@ -19,7 +19,7 @@ export function usePositionInfo(amount: BN) {
const contract = useContract();
return useQuery(['PoolPage-positionInfo', amount], async () => {
if (!contract || bn(amount).isZero()) return;
const { value: position } = await contract.functions.get_position(amount).get();
const { value: position } = await contract.functions.get_position(amount).call();
return position;
});
}
10 changes: 5 additions & 5 deletions packages/app/src/systems/Pool/machines/addLiquidityMachine.ts
@@ -1,6 +1,6 @@
import Decimal from 'decimal.js';
import type { BN, CoinQuantity, TransactionResult } from 'fuels';
import { NativeAssetId, bn } from 'fuels';
import { BaseAssetId, bn } from 'fuels';
import type { InterpreterFrom, StateFrom } from 'xstate';
import { assign, createMachine } from 'xstate';

Expand Down Expand Up @@ -352,13 +352,13 @@ export const addLiquidityMachine =
if (active === AddLiquidityActive.from && fromAmount && coinFrom) {
const { value } = await contract.functions
.get_add_liquidity(fromAmount, coinFrom.assetId)
.get();
.call();
return value;
}
if (toAmount && coinTo) {
const { value } = await contract.functions
.get_add_liquidity(toAmount, coinTo.assetId)
.get();
.call();
return value;
}
return null;
Expand All @@ -369,7 +369,7 @@ export const addLiquidityMachine =
if (fromAmount && coinFrom) {
const { value } = await contract.functions
.get_add_liquidity(fromAmount, coinFrom.assetId)
.get();
.call();
return value;
}
return null;
Expand Down Expand Up @@ -506,7 +506,7 @@ export const addLiquidityMachine =
notHasEthForNetworkFee: (ctx) => {
const networkFee = bn(ctx.transactionCost?.fee);
const ethBalance =
ctx.balances.find((balance) => balance.assetId === NativeAssetId)?.amount || bn(0);
ctx.balances.find((balance) => balance.assetId === BaseAssetId)?.amount || bn(0);
return ethBalance.lte(networkFee);
},
notHasFromAmount: (ctx) => {
Expand Down
2 changes: 1 addition & 1 deletion packages/app/src/systems/Pool/utils/queries.ts
Expand Up @@ -75,6 +75,6 @@ export async function addLiquidity(
export async function fetchPoolInfo(ctx: AddLiquidityMachineContext) {
const { contract } = ctx;
if (!contract) return null;
const { value } = await contract.functions.get_pool_info().get();
const { value } = await contract.functions.get_pool_info().call();
return value;
}
2 changes: 1 addition & 1 deletion packages/app/src/systems/Swap/machines/swapMachine.ts
Expand Up @@ -374,7 +374,7 @@ export const swapMachine =
if (!ctx.contract) {
throw new Error('Contract not found');
}
const { value: info } = await ctx.contract.functions.get_pool_info().get();
const { value: info } = await ctx.contract.functions.get_pool_info().call();
const ratio = getPoolRatio(info);
return {
info,
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/systems/Swap/utils/queries.ts
Expand Up @@ -54,7 +54,7 @@ const getSwapWithMaximumRequiredAmount = async (
.txParams({
gasPrice: ZERO,
})
.get();
.call();
return requiredAmount;
};

Expand All @@ -71,7 +71,7 @@ const getSwapWithMinimumMinAmount = async (
.txParams({
gasPrice: ZERO,
})
.get();
.call();
return minAmount;
};

Expand Down
8 changes: 4 additions & 4 deletions packages/app/src/systems/Welcome/machines/welcomeMachine.ts
Expand Up @@ -411,8 +411,8 @@ export const welcomeMachine = createMachine(
value: wallet.address.toHexString(),
};

const { value: hasMint1 } = await token1.functions.has_mint(addressId).get();
const { value: hasMint2 } = await token2.functions.has_mint(addressId).get();
const { value: hasMint1 } = await token1.functions.has_mint(addressId).call();
const { value: hasMint2 } = await token2.functions.has_mint(addressId).call();

return [hasMint1, hasMint2];
},
Expand All @@ -432,11 +432,11 @@ export const welcomeMachine = createMachine(
const addressId = {
value: wallet.address.toHexString(),
};
const { value: hasMint1 } = await token1.functions.has_mint(addressId).get();
const { value: hasMint1 } = await token1.functions.has_mint(addressId).call();
if (!hasMint1) {
calls.push(token1.functions.mint());
}
const { value: hasMint2 } = await token2.functions.has_mint(addressId).get();
const { value: hasMint2 } = await token2.functions.has_mint(addressId).call();
if (!hasMint2) {
calls.push(token2.functions.mint());
}
Expand Down

0 comments on commit 9161f93

Please sign in to comment.