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,121 @@
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 BuyHistoryFields {
8
+ class: types.AccountClassKind
9
+ buyType: types.BuyHistoryClassKind
10
+ owner: PublicKey
11
+ item: PublicKey
12
+ store: PublicKey
13
+ }
14
+
15
+ export interface BuyHistoryJSON {
16
+ class: types.AccountClassJSON
17
+ buyType: types.BuyHistoryClassJSON
18
+ owner: string
19
+ item: string
20
+ store: string
21
+ }
22
+
23
+ export class BuyHistory {
24
+ readonly class: types.AccountClassKind
25
+ readonly buyType: types.BuyHistoryClassKind
26
+ readonly owner: PublicKey
27
+ readonly item: PublicKey
28
+ readonly store: PublicKey
29
+
30
+ static readonly discriminator = Buffer.from([
31
+ 10, 217, 83, 243, 244, 164, 203, 202,
32
+ ])
33
+
34
+ static readonly layout = borsh.struct([
35
+ types.AccountClass.layout("class"),
36
+ types.BuyHistoryClass.layout("buyType"),
37
+ borsh.publicKey("owner"),
38
+ borsh.publicKey("item"),
39
+ borsh.publicKey("store"),
40
+ ])
41
+
42
+ constructor(fields: BuyHistoryFields) {
43
+ this.class = fields.class
44
+ this.buyType = fields.buyType
45
+ this.owner = fields.owner
46
+ this.item = fields.item
47
+ this.store = fields.store
48
+ }
49
+
50
+ static async fetch(
51
+ c: Connection,
52
+ address: PublicKey,
53
+ programId: PublicKey = PROGRAM_ID
54
+ ): Promise<BuyHistory | null> {
55
+ const info = await c.getAccountInfo(address)
56
+
57
+ if (info === null) {
58
+ return null
59
+ }
60
+ if (!info.owner.equals(programId)) {
61
+ throw new Error("account doesn't belong to this program")
62
+ }
63
+
64
+ return this.decode(info.data)
65
+ }
66
+
67
+ static async fetchMultiple(
68
+ c: Connection,
69
+ addresses: PublicKey[],
70
+ programId: PublicKey = PROGRAM_ID
71
+ ): Promise<Array<BuyHistory | null>> {
72
+ const infos = await c.getMultipleAccountsInfo(addresses)
73
+
74
+ return infos.map((info) => {
75
+ if (info === null) {
76
+ return null
77
+ }
78
+ if (!info.owner.equals(programId)) {
79
+ throw new Error("account doesn't belong to this program")
80
+ }
81
+
82
+ return this.decode(info.data)
83
+ })
84
+ }
85
+
86
+ static decode(data: Buffer): BuyHistory {
87
+ if (!data.slice(0, 8).equals(BuyHistory.discriminator)) {
88
+ throw new Error("invalid account discriminator")
89
+ }
90
+
91
+ const dec = BuyHistory.layout.decode(data.slice(8))
92
+
93
+ return new BuyHistory({
94
+ class: types.AccountClass.fromDecoded(dec.class),
95
+ buyType: types.BuyHistoryClass.fromDecoded(dec.buyType),
96
+ owner: dec.owner,
97
+ item: dec.item,
98
+ store: dec.store,
99
+ })
100
+ }
101
+
102
+ toJSON(): BuyHistoryJSON {
103
+ return {
104
+ class: this.class.toJSON(),
105
+ buyType: this.buyType.toJSON(),
106
+ owner: this.owner.toString(),
107
+ item: this.item.toString(),
108
+ store: this.store.toString(),
109
+ }
110
+ }
111
+
112
+ static fromJSON(obj: BuyHistoryJSON): BuyHistory {
113
+ return new BuyHistory({
114
+ class: types.AccountClass.fromJSON(obj.class),
115
+ buyType: types.BuyHistoryClass.fromJSON(obj.buyType),
116
+ owner: new PublicKey(obj.owner),
117
+ item: new PublicKey(obj.item),
118
+ store: new PublicKey(obj.store),
119
+ })
120
+ }
121
+ }
@@ -0,0 +1,94 @@
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 BuyTrackFields {
8
+ count: number
9
+ time: number
10
+ }
11
+
12
+ export interface BuyTrackJSON {
13
+ count: number
14
+ time: number
15
+ }
16
+
17
+ export class BuyTrack {
18
+ readonly count: number
19
+ readonly time: number
20
+
21
+ static readonly discriminator = Buffer.from([
22
+ 127, 195, 236, 128, 20, 28, 179, 140,
23
+ ])
24
+
25
+ static readonly layout = borsh.struct([borsh.u32("count"), borsh.u32("time")])
26
+
27
+ constructor(fields: BuyTrackFields) {
28
+ this.count = fields.count
29
+ this.time = fields.time
30
+ }
31
+
32
+ static async fetch(
33
+ c: Connection,
34
+ address: PublicKey,
35
+ programId: PublicKey = PROGRAM_ID
36
+ ): Promise<BuyTrack | null> {
37
+ const info = await c.getAccountInfo(address)
38
+
39
+ if (info === null) {
40
+ return null
41
+ }
42
+ if (!info.owner.equals(programId)) {
43
+ throw new Error("account doesn't belong to this program")
44
+ }
45
+
46
+ return this.decode(info.data)
47
+ }
48
+
49
+ static async fetchMultiple(
50
+ c: Connection,
51
+ addresses: PublicKey[],
52
+ programId: PublicKey = PROGRAM_ID
53
+ ): Promise<Array<BuyTrack | null>> {
54
+ const infos = await c.getMultipleAccountsInfo(addresses)
55
+
56
+ return infos.map((info) => {
57
+ if (info === null) {
58
+ return null
59
+ }
60
+ if (!info.owner.equals(programId)) {
61
+ throw new Error("account doesn't belong to this program")
62
+ }
63
+
64
+ return this.decode(info.data)
65
+ })
66
+ }
67
+
68
+ static decode(data: Buffer): BuyTrack {
69
+ if (!data.slice(0, 8).equals(BuyTrack.discriminator)) {
70
+ throw new Error("invalid account discriminator")
71
+ }
72
+
73
+ const dec = BuyTrack.layout.decode(data.slice(8))
74
+
75
+ return new BuyTrack({
76
+ count: dec.count,
77
+ time: dec.time,
78
+ })
79
+ }
80
+
81
+ toJSON(): BuyTrackJSON {
82
+ return {
83
+ count: this.count,
84
+ time: this.time,
85
+ }
86
+ }
87
+
88
+ static fromJSON(obj: BuyTrackJSON): BuyTrack {
89
+ return new BuyTrack({
90
+ count: obj.count,
91
+ time: obj.time,
92
+ })
93
+ }
94
+ }
@@ -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 CardFields {
8
+ class: types.AccountClassKind
9
+ globalState: types.GlobalStateKind
10
+ store: PublicKey
11
+ creator: PublicKey
12
+ holder: PublicKey
13
+ hash: BN
14
+ page: BN
15
+ manager: PublicKey
16
+ index: number
17
+ hashTraits: BN
18
+ created: number
19
+ reserved: Array<number>
20
+ item: types.ItemFields
21
+ }
22
+
23
+ export interface CardJSON {
24
+ class: types.AccountClassJSON
25
+ globalState: types.GlobalStateJSON
26
+ store: string
27
+ creator: string
28
+ holder: string
29
+ hash: string
30
+ page: string
31
+ manager: string
32
+ index: number
33
+ hashTraits: string
34
+ created: number
35
+ reserved: Array<number>
36
+ item: types.ItemJSON
37
+ }
38
+
39
+ export class Card {
40
+ readonly class: types.AccountClassKind
41
+ readonly globalState: types.GlobalStateKind
42
+ readonly store: PublicKey
43
+ readonly creator: PublicKey
44
+ readonly holder: PublicKey
45
+ readonly hash: BN
46
+ readonly page: BN
47
+ readonly manager: PublicKey
48
+ readonly index: number
49
+ readonly hashTraits: BN
50
+ readonly created: number
51
+ readonly reserved: Array<number>
52
+ readonly item: types.Item
53
+
54
+ static readonly discriminator = Buffer.from([
55
+ 166, 250, 46, 230, 152, 63, 140, 182,
56
+ ])
57
+
58
+ static readonly layout = borsh.struct([
59
+ types.AccountClass.layout("class"),
60
+ types.GlobalState.layout("globalState"),
61
+ borsh.publicKey("store"),
62
+ borsh.publicKey("creator"),
63
+ borsh.publicKey("holder"),
64
+ borsh.u64("hash"),
65
+ borsh.u64("page"),
66
+ borsh.publicKey("manager"),
67
+ borsh.u16("index"),
68
+ borsh.u64("hashTraits"),
69
+ borsh.u32("created"),
70
+ borsh.array(borsh.u8(), 16, "reserved"),
71
+ types.Item.layout("item"),
72
+ ])
73
+
74
+ constructor(fields: CardFields) {
75
+ this.class = fields.class
76
+ this.globalState = fields.globalState
77
+ this.store = fields.store
78
+ this.creator = fields.creator
79
+ this.holder = fields.holder
80
+ this.hash = fields.hash
81
+ this.page = fields.page
82
+ this.manager = fields.manager
83
+ this.index = fields.index
84
+ this.hashTraits = fields.hashTraits
85
+ this.created = fields.created
86
+ this.reserved = fields.reserved
87
+ this.item = new types.Item({ ...fields.item })
88
+ }
89
+
90
+ static async fetch(
91
+ c: Connection,
92
+ address: PublicKey,
93
+ programId: PublicKey = PROGRAM_ID
94
+ ): Promise<Card | null> {
95
+ const info = await c.getAccountInfo(address)
96
+
97
+ if (info === null) {
98
+ return null
99
+ }
100
+ if (!info.owner.equals(programId)) {
101
+ throw new Error("account doesn't belong to this program")
102
+ }
103
+
104
+ return this.decode(info.data)
105
+ }
106
+
107
+ static async fetchMultiple(
108
+ c: Connection,
109
+ addresses: PublicKey[],
110
+ programId: PublicKey = PROGRAM_ID
111
+ ): Promise<Array<Card | null>> {
112
+ const infos = await c.getMultipleAccountsInfo(addresses)
113
+
114
+ return infos.map((info) => {
115
+ if (info === null) {
116
+ return null
117
+ }
118
+ if (!info.owner.equals(programId)) {
119
+ throw new Error("account doesn't belong to this program")
120
+ }
121
+
122
+ return this.decode(info.data)
123
+ })
124
+ }
125
+
126
+ static decode(data: Buffer): Card {
127
+ if (!data.slice(0, 8).equals(Card.discriminator)) {
128
+ throw new Error("invalid account discriminator")
129
+ }
130
+
131
+ const dec = Card.layout.decode(data.slice(8))
132
+
133
+ return new Card({
134
+ class: types.AccountClass.fromDecoded(dec.class),
135
+ globalState: types.GlobalState.fromDecoded(dec.globalState),
136
+ store: dec.store,
137
+ creator: dec.creator,
138
+ holder: dec.holder,
139
+ hash: dec.hash,
140
+ page: dec.page,
141
+ manager: dec.manager,
142
+ index: dec.index,
143
+ hashTraits: dec.hashTraits,
144
+ created: dec.created,
145
+ reserved: dec.reserved,
146
+ item: types.Item.fromDecoded(dec.item),
147
+ })
148
+ }
149
+
150
+ toJSON(): CardJSON {
151
+ return {
152
+ class: this.class.toJSON(),
153
+ globalState: this.globalState.toJSON(),
154
+ store: this.store.toString(),
155
+ creator: this.creator.toString(),
156
+ holder: this.holder.toString(),
157
+ hash: this.hash.toString(),
158
+ page: this.page.toString(),
159
+ manager: this.manager.toString(),
160
+ index: this.index,
161
+ hashTraits: this.hashTraits.toString(),
162
+ created: this.created,
163
+ reserved: this.reserved,
164
+ item: this.item.toJSON(),
165
+ }
166
+ }
167
+
168
+ static fromJSON(obj: CardJSON): Card {
169
+ return new Card({
170
+ class: types.AccountClass.fromJSON(obj.class),
171
+ globalState: types.GlobalState.fromJSON(obj.globalState),
172
+ store: new PublicKey(obj.store),
173
+ creator: new PublicKey(obj.creator),
174
+ holder: new PublicKey(obj.holder),
175
+ hash: new BN(obj.hash),
176
+ page: new BN(obj.page),
177
+ manager: new PublicKey(obj.manager),
178
+ index: obj.index,
179
+ hashTraits: new BN(obj.hashTraits),
180
+ created: obj.created,
181
+ reserved: obj.reserved,
182
+ item: types.Item.fromJSON(obj.item),
183
+ })
184
+ }
185
+ }
@@ -0,0 +1,145 @@
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 CollectionRegistryFields {
8
+ class: types.AccountClassKind
9
+ storeHash: BN
10
+ currency: PublicKey
11
+ collection: PublicKey
12
+ donations: BN
13
+ date: types.IndexDateFields
14
+ filters: Array<number>
15
+ track: types.SaleTrackFields
16
+ }
17
+
18
+ export interface CollectionRegistryJSON {
19
+ class: types.AccountClassJSON
20
+ storeHash: string
21
+ currency: string
22
+ collection: string
23
+ donations: string
24
+ date: types.IndexDateJSON
25
+ filters: Array<number>
26
+ track: types.SaleTrackJSON
27
+ }
28
+
29
+ export class CollectionRegistry {
30
+ readonly class: types.AccountClassKind
31
+ readonly storeHash: BN
32
+ readonly currency: PublicKey
33
+ readonly collection: PublicKey
34
+ readonly donations: BN
35
+ readonly date: types.IndexDate
36
+ readonly filters: Array<number>
37
+ readonly track: types.SaleTrack
38
+
39
+ static readonly discriminator = Buffer.from([
40
+ 103, 157, 231, 9, 181, 43, 15, 106,
41
+ ])
42
+
43
+ static readonly layout = borsh.struct([
44
+ types.AccountClass.layout("class"),
45
+ borsh.u64("storeHash"),
46
+ borsh.publicKey("currency"),
47
+ borsh.publicKey("collection"),
48
+ borsh.u64("donations"),
49
+ types.IndexDate.layout("date"),
50
+ borsh.array(borsh.u8(), 8, "filters"),
51
+ types.SaleTrack.layout("track"),
52
+ ])
53
+
54
+ constructor(fields: CollectionRegistryFields) {
55
+ this.class = fields.class
56
+ this.storeHash = fields.storeHash
57
+ this.currency = fields.currency
58
+ this.collection = fields.collection
59
+ this.donations = fields.donations
60
+ this.date = new types.IndexDate({ ...fields.date })
61
+ this.filters = fields.filters
62
+ this.track = new types.SaleTrack({ ...fields.track })
63
+ }
64
+
65
+ static async fetch(
66
+ c: Connection,
67
+ address: PublicKey,
68
+ programId: PublicKey = PROGRAM_ID
69
+ ): Promise<CollectionRegistry | null> {
70
+ const info = await c.getAccountInfo(address)
71
+
72
+ if (info === null) {
73
+ return null
74
+ }
75
+ if (!info.owner.equals(programId)) {
76
+ throw new Error("account doesn't belong to this program")
77
+ }
78
+
79
+ return this.decode(info.data)
80
+ }
81
+
82
+ static async fetchMultiple(
83
+ c: Connection,
84
+ addresses: PublicKey[],
85
+ programId: PublicKey = PROGRAM_ID
86
+ ): Promise<Array<CollectionRegistry | null>> {
87
+ const infos = await c.getMultipleAccountsInfo(addresses)
88
+
89
+ return infos.map((info) => {
90
+ if (info === null) {
91
+ return null
92
+ }
93
+ if (!info.owner.equals(programId)) {
94
+ throw new Error("account doesn't belong to this program")
95
+ }
96
+
97
+ return this.decode(info.data)
98
+ })
99
+ }
100
+
101
+ static decode(data: Buffer): CollectionRegistry {
102
+ if (!data.slice(0, 8).equals(CollectionRegistry.discriminator)) {
103
+ throw new Error("invalid account discriminator")
104
+ }
105
+
106
+ const dec = CollectionRegistry.layout.decode(data.slice(8))
107
+
108
+ return new CollectionRegistry({
109
+ class: types.AccountClass.fromDecoded(dec.class),
110
+ storeHash: dec.storeHash,
111
+ currency: dec.currency,
112
+ collection: dec.collection,
113
+ donations: dec.donations,
114
+ date: types.IndexDate.fromDecoded(dec.date),
115
+ filters: dec.filters,
116
+ track: types.SaleTrack.fromDecoded(dec.track),
117
+ })
118
+ }
119
+
120
+ toJSON(): CollectionRegistryJSON {
121
+ return {
122
+ class: this.class.toJSON(),
123
+ storeHash: this.storeHash.toString(),
124
+ currency: this.currency.toString(),
125
+ collection: this.collection.toString(),
126
+ donations: this.donations.toString(),
127
+ date: this.date.toJSON(),
128
+ filters: this.filters,
129
+ track: this.track.toJSON(),
130
+ }
131
+ }
132
+
133
+ static fromJSON(obj: CollectionRegistryJSON): CollectionRegistry {
134
+ return new CollectionRegistry({
135
+ class: types.AccountClass.fromJSON(obj.class),
136
+ storeHash: new BN(obj.storeHash),
137
+ currency: new PublicKey(obj.currency),
138
+ collection: new PublicKey(obj.collection),
139
+ donations: new BN(obj.donations),
140
+ date: types.IndexDate.fromJSON(obj.date),
141
+ filters: obj.filters,
142
+ track: types.SaleTrack.fromJSON(obj.track),
143
+ })
144
+ }
145
+ }
@@ -0,0 +1,145 @@
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 CollectorRegistryFields {
8
+ class: types.AccountClassKind
9
+ storeHash: BN
10
+ creator: PublicKey
11
+ holder: PublicKey
12
+ currency: PublicKey
13
+ date: types.IndexDateFields
14
+ filters: Array<number>
15
+ track: types.CollectTrackFields
16
+ }
17
+
18
+ export interface CollectorRegistryJSON {
19
+ class: types.AccountClassJSON
20
+ storeHash: string
21
+ creator: string
22
+ holder: string
23
+ currency: string
24
+ date: types.IndexDateJSON
25
+ filters: Array<number>
26
+ track: types.CollectTrackJSON
27
+ }
28
+
29
+ export class CollectorRegistry {
30
+ readonly class: types.AccountClassKind
31
+ readonly storeHash: BN
32
+ readonly creator: PublicKey
33
+ readonly holder: PublicKey
34
+ readonly currency: PublicKey
35
+ readonly date: types.IndexDate
36
+ readonly filters: Array<number>
37
+ readonly track: types.CollectTrack
38
+
39
+ static readonly discriminator = Buffer.from([
40
+ 25, 164, 62, 184, 54, 145, 8, 211,
41
+ ])
42
+
43
+ static readonly layout = borsh.struct([
44
+ types.AccountClass.layout("class"),
45
+ borsh.u64("storeHash"),
46
+ borsh.publicKey("creator"),
47
+ borsh.publicKey("holder"),
48
+ borsh.publicKey("currency"),
49
+ types.IndexDate.layout("date"),
50
+ borsh.array(borsh.u8(), 4, "filters"),
51
+ types.CollectTrack.layout("track"),
52
+ ])
53
+
54
+ constructor(fields: CollectorRegistryFields) {
55
+ this.class = fields.class
56
+ this.storeHash = fields.storeHash
57
+ this.creator = fields.creator
58
+ this.holder = fields.holder
59
+ this.currency = fields.currency
60
+ this.date = new types.IndexDate({ ...fields.date })
61
+ this.filters = fields.filters
62
+ this.track = new types.CollectTrack({ ...fields.track })
63
+ }
64
+
65
+ static async fetch(
66
+ c: Connection,
67
+ address: PublicKey,
68
+ programId: PublicKey = PROGRAM_ID
69
+ ): Promise<CollectorRegistry | null> {
70
+ const info = await c.getAccountInfo(address)
71
+
72
+ if (info === null) {
73
+ return null
74
+ }
75
+ if (!info.owner.equals(programId)) {
76
+ throw new Error("account doesn't belong to this program")
77
+ }
78
+
79
+ return this.decode(info.data)
80
+ }
81
+
82
+ static async fetchMultiple(
83
+ c: Connection,
84
+ addresses: PublicKey[],
85
+ programId: PublicKey = PROGRAM_ID
86
+ ): Promise<Array<CollectorRegistry | null>> {
87
+ const infos = await c.getMultipleAccountsInfo(addresses)
88
+
89
+ return infos.map((info) => {
90
+ if (info === null) {
91
+ return null
92
+ }
93
+ if (!info.owner.equals(programId)) {
94
+ throw new Error("account doesn't belong to this program")
95
+ }
96
+
97
+ return this.decode(info.data)
98
+ })
99
+ }
100
+
101
+ static decode(data: Buffer): CollectorRegistry {
102
+ if (!data.slice(0, 8).equals(CollectorRegistry.discriminator)) {
103
+ throw new Error("invalid account discriminator")
104
+ }
105
+
106
+ const dec = CollectorRegistry.layout.decode(data.slice(8))
107
+
108
+ return new CollectorRegistry({
109
+ class: types.AccountClass.fromDecoded(dec.class),
110
+ storeHash: dec.storeHash,
111
+ creator: dec.creator,
112
+ holder: dec.holder,
113
+ currency: dec.currency,
114
+ date: types.IndexDate.fromDecoded(dec.date),
115
+ filters: dec.filters,
116
+ track: types.CollectTrack.fromDecoded(dec.track),
117
+ })
118
+ }
119
+
120
+ toJSON(): CollectorRegistryJSON {
121
+ return {
122
+ class: this.class.toJSON(),
123
+ storeHash: this.storeHash.toString(),
124
+ creator: this.creator.toString(),
125
+ holder: this.holder.toString(),
126
+ currency: this.currency.toString(),
127
+ date: this.date.toJSON(),
128
+ filters: this.filters,
129
+ track: this.track.toJSON(),
130
+ }
131
+ }
132
+
133
+ static fromJSON(obj: CollectorRegistryJSON): CollectorRegistry {
134
+ return new CollectorRegistry({
135
+ class: types.AccountClass.fromJSON(obj.class),
136
+ storeHash: new BN(obj.storeHash),
137
+ creator: new PublicKey(obj.creator),
138
+ holder: new PublicKey(obj.holder),
139
+ currency: new PublicKey(obj.currency),
140
+ date: types.IndexDate.fromJSON(obj.date),
141
+ filters: obj.filters,
142
+ track: types.CollectTrack.fromJSON(obj.track),
143
+ })
144
+ }
145
+ }