@typesol/cli 0.17.0 → 0.19.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/typesol.d.ts CHANGED
@@ -31,7 +31,28 @@ export interface Pubkey {
31
31
  * A fixed-length array stored inline in account data, e.g. `scores: FixedArray<u64, 8>`.
32
32
  * Indexes are bounds-checked; out of range aborts the instruction.
33
33
  */
34
- export interface FixedArray<T, N extends number> {
34
+ /**
35
+ * Callback methods of Vec, FixedArray and FixedVec. Each expands into a loop over the elements (as `list.get(i)` gives
36
+ * them: structs by reference) with the arrow written at the call; it may read and write the function's variables.
37
+ */
38
+ export interface ListMethods<T> {
39
+ forEach(fn: (x: T, index: u64) => void): void;
40
+ /** Whether `fn` holds for some element (stops at the first). */
41
+ some(fn: (x: T, index: u64) => boolean): boolean;
42
+ /** Whether `fn` holds for every element (stops at the first that fails). */
43
+ every(fn: (x: T, index: u64) => boolean): boolean;
44
+ /** The first element `fn` holds for, or null (integer, boolean, Pubkey and enum elements). */
45
+ find(fn: (x: T, index: u64) => boolean): T | null;
46
+ /** The index of the first element `fn` holds for, or -1. */
47
+ findIndex(fn: (x: T, index: u64) => boolean): i64;
48
+ reduce<A>(fn: (acc: A, x: T, index: u64) => A, initial: A): A;
49
+ /** Whether an element equals `value` (===). */
50
+ includes(value: T): boolean;
51
+ /** The index of the first element equal to `value`, or -1. */
52
+ indexOf(value: T): i64;
53
+ }
54
+
55
+ export interface FixedArray<T, N extends number> extends ListMethods<T> {
35
56
  readonly length: u64;
36
57
  get(index: bigint): T;
37
58
  set(index: bigint, value: T): void;
@@ -63,7 +84,7 @@ export type Option<T> = T | null;
63
84
  * A growable list. As the last field of an account struct it is stored Borsh-style (u32 length + elements)
64
85
  * and the account is resized as it grows. As an instruction argument it is a read-only view.
65
86
  */
66
- export interface Vec<T> {
87
+ export interface Vec<T> extends ListMethods<T> {
67
88
  readonly length: u64;
68
89
  get(index: bigint): T;
69
90
  set(index: bigint, value: T): void;
@@ -82,7 +103,7 @@ export interface Vec<T> {
82
103
  * always 4 + N × size(T) bytes). Unlike `Vec<T>` it can be any field, any number of times, and in nested structs;
83
104
  * `push` fails (5104) when it is full. Write a whole one with `fixedVec([a, b])`.
84
105
  */
85
- export interface FixedVec<T, N extends number> {
106
+ export interface FixedVec<T, N extends number> extends ListMethods<T> {
86
107
  readonly length: u64;
87
108
  get(index: bigint): T;
88
109
  set(index: bigint, value: T): void;
@@ -403,6 +424,13 @@ export declare function realloc(account: AccountMeta, newSize: u64, payer: Mut<S
403
424
  export declare function transferFee(mint: AccountMeta | RemainingAccount, amount: u64): u64;
404
425
  /** The TransferHook extension's program, if any. */
405
426
  export declare function transferHookProgram(mint: AccountMeta | RemainingAccount): Option<Pubkey>;
427
+ /** The TransferHook extension's authority (who may change the hook program), if any. */
428
+ export declare function transferHookAuthority(mint: AccountMeta | RemainingAccount): Option<Pubkey>;
429
+ /**
430
+ * Whether Token-2022 is transferring from this token account right now (its TransferHookAccount `transferring` flag):
431
+ * true inside a transfer hook called by Token-2022, false when the hook is invoked directly.
432
+ */
433
+ export declare function isTransferring(tokenAccount: AccountMeta | RemainingAccount): boolean;
406
434
  /** The PermanentDelegate extension's delegate, if any (it can move or burn anyone's tokens). */
407
435
  export declare function permanentDelegate(mint: AccountMeta | RemainingAccount): Option<Pubkey>;
408
436
  /** The MintCloseAuthority extension's authority, if any. */
@@ -421,6 +449,11 @@ export interface Signer extends AccountMeta {
421
449
  readonly __signer: void;
422
450
  }
423
451
 
452
+ /** An account owned by the System Program, e.g. a wallet (Anchor `SystemAccount`; 3011 otherwise). `Mut<SystemAccount>` to change lamports. */
453
+ export interface SystemAccount extends AccountMeta {
454
+ readonly __systemAccount?: void;
455
+ }
456
+
424
457
  /** Any account, no ownership or data checks. Wrap in `Mut<AccountInfo>` to change lamports. */
425
458
  export interface AccountInfo extends AccountMeta {
426
459
  readonly __info: void;
@@ -460,13 +493,53 @@ export type InitIfNeeded<T> = T extends TokenAccount
460
493
  * An existing account must be that ATA, of that mint and owner.
461
494
  */
462
495
  createIfNeeded(payer: Mut<Signer>): boolean;
496
+ /**
497
+ * Anchor `init_if_needed` + `token::…`: create it as `create(payer, seeds, mint, authority)` does unless it exists;
498
+ * an existing one must be that PDA, a token account of `mint` owned by `authority`. True when it created it now.
499
+ */
500
+ createIfNeeded(
501
+ payer: Mut<Signer>,
502
+ seeds: Seed[] | null,
503
+ mint: AccountMeta,
504
+ authority: Pubkey,
505
+ tokenProgram?: TokenProgram | Token2022Program | TokenInterface,
506
+ ): boolean;
507
+ readonly pdaBump: u8;
463
508
  }
464
- : T &
465
- AccountMeta & {
466
- createIfNeeded(payer: Mut<Signer>, seeds: Seed[]): boolean;
467
- /** The PDA bump, after createIfNeeded(). */
509
+ : T extends Mint
510
+ ? T & {
511
+ /** Anchor `init_if_needed` + `mint::…`: an existing mint must have these decimals and authorities. */
512
+ createIfNeeded(
513
+ payer: Mut<Signer>,
514
+ seeds: Seed[] | null,
515
+ decimals: u8,
516
+ mintAuthority: Pubkey,
517
+ freezeAuthority: Pubkey | null,
518
+ tokenProgram?: TokenProgram | Token2022Program | TokenInterface,
519
+ ): boolean;
520
+ /**
521
+ * With extensions: created with them, or an existing mint must carry them with these keys, as Anchor's
522
+ * `extensions::…` constraints check (2024–2039). groupPointer, groupMemberPointer, metadataPointer,
523
+ * closeAuthority, permanentDelegate and transferHook only.
524
+ */
525
+ createIfNeeded(
526
+ payer: Mut<Signer>,
527
+ seeds: Seed[] | null,
528
+ decimals: u8,
529
+ mintAuthority: Pubkey,
530
+ freezeAuthority: Pubkey | null,
531
+ extensions: MintExtensions,
532
+ tokenProgram?: Token2022Program | TokenInterface,
533
+ ): boolean;
468
534
  readonly pdaBump: u8;
469
- };
535
+ }
536
+ : T &
537
+ AccountMeta & {
538
+ /** Like create(payer, seeds, space?), unless the account exists (then it must be this PDA and a T). */
539
+ createIfNeeded(payer: Mut<Signer>, seeds: Seed[], space?: u64): boolean;
540
+ /** The PDA bump, after createIfNeeded(). */
541
+ readonly pdaBump: u8;
542
+ };
470
543
 
471
544
  /**
472
545
  * Declarative constraints, checked before your code runs (like Anchor's account attributes):
@@ -480,6 +553,15 @@ export type InitIfNeeded<T> = T extends TokenAccount
480
553
  * They nest: `CloseTo<HasOne<Mut<Vault>, "owner">, "owner">`.
481
554
  */
482
555
  export type HasOne<A, Field extends string> = A & { readonly __hasOne?: Field };
556
+ /**
557
+ * Anchor's `token::mint = mintParam, token::authority = authorityParam` on an existing token account, naming the
558
+ * parameters (2014 / 2015); `never` leaves one out.
559
+ */
560
+ export type TokenOf<A, MintParam extends string, AuthorityParam extends string = never> = A & { readonly __tokenOf?: [MintParam, AuthorityParam] };
561
+ /** Anchor's `mint::authority = a, mint::freeze_authority = f` on an existing mint, naming the parameters (2016 / 2017). */
562
+ export type MintOf<A, AuthorityParam extends string, FreezeAuthorityParam extends string = never> = A & {
563
+ readonly __mintOf?: [AuthorityParam, FreezeAuthorityParam];
564
+ };
483
565
  export type Seeds<A, Names extends readonly string[], Bump extends string = never, ProgramId extends string = never> = A & {
484
566
  readonly __seeds?: [Names, Bump, ProgramId];
485
567
  /** The PDA's bump (Anchor `ctx.bumps.<account>`): the stored bump field when one is named, else the canonical bump found. */
@@ -533,7 +615,13 @@ export declare function emitCpi<T>(event: T, eventAuthority: EventAuthority, sel
533
615
  export type CorePluginAuthority = "none" | "owner" | "updateAuthority" | Pubkey;
534
616
  /** A Metaplex Core plugin, written as an object literal (Core's Plugin enum, with its authority when it is added). */
535
617
  export type CorePlugin = (
536
- | { kind: "Royalties"; basisPoints: u16; creators: { address: Pubkey; percentage: u8 }[] }
618
+ | {
619
+ kind: "Royalties";
620
+ basisPoints: u16;
621
+ creators: { address: Pubkey; percentage: u8 }[];
622
+ /** Programs allowed (or denied) to move the asset; none by default. */
623
+ ruleSet?: { programAllowList: Pubkey[] } | { programDenyList: Pubkey[] };
624
+ }
537
625
  | { kind: "FreezeDelegate"; frozen: boolean }
538
626
  | { kind: "BurnDelegate" }
539
627
  | { kind: "TransferDelegate" }
@@ -547,8 +635,13 @@ export type CorePlugin = (
547
635
  | { kind: "ImmutableMetadata" }
548
636
  /** On a collection: lets Bubblegum mint compressed NFTs into it (mintV2 with a collection). */
549
637
  | { kind: "BubblegumV2" }
638
+ | { kind: "MasterEdition"; maxSupply?: u32 | null; name?: string | null; uri?: string | null }
639
+ | { kind: "VerifiedCreators"; signatures: { address: Pubkey; verified: boolean }[] }
640
+ | { kind: "Autograph"; signatures: { address: Pubkey; message: string }[] }
641
+ | { kind: "FreezeExecute"; frozen: boolean }
642
+ | { kind: "PermanentFreezeExecute"; frozen: boolean }
550
643
  ) & { authority?: CorePluginAuthority };
551
- export type CorePluginKind = CorePlugin["kind"] | "MasterEdition" | "VerifiedCreators" | "Autograph";
644
+ export type CorePluginKind = CorePlugin["kind"] | "Groups";
552
645
 
553
646
  export interface MplCoreProgram extends AccountMeta {
554
647
  readonly __mpl_core: void;
@@ -704,6 +797,31 @@ export interface BubblegumProgram extends AccountMeta {
704
797
  sellerFeeBasisPoints: u16,
705
798
  signerSeeds?: Seed[] | SignerSeeds,
706
799
  ): void;
800
+ /**
801
+ * MintToCollectionV1 on a V1 tree: the leaf joins a Token Metadata collection (Bubblegum verifies it; the collection
802
+ * authority signs, its record PDA is `null` when it is the update authority itself). Creators default to none,
803
+ * `isMutable` to true, `editionNonce` to None.
804
+ */
805
+ mintToCollection(
806
+ treeConfig: AccountMeta,
807
+ leafOwner: AccountMeta,
808
+ leafDelegate: AccountMeta,
809
+ merkleTree: AccountMeta,
810
+ payer: Signer,
811
+ treeDelegate: AccountMeta,
812
+ collectionAuthority: AccountMeta,
813
+ collectionAuthorityRecordPda: AccountMeta | null,
814
+ collectionMint: AccountMeta,
815
+ collectionMetadata: AccountMeta,
816
+ collectionEdition: AccountMeta,
817
+ bubblegumSigner: AccountMeta,
818
+ logWrapper: AccountMeta,
819
+ compressionProgram: AccountMeta,
820
+ tokenMetadataProgram: AccountMeta,
821
+ systemProgram: SystemProgram,
822
+ metadata: CompressedMetadata & { editionNonce?: u8 },
823
+ signerSeeds?: Seed[] | SignerSeeds,
824
+ ): void;
707
825
  /**
708
826
  * CreateTreeConfigV2: a tree on mpl-account-compression (mcmt6…, allocated by the client and owned by it) with the
709
827
  * mpl-noop log wrapper (mnoop…). `treeCreator` `null`: the payer.
@@ -785,6 +903,180 @@ export interface BubblegumProgram extends AccountMeta {
785
903
  proof: RemainingAccounts | RemainingSlice,
786
904
  signerSeeds?: Seed[] | SignerSeeds,
787
905
  ): void;
906
+ /** DelegateV2: the owner (null: the payer) sets a new leaf delegate. */
907
+ delegateV2(
908
+ treeConfig: AccountMeta,
909
+ payer: Mut<Signer>,
910
+ leafOwner: AccountMeta | null,
911
+ previousLeafDelegate: AccountMeta | null,
912
+ newLeafDelegate: AccountMeta,
913
+ merkleTree: AccountMeta,
914
+ logWrapper: AccountMeta,
915
+ compressionProgram: AccountMeta,
916
+ systemProgram: SystemProgram,
917
+ leaf: CompressedLeaf & { collectionHash?: Hash | null },
918
+ proof: RemainingAccounts | RemainingSlice,
919
+ signerSeeds?: Seed[] | SignerSeeds,
920
+ ): void;
921
+ /** FreezeV2 / ThawV2: the leaf delegate (as `authority`, null: the payer) freezes or thaws the leaf. */
922
+ freezeV2(
923
+ treeConfig: AccountMeta,
924
+ payer: Mut<Signer>,
925
+ authority: AccountMeta | null,
926
+ leafOwner: AccountMeta,
927
+ leafDelegate: AccountMeta,
928
+ merkleTree: AccountMeta,
929
+ coreCollection: AccountMeta | null,
930
+ logWrapper: AccountMeta,
931
+ compressionProgram: AccountMeta,
932
+ systemProgram: SystemProgram,
933
+ leaf: CompressedLeaf,
934
+ proof: RemainingAccounts | RemainingSlice,
935
+ signerSeeds?: Seed[] | SignerSeeds,
936
+ ): void;
937
+ thawV2(
938
+ treeConfig: AccountMeta,
939
+ payer: Mut<Signer>,
940
+ authority: AccountMeta | null,
941
+ leafOwner: AccountMeta,
942
+ leafDelegate: AccountMeta,
943
+ merkleTree: AccountMeta,
944
+ coreCollection: AccountMeta | null,
945
+ logWrapper: AccountMeta,
946
+ compressionProgram: AccountMeta,
947
+ systemProgram: SystemProgram,
948
+ leaf: CompressedLeaf,
949
+ proof: RemainingAccounts | RemainingSlice,
950
+ signerSeeds?: Seed[] | SignerSeeds,
951
+ ): void;
952
+ /** SetNonTransferableV2 (soulbound), by the collection's permanent freeze delegate. */
953
+ setNonTransferableV2(
954
+ treeConfig: AccountMeta,
955
+ payer: Mut<Signer>,
956
+ authority: AccountMeta | null,
957
+ leafOwner: AccountMeta,
958
+ leafDelegate: AccountMeta | null,
959
+ merkleTree: AccountMeta,
960
+ coreCollection: AccountMeta,
961
+ logWrapper: AccountMeta,
962
+ compressionProgram: AccountMeta,
963
+ systemProgram: SystemProgram,
964
+ leaf: CompressedLeaf,
965
+ proof: RemainingAccounts | RemainingSlice,
966
+ signerSeeds?: Seed[] | SignerSeeds,
967
+ ): void;
968
+ /** UpdateMetadataV2: the tree creator / delegate (or the collection's update authority) changes the metadata. */
969
+ updateMetadataV2(
970
+ treeConfig: AccountMeta,
971
+ payer: Mut<Signer>,
972
+ authority: AccountMeta | null,
973
+ leafOwner: AccountMeta,
974
+ leafDelegate: AccountMeta | null,
975
+ merkleTree: AccountMeta,
976
+ coreCollection: AccountMeta | null,
977
+ logWrapper: AccountMeta,
978
+ compressionProgram: AccountMeta,
979
+ systemProgram: SystemProgram,
980
+ leaf: CompressedLeafRef,
981
+ currentMetadata: CompressedMetadataV2,
982
+ update: CompressedMetadataUpdate,
983
+ proof: RemainingAccounts | RemainingSlice,
984
+ signerSeeds?: Seed[] | SignerSeeds,
985
+ ): void;
986
+ /** VerifyCreatorV2 / UnverifyCreatorV2: a creator (signing) marks itself verified or not. */
987
+ verifyCreatorV2(
988
+ treeConfig: AccountMeta,
989
+ payer: Mut<Signer>,
990
+ creator: AccountMeta | null,
991
+ leafOwner: AccountMeta,
992
+ leafDelegate: AccountMeta | null,
993
+ merkleTree: AccountMeta,
994
+ logWrapper: AccountMeta,
995
+ compressionProgram: AccountMeta,
996
+ systemProgram: SystemProgram,
997
+ leaf: CompressedLeafRef,
998
+ metadata: CompressedMetadataV2,
999
+ proof: RemainingAccounts | RemainingSlice,
1000
+ signerSeeds?: Seed[] | SignerSeeds,
1001
+ ): void;
1002
+ unverifyCreatorV2(
1003
+ treeConfig: AccountMeta,
1004
+ payer: Mut<Signer>,
1005
+ creator: AccountMeta | null,
1006
+ leafOwner: AccountMeta,
1007
+ leafDelegate: AccountMeta | null,
1008
+ merkleTree: AccountMeta,
1009
+ logWrapper: AccountMeta,
1010
+ compressionProgram: AccountMeta,
1011
+ systemProgram: SystemProgram,
1012
+ leaf: CompressedLeafRef,
1013
+ metadata: CompressedMetadataV2,
1014
+ proof: RemainingAccounts | RemainingSlice,
1015
+ signerSeeds?: Seed[] | SignerSeeds,
1016
+ ): void;
1017
+ /** SetCollectionV2: move the leaf into (or out of) a Core collection. */
1018
+ setCollectionV2(
1019
+ treeConfig: AccountMeta,
1020
+ payer: Mut<Signer>,
1021
+ authority: AccountMeta | null,
1022
+ newCollectionAuthority: AccountMeta | null,
1023
+ leafOwner: AccountMeta,
1024
+ leafDelegate: AccountMeta | null,
1025
+ merkleTree: AccountMeta,
1026
+ coreCollection: AccountMeta | null,
1027
+ newCoreCollection: AccountMeta | null,
1028
+ mplCoreCpiSigner: AccountMeta | null,
1029
+ logWrapper: AccountMeta,
1030
+ compressionProgram: AccountMeta,
1031
+ mplCoreProgram: AccountMeta,
1032
+ systemProgram: SystemProgram,
1033
+ leaf: CompressedLeafRef,
1034
+ metadata: CompressedMetadataV2,
1035
+ proof: RemainingAccounts | RemainingSlice,
1036
+ signerSeeds?: Seed[] | SignerSeeds,
1037
+ ): void;
1038
+ /**
1039
+ * V1 trees (SPL Account Compression): Transfer / Burn, signed by the leaf owner or delegate (a PDA owner signs with
1040
+ * `signerSeeds`), and Delegate by the owner.
1041
+ */
1042
+ transfer(
1043
+ treeConfig: AccountMeta,
1044
+ leafOwner: AccountMeta,
1045
+ leafDelegate: AccountMeta,
1046
+ newLeafOwner: AccountMeta,
1047
+ merkleTree: AccountMeta,
1048
+ logWrapper: AccountMeta,
1049
+ compressionProgram: AccountMeta,
1050
+ systemProgram: SystemProgram,
1051
+ leaf: CompressedLeafV1,
1052
+ proof: RemainingAccounts | RemainingSlice,
1053
+ signerSeeds?: Seed[] | SignerSeeds,
1054
+ ): void;
1055
+ burn(
1056
+ treeConfig: AccountMeta,
1057
+ leafOwner: AccountMeta,
1058
+ leafDelegate: AccountMeta,
1059
+ merkleTree: AccountMeta,
1060
+ logWrapper: AccountMeta,
1061
+ compressionProgram: AccountMeta,
1062
+ systemProgram: SystemProgram,
1063
+ leaf: CompressedLeafV1,
1064
+ proof: RemainingAccounts | RemainingSlice,
1065
+ signerSeeds?: Seed[] | SignerSeeds,
1066
+ ): void;
1067
+ delegate(
1068
+ treeConfig: AccountMeta,
1069
+ leafOwner: AccountMeta,
1070
+ previousLeafDelegate: AccountMeta,
1071
+ newLeafDelegate: AccountMeta,
1072
+ merkleTree: AccountMeta,
1073
+ logWrapper: AccountMeta,
1074
+ compressionProgram: AccountMeta,
1075
+ systemProgram: SystemProgram,
1076
+ leaf: CompressedLeafV1,
1077
+ proof: RemainingAccounts | RemainingSlice,
1078
+ signerSeeds?: Seed[] | SignerSeeds,
1079
+ ): void;
788
1080
  }
789
1081
  /** Bubblegum V2 leaf metadata (MetadataArgsV2): non-fungible, primary sale not happened, mutable unless `isMutable: false`. */
790
1082
  export interface CompressedMetadata {
@@ -795,6 +1087,37 @@ export interface CompressedMetadata {
795
1087
  creators?: { address: Pubkey; verified: boolean; share: u8 }[];
796
1088
  isMutable?: boolean;
797
1089
  }
1090
+ /** A leaf whose data and creator hashes the instruction computes from the metadata passed with it. */
1091
+ export interface CompressedLeafRef {
1092
+ root: Hash;
1093
+ assetDataHash?: Hash | null;
1094
+ flags?: u8 | null;
1095
+ nonce: u64;
1096
+ index: u32;
1097
+ }
1098
+ /** A V1 tree's leaf. */
1099
+ export interface CompressedLeafV1 {
1100
+ root: Hash;
1101
+ dataHash: Hash;
1102
+ creatorHash: Hash;
1103
+ nonce: u64;
1104
+ index: u32;
1105
+ }
1106
+ /** A leaf's full MetadataArgsV2, as it is now (with its creators' verified flags and its collection). */
1107
+ export interface CompressedMetadataV2 extends CompressedMetadata {
1108
+ primarySaleHappened?: boolean;
1109
+ collection?: Pubkey | null;
1110
+ }
1111
+ /** UpdateArgs: what to change (left out: unchanged). */
1112
+ export interface CompressedMetadataUpdate {
1113
+ name?: string;
1114
+ symbol?: string;
1115
+ uri?: string;
1116
+ creators?: { address: Pubkey; verified: boolean; share: u8 }[];
1117
+ sellerFeeBasisPoints?: u16;
1118
+ primarySaleHappened?: boolean;
1119
+ isMutable?: boolean;
1120
+ }
798
1121
  /** The leaf a transfer or burn replaces, as an indexer (DAS getAssetProof / getAsset) reports it. */
799
1122
  export interface CompressedLeaf {
800
1123
  root: Hash;
@@ -819,17 +1142,60 @@ export type Init<T> = T extends TokenAccount
819
1142
  * account of those parameters, with `payer` funding rent. Fails if it already exists.
820
1143
  */
821
1144
  create(payer: Mut<Signer>): void;
1145
+ /**
1146
+ * Anchor `init` + `token::mint` / `token::authority`: create a token account of `mint` owned by `authority`, at the
1147
+ * PDA of `seeds` (or, with `null`, a new keypair account that signs), under the instruction's token program, with
1148
+ * `payer` funding rent. Returns the bump (0 for a keypair).
1149
+ */
1150
+ create(
1151
+ payer: Mut<Signer>,
1152
+ seeds: Seed[] | null,
1153
+ mint: AccountMeta,
1154
+ authority: Pubkey,
1155
+ tokenProgram?: TokenProgram | Token2022Program | TokenInterface,
1156
+ ): u8;
1157
+ /** The PDA bump, after create(seeds, …). */
1158
+ readonly pdaBump: u8;
822
1159
  }
823
- : T &
824
- AccountMeta & {
1160
+ : T extends Mint
1161
+ ? T & {
825
1162
  /**
826
- * Derive the PDA from `seeds`, verify it matches this account, create it with
827
- * `payer` funding rent, and write the discriminator. Returns the bump.
1163
+ * Anchor `init` + `mint::decimals` / `mint::authority` / `mint::freeze_authority`: create a mint at the PDA of
1164
+ * `seeds` (or, with `null`, a new keypair account that signs) under the instruction's token program, with `payer`
1165
+ * funding rent. Returns the bump (0 for a keypair).
828
1166
  */
829
- create(payer: Mut<Signer>, seeds: Seed[]): u8;
830
- /** The PDA bump, after create(). */
1167
+ create(
1168
+ payer: Mut<Signer>,
1169
+ seeds: Seed[] | null,
1170
+ decimals: u8,
1171
+ mintAuthority: Pubkey,
1172
+ freezeAuthority: Pubkey | null,
1173
+ tokenProgram?: TokenProgram | Token2022Program | TokenInterface,
1174
+ ): u8;
1175
+ /** With Token-2022 extensions (Anchor's `extensions::…`): the mint is sized for them and each is initialized first. */
1176
+ create(
1177
+ payer: Mut<Signer>,
1178
+ seeds: Seed[] | null,
1179
+ decimals: u8,
1180
+ mintAuthority: Pubkey,
1181
+ freezeAuthority: Pubkey | null,
1182
+ extensions: MintExtensions,
1183
+ tokenProgram?: Token2022Program | TokenInterface,
1184
+ ): u8;
831
1185
  readonly pdaBump: u8;
832
- };
1186
+ }
1187
+ : T &
1188
+ AccountMeta & {
1189
+ /**
1190
+ * Derive the PDA from `seeds`, verify it matches this account, create it with
1191
+ * `payer` funding rent, and write the discriminator. Returns the bump.
1192
+ * With `null`: a new keypair account that signs the transaction (Anchor's `init` without seeds); returns 0.
1193
+ * `space` (Anchor's `space = …`, discriminator included) reserves more than 8 + the struct's size, up to 10240.
1194
+ */
1195
+ create(payer: Mut<Signer>, seeds: Seed[] | null, space?: u64): u8;
1196
+ /** The PDA bump, after create(). */
1197
+ readonly pdaBump: u8;
1198
+ };
833
1199
 
834
1200
  /**
835
1201
  * A large account (over 10 KiB, up to 10 MiB) the client already allocated with System CreateAccount,
@@ -882,9 +1248,11 @@ export interface SystemProgram extends AccountMeta {
882
1248
  interface TokenOps {
883
1249
  transfer(from: TokenAccount, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
884
1250
  transferChecked(from: TokenAccount, mint: Mint, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
885
- mintTo(mint: Mint, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1251
+ /** `mint`: a Mut<Mint>, or a mint this instruction created and initialized (Mut<Signer> / Mut<AccountInfo>). */
1252
+ mintTo(mint: Mint | AccountMeta, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
886
1253
  burn(from: TokenAccount, mint: Mint, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
887
- closeAccount(account: TokenAccount, destination: AccountMeta, authority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1254
+ /** Close a token account (empty), or under Token-2022 a mint with no supply left (its MintCloseAuthority signs). */
1255
+ closeAccount(account: TokenAccount | Mint, destination: AccountMeta, authority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
888
1256
  /** Let `delegate` move up to `amount` from `source`. */
889
1257
  approve(source: TokenAccount, delegate: AccountMeta, owner: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
890
1258
  revoke(source: TokenAccount, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
@@ -904,7 +1272,7 @@ interface TokenOps {
904
1272
  interface Token2022Ops {
905
1273
  /** Token-2022 only: write name/symbol/uri into a mint whose MetadataPointer points at itself (the mint needs lamports for the larger size). */
906
1274
  initializeMetadata(
907
- mint: Mint,
1275
+ mint: AccountMeta,
908
1276
  updateAuthority: AccountMeta,
909
1277
  mintAuthority: AccountMeta,
910
1278
  name: string,
@@ -937,6 +1305,61 @@ interface Token2022Ops {
937
1305
  initializeInterestBearingMint(mint: AccountMeta, rateAuthority: Pubkey | null, rate: i16): void;
938
1306
  /** ImmutableOwner on a token account (before initializeAccount3): its owner can never change. */
939
1307
  initializeImmutableOwner(account: AccountMeta): void;
1308
+
1309
+ // Token-2022 extension instructions on mints and accounts that have the extension.
1310
+ /** DefaultAccountState Update: new token accounts start frozen (true) or initialized (false). */
1311
+ updateDefaultAccountState(mint: AccountMeta, freezeAuthority: AccountMeta, frozen: boolean, signerSeeds?: Seed[] | SignerSeeds): void;
1312
+ /** TransferHook Update: the program invoked on every transfer (null: none). */
1313
+ updateTransferHook(mint: AccountMeta, authority: AccountMeta, programId: Pubkey | null, signerSeeds?: Seed[] | SignerSeeds): void;
1314
+ /** MemoTransfer Enable: incoming transfers to `account` need a memo instruction before them. */
1315
+ enableRequiredMemoTransfers(account: AccountMeta, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1316
+ /** MemoTransfer Disable. */
1317
+ disableRequiredMemoTransfers(account: AccountMeta, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1318
+ /** InterestBearingMint UpdateRate (basis points per year). */
1319
+ updateInterestRate(mint: AccountMeta, rateAuthority: AccountMeta, rate: i16, signerSeeds?: Seed[] | SignerSeeds): void;
1320
+ /** TransferFee TransferCheckedWithFee: `fee` must be the fee Token-2022 computes for `amount`; decimals are the mint's. */
1321
+ transferCheckedWithFee(
1322
+ from: TokenAccount,
1323
+ mint: Mint,
1324
+ to: TokenAccount,
1325
+ authority: AccountMeta,
1326
+ amount: u64,
1327
+ fee: u64,
1328
+ signerSeeds?: Seed[] | SignerSeeds,
1329
+ ): void;
1330
+ /** TransferFee HarvestWithheldTokensToMint: move withheld fees from the given token accounts (passed on writable as they were passed) to the mint. */
1331
+ harvestWithheldTokensToMint(mint: AccountMeta, sources: RemainingAccounts | RemainingSlice): void;
1332
+ /** TransferFee WithdrawWithheldTokensFromMint: the fees held by the mint to `destination`. */
1333
+ withdrawWithheldTokensFromMint(mint: AccountMeta, destination: TokenAccount, withdrawAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
1334
+ /** TransferFee SetTransferFee: takes effect two epochs later. */
1335
+ setTransferFee(mint: AccountMeta, configAuthority: AccountMeta, basisPoints: u16, maximumFee: u64, signerSeeds?: Seed[] | SignerSeeds): void;
1336
+
1337
+ // The Token Metadata interface, for metadata stored in the mint (after initializeMetadata).
1338
+ /** Set "name", "symbol" or "uri", or any other key as an additional field. */
1339
+ updateMetadataField(mint: AccountMeta, updateAuthority: AccountMeta, field: string, value: string, signerSeeds?: Seed[] | SignerSeeds): void;
1340
+ /** Remove an additional field; with `idempotent` false a missing key fails. */
1341
+ removeMetadataKey(mint: AccountMeta, updateAuthority: AccountMeta, key: string, idempotent: boolean, signerSeeds?: Seed[] | SignerSeeds): void;
1342
+ /** Hand the update authority to `newAuthority`, or make the metadata immutable with null. */
1343
+ updateMetadataAuthority(mint: AccountMeta, updateAuthority: AccountMeta, newAuthority: Pubkey | null, signerSeeds?: Seed[] | SignerSeeds): void;
1344
+ /** Emit: the whole TokenMetadata as Token-2022's return data. */
1345
+ emitMetadata(mint: AccountMeta): void;
1346
+ }
1347
+
1348
+ /**
1349
+ * Token-2022 extensions for `mint.create(…, extensions)`: Anchor's `extensions::…` constraints. `null` authorities
1350
+ * mean none; `defaultAccountState: true` starts new token accounts frozen (it needs a freeze authority).
1351
+ */
1352
+ export interface MintExtensions {
1353
+ transferFee?: { configAuthority: Pubkey | null; withdrawAuthority: Pubkey | null; basisPoints: u16; maximumFee: u64 };
1354
+ closeAuthority?: Pubkey | null;
1355
+ defaultAccountState?: boolean;
1356
+ nonTransferable?: true;
1357
+ interestBearing?: { rateAuthority: Pubkey | null; rate: i16 };
1358
+ permanentDelegate?: Pubkey;
1359
+ transferHook?: { authority: Pubkey | null; programId: Pubkey | null };
1360
+ metadataPointer?: { authority: Pubkey | null; metadataAddress: Pubkey | null };
1361
+ groupPointer?: { authority: Pubkey | null; groupAddress: Pubkey | null };
1362
+ groupMemberPointer?: { authority: Pubkey | null; memberAddress: Pubkey | null };
940
1363
  }
941
1364
 
942
1365
  /** The SPL Token program (Tokenkeg). Its address is checked. */
@@ -1007,7 +1430,90 @@ export declare function invoke(
1007
1430
  ): void;
1008
1431
 
1009
1432
  /** Abort with the given error unless `condition` holds. Use a string enum member or a string literal. */
1010
- export declare function require(condition: boolean, error: string): asserts condition;
1433
+ /**
1434
+ * Anchor's own error codes (anchor-lang `ErrorCode`): `require(condition, AnchorError.AccountDidNotDeserialize)` fails
1435
+ * with that code, as `require!(condition, ErrorCode::AccountDidNotDeserialize)` does. Not listed in the IDL's errors.
1436
+ */
1437
+ export declare enum AnchorError {
1438
+ InstructionMissing = 100,
1439
+ InstructionFallbackNotFound = 101,
1440
+ InstructionDidNotDeserialize = 102,
1441
+ InstructionDidNotSerialize = 103,
1442
+ IdlInstructionStub = 1000,
1443
+ IdlInstructionInvalidProgram = 1001,
1444
+ IdlAccountNotEmpty = 1002,
1445
+ EventInstructionStub = 1500,
1446
+ ConstraintMut = 2000,
1447
+ ConstraintHasOne = 2001,
1448
+ ConstraintSigner = 2002,
1449
+ ConstraintRaw = 2003,
1450
+ ConstraintOwner = 2004,
1451
+ ConstraintRentExempt = 2005,
1452
+ ConstraintSeeds = 2006,
1453
+ ConstraintExecutable = 2007,
1454
+ ConstraintState = 2008,
1455
+ ConstraintAssociated = 2009,
1456
+ ConstraintAssociatedInit = 2010,
1457
+ ConstraintClose = 2011,
1458
+ ConstraintAddress = 2012,
1459
+ ConstraintZero = 2013,
1460
+ ConstraintTokenMint = 2014,
1461
+ ConstraintTokenOwner = 2015,
1462
+ ConstraintMintMintAuthority = 2016,
1463
+ ConstraintMintFreezeAuthority = 2017,
1464
+ ConstraintMintDecimals = 2018,
1465
+ ConstraintSpace = 2019,
1466
+ ConstraintAccountIsNone = 2020,
1467
+ ConstraintTokenTokenProgram = 2021,
1468
+ ConstraintMintTokenProgram = 2022,
1469
+ ConstraintAssociatedTokenTokenProgram = 2023,
1470
+ ConstraintMintGroupPointerExtension = 2024,
1471
+ ConstraintMintGroupPointerExtensionAuthority = 2025,
1472
+ ConstraintMintGroupPointerExtensionGroupAddress = 2026,
1473
+ ConstraintMintGroupMemberPointerExtension = 2027,
1474
+ ConstraintMintGroupMemberPointerExtensionAuthority = 2028,
1475
+ ConstraintMintGroupMemberPointerExtensionMemberAddress = 2029,
1476
+ ConstraintMintMetadataPointerExtension = 2030,
1477
+ ConstraintMintMetadataPointerExtensionAuthority = 2031,
1478
+ ConstraintMintMetadataPointerExtensionMetadataAddress = 2032,
1479
+ ConstraintMintCloseAuthorityExtension = 2033,
1480
+ ConstraintMintCloseAuthorityExtensionAuthority = 2034,
1481
+ ConstraintMintPermanentDelegateExtension = 2035,
1482
+ ConstraintMintPermanentDelegateExtensionDelegate = 2036,
1483
+ ConstraintMintTransferHookExtension = 2037,
1484
+ ConstraintMintTransferHookExtensionAuthority = 2038,
1485
+ ConstraintMintTransferHookExtensionProgramId = 2039,
1486
+ RequireViolated = 2500,
1487
+ RequireEqViolated = 2501,
1488
+ RequireKeysEqViolated = 2502,
1489
+ RequireNeqViolated = 2503,
1490
+ RequireKeysNeqViolated = 2504,
1491
+ RequireGtViolated = 2505,
1492
+ RequireGteViolated = 2506,
1493
+ AccountDiscriminatorAlreadySet = 3000,
1494
+ AccountDiscriminatorNotFound = 3001,
1495
+ AccountDiscriminatorMismatch = 3002,
1496
+ AccountDidNotDeserialize = 3003,
1497
+ AccountDidNotSerialize = 3004,
1498
+ AccountNotEnoughKeys = 3005,
1499
+ AccountNotMutable = 3006,
1500
+ AccountOwnedByWrongProgram = 3007,
1501
+ InvalidProgramId = 3008,
1502
+ InvalidProgramExecutable = 3009,
1503
+ AccountNotSigner = 3010,
1504
+ AccountNotSystemOwned = 3011,
1505
+ AccountNotInitialized = 3012,
1506
+ AccountNotProgramData = 3013,
1507
+ AccountNotAssociatedTokenAccount = 3014,
1508
+ AccountSysvarMismatch = 3015,
1509
+ AccountReallocExceedsLimit = 3016,
1510
+ AccountDuplicateReallocs = 3017,
1511
+ DeclaredProgramIdMismatch = 4100,
1512
+ TryingToInitPayerAsProgramAccount = 4101,
1513
+ InvalidNumericConversion = 4102,
1514
+ Deprecated = 5000,
1515
+ }
1516
+ export declare function require(condition: boolean, error: string | AnchorError): asserts condition;
1011
1517
 
1012
1518
  /** Write a string, integer or pubkey to the program log. */
1013
1519
  export declare function log(value: string | bigint | Pubkey | Hash): void;
@@ -1053,7 +1559,7 @@ export declare function i128(value: bigint): i128;
1053
1559
  * << aborts when bits would be lost or the amount is not below the width; >> is arithmetic on signed types;
1054
1560
  * ~ flips the bits within the type's width.
1055
1561
  */
1056
- /** floor(a * b / c) with a 128-bit intermediate; aborts if c is 0 or the result does not fit in u64. */
1562
+ /** floor(a * b / c) with a double-width intermediate (all u64, or all u128); aborts if c is 0 or the result does not fit. */
1057
1563
  export declare function mulDiv(a: u64, b: u64, c: u64): u64;
1058
1564
  /** ceil(a * b / c), like mulDiv. */
1059
1565
  export declare function mulDivCeil(a: u64, b: u64, c: u64): u64;