@typesol/cli 0.17.0 → 0.18.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/CHANGELOG.md +75 -0
- package/README.md +4 -4
- package/dist/clientgen.js +2 -0
- package/dist/compiler/analyze.d.ts +10 -1
- package/dist/compiler/analyze.js +129 -45
- package/dist/compiler/emit/base.d.ts +29 -1
- package/dist/compiler/emit/base.js +79 -8
- package/dist/compiler/emit/borsh.js +71 -5
- package/dist/compiler/emit/calls.d.ts +2 -3
- package/dist/compiler/emit/calls.js +93 -15
- package/dist/compiler/emit/cpi.d.ts +30 -0
- package/dist/compiler/emit/cpi.js +955 -39
- package/dist/compiler/emit/expressions.d.ts +5 -0
- package/dist/compiler/emit/expressions.js +66 -3
- package/dist/compiler/emit/function.js +51 -6
- package/dist/compiler/emit/shared.d.ts +8 -0
- package/dist/compiler/emit/shared.js +4 -1
- package/dist/compiler/emit/statements.d.ts +21 -0
- package/dist/compiler/emit/statements.js +369 -16
- package/dist/compiler/emit/storage.d.ts +2 -0
- package/dist/compiler/emit/storage.js +28 -4
- package/dist/compiler/idl.js +4 -1
- package/dist/compiler/model.d.ts +29 -2
- package/dist/portgen.js +32 -2
- package/docs/errors.md +3 -2
- package/docs/language.md +30 -22
- package/docs/migrate-from-anchor.md +10 -2
- package/lib/typesol.d.ts +396 -21
- package/package.json +1 -1
- package/runtime/typesol_rt.h +198 -0
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
|
-
|
|
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,39 @@ 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
|
-
|
|
466
|
-
|
|
467
|
-
|
|
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;
|
|
468
520
|
readonly pdaBump: u8;
|
|
469
|
-
}
|
|
521
|
+
}
|
|
522
|
+
: T &
|
|
523
|
+
AccountMeta & {
|
|
524
|
+
/** Like create(payer, seeds, space?), unless the account exists (then it must be this PDA and a T). */
|
|
525
|
+
createIfNeeded(payer: Mut<Signer>, seeds: Seed[], space?: u64): boolean;
|
|
526
|
+
/** The PDA bump, after createIfNeeded(). */
|
|
527
|
+
readonly pdaBump: u8;
|
|
528
|
+
};
|
|
470
529
|
|
|
471
530
|
/**
|
|
472
531
|
* Declarative constraints, checked before your code runs (like Anchor's account attributes):
|
|
@@ -533,7 +592,13 @@ export declare function emitCpi<T>(event: T, eventAuthority: EventAuthority, sel
|
|
|
533
592
|
export type CorePluginAuthority = "none" | "owner" | "updateAuthority" | Pubkey;
|
|
534
593
|
/** A Metaplex Core plugin, written as an object literal (Core's Plugin enum, with its authority when it is added). */
|
|
535
594
|
export type CorePlugin = (
|
|
536
|
-
| {
|
|
595
|
+
| {
|
|
596
|
+
kind: "Royalties";
|
|
597
|
+
basisPoints: u16;
|
|
598
|
+
creators: { address: Pubkey; percentage: u8 }[];
|
|
599
|
+
/** Programs allowed (or denied) to move the asset; none by default. */
|
|
600
|
+
ruleSet?: { programAllowList: Pubkey[] } | { programDenyList: Pubkey[] };
|
|
601
|
+
}
|
|
537
602
|
| { kind: "FreezeDelegate"; frozen: boolean }
|
|
538
603
|
| { kind: "BurnDelegate" }
|
|
539
604
|
| { kind: "TransferDelegate" }
|
|
@@ -547,8 +612,13 @@ export type CorePlugin = (
|
|
|
547
612
|
| { kind: "ImmutableMetadata" }
|
|
548
613
|
/** On a collection: lets Bubblegum mint compressed NFTs into it (mintV2 with a collection). */
|
|
549
614
|
| { kind: "BubblegumV2" }
|
|
615
|
+
| { kind: "MasterEdition"; maxSupply?: u32 | null; name?: string | null; uri?: string | null }
|
|
616
|
+
| { kind: "VerifiedCreators"; signatures: { address: Pubkey; verified: boolean }[] }
|
|
617
|
+
| { kind: "Autograph"; signatures: { address: Pubkey; message: string }[] }
|
|
618
|
+
| { kind: "FreezeExecute"; frozen: boolean }
|
|
619
|
+
| { kind: "PermanentFreezeExecute"; frozen: boolean }
|
|
550
620
|
) & { authority?: CorePluginAuthority };
|
|
551
|
-
export type CorePluginKind = CorePlugin["kind"] | "
|
|
621
|
+
export type CorePluginKind = CorePlugin["kind"] | "Groups";
|
|
552
622
|
|
|
553
623
|
export interface MplCoreProgram extends AccountMeta {
|
|
554
624
|
readonly __mpl_core: void;
|
|
@@ -785,6 +855,180 @@ export interface BubblegumProgram extends AccountMeta {
|
|
|
785
855
|
proof: RemainingAccounts | RemainingSlice,
|
|
786
856
|
signerSeeds?: Seed[] | SignerSeeds,
|
|
787
857
|
): void;
|
|
858
|
+
/** DelegateV2: the owner (null: the payer) sets a new leaf delegate. */
|
|
859
|
+
delegateV2(
|
|
860
|
+
treeConfig: AccountMeta,
|
|
861
|
+
payer: Mut<Signer>,
|
|
862
|
+
leafOwner: AccountMeta | null,
|
|
863
|
+
previousLeafDelegate: AccountMeta | null,
|
|
864
|
+
newLeafDelegate: AccountMeta,
|
|
865
|
+
merkleTree: AccountMeta,
|
|
866
|
+
logWrapper: AccountMeta,
|
|
867
|
+
compressionProgram: AccountMeta,
|
|
868
|
+
systemProgram: SystemProgram,
|
|
869
|
+
leaf: CompressedLeaf & { collectionHash?: Hash | null },
|
|
870
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
871
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
872
|
+
): void;
|
|
873
|
+
/** FreezeV2 / ThawV2: the leaf delegate (as `authority`, null: the payer) freezes or thaws the leaf. */
|
|
874
|
+
freezeV2(
|
|
875
|
+
treeConfig: AccountMeta,
|
|
876
|
+
payer: Mut<Signer>,
|
|
877
|
+
authority: AccountMeta | null,
|
|
878
|
+
leafOwner: AccountMeta,
|
|
879
|
+
leafDelegate: AccountMeta,
|
|
880
|
+
merkleTree: AccountMeta,
|
|
881
|
+
coreCollection: AccountMeta | null,
|
|
882
|
+
logWrapper: AccountMeta,
|
|
883
|
+
compressionProgram: AccountMeta,
|
|
884
|
+
systemProgram: SystemProgram,
|
|
885
|
+
leaf: CompressedLeaf,
|
|
886
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
887
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
888
|
+
): void;
|
|
889
|
+
thawV2(
|
|
890
|
+
treeConfig: AccountMeta,
|
|
891
|
+
payer: Mut<Signer>,
|
|
892
|
+
authority: AccountMeta | null,
|
|
893
|
+
leafOwner: AccountMeta,
|
|
894
|
+
leafDelegate: AccountMeta,
|
|
895
|
+
merkleTree: AccountMeta,
|
|
896
|
+
coreCollection: AccountMeta | null,
|
|
897
|
+
logWrapper: AccountMeta,
|
|
898
|
+
compressionProgram: AccountMeta,
|
|
899
|
+
systemProgram: SystemProgram,
|
|
900
|
+
leaf: CompressedLeaf,
|
|
901
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
902
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
903
|
+
): void;
|
|
904
|
+
/** SetNonTransferableV2 (soulbound), by the collection's permanent freeze delegate. */
|
|
905
|
+
setNonTransferableV2(
|
|
906
|
+
treeConfig: AccountMeta,
|
|
907
|
+
payer: Mut<Signer>,
|
|
908
|
+
authority: AccountMeta | null,
|
|
909
|
+
leafOwner: AccountMeta,
|
|
910
|
+
leafDelegate: AccountMeta | null,
|
|
911
|
+
merkleTree: AccountMeta,
|
|
912
|
+
coreCollection: AccountMeta,
|
|
913
|
+
logWrapper: AccountMeta,
|
|
914
|
+
compressionProgram: AccountMeta,
|
|
915
|
+
systemProgram: SystemProgram,
|
|
916
|
+
leaf: CompressedLeaf,
|
|
917
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
918
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
919
|
+
): void;
|
|
920
|
+
/** UpdateMetadataV2: the tree creator / delegate (or the collection's update authority) changes the metadata. */
|
|
921
|
+
updateMetadataV2(
|
|
922
|
+
treeConfig: AccountMeta,
|
|
923
|
+
payer: Mut<Signer>,
|
|
924
|
+
authority: AccountMeta | null,
|
|
925
|
+
leafOwner: AccountMeta,
|
|
926
|
+
leafDelegate: AccountMeta | null,
|
|
927
|
+
merkleTree: AccountMeta,
|
|
928
|
+
coreCollection: AccountMeta | null,
|
|
929
|
+
logWrapper: AccountMeta,
|
|
930
|
+
compressionProgram: AccountMeta,
|
|
931
|
+
systemProgram: SystemProgram,
|
|
932
|
+
leaf: CompressedLeafRef,
|
|
933
|
+
currentMetadata: CompressedMetadataV2,
|
|
934
|
+
update: CompressedMetadataUpdate,
|
|
935
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
936
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
937
|
+
): void;
|
|
938
|
+
/** VerifyCreatorV2 / UnverifyCreatorV2: a creator (signing) marks itself verified or not. */
|
|
939
|
+
verifyCreatorV2(
|
|
940
|
+
treeConfig: AccountMeta,
|
|
941
|
+
payer: Mut<Signer>,
|
|
942
|
+
creator: AccountMeta | null,
|
|
943
|
+
leafOwner: AccountMeta,
|
|
944
|
+
leafDelegate: AccountMeta | null,
|
|
945
|
+
merkleTree: AccountMeta,
|
|
946
|
+
logWrapper: AccountMeta,
|
|
947
|
+
compressionProgram: AccountMeta,
|
|
948
|
+
systemProgram: SystemProgram,
|
|
949
|
+
leaf: CompressedLeafRef,
|
|
950
|
+
metadata: CompressedMetadataV2,
|
|
951
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
952
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
953
|
+
): void;
|
|
954
|
+
unverifyCreatorV2(
|
|
955
|
+
treeConfig: AccountMeta,
|
|
956
|
+
payer: Mut<Signer>,
|
|
957
|
+
creator: AccountMeta | null,
|
|
958
|
+
leafOwner: AccountMeta,
|
|
959
|
+
leafDelegate: AccountMeta | null,
|
|
960
|
+
merkleTree: AccountMeta,
|
|
961
|
+
logWrapper: AccountMeta,
|
|
962
|
+
compressionProgram: AccountMeta,
|
|
963
|
+
systemProgram: SystemProgram,
|
|
964
|
+
leaf: CompressedLeafRef,
|
|
965
|
+
metadata: CompressedMetadataV2,
|
|
966
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
967
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
968
|
+
): void;
|
|
969
|
+
/** SetCollectionV2: move the leaf into (or out of) a Core collection. */
|
|
970
|
+
setCollectionV2(
|
|
971
|
+
treeConfig: AccountMeta,
|
|
972
|
+
payer: Mut<Signer>,
|
|
973
|
+
authority: AccountMeta | null,
|
|
974
|
+
newCollectionAuthority: AccountMeta | null,
|
|
975
|
+
leafOwner: AccountMeta,
|
|
976
|
+
leafDelegate: AccountMeta | null,
|
|
977
|
+
merkleTree: AccountMeta,
|
|
978
|
+
coreCollection: AccountMeta | null,
|
|
979
|
+
newCoreCollection: AccountMeta | null,
|
|
980
|
+
mplCoreCpiSigner: AccountMeta | null,
|
|
981
|
+
logWrapper: AccountMeta,
|
|
982
|
+
compressionProgram: AccountMeta,
|
|
983
|
+
mplCoreProgram: AccountMeta,
|
|
984
|
+
systemProgram: SystemProgram,
|
|
985
|
+
leaf: CompressedLeafRef,
|
|
986
|
+
metadata: CompressedMetadataV2,
|
|
987
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
988
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
989
|
+
): void;
|
|
990
|
+
/**
|
|
991
|
+
* V1 trees (SPL Account Compression): Transfer / Burn, signed by the leaf owner or delegate (a PDA owner signs with
|
|
992
|
+
* `signerSeeds`), and Delegate by the owner.
|
|
993
|
+
*/
|
|
994
|
+
transfer(
|
|
995
|
+
treeConfig: AccountMeta,
|
|
996
|
+
leafOwner: AccountMeta,
|
|
997
|
+
leafDelegate: AccountMeta,
|
|
998
|
+
newLeafOwner: AccountMeta,
|
|
999
|
+
merkleTree: AccountMeta,
|
|
1000
|
+
logWrapper: AccountMeta,
|
|
1001
|
+
compressionProgram: AccountMeta,
|
|
1002
|
+
systemProgram: SystemProgram,
|
|
1003
|
+
leaf: CompressedLeafV1,
|
|
1004
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
1005
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
1006
|
+
): void;
|
|
1007
|
+
burn(
|
|
1008
|
+
treeConfig: AccountMeta,
|
|
1009
|
+
leafOwner: AccountMeta,
|
|
1010
|
+
leafDelegate: AccountMeta,
|
|
1011
|
+
merkleTree: AccountMeta,
|
|
1012
|
+
logWrapper: AccountMeta,
|
|
1013
|
+
compressionProgram: AccountMeta,
|
|
1014
|
+
systemProgram: SystemProgram,
|
|
1015
|
+
leaf: CompressedLeafV1,
|
|
1016
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
1017
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
1018
|
+
): void;
|
|
1019
|
+
delegate(
|
|
1020
|
+
treeConfig: AccountMeta,
|
|
1021
|
+
leafOwner: AccountMeta,
|
|
1022
|
+
previousLeafDelegate: AccountMeta,
|
|
1023
|
+
newLeafDelegate: AccountMeta,
|
|
1024
|
+
merkleTree: AccountMeta,
|
|
1025
|
+
logWrapper: AccountMeta,
|
|
1026
|
+
compressionProgram: AccountMeta,
|
|
1027
|
+
systemProgram: SystemProgram,
|
|
1028
|
+
leaf: CompressedLeafV1,
|
|
1029
|
+
proof: RemainingAccounts | RemainingSlice,
|
|
1030
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
1031
|
+
): void;
|
|
788
1032
|
}
|
|
789
1033
|
/** Bubblegum V2 leaf metadata (MetadataArgsV2): non-fungible, primary sale not happened, mutable unless `isMutable: false`. */
|
|
790
1034
|
export interface CompressedMetadata {
|
|
@@ -795,6 +1039,37 @@ export interface CompressedMetadata {
|
|
|
795
1039
|
creators?: { address: Pubkey; verified: boolean; share: u8 }[];
|
|
796
1040
|
isMutable?: boolean;
|
|
797
1041
|
}
|
|
1042
|
+
/** A leaf whose data and creator hashes the instruction computes from the metadata passed with it. */
|
|
1043
|
+
export interface CompressedLeafRef {
|
|
1044
|
+
root: Hash;
|
|
1045
|
+
assetDataHash?: Hash | null;
|
|
1046
|
+
flags?: u8 | null;
|
|
1047
|
+
nonce: u64;
|
|
1048
|
+
index: u32;
|
|
1049
|
+
}
|
|
1050
|
+
/** A V1 tree's leaf. */
|
|
1051
|
+
export interface CompressedLeafV1 {
|
|
1052
|
+
root: Hash;
|
|
1053
|
+
dataHash: Hash;
|
|
1054
|
+
creatorHash: Hash;
|
|
1055
|
+
nonce: u64;
|
|
1056
|
+
index: u32;
|
|
1057
|
+
}
|
|
1058
|
+
/** A leaf's full MetadataArgsV2, as it is now (with its creators' verified flags and its collection). */
|
|
1059
|
+
export interface CompressedMetadataV2 extends CompressedMetadata {
|
|
1060
|
+
primarySaleHappened?: boolean;
|
|
1061
|
+
collection?: Pubkey | null;
|
|
1062
|
+
}
|
|
1063
|
+
/** UpdateArgs: what to change (left out: unchanged). */
|
|
1064
|
+
export interface CompressedMetadataUpdate {
|
|
1065
|
+
name?: string;
|
|
1066
|
+
symbol?: string;
|
|
1067
|
+
uri?: string;
|
|
1068
|
+
creators?: { address: Pubkey; verified: boolean; share: u8 }[];
|
|
1069
|
+
sellerFeeBasisPoints?: u16;
|
|
1070
|
+
primarySaleHappened?: boolean;
|
|
1071
|
+
isMutable?: boolean;
|
|
1072
|
+
}
|
|
798
1073
|
/** The leaf a transfer or burn replaces, as an indexer (DAS getAssetProof / getAsset) reports it. */
|
|
799
1074
|
export interface CompressedLeaf {
|
|
800
1075
|
root: Hash;
|
|
@@ -819,17 +1094,60 @@ export type Init<T> = T extends TokenAccount
|
|
|
819
1094
|
* account of those parameters, with `payer` funding rent. Fails if it already exists.
|
|
820
1095
|
*/
|
|
821
1096
|
create(payer: Mut<Signer>): void;
|
|
1097
|
+
/**
|
|
1098
|
+
* Anchor `init` + `token::mint` / `token::authority`: create a token account of `mint` owned by `authority`, at the
|
|
1099
|
+
* PDA of `seeds` (or, with `null`, a new keypair account that signs), under the instruction's token program, with
|
|
1100
|
+
* `payer` funding rent. Returns the bump (0 for a keypair).
|
|
1101
|
+
*/
|
|
1102
|
+
create(
|
|
1103
|
+
payer: Mut<Signer>,
|
|
1104
|
+
seeds: Seed[] | null,
|
|
1105
|
+
mint: AccountMeta,
|
|
1106
|
+
authority: Pubkey,
|
|
1107
|
+
tokenProgram?: TokenProgram | Token2022Program | TokenInterface,
|
|
1108
|
+
): u8;
|
|
1109
|
+
/** The PDA bump, after create(seeds, …). */
|
|
1110
|
+
readonly pdaBump: u8;
|
|
822
1111
|
}
|
|
823
|
-
: T
|
|
824
|
-
|
|
1112
|
+
: T extends Mint
|
|
1113
|
+
? T & {
|
|
825
1114
|
/**
|
|
826
|
-
*
|
|
827
|
-
* `
|
|
1115
|
+
* Anchor `init` + `mint::decimals` / `mint::authority` / `mint::freeze_authority`: create a mint at the PDA of
|
|
1116
|
+
* `seeds` (or, with `null`, a new keypair account that signs) under the instruction's token program, with `payer`
|
|
1117
|
+
* funding rent. Returns the bump (0 for a keypair).
|
|
828
1118
|
*/
|
|
829
|
-
create(
|
|
830
|
-
|
|
1119
|
+
create(
|
|
1120
|
+
payer: Mut<Signer>,
|
|
1121
|
+
seeds: Seed[] | null,
|
|
1122
|
+
decimals: u8,
|
|
1123
|
+
mintAuthority: Pubkey,
|
|
1124
|
+
freezeAuthority: Pubkey | null,
|
|
1125
|
+
tokenProgram?: TokenProgram | Token2022Program | TokenInterface,
|
|
1126
|
+
): u8;
|
|
1127
|
+
/** With Token-2022 extensions (Anchor's `extensions::…`): the mint is sized for them and each is initialized first. */
|
|
1128
|
+
create(
|
|
1129
|
+
payer: Mut<Signer>,
|
|
1130
|
+
seeds: Seed[] | null,
|
|
1131
|
+
decimals: u8,
|
|
1132
|
+
mintAuthority: Pubkey,
|
|
1133
|
+
freezeAuthority: Pubkey | null,
|
|
1134
|
+
extensions: MintExtensions,
|
|
1135
|
+
tokenProgram?: Token2022Program | TokenInterface,
|
|
1136
|
+
): u8;
|
|
831
1137
|
readonly pdaBump: u8;
|
|
832
|
-
}
|
|
1138
|
+
}
|
|
1139
|
+
: T &
|
|
1140
|
+
AccountMeta & {
|
|
1141
|
+
/**
|
|
1142
|
+
* Derive the PDA from `seeds`, verify it matches this account, create it with
|
|
1143
|
+
* `payer` funding rent, and write the discriminator. Returns the bump.
|
|
1144
|
+
* With `null`: a new keypair account that signs the transaction (Anchor's `init` without seeds); returns 0.
|
|
1145
|
+
* `space` (Anchor's `space = …`, discriminator included) reserves more than 8 + the struct's size, up to 10240.
|
|
1146
|
+
*/
|
|
1147
|
+
create(payer: Mut<Signer>, seeds: Seed[] | null, space?: u64): u8;
|
|
1148
|
+
/** The PDA bump, after create(). */
|
|
1149
|
+
readonly pdaBump: u8;
|
|
1150
|
+
};
|
|
833
1151
|
|
|
834
1152
|
/**
|
|
835
1153
|
* A large account (over 10 KiB, up to 10 MiB) the client already allocated with System CreateAccount,
|
|
@@ -882,9 +1200,11 @@ export interface SystemProgram extends AccountMeta {
|
|
|
882
1200
|
interface TokenOps {
|
|
883
1201
|
transfer(from: TokenAccount, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
884
1202
|
transferChecked(from: TokenAccount, mint: Mint, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
885
|
-
|
|
1203
|
+
/** `mint`: a Mut<Mint>, or a mint this instruction created and initialized (Mut<Signer> / Mut<AccountInfo>). */
|
|
1204
|
+
mintTo(mint: Mint | AccountMeta, to: TokenAccount, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
886
1205
|
burn(from: TokenAccount, mint: Mint, authority: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
887
|
-
|
|
1206
|
+
/** Close a token account (empty), or under Token-2022 a mint with no supply left (its MintCloseAuthority signs). */
|
|
1207
|
+
closeAccount(account: TokenAccount | Mint, destination: AccountMeta, authority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
888
1208
|
/** Let `delegate` move up to `amount` from `source`. */
|
|
889
1209
|
approve(source: TokenAccount, delegate: AccountMeta, owner: AccountMeta, amount: u64, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
890
1210
|
revoke(source: TokenAccount, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
@@ -904,7 +1224,7 @@ interface TokenOps {
|
|
|
904
1224
|
interface Token2022Ops {
|
|
905
1225
|
/** Token-2022 only: write name/symbol/uri into a mint whose MetadataPointer points at itself (the mint needs lamports for the larger size). */
|
|
906
1226
|
initializeMetadata(
|
|
907
|
-
mint:
|
|
1227
|
+
mint: AccountMeta,
|
|
908
1228
|
updateAuthority: AccountMeta,
|
|
909
1229
|
mintAuthority: AccountMeta,
|
|
910
1230
|
name: string,
|
|
@@ -937,6 +1257,61 @@ interface Token2022Ops {
|
|
|
937
1257
|
initializeInterestBearingMint(mint: AccountMeta, rateAuthority: Pubkey | null, rate: i16): void;
|
|
938
1258
|
/** ImmutableOwner on a token account (before initializeAccount3): its owner can never change. */
|
|
939
1259
|
initializeImmutableOwner(account: AccountMeta): void;
|
|
1260
|
+
|
|
1261
|
+
// Token-2022 extension instructions on mints and accounts that have the extension.
|
|
1262
|
+
/** DefaultAccountState Update: new token accounts start frozen (true) or initialized (false). */
|
|
1263
|
+
updateDefaultAccountState(mint: AccountMeta, freezeAuthority: AccountMeta, frozen: boolean, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1264
|
+
/** TransferHook Update: the program invoked on every transfer (null: none). */
|
|
1265
|
+
updateTransferHook(mint: AccountMeta, authority: AccountMeta, programId: Pubkey | null, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1266
|
+
/** MemoTransfer Enable: incoming transfers to `account` need a memo instruction before them. */
|
|
1267
|
+
enableRequiredMemoTransfers(account: AccountMeta, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1268
|
+
/** MemoTransfer Disable. */
|
|
1269
|
+
disableRequiredMemoTransfers(account: AccountMeta, owner: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1270
|
+
/** InterestBearingMint UpdateRate (basis points per year). */
|
|
1271
|
+
updateInterestRate(mint: AccountMeta, rateAuthority: AccountMeta, rate: i16, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1272
|
+
/** TransferFee TransferCheckedWithFee: `fee` must be the fee Token-2022 computes for `amount`; decimals are the mint's. */
|
|
1273
|
+
transferCheckedWithFee(
|
|
1274
|
+
from: TokenAccount,
|
|
1275
|
+
mint: Mint,
|
|
1276
|
+
to: TokenAccount,
|
|
1277
|
+
authority: AccountMeta,
|
|
1278
|
+
amount: u64,
|
|
1279
|
+
fee: u64,
|
|
1280
|
+
signerSeeds?: Seed[] | SignerSeeds,
|
|
1281
|
+
): void;
|
|
1282
|
+
/** TransferFee HarvestWithheldTokensToMint: move withheld fees from the given token accounts (passed on writable as they were passed) to the mint. */
|
|
1283
|
+
harvestWithheldTokensToMint(mint: AccountMeta, sources: RemainingAccounts | RemainingSlice): void;
|
|
1284
|
+
/** TransferFee WithdrawWithheldTokensFromMint: the fees held by the mint to `destination`. */
|
|
1285
|
+
withdrawWithheldTokensFromMint(mint: AccountMeta, destination: TokenAccount, withdrawAuthority: AccountMeta, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1286
|
+
/** TransferFee SetTransferFee: takes effect two epochs later. */
|
|
1287
|
+
setTransferFee(mint: AccountMeta, configAuthority: AccountMeta, basisPoints: u16, maximumFee: u64, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1288
|
+
|
|
1289
|
+
// The Token Metadata interface, for metadata stored in the mint (after initializeMetadata).
|
|
1290
|
+
/** Set "name", "symbol" or "uri", or any other key as an additional field. */
|
|
1291
|
+
updateMetadataField(mint: AccountMeta, updateAuthority: AccountMeta, field: string, value: string, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1292
|
+
/** Remove an additional field; with `idempotent` false a missing key fails. */
|
|
1293
|
+
removeMetadataKey(mint: AccountMeta, updateAuthority: AccountMeta, key: string, idempotent: boolean, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1294
|
+
/** Hand the update authority to `newAuthority`, or make the metadata immutable with null. */
|
|
1295
|
+
updateMetadataAuthority(mint: AccountMeta, updateAuthority: AccountMeta, newAuthority: Pubkey | null, signerSeeds?: Seed[] | SignerSeeds): void;
|
|
1296
|
+
/** Emit: the whole TokenMetadata as Token-2022's return data. */
|
|
1297
|
+
emitMetadata(mint: AccountMeta): void;
|
|
1298
|
+
}
|
|
1299
|
+
|
|
1300
|
+
/**
|
|
1301
|
+
* Token-2022 extensions for `mint.create(…, extensions)`: Anchor's `extensions::…` constraints. `null` authorities
|
|
1302
|
+
* mean none; `defaultAccountState: true` starts new token accounts frozen (it needs a freeze authority).
|
|
1303
|
+
*/
|
|
1304
|
+
export interface MintExtensions {
|
|
1305
|
+
transferFee?: { configAuthority: Pubkey | null; withdrawAuthority: Pubkey | null; basisPoints: u16; maximumFee: u64 };
|
|
1306
|
+
closeAuthority?: Pubkey | null;
|
|
1307
|
+
defaultAccountState?: boolean;
|
|
1308
|
+
nonTransferable?: true;
|
|
1309
|
+
interestBearing?: { rateAuthority: Pubkey | null; rate: i16 };
|
|
1310
|
+
permanentDelegate?: Pubkey;
|
|
1311
|
+
transferHook?: { authority: Pubkey | null; programId: Pubkey | null };
|
|
1312
|
+
metadataPointer?: { authority: Pubkey | null; metadataAddress: Pubkey | null };
|
|
1313
|
+
groupPointer?: { authority: Pubkey | null; groupAddress: Pubkey | null };
|
|
1314
|
+
groupMemberPointer?: { authority: Pubkey | null; memberAddress: Pubkey | null };
|
|
940
1315
|
}
|
|
941
1316
|
|
|
942
1317
|
/** The SPL Token program (Tokenkeg). Its address is checked. */
|
|
@@ -1053,7 +1428,7 @@ export declare function i128(value: bigint): i128;
|
|
|
1053
1428
|
* << aborts when bits would be lost or the amount is not below the width; >> is arithmetic on signed types;
|
|
1054
1429
|
* ~ flips the bits within the type's width.
|
|
1055
1430
|
*/
|
|
1056
|
-
/** floor(a * b / c) with a
|
|
1431
|
+
/** 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
1432
|
export declare function mulDiv(a: u64, b: u64, c: u64): u64;
|
|
1058
1433
|
/** ceil(a * b / c), like mulDiv. */
|
|
1059
1434
|
export declare function mulDivCeil(a: u64, b: u64, c: u64): u64;
|