3land_sdk 1.0.0

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