diff --git a/.env.example b/.env.example index 69de436..8edfffe 100644 --- a/.env.example +++ b/.env.example @@ -3,8 +3,8 @@ FAL_AI_KEY= NEXT_PUBLIC_MTM_TOKEN_MINT=97RggLo3zV5kFGYW4yoQTxr4Xkz4Vg2WPHzNYXXWpump NEXT_PUBLIC_PAYMENT_RECEIVER_ADDRESS=FFDx3SdAEeXrp6BTmStB4BDHpctGsaasZq4FFcowRobY -NEXT_PUBLIC_SOLANA_RPC_URL=https://young-radial-orb.solana-mainnet.quiknode.pro/67612b364664616c29514e551bf5de38447ca3d4 -NEXT_PUBLIC_SOLANA_WEBSOCKET_URL=wss://young-radial-orb.solana-mainnet.quiknode.pro/67612b364664616c29514e551bf5de38447ca3d4 +NEXT_PUBLIC_SOLANA_RPC_URL=https://skilled-prettiest-seed.solana-mainnet.quiknode.pro/eeecfebd04e345f69f1900cc3483cbbfea02a158 +NEXT_PUBLIC_SOLANA_WEBSOCKET_URL=wss://skilled-prettiest-seed.solana-mainnet.quiknode.pro/eeecfebd04e345f69f1900cc3483cbbfea02a158 NEXT_PUBLIC_USDC_MINT=EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v # Generate a key at https://app.pinata.cloud/developers/api-keys @@ -17,3 +17,10 @@ PINATA_GATEWAY= # For development: SITE_URL=http://localhost:3000 SITE_URL=https://memes.markto.market NEXT_PUBLIC_ACCOUNT_HANDLE= + +WSOL_LOCKER_PRIVATE_KEY= +WSOL_MINT=So11111111111111111111111111111111111111112 + +# Duration in seconds that WSOL will be locked for +CLIFF_TIME=172800 # 48 hours +REWARD_MULTIPLIER=4 diff --git a/src/app/api/lock/route.ts b/src/app/api/lock/route.ts index 3cf0f84..65882bf 100644 --- a/src/app/api/lock/route.ts +++ b/src/app/api/lock/route.ts @@ -27,13 +27,13 @@ async function extractInfo(transactionSignature: string) { } async function createRewardLock(authority: string, amount: string) { - const { USER_PRIVATE_KEY, CLIFF_TIME, WSOL_MINT, NEXT_PUBLIC_MTM_TOKEN_MINT, REWARD_MULTIPLIER } = process.env; - if (!USER_PRIVATE_KEY || !CLIFF_TIME || !WSOL_MINT || !NEXT_PUBLIC_MTM_TOKEN_MINT || !REWARD_MULTIPLIER) { + const { WSOL_LOCKER_PRIVATE_KEY, CLIFF_TIME, WSOL_MINT, NEXT_PUBLIC_MTM_TOKEN_MINT, REWARD_MULTIPLIER } = process.env; + if (!WSOL_LOCKER_PRIVATE_KEY || !CLIFF_TIME || !WSOL_MINT || !NEXT_PUBLIC_MTM_TOKEN_MINT || !REWARD_MULTIPLIER) { throw new Error('Missing required environment variables'); } const duration = new BN(CLIFF_TIME).add(new BN(Math.floor(Date.now() / 1000))); - const tokenLockerKeypair = Keypair.fromSecretKey(bs58.decode(USER_PRIVATE_KEY)); + const tokenLockerKeypair = Keypair.fromSecretKey(bs58.decode(WSOL_LOCKER_PRIVATE_KEY)); const recipientPublicKey = new PublicKey(authority); const url = `https://api.jup.ag/price/v2?ids=${NEXT_PUBLIC_MTM_TOKEN_MINT}&vsToken=${WSOL_MINT}`; diff --git a/src/components/AIServiceCard.tsx b/src/components/AIServiceCard.tsx index f9e96e7..85bea1c 100644 --- a/src/components/AIServiceCard.tsx +++ b/src/components/AIServiceCard.tsx @@ -21,11 +21,11 @@ interface GenerationState { error: string | null } -const baseUnitToDecimalFormat = (value: BN, decimals: number): string => { +const baseUnitToWholeNumber = (value: BN, decimals: number): string => { const bigValue = new Big(value.toString()); const factor = new Big(10).pow(decimals); - return bigValue.div(factor).toFixed(decimals); + return bigValue.div(factor).round(0, Big.roundUp).toFixed(0); } const AIServiceCard: React.FC = ({ @@ -93,11 +93,11 @@ const AIServiceCard: React.FC = ({ const generateTwitterShareUrl = (imageUrl: string, transactionSignature: string): string => { const baseUrl = window.location.href; const cid = imageUrl.split("/image/")[1]; - const memeUrl = `${baseUrl}memes/${cid}`; + const memePageUrl = `${baseUrl}memes/${cid}`; const tweetText = `Check out this meme that I generated! \n TX Hash: '${transactionSignature}' \n @${process.env.NEXT_PUBLIC_ACCOUNT_HANDLE} \n`; - return `https://twitter.com/intent/tweet?text=${encodeURIComponent(tweetText)}&url=${encodeURIComponent(memeUrl)}`; + return `https://twitter.com/intent/tweet?text=${encodeURIComponent(tweetText)}&url=${encodeURIComponent(memePageUrl)}`; }; return ( @@ -109,7 +109,7 @@ const AIServiceCard: React.FC = ({

