From 81023eb3e52c31b605e1dcf2eb1e7425153600cd Mon Sep 17 00:00:00 2001 From: B <264380+bartosz-lipinski@users.noreply.github.com> Date: Fri, 13 Aug 2021 20:20:10 -0500 Subject: [PATCH] Warp Speed 8 (#208) * Work in progress on speed fix * Oh yeaj, it works and it's fast as sh*t...just get the metadata oyu ned * Separate the metadata gets into additional promises since technically they are async * chore: Where no man has gone before * Holy cow, now we have editions too * remove a print * feat: use string instead of pubkey * Safer script * feat: first batch * feat: batch 2 * feat: remove toBase58 * fix: build error * fix: another build issue * fix: build issue * fix: more fixes * fix: build * chore: delete dex parser * fix: delete * feat: add store as query parameter * feat: faster url check * feat: replace pubkeys with strings * fix: build * fix: build errors * feat: fix env variable Co-authored-by: Jordan Prince --- js/packages/common/src/actions/account.ts | 9 +- js/packages/common/src/actions/auction.ts | 297 +++++++-------- js/packages/common/src/actions/metadata.ts | 347 +++++++++--------- js/packages/common/src/actions/vault.ts | 288 ++++++++------- js/packages/common/src/contexts/accounts.tsx | 31 +- js/packages/common/src/models/account.ts | 2 +- js/packages/common/src/utils/borsh.ts | 15 + js/packages/common/src/utils/ids.ts | 69 +++- js/packages/common/src/utils/programIds.ts | 26 +- js/packages/common/src/utils/utils.ts | 7 +- js/packages/web/.env | 1 + js/packages/web/next.config.js | 1 + .../web/src/actions/addTokensToVault.ts | 41 +-- js/packages/web/src/actions/cancelBid.ts | 16 +- .../web/src/actions/claimUnusedPrizes.ts | 72 ++-- .../web/src/actions/closePersonalEscrow.ts | 16 +- js/packages/web/src/actions/closeVault.ts | 35 +- .../web/src/actions/convertMasterEditions.ts | 37 +- .../web/src/actions/createAuctionManager.ts | 104 +++--- .../src/actions/createExternalPriceAccount.ts | 22 +- js/packages/web/src/actions/createVault.ts | 52 +-- .../decommAuctionManagerAndReturnPrizes.ts | 18 +- ...precatedCreateReservationListsForTokens.ts | 13 +- .../deprecatedPopulatePrintingTokens.ts | 29 +- js/packages/web/src/actions/makeAuction.ts | 20 +- .../actions/markItemsThatArentMineAsSold.ts | 6 +- js/packages/web/src/actions/nft.tsx | 33 +- js/packages/web/src/actions/saveAdmin.ts | 8 +- js/packages/web/src/actions/sendPlaceBid.ts | 28 +- js/packages/web/src/actions/sendRedeemBid.ts | 156 ++++---- .../web/src/actions/sendSignMetadata.ts | 15 +- .../actions/setVaultAndAuctionAuthorities.ts | 18 +- js/packages/web/src/actions/settle.ts | 27 +- js/packages/web/src/actions/unwindVault.ts | 17 +- .../web/src/components/ArtCard/index.tsx | 4 +- .../web/src/components/AuctionCard/index.tsx | 12 +- .../src/components/Notifications/index.tsx | 59 +-- .../src/components/PreSaleBanner/index.tsx | 2 +- .../web/src/components/UserSearch/index.tsx | 4 +- .../contexts/meta/isMetadataPartOfStore.ts | 2 +- .../web/src/contexts/meta/loadAccounts.ts | 213 +++++++---- js/packages/web/src/contexts/meta/meta.tsx | 9 +- .../web/src/contexts/meta/onChangeAccount.ts | 5 +- .../web/src/contexts/meta/processAuctions.ts | 16 +- .../web/src/contexts/meta/processMetaData.ts | 21 +- .../contexts/meta/processMetaplexAccounts.ts | 26 +- .../web/src/contexts/meta/processVaultData.ts | 6 +- js/packages/web/src/contexts/meta/types.ts | 5 +- js/packages/web/src/hooks/useArt.ts | 26 +- js/packages/web/src/hooks/useAuction.ts | 9 +- js/packages/web/src/hooks/useAuctions.ts | 73 ++-- .../web/src/hooks/useBidsForAuction.ts | 14 +- js/packages/web/src/hooks/useCreator.ts | 6 +- js/packages/web/src/hooks/useCreatorArts.ts | 6 +- js/packages/web/src/hooks/useCreators.ts | 2 +- js/packages/web/src/hooks/useUserArts.ts | 18 +- js/packages/web/src/hooks/useUserBalance.ts | 17 +- js/packages/web/src/models/dex/index.ts | 1 - js/packages/web/src/models/dex/market.ts | 47 --- js/packages/web/src/models/index.ts | 1 - js/packages/web/src/models/marketOverrides.ts | 2 +- .../web/src/models/metaplex/claimBid.ts | 43 +-- .../metaplex/decommissionAuctionManager.ts | 30 +- .../deprecatedInitAuctionManagerV1.ts | 29 +- ...tedPopulateParticipationPrintingAccount.ts | 86 ++--- .../deprecatedRedeemParticipationBid.ts | 59 ++- .../src/models/metaplex/deprecatedStates.ts | 49 ++- .../deprecatedValidateParticipation.ts | 45 ++- .../deprecatedValidateSafetyDepositBoxV1.ts | 73 ++-- .../models/metaplex/emptyPaymentAccount.ts | 65 ++-- js/packages/web/src/models/metaplex/index.ts | 244 ++++++------ .../models/metaplex/initAuctionManagerV2.ts | 31 +- .../web/src/models/metaplex/redeemBid.ts | 71 ++-- .../metaplex/redeemFullRightsTransferBid.ts | 71 ++-- .../metaplex/redeemParticipationBidV3.ts | 87 ++--- .../models/metaplex/redeemPrintingV2Bid.ts | 69 ++-- .../web/src/models/metaplex/setStore.ts | 38 +- .../models/metaplex/setWhitelistedCreator.ts | 24 +- .../web/src/models/metaplex/startAuction.ts | 22 +- .../metaplex/validateSafetyDepositBoxV2.ts | 61 ++- .../models/metaplex/withdrawMasterEdition.ts | 64 ++-- js/packages/web/src/utils/isValidHttpUrl.ts | 10 +- js/packages/web/src/views/admin/index.tsx | 15 +- js/packages/web/src/views/analytics/index.tsx | 28 +- js/packages/web/src/views/art/index.tsx | 3 +- js/packages/web/src/views/artCreate/index.tsx | 9 +- js/packages/web/src/views/artist/index.tsx | 4 +- js/packages/web/src/views/artists/index.tsx | 4 +- js/packages/web/src/views/artworks/index.tsx | 6 +- js/packages/web/src/views/auction/billing.tsx | 56 +-- js/packages/web/src/views/auction/index.tsx | 18 +- .../src/views/auctionCreate/artSelector.tsx | 10 +- .../web/src/views/auctionCreate/index.tsx | 33 +- js/packages/web/src/views/home/index.tsx | 14 +- rust/token-metadata/test/src/main.rs | 8 +- 95 files changed, 2010 insertions(+), 1951 deletions(-) delete mode 100644 js/packages/web/src/models/dex/index.ts delete mode 100644 js/packages/web/src/models/dex/market.ts delete mode 100644 js/packages/web/src/models/index.ts diff --git a/js/packages/common/src/actions/account.ts b/js/packages/common/src/actions/account.ts index 2aea956..4ce7069 100644 --- a/js/packages/common/src/actions/account.ts +++ b/js/packages/common/src/actions/account.ts @@ -275,7 +275,7 @@ export function ensureWrappedAccount( signers.push(account); - return account.publicKey; + return account.publicKey.toBase58(); } // TODO: check if one of to accounts needs to be native sol ... if yes unwrap it ... @@ -290,6 +290,7 @@ export function findOrCreateAccountByMint( excluded?: Set, ): PublicKey { const accountToFind = mint.toBase58(); + const ownerKey = owner.toBase58(); const account = cache .byParser(TokenAccountParser) .map(id => cache.get(id)) @@ -297,14 +298,14 @@ export function findOrCreateAccountByMint( acc => acc !== undefined && acc.info.mint.toBase58() === accountToFind && - acc.info.owner.toBase58() === owner.toBase58() && - (excluded === undefined || !excluded.has(acc.pubkey.toBase58())), + acc.info.owner.toBase58() === ownerKey && + (excluded === undefined || !excluded.has(acc.pubkey)), ); const isWrappedSol = accountToFind === WRAPPED_SOL_MINT.toBase58(); let toAccount: PublicKey; if (account && !isWrappedSol) { - toAccount = account.pubkey; + toAccount = new PublicKey(account.pubkey); } else { // creating depositor pool account toAccount = createTokenAccount( diff --git a/js/packages/common/src/actions/auction.ts b/js/packages/common/src/actions/auction.ts index 15ed1bf..c01a12c 100644 --- a/js/packages/common/src/actions/auction.ts +++ b/js/packages/common/src/actions/auction.ts @@ -1,6 +1,5 @@ import { AccountInfo, - PublicKey, SystemProgram, SYSVAR_CLOCK_PUBKEY, SYSVAR_RENT_PUBKEY, @@ -11,7 +10,7 @@ import { deserializeUnchecked, serialize } from 'borsh'; import BN from 'bn.js'; import { AccountParser } from '../contexts'; import moment from 'moment'; -import { findProgramAddress } from '../utils'; +import { findProgramAddress, StringPublicKey, toPublicKey } from '../utils'; export const AUCTION_PREFIX = 'auction'; export const METADATA = 'metadata'; export const EXTENDED = 'extended'; @@ -29,9 +28,9 @@ export enum BidStateType { } export class Bid { - key: PublicKey; + key: StringPublicKey; amount: BN; - constructor(args: { key: PublicKey; amount: BN }) { + constructor(args: { key: StringPublicKey; amount: BN }) { this.key = args.key; this.amount = args.amount; } @@ -42,7 +41,7 @@ export class BidState { bids: Bid[]; max: BN; - public getWinnerAt(winnerIndex: number): PublicKey | null { + public getWinnerAt(winnerIndex: number): StringPublicKey | null { const convertedIndex = this.bids.length - winnerIndex - 1; if (convertedIndex >= 0 && convertedIndex < this.bids.length) { @@ -62,12 +61,10 @@ export class BidState { } } - public getWinnerIndex(bidder: PublicKey): number | null { + public getWinnerIndex(bidder: StringPublicKey): number | null { if (!this.bids) return null; - const index = this.bids.findIndex( - b => b.key.toBase58() === bidder.toBase58(), - ); + const index = this.bids.findIndex(b => b.key === bidder); // auction stores data in reverse order if (index !== -1) { const zeroBased = this.bids.length - index - 1; @@ -83,7 +80,7 @@ export class BidState { } export const AuctionParser: AccountParser = ( - pubkey: PublicKey, + pubkey: StringPublicKey, account: AccountInfo, ) => ({ pubkey, @@ -100,7 +97,7 @@ export const decodeAuction = (buffer: Buffer) => { }; export const BidderPotParser: AccountParser = ( - pubkey: PublicKey, + pubkey: StringPublicKey, account: AccountInfo, ) => ({ pubkey, @@ -113,7 +110,7 @@ export const decodeBidderPot = (buffer: Buffer) => { }; export const AuctionDataExtendedParser: AccountParser = ( - pubkey: PublicKey, + pubkey: StringPublicKey, account: AccountInfo, ) => ({ pubkey, @@ -130,7 +127,7 @@ export const decodeAuctionDataExtended = (buffer: Buffer) => { }; export const BidderMetadataParser: AccountParser = ( - pubkey: PublicKey, + pubkey: StringPublicKey, account: AccountInfo, ) => ({ pubkey, @@ -208,9 +205,9 @@ export interface CountdownState { export class AuctionData { /// Pubkey of the authority with permission to modify this auction. - authority: PublicKey; + authority: StringPublicKey; /// Token mint for the SPL token being used to bid - tokenMint: PublicKey; + tokenMint: StringPublicKey; /// The time the last bid was placed, used to keep track of auction timing. lastBid: BN | null; /// Slot time the auction was officially ended by. @@ -226,7 +223,7 @@ export class AuctionData { /// Auction Bids, each user may have one bid open at a time. bidState: BidState; /// Used for precalculation on the front end, not a backend key - bidRedemptionKey?: PublicKey; + bidRedemptionKey?: StringPublicKey; public timeToEnd(): CountdownState { const now = moment().unix(); @@ -273,8 +270,8 @@ export class AuctionData { } constructor(args: { - authority: PublicKey; - tokenMint: PublicKey; + authority: StringPublicKey; + tokenMint: StringPublicKey; lastBid: BN | null; endedAt: BN | null; endAuctionAt: BN | null; @@ -299,9 +296,9 @@ export class AuctionData { export const BIDDER_METADATA_LEN = 32 + 32 + 8 + 8 + 1; export class BidderMetadata { // Relationship with the bidder who's metadata this covers. - bidderPubkey: PublicKey; + bidderPubkey: StringPublicKey; // Relationship with the auction this bid was placed on. - auctionPubkey: PublicKey; + auctionPubkey: StringPublicKey; // Amount that the user bid. lastBid: BN; // Tracks the last time this user bid. @@ -310,8 +307,8 @@ export class BidderMetadata { // user is a winner, as if cancelled it implies previous bids were also cancelled. cancelled: boolean; constructor(args: { - bidderPubkey: PublicKey; - auctionPubkey: PublicKey; + bidderPubkey: StringPublicKey; + auctionPubkey: StringPublicKey; lastBid: BN; lastBidTimestamp: BN; cancelled: boolean; @@ -327,14 +324,14 @@ export class BidderMetadata { export const BIDDER_POT_LEN = 32 + 32 + 32 + 1; export class BidderPot { /// Points at actual pot that is a token account - bidderPot: PublicKey; - bidderAct: PublicKey; - auctionAct: PublicKey; + bidderPot: StringPublicKey; + bidderAct: StringPublicKey; + auctionAct: StringPublicKey; emptied: boolean; constructor(args: { - bidderPot: PublicKey; - bidderAct: PublicKey; - auctionAct: PublicKey; + bidderPot: StringPublicKey; + bidderAct: StringPublicKey; + auctionAct: StringPublicKey; emptied: boolean; }) { this.bidderPot = args.bidderPot; @@ -366,7 +363,7 @@ export interface IPartialCreateAuctionArgs { /// Gap time is how much time after the previous bid where the auction ends. See AuctionData. auctionGap: BN | null; /// Token mint for the SPL token used for bidding. - tokenMint: PublicKey; + tokenMint: StringPublicKey; priceFloor: PriceFloor; @@ -384,11 +381,11 @@ export class CreateAuctionArgs implements IPartialCreateAuctionArgs { /// Gap time is how much time after the previous bid where the auction ends. See AuctionData. auctionGap: BN | null; /// Token mint for the SPL token used for bidding. - tokenMint: PublicKey; + tokenMint: StringPublicKey; /// Authority - authority: PublicKey; + authority: StringPublicKey; /// The resource being auctioned. See AuctionData. - resource: PublicKey; + resource: StringPublicKey; priceFloor: PriceFloor; @@ -400,9 +397,9 @@ export class CreateAuctionArgs implements IPartialCreateAuctionArgs { winners: WinnerLimit; endAuctionAt: BN | null; auctionGap: BN | null; - tokenMint: PublicKey; - authority: PublicKey; - resource: PublicKey; + tokenMint: StringPublicKey; + authority: StringPublicKey; + resource: StringPublicKey; priceFloor: PriceFloor; tickSize: BN | null; gapTickSizePercentage: number | null; @@ -421,19 +418,19 @@ export class CreateAuctionArgs implements IPartialCreateAuctionArgs { class StartAuctionArgs { instruction: number = 4; - resource: PublicKey; + resource: StringPublicKey; - constructor(args: { resource: PublicKey }) { + constructor(args: { resource: StringPublicKey }) { this.resource = args.resource; } } class PlaceBidArgs { instruction: number = 6; - resource: PublicKey; + resource: StringPublicKey; amount: BN; - constructor(args: { resource: PublicKey; amount: BN }) { + constructor(args: { resource: StringPublicKey; amount: BN }) { this.resource = args.resource; this.amount = args.amount; } @@ -441,9 +438,9 @@ class PlaceBidArgs { class CancelBidArgs { instruction: number = 0; - resource: PublicKey; + resource: StringPublicKey; - constructor(args: { resource: PublicKey }) { + constructor(args: { resource: StringPublicKey }) { this.resource = args.resource; } } @@ -462,9 +459,9 @@ export const AUCTION_SCHEMA = new Map([ ['winners', WinnerLimit], ['endAuctionAt', { kind: 'option', type: 'u64' }], ['auctionGap', { kind: 'option', type: 'u64' }], - ['tokenMint', 'pubkey'], - ['authority', 'pubkey'], - ['resource', 'pubkey'], + ['tokenMint', 'pubkeyAsString'], + ['authority', 'pubkeyAsString'], + ['resource', 'pubkeyAsString'], ['priceFloor', PriceFloor], ['tickSize', { kind: 'option', type: 'u64' }], ['gapTickSizePercentage', { kind: 'option', type: 'u8' }], @@ -487,7 +484,7 @@ export const AUCTION_SCHEMA = new Map([ kind: 'struct', fields: [ ['instruction', 'u8'], - ['resource', 'pubkey'], + ['resource', 'pubkeyAsString'], ], }, ], @@ -498,7 +495,7 @@ export const AUCTION_SCHEMA = new Map([ fields: [ ['instruction', 'u8'], ['amount', 'u64'], - ['resource', 'pubkey'], + ['resource', 'pubkeyAsString'], ], }, ], @@ -508,7 +505,7 @@ export const AUCTION_SCHEMA = new Map([ kind: 'struct', fields: [ ['instruction', 'u8'], - ['resource', 'pubkey'], + ['resource', 'pubkeyAsString'], ], }, ], @@ -525,8 +522,8 @@ export const AUCTION_SCHEMA = new Map([ { kind: 'struct', fields: [ - ['authority', 'pubkey'], - ['tokenMint', 'pubkey'], + ['authority', 'pubkeyAsString'], + ['tokenMint', 'pubkeyAsString'], ['lastBid', { kind: 'option', type: 'u64' }], ['endedAt', { kind: 'option', type: 'u64' }], ['endAuctionAt', { kind: 'option', type: 'u64' }], @@ -574,7 +571,7 @@ export const AUCTION_SCHEMA = new Map([ { kind: 'struct', fields: [ - ['key', 'pubkey'], + ['key', 'pubkeyAsString'], ['amount', 'u64'], ], }, @@ -584,8 +581,8 @@ export const AUCTION_SCHEMA = new Map([ { kind: 'struct', fields: [ - ['bidderPubkey', 'pubkey'], - ['auctionPubkey', 'pubkey'], + ['bidderPubkey', 'pubkeyAsString'], + ['auctionPubkey', 'pubkeyAsString'], ['lastBid', 'u64'], ['lastBidTimestamp', 'u64'], ['cancelled', 'u8'], @@ -597,9 +594,9 @@ export const AUCTION_SCHEMA = new Map([ { kind: 'struct', fields: [ - ['bidderPot', 'pubkey'], - ['bidderAct', 'pubkey'], - ['auctionAct', 'pubkey'], + ['bidderPot', 'pubkeyAsString'], + ['bidderAct', 'pubkeyAsString'], + ['auctionAct', 'pubkeyAsString'], ['emptied', 'u8'], ], }, @@ -616,40 +613,42 @@ export const decodeAuctionData = (buffer: Buffer) => { export async function createAuction( settings: CreateAuctionArgs, - creator: PublicKey, + creator: StringPublicKey, instructions: TransactionInstruction[], ) { const auctionProgramId = programIds().auction; const data = Buffer.from(serialize(AUCTION_SCHEMA, settings)); - const auctionKey: PublicKey = ( + const auctionKey: StringPublicKey = ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - settings.resource.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(settings.resource).toBuffer(), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; const keys = [ { - pubkey: creator, + pubkey: toPublicKey(creator), isSigner: true, isWritable: true, }, { - pubkey: auctionKey, + pubkey: toPublicKey(auctionKey), isSigner: false, isWritable: true, }, { - pubkey: await getAuctionExtended({ - auctionProgramId, - resource: settings.resource, - }), + pubkey: toPublicKey( + await getAuctionExtended({ + auctionProgramId, + resource: settings.resource, + }), + ), isSigner: false, isWritable: true, }, @@ -667,15 +666,15 @@ export async function createAuction( instructions.push( new TransactionInstruction({ keys, - programId: auctionProgramId, + programId: toPublicKey(auctionProgramId), data: data, }), ); } export async function startAuction( - resource: PublicKey, - creator: PublicKey, + resource: StringPublicKey, + creator: StringPublicKey, instructions: TransactionInstruction[], ) { const auctionProgramId = programIds().auction; @@ -689,25 +688,25 @@ export async function startAuction( ), ); - const auctionKey: PublicKey = ( + const auctionKey: StringPublicKey = ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - resource.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(resource).toBuffer(), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; const keys = [ { - pubkey: creator, + pubkey: toPublicKey(creator), isSigner: false, isWritable: true, }, { - pubkey: auctionKey, + pubkey: toPublicKey(auctionKey), isSigner: false, isWritable: true, }, @@ -720,16 +719,16 @@ export async function startAuction( instructions.push( new TransactionInstruction({ keys, - programId: auctionProgramId, + programId: toPublicKey(auctionProgramId), data: data, }), ); } export async function setAuctionAuthority( - auction: PublicKey, - currentAuthority: PublicKey, - newAuthority: PublicKey, + auction: StringPublicKey, + currentAuthority: StringPublicKey, + newAuthority: StringPublicKey, instructions: TransactionInstruction[], ) { const auctionProgramId = programIds().auction; @@ -738,17 +737,17 @@ export async function setAuctionAuthority( const keys = [ { - pubkey: auction, + pubkey: toPublicKey(auction), isSigner: false, isWritable: true, }, { - pubkey: currentAuthority, + pubkey: toPublicKey(currentAuthority), isSigner: true, isWritable: false, }, { - pubkey: newAuthority, + pubkey: toPublicKey(newAuthority), isSigner: false, isWritable: false, }, @@ -756,20 +755,20 @@ export async function setAuctionAuthority( instructions.push( new TransactionInstruction({ keys, - programId: auctionProgramId, + programId: toPublicKey(auctionProgramId), data: data, }), ); } export async function placeBid( - bidderPubkey: PublicKey, - bidderTokenPubkey: PublicKey, - bidderPotTokenPubkey: PublicKey, - tokenMintPubkey: PublicKey, - transferAuthority: PublicKey, - payer: PublicKey, - resource: PublicKey, + bidderPubkey: StringPublicKey, + bidderTokenPubkey: StringPublicKey, + bidderPotTokenPubkey: StringPublicKey, + tokenMintPubkey: StringPublicKey, + transferAuthority: StringPublicKey, + payer: StringPublicKey, + resource: StringPublicKey, amount: BN, instructions: TransactionInstruction[], ) { @@ -785,14 +784,14 @@ export async function placeBid( ), ); - const auctionKey: PublicKey = ( + const auctionKey: StringPublicKey = ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - resource.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(resource).toBuffer(), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; @@ -802,67 +801,69 @@ export async function placeBid( bidderPubkey, }); - const bidderMetaKey: PublicKey = ( + const bidderMetaKey: StringPublicKey = ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - auctionKey.toBuffer(), - bidderPubkey.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(auctionKey).toBuffer(), + toPublicKey(bidderPubkey).toBuffer(), Buffer.from('metadata'), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; const keys = [ { - pubkey: bidderPubkey, + pubkey: toPublicKey(bidderPubkey), isSigner: true, isWritable: false, }, { - pubkey: bidderTokenPubkey, + pubkey: toPublicKey(bidderTokenPubkey), isSigner: false, isWritable: true, }, { - pubkey: bidderPotKey, + pubkey: toPublicKey(bidderPotKey), isSigner: false, isWritable: true, }, { - pubkey: bidderPotTokenPubkey, + pubkey: toPublicKey(bidderPotTokenPubkey), isSigner: false, isWritable: true, }, { - pubkey: bidderMetaKey, + pubkey: toPublicKey(bidderMetaKey), isSigner: false, isWritable: true, }, { - pubkey: auctionKey, + pubkey: toPublicKey(auctionKey), isSigner: false, isWritable: true, }, { - pubkey: await getAuctionExtended({ auctionProgramId, resource }), + pubkey: toPublicKey( + await getAuctionExtended({ auctionProgramId, resource }), + ), isSigner: false, isWritable: true, }, { - pubkey: tokenMintPubkey, + pubkey: toPublicKey(tokenMintPubkey), isSigner: false, isWritable: true, }, { - pubkey: transferAuthority, + pubkey: toPublicKey(transferAuthority), isSigner: true, isWritable: false, }, { - pubkey: payer, + pubkey: toPublicKey(payer), isSigner: true, isWritable: false, }, @@ -890,7 +891,7 @@ export async function placeBid( instructions.push( new TransactionInstruction({ keys, - programId: auctionProgramId, + programId: toPublicKey(auctionProgramId), data: data, }), ); @@ -905,19 +906,19 @@ export async function getBidderPotKey({ auctionKey, bidderPubkey, }: { - auctionProgramId: PublicKey; - auctionKey: PublicKey; - bidderPubkey: PublicKey; -}): Promise { + auctionProgramId: StringPublicKey; + auctionKey: StringPublicKey; + bidderPubkey: StringPublicKey; +}): Promise { return ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - auctionKey.toBuffer(), - bidderPubkey.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(auctionKey).toBuffer(), + toPublicKey(bidderPubkey).toBuffer(), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; } @@ -926,28 +927,28 @@ export async function getAuctionExtended({ auctionProgramId, resource, }: { - auctionProgramId: PublicKey; - resource: PublicKey; -}): Promise { + auctionProgramId: StringPublicKey; + resource: StringPublicKey; +}): Promise { return ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - resource.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(resource).toBuffer(), Buffer.from(EXTENDED), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; } export async function cancelBid( - bidderPubkey: PublicKey, - bidderTokenPubkey: PublicKey, - bidderPotTokenPubkey: PublicKey, - tokenMintPubkey: PublicKey, - resource: PublicKey, + bidderPubkey: StringPublicKey, + bidderTokenPubkey: StringPublicKey, + bidderPotTokenPubkey: StringPublicKey, + tokenMintPubkey: StringPublicKey, + resource: StringPublicKey, instructions: TransactionInstruction[], ) { const auctionProgramId = programIds().auction; @@ -961,14 +962,14 @@ export async function cancelBid( ), ); - const auctionKey: PublicKey = ( + const auctionKey = ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - resource.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(resource).toBuffer(), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; @@ -978,57 +979,59 @@ export async function cancelBid( bidderPubkey, }); - const bidderMetaKey: PublicKey = ( + const bidderMetaKey = ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - auctionProgramId.toBuffer(), - auctionKey.toBuffer(), - bidderPubkey.toBuffer(), + toPublicKey(auctionProgramId).toBuffer(), + toPublicKey(auctionKey).toBuffer(), + toPublicKey(bidderPubkey).toBuffer(), Buffer.from('metadata'), ], - auctionProgramId, + toPublicKey(auctionProgramId), ) )[0]; const keys = [ { - pubkey: bidderPubkey, + pubkey: toPublicKey(bidderPubkey), isSigner: true, isWritable: false, }, { - pubkey: bidderTokenPubkey, + pubkey: toPublicKey(bidderTokenPubkey), isSigner: false, isWritable: true, }, { - pubkey: bidderPotKey, + pubkey: toPublicKey(bidderPotKey), isSigner: false, isWritable: true, }, { - pubkey: bidderPotTokenPubkey, + pubkey: toPublicKey(bidderPotTokenPubkey), isSigner: false, isWritable: true, }, { - pubkey: bidderMetaKey, + pubkey: toPublicKey(bidderMetaKey), isSigner: false, isWritable: true, }, { - pubkey: auctionKey, + pubkey: toPublicKey(auctionKey), isSigner: false, isWritable: true, }, { - pubkey: await getAuctionExtended({ auctionProgramId, resource }), + pubkey: toPublicKey( + await getAuctionExtended({ auctionProgramId, resource }), + ), isSigner: false, isWritable: true, }, { - pubkey: tokenMintPubkey, + pubkey: toPublicKey(tokenMintPubkey), isSigner: false, isWritable: true, }, @@ -1056,7 +1059,7 @@ export async function cancelBid( instructions.push( new TransactionInstruction({ keys, - programId: auctionProgramId, + programId: toPublicKey(auctionProgramId), data: data, }), ); diff --git a/js/packages/common/src/actions/metadata.ts b/js/packages/common/src/actions/metadata.ts index 9070d2c..a91b97d 100644 --- a/js/packages/common/src/actions/metadata.ts +++ b/js/packages/common/src/actions/metadata.ts @@ -1,5 +1,4 @@ import { - PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionInstruction, @@ -7,7 +6,7 @@ import { import { programIds } from '../utils/programIds'; import { deserializeUnchecked, serialize } from 'borsh'; import BN from 'bn.js'; -import { findProgramAddress } from '../utils'; +import { findProgramAddress, StringPublicKey, toPublicKey } from '../utils'; export const METADATA_PREFIX = 'metadata'; export const EDITION = 'edition'; export const RESERVATION = 'reservation'; @@ -92,7 +91,7 @@ export class MasterEditionV1 { supply: BN; maxSupply?: BN; /// Can be used to mint tokens that give one-time permission to mint a single limited edition. - printingMint: PublicKey; + printingMint: StringPublicKey; /// If you don't know how many printing tokens you are going to need, but you do know /// you are going to need some amount in the future, you can use a token from this mint. /// Coming back to token metadata with one of these tokens allows you to mint (one time) @@ -103,14 +102,14 @@ export class MasterEditionV1 { /// but at the end we will. At the end it then burns this token with token-metadata to /// get the printing tokens it needs to give to bidders. Each bidder then redeems a printing token /// to get their limited editions. - oneTimePrintingAuthorizationMint: PublicKey; + oneTimePrintingAuthorizationMint: StringPublicKey; constructor(args: { key: MetadataKey; supply: BN; maxSupply?: BN; - printingMint: PublicKey; - oneTimePrintingAuthorizationMint: PublicKey; + printingMint: StringPublicKey; + oneTimePrintingAuthorizationMint: StringPublicKey; }) { this.key = MetadataKey.MasterEditionV1; this.supply = args.supply; @@ -163,22 +162,30 @@ export class EditionMarker { export class Edition { key: MetadataKey; /// Points at MasterEdition struct - parent: PublicKey; + parent: StringPublicKey; /// Starting at 0 for master record, this is incremented for each edition minted. edition: BN; - constructor(args: { key: MetadataKey; parent: PublicKey; edition: BN }) { + constructor(args: { + key: MetadataKey; + parent: StringPublicKey; + edition: BN; + }) { this.key = MetadataKey.EditionV1; this.parent = args.parent; this.edition = args.edition; } } export class Creator { - address: PublicKey; + address: StringPublicKey; verified: boolean; share: number; - constructor(args: { address: PublicKey; verified: boolean; share: number }) { + constructor(args: { + address: StringPublicKey; + verified: boolean; + share: number; + }) { this.address = args.address; this.verified = args.verified; this.share = args.share; @@ -208,20 +215,20 @@ export class Data { export class Metadata { key: MetadataKey; - updateAuthority: PublicKey; - mint: PublicKey; + updateAuthority: StringPublicKey; + mint: StringPublicKey; data: Data; primarySaleHappened: boolean; isMutable: boolean; editionNonce: number | null; // set lazy - masterEdition?: PublicKey; - edition?: PublicKey; + masterEdition?: StringPublicKey; + edition?: StringPublicKey; constructor(args: { - updateAuthority: PublicKey; - mint: PublicKey; + updateAuthority: StringPublicKey; + mint: StringPublicKey; data: Data; primarySaleHappened: boolean; isMutable: boolean; @@ -257,7 +264,7 @@ class UpdateMetadataArgs { instruction: number = 1; data: Data | null; // Not used by this app, just required for instruction - updateAuthority: PublicKey | null; + updateAuthority: StringPublicKey | null; primarySaleHappened: boolean | null; constructor(args: { data?: Data; @@ -265,9 +272,7 @@ class UpdateMetadataArgs { primarySaleHappened: boolean | null; }) { this.data = args.data ? args.data : null; - this.updateAuthority = args.updateAuthority - ? new PublicKey(args.updateAuthority) - : null; + this.updateAuthority = args.updateAuthority ? args.updateAuthority : null; this.primarySaleHappened = args.primarySaleHappened; } } @@ -308,7 +313,7 @@ export const METADATA_SCHEMA = new Map([ fields: [ ['instruction', 'u8'], ['data', { kind: 'option', type: Data }], - ['updateAuthority', { kind: 'option', type: 'pubkey' }], + ['updateAuthority', { kind: 'option', type: 'pubkeyAsString' }], ['primarySaleHappened', { kind: 'option', type: 'u8' }], ], }, @@ -342,8 +347,8 @@ export const METADATA_SCHEMA = new Map([ ['key', 'u8'], ['supply', 'u64'], ['maxSupply', { kind: 'option', type: 'u64' }], - ['printingMint', 'pubkey'], - ['oneTimePrintingAuthorizationMint', 'pubkey'], + ['printingMint', 'pubkeyAsString'], + ['oneTimePrintingAuthorizationMint', 'pubkeyAsString'], ], }, ], @@ -364,7 +369,7 @@ export const METADATA_SCHEMA = new Map([ kind: 'struct', fields: [ ['key', 'u8'], - ['parent', 'pubkey'], + ['parent', 'pubkeyAsString'], ['edition', 'u64'], ], }, @@ -387,7 +392,7 @@ export const METADATA_SCHEMA = new Map([ { kind: 'struct', fields: [ - ['address', 'pubkey'], + ['address', 'pubkeyAsString'], ['verified', 'u8'], ['share', 'u8'], ], @@ -399,8 +404,8 @@ export const METADATA_SCHEMA = new Map([ kind: 'struct', fields: [ ['key', 'u8'], - ['updateAuthority', 'pubkey'], - ['mint', 'pubkey'], + ['updateAuthority', 'pubkeyAsString'], + ['mint', 'pubkeyAsString'], ['data', Data], ['primarySaleHappened', 'u8'], // bool ['isMutable', 'u8'], // bool @@ -463,10 +468,10 @@ export async function updateMetadata( data: Data | undefined, newUpdateAuthority: string | undefined, primarySaleHappened: boolean | null | undefined, - mintKey: PublicKey, - updateAuthority: PublicKey, + mintKey: StringPublicKey, + updateAuthority: StringPublicKey, instructions: TransactionInstruction[], - metadataAccount?: PublicKey, + metadataAccount?: StringPublicKey, ) { const metadataProgramId = programIds().metadata; @@ -476,10 +481,10 @@ export async function updateMetadata( await findProgramAddress( [ Buffer.from('metadata'), - metadataProgramId.toBuffer(), - mintKey.toBuffer(), + toPublicKey(metadataProgramId).toBuffer(), + toPublicKey(mintKey).toBuffer(), ], - metadataProgramId, + toPublicKey(metadataProgramId), ) )[0]; @@ -494,12 +499,12 @@ export async function updateMetadata( const txnData = Buffer.from(serialize(METADATA_SCHEMA, value)); const keys = [ { - pubkey: metadataAccount, + pubkey: toPublicKey(metadataAccount), isSigner: false, isWritable: true, }, { - pubkey: updateAuthority, + pubkey: toPublicKey(updateAuthority), isSigner: true, isWritable: false, }, @@ -507,7 +512,7 @@ export async function updateMetadata( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data: txnData, }), ); @@ -517,11 +522,11 @@ export async function updateMetadata( export async function createMetadata( data: Data, - updateAuthority: PublicKey, - mintKey: PublicKey, - mintAuthorityKey: PublicKey, + updateAuthority: StringPublicKey, + mintKey: StringPublicKey, + mintAuthorityKey: StringPublicKey, instructions: TransactionInstruction[], - payer: PublicKey, + payer: StringPublicKey, ) { const metadataProgramId = programIds().metadata; @@ -529,10 +534,10 @@ export async function createMetadata( await findProgramAddress( [ Buffer.from('metadata'), - metadataProgramId.toBuffer(), - mintKey.toBuffer(), + toPublicKey(metadataProgramId).toBuffer(), + toPublicKey(mintKey).toBuffer(), ], - metadataProgramId, + toPublicKey(metadataProgramId), ) )[0]; console.log('Data', data); @@ -541,27 +546,27 @@ export async function createMetadata( const keys = [ { - pubkey: metadataAccount, + pubkey: toPublicKey(metadataAccount), isSigner: false, isWritable: true, }, { - pubkey: mintKey, + pubkey: toPublicKey(mintKey), isSigner: false, isWritable: false, }, { - pubkey: mintAuthorityKey, + pubkey: toPublicKey(mintAuthorityKey), isSigner: true, isWritable: false, }, { - pubkey: payer, + pubkey: toPublicKey(payer), isSigner: true, isWritable: false, }, { - pubkey: updateAuthority, + pubkey: toPublicKey(updateAuthority), isSigner: false, isWritable: false, }, @@ -579,7 +584,7 @@ export async function createMetadata( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data: txnData, }), ); @@ -589,10 +594,10 @@ export async function createMetadata( export async function createMasterEdition( maxSupply: BN | undefined, - mintKey: PublicKey, - updateAuthorityKey: PublicKey, - mintAuthorityKey: PublicKey, - payer: PublicKey, + mintKey: StringPublicKey, + updateAuthorityKey: StringPublicKey, + mintAuthorityKey: StringPublicKey, + payer: StringPublicKey, instructions: TransactionInstruction[], ) { const metadataProgramId = programIds().metadata; @@ -601,10 +606,10 @@ export async function createMasterEdition( await findProgramAddress( [ Buffer.from(METADATA_PREFIX), - metadataProgramId.toBuffer(), - mintKey.toBuffer(), + toPublicKey(metadataProgramId).toBuffer(), + toPublicKey(mintKey).toBuffer(), ], - metadataProgramId, + toPublicKey(metadataProgramId), ) )[0]; @@ -612,11 +617,11 @@ export async function createMasterEdition( await findProgramAddress( [ Buffer.from(METADATA_PREFIX), - metadataProgramId.toBuffer(), - mintKey.toBuffer(), + toPublicKey(metadataProgramId).toBuffer(), + toPublicKey(mintKey).toBuffer(), Buffer.from(EDITION), ], - metadataProgramId, + toPublicKey(metadataProgramId), ) )[0]; @@ -625,32 +630,32 @@ export async function createMasterEdition( const keys = [ { - pubkey: editionAccount, + pubkey: toPublicKey(editionAccount), isSigner: false, isWritable: true, }, { - pubkey: mintKey, + pubkey: toPublicKey(mintKey), isSigner: false, isWritable: true, }, { - pubkey: updateAuthorityKey, + pubkey: toPublicKey(updateAuthorityKey), isSigner: true, isWritable: false, }, { - pubkey: mintAuthorityKey, + pubkey: toPublicKey(mintAuthorityKey), isSigner: true, isWritable: false, }, { - pubkey: payer, + pubkey: toPublicKey(payer), isSigner: true, isWritable: false, }, { - pubkey: metadataAccount, + pubkey: toPublicKey(metadataAccount), isSigner: false, isWritable: false, }, @@ -675,23 +680,23 @@ export async function createMasterEdition( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } export async function deprecatedMintNewEditionFromMasterEditionViaPrintingToken( - newMint: PublicKey, - tokenMint: PublicKey, - newMintAuthority: PublicKey, - printingMint: PublicKey, - authorizationTokenHoldingAccount: PublicKey, - burnAuthority: PublicKey, - updateAuthorityOfMaster: PublicKey, - reservationList: PublicKey | undefined, + newMint: StringPublicKey, + tokenMint: StringPublicKey, + newMintAuthority: StringPublicKey, + printingMint: StringPublicKey, + authorizationTokenHoldingAccount: StringPublicKey, + burnAuthority: StringPublicKey, + updateAuthorityOfMaster: StringPublicKey, + reservationList: StringPublicKey | undefined, instructions: TransactionInstruction[], - payer: PublicKey, + payer: StringPublicKey, ) { const metadataProgramId = programIds().metadata; @@ -704,57 +709,57 @@ export async function deprecatedMintNewEditionFromMasterEditionViaPrintingToken( const keys = [ { - pubkey: newMetadataKey, + pubkey: toPublicKey(newMetadataKey), isSigner: false, isWritable: true, }, { - pubkey: newEdition, + pubkey: toPublicKey(newEdition), isSigner: false, isWritable: true, }, { - pubkey: masterEdition, + pubkey: toPublicKey(masterEdition), isSigner: false, isWritable: true, }, { - pubkey: newMint, + pubkey: toPublicKey(newMint), isSigner: false, isWritable: true, }, { - pubkey: newMintAuthority, + pubkey: toPublicKey(newMintAuthority), isSigner: true, isWritable: false, }, { - pubkey: printingMint, + pubkey: toPublicKey(printingMint), isSigner: false, isWritable: true, }, { - pubkey: authorizationTokenHoldingAccount, + pubkey: toPublicKey(authorizationTokenHoldingAccount), isSigner: false, isWritable: true, }, { - pubkey: burnAuthority, + pubkey: toPublicKey(burnAuthority), isSigner: true, isWritable: false, }, { - pubkey: payer, + pubkey: toPublicKey(payer), isSigner: true, isWritable: false, }, { - pubkey: updateAuthorityOfMaster, + pubkey: toPublicKey(updateAuthorityOfMaster), isSigner: false, isWritable: false, }, { - pubkey: masterMetadataKey, + pubkey: toPublicKey(masterMetadataKey), isSigner: false, isWritable: false, }, @@ -777,7 +782,7 @@ export async function deprecatedMintNewEditionFromMasterEditionViaPrintingToken( if (reservationList) { keys.push({ - pubkey: reservationList, + pubkey: toPublicKey(reservationList), isSigner: false, isWritable: true, }); @@ -785,21 +790,21 @@ export async function deprecatedMintNewEditionFromMasterEditionViaPrintingToken( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } export async function mintNewEditionFromMasterEditionViaToken( - newMint: PublicKey, - tokenMint: PublicKey, - newMintAuthority: PublicKey, - newUpdateAuthority: PublicKey, - tokenOwner: PublicKey, - tokenAccount: PublicKey, + newMint: StringPublicKey, + tokenMint: StringPublicKey, + newMintAuthority: StringPublicKey, + newUpdateAuthority: StringPublicKey, + tokenOwner: StringPublicKey, + tokenAccount: StringPublicKey, instructions: TransactionInstruction[], - payer: PublicKey, + payer: StringPublicKey, edition: BN, ) { const metadataProgramId = programIds().metadata; @@ -814,57 +819,57 @@ export async function mintNewEditionFromMasterEditionViaToken( const keys = [ { - pubkey: newMetadataKey, + pubkey: toPublicKey(newMetadataKey), isSigner: false, isWritable: true, }, { - pubkey: newEdition, + pubkey: toPublicKey(newEdition), isSigner: false, isWritable: true, }, { - pubkey: masterEdition, + pubkey: toPublicKey(masterEdition), isSigner: false, isWritable: true, }, { - pubkey: newMint, + pubkey: toPublicKey(newMint), isSigner: false, isWritable: true, }, { - pubkey: editionMarkPda, + pubkey: toPublicKey(editionMarkPda), isSigner: false, isWritable: true, }, { - pubkey: newMintAuthority, + pubkey: toPublicKey(newMintAuthority), isSigner: true, isWritable: false, }, { - pubkey: payer, + pubkey: toPublicKey(payer), isSigner: true, isWritable: false, }, { - pubkey: tokenOwner, + pubkey: toPublicKey(tokenOwner), isSigner: true, isWritable: false, }, { - pubkey: tokenAccount, + pubkey: toPublicKey(tokenAccount), isSigner: false, isWritable: false, }, { - pubkey: newUpdateAuthority, + pubkey: toPublicKey(newUpdateAuthority), isSigner: false, isWritable: false, }, { - pubkey: masterMetadataKey, + pubkey: toPublicKey(masterMetadataKey), isSigner: false, isWritable: false, }, @@ -888,16 +893,16 @@ export async function mintNewEditionFromMasterEditionViaToken( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } export async function updatePrimarySaleHappenedViaToken( - metadata: PublicKey, - owner: PublicKey, - tokenAccount: PublicKey, + metadata: StringPublicKey, + owner: StringPublicKey, + tokenAccount: StringPublicKey, instructions: TransactionInstruction[], ) { const metadataProgramId = programIds().metadata; @@ -906,17 +911,17 @@ export async function updatePrimarySaleHappenedViaToken( const keys = [ { - pubkey: metadata, + pubkey: toPublicKey(metadata), isSigner: false, isWritable: true, }, { - pubkey: owner, + pubkey: toPublicKey(owner), isSigner: true, isWritable: false, }, { - pubkey: tokenAccount, + pubkey: toPublicKey(tokenAccount), isSigner: false, isWritable: false, }, @@ -924,18 +929,18 @@ export async function updatePrimarySaleHappenedViaToken( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } export async function deprecatedCreateReservationList( - metadata: PublicKey, - masterEdition: PublicKey, - resource: PublicKey, - updateAuthority: PublicKey, - payer: PublicKey, + metadata: StringPublicKey, + masterEdition: StringPublicKey, + resource: StringPublicKey, + updateAuthority: StringPublicKey, + payer: StringPublicKey, instructions: TransactionInstruction[], ) { const metadataProgramId = programIds().metadata; @@ -948,33 +953,33 @@ export async function deprecatedCreateReservationList( const keys = [ { - pubkey: reservationList, + pubkey: toPublicKey(reservationList), isSigner: false, isWritable: true, }, { - pubkey: payer, + pubkey: toPublicKey(payer), isSigner: true, isWritable: false, }, { - pubkey: updateAuthority, + pubkey: toPublicKey(updateAuthority), isSigner: true, isWritable: false, }, { - pubkey: masterEdition, + pubkey: toPublicKey(masterEdition), isSigner: false, isWritable: false, }, { - pubkey: resource, + pubkey: toPublicKey(resource), isSigner: false, isWritable: false, }, { - pubkey: metadata, + pubkey: toPublicKey(metadata), isSigner: false, isWritable: false, }, @@ -992,15 +997,15 @@ export async function deprecatedCreateReservationList( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } export async function signMetadata( - metadata: PublicKey, - creator: PublicKey, + metadata: StringPublicKey, + creator: StringPublicKey, instructions: TransactionInstruction[], ) { const metadataProgramId = programIds().metadata; @@ -1009,12 +1014,12 @@ export async function signMetadata( const keys = [ { - pubkey: metadata, + pubkey: toPublicKey(metadata), isSigner: false, isWritable: true, }, { - pubkey: creator, + pubkey: toPublicKey(creator), isSigner: true, isWritable: false, }, @@ -1022,18 +1027,18 @@ export async function signMetadata( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } export async function deprecatedMintPrintingTokens( - destination: PublicKey, - printingMint: PublicKey, - updateAuthority: PublicKey, - metadata: PublicKey, - masterEdition: PublicKey, + destination: StringPublicKey, + printingMint: StringPublicKey, + updateAuthority: StringPublicKey, + metadata: StringPublicKey, + masterEdition: StringPublicKey, supply: BN, instructions: TransactionInstruction[], ) { @@ -1045,27 +1050,27 @@ export async function deprecatedMintPrintingTokens( const keys = [ { - pubkey: destination, + pubkey: toPublicKey(destination), isSigner: false, isWritable: true, }, { - pubkey: printingMint, + pubkey: toPublicKey(printingMint), isSigner: false, isWritable: true, }, { - pubkey: updateAuthority, + pubkey: toPublicKey(updateAuthority), isSigner: true, isWritable: false, }, { - pubkey: metadata, + pubkey: toPublicKey(metadata), isSigner: false, isWritable: false, }, { - pubkey: masterEdition, + pubkey: toPublicKey(masterEdition), isSigner: false, isWritable: false, }, @@ -1083,16 +1088,16 @@ export async function deprecatedMintPrintingTokens( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } export async function convertMasterEditionV1ToV2( - masterEdition: PublicKey, - oneTimeAuthMint: PublicKey, - printingMint: PublicKey, + masterEdition: StringPublicKey, + oneTimeAuthMint: StringPublicKey, + printingMint: StringPublicKey, instructions: TransactionInstruction[], ) { const metadataProgramId = programIds().metadata; @@ -1101,17 +1106,17 @@ export async function convertMasterEditionV1ToV2( const keys = [ { - pubkey: masterEdition, + pubkey: toPublicKey(masterEdition), isSigner: false, isWritable: true, }, { - pubkey: oneTimeAuthMint, + pubkey: toPublicKey(oneTimeAuthMint), isSigner: false, isWritable: true, }, { - pubkey: printingMint, + pubkey: toPublicKey(printingMint), isSigner: false, isWritable: true, }, @@ -1119,67 +1124,71 @@ export async function convertMasterEditionV1ToV2( instructions.push( new TransactionInstruction({ keys, - programId: metadataProgramId, + programId: toPublicKey(metadataProgramId), data, }), ); } -export async function getEdition(tokenMint: PublicKey): Promise { +export async function getEdition( + tokenMint: StringPublicKey, +): Promise { const PROGRAM_IDS = programIds(); return ( await findProgramAddress( [ Buffer.from(METADATA_PREFIX), - PROGRAM_IDS.metadata.toBuffer(), - tokenMint.toBuffer(), + toPublicKey(PROGRAM_IDS.metadata).toBuffer(), + toPublicKey(tokenMint).toBuffer(), Buffer.from(EDITION), ], - PROGRAM_IDS.metadata, + toPublicKey(PROGRAM_IDS.metadata), ) )[0]; } -export async function getMetadata(tokenMint: PublicKey): Promise { +export async function getMetadata( + tokenMint: StringPublicKey, +): Promise { const PROGRAM_IDS = programIds(); return ( await findProgramAddress( [ Buffer.from(METADATA_PREFIX), - PROGRAM_IDS.metadata.toBuffer(), - tokenMint.toBuffer(), + toPublicKey(PROGRAM_IDS.metadata).toBuffer(), + toPublicKey(tokenMint).toBuffer(), ], - PROGRAM_IDS.metadata, + toPublicKey(PROGRAM_IDS.metadata), ) )[0]; } export async function deprecatedGetReservationList( - masterEdition: PublicKey, - resource: PublicKey, -): Promise { + masterEdition: StringPublicKey, + resource: StringPublicKey, +): Promise { const PROGRAM_IDS = programIds(); return ( await findProgramAddress( [ Buffer.from(METADATA_PREFIX), - PROGRAM_IDS.metadata.toBuffer(), - masterEdition.toBuffer(), + toPublicKey(PROGRAM_IDS.metadata).toBuffer(), + toPublicKey(masterEdition).toBuffer(), Buffer.from(RESERVATION), - resource.toBuffer(), + toPublicKey(resource).toBuffer(), ], - PROGRAM_IDS.metadata, + toPublicKey(PROGRAM_IDS.metadata), ) )[0]; } export async function getEditionMarkPda( - mint: PublicKey, + mint: StringPublicKey, edition: BN, -): Promise { +): Promise { const PROGRAM_IDS = programIds(); const editionNumber = Math.floor(edition.toNumber() / 248); @@ -1187,12 +1196,12 @@ export async function getEditionMarkPda( await findProgramAddress( [ Buffer.from(METADATA_PREFIX), - PROGRAM_IDS.metadata.toBuffer(), - mint.toBuffer(), + toPublicKey(PROGRAM_IDS.metadata).toBuffer(), + toPublicKey(mint).toBuffer(), Buffer.from(EDITION), Buffer.from(editionNumber.toString()), ], - PROGRAM_IDS.metadata, + toPublicKey(PROGRAM_IDS.metadata), ) )[0]; } diff --git a/js/packages/common/src/actions/vault.ts b/js/packages/common/src/actions/vault.ts index 1a8d386..8e1a58a 100644 --- a/js/packages/common/src/actions/vault.ts +++ b/js/packages/common/src/actions/vault.ts @@ -1,5 +1,4 @@ import { - PublicKey, SystemProgram, SYSVAR_RENT_PUBKEY, TransactionInstruction, @@ -7,7 +6,7 @@ import { import { programIds } from '../utils/programIds'; import { deserializeUnchecked, serialize } from 'borsh'; import BN from 'bn.js'; -import { findProgramAddress } from '../utils'; +import { findProgramAddress, StringPublicKey, toPublicKey } from '../utils'; export const VAULT_PREFIX = 'vault'; export enum VaultKey { @@ -31,20 +30,20 @@ export const MAX_EXTERNAL_ACCOUNT_SIZE = 1 + 8 + 32 + 1; export class Vault { key: VaultKey; /// Store token program used - tokenProgram: PublicKey; + tokenProgram: StringPublicKey; /// Mint that produces the fractional shares - fractionMint: PublicKey; + fractionMint: StringPublicKey; /// Authority who can make changes to the vault - authority: PublicKey; + authority: StringPublicKey; /// treasury where fractional shares are held for redemption by authority - fractionTreasury: PublicKey; + fractionTreasury: StringPublicKey; /// treasury where monies are held for fractional share holders to redeem(burn) shares once buyout is made - redeemTreasury: PublicKey; + redeemTreasury: StringPublicKey; /// Can authority mint more shares from fraction_mint after activation allowFurtherShareCreation: boolean; /// Must point at an ExternalPriceAccount, which gives permission and price for buyout. - pricingLookupAddress: PublicKey; + pricingLookupAddress: StringPublicKey; /// In inactive state, we use this to set the order key on Safety Deposit Boxes being added and /// then we increment it and save so the next safety deposit box gets the next number. /// In the Combined state during token redemption by authority, we use it as a decrementing counter each time @@ -59,13 +58,13 @@ export class Vault { lockedPricePerShare: BN; constructor(args: { - tokenProgram: PublicKey; - fractionMint: PublicKey; - authority: PublicKey; - fractionTreasury: PublicKey; - redeemTreasury: PublicKey; + tokenProgram: StringPublicKey; + fractionMint: StringPublicKey; + authority: StringPublicKey; + fractionTreasury: StringPublicKey; + redeemTreasury: StringPublicKey; allowFurtherShareCreation: boolean; - pricingLookupAddress: PublicKey; + pricingLookupAddress: StringPublicKey; tokenTypeCount: number; state: VaultState; lockedPricePerShare: BN; @@ -87,18 +86,18 @@ export class SafetyDepositBox { /// Each token type in a vault has it's own box that contains it's mint and a look-back key: VaultKey; /// VaultKey pointing to the parent vault - vault: PublicKey; + vault: StringPublicKey; /// This particular token's mint - tokenMint: PublicKey; + tokenMint: StringPublicKey; /// Account that stores the tokens under management - store: PublicKey; + store: StringPublicKey; /// the order in the array of registries order: number; constructor(args: { - vault: PublicKey; - tokenMint: PublicKey; - store: PublicKey; + vault: StringPublicKey; + tokenMint: StringPublicKey; + store: StringPublicKey; order: number; }) { this.key = VaultKey.SafetyDepositBoxV1; @@ -114,13 +113,13 @@ export class ExternalPriceAccount { pricePerShare: BN; /// Mint of the currency we are pricing the shares against, should be same as redeem_treasury. /// Most likely will be USDC mint most of the time. - priceMint: PublicKey; + priceMint: StringPublicKey; /// Whether or not combination has been allowed for this vault. allowedToCombine: boolean; constructor(args: { pricePerShare: BN; - priceMint: PublicKey; + priceMint: StringPublicKey; allowedToCombine: boolean; }) { this.key = VaultKey.ExternalPriceAccountV1; @@ -215,13 +214,13 @@ export const VAULT_SCHEMA = new Map([ kind: 'struct', fields: [ ['key', 'u8'], - ['tokenProgram', 'pubkey'], - ['fractionMint', 'pubkey'], - ['authority', 'pubkey'], - ['fractionTreasury', 'pubkey'], - ['redeemTreasury', 'pubkey'], + ['tokenProgram', 'pubkeyAsString'], + ['fractionMint', 'pubkeyAsString'], + ['authority', 'pubkeyAsString'], + ['fractionTreasury', 'pubkeyAsString'], + ['redeemTreasury', 'pubkeyAsString'], ['allowFurtherShareCreation', 'u8'], - ['pricingLookupAddress', 'pubkey'], + ['pricingLookupAddress', 'pubkeyAsString'], ['tokenTypeCount', 'u8'], ['state', 'u8'], ['lockedPricePerShare', 'u64'], @@ -234,9 +233,9 @@ export const VAULT_SCHEMA = new Map([ kind: 'struct', fields: [ ['key', 'u8'], - ['vault', 'pubkey'], - ['tokenMint', 'pubkey'], - ['store', 'pubkey'], + ['vault', 'pubkeyAsString'], + ['tokenMint', 'pubkeyAsString'], + ['store', 'pubkeyAsString'], ['order', 'u8'], ], }, @@ -248,7 +247,7 @@ export const VAULT_SCHEMA = new Map([ fields: [ ['key', 'u8'], ['pricePerShare', 'u64'], - ['priceMint', 'pubkey'], + ['priceMint', 'pubkeyAsString'], ['allowedToCombine', 'u8'], ], }, @@ -276,9 +275,9 @@ export const decodeSafetyDeposit = (buffer: Buffer) => { }; export async function setVaultAuthority( - vault: PublicKey, - currentAuthority: PublicKey, - newAuthority: PublicKey, + vault: StringPublicKey, + currentAuthority: StringPublicKey, + newAuthority: StringPublicKey, instructions: TransactionInstruction[], ) { const vaultProgramId = programIds().vault; @@ -287,17 +286,17 @@ export async function setVaultAuthority( const keys = [ { - pubkey: vault, + pubkey: toPublicKey(vault), isSigner: false, isWritable: true, }, { - pubkey: currentAuthority, + pubkey: toPublicKey(currentAuthority), isSigner: true, isWritable: false, }, { - pubkey: newAuthority, + pubkey: toPublicKey(newAuthority), isSigner: false, isWritable: false, }, @@ -305,7 +304,7 @@ export async function setVaultAuthority( instructions.push( new TransactionInstruction({ keys, - programId: vaultProgramId, + programId: toPublicKey(vaultProgramId), data: data, }), ); @@ -313,12 +312,12 @@ export async function setVaultAuthority( export async function initVault( allowFurtherShareCreation: boolean, - fractionalMint: PublicKey, - redeemTreasury: PublicKey, - fractionalTreasury: PublicKey, - vault: PublicKey, - vaultAuthority: PublicKey, - pricingLookupAddress: PublicKey, + fractionalMint: StringPublicKey, + redeemTreasury: StringPublicKey, + fractionalTreasury: StringPublicKey, + vault: StringPublicKey, + vaultAuthority: StringPublicKey, + pricingLookupAddress: StringPublicKey, instructions: TransactionInstruction[], ) { const vaultProgramId = programIds().vault; @@ -329,32 +328,32 @@ export async function initVault( const keys = [ { - pubkey: fractionalMint, + pubkey: toPublicKey(fractionalMint), isSigner: false, isWritable: true, }, { - pubkey: redeemTreasury, + pubkey: toPublicKey(redeemTreasury), isSigner: false, isWritable: true, }, { - pubkey: fractionalTreasury, + pubkey: toPublicKey(fractionalTreasury), isSigner: false, isWritable: true, }, { - pubkey: vault, + pubkey: toPublicKey(vault), isSigner: false, isWritable: true, }, { - pubkey: vaultAuthority, + pubkey: toPublicKey(vaultAuthority), isSigner: false, isWritable: false, }, { - pubkey: pricingLookupAddress, + pubkey: toPublicKey(pricingLookupAddress), isSigner: false, isWritable: false, }, @@ -373,43 +372,44 @@ export async function initVault( instructions.push( new TransactionInstruction({ keys, - programId: vaultProgramId, + programId: toPublicKey(vaultProgramId), data: data, }), ); } export async function getSafetyDepositBox( - vault: PublicKey, - tokenMint: PublicKey, -): Promise { + vault: StringPublicKey, + tokenMint: StringPublicKey, +): Promise { const vaultProgramId = programIds().vault; return ( await findProgramAddress( - [Buffer.from(VAULT_PREFIX), vault.toBuffer(), tokenMint.toBuffer()], - vaultProgramId, + [ + Buffer.from(VAULT_PREFIX), + toPublicKey(vault).toBuffer(), + toPublicKey(tokenMint).toBuffer(), + ], + toPublicKey(vaultProgramId), ) )[0]; } export async function addTokenToInactiveVault( amount: BN, - tokenMint: PublicKey, - tokenAccount: PublicKey, - tokenStoreAccount: PublicKey, - vault: PublicKey, - vaultAuthority: PublicKey, - payer: PublicKey, - transferAuthority: PublicKey, + tokenMint: StringPublicKey, + tokenAccount: StringPublicKey, + tokenStoreAccount: StringPublicKey, + vault: StringPublicKey, + vaultAuthority: StringPublicKey, + payer: StringPublicKey, + transferAuthority: StringPublicKey, instructions: TransactionInstruction[], ) { const vaultProgramId = programIds().vault; - const safetyDepositBox: PublicKey = await getSafetyDepositBox( - vault, - tokenMint, - ); + const safetyDepositBox = await getSafetyDepositBox(vault, tokenMint); const value = new AmountArgs({ instruction: 1, @@ -419,37 +419,37 @@ export async function addTokenToInactiveVault( const data = Buffer.from(serialize(VAULT_SCHEMA, value)); const keys = [ { - pubkey: safetyDepositBox, + pubkey: toPublicKey(safetyDepositBox), isSigner: false, isWritable: true, }, { - pubkey: tokenAccount, + pubkey: toPublicKey(tokenAccount), isSigner: false, isWritable: true, }, { - pubkey: tokenStoreAccount, + pubkey: toPublicKey(tokenStoreAccount), isSigner: false, isWritable: true, }, { - pubkey: vault, + pubkey: toPublicKey(vault), isSigner: false, isWritable: true, }, { - pubkey: vaultAuthority, + pubkey: toPublicKey(vaultAuthority), isSigner: true, isWritable: false, }, { - pubkey: payer, + pubkey: toPublicKey(payer), isSigner: true, isWritable: false, }, { - pubkey: transferAuthority, + pubkey: toPublicKey(transferAuthority), isSigner: true, isWritable: false, }, @@ -472,7 +472,7 @@ export async function addTokenToInactiveVault( instructions.push( new TransactionInstruction({ keys, - programId: vaultProgramId, + programId: toPublicKey(vaultProgramId), data, }), ); @@ -480,18 +480,22 @@ export async function addTokenToInactiveVault( export async function activateVault( numberOfShares: BN, - vault: PublicKey, - fractionMint: PublicKey, - fractionTreasury: PublicKey, - vaultAuthority: PublicKey, + vault: StringPublicKey, + fractionMint: StringPublicKey, + fractionTreasury: StringPublicKey, + vaultAuthority: StringPublicKey, instructions: TransactionInstruction[], ) { const vaultProgramId = programIds().vault; const fractionMintAuthority = ( await findProgramAddress( - [Buffer.from(VAULT_PREFIX), vaultProgramId.toBuffer(), vault.toBuffer()], - vaultProgramId, + [ + Buffer.from(VAULT_PREFIX), + toPublicKey(vaultProgramId).toBuffer(), + toPublicKey(vault).toBuffer(), + ], + toPublicKey(vaultProgramId), ) )[0]; @@ -500,27 +504,27 @@ export async function activateVault( const keys = [ { - pubkey: vault, + pubkey: toPublicKey(vault), isSigner: false, isWritable: true, }, { - pubkey: fractionMint, + pubkey: toPublicKey(fractionMint), isSigner: false, isWritable: true, }, { - pubkey: fractionTreasury, + pubkey: toPublicKey(fractionTreasury), isSigner: false, isWritable: true, }, { - pubkey: fractionMintAuthority, + pubkey: toPublicKey(fractionMintAuthority), isSigner: false, isWritable: false, }, { - pubkey: vaultAuthority, + pubkey: toPublicKey(vaultAuthority), isSigner: true, isWritable: false, }, @@ -533,31 +537,35 @@ export async function activateVault( instructions.push( new TransactionInstruction({ keys, - programId: vaultProgramId, + programId: toPublicKey(vaultProgramId), data, }), ); } export async function combineVault( - vault: PublicKey, - outstandingShareTokenAccount: PublicKey, - payingTokenAccount: PublicKey, - fractionMint: PublicKey, - fractionTreasury: PublicKey, - redeemTreasury: PublicKey, - newVaultAuthority: PublicKey | undefined, - vaultAuthority: PublicKey, - transferAuthority: PublicKey, - externalPriceAccount: PublicKey, + vault: StringPublicKey, + outstandingShareTokenAccount: StringPublicKey, + payingTokenAccount: StringPublicKey, + fractionMint: StringPublicKey, + fractionTreasury: StringPublicKey, + redeemTreasury: StringPublicKey, + newVaultAuthority: StringPublicKey | undefined, + vaultAuthority: StringPublicKey, + transferAuthority: StringPublicKey, + externalPriceAccount: StringPublicKey, instructions: TransactionInstruction[], ) { const vaultProgramId = programIds().vault; const burnAuthority = ( await findProgramAddress( - [Buffer.from(VAULT_PREFIX), vaultProgramId.toBuffer(), vault.toBuffer()], - vaultProgramId, + [ + Buffer.from(VAULT_PREFIX), + toPublicKey(vaultProgramId).toBuffer(), + toPublicKey(vault).toBuffer(), + ], + toPublicKey(vaultProgramId), ) )[0]; @@ -565,57 +573,57 @@ export async function combineVault( const keys = [ { - pubkey: vault, + pubkey: toPublicKey(vault), isSigner: false, isWritable: true, }, { - pubkey: outstandingShareTokenAccount, + pubkey: toPublicKey(outstandingShareTokenAccount), isSigner: false, isWritable: true, }, { - pubkey: payingTokenAccount, + pubkey: toPublicKey(payingTokenAccount), isSigner: false, isWritable: true, }, { - pubkey: fractionMint, + pubkey: toPublicKey(fractionMint), isSigner: false, isWritable: true, }, { - pubkey: fractionTreasury, + pubkey: toPublicKey(fractionTreasury), isSigner: false, isWritable: true, }, { - pubkey: redeemTreasury, + pubkey: toPublicKey(redeemTreasury), isSigner: false, isWritable: true, }, { - pubkey: newVaultAuthority || vaultAuthority, + pubkey: toPublicKey(newVaultAuthority || vaultAuthority), isSigner: false, isWritable: false, }, { - pubkey: vaultAuthority, + pubkey: toPublicKey(vaultAuthority), isSigner: true, isWritable: false, }, { - pubkey: transferAuthority, + pubkey: toPublicKey(transferAuthority), isSigner: true, isWritable: false, }, { - pubkey: burnAuthority, + pubkey: toPublicKey(burnAuthority), isSigner: false, isWritable: false, }, { - pubkey: externalPriceAccount, + pubkey: toPublicKey(externalPriceAccount), isSigner: false, isWritable: false, }, @@ -628,7 +636,7 @@ export async function combineVault( instructions.push( new TransactionInstruction({ keys, - programId: vaultProgramId, + programId: toPublicKey(vaultProgramId), data, }), ); @@ -636,20 +644,24 @@ export async function combineVault( export async function withdrawTokenFromSafetyDepositBox( amount: BN, - destination: PublicKey, - safetyDepositBox: PublicKey, - storeKey: PublicKey, - vault: PublicKey, - fractionMint: PublicKey, - vaultAuthority: PublicKey, + destination: StringPublicKey, + safetyDepositBox: StringPublicKey, + storeKey: StringPublicKey, + vault: StringPublicKey, + fractionMint: StringPublicKey, + vaultAuthority: StringPublicKey, instructions: TransactionInstruction[], ) { const vaultProgramId = programIds().vault; const transferAuthority = ( await findProgramAddress( - [Buffer.from(VAULT_PREFIX), vaultProgramId.toBuffer(), vault.toBuffer()], - vaultProgramId, + [ + Buffer.from(VAULT_PREFIX), + toPublicKey(vaultProgramId).toBuffer(), + toPublicKey(vault).toBuffer(), + ], + toPublicKey(vaultProgramId), ) )[0]; @@ -658,37 +670,37 @@ export async function withdrawTokenFromSafetyDepositBox( const keys = [ { - pubkey: destination, + pubkey: toPublicKey(destination), isSigner: false, isWritable: true, }, { - pubkey: safetyDepositBox, + pubkey: toPublicKey(safetyDepositBox), isSigner: false, isWritable: true, }, { - pubkey: storeKey, + pubkey: toPublicKey(storeKey), isSigner: false, isWritable: true, }, { - pubkey: vault, + pubkey: toPublicKey(vault), isSigner: false, isWritable: true, }, { - pubkey: fractionMint, + pubkey: toPublicKey(fractionMint), isSigner: false, isWritable: true, }, { - pubkey: vaultAuthority, + pubkey: toPublicKey(vaultAuthority), isSigner: true, isWritable: false, }, { - pubkey: transferAuthority, + pubkey: toPublicKey(transferAuthority), isSigner: false, isWritable: false, }, @@ -706,14 +718,14 @@ export async function withdrawTokenFromSafetyDepositBox( instructions.push( new TransactionInstruction({ keys, - programId: vaultProgramId, + programId: toPublicKey(vaultProgramId), data, }), ); } export async function updateExternalPriceAccount( - externalPriceAccountKey: PublicKey, + externalPriceAccountKey: StringPublicKey, externalPriceAccount: ExternalPriceAccount, instructions: TransactionInstruction[], ) { @@ -725,7 +737,7 @@ export async function updateExternalPriceAccount( const keys = [ { - pubkey: externalPriceAccountKey, + pubkey: toPublicKey(externalPriceAccountKey), isSigner: false, isWritable: true, }, @@ -733,21 +745,25 @@ export async function updateExternalPriceAccount( instructions.push( new TransactionInstruction({ keys, - programId: vaultProgramId, + programId: toPublicKey(vaultProgramId), data, }), ); } export async function getSafetyDepositBoxAddress( - vault: PublicKey, - tokenMint: PublicKey, -): Promise { + vault: StringPublicKey, + tokenMint: StringPublicKey, +): Promise { const PROGRAM_IDS = programIds(); return ( await findProgramAddress( - [Buffer.from(VAULT_PREFIX), vault.toBuffer(), tokenMint.toBuffer()], - PROGRAM_IDS.vault, + [ + Buffer.from(VAULT_PREFIX), + toPublicKey(vault).toBuffer(), + toPublicKey(tokenMint).toBuffer(), + ], + toPublicKey(PROGRAM_IDS.vault), ) )[0]; } diff --git a/js/packages/common/src/contexts/accounts.tsx b/js/packages/common/src/contexts/accounts.tsx index 37f92a6..c7eb588 100644 --- a/js/packages/common/src/contexts/accounts.tsx +++ b/js/packages/common/src/contexts/accounts.tsx @@ -12,10 +12,8 @@ import { AccountLayout, MintInfo, MintLayout, u64 } from '@solana/spl-token'; import { TokenAccount } from '../models'; import { chunks } from '../utils/utils'; import { EventEmitter } from '../utils/eventEmitter'; -import { useUserAccounts } from '../hooks/useUserAccounts'; -import { WRAPPED_SOL_MINT } from '../utils/ids'; +import { StringPublicKey, WRAPPED_SOL_MINT } from '../utils/ids'; import { programIds } from '../utils/programIds'; -import { AuctionParser } from '../actions'; const AccountsContext = React.createContext(null); @@ -25,13 +23,13 @@ const pendingMintCalls = new Map>(); const mintCache = new Map(); export interface ParsedAccountBase { - pubkey: PublicKey; + pubkey: StringPublicKey; account: AccountInfo; - info: any; // TODO: change to unkown + info: any; // TODO: change to unknown } export type AccountParser = ( - pubkey: PublicKey, + pubkey: StringPublicKey, data: AccountInfo, ) => ParsedAccountBase | undefined; @@ -50,7 +48,7 @@ const getMintInfo = async (connection: Connection, pubKey: PublicKey) => { return deserializeMint(data); }; -export const MintParser = (pubKey: PublicKey, info: AccountInfo) => { +export const MintParser = (pubKey: string, info: AccountInfo) => { const buffer = Buffer.from(info.data); const data = deserializeMint(buffer); @@ -67,7 +65,7 @@ export const MintParser = (pubKey: PublicKey, info: AccountInfo) => { }; export const TokenAccountParser = ( - pubKey: PublicKey, + pubKey: string, info: AccountInfo, ) => { // Sometimes a wrapped sol account gets closed, goes to 0 length, @@ -90,7 +88,7 @@ export const TokenAccountParser = ( }; export const GenericAccountParser = ( - pubKey: PublicKey, + pubKey: string, info: AccountInfo, ) => { const buffer = Buffer.from(info.data); @@ -162,7 +160,7 @@ export const cache = { cache.registerParser(id, deserialize); pendingCalls.delete(address); - const account = deserialize(new PublicKey(address), obj); + const account = deserialize(address, obj); if (!account) { return; } @@ -274,20 +272,22 @@ export const useAccountsContext = () => { }; function wrapNativeAccount( - pubkey: PublicKey, + pubkey: string, account?: AccountInfo, ): TokenAccount | undefined { if (!account) { return undefined; } + const key = new PublicKey(pubkey); + return { pubkey: pubkey, account, info: { - address: pubkey, + address: key, mint: WRAPPED_SOL_MINT, - owner: pubkey, + owner: key, amount: new u64(account.lamports), delegate: null, delegatedAmount: new u64(0), @@ -319,7 +319,7 @@ const UseNativeAccount = () => { const updateCache = useCallback( account => { if (wallet && wallet.publicKey) { - const wrapped = wrapNativeAccount(wallet.publicKey, account); + const wrapped = wrapNativeAccount(wallet.publicKey?.toBase58(), account); if (wrapped !== undefined && wallet) { const id = wallet.publicKey?.toBase58(); cache.registerParser(id, TokenAccountParser); @@ -388,13 +388,14 @@ export function AccountsProvider({ children = null as any }) { const [tokenAccounts, setTokenAccounts] = useState([]); const [userAccounts, setUserAccounts] = useState([]); const { nativeAccount } = UseNativeAccount(); + const walletKey = wallet?.publicKey?.toBase58(); const selectUserAccounts = useCallback(() => { return cache .byParser(TokenAccountParser) .map(id => cache.get(id)) .filter( - a => a && a.info.owner.toBase58() === wallet?.publicKey?.toBase58(), + a => a && a.info.owner.toBase58() === walletKey, ) .map(a => a as TokenAccount); }, [wallet]); diff --git a/js/packages/common/src/models/account.ts b/js/packages/common/src/models/account.ts index 7825e92..8e39274 100644 --- a/js/packages/common/src/models/account.ts +++ b/js/packages/common/src/models/account.ts @@ -10,7 +10,7 @@ import { TOKEN_PROGRAM_ID } from '../utils/ids'; import BufferLayout from 'buffer-layout'; export interface TokenAccount { - pubkey: PublicKey; + pubkey: string; account: AccountInfo; info: TokenAccountInfo; } diff --git a/js/packages/common/src/utils/borsh.ts b/js/packages/common/src/utils/borsh.ts index d3d4ed6..2e540cc 100644 --- a/js/packages/common/src/utils/borsh.ts +++ b/js/packages/common/src/utils/borsh.ts @@ -1,5 +1,7 @@ import { PublicKey } from '@solana/web3.js'; import { BinaryReader, BinaryWriter } from 'borsh'; +import base58 from 'bs58'; +import { StringPublicKey } from './ids'; export const extendBorsh = () => { (BinaryReader.prototype as any).readPubkey = function () { @@ -12,6 +14,19 @@ export const extendBorsh = () => { const writer = this as unknown as BinaryWriter; writer.writeFixedArray(value.toBuffer()); }; + + (BinaryReader.prototype as any).readPubkeyAsString = function () { + const reader = this as unknown as BinaryReader; + const array = reader.readFixedArray(32); + return base58.encode(array) as StringPublicKey; + }; + + (BinaryWriter.prototype as any).writePubkeyAsString = function ( + value: StringPublicKey, + ) { + const writer = this as unknown as BinaryWriter; + writer.writeFixedArray(base58.decode(value)); + }; }; extendBorsh(); diff --git a/js/packages/common/src/utils/ids.ts b/js/packages/common/src/utils/ids.ts index 32d9413..8b36516 100644 --- a/js/packages/common/src/utils/ids.ts +++ b/js/packages/common/src/utils/ids.ts @@ -1,4 +1,45 @@ -import { PublicKey } from '@solana/web3.js'; +import { PublicKey, AccountInfo, Account } from '@solana/web3.js'; + +export type StringPublicKey = string; + +export class LazyAccountInfoProxy { + executable: boolean = false; + owner: StringPublicKey = ''; + lamports: number = 0; + + get data() { + // + return undefined as unknown as T; + } +} + +export interface LazyAccountInfo { + executable: boolean; + owner: StringPublicKey; + lamports: number; + data: [string, string]; +} + +const PubKeysInternedMap = new Map(); + +export const toPublicKey = (key: string | PublicKey) => { + if (typeof key !== 'string') { + return key; + } + + let result = PubKeysInternedMap.get(key); + if (!result) { + result = new PublicKey(key); + PubKeysInternedMap.set(key, result); + } + + return result; +}; + +export interface PublicKeyStringAndAccount { + pubkey: string; + account: AccountInfo; +} export const WRAPPED_SOL_MINT = new PublicKey( 'So11111111111111111111111111111111111111112', @@ -16,28 +57,20 @@ export const BPF_UPGRADE_LOADER_ID = new PublicKey( 'BPFLoaderUpgradeab1e11111111111111111111111', ); -export const METADATA_PROGRAM_ID = new PublicKey( - 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s', - //'GCUQ7oWCzgtRKnHnuJGxpr5XVeEkxYUXwTKYcqGtxLv4', -); - export const MEMO_ID = new PublicKey( 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr', ); -export const VAULT_ID = new PublicKey( - 'vau1zxA2LbssAUEF7Gpw91zMM1LvXrvpzJtmZ58rPsn', - //'41cCnZ1Z1upJdtsS1tzFGR34cPFgJLzvJFmgYKpCqkz7', -); +export const METADATA_PROGRAM_ID = + 'metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s' as StringPublicKey; -export const AUCTION_ID = new PublicKey( - 'auctxRXPeJoc4817jDhf4HbjnhEcr1cCXenosMhK5R8', - //'6u5XVthCStUfmNrYhFsST94oKxzwEZfZFHFhiCnB2nR1', -); +export const VAULT_ID = + 'vau1zxA2LbssAUEF7Gpw91zMM1LvXrvpzJtmZ58rPsn' as StringPublicKey; -export const METAPLEX_ID = new PublicKey( - 'p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98', - //'98jcGaKLKx9vv33H9edLUXAydrSipHhJGDQuPXBVPVGp', -); +export const AUCTION_ID = + 'auctxRXPeJoc4817jDhf4HbjnhEcr1cCXenosMhK5R8' as StringPublicKey; + +export const METAPLEX_ID = + 'p1exdMJcjVao65QdewkaZRUnU6VPSXhus9n2GzWfh98' as StringPublicKey; export const SYSTEM = new PublicKey('11111111111111111111111111111111'); diff --git a/js/packages/common/src/utils/programIds.ts b/js/packages/common/src/utils/programIds.ts index 448e72d..81343e2 100644 --- a/js/packages/common/src/utils/programIds.ts +++ b/js/packages/common/src/utils/programIds.ts @@ -11,6 +11,7 @@ import { MEMO_ID, VAULT_ID, AUCTION_ID, + toPublicKey, } from './ids'; export const ENABLE_FEES_INPUT = false; @@ -42,21 +43,33 @@ export const setStoreID = (storeId: any) => { }; const getStoreID = async () => { - console.log(`STORE_OWNER_ADDRESS: ${STORE_OWNER_ADDRESS?.toBase58()}`); if (!STORE_OWNER_ADDRESS) { return undefined; } + let urlStoreId: PublicKey | null = null; + try { + const urlParams = new URLSearchParams(window.location.search); + const text = urlParams.get('store'); + if (text) { + urlStoreId = new PublicKey(text); + } + } catch { + // ignore + } + + const storeOwnerAddress = urlStoreId || STORE_OWNER_ADDRESS; + console.log(`STORE_OWNER_ADDRESS: ${storeOwnerAddress?.toBase58()}`); const programs = await findProgramAddress( [ Buffer.from('metaplex'), - METAPLEX_ID.toBuffer(), - STORE_OWNER_ADDRESS.toBuffer(), + toPublicKey(METAPLEX_ID).toBuffer(), + storeOwnerAddress.toBuffer(), ], - METAPLEX_ID, + toPublicKey(METAPLEX_ID), ); const CUSTOM = programs[0]; - console.log(`CUSTOM STORE: ${CUSTOM.toBase58()}`); + console.log(`CUSTOM STORE: ${CUSTOM}`); return CUSTOM; }; @@ -68,7 +81,8 @@ export const setProgramIds = async (envName: string) => { } if (!STORE) { - STORE = await getStoreID(); + const potential_store = await getStoreID(); + STORE = potential_store ? toPublicKey(potential_store) : undefined; } }; diff --git a/js/packages/common/src/utils/utils.ts b/js/packages/common/src/utils/utils.ts index a63304f..2a4e308 100644 --- a/js/packages/common/src/utils/utils.ts +++ b/js/packages/common/src/utils/utils.ts @@ -60,10 +60,7 @@ export const findProgramAddress = async ( if (cached) { const value = JSON.parse(cached); - return [new PublicKey(value.key), parseInt(value.nonce)] as [ - PublicKey, - number, - ]; + return [value.key, parseInt(value.nonce)] as [string, number]; } const result = await PublicKey.findProgramAddress(seeds, programId); @@ -80,7 +77,7 @@ export const findProgramAddress = async ( // ignore } - return result; + return [result[0].toBase58(), result[1]] as [string, number]; }; // shorten the checksummed version of the input address to have 4 characters at start and end diff --git a/js/packages/web/.env b/js/packages/web/.env index 7894a4d..0b2474e 100644 --- a/js/packages/web/.env +++ b/js/packages/web/.env @@ -1 +1,2 @@ REACT_APP_STORE_OWNER_ADDRESS_ADDRESS= +REACT_APP_BIG_STORE=FALSE diff --git a/js/packages/web/next.config.js b/js/packages/web/next.config.js index d661ff1..a77aba2 100644 --- a/js/packages/web/next.config.js +++ b/js/packages/web/next.config.js @@ -29,6 +29,7 @@ module.exports = withPlugins(plugins, { }, env:{ NEXT_PUBLIC_STORE_OWNER_ADDRESS_ADDRESS: process.env.REACT_APP_STORE_OWNER_ADDRESS_ADDRESS, + NEXT_PUBLIC_BIG_STORE: process.env.REACT_APP_BIG_STORE, }, async rewrites() { return [ diff --git a/js/packages/web/src/actions/addTokensToVault.ts b/js/packages/web/src/actions/addTokensToVault.ts index f9e161e..e276389 100644 --- a/js/packages/web/src/actions/addTokensToVault.ts +++ b/js/packages/web/src/actions/addTokensToVault.ts @@ -1,15 +1,12 @@ -import { - Keypair, - Connection, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { utils, actions, models, findProgramAddress, MetadataKey, + StringPublicKey, + toPublicKey, } from '@oyster/common'; import { AccountLayout } from '@solana/spl-token'; @@ -21,8 +18,8 @@ const { approve } = models; export interface SafetyDepositInstructionTemplate { box: { - tokenAccount?: PublicKey; - tokenMint: PublicKey; + tokenAccount?: StringPublicKey; + tokenMint: StringPublicKey; amount: BN; }; draft: SafetyDepositDraft; @@ -35,12 +32,12 @@ const BATCH_SIZE = 1; export async function addTokensToVault( connection: Connection, wallet: any, - vault: PublicKey, + vault: StringPublicKey, nfts: SafetyDepositInstructionTemplate[], ): Promise<{ instructions: Array; signers: Array; - safetyDepositTokenStores: PublicKey[]; + safetyDepositTokenStores: StringPublicKey[]; }> { const PROGRAM_IDS = utils.programIds(); @@ -52,10 +49,10 @@ export async function addTokensToVault( await findProgramAddress( [ Buffer.from(VAULT_PREFIX), - PROGRAM_IDS.vault.toBuffer(), - vault.toBuffer(), + toPublicKey(PROGRAM_IDS.vault).toBuffer(), + toPublicKey(vault).toBuffer(), ], - PROGRAM_IDS.vault, + toPublicKey(PROGRAM_IDS.vault), ) )[0]; @@ -63,7 +60,7 @@ export async function addTokensToVault( let signers: Array = []; let instructions: Array = []; - let newStores: PublicKey[] = []; + let newStores: StringPublicKey[] = []; let currSigners: Keypair[] = []; let currInstructions: TransactionInstruction[] = []; @@ -74,16 +71,16 @@ export async function addTokensToVault( currInstructions, wallet.publicKey, accountRentExempt, - nft.box.tokenMint, - vaultAuthority, + toPublicKey(nft.box.tokenMint), + toPublicKey(vaultAuthority), currSigners, ); - newStores.push(newStoreAccount); + newStores.push(newStoreAccount.toBase58()); const transferAuthority = approve( currInstructions, [], - nft.box.tokenAccount, + toPublicKey(nft.box.tokenAccount), wallet.publicKey, nft.box.amount.toNumber(), ); @@ -97,11 +94,11 @@ export async function addTokensToVault( : nft.box.amount, nft.box.tokenMint, nft.box.tokenAccount, - newStoreAccount, + newStoreAccount.toBase58(), vault, - wallet.publicKey, - wallet.publicKey, - transferAuthority.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), + transferAuthority.publicKey.toBase58(), currInstructions, ); diff --git a/js/packages/web/src/actions/cancelBid.ts b/js/packages/web/src/actions/cancelBid.ts index 52393f5..4834ed6 100644 --- a/js/packages/web/src/actions/cancelBid.ts +++ b/js/packages/web/src/actions/cancelBid.ts @@ -9,14 +9,10 @@ import { sendTransactions, ParsedAccount, BidderMetadata, + StringPublicKey, } from '@oyster/common'; import { AccountLayout } from '@solana/spl-token'; -import { - TransactionInstruction, - Keypair, - Connection, - PublicKey, -} from '@solana/web3.js'; +import { TransactionInstruction, Keypair, Connection } from '@solana/web3.js'; import { AuctionView } from '../hooks'; import { BidRedemptionTicket, PrizeTrackingTicket } from '../models/metaplex'; import { claimUnusedPrizes } from './claimUnusedPrizes'; @@ -25,7 +21,7 @@ import { setupPlaceBid } from './sendPlaceBid'; export async function sendCancelBid( connection: Connection, wallet: any, - payingAccount: PublicKey, + payingAccount: StringPublicKey, auctionView: AuctionView, accountsByMint: Map, bids: ParsedAccount[], @@ -110,9 +106,7 @@ export async function setupCancelBid( let cancelInstructions: TransactionInstruction[] = []; let cleanupInstructions: TransactionInstruction[] = []; - let tokenAccount = accountsByMint.get( - auctionView.auction.info.tokenMint.toBase58(), - ); + let tokenAccount = accountsByMint.get(auctionView.auction.info.tokenMint); const mint = cache.get(auctionView.auction.info.tokenMint); if (mint && auctionView.myBidderPot) { @@ -126,7 +120,7 @@ export async function setupCancelBid( ); await cancelBid( - wallet.publicKey, + wallet.publicKey.toBase58(), receivingSolAccount, auctionView.myBidderPot.info.bidderPot, auctionView.auction.info.tokenMint, diff --git a/js/packages/web/src/actions/claimUnusedPrizes.ts b/js/packages/web/src/actions/claimUnusedPrizes.ts index a4a7aad..adf8a28 100644 --- a/js/packages/web/src/actions/claimUnusedPrizes.ts +++ b/js/packages/web/src/actions/claimUnusedPrizes.ts @@ -1,9 +1,4 @@ -import { - Keypair, - Connection, - TransactionInstruction, - PublicKey, -} from '@solana/web3.js'; +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { actions, ParsedAccount, @@ -17,6 +12,7 @@ import { createAssociatedTokenAccountInstruction, MetadataKey, BidderMetadata, + toPublicKey, } from '@oyster/common'; import { AccountLayout, MintLayout } from '@solana/spl-token'; @@ -35,7 +31,6 @@ import { setupRedeemParticipationInstructions, setupRedeemPrintingV2Instructions, } from './sendRedeemBid'; -import { WinningConfigStateItem } from '../models/metaplex/deprecatedStates'; const { createTokenAccount } = actions; export async function findEligibleParticipationBidsForRedemption( @@ -60,9 +55,7 @@ export async function findEligibleParticipationBidsForRedemption( ); const bidRedemption = bidRedemptions[ - ( - await getBidRedemption(auctionView.auction.pubkey, bid.pubkey) - ).toBase58() + await getBidRedemption(auctionView.auction.pubkey, bid.pubkey) ]; const eligible = eligibleForParticipationPrizeGivenWinningIndex( winnerIndex, @@ -70,7 +63,7 @@ export async function findEligibleParticipationBidsForRedemption( bid, bidRedemption, ); - console.log(bid.pubkey.toBase58(), 'eligible?', eligible); + console.log(bid.pubkey, 'eligible?', eligible); if (eligible) { unredeemedParticipations.push({ bid, bidRedemption }); } @@ -104,7 +97,7 @@ export async function claimUnusedPrizes( MetadataKey.MasterEditionV2 ) { const balance = await connection.getTokenAccountBalance( - auctionView.participationItem.safetyDeposit.info.store, + toPublicKey(auctionView.participationItem.safetyDeposit.info.store), ); if (balance.value.uiAmount || 0 > 0) { // before we can redeem, check if we need to print other people's stuff. @@ -164,7 +157,7 @@ export async function claimUnusedPrizes( const safetyDeposit = item.safetyDeposit; const tokenBalance = await connection.getTokenAccountBalance( - safetyDeposit.info.store, + toPublicKey(safetyDeposit.info.store), ); // If box is empty, we cant redeem this. Could be broken AM we are claiming against. if (tokenBalance.value.uiAmount === 0) { @@ -199,14 +192,11 @@ export async function claimUnusedPrizes( const winningBidder = auctionView.auction.info.bidState.getWinnerAt(winnerIndex); if (winningBidder) { - const bidderMetadata = bids.find(b => - b.info.bidderPubkey.equals(winningBidder), + const bidderMetadata = bids.find( + b => b.info.bidderPubkey === winningBidder, ); if (bidderMetadata) { - console.log( - 'Redeeming v2 for bid by wallet', - winningBidder.toBase58(), - ); + console.log('Redeeming v2 for bid by wallet', winningBidder); await setupRedeemPrintingV2Instructions( connection, auctionView, @@ -222,7 +212,7 @@ export async function claimUnusedPrizes( ); } } - printingV2ByMint[item.metadata.info.mint.toBase58()] = item; + printingV2ByMint[item.metadata.info.mint] = item; break; case WinningConfigType.FullRightsTransfer: console.log('Redeeming Full Rights'); @@ -292,17 +282,17 @@ async function setupRedeemInstructions( if (!claimed) { let newTokenAccount = accountsByMint.get( - safetyDeposit.info.tokenMint.toBase58(), + safetyDeposit.info.tokenMint, )?.pubkey; if (!newTokenAccount) newTokenAccount = createTokenAccount( winningPrizeInstructions, wallet.publicKey, accountRentExempt, - safetyDeposit.info.tokenMint, + toPublicKey(safetyDeposit.info.tokenMint), wallet.publicKey, winningPrizeSigner, - ); + ).toBase58(); await redeemBid( auctionView.auctionManager.vault, @@ -310,8 +300,8 @@ async function setupRedeemInstructions( newTokenAccount, safetyDeposit.pubkey, auctionView.vault.info.fractionMint, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), undefined, undefined, false, @@ -342,17 +332,17 @@ async function setupRedeemFullRightsTransferInstructions( instructions.push(winningPrizeInstructions); if (!claimed) { let newTokenAccount = accountsByMint.get( - safetyDeposit.info.tokenMint.toBase58(), + safetyDeposit.info.tokenMint, )?.pubkey; if (!newTokenAccount) newTokenAccount = createTokenAccount( winningPrizeInstructions, wallet.publicKey, accountRentExempt, - safetyDeposit.info.tokenMint, + toPublicKey(safetyDeposit.info.tokenMint), wallet.publicKey, winningPrizeSigner, - ); + ).toBase58(); await redeemFullRightsTransferBid( auctionView.auctionManager.vault, @@ -360,11 +350,11 @@ async function setupRedeemFullRightsTransferInstructions( newTokenAccount, safetyDeposit.pubkey, auctionView.vault.info.fractionMint, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), winningPrizeInstructions, item.metadata.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), winningConfigIndex, ); } @@ -390,21 +380,21 @@ async function setupWithdrawMasterEditionInstructions( [ wallet.publicKey.toBuffer(), programIds().token.toBuffer(), - item.metadata.info.mint.toBuffer(), + toPublicKey(item.metadata.info.mint).toBuffer(), ], programIds().associatedToken, ) )[0]; - const existingAta = await connection.getAccountInfo(ata); + const existingAta = await connection.getAccountInfo(toPublicKey(ata)); console.log('Existing ata?', existingAta); if (!existingAta) { createAssociatedTokenAccountInstruction( myInstructions, - ata, + toPublicKey(ata), wallet.publicKey, wallet.publicKey, - item.metadata.info.mint, + toPublicKey(item.metadata.info.mint), ); } @@ -443,8 +433,8 @@ async function deprecatedSetupRedeemPrintingInstructions( auctionView.auctionManager.pubkey, ); - const newTokenAccount = accountsByMint.get(me.info.printingMint.toBase58()); - let newTokenAccountKey: PublicKey | undefined = newTokenAccount?.pubkey; + const newTokenAccount = accountsByMint.get(me.info.printingMint); + let newTokenAccountKey = newTokenAccount?.pubkey; if (updateAuth) { const claimed = auctionView.auctionManager.isItemClaimed( @@ -464,10 +454,10 @@ async function deprecatedSetupRedeemPrintingInstructions( winningPrizeInstructions, wallet.publicKey, accountRentExempt, - me.info.printingMint, + toPublicKey(me.info.printingMint), wallet.publicKey, winningPrizeSigner, - ); + ).toBase58(); await redeemBid( auctionView.auctionManager.vault, @@ -475,8 +465,8 @@ async function deprecatedSetupRedeemPrintingInstructions( newTokenAccountKey, safetyDeposit.pubkey, auctionView.vault.info.fractionMint, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), item.masterEdition.pubkey, reservationList, true, diff --git a/js/packages/web/src/actions/closePersonalEscrow.ts b/js/packages/web/src/actions/closePersonalEscrow.ts index 4c6e32d..1112886 100644 --- a/js/packages/web/src/actions/closePersonalEscrow.ts +++ b/js/packages/web/src/actions/closePersonalEscrow.ts @@ -1,10 +1,10 @@ +import { Connection, Keypair, TransactionInstruction } from '@solana/web3.js'; import { - Connection, - Keypair, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; -import { utils, sendTransactionWithRetry } from '@oyster/common'; + utils, + sendTransactionWithRetry, + StringPublicKey, + toPublicKey, +} from '@oyster/common'; import { Token } from '@solana/spl-token'; // When you are an artist and you receive royalties, due to the design of the system @@ -16,7 +16,7 @@ import { Token } from '@solana/spl-token'; export async function closePersonalEscrow( connection: Connection, wallet: any, - ata: PublicKey, + ata: StringPublicKey, ) { const PROGRAM_IDS = utils.programIds(); @@ -25,7 +25,7 @@ export async function closePersonalEscrow( let instructions: TransactionInstruction[] = [ Token.createCloseAccountInstruction( PROGRAM_IDS.token, - ata, + toPublicKey(ata), wallet.publicKey, wallet.publicKey, [], diff --git a/js/packages/web/src/actions/closeVault.ts b/js/packages/web/src/actions/closeVault.ts index bdcaf86..26c0ca9 100644 --- a/js/packages/web/src/actions/closeVault.ts +++ b/js/packages/web/src/actions/closeVault.ts @@ -1,10 +1,5 @@ -import { - Keypair, - Connection, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; -import { actions, models } from '@oyster/common'; +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; +import { actions, models, StringPublicKey, toPublicKey } from '@oyster/common'; import { AccountLayout } from '@solana/spl-token'; import BN from 'bn.js'; @@ -16,12 +11,12 @@ const { approve } = models; export async function closeVault( connection: Connection, wallet: any, - vault: PublicKey, - fractionMint: PublicKey, - fractionTreasury: PublicKey, - redeemTreasury: PublicKey, - priceMint: PublicKey, - externalPriceAccount: PublicKey, + vault: StringPublicKey, + fractionMint: StringPublicKey, + fractionTreasury: StringPublicKey, + redeemTreasury: StringPublicKey, + priceMint: StringPublicKey, + externalPriceAccount: StringPublicKey, ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; @@ -45,7 +40,7 @@ export async function closeVault( instructions, wallet.publicKey, accountRentExempt, - fractionMint, + toPublicKey(fractionMint), wallet.publicKey, signers, ); @@ -54,7 +49,7 @@ export async function closeVault( instructions, wallet.publicKey, accountRentExempt, - priceMint, + toPublicKey(priceMint), wallet.publicKey, signers, ); @@ -89,14 +84,14 @@ export async function closeVault( await combineVault( vault, - outstandingShareAccount, - payingTokenAccount, + outstandingShareAccount.toBase58(), + payingTokenAccount.toBase58(), fractionMint, fractionTreasury, redeemTreasury, - wallet.publicKey, - wallet.publicKey, - transferAuthority.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), + transferAuthority.publicKey.toBase58(), externalPriceAccount, instructions, ); diff --git a/js/packages/web/src/actions/convertMasterEditions.ts b/js/packages/web/src/actions/convertMasterEditions.ts index 9d65bf5..86462cd 100644 --- a/js/packages/web/src/actions/convertMasterEditions.ts +++ b/js/packages/web/src/actions/convertMasterEditions.ts @@ -11,6 +11,7 @@ import { convertMasterEditionV1ToV2, TokenAccount, programIds, + toPublicKey, } from '@oyster/common'; import { Token } from '@solana/spl-token'; const BATCH_SIZE = 10; @@ -35,7 +36,7 @@ export async function filterMetadata( for (let i = 0; i < metadata.length; i++) { const md = metadata[i]; const masterEdition = masterEditions[ - md.info.masterEdition?.toBase58() || '' + md.info.masterEdition || '' ] as ParsedAccount; if ( masterEdition && @@ -46,20 +47,18 @@ export async function filterMetadata( await new Promise(resolve => setTimeout(resolve, 10000)); batchWaitCounter = 0; } - console.log('Reviewing', masterEdition.pubkey.toBase58()); + console.log('Reviewing', masterEdition.pubkey); let printingBal = 0; try { let printingBalResp = await connection.getTokenSupply( - masterEdition.info.printingMint, + toPublicKey(masterEdition.info.printingMint), ); printingBal = printingBalResp.value.uiAmount || 0; } catch (e) { console.error(e); } - const myAcct = accountsByMint.get( - masterEdition.info.printingMint.toBase58(), - ); + const myAcct = accountsByMint.get(masterEdition.info.printingMint); if (myAcct) { console.log( 'Existing print account subtracts', @@ -73,7 +72,7 @@ export async function filterMetadata( if (printingBal > 0) { console.log( 'Reject', - masterEdition.pubkey.toBase58(), + masterEdition.pubkey, 'due to printing bal of', printingBal, ); @@ -82,7 +81,7 @@ export async function filterMetadata( let oneTimeBal = 0; try { let oneTimeBalResp = await connection.getTokenSupply( - masterEdition.info.oneTimePrintingAuthorizationMint, + toPublicKey(masterEdition.info.oneTimePrintingAuthorizationMint), ); oneTimeBal = oneTimeBalResp.value.uiAmount || 0; } catch (e) { @@ -90,7 +89,7 @@ export async function filterMetadata( } const myAcct = accountsByMint.get( - masterEdition.info.oneTimePrintingAuthorizationMint.toBase58(), + masterEdition.info.oneTimePrintingAuthorizationMint, ); if (myAcct) { console.log( @@ -105,7 +104,7 @@ export async function filterMetadata( if (oneTimeBal > 0) { console.log( 'Reject', - masterEdition.pubkey.toBase58(), + masterEdition.pubkey, 'due to one time auth bal of', oneTimeBal, ); @@ -143,20 +142,20 @@ export async function convertMasterEditions( for (let i = 0; i < masterEditions.length; i++) { const masterEdition = masterEditions[i] as ParsedAccount; - console.log('Converting', masterEdition.pubkey.toBase58()); + console.log('Converting', masterEdition.pubkey); const printingMintAcct = accountsByMint.get( - masterEdition.info.printingMint.toBase58(), + masterEdition.info.printingMint, ); const oneTimeAuthMintAcct = accountsByMint.get( - masterEdition.info.oneTimePrintingAuthorizationMint.toBase58(), + masterEdition.info.oneTimePrintingAuthorizationMint, ); if (printingMintAcct) { if (printingMintAcct.info.amount.toNumber() > 0) { convertInstructions.push( Token.createBurnInstruction( PROGRAM_IDS.token, - masterEdition.info.printingMint, - printingMintAcct.pubkey, + toPublicKey(masterEdition.info.printingMint), + toPublicKey(printingMintAcct.pubkey), wallet.publicKey, [], printingMintAcct.info.amount, @@ -167,7 +166,7 @@ export async function convertMasterEditions( convertInstructions.push( Token.createCloseAccountInstruction( PROGRAM_IDS.token, - printingMintAcct.pubkey, + toPublicKey(printingMintAcct.pubkey), wallet.publicKey, wallet.publicKey, [], @@ -180,8 +179,8 @@ export async function convertMasterEditions( convertInstructions.push( Token.createBurnInstruction( PROGRAM_IDS.token, - masterEdition.info.oneTimePrintingAuthorizationMint, - oneTimeAuthMintAcct.pubkey, + toPublicKey(masterEdition.info.oneTimePrintingAuthorizationMint), + toPublicKey(oneTimeAuthMintAcct.pubkey), wallet.publicKey, [], oneTimeAuthMintAcct.info.amount, @@ -192,7 +191,7 @@ export async function convertMasterEditions( convertInstructions.push( Token.createCloseAccountInstruction( PROGRAM_IDS.token, - oneTimeAuthMintAcct.pubkey, + toPublicKey(oneTimeAuthMintAcct.pubkey), wallet.publicKey, wallet.publicKey, [], diff --git a/js/packages/web/src/actions/createAuctionManager.ts b/js/packages/web/src/actions/createAuctionManager.ts index 5da63fc..e5fb110 100644 --- a/js/packages/web/src/actions/createAuctionManager.ts +++ b/js/packages/web/src/actions/createAuctionManager.ts @@ -1,7 +1,6 @@ import { Keypair, Connection, - PublicKey, TransactionInstruction, SystemProgram, } from '@solana/web3.js'; @@ -24,6 +23,8 @@ import { findProgramAddress, IPartialCreateAuctionArgs, MetadataKey, + StringPublicKey, + toPublicKey, } from '@oyster/common'; import { AccountLayout, Token } from '@solana/spl-token'; @@ -87,8 +88,8 @@ export interface SafetyDepositDraft { metadata: ParsedAccount; masterEdition?: ParsedAccount; edition?: ParsedAccount; - holding: PublicKey; - printingMintHolding?: PublicKey; + holding: StringPublicKey; + printingMintHolding?: StringPublicKey; winningConfigType: WinningConfigType; amountRanges: AmountRange[]; participationConfig?: ParticipationConfigV2; @@ -106,11 +107,11 @@ export async function createAuctionManager( auctionSettings: IPartialCreateAuctionArgs, safetyDepositDrafts: SafetyDepositDraft[], participationSafetyDepositDraft: SafetyDepositDraft | undefined, - paymentMint: PublicKey, + paymentMint: StringPublicKey, ): Promise<{ - vault: PublicKey; - auction: PublicKey; - auctionManager: PublicKey; + vault: StringPublicKey; + auction: StringPublicKey; + auctionManager: StringPublicKey; }> { const accountRentExempt = await connection.getMinimumBalanceForRentExemption( AccountLayout.span, @@ -260,9 +261,8 @@ export async function createAuctionManager( // Only V1s need to skip normal validation and use special endpoint (participationSafetyDepositDraft.masterEdition?.info.key == MetadataKey.MasterEditionV1 && - !c.draft.metadata.pubkey.equals( - participationSafetyDepositDraft.metadata.pubkey, - )) || + c.draft.metadata.pubkey !== + participationSafetyDepositDraft.metadata.pubkey) || participationSafetyDepositDraft.masterEdition?.info.key == MetadataKey.MasterEditionV2, ), @@ -405,7 +405,7 @@ async function buildSafetyDepositArray( }, config: new SafetyDepositConfig({ directArgs: { - auctionManager: SystemProgram.programId, + auctionManager: SystemProgram.programId.toBase58(), order: new BN(i), amountRanges: s.amountRanges, amountType: maxAmount.gte(new BN(254)) @@ -439,7 +439,7 @@ async function buildSafetyDepositArray( .reverse()[0]; const config = new SafetyDepositConfig({ directArgs: { - auctionManager: SystemProgram.programId, + auctionManager: SystemProgram.programId.toBase58(), order: new BN(safetyDeposits.length), amountRanges: participationSafetyDepositDraft.amountRanges, amountType: maxAmount?.gte(new BN(255)) @@ -470,7 +470,9 @@ async function buildSafetyDepositArray( [ wallet.publicKey.toBuffer(), programIds().token.toBuffer(), - me?.info.oneTimePrintingAuthorizationMint.toBuffer(), + toPublicKey( + me?.info.oneTimePrintingAuthorizationMint, + ).toBuffer(), ], programIds().associatedToken, ) @@ -499,17 +501,17 @@ async function buildSafetyDepositArray( async function setupAuctionManagerInstructions( wallet: any, - vault: PublicKey, - paymentMint: PublicKey, + vault: StringPublicKey, + paymentMint: StringPublicKey, accountRentExempt: number, safetyDeposits: SafetyDepositInstructionTemplate[], auctionSettings: IPartialCreateAuctionArgs, ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; - auctionManager: PublicKey; + auctionManager: StringPublicKey; }> { - let store = programIds().store; + let store = programIds().store?.toBase58(); if (!store) { throw new Error('Store not initialized'); } @@ -523,10 +525,10 @@ async function setupAuctionManagerInstructions( instructions, wallet.publicKey, accountRentExempt, - paymentMint, - auctionManagerKey, + toPublicKey(paymentMint), + toPublicKey(auctionManagerKey), signers, - ); + ).toBase58(); let maxRanges = [ auctionSettings.winners.usize.toNumber(), @@ -539,8 +541,8 @@ async function setupAuctionManagerInstructions( await initAuctionManagerV2( vault, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), acceptPayment, store, safetyDeposits.length >= 254 ? TupleNumericType.U16 : TupleNumericType.U8, @@ -556,7 +558,7 @@ async function setupAuctionManagerInstructions( async function setupStartAuction( wallet: any, - vault: PublicKey, + vault: StringPublicKey, ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; @@ -571,17 +573,17 @@ async function setupStartAuction( async function deprecatedValidateParticipationHelper( wallet: any, - auctionManager: PublicKey, + auctionManager: StringPublicKey, whitelistedCreatorsByCreator: Record< string, ParsedAccount >, - vault: PublicKey, - tokenStore: PublicKey, + vault: StringPublicKey, + tokenStore: StringPublicKey, participationSafetyDepositDraft: SafetyDepositDraft, accountRentExempt: number, ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[] }> { - const store = programIds().store; + const store = programIds().store?.toBase58(); if (!store) { throw new Error('Store not initialized'); } @@ -611,16 +613,16 @@ async function deprecatedValidateParticipationHelper( instructions, wallet.publicKey, accountRentExempt, - me.info.printingMint, - auctionManagerKey, + toPublicKey(me.info.printingMint), + toPublicKey(auctionManagerKey), signers, - ); + ).toBase58(); await deprecatedValidateParticipation( auctionManager, participationSafetyDepositDraft.metadata.pubkey, participationSafetyDepositDraft.masterEdition?.pubkey, printingTokenHoldingAccount, - wallet.publicKey, + wallet.publicKey.toBase58(), whitelistedCreator, store, await getSafetyDepositBoxAddress( @@ -642,14 +644,12 @@ async function findValidWhitelistedCreator( ParsedAccount >, creators: Creator[], -): Promise { +): Promise { for (let i = 0; i < creators.length; i++) { const creator = creators[i]; - if ( - whitelistedCreatorsByCreator[creator.address.toBase58()]?.info.activated - ) - return whitelistedCreatorsByCreator[creator.address.toBase58()].pubkey; + if (whitelistedCreatorsByCreator[creator.address]?.info.activated) + return whitelistedCreatorsByCreator[creator.address].pubkey; } return await getWhitelistedCreator(creators[0]?.address); } @@ -660,14 +660,14 @@ async function validateBoxes( string, ParsedAccount >, - vault: PublicKey, + vault: StringPublicKey, safetyDeposits: SafetyDepositInstructionTemplate[], - safetyDepositTokenStores: PublicKey[], + safetyDepositTokenStores: StringPublicKey[], ): Promise<{ instructions: TransactionInstruction[][]; signers: Keypair[][]; }> { - const store = programIds().store; + const store = programIds().store?.toBase58(); if (!store) { throw new Error('Store not initialized'); } @@ -678,7 +678,7 @@ async function validateBoxes( let tokenSigners: Keypair[] = []; let tokenInstructions: TransactionInstruction[] = []; - let safetyDepositBox: PublicKey; + let safetyDepositBox: StringPublicKey; const me = safetyDeposits[i].draft .masterEdition as ParsedAccount; @@ -699,7 +699,7 @@ async function validateBoxes( safetyDeposits[i].draft.metadata.info.mint, ); } - const edition: PublicKey = await getEdition( + const edition: StringPublicKey = await getEdition( safetyDeposits[i].draft.metadata.info.mint, ); @@ -721,9 +721,9 @@ async function validateBoxes( WinningConfigType.PrintingV1 ? me?.info.printingMint : safetyDeposits[i].draft.metadata.info.mint, - wallet.publicKey, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), tokenInstructions, edition, whitelistedCreator, @@ -740,7 +740,7 @@ async function validateBoxes( async function deprecatedBuildAndPopulateOneTimeAuthorizationAccount( connection: Connection, wallet: any, - oneTimePrintingAuthorizationMint: PublicKey | undefined, + oneTimePrintingAuthorizationMint: StringPublicKey | undefined, ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; @@ -749,32 +749,32 @@ async function deprecatedBuildAndPopulateOneTimeAuthorizationAccount( return { instructions: [], signers: [] }; let signers: Keypair[] = []; let instructions: TransactionInstruction[] = []; - const recipientKey: PublicKey = ( + const recipientKey: StringPublicKey = ( await findProgramAddress( [ wallet.publicKey.toBuffer(), programIds().token.toBuffer(), - oneTimePrintingAuthorizationMint.toBuffer(), + toPublicKey(oneTimePrintingAuthorizationMint).toBuffer(), ], programIds().associatedToken, ) )[0]; - if (!(await connection.getAccountInfo(recipientKey))) { + if (!(await connection.getAccountInfo(toPublicKey(recipientKey)))) { createAssociatedTokenAccountInstruction( instructions, - recipientKey, + toPublicKey(recipientKey), wallet.publicKey, wallet.publicKey, - oneTimePrintingAuthorizationMint, + toPublicKey(oneTimePrintingAuthorizationMint), ); } instructions.push( Token.createMintToInstruction( programIds().token, - oneTimePrintingAuthorizationMint, - recipientKey, + toPublicKey(oneTimePrintingAuthorizationMint), + toPublicKey(recipientKey), wallet.publicKey, [], 1, diff --git a/js/packages/web/src/actions/createExternalPriceAccount.ts b/js/packages/web/src/actions/createExternalPriceAccount.ts index 26941c6..2d87fcd 100644 --- a/js/packages/web/src/actions/createExternalPriceAccount.ts +++ b/js/packages/web/src/actions/createExternalPriceAccount.ts @@ -1,11 +1,10 @@ import { Keypair, Connection, - PublicKey, SystemProgram, TransactionInstruction, } from '@solana/web3.js'; -import { utils, actions } from '@oyster/common'; +import { utils, actions, StringPublicKey, toPublicKey } from '@oyster/common'; import BN from 'bn.js'; import { QUOTE_MINT } from '../constants'; @@ -20,8 +19,8 @@ export async function createExternalPriceAccount( connection: Connection, wallet: any, ): Promise<{ - priceMint: PublicKey; - externalPriceAccount: PublicKey; + priceMint: StringPublicKey; + externalPriceAccount: StringPublicKey; instructions: TransactionInstruction[]; signers: Keypair[]; }> { @@ -35,10 +34,11 @@ export async function createExternalPriceAccount( ); let externalPriceAccount = Keypair.generate(); + let key = externalPriceAccount.publicKey.toBase58(); let epaStruct = new ExternalPriceAccount({ pricePerShare: new BN(0), - priceMint: QUOTE_MINT, + priceMint: QUOTE_MINT.toBase58(), allowedToCombine: true, }); @@ -47,20 +47,16 @@ export async function createExternalPriceAccount( newAccountPubkey: externalPriceAccount.publicKey, lamports: epaRentExempt, space: MAX_EXTERNAL_ACCOUNT_SIZE, - programId: PROGRAM_IDS.vault, + programId: toPublicKey(PROGRAM_IDS.vault), }); instructions.push(uninitializedEPA); signers.push(externalPriceAccount); - await updateExternalPriceAccount( - externalPriceAccount.publicKey, - epaStruct, - instructions, - ); + await updateExternalPriceAccount(key, epaStruct, instructions); return { - externalPriceAccount: externalPriceAccount.publicKey, - priceMint: QUOTE_MINT, + externalPriceAccount: key, + priceMint: QUOTE_MINT.toBase58(), instructions, signers, }; diff --git a/js/packages/web/src/actions/createVault.ts b/js/packages/web/src/actions/createVault.ts index 4788e7b..d3aaab9 100644 --- a/js/packages/web/src/actions/createVault.ts +++ b/js/packages/web/src/actions/createVault.ts @@ -1,11 +1,17 @@ import { Keypair, Connection, - PublicKey, SystemProgram, TransactionInstruction, } from '@solana/web3.js'; -import { utils, actions, createMint, findProgramAddress } from '@oyster/common'; +import { + utils, + actions, + createMint, + findProgramAddress, + StringPublicKey, + toPublicKey, +} from '@oyster/common'; import { AccountLayout, MintLayout } from '@solana/spl-token'; const { createTokenAccount, initVault, MAX_VAULT_SIZE, VAULT_PREFIX } = actions; @@ -15,13 +21,13 @@ const { createTokenAccount, initVault, MAX_VAULT_SIZE, VAULT_PREFIX } = actions; export async function createVault( connection: Connection, wallet: any, - priceMint: PublicKey, - externalPriceAccount: PublicKey, + priceMint: StringPublicKey, + externalPriceAccount: StringPublicKey, ): Promise<{ - vault: PublicKey; - fractionalMint: PublicKey; - redeemTreasury: PublicKey; - fractionTreasury: PublicKey; + vault: StringPublicKey; + fractionalMint: StringPublicKey; + redeemTreasury: StringPublicKey; + fractionTreasury: StringPublicKey; instructions: TransactionInstruction[]; signers: Keypair[]; }> { @@ -48,10 +54,10 @@ export async function createVault( await findProgramAddress( [ Buffer.from(VAULT_PREFIX), - PROGRAM_IDS.vault.toBuffer(), + toPublicKey(PROGRAM_IDS.vault).toBuffer(), vault.publicKey.toBuffer(), ], - PROGRAM_IDS.vault, + toPublicKey(PROGRAM_IDS.vault), ) )[0]; @@ -60,35 +66,35 @@ export async function createVault( wallet.publicKey, mintRentExempt, 0, - vaultAuthority, - vaultAuthority, + toPublicKey(vaultAuthority), + toPublicKey(vaultAuthority), signers, - ); + ).toBase58(); const redeemTreasury = createTokenAccount( instructions, wallet.publicKey, accountRentExempt, - priceMint, - vaultAuthority, + toPublicKey(priceMint), + toPublicKey(vaultAuthority), signers, - ); + ).toBase58(); const fractionTreasury = createTokenAccount( instructions, wallet.publicKey, accountRentExempt, - fractionalMint, - vaultAuthority, + toPublicKey(fractionalMint), + toPublicKey(vaultAuthority), signers, - ); + ).toBase58(); const uninitializedVault = SystemProgram.createAccount({ fromPubkey: wallet.publicKey, newAccountPubkey: vault.publicKey, lamports: vaultRentExempt, space: MAX_VAULT_SIZE, - programId: PROGRAM_IDS.vault, + programId: toPublicKey(PROGRAM_IDS.vault), }); instructions.push(uninitializedVault); signers.push(vault); @@ -98,14 +104,14 @@ export async function createVault( fractionalMint, redeemTreasury, fractionTreasury, - vault.publicKey, - wallet.publicKey, + vault.publicKey.toBase58(), + wallet.publicKey.toBase58(), externalPriceAccount, instructions, ); return { - vault: vault.publicKey, + vault: vault.publicKey.toBase58(), fractionalMint, redeemTreasury, fractionTreasury, diff --git a/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts b/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts index 94c7ad9..19c4324 100644 --- a/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts +++ b/js/packages/web/src/actions/decommAuctionManagerAndReturnPrizes.ts @@ -1,7 +1,5 @@ import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { - BidderMetadata, - ParsedAccount, sendTransactionsWithManualRetry, setAuctionAuthority, setVaultAuthority, @@ -9,11 +7,7 @@ import { } from '@oyster/common'; import { AuctionView } from '../hooks'; -import { - AuctionManagerStatus, - BidRedemptionTicket, - PrizeTrackingTicket, -} from '../models/metaplex'; +import { AuctionManagerStatus } from '../models/metaplex'; import { decommissionAuctionManager } from '../models/metaplex/decommissionAuctionManager'; import { claimUnusedPrizes } from './claimUnusedPrizes'; @@ -30,18 +24,18 @@ export async function decommAuctionManagerAndReturnPrizes( let decomSigners: Keypair[] = []; let decomInstructions: TransactionInstruction[] = []; - if (auctionView.auction.info.authority.equals(wallet.publicKey)) { + if (auctionView.auction.info.authority === wallet.publicKey.toBase58()) { await setAuctionAuthority( auctionView.auction.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), auctionView.auctionManager.pubkey, decomInstructions, ); } - if (auctionView.vault.info.authority.equals(wallet.publicKey)) { + if (auctionView.vault.info.authority === wallet.publicKey.toBase58()) { await setVaultAuthority( auctionView.vault.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), auctionView.auctionManager.pubkey, decomInstructions, ); @@ -49,7 +43,7 @@ export async function decommAuctionManagerAndReturnPrizes( await decommissionAuctionManager( auctionView.auctionManager.pubkey, auctionView.auction.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), auctionView.vault.pubkey, decomInstructions, ); diff --git a/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts b/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts index 5afd630..0d1f01d 100644 --- a/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts +++ b/js/packages/web/src/actions/deprecatedCreateReservationListsForTokens.ts @@ -1,5 +1,8 @@ -import { Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js'; -import { deprecatedCreateReservationList } from '@oyster/common'; +import { Keypair, TransactionInstruction } from '@solana/web3.js'; +import { + deprecatedCreateReservationList, + StringPublicKey, +} from '@oyster/common'; import { SafetyDepositInstructionTemplate } from './addTokensToVault'; import { WinningConfigType } from '../models/metaplex'; @@ -9,7 +12,7 @@ const BATCH_SIZE = 10; // Reservation lists are used to insure printing order among limited editions. export async function deprecatedCreateReservationListForTokens( wallet: any, - auctionManager: PublicKey, + auctionManager: StringPublicKey, safetyDepositInstructionTemplates: SafetyDepositInstructionTemplate[], ): Promise<{ instructions: Array; @@ -33,8 +36,8 @@ export async function deprecatedCreateReservationListForTokens( safetyDeposit.draft.metadata.pubkey, safetyDeposit.draft.masterEdition.pubkey, auctionManager, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), currInstructions, ); diff --git a/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts b/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts index 51833be..b015f72 100644 --- a/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts +++ b/js/packages/web/src/actions/deprecatedPopulatePrintingTokens.ts @@ -1,9 +1,4 @@ -import { - Keypair, - Connection, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { utils, createAssociatedTokenAccountInstruction, @@ -12,6 +7,7 @@ import { MasterEditionV1, ParsedAccount, MetadataKey, + toPublicKey, } from '@oyster/common'; import BN from 'bn.js'; @@ -46,13 +42,13 @@ export async function deprecatedPopulatePrintingTokens( const printingMint = ( nft.draft.masterEdition as ParsedAccount )?.info.printingMint; - if (nft.box.tokenMint.equals(printingMint) && !nft.box.tokenAccount) { - const holdingKey: PublicKey = ( + if (nft.box.tokenMint === printingMint && !nft.box.tokenAccount) { + const holdingKey = ( await findProgramAddress( [ wallet.publicKey.toBuffer(), PROGRAM_IDS.token.toBuffer(), - printingMint.toBuffer(), + toPublicKey(printingMint).toBuffer(), ], PROGRAM_IDS.associatedToken, ) @@ -60,22 +56,25 @@ export async function deprecatedPopulatePrintingTokens( createAssociatedTokenAccountInstruction( currInstructions, - holdingKey, + toPublicKey(holdingKey), wallet.publicKey, wallet.publicKey, - printingMint, + toPublicKey(printingMint), ); console.log('Making atas'); nft.draft.printingMintHolding = holdingKey; nft.box.tokenAccount = holdingKey; } - if (nft.box.tokenAccount && nft.box.tokenMint.equals(printingMint)) { + if (nft.box.tokenAccount && nft.box.tokenMint === printingMint) { let balance = 0; try { balance = - (await connection.getTokenAccountBalance(nft.box.tokenAccount)).value - .uiAmount || 0; + ( + await connection.getTokenAccountBalance( + toPublicKey(nft.box.tokenAccount), + ) + ).value.uiAmount || 0; } catch (e) { console.error(e); } @@ -84,7 +83,7 @@ export async function deprecatedPopulatePrintingTokens( await deprecatedMintPrintingTokens( nft.box.tokenAccount, nft.box.tokenMint, - wallet.publicKey, + wallet.publicKey.toBase58(), nft.draft.metadata.pubkey, nft.draft.masterEdition.pubkey, new BN(nft.box.amount.toNumber() - balance), diff --git a/js/packages/web/src/actions/makeAuction.ts b/js/packages/web/src/actions/makeAuction.ts index ac58b52..eda0934 100644 --- a/js/packages/web/src/actions/makeAuction.ts +++ b/js/packages/web/src/actions/makeAuction.ts @@ -1,10 +1,12 @@ -import { Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js'; +import { Keypair, TransactionInstruction } from '@solana/web3.js'; import { utils, actions, findProgramAddress, IPartialCreateAuctionArgs, CreateAuctionArgs, + StringPublicKey, + toPublicKey, } from '@oyster/common'; const { AUCTION_PREFIX, createAuction } = actions; @@ -12,10 +14,10 @@ const { AUCTION_PREFIX, createAuction } = actions; // This command makes an auction export async function makeAuction( wallet: any, - vault: PublicKey, + vault: StringPublicKey, auctionSettings: IPartialCreateAuctionArgs, ): Promise<{ - auction: PublicKey; + auction: StringPublicKey; instructions: TransactionInstruction[]; signers: Keypair[]; }> { @@ -23,24 +25,24 @@ export async function makeAuction( let signers: Keypair[] = []; let instructions: TransactionInstruction[] = []; - const auctionKey: PublicKey = ( + const auctionKey = ( await findProgramAddress( [ Buffer.from(AUCTION_PREFIX), - PROGRAM_IDS.auction.toBuffer(), - vault.toBuffer(), + toPublicKey(PROGRAM_IDS.auction).toBuffer(), + toPublicKey(vault).toBuffer(), ], - PROGRAM_IDS.auction, + toPublicKey(PROGRAM_IDS.auction), ) )[0]; const fullSettings = new CreateAuctionArgs({ ...auctionSettings, - authority: wallet.publicKey, + authority: wallet.publicKey.toBase58(), resource: vault, }); - createAuction(fullSettings, wallet.publicKey, instructions); + createAuction(fullSettings, wallet.publicKey.toBase58(), instructions); return { instructions, signers, auction: auctionKey }; } diff --git a/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts b/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts index d042f45..c648ad3 100644 --- a/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts +++ b/js/packages/web/src/actions/markItemsThatArentMineAsSold.ts @@ -19,7 +19,9 @@ export async function markItemsThatArentMineAsSold( const item = safetyDepositDrafts[i].metadata; if ( - !item.info.data.creators?.find(c => c.address.equals(wallet.publicKey)) && + !item.info.data.creators?.find( + c => c.address === wallet.publicKey.toBase58(), + ) && !item.info.primarySaleHappened ) { console.log( @@ -29,7 +31,7 @@ export async function markItemsThatArentMineAsSold( ); await updatePrimarySaleHappenedViaToken( item.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), safetyDepositDrafts[i].holding, markInstructions, ); diff --git a/js/packages/web/src/actions/nft.tsx b/js/packages/web/src/actions/nft.tsx index 7399509..2218771 100644 --- a/js/packages/web/src/actions/nft.tsx +++ b/js/packages/web/src/actions/nft.tsx @@ -11,6 +11,8 @@ import { Data, Creator, findProgramAddress, + StringPublicKey, + toPublicKey, } from '@oyster/common'; import React from 'react'; import { MintLayout, Token } from '@solana/spl-token'; @@ -18,7 +20,6 @@ import { WalletAdapter } from '@solana/wallet-base'; import { Keypair, Connection, - PublicKey, SystemProgram, TransactionInstruction, } from '@solana/web3.js'; @@ -56,7 +57,7 @@ export const mintNFT = async ( }, maxSupply?: number, ): Promise<{ - metadataAccount: PublicKey; + metadataAccount: StringPublicKey; } | void> => { if (!wallet?.publicKey) { return; @@ -74,7 +75,7 @@ export const mintNFT = async ( ...metadata.properties, creators: metadata.creators?.map(creator => { return { - address: creator.address.toBase58(), + address: creator.address, share: creator.share, }; }), @@ -103,7 +104,7 @@ export const mintNFT = async ( // twice post Arweave. We store in an account (payer) and use it post-Arweave to update MD with new link // then give control back to the user. // const payer = new Account(); - const payerPublicKey = wallet.publicKey; + const payerPublicKey = wallet.publicKey.toBase58(); const instructions: TransactionInstruction[] = [...pushInstructions]; const signers: Keypair[] = [...pushSigners]; @@ -114,17 +115,17 @@ export const mintNFT = async ( mintRent, 0, // Some weird bug with phantom where it's public key doesnt mesh with data encode wellff - payerPublicKey, - payerPublicKey, + toPublicKey(payerPublicKey), + toPublicKey(payerPublicKey), signers, - ); + ).toBase58(); - const recipientKey: PublicKey = ( + const recipientKey = ( await findProgramAddress( [ wallet.publicKey.toBuffer(), programIds().token.toBuffer(), - mintKey.toBuffer(), + toPublicKey(mintKey).toBuffer(), ], programIds().associatedToken, ) @@ -132,10 +133,10 @@ export const mintNFT = async ( createAssociatedTokenAccountInstruction( instructions, - recipientKey, + toPublicKey(recipientKey), wallet.publicKey, wallet.publicKey, - mintKey, + toPublicKey(mintKey), ); const metadataAccount = await createMetadata( @@ -150,7 +151,7 @@ export const mintNFT = async ( mintKey, payerPublicKey, instructions, - wallet.publicKey, + wallet.publicKey.toBase58(), ); // TODO: enable when using payer account to avoid 2nd popup @@ -185,7 +186,7 @@ export const mintNFT = async ( const tags = realFiles.reduce( (acc: Record>, f) => { - acc[f.name] = [{ name: 'mint', value: mintKey.toBase58() }]; + acc[f.name] = [{ name: 'mint', value: mintKey }]; return acc; }, {}, @@ -237,9 +238,9 @@ export const mintNFT = async ( updateInstructions.push( Token.createMintToInstruction( TOKEN_PROGRAM_ID, - mintKey, - recipientKey, - payerPublicKey, + toPublicKey(mintKey), + toPublicKey(recipientKey), + toPublicKey(payerPublicKey), [], 1, ), diff --git a/js/packages/web/src/actions/saveAdmin.ts b/js/packages/web/src/actions/saveAdmin.ts index 473ad65..a3be6e5 100644 --- a/js/packages/web/src/actions/saveAdmin.ts +++ b/js/packages/web/src/actions/saveAdmin.ts @@ -25,8 +25,8 @@ export async function saveAdmin( await setStore( isPublic, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), storeInstructions, ); signers.push(storeSigners); @@ -40,8 +40,8 @@ export async function saveAdmin( await setWhitelistedCreator( wc.address, wc.activated, - wallet.publicKey, - wallet.publicKey, + wallet.publicKey.toBase58(), + wallet.publicKey.toBase58(), wcInstructions, ); signers.push(wcSigners); diff --git a/js/packages/web/src/actions/sendPlaceBid.ts b/js/packages/web/src/actions/sendPlaceBid.ts index 8582cc7..729d1f7 100644 --- a/js/packages/web/src/actions/sendPlaceBid.ts +++ b/js/packages/web/src/actions/sendPlaceBid.ts @@ -1,9 +1,4 @@ -import { - Keypair, - Connection, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { actions, sendTransactionWithRetry, @@ -14,6 +9,7 @@ import { ensureWrappedAccount, toLamports, ParsedAccount, + toPublicKey, } from '@oyster/common'; import { AccountLayout, MintInfo } from '@solana/spl-token'; @@ -27,7 +23,7 @@ const { approve } = models; export async function sendPlaceBid( connection: Connection, wallet: any, - bidderTokenAccount: PublicKey | undefined, + bidderTokenAccount: string | undefined, auctionView: AuctionView, accountsByMint: Map, // value entered by the user adjust to decimals of the mint @@ -62,7 +58,7 @@ export async function sendPlaceBid( export async function setupPlaceBid( connection: Connection, wallet: any, - bidderTokenAccount: PublicKey | undefined, + bidderTokenAccount: string | undefined, auctionView: AuctionView, accountsByMint: Map, // value entered by the user adjust to decimals of the mint @@ -86,16 +82,16 @@ export async function setupPlaceBid( ) as ParsedAccount; let lamports = toLamports(amount, mint.info) + accountRentExempt; - let bidderPotTokenAccount: PublicKey; + let bidderPotTokenAccount: string; if (!auctionView.myBidderPot) { bidderPotTokenAccount = createTokenAccount( instructions, wallet.publicKey, accountRentExempt, - auctionView.auction.info.tokenMint, - auctionView.auction.pubkey, + toPublicKey(auctionView.auction.info.tokenMint), + toPublicKey(auctionView.auction.pubkey), signers, - ); + ).toBase58(); } else { bidderPotTokenAccount = auctionView.myBidderPot?.info.bidderPot; if (!auctionView.auction.info.ended()) { @@ -126,7 +122,7 @@ export async function setupPlaceBid( const transferAuthority = approve( instructions, cleanupInstructions, - payingSolAccount, + toPublicKey(payingSolAccount), wallet.publicKey, lamports - accountRentExempt, ); @@ -135,12 +131,12 @@ export async function setupPlaceBid( const bid = new BN(lamports - accountRentExempt); await placeBid( - wallet.publicKey, + wallet.publicKey.toBase58(), payingSolAccount, bidderPotTokenAccount, auctionView.auction.info.tokenMint, - transferAuthority.publicKey, - wallet.publicKey, + transferAuthority.publicKey.toBase58(), + wallet.publicKey.toBase58(), auctionView.auctionManager.vault, bid, instructions, diff --git a/js/packages/web/src/actions/sendRedeemBid.ts b/js/packages/web/src/actions/sendRedeemBid.ts index 0095fa5..042500e 100644 --- a/js/packages/web/src/actions/sendRedeemBid.ts +++ b/js/packages/web/src/actions/sendRedeemBid.ts @@ -1,9 +1,4 @@ -import { - Keypair, - Connection, - PublicKey, - TransactionInstruction, -} from '@solana/web3.js'; +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { actions, ParsedAccount, @@ -30,6 +25,8 @@ import { getEditionMarkPda, decodeEditionMarker, BidStateType, + StringPublicKey, + toPublicKey, } from '@oyster/common'; import { AccountLayout, MintLayout, Token } from '@solana/spl-token'; @@ -90,7 +87,7 @@ export function eligibleForParticipationPrizeGivenWinningIndex( export async function sendRedeemBid( connection: Connection, wallet: any, - payingAccount: PublicKey, + payingAccount: StringPublicKey, auctionView: AuctionView, accountsByMint: Map, prizeTrackingTickets: Record>, @@ -163,7 +160,7 @@ export async function sendRedeemBid( auctionView, mintRentExempt, wallet, - wallet.publicKey, + wallet.publicKey.toBase58(), safetyDeposit, item, signers, @@ -262,7 +259,7 @@ export async function sendRedeemBid( accountRentExempt, mintRentExempt, wallet, - wallet.publicKey, + wallet.publicKey.toBase58(), safetyDeposit, auctionView.myBidRedemption, auctionView.myBidderMetadata, @@ -273,7 +270,7 @@ export async function sendRedeemBid( } } - if (wallet.publicKey.equals(auctionView.auctionManager.authority)) { + if (wallet.publicKey.toBase58() === auctionView.auctionManager.authority) { await claimUnusedPrizes( connection, wallet, @@ -316,17 +313,17 @@ async function setupRedeemInstructions( ); if (!claimed && auctionView.myBidderMetadata) { let newTokenAccount = accountsByMint.get( - safetyDeposit.info.tokenMint.toBase58(), + safetyDeposit.info.tokenMint, )?.pubkey; if (!newTokenAccount) newTokenAccount = createTokenAccount( winningPrizeInstructions, wallet.publicKey, accountRentExempt, - safetyDeposit.info.tokenMint, + toPublicKey(safetyDeposit.info.tokenMint), wallet.publicKey, winningPrizeSigner, - ); + ).toBase58(); await redeemBid( auctionView.auctionManager.vault, @@ -335,7 +332,7 @@ async function setupRedeemInstructions( safetyDeposit.pubkey, auctionView.vault.info.fractionMint, auctionView.myBidderMetadata.info.bidderPubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), undefined, undefined, false, @@ -345,7 +342,7 @@ async function setupRedeemInstructions( const metadata = await getMetadata(safetyDeposit.info.tokenMint); await updatePrimarySaleHappenedViaToken( metadata, - wallet.publicKey, + wallet.publicKey.toBase58(), newTokenAccount, winningPrizeInstructions, ); @@ -375,17 +372,17 @@ async function setupRedeemFullRightsTransferInstructions( ); if (!claimed && auctionView.myBidderMetadata) { let newTokenAccount = accountsByMint.get( - safetyDeposit.info.tokenMint.toBase58(), + safetyDeposit.info.tokenMint, )?.pubkey; if (!newTokenAccount) newTokenAccount = createTokenAccount( winningPrizeInstructions, wallet.publicKey, accountRentExempt, - safetyDeposit.info.tokenMint, + toPublicKey(safetyDeposit.info.tokenMint), wallet.publicKey, winningPrizeSigner, - ); + ).toBase58(); await redeemFullRightsTransferBid( auctionView.auctionManager.vault, @@ -394,10 +391,10 @@ async function setupRedeemFullRightsTransferInstructions( safetyDeposit.pubkey, auctionView.vault.info.fractionMint, auctionView.myBidderMetadata.info.bidderPubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), winningPrizeInstructions, item.metadata.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), ); const metadata = await getMetadata(safetyDeposit.info.tokenMint); @@ -412,11 +409,11 @@ async function setupRedeemFullRightsTransferInstructions( async function createMintAndAccountWithOne( wallet: any, - receiverWallet: PublicKey, + receiverWallet: StringPublicKey, mintRent: any, instructions: TransactionInstruction[], signers: Keypair[], -): Promise<{ mint: PublicKey; account: PublicKey }> { +): Promise<{ mint: StringPublicKey; account: StringPublicKey }> { const mint = createMint( instructions, wallet.publicKey, @@ -429,10 +426,10 @@ async function createMintAndAccountWithOne( const PROGRAM_IDS = programIds(); - const account: PublicKey = ( + const account: StringPublicKey = ( await findProgramAddress( [ - receiverWallet.toBuffer(), + toPublicKey(receiverWallet).toBuffer(), PROGRAM_IDS.token.toBuffer(), mint.toBuffer(), ], @@ -442,9 +439,9 @@ async function createMintAndAccountWithOne( createAssociatedTokenAccountInstruction( instructions, - account, + toPublicKey(account), wallet.publicKey, - receiverWallet, + toPublicKey(receiverWallet), mint, ); @@ -452,14 +449,14 @@ async function createMintAndAccountWithOne( Token.createMintToInstruction( PROGRAM_IDS.token, mint, - account, + toPublicKey(account), wallet.publicKey, [], 1, ), ); - return { mint, account }; + return { mint: mint.toBase58(), account }; } export async function setupRedeemPrintingV2Instructions( @@ -467,7 +464,7 @@ export async function setupRedeemPrintingV2Instructions( auctionView: AuctionView, mintRentExempt: number, wallet: any, - receiverWallet: PublicKey, + receiverWallet: StringPublicKey, safetyDeposit: ParsedAccount, item: AuctionViewItem, signers: Array, @@ -486,8 +483,7 @@ export async function setupRedeemPrintingV2Instructions( item.metadata.info.mint, ); - const myPrizeTrackingTicket = - prizeTrackingTickets[myPrizeTrackingTicketKey.toBase58()]; + const myPrizeTrackingTicket = prizeTrackingTickets[myPrizeTrackingTicketKey]; // We are not entirely guaranteed this is right. Someone could be clicking at the same time. Contract will throw error if this // is the case and they'll need to refresh to get tracking ticket which may not have existed when they first clicked. const editionBase = myPrizeTrackingTicket @@ -530,7 +526,9 @@ export async function setupRedeemPrintingV2Instructions( ); try { - const editionData = await connection.getAccountInfo(editionMarkPda); + const editionData = await connection.getAccountInfo( + toPublicKey(editionMarkPda), + ); if (editionData) { const marker = decodeEditionMarker(editionData.data); @@ -550,7 +548,7 @@ export async function setupRedeemPrintingV2Instructions( account, safetyDeposit.pubkey, receiverWallet, - wallet.publicKey, + wallet.publicKey.toBase58(), item.metadata.pubkey, me.pubkey, item.metadata.info.mint, @@ -563,10 +561,10 @@ export async function setupRedeemPrintingV2Instructions( const metadata = await getMetadata(mint); - if (wallet.publicKey.equals(receiverWallet)) { + if (wallet.publicKey.toBase58() === receiverWallet) { await updatePrimarySaleHappenedViaToken( metadata, - wallet.publicKey, + wallet.publicKey.toBase58(), account, myInstructions, ); @@ -600,8 +598,8 @@ async function deprecatedSetupRedeemPrintingV1Instructions( const me = item.masterEdition as ParsedAccount; - const newTokenAccount = accountsByMint.get(me.info.printingMint.toBase58()); - let newTokenAccountKey: PublicKey | undefined = newTokenAccount?.pubkey; + const newTokenAccount = accountsByMint.get(me.info.printingMint); + let newTokenAccountKey: StringPublicKey | undefined = newTokenAccount?.pubkey; let newTokenAccountBalance: number = newTokenAccount ? newTokenAccount.info.amount.toNumber() @@ -626,10 +624,10 @@ async function deprecatedSetupRedeemPrintingV1Instructions( winningPrizeInstructions, wallet.publicKey, accountRentExempt, - me.info.printingMint, + toPublicKey(me.info.printingMint), wallet.publicKey, winningPrizeSigner, - ); + ).toBase58(); await redeemBid( auctionView.auctionManager.vault, @@ -638,7 +636,7 @@ async function deprecatedSetupRedeemPrintingV1Instructions( safetyDeposit.pubkey, auctionView.vault.info.fractionMint, auctionView.myBidderMetadata.info.bidderPubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), item.masterEdition.pubkey, reservationList, true, @@ -669,14 +667,14 @@ async function deprecatedSetupRedeemPrintingV1Instructions( async function deprecatedRedeemPrintingV1Token( wallet: any, - updateAuth: PublicKey, + updateAuth: StringPublicKey, item: AuctionViewItem, - newTokenAccount: PublicKey, + newTokenAccount: StringPublicKey, mintRentExempt: number, accountRentExempt: number, signers: Keypair[][], instructions: TransactionInstruction[][], - reservationList?: PublicKey, + reservationList?: StringPublicKey, ) { if (!item.masterEdition) return; let cashInLimitedPrizeAuthorizationTokenSigner: Keypair[] = []; @@ -693,12 +691,12 @@ async function deprecatedRedeemPrintingV1Token( wallet.publicKey, wallet.publicKey, cashInLimitedPrizeAuthorizationTokenSigner, - ); + ).toBase58(); const newLimitedEdition = createTokenAccount( cashInLimitedPrizeAuthorizationTokenInstruction, wallet.publicKey, accountRentExempt, - newLimitedEditionMint, + toPublicKey(newLimitedEditionMint), wallet.publicKey, cashInLimitedPrizeAuthorizationTokenSigner, ); @@ -706,7 +704,7 @@ async function deprecatedRedeemPrintingV1Token( cashInLimitedPrizeAuthorizationTokenInstruction.push( Token.createMintToInstruction( programIds().token, - newLimitedEditionMint, + toPublicKey(newLimitedEditionMint), newLimitedEdition, wallet.publicKey, [], @@ -717,7 +715,7 @@ async function deprecatedRedeemPrintingV1Token( const burnAuthority = approve( cashInLimitedPrizeAuthorizationTokenInstruction, [], - newTokenAccount, + toPublicKey(newTokenAccount), wallet.publicKey, 1, ); @@ -729,21 +727,21 @@ async function deprecatedRedeemPrintingV1Token( await deprecatedMintNewEditionFromMasterEditionViaPrintingToken( newLimitedEditionMint, item.metadata.info.mint, - wallet.publicKey, + wallet.publicKey.toBase58(), me.info.printingMint, newTokenAccount, - burnAuthority.publicKey, + burnAuthority.publicKey.toBase58(), updateAuth, reservationList, cashInLimitedPrizeAuthorizationTokenInstruction, - wallet.publicKey, + wallet.publicKey.toBase58(), ); const metadata = await getMetadata(newLimitedEditionMint); await updatePrimarySaleHappenedViaToken( metadata, - wallet.publicKey, - newLimitedEdition, + wallet.publicKey.toBase58(), + newLimitedEdition.toBase58(), cashInLimitedPrizeAuthorizationTokenInstruction, ); } @@ -755,7 +753,7 @@ export async function setupRedeemParticipationInstructions( accountRentExempt: number, mintRentExempt: number, wallet: any, - receiverWallet: PublicKey, + receiverWallet: StringPublicKey, safetyDeposit: ParsedAccount, bidRedemption: ParsedAccount | undefined, bid: ParsedAccount | undefined, @@ -793,9 +791,7 @@ export async function setupRedeemParticipationInstructions( ? fixedPrice.toNumber() : bid?.info.lastBid.toNumber() || 0; - let tokenAccount = accountsByMint.get( - auctionView.auction.info.tokenMint.toBase58(), - ); + let tokenAccount = accountsByMint.get(auctionView.auction.info.tokenMint); console.log('Have token account', tokenAccount); if (!tokenAccount) { @@ -807,7 +803,7 @@ export async function setupRedeemParticipationInstructions( if (allAccounts.value.length > 0) { tokenAccount = TokenAccountParser( - allAccounts.value[0].pubkey, + allAccounts.value[0].pubkey.toBase58(), allAccounts.value[0].account, ); } @@ -833,14 +829,14 @@ export async function setupRedeemParticipationInstructions( const transferAuthority = approve( myInstructions, cleanupInstructions, - payingSolAccount, + toPublicKey(payingSolAccount), wallet.publicKey, price, ); mySigners.push(transferAuthority); const winnerIndex = auctionView.auction.info.bidState.getWinnerIndex( - wallet.publicKey, + wallet.publicKey.toBase58(), ); await redeemParticipationBidV3( auctionView.vault.pubkey, @@ -848,11 +844,11 @@ export async function setupRedeemParticipationInstructions( account, safetyDeposit.pubkey, receiverWallet, - wallet.publicKey, + wallet.publicKey.toBase58(), item.metadata.pubkey, me.pubkey, item.metadata.info.mint, - transferAuthority.publicKey, + transferAuthority.publicKey.toBase58(), auctionView.auctionManager.acceptPayment, payingSolAccount, mint, @@ -866,13 +862,13 @@ export async function setupRedeemParticipationInstructions( signers.push(mySigners); const metadata = await getMetadata(mint); - if (receiverWallet.equals(wallet.publicKey)) { + if (receiverWallet === wallet.publicKey.toBase58()) { let updatePrimarySaleHappenedInstructions: TransactionInstruction[] = []; let updatePrimarySaleHappenedSigners: Keypair[] = []; await updatePrimarySaleHappenedViaToken( metadata, - wallet.publicKey, + wallet.publicKey.toBase58(), account, updatePrimarySaleHappenedInstructions, ); @@ -880,7 +876,7 @@ export async function setupRedeemParticipationInstructions( signers.push(updatePrimarySaleHappenedSigners); } } else { - console.log('Item is already claimed!', item.metadata.info.mint.toBase58()); + console.log('Item is already claimed!', item.metadata.info.mint); } } @@ -909,16 +905,14 @@ async function deprecatedSetupRedeemParticipationInstructions( return; const updateAuth = item.metadata.info.updateAuthority; - let tokenAccount = accountsByMint.get( - auctionView.auction.info.tokenMint.toBase58(), - ); + let tokenAccount = accountsByMint.get(auctionView.auction.info.tokenMint); const mint = cache.get(auctionView.auction.info.tokenMint); const participationBalance = await connection.getTokenAccountBalance( - participationState.printingAuthorizationTokenAccount, + toPublicKey(participationState.printingAuthorizationTokenAccount), ); const tokenBalance = await connection.getTokenAccountBalance( - safetyDeposit.info.store, + toPublicKey(safetyDeposit.info.store), ); if ( @@ -932,10 +926,10 @@ async function deprecatedSetupRedeemParticipationInstructions( fillParticipationStashInstructions, wallet.publicKey, accountRentExempt, - me?.info.oneTimePrintingAuthorizationMint, - auctionView.auctionManager.pubkey, + toPublicKey(me?.info.oneTimePrintingAuthorizationMint), + toPublicKey(auctionView.auctionManager.pubkey), fillParticipationStashSigners, - ); + ).toBase58(); await deprecatedPopulateParticipationPrintingAccount( auctionView.vault.pubkey, @@ -950,7 +944,7 @@ async function deprecatedSetupRedeemParticipationInstructions( me.info.oneTimePrintingAuthorizationMint, me.pubkey, item.metadata.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), fillParticipationStashInstructions, ); @@ -958,12 +952,12 @@ async function deprecatedSetupRedeemParticipationInstructions( instructions.push(fillParticipationStashInstructions); } - let newTokenAccount: PublicKey | undefined = accountsByMint.get( - me.info.printingMint.toBase58(), + let newTokenAccount: StringPublicKey | undefined = accountsByMint.get( + me.info.printingMint, )?.pubkey; let newTokenBalance = - accountsByMint.get(me.info.printingMint.toBase58())?.info.amount || 0; + accountsByMint.get(me.info.printingMint)?.info.amount || 0; if ( me && @@ -991,10 +985,10 @@ async function deprecatedSetupRedeemParticipationInstructions( newTokenAccountInstructions, wallet.publicKey, accountRentExempt, - me.info.printingMint, + toPublicKey(me.info.printingMint), wallet.publicKey, newTokenAccountSigner, - ); + ).toBase58(); } signers.push(winningPrizeSigner); @@ -1017,7 +1011,7 @@ async function deprecatedSetupRedeemParticipationInstructions( const transferAuthority = approve( winningPrizeInstructions, cleanupInstructions, - payingSolAccount, + toPublicKey(payingSolAccount), wallet.publicKey, price, ); @@ -1030,10 +1024,10 @@ async function deprecatedSetupRedeemParticipationInstructions( newTokenAccount, safetyDeposit.pubkey, auctionView.myBidderMetadata.info.bidderPubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), winningPrizeInstructions, participationState.printingAuthorizationTokenAccount, - transferAuthority.publicKey, + transferAuthority.publicKey.toBase58(), auctionView.auctionManager.acceptPayment, payingSolAccount, ); diff --git a/js/packages/web/src/actions/sendSignMetadata.ts b/js/packages/web/src/actions/sendSignMetadata.ts index 57a7705..503b7ff 100644 --- a/js/packages/web/src/actions/sendSignMetadata.ts +++ b/js/packages/web/src/actions/sendSignMetadata.ts @@ -1,20 +1,19 @@ +import { Keypair, Connection, TransactionInstruction } from '@solana/web3.js'; import { - Keypair, - Connection, - TransactionInstruction, - PublicKey, -} from '@solana/web3.js'; -import { sendTransactionWithRetry, signMetadata } from '@oyster/common'; + sendTransactionWithRetry, + signMetadata, + StringPublicKey, +} from '@oyster/common'; export async function sendSignMetadata( connection: Connection, wallet: any, - metadata: PublicKey, + metadata: StringPublicKey, ) { let signers: Keypair[] = []; let instructions: TransactionInstruction[] = []; - await signMetadata(metadata, wallet.publicKey, instructions); + await signMetadata(metadata, wallet.publicKey.toBase58(), instructions); await sendTransactionWithRetry( connection, diff --git a/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts b/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts index 16a82a0..de297a3 100644 --- a/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts +++ b/js/packages/web/src/actions/setVaultAndAuctionAuthorities.ts @@ -1,12 +1,16 @@ -import { Keypair, PublicKey, TransactionInstruction } from '@solana/web3.js'; -import { setAuctionAuthority, setVaultAuthority } from '@oyster/common'; +import { Keypair, TransactionInstruction } from '@solana/web3.js'; +import { + setAuctionAuthority, + setVaultAuthority, + StringPublicKey, +} from '@oyster/common'; // This command sets the authorities on the vault and auction to be the newly created auction manager. export async function setVaultAndAuctionAuthorities( wallet: any, - vault: PublicKey, - auction: PublicKey, - auctionManager: PublicKey, + vault: StringPublicKey, + auction: StringPublicKey, + auctionManager: StringPublicKey, ): Promise<{ instructions: TransactionInstruction[]; signers: Keypair[]; @@ -16,13 +20,13 @@ export async function setVaultAndAuctionAuthorities( await setAuctionAuthority( auction, - wallet.publicKey, + wallet.publicKey.toBase58(), auctionManager, instructions, ); await setVaultAuthority( vault, - wallet.publicKey, + wallet.publicKey.toBase58(), auctionManager, instructions, ); diff --git a/js/packages/web/src/actions/settle.ts b/js/packages/web/src/actions/settle.ts index e15045c..74627c6 100644 --- a/js/packages/web/src/actions/settle.ts +++ b/js/packages/web/src/actions/settle.ts @@ -15,6 +15,7 @@ import { findProgramAddress, AuctionState, TokenAccount, + toPublicKey, } from '@oyster/common'; import { AuctionView } from '../hooks'; @@ -32,7 +33,7 @@ export async function settle( wallet: any, auctionView: AuctionView, bidsToClaim: ParsedAccount[], - payingAccount: PublicKey | undefined, + payingAccount: string | undefined, accountsByMint: Map, ) { if ( @@ -96,9 +97,7 @@ async function emptyPaymentAccountForAllTokens( const creators = item.metadata.info.data.creators; const edgeCaseWhereCreatorIsAuctioneer = !!creators ?.map(c => c.address) - .find( - c => c.toBase58() === auctionView.auctionManager.authority.toBase58(), - ); + .find(c => c === auctionView.auctionManager.authority); const addresses = [ ...(creators ? creators.map(c => c.address) : []), @@ -109,7 +108,7 @@ async function emptyPaymentAccountForAllTokens( const ata = ( await findProgramAddress( [ - addresses[k].toBuffer(), + toPublicKey(addresses[k]).toBuffer(), PROGRAM_IDS.token.toBuffer(), QUOTE_MINT.toBuffer(), ], @@ -117,23 +116,21 @@ async function emptyPaymentAccountForAllTokens( ) )[0]; - const existingAta = await connection.getAccountInfo(ata); + const existingAta = await connection.getAccountInfo(toPublicKey(ata)); console.log('Existing ata?', existingAta); - if (!existingAta && !ataLookup[ata.toBase58()]) + if (!existingAta && !ataLookup[ata]) createAssociatedTokenAccountInstruction( settleInstructions, - ata, + toPublicKey(ata), wallet.publicKey, - addresses[k], + toPublicKey(addresses[k]), QUOTE_MINT, ); - ataLookup[ata.toBase58()] = true; + ataLookup[ata] = true; const creatorIndex = creators - ? creators - .map(c => c.address.toBase58()) - .indexOf(addresses[k].toBase58()) + ? creators.map(c => c.address).indexOf(addresses[k]) : null; await emptyPaymentAccount( @@ -145,7 +142,7 @@ async function emptyPaymentAccountForAllTokens( item.safetyDeposit.pubkey, item.safetyDeposit.info.vault, auctionView.auction.pubkey, - wallet.publicKey, + wallet.publicKey.toBase58(), addresses[k], item === auctionView.participationItem ? null : i, item === auctionView.participationItem ? null : j, @@ -233,7 +230,7 @@ async function claimAllBids( // That's what this loop is building. for (let i = 0; i < bids.length; i++) { const bid = bids[i]; - console.log('Claiming', bid.info.bidderAct.toBase58()); + console.log('Claiming', bid.info.bidderAct); await claimBid( auctionView.auctionManager.acceptPayment, bid.info.bidderAct, diff --git a/js/packages/web/src/actions/unwindVault.ts b/js/packages/web/src/actions/unwindVault.ts index 4d3813a..0f0fcbd 100644 --- a/js/packages/web/src/actions/unwindVault.ts +++ b/js/packages/web/src/actions/unwindVault.ts @@ -10,6 +10,7 @@ import { sendTransactionsWithManualRetry, decodeExternalPriceAccount, findProgramAddress, + toPublicKey, } from '@oyster/common'; import BN from 'bn.js'; @@ -38,7 +39,7 @@ export async function unwindVault( if (vault.info.state === VaultState.Inactive) { console.log('Vault is inactive, combining'); const epa = await connection.getAccountInfo( - vault.info.pricingLookupAddress, + toPublicKey(vault.info.pricingLookupAddress), ); if (epa) { const decoded = decodeExternalPriceAccount(epa.data); @@ -60,7 +61,7 @@ export async function unwindVault( } } - const vaultKey = vault.pubkey.toBase58(); + const vaultKey = vault.pubkey; let boxes: ParsedAccount[] = []; let box = safetyDepositBoxesByVaultAndIndex[vaultKey + '-0']; @@ -81,24 +82,26 @@ export async function unwindVault( [ wallet.publicKey.toBuffer(), PROGRAM_IDS.token.toBuffer(), - nft.info.tokenMint.toBuffer(), + toPublicKey(nft.info.tokenMint).toBuffer(), ], PROGRAM_IDS.associatedToken, ) )[0]; - const existingAta = await connection.getAccountInfo(ata); + const existingAta = await connection.getAccountInfo(toPublicKey(ata)); console.log('Existing ata?', existingAta); if (!existingAta) createAssociatedTokenAccountInstruction( currInstructions, - ata, + toPublicKey(ata), wallet.publicKey, wallet.publicKey, - nft.info.tokenMint, + toPublicKey(nft.info.tokenMint), ); - const value = await connection.getTokenAccountBalance(nft.info.store); + const value = await connection.getTokenAccountBalance( + toPublicKey(nft.info.store), + ); await withdrawTokenFromSafetyDepositBox( new BN(value.value.uiAmount || 1), ata, diff --git a/js/packages/web/src/components/ArtCard/index.tsx b/js/packages/web/src/components/ArtCard/index.tsx index c83bbc7..e40d144 100644 --- a/js/packages/web/src/components/ArtCard/index.tsx +++ b/js/packages/web/src/components/ArtCard/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Card, CardProps, Button, Badge } from 'antd'; -import { MetadataCategory } from '@oyster/common'; +import { MetadataCategory, StringPublicKey } from '@oyster/common'; import { ArtContent } from './../ArtContent'; import { useArt } from '../../hooks'; import { PublicKey } from '@solana/web3.js'; @@ -10,7 +10,7 @@ import { MetaAvatar } from '../MetaAvatar'; const { Meta } = Card; export interface ArtCardProps extends CardProps { - pubkey?: PublicKey; + pubkey?: StringPublicKey; image?: string; animationURL?: string; diff --git a/js/packages/web/src/components/AuctionCard/index.tsx b/js/packages/web/src/components/AuctionCard/index.tsx index 1472af4..a715624 100644 --- a/js/packages/web/src/components/AuctionCard/index.tsx +++ b/js/packages/web/src/components/AuctionCard/index.tsx @@ -81,7 +81,7 @@ async function calculateTotalCostOfRedeemingOtherPeoplesBids( if (!winner) { break; } else { - const bid = bids.find(b => b.info.bidderPubkey.equals(winner)); + const bid = bids.find(b => b.info.bidderPubkey === winner); if (bid) { for ( let j = 0; @@ -162,7 +162,7 @@ function useAuctionExtended( auctionProgramId: PROGRAM_IDS.auction, resource: auctionView.vault.pubkey, }); - const extendedValue = auctionDataExtended[extendedKey.toBase58()]; + const extendedValue = auctionDataExtended[extendedKey]; if (extendedValue) setAuctionExtended(extendedValue); } }; @@ -239,7 +239,7 @@ export const AuctionCard = ({ const gapBidInvalid = useGapTickCheck(value, gapTick, gapTime, auctionView); const isAuctionManagerAuthorityNotWalletOwner = - auctionView.auctionManager.authority.toBase58() != + auctionView.auctionManager.authority !== wallet?.publicKey?.toBase58(); const isAuctionNotStarted = @@ -272,7 +272,7 @@ export const AuctionCard = ({ setLoading(true); setShowRedemptionIssue(false); if ( - wallet?.publicKey?.equals(auctionView.auctionManager.authority) + wallet?.publicKey?.toBase58() === auctionView.auctionManager.authority ) { const totalCost = await calculateTotalCostOfRedeemingOtherPeoplesBids( @@ -325,7 +325,7 @@ export const AuctionCard = ({ ) : ( `${ wallet?.publicKey && - auctionView.auctionManager.authority.equals(wallet.publicKey) + auctionView.auctionManager.authority === wallet.publicKey.toBase58() ? 'Reclaim Items' : 'Refund bid' }` @@ -515,7 +515,7 @@ export const AuctionCard = ({ width: '100%', background: '#242424', borderRadius: 14, - color: 'rgba(0, 0, 0, 0.5);', + color: 'rgba(0, 0, 0, 0.5)', }} > { +): Promise { const PROGRAM_IDS = programIds(); if (!wallet?.publicKey) return undefined; return ( - await PublicKey.findProgramAddress( + await findProgramAddress( [ wallet.publicKey.toBuffer(), PROGRAM_IDS.token.toBuffer(), @@ -126,7 +129,7 @@ export function useCollapseWrappedSol({ const ata = await getPersonalEscrowAta(wallet); if (ata) { try { - const balance = await connection.getTokenAccountBalance(ata); + const balance = await connection.getTokenAccountBalance(toPublicKey(ata)); if ((balance && balance.value.uiAmount) || 0 > 0) { setShowNotification(true); @@ -149,7 +152,7 @@ export function useCollapseWrappedSol({ try { const ata = await getPersonalEscrowAta(wallet); if (ata) { - const data = await connection.getAccountInfo(ata); + const data = await connection.getAccountInfo(toPublicKey(ata)); if (data?.data.length || 0 > 0) await closePersonalEscrow(connection, wallet, ata); } @@ -174,7 +177,7 @@ export function useSettlementAuctions({ notifications: NotificationCard[]; }) { const { accountByMint } = useUserAccounts(); - const walletPubkey = wallet?.publicKey; + const walletPubkey = wallet?.publicKey?.toBase58(); const { bidderPotsByAuctionAndBidder } = useMeta(); const auctionsNeedingSettling = useAuctions(AuctionViewState.Ended); @@ -186,7 +189,7 @@ export function useSettlementAuctions({ .filter( a => walletPubkey && - a.auctionManager.authority.equals(walletPubkey) && + a.auctionManager.authority === walletPubkey && a.auction.info.ended(), ) .sort( @@ -196,11 +199,11 @@ export function useSettlementAuctions({ ); for (let i = 0; i < nextBatch.length; i++) { const av = nextBatch[i]; - if (!CALLING_MUTEX[av.auctionManager.pubkey.toBase58()]) { - CALLING_MUTEX[av.auctionManager.pubkey.toBase58()] = true; + if (!CALLING_MUTEX[av.auctionManager.pubkey]) { + CALLING_MUTEX[av.auctionManager.pubkey] = true; try { const balance = await connection.getTokenAccountBalance( - av.auctionManager.acceptPayment, + toPublicKey(av.auctionManager.acceptPayment), ); if ( ((balance.value.uiAmount || 0) === 0 && @@ -211,7 +214,7 @@ export function useSettlementAuctions({ ) { setValidDiscoveredEndedAuctions(old => ({ ...old, - [av.auctionManager.pubkey.toBase58()]: + [av.auctionManager.pubkey]: balance.value.uiAmount || 0, })); } @@ -226,26 +229,26 @@ export function useSettlementAuctions({ Object.keys(validDiscoveredEndedAuctions).forEach(auctionViewKey => { const auctionView = auctionsNeedingSettling.find( - a => a.auctionManager.pubkey.toBase58() === auctionViewKey, + a => a.auctionManager.pubkey === auctionViewKey, ); if (!auctionView) return; const winners = [...auctionView.auction.info.bidState.bids] .reverse() .slice(0, auctionView.auctionManager.numWinners.toNumber()) .reduce((acc: Record, r) => { - acc[r.key.toBase58()] = true; + acc[r.key] = true; return acc; }, {}); const myPayingAccount = accountByMint.get( - auctionView.auction.info.tokenMint.toBase58(), + auctionView.auction.info.tokenMint, ); - const auctionKey = auctionView.auction.pubkey.toBase58(); + const auctionKey = auctionView.auction.pubkey; const bidsToClaim = Object.values(bidderPotsByAuctionAndBidder).filter( b => - winners[b.info.bidderAct.toBase58()] && + winners[b.info.bidderAct] && !b.info.emptied && - b.info.auctionAct.toBase58() === auctionKey, + b.info.auctionAct === auctionKey, ); if (bidsToClaim.length || validDiscoveredEndedAuctions[auctionViewKey] > 0) notifications.push({ @@ -312,7 +315,7 @@ export function Notifications() { () => Object.values(vaults).filter( v => - v.info.authority.toBase58() === walletPubkey && + v.info.authority === walletPubkey && v.info.state !== VaultState.Deactivated && v.info.tokenTypeCount > 0, ), @@ -321,7 +324,7 @@ export function Notifications() { vaultsNeedUnwinding.forEach(v => { notifications.push({ - id: v.pubkey.toBase58(), + id: v.pubkey, title: 'You have items locked in a defective auction!', description: ( @@ -347,10 +350,10 @@ export function Notifications() { }); possiblyBrokenAuctionManagerSetups - .filter(v => v.auctionManager.authority.toBase58() === walletPubkey) + .filter(v => v.auctionManager.authority === walletPubkey) .forEach(v => { notifications.push({ - id: v.auctionManager.pubkey.toBase58(), + id: v.auctionManager.pubkey, title: 'You have items locked in a defective auction!', description: ( @@ -380,11 +383,11 @@ export function Notifications() { metadata.filter(m => { return ( m.info.data.creators && - (whitelistedCreatorsByCreator[m.info.updateAuthority.toBase58()]?.info + (whitelistedCreatorsByCreator[m.info.updateAuthority]?.info ?.activated || store?.info.public) && m.info.data.creators.find( - c => c.address.toBase58() === walletPubkey && !c.verified, + c => c.address === walletPubkey && !c.verified, ) ); }), @@ -393,14 +396,14 @@ export function Notifications() { metaNeedsApproving.forEach(m => { notifications.push({ - id: m.pubkey.toBase58(), + id: m.pubkey, title: 'You have a new artwork to approve!', description: ( - {whitelistedCreatorsByCreator[m.info.updateAuthority.toBase58()]?.info - ?.name || m.pubkey.toBase58()}{' '} + {whitelistedCreatorsByCreator[m.info.updateAuthority]?.info + ?.name || m.pubkey}{' '} wants you to approve that you helped create their art{' '} - here. + here. ), action: async () => { @@ -416,10 +419,10 @@ export function Notifications() { }); upcomingAuctions - .filter(v => v.auctionManager.authority.toBase58() === walletPubkey) + .filter(v => v.auctionManager.authority === walletPubkey) .forEach(v => { notifications.push({ - id: v.auctionManager.pubkey.toBase58(), + id: v.auctionManager.pubkey, title: 'You have an auction which is not started yet!', description: You can activate it now if you wish., action: async () => { diff --git a/js/packages/web/src/components/PreSaleBanner/index.tsx b/js/packages/web/src/components/PreSaleBanner/index.tsx index c907ab9..85344a8 100644 --- a/js/packages/web/src/components/PreSaleBanner/index.tsx +++ b/js/packages/web/src/components/PreSaleBanner/index.tsx @@ -43,7 +43,7 @@ export const PreSaleBanner = ({ auction }: IPreSaleBanner) => { hideDefaultAction={true} action={ <> - +