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,153 @@
|
|
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 CreatorRegistryFields {
|
8
|
+
class: types.AccountClassKind
|
9
|
+
storeHash: BN
|
10
|
+
currency: PublicKey
|
11
|
+
creator: PublicKey
|
12
|
+
donations: BN
|
13
|
+
date: types.IndexDateFields
|
14
|
+
filters: Array<number>
|
15
|
+
track: types.SaleTrackFields
|
16
|
+
lut: PublicKey
|
17
|
+
}
|
18
|
+
|
19
|
+
export interface CreatorRegistryJSON {
|
20
|
+
class: types.AccountClassJSON
|
21
|
+
storeHash: string
|
22
|
+
currency: string
|
23
|
+
creator: string
|
24
|
+
donations: string
|
25
|
+
date: types.IndexDateJSON
|
26
|
+
filters: Array<number>
|
27
|
+
track: types.SaleTrackJSON
|
28
|
+
lut: string
|
29
|
+
}
|
30
|
+
|
31
|
+
export class CreatorRegistry {
|
32
|
+
readonly class: types.AccountClassKind
|
33
|
+
readonly storeHash: BN
|
34
|
+
readonly currency: PublicKey
|
35
|
+
readonly creator: PublicKey
|
36
|
+
readonly donations: BN
|
37
|
+
readonly date: types.IndexDate
|
38
|
+
readonly filters: Array<number>
|
39
|
+
readonly track: types.SaleTrack
|
40
|
+
readonly lut: PublicKey
|
41
|
+
|
42
|
+
static readonly discriminator = Buffer.from([
|
43
|
+
14, 189, 133, 111, 190, 233, 2, 236,
|
44
|
+
])
|
45
|
+
|
46
|
+
static readonly layout = borsh.struct([
|
47
|
+
types.AccountClass.layout("class"),
|
48
|
+
borsh.u64("storeHash"),
|
49
|
+
borsh.publicKey("currency"),
|
50
|
+
borsh.publicKey("creator"),
|
51
|
+
borsh.u64("donations"),
|
52
|
+
types.IndexDate.layout("date"),
|
53
|
+
borsh.array(borsh.u8(), 8, "filters"),
|
54
|
+
types.SaleTrack.layout("track"),
|
55
|
+
borsh.publicKey("lut"),
|
56
|
+
])
|
57
|
+
|
58
|
+
constructor(fields: CreatorRegistryFields) {
|
59
|
+
this.class = fields.class
|
60
|
+
this.storeHash = fields.storeHash
|
61
|
+
this.currency = fields.currency
|
62
|
+
this.creator = fields.creator
|
63
|
+
this.donations = fields.donations
|
64
|
+
this.date = new types.IndexDate({ ...fields.date })
|
65
|
+
this.filters = fields.filters
|
66
|
+
this.track = new types.SaleTrack({ ...fields.track })
|
67
|
+
this.lut = fields.lut
|
68
|
+
}
|
69
|
+
|
70
|
+
static async fetch(
|
71
|
+
c: Connection,
|
72
|
+
address: PublicKey,
|
73
|
+
programId: PublicKey = PROGRAM_ID
|
74
|
+
): Promise<CreatorRegistry | null> {
|
75
|
+
const info = await c.getAccountInfo(address)
|
76
|
+
|
77
|
+
if (info === null) {
|
78
|
+
return null
|
79
|
+
}
|
80
|
+
if (!info.owner.equals(programId)) {
|
81
|
+
throw new Error("account doesn't belong to this program")
|
82
|
+
}
|
83
|
+
|
84
|
+
return this.decode(info.data)
|
85
|
+
}
|
86
|
+
|
87
|
+
static async fetchMultiple(
|
88
|
+
c: Connection,
|
89
|
+
addresses: PublicKey[],
|
90
|
+
programId: PublicKey = PROGRAM_ID
|
91
|
+
): Promise<Array<CreatorRegistry | null>> {
|
92
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
93
|
+
|
94
|
+
return infos.map((info) => {
|
95
|
+
if (info === null) {
|
96
|
+
return null
|
97
|
+
}
|
98
|
+
if (!info.owner.equals(programId)) {
|
99
|
+
throw new Error("account doesn't belong to this program")
|
100
|
+
}
|
101
|
+
|
102
|
+
return this.decode(info.data)
|
103
|
+
})
|
104
|
+
}
|
105
|
+
|
106
|
+
static decode(data: Buffer): CreatorRegistry {
|
107
|
+
if (!data.slice(0, 8).equals(CreatorRegistry.discriminator)) {
|
108
|
+
throw new Error("invalid account discriminator")
|
109
|
+
}
|
110
|
+
|
111
|
+
const dec = CreatorRegistry.layout.decode(data.slice(8))
|
112
|
+
|
113
|
+
return new CreatorRegistry({
|
114
|
+
class: types.AccountClass.fromDecoded(dec.class),
|
115
|
+
storeHash: dec.storeHash,
|
116
|
+
currency: dec.currency,
|
117
|
+
creator: dec.creator,
|
118
|
+
donations: dec.donations,
|
119
|
+
date: types.IndexDate.fromDecoded(dec.date),
|
120
|
+
filters: dec.filters,
|
121
|
+
track: types.SaleTrack.fromDecoded(dec.track),
|
122
|
+
lut: dec.lut,
|
123
|
+
})
|
124
|
+
}
|
125
|
+
|
126
|
+
toJSON(): CreatorRegistryJSON {
|
127
|
+
return {
|
128
|
+
class: this.class.toJSON(),
|
129
|
+
storeHash: this.storeHash.toString(),
|
130
|
+
currency: this.currency.toString(),
|
131
|
+
creator: this.creator.toString(),
|
132
|
+
donations: this.donations.toString(),
|
133
|
+
date: this.date.toJSON(),
|
134
|
+
filters: this.filters,
|
135
|
+
track: this.track.toJSON(),
|
136
|
+
lut: this.lut.toString(),
|
137
|
+
}
|
138
|
+
}
|
139
|
+
|
140
|
+
static fromJSON(obj: CreatorRegistryJSON): CreatorRegistry {
|
141
|
+
return new CreatorRegistry({
|
142
|
+
class: types.AccountClass.fromJSON(obj.class),
|
143
|
+
storeHash: new BN(obj.storeHash),
|
144
|
+
currency: new PublicKey(obj.currency),
|
145
|
+
creator: new PublicKey(obj.creator),
|
146
|
+
donations: new BN(obj.donations),
|
147
|
+
date: types.IndexDate.fromJSON(obj.date),
|
148
|
+
filters: obj.filters,
|
149
|
+
track: types.SaleTrack.fromJSON(obj.track),
|
150
|
+
lut: new PublicKey(obj.lut),
|
151
|
+
})
|
152
|
+
}
|
153
|
+
}
|
@@ -0,0 +1,113 @@
|
|
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 CurrencyArtistProofFields {
|
8
|
+
proofHash: BN
|
9
|
+
amount: BN
|
10
|
+
currencyVerifier: number
|
11
|
+
artistVerifier: number
|
12
|
+
}
|
13
|
+
|
14
|
+
export interface CurrencyArtistProofJSON {
|
15
|
+
proofHash: string
|
16
|
+
amount: string
|
17
|
+
currencyVerifier: number
|
18
|
+
artistVerifier: number
|
19
|
+
}
|
20
|
+
|
21
|
+
export class CurrencyArtistProof {
|
22
|
+
readonly proofHash: BN
|
23
|
+
readonly amount: BN
|
24
|
+
readonly currencyVerifier: number
|
25
|
+
readonly artistVerifier: number
|
26
|
+
|
27
|
+
static readonly discriminator = Buffer.from([
|
28
|
+
11, 32, 176, 50, 245, 55, 208, 119,
|
29
|
+
])
|
30
|
+
|
31
|
+
static readonly layout = borsh.struct([
|
32
|
+
borsh.u64("proofHash"),
|
33
|
+
borsh.u64("amount"),
|
34
|
+
borsh.u32("currencyVerifier"),
|
35
|
+
borsh.u32("artistVerifier"),
|
36
|
+
])
|
37
|
+
|
38
|
+
constructor(fields: CurrencyArtistProofFields) {
|
39
|
+
this.proofHash = fields.proofHash
|
40
|
+
this.amount = fields.amount
|
41
|
+
this.currencyVerifier = fields.currencyVerifier
|
42
|
+
this.artistVerifier = fields.artistVerifier
|
43
|
+
}
|
44
|
+
|
45
|
+
static async fetch(
|
46
|
+
c: Connection,
|
47
|
+
address: PublicKey,
|
48
|
+
programId: PublicKey = PROGRAM_ID
|
49
|
+
): Promise<CurrencyArtistProof | null> {
|
50
|
+
const info = await c.getAccountInfo(address)
|
51
|
+
|
52
|
+
if (info === null) {
|
53
|
+
return null
|
54
|
+
}
|
55
|
+
if (!info.owner.equals(programId)) {
|
56
|
+
throw new Error("account doesn't belong to this program")
|
57
|
+
}
|
58
|
+
|
59
|
+
return this.decode(info.data)
|
60
|
+
}
|
61
|
+
|
62
|
+
static async fetchMultiple(
|
63
|
+
c: Connection,
|
64
|
+
addresses: PublicKey[],
|
65
|
+
programId: PublicKey = PROGRAM_ID
|
66
|
+
): Promise<Array<CurrencyArtistProof | null>> {
|
67
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
68
|
+
|
69
|
+
return infos.map((info) => {
|
70
|
+
if (info === null) {
|
71
|
+
return null
|
72
|
+
}
|
73
|
+
if (!info.owner.equals(programId)) {
|
74
|
+
throw new Error("account doesn't belong to this program")
|
75
|
+
}
|
76
|
+
|
77
|
+
return this.decode(info.data)
|
78
|
+
})
|
79
|
+
}
|
80
|
+
|
81
|
+
static decode(data: Buffer): CurrencyArtistProof {
|
82
|
+
if (!data.slice(0, 8).equals(CurrencyArtistProof.discriminator)) {
|
83
|
+
throw new Error("invalid account discriminator")
|
84
|
+
}
|
85
|
+
|
86
|
+
const dec = CurrencyArtistProof.layout.decode(data.slice(8))
|
87
|
+
|
88
|
+
return new CurrencyArtistProof({
|
89
|
+
proofHash: dec.proofHash,
|
90
|
+
amount: dec.amount,
|
91
|
+
currencyVerifier: dec.currencyVerifier,
|
92
|
+
artistVerifier: dec.artistVerifier,
|
93
|
+
})
|
94
|
+
}
|
95
|
+
|
96
|
+
toJSON(): CurrencyArtistProofJSON {
|
97
|
+
return {
|
98
|
+
proofHash: this.proofHash.toString(),
|
99
|
+
amount: this.amount.toString(),
|
100
|
+
currencyVerifier: this.currencyVerifier,
|
101
|
+
artistVerifier: this.artistVerifier,
|
102
|
+
}
|
103
|
+
}
|
104
|
+
|
105
|
+
static fromJSON(obj: CurrencyArtistProofJSON): CurrencyArtistProof {
|
106
|
+
return new CurrencyArtistProof({
|
107
|
+
proofHash: new BN(obj.proofHash),
|
108
|
+
amount: new BN(obj.amount),
|
109
|
+
currencyVerifier: obj.currencyVerifier,
|
110
|
+
artistVerifier: obj.artistVerifier,
|
111
|
+
})
|
112
|
+
}
|
113
|
+
}
|
@@ -0,0 +1,185 @@
|
|
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 GenericUserFields {
|
8
|
+
class: types.AccountClassKind
|
9
|
+
subApp: BN
|
10
|
+
holderHash: BN
|
11
|
+
category: BN
|
12
|
+
creator: PublicKey
|
13
|
+
lutAccount: PublicKey
|
14
|
+
subWallets: Array<PublicKey>
|
15
|
+
extended: number
|
16
|
+
flags: Array<number>
|
17
|
+
username: string
|
18
|
+
genericStore: Array<types.GenericStoreFields>
|
19
|
+
extra: Array<number>
|
20
|
+
}
|
21
|
+
|
22
|
+
export interface GenericUserJSON {
|
23
|
+
class: types.AccountClassJSON
|
24
|
+
subApp: string
|
25
|
+
holderHash: string
|
26
|
+
category: string
|
27
|
+
creator: string
|
28
|
+
lutAccount: string
|
29
|
+
subWallets: Array<string>
|
30
|
+
extended: number
|
31
|
+
flags: Array<number>
|
32
|
+
username: string
|
33
|
+
genericStore: Array<types.GenericStoreJSON>
|
34
|
+
extra: Array<number>
|
35
|
+
}
|
36
|
+
|
37
|
+
export class GenericUser {
|
38
|
+
readonly class: types.AccountClassKind
|
39
|
+
readonly subApp: BN
|
40
|
+
readonly holderHash: BN
|
41
|
+
readonly category: BN
|
42
|
+
readonly creator: PublicKey
|
43
|
+
readonly lutAccount: PublicKey
|
44
|
+
readonly subWallets: Array<PublicKey>
|
45
|
+
readonly extended: number
|
46
|
+
readonly flags: Array<number>
|
47
|
+
readonly username: string
|
48
|
+
readonly genericStore: Array<types.GenericStore>
|
49
|
+
readonly extra: Array<number>
|
50
|
+
|
51
|
+
static readonly discriminator = Buffer.from([
|
52
|
+
222, 233, 191, 5, 55, 3, 237, 241,
|
53
|
+
])
|
54
|
+
|
55
|
+
static readonly layout = borsh.struct([
|
56
|
+
types.AccountClass.layout("class"),
|
57
|
+
borsh.u64("subApp"),
|
58
|
+
borsh.u64("holderHash"),
|
59
|
+
borsh.u64("category"),
|
60
|
+
borsh.publicKey("creator"),
|
61
|
+
borsh.publicKey("lutAccount"),
|
62
|
+
borsh.vec(borsh.publicKey(), "subWallets"),
|
63
|
+
borsh.u8("extended"),
|
64
|
+
borsh.array(borsh.u8(), 8, "flags"),
|
65
|
+
borsh.str("username"),
|
66
|
+
borsh.vec(types.GenericStore.layout(), "genericStore"),
|
67
|
+
borsh.array(borsh.u8(), 32, "extra"),
|
68
|
+
])
|
69
|
+
|
70
|
+
constructor(fields: GenericUserFields) {
|
71
|
+
this.class = fields.class
|
72
|
+
this.subApp = fields.subApp
|
73
|
+
this.holderHash = fields.holderHash
|
74
|
+
this.category = fields.category
|
75
|
+
this.creator = fields.creator
|
76
|
+
this.lutAccount = fields.lutAccount
|
77
|
+
this.subWallets = fields.subWallets
|
78
|
+
this.extended = fields.extended
|
79
|
+
this.flags = fields.flags
|
80
|
+
this.username = fields.username
|
81
|
+
this.genericStore = fields.genericStore.map(
|
82
|
+
(item) => new types.GenericStore({ ...item })
|
83
|
+
)
|
84
|
+
this.extra = fields.extra
|
85
|
+
}
|
86
|
+
|
87
|
+
static async fetch(
|
88
|
+
c: Connection,
|
89
|
+
address: PublicKey,
|
90
|
+
programId: PublicKey = PROGRAM_ID
|
91
|
+
): Promise<GenericUser | null> {
|
92
|
+
const info = await c.getAccountInfo(address)
|
93
|
+
|
94
|
+
if (info === null) {
|
95
|
+
return null
|
96
|
+
}
|
97
|
+
if (!info.owner.equals(programId)) {
|
98
|
+
throw new Error("account doesn't belong to this program")
|
99
|
+
}
|
100
|
+
|
101
|
+
return this.decode(info.data)
|
102
|
+
}
|
103
|
+
|
104
|
+
static async fetchMultiple(
|
105
|
+
c: Connection,
|
106
|
+
addresses: PublicKey[],
|
107
|
+
programId: PublicKey = PROGRAM_ID
|
108
|
+
): Promise<Array<GenericUser | null>> {
|
109
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
110
|
+
|
111
|
+
return infos.map((info) => {
|
112
|
+
if (info === null) {
|
113
|
+
return null
|
114
|
+
}
|
115
|
+
if (!info.owner.equals(programId)) {
|
116
|
+
throw new Error("account doesn't belong to this program")
|
117
|
+
}
|
118
|
+
|
119
|
+
return this.decode(info.data)
|
120
|
+
})
|
121
|
+
}
|
122
|
+
|
123
|
+
static decode(data: Buffer): GenericUser {
|
124
|
+
if (!data.slice(0, 8).equals(GenericUser.discriminator)) {
|
125
|
+
throw new Error("invalid account discriminator")
|
126
|
+
}
|
127
|
+
|
128
|
+
const dec = GenericUser.layout.decode(data.slice(8))
|
129
|
+
|
130
|
+
return new GenericUser({
|
131
|
+
class: types.AccountClass.fromDecoded(dec.class),
|
132
|
+
subApp: dec.subApp,
|
133
|
+
holderHash: dec.holderHash,
|
134
|
+
category: dec.category,
|
135
|
+
creator: dec.creator,
|
136
|
+
lutAccount: dec.lutAccount,
|
137
|
+
subWallets: dec.subWallets,
|
138
|
+
extended: dec.extended,
|
139
|
+
flags: dec.flags,
|
140
|
+
username: dec.username,
|
141
|
+
genericStore: dec.genericStore.map(
|
142
|
+
(
|
143
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
144
|
+
) => types.GenericStore.fromDecoded(item)
|
145
|
+
),
|
146
|
+
extra: dec.extra,
|
147
|
+
})
|
148
|
+
}
|
149
|
+
|
150
|
+
toJSON(): GenericUserJSON {
|
151
|
+
return {
|
152
|
+
class: this.class.toJSON(),
|
153
|
+
subApp: this.subApp.toString(),
|
154
|
+
holderHash: this.holderHash.toString(),
|
155
|
+
category: this.category.toString(),
|
156
|
+
creator: this.creator.toString(),
|
157
|
+
lutAccount: this.lutAccount.toString(),
|
158
|
+
subWallets: this.subWallets.map((item) => item.toString()),
|
159
|
+
extended: this.extended,
|
160
|
+
flags: this.flags,
|
161
|
+
username: this.username,
|
162
|
+
genericStore: this.genericStore.map((item) => item.toJSON()),
|
163
|
+
extra: this.extra,
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
static fromJSON(obj: GenericUserJSON): GenericUser {
|
168
|
+
return new GenericUser({
|
169
|
+
class: types.AccountClass.fromJSON(obj.class),
|
170
|
+
subApp: new BN(obj.subApp),
|
171
|
+
holderHash: new BN(obj.holderHash),
|
172
|
+
category: new BN(obj.category),
|
173
|
+
creator: new PublicKey(obj.creator),
|
174
|
+
lutAccount: new PublicKey(obj.lutAccount),
|
175
|
+
subWallets: obj.subWallets.map((item) => new PublicKey(item)),
|
176
|
+
extended: obj.extended,
|
177
|
+
flags: obj.flags,
|
178
|
+
username: obj.username,
|
179
|
+
genericStore: obj.genericStore.map((item) =>
|
180
|
+
types.GenericStore.fromJSON(item)
|
181
|
+
),
|
182
|
+
extra: obj.extra,
|
183
|
+
})
|
184
|
+
}
|
185
|
+
}
|
@@ -0,0 +1,223 @@
|
|
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 ItemArchiveFields {
|
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
|
+
state: types.ItemStateKind
|
19
|
+
collection: PublicKey
|
20
|
+
cnft: PublicKey
|
21
|
+
identifier: BN
|
22
|
+
hash: BN
|
23
|
+
supply: BN
|
24
|
+
volume: Array<types.FakeVolumeTrackFields>
|
25
|
+
}
|
26
|
+
|
27
|
+
export interface ItemArchiveJSON {
|
28
|
+
class: types.AccountClassJSON
|
29
|
+
globalState: types.GlobalStateJSON
|
30
|
+
holder: string
|
31
|
+
creator: string
|
32
|
+
dates: types.IndexDatesJSON
|
33
|
+
category: types.CategoryJSON
|
34
|
+
superCategory: types.SuperCategoryJSON
|
35
|
+
eventCategory: number
|
36
|
+
trackType: types.TrackRegistryJSON
|
37
|
+
mainCurrencyHash: string
|
38
|
+
state: types.ItemStateJSON
|
39
|
+
collection: string
|
40
|
+
cnft: string
|
41
|
+
identifier: string
|
42
|
+
hash: string
|
43
|
+
supply: string
|
44
|
+
volume: Array<types.FakeVolumeTrackJSON>
|
45
|
+
}
|
46
|
+
|
47
|
+
export class ItemArchive {
|
48
|
+
readonly class: types.AccountClassKind
|
49
|
+
readonly globalState: types.GlobalStateKind
|
50
|
+
readonly holder: PublicKey
|
51
|
+
readonly creator: PublicKey
|
52
|
+
readonly dates: types.IndexDates
|
53
|
+
readonly category: types.Category
|
54
|
+
readonly superCategory: types.SuperCategory
|
55
|
+
readonly eventCategory: number
|
56
|
+
readonly trackType: types.TrackRegistryKind
|
57
|
+
readonly mainCurrencyHash: BN
|
58
|
+
readonly state: types.ItemStateKind
|
59
|
+
readonly collection: PublicKey
|
60
|
+
readonly cnft: PublicKey
|
61
|
+
readonly identifier: BN
|
62
|
+
readonly hash: BN
|
63
|
+
readonly supply: BN
|
64
|
+
readonly volume: Array<types.FakeVolumeTrack>
|
65
|
+
|
66
|
+
static readonly discriminator = Buffer.from([
|
67
|
+
11, 87, 59, 106, 157, 209, 221, 195,
|
68
|
+
])
|
69
|
+
|
70
|
+
static readonly layout = borsh.struct([
|
71
|
+
types.AccountClass.layout("class"),
|
72
|
+
types.GlobalState.layout("globalState"),
|
73
|
+
borsh.publicKey("holder"),
|
74
|
+
borsh.publicKey("creator"),
|
75
|
+
types.IndexDates.layout("dates"),
|
76
|
+
types.Category.layout("category"),
|
77
|
+
types.SuperCategory.layout("superCategory"),
|
78
|
+
borsh.u16("eventCategory"),
|
79
|
+
types.TrackRegistry.layout("trackType"),
|
80
|
+
borsh.u64("mainCurrencyHash"),
|
81
|
+
types.ItemState.layout("state"),
|
82
|
+
borsh.publicKey("collection"),
|
83
|
+
borsh.publicKey("cnft"),
|
84
|
+
borsh.u64("identifier"),
|
85
|
+
borsh.u64("hash"),
|
86
|
+
borsh.u64("supply"),
|
87
|
+
borsh.vec(types.FakeVolumeTrack.layout(), "volume"),
|
88
|
+
])
|
89
|
+
|
90
|
+
constructor(fields: ItemArchiveFields) {
|
91
|
+
this.class = fields.class
|
92
|
+
this.globalState = fields.globalState
|
93
|
+
this.holder = fields.holder
|
94
|
+
this.creator = fields.creator
|
95
|
+
this.dates = new types.IndexDates({ ...fields.dates })
|
96
|
+
this.category = new types.Category({ ...fields.category })
|
97
|
+
this.superCategory = new types.SuperCategory({ ...fields.superCategory })
|
98
|
+
this.eventCategory = fields.eventCategory
|
99
|
+
this.trackType = fields.trackType
|
100
|
+
this.mainCurrencyHash = fields.mainCurrencyHash
|
101
|
+
this.state = fields.state
|
102
|
+
this.collection = fields.collection
|
103
|
+
this.cnft = fields.cnft
|
104
|
+
this.identifier = fields.identifier
|
105
|
+
this.hash = fields.hash
|
106
|
+
this.supply = fields.supply
|
107
|
+
this.volume = fields.volume.map(
|
108
|
+
(item) => new types.FakeVolumeTrack({ ...item })
|
109
|
+
)
|
110
|
+
}
|
111
|
+
|
112
|
+
static async fetch(
|
113
|
+
c: Connection,
|
114
|
+
address: PublicKey,
|
115
|
+
programId: PublicKey = PROGRAM_ID
|
116
|
+
): Promise<ItemArchive | null> {
|
117
|
+
const info = await c.getAccountInfo(address)
|
118
|
+
|
119
|
+
if (info === null) {
|
120
|
+
return null
|
121
|
+
}
|
122
|
+
if (!info.owner.equals(programId)) {
|
123
|
+
throw new Error("account doesn't belong to this program")
|
124
|
+
}
|
125
|
+
|
126
|
+
return this.decode(info.data)
|
127
|
+
}
|
128
|
+
|
129
|
+
static async fetchMultiple(
|
130
|
+
c: Connection,
|
131
|
+
addresses: PublicKey[],
|
132
|
+
programId: PublicKey = PROGRAM_ID
|
133
|
+
): Promise<Array<ItemArchive | null>> {
|
134
|
+
const infos = await c.getMultipleAccountsInfo(addresses)
|
135
|
+
|
136
|
+
return infos.map((info) => {
|
137
|
+
if (info === null) {
|
138
|
+
return null
|
139
|
+
}
|
140
|
+
if (!info.owner.equals(programId)) {
|
141
|
+
throw new Error("account doesn't belong to this program")
|
142
|
+
}
|
143
|
+
|
144
|
+
return this.decode(info.data)
|
145
|
+
})
|
146
|
+
}
|
147
|
+
|
148
|
+
static decode(data: Buffer): ItemArchive {
|
149
|
+
if (!data.slice(0, 8).equals(ItemArchive.discriminator)) {
|
150
|
+
throw new Error("invalid account discriminator")
|
151
|
+
}
|
152
|
+
|
153
|
+
const dec = ItemArchive.layout.decode(data.slice(8))
|
154
|
+
|
155
|
+
return new ItemArchive({
|
156
|
+
class: types.AccountClass.fromDecoded(dec.class),
|
157
|
+
globalState: types.GlobalState.fromDecoded(dec.globalState),
|
158
|
+
holder: dec.holder,
|
159
|
+
creator: dec.creator,
|
160
|
+
dates: types.IndexDates.fromDecoded(dec.dates),
|
161
|
+
category: types.Category.fromDecoded(dec.category),
|
162
|
+
superCategory: types.SuperCategory.fromDecoded(dec.superCategory),
|
163
|
+
eventCategory: dec.eventCategory,
|
164
|
+
trackType: types.TrackRegistry.fromDecoded(dec.trackType),
|
165
|
+
mainCurrencyHash: dec.mainCurrencyHash,
|
166
|
+
state: types.ItemState.fromDecoded(dec.state),
|
167
|
+
collection: dec.collection,
|
168
|
+
cnft: dec.cnft,
|
169
|
+
identifier: dec.identifier,
|
170
|
+
hash: dec.hash,
|
171
|
+
supply: dec.supply,
|
172
|
+
volume: dec.volume.map(
|
173
|
+
(
|
174
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
175
|
+
) => types.FakeVolumeTrack.fromDecoded(item)
|
176
|
+
),
|
177
|
+
})
|
178
|
+
}
|
179
|
+
|
180
|
+
toJSON(): ItemArchiveJSON {
|
181
|
+
return {
|
182
|
+
class: this.class.toJSON(),
|
183
|
+
globalState: this.globalState.toJSON(),
|
184
|
+
holder: this.holder.toString(),
|
185
|
+
creator: this.creator.toString(),
|
186
|
+
dates: this.dates.toJSON(),
|
187
|
+
category: this.category.toJSON(),
|
188
|
+
superCategory: this.superCategory.toJSON(),
|
189
|
+
eventCategory: this.eventCategory,
|
190
|
+
trackType: this.trackType.toJSON(),
|
191
|
+
mainCurrencyHash: this.mainCurrencyHash.toString(),
|
192
|
+
state: this.state.toJSON(),
|
193
|
+
collection: this.collection.toString(),
|
194
|
+
cnft: this.cnft.toString(),
|
195
|
+
identifier: this.identifier.toString(),
|
196
|
+
hash: this.hash.toString(),
|
197
|
+
supply: this.supply.toString(),
|
198
|
+
volume: this.volume.map((item) => item.toJSON()),
|
199
|
+
}
|
200
|
+
}
|
201
|
+
|
202
|
+
static fromJSON(obj: ItemArchiveJSON): ItemArchive {
|
203
|
+
return new ItemArchive({
|
204
|
+
class: types.AccountClass.fromJSON(obj.class),
|
205
|
+
globalState: types.GlobalState.fromJSON(obj.globalState),
|
206
|
+
holder: new PublicKey(obj.holder),
|
207
|
+
creator: new PublicKey(obj.creator),
|
208
|
+
dates: types.IndexDates.fromJSON(obj.dates),
|
209
|
+
category: types.Category.fromJSON(obj.category),
|
210
|
+
superCategory: types.SuperCategory.fromJSON(obj.superCategory),
|
211
|
+
eventCategory: obj.eventCategory,
|
212
|
+
trackType: types.TrackRegistry.fromJSON(obj.trackType),
|
213
|
+
mainCurrencyHash: new BN(obj.mainCurrencyHash),
|
214
|
+
state: types.ItemState.fromJSON(obj.state),
|
215
|
+
collection: new PublicKey(obj.collection),
|
216
|
+
cnft: new PublicKey(obj.cnft),
|
217
|
+
identifier: new BN(obj.identifier),
|
218
|
+
hash: new BN(obj.hash),
|
219
|
+
supply: new BN(obj.supply),
|
220
|
+
volume: obj.volume.map((item) => types.FakeVolumeTrack.fromJSON(item)),
|
221
|
+
})
|
222
|
+
}
|
223
|
+
}
|