-
Notifications
You must be signed in to change notification settings - Fork 77
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: set whitelisted tx & minor fixes
- Loading branch information
Showing
8 changed files
with
134 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
82 changes: 82 additions & 0 deletions
82
api/src/programs/metaplex/transactions/SetWhitelistedCreator.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
import { borsh } from '@metaplex/utils'; | ||
import { | ||
PublicKey, | ||
SystemProgram, | ||
SYSVAR_RENT_PUBKEY, | ||
TransactionCtorFields, | ||
TransactionInstruction, | ||
} from '@solana/web3.js'; | ||
import { Transaction } from '../../../Transaction'; | ||
import { MetaplexProgram } from '../MetaplexProgram'; | ||
|
||
export interface SetWhitelistedCreatorArgs { | ||
instruction: number; | ||
activated: boolean; | ||
} | ||
|
||
const setWhitelistedCreatorStruct = borsh.struct<SetWhitelistedCreatorArgs>([ | ||
['instruction', 'u8'], | ||
['activated', 'u8'], | ||
]); | ||
|
||
type SetWhitelistedCreatorParams = { | ||
store: PublicKey; | ||
admin: PublicKey; | ||
whitelistedCreatorPDA: PublicKey; | ||
creator: PublicKey; | ||
activated: boolean; | ||
}; | ||
|
||
export class SetWhitelistedCreator extends Transaction { | ||
constructor(options: TransactionCtorFields, params: SetWhitelistedCreatorParams) { | ||
super(options); | ||
const { feePayer } = options; | ||
const { admin, whitelistedCreatorPDA, store, creator, activated } = params; | ||
|
||
const data = setWhitelistedCreatorStruct.serialize({ instruction: 8, activated }); | ||
|
||
this.add( | ||
new TransactionInstruction({ | ||
keys: [ | ||
{ | ||
pubkey: whitelistedCreatorPDA, | ||
isSigner: false, | ||
isWritable: true, | ||
}, | ||
{ | ||
pubkey: admin, | ||
isSigner: true, | ||
isWritable: false, | ||
}, | ||
{ | ||
pubkey: feePayer, | ||
isSigner: true, | ||
isWritable: false, | ||
}, | ||
{ | ||
pubkey: creator, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ | ||
pubkey: store, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ | ||
pubkey: SystemProgram.programId, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
{ | ||
pubkey: SYSVAR_RENT_PUBKEY, | ||
isSigner: false, | ||
isWritable: false, | ||
}, | ||
], | ||
programId: MetaplexProgram.PUBKEY, | ||
data, | ||
}), | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { jest } from '@jest/globals'; | ||
import { Keypair, sendAndConfirmTransaction } from '@solana/web3.js'; | ||
import { Connection, SetStore, Store } from '../../src'; | ||
import { FEE_PAYER } from '../utils'; | ||
|
||
describe('Metaplex transactions', () => { | ||
let connection: Connection; | ||
let owner: Keypair; | ||
|
||
jest.setTimeout(80000); | ||
|
||
beforeAll(() => { | ||
connection = new Connection('devnet'); | ||
owner = Keypair.generate(); | ||
}); | ||
|
||
test.skip('setStore', async () => { | ||
const storeId = await Store.getPDA(owner.publicKey); | ||
|
||
const setStoreTx = new SetStore( | ||
{ | ||
feePayer: FEE_PAYER.publicKey, | ||
}, | ||
{ | ||
admin: owner.publicKey, | ||
store: storeId, | ||
isPublic: true, | ||
}, | ||
); | ||
|
||
const txid = await sendAndConfirmTransaction(connection, setStoreTx, [FEE_PAYER, owner], { | ||
commitment: 'confirmed', | ||
}); | ||
|
||
// console.log(txid); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters