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

Wallet2 #63

Open
wants to merge 6 commits into
base: build
Choose a base branch
from
Open
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
5 changes: 4 additions & 1 deletion apps/staking4u/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@
"react-native-url-polyfill": "*",
"text-encoding": "*",
"text-encoding-polyfill": "*",
"@solana/spl-token": "*"
"@solana/spl-token": "*",
"@solana/wallet-adapter-react": "*",
"react-native-fs": "*",
"bs58": "*"
}
}
29 changes: 29 additions & 0 deletions apps/staking4u/src/app/accounts.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { Commitment, Connection, PublicKey, AccountInfo } from '@solana/web3.js';
export interface Account {
/** Address of the account */
address: PublicKey;
/** Mint associated with the account */
mint: PublicKey;
/** Owner of the account */
owner: PublicKey;
/** Number of tokens the account holds */
amount: bigint;
/** Authority that can transfer tokens from the account */
delegate: PublicKey | null;
/** Number of tokens the delegate is authorized to transfer */
delegatedAmount: bigint;
/** True if the account is initialized */
isInitialized: boolean;
/** True if the account is frozen */
isFrozen: boolean;
/** True if the account is a native token account */
isNative: boolean;
/**
* If the account is a native token account, it must be rent-exempt. The rent-exempt reserve is the amount that must
* remain in the balance until the account is closed.
*/
rentExemptReserve: bigint | null;
/** Optional authority to close the account */
closeAuthority: PublicKey | null;
tlvData: Buffer;
}
2 changes: 1 addition & 1 deletion apps/staking4u/src/app/components/items/stake/Products.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { Actions } from 'react-native-router-flux';

