Skip to content

Commit

Permalink
fix conflicts
Browse files Browse the repository at this point in the history
  • Loading branch information
ERussel committed Dec 14, 2023
2 parents 534341a + a3c052a commit aa75762
Show file tree
Hide file tree
Showing 51 changed files with 335 additions and 321 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/build_and_publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,9 @@ jobs:
docker-compose down
rm .env
echo "NEXT_PUBLIC_BOT_API_URL=${{ secrets.NEXT_PUBLIC_BOT_API_URL }}" >> .env
docker image prune -f
docker-compose pull
docker-compose up -d
docker image prune -f
- name: Notify Telegram channel
uses: appleboy/telegram-action@master
Expand Down
22 changes: 22 additions & 0 deletions public/images/Address.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
28 changes: 4 additions & 24 deletions public/images/Buy.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 3 additions & 23 deletions public/images/Receive.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
26 changes: 3 additions & 23 deletions public/images/Send.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/images/User.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions public/images/chevron-forward.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed public/images/create-gif.gif
Binary file not shown.
Binary file removed public/images/firework.png
Binary file not shown.
Binary file added public/videos/create-wallet.webm
Binary file not shown.
Binary file added public/videos/firework1.webm
Binary file not shown.
Binary file removed src/common/assets/fonts/Inter/Inter-400.woff2
Binary file not shown.
Binary file removed src/common/assets/fonts/Inter/Inter-500.woff2
Binary file not shown.
Binary file removed src/common/assets/fonts/Inter/Inter-600.woff2
Binary file not shown.
Binary file removed src/common/assets/fonts/Inter/Inter-800.woff2
Binary file not shown.
8 changes: 0 additions & 8 deletions src/common/chainRegistry/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,6 @@ export type Asset = {
precision: number;
};

export type AssetWithBalance = Asset & {
name: string;
balance: string;
assetId: number;
symbol: string;
precision: number;
};

