-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #14 from metaplex-foundation/feat/asset-gate
Add asset gate guard
- Loading branch information
Showing
12 changed files
with
467 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import { PublicKey } from '@metaplex-foundation/umi'; | ||
import { getAssetGateSerializer, AssetGate, AssetGateArgs } from '../generated'; | ||
import { GuardManifest, noopParser } from '../guards'; | ||
|
||
/** | ||
* The assetGate guard restricts minting to holders | ||
* of a specified NFT collection. | ||
* | ||
* This means the mint address of an NFT from this | ||
* collection must be passed when minting. | ||
*/ | ||
export const assetGateGuardManifest: GuardManifest< | ||
AssetGateArgs, | ||
AssetGate, | ||
AssetGateMintArgs | ||
> = { | ||
name: 'assetGate', | ||
serializer: getAssetGateSerializer, | ||
mintParser: (context, mintContext, args) => ({ | ||
data: new Uint8Array(), | ||
remainingAccounts: [{ publicKey: args.asset, isWritable: false }], | ||
}), | ||
routeParser: noopParser, | ||
}; | ||
|
||
export type AssetGateMintArgs = { | ||
/** | ||
* The address of an Asset from the required | ||
* collection that belongs to the payer. | ||
*/ | ||
asset: PublicKey; | ||
}; |
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,32 @@ | ||
/** | ||
* This code was AUTOGENERATED using the kinobi library. | ||
* Please DO NOT EDIT THIS FILE, instead use visitors | ||
* to add features, then rerun kinobi to update it. | ||
* | ||
* @see https://github.com/metaplex-foundation/kinobi | ||
*/ | ||
|
||
import { PublicKey } from '@metaplex-foundation/umi'; | ||
import { | ||
Serializer, | ||
publicKey as publicKeySerializer, | ||
struct, | ||
} from '@metaplex-foundation/umi/serializers'; | ||
|
||
/** | ||
* Guard that restricts the transaction to holders of a specified collection. | ||
* | ||
* List of accounts required: | ||
* | ||
* 0. `[]` Account of the Asset. | ||
*/ | ||
|
||
export type AssetGate = { requiredCollection: PublicKey }; | ||
|
||
export type AssetGateArgs = AssetGate; | ||
|
||
export function getAssetGateSerializer(): Serializer<AssetGateArgs, AssetGate> { | ||
return struct<AssetGate>([['requiredCollection', publicKeySerializer()]], { | ||
description: 'AssetGate', | ||
}) as Serializer<AssetGateArgs, AssetGate>; | ||
} |
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.