Skip to content

Commit

Permalink
♻️ upgrade taquito
Browse files Browse the repository at this point in the history
  • Loading branch information
Quentin Burg committed Sep 11, 2023
1 parent 5b48165 commit bba18f5
Show file tree
Hide file tree
Showing 6 changed files with 350 additions and 360 deletions.
627 changes: 308 additions & 319 deletions batcher-ui/package-lock.json

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions batcher-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
"not ie <= 10"
],
"dependencies": {
"@airgap/beacon-sdk": "^4.0.6",
"@airgap/beacon-sdk": "^4.0.10",
"@fortawesome/fontawesome-svg-core": "^6.4.2",
"@fortawesome/free-solid-svg-icons": "^6.4.2",
"@fortawesome/react-fontawesome": "^0.2.0",
Expand All @@ -40,10 +40,10 @@
"@radix-ui/react-select": "^1.2.2",
"@radix-ui/react-toast": "^1.1.4",
"@radix-ui/react-tooltip": "^1.0.6",
"@taquito/beacon-wallet": "^16.0.0",
"@taquito/taquito": "^16.0.0",
"@taquito/tzip12": "^16.0.0",
"@taquito/tzip16": "^16.0.0",
"@taquito/beacon-wallet": "^17.3.0",
"@taquito/taquito": "^17.3.0",
"@taquito/tzip12": "^17.3.0",
"@taquito/tzip16": "^17.3.0",
"@types/react-redux": "^7.1.25",
"date-fns": "^2.29.3",
"fp-ts": "^2.16.0",
Expand Down
2 changes: 1 addition & 1 deletion batcher-ui/pages/holdings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const Holdings = () => {
dispatch(newInfo('Attempting to redeem holdings...'));
// message.loading('Attempting to redeem holdings...', 0);
const confirm = await redeemTransaction.confirmation();
if (!confirm.completed) {
if (!confirm || !confirm.completed) {
dispatch(newError('Failed to redeem holdings.'));
} else {
dispatch(newInfo('Successfully redeemed holdings.'));
Expand Down
19 changes: 11 additions & 8 deletions batcher-ui/src/components/Exchange.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,17 @@ const Exchange = () => {
const [amountInput, setAmount] = useState<string>('0');
const [animate, setAnimate] = useState(false);

if (!tezos) {
dispatch(
newError(
"There is an error with Tezos Tool Kit, can't swap ! Please contact Marigold if problem persists."
)
if (!tezos)
return (
<div>
<p className="text-xxl">
{
"There is an error with Tezos Tool Kit, can't swap ! Please contact \
Marigold if problem persists."
}
</p>
</div>
);
return null;
}

const toTolerance = (isReverse: boolean, priceStategy: PriceStrategy) => {
switch (priceStategy) {
Expand Down Expand Up @@ -222,7 +225,7 @@ const Exchange = () => {
dispatch(newInfo('Attempt to deposit the order...'));
const confirm = await order_batcher_op?.confirmation();

if (!confirm.completed) {
if (!confirm || !confirm.completed) {
console.error(confirm);
dispatch(
newError(
Expand Down
48 changes: 24 additions & 24 deletions batcher-ui/src/contexts/wallet.tsx
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
import { TezosToolkit } from '@taquito/taquito';
import React, { createContext, useEffect, useReducer } from 'react';
import { BeaconWallet } from '@taquito/beacon-wallet';
import { AccountInfo } from '@airgap/beacon-sdk';
import { AccountInfo, NetworkType } from '@airgap/beacon-sdk';
import { useTezosToolkit } from './tezos-toolkit';
import { getByKey, setByKey } from 'src/utils/local-storage';
import { NetworkType } from '@airgap/beacon-types';

type WalletState = {
wallet: BeaconWallet | undefined;
Expand Down Expand Up @@ -41,6 +39,8 @@ const connectWallet = async (tezos: TezosToolkit | undefined) => {
: NetworkType.MAINNET,
});

//TODO: Find a way to fix error "Argument of type 'BeaconWallet' is not assignable to parameter of type 'WalletProvider'.
// @ts-ignore
tezos.setWalletProvider(wallet);

await wallet.requestPermissions({
Expand All @@ -57,8 +57,6 @@ const connectWallet = async (tezos: TezosToolkit | undefined) => {
return await wallet.client.getActiveAccount().then(async userAccount => {
const userAddress = await wallet.getPKH();

setByKey('userAddress', userAddress);

return { wallet, userAddress, userAccount };
});
};
Expand All @@ -73,8 +71,6 @@ const disconnectWallet = async (
wallet.clearActiveAccount();
wallet.disconnect();

setByKey('userAddress');

return Promise.resolve();
};

Expand All @@ -94,7 +90,7 @@ const reducer = (
}
| {
type: 'HYDRATE_WALLET';
userAddress: string;
userAddress: string | undefined;
userAccount: AccountInfo | undefined;
wallet: BeaconWallet;
}
Expand All @@ -119,23 +115,27 @@ export const WalletProvider = ({ children }: { children: React.ReactNode }) => {
const [state, dispatch] = useReducer(reducer, initialState);

useEffect(() => {
const userAddress = getByKey('userAddress');

if (userAddress) {
const wallet = new BeaconWallet({
name: 'batcher',
// @ts-ignore
preferredNetwork:
process.env.NEXT_PUBLIC_NETWORK_TARGET === 'GHOSTNET'
? NetworkType.GHOSTNET
: NetworkType.MAINNET,
});
wallet.client.getActiveAccount().then(userAccount => {
dispatch({ type: 'HYDRATE_WALLET', userAddress, userAccount, wallet });
});
const wallet = new BeaconWallet({
name: 'batcher',
// @ts-ignore
preferredNetwork:
process.env.NEXT_PUBLIC_NETWORK_TARGET === 'GHOSTNET'
? NetworkType.GHOSTNET
: NetworkType.MAINNET,
});

tezos?.setWalletProvider(wallet);
}
//TODO: Find a way to fix error "Argument of type 'BeaconWallet' is not assignable to parameter of type 'WalletProvider'.
// @ts-ignore
tezos?.setWalletProvider(wallet);

wallet.client.getActiveAccount().then(userAccount => {
dispatch({
type: 'HYDRATE_WALLET',
userAddress: userAccount?.address,
userAccount,
wallet,
});
});
}, [tezos]);

return (
Expand Down
4 changes: 1 addition & 3 deletions batcher-ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"forceConsistentCasingInFileNames": true,
"noImplicitReturns": true,
"noUnusedLocals": true,
"allowJs": true,
"allowJs": false,
"skipLibCheck": true,
"experimentalDecorators": true,
"strict": true,
Expand All @@ -27,12 +27,10 @@
"module": "esnext",
},
"include": [
"src/utils/**/*",
"src/**/*",
"tests/**/*",
"test/**/*",
"__test__/**/*",
"src/config/**/*",
".eslintrc.json",
".prettierrc.json",
"jest.config.js",
Expand Down

0 comments on commit bba18f5

Please sign in to comment.