3land_sdk 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +352 -0
- package/assets/3land_rebrand.gif +0 -0
- package/assets/battle_sol.gif +0 -0
- package/assets/ds.jpeg +0 -0
- package/assets/future.webp +0 -0
- package/assets/music.mp3 +0 -0
- package/assets/niicl.gif +0 -0
- package/assets/og.png +0 -0
- package/assets/phone.glb +0 -0
- package/assets/testvid.mp4 +0 -0
- package/idl.json +7652 -0
- package/package.json +35 -0
- package/src/index.ts +89 -0
- package/src/library/Irys/irys.ts +412 -0
- package/src/library/Store.ts +613 -0
- package/src/library/implementation/storeImplementation.ts +385 -0
- package/src/library/instructions/store/buySingleEdition.ts +227 -0
- package/src/library/instructions/store/createSingleEdition.ts +49 -0
- package/src/library/instructions/store/createStore.ts +19 -0
- package/src/library/instructions/store/idl.ts +7622 -0
- package/src/library/instructions/store/uploadFilesIryis.ts +133 -0
- package/src/types/accounts/ArchiveDeposit.ts +207 -0
- package/src/types/accounts/Authority.ts +73 -0
- package/src/types/accounts/BurnDeposit.ts +111 -0
- package/src/types/accounts/BurnProgress.ts +97 -0
- package/src/types/accounts/BuyHistory.ts +121 -0
- package/src/types/accounts/BuyTrack.ts +94 -0
- package/src/types/accounts/Card.ts +185 -0
- package/src/types/accounts/CollectionRegistry.ts +145 -0
- package/src/types/accounts/CollectorRegistry.ts +145 -0
- package/src/types/accounts/CreatorRegistry.ts +153 -0
- package/src/types/accounts/CurrencyArtistProof.ts +113 -0
- package/src/types/accounts/GenericUser.ts +185 -0
- package/src/types/accounts/ItemArchive.ts +223 -0
- package/src/types/accounts/ItemReserveList.ts +87 -0
- package/src/types/accounts/ItemReserveList2.ts +73 -0
- package/src/types/accounts/LutVault.ts +97 -0
- package/src/types/accounts/Pack.ts +367 -0
- package/src/types/accounts/PackContent.ts +97 -0
- package/src/types/accounts/PackOpenHolder.ts +141 -0
- package/src/types/accounts/PackReceipt.ts +145 -0
- package/src/types/accounts/PackTraits.ts +101 -0
- package/src/types/accounts/Payment.ts +97 -0
- package/src/types/accounts/PoolVault.ts +177 -0
- package/src/types/accounts/RevealForMe.ts +139 -0
- package/src/types/accounts/SecureHolder.ts +97 -0
- package/src/types/accounts/Single.ts +301 -0
- package/src/types/accounts/Store.ts +180 -0
- package/src/types/accounts/StoresHolder.ts +131 -0
- package/src/types/accounts/ThreeId.ts +189 -0
- package/src/types/accounts/TokenManager.ts +217 -0
- package/src/types/accounts/ZeroCard.ts +73 -0
- package/src/types/accounts/ZeroContent.ts +89 -0
- package/src/types/accounts/ZeroOpenHolder.ts +183 -0
- package/src/types/accounts/index.ts +84 -0
- package/src/types/errors/anchor.ts +773 -0
- package/src/types/errors/index.ts +59 -0
- package/src/types/implementation/implementationTypes.ts +27 -0
- package/src/types/instructions/addBurn.ts +56 -0
- package/src/types/instructions/adjustDepositBurn.ts +33 -0
- package/src/types/instructions/archiveItem.ts +60 -0
- package/src/types/instructions/assignPackDelegate.ts +30 -0
- package/src/types/instructions/burnPay.ts +55 -0
- package/src/types/instructions/buyPack.ts +69 -0
- package/src/types/instructions/buyPay.ts +71 -0
- package/src/types/instructions/buyToken.ts +64 -0
- package/src/types/instructions/claimZeroCard.ts +106 -0
- package/src/types/instructions/closeDepositBurn.ts +47 -0
- package/src/types/instructions/closeRegisterTraits.ts +28 -0
- package/src/types/instructions/createCard.ts +56 -0
- package/src/types/instructions/createCollection.ts +68 -0
- package/src/types/instructions/createPack.ts +71 -0
- package/src/types/instructions/createSingle.ts +71 -0
- package/src/types/instructions/createStore.ts +50 -0
- package/src/types/instructions/createTokenLauncher.ts +82 -0
- package/src/types/instructions/createZeroCard.ts +76 -0
- package/src/types/instructions/deleteCard.ts +32 -0
- package/src/types/instructions/deletePack.ts +40 -0
- package/src/types/instructions/deleteSingle.ts +36 -0
- package/src/types/instructions/deleteTokenLauncher.ts +38 -0
- package/src/types/instructions/depositBurn.ts +55 -0
- package/src/types/instructions/donateUser.ts +84 -0
- package/src/types/instructions/feedPool.ts +61 -0
- package/src/types/instructions/feedTraits.ts +44 -0
- package/src/types/instructions/feedTree.ts +63 -0
- package/src/types/instructions/flagPack.ts +50 -0
- package/src/types/instructions/flagSingle.ts +47 -0
- package/src/types/instructions/gatePay.ts +59 -0
- package/src/types/instructions/index.ts +140 -0
- package/src/types/instructions/initialize.ts +46 -0
- package/src/types/instructions/openPack.ts +79 -0
- package/src/types/instructions/prepareCreator.ts +30 -0
- package/src/types/instructions/preparePack.ts +51 -0
- package/src/types/instructions/prepareTraits.ts +28 -0
- package/src/types/instructions/printPack.ts +95 -0
- package/src/types/instructions/printSingle.ts +108 -0
- package/src/types/instructions/recoverDepositBurn.ts +80 -0
- package/src/types/instructions/registerActivity.ts +43 -0
- package/src/types/instructions/registerCollector.ts +63 -0
- package/src/types/instructions/registerCreator.ts +48 -0
- package/src/types/instructions/registerGenericUser.ts +94 -0
- package/src/types/instructions/registerPackUploads.ts +44 -0
- package/src/types/instructions/registerTraits.ts +42 -0
- package/src/types/instructions/registerUser.ts +50 -0
- package/src/types/instructions/storeLutFor.ts +44 -0
- package/src/types/instructions/unwrapAndDestroy.ts +56 -0
- package/src/types/instructions/updateCard.ts +54 -0
- package/src/types/instructions/updatePack.ts +71 -0
- package/src/types/instructions/updateSingle.ts +64 -0
- package/src/types/instructions/updateStore.ts +47 -0
- package/src/types/instructions/withdrawFromStore.ts +26 -0
- package/src/types/programId.ts +42 -0
- package/src/types/types/AccountClass.ts +868 -0
- package/src/types/types/AccountHasher.ts +89 -0
- package/src/types/types/ActionAfter.ts +202 -0
- package/src/types/types/AllowedCurrencyArgs.ts +53 -0
- package/src/types/types/AuthorityGateTypes.ts +90 -0
- package/src/types/types/BurnCount.ts +60 -0
- package/src/types/types/BurnState.ts +88 -0
- package/src/types/types/BurnTrack.ts +64 -0
- package/src/types/types/BurnType.ts +118 -0
- package/src/types/types/BurnTypeBurn.ts +56 -0
- package/src/types/types/BuyHistoryClass.ts +90 -0
- package/src/types/types/CardClass.ts +56 -0
- package/src/types/types/CardState.ts +238 -0
- package/src/types/types/CardTrack.ts +76 -0
- package/src/types/types/Category.ts +72 -0
- package/src/types/types/CnftData.ts +85 -0
- package/src/types/types/CollectTrack.ts +61 -0
- package/src/types/types/Collection.ts +64 -0
- package/src/types/types/CompactCnftData.ts +76 -0
- package/src/types/types/CoolTimePerAmountArgs.ts +72 -0
- package/src/types/types/Creator.ts +72 -0
- package/src/types/types/CreatorGateArgs.ts +53 -0
- package/src/types/types/CurrencyArtistProof.ts +85 -0
- package/src/types/types/CurrencyType.ts +259 -0
- package/src/types/types/DateTraitInit.ts +61 -0
- package/src/types/types/DateTraitInitMap.ts +72 -0
- package/src/types/types/Deposit.ts +85 -0
- package/src/types/types/DepositFormat.ts +90 -0
- package/src/types/types/DepositState.ts +88 -0
- package/src/types/types/DepositSubtype.ts +90 -0
- package/src/types/types/DepositTrack.ts +69 -0
- package/src/types/types/DepositTrackType.ts +120 -0
- package/src/types/types/DepositType.ts +245 -0
- package/src/types/types/Earnings.ts +37 -0
- package/src/types/types/EditionStoreType.ts +120 -0
- package/src/types/types/EncryptedPayload.ts +61 -0
- package/src/types/types/ExtraParameter.ts +117 -0
- package/src/types/types/FakeBurnCount.ts +64 -0
- package/src/types/types/FakeDeposit.ts +64 -0
- package/src/types/types/FakeTraitPair.ts +61 -0
- package/src/types/types/FakeTraitValue.ts +61 -0
- package/src/types/types/FakeVolumeTrack.ts +64 -0
- package/src/types/types/FeeType.ts +118 -0
- package/src/types/types/FeedingTraits.ts +57 -0
- package/src/types/types/Filter.ts +64 -0
- package/src/types/types/FilterType.ts +56 -0
- package/src/types/types/GeneralStore.ts +56 -0
- package/src/types/types/GenericStore.ts +64 -0
- package/src/types/types/GenericValue.ts +172 -0
- package/src/types/types/GlobalFee.ts +85 -0
- package/src/types/types/GlobalState.ts +148 -0
- package/src/types/types/IndexDate.ts +94 -0
- package/src/types/types/IndexDates.ts +64 -0
- package/src/types/types/Item.ts +53 -0
- package/src/types/types/ItemClass.ts +88 -0
- package/src/types/types/ItemState.ts +298 -0
- package/src/types/types/ItemTrack.ts +76 -0
- package/src/types/types/ListingPerWalletArgs.ts +53 -0
- package/src/types/types/MemeVaultProof.ts +64 -0
- package/src/types/types/MetadataArgs.ts +207 -0
- package/src/types/types/NonFungibleTraitInit.ts +64 -0
- package/src/types/types/NonFungibleTraitInitMap.ts +84 -0
- package/src/types/types/OnlyBetweenTimesArgs.ts +76 -0
- package/src/types/types/OnlyTheseDOWArgs.ts +53 -0
- package/src/types/types/PackConfig.ts +98 -0
- package/src/types/types/PackOpenHolderState.ts +120 -0
- package/src/types/types/PackRule.ts +85 -0
- package/src/types/types/PackState.ts +118 -0
- package/src/types/types/PackType.ts +118 -0
- package/src/types/types/PaymentClass.ts +118 -0
- package/src/types/types/PoolAccess.ts +88 -0
- package/src/types/types/PoolState.ts +88 -0
- package/src/types/types/PoolType.ts +88 -0
- package/src/types/types/Popularity.ts +76 -0
- package/src/types/types/PopularityState.ts +630 -0
- package/src/types/types/PreviousDonationRecord.ts +76 -0
- package/src/types/types/Price.ts +64 -0
- package/src/types/types/PriceRule.ts +216 -0
- package/src/types/types/RecoverDeposit.ts +56 -0
- package/src/types/types/Rule.ts +199 -0
- package/src/types/types/SaleConfig.ts +102 -0
- package/src/types/types/SaleTrack.ts +85 -0
- package/src/types/types/SaleType.ts +148 -0
- package/src/types/types/Seed.ts +61 -0
- package/src/types/types/SelectedCard.ts +61 -0
- package/src/types/types/SelectedZeroCard.ts +61 -0
- package/src/types/types/SemiFungibleTraitInit.ts +61 -0
- package/src/types/types/SemiFungibleTraitInitMap.ts +72 -0
- package/src/types/types/ShortCreator.ts +64 -0
- package/src/types/types/ShortMetadata.ts +145 -0
- package/src/types/types/ShortMetadataArgs.ts +111 -0
- package/src/types/types/StoreConfig.ts +98 -0
- package/src/types/types/StoreRule.ts +145 -0
- package/src/types/types/SuperCategory.ts +61 -0
- package/src/types/types/TightCardMetadata.ts +120 -0
- package/src/types/types/TimeRangeType.ts +120 -0
- package/src/types/types/TimedPerWalletArgs.ts +53 -0
- package/src/types/types/TokenMetadata.ts +72 -0
- package/src/types/types/TokenProgramVersion.ts +90 -0
- package/src/types/types/TokenStandard.ts +150 -0
- package/src/types/types/TokenState.ts +88 -0
- package/src/types/types/TokenType.ts +88 -0
- package/src/types/types/TotalPerTimeArgs.ts +85 -0
- package/src/types/types/TotalPerTimeWalletArgs.ts +61 -0
- package/src/types/types/TrackRegistry.ts +90 -0
- package/src/types/types/TraitInit.ts +210 -0
- package/src/types/types/TraitPass.ts +60 -0
- package/src/types/types/TraitPassType.ts +225 -0
- package/src/types/types/TraitType.ts +267 -0
- package/src/types/types/TraitValue.ts +72 -0
- package/src/types/types/UnlocksAfter.ts +172 -0
- package/src/types/types/UnwrapMetadata.ts +156 -0
- package/src/types/types/UseMethod.ts +118 -0
- package/src/types/types/Uses.ts +76 -0
- package/src/types/types/VerifyCollectionMetadata.ts +109 -0
- package/src/types/types/VolumeTrack.ts +61 -0
- package/src/types/types/WrappedSource.ts +85 -0
- package/src/types/types/ZeroConfig.ts +85 -0
- package/src/types/types/index.ts +798 -0
- package/src/utility/Connection.ts +9 -0
- package/src/utility/Holders.ts +8 -0
- package/src/utility/PdaManager.ts +230 -0
- package/src/utility/config.ts +32 -0
- package/src/utility/utils.ts +191 -0
- package/src/utility/validation.ts +229 -0
- package/tsconfig.json +12 -0
@@ -0,0 +1,87 @@
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
6
|
+
|
7
|
+
export interface ItemReserveListFields {
|
8
|
+
queue: PublicKey
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface ItemReserveListJSON {
|
12
|
+
queue: string
|
13
|
+
}
|
14
|
+
|
15
|
+
export class ItemReserveList {
|
16
|
+
readonly queue: PublicKey
|
17
|
+
|
18
|
+
static readonly discriminator = Buffer.from([
|
19
|
+
91, 20, 28, 149, 203, 38, 189, 82,
|
20
|
+
])
|
21
|
+
|
22
|
+
static readonly layout = borsh.struct([borsh.publicKey("queue")])
|
23
|
+
|
24
|
+
constructor(fields: ItemReserveListFields) {
|
25
|
+
this.queue = fields.queue
|
26
|
+
}
|
27
|
+
|
28
|
+
static async fetch(
|
29
|
+
c: Connection,
|
30
|
+
address: PublicKey,
|
31
|
+
programId: PublicKey = PROGRAM_ID
|
32
|
+
): Promise<ItemReserveList | null> {
|
33
|
+
const info = await c.getAccountInfo(address)
|
34
|
+
|
35
|
+
if (info === null) {
|
36
|
+
return null
|
37
|
+
}
|
38
|
+
if (!info.owner.equals(programId)) {
|
39
|
+
throw new Error("account doesn't belong to this program")
|
40
|
+
}
|
41
|
+
|
42
|
+
return this.decode(info.data)
|
43
|
+
}
|
44
|
+
|
45
|
+
static async fetchMultiple(
|
46
|
+
c: Connection,
|
47
|
+
addresses: PublicKey[],
|
48
|
+
programId: PublicKey = PROGRAM_ID
|
49
|
+
): Promise<Array<ItemReserveList | null>> {
|
50
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
51
|
+
|
52
|
+
return infos.map((info) => {
|
53
|
+
if (info === null) {
|
54
|
+
return null
|
55
|
+
}
|
56
|
+
if (!info.owner.equals(programId)) {
|
57
|
+
throw new Error("account doesn't belong to this program")
|
58
|
+
}
|
59
|
+
|
60
|
+
return this.decode(info.data)
|
61
|
+
})
|
62
|
+
}
|
63
|
+
|
64
|
+
static decode(data: Buffer): ItemReserveList {
|
65
|
+
if (!data.slice(0, 8).equals(ItemReserveList.discriminator)) {
|
66
|
+
throw new Error("invalid account discriminator")
|
67
|
+
}
|
68
|
+
|
69
|
+
const dec = ItemReserveList.layout.decode(data.slice(8))
|
70
|
+
|
71
|
+
return new ItemReserveList({
|
72
|
+
queue: dec.queue,
|
73
|
+
})
|
74
|
+
}
|
75
|
+
|
76
|
+
toJSON(): ItemReserveListJSON {
|
77
|
+
return {
|
78
|
+
queue: this.queue.toString(),
|
79
|
+
}
|
80
|
+
}
|
81
|
+
|
82
|
+
static fromJSON(obj: ItemReserveListJSON): ItemReserveList {
|
83
|
+
return new ItemReserveList({
|
84
|
+
queue: new PublicKey(obj.queue),
|
85
|
+
})
|
86
|
+
}
|
87
|
+
}
|
@@ -0,0 +1,73 @@
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
6
|
+
|
7
|
+
export interface ItemReserveList2Fields {}
|
8
|
+
|
9
|
+
export interface ItemReserveList2JSON {}
|
10
|
+
|
11
|
+
export class ItemReserveList2 {
|
12
|
+
static readonly discriminator = Buffer.from([
|
13
|
+
228, 108, 231, 95, 72, 92, 29, 53,
|
14
|
+
])
|
15
|
+
|
16
|
+
static readonly layout = borsh.struct([])
|
17
|
+
|
18
|
+
constructor(fields: ItemReserveList2Fields) {}
|
19
|
+
|
20
|
+
static async fetch(
|
21
|
+
c: Connection,
|
22
|
+
address: PublicKey,
|
23
|
+
programId: PublicKey = PROGRAM_ID
|
24
|
+
): Promise<ItemReserveList2 | null> {
|
25
|
+
const info = await c.getAccountInfo(address)
|
26
|
+
|
27
|
+
if (info === null) {
|
28
|
+
return null
|
29
|
+
}
|
30
|
+
if (!info.owner.equals(programId)) {
|
31
|
+
throw new Error("account doesn't belong to this program")
|
32
|
+
}
|
33
|
+
|
34
|
+
return this.decode(info.data)
|
35
|
+
}
|
36
|
+
|
37
|
+
static async fetchMultiple(
|
38
|
+
c: Connection,
|
39
|
+
addresses: PublicKey[],
|
40
|
+
programId: PublicKey = PROGRAM_ID
|
41
|
+
): Promise<Array<ItemReserveList2 | null>> {
|
42
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
43
|
+
|
44
|
+
return infos.map((info) => {
|
45
|
+
if (info === null) {
|
46
|
+
return null
|
47
|
+
}
|
48
|
+
if (!info.owner.equals(programId)) {
|
49
|
+
throw new Error("account doesn't belong to this program")
|
50
|
+
}
|
51
|
+
|
52
|
+
return this.decode(info.data)
|
53
|
+
})
|
54
|
+
}
|
55
|
+
|
56
|
+
static decode(data: Buffer): ItemReserveList2 {
|
57
|
+
if (!data.slice(0, 8).equals(ItemReserveList2.discriminator)) {
|
58
|
+
throw new Error("invalid account discriminator")
|
59
|
+
}
|
60
|
+
|
61
|
+
const dec = ItemReserveList2.layout.decode(data.slice(8))
|
62
|
+
|
63
|
+
return new ItemReserveList2({})
|
64
|
+
}
|
65
|
+
|
66
|
+
toJSON(): ItemReserveList2JSON {
|
67
|
+
return {}
|
68
|
+
}
|
69
|
+
|
70
|
+
static fromJSON(obj: ItemReserveList2JSON): ItemReserveList2 {
|
71
|
+
return new ItemReserveList2({})
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,97 @@
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
6
|
+
|
7
|
+
export interface LutVaultFields {
|
8
|
+
address: PublicKey
|
9
|
+
creator: PublicKey
|
10
|
+
}
|
11
|
+
|
12
|
+
export interface LutVaultJSON {
|
13
|
+
address: string
|
14
|
+
creator: string
|
15
|
+
}
|
16
|
+
|
17
|
+
export class LutVault {
|
18
|
+
readonly address: PublicKey
|
19
|
+
readonly creator: PublicKey
|
20
|
+
|
21
|
+
static readonly discriminator = Buffer.from([
|
22
|
+
156, 232, 87, 247, 4, 41, 107, 182,
|
23
|
+
])
|
24
|
+
|
25
|
+
static readonly layout = borsh.struct([
|
26
|
+
borsh.publicKey("address"),
|
27
|
+
borsh.publicKey("creator"),
|
28
|
+
])
|
29
|
+
|
30
|
+
constructor(fields: LutVaultFields) {
|
31
|
+
this.address = fields.address
|
32
|
+
this.creator = fields.creator
|
33
|
+
}
|
34
|
+
|
35
|
+
static async fetch(
|
36
|
+
c: Connection,
|
37
|
+
address: PublicKey,
|
38
|
+
programId: PublicKey = PROGRAM_ID
|
39
|
+
): Promise<LutVault | null> {
|
40
|
+
const info = await c.getAccountInfo(address)
|
41
|
+
|
42
|
+
if (info === null) {
|
43
|
+
return null
|
44
|
+
}
|
45
|
+
if (!info.owner.equals(programId)) {
|
46
|
+
throw new Error("account doesn't belong to this program")
|
47
|
+
}
|
48
|
+
|
49
|
+
return this.decode(info.data)
|
50
|
+
}
|
51
|
+
|
52
|
+
static async fetchMultiple(
|
53
|
+
c: Connection,
|
54
|
+
addresses: PublicKey[],
|
55
|
+
programId: PublicKey = PROGRAM_ID
|
56
|
+
): Promise<Array<LutVault | null>> {
|
57
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
58
|
+
|
59
|
+
return infos.map((info) => {
|
60
|
+
if (info === null) {
|
61
|
+
return null
|
62
|
+
}
|
63
|
+
if (!info.owner.equals(programId)) {
|
64
|
+
throw new Error("account doesn't belong to this program")
|
65
|
+
}
|
66
|
+
|
67
|
+
return this.decode(info.data)
|
68
|
+
})
|
69
|
+
}
|
70
|
+
|
71
|
+
static decode(data: Buffer): LutVault {
|
72
|
+
if (!data.slice(0, 8).equals(LutVault.discriminator)) {
|
73
|
+
throw new Error("invalid account discriminator")
|
74
|
+
}
|
75
|
+
|
76
|
+
const dec = LutVault.layout.decode(data.slice(8))
|
77
|
+
|
78
|
+
return new LutVault({
|
79
|
+
address: dec.address,
|
80
|
+
creator: dec.creator,
|
81
|
+
})
|
82
|
+
}
|
83
|
+
|
84
|
+
toJSON(): LutVaultJSON {
|
85
|
+
return {
|
86
|
+
address: this.address.toString(),
|
87
|
+
creator: this.creator.toString(),
|
88
|
+
}
|
89
|
+
}
|
90
|
+
|
91
|
+
static fromJSON(obj: LutVaultJSON): LutVault {
|
92
|
+
return new LutVault({
|
93
|
+
address: new PublicKey(obj.address),
|
94
|
+
creator: new PublicKey(obj.creator),
|
95
|
+
})
|
96
|
+
}
|
97
|
+
}
|
@@ -0,0 +1,367 @@
|
|
1
|
+
import { PublicKey, Connection } from "@solana/web3.js"
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as borsh from "@coral-xyz/borsh" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
5
|
+
import { PROGRAM_ID } from "../programId"
|
6
|
+
|
7
|
+
export interface PackFields {
|
8
|
+
class: types.AccountClassKind
|
9
|
+
globalState: types.GlobalStateKind
|
10
|
+
holder: PublicKey
|
11
|
+
creator: PublicKey
|
12
|
+
dates: types.IndexDatesFields
|
13
|
+
category: types.CategoryFields
|
14
|
+
superCategory: types.SuperCategoryFields
|
15
|
+
eventCategory: number
|
16
|
+
trackType: types.TrackRegistryKind
|
17
|
+
mainCurrencyHash: BN
|
18
|
+
track: types.ItemTrackFields
|
19
|
+
popularity: types.PopularityFields
|
20
|
+
filtering: types.FilterFields
|
21
|
+
page: BN
|
22
|
+
manager: PublicKey
|
23
|
+
isServerless: number
|
24
|
+
availableOption: number
|
25
|
+
hasWrappedTokens: number
|
26
|
+
burntPieces: number
|
27
|
+
flag: Array<number>
|
28
|
+
item: types.ItemFields
|
29
|
+
count: BN
|
30
|
+
live: BN
|
31
|
+
available: BN
|
32
|
+
printed: BN
|
33
|
+
saleConfig: types.SaleConfigFields
|
34
|
+
opened: BN
|
35
|
+
owed: BN
|
36
|
+
identifier: BN
|
37
|
+
hash: BN
|
38
|
+
hashTraits: BN
|
39
|
+
packConfig: types.PackConfigFields
|
40
|
+
volume: Array<types.FakeVolumeTrackFields>
|
41
|
+
delegate: Array<PublicKey>
|
42
|
+
extra: Array<number>
|
43
|
+
}
|
44
|
+
|
45
|
+
export interface PackJSON {
|
46
|
+
class: types.AccountClassJSON
|
47
|
+
globalState: types.GlobalStateJSON
|
48
|
+
holder: string
|
49
|
+
creator: string
|
50
|
+
dates: types.IndexDatesJSON
|
51
|
+
category: types.CategoryJSON
|
52
|
+
superCategory: types.SuperCategoryJSON
|
53
|
+
eventCategory: number
|
54
|
+
trackType: types.TrackRegistryJSON
|
55
|
+
mainCurrencyHash: string
|
56
|
+
track: types.ItemTrackJSON
|
57
|
+
popularity: types.PopularityJSON
|
58
|
+
filtering: types.FilterJSON
|
59
|
+
page: string
|
60
|
+
manager: string
|
61
|
+
isServerless: number
|
62
|
+
availableOption: number
|
63
|
+
hasWrappedTokens: number
|
64
|
+
burntPieces: number
|
65
|
+
flag: Array<number>
|
66
|
+
item: types.ItemJSON
|
67
|
+
count: string
|
68
|
+
live: string
|
69
|
+
available: string
|
70
|
+
printed: string
|
71
|
+
saleConfig: types.SaleConfigJSON
|
72
|
+
opened: string
|
73
|
+
owed: string
|
74
|
+
identifier: string
|
75
|
+
hash: string
|
76
|
+
hashTraits: string
|
77
|
+
packConfig: types.PackConfigJSON
|
78
|
+
volume: Array<types.FakeVolumeTrackJSON>
|
79
|
+
delegate: Array<string>
|
80
|
+
extra: Array<number>
|
81
|
+
}
|
82
|
+
|
83
|
+
export class Pack {
|
84
|
+
readonly class: types.AccountClassKind
|
85
|
+
readonly globalState: types.GlobalStateKind
|
86
|
+
readonly holder: PublicKey
|
87
|
+
readonly creator: PublicKey
|
88
|
+
readonly dates: types.IndexDates
|
89
|
+
readonly category: types.Category
|
90
|
+
readonly superCategory: types.SuperCategory
|
91
|
+
readonly eventCategory: number
|
92
|
+
readonly trackType: types.TrackRegistryKind
|
93
|
+
readonly mainCurrencyHash: BN
|
94
|
+
readonly track: types.ItemTrack
|
95
|
+
readonly popularity: types.Popularity
|
96
|
+
readonly filtering: types.Filter
|
97
|
+
readonly page: BN
|
98
|
+
readonly manager: PublicKey
|
99
|
+
readonly isServerless: number
|
100
|
+
readonly availableOption: number
|
101
|
+
readonly hasWrappedTokens: number
|
102
|
+
readonly burntPieces: number
|
103
|
+
readonly flag: Array<number>
|
104
|
+
readonly item: types.Item
|
105
|
+
readonly count: BN
|
106
|
+
readonly live: BN
|
107
|
+
readonly available: BN
|
108
|
+
readonly printed: BN
|
109
|
+
readonly saleConfig: types.SaleConfig
|
110
|
+
readonly opened: BN
|
111
|
+
readonly owed: BN
|
112
|
+
readonly identifier: BN
|
113
|
+
readonly hash: BN
|
114
|
+
readonly hashTraits: BN
|
115
|
+
readonly packConfig: types.PackConfig
|
116
|
+
readonly volume: Array<types.FakeVolumeTrack>
|
117
|
+
readonly delegate: Array<PublicKey>
|
118
|
+
readonly extra: Array<number>
|
119
|
+
|
120
|
+
static readonly discriminator = Buffer.from([
|
121
|
+
244, 192, 97, 212, 134, 91, 198, 200,
|
122
|
+
])
|
123
|
+
|
124
|
+
static readonly layout = borsh.struct([
|
125
|
+
types.AccountClass.layout("class"),
|
126
|
+
types.GlobalState.layout("globalState"),
|
127
|
+
borsh.publicKey("holder"),
|
128
|
+
borsh.publicKey("creator"),
|
129
|
+
types.IndexDates.layout("dates"),
|
130
|
+
types.Category.layout("category"),
|
131
|
+
types.SuperCategory.layout("superCategory"),
|
132
|
+
borsh.u16("eventCategory"),
|
133
|
+
types.TrackRegistry.layout("trackType"),
|
134
|
+
borsh.u64("mainCurrencyHash"),
|
135
|
+
types.ItemTrack.layout("track"),
|
136
|
+
types.Popularity.layout("popularity"),
|
137
|
+
types.Filter.layout("filtering"),
|
138
|
+
borsh.u64("page"),
|
139
|
+
borsh.publicKey("manager"),
|
140
|
+
borsh.u8("isServerless"),
|
141
|
+
borsh.u8("availableOption"),
|
142
|
+
borsh.u8("hasWrappedTokens"),
|
143
|
+
borsh.u32("burntPieces"),
|
144
|
+
borsh.array(borsh.u8(), 1, "flag"),
|
145
|
+
types.Item.layout("item"),
|
146
|
+
borsh.u64("count"),
|
147
|
+
borsh.u64("live"),
|
148
|
+
borsh.u64("available"),
|
149
|
+
borsh.u64("printed"),
|
150
|
+
types.SaleConfig.layout("saleConfig"),
|
151
|
+
borsh.u64("opened"),
|
152
|
+
borsh.u64("owed"),
|
153
|
+
borsh.u64("identifier"),
|
154
|
+
borsh.u64("hash"),
|
155
|
+
borsh.u64("hashTraits"),
|
156
|
+
types.PackConfig.layout("packConfig"),
|
157
|
+
borsh.vec(types.FakeVolumeTrack.layout(), "volume"),
|
158
|
+
borsh.vec(borsh.publicKey(), "delegate"),
|
159
|
+
borsh.array(borsh.u8(), 4, "extra"),
|
160
|
+
])
|
161
|
+
|
162
|
+
constructor(fields: PackFields) {
|
163
|
+
this.class = fields.class
|
164
|
+
this.globalState = fields.globalState
|
165
|
+
this.holder = fields.holder
|
166
|
+
this.creator = fields.creator
|
167
|
+
this.dates = new types.IndexDates({ ...fields.dates })
|
168
|
+
this.category = new types.Category({ ...fields.category })
|
169
|
+
this.superCategory = new types.SuperCategory({ ...fields.superCategory })
|
170
|
+
this.eventCategory = fields.eventCategory
|
171
|
+
this.trackType = fields.trackType
|
172
|
+
this.mainCurrencyHash = fields.mainCurrencyHash
|
173
|
+
this.track = new types.ItemTrack({ ...fields.track })
|
174
|
+
this.popularity = new types.Popularity({ ...fields.popularity })
|
175
|
+
this.filtering = new types.Filter({ ...fields.filtering })
|
176
|
+
this.page = fields.page
|
177
|
+
this.manager = fields.manager
|
178
|
+
this.isServerless = fields.isServerless
|
179
|
+
this.availableOption = fields.availableOption
|
180
|
+
this.hasWrappedTokens = fields.hasWrappedTokens
|
181
|
+
this.burntPieces = fields.burntPieces
|
182
|
+
this.flag = fields.flag
|
183
|
+
this.item = new types.Item({ ...fields.item })
|
184
|
+
this.count = fields.count
|
185
|
+
this.live = fields.live
|
186
|
+
this.available = fields.available
|
187
|
+
this.printed = fields.printed
|
188
|
+
this.saleConfig = new types.SaleConfig({ ...fields.saleConfig })
|
189
|
+
this.opened = fields.opened
|
190
|
+
this.owed = fields.owed
|
191
|
+
this.identifier = fields.identifier
|
192
|
+
this.hash = fields.hash
|
193
|
+
this.hashTraits = fields.hashTraits
|
194
|
+
this.packConfig = new types.PackConfig({ ...fields.packConfig })
|
195
|
+
this.volume = fields.volume.map(
|
196
|
+
(item) => new types.FakeVolumeTrack({ ...item })
|
197
|
+
)
|
198
|
+
this.delegate = fields.delegate
|
199
|
+
this.extra = fields.extra
|
200
|
+
}
|
201
|
+
|
202
|
+
static async fetch(
|
203
|
+
c: Connection,
|
204
|
+
address: PublicKey,
|
205
|
+
programId: PublicKey = PROGRAM_ID
|
206
|
+
): Promise<Pack | null> {
|
207
|
+
const info = await c.getAccountInfo(address)
|
208
|
+
|
209
|
+
if (info === null) {
|
210
|
+
return null
|
211
|
+
}
|
212
|
+
if (!info.owner.equals(programId)) {
|
213
|
+
throw new Error("account doesn't belong to this program")
|
214
|
+
}
|
215
|
+
|
216
|
+
return this.decode(info.data)
|
217
|
+
}
|
218
|
+
|
219
|
+
static async fetchMultiple(
|
220
|
+
c: Connection,
|
221
|
+
addresses: PublicKey[],
|
222
|
+
programId: PublicKey = PROGRAM_ID
|
223
|
+
): Promise<Array<Pack | null>> {
|
224
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
225
|
+
|
226
|
+
return infos.map((info) => {
|
227
|
+
if (info === null) {
|
228
|
+
return null
|
229
|
+
}
|
230
|
+
if (!info.owner.equals(programId)) {
|
231
|
+
throw new Error("account doesn't belong to this program")
|
232
|
+
}
|
233
|
+
|
234
|
+
return this.decode(info.data)
|
235
|
+
})
|
236
|
+
}
|
237
|
+
|
238
|
+
static decode(data: Buffer): Pack {
|
239
|
+
if (!data.slice(0, 8).equals(Pack.discriminator)) {
|
240
|
+
throw new Error("invalid account discriminator")
|
241
|
+
}
|
242
|
+
|
243
|
+
const dec = Pack.layout.decode(data.slice(8))
|
244
|
+
|
245
|
+
return new Pack({
|
246
|
+
class: types.AccountClass.fromDecoded(dec.class),
|
247
|
+
globalState: types.GlobalState.fromDecoded(dec.globalState),
|
248
|
+
holder: dec.holder,
|
249
|
+
creator: dec.creator,
|
250
|
+
dates: types.IndexDates.fromDecoded(dec.dates),
|
251
|
+
category: types.Category.fromDecoded(dec.category),
|
252
|
+
superCategory: types.SuperCategory.fromDecoded(dec.superCategory),
|
253
|
+
eventCategory: dec.eventCategory,
|
254
|
+
trackType: types.TrackRegistry.fromDecoded(dec.trackType),
|
255
|
+
mainCurrencyHash: dec.mainCurrencyHash,
|
256
|
+
track: types.ItemTrack.fromDecoded(dec.track),
|
257
|
+
popularity: types.Popularity.fromDecoded(dec.popularity),
|
258
|
+
filtering: types.Filter.fromDecoded(dec.filtering),
|
259
|
+
page: dec.page,
|
260
|
+
manager: dec.manager,
|
261
|
+
isServerless: dec.isServerless,
|
262
|
+
availableOption: dec.availableOption,
|
263
|
+
hasWrappedTokens: dec.hasWrappedTokens,
|
264
|
+
burntPieces: dec.burntPieces,
|
265
|
+
flag: dec.flag,
|
266
|
+
item: types.Item.fromDecoded(dec.item),
|
267
|
+
count: dec.count,
|
268
|
+
live: dec.live,
|
269
|
+
available: dec.available,
|
270
|
+
printed: dec.printed,
|
271
|
+
saleConfig: types.SaleConfig.fromDecoded(dec.saleConfig),
|
272
|
+
opened: dec.opened,
|
273
|
+
owed: dec.owed,
|
274
|
+
identifier: dec.identifier,
|
275
|
+
hash: dec.hash,
|
276
|
+
hashTraits: dec.hashTraits,
|
277
|
+
packConfig: types.PackConfig.fromDecoded(dec.packConfig),
|
278
|
+
volume: dec.volume.map(
|
279
|
+
(
|
280
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
281
|
+
) => types.FakeVolumeTrack.fromDecoded(item)
|
282
|
+
),
|
283
|
+
delegate: dec.delegate,
|
284
|
+
extra: dec.extra,
|
285
|
+
})
|
286
|
+
}
|
287
|
+
|
288
|
+
toJSON(): PackJSON {
|
289
|
+
return {
|
290
|
+
class: this.class.toJSON(),
|
291
|
+
globalState: this.globalState.toJSON(),
|
292
|
+
holder: this.holder.toString(),
|
293
|
+
creator: this.creator.toString(),
|
294
|
+
dates: this.dates.toJSON(),
|
295
|
+
category: this.category.toJSON(),
|
296
|
+
superCategory: this.superCategory.toJSON(),
|
297
|
+
eventCategory: this.eventCategory,
|
298
|
+
trackType: this.trackType.toJSON(),
|
299
|
+
mainCurrencyHash: this.mainCurrencyHash.toString(),
|
300
|
+
track: this.track.toJSON(),
|
301
|
+
popularity: this.popularity.toJSON(),
|
302
|
+
filtering: this.filtering.toJSON(),
|
303
|
+
page: this.page.toString(),
|
304
|
+
manager: this.manager.toString(),
|
305
|
+
isServerless: this.isServerless,
|
306
|
+
availableOption: this.availableOption,
|
307
|
+
hasWrappedTokens: this.hasWrappedTokens,
|
308
|
+
burntPieces: this.burntPieces,
|
309
|
+
flag: this.flag,
|
310
|
+
item: this.item.toJSON(),
|
311
|
+
count: this.count.toString(),
|
312
|
+
live: this.live.toString(),
|
313
|
+
available: this.available.toString(),
|
314
|
+
printed: this.printed.toString(),
|
315
|
+
saleConfig: this.saleConfig.toJSON(),
|
316
|
+
opened: this.opened.toString(),
|
317
|
+
owed: this.owed.toString(),
|
318
|
+
identifier: this.identifier.toString(),
|
319
|
+
hash: this.hash.toString(),
|
320
|
+
hashTraits: this.hashTraits.toString(),
|
321
|
+
packConfig: this.packConfig.toJSON(),
|
322
|
+
volume: this.volume.map((item) => item.toJSON()),
|
323
|
+
delegate: this.delegate.map((item) => item.toString()),
|
324
|
+
extra: this.extra,
|
325
|
+
}
|
326
|
+
}
|
327
|
+
|
328
|
+
static fromJSON(obj: PackJSON): Pack {
|
329
|
+
return new Pack({
|
330
|
+
class: types.AccountClass.fromJSON(obj.class),
|
331
|
+
globalState: types.GlobalState.fromJSON(obj.globalState),
|
332
|
+
holder: new PublicKey(obj.holder),
|
333
|
+
creator: new PublicKey(obj.creator),
|
334
|
+
dates: types.IndexDates.fromJSON(obj.dates),
|
335
|
+
category: types.Category.fromJSON(obj.category),
|
336
|
+
superCategory: types.SuperCategory.fromJSON(obj.superCategory),
|
337
|
+
eventCategory: obj.eventCategory,
|
338
|
+
trackType: types.TrackRegistry.fromJSON(obj.trackType),
|
339
|
+
mainCurrencyHash: new BN(obj.mainCurrencyHash),
|
340
|
+
track: types.ItemTrack.fromJSON(obj.track),
|
341
|
+
popularity: types.Popularity.fromJSON(obj.popularity),
|
342
|
+
filtering: types.Filter.fromJSON(obj.filtering),
|
343
|
+
page: new BN(obj.page),
|
344
|
+
manager: new PublicKey(obj.manager),
|
345
|
+
isServerless: obj.isServerless,
|
346
|
+
availableOption: obj.availableOption,
|
347
|
+
hasWrappedTokens: obj.hasWrappedTokens,
|
348
|
+
burntPieces: obj.burntPieces,
|
349
|
+
flag: obj.flag,
|
350
|
+
item: types.Item.fromJSON(obj.item),
|
351
|
+
count: new BN(obj.count),
|
352
|
+
live: new BN(obj.live),
|
353
|
+
available: new BN(obj.available),
|
354
|
+
printed: new BN(obj.printed),
|
355
|
+
saleConfig: types.SaleConfig.fromJSON(obj.saleConfig),
|
356
|
+
opened: new BN(obj.opened),
|
357
|
+
owed: new BN(obj.owed),
|
358
|
+
identifier: new BN(obj.identifier),
|
359
|
+
hash: new BN(obj.hash),
|
360
|
+
hashTraits: new BN(obj.hashTraits),
|
361
|
+
packConfig: types.PackConfig.fromJSON(obj.packConfig),
|
362
|
+
volume: obj.volume.map((item) => types.FakeVolumeTrack.fromJSON(item)),
|
363
|
+
delegate: obj.delegate.map((item) => new PublicKey(item)),
|
364
|
+
extra: obj.extra,
|
365
|
+
})
|
366
|
+
}
|
367
|
+
}
|