-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CandyGuard program from IDL, Update CandyMachine IDL generated co…
…de (#5) * Update all CandyMachine generated types to latest IDL for CMv3. * Update incorrect PDALookup + Add CandyGuard generated code. * Add missing GuardData type for combining guard sets. * Add GuardData deserialization.
- Loading branch information
1 parent
4925fa6
commit feea78c
Showing
12 changed files
with
2,030 additions
and
661 deletions.
There are no files selected for viewing
93 changes: 93 additions & 0 deletions
93
Solana.Unity.Metaplex/Candy Guard Program/Accounts/CandyGuardAccounts.cs
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,93 @@ | ||
using Solana.Unity.Programs.Utilities; | ||
using Solana.Unity.Wallet; | ||
using System; | ||
|
||
namespace Solana.Unity.Metaplex.CandyGuard.Accounts | ||
{ | ||
public class CandyGuardAccounts | ||
{ | ||
public partial class FreezeEscrow | ||
{ | ||
public static ulong ACCOUNT_DISCRIMINATOR => 13295661872568646371UL; | ||
public static ReadOnlySpan<byte> ACCOUNT_DISCRIMINATOR_BYTES => new byte[] { 227, 186, 40, 152, 7, 174, 131, 184 }; | ||
public static string ACCOUNT_DISCRIMINATOR_B58 => "f6ErkZturrj"; | ||
public PublicKey CandyGuard { get; set; } | ||
|
||
public PublicKey CandyMachine { get; set; } | ||
|
||
public ulong FrozenCount { get; set; } | ||
|
||
public long? FirstMintTime { get; set; } | ||
|
||
public long FreezePeriod { get; set; } | ||
|
||
public PublicKey Destination { get; set; } | ||
|
||
public PublicKey Authority { get; set; } | ||
|
||
public static FreezeEscrow Deserialize(ReadOnlySpan<byte> _data) | ||
{ | ||
int offset = 0; | ||
ulong accountHashValue = _data.GetU64(offset); | ||
offset += 8; | ||
if (accountHashValue != ACCOUNT_DISCRIMINATOR) | ||
{ | ||
return null; | ||
} | ||
|
||
FreezeEscrow result = new FreezeEscrow(); | ||
result.CandyGuard = _data.GetPubKey(offset); | ||
offset += 32; | ||
result.CandyMachine = _data.GetPubKey(offset); | ||
offset += 32; | ||
result.FrozenCount = _data.GetU64(offset); | ||
offset += 8; | ||
if (_data.GetBool(offset++)) | ||
{ | ||
result.FirstMintTime = _data.GetS64(offset); | ||
offset += 8; | ||
} | ||
|
||
result.FreezePeriod = _data.GetS64(offset); | ||
offset += 8; | ||
result.Destination = _data.GetPubKey(offset); | ||
offset += 32; | ||
result.Authority = _data.GetPubKey(offset); | ||
offset += 32; | ||
return result; | ||
} | ||
} | ||
|
||
public partial class CandyGuard | ||
{ | ||
public static ulong ACCOUNT_DISCRIMINATOR => 13052108403907219244UL; | ||
public static ReadOnlySpan<byte> ACCOUNT_DISCRIMINATOR_BYTES => new byte[] { 44, 207, 199, 184, 112, 103, 34, 181 }; | ||
public static string ACCOUNT_DISCRIMINATOR_B58 => "8VjHY4paKeL"; | ||
public PublicKey Base { get; set; } | ||
|
||
public byte Bump { get; set; } | ||
|
||
public PublicKey Authority { get; set; } | ||
|
||
public static CandyGuard Deserialize(ReadOnlySpan<byte> _data) | ||
{ | ||
int offset = 0; | ||
ulong accountHashValue = _data.GetU64(offset); | ||
offset += 8; | ||
if (accountHashValue != ACCOUNT_DISCRIMINATOR) | ||
{ | ||
return null; | ||
} | ||
|
||
CandyGuard result = new CandyGuard(); | ||
result.Base = _data.GetPubKey(offset); | ||
offset += 32; | ||
result.Bump = _data.GetU8(offset); | ||
offset += 1; | ||
result.Authority = _data.GetPubKey(offset); | ||
offset += 32; | ||
return result; | ||
} | ||
} | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
Solana.Unity.Metaplex/Candy Guard Program/Errors/CandyGuardErrors.cs
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,58 @@ | ||
namespace Solana.Unity.Metaplex.CandyGuard.Errors | ||
{ | ||
public enum CandyGuardErrorKind : uint | ||
{ | ||
InvalidAccountSize = 6000U, | ||
DeserializationError = 6001U, | ||
PublicKeyMismatch = 6002U, | ||
DataIncrementLimitExceeded = 6003U, | ||
IncorrectOwner = 6004U, | ||
Uninitialized = 6005U, | ||
MissingRemainingAccount = 6006U, | ||
NumericalOverflowError = 6007U, | ||
RequiredGroupLabelNotFound = 6008U, | ||
GroupNotFound = 6009U, | ||
ExceededLength = 6010U, | ||
CandyMachineEmpty = 6011U, | ||
InstructionNotFound = 6012U, | ||
CollectionKeyMismatch = 6013U, | ||
MissingCollectionAccounts = 6014U, | ||
CollectionUpdateAuthorityKeyMismatch = 6015U, | ||
MintNotLastTransaction = 6016U, | ||
MintNotLive = 6017U, | ||
NotEnoughSOL = 6018U, | ||
TokenBurnFailed = 6019U, | ||
NotEnoughTokens = 6020U, | ||
TokenTransferFailed = 6021U, | ||
MissingRequiredSignature = 6022U, | ||
GatewayTokenInvalid = 6023U, | ||
AfterEndDate = 6024U, | ||
InvalidMintTime = 6025U, | ||
AddressNotFoundInAllowedList = 6026U, | ||
MissingAllowedListProof = 6027U, | ||
AllowedListNotEnabled = 6028U, | ||
AllowedMintLimitReached = 6029U, | ||
InvalidNftCollection = 6030U, | ||
MissingNft = 6031U, | ||
MaximumRedeemedAmount = 6032U, | ||
AddressNotAuthorized = 6033U, | ||
MissingFreezeInstruction = 6034U, | ||
FreezeGuardNotEnabled = 6035U, | ||
FreezeNotInitialized = 6036U, | ||
MissingFreezePeriod = 6037U, | ||
FreezeEscrowAlreadyExists = 6038U, | ||
ExceededMaximumFreezePeriod = 6039U, | ||
ThawNotEnabled = 6040U, | ||
UnlockNotEnabled = 6041U, | ||
DuplicatedGroupLabel = 6042U, | ||
DuplicatedMintLimitId = 6043U, | ||
UnauthorizedProgramFound = 6044U, | ||
ExceededProgramListSize = 6045U, | ||
AllocationNotInitialized = 6046U, | ||
AllocationLimitReached = 6047U, | ||
AllocationGuardNotEnabled = 6048U, | ||
InvalidMintAuthority = 6049U, | ||
InstructionBuilderFailed = 6050U, | ||
InvalidAccountVersion = 6051U | ||
} | ||
} |
144 changes: 144 additions & 0 deletions
144
Solana.Unity.Metaplex/Candy Guard Program/Program/CandyGuardClient.cs
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.