From 5bd305339b5b2e87a877dc423d121436dbb13b98 Mon Sep 17 00:00:00 2001 From: Adam Jeffries <896669+adamjeffries@users.noreply.github.com> Date: Wed, 1 Sep 2021 11:21:27 -0500 Subject: [PATCH 01/26] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index e14383c..44d5801 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Metaplex is comprised of two core components: an on-chain program, and a self-ho If you want to deep dive on the Architecture, you can do so here: -https://www.notion.so/Metaplex-Developer-Guide-afefbc19841744c28587ab948a08cfac +https://docs.metaplex.com/ ## Installing From e2acaae9f22d521cbd63246f288cce61f38e52ca Mon Sep 17 00:00:00 2001 From: nftintern <89903221+nftintern@users.noreply.github.com> Date: Wed, 1 Sep 2021 12:26:34 -0500 Subject: [PATCH 02/26] correction: tx -> tx['txid']; also remove duplicate @solana/web3.js package that was causing name collision (#270) --- js/packages/cli/package.json | 1 - js/packages/cli/src/cli.ts | 3 ++- js/yarn.lock | 20 -------------------- 3 files changed, 2 insertions(+), 22 deletions(-) diff --git a/js/packages/cli/package.json b/js/packages/cli/package.json index 67591e7..5e27ceb 100644 --- a/js/packages/cli/package.json +++ b/js/packages/cli/package.json @@ -21,7 +21,6 @@ }, "dependencies": { "@project-serum/anchor": "^0.13.2", - "@solana/web3.js": "^1.24.1", "arweave": "^1.10.16", "bn.js": "^5.2.0", "commander": "^8.1.0", diff --git a/js/packages/cli/src/cli.ts b/js/packages/cli/src/cli.ts index d81856a..a124b35 100755 --- a/js/packages/cli/src/cli.ts +++ b/js/packages/cli/src/cli.ts @@ -389,11 +389,12 @@ program [], 'single', ); + console.info('transaction for arweave payment:', tx); // data.append('tags', JSON.stringify(tags)); // payment transaction const data = new FormData(); - data.append('transaction', tx); + data.append('transaction', tx['txid']); data.append('env', ENV); data.append('file[]', fs.createReadStream(image), `image.png`); data.append('file[]', manifestBuffer, 'metadata.json'); diff --git a/js/yarn.lock b/js/yarn.lock index 8c895ae..fbf1d7a 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -2211,26 +2211,6 @@ superstruct "^0.14.2" tweetnacl "^1.0.0" -"@solana/web3.js@^1.24.1": - version "1.24.1" - resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.24.1.tgz#1fb29f344454669183206f452ab3b8792567cade" - integrity sha512-XImMWAvjcXteMQwe1FFjoe6u72xmcu+UYobPIxLEMX29XXWVTalyYRKBXvcOXwz6DliTYnFXmncNEwUDEFFHGg== - dependencies: - "@babel/runtime" "^7.12.5" - "@solana/buffer-layout" "^3.0.0" - bn.js "^5.0.0" - borsh "^0.4.0" - bs58 "^4.0.1" - buffer "6.0.1" - crypto-hash "^1.2.2" - jayson "^3.4.4" - js-sha3 "^0.8.0" - node-fetch "^2.6.1" - rpc-websockets "^7.4.2" - secp256k1 "^4.0.2" - superstruct "^0.14.2" - tweetnacl "^1.0.0" - "@testing-library/dom@*", "@testing-library/dom@^7.28.1": version "7.31.0" resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-7.31.0.tgz#938451abd3ca27e1b69bb395d4a40759fd7f5b3b" From 06534bf5bec431a4b43dfeff95b0e84e69fc420d Mon Sep 17 00:00:00 2001 From: 0xsolsurfer <89321164+0xsolsurfer@users.noreply.github.com> Date: Wed, 1 Sep 2021 10:31:02 -0700 Subject: [PATCH 04/26] Update deploy.md for Vercel deploys (#247) Updates deploy.md to include a missing step, enabling Vercel deploys using next.js. --- docs/deploy.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/deploy.md b/docs/deploy.md index 2dd3590..7fec7ab 100644 --- a/docs/deploy.md +++ b/docs/deploy.md @@ -52,7 +52,7 @@ yarn deploy ## Vercel -To publish the Metaplex app to Vercel, you first need to visit [https://vercel.com/](https://vercel.com/) and create a new project linked to your github repo. +To publish the Metaplex app to Vercel, you first need to visit [https://vercel.com/](https://vercel.com/) and create a new project linked to your github repo. Then, create a `pages/` directory under `js`. After that, configure this project with the following settings: From f98142b182aa4c1c5895cebd3430b564da2b567b Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Wed, 1 Sep 2021 18:02:50 -0500 Subject: [PATCH 05/26] Update .env --- js/packages/web/.env | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/packages/web/.env b/js/packages/web/.env index 9d5a95c..f01fb3a 100644 --- a/js/packages/web/.env +++ b/js/packages/web/.env @@ -1,3 +1,3 @@ -REACT_APP_STORE_OWNER_ADDRESS_ADDRESS=CduMjFZLBeg3A9wMP3hQCoU1RQzzCpgSvQNXfCi1GCSB +REACT_APP_STORE_OWNER_ADDRESS_ADDRESS= REACT_APP_STORE_ADDRESS= REACT_APP_BIG_STORE=FALSE From c09c96e58c5ec9fc5bb66b49f626192956c96aae Mon Sep 17 00:00:00 2001 From: Slavomir Date: Thu, 2 Sep 2021 18:09:50 +0300 Subject: [PATCH 06/26] Fix Anchor.toml (#272) --- rust/Anchor.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/Anchor.toml b/rust/Anchor.toml index 76a873b..829f7c0 100644 --- a/rust/Anchor.toml +++ b/rust/Anchor.toml @@ -3,7 +3,7 @@ url = "https://anchor.projectserum.com" [provider] cluster = "localnet" -wallet = "/Users/jprince/.config/solana/id.json" +wallet = "~/.config/solana/id.json" [scripts] test = "mocha -t 1000000 tests/" From 9d9d9d93b105bb3aa441bb7295ed5540cb3749f2 Mon Sep 17 00:00:00 2001 From: lpeace <46713580+superb20@users.noreply.github.com> Date: Fri, 3 Sep 2021 00:10:44 +0900 Subject: [PATCH 07/26] Fix example link (#252) --- rust/token-metadata/program/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/token-metadata/program/README.md b/rust/token-metadata/program/README.md index 251ce75..034019c 100644 --- a/rust/token-metadata/program/README.md +++ b/rust/token-metadata/program/README.md @@ -16,7 +16,7 @@ The Token Metadata Program's source is available on [github](https://github.com/metaplex-foundation/metaplex) There is also an example Rust client located at -[github](https://github.com/metaplex-foundation/metaplex/tree/master/token_metadata/test/src/main.rs) +[github](https://github.com/metaplex-foundation/metaplex/tree/master/rust/token-metadata/test/src/main.rs) that can be perused for learning and run if desired with `cargo run --bin spl-token-metadata-test-client`. It allows testing out a variety of scenarios. ## Interface From 617d197e8433322a6e625929f6c9402c642247d2 Mon Sep 17 00:00:00 2001 From: Koenrad MacBride Date: Thu, 2 Sep 2021 09:18:13 -0700 Subject: [PATCH 08/26] Fix/candy machine cli (#280) * fix: stringify tx object * add: log the CM publicKey * mod: mine_one_token ty Dad! * remove: built js file (i m smurt) --- js/packages/cli/src/cli.ts | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/js/packages/cli/src/cli.ts b/js/packages/cli/src/cli.ts index a124b35..6e18fc3 100755 --- a/js/packages/cli/src/cli.ts +++ b/js/packages/cli/src/cli.ts @@ -611,12 +611,12 @@ program }, ); - console.log('Done'); + console.log(`Done: CANDYMACHINE: ${candyMachine.toBase58()}`); }); program - .command('mint_token_as_candy_machine_owner') - .option('-k, --keypair ', 'Solana wallet') + .command('mint_one_token') + .option('-k, --keypair ', `The purchaser's wallet key`) .option('-c, --cache-name ', 'Cache file name') .action(async (directory, cmd) => { const solConnection = new anchor.web3.Connection( @@ -649,6 +649,7 @@ program config, cachedContent.program.uuid, ); + const candy = await anchorProgram.account.candyMachine.fetch(candyMachine); const metadata = await getMetadata(mint.publicKey); const masterEdition = await getMasterEdition(mint.publicKey); const tx = await anchorProgram.rpc.mintNft({ @@ -656,7 +657,8 @@ program config: config, candyMachine: candyMachine, payer: walletKey.publicKey, - wallet: walletKey.publicKey, + //@ts-ignore + wallet: candy.wallet, mint: mint.publicKey, metadata, masterEdition, From 0b064b6df49eb5b94f21796a1b04d223a921f16d Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Fri, 3 Sep 2021 15:38:03 -0500 Subject: [PATCH 09/26] Fix 10k error (#287) --- rust/nft-candy-machine/src/lib.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust/nft-candy-machine/src/lib.rs b/rust/nft-candy-machine/src/lib.rs index 1bb60a9..cc55bf4 100644 --- a/rust/nft-candy-machine/src/lib.rs +++ b/rust/nft-candy-machine/src/lib.rs @@ -430,7 +430,7 @@ pub struct InitializeCandyMachine<'info> { #[derive(Accounts)] #[instruction(data: ConfigData)] pub struct InitializeConfig<'info> { - #[account(mut, constraint= config.to_account_info().owner == program_id && config.to_account_info().data_len() > CONFIG_ARRAY_START+4+(data.max_number_of_lines as usize)*CONFIG_LINE_SIZE + 4 + (data.max_number_of_lines.checked_div(8).ok_or(ErrorCode::NumericalOverflowError)? as usize))] + #[account(mut, constraint= config.to_account_info().owner == program_id && config.to_account_info().data_len() >= CONFIG_ARRAY_START+4+(data.max_number_of_lines as usize)*CONFIG_LINE_SIZE + 4 + (data.max_number_of_lines.checked_div(8).ok_or(ErrorCode::NumericalOverflowError)? as usize))] config: AccountInfo<'info>, #[account(constraint= authority.data_is_empty() && authority.lamports() > 0 )] authority: AccountInfo<'info>, From 14401e878d36cac16c0ba4e6b606420c29eeed08 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Fri, 3 Sep 2021 18:58:43 -0500 Subject: [PATCH 10/26] feat: mint editions into wallet (#289) feat(ArtMinting): add mint destination address validation feat(ArtMinting): add cofetti feat(ArtMinting): add remounting logic chore(mint editions): upodate types chore(art minting): update imports Co-authored-by: shotgunofdeath <42133844+shotgunofdeath@users.noreply.github.com> --- .../actions/createMintAndAccountWithOne.ts | 65 +++++ .../web/src/actions/mintEditionsIntoWallet.ts | 106 ++++++++ js/packages/web/src/actions/sendRedeemBid.ts | 59 +---- .../setupMintEditionIntoWalletInstructions.ts | 58 ++++ .../web/src/components/ArtMinting/index.tsx | 248 ++++++++++++++++++ js/packages/web/src/views/art/index.tsx | 46 +++- 6 files changed, 510 insertions(+), 72 deletions(-) create mode 100644 js/packages/web/src/actions/createMintAndAccountWithOne.ts create mode 100644 js/packages/web/src/actions/mintEditionsIntoWallet.ts create mode 100644 js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts create mode 100644 js/packages/web/src/components/ArtMinting/index.tsx diff --git a/js/packages/web/src/actions/createMintAndAccountWithOne.ts b/js/packages/web/src/actions/createMintAndAccountWithOne.ts new file mode 100644 index 0000000..ca16b7d --- /dev/null +++ b/js/packages/web/src/actions/createMintAndAccountWithOne.ts @@ -0,0 +1,65 @@ +import { Keypair, TransactionInstruction } from '@solana/web3.js'; +import { Token } from '@solana/spl-token'; +import { + createAssociatedTokenAccountInstruction, + createMint, + findProgramAddress, + programIds, + StringPublicKey, + toPublicKey, +} from '@oyster/common'; +import { WalletNotConnectedError } from '@solana/wallet-adapter-base'; + +export async function createMintAndAccountWithOne( + wallet: any, + receiverWallet: StringPublicKey, + mintRent: any, + instructions: TransactionInstruction[], + signers: Keypair[], +): Promise<{ mint: StringPublicKey; account: StringPublicKey }> { + if (!wallet.publicKey) throw new WalletNotConnectedError(); + + const mint = createMint( + instructions, + wallet.publicKey, + mintRent, + 0, + wallet.publicKey, + wallet.publicKey, + signers, + ); + + const PROGRAM_IDS = programIds(); + + const account: StringPublicKey = ( + await findProgramAddress( + [ + toPublicKey(receiverWallet).toBuffer(), + PROGRAM_IDS.token.toBuffer(), + mint.toBuffer(), + ], + PROGRAM_IDS.associatedToken, + ) + )[0]; + + createAssociatedTokenAccountInstruction( + instructions, + toPublicKey(account), + wallet.publicKey, + toPublicKey(receiverWallet), + mint, + ); + + instructions.push( + Token.createMintToInstruction( + PROGRAM_IDS.token, + mint, + toPublicKey(account), + wallet.publicKey, + [], + 1, + ), + ); + + return { mint: mint.toBase58(), account }; +} diff --git a/js/packages/web/src/actions/mintEditionsIntoWallet.ts b/js/packages/web/src/actions/mintEditionsIntoWallet.ts new file mode 100644 index 0000000..44df303 --- /dev/null +++ b/js/packages/web/src/actions/mintEditionsIntoWallet.ts @@ -0,0 +1,106 @@ +import BN from 'bn.js'; +import { Connection, Keypair, TransactionInstruction } from '@solana/web3.js'; +import { + sendTransactions, + sendTransactionWithRetry, + SequenceType, + StringPublicKey, + TokenAccount, +} from '@oyster/common'; +import { setupMintEditionIntoWalletInstructions } from './setupMintEditionIntoWalletInstructions'; +import { Art } from '../types'; +import { WalletAdapter } from '@solana/wallet-base'; + +// TODO: Refactor. Extract batching logic, +// as the similar one is used in settle.ts and convertMasterEditions.ts +const MINT_TRANSACTION_SIZE = 5; +const BATCH_SIZE = 10; + +export async function mintEditionsToWallet( + art: Art, + wallet: WalletAdapter, + connection: Connection, + mintTokenAccount: TokenAccount, + editions: number = 1, + mintDestination: StringPublicKey, +) { + let signers: Array> = []; + let instructions: Array> = []; + + let currSignerBatch: Array = []; + let currInstrBatch: Array = []; + + let mintEditionIntoWalletSigners: Keypair[] = []; + let mintEditionIntoWalletInstructions: TransactionInstruction[] = []; + + // TODO replace all this with payer account so user doesnt need to click approve several times. + + // Overall we have 10 parallel txns. + // That's what this loop is building. + for (let i = 0; i < editions; i++) { + console.log('Minting', i); + await setupMintEditionIntoWalletInstructions( + art, + wallet, + connection, + mintTokenAccount, + new BN(art.supply! + 1 + i), + mintEditionIntoWalletInstructions, + mintEditionIntoWalletSigners, + mintDestination, + ); + + if (mintEditionIntoWalletInstructions.length === MINT_TRANSACTION_SIZE) { + currSignerBatch.push(mintEditionIntoWalletSigners); + currInstrBatch.push(mintEditionIntoWalletInstructions); + mintEditionIntoWalletSigners = []; + mintEditionIntoWalletInstructions = []; + } + + if (currInstrBatch.length === BATCH_SIZE) { + signers.push(currSignerBatch); + instructions.push(currInstrBatch); + currSignerBatch = []; + currInstrBatch = []; + } + } + + if ( + mintEditionIntoWalletInstructions.length < MINT_TRANSACTION_SIZE && + mintEditionIntoWalletInstructions.length > 0 + ) { + currSignerBatch.push(mintEditionIntoWalletSigners); + currInstrBatch.push(mintEditionIntoWalletInstructions); + } + + if (currInstrBatch.length <= BATCH_SIZE && currInstrBatch.length > 0) { + // add the last one on + signers.push(currSignerBatch); + instructions.push(currInstrBatch); + } + console.log('Instructions', instructions); + for (let i = 0; i < instructions.length; i++) { + const instructionBatch = instructions[i]; + const signerBatch = signers[i]; + console.log('Running batch', i); + if (instructionBatch.length >= 2) + // Pump em through! + await sendTransactions( + connection, + wallet, + instructionBatch, + signerBatch, + SequenceType.StopOnFailure, + 'single', + ); + else + await sendTransactionWithRetry( + connection, + wallet, + instructionBatch[0], + signerBatch[0], + 'single', + ); + console.log('Done'); + } +} diff --git a/js/packages/web/src/actions/sendRedeemBid.ts b/js/packages/web/src/actions/sendRedeemBid.ts index e0be071..b7c2a8b 100644 --- a/js/packages/web/src/actions/sendRedeemBid.ts +++ b/js/packages/web/src/actions/sendRedeemBid.ts @@ -16,15 +16,12 @@ import { sendTransactionsWithManualRetry, MasterEditionV1, MasterEditionV2, - findProgramAddress, - createAssociatedTokenAccountInstruction, deprecatedMintNewEditionFromMasterEditionViaPrintingToken, MetadataKey, TokenAccountParser, BidderMetadata, getEditionMarkPda, decodeEditionMarker, - BidStateType, StringPublicKey, toPublicKey, WalletSigner, @@ -44,13 +41,13 @@ import { PrizeTrackingTicket, getPrizeTrackingTicket, BidRedemptionTicket, - getBidRedemption, } from '../models/metaplex'; import { claimBid } from '../models/metaplex/claimBid'; import { setupCancelBid } from './cancelBid'; import { deprecatedPopulateParticipationPrintingAccount } from '../models/metaplex/deprecatedPopulateParticipationPrintingAccount'; import { setupPlaceBid } from './sendPlaceBid'; import { claimUnusedPrizes } from './claimUnusedPrizes'; +import { createMintAndAccountWithOne } from './createMintAndAccountWithOne'; import { BN } from 'bn.js'; import { QUOTE_MINT } from '../constants'; import { @@ -414,60 +411,6 @@ async function setupRedeemFullRightsTransferInstructions( } } -async function createMintAndAccountWithOne( - wallet: WalletSigner, - receiverWallet: StringPublicKey, - mintRent: any, - instructions: TransactionInstruction[], - signers: Keypair[], -): Promise<{ mint: StringPublicKey; account: StringPublicKey }> { - if (!wallet.publicKey) throw new WalletNotConnectedError(); - - const mint = createMint( - instructions, - wallet.publicKey, - mintRent, - 0, - wallet.publicKey, - wallet.publicKey, - signers, - ); - - const PROGRAM_IDS = programIds(); - - const account: StringPublicKey = ( - await findProgramAddress( - [ - toPublicKey(receiverWallet).toBuffer(), - PROGRAM_IDS.token.toBuffer(), - mint.toBuffer(), - ], - PROGRAM_IDS.associatedToken, - ) - )[0]; - - createAssociatedTokenAccountInstruction( - instructions, - toPublicKey(account), - wallet.publicKey, - toPublicKey(receiverWallet), - mint, - ); - - instructions.push( - Token.createMintToInstruction( - PROGRAM_IDS.token, - mint, - toPublicKey(account), - wallet.publicKey, - [], - 1, - ), - ); - - return { mint: mint.toBase58(), account }; -} - export async function setupRedeemPrintingV2Instructions( connection: Connection, auctionView: AuctionView, diff --git a/js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts b/js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts new file mode 100644 index 0000000..2c5d5a7 --- /dev/null +++ b/js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts @@ -0,0 +1,58 @@ +import { Connection } from '@solana/web3.js'; +import { MintLayout } from '@solana/spl-token'; +import BN from 'bn.js'; +import { + mintNewEditionFromMasterEditionViaToken, + StringPublicKey, + TokenAccount, +} from '@oyster/common'; +import { createMintAndAccountWithOne } from './createMintAndAccountWithOne'; +import { Art } from '../types'; +import { WalletAdapter } from '@solana/wallet-base'; + +export async function setupMintEditionIntoWalletInstructions( + art: Art, + wallet: WalletAdapter, + connection: Connection, + mintTokenAccount: TokenAccount, + edition: BN, + instructions: any, + signers: any, + mintDestination: StringPublicKey, +) { + if (!art.mint) throw new Error('Art mint is not provided'); + if (typeof art.supply === 'undefined') { + throw new Error('Art supply is not provided'); + } + if (!wallet.publicKey) throw new Error('Wallet pubKey is not provided'); + if (!mintTokenAccount) { + throw new Error('Art mint token account is not provided'); + } + const walletPubKey = wallet.publicKey.toString(); + const { mint: tokenMint } = art; + const { pubkey: mintTokenAccountPubKey } = mintTokenAccount; + const mintTokenAccountOwner = mintTokenAccount.info.owner.toString(); + + const mintRentExempt = await connection.getMinimumBalanceForRentExemption( + MintLayout.span, + ); + const { mint: newMint } = await createMintAndAccountWithOne( + wallet, + mintDestination, + mintRentExempt, + instructions, + signers, + ); + + await mintNewEditionFromMasterEditionViaToken( + newMint, + tokenMint, + walletPubKey, + walletPubKey, + mintTokenAccountOwner, + mintTokenAccountPubKey, + instructions, + walletPubKey, + edition, + ); +} diff --git a/js/packages/web/src/components/ArtMinting/index.tsx b/js/packages/web/src/components/ArtMinting/index.tsx new file mode 100644 index 0000000..7f3e156 --- /dev/null +++ b/js/packages/web/src/components/ArtMinting/index.tsx @@ -0,0 +1,248 @@ +import React, { useState, useMemo, useCallback, useEffect } from 'react'; +import { LAMPORTS_PER_SOL, PublicKey } from '@solana/web3.js'; +import { MintLayout, AccountLayout } from '@solana/spl-token'; +import { Button, Form, Input, Modal, InputNumber } from 'antd'; +import debounce from 'lodash/debounce'; +import { + decodeMasterEdition, + MAX_EDITION_LEN, + MAX_METADATA_LEN, + MetadataKey, + MetaplexOverlay, + useConnection, + useUserAccounts, + useWallet, +} from '@oyster/common'; +import { useArt } from '../../hooks'; +import { mintEditionsToWallet } from '../../actions/mintEditionsIntoWallet'; +import { ArtType } from '../../types'; +import { Confetti } from '../Confetti'; +import { Link } from 'react-router-dom'; + +interface ArtMintingProps { + id: string; + onMint: Function; +} + +export const ArtMinting = ({ id, onMint }: ArtMintingProps) => { + const { wallet } = useWallet(); + const connection = useConnection(); + const { accountByMint } = useUserAccounts(); + const [showMintModal, setShowMintModal] = useState(false); + const [showCongrats, setShowCongrats] = useState(false); + const [mintingDestination, setMintingDestination] = useState(''); + const [editions, setEditions] = useState(1); + const [totalCost, setTotalCost] = useState(0); + const [isLoading, setIsLoading] = useState(false); + const art = useArt(id); + + const walletPubKey = wallet?.publicKey?.toString() || ''; + const maxEditionsToMint = art.maxSupply! - art.supply!; + const isArtMasterEdition = art.type === ArtType.Master; + const artMintTokenAccount = accountByMint.get(art.mint!); + const isArtOwnedByUser = + ((accountByMint.has(art.mint!) && + artMintTokenAccount?.info.amount.toNumber()) || + 0) > 0; + const isMasterEditionV1 = artMintTokenAccount + ? decodeMasterEdition(artMintTokenAccount.account.data).key === + MetadataKey.MasterEditionV1 + : false; + const renderMintEdition = + isArtMasterEdition && + isArtOwnedByUser && + !isMasterEditionV1 && + maxEditionsToMint !== 0; + + const mintingDestinationErr = useMemo(() => { + if (!mintingDestination) return 'Required'; + + try { + new PublicKey(mintingDestination); + return ''; + } catch (e) { + return 'Invalid address format'; + } + }, [mintingDestination]); + + const isMintingDisabled = + isLoading || editions < 1 || Boolean(mintingDestinationErr); + + const debouncedEditionsChangeHandler = useCallback( + debounce(val => { + setEditions(val < 1 ? 1 : val); + }, 300), + [], + ); + + useEffect(() => { + if (editions < 1) return; + + (async () => { + const mintRentExempt = await connection.getMinimumBalanceForRentExemption( + MintLayout.span, + ); + const accountRentExempt = + await connection.getMinimumBalanceForRentExemption(AccountLayout.span); + const metadataRentExempt = + await connection.getMinimumBalanceForRentExemption(MAX_METADATA_LEN); + const editionRentExempt = + await connection.getMinimumBalanceForRentExemption(MAX_EDITION_LEN); + + const cost = + ((mintRentExempt + + accountRentExempt + + metadataRentExempt + + editionRentExempt) * + editions) / + LAMPORTS_PER_SOL; + + setTotalCost(cost); + })(); + }, [connection, editions]); + + useEffect(() => { + if (!walletPubKey) return; + + setMintingDestination(walletPubKey); + }, [walletPubKey]); + + useEffect(() => { + return debouncedEditionsChangeHandler.cancel(); + }, []); + + const onSuccessfulMint = () => { + setShowMintModal(false); + setMintingDestination(walletPubKey); + setEditions(1); + setShowCongrats(true); + }; + + const mint = async () => { + try { + setIsLoading(true); + await mintEditionsToWallet( + art, + wallet!, + connection, + artMintTokenAccount!, + editions, + mintingDestination, + ); + onSuccessfulMint(); + } catch (e) { + console.error(e); + } finally { + setIsLoading(false); + } + }; + + return ( + <> + {renderMintEdition && ( +
+ + + setShowMintModal(false)} + > + Mint to} + labelAlign="left" + colon={false} + validateStatus={mintingDestinationErr ? 'error' : 'success'} + help={mintingDestinationErr} + > + { + setMintingDestination(e.target.value); + }} + /> + + + Number of editions to mint} + labelAlign="left" + colon={false} + > + + + +
Total cost: {`◎${totalCost}`}
+
+ + + +

+ Congratulations +

+

+ New editions have been minted please view your NFTs in{' '} + My Items. +

