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,267 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
5
|
+
|
6
|
+
export type SemiFungibleFields = {
|
7
|
+
hash: BN
|
8
|
+
count: number
|
9
|
+
supply: BN
|
10
|
+
total: BN
|
11
|
+
}
|
12
|
+
export type SemiFungibleValue = {
|
13
|
+
hash: BN
|
14
|
+
count: number
|
15
|
+
supply: BN
|
16
|
+
total: BN
|
17
|
+
}
|
18
|
+
|
19
|
+
export interface SemiFungibleJSON {
|
20
|
+
kind: "SemiFungible"
|
21
|
+
value: {
|
22
|
+
hash: string
|
23
|
+
count: number
|
24
|
+
supply: string
|
25
|
+
total: string
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
export class SemiFungible {
|
30
|
+
static readonly discriminator = 0
|
31
|
+
static readonly kind = "SemiFungible"
|
32
|
+
readonly discriminator = 0
|
33
|
+
readonly kind = "SemiFungible"
|
34
|
+
readonly value: SemiFungibleValue
|
35
|
+
|
36
|
+
constructor(value: SemiFungibleFields) {
|
37
|
+
this.value = {
|
38
|
+
hash: value.hash,
|
39
|
+
count: value.count,
|
40
|
+
supply: value.supply,
|
41
|
+
total: value.total,
|
42
|
+
}
|
43
|
+
}
|
44
|
+
|
45
|
+
toJSON(): SemiFungibleJSON {
|
46
|
+
return {
|
47
|
+
kind: "SemiFungible",
|
48
|
+
value: {
|
49
|
+
hash: this.value.hash.toString(),
|
50
|
+
count: this.value.count,
|
51
|
+
supply: this.value.supply.toString(),
|
52
|
+
total: this.value.total.toString(),
|
53
|
+
},
|
54
|
+
}
|
55
|
+
}
|
56
|
+
|
57
|
+
toEncodable() {
|
58
|
+
return {
|
59
|
+
SemiFungible: {
|
60
|
+
hash: this.value.hash,
|
61
|
+
count: this.value.count,
|
62
|
+
supply: this.value.supply,
|
63
|
+
total: this.value.total,
|
64
|
+
},
|
65
|
+
}
|
66
|
+
}
|
67
|
+
}
|
68
|
+
|
69
|
+
export type DateFields = {
|
70
|
+
hash: BN
|
71
|
+
count: number
|
72
|
+
supply: BN
|
73
|
+
}
|
74
|
+
export type DateValue = {
|
75
|
+
hash: BN
|
76
|
+
count: number
|
77
|
+
supply: BN
|
78
|
+
}
|
79
|
+
|
80
|
+
export interface DateJSON {
|
81
|
+
kind: "Date"
|
82
|
+
value: {
|
83
|
+
hash: string
|
84
|
+
count: number
|
85
|
+
supply: string
|
86
|
+
}
|
87
|
+
}
|
88
|
+
|
89
|
+
export class Date {
|
90
|
+
static readonly discriminator = 1
|
91
|
+
static readonly kind = "Date"
|
92
|
+
readonly discriminator = 1
|
93
|
+
readonly kind = "Date"
|
94
|
+
readonly value: DateValue
|
95
|
+
|
96
|
+
constructor(value: DateFields) {
|
97
|
+
this.value = {
|
98
|
+
hash: value.hash,
|
99
|
+
count: value.count,
|
100
|
+
supply: value.supply,
|
101
|
+
}
|
102
|
+
}
|
103
|
+
|
104
|
+
toJSON(): DateJSON {
|
105
|
+
return {
|
106
|
+
kind: "Date",
|
107
|
+
value: {
|
108
|
+
hash: this.value.hash.toString(),
|
109
|
+
count: this.value.count,
|
110
|
+
supply: this.value.supply.toString(),
|
111
|
+
},
|
112
|
+
}
|
113
|
+
}
|
114
|
+
|
115
|
+
toEncodable() {
|
116
|
+
return {
|
117
|
+
Date: {
|
118
|
+
hash: this.value.hash,
|
119
|
+
count: this.value.count,
|
120
|
+
supply: this.value.supply,
|
121
|
+
},
|
122
|
+
}
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
export type NonFungibleFields = {
|
127
|
+
hash: BN
|
128
|
+
values: Array<types.TraitValueFields>
|
129
|
+
}
|
130
|
+
export type NonFungibleValue = {
|
131
|
+
hash: BN
|
132
|
+
values: Array<types.TraitValue>
|
133
|
+
}
|
134
|
+
|
135
|
+
export interface NonFungibleJSON {
|
136
|
+
kind: "NonFungible"
|
137
|
+
value: {
|
138
|
+
hash: string
|
139
|
+
values: Array<types.TraitValueJSON>
|
140
|
+
}
|
141
|
+
}
|
142
|
+
|
143
|
+
export class NonFungible {
|
144
|
+
static readonly discriminator = 2
|
145
|
+
static readonly kind = "NonFungible"
|
146
|
+
readonly discriminator = 2
|
147
|
+
readonly kind = "NonFungible"
|
148
|
+
readonly value: NonFungibleValue
|
149
|
+
|
150
|
+
constructor(value: NonFungibleFields) {
|
151
|
+
this.value = {
|
152
|
+
hash: value.hash,
|
153
|
+
values: value.values.map((item) => new types.TraitValue({ ...item })),
|
154
|
+
}
|
155
|
+
}
|
156
|
+
|
157
|
+
toJSON(): NonFungibleJSON {
|
158
|
+
return {
|
159
|
+
kind: "NonFungible",
|
160
|
+
value: {
|
161
|
+
hash: this.value.hash.toString(),
|
162
|
+
values: this.value.values.map((item) => item.toJSON()),
|
163
|
+
},
|
164
|
+
}
|
165
|
+
}
|
166
|
+
|
167
|
+
toEncodable() {
|
168
|
+
return {
|
169
|
+
NonFungible: {
|
170
|
+
hash: this.value.hash,
|
171
|
+
values: this.value.values.map((item) =>
|
172
|
+
types.TraitValue.toEncodable(item)
|
173
|
+
),
|
174
|
+
},
|
175
|
+
}
|
176
|
+
}
|
177
|
+
}
|
178
|
+
|
179
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
180
|
+
export function fromDecoded(obj: any): types.TraitTypeKind {
|
181
|
+
if (typeof obj !== "object") {
|
182
|
+
throw new Error("Invalid enum object")
|
183
|
+
}
|
184
|
+
|
185
|
+
if ("SemiFungible" in obj) {
|
186
|
+
const val = obj["SemiFungible"]
|
187
|
+
return new SemiFungible({
|
188
|
+
hash: val["hash"],
|
189
|
+
count: val["count"],
|
190
|
+
supply: val["supply"],
|
191
|
+
total: val["total"],
|
192
|
+
})
|
193
|
+
}
|
194
|
+
if ("Date" in obj) {
|
195
|
+
const val = obj["Date"]
|
196
|
+
return new Date({
|
197
|
+
hash: val["hash"],
|
198
|
+
count: val["count"],
|
199
|
+
supply: val["supply"],
|
200
|
+
})
|
201
|
+
}
|
202
|
+
if ("NonFungible" in obj) {
|
203
|
+
const val = obj["NonFungible"]
|
204
|
+
return new NonFungible({
|
205
|
+
hash: val["hash"],
|
206
|
+
values: val["values"].map(
|
207
|
+
(
|
208
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
209
|
+
) => types.TraitValue.fromDecoded(item)
|
210
|
+
),
|
211
|
+
})
|
212
|
+
}
|
213
|
+
|
214
|
+
throw new Error("Invalid enum object")
|
215
|
+
}
|
216
|
+
|
217
|
+
export function fromJSON(obj: types.TraitTypeJSON): types.TraitTypeKind {
|
218
|
+
switch (obj.kind) {
|
219
|
+
case "SemiFungible": {
|
220
|
+
return new SemiFungible({
|
221
|
+
hash: new BN(obj.value.hash),
|
222
|
+
count: obj.value.count,
|
223
|
+
supply: new BN(obj.value.supply),
|
224
|
+
total: new BN(obj.value.total),
|
225
|
+
})
|
226
|
+
}
|
227
|
+
case "Date": {
|
228
|
+
return new Date({
|
229
|
+
hash: new BN(obj.value.hash),
|
230
|
+
count: obj.value.count,
|
231
|
+
supply: new BN(obj.value.supply),
|
232
|
+
})
|
233
|
+
}
|
234
|
+
case "NonFungible": {
|
235
|
+
return new NonFungible({
|
236
|
+
hash: new BN(obj.value.hash),
|
237
|
+
values: obj.value.values.map((item) => types.TraitValue.fromJSON(item)),
|
238
|
+
})
|
239
|
+
}
|
240
|
+
}
|
241
|
+
}
|
242
|
+
|
243
|
+
export function layout(property?: string) {
|
244
|
+
const ret = borsh.rustEnum([
|
245
|
+
borsh.struct(
|
246
|
+
[
|
247
|
+
borsh.u64("hash"),
|
248
|
+
borsh.u32("count"),
|
249
|
+
borsh.u64("supply"),
|
250
|
+
borsh.u64("total"),
|
251
|
+
],
|
252
|
+
"SemiFungible"
|
253
|
+
),
|
254
|
+
borsh.struct(
|
255
|
+
[borsh.u64("hash"), borsh.u32("count"), borsh.u64("supply")],
|
256
|
+
"Date"
|
257
|
+
),
|
258
|
+
borsh.struct(
|
259
|
+
[borsh.u64("hash"), borsh.vec(types.TraitValue.layout(), "values")],
|
260
|
+
"NonFungible"
|
261
|
+
),
|
262
|
+
])
|
263
|
+
if (property !== undefined) {
|
264
|
+
return ret.replicate(property)
|
265
|
+
}
|
266
|
+
return ret
|
267
|
+
}
|
@@ -0,0 +1,72 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
5
|
+
|
6
|
+
export interface TraitValueFields {
|
7
|
+
hash: BN
|
8
|
+
count: number
|
9
|
+
supply: BN
|
10
|
+
}
|
11
|
+
|
12
|
+
export interface TraitValueJSON {
|
13
|
+
hash: string
|
14
|
+
count: number
|
15
|
+
supply: string
|
16
|
+
}
|
17
|
+
|
18
|
+
export class TraitValue {
|
19
|
+
readonly hash: BN
|
20
|
+
readonly count: number
|
21
|
+
readonly supply: BN
|
22
|
+
|
23
|
+
constructor(fields: TraitValueFields) {
|
24
|
+
this.hash = fields.hash
|
25
|
+
this.count = fields.count
|
26
|
+
this.supply = fields.supply
|
27
|
+
}
|
28
|
+
|
29
|
+
static layout(property?: string) {
|
30
|
+
return borsh.struct(
|
31
|
+
[borsh.u64("hash"), borsh.u32("count"), borsh.u64("supply")],
|
32
|
+
property
|
33
|
+
)
|
34
|
+
}
|
35
|
+
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
37
|
+
static fromDecoded(obj: any) {
|
38
|
+
return new TraitValue({
|
39
|
+
hash: obj.hash,
|
40
|
+
count: obj.count,
|
41
|
+
supply: obj.supply,
|
42
|
+
})
|
43
|
+
}
|
44
|
+
|
45
|
+
static toEncodable(fields: TraitValueFields) {
|
46
|
+
return {
|
47
|
+
hash: fields.hash,
|
48
|
+
count: fields.count,
|
49
|
+
supply: fields.supply,
|
50
|
+
}
|
51
|
+
}
|
52
|
+
|
53
|
+
toJSON(): TraitValueJSON {
|
54
|
+
return {
|
55
|
+
hash: this.hash.toString(),
|
56
|
+
count: this.count,
|
57
|
+
supply: this.supply.toString(),
|
58
|
+
}
|
59
|
+
}
|
60
|
+
|
61
|
+
static fromJSON(obj: TraitValueJSON): TraitValue {
|
62
|
+
return new TraitValue({
|
63
|
+
hash: new BN(obj.hash),
|
64
|
+
count: obj.count,
|
65
|
+
supply: new BN(obj.supply),
|
66
|
+
})
|
67
|
+
}
|
68
|
+
|
69
|
+
toEncodable() {
|
70
|
+
return TraitValue.toEncodable(this)
|
71
|
+
}
|
72
|
+
}
|
@@ -0,0 +1,172 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
5
|
+
|
6
|
+
export interface MintingOutJSON {
|
7
|
+
kind: "MintingOut"
|
8
|
+
}
|
9
|
+
|
10
|
+
export class MintingOut {
|
11
|
+
static readonly discriminator = 0
|
12
|
+
static readonly kind = "MintingOut"
|
13
|
+
readonly discriminator = 0
|
14
|
+
readonly kind = "MintingOut"
|
15
|
+
|
16
|
+
toJSON(): MintingOutJSON {
|
17
|
+
return {
|
18
|
+
kind: "MintingOut",
|
19
|
+
}
|
20
|
+
}
|
21
|
+
|
22
|
+
toEncodable() {
|
23
|
+
return {
|
24
|
+
MintingOut: {},
|
25
|
+
}
|
26
|
+
}
|
27
|
+
}
|
28
|
+
|
29
|
+
export type SupplyFields = {
|
30
|
+
limit: number
|
31
|
+
}
|
32
|
+
export type SupplyValue = {
|
33
|
+
limit: number
|
34
|
+
}
|
35
|
+
|
36
|
+
export interface SupplyJSON {
|
37
|
+
kind: "Supply"
|
38
|
+
value: {
|
39
|
+
limit: number
|
40
|
+
}
|
41
|
+
}
|
42
|
+
|
43
|
+
export class Supply {
|
44
|
+
static readonly discriminator = 1
|
45
|
+
static readonly kind = "Supply"
|
46
|
+
readonly discriminator = 1
|
47
|
+
readonly kind = "Supply"
|
48
|
+
readonly value: SupplyValue
|
49
|
+
|
50
|
+
constructor(value: SupplyFields) {
|
51
|
+
this.value = {
|
52
|
+
limit: value.limit,
|
53
|
+
}
|
54
|
+
}
|
55
|
+
|
56
|
+
toJSON(): SupplyJSON {
|
57
|
+
return {
|
58
|
+
kind: "Supply",
|
59
|
+
value: {
|
60
|
+
limit: this.value.limit,
|
61
|
+
},
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
65
|
+
toEncodable() {
|
66
|
+
return {
|
67
|
+
Supply: {
|
68
|
+
limit: this.value.limit,
|
69
|
+
},
|
70
|
+
}
|
71
|
+
}
|
72
|
+
}
|
73
|
+
|
74
|
+
export type HoursFields = {
|
75
|
+
hours: number
|
76
|
+
}
|
77
|
+
export type HoursValue = {
|
78
|
+
hours: number
|
79
|
+
}
|
80
|
+
|
81
|
+
export interface HoursJSON {
|
82
|
+
kind: "Hours"
|
83
|
+
value: {
|
84
|
+
hours: number
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
export class Hours {
|
89
|
+
static readonly discriminator = 2
|
90
|
+
static readonly kind = "Hours"
|
91
|
+
readonly discriminator = 2
|
92
|
+
readonly kind = "Hours"
|
93
|
+
readonly value: HoursValue
|
94
|
+
|
95
|
+
constructor(value: HoursFields) {
|
96
|
+
this.value = {
|
97
|
+
hours: value.hours,
|
98
|
+
}
|
99
|
+
}
|
100
|
+
|
101
|
+
toJSON(): HoursJSON {
|
102
|
+
return {
|
103
|
+
kind: "Hours",
|
104
|
+
value: {
|
105
|
+
hours: this.value.hours,
|
106
|
+
},
|
107
|
+
}
|
108
|
+
}
|
109
|
+
|
110
|
+
toEncodable() {
|
111
|
+
return {
|
112
|
+
Hours: {
|
113
|
+
hours: this.value.hours,
|
114
|
+
},
|
115
|
+
}
|
116
|
+
}
|
117
|
+
}
|
118
|
+
|
119
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
120
|
+
export function fromDecoded(obj: any): types.UnlocksAfterKind {
|
121
|
+
if (typeof obj !== "object") {
|
122
|
+
throw new Error("Invalid enum object")
|
123
|
+
}
|
124
|
+
|
125
|
+
if ("MintingOut" in obj) {
|
126
|
+
return new MintingOut()
|
127
|
+
}
|
128
|
+
if ("Supply" in obj) {
|
129
|
+
const val = obj["Supply"]
|
130
|
+
return new Supply({
|
131
|
+
limit: val["limit"],
|
132
|
+
})
|
133
|
+
}
|
134
|
+
if ("Hours" in obj) {
|
135
|
+
const val = obj["Hours"]
|
136
|
+
return new Hours({
|
137
|
+
hours: val["hours"],
|
138
|
+
})
|
139
|
+
}
|
140
|
+
|
141
|
+
throw new Error("Invalid enum object")
|
142
|
+
}
|
143
|
+
|
144
|
+
export function fromJSON(obj: types.UnlocksAfterJSON): types.UnlocksAfterKind {
|
145
|
+
switch (obj.kind) {
|
146
|
+
case "MintingOut": {
|
147
|
+
return new MintingOut()
|
148
|
+
}
|
149
|
+
case "Supply": {
|
150
|
+
return new Supply({
|
151
|
+
limit: obj.value.limit,
|
152
|
+
})
|
153
|
+
}
|
154
|
+
case "Hours": {
|
155
|
+
return new Hours({
|
156
|
+
hours: obj.value.hours,
|
157
|
+
})
|
158
|
+
}
|
159
|
+
}
|
160
|
+
}
|
161
|
+
|
162
|
+
export function layout(property?: string) {
|
163
|
+
const ret = borsh.rustEnum([
|
164
|
+
borsh.struct([], "MintingOut"),
|
165
|
+
borsh.struct([borsh.u32("limit")], "Supply"),
|
166
|
+
borsh.struct([borsh.u16("hours")], "Hours"),
|
167
|
+
])
|
168
|
+
if (property !== undefined) {
|
169
|
+
return ret.replicate(property)
|
170
|
+
}
|
171
|
+
return ret
|
172
|
+
}
|
@@ -0,0 +1,156 @@
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
5
|
+
|
6
|
+
export interface UnwrapMetadataFields {
|
7
|
+
wrappedAmount: BN
|
8
|
+
decimals: number
|
9
|
+
traitHash: BN
|
10
|
+
name: string
|
11
|
+
arweave: string
|
12
|
+
edition: number
|
13
|
+
leafIndex: number
|
14
|
+
cardIndex: number | null
|
15
|
+
royalty: number
|
16
|
+
creators: Array<types.ShortCreatorFields>
|
17
|
+
bumps: Array<number>
|
18
|
+
}
|
19
|
+
|
20
|
+
export interface UnwrapMetadataJSON {
|
21
|
+
wrappedAmount: string
|
22
|
+
decimals: number
|
23
|
+
traitHash: string
|
24
|
+
name: string
|
25
|
+
arweave: string
|
26
|
+
edition: number
|
27
|
+
leafIndex: number
|
28
|
+
cardIndex: number | null
|
29
|
+
royalty: number
|
30
|
+
creators: Array<types.ShortCreatorJSON>
|
31
|
+
bumps: Array<number>
|
32
|
+
}
|
33
|
+
|
34
|
+
export class UnwrapMetadata {
|
35
|
+
readonly wrappedAmount: BN
|
36
|
+
readonly decimals: number
|
37
|
+
readonly traitHash: BN
|
38
|
+
readonly name: string
|
39
|
+
readonly arweave: string
|
40
|
+
readonly edition: number
|
41
|
+
readonly leafIndex: number
|
42
|
+
readonly cardIndex: number | null
|
43
|
+
readonly royalty: number
|
44
|
+
readonly creators: Array<types.ShortCreator>
|
45
|
+
readonly bumps: Array<number>
|
46
|
+
|
47
|
+
constructor(fields: UnwrapMetadataFields) {
|
48
|
+
this.wrappedAmount = fields.wrappedAmount
|
49
|
+
this.decimals = fields.decimals
|
50
|
+
this.traitHash = fields.traitHash
|
51
|
+
this.name = fields.name
|
52
|
+
this.arweave = fields.arweave
|
53
|
+
this.edition = fields.edition
|
54
|
+
this.leafIndex = fields.leafIndex
|
55
|
+
this.cardIndex = fields.cardIndex
|
56
|
+
this.royalty = fields.royalty
|
57
|
+
this.creators = fields.creators.map(
|
58
|
+
(item) => new types.ShortCreator({ ...item })
|
59
|
+
)
|
60
|
+
this.bumps = fields.bumps
|
61
|
+
}
|
62
|
+
|
63
|
+
static layout(property?: string) {
|
64
|
+
return borsh.struct(
|
65
|
+
[
|
66
|
+
borsh.u64("wrappedAmount"),
|
67
|
+
borsh.u8("decimals"),
|
68
|
+
borsh.u64("traitHash"),
|
69
|
+
borsh.str("name"),
|
70
|
+
borsh.str("arweave"),
|
71
|
+
borsh.u32("edition"),
|
72
|
+
borsh.u32("leafIndex"),
|
73
|
+
borsh.option(borsh.u32(), "cardIndex"),
|
74
|
+
borsh.u16("royalty"),
|
75
|
+
borsh.vec(types.ShortCreator.layout(), "creators"),
|
76
|
+
borsh.array(borsh.u8(), 2, "bumps"),
|
77
|
+
],
|
78
|
+
property
|
79
|
+
)
|
80
|
+
}
|
81
|
+
|
82
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
83
|
+
static fromDecoded(obj: any) {
|
84
|
+
return new UnwrapMetadata({
|
85
|
+
wrappedAmount: obj.wrappedAmount,
|
86
|
+
decimals: obj.decimals,
|
87
|
+
traitHash: obj.traitHash,
|
88
|
+
name: obj.name,
|
89
|
+
arweave: obj.arweave,
|
90
|
+
edition: obj.edition,
|
91
|
+
leafIndex: obj.leafIndex,
|
92
|
+
cardIndex: obj.cardIndex,
|
93
|
+
royalty: obj.royalty,
|
94
|
+
creators: obj.creators.map(
|
95
|
+
(
|
96
|
+
item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
|
97
|
+
) => types.ShortCreator.fromDecoded(item)
|
98
|
+
),
|
99
|
+
bumps: obj.bumps,
|
100
|
+
})
|
101
|
+
}
|
102
|
+
|
103
|
+
static toEncodable(fields: UnwrapMetadataFields) {
|
104
|
+
return {
|
105
|
+
wrappedAmount: fields.wrappedAmount,
|
106
|
+
decimals: fields.decimals,
|
107
|
+
traitHash: fields.traitHash,
|
108
|
+
name: fields.name,
|
109
|
+
arweave: fields.arweave,
|
110
|
+
edition: fields.edition,
|
111
|
+
leafIndex: fields.leafIndex,
|
112
|
+
cardIndex: fields.cardIndex,
|
113
|
+
royalty: fields.royalty,
|
114
|
+
creators: fields.creators.map((item) =>
|
115
|
+
types.ShortCreator.toEncodable(item)
|
116
|
+
),
|
117
|
+
bumps: fields.bumps,
|
118
|
+
}
|
119
|
+
}
|
120
|
+
|
121
|
+
toJSON(): UnwrapMetadataJSON {
|
122
|
+
return {
|
123
|
+
wrappedAmount: this.wrappedAmount.toString(),
|
124
|
+
decimals: this.decimals,
|
125
|
+
traitHash: this.traitHash.toString(),
|
126
|
+
name: this.name,
|
127
|
+
arweave: this.arweave,
|
128
|
+
edition: this.edition,
|
129
|
+
leafIndex: this.leafIndex,
|
130
|
+
cardIndex: this.cardIndex,
|
131
|
+
royalty: this.royalty,
|
132
|
+
creators: this.creators.map((item) => item.toJSON()),
|
133
|
+
bumps: this.bumps,
|
134
|
+
}
|
135
|
+
}
|
136
|
+
|
137
|
+
static fromJSON(obj: UnwrapMetadataJSON): UnwrapMetadata {
|
138
|
+
return new UnwrapMetadata({
|
139
|
+
wrappedAmount: new BN(obj.wrappedAmount),
|
140
|
+
decimals: obj.decimals,
|
141
|
+
traitHash: new BN(obj.traitHash),
|
142
|
+
name: obj.name,
|
143
|
+
arweave: obj.arweave,
|
144
|
+
edition: obj.edition,
|
145
|
+
leafIndex: obj.leafIndex,
|
146
|
+
cardIndex: obj.cardIndex,
|
147
|
+
royalty: obj.royalty,
|
148
|
+
creators: obj.creators.map((item) => types.ShortCreator.fromJSON(item)),
|
149
|
+
bumps: obj.bumps,
|
150
|
+
})
|
151
|
+
}
|
152
|
+
|
153
|
+
toEncodable() {
|
154
|
+
return UnwrapMetadata.toEncodable(this)
|
155
|
+
}
|
156
|
+
}
|