const Product = ({ name}) => {
const { isLoading: infoLoading, data: infoData } = useQuery(["info", name], getCoin.info);
const rate = infoData?.market_data?.price_change_24h.toFixed(2);
const rate = 789; // infoData?.market_data?.price_change_24h.toFixed(2);
const price = infoData?.tickers[0].last
const image = infoData?.image.thumb
const onPressItem = () => {
Expand Down
25 changes: 25 additions & 0 deletions apps/staking4u/src/app/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { PublicKey } from '@solana/web3.js';

/** Address of the SPL Token program */
export const TOKEN_PROGRAM_ID = new PublicKey('TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA');

/** Address of the SPL Token 2022 program */
export const TOKEN_2022_PROGRAM_ID = new PublicKey('TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb');

/** Address of the SPL Associated Token Account program */
export const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey('ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL');

/** Address of the special mint for wrapped native SOL in spl-token */
export const NATIVE_MINT = new PublicKey('So11111111111111111111111111111111111111112');

/** Address of the special mint for wrapped native SOL in spl-token-2022 */
export const NATIVE_MINT_2022 = new PublicKey('9pan9bMn5HatX4EJdBwg9VgCa7Uz5HL8N1m5D3NdXejP');

/** Check that the token program provided is not `Tokenkeg...`, useful when using extensions */
export function programSupportsExtensions(programId: PublicKey): boolean {
if (programId === TOKEN_PROGRAM_ID) {
return false;
} else {
return true;
}
}
66 changes: 66 additions & 0 deletions apps/staking4u/src/app/error.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
/** Base class for errors */
export abstract class TokenError extends Error {
constructor(message?: string) {
super(message);
}
}

/** Thrown if an account is not found at the expected address */
export class TokenAccountNotFoundError extends TokenError {
name = 'TokenAccountNotFoundError';
}

/** Thrown if a program state account is not a valid Account */
export class TokenInvalidAccountError extends TokenError {
name = 'TokenInvalidAccountError';
}

/** Thrown if a program state account is not owned by the expected token program */
export class TokenInvalidAccountOwnerError extends TokenError {
name = 'TokenInvalidAccountOwnerError';
}

/** Thrown if the byte length of an program state account doesn't match the expected size */
export class TokenInvalidAccountSizeError extends TokenError {
name = 'TokenInvalidAccountSizeError';
}

/** Thrown if the mint of a token account doesn't match the expected mint */
export class TokenInvalidMintError extends TokenError {
name = 'TokenInvalidMintError';
}

/** Thrown if the owner of a token account doesn't match the expected owner */
export class TokenInvalidOwnerError extends TokenError {
name = 'TokenInvalidOwnerError';
}

/** Thrown if the owner of a token account is a PDA (Program Derived Address) */
export class TokenOwnerOffCurveError extends TokenError {
name = 'TokenOwnerOffCurveError';
}

/** Thrown if an instruction's program is invalid */
export class TokenInvalidInstructionProgramError extends TokenError {
name = 'TokenInvalidInstructionProgramError';
}

/** Thrown if an instruction's keys are invalid */
export class TokenInvalidInstructionKeysError extends TokenError {
name = 'TokenInvalidInstructionKeysError';
}

/** Thrown if an instruction's data is invalid */
export class TokenInvalidInstructionDataError extends TokenError {
name = 'TokenInvalidInstructionDataError';
}

/** Thrown if an instruction's type is invalid */
export class TokenInvalidInstructionTypeError extends TokenError {
name = 'TokenInvalidInstructionTypeError';
}

/** Thrown if the program does not support the desired instruction */
export class TokenUnsupportedInstructionError extends TokenError {
name = 'TokenUnsupportedInstructionError';
}
93 changes: 48 additions & 45 deletions apps/staking4u/src/app/screens/global/ScreenRouter.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ import WalletNftDetailScreen from '../home/wallet/WalletNftDetailScreen';
import NftSellScreen from '../home/wallet/nft/nftSell';
import NftSendScreen from '../home/wallet/nft/nftSend';
import NftSendDetailScreen from '../home/wallet/nft/nftSendDetail';
import ExportKeyScreen from '../home/myinfo/exportkey/exportkeyScreen';
import ImportKeyScreen from '../home/myinfo/importKey/importKeyScreen';
// import TermsOfServiceScreen from './TermsOfServiceScreen';
// import PrivacyScreen from './PrivacyScreen';

Expand Down Expand Up @@ -111,16 +113,16 @@ const ScreenRouter = (props) => {
return (
<Router>
<Stack hideNavBar key="root">
{/* <Scene key={'Index'}>
<Scene key={'Index'}>
<Scene
key="indexScreen"
component={IndexScreen}
hideTabBar
hideNavBar
/>
</Scene> */}
</Scene>

{/* <Scene key={'GetMnemonic'}>
<Scene key={'GetMnemonic'}>
<Scene
key="mnemonicInputScreen"
component={MnemonicInputScreen}
Expand Down Expand Up @@ -172,8 +174,7 @@ const ScreenRouter = (props) => {
hideTabBar
hideNavBar
/>
</Scene> */}

</Scene>

<Scene
key={'tabBar'}
Expand Down Expand Up @@ -208,7 +209,7 @@ const ScreenRouter = (props) => {
component={FlexibleInputScreen}
/>
{/* 유동성풀 이동 */}
<Scene
<Scene
hideNavBar
hideTabBar
key="LiquidityDetailScreen"
Expand All @@ -224,48 +225,40 @@ const ScreenRouter = (props) => {
{/* 지갑 */}
<Scene hideNavBar key={'Wallet'} title={'wallet'} icon={tabBarIcon}>
<Scene key="walletScreen" component={WalletScreen} />
<Scene
hideTabBar
key="walletDetailScreen"
component={WalletDetailScreen}
/>
<Scene
hideTabBar
key="walletNftDetailScreen"
component={WalletNftDetailScreen}
/>
<Scene
key={'sellNftScreen'}
component={NftSellScreen}
hideTabBar
/>
<Scene
key={'sendNftScreen'}
component={NftSendScreen}
hideTabBar
/>
<Scene
key={'sendNftDetailScreen'}
component={NftSendDetailScreen}
hideTabBar
/>
<Scene key={'receiveScreen'} component={ReceiveScreen} hideTabBar />
<Scene
key={'sendAddressScreen'}
component={SendAddressScreen}
hideTabBar
/>
{/* <Scene
<Scene
hideTabBar
key="walletDetailScreen"
component={WalletDetailScreen}
/>
<Scene
hideTabBar
key="walletNftDetailScreen"
component={WalletNftDetailScreen}
/>
<Scene key={'sellNftScreen'} component={NftSellScreen} hideTabBar />
<Scene key={'sendNftScreen'} component={NftSendScreen} hideTabBar />
<Scene
key={'sendNftDetailScreen'}
component={NftSendDetailScreen}
hideTabBar
/>
<Scene key={'receiveScreen'} component={ReceiveScreen} hideTabBar />
<Scene
key={'sendAddressScreen'}
component={SendAddressScreen}
hideTabBar
/>
{/* <Scene
key={'ethSendAmountScreen'}
component={EthSendAmountScreen}
hideTabBar
/> */}
<Scene
key={'solSendAmountScreen'}
component={SolSendAmountScreen}
hideTabBar
/>
</Scene>
<Scene
key={'solSendAmountScreen'}
component={SolSendAmountScreen}
hideTabBar
/>
</Scene>
{/* 투자내역 */}
<Scene
hideNavBar
Expand Down Expand Up @@ -304,12 +297,22 @@ const ScreenRouter = (props) => {
/>
</Scene>
{/* swap */}
<Scene hideNavBar key={'Swap'} title={'Swap'} icon={tabBarIcon}>
<Scene hideNavBar key={'Swap'} title={'Swap'} icon={tabBarIcon}>
<Scene hideNavBar key="SwapScreen" component={SwapScreen} />
</Scene>
{/* 나의 정보 */}
<Scene hideNavBar key={'MyInfo'} title={'myInfo'} icon={tabBarIcon}>
<Scene hideNavBar key="myInfoScreen" component={MyInfoScreen} />
<Scene
hideNavBar
key="ExportKeyScreen"
component={ExportKeyScreen}
/>
<Scene
hideNavBar
key="ImportKeyScreen"
component={ImportKeyScreen}
/>
</Scene>
</Scene>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getCoin } from '../../../../api/coinStaking';

const FlexibleDetailScreen = ({data}) => {
const { isLoading: infoLoading, data: infoData } = useQuery(["info", data], getCoin.info);
const rate = infoData?.market_data?.price_change_24h.toFixed(2);
const rate = 987; // infoData?.market_data?.price_change_24h.toFixed(2);
const price = infoData?.tickers[0].last;
const image = infoData?.image.thumb
const onPressStart = () => {
Expand Down
24 changes: 23 additions & 1 deletion apps/staking4u/src/app/screens/home/myinfo/MyInfoScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,15 @@ const MyInfoScreen = () => {
dispatch(authsActions.reset_jwt());
dispatch(authsActions.reset_email_auth());
await AsyncStorage.clear();
Actions.reset('Main'); // 작동 안함
Actions.Index();
// Actions.reset('Main'); // 작동 안함
};

const onPressExportKey = async () => {
Actions.ExportKeyScreen();
};
const onPressImportKey = async () => {
Actions.ImportKeyScreen();
};

const sections = [
Expand All @@ -35,6 +43,20 @@ const MyInfoScreen = () => {
title: 'App version 0.0.2',
isButton: false,
},
{
title: 'Import Key',
isButton: true,
onPress: () => {
onPressImportKey();
},
},
{
title: 'Export Key',
isButton: true,
onPress: () => {
onPressExportKey();
},
},
{
title: 'Logout',
isButton: true,
Expand Down
Loading