+ +
+
+ )} + + ); +}; diff --git a/js/packages/web/src/views/art/index.tsx b/js/packages/web/src/views/art/index.tsx index bd85cef..772f389 100644 --- a/js/packages/web/src/views/art/index.tsx +++ b/js/packages/web/src/views/art/index.tsx @@ -1,21 +1,33 @@ -import React from 'react'; -import { Row, Col, Divider, Layout, Tag, Button, Skeleton, List, Card } from 'antd'; +import React, { useState } from 'react'; +import { + Row, + Col, + Divider, + Layout, + Tag, + Button, + Skeleton, + List, + Card, +} from 'antd'; import { useParams } from 'react-router-dom'; -import { useArt, useExtendedArt } from './../../hooks'; +import { useArt, useExtendedArt } from '../../hooks'; import { ArtContent } from '../../components/ArtContent'; import { shortenAddress, useConnection } from '@oyster/common'; import { useWallet } from '@solana/wallet-adapter-react'; import { MetaAvatar } from '../../components/MetaAvatar'; import { sendSignMetadata } from '../../actions/sendSignMetadata'; -import { ViewOn } from './../../components/ViewOn'; +import { ViewOn } from '../../components/ViewOn'; import { ArtType } from '../../types'; +import { ArtMinting } from '../../components/ArtMinting'; const { Content } = Layout; export const ArtView = () => { const { id } = useParams<{ id: string }>(); const wallet = useWallet(); + const [remountArtMinting, setRemountArtMinting] = useState(0); const connection = useConnection(); const art = useArt(id); @@ -39,7 +51,7 @@ export const ArtView = () => { const description = data?.description; const attributes = data?.attributes; - const pubkey = wallet.publicKey?.toBase58() || ''; + const pubkey = wallet?.publicKey?.toBase58() || ''; const tag = (
@@ -181,6 +193,13 @@ export const ArtView = () => { > Mark as Sold */} + + {/* TODO: Add conversion of MasterEditionV1 to MasterEditionV2 */} + await setRemountArtMinting(prev => prev + 1)} + /> @@ -197,23 +216,22 @@ export const ArtView = () => {
{art.about}
*/} - {attributes && + {attributes && ( <>
Attributes
- - {attributes.map(attribute => + + {attributes.map(attribute => ( - {attribute.value} + + {attribute.value} + - )} + ))} - } + )} From 2bcd97ac04bcb70e36bc3de0bbfb22e552863393 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Fri, 3 Sep 2021 19:20:06 -0500 Subject: [PATCH 11/26] minor fix to type declaration (#291) --- js/packages/web/src/actions/mintEditionsIntoWallet.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/packages/web/src/actions/mintEditionsIntoWallet.ts b/js/packages/web/src/actions/mintEditionsIntoWallet.ts index 44df303..7ce681e 100644 --- a/js/packages/web/src/actions/mintEditionsIntoWallet.ts +++ b/js/packages/web/src/actions/mintEditionsIntoWallet.ts @@ -9,7 +9,7 @@ import { } from '@oyster/common'; import { setupMintEditionIntoWalletInstructions } from './setupMintEditionIntoWalletInstructions'; import { Art } from '../types'; -import { WalletAdapter } from '@solana/wallet-base'; +import { WalletAdapter } from '@solana/wallet-adapter-base'; // TODO: Refactor. Extract batching logic, // as the similar one is used in settle.ts and convertMasterEditions.ts From 0ba4954762c8ad7a7802cbb03268fce5de932b40 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Fri, 3 Sep 2021 19:37:05 -0500 Subject: [PATCH 12/26] Wallet adapter fix (#292) * minor fix to type declaration * Some more typescript fixes --- js/packages/web/src/actions/mintEditionsIntoWallet.ts | 4 ++-- .../web/src/actions/setupMintEditionIntoWalletInstructions.ts | 4 ++-- js/packages/web/src/components/ArtMinting/index.tsx | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/js/packages/web/src/actions/mintEditionsIntoWallet.ts b/js/packages/web/src/actions/mintEditionsIntoWallet.ts index 7ce681e..29e1fbe 100644 --- a/js/packages/web/src/actions/mintEditionsIntoWallet.ts +++ b/js/packages/web/src/actions/mintEditionsIntoWallet.ts @@ -9,7 +9,7 @@ import { } from '@oyster/common'; import { setupMintEditionIntoWalletInstructions } from './setupMintEditionIntoWalletInstructions'; import { Art } from '../types'; -import { WalletAdapter } from '@solana/wallet-adapter-base'; +import { WalletContextState } from '@solana/wallet-adapter-react'; // TODO: Refactor. Extract batching logic, // as the similar one is used in settle.ts and convertMasterEditions.ts @@ -18,7 +18,7 @@ const BATCH_SIZE = 10; export async function mintEditionsToWallet( art: Art, - wallet: WalletAdapter, + wallet: WalletContextState, connection: Connection, mintTokenAccount: TokenAccount, editions: number = 1, diff --git a/js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts b/js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts index 2c5d5a7..6cca0d9 100644 --- a/js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts +++ b/js/packages/web/src/actions/setupMintEditionIntoWalletInstructions.ts @@ -8,11 +8,11 @@ import { } from '@oyster/common'; import { createMintAndAccountWithOne } from './createMintAndAccountWithOne'; import { Art } from '../types'; -import { WalletAdapter } from '@solana/wallet-base'; +import { WalletContextState } from '@solana/wallet-adapter-react'; export async function setupMintEditionIntoWalletInstructions( art: Art, - wallet: WalletAdapter, + wallet: WalletContextState, connection: Connection, mintTokenAccount: TokenAccount, edition: BN, diff --git a/js/packages/web/src/components/ArtMinting/index.tsx b/js/packages/web/src/components/ArtMinting/index.tsx index 7f3e156..d19b3f6 100644 --- a/js/packages/web/src/components/ArtMinting/index.tsx +++ b/js/packages/web/src/components/ArtMinting/index.tsx @@ -11,13 +11,13 @@ import { MetaplexOverlay, useConnection, useUserAccounts, - useWallet, } from '@oyster/common'; import { useArt } from '../../hooks'; import { mintEditionsToWallet } from '../../actions/mintEditionsIntoWallet'; import { ArtType } from '../../types'; import { Confetti } from '../Confetti'; import { Link } from 'react-router-dom'; +import { useWallet } from '@solana/wallet-adapter-react'; interface ArtMintingProps { id: string; @@ -25,7 +25,7 @@ interface ArtMintingProps { } export const ArtMinting = ({ id, onMint }: ArtMintingProps) => { - const { wallet } = useWallet(); + const wallet = useWallet(); const connection = useConnection(); const { accountByMint } = useUserAccounts(); const [showMintModal, setShowMintModal] = useState(false); From 40cfa295117d50dbf2593b81b9c63f0fcf22a17b Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Sat, 4 Sep 2021 15:32:45 -0500 Subject: [PATCH 13/26] A few candy machine fixes - to uploader and program (#304) --- js/packages/cli/src/cli.ts | 32 ++++++++++++------------------- rust/nft-candy-machine/src/lib.rs | 5 +++-- 2 files changed, 15 insertions(+), 22 deletions(-) diff --git a/js/packages/cli/src/cli.ts b/js/packages/cli/src/cli.ts index 6e18fc3..eea3372 100755 --- a/js/packages/cli/src/cli.ts +++ b/js/packages/cli/src/cli.ts @@ -433,9 +433,10 @@ program } } + const keys = Object.keys(cacheContent.items); try { await Promise.all( - chunks(Array.from(Array(images.length).keys()), 1000).map( + chunks(Array.from(Array(keys.length).keys()), 1000).map( async allIndexesInSlice => { for ( let offset = 0; @@ -444,30 +445,23 @@ program ) { const indexes = allIndexesInSlice.slice(offset, offset + 10); const onChain = indexes.filter(i => { - const index = images[i].replace(extension, '').split('/').pop(); - return cacheContent.items[index].onChain; + const index = keys[i]; + return cacheContent.items[index]?.onChain; }); - const ind = images[indexes[0]] - .replace(extension, '') - .split('/') - .pop(); + const ind = keys[indexes[0]]; if (onChain.length != indexes.length) { console.log( 'Writing indices ', ind, '-', - parseInt(ind) + indexes.length, + keys[indexes[indexes.length - 1]], ); const txId = await anchorProgram.rpc.addConfigLines( ind, indexes.map(i => ({ - uri: cacheContent.items[ - images[i].replace(extension, '').split('/').pop() - ].link, - name: cacheContent.items[ - images[i].replace(extension, '').split('/').pop() - ].name, + uri: cacheContent.items[keys[i]].link, + name: cacheContent.items[keys[i]].name, })), { accounts: { @@ -478,12 +472,8 @@ program }, ); indexes.forEach(i => { - cacheContent.items[ - images[i].replace(extension, '').split('/').pop() - ] = { - ...cacheContent.items[ - images[i].replace(extension, '').split('/').pop() - ], + cacheContent.items[keys[i]] = { + ...cacheContent.items[keys[i]], onChain: true, }; }); @@ -723,6 +713,8 @@ program const config = await solConnection.getAccountInfo( new PublicKey(cachedContent.program.config), ); + const number = new BN(config.data.slice(247, 247 + 4), undefined, 'le'); + console.log('Number', number.toNumber()); const keys = Object.keys(cachedContent.items); for (let i = 0; i < keys.length; i++) { diff --git a/rust/nft-candy-machine/src/lib.rs b/rust/nft-candy-machine/src/lib.rs index cc55bf4..c785abf 100644 --- a/rust/nft-candy-machine/src/lib.rs +++ b/rust/nft-candy-machine/src/lib.rs @@ -351,6 +351,7 @@ pub mod nft_candy_machine { position_from_right ); if old_value_in_vec != data[my_position_in_vec] { + msg!("Increasing count"); new_count = new_count .checked_add(1) .ok_or(ErrorCode::NumericalOverflowError)?; @@ -395,7 +396,7 @@ pub mod nft_candy_machine { } if get_config_count(&ctx.accounts.config.to_account_info().data.borrow())? - != candy_machine.data.items_available as usize + < candy_machine.data.items_available as usize { return Err(ErrorCode::ConfigLineMismatch.into()); } @@ -610,6 +611,6 @@ pub enum ErrorCode { CandyMachineEmpty, #[msg("Candy machine is not live yet!")] CandyMachineNotLiveYet, - #[msg("Number of config lines must match items available")] + #[msg("Number of config lines must be at least number of items available")] ConfigLineMismatch, } From e0f2c1b0689178585517e6c6dd080104887f9955 Mon Sep 17 00:00:00 2001 From: Armani Ferrante Date: Sat, 4 Sep 2021 15:59:44 -0700 Subject: [PATCH 14/26] Update candy machine with anchor v0.14.0 (#283) --- rust/Anchor.toml | 3 + rust/Cargo.lock | 640 +++++++----------------------- rust/nft-candy-machine/Cargo.toml | 3 +- rust/nft-candy-machine/src/lib.rs | 15 +- 4 files changed, 158 insertions(+), 503 deletions(-) diff --git a/rust/Anchor.toml b/rust/Anchor.toml index 829f7c0..7607f4a 100644 --- a/rust/Anchor.toml +++ b/rust/Anchor.toml @@ -5,6 +5,9 @@ url = "https://anchor.projectserum.com" cluster = "localnet" wallet = "~/.config/solana/id.json" +[programs.mainnet] +nft_candy_machine = "cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ" + [scripts] test = "mocha -t 1000000 tests/" diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 3175c1f..5620d4f 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -1,5 +1,7 @@ # This file is automatically @generated by Cargo. # It is not intended for manual editing. +version = 3 + [[package]] name = "Inflector" version = "0.11.4" @@ -48,9 +50,9 @@ checksum = "250f629c0161ad8107cf89319e990051fae62832fd343083bea452d93e2205fd" [[package]] name = "anchor-attribute-access-control" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "35ba6adc8bed8a9b284219ba12489b459ad233679a489edf9642987e6b090473" +checksum = "d71a7ef3d6eb99d9e4586fa99245d1adfc71e68df3032a262ee02dee25919237" dependencies = [ "anchor-syn", "anyhow", @@ -62,9 +64,9 @@ dependencies = [ [[package]] name = "anchor-attribute-account" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab91b688a60b289767724288d73bf5d4fc425438e13d4d4f604a73ab9686c675" +checksum = "ad63b9ca28de653ca0bc735ea7d2768ab619ccd678f06f642da16ea39108e8f2" dependencies = [ "anchor-syn", "anyhow", @@ -75,9 +77,9 @@ dependencies = [ [[package]] name = "anchor-attribute-error" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a7a9215bb3b101f7237c06d5fc873278b82f685bfee95e4ec7e8427ff83c390" +checksum = "b7f013d4fbe3de1f6828e856a7e7c1f47120e05a7f76667981b34efb64b04371" dependencies = [ "anchor-syn", "proc-macro2 1.0.28", @@ -87,9 +89,9 @@ dependencies = [ [[package]] name = "anchor-attribute-event" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3b26d266d84ec0d8097214cf37430b4681e29da0522fbd3fdb0afc6fc16b2313" +checksum = "3ba91ad4e01c7fa5dec530c8950e817ebda38371e63e292705e5bad02ffab4e0" dependencies = [ "anchor-syn", "anyhow", @@ -100,9 +102,9 @@ dependencies = [ [[package]] name = "anchor-attribute-interface" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08e35d76a8f8bc8934acc877c8643ec14ddcb355d423de8f9b7e225fe9824b60" +checksum = "c22614501a321f04070dc8caf145885e5786503e8116dac0663f9e36878df133" dependencies = [ "anchor-syn", "anyhow", @@ -114,9 +116,9 @@ dependencies = [ [[package]] name = "anchor-attribute-program" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8f6e8a3822e58df25ef45125a6dbe5ceeefebea68954f22beeeff83e4bd040a4" +checksum = "6e3f8ef5378318b4ce699bc7998e9b34698374b16a68675493ecb75d0192ef3e" dependencies = [ "anchor-syn", "anyhow", @@ -127,9 +129,9 @@ dependencies = [ [[package]] name = "anchor-attribute-state" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "86586d43cf7e0f10431e018c72f51cfc60d1ce3323df44249ff3a70a45168b20" +checksum = "e5363d1b812c8a85bc080132b57402e9b2d2d30c734dadba0f075e5de65d122b" dependencies = [ "anchor-syn", "anyhow", @@ -140,9 +142,9 @@ dependencies = [ [[package]] name = "anchor-derive-accounts" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "85aa313d4317811983cab3e7a66ede358c4eb3f1fe47acf51a6078cd239bdbe7" +checksum = "494696ea2500856baca41aeee7da07cf85883a2e11d9f912255e088d2b4a0dea" dependencies = [ "anchor-syn", "anyhow", @@ -153,9 +155,9 @@ dependencies = [ [[package]] name = "anchor-lang" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e0b300d7222b786b7947bd1c14ab82a6c519fa1bbce4ed0f0ffe4db1e6c05669" +checksum = "6e209e7e6fc0dfff1b5697a245ee854151e71ad3ef700fa49019c2201011e056" dependencies = [ "anchor-attribute-access-control", "anchor-attribute-account", @@ -174,9 +176,9 @@ dependencies = [ [[package]] name = "anchor-syn" -version = "0.13.2" +version = "0.14.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "833a32a3945814ecd8b6fdcb8666580e69037fe2efc4eaa4a9c68b1940450505" +checksum = "93cd94aadc922965d9eb5d49f266c9450f3d5666f5a3e9648996cb7fe91d61e8" dependencies = [ "anyhow", "bs58", @@ -197,7 +199,7 @@ version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ee49baf6cb617b853aa8d93bf420db2383fab46d314482ca2803b40d5fde979b" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -249,7 +251,7 @@ checksum = "d9b39be18770d11421cdb1b9947a45dd3f37e93092cbf377614828a319d5fee8" dependencies = [ "hermit-abi", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -526,7 +528,7 @@ dependencies = [ "num-traits", "serde", "time", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -588,7 +590,7 @@ dependencies = [ "terminal_size", "termios", "unicode-width", - "winapi 0.3.9", + "winapi", "winapi-util", ] @@ -604,7 +606,7 @@ dependencies = [ "regex", "terminal_size", "unicode-width", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -667,17 +669,6 @@ dependencies = [ "crossbeam-utils 0.8.5", ] -[[package]] -name = "crossbeam-deque" -version = "0.7.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c20ff29ded3204c5106278a81a38f4b482636ed4fa1e6cfbeef193291beb29ed" -dependencies = [ - "crossbeam-epoch 0.8.2", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - [[package]] name = "crossbeam-deque" version = "0.8.1" @@ -685,25 +676,10 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "6455c0ca19f0d2fbf751b908d5c55c1f5cbc65e03c4225427254b46890bdde1e" dependencies = [ "cfg-if 1.0.0", - "crossbeam-epoch 0.9.5", + "crossbeam-epoch", "crossbeam-utils 0.8.5", ] -[[package]] -name = "crossbeam-epoch" -version = "0.8.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "058ed274caafc1f60c4997b5fc07bf7dc7cca454af7c6e81edffe5f33f70dace" -dependencies = [ - "autocfg", - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "lazy_static", - "maybe-uninit", - "memoffset 0.5.6", - "scopeguard", -] - [[package]] name = "crossbeam-epoch" version = "0.9.5" @@ -713,21 +689,10 @@ dependencies = [ "cfg-if 1.0.0", "crossbeam-utils 0.8.5", "lazy_static", - "memoffset 0.6.4", + "memoffset", "scopeguard", ] -[[package]] -name = "crossbeam-queue" -version = "0.2.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "774ba60a54c213d409d5353bda12d49cd68d14e45036a285234c8d6f91f92570" -dependencies = [ - "cfg-if 0.1.10", - "crossbeam-utils 0.7.2", - "maybe-uninit", -] - [[package]] name = "crossbeam-utils" version = "0.7.2" @@ -898,7 +863,7 @@ checksum = "4ebda144c4fe02d1f7ea1a7d9641b6fc6b580adcfa024ae48797ecdeb6825b4d" dependencies = [ "libc", "redox_users", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1047,7 +1012,7 @@ dependencies = [ "cfg-if 1.0.0", "libc", "redox_syscall 0.2.10", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1093,28 +1058,6 @@ dependencies = [ "percent-encoding", ] -[[package]] -name = "fuchsia-zircon" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2e9763c69ebaae630ba35f74888db465e49e259ba1bc0eda7d06f4a067615d82" -dependencies = [ - "bitflags", - "fuchsia-zircon-sys", -] - -[[package]] -name = "fuchsia-zircon-sys" -version = "0.3.3" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" - -[[package]] -name = "futures" -version = "0.1.31" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3a471a38ef8ed83cd6e40aa59c1ffe17db6855c18e3604d9c4ed8c08ebc28678" - [[package]] name = "futures" version = "0.3.16" @@ -1236,7 +1179,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "e692e296bfac1d2533ef168d0b60ff5897b8b70a4009276834014dd8924cc028" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1298,7 +1241,7 @@ dependencies = [ "http", "indexmap", "slab", - "tokio 1.10.1", + "tokio", "tokio-util", "tracing", ] @@ -1461,7 +1404,7 @@ dependencies = [ "itoa", "pin-project-lite", "socket2 0.4.1", - "tokio 1.10.1", + "tokio", "tower-service", "tracing", "want", @@ -1477,7 +1420,7 @@ dependencies = [ "hyper", "log", "rustls", - "tokio 1.10.1", + "tokio", "tokio-rustls", "webpki", ] @@ -1583,11 +1526,11 @@ dependencies = [ [[package]] name = "jsonrpc-core" -version = "17.1.0" +version = "18.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d4467ab6dfa369b69e52bd0692e480c4d117410538526a57a304a0f2250fd95e" +checksum = "14f7f76aef2d054868398427f6c54943cf3d1caa9a7ec7d0c38d69df97a965eb" dependencies = [ - "futures 0.3.16", + "futures", "futures-executor", "futures-util", "log", @@ -1602,16 +1545,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "67c21572b4949434e4fc1e1978b99c5f77064153c59d998bf13ecd96fb5ecba7" -[[package]] -name = "kernel32-sys" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7507624b29483431c0ba2d82aece8ca6cdba9382bff4ddd0f7490560c056098d" -dependencies = [ - "winapi 0.2.8", - "winapi-build", -] - [[package]] name = "lazy_static" version = "1.4.0" @@ -1634,7 +1567,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "351a32417a12d5f7e82c368a66781e307834dae04c6ce0cd4456d52989229883" dependencies = [ "cfg-if 1.0.0", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1745,15 +1678,6 @@ dependencies = [ "libc", ] -[[package]] -name = "memoffset" -version = "0.5.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "043175f069eda7b85febe4a74abbaeff828d9f8b448515d3151a14a3542811aa" -dependencies = [ - "autocfg", -] - [[package]] name = "memoffset" version = "0.6.4" @@ -1779,25 +1703,6 @@ dependencies = [ "autocfg", ] -[[package]] -name = "mio" -version = "0.6.23" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4afd66f5b91bf2a3bc13fad0e21caedac168ca4c707504e75585648ae80e4cc4" -dependencies = [ - "cfg-if 0.1.10", - "fuchsia-zircon", - "fuchsia-zircon-sys", - "iovec", - "kernel32-sys", - "libc", - "log", - "miow 0.2.2", - "net2", - "slab", - "winapi 0.2.8", -] - [[package]] name = "mio" version = "0.7.13" @@ -1806,32 +1711,9 @@ checksum = "8c2bdb6314ec10835cd3293dd268473a835c02b7b352e788be788b3c6ca6bb16" dependencies = [ "libc", "log", - "miow 0.3.7", + "miow", "ntapi", - "winapi 0.3.9", -] - -[[package]] -name = "mio-uds" -version = "0.6.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "afcb699eb26d4332647cc848492bbc15eafb26f08d0304550d5aa1f612e066f0" -dependencies = [ - "iovec", - "libc", - "mio 0.6.23", -] - -[[package]] -name = "miow" -version = "0.2.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ebd808424166322d4a38da87083bfddd3ac4c131334ed55856112eb06d46944d" -dependencies = [ - "kernel32-sys", - "net2", - "winapi 0.2.8", - "ws2_32-sys", + "winapi", ] [[package]] @@ -1840,7 +1722,7 @@ version = "0.3.7" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b9f1c5b025cda876f66ef43a113f91ebc9f4ccef34843000e0adf6ebbab84e21" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1869,7 +1751,7 @@ checksum = "391630d12b68002ae1e25e8f974306474966550ad82dac6886fb8910c19568ae" dependencies = [ "cfg-if 0.1.10", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -1900,7 +1782,7 @@ version = "0.3.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3f6bb902e437b6d86e03cce10a7e2af662292c5dfef23b65899ea3ac9354ad44" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2115,17 +1997,6 @@ dependencies = [ "syn 1.0.75", ] -[[package]] -name = "parking_lot" -version = "0.9.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f842b1982eb6c2fe34036a4fbfb06dd185a3f5c8edfaacdf7d1ea10b07de6252" -dependencies = [ - "lock_api 0.3.4", - "parking_lot_core 0.6.2", - "rustc_version", -] - [[package]] name = "parking_lot" version = "0.10.2" @@ -2147,21 +2018,6 @@ dependencies = [ "parking_lot_core 0.8.5", ] -[[package]] -name = "parking_lot_core" -version = "0.6.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b876b1b9e7ac6e1a74a6da34d25c42e17e8862aa409cbbbdcfc8d86c6f3bc62b" -dependencies = [ - "cfg-if 0.1.10", - "cloudabi", - "libc", - "redox_syscall 0.1.57", - "rustc_version", - "smallvec 0.6.14", - "winapi 0.3.9", -] - [[package]] name = "parking_lot_core" version = "0.7.2" @@ -2172,8 +2028,8 @@ dependencies = [ "cloudabi", "libc", "redox_syscall 0.1.57", - "smallvec 1.6.1", - "winapi 0.3.9", + "smallvec", + "winapi", ] [[package]] @@ -2186,8 +2042,8 @@ dependencies = [ "instant", "libc", "redox_syscall 0.2.10", - "smallvec 1.6.1", - "winapi 0.3.9", + "smallvec", + "winapi", ] [[package]] @@ -2484,7 +2340,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c06aca804d41dbc8ba42dfd964f0d01334eceb64314b9ecf7c5fad5188a06d90" dependencies = [ "autocfg", - "crossbeam-deque 0.8.1", + "crossbeam-deque", "either", "rayon-core", ] @@ -2496,7 +2352,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d78120e2c850279833f1dd3582f730c4ab53ed95aeaaaa862a2a5c71b1656d8e" dependencies = [ "crossbeam-channel 0.5.1", - "crossbeam-deque 0.8.1", + "crossbeam-deque", "crossbeam-utils 0.8.5", "lazy_static", "num_cpus", @@ -2550,7 +2406,7 @@ version = "0.5.3" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3acd125665422973a33ac9d3dd2df85edad0f4ae9b00dafb1a05e43a9f5ef8e7" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2579,7 +2435,7 @@ dependencies = [ "serde", "serde_json", "serde_urlencoded", - "tokio 1.10.1", + "tokio", "tokio-rustls", "url", "wasm-bindgen", @@ -2601,7 +2457,7 @@ dependencies = [ "spin", "untrusted", "web-sys", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2611,7 +2467,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99371657d3c8e4d816fb6221db98fa408242b0b53bac08f8676a41f8554fe99f" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2676,7 +2532,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8f05ba609c234e60bee0d547fe94a4c7e9da733d1c962cf6e59efa4cd9c8bc75" dependencies = [ "lazy_static", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2894,15 +2750,6 @@ version = "0.4.4" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "c307a32c1c5c437f38c7fd45d753050587732ba8628319fbdf12a7e289ccc590" -[[package]] -name = "smallvec" -version = "0.6.14" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b97fcaeba89edba30f044a10c6a3cc39df9c3f17d7cd829dd1446cab35f890e0" -dependencies = [ - "maybe-uninit", -] - [[package]] name = "smallvec" version = "1.6.1" @@ -2917,7 +2764,7 @@ checksum = "122e570113d28d773067fab24266b66753f6ea915758651696b6e35e49f88d6e" dependencies = [ "cfg-if 1.0.0", "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -2927,14 +2774,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "765f090f0e423d2b55843402a07915add955e7d60657db13707a159727326cad" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] name = "solana-account-decoder" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a67e4a537eccc21f8b942f60990d57f76980638db834161747e47cfba4b8f050" +checksum = "d89741082d52115e1d866befdf65a9c3197c50734b998f75cfb0a291c3555738" dependencies = [ "Inflector", "base64 0.12.3", @@ -2955,30 +2802,30 @@ dependencies = [ [[package]] name = "solana-banks-client" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a51c83e33eb5fc2a688db5e7e19a8c5b481385e1d9f30b012962e9bcdb002629" +checksum = "15e2822ab4ddf7a9de1c190f817274922efcdc9cb00cd4bb3d5cb4a045f458e7" dependencies = [ "bincode", "borsh", "borsh-derive", - "futures 0.3.16", - "mio 0.7.13", + "futures", + "mio", "solana-banks-interface", "solana-program", "solana-sdk", "tarpc", - "tokio 1.10.1", + "tokio", "tokio-serde", ] [[package]] name = "solana-banks-interface" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f73a34a243df509dfde8fe42129aa34a3db9913e90b7c7eb290f597361016268" +checksum = "ec2a702be6df37c117b2b9cadc90508eaad3ad03004873d4e5ef434fd6b9788a" dependencies = [ - "mio 0.7.13", + "mio", "serde", "solana-sdk", "tarpc", @@ -2986,29 +2833,29 @@ dependencies = [ [[package]] name = "solana-banks-server" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3929ed2f73a4a9c80ddff4b1b49ecc81fa6e8689ca475e9e625034aaebc22516" +checksum = "e4f44e5b8eef83073dc34847fb8cd33297caf706b6c7ada80440e0b50839d907" dependencies = [ "bincode", - "futures 0.3.16", + "futures", "log", - "mio 0.7.13", + "mio", "solana-banks-interface", "solana-metrics", "solana-runtime", "solana-sdk", "tarpc", - "tokio 1.10.1", + "tokio", "tokio-serde", "tokio-stream", ] [[package]] name = "solana-bpf-loader-program" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d848ee15b984d2703750a52e3cbe23024256184b11426a1677bc98934087f8c7" +checksum = "44b703485a6f497d91fa76cd3111bee638a494c69b7508efdbbcedf7d4cb3f5e" dependencies = [ "bincode", "byteorder", @@ -3027,9 +2874,9 @@ dependencies = [ [[package]] name = "solana-clap-utils" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97d2792f093f28b0a7403443225494c0d75215253784897a6f8b8e6fb83ce91a" +checksum = "1ff790bd97dee3be05ec879b176875f0bb0ef0eb62e5e11e6b269a2d7dc8bf10" dependencies = [ "chrono", "clap", @@ -3044,9 +2891,9 @@ dependencies = [ [[package]] name = "solana-cli-config" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d1c3982b00bf2ac283c86e760aae127d395ab8b610cc3690a0a6ff500ae561e7" +checksum = "6eb21cb2d46661d9e549293ce2ec4e4afa7205b66562e3768e16f5fe737f420f" dependencies = [ "dirs-next", "lazy_static", @@ -3058,9 +2905,9 @@ dependencies = [ [[package]] name = "solana-client" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "023263a79a3356532549c9e0555c6e1b2a2e94205b5d58c7041703bbd455133d" +checksum = "779f90ee9f77c831426af58c9732902051314bb8f2607473ffd6089a3b008133" dependencies = [ "base64 0.13.0", "bincode", @@ -3085,16 +2932,16 @@ dependencies = [ "solana-version", "solana-vote-program", "thiserror", - "tokio 1.10.1", + "tokio", "tungstenite", "url", ] [[package]] name = "solana-config-program" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9b5348055cf52ab01efc1578d4159ec40bb39c3913df4365787c3e1382c101c1" +checksum = "e6cebea98645f683ed9bf32f7f1e50a643479ab85fc8e6ba1c287a4562f534a4" dependencies = [ "bincode", "chrono", @@ -3107,9 +2954,9 @@ dependencies = [ [[package]] name = "solana-crate-features" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5c9b446eea7a5af7d4631ce3fd0625439fdc68eda4557223233f1c6bba3e847a" +checksum = "23f7002fb7a602e75e9f077ba8aab67fff49e24327b958280648e731dab894a6" dependencies = [ "backtrace", "bytes 0.4.12", @@ -3126,15 +2973,14 @@ dependencies = [ "serde", "syn 0.15.44", "syn 1.0.75", - "tokio 0.1.22", - "winapi 0.3.9", + "winapi", ] [[package]] name = "solana-faucet" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d58750a03b49940f486c0dcb5744bb6ee5da82ced6636000a90af7618a67dd1b" +checksum = "45ce6d1994d0bdcb0571eeaad0718c540b89b626c24df2bdf6987f80837af4c5" dependencies = [ "bincode", "byteorder", @@ -3150,14 +2996,14 @@ dependencies = [ "solana-version", "spl-memo", "thiserror", - "tokio 1.10.1", + "tokio", ] [[package]] name = "solana-frozen-abi" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "45c6760c1dd139c202ef6df28bff467c904aa35b1aa1a59be268c47aec8bc6c0" +checksum = "21ddfc2b65a555c0e0156c043bce092d473bc4f00daa7ca3c223d97d92d2e807" dependencies = [ "bs58", "bv", @@ -3175,9 +3021,9 @@ dependencies = [ [[package]] name = "solana-frozen-abi-macro" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a4dbe296c16dec41e8e6f4e6c2694c6224820d34c0ab11a2d3ff9683f44878ef" +checksum = "a876aa31298fdee6560c8ee0695ebed313bbdbb6fbbee439ac3b9df8aebfb87c" dependencies = [ "proc-macro2 1.0.28", "quote 1.0.9", @@ -3187,9 +3033,9 @@ dependencies = [ [[package]] name = "solana-logger" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80af1959b520c0fc99bc6583ba9d82bfa15b1ac007516795bceeb4a951af77c7" +checksum = "98a07290cc521e529bff0b0afd3aacd1d3904a41f35321ede6d1f3574efa3e94" dependencies = [ "env_logger", "lazy_static", @@ -3198,9 +3044,9 @@ dependencies = [ [[package]] name = "solana-measure" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "db2915d20f35948b35deffa8624cb189385f13758bd171d8d4a966ae8bf360a4" +checksum = "b5ab24cb5a8fb2fdb32e151606e6a954a6d6e4d764102eb96616cb895622d284" dependencies = [ "log", "solana-metrics", @@ -3209,9 +3055,9 @@ dependencies = [ [[package]] name = "solana-metrics" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8d87867f1f9e399274e08902eb72c9158bef5399e2566161dbe831abeaaa7d14" +checksum = "a49cfd9ec1637885f80d0ac33cf71c685fe13bad6de2bfd469e8aa7dc39967a3" dependencies = [ "env_logger", "gethostname", @@ -3223,9 +3069,9 @@ dependencies = [ [[package]] name = "solana-net-utils" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc7dd877b66b4436b9fcb6d2c2e6055a1dd18b0dcf5938ea1f20efa0b7f09159" +checksum = "2be3ee1237d9013cbd11f0d0af69a4473c703b700165e6c39b49cf0c0554d6f9" dependencies = [ "bincode", "clap", @@ -3239,15 +3085,15 @@ dependencies = [ "solana-logger", "solana-sdk", "solana-version", - "tokio 1.10.1", + "tokio", "url", ] [[package]] name = "solana-program" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fe5e5dd99d642b5e89eeb20457310c3c23f20dbf44e67c64e473a02fbc50d646" +checksum = "49ffc60d33a318300682e42d28ff4f1276327f6374cab9591c8620a54be7aec1" dependencies = [ "bincode", "blake3", @@ -3280,9 +3126,9 @@ dependencies = [ [[package]] name = "solana-program-test" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "20a2961354afb2ef3ed35ec477961f1f6f0113291c83b993a30382180c496d96" +checksum = "692786837dcb915006b39f3e91b1771abc06e3dee4db478400817b436eeac73a" dependencies = [ "async-trait", "base64 0.12.3", @@ -3290,7 +3136,7 @@ dependencies = [ "chrono", "chrono-humanize", "log", - "mio 0.7.13", + "mio", "serde", "serde_derive", "solana-banks-client", @@ -3301,14 +3147,14 @@ dependencies = [ "solana-sdk", "solana-vote-program", "thiserror", - "tokio 1.10.1", + "tokio", ] [[package]] name = "solana-rayon-threadlimit" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "30c3a0037afa0b03e0aad9f8fb451d1008d5538023919835cf86c9833bc93103" +checksum = "e0375eae0722ae7303dbc5ce024104155b851017f31d7bc5096a871153540561" dependencies = [ "lazy_static", "num_cpus", @@ -3316,9 +3162,9 @@ dependencies = [ [[package]] name = "solana-remote-wallet" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "083d31e6510a746ecc4ce8d151a232324056c7a124a218948060947b668d6db8" +checksum = "c2cfa60250c3f8f1c2de9258d35202021ddf1379a24a5820ec813de392af3d94" dependencies = [ "base32", "console 0.14.1", @@ -3337,9 +3183,9 @@ dependencies = [ [[package]] name = "solana-runtime" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f047727075c3434f17d33467bd26033fea3b4e71e7c23caa261015507b162581" +checksum = "58793cb7e9a2996ad3785816f58fddb7e29be245e6c12d0db62d8b4c6f6d17c2" dependencies = [ "arrayref", "bincode", @@ -3388,9 +3234,9 @@ dependencies = [ [[package]] name = "solana-sdk" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0048d346fdf3629dca2bccc2ed63320da9d0291c32b816911ed63d34c65286a5" +checksum = "95179bc7d87c5b61c86f3bbbac4e52a5d909432473593d33546e4f20dc582052" dependencies = [ "assert_matches", "bincode", @@ -3437,9 +3283,9 @@ dependencies = [ [[package]] name = "solana-sdk-macro" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fee909dcddb5b4d349b3e5e1ae92f6660cd2f783dea392ae2e73210776aadc9b" +checksum = "b453dca160617b1676c47e3cfd4361f455dc5bb1c93659ec84b0c5d566b5c039" dependencies = [ "bs58", "proc-macro2 1.0.28", @@ -3450,18 +3296,18 @@ dependencies = [ [[package]] name = "solana-secp256k1-program" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd4c29c6b269800898610da38de45d28fd56b24cb4030c588ffd6acc11a7443" +checksum = "389178c92126e1e85189414688f93e9be836272bbe6ab03db04c804921eb09bd" dependencies = [ "solana-sdk", ] [[package]] name = "solana-stake-program" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3c01fa18bedd1773c9abf86fc58b87ed6e1117ce9f42c9a703becc1d351d810d" +checksum = "2e690a0aed0ff8c854ee79ec9c437756f9c0a24cdb0c1d0e979b60db8b6a4513" dependencies = [ "bincode", "log", @@ -3481,9 +3327,9 @@ dependencies = [ [[package]] name = "solana-transaction-status" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b6ea7cfdeff6ff1fba74096f3bb94688f0fdb780524e08676323108352532dfa" +checksum = "692b993f3e2ee1d3ffd9eb50e079bc9cc702d6a3a833d0c2c14a46d9268ea750" dependencies = [ "Inflector", "base64 0.12.3", @@ -3505,9 +3351,9 @@ dependencies = [ [[package]] name = "solana-version" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "978569fec8c913d798f5e3dad2c8b6d03a6a30e8e04da633ac356ddde832f933" +checksum = "de8d410e68becf2a80a582caa46349dca6959ecf1319fe722a11a33e46af229b" dependencies = [ "log", "rustc_version", @@ -3521,9 +3367,9 @@ dependencies = [ [[package]] name = "solana-vote-program" -version = "1.7.8" +version = "1.7.11" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "506df67749a343d9f9a48b7b5566faf2bc43d0611b520467664a58cd78d4b1be" +checksum = "4cc0bed4119e725a813a56ace42738ab5bbfbfc36152b169bd957ae38e62543a" dependencies = [ "bincode", "log", @@ -3812,7 +3658,7 @@ checksum = "e325774dd5b35d979e9f4db2b0f0d7d85dc2ff2b676a3150af56c09eafc14b07" dependencies = [ "anyhow", "fnv", - "futures 0.3.16", + "futures", "humantime", "log", "pin-project", @@ -3820,7 +3666,7 @@ dependencies = [ "serde", "static_assertions", "tarpc-plugins", - "tokio 1.10.1", + "tokio", "tokio-serde", "tokio-util", ] @@ -3847,7 +3693,7 @@ dependencies = [ "rand 0.8.4", "redox_syscall 0.2.10", "remove_dir_all", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -3866,7 +3712,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "633c1a546cee861a1a6d0dc69ebeca693bf4296661ba7852b9d21d159e0506df" dependencies = [ "libc", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -3915,7 +3761,7 @@ checksum = "6db9e6914ab8b1ae1c260a4ae7a49b6c5611b40328a735b21862567685e73255" dependencies = [ "libc", "wasi 0.10.0+wasi-snapshot-preview1", - "winapi 0.3.9", + "winapi", ] [[package]] @@ -3951,30 +3797,6 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "cda74da7e1a664f795bb1f8a87ec406fb89a02522cf6e50620d016add6dbbf5c" -[[package]] -name = "tokio" -version = "0.1.22" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5a09c0b5bb588872ab2f09afa13ee6e9dac11e10a0ec9e8e3ba39a5a5d530af6" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "mio 0.6.23", - "num_cpus", - "tokio-codec", - "tokio-current-thread", - "tokio-executor", - "tokio-fs", - "tokio-io", - "tokio-reactor", - "tokio-sync", - "tokio-tcp", - "tokio-threadpool", - "tokio-timer", - "tokio-udp", - "tokio-uds", -] - [[package]] name = "tokio" version = "1.10.1" @@ -3985,67 +3807,14 @@ dependencies = [ "bytes 1.1.0", "libc", "memchr", - "mio 0.7.13", + "mio", "num_cpus", "once_cell", "parking_lot 0.11.2", "pin-project-lite", "signal-hook-registry", "tokio-macros", - "winapi 0.3.9", -] - -[[package]] -name = "tokio-codec" -version = "0.1.2" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "25b2998660ba0e70d18684de5d06b70b70a3a747469af9dea7618cc59e75976b" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "tokio-io", -] - -[[package]] -name = "tokio-current-thread" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1de0e32a83f131e002238d7ccde18211c0a5397f60cbfffcb112868c2e0e20e" -dependencies = [ - "futures 0.1.31", - "tokio-executor", -] - -[[package]] -name = "tokio-executor" -version = "0.1.10" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fb2d1b8f4548dbf5e1f7818512e9c406860678f29c300cdf0ebac72d1a3a1671" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.31", -] - -[[package]] -name = "tokio-fs" -version = "0.1.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "297a1206e0ca6302a0eed35b700d292b275256f596e2f3fea7729d5e629b6ff4" -dependencies = [ - "futures 0.1.31", - "tokio-io", - "tokio-threadpool", -] - -[[package]] -name = "tokio-io" -version = "0.1.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "57fc868aae093479e3131e3d165c93b1c7474109d13c90ec0dda2a1bbfff0674" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "log", + "winapi", ] [[package]] @@ -4059,25 +3828,6 @@ dependencies = [ "syn 1.0.75", ] -[[package]] -name = "tokio-reactor" -version = "0.1.12" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "09bc590ec4ba8ba87652da2068d150dcada2cfa2e07faae270a5e0409aa51351" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.31", - "lazy_static", - "log", - "mio 0.6.23", - "num_cpus", - "parking_lot 0.9.0", - "slab", - "tokio-executor", - "tokio-io", - "tokio-sync", -] - [[package]] name = "tokio-rustls" version = "0.22.0" @@ -4085,7 +3835,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "bc6844de72e57df1980054b38be3a9f4702aba4858be64dd700181a8a6d0e1b6" dependencies = [ "rustls", - "tokio 1.10.1", + "tokio", "webpki", ] @@ -4113,93 +3863,7 @@ checksum = "7b2f3f698253f03119ac0102beaa64f67a67e08074d03a22d18784104543727f" dependencies = [ "futures-core", "pin-project-lite", - "tokio 1.10.1", -] - -[[package]] -name = "tokio-sync" -version = "0.1.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "edfe50152bc8164fcc456dab7891fa9bf8beaf01c5ee7e1dd43a397c3cf87dee" -dependencies = [ - "fnv", - "futures 0.1.31", -] - -[[package]] -name = "tokio-tcp" -version = "0.1.4" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "98df18ed66e3b72e742f185882a9e201892407957e45fbff8da17ae7a7c51f72" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "iovec", - "mio 0.6.23", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-threadpool" -version = "0.1.18" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "df720b6581784c118f0eb4310796b12b1d242a7eb95f716a8367855325c25f89" -dependencies = [ - "crossbeam-deque 0.7.4", - "crossbeam-queue", - "crossbeam-utils 0.7.2", - "futures 0.1.31", - "lazy_static", - "log", - "num_cpus", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-timer" -version = "0.2.13" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "93044f2d313c95ff1cb7809ce9a7a05735b012288a888b62d4434fd58c94f296" -dependencies = [ - "crossbeam-utils 0.7.2", - "futures 0.1.31", - "slab", - "tokio-executor", -] - -[[package]] -name = "tokio-udp" -version = "0.1.6" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e2a0b10e610b39c38b031a2fcab08e4b82f16ece36504988dcbd81dbba650d82" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "log", - "mio 0.6.23", - "tokio-codec", - "tokio-io", - "tokio-reactor", -] - -[[package]] -name = "tokio-uds" -version = "0.2.7" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ab57a4ac4111c8c9dbcf70779f6fc8bc35ae4b2454809febac840ad19bd7e4e0" -dependencies = [ - "bytes 0.4.12", - "futures 0.1.31", - "iovec", - "libc", - "log", - "mio 0.6.23", - "mio-uds", - "tokio-codec", - "tokio-io", - "tokio-reactor", + "tokio", ] [[package]] @@ -4213,7 +3877,7 @@ dependencies = [ "futures-sink", "log", "pin-project-lite", - "tokio 1.10.1", + "tokio", ] [[package]] @@ -4402,7 +4066,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "808cf2735cd4b6866113f648b791c6adc5714537bc222d9347bb203386ffda56" dependencies = [ "same-file", - "winapi 0.3.9", + "winapi", "winapi-util", ] @@ -4525,12 +4189,6 @@ dependencies = [ "webpki", ] -[[package]] -name = "winapi" -version = "0.2.8" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "167dc9d6949a9b857f3451275e911c3f44255842c1f7a76f33c55103a909087a" - [[package]] name = "winapi" version = "0.3.9" @@ -4541,12 +4199,6 @@ dependencies = [ "winapi-x86_64-pc-windows-gnu", ] -[[package]] -name = "winapi-build" -version = "0.1.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "2d315eee3b34aca4797b2da6b13ed88266e6d612562a0c46390af8299fc699bc" - [[package]] name = "winapi-i686-pc-windows-gnu" version = "0.4.0" @@ -4559,7 +4211,7 @@ version = "0.1.5" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "70ec6ce85bb158151cae5e5c87f95a8e97d2c0c4b001223f33a334e3ce5de178" dependencies = [ - "winapi 0.3.9", + "winapi", ] [[package]] @@ -4574,17 +4226,7 @@ version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0120db82e8a1e0b9fb3345a539c478767c0048d842860994d96113d5b667bd69" dependencies = [ - "winapi 0.3.9", -] - -[[package]] -name = "ws2_32-sys" -version = "0.2.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d59cefebd0c892fa2dd6de581e937301d8552cb44489cdff035c6187cb63fa5e" -dependencies = [ - "winapi 0.2.8", - "winapi-build", + "winapi", ] [[package]] diff --git a/rust/nft-candy-machine/Cargo.toml b/rust/nft-candy-machine/Cargo.toml index 8bb8a28..f352495 100644 --- a/rust/nft-candy-machine/Cargo.toml +++ b/rust/nft-candy-machine/Cargo.toml @@ -15,8 +15,7 @@ cpi = ["no-entrypoint"] default = [] [dependencies] -anchor-lang = "0.13.2" +anchor-lang = "0.14.0" arrayref = "0.3.6" spl-token = { version="3.1.1", features = [ "no-entrypoint" ] } spl-token-metadata = { path = "../token-metadata/program", features = [ "no-entrypoint" ] } - diff --git a/rust/nft-candy-machine/src/lib.rs b/rust/nft-candy-machine/src/lib.rs index c785abf..d45c177 100644 --- a/rust/nft-candy-machine/src/lib.rs +++ b/rust/nft-candy-machine/src/lib.rs @@ -451,7 +451,13 @@ pub struct AddConfigLines<'info> { #[derive(Accounts)] pub struct MintNFT<'info> { config: ProgramAccount<'info, Config>, - #[account(mut, has_one = config, has_one = wallet, seeds=[PREFIX.as_bytes(), config.key().as_ref(), candy_machine.data.uuid.as_bytes(), &[candy_machine.bump]])] + #[account( + mut, + has_one = config, + has_one = wallet, + seeds = [PREFIX.as_bytes(), config.key().as_ref(), candy_machine.data.uuid.as_bytes()], + bump = candy_machine.bump, + )] candy_machine: ProgramAccount<'info, CandyMachine>, #[account(mut, signer)] payer: AccountInfo<'info>, @@ -481,7 +487,12 @@ pub struct MintNFT<'info> { #[derive(Accounts)] pub struct UpdateCandyMachine<'info> { - #[account(mut, has_one=authority, seeds=[PREFIX.as_bytes(), candy_machine.config.key().as_ref(), candy_machine.data.uuid.as_bytes(), &[candy_machine.bump]])] + #[account( + mut, + has_one = authority, + seeds = [PREFIX.as_bytes(), candy_machine.config.key().as_ref(), candy_machine.data.uuid.as_bytes()], + bump = candy_machine.bump + )] candy_machine: ProgramAccount<'info, CandyMachine>, #[account(signer)] authority: AccountInfo<'info>, From f27ffb39a7386e25b8ec78037c49a9a37d176c69 Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Mon, 30 Aug 2021 16:04:31 +0300 Subject: [PATCH 15/26] Fix: eslint configuration + fix and reformat existing code + eslint as step for lint-staged I --- .gitignore | 1 + js/.eslintrc.js | 33 ++++ js/package.json | 4 +- js/packages/common/src/actions/metadata.ts | 1 + js/packages/common/src/contracts/token.ts | 15 +- js/packages/common/src/models/account.ts | 2 +- js/packages/common/src/utils/ids.ts | 2 +- js/packages/common/src/utils/shortvec.ts | 2 +- js/packages/common/src/utils/strings.ts | 2 +- js/packages/common/src/utils/utils.ts | 12 +- js/packages/web/package.json | 3 - .../web/src/actions/addTokensToVault.ts | 8 +- js/packages/web/src/actions/cancelBid.ts | 12 +- .../web/src/actions/claimUnusedPrizes.ts | 22 +-- .../web/src/actions/closePersonalEscrow.ts | 4 +- js/packages/web/src/actions/closeVault.ts | 6 +- .../web/src/actions/convertMasterEditions.ts | 8 +- .../web/src/actions/createAuctionManager.ts | 34 ++-- .../src/actions/createExternalPriceAccount.ts | 10 +- js/packages/web/src/actions/createVault.ts | 6 +- .../decommAuctionManagerAndReturnPrizes.ts | 9 +- ...precatedCreateReservationListsForTokens.ts | 4 +- .../deprecatedPopulatePrintingTokens.ts | 6 +- js/packages/web/src/actions/makeAuction.ts | 4 +- .../actions/markItemsThatArentMineAsSold.ts | 6 +- js/packages/web/src/actions/saveAdmin.ts | 12 +- js/packages/web/src/actions/sendPlaceBid.ts | 14 +- js/packages/web/src/actions/sendRedeemBid.ts | 61 ++++---- .../web/src/actions/sendSignMetadata.ts | 4 +- .../actions/setVaultAndAuctionAuthorities.ts | 4 +- js/packages/web/src/actions/settle.ts | 21 +-- .../web/src/actions/startAuctionManually.ts | 2 +- js/packages/web/src/actions/unwindVault.ts | 10 +- .../web/src/components/MeshViewer/index.tsx | 11 +- .../web/src/contexts/meta/loadAccounts.ts | 5 +- js/packages/web/src/contexts/meta/types.ts | 2 +- js/packages/web/src/hooks/useArt.ts | 2 +- js/packages/web/src/hooks/useAuctions.ts | 15 +- .../web/src/hooks/useBidsForAuction.ts | 2 +- js/packages/web/src/hooks/useUserArts.ts | 4 +- .../src/models/metaplex/deprecatedStates.ts | 2 +- js/packages/web/src/models/metaplex/index.ts | 7 +- js/packages/web/src/pages/index.tsx | 1 - js/packages/web/src/utils/assets.ts | 5 - js/packages/web/src/views/admin/index.tsx | 5 +- js/packages/web/src/views/auction/index.tsx | 14 +- .../web/src/views/home/auctionList.tsx | 3 +- js/packages/web/src/views/home/setup.tsx | 7 +- js/yarn.lock | 146 +++++++++++++++++- 49 files changed, 372 insertions(+), 203 deletions(-) create mode 100644 js/.eslintrc.js diff --git a/.gitignore b/.gitignore index 6a51275..34d55fb 100644 --- a/.gitignore +++ b/.gitignore @@ -17,6 +17,7 @@ yarn-error.log* *.css.map !js/packages/metaplex/src/fonts/fonts.css !js/packages/metaplex/src/utils/globals.css +js/.eslintcache target .env .vscode diff --git a/js/.eslintrc.js b/js/.eslintrc.js new file mode 100644 index 0000000..238d438 --- /dev/null +++ b/js/.eslintrc.js @@ -0,0 +1,33 @@ +module.exports = { + env: { + browser: true, + es6: true, + }, + extends: [ + "eslint:recommended", + "plugin:react/recommended", + "plugin:@typescript-eslint/eslint-recommended" + ], + globals: { + Atomics: 'readonly', + SharedArrayBuffer: 'readonly', + }, + parser: '@typescript-eslint/parser', + parserOptions: { + ecmaFeatures: { + jsx: true, + }, + ecmaVersion: 2018, + }, + plugins: ['react', '@typescript-eslint'], + settings: { + react: { + pragma: 'React', + version: '17.0.2', + }, + }, + rules: { + 'no-unused-vars': 'off', + '@typescript-eslint/no-unused-vars': ['error'], + }, +}; diff --git a/js/package.json b/js/package.json index b5a7d25..e365023 100644 --- a/js/package.json +++ b/js/package.json @@ -24,7 +24,8 @@ }, "lint-staged": { "packages/*/{src,test}/**/*.ts": [ - "prettier --write" + "prettier --write", + "eslint --cache --fix --max-warnings=0" ] }, "husky": { @@ -56,6 +57,7 @@ "@types/jest": "^24.0.0", "@typescript-eslint/eslint-plugin": "^4.6.0", "@typescript-eslint/parser": "^4.6.0", + "eslint-plugin-react": "^7.25.1", "eslint": "^6.6.0", "eslint-config-prettier": "^6.15.0", "gh-pages": "^3.1.0", diff --git a/js/packages/common/src/actions/metadata.ts b/js/packages/common/src/actions/metadata.ts index c4d965a..0731082 100644 --- a/js/packages/common/src/actions/metadata.ts +++ b/js/packages/common/src/actions/metadata.ts @@ -432,6 +432,7 @@ export const METADATA_SCHEMA = new Map([ ], ]); +// eslint-disable-next-line no-control-regex const METADATA_REPLACE = new RegExp('\u0000', 'g'); export const decodeMetadata = (buffer: Buffer): Metadata => { diff --git a/js/packages/common/src/contracts/token.ts b/js/packages/common/src/contracts/token.ts index a09d52e..581a368 100644 --- a/js/packages/common/src/contracts/token.ts +++ b/js/packages/common/src/contracts/token.ts @@ -1,9 +1,4 @@ -import { - MintLayout, - AccountLayout, - Token, - AuthorityType, -} from '@solana/spl-token'; +import { MintLayout, AccountLayout, Token } from '@solana/spl-token'; import { Connection, PublicKey, @@ -25,9 +20,9 @@ export const mintNFT = async ( const TOKEN_PROGRAM_ID = new PublicKey( 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', ); - const SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new PublicKey( - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', - ); + //const SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new PublicKey( + // 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', + //); const mintAccount = new Account(); const tokenAccount = new Account(); @@ -110,7 +105,7 @@ export const mintNFT = async ( } transaction = await wallet.signTransaction(transaction); const rawTransaction = transaction.serialize(); - let options = { + const options = { skipPreflight: true, commitment: 'singleGossip', }; diff --git a/js/packages/common/src/models/account.ts b/js/packages/common/src/models/account.ts index 8e39274..f2590d0 100644 --- a/js/packages/common/src/models/account.ts +++ b/js/packages/common/src/models/account.ts @@ -62,7 +62,7 @@ export function approve( const tokenProgram = TOKEN_PROGRAM_ID; const transferAuthority = existingTransferAuthority || Keypair.generate(); - const delegateKey = delegate ?? transferAuthority.publicKey; + //const delegateKey = delegate ?? transferAuthority.publicKey; instructions.push( Token.createApproveInstruction( diff --git a/js/packages/common/src/utils/ids.ts b/js/packages/common/src/utils/ids.ts index 8b36516..6816fff 100644 --- a/js/packages/common/src/utils/ids.ts +++ b/js/packages/common/src/utils/ids.ts @@ -1,4 +1,4 @@ -import { PublicKey, AccountInfo, Account } from '@solana/web3.js'; +import { PublicKey, AccountInfo } from '@solana/web3.js'; export type StringPublicKey = string; diff --git a/js/packages/common/src/utils/shortvec.ts b/js/packages/common/src/utils/shortvec.ts index 0acc0fc..077966e 100644 --- a/js/packages/common/src/utils/shortvec.ts +++ b/js/packages/common/src/utils/shortvec.ts @@ -2,7 +2,7 @@ export function decodeLength(bytes: Array): number { let len = 0; let size = 0; for (;;) { - let elem = bytes.shift(); + const elem = bytes.shift(); //@ts-ignore len |= (elem & 0x7f) << (size * 7); size += 1; diff --git a/js/packages/common/src/utils/strings.ts b/js/packages/common/src/utils/strings.ts index 28a7356..c0272a4 100644 --- a/js/packages/common/src/utils/strings.ts +++ b/js/packages/common/src/utils/strings.ts @@ -1,6 +1,6 @@ // credit https://stackoverflow.com/questions/18729405/how-to-convert-utf8-string-to-byte-array export function toUTF8Array(str: string) { - let utf8 = []; + const utf8: number[] = []; for (let i = 0; i < str.length; i++) { let charcode = str.charCodeAt(i); if (charcode < 0x80) utf8.push(charcode); diff --git a/js/packages/common/src/utils/utils.ts b/js/packages/common/src/utils/utils.ts index 2a4e308..9fa7b30 100644 --- a/js/packages/common/src/utils/utils.ts +++ b/js/packages/common/src/utils/utils.ts @@ -56,7 +56,7 @@ export const findProgramAddress = async ( 'pda-' + seeds.reduce((agg, item) => agg + item.toString('hex'), '') + programId.toString(); - let cached = localStorage.getItem(key); + const cached = localStorage.getItem(key); if (cached) { const value = JSON.parse(cached); @@ -207,14 +207,14 @@ export const tryParseKey = (key: string): PublicKey | null => { } }; -var SI_SYMBOL = ['', 'k', 'M', 'G', 'T', 'P', 'E']; +const SI_SYMBOL = ['', 'k', 'M', 'G', 'T', 'P', 'E'] as const; const abbreviateNumber = (number: number, precision: number) => { - let tier = (Math.log10(number) / 3) | 0; + const tier = (Math.log10(number) / 3) | 0; let scaled = number; - let suffix = SI_SYMBOL[tier]; + const suffix = SI_SYMBOL[tier]; if (tier !== 0) { - let scale = Math.pow(10, tier * 3); + const scale = Math.pow(10, tier * 3); scaled = number / scale; } @@ -287,7 +287,7 @@ export function convert( typeof account === 'number' ? account : account.info.amount?.toNumber(); const precision = Math.pow(10, mint?.decimals || 0); - let result = (amount / precision) * rate; + const result = (amount / precision) * rate; return result; } diff --git a/js/packages/web/package.json b/js/packages/web/package.json index 79117d9..9276dad 100644 --- a/js/packages/web/package.json +++ b/js/packages/web/package.json @@ -51,9 +51,6 @@ "deploy": "cross-env ASSET_PREFIX=/metaplex/ yarn build && yarn deploy:gh", "format:fix": "prettier --write \"**/*.+(js|jsx|ts|tsx|json|css|md)\"" }, - "eslintConfig": { - "extends": "react-app" - }, "browserslist": { "production": [ ">0.2%", diff --git a/js/packages/web/src/actions/addTokensToVault.ts b/js/packages/web/src/actions/addTokensToVault.ts index bcfb6c1..73162fb 100644 --- a/js/packages/web/src/actions/addTokensToVault.ts +++ b/js/packages/web/src/actions/addTokensToVault.ts @@ -62,14 +62,14 @@ export async function addTokensToVault( let batchCounter = 0; - let signers: Array = []; - let instructions: Array = []; - let newStores: StringPublicKey[] = []; + const signers: Array = []; + const instructions: Array = []; + const newStores: StringPublicKey[] = []; let currSigners: Keypair[] = []; let currInstructions: TransactionInstruction[] = []; for (let i = 0; i < nfts.length; i++) { - let nft = nfts[i]; + const nft = nfts[i]; if (nft.box.tokenAccount) { const newStoreAccount = createTokenAccount( currInstructions, diff --git a/js/packages/web/src/actions/cancelBid.ts b/js/packages/web/src/actions/cancelBid.ts index 4f86ffd..20ab562 100644 --- a/js/packages/web/src/actions/cancelBid.ts +++ b/js/packages/web/src/actions/cancelBid.ts @@ -33,8 +33,8 @@ export async function sendCancelBid( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; if ( auctionView.auction.info.ended() && @@ -112,11 +112,11 @@ export async function setupCancelBid( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let cancelSigners: Keypair[] = []; - let cancelInstructions: TransactionInstruction[] = []; - let cleanupInstructions: TransactionInstruction[] = []; + const cancelSigners: Keypair[] = []; + const cancelInstructions: TransactionInstruction[] = []; + const cleanupInstructions: TransactionInstruction[] = []; - let tokenAccount = accountsByMint.get(auctionView.auction.info.tokenMint); + const tokenAccount = accountsByMint.get(auctionView.auction.info.tokenMint); const mint = cache.get(auctionView.auction.info.tokenMint); if (mint && auctionView.myBidderPot) { diff --git a/js/packages/web/src/actions/claimUnusedPrizes.ts b/js/packages/web/src/actions/claimUnusedPrizes.ts index 4a0bb8c..0f74ebf 100644 --- a/js/packages/web/src/actions/claimUnusedPrizes.ts +++ b/js/packages/web/src/actions/claimUnusedPrizes.ts @@ -6,7 +6,6 @@ import { SafetyDepositBox, deprecatedGetReservationList, MasterEditionV1, - MasterEditionV2, findProgramAddress, programIds, createAssociatedTokenAccountInstruction, @@ -144,7 +143,7 @@ export async function claimUnusedPrizes( } } - let printingV2ByMint: Record = {}; + const printingV2ByMint: Record = {}; for ( let winnerIndex = 0; @@ -189,7 +188,7 @@ export async function claimUnusedPrizes( winnerIndex, ); break; - case WinningConfigType.PrintingV2: + case WinningConfigType.PrintingV2: { const winningBidder = auctionView.auction.info.bidState.getWinnerAt(winnerIndex); if (winningBidder) { @@ -215,6 +214,7 @@ export async function claimUnusedPrizes( } printingV2ByMint[item.metadata.info.mint] = item; break; + } case WinningConfigType.FullRightsTransfer: console.log('Redeeming Full Rights'); await setupRedeemFullRightsTransferInstructions( @@ -246,9 +246,9 @@ export async function claimUnusedPrizes( } } - let allV2s = Object.values(printingV2ByMint); + const allV2s = Object.values(printingV2ByMint); for (let i = 0; i < allV2s.length; i++) { - let item = allV2s[i]; + const item = allV2s[i]; await setupWithdrawMasterEditionInstructions( connection, auctionView, @@ -273,8 +273,8 @@ async function setupRedeemInstructions( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let winningPrizeSigner: Keypair[] = []; - let winningPrizeInstructions: TransactionInstruction[] = []; + const winningPrizeSigner: Keypair[] = []; + const winningPrizeInstructions: TransactionInstruction[] = []; signers.push(winningPrizeSigner); instructions.push(winningPrizeInstructions); @@ -327,8 +327,8 @@ async function setupRedeemFullRightsTransferInstructions( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let winningPrizeSigner: Keypair[] = []; - let winningPrizeInstructions: TransactionInstruction[] = []; + const winningPrizeSigner: Keypair[] = []; + const winningPrizeInstructions: TransactionInstruction[] = []; const claimed = auctionView.auctionManager.isItemClaimed( winningConfigIndex, safetyDeposit.info.order, @@ -452,8 +452,8 @@ async function deprecatedSetupRedeemPrintingInstructions( ); console.log('This state item is', claimed); if (!claimed) { - let winningPrizeSigner: Keypair[] = []; - let winningPrizeInstructions: TransactionInstruction[] = []; + const winningPrizeSigner: Keypair[] = []; + const winningPrizeInstructions: TransactionInstruction[] = []; signers.push(winningPrizeSigner); instructions.push(winningPrizeInstructions); diff --git a/js/packages/web/src/actions/closePersonalEscrow.ts b/js/packages/web/src/actions/closePersonalEscrow.ts index 6becdb4..f4e3b6b 100644 --- a/js/packages/web/src/actions/closePersonalEscrow.ts +++ b/js/packages/web/src/actions/closePersonalEscrow.ts @@ -23,9 +23,9 @@ export async function closePersonalEscrow( const PROGRAM_IDS = utils.programIds(); - let signers: Keypair[] = []; + const signers: Keypair[] = []; - let instructions: TransactionInstruction[] = [ + const instructions: TransactionInstruction[] = [ Token.createCloseAccountInstruction( PROGRAM_IDS.token, toPublicKey(ata), diff --git a/js/packages/web/src/actions/closeVault.ts b/js/packages/web/src/actions/closeVault.ts index ed9fcc4..eb5ac8e 100644 --- a/js/packages/web/src/actions/closeVault.ts +++ b/js/packages/web/src/actions/closeVault.ts @@ -32,8 +32,8 @@ export async function closeVault( const accountRentExempt = await connection.getMinimumBalanceForRentExemption( AccountLayout.span, ); - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; await activateVault( new BN(0), @@ -62,7 +62,7 @@ export async function closeVault( signers, ); - let transferAuthority = Keypair.generate(); + const transferAuthority = Keypair.generate(); // Shouldn't need to pay anything since we activated vault with 0 shares, but we still // need this setup anyway. diff --git a/js/packages/web/src/actions/convertMasterEditions.ts b/js/packages/web/src/actions/convertMasterEditions.ts index 42627fc..004aeca 100644 --- a/js/packages/web/src/actions/convertMasterEditions.ts +++ b/js/packages/web/src/actions/convertMasterEditions.ts @@ -53,7 +53,7 @@ export async function filterMetadata( console.log('Reviewing', masterEdition.pubkey); let printingBal = 0; try { - let printingBalResp = await connection.getTokenSupply( + const printingBalResp = await connection.getTokenSupply( toPublicKey(masterEdition.info.printingMint), ); printingBal = printingBalResp.value.uiAmount || 0; @@ -83,7 +83,7 @@ export async function filterMetadata( } else { let oneTimeBal = 0; try { - let oneTimeBalResp = await connection.getTokenSupply( + const oneTimeBalResp = await connection.getTokenSupply( toPublicKey(masterEdition.info.oneTimePrintingAuthorizationMint), ); oneTimeBal = oneTimeBalResp.value.uiAmount || 0; @@ -133,8 +133,8 @@ export async function convertMasterEditions( if (!wallet.publicKey) throw new WalletNotConnectedError(); const PROGRAM_IDS = programIds(); - let signers: Array> = []; - let instructions: Array> = []; + const signers: Array> = []; + const instructions: Array> = []; let currSignerBatch: Array = []; let currInstrBatch: Array = []; diff --git a/js/packages/web/src/actions/createAuctionManager.ts b/js/packages/web/src/actions/createAuctionManager.ts index b40fb6f..910aa87 100644 --- a/js/packages/web/src/actions/createAuctionManager.ts +++ b/js/packages/web/src/actions/createAuctionManager.ts @@ -142,7 +142,7 @@ export async function createAuctionManager( auction, } = await makeAuction(wallet, vault, auctionSettings); - let safetyDepositConfigsWithPotentiallyUnsetTokens = + const safetyDepositConfigsWithPotentiallyUnsetTokens = await buildSafetyDepositArray( wallet, safetyDepositDrafts, @@ -189,7 +189,7 @@ export async function createAuctionManager( safetyDepositConfigs, ); - let lookup: byType = { + const lookup: byType = { markItemsThatArentMineAsSold: await markItemsThatArentMineAsSold( wallet, safetyDepositDrafts, @@ -277,7 +277,7 @@ export async function createAuctionManager( }, }; - let signers: Keypair[][] = [ + const signers: Keypair[][] = [ ...lookup.markItemsThatArentMineAsSold.signers, lookup.externalPriceAccount.signers, lookup.deprecatedBuildAndPopulateOneTimeAuthorizationAccount?.signers || [], @@ -377,7 +377,7 @@ async function buildSafetyDepositArray( ): Promise { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let safetyDepositTemplates: SafetyDepositInstructionTemplate[] = []; + const safetyDepositTemplates: SafetyDepositInstructionTemplate[] = []; safetyDeposits.forEach((s, i) => { const maxAmount = [...s.amountRanges.map(a => a.amount)] .sort() @@ -518,13 +518,13 @@ async function setupAuctionManagerInstructions( }> { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let store = programIds().store?.toBase58(); + const store = programIds().store?.toBase58(); if (!store) { throw new Error('Store not initialized'); } - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; const { auctionManagerKey } = await getAuctionKeys(vault); @@ -572,8 +572,8 @@ async function setupStartAuction( }> { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; await startAuction(vault, wallet.publicKey.toBase58(), instructions); @@ -599,8 +599,8 @@ async function deprecatedValidateParticipationHelper( throw new Error('Store not initialized'); } - let instructions: TransactionInstruction[] = []; - let signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; const whitelistedCreator = participationSafetyDepositDraft.metadata.info.data .creators ? await findValidWhitelistedCreator( @@ -684,12 +684,12 @@ async function validateBoxes( if (!store) { throw new Error('Store not initialized'); } - let signers: Keypair[][] = []; - let instructions: TransactionInstruction[][] = []; + const signers: Keypair[][] = []; + const instructions: TransactionInstruction[][] = []; for (let i = 0; i < safetyDeposits.length; i++) { - let tokenSigners: Keypair[] = []; - let tokenInstructions: TransactionInstruction[] = []; + const tokenSigners: Keypair[] = []; + const tokenInstructions: TransactionInstruction[] = []; let safetyDepositBox: StringPublicKey; @@ -762,8 +762,8 @@ async function deprecatedBuildAndPopulateOneTimeAuthorizationAccount( if (!oneTimePrintingAuthorizationMint) return { instructions: [], signers: [] }; - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; const recipientKey: StringPublicKey = ( await findProgramAddress( [ diff --git a/js/packages/web/src/actions/createExternalPriceAccount.ts b/js/packages/web/src/actions/createExternalPriceAccount.ts index 88a91f8..7dc1e01 100644 --- a/js/packages/web/src/actions/createExternalPriceAccount.ts +++ b/js/packages/web/src/actions/createExternalPriceAccount.ts @@ -35,17 +35,17 @@ export async function createExternalPriceAccount( const PROGRAM_IDS = utils.programIds(); - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; const epaRentExempt = await connection.getMinimumBalanceForRentExemption( MAX_EXTERNAL_ACCOUNT_SIZE, ); - let externalPriceAccount = Keypair.generate(); - let key = externalPriceAccount.publicKey.toBase58(); + const externalPriceAccount = Keypair.generate(); + const key = externalPriceAccount.publicKey.toBase58(); - let epaStruct = new ExternalPriceAccount({ + const epaStruct = new ExternalPriceAccount({ pricePerShare: new BN(0), priceMint: QUOTE_MINT.toBase58(), allowedToCombine: true, diff --git a/js/packages/web/src/actions/createVault.ts b/js/packages/web/src/actions/createVault.ts index 8dac705..0ba20f5 100644 --- a/js/packages/web/src/actions/createVault.ts +++ b/js/packages/web/src/actions/createVault.ts @@ -38,8 +38,8 @@ export async function createVault( const PROGRAM_IDS = utils.programIds(); - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; const accountRentExempt = await connection.getMinimumBalanceForRentExemption( AccountLayout.span, @@ -53,7 +53,7 @@ export async function createVault( MAX_VAULT_SIZE, ); - let vault = Keypair.generate(); + const vault = Keypair.generate(); const vaultAuthority = ( await findProgramAddress( diff --git a/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts b/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts index 3452dda..084b7ca 100644 --- a/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts +++ b/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts @@ -5,7 +5,6 @@ import { sendTransactionsWithManualRetry, setAuctionAuthority, setVaultAuthority, - TokenAccount, WalletSigner, } from '@oyster/common'; import { WalletNotConnectedError } from '@solana/wallet-adapter-base'; @@ -25,12 +24,12 @@ export async function decommAuctionManagerAndReturnPrizes( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; if (auctionView.auctionManager.status === AuctionManagerStatus.Initialized) { - let decomSigners: Keypair[] = []; - let decomInstructions: TransactionInstruction[] = []; + const decomSigners: Keypair[] = []; + const decomInstructions: TransactionInstruction[] = []; if (auctionView.auction.info.authority === wallet.publicKey.toBase58()) { await setAuctionAuthority( diff --git a/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts b/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts index ee58303..63372f5 100644 --- a/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts +++ b/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts @@ -23,8 +23,8 @@ export async function deprecatedCreateReservationListForTokens( let batchCounter = 0; - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; let currSigners: Keypair[] = []; let currInstructions: TransactionInstruction[] = []; diff --git a/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts b/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts index bb1e5c2..d546049 100644 --- a/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts +++ b/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts @@ -32,13 +32,13 @@ export async function deprecatedPopulatePrintingTokens( let batchCounter = 0; - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; let currSigners: Keypair[] = []; let currInstructions: TransactionInstruction[] = []; for (let i = 0; i < safetyDepositConfigs.length; i++) { - let nft = safetyDepositConfigs[i]; + const nft = safetyDepositConfigs[i]; if (nft.draft.masterEdition?.info.key != MetadataKey.MasterEditionV1) { continue; } diff --git a/js/packages/web/src/actions/makeAuction.ts b/js/packages/web/src/actions/makeAuction.ts index a9fd05a..1e71385 100644 --- a/js/packages/web/src/actions/makeAuction.ts +++ b/js/packages/web/src/actions/makeAuction.ts @@ -27,8 +27,8 @@ export async function makeAuction( const PROGRAM_IDS = utils.programIds(); - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; const auctionKey = ( await findProgramAddress( [ diff --git a/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts b/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts index f425927..4201a70 100644 --- a/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts +++ b/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts @@ -1,4 +1,4 @@ -import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; +import { Keypair, TransactionInstruction } from '@solana/web3.js'; import { updatePrimarySaleHappenedViaToken, WalletSigner, @@ -15,8 +15,8 @@ export async function markItemsThatArentMineAsSold( const publicKey = wallet.publicKey.toBase58(); - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; let markSigners: Keypair[] = []; let markInstructions: TransactionInstruction[] = []; diff --git a/js/packages/web/src/actions/saveAdmin.ts b/js/packages/web/src/actions/saveAdmin.ts index c5c1731..95cf681 100644 --- a/js/packages/web/src/actions/saveAdmin.ts +++ b/js/packages/web/src/actions/saveAdmin.ts @@ -20,11 +20,11 @@ export async function saveAdmin( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; - let storeSigners: Keypair[] = []; - let storeInstructions: TransactionInstruction[] = []; + const storeSigners: Keypair[] = []; + const storeInstructions: TransactionInstruction[] = []; await setStore( isPublic, @@ -37,8 +37,8 @@ export async function saveAdmin( for (let i = 0; i < whitelistedCreators.length; i++) { const wc = whitelistedCreators[i]; - let wcSigners: Keypair[] = []; - let wcInstructions: TransactionInstruction[] = []; + const wcSigners: Keypair[] = []; + const wcInstructions: TransactionInstruction[] = []; await setWhitelistedCreator( wc.address, diff --git a/js/packages/web/src/actions/sendPlaceBid.ts b/js/packages/web/src/actions/sendPlaceBid.ts index 5145827..e2d6028 100644 --- a/js/packages/web/src/actions/sendPlaceBid.ts +++ b/js/packages/web/src/actions/sendPlaceBid.ts @@ -31,9 +31,9 @@ export async function sendPlaceBid( // value entered by the user adjust to decimals of the mint amount: number, ) { - let signers: Keypair[][] = []; - let instructions: TransactionInstruction[][] = []; - let bid = await setupPlaceBid( + const signers: Keypair[][] = []; + const instructions: TransactionInstruction[][] = []; + const bid = await setupPlaceBid( connection, wallet, bidderTokenAccount, @@ -72,7 +72,7 @@ export async function setupPlaceBid( let signers: Keypair[] = []; let instructions: TransactionInstruction[] = []; - let cleanupInstructions: TransactionInstruction[] = []; + const cleanupInstructions: TransactionInstruction[] = []; const accountRentExempt = await connection.getMinimumBalanceForRentExemption( AccountLayout.span, @@ -84,7 +84,7 @@ export async function setupPlaceBid( const mint = cache.get( tokenAccount ? tokenAccount.info.mint : QUOTE_MINT, ) as ParsedAccount; - let lamports = toLamports(amount, mint.info) + accountRentExempt; + const lamports = toLamports(amount, mint.info) + accountRentExempt; let bidderPotTokenAccount: string; if (!auctionView.myBidderPot) { @@ -99,8 +99,8 @@ export async function setupPlaceBid( } else { bidderPotTokenAccount = auctionView.myBidderPot?.info.bidderPot; if (!auctionView.auction.info.ended()) { - let cancelSigners: Keypair[][] = []; - let cancelInstr: TransactionInstruction[][] = []; + const cancelSigners: Keypair[][] = []; + const cancelInstr: TransactionInstruction[][] = []; await setupCancelBid( auctionView, accountsByMint, diff --git a/js/packages/web/src/actions/sendRedeemBid.ts b/js/packages/web/src/actions/sendRedeemBid.ts index b7c2a8b..d2ccd93 100644 --- a/js/packages/web/src/actions/sendRedeemBid.ts +++ b/js/packages/web/src/actions/sendRedeemBid.ts @@ -94,8 +94,8 @@ export async function sendRedeemBid( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; if ( auctionView.auction.info.ended() && @@ -200,8 +200,8 @@ export async function sendRedeemBid( } if (auctionView.myBidderMetadata && auctionView.myBidderPot) { - let claimSigners: Keypair[] = []; - let claimInstructions: TransactionInstruction[] = []; + const claimSigners: Keypair[] = []; + const claimInstructions: TransactionInstruction[] = []; instructions.push(claimInstructions); signers.push(claimSigners); console.log('Claimed'); @@ -304,8 +304,8 @@ async function setupRedeemInstructions( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let winningPrizeSigner: Keypair[] = []; - let winningPrizeInstructions: TransactionInstruction[] = []; + const winningPrizeSigner: Keypair[] = []; + const winningPrizeInstructions: TransactionInstruction[] = []; signers.push(winningPrizeSigner); instructions.push(winningPrizeInstructions); @@ -364,8 +364,8 @@ async function setupRedeemFullRightsTransferInstructions( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let winningPrizeSigner: Keypair[] = []; - let winningPrizeInstructions: TransactionInstruction[] = []; + const winningPrizeSigner: Keypair[] = []; + const winningPrizeInstructions: TransactionInstruction[] = []; signers.push(winningPrizeSigner); instructions.push(winningPrizeInstructions); @@ -459,8 +459,8 @@ export async function setupRedeemPrintingV2Instructions( ); for (let i = 0; i < item.amount.toNumber(); i++) { - let myInstructions: TransactionInstruction[] = []; - let mySigners: Keypair[] = []; + const myInstructions: TransactionInstruction[] = []; + const mySigners: Keypair[] = []; const { mint, account } = await createMintAndAccountWithOne( wallet, @@ -569,8 +569,8 @@ async function deprecatedSetupRedeemPrintingV1Instructions( if (updateAuth && auctionView.myBidderMetadata) { console.log('This state item is', claimed); if (!claimed) { - let winningPrizeSigner: Keypair[] = []; - let winningPrizeInstructions: TransactionInstruction[] = []; + const winningPrizeSigner: Keypair[] = []; + const winningPrizeInstructions: TransactionInstruction[] = []; signers.push(winningPrizeSigner); instructions.push(winningPrizeInstructions); @@ -635,8 +635,8 @@ async function deprecatedRedeemPrintingV1Token( if (!wallet.publicKey) throw new WalletNotConnectedError(); if (!item.masterEdition) return; - let cashInLimitedPrizeAuthorizationTokenSigner: Keypair[] = []; - let cashInLimitedPrizeAuthorizationTokenInstruction: TransactionInstruction[] = + const cashInLimitedPrizeAuthorizationTokenSigner: Keypair[] = []; + const cashInLimitedPrizeAuthorizationTokenInstruction: TransactionInstruction[] = []; signers.push(cashInLimitedPrizeAuthorizationTokenSigner); instructions.push(cashInLimitedPrizeAuthorizationTokenInstruction); @@ -731,8 +731,8 @@ export async function setupRedeemParticipationInstructions( const me = item.masterEdition as ParsedAccount; // Super unfortunate but cant fit this all in one txn - let mintingInstructions: TransactionInstruction[] = []; - let mintingSigners: Keypair[] = []; + const mintingInstructions: TransactionInstruction[] = []; + const mintingSigners: Keypair[] = []; const cleanupInstructions: TransactionInstruction[] = []; @@ -746,7 +746,7 @@ export async function setupRedeemParticipationInstructions( const fixedPrice = auctionView.auctionManager.participationConfig?.fixedPrice; - let price: number = + const price: number = fixedPrice !== undefined && fixedPrice !== null ? fixedPrice.toNumber() : bid?.info.lastBid.toNumber() || 0; @@ -782,9 +782,9 @@ export async function setupRedeemParticipationInstructions( instructions.push(mintingInstructions); signers.push(mintingSigners); - let myInstructions: TransactionInstruction[] = []; + const myInstructions: TransactionInstruction[] = []; - let mySigners: Keypair[] = []; + const mySigners: Keypair[] = []; const transferAuthority = approve( myInstructions, @@ -823,8 +823,9 @@ export async function setupRedeemParticipationInstructions( const metadata = await getMetadata(mint); if (receiverWallet === wallet.publicKey.toBase58()) { - let updatePrimarySaleHappenedInstructions: TransactionInstruction[] = []; - let updatePrimarySaleHappenedSigners: Keypair[] = []; + const updatePrimarySaleHappenedInstructions: TransactionInstruction[] = + []; + const updatePrimarySaleHappenedSigners: Keypair[] = []; await updatePrimarySaleHappenedViaToken( metadata, @@ -867,7 +868,7 @@ async function deprecatedSetupRedeemParticipationInstructions( return; const updateAuth = item.metadata.info.updateAuthority; - let tokenAccount = accountsByMint.get(auctionView.auction.info.tokenMint); + const tokenAccount = accountsByMint.get(auctionView.auction.info.tokenMint); const mint = cache.get(auctionView.auction.info.tokenMint); const participationBalance = await connection.getTokenAccountBalance( @@ -882,8 +883,8 @@ async function deprecatedSetupRedeemParticipationInstructions( tokenBalance.value.uiAmount === 1 ) { // I'm the first, I need to populate for the others with a crank turn. - let fillParticipationStashSigners: Keypair[] = []; - let fillParticipationStashInstructions: TransactionInstruction[] = []; + const fillParticipationStashSigners: Keypair[] = []; + const fillParticipationStashInstructions: TransactionInstruction[] = []; const oneTimeTransient = createTokenAccount( fillParticipationStashInstructions, wallet.publicKey, @@ -933,14 +934,14 @@ async function deprecatedSetupRedeemParticipationInstructions( safetyDeposit.info.order, ) ) { - let winningPrizeSigner: Keypair[] = []; - let winningPrizeInstructions: TransactionInstruction[] = []; - let cleanupInstructions: TransactionInstruction[] = []; + const winningPrizeSigner: Keypair[] = []; + const winningPrizeInstructions: TransactionInstruction[] = []; + const cleanupInstructions: TransactionInstruction[] = []; if (!newTokenAccount) { // made a separate txn because we're over the txn limit by like 10 bytes. - let newTokenAccountSigner: Keypair[] = []; - let newTokenAccountInstructions: TransactionInstruction[] = []; + const newTokenAccountSigner: Keypair[] = []; + const newTokenAccountInstructions: TransactionInstruction[] = []; signers.push(newTokenAccountSigner); instructions.push(newTokenAccountInstructions); newTokenAccount = createTokenAccount( @@ -956,7 +957,7 @@ async function deprecatedSetupRedeemParticipationInstructions( const fixedPrice = auctionView.auctionManager.participationConfig?.fixedPrice; - let price: number = + const price: number = fixedPrice !== undefined && fixedPrice !== null ? fixedPrice.toNumber() : auctionView.myBidderMetadata.info.lastBid.toNumber() || 0; diff --git a/js/packages/web/src/actions/sendSignMetadata.ts b/js/packages/web/src/actions/sendSignMetadata.ts index 09ff7e5..8f0b15c 100644 --- a/js/packages/web/src/actions/sendSignMetadata.ts +++ b/js/packages/web/src/actions/sendSignMetadata.ts @@ -14,8 +14,8 @@ export async function sendSignMetadata( ) { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; await signMetadata(metadata, wallet.publicKey.toBase58(), instructions); diff --git a/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts b/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts index b50ef20..4dfc201 100644 --- a/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts +++ b/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts @@ -19,8 +19,8 @@ export async function setVaultAndAuctionAuthorities( }> { if (!wallet.publicKey) throw new WalletNotConnectedError(); - let signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const signers: Keypair[] = []; + const instructions: TransactionInstruction[] = []; await setAuctionAuthority( auction, diff --git a/js/packages/web/src/actions/settle.ts b/js/packages/web/src/actions/settle.ts index 03e764a..b165d5b 100644 --- a/js/packages/web/src/actions/settle.ts +++ b/js/packages/web/src/actions/settle.ts @@ -1,9 +1,4 @@ -import { - Keypair, - Connection, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { ParsedAccount, SequenceType, @@ -42,8 +37,8 @@ export async function settle( auctionView.auction.info.ended() && auctionView.auction.info.state !== AuctionState.Ended ) { - let signers: Keypair[][] = []; - let instructions: TransactionInstruction[][] = []; + const signers: Keypair[][] = []; + const instructions: TransactionInstruction[][] = []; await setupPlaceBid( connection, @@ -76,15 +71,15 @@ async function emptyPaymentAccountForAllTokens( if (!wallet.publicKey) throw new WalletNotConnectedError(); const PROGRAM_IDS = programIds(); - let signers: Array> = []; - let instructions: Array> = []; + const signers: Array> = []; + const instructions: Array> = []; let currSignerBatch: Array = []; let currInstrBatch: Array = []; let settleSigners: Keypair[] = []; let settleInstructions: TransactionInstruction[] = []; - let ataLookup: Record = {}; + const ataLookup: Record = {}; // TODO replace all this with payer account so user doesnt need to click approve several times. // Overall we have 10 parallel txns, of up to 4 settlements per txn @@ -219,8 +214,8 @@ async function claimAllBids( auctionView: AuctionView, bids: ParsedAccount[], ) { - let signers: Array> = []; - let instructions: Array> = []; + const signers: Array> = []; + const instructions: Array> = []; let currSignerBatch: Array = []; let currInstrBatch: Array = []; diff --git a/js/packages/web/src/actions/startAuctionManually.ts b/js/packages/web/src/actions/startAuctionManually.ts index d957ad7..ac59450 100644 --- a/js/packages/web/src/actions/startAuctionManually.ts +++ b/js/packages/web/src/actions/startAuctionManually.ts @@ -10,7 +10,7 @@ export async function startAuctionManually( ) { try { const signers: Keypair[] = []; - let instructions: TransactionInstruction[] = []; + const instructions: TransactionInstruction[] = []; await startAuction( auctionView.vault.pubkey, diff --git a/js/packages/web/src/actions/unwindVault.ts b/js/packages/web/src/actions/unwindVault.ts index 8111830..a05913e 100644 --- a/js/packages/web/src/actions/unwindVault.ts +++ b/js/packages/web/src/actions/unwindVault.ts @@ -34,8 +34,8 @@ export async function unwindVault( let batchCounter = 0; const PROGRAM_IDS = programIds(); - let signers: Array = []; - let instructions: Array = []; + const signers: Array = []; + const instructions: Array = []; let currSigners: Keypair[] = []; let currInstructions: TransactionInstruction[] = []; @@ -48,7 +48,7 @@ export async function unwindVault( if (epa) { const decoded = decodeExternalPriceAccount(epa.data); // "Closing" it here actually brings it to Combined state which means we can withdraw tokens. - let { instructions: cvInstructions, signers: cvSigners } = + const { instructions: cvInstructions, signers: cvSigners } = await closeVault( connection, wallet, @@ -66,7 +66,7 @@ export async function unwindVault( } const vaultKey = vault.pubkey; - let boxes: ParsedAccount[] = []; + const boxes: ParsedAccount[] = []; let box = safetyDepositBoxesByVaultAndIndex[vaultKey + '-0']; if (box) { @@ -80,7 +80,7 @@ export async function unwindVault( } console.log('Found boxes', boxes); for (let i = 0; i < boxes.length; i++) { - let nft = boxes[i]; + const nft = boxes[i]; const ata = ( await findProgramAddress( [ diff --git a/js/packages/web/src/components/MeshViewer/index.tsx b/js/packages/web/src/components/MeshViewer/index.tsx index 1f39fb6..b34fd54 100644 --- a/js/packages/web/src/components/MeshViewer/index.tsx +++ b/js/packages/web/src/components/MeshViewer/index.tsx @@ -12,12 +12,19 @@ export function MeshViewer(props: MeshViewerProps) { return ( // @ts-ignore - ) + ); } diff --git a/js/packages/web/src/contexts/meta/loadAccounts.ts b/js/packages/web/src/contexts/meta/loadAccounts.ts index f153e18..f3551ab 100644 --- a/js/packages/web/src/contexts/meta/loadAccounts.ts +++ b/js/packages/web/src/contexts/meta/loadAccounts.ts @@ -34,14 +34,14 @@ async function getProgramAccounts( ): Promise> { const extra: any = {}; let commitment; - let encoding; + //let encoding; if (configOrCommitment) { if (typeof configOrCommitment === 'string') { commitment = configOrCommitment; } else { commitment = configOrCommitment.commitment; - encoding = configOrCommitment.encoding; + //encoding = configOrCommitment.encoding; if (configOrCommitment.dataSlice) { extra.dataSlice = configOrCommitment.dataSlice; @@ -124,7 +124,6 @@ export const loadAccounts = async (connection: Connection, all: boolean) => { const promises = [ getProgramAccounts(connection, VAULT_ID).then(forEach(processVaultData)), getProgramAccounts(connection, AUCTION_ID).then(forEach(processAuctions)), - , getProgramAccounts(connection, METAPLEX_ID).then( forEach(processMetaplexAccounts), ), diff --git a/js/packages/web/src/contexts/meta/types.ts b/js/packages/web/src/contexts/meta/types.ts index 368cb68..a4f9b25 100644 --- a/js/packages/web/src/contexts/meta/types.ts +++ b/js/packages/web/src/contexts/meta/types.ts @@ -12,7 +12,7 @@ import { MasterEditionV2, PublicKeyStringAndAccount, } from '@oyster/common'; -import { AccountInfo, PublicKey } from '@solana/web3.js'; +import { AccountInfo } from '@solana/web3.js'; import { BidRedemptionTicket, Store, diff --git a/js/packages/web/src/hooks/useArt.ts b/js/packages/web/src/hooks/useArt.ts index ea3d065..d676382 100644 --- a/js/packages/web/src/hooks/useArt.ts +++ b/js/packages/web/src/hooks/useArt.ts @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { useMeta } from '../contexts'; import { Art, Artist, ArtType } from '../types'; import { diff --git a/js/packages/web/src/hooks/useAuctions.ts b/js/packages/web/src/hooks/useAuctions.ts index 97859f0..299ebf1 100644 --- a/js/packages/web/src/hooks/useAuctions.ts +++ b/js/packages/web/src/hooks/useAuctions.ts @@ -288,13 +288,13 @@ export function processAccountsIntoAuctionView( const vault = vaults[auctionManagerInstance.info.vault]; const auctionManagerKey = auctionManagerInstance.pubkey; - let safetyDepositConfigs: ParsedAccount[] = + const safetyDepositConfigs: ParsedAccount[] = buildListWhileNonZero( safetyDepositConfigsByAuctionManagerAndIndex, auctionManagerKey, ); - let bidRedemptions: ParsedAccount[] = + const bidRedemptions: ParsedAccount[] = buildListWhileNonZero( bidRedemptionV2sByAuctionManagerAndWinningIndex, auctionManagerKey, @@ -309,7 +309,7 @@ export function processAccountsIntoAuctionView( const boxesExpected = auctionManager.safetyDepositBoxesExpected.toNumber(); - let bidRedemption: ParsedAccount | undefined = + const bidRedemption: ParsedAccount | undefined = cachedRedemptionKeysByWallet[auction.pubkey]?.info ? (cachedRedemptionKeysByWallet[ auction.pubkey @@ -336,7 +336,7 @@ export function processAccountsIntoAuctionView( metadataByMint[curr.safetyDeposit.info.tokenMint]; if (!foundMetadata) { // Means is a limited edition, so the tokenMint is the printingMint - let masterEdition = + const masterEdition = masterEditionsByPrintingMint[curr.safetyDeposit.info.tokenMint]; if (masterEdition) { foundMetadata = metadataByMasterEdition[masterEdition.pubkey]; @@ -350,7 +350,8 @@ export function processAccountsIntoAuctionView( !curr.masterEdition && curr.metadata.info.masterEdition ) { - let foundMaster = masterEditions[curr.metadata.info.masterEdition]; + const foundMaster = + masterEditions[curr.metadata.info.masterEdition]; curr.masterEdition = foundMaster; } @@ -361,7 +362,7 @@ export function processAccountsIntoAuctionView( } const vaultKey = auctionManager.vault; - let boxes: ParsedAccount[] = buildListWhileNonZero( + const boxes: ParsedAccount[] = buildListWhileNonZero( safetyDepositBoxesByVaultAndIndex, vaultKey, ); @@ -394,7 +395,7 @@ export function processAccountsIntoAuctionView( } } - let view: Partial = { + const view: Partial = { auction, auctionManager, state, diff --git a/js/packages/web/src/hooks/useBidsForAuction.ts b/js/packages/web/src/hooks/useBidsForAuction.ts index a70e2d4..bc78216 100644 --- a/js/packages/web/src/hooks/useBidsForAuction.ts +++ b/js/packages/web/src/hooks/useBidsForAuction.ts @@ -1,4 +1,4 @@ -import React, { useEffect, useMemo, useState } from 'react'; +import { useEffect, useMemo, useState } from 'react'; import { BidderMetadata, BidderMetadataParser, diff --git a/js/packages/web/src/hooks/useUserArts.ts b/js/packages/web/src/hooks/useUserArts.ts index 6bdcb03..58593cc 100644 --- a/js/packages/web/src/hooks/useUserArts.ts +++ b/js/packages/web/src/hooks/useUserArts.ts @@ -38,10 +38,10 @@ export const useUserArts = (): SafetyDepositDraft[] => { m.info.masterEdition ? masterEditions[m.info.masterEdition] : undefined, ); - let safetyDeposits: SafetyDepositDraft[] = []; + const safetyDeposits: SafetyDepositDraft[] = []; let i = 0; ownedMetadata.forEach(m => { - let a = accountByMint.get(m.info.mint); + const a = accountByMint.get(m.info.mint); let masterA; const masterEdition = possibleMasterEditions[i]; if (masterEdition?.info.key == MetadataKey.MasterEditionV1) { diff --git a/js/packages/web/src/models/metaplex/deprecatedStates.ts b/js/packages/web/src/models/metaplex/deprecatedStates.ts index 530f7c3..37041ba 100644 --- a/js/packages/web/src/models/metaplex/deprecatedStates.ts +++ b/js/packages/web/src/models/metaplex/deprecatedStates.ts @@ -156,7 +156,7 @@ export class BidRedemptionTicketV1 implements BidRedemptionTicket { Object.assign(this, args); } - getBidRedeemed(order: number): boolean { + getBidRedeemed(): boolean { return this.participationRedeemed; } } diff --git a/js/packages/web/src/models/metaplex/index.ts b/js/packages/web/src/models/metaplex/index.ts index 7057138..bfb62a2 100644 --- a/js/packages/web/src/models/metaplex/index.ts +++ b/js/packages/web/src/models/metaplex/index.ts @@ -9,7 +9,6 @@ import { Vault, Metadata, MasterEditionV1, - MetadataKey, SafetyDepositBox, MasterEditionV2, toPublicKey, @@ -205,7 +204,7 @@ export class AuctionManager { metadataByMint[boxes[it.safetyDepositBoxIndex]?.info.tokenMint]; if (!metadata) { // Means is a limited edition v1, so the tokenMint is the printingMint - let masterEdition = + const masterEdition = masterEditionsByPrintingMint[ boxes[it.safetyDepositBoxIndex]?.info.tokenMint ]; @@ -645,7 +644,7 @@ export class SafetyDepositConfig { this.winningConfigType = args.data[41]; this.amountType = args.data[42]; this.lengthType = args.data[43]; - let lengthOfArray = new BN(args.data.slice(44, 48), 'le'); + const lengthOfArray = new BN(args.data.slice(44, 48), 'le'); this.amountRanges = []; let offset = 48; for (let i = 0; i < lengthOfArray.toNumber(); i++) { @@ -716,7 +715,7 @@ export class SafetyDepositConfig { getAmountForWinner(winner: BN): BN { let start = new BN(0); for (let i = 0; i < this.amountRanges.length; i++) { - let end = start.add(this.amountRanges[i].length); + const end = start.add(this.amountRanges[i].length); if (winner.gte(start) && winner.lt(end)) { return this.amountRanges[i].amount; } diff --git a/js/packages/web/src/pages/index.tsx b/js/packages/web/src/pages/index.tsx index e21bed2..0341c66 100644 --- a/js/packages/web/src/pages/index.tsx +++ b/js/packages/web/src/pages/index.tsx @@ -1,4 +1,3 @@ -import { useState, useEffect } from 'react'; import dynamic from 'next/dynamic'; const CreateReactAppEntryPoint = dynamic(() => import('../App'), { diff --git a/js/packages/web/src/utils/assets.ts b/js/packages/web/src/utils/assets.ts index bfc76e5..6d191f0 100644 --- a/js/packages/web/src/utils/assets.ts +++ b/js/packages/web/src/utils/assets.ts @@ -1,8 +1,3 @@ -import { - getTokenName, - getVerboseTokenName, - KnownTokenMap, -} from '@oyster/common'; import { TokenInfo } from '@solana/spl-token-registry'; export const LAMPORT_MULTIPLIER = 10 ** 9; diff --git a/js/packages/web/src/views/admin/index.tsx b/js/packages/web/src/views/admin/index.tsx index 99d5724..5cd136b 100644 --- a/js/packages/web/src/views/admin/index.tsx +++ b/js/packages/web/src/views/admin/index.tsx @@ -1,4 +1,4 @@ -import React, {useCallback, useEffect, useMemo, useState} from 'react'; +import React, { useCallback, useEffect, useMemo, useState } from 'react'; import { Layout, Row, @@ -21,7 +21,8 @@ import { StringPublicKey, useConnection, useStore, - useUserAccounts, useWalletModal, + useUserAccounts, + useWalletModal, WalletSigner, } from '@oyster/common'; import { useWallet } from '@solana/wallet-adapter-react'; diff --git a/js/packages/web/src/views/auction/index.tsx b/js/packages/web/src/views/auction/index.tsx index 69e152e..c4f6310 100644 --- a/js/packages/web/src/views/auction/index.tsx +++ b/js/packages/web/src/views/auction/index.tsx @@ -159,22 +159,20 @@ export const AuctionView = () => { No description provided.
))} - - {attributes && + {attributes && ( <>
Attributes
- - {attributes.map(attribute => + + {attributes.map(attribute => ( {attribute.value} - )} + ))} - } + + )} {/* {auctionData[id] && ( <>
About this Auction
diff --git a/js/packages/web/src/views/home/auctionList.tsx b/js/packages/web/src/views/home/auctionList.tsx index 5e4f947..49f9cda 100644 --- a/js/packages/web/src/views/home/auctionList.tsx +++ b/js/packages/web/src/views/home/auctionList.tsx @@ -80,8 +80,7 @@ export const AuctionListView = () => { .concat(auctionsEnded) .filter( (m, idx) => - m.myBidderMetadata?.info.bidderPubkey == - publicKey?.toBase58(), + m.myBidderMetadata?.info.bidderPubkey == publicKey?.toBase58(), ); break; case LiveAuctionViewState.Resale: diff --git a/js/packages/web/src/views/home/setup.tsx b/js/packages/web/src/views/home/setup.tsx index 6ff889b..358a38d 100644 --- a/js/packages/web/src/views/home/setup.tsx +++ b/js/packages/web/src/views/home/setup.tsx @@ -1,4 +1,9 @@ -import { useConnection, useStore, useWalletModal, WalletSigner } from '@oyster/common'; +import { + useConnection, + useStore, + useWalletModal, + WalletSigner, +} from '@oyster/common'; import { useWallet } from '@solana/wallet-adapter-react'; import { Button } from 'antd'; import { useCallback, useEffect, useState } from 'react'; diff --git a/js/yarn.lock b/js/yarn.lock index fbf1d7a..464a33f 100644 --- a/js/yarn.lock +++ b/js/yarn.lock @@ -3418,6 +3418,17 @@ array-ify@^1.0.0: resolved "https://registry.yarnpkg.com/array-ify/-/array-ify-1.0.0.tgz#9e528762b4a9066ad163a6962a364418e9626ece" integrity sha1-nlKHYrSpBmrRY6aWKjZEGOlibs4= +array-includes@^3.1.2, array-includes@^3.1.3: + version "3.1.3" + resolved "https://registry.yarnpkg.com/array-includes/-/array-includes-3.1.3.tgz#c7f619b382ad2afaf5326cddfdc0afc61af7690a" + integrity sha512-gcem1KlBU7c9rB+Rq8/3PPKsK2kjqeEBa3bD5kkQo4nYlOHQCJqIJFqBXDEfwaRuYTT4E+FxA9xez7Gf/e3Q7A== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.0-next.2" + get-intrinsic "^1.1.1" + is-string "^1.0.5" + array-tree-filter@^2.1.0: version "2.1.0" resolved "https://registry.yarnpkg.com/array-tree-filter/-/array-tree-filter-2.1.0.tgz#873ac00fec83749f255ac8dd083814b4f6329190" @@ -3445,6 +3456,16 @@ array-unique@^0.3.2: resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.3.2.tgz#a894b75d4bc4f6cd679ef3244a9fd8f46ae2d428" integrity sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg= +array.prototype.flatmap@^1.2.4: + version "1.2.4" + resolved "https://registry.yarnpkg.com/array.prototype.flatmap/-/array.prototype.flatmap-1.2.4.tgz#94cfd47cc1556ec0747d97f7c7738c58122004c9" + integrity sha512-r9Z0zYoxqHz60vvQbWEdXIEtCwHF0yxaWfno9qzXeNHvfyl3BZqygmGzb84dsubyaXLH4husF+NFgMSdpZhk2Q== + dependencies: + call-bind "^1.0.0" + define-properties "^1.1.3" + es-abstract "^1.18.0-next.1" + function-bind "^1.1.1" + arrify@^1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d" @@ -6047,6 +6068,13 @@ dns-txt@^2.0.2: dependencies: buffer-indexof "^1.0.0" +doctrine@^2.1.0: + version "2.1.0" + resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.1.0.tgz#5cd01fc101621b42c4cd7f5d1a66243716d3f39d" + integrity sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw== + dependencies: + esutils "^2.0.2" + doctrine@^3.0.0: version "3.0.0" resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-3.0.0.tgz#addebead72a6574db783639dc87a121773973961" @@ -6313,6 +6341,29 @@ es-abstract@^1.18.0-next.1, es-abstract@^1.18.0-next.2: string.prototype.trimstart "^1.0.4" unbox-primitive "^1.0.1" +es-abstract@^1.18.2: + version "1.18.5" + resolved "https://registry.yarnpkg.com/es-abstract/-/es-abstract-1.18.5.tgz#9b10de7d4c206a3581fd5b2124233e04db49ae19" + integrity sha512-DDggyJLoS91CkJjgauM5c0yZMjiD1uK3KcaCeAmffGwZ+ODWzOkPN4QwRbsK5DOFf06fywmyLci3ZD8jLGhVYA== + dependencies: + call-bind "^1.0.2" + es-to-primitive "^1.2.1" + function-bind "^1.1.1" + get-intrinsic "^1.1.1" + has "^1.0.3" + has-symbols "^1.0.2" + internal-slot "^1.0.3" + is-callable "^1.2.3" + is-negative-zero "^2.0.1" + is-regex "^1.1.3" + is-string "^1.0.6" + object-inspect "^1.11.0" + object-keys "^1.1.1" + object.assign "^4.1.2" + string.prototype.trimend "^1.0.4" + string.prototype.trimstart "^1.0.4" + unbox-primitive "^1.0.1" + es-to-primitive@^1.2.1: version "1.2.1" resolved "https://registry.yarnpkg.com/es-to-primitive/-/es-to-primitive-1.2.1.tgz#e55cd4c9cdc188bcefb03b366c736323fc5c898a" @@ -6416,6 +6467,25 @@ eslint-config-prettier@^6.15.0: dependencies: get-stdin "^6.0.0" +eslint-plugin-react@^7.25.1: + version "7.25.1" + resolved "https://registry.yarnpkg.com/eslint-plugin-react/-/eslint-plugin-react-7.25.1.tgz#9286b7cd9bf917d40309760f403e53016eda8331" + integrity sha512-P4j9K1dHoFXxDNP05AtixcJEvIT6ht8FhYKsrkY0MPCPaUMYijhpWwNiRDZVtA8KFuZOkGSeft6QwH8KuVpJug== + dependencies: + array-includes "^3.1.3" + array.prototype.flatmap "^1.2.4" + doctrine "^2.1.0" + estraverse "^5.2.0" + has "^1.0.3" + jsx-ast-utils "^2.4.1 || ^3.0.0" + minimatch "^3.0.4" + object.entries "^1.1.4" + object.fromentries "^2.0.4" + object.values "^1.1.4" + prop-types "^15.7.2" + resolve "^2.0.0-next.3" + string.prototype.matchall "^4.0.5" + eslint-scope@^5.0.0, eslint-scope@^5.1.1: version "5.1.1" resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-5.1.1.tgz#e786e59a66cb92b3f6c1fb0d508aab174848f48c" @@ -7681,7 +7751,7 @@ get-caller-file@^2.0.1, get-caller-file@^2.0.5: resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e" integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg== -get-intrinsic@^1.0.2, get-intrinsic@^1.1.1: +get-intrinsic@^1.0.2, get-intrinsic@^1.1.0, get-intrinsic@^1.1.1: version "1.1.1" resolved "https://registry.yarnpkg.com/get-intrinsic/-/get-intrinsic-1.1.1.tgz#15f59f376f855c446963948f0d24cd3637b4abc6" integrity sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q== @@ -8515,6 +8585,15 @@ internal-ip@^4.3.0: default-gateway "^4.2.0" ipaddr.js "^1.9.0" +internal-slot@^1.0.3: + version "1.0.3" + resolved "https://registry.yarnpkg.com/internal-slot/-/internal-slot-1.0.3.tgz#7347e307deeea2faac2ac6205d4bc7d34967f59c" + integrity sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA== + dependencies: + get-intrinsic "^1.1.0" + has "^1.0.3" + side-channel "^1.0.4" + interpret@^1.0.0: version "1.4.0" resolved "https://registry.yarnpkg.com/interpret/-/interpret-1.4.0.tgz#665ab8bc4da27a774a40584e812e3e0fa45b1a1e" @@ -9657,6 +9736,14 @@ jsprim@^1.2.2: json-schema "0.2.3" verror "1.10.0" +"jsx-ast-utils@^2.4.1 || ^3.0.0": + version "3.2.0" + resolved "https://registry.yarnpkg.com/jsx-ast-utils/-/jsx-ast-utils-3.2.0.tgz#41108d2cec408c3453c1bbe8a4aae9e1e2bd8f82" + integrity sha512-EIsmt3O3ljsU6sot/J4E1zDRxfBNrhjyf/OKjlydwgEimQuznlM4Wv7U+ueONJMyEn1WRE0K8dhi3dVAXYT24Q== + dependencies: + array-includes "^3.1.2" + object.assign "^4.1.2" + keccak256@^1.0.0: version "1.0.2" resolved "https://registry.yarnpkg.com/keccak256/-/keccak256-1.0.2.tgz#ee0d38c2d5fb817f39d37c3fef842cab0164a067" @@ -11159,6 +11246,11 @@ object-inspect@^1.10.3, object-inspect@^1.9.0: resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.10.3.tgz#c2aa7d2d09f50c99375704f7a0adf24c5782d369" integrity sha512-e5mCJlSH7poANfC8z8S9s9S2IN5/4Zb3aZ33f5s8YqoazCFzNLloLU8r5VCG+G7WoqLvAAZoVMcy3tp/3X0Plw== +object-inspect@^1.11.0: + version "1.11.0" + resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.11.0.tgz#9dceb146cedd4148a0d9e51ab88d34cf509922b1" + integrity sha512-jp7ikS6Sd3GxQfZJPyH3cjcbJF6GZPClgdV+EFygjFLQ5FmW/dRUnTd9PQ9k0JhoNDabWFbpF1yCdSWCC6gexg== + object-inspect@~1.7.0: version "1.7.0" resolved "https://registry.yarnpkg.com/object-inspect/-/object-inspect-1.7.0.tgz#f4f6bd181ad77f006b5ece60bd0b6f398ff74a67" @@ -11199,6 +11291,25 @@ object.assign@^4.1.2: has-symbols "^1.0.1" object-keys "^1.1.1" +object.entries@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/object.entries/-/object.entries-1.1.4.tgz#43ccf9a50bc5fd5b649d45ab1a579f24e088cafd" + integrity sha512-h4LWKWE+wKQGhtMjZEBud7uLGhqyLwj8fpHOarZhD2uY3C9cRtk57VQ89ke3moByLXMedqs3XCHzyb4AmA2DjA== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.2" + +object.fromentries@^2.0.4: + version "2.0.4" + resolved "https://registry.yarnpkg.com/object.fromentries/-/object.fromentries-2.0.4.tgz#26e1ba5c4571c5c6f0890cef4473066456a120b8" + integrity sha512-EsFBshs5RUUpQEY1D4q/m59kMfz4YJvxuNCJcv/jWwOJr34EaVnG11ZrZa0UHB3wnzV1wx8m58T4hQL8IuNXlQ== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.0-next.2" + has "^1.0.3" + object.getownpropertydescriptors@^2.0.3, object.getownpropertydescriptors@^2.1.1: version "2.1.2" resolved "https://registry.yarnpkg.com/object.getownpropertydescriptors/-/object.getownpropertydescriptors-2.1.2.tgz#1bd63aeacf0d5d2d2f31b5e393b03a7c601a23f7" @@ -11215,6 +11326,15 @@ object.pick@^1.3.0: dependencies: isobject "^3.0.1" +object.values@^1.1.4: + version "1.1.4" + resolved "https://registry.yarnpkg.com/object.values/-/object.values-1.1.4.tgz#0d273762833e816b693a637d30073e7051535b30" + integrity sha512-TnGo7j4XSnKQoK3MfvkzqKCi0nVe/D9I9IjwTNYdb/fxYHpjrluHVOgw0AF6jrRFGMPHdfuidR09tIDiIvnaSg== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.2" + oboe@2.1.4: version "2.1.4" resolved "https://registry.yarnpkg.com/oboe/-/oboe-2.1.4.tgz#20c88cdb0c15371bb04119257d4fdd34b0aa49f6" @@ -12995,7 +13115,7 @@ regex-not@^1.0.0, regex-not@^1.0.2: extend-shallow "^3.0.2" safe-regex "^1.1.0" -regexp.prototype.flags@^1.2.0: +regexp.prototype.flags@^1.2.0, regexp.prototype.flags@^1.3.1: version "1.3.1" resolved "https://registry.yarnpkg.com/regexp.prototype.flags/-/regexp.prototype.flags-1.3.1.tgz#7ef352ae8d159e758c0eadca6f8fcb4eef07be26" integrity sha512-JiBdRBq91WlY7uRJ0ds7R+dU02i6LKi8r3BuQhNXn+kmeLN+EfHhfjqMRis1zJxnlu88hq/4dx0P2OP3APRTOA== @@ -13170,6 +13290,14 @@ resolve@1.x, resolve@^1.1.6, resolve@^1.10.0, resolve@^1.14.2, resolve@^1.20.0: is-core-module "^2.2.0" path-parse "^1.0.6" +resolve@^2.0.0-next.3: + version "2.0.0-next.3" + resolved "https://registry.yarnpkg.com/resolve/-/resolve-2.0.0-next.3.tgz#d41016293d4a8586a39ca5d9b5f15cbea1f55e46" + integrity sha512-W8LucSynKUIDu9ylraa7ueVZ7hc0uAgJBxVsQSKOXOyle8a93qXhcz+XAXZ8bIq2d6i4Ehddn6Evt+0/UwKk6Q== + dependencies: + is-core-module "^2.2.0" + path-parse "^1.0.6" + resolve@~1.17.0: version "1.17.0" resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.17.0.tgz#b25941b54968231cc2d1bb76a79cb7f2c0bf8444" @@ -14188,6 +14316,20 @@ string-width@^4.1.0, string-width@^4.2.0: is-fullwidth-code-point "^3.0.0" strip-ansi "^6.0.0" +string.prototype.matchall@^4.0.5: + version "4.0.5" + resolved "https://registry.yarnpkg.com/string.prototype.matchall/-/string.prototype.matchall-4.0.5.tgz#59370644e1db7e4c0c045277690cf7b01203c4da" + integrity sha512-Z5ZaXO0svs0M2xd/6By3qpeKpLKd9mO4v4q3oMEQrk8Ck4xOD5d5XeBOOjGrmVZZ/AHB1S0CgG4N5r1G9N3E2Q== + dependencies: + call-bind "^1.0.2" + define-properties "^1.1.3" + es-abstract "^1.18.2" + get-intrinsic "^1.1.1" + has-symbols "^1.0.2" + internal-slot "^1.0.3" + regexp.prototype.flags "^1.3.1" + side-channel "^1.0.4" + string.prototype.padend@^3.0.0: version "3.1.2" resolved "https://registry.yarnpkg.com/string.prototype.padend/-/string.prototype.padend-3.1.2.tgz#6858ca4f35c5268ebd5e8615e1327d55f59ee311" From b3e2808e7a2dcb206b8ab3ac5a0d06463873f79a Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Mon, 30 Aug 2021 18:01:47 +0300 Subject: [PATCH 16/26] Add: github action for linting --- .github/workflows/lint.yml | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .github/workflows/lint.yml diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml new file mode 100644 index 0000000..5d7b701 --- /dev/null +++ b/.github/workflows/lint.yml @@ -0,0 +1,13 @@ +name: Lint + +on: [push] + +jobs: + eslint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v1 + - uses: stefanoeb/eslint-action@1.0.2 + working-directory: ./js + with: + files: js/packages From ba7bd508dca80e28126b76b5b9648eafe8237ece Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Mon, 30 Aug 2021 18:25:36 +0300 Subject: [PATCH 17/26] Add: github action for linting --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 5d7b701..f16bacf 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -8,6 +8,6 @@ jobs: steps: - uses: actions/checkout@v1 - uses: stefanoeb/eslint-action@1.0.2 - working-directory: ./js with: + working-directory: ./js files: js/packages From 91b613dbc7cc102bd900c3f31f47dbcc1bef7f29 Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Mon, 30 Aug 2021 18:26:35 +0300 Subject: [PATCH 18/26] Add: github action for linting --- .github/workflows/lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index f16bacf..15a51a0 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -9,5 +9,5 @@ jobs: - uses: actions/checkout@v1 - uses: stefanoeb/eslint-action@1.0.2 with: - working-directory: ./js + entryPoint: ./js files: js/packages From 908ece91b6a7184e8d8782be1ccaca3587f8d0d8 Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Mon, 30 Aug 2021 18:32:45 +0300 Subject: [PATCH 19/26] Add: github action for linting --- .github/workflows/lint.yml | 11 +++++++---- js/package.json | 3 ++- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 15a51a0..e04e7f6 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -7,7 +7,10 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 - - uses: stefanoeb/eslint-action@1.0.2 - with: - entryPoint: ./js - files: js/packages + - name: Install modules + run: yarn + working-directory: ./js + - name: Run ESLint + run: yarn lint:eslint + working-directory: ./js + diff --git a/js/package.json b/js/package.json index e365023..fe6581b 100644 --- a/js/package.json +++ b/js/package.json @@ -14,7 +14,8 @@ "bootstrap": "lerna link && lerna bootstrap", "build": "lerna run build", "start": "cross-env CI=true lerna run start --scope @oyster/common --stream --parallel --scope web", - "lint": "eslint 'packages/*/{src,test}/**/*.ts' && prettier -c 'packages/*/{src,test}/**/*.ts'", + "lint": "npm run lint:eslint && prettier -c 'packages/*/{src,test}/**/*.ts'", + "lint:eslint": "eslint 'packages/*/{src,test}/**/*.ts'", "lint:fix": "eslint --fix 'packages/*/{src,test}/**/*.ts' && prettier --write 'packages/*/{src,test}/**/*.{ts,tsx}'", "format:fix": "lerna run format:fix", "deploy": "run-s deploy:docs build deploy:apps && gh-pages -d docs", From 137ff3baf7451efa6e320483c290e693eb4cd803 Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Tue, 31 Aug 2021 16:27:23 +0300 Subject: [PATCH 20/26] Update .github/workflows/lint.yml Co-authored-by: Sergey Ponomarev --- .github/workflows/lint.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index e04e7f6..fbf5077 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -1,6 +1,9 @@ name: Lint -on: [push] +on: + pull_request: + push: + branches: [master] jobs: eslint: From baa8d36117b2705e0ad3bf5b50c412bc16921ad7 Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Tue, 31 Aug 2021 16:35:04 +0300 Subject: [PATCH 21/26] Turn on lint for PR and master --- .github/workflows/lint.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index fbf5077..713e8c9 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,10 +10,16 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v1 + + - uses: actions/cache@v2 + with: + path: '**/node_modules' + key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }} + - name: Install modules - run: yarn + run: yarn install working-directory: ./js + - name: Run ESLint run: yarn lint:eslint working-directory: ./js - From 542d2a7b0fce29701033891100fd6656e8ea731d Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Tue, 31 Aug 2021 16:45:37 +0300 Subject: [PATCH 22/26] change working dirs paths --- .github/workflows/lint.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 713e8c9..bc0299a 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -18,8 +18,8 @@ jobs: - name: Install modules run: yarn install - working-directory: ./js + working-directory: js - name: Run ESLint run: yarn lint:eslint - working-directory: ./js + working-directory: js From c0bba430b865d28fac1cec6a8ea0c5cb2ad8970e Mon Sep 17 00:00:00 2001 From: Efremov Alexey Date: Mon, 6 Sep 2021 13:34:03 +0300 Subject: [PATCH 23/26] update --- js/package.json | 4 +- js/packages/cli/src/cli.ts | 38 +++++++++---------- js/packages/cli/src/helper.ts | 7 +++- .../web/src/actions/mintEditionsIntoWallet.ts | 4 +- 4 files changed, 27 insertions(+), 26 deletions(-) diff --git a/js/package.json b/js/package.json index fe6581b..b8eba9a 100644 --- a/js/package.json +++ b/js/package.json @@ -14,9 +14,9 @@ "bootstrap": "lerna link && lerna bootstrap", "build": "lerna run build", "start": "cross-env CI=true lerna run start --scope @oyster/common --stream --parallel --scope web", - "lint": "npm run lint:eslint && prettier -c 'packages/*/{src,test}/**/*.ts'", + "lint": "prettier -c 'packages/*/{src,test}/**/*.ts' && npm run lint:eslint", "lint:eslint": "eslint 'packages/*/{src,test}/**/*.ts'", - "lint:fix": "eslint --fix 'packages/*/{src,test}/**/*.ts' && prettier --write 'packages/*/{src,test}/**/*.{ts,tsx}'", + "lint:fix": "prettier --write 'packages/*/{src,test}/**/*.{ts,tsx}' && eslint --fix 'packages/*/{src,test}/**/*.ts'", "format:fix": "lerna run format:fix", "deploy": "run-s deploy:docs build deploy:apps && gh-pages -d docs", "deploy:docs": "lerna run docs", diff --git a/js/packages/cli/src/cli.ts b/js/packages/cli/src/cli.ts index eea3372..8b983da 100755 --- a/js/packages/cli/src/cli.ts +++ b/js/packages/cli/src/cli.ts @@ -1,6 +1,5 @@ #!/usr/bin/env node import * as fs from 'fs'; -import Arweave from 'arweave'; import * as path from 'path'; import fetch from 'node-fetch'; import FormData from 'form-data'; @@ -17,7 +16,6 @@ import { SYSVAR_RENT_PUBKEY, TransactionInstruction, } from '@solana/web3.js'; -import { token } from '@project-serum/anchor/dist/utils'; const CACHE_PATH = './.cache'; const PAYMENT_WALLET = new anchor.web3.PublicKey( @@ -132,12 +130,12 @@ const getCandyMachine = async (config: anchor.web3.PublicKey, uuid: string) => { ); }; -const getConfig = async (authority: anchor.web3.PublicKey, uuid: string) => { - return await anchor.web3.PublicKey.findProgramAddress( - [Buffer.from(CANDY_MACHINE), authority.toBuffer(), Buffer.from(uuid)], - programId, - ); -}; +// const getConfig = async (authority: anchor.web3.PublicKey, uuid: string) => { +// return await anchor.web3.PublicKey.findProgramAddress( +// [Buffer.from(CANDY_MACHINE), authority.toBuffer(), Buffer.from(uuid)], +// programId, +// ); +// }; const getMetadata = async ( mint: anchor.web3.PublicKey, @@ -252,7 +250,7 @@ program .option('-c, --cache-name ', 'Cache file name') .action(async (files: string[], options, cmd) => { const extension = '.png'; - const { startWith, keypair } = cmd.opts(); + const { keypair } = cmd.opts(); const cacheName = program.getOptionValue('cacheName') || 'temp'; const cachePath = path.join(CACHE_PATH, cacheName); const savedContent = fs.existsSync(cachePath) @@ -317,7 +315,7 @@ program ? new anchor.web3.PublicKey(cacheContent.program.config) : undefined; - const block = await solConnection.getRecentBlockhash(); + await solConnection.getRecentBlockhash(); for (let i = 0; i < SIZE; i++) { const image = images[i]; const imageName = path.basename(image); @@ -329,7 +327,7 @@ program let link = cacheContent?.items?.[index]?.link; if (!link || !cacheContent.program.uuid) { - const imageBuffer = Buffer.from(fs.readFileSync(image)); + //const imageBuffer = Buffer.from(fs.readFileSync(image)); const manifestPath = image.replace(extension, '.json'); const manifestContent = fs .readFileSync(manifestPath) @@ -339,7 +337,7 @@ program const manifest = JSON.parse(manifestContent); const manifestBuffer = Buffer.from(JSON.stringify(manifest)); - const sizeInBytes = imageBuffer.length + manifestBuffer.length; + // const sizeInBytes = imageBuffer.length + manifestBuffer.length; if (i === 0 && !cacheContent.program.uuid) { // initialize config @@ -374,7 +372,7 @@ program } if (!link) { - let instructions = [ + const instructions = [ anchor.web3.SystemProgram.transfer({ fromPubkey: walletKey.publicKey, toPubkey: PAYMENT_WALLET, @@ -457,7 +455,7 @@ program '-', keys[indexes[indexes.length - 1]], ); - const txId = await anchorProgram.rpc.addConfigLines( + await anchorProgram.rpc.addConfigLines( ind, indexes.map(i => ({ uri: cacheContent.items[keys[i]].link, @@ -526,7 +524,7 @@ program }); const idl = await anchor.Program.fetchIdl(programId, provider); const anchorProgram = new anchor.Program(idl, programId, provider); - const [candyMachine, _] = await getCandyMachine( + const [candyMachine] = await getCandyMachine( new anchor.web3.PublicKey(cachedContent.program.config), cachedContent.program.uuid, ); @@ -579,7 +577,7 @@ program config, cachedContent.program.uuid, ); - const tx = await anchorProgram.rpc.initializeCandyMachine( + await anchorProgram.rpc.initializeCandyMachine( bump, { uuid: cachedContent.program.uuid, @@ -614,8 +612,8 @@ program ); const { keypair } = cmd.opts(); - const solPriceStr = program.getOptionValue('price') || '1'; - const lamports = parseInt(solPriceStr) * LAMPORTS_PER_SOL; + // const solPriceStr = program.getOptionValue('price') || '1'; + //const lamports = parseInt(solPriceStr) * LAMPORTS_PER_SOL; const cacheName = program.getOptionValue('cacheName') || 'temp'; const cachePath = path.join(CACHE_PATH, cacheName); @@ -635,7 +633,7 @@ program const idl = await anchor.Program.fetchIdl(programId, provider); const anchorProgram = new anchor.Program(idl, programId, provider); const config = new anchor.web3.PublicKey(cachedContent.program.config); - const [candyMachine, bump] = await getCandyMachine( + const [candyMachine] = await getCandyMachine( config, cachedContent.program.uuid, ); @@ -700,7 +698,7 @@ program program .command('verify') .option('-c, --cache-name ', 'Cache file name') - .action(async (directory, second, options) => { + .action(async () => { const solConnection = new anchor.web3.Connection( `https://api.${ENV}.solana.com/`, ); diff --git a/js/packages/cli/src/helper.ts b/js/packages/cli/src/helper.ts index f4d419d..2dae00f 100644 --- a/js/packages/cli/src/helper.ts +++ b/js/packages/cli/src/helper.ts @@ -35,7 +35,7 @@ export const sendTransactionWithRetryWithKeypair = async ( block?: BlockhashAndFeeCalculator, beforeSend?: () => void, ) => { - let transaction = new Transaction(); + const transaction = new Transaction(); instructions.forEach(instruction => transaction.add(instruction)); transaction.recentBlockhash = ( block || (await connection.getRecentBlockhash(commitment)) @@ -135,7 +135,9 @@ export async function sendSignedTransaction({ simulateResult = ( await simulateTransaction(connection, signedTransaction, 'single') ).value; - } catch (e) {} + } catch (e) { + console.error('Simulate Transaction error', e); + } if (simulateResult && simulateResult.err) { if (simulateResult.logs) { for (let i = simulateResult.logs.length - 1; i >= 0; --i) { @@ -198,6 +200,7 @@ async function awaitTransactionSignatureConfirmation( err: null, }; let subId = 0; + // eslint-disable-next-line no-async-promise-executor status = await new Promise(async (resolve, reject) => { setTimeout(() => { if (done) { diff --git a/js/packages/web/src/actions/mintEditionsIntoWallet.ts b/js/packages/web/src/actions/mintEditionsIntoWallet.ts index 29e1fbe..67a4f56 100644 --- a/js/packages/web/src/actions/mintEditionsIntoWallet.ts +++ b/js/packages/web/src/actions/mintEditionsIntoWallet.ts @@ -24,8 +24,8 @@ export async function mintEditionsToWallet( editions: number = 1, mintDestination: StringPublicKey, ) { - let signers: Array> = []; - let instructions: Array> = []; + const signers: Array> = []; + const instructions: Array> = []; let currSignerBatch: Array = []; let currInstrBatch: Array = []; From e529eee3d5a823965eea603b267777f2e8c1a995 Mon Sep 17 00:00:00 2001 From: B <264380+bartosz-lipinski@users.noreply.github.com> Date: Mon, 6 Sep 2021 11:25:41 -0500 Subject: [PATCH 24/26] Add env option to bundler (#320) * feature: add env to cli * fix: format --- js/packages/cli/src/cli.ts | 29 ++++++++++++++--------------- 1 file changed, 14 insertions(+), 15 deletions(-) diff --git a/js/packages/cli/src/cli.ts b/js/packages/cli/src/cli.ts index 8b983da..7ca9d51 100755 --- a/js/packages/cli/src/cli.ts +++ b/js/packages/cli/src/cli.ts @@ -21,7 +21,6 @@ const CACHE_PATH = './.cache'; const PAYMENT_WALLET = new anchor.web3.PublicKey( 'HvwC9QSAzvGXhhVrgPmauVwFWcYZhne3hVot9EbHuFTm', ); -const ENV = 'devnet'; const CANDY_MACHINE = 'candy_machine'; const programId = new anchor.web3.PublicKey( @@ -130,13 +129,6 @@ const getCandyMachine = async (config: anchor.web3.PublicKey, uuid: string) => { ); }; -// const getConfig = async (authority: anchor.web3.PublicKey, uuid: string) => { -// return await anchor.web3.PublicKey.findProgramAddress( -// [Buffer.from(CANDY_MACHINE), authority.toBuffer(), Buffer.from(uuid)], -// programId, -// ); -// }; - const getMetadata = async ( mint: anchor.web3.PublicKey, ): Promise => { @@ -194,7 +186,6 @@ const createConfig = async function ( const config = anchor.web3.Keypair.generate(); const uuid = config.publicKey.toBase58().slice(0, 6); - return { config: config.publicKey, uuid, @@ -248,10 +239,12 @@ program .option('-s, --start-with', 'Image index to start with', '0') .option('-n, --number', 'Number of images to upload', '10000') .option('-c, --cache-name ', 'Cache file name') + .option('-e, --env ', 'Environment') .action(async (files: string[], options, cmd) => { const extension = '.png'; const { keypair } = cmd.opts(); const cacheName = program.getOptionValue('cacheName') || 'temp'; + const ENV = program.getOptionValue('env') || 'devnet'; const cachePath = path.join(CACHE_PATH, cacheName); const savedContent = fs.existsSync(cachePath) ? JSON.parse(fs.readFileSync(cachePath).toString()) @@ -327,7 +320,7 @@ program let link = cacheContent?.items?.[index]?.link; if (!link || !cacheContent.program.uuid) { - //const imageBuffer = Buffer.from(fs.readFileSync(image)); + // const imageBuffer = Buffer.from(fs.readFileSync(image)); const manifestPath = image.replace(extension, '.json'); const manifestContent = fs .readFileSync(manifestPath) @@ -444,7 +437,7 @@ program const indexes = allIndexesInSlice.slice(offset, offset + 10); const onChain = indexes.filter(i => { const index = keys[i]; - return cacheContent.items[index]?.onChain; + return cacheContent.items[index]?.onChain || false; }); const ind = keys[indexes[0]]; @@ -500,7 +493,9 @@ program .option('-k, --keypair ', 'Solana wallet') .option('-c, --cache-name ', 'Cache file name') .option('-d, --date ', 'timestamp - eg "04 Dec 1995 00:12:00 GMT"') + .option('-e, --env ', 'Environment') .action(async (directory, cmd) => { + const ENV = program.getOptionValue('env') || 'devnet'; const solConnection = new anchor.web3.Connection( `https://api.${ENV}.solana.com/`, ); @@ -547,7 +542,9 @@ program .option('-k, --keypair ', 'Solana wallet') .option('-c, --cache-name ', 'Cache file name') .option('-p, --price ', 'SOL price') + .option('-e, --env ', 'Environment') .action(async (directory, cmd) => { + const ENV = program.getOptionValue('env') || 'devnet'; const solConnection = new anchor.web3.Connection( `https://api.${ENV}.solana.com/`, ); @@ -606,14 +603,16 @@ program .command('mint_one_token') .option('-k, --keypair ', `The purchaser's wallet key`) .option('-c, --cache-name ', 'Cache file name') + .option('-e, --env ', 'Environment') .action(async (directory, cmd) => { + const ENV = program.getOptionValue('env') || 'devnet'; const solConnection = new anchor.web3.Connection( `https://api.${ENV}.solana.com/`, ); const { keypair } = cmd.opts(); // const solPriceStr = program.getOptionValue('price') || '1'; - //const lamports = parseInt(solPriceStr) * LAMPORTS_PER_SOL; + // const lamports = parseInt(solPriceStr) * LAMPORTS_PER_SOL; const cacheName = program.getOptionValue('cacheName') || 'temp'; const cachePath = path.join(CACHE_PATH, cacheName); @@ -698,7 +697,9 @@ program program .command('verify') .option('-c, --cache-name ', 'Cache file name') - .action(async () => { + .option('-e, --env ', 'Environment') + .action(async (directory, second, options) => { + const ENV = program.getOptionValue('env') || 'devnet'; const solConnection = new anchor.web3.Connection( `https://api.${ENV}.solana.com/`, ); @@ -711,8 +712,6 @@ program const config = await solConnection.getAccountInfo( new PublicKey(cachedContent.program.config), ); - const number = new BN(config.data.slice(247, 247 + 4), undefined, 'le'); - console.log('Number', number.toNumber()); const keys = Object.keys(cachedContent.items); for (let i = 0; i < keys.length; i++) { From 929a5e269736147b58d846c0398c9804ddb407a4 Mon Sep 17 00:00:00 2001 From: Bertrand Date: Tue, 7 Sep 2021 03:52:27 +0200 Subject: [PATCH 25/26] allow float price (#321) --- js/packages/cli/src/cli.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/packages/cli/src/cli.ts b/js/packages/cli/src/cli.ts index 7ca9d51..0677735 100755 --- a/js/packages/cli/src/cli.ts +++ b/js/packages/cli/src/cli.ts @@ -552,7 +552,7 @@ program const { keypair } = cmd.opts(); const solPriceStr = cmd.getOptionValue('price') || '1'; - const lamports = parseInt(solPriceStr) * LAMPORTS_PER_SOL; + const lamports = Math.ceil(parseFloat(solPriceStr) * LAMPORTS_PER_SOL); const cacheName = program.getOptionValue('cacheName') || 'temp'; const cachePath = path.join(CACHE_PATH, cacheName); From 4a1b7d2f674013bc8bd3149294c66b03b27120d0 Mon Sep 17 00:00:00 2001 From: Jordan Prince Date: Tue, 7 Sep 2021 14:02:10 -0500 Subject: [PATCH 26/26] Feat/metaplex cli overhaul merged (#334) * feat: candy-machine cli overhaul, so it's more readable - extracted constants - separated some helpers out - removed duplication of crucial parts (like cache management, instruction creation, etc) - renamed some variables to make them more accurate - added `env` option and removed `url` option - used env in all operations - added some error handling * more cleanups * Add env option to bundler (#320) * feature: add env to cli * fix: format * more cleanups * added error checking * eslint updates * Some small bugfixes Co-authored-by: Radoslaw Domanski Co-authored-by: B <264380+bartosz-lipinski@users.noreply.github.com> --- js/packages/cli/src/cli.ts | 913 +++++++----------- js/packages/cli/src/helpers/accounts.ts | 144 +++ js/packages/cli/src/helpers/constants.ts | 42 + js/packages/cli/src/helpers/instructions.ts | 89 ++ .../{helper.ts => helpers/transactions.ts} | 73 +- js/packages/cli/src/helpers/various.ts | 93 ++ js/packages/cli/src/types.ts | 56 ++ rust/nft-candy-machine/src/lib.rs | 2 +- 8 files changed, 807 insertions(+), 605 deletions(-) create mode 100644 js/packages/cli/src/helpers/accounts.ts create mode 100644 js/packages/cli/src/helpers/constants.ts create mode 100644 js/packages/cli/src/helpers/instructions.ts rename js/packages/cli/src/{helper.ts => helpers/transactions.ts} (83%) create mode 100644 js/packages/cli/src/helpers/various.ts create mode 100644 js/packages/cli/src/types.ts diff --git a/js/packages/cli/src/cli.ts b/js/packages/cli/src/cli.ts index 0677735..bfce884 100755 --- a/js/packages/cli/src/cli.ts +++ b/js/packages/cli/src/cli.ts @@ -1,225 +1,50 @@ #!/usr/bin/env node import * as fs from 'fs'; import * as path from 'path'; -import fetch from 'node-fetch'; import FormData from 'form-data'; import { program } from 'commander'; import * as anchor from '@project-serum/anchor'; import BN from 'bn.js'; import { MintLayout, Token } from '@solana/spl-token'; -import { sendTransactionWithRetryWithKeypair, fromUTF8Array } from './helper'; import { - LAMPORTS_PER_SOL, - PublicKey, - SystemProgram, - SYSVAR_RENT_PUBKEY, - TransactionInstruction, -} from '@solana/web3.js'; + chunks, + fromUTF8Array, + loadCache, + parsePrice, + saveCache, + upload, +} from './helpers/various'; +import { Keypair, PublicKey, SystemProgram } from '@solana/web3.js'; +import { createAssociatedTokenAccountInstruction } from './helpers/instructions'; +import { + CACHE_PATH, + CONFIG_ARRAY_START, + CONFIG_LINE_SIZE, + EXTENSION_JSON, + EXTENSION_PNG, + PAYMENT_WALLET, + TOKEN_METADATA_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from './helpers/constants'; +import { sendTransactionWithRetryWithKeypair } from './helpers/transactions'; +import { + createConfig, + getCandyMachineAddress, + getMasterEdition, + getMetadata, + getTokenWallet, + loadAnchorProgram, + loadWalletKey, +} from './helpers/accounts'; +import { Config } from './types'; -const CACHE_PATH = './.cache'; -const PAYMENT_WALLET = new anchor.web3.PublicKey( - 'HvwC9QSAzvGXhhVrgPmauVwFWcYZhne3hVot9EbHuFTm', -); -const CANDY_MACHINE = 'candy_machine'; - -const programId = new anchor.web3.PublicKey( - 'cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ', -); -const TOKEN_METADATA_PROGRAM_ID = new PublicKey( - 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', -); - -const SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new PublicKey( - 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', -); -const TOKEN_PROGRAM_ID = new PublicKey( - 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', -); -const getTokenWallet = async function (wallet: PublicKey, mint: PublicKey) { - return ( - await PublicKey.findProgramAddress( - [wallet.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], - SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, - ) - )[0]; -}; - -export function createAssociatedTokenAccountInstruction( - associatedTokenAddress: PublicKey, - payer: PublicKey, - walletAddress: PublicKey, - splTokenMintAddress: PublicKey, -) { - const keys = [ - { - pubkey: payer, - isSigner: true, - isWritable: true, - }, - { - pubkey: associatedTokenAddress, - isSigner: false, - isWritable: true, - }, - { - pubkey: walletAddress, - isSigner: false, - isWritable: false, - }, - { - pubkey: splTokenMintAddress, - isSigner: false, - isWritable: false, - }, - { - pubkey: SystemProgram.programId, - isSigner: false, - isWritable: false, - }, - { - pubkey: TOKEN_PROGRAM_ID, - isSigner: false, - isWritable: false, - }, - { - pubkey: SYSVAR_RENT_PUBKEY, - isSigner: false, - isWritable: false, - }, - ]; - return new TransactionInstruction({ - keys, - programId: SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, - data: Buffer.from([]), - }); -} - -function chunks(array, size) { - return Array.apply(0, new Array(Math.ceil(array.length / size))).map( - (_, index) => array.slice(index * size, (index + 1) * size), - ); -} - -const configArrayStart = - 32 + // authority - 4 + - 6 + // uuid + u32 len - 4 + - 10 + // u32 len + symbol - 2 + // seller fee basis points - 1 + - 4 + - 5 * 34 + // optional + u32 len + actual vec - 8 + //max supply - 1 + //is mutable - 1 + // retain authority - 4; // max number of lines; -const configLineSize = 4 + 32 + 4 + 200; program.version('0.0.1'); if (!fs.existsSync(CACHE_PATH)) { fs.mkdirSync(CACHE_PATH); } -const getCandyMachine = async (config: anchor.web3.PublicKey, uuid: string) => { - return await anchor.web3.PublicKey.findProgramAddress( - [Buffer.from(CANDY_MACHINE), config.toBuffer(), Buffer.from(uuid)], - programId, - ); -}; - -const getMetadata = async ( - mint: anchor.web3.PublicKey, -): Promise => { - return ( - await anchor.web3.PublicKey.findProgramAddress( - [ - Buffer.from('metadata'), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - ], - TOKEN_METADATA_PROGRAM_ID, - ) - )[0]; -}; - -const getMasterEdition = async ( - mint: anchor.web3.PublicKey, -): Promise => { - return ( - await anchor.web3.PublicKey.findProgramAddress( - [ - Buffer.from('metadata'), - TOKEN_METADATA_PROGRAM_ID.toBuffer(), - mint.toBuffer(), - Buffer.from('edition'), - ], - TOKEN_METADATA_PROGRAM_ID, - ) - )[0]; -}; - -const createConfig = async function ( - anchorProgram: anchor.Program, - payerWallet: anchor.web3.Keypair, - configData: { - maxNumberOfLines: BN; - symbol: string; - sellerFeeBasisPoints: number; - isMutable: boolean; - maxSupply: BN; - retainAuthority: boolean; - creators: { - address: anchor.web3.PublicKey; - verified: boolean; - share: number; - }[]; - }, -) { - const size = - configArrayStart + - 4 + - configData.maxNumberOfLines.toNumber() * configLineSize + - 4 + - Math.ceil(configData.maxNumberOfLines.toNumber() / 8); - - const config = anchor.web3.Keypair.generate(); - const uuid = config.publicKey.toBase58().slice(0, 6); - return { - config: config.publicKey, - uuid, - txId: await anchorProgram.rpc.initializeConfig( - { - uuid, - ...configData, - }, - { - accounts: { - config: config.publicKey, - authority: payerWallet.publicKey, - payer: payerWallet.publicKey, - systemProgram: anchor.web3.SystemProgram.programId, - rent: anchor.web3.SYSVAR_RENT_PUBKEY, - }, - signers: [payerWallet, config], - instructions: [ - anchor.web3.SystemProgram.createAccount({ - fromPubkey: payerWallet.publicKey, - newAccountPubkey: config.publicKey, - space: size, - lamports: - await anchorProgram.provider.connection.getMinimumBalanceForRentExemption( - size, - ), - programId: programId, - }), - ], - }, - ), - }; -}; - program .command('upload') .argument( @@ -230,25 +55,42 @@ program }, ) .option( - '-u, --url', - 'Solana cluster url', - 'https://api.mainnet-beta.solana.com/', + '-e, --env ', + 'Solana cluster env name', + 'devnet', //mainnet-beta, testnet, devnet + ) + .option( + '-k, --keypair ', + `Solana wallet location`, + '--keypair not provided', ) - .option('-k, --keypair ', 'Solana wallet') // .argument('[second]', 'integer argument', (val) => parseInt(val), 1000) - .option('-s, --start-with', 'Image index to start with', '0') - .option('-n, --number', 'Number of images to upload', '10000') - .option('-c, --cache-name ', 'Cache file name') - .option('-e, --env ', 'Environment') + .option('-n, --number ', 'Number of images to upload') + .option('-c, --cache-name ', 'Cache file name', 'temp') .action(async (files: string[], options, cmd) => { - const extension = '.png'; - const { keypair } = cmd.opts(); - const cacheName = program.getOptionValue('cacheName') || 'temp'; - const ENV = program.getOptionValue('env') || 'devnet'; - const cachePath = path.join(CACHE_PATH, cacheName); - const savedContent = fs.existsSync(cachePath) - ? JSON.parse(fs.readFileSync(cachePath).toString()) - : undefined; + const { number, keypair, env, cacheName } = cmd.opts(); + const parsedNumber = parseInt(number); + + const pngFileCount = files.filter(it => { + return it.endsWith(EXTENSION_PNG); + }).length; + const jsonFileCount = files.filter(it => { + return it.endsWith(EXTENSION_JSON); + }).length; + + if (pngFileCount !== jsonFileCount) { + throw new Error( + `number of png files (${pngFileCount}) is different than the number of json files (${jsonFileCount})`, + ); + } + + if (parsedNumber < pngFileCount) { + throw new Error( + `max number (${parsedNumber})cannot be smaller than the number of elements in the source folder (${pngFileCount})`, + ); + } + + const savedContent = loadCache(cacheName, env); const cacheContent = savedContent || {}; if (!cacheContent.program) { @@ -266,8 +108,8 @@ program const newFiles = []; files.forEach(f => { - if (!seen[f.replace(extension, '').split('/').pop()]) { - seen[f.replace(extension, '').split('/').pop()] = true; + if (!seen[f.replace(EXTENSION_PNG, '').split('/').pop()]) { + seen[f.replace(EXTENSION_PNG, '').split('/').pop()] = true; newFiles.push(f); } }); @@ -278,41 +120,20 @@ program } }); - const images = newFiles.filter(val => path.extname(val) === extension); - const SIZE = images.length; // images.length; - const walletKey = anchor.web3.Keypair.fromSecretKey( - new Uint8Array(JSON.parse(fs.readFileSync(keypair).toString())), - ); + const images = newFiles.filter(val => path.extname(val) === EXTENSION_PNG); + const SIZE = images.length; - // const conversionRates = JSON.parse( - // await ( - // await fetch( - // 'https://api.coingecko.com/api/v3/simple/price?ids=solana,arweave&vs_currencies=usd', - // ) - // ).text(), - // ); - // const baseCost = fetch(``); - // const increment = fetch(``); + const walletKeyPair = loadWalletKey(keypair); + const anchorProgram = await loadAnchorProgram(walletKeyPair, env); - const solConnection = new anchor.web3.Connection( - `https://api.${ENV}.solana.com/`, - ); - - const walletWrapper = new anchor.Wallet(walletKey); - const provider = new anchor.Provider(solConnection, walletWrapper, { - preflightCommitment: 'recent', - }); - const idl = await anchor.Program.fetchIdl(programId, provider); - const anchorProgram = new anchor.Program(idl, programId, provider); let config = cacheContent.program.config - ? new anchor.web3.PublicKey(cacheContent.program.config) + ? new PublicKey(cacheContent.program.config) : undefined; - await solConnection.getRecentBlockhash(); for (let i = 0; i < SIZE; i++) { const image = images[i]; const imageName = path.basename(image); - const index = imageName.replace(extension, ''); + const index = imageName.replace(EXTENSION_PNG, ''); console.log(`Processing file: ${index}`); @@ -320,8 +141,7 @@ program let link = cacheContent?.items?.[index]?.link; if (!link || !cacheContent.program.uuid) { - // const imageBuffer = Buffer.from(fs.readFileSync(image)); - const manifestPath = image.replace(extension, '.json'); + const manifestPath = image.replace(EXTENSION_PNG, '.json'); const manifestContent = fs .readFileSync(manifestPath) .toString() @@ -330,13 +150,13 @@ program const manifest = JSON.parse(manifestContent); const manifestBuffer = Buffer.from(JSON.stringify(manifest)); - // const sizeInBytes = imageBuffer.length + manifestBuffer.length; if (i === 0 && !cacheContent.program.uuid) { // initialize config + console.log(`initializing config`); try { - const res = await createConfig(anchorProgram, walletKey, { - maxNumberOfLines: new BN(SIZE), + const res = await createConfig(anchorProgram, walletKeyPair, { + maxNumberOfLines: new BN(parsedNumber || SIZE), symbol: manifest.symbol, sellerFeeBasisPoints: manifest.seller_fee_basis_points, isMutable: true, @@ -344,8 +164,8 @@ program retainAuthority: true, creators: manifest.properties.creators.map(creator => { return { - address: new anchor.web3.PublicKey(creator.address), - verified: false, + address: new PublicKey(creator.address), + verified: true, share: creator.share, }; }), @@ -354,10 +174,11 @@ program cacheContent.program.config = res.config.toBase58(); config = res.config; - fs.writeFileSync( - path.join(CACHE_PATH, cacheName), - JSON.stringify(cacheContent), + console.log( + `initialized config for a candy machine with uuid: ${res.uuid}`, ); + + saveCache(cacheName, env, cacheContent); } catch (exx) { console.error('Error deploying config to Solana network.', exx); // console.error(exx); @@ -367,15 +188,15 @@ program if (!link) { const instructions = [ anchor.web3.SystemProgram.transfer({ - fromPubkey: walletKey.publicKey, + fromPubkey: walletKeyPair.publicKey, toPubkey: PAYMENT_WALLET, lamports: storageCost, }), ]; const tx = await sendTransactionWithRetryWithKeypair( - solConnection, - walletKey, + anchorProgram.provider.connection, + walletKeyPair, instructions, [], 'single', @@ -386,19 +207,14 @@ program // payment transaction const data = new FormData(); data.append('transaction', tx['txid']); - data.append('env', ENV); - data.append('file[]', fs.createReadStream(image), `image.png`); + data.append('env', env); + data.append('file[]', fs.createReadStream(image), { + filename: `image.png`, + contentType: 'image/png', + }); data.append('file[]', manifestBuffer, 'metadata.json'); try { - const result = await ( - await fetch( - 'https://us-central1-principal-lane-200702.cloudfunctions.net/uploadFile3', - { - method: 'POST', - body: data, - }, - ) - ).json(); + const result = await upload(data, manifest, index); const metadataFile = result.messages?.find( m => m.filename === 'manifest.json', @@ -407,16 +223,13 @@ program link = `https://arweave.net/${metadataFile.transactionId}`; console.log(`File uploaded: ${link}`); } - + console.log('setting cache for ', index); cacheContent.items[index] = { link, name: manifest.name, onChain: false, }; - fs.writeFileSync( - path.join(CACHE_PATH, cacheName), - JSON.stringify(cacheContent), - ); + saveCache(cacheName, env, cacheContent); } catch (er) { console.error(`Error uploading file ${index}`, er); } @@ -424,6 +237,7 @@ program } } + let updateSuccessful = true; const keys = Object.keys(cacheContent.items); try { await Promise.all( @@ -443,35 +257,39 @@ program if (onChain.length != indexes.length) { console.log( - 'Writing indices ', - ind, - '-', - keys[indexes[indexes.length - 1]], + `Writing indices ${ind}-${keys[indexes[indexes.length - 1]]}`, ); - await anchorProgram.rpc.addConfigLines( - ind, - indexes.map(i => ({ - uri: cacheContent.items[keys[i]].link, - name: cacheContent.items[keys[i]].name, - })), - { - accounts: { - config, - authority: walletKey.publicKey, + try { + await anchorProgram.rpc.addConfigLines( + ind, + indexes.map(i => ({ + uri: cacheContent.items[keys[i]].link, + name: cacheContent.items[keys[i]].name, + })), + { + accounts: { + config, + authority: walletKeyPair.publicKey, + }, + signers: [walletKeyPair], }, - signers: [walletKey], - }, - ); - indexes.forEach(i => { - cacheContent.items[keys[i]] = { - ...cacheContent.items[keys[i]], - onChain: true, - }; - }); - fs.writeFileSync( - path.join(CACHE_PATH, cacheName), - JSON.stringify(cacheContent), - ); + ); + indexes.forEach(i => { + cacheContent.items[keys[i]] = { + ...cacheContent.items[keys[i]], + onChain: true, + }; + }); + saveCache(cacheName, env, cacheContent); + } catch (e) { + console.log( + `saving config line ${ind}-${ + keys[indexes[indexes.length - 1]] + } failed`, + e, + ); + updateSuccessful = false; + } } } }, @@ -480,250 +298,48 @@ program } catch (e) { console.error(e); } finally { - fs.writeFileSync( - path.join(CACHE_PATH, cacheName), - JSON.stringify(cacheContent), - ); + saveCache(cacheName, env, cacheContent); } - console.log('Done'); - // TODO: start candy machine - }); -program - .command('set_start_date') - .option('-k, --keypair ', 'Solana wallet') - .option('-c, --cache-name ', 'Cache file name') - .option('-d, --date ', 'timestamp - eg "04 Dec 1995 00:12:00 GMT"') - .option('-e, --env ', 'Environment') - .action(async (directory, cmd) => { - const ENV = program.getOptionValue('env') || 'devnet'; - const solConnection = new anchor.web3.Connection( - `https://api.${ENV}.solana.com/`, - ); - - const { keypair } = cmd.opts(); - - const cacheName = cmd.getOptionValue('cacheName') || 'temp'; - const cachePath = path.join(CACHE_PATH, cacheName); - const cachedContent = fs.existsSync(cachePath) - ? JSON.parse(fs.readFileSync(cachePath).toString()) - : undefined; - - const date = cmd.getOptionValue('date'); - const secondsSinceEpoch = (date ? Date.parse(date) : Date.now()) / 1000; - const walletKey = anchor.web3.Keypair.fromSecretKey( - new Uint8Array(JSON.parse(fs.readFileSync(keypair).toString())), - ); - const walletWrapper = new anchor.Wallet(walletKey); - const provider = new anchor.Provider(solConnection, walletWrapper, { - preflightCommitment: 'recent', - }); - const idl = await anchor.Program.fetchIdl(programId, provider); - const anchorProgram = new anchor.Program(idl, programId, provider); - const [candyMachine] = await getCandyMachine( - new anchor.web3.PublicKey(cachedContent.program.config), - cachedContent.program.uuid, - ); - const tx = await anchorProgram.rpc.updateCandyMachine( - null, - new anchor.BN(secondsSinceEpoch), - { - accounts: { - candyMachine, - authority: walletKey.publicKey, - }, - }, - ); - - console.log('Done', secondsSinceEpoch, tx); + console.log(`Done. Successful = ${updateSuccessful}. If 'false' - rerun`); }); -program - .command('create_candy_machine') - .option('-k, --keypair ', 'Solana wallet') - .option('-c, --cache-name ', 'Cache file name') - .option('-p, --price ', 'SOL price') - .option('-e, --env ', 'Environment') - .action(async (directory, cmd) => { - const ENV = program.getOptionValue('env') || 'devnet'; - const solConnection = new anchor.web3.Connection( - `https://api.${ENV}.solana.com/`, - ); - - const { keypair } = cmd.opts(); - const solPriceStr = cmd.getOptionValue('price') || '1'; - - const lamports = Math.ceil(parseFloat(solPriceStr) * LAMPORTS_PER_SOL); - - const cacheName = program.getOptionValue('cacheName') || 'temp'; - const cachePath = path.join(CACHE_PATH, cacheName); - const cachedContent = fs.existsSync(cachePath) - ? JSON.parse(fs.readFileSync(cachePath).toString()) - : undefined; - - const walletKey = anchor.web3.Keypair.fromSecretKey( - new Uint8Array(JSON.parse(fs.readFileSync(keypair).toString())), - ); - const walletWrapper = new anchor.Wallet(walletKey); - const provider = new anchor.Provider(solConnection, walletWrapper, { - preflightCommitment: 'recent', - }); - const idl = await anchor.Program.fetchIdl(programId, provider); - const anchorProgram = new anchor.Program(idl, programId, provider); - const config = new anchor.web3.PublicKey(cachedContent.program.config); - const [candyMachine, bump] = await getCandyMachine( - config, - cachedContent.program.uuid, - ); - await anchorProgram.rpc.initializeCandyMachine( - bump, - { - uuid: cachedContent.program.uuid, - price: new anchor.BN(lamports), - itemsAvailable: new anchor.BN(Object.keys(cachedContent.items).length), - goLiveDate: null, - }, - { - accounts: { - candyMachine, - wallet: walletKey.publicKey, - config: config, - authority: walletKey.publicKey, - payer: walletKey.publicKey, - systemProgram: anchor.web3.SystemProgram.programId, - rent: anchor.web3.SYSVAR_RENT_PUBKEY, - }, - signers: [], - }, - ); - - console.log(`Done: CANDYMACHINE: ${candyMachine.toBase58()}`); - }); - -program - .command('mint_one_token') - .option('-k, --keypair ', `The purchaser's wallet key`) - .option('-c, --cache-name ', 'Cache file name') - .option('-e, --env ', 'Environment') - .action(async (directory, cmd) => { - const ENV = program.getOptionValue('env') || 'devnet'; - const solConnection = new anchor.web3.Connection( - `https://api.${ENV}.solana.com/`, - ); - - const { keypair } = cmd.opts(); - // const solPriceStr = program.getOptionValue('price') || '1'; - // const lamports = parseInt(solPriceStr) * LAMPORTS_PER_SOL; - - const cacheName = program.getOptionValue('cacheName') || 'temp'; - const cachePath = path.join(CACHE_PATH, cacheName); - const cachedContent = fs.existsSync(cachePath) - ? JSON.parse(fs.readFileSync(cachePath).toString()) - : undefined; - const mint = anchor.web3.Keypair.generate(); - - const walletKey = anchor.web3.Keypair.fromSecretKey( - new Uint8Array(JSON.parse(fs.readFileSync(keypair).toString())), - ); - const token = await getTokenWallet(walletKey.publicKey, mint.publicKey); - const walletWrapper = new anchor.Wallet(walletKey); - const provider = new anchor.Provider(solConnection, walletWrapper, { - preflightCommitment: 'recent', - }); - const idl = await anchor.Program.fetchIdl(programId, provider); - const anchorProgram = new anchor.Program(idl, programId, provider); - const config = new anchor.web3.PublicKey(cachedContent.program.config); - const [candyMachine] = await getCandyMachine( - config, - cachedContent.program.uuid, - ); - const candy = await anchorProgram.account.candyMachine.fetch(candyMachine); - const metadata = await getMetadata(mint.publicKey); - const masterEdition = await getMasterEdition(mint.publicKey); - const tx = await anchorProgram.rpc.mintNft({ - accounts: { - config: config, - candyMachine: candyMachine, - payer: walletKey.publicKey, - //@ts-ignore - wallet: candy.wallet, - mint: mint.publicKey, - metadata, - masterEdition, - mintAuthority: walletKey.publicKey, - updateAuthority: walletKey.publicKey, - tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, - tokenProgram: TOKEN_PROGRAM_ID, - systemProgram: SystemProgram.programId, - rent: anchor.web3.SYSVAR_RENT_PUBKEY, - clock: anchor.web3.SYSVAR_CLOCK_PUBKEY, - }, - signers: [mint, walletKey], - instructions: [ - anchor.web3.SystemProgram.createAccount({ - fromPubkey: walletKey.publicKey, - newAccountPubkey: mint.publicKey, - space: MintLayout.span, - lamports: await provider.connection.getMinimumBalanceForRentExemption( - MintLayout.span, - ), - programId: TOKEN_PROGRAM_ID, - }), - Token.createInitMintInstruction( - TOKEN_PROGRAM_ID, - mint.publicKey, - 0, - walletKey.publicKey, - walletKey.publicKey, - ), - createAssociatedTokenAccountInstruction( - token, - walletKey.publicKey, - walletKey.publicKey, - mint.publicKey, - ), - Token.createMintToInstruction( - TOKEN_PROGRAM_ID, - mint.publicKey, - token, - walletKey.publicKey, - [], - 1, - ), - ], - }); - - console.log('Done', tx); - }); program .command('verify') - .option('-c, --cache-name ', 'Cache file name') - .option('-e, --env ', 'Environment') - .action(async (directory, second, options) => { - const ENV = program.getOptionValue('env') || 'devnet'; - const solConnection = new anchor.web3.Connection( - `https://api.${ENV}.solana.com/`, - ); - const cacheName = program.getOptionValue('cacheName') || 'temp'; - const cachePath = path.join(CACHE_PATH, cacheName); - const cachedContent = fs.existsSync(cachePath) - ? JSON.parse(fs.readFileSync(cachePath).toString()) - : undefined; + .option( + '-e, --env ', + 'Solana cluster env name', + 'devnet', //mainnet-beta, testnet, devnet + ) + .option( + '-k, --keypair ', + `Solana wallet location`, + '--keypair not provided', + ) + .option('-c, --cache-name ', 'Cache file name', 'temp') + .action(async (directory, cmd) => { + const { env, keypair, cacheName } = cmd.opts(); - const config = await solConnection.getAccountInfo( - new PublicKey(cachedContent.program.config), - ); + const cacheContent = loadCache(cacheName, env); + const walletKeyPair = loadWalletKey(keypair); + const anchorProgram = await loadAnchorProgram(walletKeyPair, env); - const keys = Object.keys(cachedContent.items); + const configAddress = new PublicKey(cacheContent.program.config); + const config = await anchorProgram.provider.connection.getAccountInfo( + configAddress, + ); + let allGood = true; + + const keys = Object.keys(cacheContent.items); for (let i = 0; i < keys.length; i++) { console.log('Looking at key ', i); const key = keys[i]; const thisSlice = config.data.slice( - configArrayStart + 4 + configLineSize * i, - configArrayStart + 4 + configLineSize * (i + 1), + CONFIG_ARRAY_START + 4 + CONFIG_LINE_SIZE * i, + CONFIG_ARRAY_START + 4 + CONFIG_LINE_SIZE * (i + 1), ); const name = fromUTF8Array([...thisSlice.slice(4, 36)]); const uri = fromUTF8Array([...thisSlice.slice(40, 240)]); - const cacheItem = cachedContent.items[key]; + const cacheItem = cacheContent.items[key]; if (!name.match(cacheItem.name) || !uri.match(cacheItem.link)) { console.log( 'Name', @@ -738,14 +354,231 @@ program key, ); cacheItem.onChain = false; + allGood = false; } else { - console.log('Name', name, 'with', uri, 'checked out'); + console.debug('Name', name, 'with', uri, 'checked out'); } } - fs.writeFileSync( - path.join(CACHE_PATH, cacheName), - JSON.stringify(cachedContent), + + if (!allGood) { + saveCache(cacheName, env, cacheContent); + + throw new Error( + `not all NFTs checked out. check out logs above for details`, + ); + } + + const configData = (await anchorProgram.account.config.fetch( + configAddress, + )) as Config; + + const lineCount = new BN(config.data.slice(247, 247 + 4), undefined, 'le'); + + console.log( + `uploaded (${lineCount.toNumber()}) out of (${ + configData.data.maxNumberOfLines + })`, ); + if (configData.data.maxNumberOfLines > lineCount.toNumber()) { + throw new Error( + `predefined number of NFTs (${ + configData.data.maxNumberOfLines + }) is smaller than the uploaded one (${lineCount.toNumber()})`, + ); + } else { + console.log('ready to deploy!'); + } + + saveCache(cacheName, env, cacheContent); + }); + +program + .command('create_candy_machine') + .option( + '-e, --env ', + 'Solana cluster env name', + 'devnet', //mainnet-beta, testnet, devnet + ) + .option( + '-k, --keypair ', + `Solana wallet location`, + '--keypair not provided', + ) + .option('-c, --cache-name ', 'Cache file name', 'temp') + .option('-p, --price ', 'SOL price', '1') + .action(async (directory, cmd) => { + const { keypair, env, price, cacheName } = cmd.opts(); + + const lamports = parsePrice(price); + const cacheContent = loadCache(cacheName, env); + + const walletKeyPair = loadWalletKey(keypair); + const anchorProgram = await loadAnchorProgram(walletKeyPair, env); + + const config = new PublicKey(cacheContent.program.config); + const [candyMachine, bump] = await getCandyMachineAddress( + config, + cacheContent.program.uuid, + ); + await anchorProgram.rpc.initializeCandyMachine( + bump, + { + uuid: cacheContent.program.uuid, + price: new anchor.BN(lamports), + itemsAvailable: new anchor.BN(Object.keys(cacheContent.items).length), + goLiveDate: null, + }, + { + accounts: { + candyMachine, + wallet: walletKeyPair.publicKey, + config: config, + authority: walletKeyPair.publicKey, + payer: walletKeyPair.publicKey, + systemProgram: anchor.web3.SystemProgram.programId, + rent: anchor.web3.SYSVAR_RENT_PUBKEY, + }, + signers: [], + }, + ); + + console.log(`create_candy_machine Done: ${candyMachine.toBase58()}`); + }); + +program + .command('set_start_date') + .option( + '-e, --env ', + 'Solana cluster env name', + 'devnet', //mainnet-beta, testnet, devnet + ) + .option( + '-k, --keypair ', + `Solana wallet location`, + '--keypair not provided', + ) + .option('-c, --cache-name ', 'Cache file name', 'temp') + .option('-d, --date ', 'timestamp - eg "04 Dec 1995 00:12:00 GMT"') + .action(async (directory, cmd) => { + const { keypair, env, date, cacheName } = cmd.opts(); + const cacheContent = loadCache(cacheName, env); + + const secondsSinceEpoch = (date ? Date.parse(date) : Date.now()) / 1000; + + const walletKeyPair = loadWalletKey(keypair); + const anchorProgram = await loadAnchorProgram(walletKeyPair, env); + + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [candyMachine, _] = await getCandyMachineAddress( + new PublicKey(cacheContent.program.config), + cacheContent.program.uuid, + ); + const tx = await anchorProgram.rpc.updateCandyMachine( + null, + new anchor.BN(secondsSinceEpoch), + { + accounts: { + candyMachine, + authority: walletKeyPair.publicKey, + }, + }, + ); + + console.log('set_start_date Done', secondsSinceEpoch, tx); + }); + +program + .command('mint_one_token') + .option( + '-e, --env ', + 'Solana cluster env name', + 'devnet', //mainnet-beta, testnet, devnet + ) + .option( + '-k, --keypair ', + `Solana wallet location`, + '--keypair not provided', + ) + .option('-c, --cache-name ', 'Cache file name', 'temp') + .action(async (directory, cmd) => { + const { keypair, env, cacheName } = cmd.opts(); + + const cacheContent = loadCache(cacheName, env); + const mint = Keypair.generate(); + + const walletKeyPair = loadWalletKey(keypair); + const anchorProgram = await loadAnchorProgram(walletKeyPair, env); + const userTokenAccountAddress = await getTokenWallet( + walletKeyPair.publicKey, + mint.publicKey, + ); + + const configAddress = new PublicKey(cacheContent.program.config); + // eslint-disable-next-line @typescript-eslint/no-unused-vars + const [candyMachineAddress, bump] = await getCandyMachineAddress( + configAddress, + cacheContent.program.uuid, + ); + const candyMachine = await anchorProgram.account.candyMachine.fetch( + candyMachineAddress, + ); + const metadataAddress = await getMetadata(mint.publicKey); + const masterEdition = await getMasterEdition(mint.publicKey); + const tx = await anchorProgram.rpc.mintNft({ + accounts: { + config: configAddress, + candyMachine: candyMachineAddress, + payer: walletKeyPair.publicKey, + //@ts-ignore + wallet: candyMachine.wallet, + mint: mint.publicKey, + metadata: metadataAddress, + masterEdition, + mintAuthority: walletKeyPair.publicKey, + updateAuthority: walletKeyPair.publicKey, + tokenMetadataProgram: TOKEN_METADATA_PROGRAM_ID, + tokenProgram: TOKEN_PROGRAM_ID, + systemProgram: SystemProgram.programId, + rent: anchor.web3.SYSVAR_RENT_PUBKEY, + clock: anchor.web3.SYSVAR_CLOCK_PUBKEY, + }, + signers: [mint, walletKeyPair], + instructions: [ + anchor.web3.SystemProgram.createAccount({ + fromPubkey: walletKeyPair.publicKey, + newAccountPubkey: mint.publicKey, + space: MintLayout.span, + lamports: + await anchorProgram.provider.connection.getMinimumBalanceForRentExemption( + MintLayout.span, + ), + programId: TOKEN_PROGRAM_ID, + }), + Token.createInitMintInstruction( + TOKEN_PROGRAM_ID, + mint.publicKey, + 0, + walletKeyPair.publicKey, + walletKeyPair.publicKey, + ), + createAssociatedTokenAccountInstruction( + userTokenAccountAddress, + walletKeyPair.publicKey, + walletKeyPair.publicKey, + mint.publicKey, + ), + Token.createMintToInstruction( + TOKEN_PROGRAM_ID, + mint.publicKey, + userTokenAccountAddress, + walletKeyPair.publicKey, + [], + 1, + ), + ], + }); + + console.log('Done', tx); }); program.command('find-wallets').action(() => {}); diff --git a/js/packages/cli/src/helpers/accounts.ts b/js/packages/cli/src/helpers/accounts.ts new file mode 100644 index 0000000..022641a --- /dev/null +++ b/js/packages/cli/src/helpers/accounts.ts @@ -0,0 +1,144 @@ +import {Keypair, PublicKey, SystemProgram} from '@solana/web3.js'; +import { + CANDY_MACHINE, + CANDY_MACHINE_PROGRAM_ID, + SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, + TOKEN_METADATA_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from './constants'; +import * as anchor from '@project-serum/anchor'; +import fs from 'fs'; +import BN from "bn.js"; +import {createConfigAccount} from "./instructions"; + +export const createConfig = async function ( + anchorProgram: anchor.Program, + payerWallet: Keypair, + configData: { + maxNumberOfLines: BN; + symbol: string; + sellerFeeBasisPoints: number; + isMutable: boolean; + maxSupply: BN; + retainAuthority: boolean; + creators: { + address: PublicKey; + verified: boolean; + share: number; + }[]; + }, +) { + const configAccount = Keypair.generate(); + const uuid = configAccount.publicKey.toBase58().slice(0, 6); + + return { + config: configAccount.publicKey, + uuid, + txId: await anchorProgram.rpc.initializeConfig( + { + uuid, + ...configData, + }, + { + accounts: { + config: configAccount.publicKey, + authority: payerWallet.publicKey, + payer: payerWallet.publicKey, + systemProgram: SystemProgram.programId, + rent: anchor.web3.SYSVAR_RENT_PUBKEY, + }, + signers: [payerWallet, configAccount], + instructions: [ + await createConfigAccount( + anchorProgram, + configData, + payerWallet.publicKey, + configAccount.publicKey, + ), + ], + }, + ), + }; +}; + +export const getTokenWallet = async function ( + wallet: PublicKey, + mint: PublicKey, +) { + return ( + await PublicKey.findProgramAddress( + [wallet.toBuffer(), TOKEN_PROGRAM_ID.toBuffer(), mint.toBuffer()], + SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, + ) + )[0]; +}; + +export const getCandyMachineAddress = async ( + config: anchor.web3.PublicKey, + uuid: string, +) => { + return await anchor.web3.PublicKey.findProgramAddress( + [Buffer.from(CANDY_MACHINE), config.toBuffer(), Buffer.from(uuid)], + CANDY_MACHINE_PROGRAM_ID, + ); +}; + +export const getConfig = async ( + authority: anchor.web3.PublicKey, + uuid: string, +) => { + return await anchor.web3.PublicKey.findProgramAddress( + [Buffer.from(CANDY_MACHINE), authority.toBuffer(), Buffer.from(uuid)], + CANDY_MACHINE_PROGRAM_ID, + ); +}; + +export const getMetadata = async ( + mint: anchor.web3.PublicKey, +): Promise => { + return ( + await anchor.web3.PublicKey.findProgramAddress( + [ + Buffer.from('metadata'), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mint.toBuffer(), + ], + TOKEN_METADATA_PROGRAM_ID, + ) + )[0]; +}; + +export const getMasterEdition = async ( + mint: anchor.web3.PublicKey, +): Promise => { + return ( + await anchor.web3.PublicKey.findProgramAddress( + [ + Buffer.from('metadata'), + TOKEN_METADATA_PROGRAM_ID.toBuffer(), + mint.toBuffer(), + Buffer.from('edition'), + ], + TOKEN_METADATA_PROGRAM_ID, + ) + )[0]; +}; + +export function loadWalletKey(keypair): Keypair { + return Keypair.fromSecretKey( + new Uint8Array(JSON.parse(fs.readFileSync(keypair).toString())), + ); +} + +export async function loadAnchorProgram(walletKeyPair: Keypair, env: string) { + const solConnection = new anchor.web3.Connection( + `https://api.${env}.solana.com/`, + ); + const walletWrapper = new anchor.Wallet(walletKeyPair); + const provider = new anchor.Provider(solConnection, walletWrapper, { + preflightCommitment: 'recent', + }); + const idl = await anchor.Program.fetchIdl(CANDY_MACHINE_PROGRAM_ID, provider); + + return new anchor.Program(idl, CANDY_MACHINE_PROGRAM_ID, provider); +} diff --git a/js/packages/cli/src/helpers/constants.ts b/js/packages/cli/src/helpers/constants.ts new file mode 100644 index 0000000..16a338f --- /dev/null +++ b/js/packages/cli/src/helpers/constants.ts @@ -0,0 +1,42 @@ +import { PublicKey } from '@solana/web3.js'; + +export const CANDY_MACHINE = 'candy_machine'; + +export const PAYMENT_WALLET = new PublicKey( + 'HvwC9QSAzvGXhhVrgPmauVwFWcYZhne3hVot9EbHuFTm', +); +export const CANDY_MACHINE_PROGRAM_ID = new PublicKey( + 'cndyAnrLdpjq1Ssp1z8xxDsB8dxe7u4HL5Nxi2K5WXZ', +); +export const TOKEN_METADATA_PROGRAM_ID = new PublicKey( + 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', +); +export const SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID = new PublicKey( + 'ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL', +); +export const TOKEN_PROGRAM_ID = new PublicKey( + 'TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA', +); + +export const CONFIG_ARRAY_START = + 32 + // authority + 4 + + 6 + // uuid + u32 len + 4 + + 10 + // u32 len + symbol + 2 + // seller fee basis points + 1 + + 4 + + 5 * 34 + // optional + u32 len + actual vec + 8 + //max supply + 1 + //is mutable + 1 + // retain authority + 4; // max number of lines; +export const CONFIG_LINE_SIZE = 4 + 32 + 4 + 200; + +export const CACHE_PATH = './.cache'; + +export const DEFAULT_TIMEOUT = 15000; + +export const EXTENSION_PNG = '.png'; +export const EXTENSION_JSON = '.json'; diff --git a/js/packages/cli/src/helpers/instructions.ts b/js/packages/cli/src/helpers/instructions.ts new file mode 100644 index 0000000..d110310 --- /dev/null +++ b/js/packages/cli/src/helpers/instructions.ts @@ -0,0 +1,89 @@ +import { + PublicKey, + SystemProgram, + SYSVAR_RENT_PUBKEY, + TransactionInstruction, +} from '@solana/web3.js'; +import { + CANDY_MACHINE_PROGRAM_ID, + CONFIG_ARRAY_START, + CONFIG_LINE_SIZE, + SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, + TOKEN_PROGRAM_ID, +} from './constants'; +import * as anchor from '@project-serum/anchor'; + +export function createAssociatedTokenAccountInstruction( + associatedTokenAddress: PublicKey, + payer: PublicKey, + walletAddress: PublicKey, + splTokenMintAddress: PublicKey, +) { + const keys = [ + { + pubkey: payer, + isSigner: true, + isWritable: true, + }, + { + pubkey: associatedTokenAddress, + isSigner: false, + isWritable: true, + }, + { + pubkey: walletAddress, + isSigner: false, + isWritable: false, + }, + { + pubkey: splTokenMintAddress, + isSigner: false, + isWritable: false, + }, + { + pubkey: SystemProgram.programId, + isSigner: false, + isWritable: false, + }, + { + pubkey: TOKEN_PROGRAM_ID, + isSigner: false, + isWritable: false, + }, + { + pubkey: SYSVAR_RENT_PUBKEY, + isSigner: false, + isWritable: false, + }, + ]; + return new TransactionInstruction({ + keys, + programId: SPL_ASSOCIATED_TOKEN_ACCOUNT_PROGRAM_ID, + data: Buffer.from([]), + }); +} + +export async function createConfigAccount( + anchorProgram, + configData, + payerWallet, + configAccount, +) { + const size = + CONFIG_ARRAY_START + + 4 + + configData.maxNumberOfLines.toNumber() * CONFIG_LINE_SIZE + + 4 + + Math.ceil(configData.maxNumberOfLines.toNumber() / 8); + + return anchor.web3.SystemProgram.createAccount({ + fromPubkey: payerWallet, + newAccountPubkey: configAccount, + space: size, + lamports: + await anchorProgram.provider.connection.getMinimumBalanceForRentExemption( + size, + ), + programId: CANDY_MACHINE_PROGRAM_ID, + }); +} diff --git a/js/packages/cli/src/helper.ts b/js/packages/cli/src/helpers/transactions.ts similarity index 83% rename from js/packages/cli/src/helper.ts rename to js/packages/cli/src/helpers/transactions.ts index 2dae00f..e523253 100644 --- a/js/packages/cli/src/helper.ts +++ b/js/packages/cli/src/helpers/transactions.ts @@ -1,30 +1,24 @@ -// const createPaymentTransaction = () => { -// // TODO: -// const tx = new Transaction(); -// tx.add(SystemProgram.transfer({ -// fromPubkey: walletKey.publicKey, -// toPubkey: PAYMENT_WALLET, -// lamports: storageCost, -// })); - import { - Connection, - Keypair, - TransactionInstruction, + Blockhash, Commitment, - Transaction, + Connection, + FeeCalculator, + Keypair, RpcResponseAndContext, SignatureStatus, SimulatedTransactionResponse, + Transaction, + TransactionInstruction, TransactionSignature, - FeeCalculator, - Blockhash, } from '@solana/web3.js'; +import { getUnixTs, sleep } from './various'; +import { DEFAULT_TIMEOUT } from './constants'; interface BlockhashAndFeeCalculator { blockhash: Blockhash; feeCalculator: FeeCalculator; } + export const sendTransactionWithRetryWithKeypair = async ( connection: Connection, wallet: Keypair, @@ -69,11 +63,6 @@ export const sendTransactionWithRetryWithKeypair = async ( return { txid, slot }; }; -export const getUnixTs = () => { - return new Date().getTime() / 1000; -}; -const DEFAULT_TIMEOUT = 15000; - export async function sendSignedTransaction({ signedTransaction, connection, @@ -274,47 +263,3 @@ async function awaitTransactionSignatureConfirmation( console.log('Returning status', status); return status; } - -export function sleep(ms: number): Promise { - return new Promise(resolve => setTimeout(resolve, ms)); -} - -export function fromUTF8Array(data: number[]) { - // array of bytes - let str = '', - i; - - for (i = 0; i < data.length; i++) { - const value = data[i]; - - if (value < 0x80) { - str += String.fromCharCode(value); - } else if (value > 0xbf && value < 0xe0) { - str += String.fromCharCode(((value & 0x1f) << 6) | (data[i + 1] & 0x3f)); - i += 1; - } else if (value > 0xdf && value < 0xf0) { - str += String.fromCharCode( - ((value & 0x0f) << 12) | - ((data[i + 1] & 0x3f) << 6) | - (data[i + 2] & 0x3f), - ); - i += 2; - } else { - // surrogate pair - const charCode = - (((value & 0x07) << 18) | - ((data[i + 1] & 0x3f) << 12) | - ((data[i + 2] & 0x3f) << 6) | - (data[i + 3] & 0x3f)) - - 0x010000; - - str += String.fromCharCode( - (charCode >> 10) | 0xd800, - (charCode & 0x03ff) | 0xdc00, - ); - i += 3; - } - } - - return str; -} diff --git a/js/packages/cli/src/helpers/various.ts b/js/packages/cli/src/helpers/various.ts new file mode 100644 index 0000000..8856e5c --- /dev/null +++ b/js/packages/cli/src/helpers/various.ts @@ -0,0 +1,93 @@ +import { LAMPORTS_PER_SOL } from '@solana/web3.js'; +import { CACHE_PATH } from './constants'; +import path from 'path'; +import fs from 'fs'; +import FormData from 'form-data'; +import fetch from 'node-fetch'; + +export const getUnixTs = () => { + return new Date().getTime() / 1000; +}; + +export function sleep(ms: number): Promise { + return new Promise(resolve => setTimeout(resolve, ms)); +} + +export function fromUTF8Array(data: number[]) { + // array of bytes + let str = '', + i; + + for (i = 0; i < data.length; i++) { + const value = data[i]; + + if (value < 0x80) { + str += String.fromCharCode(value); + } else if (value > 0xbf && value < 0xe0) { + str += String.fromCharCode(((value & 0x1f) << 6) | (data[i + 1] & 0x3f)); + i += 1; + } else if (value > 0xdf && value < 0xf0) { + str += String.fromCharCode( + ((value & 0x0f) << 12) | + ((data[i + 1] & 0x3f) << 6) | + (data[i + 2] & 0x3f), + ); + i += 2; + } else { + // surrogate pair + const charCode = + (((value & 0x07) << 18) | + ((data[i + 1] & 0x3f) << 12) | + ((data[i + 2] & 0x3f) << 6) | + (data[i + 3] & 0x3f)) - + 0x010000; + + str += String.fromCharCode( + (charCode >> 10) | 0xd800, + (charCode & 0x03ff) | 0xdc00, + ); + i += 3; + } + } + + return str; +} + +export function chunks(array, size) { + return Array.apply(0, new Array(Math.ceil(array.length / size))).map( + (_, index) => array.slice(index * size, (index + 1) * size), + ); +} + +export function cachePath(env: string, cacheName: string) { + return path.join(CACHE_PATH, `${env}-${cacheName}`); +} + +export function loadCache(cacheName: string, env: string) { + const path = cachePath(env, cacheName); + return fs.existsSync(path) + ? JSON.parse(fs.readFileSync(path).toString()) + : undefined; +} + +export function saveCache(cacheName: string, env: string, cacheContent) { + fs.writeFileSync(cachePath(env, cacheName), JSON.stringify(cacheContent)); +} + +export function parsePrice(price): number { + return Math.ceil(parseFloat(price) * LAMPORTS_PER_SOL); +} + +export async function upload(data: FormData, manifest, index) { + console.log(`trying to upload ${index}.png: ${manifest.name}`); + return await ( + await fetch( + 'https://us-central1-principal-lane-200702.cloudfunctions.net/uploadFile4', + { + method: 'POST', + // @ts-ignore + body: data, + }, + ) + ).json(); +} diff --git a/js/packages/cli/src/types.ts b/js/packages/cli/src/types.ts new file mode 100644 index 0000000..a1f3c5e --- /dev/null +++ b/js/packages/cli/src/types.ts @@ -0,0 +1,56 @@ +import {BN} from "@project-serum/anchor"; +import {PublicKey} from "@solana/web3.js"; + +export class Creator { + address: string; + verified: boolean; + share: number; + + constructor(args: { + address: string; + verified: boolean; + share: number; + }) { + this.address = args.address; + this.verified = args.verified; + this.share = args.share; + } +} + +export interface Config { + authority: PublicKey; + data: ConfigData; +} + +export class ConfigData { + name: string; + symbol: string; + uri: string; + sellerFeeBasisPoints: number; + creators: Creator[] | null; + maxNumberOfLines: BN | number; + isMutable: boolean; + maxSupply: BN; + retainAuthority: boolean; + constructor(args: { + name: string; + symbol: string; + uri: string; + sellerFeeBasisPoints: number; + creators: Creator[] | null; + maxNumberOfLines: BN; + isMutable: boolean; + maxSupply: BN; + retainAuthority: boolean; + }) { + this.name = args.name; + this.symbol = args.symbol; + this.uri = args.uri; + this.sellerFeeBasisPoints = args.sellerFeeBasisPoints; + this.creators = args.creators; + this.maxNumberOfLines = args.maxNumberOfLines; + this.isMutable = args.isMutable; + this.maxSupply = args.maxSupply; + this.retainAuthority = args.retainAuthority; + } +} diff --git a/rust/nft-candy-machine/src/lib.rs b/rust/nft-candy-machine/src/lib.rs index d45c177..8ef89b8 100644 --- a/rust/nft-candy-machine/src/lib.rs +++ b/rust/nft-candy-machine/src/lib.rs @@ -121,7 +121,7 @@ pub mod nft_candy_machine { for c in &config.data.creators { creators.push(spl_token_metadata::state::Creator { address: c.address, - verified: false, + verified: true, share: c.share, }); }