-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix next edition calculation for burned items (#1126)
* calculate next edition from edition marker * change error message to be more descriptive * regen api; fix JS tests * refactor logic for multiple PDAs * fix logic * clean up; add multiple marker pda test * ignore really long test for CI * new extra and check * rejen JS api * add buy_v2 * reduce buy_v2 test edition number for ci * regenerate JS api * refactor to remove redundant code * fix buy_v2 test * clean up tests * fix bug in loop * add tests for minting from multiple markers
- Loading branch information
1 parent
c71d237
commit eb000db
Showing
21 changed files
with
3,005 additions
and
49 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
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,40 @@ | ||
#!/bin/bash | ||
# | ||
# To run this script, you need: | ||
# - npm install -g esbuild-runner | ||
# - npm install -g tap-spec | ||
|
||
# error output colour | ||
RED() { echo $'\e[1;31m'$1$'\e[0m'; } | ||
RUN_ALL=0 | ||
|
||
# check whether we are running all test files or not | ||
|
||
while getopts a-: optchar; do | ||
case "${optchar}" in | ||
a) | ||
RUN_ALL=1 ;; | ||
-) | ||
case "${OPTARG}" in | ||
all) RUN_ALL=1 ;; | ||
*) ;; | ||
esac ;; | ||
*) ;; | ||
esac | ||
done | ||
|
||
# runs single or multiple tests | ||
|
||
if [ $RUN_ALL -eq 1 ]; then | ||
for file in `ls test/*.test.ts` | ||
do | ||
esr $file | tap-spec | ||
done | ||
else | ||
if [ ! -z "$1" ] && [[ -f "$1" ]]; then | ||
esr $1 | tap-spec | ||
else | ||
echo "$(RED "Error: ")Please specify a test file or [-a | --all] to run all tests" | ||
exit 1 | ||
fi | ||
fi |
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
224 changes: 224 additions & 0 deletions
224
fixed-price-sale/js/src/generated/instructions/buyV2.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,224 @@ | ||
/** | ||
* This code was GENERATED using the solita package. | ||
* Please DO NOT EDIT THIS FILE, instead rerun solita to update it or write a wrapper to add functionality. | ||
* | ||
* See: https://github.com/metaplex-foundation/solita | ||
*/ | ||
|
||
import * as splToken from '@solana/spl-token'; | ||
import * as beet from '@metaplex-foundation/beet'; | ||
import * as web3 from '@solana/web3.js'; | ||
|
||
/** | ||
* @category Instructions | ||
* @category BuyV2 | ||
* @category generated | ||
*/ | ||
export type BuyV2InstructionArgs = { | ||
tradeHistoryBump: number; | ||
vaultOwnerBump: number; | ||
editionMarkerNumber: beet.bignum; | ||
}; | ||
/** | ||
* @category Instructions | ||
* @category BuyV2 | ||
* @category generated | ||
*/ | ||
export const buyV2Struct = new beet.BeetArgsStruct< | ||
BuyV2InstructionArgs & { | ||
instructionDiscriminator: number[] /* size: 8 */; | ||
} | ||
>( | ||
[ | ||
['instructionDiscriminator', beet.uniformFixedSizeArray(beet.u8, 8)], | ||
['tradeHistoryBump', beet.u8], | ||
['vaultOwnerBump', beet.u8], | ||
['editionMarkerNumber', beet.u64], | ||
], | ||
'BuyV2InstructionArgs', | ||
); | ||
/** | ||
* Accounts required by the _buyV2_ instruction | ||
* | ||
* @property [_writable_] market | ||
* @property [_writable_] sellingResource | ||
* @property [_writable_] userTokenAccount | ||
* @property [_writable_, **signer**] userWallet | ||
* @property [_writable_] tradeHistory | ||
* @property [_writable_] treasuryHolder | ||
* @property [_writable_] newMetadata | ||
* @property [_writable_] newEdition | ||
* @property [_writable_] masterEdition | ||
* @property [_writable_] newMint | ||
* @property [_writable_] editionMarker | ||
* @property [_writable_] vault | ||
* @property [] owner | ||
* @property [_writable_] newTokenAccount | ||
* @property [_writable_] masterEditionMetadata | ||
* @property [] clock | ||
* @property [] tokenMetadataProgram | ||
* @category Instructions | ||
* @category BuyV2 | ||
* @category generated | ||
*/ | ||
export type BuyV2InstructionAccounts = { | ||
market: web3.PublicKey; | ||
sellingResource: web3.PublicKey; | ||
userTokenAccount: web3.PublicKey; | ||
userWallet: web3.PublicKey; | ||
tradeHistory: web3.PublicKey; | ||
treasuryHolder: web3.PublicKey; | ||
newMetadata: web3.PublicKey; | ||
newEdition: web3.PublicKey; | ||
masterEdition: web3.PublicKey; | ||
newMint: web3.PublicKey; | ||
editionMarker: web3.PublicKey; | ||
vault: web3.PublicKey; | ||
owner: web3.PublicKey; | ||
newTokenAccount: web3.PublicKey; | ||
masterEditionMetadata: web3.PublicKey; | ||
clock: web3.PublicKey; | ||
rent?: web3.PublicKey; | ||
tokenMetadataProgram: web3.PublicKey; | ||
tokenProgram?: web3.PublicKey; | ||
systemProgram?: web3.PublicKey; | ||
anchorRemainingAccounts?: web3.AccountMeta[]; | ||
}; | ||
|
||
export const buyV2InstructionDiscriminator = [184, 23, 238, 97, 103, 197, 211, 61]; | ||
|
||
/** | ||
* Creates a _BuyV2_ instruction. | ||
* | ||
* @param accounts that will be accessed while the instruction is processed | ||
* @param args to provide as instruction data to the program | ||
* | ||
* @category Instructions | ||
* @category BuyV2 | ||
* @category generated | ||
*/ | ||
export function createBuyV2Instruction( | ||
accounts: BuyV2InstructionAccounts, | ||
args: BuyV2InstructionArgs, | ||
programId = new web3.PublicKey('SaLeTjyUa5wXHnGuewUSyJ5JWZaHwz3TxqUntCE9czo'), | ||
) { | ||
const [data] = buyV2Struct.serialize({ | ||
instructionDiscriminator: buyV2InstructionDiscriminator, | ||
...args, | ||
}); | ||
const keys: web3.AccountMeta[] = [ | ||
{ | ||
pubkey: accounts.market, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.sellingResource, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.userTokenAccount, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.userWallet, | ||
isWritable: true, | ||
isSigner: true, | ||
}, | ||
{ | ||
pubkey: accounts.tradeHistory, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.treasuryHolder, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.newMetadata, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.newEdition, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.masterEdition, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.newMint, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.editionMarker, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.vault, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.owner, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.newTokenAccount, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.masterEditionMetadata, | ||
isWritable: true, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.clock, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.rent ?? web3.SYSVAR_RENT_PUBKEY, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.tokenMetadataProgram, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.tokenProgram ?? splToken.TOKEN_PROGRAM_ID, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
{ | ||
pubkey: accounts.systemProgram ?? web3.SystemProgram.programId, | ||
isWritable: false, | ||
isSigner: false, | ||
}, | ||
]; | ||
|
||
if (accounts.anchorRemainingAccounts != null) { | ||
for (const acc of accounts.anchorRemainingAccounts) { | ||
keys.push(acc); | ||
} | ||
} | ||
|
||
const ix = new web3.TransactionInstruction({ | ||
programId, | ||
keys, | ||
data, | ||
}); | ||
return ix; | ||
} |
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
Oops, something went wrong.