Skip to content

Commit

Permalink
Add customProgramId JS handling
Browse files Browse the repository at this point in the history
  • Loading branch information
danenbm committed May 9, 2024
1 parent c33fab6 commit 640a2bd
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions clients/js/src/plugins/extraAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
} from '@metaplex-foundation/umi/serializers';
import { BaseExtraAccount } from '../generated';
import { Seed, seedFromBase, seedToBase } from './seed';
import { RenameToType } from '../utils';
import { RenameToType, someOrNone, unwrapOption } from '../utils';

export const PRECONFIGURED_SEED = 'mpl-core';

Expand Down Expand Up @@ -33,6 +33,7 @@ export type ExtraAccount =
| {
type: 'CustomPda';
seeds: Array<Seed>;
customProgramId?: PublicKey;
isSigner?: boolean;
isWritable?: boolean;
}
Expand Down Expand Up @@ -120,7 +121,7 @@ export function extraAccountToAccountMeta(
case 'CustomPda':
return {
pubkey: context.eddsa.findPda(
inputs.program!,
e.customProgramId ? e.customProgramId : inputs.program!,
e.seeds.map((seed) => {
switch (seed.type) {
case 'Collection':
Expand Down Expand Up @@ -162,6 +163,7 @@ export function extraAccountToBase(s: ExtraAccount): BaseExtraAccount {
__kind: 'CustomPda',
...acccountMeta,
seeds: s.seeds.map(seedToBase),
customProgramId: someOrNone(s.customProgramId)
};
}
if (s.type === 'Address') {
Expand All @@ -185,6 +187,7 @@ export function extraAccountFromBase(s: BaseExtraAccount): ExtraAccount {
isSigner: s.isSigner,
isWritable: s.isWritable,
seeds: s.seeds.map(seedFromBase),
customProgramId: unwrapOption(s.customProgramId),
};
}
if (s.__kind === 'Address') {
Expand Down

0 comments on commit 640a2bd

Please sign in to comment.