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,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 ZeroCardFields {}
|
8
|
+
|
9
|
+
export interface ZeroCardJSON {}
|
10
|
+
|
11
|
+
export class ZeroCard {
|
12
|
+
static readonly discriminator = Buffer.from([
|
13
|
+
31, 109, 105, 105, 213, 228, 142, 232,
|
14
|
+
])
|
15
|
+
|
16
|
+
static readonly layout = borsh.struct([])
|
17
|
+
|
18
|
+
constructor(fields: ZeroCardFields) {}
|
19
|
+
|
20
|
+
static async fetch(
|
21
|
+
c: Connection,
|
22
|
+
address: PublicKey,
|
23
|
+
programId: PublicKey = PROGRAM_ID
|
24
|
+
): Promise<ZeroCard | 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<ZeroCard | 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): ZeroCard {
|
57
|
+
if (!data.slice(0, 8).equals(ZeroCard.discriminator)) {
|
58
|
+
throw new Error("invalid account discriminator")
|
59
|
+
}
|
60
|
+
|
61
|
+
const dec = ZeroCard.layout.decode(data.slice(8))
|
62
|
+
|
63
|
+
return new ZeroCard({})
|
64
|
+
}
|
65
|
+
|
66
|
+
toJSON(): ZeroCardJSON {
|
67
|
+
return {}
|
68
|
+
}
|
69
|
+
|
70
|
+
static fromJSON(obj: ZeroCardJSON): ZeroCard {
|
71
|
+
return new ZeroCard({})
|
72
|
+
}
|
73
|
+
}
|
@@ -0,0 +1,89 @@
|
|
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 ZeroContentFields {
|
8
|
+
cards: Array<number>
|
9
|
+
}
|
10
|
+
|
11
|
+
export interface ZeroContentJSON {
|
12
|
+
cards: Array<number>
|
13
|
+
}
|
14
|
+
|
15
|
+
export class ZeroContent {
|
16
|
+
readonly cards: Array<number>
|
17
|
+
|
18
|
+
static readonly discriminator = Buffer.from([
|
19
|
+
60, 71, 181, 209, 154, 77, 4, 225,
|
20
|
+
])
|
21
|
+
|
22
|
+
static readonly layout = borsh.struct([
|
23
|
+
borsh.array(borsh.u8(), 10000000, "cards"),
|
24
|
+
])
|
25
|
+
|
26
|
+
constructor(fields: ZeroContentFields) {
|
27
|
+
this.cards = fields.cards
|
28
|
+
}
|
29
|
+
|
30
|
+
static async fetch(
|
31
|
+
c: Connection,
|
32
|
+
address: PublicKey,
|
33
|
+
programId: PublicKey = PROGRAM_ID
|
34
|
+
): Promise<ZeroContent | null> {
|
35
|
+
const info = await c.getAccountInfo(address)
|
36
|
+
|
37
|
+
if (info === null) {
|
38
|
+
return null
|
39
|
+
}
|
40
|
+
if (!info.owner.equals(programId)) {
|
41
|
+
throw new Error("account doesn't belong to this program")
|
42
|
+
}
|
43
|
+
|
44
|
+
return this.decode(info.data)
|
45
|
+
}
|
46
|
+
|
47
|
+
static async fetchMultiple(
|
48
|
+
c: Connection,
|
49
|
+
addresses: PublicKey[],
|
50
|
+
programId: PublicKey = PROGRAM_ID
|
51
|
+
): Promise<Array<ZeroContent | null>> {
|
52
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
53
|
+
|
54
|
+
return infos.map((info) => {
|
55
|
+
if (info === null) {
|
56
|
+
return null
|
57
|
+
}
|
58
|
+
if (!info.owner.equals(programId)) {
|
59
|
+
throw new Error("account doesn't belong to this program")
|
60
|
+
}
|
61
|
+
|
62
|
+
return this.decode(info.data)
|
63
|
+
})
|
64
|
+
}
|
65
|
+
|
66
|
+
static decode(data: Buffer): ZeroContent {
|
67
|
+
if (!data.slice(0, 8).equals(ZeroContent.discriminator)) {
|
68
|
+
throw new Error("invalid account discriminator")
|
69
|
+
}
|
70
|
+
|
71
|
+
const dec = ZeroContent.layout.decode(data.slice(8))
|
72
|
+
|
73
|
+
return new ZeroContent({
|
74
|
+
cards: dec.cards,
|
75
|
+
})
|
76
|
+
}
|
77
|
+
|
78
|
+
toJSON(): ZeroContentJSON {
|
79
|
+
return {
|
80
|
+
cards: this.cards,
|
81
|
+
}
|
82
|
+
}
|
83
|
+
|
84
|
+
static fromJSON(obj: ZeroContentJSON): ZeroContent {
|
85
|
+
return new ZeroContent({
|
86
|
+
cards: obj.cards,
|
87
|
+
})
|
88
|
+
}
|
89
|
+
}
|
@@ -0,0 +1,183 @@
|
|
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 ZeroOpenHolderFields {
|
8
|
+
class: types.AccountClassKind
|
9
|
+
storeHalfHash: Array<number>
|
10
|
+
state: types.PackOpenHolderStateKind
|
11
|
+
paidFee: number
|
12
|
+
pack: PublicKey
|
13
|
+
creator: PublicKey
|
14
|
+
claimer: PublicKey
|
15
|
+
randomBase: BN
|
16
|
+
packType: types.PackTypeKind
|
17
|
+
sendToVault: types.MemeVaultProofFields | null
|
18
|
+
items: Array<types.SelectedZeroCardFields>
|
19
|
+
}
|
20
|
+
|
21
|
+
export interface ZeroOpenHolderJSON {
|
22
|
+
class: types.AccountClassJSON
|
23
|
+
storeHalfHash: Array<number>
|
24
|
+
state: types.PackOpenHolderStateJSON
|
25
|
+
paidFee: number
|
26
|
+
pack: string
|
27
|
+
creator: string
|
28
|
+
claimer: string
|
29
|
+
randomBase: string
|
30
|
+
packType: types.PackTypeJSON
|
31
|
+
sendToVault: types.MemeVaultProofJSON | null
|
32
|
+
items: Array<types.SelectedZeroCardJSON>
|
33
|
+
}
|
34
|
+
|
35
|
+
export class ZeroOpenHolder {
|
36
|
+
readonly class: types.AccountClassKind
|
37
|
+
readonly storeHalfHash: Array<number>
|
38
|
+
readonly state: types.PackOpenHolderStateKind
|
39
|
+
readonly paidFee: number
|
40
|
+
readonly pack: PublicKey
|
41
|
+
readonly creator: PublicKey
|
42
|
+
readonly claimer: PublicKey
|
43
|
+
readonly randomBase: BN
|
44
|
+
readonly packType: types.PackTypeKind
|
45
|
+
readonly sendToVault: types.MemeVaultProof | null
|
46
|
+
readonly items: Array<types.SelectedZeroCard>
|
47
|
+
|
48
|
+
static readonly discriminator = Buffer.from([
|
49
|
+
106, 194, 12, 193, 165, 210, 56, 2,
|
50
|
+
])
|
51
|
+
|
52
|
+
static readonly layout = borsh.struct([
|
53
|
+
types.AccountClass.layout("class"),
|
54
|
+
borsh.array(borsh.u8(), 4, "storeHalfHash"),
|
55
|
+
types.PackOpenHolderState.layout("state"),
|
56
|
+
borsh.u8("paidFee"),
|
57
|
+
borsh.publicKey("pack"),
|
58
|
+
borsh.publicKey("creator"),
|
59
|
+
borsh.publicKey("claimer"),
|
60
|
+
borsh.u64("randomBase"),
|
61
|
+
types.PackType.layout("packType"),
|
62
|
+
borsh.option(types.MemeVaultProof.layout(), "sendToVault"),
|
63
|
+
borsh.vec(types.SelectedZeroCard.layout(), "items"),
|
64
|
+
])
|
65
|
+
|
66
|
+
constructor(fields: ZeroOpenHolderFields) {
|
67
|
+
this.class = fields.class
|
68
|
+
this.storeHalfHash = fields.storeHalfHash
|
69
|
+
this.state = fields.state
|
70
|
+
this.paidFee = fields.paidFee
|
71
|
+
this.pack = fields.pack
|
72
|
+
this.creator = fields.creator
|
73
|
+
this.claimer = fields.claimer
|
74
|
+
this.randomBase = fields.randomBase
|
75
|
+
this.packType = fields.packType
|
76
|
+
this.sendToVault =
|
77
|
+
(fields.sendToVault &&
|
78
|
+
new types.MemeVaultProof({ ...fields.sendToVault })) ||
|
79
|
+
null
|
80
|
+
this.items = fields.items.map(
|
81
|
+
(item) => new types.SelectedZeroCard({ ...item })
|
82
|
+
)
|
83
|
+
}
|
84
|
+
|
85
|
+
static async fetch(
|
86
|
+
c: Connection,
|
87
|
+
address: PublicKey,
|
88
|
+
programId: PublicKey = PROGRAM_ID
|
89
|
+
): Promise<ZeroOpenHolder | null> {
|
90
|
+
const info = await c.getAccountInfo(address)
|
91
|
+
|
92
|
+
if (info === null) {
|
93
|
+
return null
|
94
|
+
}
|
95
|
+
if (!info.owner.equals(programId)) {
|
96
|
+
throw new Error("account doesn't belong to this program")
|
97
|
+
}
|
98
|
+
|
99
|
+
return this.decode(info.data)
|
100
|
+
}
|
101
|
+
|
102
|
+
static async fetchMultiple(
|
103
|
+
c: Connection,
|
104
|
+
addresses: PublicKey[],
|
105
|
+
programId: PublicKey = PROGRAM_ID
|
106
|
+
): Promise<Array<ZeroOpenHolder | null>> {
|
107
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
108
|
+
|
109
|
+
return infos.map((info) => {
|
110
|
+
if (info === null) {
|
111
|
+
return null
|
112
|
+
}
|
113
|
+
if (!info.owner.equals(programId)) {
|
114
|
+
throw new Error("account doesn't belong to this program")
|
115
|
+
}
|
116
|
+
|
117
|
+
return this.decode(info.data)
|
118
|
+
})
|
119
|
+
}
|
120
|
+
|
121
|
+
static decode(data: Buffer): ZeroOpenHolder {
|
122
|
+
if (!data.slice(0, 8).equals(ZeroOpenHolder.discriminator)) {
|
123
|
+
throw new Error("invalid account discriminator")
|
124
|
+
}
|
125
|
+
|
126
|
+
const dec = ZeroOpenHolder.layout.decode(data.slice(8))
|
127
|
+
|
128
|
+
return new ZeroOpenHolder({
|
129
|
+
class: types.AccountClass.fromDecoded(dec.class),
|
130
|
+
storeHalfHash: dec.storeHalfHash,
|
131
|
+
state: types.PackOpenHolderState.fromDecoded(dec.state),
|
132
|
+
paidFee: dec.paidFee,
|
133
|
+
pack: dec.pack,
|
134
|
+
creator: dec.creator,
|
135
|
+
claimer: dec.claimer,
|
136
|
+
randomBase: dec.randomBase,
|
137
|
+
packType: types.PackType.fromDecoded(dec.packType),
|
138
|
+
sendToVault:
|
139
|
+
(dec.sendToVault &&
|
140
|
+
types.MemeVaultProof.fromDecoded(dec.sendToVault)) ||
|
141
|
+
null,
|
142
|
+
items: dec.items.map(
|
143
|
+
(
|
144
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
145
|
+
) => types.SelectedZeroCard.fromDecoded(item)
|
146
|
+
),
|
147
|
+
})
|
148
|
+
}
|
149
|
+
|
150
|
+
toJSON(): ZeroOpenHolderJSON {
|
151
|
+
return {
|
152
|
+
class: this.class.toJSON(),
|
153
|
+
storeHalfHash: this.storeHalfHash,
|
154
|
+
state: this.state.toJSON(),
|
155
|
+
paidFee: this.paidFee,
|
156
|
+
pack: this.pack.toString(),
|
157
|
+
creator: this.creator.toString(),
|
158
|
+
claimer: this.claimer.toString(),
|
159
|
+
randomBase: this.randomBase.toString(),
|
160
|
+
packType: this.packType.toJSON(),
|
161
|
+
sendToVault: (this.sendToVault && this.sendToVault.toJSON()) || null,
|
162
|
+
items: this.items.map((item) => item.toJSON()),
|
163
|
+
}
|
164
|
+
}
|
165
|
+
|
166
|
+
static fromJSON(obj: ZeroOpenHolderJSON): ZeroOpenHolder {
|
167
|
+
return new ZeroOpenHolder({
|
168
|
+
class: types.AccountClass.fromJSON(obj.class),
|
169
|
+
storeHalfHash: obj.storeHalfHash,
|
170
|
+
state: types.PackOpenHolderState.fromJSON(obj.state),
|
171
|
+
paidFee: obj.paidFee,
|
172
|
+
pack: new PublicKey(obj.pack),
|
173
|
+
creator: new PublicKey(obj.creator),
|
174
|
+
claimer: new PublicKey(obj.claimer),
|
175
|
+
randomBase: new BN(obj.randomBase),
|
176
|
+
packType: types.PackType.fromJSON(obj.packType),
|
177
|
+
sendToVault:
|
178
|
+
(obj.sendToVault && types.MemeVaultProof.fromJSON(obj.sendToVault)) ||
|
179
|
+
null,
|
180
|
+
items: obj.items.map((item) => types.SelectedZeroCard.fromJSON(item)),
|
181
|
+
})
|
182
|
+
}
|
183
|
+
}
|
@@ -0,0 +1,84 @@
|
|
1
|
+
export { BuyTrack } from "./BuyTrack"
|
2
|
+
export type { BuyTrackFields, BuyTrackJSON } from "./BuyTrack"
|
3
|
+
export { BuyHistory } from "./BuyHistory"
|
4
|
+
export type { BuyHistoryFields, BuyHistoryJSON } from "./BuyHistory"
|
5
|
+
export { ZeroOpenHolder } from "./ZeroOpenHolder"
|
6
|
+
export type { ZeroOpenHolderFields, ZeroOpenHolderJSON } from "./ZeroOpenHolder"
|
7
|
+
export { PackOpenHolder } from "./PackOpenHolder"
|
8
|
+
export type { PackOpenHolderFields, PackOpenHolderJSON } from "./PackOpenHolder"
|
9
|
+
export { ArchiveDeposit } from "./ArchiveDeposit"
|
10
|
+
export type { ArchiveDepositFields, ArchiveDepositJSON } from "./ArchiveDeposit"
|
11
|
+
export { CollectorRegistry } from "./CollectorRegistry"
|
12
|
+
export type {
|
13
|
+
CollectorRegistryFields,
|
14
|
+
CollectorRegistryJSON,
|
15
|
+
} from "./CollectorRegistry"
|
16
|
+
export { LutVault } from "./LutVault"
|
17
|
+
export type { LutVaultFields, LutVaultJSON } from "./LutVault"
|
18
|
+
export { TokenManager } from "./TokenManager"
|
19
|
+
export type { TokenManagerFields, TokenManagerJSON } from "./TokenManager"
|
20
|
+
export { CreatorRegistry } from "./CreatorRegistry"
|
21
|
+
export type {
|
22
|
+
CreatorRegistryFields,
|
23
|
+
CreatorRegistryJSON,
|
24
|
+
} from "./CreatorRegistry"
|
25
|
+
export { CollectionRegistry } from "./CollectionRegistry"
|
26
|
+
export type {
|
27
|
+
CollectionRegistryFields,
|
28
|
+
CollectionRegistryJSON,
|
29
|
+
} from "./CollectionRegistry"
|
30
|
+
export { PoolVault } from "./PoolVault"
|
31
|
+
export type { PoolVaultFields, PoolVaultJSON } from "./PoolVault"
|
32
|
+
export { Store } from "./Store"
|
33
|
+
export type { StoreFields, StoreJSON } from "./Store"
|
34
|
+
export { CurrencyArtistProof } from "./CurrencyArtistProof"
|
35
|
+
export type {
|
36
|
+
CurrencyArtistProofFields,
|
37
|
+
CurrencyArtistProofJSON,
|
38
|
+
} from "./CurrencyArtistProof"
|
39
|
+
export { Payment } from "./Payment"
|
40
|
+
export type { PaymentFields, PaymentJSON } from "./Payment"
|
41
|
+
export { RevealForMe } from "./RevealForMe"
|
42
|
+
export type { RevealForMeFields, RevealForMeJSON } from "./RevealForMe"
|
43
|
+
export { BurnDeposit } from "./BurnDeposit"
|
44
|
+
export type { BurnDepositFields, BurnDepositJSON } from "./BurnDeposit"
|
45
|
+
export { BurnProgress } from "./BurnProgress"
|
46
|
+
export type { BurnProgressFields, BurnProgressJSON } from "./BurnProgress"
|
47
|
+
export { ItemReserveList } from "./ItemReserveList"
|
48
|
+
export type {
|
49
|
+
ItemReserveListFields,
|
50
|
+
ItemReserveListJSON,
|
51
|
+
} from "./ItemReserveList"
|
52
|
+
export { ItemReserveList2 } from "./ItemReserveList2"
|
53
|
+
export type {
|
54
|
+
ItemReserveList2Fields,
|
55
|
+
ItemReserveList2JSON,
|
56
|
+
} from "./ItemReserveList2"
|
57
|
+
export { PackTraits } from "./PackTraits"
|
58
|
+
export type { PackTraitsFields, PackTraitsJSON } from "./PackTraits"
|
59
|
+
export { PackReceipt } from "./PackReceipt"
|
60
|
+
export type { PackReceiptFields, PackReceiptJSON } from "./PackReceipt"
|
61
|
+
export { ZeroContent } from "./ZeroContent"
|
62
|
+
export type { ZeroContentFields, ZeroContentJSON } from "./ZeroContent"
|
63
|
+
export { PackContent } from "./PackContent"
|
64
|
+
export type { PackContentFields, PackContentJSON } from "./PackContent"
|
65
|
+
export { ZeroCard } from "./ZeroCard"
|
66
|
+
export type { ZeroCardFields, ZeroCardJSON } from "./ZeroCard"
|
67
|
+
export { Authority } from "./Authority"
|
68
|
+
export type { AuthorityFields, AuthorityJSON } from "./Authority"
|
69
|
+
export { Card } from "./Card"
|
70
|
+
export type { CardFields, CardJSON } from "./Card"
|
71
|
+
export { ItemArchive } from "./ItemArchive"
|
72
|
+
export type { ItemArchiveFields, ItemArchiveJSON } from "./ItemArchive"
|
73
|
+
export { SecureHolder } from "./SecureHolder"
|
74
|
+
export type { SecureHolderFields, SecureHolderJSON } from "./SecureHolder"
|
75
|
+
export { Single } from "./Single"
|
76
|
+
export type { SingleFields, SingleJSON } from "./Single"
|
77
|
+
export { Pack } from "./Pack"
|
78
|
+
export type { PackFields, PackJSON } from "./Pack"
|
79
|
+
export { GenericUser } from "./GenericUser"
|
80
|
+
export type { GenericUserFields, GenericUserJSON } from "./GenericUser"
|
81
|
+
export { ThreeId } from "./ThreeId"
|
82
|
+
export type { ThreeIdFields, ThreeIdJSON } from "./ThreeId"
|
83
|
+
export { StoresHolder } from "./StoresHolder"
|
84
|
+
export type { StoresHolderFields, StoresHolderJSON } from "./StoresHolder"
|