-
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 #15 from metaplex-foundation/feat/vanity_address
Add a guard to verify the mint of the new asset matches a vanity pattern
- Loading branch information
Showing
18 changed files
with
499 additions
and
22 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
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,34 @@ | ||
import { | ||
fixSerializer, | ||
mapSerializer, | ||
} from '@metaplex-foundation/umi/serializers'; | ||
import { ExceededRegexLengthError } from '../errors'; | ||
import { | ||
getVanityMintSerializer, | ||
VanityMint, | ||
VanityMintArgs, | ||
} from '../generated'; | ||
import { GuardManifest, noopParser } from '../guards'; | ||
|
||
/** | ||
* The vanityMint guard verifies that the new asset | ||
* address matches the provided regex. | ||
*/ | ||
export const vanityMintGuardManifest: GuardManifest< | ||
VanityMintArgs, | ||
VanityMint | ||
> = { | ||
name: 'vanityMint', | ||
serializer: () => | ||
mapSerializer( | ||
fixSerializer(getVanityMintSerializer(), 4 + 100), | ||
(value) => { | ||
if (value.regex.length > 100) { | ||
throw new ExceededRegexLengthError(); | ||
} | ||
return value; | ||
} | ||
), | ||
mintParser: noopParser, | ||
routeParser: noopParser, | ||
}; |
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
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,27 @@ | ||
/** | ||
* 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 { | ||
Serializer, | ||
string, | ||
struct, | ||
} from '@metaplex-foundation/umi/serializers'; | ||
|
||
/** Guard that sets a specific start date for the mint. */ | ||
export type VanityMint = { regex: string }; | ||
|
||
export type VanityMintArgs = VanityMint; | ||
|
||
export function getVanityMintSerializer(): Serializer< | ||
VanityMintArgs, | ||
VanityMint | ||
> { | ||
return struct<VanityMint>([['regex', string()]], { | ||
description: 'VanityMint', | ||
}) as Serializer<VanityMintArgs, VanityMint>; | ||
} |
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.