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,177 @@
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 PoolVaultFields {
8
+ class: types.AccountClassKind
9
+ state: types.PoolStateKind
10
+ storeHash: BN
11
+ currency: PublicKey
12
+ creator: PublicKey
13
+ poolType: types.PoolTypeKind
14
+ access: types.PoolAccessKind
15
+ deposit: BN
16
+ secured: BN
17
+ decimals: number
18
+ managers: Array<PublicKey>
19
+ name: string
20
+ }
21
+
22
+ export interface PoolVaultJSON {
23
+ class: types.AccountClassJSON
24
+ state: types.PoolStateJSON
25
+ storeHash: string
26
+ currency: string
27
+ creator: string
28
+ poolType: types.PoolTypeJSON
29
+ access: types.PoolAccessJSON
30
+ deposit: string
31
+ secured: string
32
+ decimals: number
33
+ managers: Array<string>
34
+ name: string
35
+ }
36
+
37
+ export class PoolVault {
38
+ readonly class: types.AccountClassKind
39
+ readonly state: types.PoolStateKind
40
+ readonly storeHash: BN
41
+ readonly currency: PublicKey
42
+ readonly creator: PublicKey
43
+ readonly poolType: types.PoolTypeKind
44
+ readonly access: types.PoolAccessKind
45
+ readonly deposit: BN
46
+ readonly secured: BN
47
+ readonly decimals: number
48
+ readonly managers: Array<PublicKey>
49
+ readonly name: string
50
+
51
+ static readonly discriminator = Buffer.from([
52
+ 9, 184, 204, 69, 231, 82, 252, 154,
53
+ ])
54
+
55
+ static readonly layout = borsh.struct([
56
+ types.AccountClass.layout("class"),
57
+ types.PoolState.layout("state"),
58
+ borsh.u64("storeHash"),
59
+ borsh.publicKey("currency"),
60
+ borsh.publicKey("creator"),
61
+ types.PoolType.layout("poolType"),
62
+ types.PoolAccess.layout("access"),
63
+ borsh.u64("deposit"),
64
+ borsh.u64("secured"),
65
+ borsh.u8("decimals"),
66
+ borsh.vec(borsh.publicKey(), "managers"),
67
+ borsh.str("name"),
68
+ ])
69
+
70
+ constructor(fields: PoolVaultFields) {
71
+ this.class = fields.class
72
+ this.state = fields.state
73
+ this.storeHash = fields.storeHash
74
+ this.currency = fields.currency
75
+ this.creator = fields.creator
76
+ this.poolType = fields.poolType
77
+ this.access = fields.access
78
+ this.deposit = fields.deposit
79
+ this.secured = fields.secured
80
+ this.decimals = fields.decimals
81
+ this.managers = fields.managers
82
+ this.name = fields.name
83
+ }
84
+
85
+ static async fetch(
86
+ c: Connection,
87
+ address: PublicKey,
88
+ programId: PublicKey = PROGRAM_ID
89
+ ): Promise<PoolVault | null> {
90
+ const info = await c.getAccountInfo(address)
91
+
92
+ if (info === null) {
93
+ return null
94
+ }
95
+ if (!info.owner.equals(programId)) {
96
+ throw new Error("account doesn't belong to this program")
97
+ }
98
+
99
+ return this.decode(info.data)
100
+ }
101
+
102
+ static async fetchMultiple(
103
+ c: Connection,
104
+ addresses: PublicKey[],
105
+ programId: PublicKey = PROGRAM_ID
106
+ ): Promise<Array<PoolVault | null>> {
107
+ const infos = await c.getMultipleAccountsInfo(addresses)
108
+
109
+ return infos.map((info) => {
110
+ if (info === null) {
111
+ return null
112
+ }
113
+ if (!info.owner.equals(programId)) {
114
+ throw new Error("account doesn't belong to this program")
115
+ }
116
+
117
+ return this.decode(info.data)
118
+ })
119
+ }
120
+
121
+ static decode(data: Buffer): PoolVault {
122
+ if (!data.slice(0, 8).equals(PoolVault.discriminator)) {
123
+ throw new Error("invalid account discriminator")
124
+ }
125
+
126
+ const dec = PoolVault.layout.decode(data.slice(8))
127
+
128
+ return new PoolVault({
129
+ class: types.AccountClass.fromDecoded(dec.class),
130
+ state: types.PoolState.fromDecoded(dec.state),
131
+ storeHash: dec.storeHash,
132
+ currency: dec.currency,
133
+ creator: dec.creator,
134
+ poolType: types.PoolType.fromDecoded(dec.poolType),
135
+ access: types.PoolAccess.fromDecoded(dec.access),
136
+ deposit: dec.deposit,
137
+ secured: dec.secured,
138
+ decimals: dec.decimals,
139
+ managers: dec.managers,
140
+ name: dec.name,
141
+ })
142
+ }
143
+
144
+ toJSON(): PoolVaultJSON {
145
+ return {
146
+ class: this.class.toJSON(),
147
+ state: this.state.toJSON(),
148
+ storeHash: this.storeHash.toString(),
149
+ currency: this.currency.toString(),
150
+ creator: this.creator.toString(),
151
+ poolType: this.poolType.toJSON(),
152
+ access: this.access.toJSON(),
153
+ deposit: this.deposit.toString(),
154
+ secured: this.secured.toString(),
155
+ decimals: this.decimals,
156
+ managers: this.managers.map((item) => item.toString()),
157
+ name: this.name,
158
+ }
159
+ }
160
+
161
+ static fromJSON(obj: PoolVaultJSON): PoolVault {
162
+ return new PoolVault({
163
+ class: types.AccountClass.fromJSON(obj.class),
164
+ state: types.PoolState.fromJSON(obj.state),
165
+ storeHash: new BN(obj.storeHash),
166
+ currency: new PublicKey(obj.currency),
167
+ creator: new PublicKey(obj.creator),
168
+ poolType: types.PoolType.fromJSON(obj.poolType),
169
+ access: types.PoolAccess.fromJSON(obj.access),
170
+ deposit: new BN(obj.deposit),
171
+ secured: new BN(obj.secured),
172
+ decimals: obj.decimals,
173
+ managers: obj.managers.map((item) => new PublicKey(item)),
174
+ name: obj.name,
175
+ })
176
+ }
177
+ }
@@ -0,0 +1,139 @@
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 RevealForMeFields {
8
+ class: types.AccountClassKind
9
+ storeHalfHash: Array<number>
10
+ state: number
11
+ creator: PublicKey
12
+ nft: PublicKey
13
+ random: number
14
+ data: Uint8Array
15
+ }
16
+
17
+ export interface RevealForMeJSON {
18
+ class: types.AccountClassJSON
19
+ storeHalfHash: Array<number>
20
+ state: number
21
+ creator: string
22
+ nft: string
23
+ random: number
24
+ data: Array<number>
25
+ }
26
+
27
+ export class RevealForMe {
28
+ readonly class: types.AccountClassKind
29
+ readonly storeHalfHash: Array<number>
30
+ readonly state: number
31
+ readonly creator: PublicKey
32
+ readonly nft: PublicKey
33
+ readonly random: number
34
+ readonly data: Uint8Array
35
+
36
+ static readonly discriminator = Buffer.from([5, 57, 21, 62, 5, 138, 252, 237])
37
+
38
+ static readonly layout = borsh.struct([
39
+ types.AccountClass.layout("class"),
40
+ borsh.array(borsh.u8(), 4, "storeHalfHash"),
41
+ borsh.u8("state"),
42
+ borsh.publicKey("creator"),
43
+ borsh.publicKey("nft"),
44
+ borsh.u16("random"),
45
+ borsh.vecU8("data"),
46
+ ])
47
+
48
+ constructor(fields: RevealForMeFields) {
49
+ this.class = fields.class
50
+ this.storeHalfHash = fields.storeHalfHash
51
+ this.state = fields.state
52
+ this.creator = fields.creator
53
+ this.nft = fields.nft
54
+ this.random = fields.random
55
+ this.data = fields.data
56
+ }
57
+
58
+ static async fetch(
59
+ c: Connection,
60
+ address: PublicKey,
61
+ programId: PublicKey = PROGRAM_ID
62
+ ): Promise<RevealForMe | null> {
63
+ const info = await c.getAccountInfo(address)
64
+
65
+ if (info === null) {
66
+ return null
67
+ }
68
+ if (!info.owner.equals(programId)) {
69
+ throw new Error("account doesn't belong to this program")
70
+ }
71
+
72
+ return this.decode(info.data)
73
+ }
74
+
75
+ static async fetchMultiple(
76
+ c: Connection,
77
+ addresses: PublicKey[],
78
+ programId: PublicKey = PROGRAM_ID
79
+ ): Promise<Array<RevealForMe | null>> {
80
+ const infos = await c.getMultipleAccountsInfo(addresses)
81
+
82
+ return infos.map((info) => {
83
+ if (info === null) {
84
+ return null
85
+ }
86
+ if (!info.owner.equals(programId)) {
87
+ throw new Error("account doesn't belong to this program")
88
+ }
89
+
90
+ return this.decode(info.data)
91
+ })
92
+ }
93
+
94
+ static decode(data: Buffer): RevealForMe {
95
+ if (!data.slice(0, 8).equals(RevealForMe.discriminator)) {
96
+ throw new Error("invalid account discriminator")
97
+ }
98
+
99
+ const dec = RevealForMe.layout.decode(data.slice(8))
100
+
101
+ return new RevealForMe({
102
+ class: types.AccountClass.fromDecoded(dec.class),
103
+ storeHalfHash: dec.storeHalfHash,
104
+ state: dec.state,
105
+ creator: dec.creator,
106
+ nft: dec.nft,
107
+ random: dec.random,
108
+ data: new Uint8Array(
109
+ dec.data.buffer,
110
+ dec.data.byteOffset,
111
+ dec.data.length
112
+ ),
113
+ })
114
+ }
115
+
116
+ toJSON(): RevealForMeJSON {
117
+ return {
118
+ class: this.class.toJSON(),
119
+ storeHalfHash: this.storeHalfHash,
120
+ state: this.state,
121
+ creator: this.creator.toString(),
122
+ nft: this.nft.toString(),
123
+ random: this.random,
124
+ data: Array.from(this.data.values()),
125
+ }
126
+ }
127
+
128
+ static fromJSON(obj: RevealForMeJSON): RevealForMe {
129
+ return new RevealForMe({
130
+ class: types.AccountClass.fromJSON(obj.class),
131
+ storeHalfHash: obj.storeHalfHash,
132
+ state: obj.state,
133
+ creator: new PublicKey(obj.creator),
134
+ nft: new PublicKey(obj.nft),
135
+ random: obj.random,
136
+ data: Uint8Array.from(obj.data),
137
+ })
138
+ }
139
+ }
@@ -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 SecureHolderFields {
8
+ class: types.AccountClassKind
9
+ payload: types.EncryptedPayloadFields
10
+ }
11
+
12
+ export interface SecureHolderJSON {
13
+ class: types.AccountClassJSON
14
+ payload: types.EncryptedPayloadJSON
15
+ }
16
+
17
+ export class SecureHolder {
18
+ readonly class: types.AccountClassKind
19
+ readonly payload: types.EncryptedPayload
20
+
21
+ static readonly discriminator = Buffer.from([
22
+ 103, 104, 14, 27, 41, 183, 120, 21,
23
+ ])
24
+
25
+ static readonly layout = borsh.struct([
26
+ types.AccountClass.layout("class"),
27
+ types.EncryptedPayload.layout("payload"),
28
+ ])
29
+
30
+ constructor(fields: SecureHolderFields) {
31
+ this.class = fields.class
32
+ this.payload = new types.EncryptedPayload({ ...fields.payload })
33
+ }
34
+
35
+ static async fetch(
36
+ c: Connection,
37
+ address: PublicKey,
38
+ programId: PublicKey = PROGRAM_ID
39
+ ): Promise<SecureHolder | 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<SecureHolder | 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): SecureHolder {
72
+ if (!data.slice(0, 8).equals(SecureHolder.discriminator)) {
73
+ throw new Error("invalid account discriminator")
74
+ }
75
+
76
+ const dec = SecureHolder.layout.decode(data.slice(8))
77
+
78
+ return new SecureHolder({
79
+ class: types.AccountClass.fromDecoded(dec.class),
80
+ payload: types.EncryptedPayload.fromDecoded(dec.payload),
81
+ })
82
+ }
83
+
84
+ toJSON(): SecureHolderJSON {
85
+ return {
86
+ class: this.class.toJSON(),
87
+ payload: this.payload.toJSON(),
88
+ }
89
+ }
90
+
91
+ static fromJSON(obj: SecureHolderJSON): SecureHolder {
92
+ return new SecureHolder({
93
+ class: types.AccountClass.fromJSON(obj.class),
94
+ payload: types.EncryptedPayload.fromJSON(obj.payload),
95
+ })
96
+ }
97
+ }
@@ -0,0 +1,301 @@
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 SingleFields {
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
+ saleConfig: types.SaleConfigFields
30
+ identifier: BN
31
+ hash: BN
32
+ hashTraits: BN
33
+ volume: Array<types.FakeVolumeTrackFields>
34
+ extra: Array<number>
35
+ }
36
+
37
+ export interface SingleJSON {
38
+ class: types.AccountClassJSON
39
+ globalState: types.GlobalStateJSON
40
+ holder: string
41
+ creator: string
42
+ dates: types.IndexDatesJSON
43
+ category: types.CategoryJSON
44
+ superCategory: types.SuperCategoryJSON
45
+ eventCategory: number
46
+ trackType: types.TrackRegistryJSON
47
+ mainCurrencyHash: string
48
+ track: types.ItemTrackJSON
49
+ popularity: types.PopularityJSON
50
+ filtering: types.FilterJSON
51
+ page: string
52
+ manager: string
53
+ isServerless: number
54
+ availableOption: number
55
+ hasWrappedTokens: number
56
+ burntPieces: number
57
+ flag: Array<number>
58
+ item: types.ItemJSON
59
+ saleConfig: types.SaleConfigJSON
60
+ identifier: string
61
+ hash: string
62
+ hashTraits: string
63
+ volume: Array<types.FakeVolumeTrackJSON>
64
+ extra: Array<number>
65
+ }
66
+
67
+ export class Single {
68
+ readonly class: types.AccountClassKind
69
+ readonly globalState: types.GlobalStateKind
70
+ readonly holder: PublicKey
71
+ readonly creator: PublicKey
72
+ readonly dates: types.IndexDates
73
+ readonly category: types.Category
74
+ readonly superCategory: types.SuperCategory
75
+ readonly eventCategory: number
76
+ readonly trackType: types.TrackRegistryKind
77
+ readonly mainCurrencyHash: BN
78
+ readonly track: types.ItemTrack
79
+ readonly popularity: types.Popularity
80
+ readonly filtering: types.Filter
81
+ readonly page: BN
82
+ readonly manager: PublicKey
83
+ readonly isServerless: number
84
+ readonly availableOption: number
85
+ readonly hasWrappedTokens: number
86
+ readonly burntPieces: number
87
+ readonly flag: Array<number>
88
+ readonly item: types.Item
89
+ readonly saleConfig: types.SaleConfig
90
+ readonly identifier: BN
91
+ readonly hash: BN
92
+ readonly hashTraits: BN
93
+ readonly volume: Array<types.FakeVolumeTrack>
94
+ readonly extra: Array<number>
95
+
96
+ static readonly discriminator = Buffer.from([23, 154, 0, 26, 73, 227, 49, 70])
97
+
98
+ static readonly layout = borsh.struct([
99
+ types.AccountClass.layout("class"),
100
+ types.GlobalState.layout("globalState"),
101
+ borsh.publicKey("holder"),
102
+ borsh.publicKey("creator"),
103
+ types.IndexDates.layout("dates"),
104
+ types.Category.layout("category"),
105
+ types.SuperCategory.layout("superCategory"),
106
+ borsh.u16("eventCategory"),
107
+ types.TrackRegistry.layout("trackType"),
108
+ borsh.u64("mainCurrencyHash"),
109
+ types.ItemTrack.layout("track"),
110
+ types.Popularity.layout("popularity"),
111
+ types.Filter.layout("filtering"),
112
+ borsh.u64("page"),
113
+ borsh.publicKey("manager"),
114
+ borsh.u8("isServerless"),
115
+ borsh.u8("availableOption"),
116
+ borsh.u8("hasWrappedTokens"),
117
+ borsh.u32("burntPieces"),
118
+ borsh.array(borsh.u8(), 1, "flag"),
119
+ types.Item.layout("item"),
120
+ types.SaleConfig.layout("saleConfig"),
121
+ borsh.u64("identifier"),
122
+ borsh.u64("hash"),
123
+ borsh.u64("hashTraits"),
124
+ borsh.vec(types.FakeVolumeTrack.layout(), "volume"),
125
+ borsh.array(borsh.u8(), 4, "extra"),
126
+ ])
127
+
128
+ constructor(fields: SingleFields) {
129
+ this.class = fields.class
130
+ this.globalState = fields.globalState
131
+ this.holder = fields.holder
132
+ this.creator = fields.creator
133
+ this.dates = new types.IndexDates({ ...fields.dates })
134
+ this.category = new types.Category({ ...fields.category })
135
+ this.superCategory = new types.SuperCategory({ ...fields.superCategory })
136
+ this.eventCategory = fields.eventCategory
137
+ this.trackType = fields.trackType
138
+ this.mainCurrencyHash = fields.mainCurrencyHash
139
+ this.track = new types.ItemTrack({ ...fields.track })
140
+ this.popularity = new types.Popularity({ ...fields.popularity })
141
+ this.filtering = new types.Filter({ ...fields.filtering })
142
+ this.page = fields.page
143
+ this.manager = fields.manager
144
+ this.isServerless = fields.isServerless
145
+ this.availableOption = fields.availableOption
146
+ this.hasWrappedTokens = fields.hasWrappedTokens
147
+ this.burntPieces = fields.burntPieces
148
+ this.flag = fields.flag
149
+ this.item = new types.Item({ ...fields.item })
150
+ this.saleConfig = new types.SaleConfig({ ...fields.saleConfig })
151
+ this.identifier = fields.identifier
152
+ this.hash = fields.hash
153
+ this.hashTraits = fields.hashTraits
154
+ this.volume = fields.volume.map(
155
+ (item) => new types.FakeVolumeTrack({ ...item })
156
+ )
157
+ this.extra = fields.extra
158
+ }
159
+
160
+ static async fetch(
161
+ c: Connection,
162
+ address: PublicKey,
163
+ programId: PublicKey = PROGRAM_ID
164
+ ): Promise<Single | null> {
165
+ const info = await c.getAccountInfo(address)
166
+
167
+ if (info === null) {
168
+ return null
169
+ }
170
+ if (!info.owner.equals(programId)) {
171
+ throw new Error("account doesn't belong to this program")
172
+ }
173
+
174
+ return this.decode(info.data)
175
+ }
176
+
177
+ static async fetchMultiple(
178
+ c: Connection,
179
+ addresses: PublicKey[],
180
+ programId: PublicKey = PROGRAM_ID
181
+ ): Promise<Array<Single | null>> {
182
+ const infos = await c.getMultipleAccountsInfo(addresses)
183
+
184
+ return infos.map((info) => {
185
+ if (info === null) {
186
+ return null
187
+ }
188
+ if (!info.owner.equals(programId)) {
189
+ throw new Error("account doesn't belong to this program")
190
+ }
191
+
192
+ return this.decode(info.data)
193
+ })
194
+ }
195
+
196
+ static decode(data: Buffer): Single {
197
+ if (!data.slice(0, 8).equals(Single.discriminator)) {
198
+ throw new Error("invalid account discriminator")
199
+ }
200
+
201
+ const dec = Single.layout.decode(data.slice(8))
202
+
203
+ return new Single({
204
+ class: types.AccountClass.fromDecoded(dec.class),
205
+ globalState: types.GlobalState.fromDecoded(dec.globalState),
206
+ holder: dec.holder,
207
+ creator: dec.creator,
208
+ dates: types.IndexDates.fromDecoded(dec.dates),
209
+ category: types.Category.fromDecoded(dec.category),
210
+ superCategory: types.SuperCategory.fromDecoded(dec.superCategory),
211
+ eventCategory: dec.eventCategory,
212
+ trackType: types.TrackRegistry.fromDecoded(dec.trackType),
213
+ mainCurrencyHash: dec.mainCurrencyHash,
214
+ track: types.ItemTrack.fromDecoded(dec.track),
215
+ popularity: types.Popularity.fromDecoded(dec.popularity),
216
+ filtering: types.Filter.fromDecoded(dec.filtering),
217
+ page: dec.page,
218
+ manager: dec.manager,
219
+ isServerless: dec.isServerless,
220
+ availableOption: dec.availableOption,
221
+ hasWrappedTokens: dec.hasWrappedTokens,
222
+ burntPieces: dec.burntPieces,
223
+ flag: dec.flag,
224
+ item: types.Item.fromDecoded(dec.item),
225
+ saleConfig: types.SaleConfig.fromDecoded(dec.saleConfig),
226
+ identifier: dec.identifier,
227
+ hash: dec.hash,
228
+ hashTraits: dec.hashTraits,
229
+ volume: dec.volume.map(
230
+ (
231
+ item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
232
+ ) => types.FakeVolumeTrack.fromDecoded(item)
233
+ ),
234
+ extra: dec.extra,
235
+ })
236
+ }
237
+
238
+ toJSON(): SingleJSON {
239
+ return {
240
+ class: this.class.toJSON(),
241
+ globalState: this.globalState.toJSON(),
242
+ holder: this.holder.toString(),
243
+ creator: this.creator.toString(),
244
+ dates: this.dates.toJSON(),
245
+ category: this.category.toJSON(),
246
+ superCategory: this.superCategory.toJSON(),
247
+ eventCategory: this.eventCategory,
248
+ trackType: this.trackType.toJSON(),
249
+ mainCurrencyHash: this.mainCurrencyHash.toString(),
250
+ track: this.track.toJSON(),
251
+ popularity: this.popularity.toJSON(),
252
+ filtering: this.filtering.toJSON(),
253
+ page: this.page.toString(),
254
+ manager: this.manager.toString(),
255
+ isServerless: this.isServerless,
256
+ availableOption: this.availableOption,
257
+ hasWrappedTokens: this.hasWrappedTokens,
258
+ burntPieces: this.burntPieces,
259
+ flag: this.flag,
260
+ item: this.item.toJSON(),
261
+ saleConfig: this.saleConfig.toJSON(),
262
+ identifier: this.identifier.toString(),
263
+ hash: this.hash.toString(),
264
+ hashTraits: this.hashTraits.toString(),
265
+ volume: this.volume.map((item) => item.toJSON()),
266
+ extra: this.extra,
267
+ }
268
+ }
269
+
270
+ static fromJSON(obj: SingleJSON): Single {
271
+ return new Single({
272
+ class: types.AccountClass.fromJSON(obj.class),
273
+ globalState: types.GlobalState.fromJSON(obj.globalState),
274
+ holder: new PublicKey(obj.holder),
275
+ creator: new PublicKey(obj.creator),
276
+ dates: types.IndexDates.fromJSON(obj.dates),
277
+ category: types.Category.fromJSON(obj.category),
278
+ superCategory: types.SuperCategory.fromJSON(obj.superCategory),
279
+ eventCategory: obj.eventCategory,
280
+ trackType: types.TrackRegistry.fromJSON(obj.trackType),
281
+ mainCurrencyHash: new BN(obj.mainCurrencyHash),
282
+ track: types.ItemTrack.fromJSON(obj.track),
283
+ popularity: types.Popularity.fromJSON(obj.popularity),
284
+ filtering: types.Filter.fromJSON(obj.filtering),
285
+ page: new BN(obj.page),
286
+ manager: new PublicKey(obj.manager),
287
+ isServerless: obj.isServerless,
288
+ availableOption: obj.availableOption,
289
+ hasWrappedTokens: obj.hasWrappedTokens,
290
+ burntPieces: obj.burntPieces,
291
+ flag: obj.flag,
292
+ item: types.Item.fromJSON(obj.item),
293
+ saleConfig: types.SaleConfig.fromJSON(obj.saleConfig),
294
+ identifier: new BN(obj.identifier),
295
+ hash: new BN(obj.hash),
296
+ hashTraits: new BN(obj.hashTraits),
297
+ volume: obj.volume.map((item) => types.FakeVolumeTrack.fromJSON(item)),
298
+ extra: obj.extra,
299
+ })
300
+ }
301
+ }