{description}

- Cost: {priceMTM ? baseUnitToDecimalFormat(priceMTM, 6) : '...'} MTM + Cost: {priceMTM ? baseUnitToWholeNumber(priceMTM, 6) : '...'} MTM
@@ -133,7 +133,7 @@ const AIServiceCard: React.FC = ({ transition-all duration-200 shadow-lg hover:shadow-green-500/25 disabled:opacity-50 disabled:cursor-not-allowed disabled:hover:shadow-none" > - {generationState.loading ? 'Processing...' : `Pay ${priceMTM ? baseUnitToDecimalFormat(priceMTM, 6) : '...'} MTM & Generate`} + {generationState.loading ? 'Processing...' : `Pay ${priceMTM ? baseUnitToWholeNumber(priceMTM, 6) : '...'} MTM & Generate`} diff --git a/src/locker-utils/index.ts b/src/locker-utils/index.ts index fef9b83..d8ab321 100644 --- a/src/locker-utils/index.ts +++ b/src/locker-utils/index.ts @@ -35,9 +35,9 @@ import { RemainingAccountsType, } from './token-2022/remaining-accounts'; -assert(process.env.RPC_ENDPOINT); +assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL); -const connection = new Connection(process.env.RPC_ENDPOINT); +const connection = new Connection(process.env.NEXT_PUBLIC_SOLANA_RPC_URL); const ESCROW_USE_SPL_TOKEN = 0; @@ -116,7 +116,7 @@ export async function createVestingPlanV2(params: CreateVestingPlanParams) { ASSOCIATED_TOKEN_PROGRAM_ID ); - let remainingAccountsInfo = null; + let remainingAccountsInfo; let remainingAccounts: AccountMeta[] = []; if (tokenProgram == TOKEN_2022_PROGRAM_ID) { let inputTransferHookAccounts = @@ -225,7 +225,7 @@ export async function claimTokenV2(params: ClaimTokenParamsV2) { ASSOCIATED_TOKEN_PROGRAM_ID ); - let remainingAccountsInfo = null; + let remainingAccountsInfo; let remainingAccounts: AccountMeta[] | undefined = []; if (tokenProgram == TOKEN_2022_PROGRAM_ID) { let claimTransferHookAccounts = diff --git a/src/utils/create-lock.ts b/src/utils/create-lock.ts index b7a05ab..da5ac80 100644 --- a/src/utils/create-lock.ts +++ b/src/utils/create-lock.ts @@ -11,16 +11,15 @@ import { Connection, PublicKey } from "@solana/web3.js"; import { createVestingPlanV2 } from '../locker-utils'; -assert(process.env.RPC_ENDPOINT); -assert(process.env.USER_PRIVATE_KEY); -//assert(process.env.RECIPIENT_PUBLIC_KEY); +assert(process.env.NEXT_PUBLIC_SOLANA_RPC_URL); +assert(process.env.WSOL_LOCKER_PRIVATE_KEY); assert(process.env.WSOL_MINT); -const RPC_ENDPOINT= process.env.RPC_ENDPOINT; +const RPC_ENDPOINT= process.env.NEXT_PUBLIC_SOLANA_RPC_URL; const WSOL_MINT = process.env.WSOL_MINT; -const USER_PRIVATE_KEY = process.env.USER_PRIVATE_KEY; +const WSOL_LOCKER_PRIVATE_KEY = process.env.WSOL_LOCKER_PRIVATE_KEY; -const userKP = anchor.web3.Keypair.fromSecretKey(bs58.decode(USER_PRIVATE_KEY)); +const userKP = anchor.web3.Keypair.fromSecretKey(bs58.decode(WSOL_LOCKER_PRIVATE_KEY)); const connection = new Connection(RPC_ENDPOINT); const token = new PublicKey(WSOL_MINT);