@metaplex-foundation/mpl-token-auth-rules
Advanced tools
Comparing version 3.0.0-alpha.7 to 3.0.0-alpha.8
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Account, Context, PublicKey, RpcAccount, RpcGetAccountOptions, RpcGetAccountsOptions, Serializer } from '@metaplex-foundation/umi'; | ||
import { Account, Context, Pda, PublicKey, RpcAccount, RpcGetAccountOptions, RpcGetAccountsOptions, Serializer } from '@metaplex-foundation/umi'; | ||
import { Key, KeyArgs } from '../types'; | ||
@@ -24,6 +24,6 @@ export type FrequencyAccount = Account<FrequencyAccountAccountData>; | ||
export declare function deserializeFrequencyAccount(context: Pick<Context, 'serializer'>, rawAccount: RpcAccount): FrequencyAccount; | ||
export declare function fetchFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey, options?: RpcGetAccountOptions): Promise<FrequencyAccount>; | ||
export declare function safeFetchFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey, options?: RpcGetAccountOptions): Promise<FrequencyAccount | null>; | ||
export declare function fetchAllFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: PublicKey[], options?: RpcGetAccountsOptions): Promise<FrequencyAccount[]>; | ||
export declare function safeFetchAllFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: PublicKey[], options?: RpcGetAccountsOptions): Promise<FrequencyAccount[]>; | ||
export declare function fetchFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions): Promise<FrequencyAccount>; | ||
export declare function safeFetchFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions): Promise<FrequencyAccount | null>; | ||
export declare function fetchAllFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: Array<PublicKey | Pda>, options?: RpcGetAccountsOptions): Promise<FrequencyAccount[]>; | ||
export declare function safeFetchAllFrequencyAccount(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: Array<PublicKey | Pda>, options?: RpcGetAccountsOptions): Promise<FrequencyAccount[]>; | ||
export declare function getFrequencyAccountGpaBuilder(context: Pick<Context, 'rpc' | 'serializer' | 'programs'>): import("@metaplex-foundation/umi").GpaBuilder<FrequencyAccount, { | ||
@@ -30,0 +30,0 @@ key: KeyArgs; |
@@ -27,3 +27,3 @@ "use strict"; | ||
async function fetchFrequencyAccount(context, publicKey, options) { | ||
const maybeAccount = await context.rpc.getAccount(publicKey, options); | ||
const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options); | ||
(0, umi_1.assertAccountExists)(maybeAccount, 'FrequencyAccount'); | ||
@@ -34,3 +34,3 @@ return deserializeFrequencyAccount(context, maybeAccount); | ||
async function safeFetchFrequencyAccount(context, publicKey, options) { | ||
const maybeAccount = await context.rpc.getAccount(publicKey, options); | ||
const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options); | ||
return maybeAccount.exists | ||
@@ -42,3 +42,3 @@ ? deserializeFrequencyAccount(context, maybeAccount) | ||
async function fetchAllFrequencyAccount(context, publicKeys, options) { | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys, options); | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options); | ||
return maybeAccounts.map((maybeAccount) => { | ||
@@ -51,3 +51,3 @@ (0, umi_1.assertAccountExists)(maybeAccount, 'FrequencyAccount'); | ||
async function safeFetchAllFrequencyAccount(context, publicKeys, options) { | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys, options); | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options); | ||
return maybeAccounts | ||
@@ -54,0 +54,0 @@ .filter((maybeAccount) => maybeAccount.exists) |
@@ -13,6 +13,6 @@ /** | ||
export declare function deserializeRuleSet(context: Pick<Context, 'serializer'>, rawAccount: RpcAccount): RuleSet; | ||
export declare function fetchRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey, options?: RpcGetAccountOptions): Promise<RuleSet>; | ||
export declare function safeFetchRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey, options?: RpcGetAccountOptions): Promise<RuleSet | null>; | ||
export declare function fetchAllRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: PublicKey[], options?: RpcGetAccountsOptions): Promise<RuleSet[]>; | ||
export declare function safeFetchAllRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: PublicKey[], options?: RpcGetAccountsOptions): Promise<RuleSet[]>; | ||
export declare function fetchRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions): Promise<RuleSet>; | ||
export declare function safeFetchRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions): Promise<RuleSet | null>; | ||
export declare function fetchAllRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: Array<PublicKey | Pda>, options?: RpcGetAccountsOptions): Promise<RuleSet[]>; | ||
export declare function safeFetchAllRuleSet(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: Array<PublicKey | Pda>, options?: RpcGetAccountsOptions): Promise<RuleSet[]>; | ||
export declare function getRuleSetGpaBuilder(context: Pick<Context, 'rpc' | 'serializer' | 'programs'>): import("@metaplex-foundation/umi").GpaBuilder<RuleSet, { | ||
@@ -19,0 +19,0 @@ key: KeyArgs; |
@@ -19,3 +19,3 @@ "use strict"; | ||
async function fetchRuleSet(context, publicKey, options) { | ||
const maybeAccount = await context.rpc.getAccount(publicKey, options); | ||
const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options); | ||
(0, umi_1.assertAccountExists)(maybeAccount, 'RuleSet'); | ||
@@ -26,3 +26,3 @@ return deserializeRuleSet(context, maybeAccount); | ||
async function safeFetchRuleSet(context, publicKey, options) { | ||
const maybeAccount = await context.rpc.getAccount(publicKey, options); | ||
const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options); | ||
return maybeAccount.exists ? deserializeRuleSet(context, maybeAccount) : null; | ||
@@ -32,3 +32,3 @@ } | ||
async function fetchAllRuleSet(context, publicKeys, options) { | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys, options); | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options); | ||
return maybeAccounts.map((maybeAccount) => { | ||
@@ -41,3 +41,3 @@ (0, umi_1.assertAccountExists)(maybeAccount, 'RuleSet'); | ||
async function safeFetchAllRuleSet(context, publicKeys, options) { | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys, options); | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options); | ||
return maybeAccounts | ||
@@ -44,0 +44,0 @@ .filter((maybeAccount) => maybeAccount.exists) |
@@ -16,6 +16,6 @@ /** | ||
export declare function deserializeRuleSetBuffer(context: Pick<Context, 'serializer'>, rawAccount: RpcAccount): RuleSetBuffer; | ||
export declare function fetchRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey, options?: RpcGetAccountOptions): Promise<RuleSetBuffer>; | ||
export declare function safeFetchRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey, options?: RpcGetAccountOptions): Promise<RuleSetBuffer | null>; | ||
export declare function fetchAllRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: PublicKey[], options?: RpcGetAccountsOptions): Promise<RuleSetBuffer[]>; | ||
export declare function safeFetchAllRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: PublicKey[], options?: RpcGetAccountsOptions): Promise<RuleSetBuffer[]>; | ||
export declare function fetchRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions): Promise<RuleSetBuffer>; | ||
export declare function safeFetchRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKey: PublicKey | Pda, options?: RpcGetAccountOptions): Promise<RuleSetBuffer | null>; | ||
export declare function fetchAllRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: Array<PublicKey | Pda>, options?: RpcGetAccountsOptions): Promise<RuleSetBuffer[]>; | ||
export declare function safeFetchAllRuleSetBuffer(context: Pick<Context, 'rpc' | 'serializer'>, publicKeys: Array<PublicKey | Pda>, options?: RpcGetAccountsOptions): Promise<RuleSetBuffer[]>; | ||
export declare function getRuleSetBufferGpaBuilder(context: Pick<Context, 'rpc' | 'serializer' | 'programs'>): import("@metaplex-foundation/umi").GpaBuilder<RuleSetBuffer, { | ||
@@ -22,0 +22,0 @@ serializedRuleSet: Uint8Array; |
@@ -22,3 +22,3 @@ "use strict"; | ||
async function fetchRuleSetBuffer(context, publicKey, options) { | ||
const maybeAccount = await context.rpc.getAccount(publicKey, options); | ||
const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options); | ||
(0, umi_1.assertAccountExists)(maybeAccount, 'RuleSetBuffer'); | ||
@@ -29,3 +29,3 @@ return deserializeRuleSetBuffer(context, maybeAccount); | ||
async function safeFetchRuleSetBuffer(context, publicKey, options) { | ||
const maybeAccount = await context.rpc.getAccount(publicKey, options); | ||
const maybeAccount = await context.rpc.getAccount((0, umi_1.publicKey)(publicKey, false), options); | ||
return maybeAccount.exists | ||
@@ -37,3 +37,3 @@ ? deserializeRuleSetBuffer(context, maybeAccount) | ||
async function fetchAllRuleSetBuffer(context, publicKeys, options) { | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys, options); | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options); | ||
return maybeAccounts.map((maybeAccount) => { | ||
@@ -46,3 +46,3 @@ (0, umi_1.assertAccountExists)(maybeAccount, 'RuleSetBuffer'); | ||
async function safeFetchAllRuleSetBuffer(context, publicKeys, options) { | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys, options); | ||
const maybeAccounts = await context.rpc.getAccounts(publicKeys.map((key) => (0, umi_1.publicKey)(key, false)), options); | ||
return maybeAccounts | ||
@@ -49,0 +49,0 @@ .filter((maybeAccount) => maybeAccount.exists) |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Context, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
import { Context, Pda, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
import { RuleSetRevisionInput, RuleSetRevisionInputArgs } from '../../hooked'; | ||
@@ -15,7 +15,7 @@ export type CreateOrUpdateV1InstructionAccounts = { | ||
/** The PDA account where the RuleSet is stored */ | ||
ruleSetPda: PublicKey; | ||
ruleSetPda: PublicKey | Pda; | ||
/** System program */ | ||
systemProgram?: PublicKey; | ||
systemProgram?: PublicKey | Pda; | ||
/** The buffer to copy a complete ruleset from */ | ||
bufferPda?: PublicKey; | ||
bufferPda?: PublicKey | Pda; | ||
}; | ||
@@ -22,0 +22,0 @@ export type CreateOrUpdateV1InstructionData = { |
@@ -33,42 +33,25 @@ "use strict"; | ||
// Program ID. | ||
const programId = { | ||
...context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'), | ||
isWritable: false, | ||
const programId = context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'); | ||
// Resolved inputs. | ||
const resolvedAccounts = { | ||
ruleSetPda: [input.ruleSetPda, true], | ||
}; | ||
// Resolved inputs. | ||
const resolvingAccounts = {}; | ||
const resolvingArgs = {}; | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'payer', input.payer ?? context.payer); | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'systemProgram', input.systemProgram ?? { | ||
...context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
isWritable: false, | ||
}); | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'bufferPda', input.bufferPda ?? programId); | ||
const resolvedAccounts = { ...input, ...resolvingAccounts }; | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'payer', input.payer | ||
? [input.payer, true] | ||
: [context.payer, true]); | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'systemProgram', input.systemProgram | ||
? [input.systemProgram, false] | ||
: [ | ||
context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
false, | ||
]); | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'bufferPda', input.bufferPda | ||
? [input.bufferPda, false] | ||
: [programId, false]); | ||
const resolvedArgs = { ...input, ...resolvingArgs }; | ||
// Payer. | ||
signers.push(resolvedAccounts.payer); | ||
keys.push({ | ||
pubkey: resolvedAccounts.payer.publicKey, | ||
isSigner: true, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.payer, true), | ||
}); | ||
// Rule Set Pda. | ||
keys.push({ | ||
pubkey: resolvedAccounts.ruleSetPda, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.ruleSetPda, true), | ||
}); | ||
// System Program. | ||
keys.push({ | ||
pubkey: resolvedAccounts.systemProgram, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.systemProgram, false), | ||
}); | ||
// Buffer Pda. | ||
keys.push({ | ||
pubkey: resolvedAccounts.bufferPda, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.bufferPda, false), | ||
}); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.payer, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.ruleSetPda, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.systemProgram, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.bufferPda, false); | ||
// Data. | ||
@@ -75,0 +58,0 @@ const data = getCreateOrUpdateV1InstructionDataSerializer(context).serialize(resolvedArgs); |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Context, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
import { Context, Pda, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
export type PuffRuleSetV1InstructionAccounts = { | ||
@@ -14,5 +14,5 @@ /** Payer and creator of the RuleSet */ | ||
/** The PDA account where the RuleSet is stored */ | ||
ruleSetPda: PublicKey; | ||
ruleSetPda: PublicKey | Pda; | ||
/** System program */ | ||
systemProgram?: PublicKey; | ||
systemProgram?: PublicKey | Pda; | ||
}; | ||
@@ -19,0 +19,0 @@ export type PuffRuleSetV1InstructionData = { |
@@ -27,35 +27,21 @@ "use strict"; | ||
// Program ID. | ||
const programId = { | ||
...context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'), | ||
isWritable: false, | ||
const programId = context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'); | ||
// Resolved inputs. | ||
const resolvedAccounts = { | ||
ruleSetPda: [input.ruleSetPda, true], | ||
}; | ||
// Resolved inputs. | ||
const resolvingAccounts = {}; | ||
const resolvingArgs = {}; | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'payer', input.payer ?? context.payer); | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'systemProgram', input.systemProgram ?? { | ||
...context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
isWritable: false, | ||
}); | ||
const resolvedAccounts = { ...input, ...resolvingAccounts }; | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'payer', input.payer | ||
? [input.payer, true] | ||
: [context.payer, true]); | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'systemProgram', input.systemProgram | ||
? [input.systemProgram, false] | ||
: [ | ||
context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
false, | ||
]); | ||
const resolvedArgs = { ...input, ...resolvingArgs }; | ||
// Payer. | ||
signers.push(resolvedAccounts.payer); | ||
keys.push({ | ||
pubkey: resolvedAccounts.payer.publicKey, | ||
isSigner: true, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.payer, true), | ||
}); | ||
// Rule Set Pda. | ||
keys.push({ | ||
pubkey: resolvedAccounts.ruleSetPda, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.ruleSetPda, true), | ||
}); | ||
// System Program. | ||
keys.push({ | ||
pubkey: resolvedAccounts.systemProgram, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.systemProgram, false), | ||
}); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.payer, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.ruleSetPda, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.systemProgram, false); | ||
// Data. | ||
@@ -62,0 +48,0 @@ const data = getPuffRuleSetV1InstructionDataSerializer(context).serialize(resolvedArgs); |
@@ -8,11 +8,11 @@ /** | ||
*/ | ||
import { Context, Option, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
import { Context, Option, Pda, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
import { Payload, PayloadArgs } from '../types'; | ||
export type ValidateV1InstructionAccounts = { | ||
/** The PDA account where the RuleSet is stored */ | ||
ruleSetPda: PublicKey; | ||
ruleSetPda: PublicKey | Pda; | ||
/** Mint of token asset */ | ||
mint: PublicKey; | ||
mint: PublicKey | Pda; | ||
/** System program */ | ||
systemProgram?: PublicKey; | ||
systemProgram?: PublicKey | Pda; | ||
/** Payer for RuleSet state PDA account */ | ||
@@ -23,3 +23,3 @@ payer?: Signer; | ||
/** The PDA account where any RuleSet state is stored */ | ||
ruleSetStatePda?: PublicKey; | ||
ruleSetStatePda?: PublicKey | Pda; | ||
}; | ||
@@ -26,0 +26,0 @@ export type ValidateV1InstructionData = { |
@@ -31,60 +31,29 @@ "use strict"; | ||
// Program ID. | ||
const programId = { | ||
...context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'), | ||
isWritable: false, | ||
const programId = context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'); | ||
// Resolved inputs. | ||
const resolvedAccounts = { | ||
ruleSetPda: [input.ruleSetPda, false], | ||
mint: [input.mint, false], | ||
}; | ||
// Resolved inputs. | ||
const resolvingAccounts = {}; | ||
const resolvingArgs = {}; | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'systemProgram', input.systemProgram ?? { | ||
...context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
isWritable: false, | ||
}); | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'payer', input.payer ?? programId); | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'ruleAuthority', input.ruleAuthority ?? programId); | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'ruleSetStatePda', input.ruleSetStatePda ?? programId); | ||
const resolvedAccounts = { ...input, ...resolvingAccounts }; | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'systemProgram', input.systemProgram | ||
? [input.systemProgram, false] | ||
: [ | ||
context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
false, | ||
]); | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'payer', input.payer ? [input.payer, true] : [programId, false]); | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'ruleAuthority', input.ruleAuthority | ||
? [input.ruleAuthority, false] | ||
: [programId, false]); | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'ruleSetStatePda', input.ruleSetStatePda | ||
? [input.ruleSetStatePda, true] | ||
: [programId, false]); | ||
const resolvedArgs = { ...input, ...resolvingArgs }; | ||
// Rule Set Pda. | ||
keys.push({ | ||
pubkey: resolvedAccounts.ruleSetPda, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.ruleSetPda, false), | ||
}); | ||
// Mint. | ||
keys.push({ | ||
pubkey: resolvedAccounts.mint, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.mint, false), | ||
}); | ||
// System Program. | ||
keys.push({ | ||
pubkey: resolvedAccounts.systemProgram, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.systemProgram, false), | ||
}); | ||
// Payer. | ||
if ((0, umi_1.isSigner)(resolvedAccounts.payer)) { | ||
signers.push(resolvedAccounts.payer); | ||
} | ||
keys.push({ | ||
pubkey: (0, umi_1.publicKey)(resolvedAccounts.payer), | ||
isSigner: (0, umi_1.isSigner)(resolvedAccounts.payer), | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.payer, true), | ||
}); | ||
// Rule Authority. | ||
if ((0, umi_1.isSigner)(resolvedAccounts.ruleAuthority)) { | ||
signers.push(resolvedAccounts.ruleAuthority); | ||
} | ||
keys.push({ | ||
pubkey: (0, umi_1.publicKey)(resolvedAccounts.ruleAuthority), | ||
isSigner: (0, umi_1.isSigner)(resolvedAccounts.ruleAuthority), | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.ruleAuthority, false), | ||
}); | ||
// Rule Set State Pda. | ||
keys.push({ | ||
pubkey: resolvedAccounts.ruleSetStatePda, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.ruleSetStatePda, true), | ||
}); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.ruleSetPda, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.mint, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.systemProgram, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.payer, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.ruleAuthority, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.ruleSetStatePda, false); | ||
// Data. | ||
@@ -91,0 +60,0 @@ const data = getValidateV1InstructionDataSerializer(context).serialize(resolvedArgs); |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { Context, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
import { Context, Pda, PublicKey, Serializer, Signer, TransactionBuilder } from '@metaplex-foundation/umi'; | ||
export type WriteToBufferV1InstructionAccounts = { | ||
@@ -14,5 +14,5 @@ /** Payer and creator of the RuleSet */ | ||
/** The PDA account where the RuleSet buffer is stored */ | ||
bufferPda: PublicKey; | ||
bufferPda: PublicKey | Pda; | ||
/** System program */ | ||
systemProgram?: PublicKey; | ||
systemProgram?: PublicKey | Pda; | ||
}; | ||
@@ -19,0 +19,0 @@ export type WriteToBufferV1InstructionData = { |
@@ -28,35 +28,21 @@ "use strict"; | ||
// Program ID. | ||
const programId = { | ||
...context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'), | ||
isWritable: false, | ||
const programId = context.programs.getPublicKey('mplTokenAuthRules', 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'); | ||
// Resolved inputs. | ||
const resolvedAccounts = { | ||
bufferPda: [input.bufferPda, true], | ||
}; | ||
// Resolved inputs. | ||
const resolvingAccounts = {}; | ||
const resolvingArgs = {}; | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'payer', input.payer ?? context.payer); | ||
(0, shared_1.addObjectProperty)(resolvingAccounts, 'systemProgram', input.systemProgram ?? { | ||
...context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
isWritable: false, | ||
}); | ||
const resolvedAccounts = { ...input, ...resolvingAccounts }; | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'payer', input.payer | ||
? [input.payer, true] | ||
: [context.payer, true]); | ||
(0, shared_1.addObjectProperty)(resolvedAccounts, 'systemProgram', input.systemProgram | ||
? [input.systemProgram, false] | ||
: [ | ||
context.programs.getPublicKey('splSystem', '11111111111111111111111111111111'), | ||
false, | ||
]); | ||
const resolvedArgs = { ...input, ...resolvingArgs }; | ||
// Payer. | ||
signers.push(resolvedAccounts.payer); | ||
keys.push({ | ||
pubkey: resolvedAccounts.payer.publicKey, | ||
isSigner: true, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.payer, true), | ||
}); | ||
// Buffer Pda. | ||
keys.push({ | ||
pubkey: resolvedAccounts.bufferPda, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.bufferPda, true), | ||
}); | ||
// System Program. | ||
keys.push({ | ||
pubkey: resolvedAccounts.systemProgram, | ||
isSigner: false, | ||
isWritable: (0, shared_1.isWritable)(resolvedAccounts.systemProgram, false), | ||
}); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.payer, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.bufferPda, false); | ||
(0, shared_1.addAccountMeta)(keys, signers, resolvedAccounts.systemProgram, false); | ||
// Data. | ||
@@ -63,0 +49,0 @@ const data = getWriteToBufferV1InstructionDataSerializer(context).serialize(resolvedArgs); |
@@ -9,5 +9,5 @@ /** | ||
import { ClusterFilter, Context, Program, PublicKey } from '@metaplex-foundation/umi'; | ||
export declare const MPL_TOKEN_AUTH_RULES_PROGRAM_ID: PublicKey; | ||
export declare const MPL_TOKEN_AUTH_RULES_PROGRAM_ID: PublicKey<"auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg">; | ||
export declare function createMplTokenAuthRulesProgram(): Program; | ||
export declare function getMplTokenAuthRulesProgram<T extends Program = Program>(context: Pick<Context, 'programs'>, clusterFilter?: ClusterFilter): T; | ||
export declare function getMplTokenAuthRulesProgramId(context: Pick<Context, 'programs'>, clusterFilter?: ClusterFilter): PublicKey; |
@@ -11,5 +11,4 @@ "use strict"; | ||
exports.getMplTokenAuthRulesProgramId = exports.getMplTokenAuthRulesProgram = exports.createMplTokenAuthRulesProgram = exports.MPL_TOKEN_AUTH_RULES_PROGRAM_ID = void 0; | ||
const umi_1 = require("@metaplex-foundation/umi"); | ||
const errors_1 = require("../errors"); | ||
exports.MPL_TOKEN_AUTH_RULES_PROGRAM_ID = (0, umi_1.publicKey)('auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'); | ||
exports.MPL_TOKEN_AUTH_RULES_PROGRAM_ID = 'auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg'; | ||
function createMplTokenAuthRulesProgram() { | ||
@@ -16,0 +15,0 @@ return { |
@@ -8,3 +8,3 @@ /** | ||
*/ | ||
import { PublicKey, HasPublicKey } from '@metaplex-foundation/umi'; | ||
import { AccountMeta, Pda, PublicKey, Signer } from '@metaplex-foundation/umi'; | ||
/** | ||
@@ -16,2 +16,7 @@ * Transforms the given object such that the given keys are optional. | ||
/** | ||
* Defines an instruction account that keeps track of whether it is writable or not. | ||
* @internal | ||
*/ | ||
export type WithWritable<T extends PublicKey | Pda | Signer | undefined> = readonly [T, boolean]; | ||
/** | ||
* Helper function that dynamically updates the type of | ||
@@ -25,8 +30,6 @@ * an object as we add more properties to the object. | ||
/** | ||
* Helper function that enables public keys and signers | ||
* to override the `isWritable` property of an account meta. | ||
* Adds an instruction account to the given list of keys and signers. | ||
* @internal | ||
*/ | ||
export declare const isWritable: (account: (PublicKey | HasPublicKey) & { | ||
isWritable?: boolean; | ||
}, value: boolean) => boolean; | ||
export declare function addAccountMeta(keys: AccountMeta[], signers: Signer[], account: WithWritable<PublicKey | Pda | Signer>, isOptional: false): void; | ||
export declare function addAccountMeta(keys: AccountMeta[], signers: Signer[], account: WithWritable<PublicKey | Pda | Signer | undefined>, isOptional: true): void; |
@@ -10,3 +10,4 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.isWritable = exports.addObjectProperty = void 0; | ||
exports.addAccountMeta = exports.addObjectProperty = void 0; | ||
const umi_1 = require("@metaplex-foundation/umi"); | ||
/** | ||
@@ -21,11 +22,19 @@ * Helper function that dynamically updates the type of | ||
exports.addObjectProperty = addObjectProperty; | ||
/** | ||
* Helper function that enables public keys and signers | ||
* to override the `isWritable` property of an account meta. | ||
* @internal | ||
*/ | ||
const isWritable = (account, value) => 'isWritable' in account && typeof account.isWritable === 'boolean' | ||
? account.isWritable | ||
: value; | ||
exports.isWritable = isWritable; | ||
function addAccountMeta(keys, signers, account, isOptional) { | ||
if (isOptional && !account[0]) { | ||
return; | ||
} | ||
if (!account[0]) { | ||
throw new Error('Expected instruction account to be defined'); | ||
} | ||
if ((0, umi_1.isSigner)(account[0])) { | ||
signers.push(account[0]); | ||
} | ||
keys.push({ | ||
pubkey: (0, umi_1.publicKey)(account[0], false), | ||
isSigner: (0, umi_1.isSigner)(account[0]), | ||
isWritable: account[1], | ||
}); | ||
} | ||
exports.addAccountMeta = addAccountMeta; | ||
//# sourceMappingURL=index.js.map |
@@ -1,2 +0,2 @@ | ||
import { Context, PublicKeyBase58, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import { Context, PublicKey, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import type { RuleV1 } from '../v1'; | ||
@@ -6,3 +6,3 @@ import { RuleV2 } from './rule'; | ||
type: 'AdditionalSigner'; | ||
publicKey: PublicKeyBase58; | ||
publicKey: PublicKey; | ||
}; | ||
@@ -9,0 +9,0 @@ export declare const additionalSignerV2: (publicKey: PublicKeyInput) => AdditionalSignerRuleV2; |
@@ -10,3 +10,3 @@ "use strict"; | ||
type: 'AdditionalSigner', | ||
publicKey: (0, umi_1.base58PublicKey)(publicKey), | ||
publicKey: (0, umi_1.publicKey)(publicKey), | ||
}); | ||
@@ -16,3 +16,3 @@ exports.additionalSignerV2 = additionalSignerV2; | ||
const s = context.serializer; | ||
return (0, ruleHeader_1.wrapSerializerInRuleHeaderV2)(context, ruleType_1.RuleTypeV2.AdditionalSigner, s.struct([['publicKey', s.string({ encoding: umi_1.base58, size: 32 })]])); | ||
return (0, ruleHeader_1.wrapSerializerInRuleHeaderV2)(context, ruleType_1.RuleTypeV2.AdditionalSigner, s.struct([['publicKey', s.publicKey()]])); | ||
}; | ||
@@ -19,0 +19,0 @@ exports.getAdditionalSignerRuleV2Serializer = getAdditionalSignerRuleV2Serializer; |
@@ -1,2 +0,2 @@ | ||
import { Context, PublicKeyBase58, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import { Context, PublicKey, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import type { RuleV1 } from '../v1'; | ||
@@ -7,3 +7,3 @@ import { RuleV2 } from './rule'; | ||
pdaField: string; | ||
program: PublicKeyBase58; | ||
program: PublicKey; | ||
seedsField: string; | ||
@@ -10,0 +10,0 @@ }; |
@@ -11,3 +11,3 @@ "use strict"; | ||
pdaField, | ||
program: (0, umi_1.base58PublicKey)(program), | ||
program: (0, umi_1.publicKey)(program), | ||
seedsField, | ||
@@ -19,3 +19,3 @@ }); | ||
return (0, ruleHeader_1.wrapSerializerInRuleHeaderV2)(context, ruleType_1.RuleTypeV2.PdaMatch, s.struct([ | ||
['program', s.string({ encoding: umi_1.base58, size: 32 })], | ||
['program', s.publicKey()], | ||
['pdaField', s.string({ size: 32 })], | ||
@@ -22,0 +22,0 @@ ['seedsField', s.string({ size: 32 })], |
@@ -1,2 +0,2 @@ | ||
import { Context, PublicKeyBase58, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import { Context, PublicKey, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import type { RuleV1 } from '../v1'; | ||
@@ -7,3 +7,3 @@ import { RuleV2 } from './rule'; | ||
field: string; | ||
program: PublicKeyBase58; | ||
program: PublicKey; | ||
}; | ||
@@ -10,0 +10,0 @@ export declare const programOwnedV2: (field: string, program: PublicKeyInput) => ProgramOwnedRuleV2; |
@@ -10,3 +10,3 @@ "use strict"; | ||
type: 'ProgramOwned', | ||
program: (0, umi_1.base58PublicKey)(program), | ||
program: (0, umi_1.publicKey)(program), | ||
field, | ||
@@ -18,3 +18,3 @@ }); | ||
return (0, ruleHeader_1.wrapSerializerInRuleHeaderV2)(context, ruleType_1.RuleTypeV2.ProgramOwned, s.struct([ | ||
['program', s.string({ encoding: umi_1.base58, size: 32 })], | ||
['program', s.publicKey()], | ||
['field', s.string({ size: 32 })], | ||
@@ -21,0 +21,0 @@ ])); |
@@ -1,2 +0,2 @@ | ||
import { Context, PublicKeyBase58, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import { Context, PublicKey, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import type { RuleV1 } from '../v1'; | ||
@@ -7,3 +7,3 @@ import { RuleV2 } from './rule'; | ||
field: string; | ||
programs: PublicKeyBase58[]; | ||
programs: PublicKey[]; | ||
}; | ||
@@ -10,0 +10,0 @@ export declare const programOwnedListV2: (field: string, programs: PublicKeyInput[]) => ProgramOwnedListRuleV2; |
@@ -11,3 +11,3 @@ "use strict"; | ||
field, | ||
programs: programs.map(umi_1.base58PublicKey), | ||
programs: programs.map((program) => (0, umi_1.publicKey)(program)), | ||
}); | ||
@@ -19,8 +19,3 @@ exports.programOwnedListV2 = programOwnedListV2; | ||
['field', s.string({ size: 32 })], | ||
[ | ||
'programs', | ||
s.array(s.string({ encoding: umi_1.base58, size: 32 }), { | ||
size: 'remainder', | ||
}), | ||
], | ||
['programs', s.array(s.publicKey(), { size: 'remainder' })], | ||
])); | ||
@@ -27,0 +22,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { Context, PublicKeyBase58, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import { Context, PublicKey, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import type { RuleV1 } from '../v1'; | ||
@@ -7,3 +7,3 @@ import { RuleV2 } from './rule'; | ||
field: string; | ||
publicKeys: PublicKeyBase58[]; | ||
publicKeys: PublicKey[]; | ||
}; | ||
@@ -10,0 +10,0 @@ export declare const pubkeyListMatchV2: (field: string, publicKeys: PublicKeyInput[]) => PubkeyListMatchRuleV2; |
@@ -11,3 +11,3 @@ "use strict"; | ||
field, | ||
publicKeys: publicKeys.map(umi_1.base58PublicKey), | ||
publicKeys: publicKeys.map((program) => (0, umi_1.publicKey)(program)), | ||
}); | ||
@@ -19,8 +19,3 @@ exports.pubkeyListMatchV2 = pubkeyListMatchV2; | ||
['field', s.string({ size: 32 })], | ||
[ | ||
'publicKeys', | ||
s.array(s.string({ encoding: umi_1.base58, size: 32 }), { | ||
size: 'remainder', | ||
}), | ||
], | ||
['publicKeys', s.array(s.publicKey(), { size: 'remainder' })], | ||
])); | ||
@@ -27,0 +22,0 @@ }; |
@@ -1,2 +0,2 @@ | ||
import { Context, PublicKeyBase58, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import { Context, PublicKey, PublicKeyInput, Serializer } from '@metaplex-foundation/umi'; | ||
import type { RuleV1 } from '../v1'; | ||
@@ -7,3 +7,3 @@ import { RuleV2 } from './rule'; | ||
field: string; | ||
publicKey: PublicKeyBase58; | ||
publicKey: PublicKey; | ||
}; | ||
@@ -10,0 +10,0 @@ export declare const pubkeyMatchV2: (field: string, publicKey: PublicKeyInput) => PubkeyMatchRuleV2; |
@@ -10,3 +10,3 @@ "use strict"; | ||
type: 'PubkeyMatch', | ||
publicKey: (0, umi_1.base58PublicKey)(publicKey), | ||
publicKey: (0, umi_1.publicKey)(publicKey), | ||
field, | ||
@@ -18,3 +18,3 @@ }); | ||
return (0, ruleHeader_1.wrapSerializerInRuleHeaderV2)(context, ruleType_1.RuleTypeV2.PubkeyMatch, s.struct([ | ||
['publicKey', s.string({ encoding: umi_1.base58, size: 32 })], | ||
['publicKey', s.publicKey()], | ||
['field', s.string({ size: 32 })], | ||
@@ -21,0 +21,0 @@ ])); |
@@ -1,2 +0,2 @@ | ||
import { Context, PublicKeyBase58, Serializer } from '@metaplex-foundation/umi'; | ||
import { Context, PublicKey, Serializer } from '@metaplex-foundation/umi'; | ||
import { RuleSetRevisionV1, RuleV1 } from '../v1'; | ||
@@ -7,3 +7,3 @@ import { RuleV2 } from './rule'; | ||
name: string; | ||
owner: PublicKeyBase58; | ||
owner: PublicKey; | ||
operations: Record<string, RuleV2>; | ||
@@ -10,0 +10,0 @@ }; |
@@ -34,3 +34,3 @@ "use strict"; | ||
s.u32().serialize(ruleSize), | ||
s.string({ encoding: umi_1.base58, size: 32 }).serialize(revision.owner), | ||
s.publicKey().serialize(revision.owner), | ||
s.string({ size: 32 }).serialize(revision.name), | ||
@@ -53,5 +53,3 @@ s | ||
offset = ruleSizeOffset; | ||
const [owner, ownerOffset] = s | ||
.string({ encoding: umi_1.base58, size: 32 }) | ||
.deserialize(buffer, offset); | ||
const [owner, ownerOffset] = s.publicKey().deserialize(buffer, offset); | ||
offset = ownerOffset; | ||
@@ -85,3 +83,3 @@ const [name, nameOffset] = s | ||
name: ruleSetV1.ruleSetName, | ||
owner: (0, umi_1.base58PublicKey)(new Uint8Array(ruleSetV1.owner)), | ||
owner: (0, umi_1.publicKey)(new Uint8Array(ruleSetV1.owner)), | ||
operations: Object.fromEntries(Object.entries(ruleSetV1.operations).map(([operation, rule]) => [ | ||
@@ -88,0 +86,0 @@ operation, |
{ | ||
"name": "@metaplex-foundation/mpl-token-auth-rules", | ||
"version": "3.0.0-alpha.7", | ||
"version": "3.0.0-alpha.8", | ||
"description": "Javascript SDK for MPL Token Authorization Rules. MPL Token Authorization Rules can be used to restrict common token operations", | ||
@@ -22,9 +22,9 @@ "main": "dist/src/index.js", | ||
"peerDependencies": { | ||
"@metaplex-foundation/umi": "^0.7.7" | ||
"@metaplex-foundation/umi": "^0.8.0" | ||
}, | ||
"devDependencies": { | ||
"@ava/typescript": "^3.0.1", | ||
"@metaplex-foundation/mpl-token-metadata": "3.0.0-alpha.18", | ||
"@metaplex-foundation/umi": "^0.7.7", | ||
"@metaplex-foundation/umi-bundle-tests": "^0.7.7", | ||
"@metaplex-foundation/mpl-token-metadata": "3.0.0-alpha.23", | ||
"@metaplex-foundation/umi": "^0.8.0", | ||
"@metaplex-foundation/umi-bundle-tests": "^0.8.0", | ||
"@solana/web3.js": "^1.73.0", | ||
@@ -31,0 +31,0 @@ "@typescript-eslint/eslint-plugin": "^5.0.0", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
263303
3901