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,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 PackContentFields {
8
+ class: types.AccountClassKind
9
+ cards: PublicKey
10
+ }
11
+
12
+ export interface PackContentJSON {
13
+ class: types.AccountClassJSON
14
+ cards: string
15
+ }
16
+
17
+ export class PackContent {
18
+ readonly class: types.AccountClassKind
19
+ readonly cards: PublicKey
20
+
21
+ static readonly discriminator = Buffer.from([
22
+ 89, 183, 142, 94, 35, 115, 253, 159,
23
+ ])
24
+
25
+ static readonly layout = borsh.struct([
26
+ types.AccountClass.layout("class"),
27
+ borsh.publicKey("cards"),
28
+ ])
29
+
30
+ constructor(fields: PackContentFields) {
31
+ this.class = fields.class
32
+ this.cards = fields.cards
33
+ }
34
+
35
+ static async fetch(
36
+ c: Connection,
37
+ address: PublicKey,
38
+ programId: PublicKey = PROGRAM_ID
39
+ ): Promise<PackContent | 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<PackContent | 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): PackContent {
72
+ if (!data.slice(0, 8).equals(PackContent.discriminator)) {
73
+ throw new Error("invalid account discriminator")
74
+ }
75
+
76
+ const dec = PackContent.layout.decode(data.slice(8))
77
+
78
+ return new PackContent({
79
+ class: types.AccountClass.fromDecoded(dec.class),
80
+ cards: dec.cards,
81
+ })
82
+ }
83
+
84
+ toJSON(): PackContentJSON {
85
+ return {
86
+ class: this.class.toJSON(),
87
+ cards: this.cards.toString(),
88
+ }
89
+ }
90
+
91
+ static fromJSON(obj: PackContentJSON): PackContent {
92
+ return new PackContent({
93
+ class: types.AccountClass.fromJSON(obj.class),
94
+ cards: new PublicKey(obj.cards),
95
+ })
96
+ }
97
+ }
@@ -0,0 +1,141 @@
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 PackOpenHolderFields {
8
+ class: types.AccountClassKind
9
+ state: types.PackOpenHolderStateKind
10
+ pack: PublicKey
11
+ creator: PublicKey
12
+ claimer: PublicKey
13
+ packType: types.PackTypeKind
14
+ items: Array<types.SelectedCardFields>
15
+ }
16
+
17
+ export interface PackOpenHolderJSON {
18
+ class: types.AccountClassJSON
19
+ state: types.PackOpenHolderStateJSON
20
+ pack: string
21
+ creator: string
22
+ claimer: string
23
+ packType: types.PackTypeJSON
24
+ items: Array<types.SelectedCardJSON>
25
+ }
26
+
27
+ export class PackOpenHolder {
28
+ readonly class: types.AccountClassKind
29
+ readonly state: types.PackOpenHolderStateKind
30
+ readonly pack: PublicKey
31
+ readonly creator: PublicKey
32
+ readonly claimer: PublicKey
33
+ readonly packType: types.PackTypeKind
34
+ readonly items: Array<types.SelectedCard>
35
+
36
+ static readonly discriminator = Buffer.from([
37
+ 54, 190, 160, 171, 255, 212, 144, 120,
38
+ ])
39
+
40
+ static readonly layout = borsh.struct([
41
+ types.AccountClass.layout("class"),
42
+ types.PackOpenHolderState.layout("state"),
43
+ borsh.publicKey("pack"),
44
+ borsh.publicKey("creator"),
45
+ borsh.publicKey("claimer"),
46
+ types.PackType.layout("packType"),
47
+ borsh.vec(types.SelectedCard.layout(), "items"),
48
+ ])
49
+
50
+ constructor(fields: PackOpenHolderFields) {
51
+ this.class = fields.class
52
+ this.state = fields.state
53
+ this.pack = fields.pack
54
+ this.creator = fields.creator
55
+ this.claimer = fields.claimer
56
+ this.packType = fields.packType
57
+ this.items = fields.items.map((item) => new types.SelectedCard({ ...item }))
58
+ }
59
+
60
+ static async fetch(
61
+ c: Connection,
62
+ address: PublicKey,
63
+ programId: PublicKey = PROGRAM_ID
64
+ ): Promise<PackOpenHolder | null> {
65
+ const info = await c.getAccountInfo(address)
66
+
67
+ if (info === null) {
68
+ return null
69
+ }
70
+ if (!info.owner.equals(programId)) {
71
+ throw new Error("account doesn't belong to this program")
72
+ }
73
+
74
+ return this.decode(info.data)
75
+ }
76
+
77
+ static async fetchMultiple(
78
+ c: Connection,
79
+ addresses: PublicKey[],
80
+ programId: PublicKey = PROGRAM_ID
81
+ ): Promise<Array<PackOpenHolder | null>> {
82
+ const infos = await c.getMultipleAccountsInfo(addresses)
83
+
84
+ return infos.map((info) => {
85
+ if (info === null) {
86
+ return null
87
+ }
88
+ if (!info.owner.equals(programId)) {
89
+ throw new Error("account doesn't belong to this program")
90
+ }
91
+
92
+ return this.decode(info.data)
93
+ })
94
+ }
95
+
96
+ static decode(data: Buffer): PackOpenHolder {
97
+ if (!data.slice(0, 8).equals(PackOpenHolder.discriminator)) {
98
+ throw new Error("invalid account discriminator")
99
+ }
100
+
101
+ const dec = PackOpenHolder.layout.decode(data.slice(8))
102
+
103
+ return new PackOpenHolder({
104
+ class: types.AccountClass.fromDecoded(dec.class),
105
+ state: types.PackOpenHolderState.fromDecoded(dec.state),
106
+ pack: dec.pack,
107
+ creator: dec.creator,
108
+ claimer: dec.claimer,
109
+ packType: types.PackType.fromDecoded(dec.packType),
110
+ items: dec.items.map(
111
+ (
112
+ item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
113
+ ) => types.SelectedCard.fromDecoded(item)
114
+ ),
115
+ })
116
+ }
117
+
118
+ toJSON(): PackOpenHolderJSON {
119
+ return {
120
+ class: this.class.toJSON(),
121
+ state: this.state.toJSON(),
122
+ pack: this.pack.toString(),
123
+ creator: this.creator.toString(),
124
+ claimer: this.claimer.toString(),
125
+ packType: this.packType.toJSON(),
126
+ items: this.items.map((item) => item.toJSON()),
127
+ }
128
+ }
129
+
130
+ static fromJSON(obj: PackOpenHolderJSON): PackOpenHolder {
131
+ return new PackOpenHolder({
132
+ class: types.AccountClass.fromJSON(obj.class),
133
+ state: types.PackOpenHolderState.fromJSON(obj.state),
134
+ pack: new PublicKey(obj.pack),
135
+ creator: new PublicKey(obj.creator),
136
+ claimer: new PublicKey(obj.claimer),
137
+ packType: types.PackType.fromJSON(obj.packType),
138
+ items: obj.items.map((item) => types.SelectedCard.fromJSON(item)),
139
+ })
140
+ }
141
+ }
@@ -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 PackReceiptFields {
8
+ class: types.AccountClassKind
9
+ cnft: PublicKey
10
+ pack: PublicKey
11
+ creator: PublicKey
12
+ state: types.PackStateKind
13
+ cardsInside: number
14
+ slot: BN
15
+ created: number
16
+ }
17
+
18
+ export interface PackReceiptJSON {
19
+ class: types.AccountClassJSON
20
+ cnft: string
21
+ pack: string
22
+ creator: string
23
+ state: types.PackStateJSON
24
+ cardsInside: number
25
+ slot: string
26
+ created: number
27
+ }
28
+
29
+ export class PackReceipt {
30
+ readonly class: types.AccountClassKind
31
+ readonly cnft: PublicKey
32
+ readonly pack: PublicKey
33
+ readonly creator: PublicKey
34
+ readonly state: types.PackStateKind
35
+ readonly cardsInside: number
36
+ readonly slot: BN
37
+ readonly created: number
38
+
39
+ static readonly discriminator = Buffer.from([
40
+ 117, 14, 250, 166, 162, 131, 180, 180,
41
+ ])
42
+
43
+ static readonly layout = borsh.struct([
44
+ types.AccountClass.layout("class"),
45
+ borsh.publicKey("cnft"),
46
+ borsh.publicKey("pack"),
47
+ borsh.publicKey("creator"),
48
+ types.PackState.layout("state"),
49
+ borsh.u8("cardsInside"),
50
+ borsh.u64("slot"),
51
+ borsh.u32("created"),
52
+ ])
53
+
54
+ constructor(fields: PackReceiptFields) {
55
+ this.class = fields.class
56
+ this.cnft = fields.cnft
57
+ this.pack = fields.pack
58
+ this.creator = fields.creator
59
+ this.state = fields.state
60
+ this.cardsInside = fields.cardsInside
61
+ this.slot = fields.slot
62
+ this.created = fields.created
63
+ }
64
+
65
+ static async fetch(
66
+ c: Connection,
67
+ address: PublicKey,
68
+ programId: PublicKey = PROGRAM_ID
69
+ ): Promise<PackReceipt | 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<PackReceipt | 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): PackReceipt {
102
+ if (!data.slice(0, 8).equals(PackReceipt.discriminator)) {
103
+ throw new Error("invalid account discriminator")
104
+ }
105
+
106
+ const dec = PackReceipt.layout.decode(data.slice(8))
107
+
108
+ return new PackReceipt({
109
+ class: types.AccountClass.fromDecoded(dec.class),
110
+ cnft: dec.cnft,
111
+ pack: dec.pack,
112
+ creator: dec.creator,
113
+ state: types.PackState.fromDecoded(dec.state),
114
+ cardsInside: dec.cardsInside,
115
+ slot: dec.slot,
116
+ created: dec.created,
117
+ })
118
+ }
119
+
120
+ toJSON(): PackReceiptJSON {
121
+ return {
122
+ class: this.class.toJSON(),
123
+ cnft: this.cnft.toString(),
124
+ pack: this.pack.toString(),
125
+ creator: this.creator.toString(),
126
+ state: this.state.toJSON(),
127
+ cardsInside: this.cardsInside,
128
+ slot: this.slot.toString(),
129
+ created: this.created,
130
+ }
131
+ }
132
+
133
+ static fromJSON(obj: PackReceiptJSON): PackReceipt {
134
+ return new PackReceipt({
135
+ class: types.AccountClass.fromJSON(obj.class),
136
+ cnft: new PublicKey(obj.cnft),
137
+ pack: new PublicKey(obj.pack),
138
+ creator: new PublicKey(obj.creator),
139
+ state: types.PackState.fromJSON(obj.state),
140
+ cardsInside: obj.cardsInside,
141
+ slot: new BN(obj.slot),
142
+ created: obj.created,
143
+ })
144
+ }
145
+ }
@@ -0,0 +1,101 @@
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 PackTraitsFields {
8
+ class: types.AccountClassKind
9
+ list: Array<types.TraitTypeKind>
10
+ }
11
+
12
+ export interface PackTraitsJSON {
13
+ class: types.AccountClassJSON
14
+ list: Array<types.TraitTypeJSON>
15
+ }
16
+
17
+ export class PackTraits {
18
+ readonly class: types.AccountClassKind
19
+ readonly list: Array<types.TraitTypeKind>
20
+
21
+ static readonly discriminator = Buffer.from([
22
+ 238, 139, 229, 97, 133, 123, 168, 248,
23
+ ])
24
+
25
+ static readonly layout = borsh.struct([
26
+ types.AccountClass.layout("class"),
27
+ borsh.vec(types.TraitType.layout(), "list"),
28
+ ])
29
+
30
+ constructor(fields: PackTraitsFields) {
31
+ this.class = fields.class
32
+ this.list = fields.list
33
+ }
34
+
35
+ static async fetch(
36
+ c: Connection,
37
+ address: PublicKey,
38
+ programId: PublicKey = PROGRAM_ID
39
+ ): Promise<PackTraits | 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<PackTraits | 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): PackTraits {
72
+ if (!data.slice(0, 8).equals(PackTraits.discriminator)) {
73
+ throw new Error("invalid account discriminator")
74
+ }
75
+
76
+ const dec = PackTraits.layout.decode(data.slice(8))
77
+
78
+ return new PackTraits({
79
+ class: types.AccountClass.fromDecoded(dec.class),
80
+ list: dec.list.map(
81
+ (
82
+ item: any /* eslint-disable-line @typescript-eslint/no-explicit-any */
83
+ ) => types.TraitType.fromDecoded(item)
84
+ ),
85
+ })
86
+ }
87
+
88
+ toJSON(): PackTraitsJSON {
89
+ return {
90
+ class: this.class.toJSON(),
91
+ list: this.list.map((item) => item.toJSON()),
92
+ }
93
+ }
94
+
95
+ static fromJSON(obj: PackTraitsJSON): PackTraits {
96
+ return new PackTraits({
97
+ class: types.AccountClass.fromJSON(obj.class),
98
+ list: obj.list.map((item) => types.TraitType.fromJSON(item)),
99
+ })
100
+ }
101
+ }
@@ -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 PaymentFields {
8
+ class: types.PaymentClassKind
9
+ hash: Array<number>
10
+ }
11
+
12
+ export interface PaymentJSON {
13
+ class: types.PaymentClassJSON
14
+ hash: Array<number>
15
+ }
16
+
17
+ export class Payment {
18
+ readonly class: types.PaymentClassKind
19
+ readonly hash: Array<number>
20
+
21
+ static readonly discriminator = Buffer.from([
22
+ 227, 231, 51, 26, 244, 88, 4, 148,
23
+ ])
24
+
25
+ static readonly layout = borsh.struct([
26
+ types.PaymentClass.layout("class"),
27
+ borsh.array(borsh.u8(), 32, "hash"),
28
+ ])
29
+
30
+ constructor(fields: PaymentFields) {
31
+ this.class = fields.class
32
+ this.hash = fields.hash
33
+ }
34
+
35
+ static async fetch(
36
+ c: Connection,
37
+ address: PublicKey,
38
+ programId: PublicKey = PROGRAM_ID
39
+ ): Promise<Payment | 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<Payment | 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): Payment {
72
+ if (!data.slice(0, 8).equals(Payment.discriminator)) {
73
+ throw new Error("invalid account discriminator")
74
+ }
75
+
76
+ const dec = Payment.layout.decode(data.slice(8))
77
+
78
+ return new Payment({
79
+ class: types.PaymentClass.fromDecoded(dec.class),
80
+ hash: dec.hash,
81
+ })
82
+ }
83
+
84
+ toJSON(): PaymentJSON {
85
+ return {
86
+ class: this.class.toJSON(),
87
+ hash: this.hash,
88
+ }
89
+ }
90
+
91
+ static fromJSON(obj: PaymentJSON): Payment {
92
+ return new Payment({
93
+ class: types.PaymentClass.fromJSON(obj.class),
94
+ hash: obj.hash,
95
+ })
96
+ }
97
+ }