export type Chain = {
chainId: ChainId;
name: string;
Expand Down
2 changes: 1 addition & 1 deletion src/common/extrinsicService/ExtrinsicProvider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { SubmittableResultResult } from '@polkadot/api-base/types/submittable';
import { useExtrinsicService } from '@common/extrinsicService/ExtrinsicService';
import { ApiTypes } from '@polkadot/api-base/types/base';
import { KeyringPair } from '@polkadot/keyring/types';
import { PasswordPage } from '@app/password/Password';
import { PasswordPage } from '@/screens/password/Password';

type ExtrinsicProviderContextProps = {
estimateFee: (
Expand Down
13 changes: 10 additions & 3 deletions src/common/providers/contextProvider.tsx
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
import React, { createContext, useContext, useState } from 'react';
import { HexString } from '../types';
import { AssetAccount, HexString } from '../types';

export interface IContext {
publicKey?: HexString;
assets: AssetAccount[] | [];
setPublicKey: React.Dispatch<React.SetStateAction<HexString | undefined>>;
setAssets: React.Dispatch<React.SetStateAction<AssetAccount[]>>;
}

export const GlobalContext = createContext<IContext>({ setPublicKey: () => {} });
export const GlobalContext = createContext<IContext>({
assets: [],
setPublicKey: () => {},
setAssets: () => {},
});

export const GlobalStateProvider = ({ children }: { children: React.ReactNode }) => {
const [publicKey, setPublicKey] = useState<HexString>();
const [assets, setAssets] = useState<AssetAccount[]>([]);

const value = { publicKey, setPublicKey };
const value = { publicKey, assets, setPublicKey, setAssets };

return <GlobalContext.Provider value={value}>{children}</GlobalContext.Provider>;
};
Expand Down
9 changes: 9 additions & 0 deletions src/common/types/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,15 @@ export type ChainAssetAccount = {
chainId: ChainId;
assetId: AssetId;
publicKey: PublicKey;
symbol: string;
name: string;
precision: number;
};

export type AssetAccount = ChainAssetAccount & {
address: Address;
totalBalance?: string;
transferableBalance?: string;
};

export type StateResolution<T> = { resolve: (value: T) => void; reject: () => void };
Expand Down
48 changes: 48 additions & 0 deletions src/common/utils/balance.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import BigNumber from 'bignumber.js';
import { AssetAccount } from '../types';
import { Chain } from '../chainRegistry/types';
import { IAssetBalance } from '../balances/types';

const ZERO_BALANCE = '0';

Expand Down Expand Up @@ -122,3 +125,48 @@ export const formatFiatBalance = (balance = '0', precision = 0): FormattedBalanc
decimalPlaces,
};
};

export const updateAssetsBalance = (prevAssets: AssetAccount[], chain: Chain, balance: IAssetBalance) => {
return prevAssets.map((asset) =>
asset?.chainId === chain.chainId
? {
...asset,
totalBalance: balance.total().toString(),
transferableBalance: balance.transferable().toString(),
}
: asset,
);
};

// async function handleSign() {
// extrinsicService
// .submitExtrinsic(polkadot.chainId, (builder) => builder.addCall(builder.api.tx.system.remark('Hello')))
// .then(
// (hash) => {
// alert('Success: ' + hash);
// },
// (failure) => {
// alert('Failed: ' + failure);
// },
// );
// }

// async function handleFee() {
// extrinsicService
// .estimateFee(polkadot.chainId, (builder) =>
// builder.addCall(
// builder.api.tx.balances.transferKeepAlive(
// '0xcc23ed33549e874ae7c7653fc5d95b3242dc7df5742664b4809e337a13126433',
// '1234',
// ),
// ),
// )
// .then(
// (fee) => {
// alert('Fee: ' + fee);
// },
// (failure) => {
// alert('Failed to calculate fee: ' + failure);
// },
// );
// }
8 changes: 3 additions & 5 deletions src/common/wallet/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,11 +77,9 @@ export const resetWallet = () => {
window.Telegram.WebApp.CloudStorage.removeItem(MNEMONIC_STORE);
};

export const initializeWalletFromCloud = (password: string, encryptedMnemonic: string): boolean => {
export const initializeWalletFromCloud = (password: string, encryptedMnemonic: string): Wallet | null => {
const mnemonic = AES.decrypt(encryptedMnemonic, password).toString(CryptoJS.enc.Utf8);
if (!mnemonic) return false;
if (!mnemonic) return null;

createWallet(mnemonic);

return true;
return createWallet(mnemonic);
};
23 changes: 14 additions & 9 deletions src/components/AssetsList/Asset.tsx
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
import { cnTw } from '@/common/utils/twMerge';
import { formatBalance } from '@/common/utils/balance';
import Icon from '../Icon/Icon';
import { CaptionText } from '../Typography';

import { Shimmering, CaptionText, Icon } from '@/components';

type Props = {
value: string;
asset: any;
balance?: string;
name?: string;
className?: string;
showIcon?: boolean;
imgClassName?: string;
wrapperClassName?: string;
};

export const AssetBalance = ({ value, asset, className, imgClassName }: Props) => {
export const AssetBalance = ({ balance, asset, name, className, imgClassName }: Props) => {
const { precision, symbol } = asset;
const { formattedValue, suffix } = formatBalance(value, precision);
const { formattedValue, suffix } = formatBalance(balance, precision);

return (
<span className={cnTw('flex items-center gap-x-2', className)}>
<Icon name={symbol} size={40} alt="logo" className={imgClassName} />
<Icon name={symbol} size={40} alt={name} className={imgClassName} />
<CaptionText>{symbol}</CaptionText>
<CaptionText>
{formattedValue} {suffix}
</CaptionText>
{balance === undefined ? (
<Shimmering width={100} height={20} />
) : (
<CaptionText>
{formattedValue} {suffix}
</CaptionText>
)}
</span>
);
};
34 changes: 18 additions & 16 deletions src/components/AssetsList/AssetsList.tsx
Original file line number Diff line number Diff line change
@@ -1,21 +1,23 @@
import { AssetWithBalance } from '@/common/chainRegistry/types';
import { useGlobalContext } from '@/common/providers/contextProvider';
import { AssetBalance } from './Asset';

type Props = {
assets: AssetWithBalance[];
};
const AssetsList = () => {
const { assets } = useGlobalContext();
const sortedAssets = assets.sort((a, b) => a.symbol.localeCompare(b.symbol));

const AssetsList = ({ assets }: Props) => (
<div className="flex flex-col gap-6 mt-4">
{assets.map((asset) => (
<AssetBalance
asset={asset}
value={asset.balance}
className="grid grid-cols-[50px,1fr,auto] items-center"
key={asset.assetId}
/>
))}
</div>
);
return (
<div className="flex flex-col gap-6 mt-4">
{sortedAssets.map((asset) => (
<AssetBalance
asset={asset}
balance={asset.totalBalance}
className="grid grid-cols-[50px,1fr,auto] items-center"
name={asset.name}
key={asset.chainId}
/>
))}
</div>
);
};

export default AssetsList;
Loading

0 comments on commit aa75762

Please sign in to comment.