Skip to content

Commit

Permalink
use TOKEN_ACCOUNT_RENT_EXEMPTION_LAMPORTS
Browse files Browse the repository at this point in the history
  • Loading branch information
wentokay committed Mar 10, 2023
1 parent bf12e24 commit b229cee
Show file tree
Hide file tree
Showing 4 changed files with 61 additions and 61 deletions.
7 changes: 3 additions & 4 deletions packages/app-extension/src/components/Unlocked/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -817,11 +817,10 @@ const SwapInfoRow = ({ label, value, tooltip }: SwapInfoRowProps) => {
return (
<div className={classes.swapInfoRow}>
<div
className={classes.swapInfoTitleLeft}
onMouseOver={() => setTooltipVisible(true)}
onMouseOut={() => setTooltipVisible(false)}
>
<Typography>
<Typography className={classes.swapInfoTitleLeft}>
{label}
{tooltip ? (
<Tooltip title={tooltip} arrow open={tooltipVisible}>
Expand Down Expand Up @@ -954,8 +953,8 @@ export function SwapSelectToken({

/**
* Hides miniscule amounts of SOL
* @example approximateAmount(0.000203928) = "0.0002"
* @example approximateAmount(0.00203928) = "0.002"
* @param value BigNumberish amount of Solana Lamports
*/
const approximateAmount = (value: BigNumberish) =>
ethers.utils.formatUnits(value, 9).replace(/(0.0{3,}[1-9])(\d+)/, "$1");
ethers.utils.formatUnits(value, 9).replace(/(0.0{2,}[1-9])(\d+)/, "$1");
102 changes: 51 additions & 51 deletions packages/common/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -565,8 +565,8 @@ export const QUERY_ADD_USER_ACCOUNT = "add-user-account=true";

export const SIMULATOR_PORT = 9933;

export const NATIVE_ACCOUNT_RENT_EXEMPTION_LAMPORTS = 890880;
export const TOKEN_ACCOUNT_RENT_EXEMPTION_LAMPORTS = 2039280;
export const NATIVE_ACCOUNT_RENT_EXEMPTION_LAMPORTS = 890880 as const;
export const TOKEN_ACCOUNT_RENT_EXEMPTION_LAMPORTS = 2039280 as const;

export const DISCORD_INVITE_LINK = "https://discord.gg/RhKxgS8SaD";
export const TWITTER_LINK = "https://twitter.com/xNFT_Backpack";
Expand Down Expand Up @@ -595,13 +595,13 @@ export const DEFAULT_GROUP_CHATS: {
name: string;
image: string;
}[] = [
{
id: "backpack-chat",
name: "Backpack",
image:
"https://user-images.githubusercontent.com/321395/206757416-a80e662a-0ccc-41cc-a20f-ff397755d47f.png",
},
];
{
id: "backpack-chat",
name: "Backpack",
image:
"https://user-images.githubusercontent.com/321395/206757416-a80e662a-0ccc-41cc-a20f-ff397755d47f.png",
},
];

export const WHITELISTED_CHAT_COLLECTIONS: {
id: string;
Expand All @@ -610,49 +610,49 @@ export const WHITELISTED_CHAT_COLLECTIONS: {
collectionId: string;
attributeMapping?: { [key: string]: string };
}[] = [
{
id: "nouns",
name: "Y00ts + Nouns",
image: "https://metadata.y00ts.com/y/12189.png",
collectionId: "4mKSoDDqApmF1DqXvVTSL6tu2zixrSSNjqMxUnwvVzy2",
attributeMapping: {
Eyewear: "Nouns",
},
},
{
id: "nokiamon",
name: "Nokiamon",
image:
"https://madlist-images.s3.us-west-2.amazonaws.com/nokiamon_pfp_1675332500467.png",
collectionId: "3YysdoK6ZcJFEL5QJxccY3q8AcTUFpahgbp4HFgBtjNF",
},
{
id: "backpack-chat-internal",
name: "Backpack Team",
image: "https://one.xnfts.dev/BackpackTeamNFT.gif",

collectionId: "BjN9u6zneFrjzuC7LH3eLaGC9FgYLnwQJMGA1xzVBKsj",
{
id: "nouns",
name: "Y00ts + Nouns",
image: "https://metadata.y00ts.com/y/12189.png",
collectionId: "4mKSoDDqApmF1DqXvVTSL6tu2zixrSSNjqMxUnwvVzy2",
attributeMapping: {
Eyewear: "Nouns",
},
{
id: "bonkz",
name: "BONKz",
image:
"https://bafybeiecuemcqxzuv4ti4sgffjlwvrqedr7golppwrbbu2u5yttglath3m.ipfs.nftstorage.link/0.png",
collectionId: "ajM4QBHtZBBRcMqqq9gawdHK28GXcb2yeRs6WBnqhay",
},
{
id: "3PMczHyeW2ds7ZWDZbDSF3d21HBqG6yR4tG7vP6qczfj",
name: "The Madlist",
image: "https://www.madlads.com/mad_lads_logo.svg",
collectionId: "3PMczHyeW2ds7ZWDZbDSF3d21HBqG6yR4tG7vP6qczfj",
},
{
id: "FCk24cq1pYhQo5MQYKHf5N9VnY8tdrToF7u6gvvsnGrn",
name: "The Madlist",
image: "https://www.madlads.com/mad_lads_logo.svg",
collectionId: "FCk24cq1pYhQo5MQYKHf5N9VnY8tdrToF7u6gvvsnGrn",
},
];
},
{
id: "nokiamon",
name: "Nokiamon",
image:
"https://madlist-images.s3.us-west-2.amazonaws.com/nokiamon_pfp_1675332500467.png",
collectionId: "3YysdoK6ZcJFEL5QJxccY3q8AcTUFpahgbp4HFgBtjNF",
},
{
id: "backpack-chat-internal",
name: "Backpack Team",
image: "https://one.xnfts.dev/BackpackTeamNFT.gif",

collectionId: "BjN9u6zneFrjzuC7LH3eLaGC9FgYLnwQJMGA1xzVBKsj",
},
{
id: "bonkz",
name: "BONKz",
image:
"https://bafybeiecuemcqxzuv4ti4sgffjlwvrqedr7golppwrbbu2u5yttglath3m.ipfs.nftstorage.link/0.png",
collectionId: "ajM4QBHtZBBRcMqqq9gawdHK28GXcb2yeRs6WBnqhay",
},
{
id: "3PMczHyeW2ds7ZWDZbDSF3d21HBqG6yR4tG7vP6qczfj",
name: "The Madlist",
image: "https://www.madlads.com/mad_lads_logo.svg",
collectionId: "3PMczHyeW2ds7ZWDZbDSF3d21HBqG6yR4tG7vP6qczfj",
},
{
id: "FCk24cq1pYhQo5MQYKHf5N9VnY8tdrToF7u6gvvsnGrn",
name: "The Madlist",
image: "https://www.madlads.com/mad_lads_logo.svg",
collectionId: "FCk24cq1pYhQo5MQYKHf5N9VnY8tdrToF7u6gvvsnGrn",
},
];

// Load a fixed amount of public keys for various actions, e.g. import list,
// searching mnemonics
Expand Down
9 changes: 5 additions & 4 deletions packages/common/src/solana/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,13 @@ import {
} from "@magiceden-oss/open_creator_protocol";
import type {
TransferInstructionAccounts,
TransferInstructionArgs} from "@metaplex-foundation/mpl-token-metadata";
TransferInstructionArgs,
} from "@metaplex-foundation/mpl-token-metadata";
import {
createTransferInstruction as createTokenMetadataTransferInstruction,
Metadata,
TokenRecord,
TokenState
TokenState,
} from "@metaplex-foundation/mpl-token-metadata";
import type { Program, SplToken } from "@project-serum/anchor";
import * as anchor from "@project-serum/anchor";
Expand Down Expand Up @@ -50,6 +51,7 @@ import {
import BN from "bn.js";

import type { BackgroundClient } from "../";
import { TOKEN_ACCOUNT_RENT_EXEMPTION_LAMPORTS } from "../constants";

import * as assertOwner from "./programs/assert-owner";
import {
Expand Down Expand Up @@ -678,13 +680,12 @@ export const generateUnwrapSolTx = async (
);
} else {
const newAccount = Keypair.generate();
const rentExemptionLamports = 2039280;
// Create a new account to transfer wSOL into and then close
tx.instructions.push(
SystemProgram.createAccount({
fromPubkey: walletPublicKey,
newAccountPubkey: newAccount.publicKey,
lamports: rentExemptionLamports,
lamports: TOKEN_ACCOUNT_RENT_EXEMPTION_LAMPORTS,
space: 165,
programId: TOKEN_PROGRAM_ID,
})
Expand Down
4 changes: 2 additions & 2 deletions packages/recoil/src/context/Swap.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
generateWrapSolTx,
NATIVE_ACCOUNT_RENT_EXEMPTION_LAMPORTS,
SOL_NATIVE_MINT,
TOKEN_ACCOUNT_RENT_EXEMPTION_LAMPORTS,
UI_RPC_METHOD_SOLANA_SIGN_AND_SEND_TRANSACTION,
USDC_MINT,
WSOL_MINT,
Expand Down Expand Up @@ -369,8 +370,7 @@ export function SwapProvider({
)
))
) {
// rent-exemption lamports required for SPL Token V2 (0.00203928 SOL)
return 203928;
return TOKEN_ACCOUNT_RENT_EXEMPTION_LAMPORTS;
}
} catch (err) {
// don't throw on this until it's undergone further testing
Expand Down

0 comments on commit b229cee

Please sign in to comment.