@helium/spl-utils 0.2.21 → 0.2.22-next.33

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (62) hide show
  1. package/package.json +9 -9
  2. package/lib/cjs/anchorError.js +0 -265
  3. package/lib/cjs/anchorError.js.map +0 -1
  4. package/lib/cjs/constants.js +0 -11
  5. package/lib/cjs/constants.js.map +0 -1
  6. package/lib/cjs/executeRemoteTxn.js +0 -109
  7. package/lib/cjs/executeRemoteTxn.js.map +0 -1
  8. package/lib/cjs/extendBorsh.js +0 -33
  9. package/lib/cjs/extendBorsh.js.map +0 -1
  10. package/lib/cjs/index.js +0 -33
  11. package/lib/cjs/index.js.map +0 -1
  12. package/lib/cjs/mplAssetAPI.js +0 -188
  13. package/lib/cjs/mplAssetAPI.js.map +0 -1
  14. package/lib/cjs/proofArgsAndAccounts.js +0 -52
  15. package/lib/cjs/proofArgsAndAccounts.js.map +0 -1
  16. package/lib/cjs/token.js +0 -235
  17. package/lib/cjs/token.js.map +0 -1
  18. package/lib/cjs/transaction.js +0 -479
  19. package/lib/cjs/transaction.js.map +0 -1
  20. package/lib/cjs/utils.js +0 -116
  21. package/lib/cjs/utils.js.map +0 -1
  22. package/lib/esm/src/anchorError.js +0 -262
  23. package/lib/esm/src/anchorError.js.map +0 -1
  24. package/lib/esm/src/constants.js +0 -8
  25. package/lib/esm/src/constants.js.map +0 -1
  26. package/lib/esm/src/executeRemoteTxn.js +0 -79
  27. package/lib/esm/src/executeRemoteTxn.js.map +0 -1
  28. package/lib/esm/src/extendBorsh.js +0 -26
  29. package/lib/esm/src/extendBorsh.js.map +0 -1
  30. package/lib/esm/src/index.js +0 -10
  31. package/lib/esm/src/index.js.map +0 -1
  32. package/lib/esm/src/mplAssetAPI.js +0 -167
  33. package/lib/esm/src/mplAssetAPI.js.map +0 -1
  34. package/lib/esm/src/proofArgsAndAccounts.js +0 -37
  35. package/lib/esm/src/proofArgsAndAccounts.js.map +0 -1
  36. package/lib/esm/src/token.js +0 -208
  37. package/lib/esm/src/token.js.map +0 -1
  38. package/lib/esm/src/transaction.js +0 -415
  39. package/lib/esm/src/transaction.js.map +0 -1
  40. package/lib/esm/src/utils.js +0 -73
  41. package/lib/esm/src/utils.js.map +0 -1
  42. package/lib/esm/tsconfig.esm.tsbuildinfo +0 -1
  43. package/lib/types/src/anchorError.d.ts +0 -9
  44. package/lib/types/src/anchorError.d.ts.map +0 -1
  45. package/lib/types/src/constants.d.ts +0 -7
  46. package/lib/types/src/constants.d.ts.map +0 -1
  47. package/lib/types/src/executeRemoteTxn.d.ts +0 -23
  48. package/lib/types/src/executeRemoteTxn.d.ts.map +0 -1
  49. package/lib/types/src/extendBorsh.d.ts +0 -3
  50. package/lib/types/src/extendBorsh.d.ts.map +0 -1
  51. package/lib/types/src/index.d.ts +0 -12
  52. package/lib/types/src/index.d.ts.map +0 -1
  53. package/lib/types/src/mplAssetAPI.d.ts +0 -70
  54. package/lib/types/src/mplAssetAPI.d.ts.map +0 -1
  55. package/lib/types/src/proofArgsAndAccounts.d.ts +0 -21
  56. package/lib/types/src/proofArgsAndAccounts.d.ts.map +0 -1
  57. package/lib/types/src/token.d.ts +0 -21
  58. package/lib/types/src/token.d.ts.map +0 -1
  59. package/lib/types/src/transaction.d.ts +0 -37
  60. package/lib/types/src/transaction.d.ts.map +0 -1
  61. package/lib/types/src/utils.d.ts +0 -19
  62. package/lib/types/src/utils.d.ts.map +0 -1
@@ -1,262 +0,0 @@
1
- // TODO: Go back to anchor once they handle:
2
- // Error: Raw transaction 4nZwiENzNwKLfCBtDirAr5xE71GUqsNKsUNafSUHiEUkWhqbVgEmximswnDFp4ZFFy5C4NXJ75qCKP6nnWBSmFey failed ({"err":{"InstructionError":[4,{"Custom":1}]}})
3
- const LangErrorCode = {
4
- // Instructions.
5
- InstructionMissing: 100,
6
- InstructionFallbackNotFound: 101,
7
- InstructionDidNotDeserialize: 102,
8
- InstructionDidNotSerialize: 103,
9
- // IDL instructions.
10
- IdlInstructionStub: 1000,
11
- IdlInstructionInvalidProgram: 1001,
12
- // Constraints.
13
- ConstraintMut: 2000,
14
- ConstraintHasOne: 2001,
15
- ConstraintSigner: 2002,
16
- ConstraintRaw: 2003,
17
- ConstraintOwner: 2004,
18
- ConstraintRentExempt: 2005,
19
- ConstraintSeeds: 2006,
20
- ConstraintExecutable: 2007,
21
- ConstraintState: 2008,
22
- ConstraintAssociated: 2009,
23
- ConstraintAssociatedInit: 2010,
24
- ConstraintClose: 2011,
25
- ConstraintAddress: 2012,
26
- ConstraintZero: 2013,
27
- ConstraintTokenMint: 2014,
28
- ConstraintTokenOwner: 2015,
29
- ConstraintMintMintAuthority: 2016,
30
- ConstraintMintFreezeAuthority: 2017,
31
- ConstraintMintDecimals: 2018,
32
- ConstraintSpace: 2019,
33
- // Accounts.
34
- AccountDiscriminatorAlreadySet: 3000,
35
- AccountDiscriminatorNotFound: 3001,
36
- AccountDiscriminatorMismatch: 3002,
37
- AccountDidNotDeserialize: 3003,
38
- AccountDidNotSerialize: 3004,
39
- AccountNotEnoughKeys: 3005,
40
- AccountNotMutable: 3006,
41
- AccountOwnedByWrongProgram: 3007,
42
- InvalidProgramId: 3008,
43
- InvalidProgramExecutable: 3009,
44
- AccountNotSigner: 3010,
45
- AccountNotSystemOwned: 3011,
46
- AccountNotInitialized: 3012,
47
- AccountNotProgramData: 3013,
48
- AccountNotAssociatedTokenAccount: 3014,
49
- // State.
50
- StateInvalidAddress: 4000,
51
- // Used for APIs that shouldn't be used anymore.
52
- Deprecated: 5000,
53
- };
54
- export const SystemErrorMessage = new Map([
55
- [
56
- 1,
57
- "Insufficient balance."
58
- ], [
59
- 2,
60
- "Invalid instruction data."
61
- ], [
62
- 3,
63
- "Invalid account data"
64
- ], [
65
- 4,
66
- "Account data too small"
67
- ], [
68
- 5,
69
- "Insufficient funds"
70
- ], [
71
- 6,
72
- "Incorrect prgoram id"
73
- ], [
74
- 7,
75
- "Missing required signature"
76
- ], [
77
- 8,
78
- "Account already initialized"
79
- ], [
80
- 9,
81
- "Attempt to operate on an account that was not yet initialized"
82
- ], [
83
- 10,
84
- "Not enough account keys provided"
85
- ], [
86
- 11,
87
- "Account borrow failed, already borrowed"
88
- ], [
89
- 12,
90
- "Max seed length exceeded"
91
- ], [
92
- 13,
93
- "Invalid seeds"
94
- ], [
95
- 14,
96
- "Borsh IO Error"
97
- ], [
98
- 15,
99
- "Account not rent exempt"
100
- ]
101
- ]);
102
- const LangErrorMessage = new Map([
103
- // Instructions.
104
- [
105
- LangErrorCode.InstructionMissing,
106
- "8 byte instruction identifier not provided",
107
- ],
108
- [
109
- LangErrorCode.InstructionFallbackNotFound,
110
- "Fallback functions are not supported",
111
- ],
112
- [
113
- LangErrorCode.InstructionDidNotDeserialize,
114
- "The program could not deserialize the given instruction",
115
- ],
116
- [
117
- LangErrorCode.InstructionDidNotSerialize,
118
- "The program could not serialize the given instruction",
119
- ],
120
- // Idl instructions.
121
- [
122
- LangErrorCode.IdlInstructionStub,
123
- "The program was compiled without idl instructions",
124
- ],
125
- [
126
- LangErrorCode.IdlInstructionInvalidProgram,
127
- "The transaction was given an invalid program for the IDL instruction",
128
- ],
129
- // Constraints.
130
- [LangErrorCode.ConstraintMut, "A mut constraint was violated"],
131
- [LangErrorCode.ConstraintHasOne, "A has_one constraint was violated"],
132
- [LangErrorCode.ConstraintSigner, "A signer constraint was violated"],
133
- [LangErrorCode.ConstraintRaw, "A raw constraint was violated"],
134
- [LangErrorCode.ConstraintOwner, "An owner constraint was violated"],
135
- [LangErrorCode.ConstraintRentExempt, "A rent exempt constraint was violated"],
136
- [LangErrorCode.ConstraintSeeds, "A seeds constraint was violated"],
137
- [LangErrorCode.ConstraintExecutable, "An executable constraint was violated"],
138
- [LangErrorCode.ConstraintState, "A state constraint was violated"],
139
- [LangErrorCode.ConstraintAssociated, "An associated constraint was violated"],
140
- [
141
- LangErrorCode.ConstraintAssociatedInit,
142
- "An associated init constraint was violated",
143
- ],
144
- [LangErrorCode.ConstraintClose, "A close constraint was violated"],
145
- [LangErrorCode.ConstraintAddress, "An address constraint was violated"],
146
- [LangErrorCode.ConstraintZero, "Expected zero account discriminant"],
147
- [LangErrorCode.ConstraintTokenMint, "A token mint constraint was violated"],
148
- [LangErrorCode.ConstraintTokenOwner, "A token owner constraint was violated"],
149
- [
150
- LangErrorCode.ConstraintMintMintAuthority,
151
- "A mint mint authority constraint was violated",
152
- ],
153
- [
154
- LangErrorCode.ConstraintMintFreezeAuthority,
155
- "A mint freeze authority constraint was violated",
156
- ],
157
- [
158
- LangErrorCode.ConstraintMintDecimals,
159
- "A mint decimals constraint was violated",
160
- ],
161
- [LangErrorCode.ConstraintSpace, "A space constraint was violated"],
162
- // Accounts.
163
- [
164
- LangErrorCode.AccountDiscriminatorAlreadySet,
165
- "The account discriminator was already set on this account",
166
- ],
167
- [
168
- LangErrorCode.AccountDiscriminatorNotFound,
169
- "No 8 byte discriminator was found on the account",
170
- ],
171
- [
172
- LangErrorCode.AccountDiscriminatorMismatch,
173
- "8 byte discriminator did not match what was expected",
174
- ],
175
- [LangErrorCode.AccountDidNotDeserialize, "Failed to deserialize the account"],
176
- [LangErrorCode.AccountDidNotSerialize, "Failed to serialize the account"],
177
- [
178
- LangErrorCode.AccountNotEnoughKeys,
179
- "Not enough account keys given to the instruction",
180
- ],
181
- [LangErrorCode.AccountNotMutable, "The given account is not mutable"],
182
- [
183
- LangErrorCode.AccountOwnedByWrongProgram,
184
- "The given account is owned by a different program than expected",
185
- ],
186
- [LangErrorCode.InvalidProgramId, "Program ID was not as expected"],
187
- [LangErrorCode.InvalidProgramExecutable, "Program account is not executable"],
188
- [LangErrorCode.AccountNotSigner, "The given account did not sign"],
189
- [
190
- LangErrorCode.AccountNotSystemOwned,
191
- "The given account is not owned by the system program",
192
- ],
193
- [
194
- LangErrorCode.AccountNotInitialized,
195
- "The program expected this account to be already initialized",
196
- ],
197
- [
198
- LangErrorCode.AccountNotProgramData,
199
- "The given account is not a program data account",
200
- ],
201
- [
202
- LangErrorCode.AccountNotAssociatedTokenAccount,
203
- "The given account is not the associated token account",
204
- ],
205
- // State.
206
- [
207
- LangErrorCode.StateInvalidAddress,
208
- "The given state account does not have the correct address",
209
- ],
210
- // Misc.
211
- [
212
- LangErrorCode.Deprecated,
213
- "The API being used is deprecated and should no longer be used",
214
- ],
215
- ]);
216
- // An error from a user defined program.
217
- export class ProgramError {
218
- code;
219
- msg;
220
- constructor(code, msg, ...params) {
221
- this.code = code;
222
- this.msg = msg;
223
- }
224
- static parse(err, idlErrors) {
225
- let errorCode = null;
226
- if (err.InstructionError) {
227
- if (typeof err.InstructionError[0] == "number") {
228
- errorCode = err.InstructionError[0];
229
- }
230
- if (err.InstructionError[1]?.Custom) {
231
- errorCode = err.InstructionError[1].Custom;
232
- }
233
- }
234
- if (errorCode == null) {
235
- // TODO: don't rely on the error string. web3.js should preserve the error
236
- // code information instead of giving us an untyped string.
237
- let components = err.toString().split("custom program error: ");
238
- if (errorCode == null && components.length !== 2) {
239
- return null;
240
- }
241
- try {
242
- errorCode = parseInt(components[1]);
243
- }
244
- catch (parseErr) {
245
- return null;
246
- }
247
- }
248
- let errorMsg = (err.InstructionErr && err.InstructionErr[1]) ||
249
- idlErrors.get(errorCode) ||
250
- LangErrorMessage.get(errorCode) ||
251
- SystemErrorMessage.get(errorCode);
252
- if (errorMsg !== undefined) {
253
- return new ProgramError(errorCode, errorMsg, errorCode + ": " + errorMsg);
254
- }
255
- // Unable to parse the error. Just return the untranslated error.
256
- return null;
257
- }
258
- toString() {
259
- return this.msg;
260
- }
261
- }
262
- //# sourceMappingURL=anchorError.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"anchorError.js","sourceRoot":"","sources":["../../../src/anchorError.ts"],"names":[],"mappings":"AAAA,4CAA4C;AAC5C,yKAAyK;AAGzK,MAAM,aAAa,GAAG;IACpB,gBAAgB;IAChB,kBAAkB,EAAE,GAAG;IACvB,2BAA2B,EAAE,GAAG;IAChC,4BAA4B,EAAE,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AC,MAAM,KAAK,CAAC,EAAE;gBAChD,OAAO,IAAI,CAAC;aACb;YAED,IAAI;gBACF,SAAS,GAAG,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC;aACrC;YAAC,OAAO,QAAQ,EAAE;gBACjB,OAAO,IAAI,CAAC;aACb;SACF;QAED,IAAI,QAAQ,GACV,CAAC,GAAG,CAAC,cAAc,IAAI,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,CAAC;YAC7C,SAAS,CAAC,GAAG,CAAC,SAAS,CAAC;YACxB,gBAAgB,CAAC,GAAG,CAAC,SAAS,CAAC;YAC/B,kBAAkB,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC;QACpC,IAAI,QAAQ,KAAK,SAAS,EAAE;YAC1B,OAAO,IAAI,YAAY,CAAC,SAAS,EAAE,QAAQ,EAAE,SAAS,GAAG,IAAI,GAAG,QAAQ,CAAC,CAAC;SAC3E;QAED,iEAAiE;QACjE,OAAO,IAAI,CAAC;IACd,CAAC;IAEM,QAAQ;QACb,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;CACF"}
@@ -1,8 +0,0 @@
1
- import { PublicKey } from "@solana/web3.js";
2
- export const DC_MINT = new PublicKey("dcuc8Amr83Wz27ZkQ2K9NS6r8zRpf1J6cvArEBDZDmm");
3
- export const HNT_MINT = new PublicKey("hntyVP6YFm1Hg25TN9WGLqM12b8TQmcknKrdu1oxWux");
4
- export const MOBILE_MINT = new PublicKey("mb1eu7TzEc71KxDpsmsKoucSSuuoGLv1drys1oP2jh6");
5
- export const IOT_MINT = new PublicKey("iotEVVZLEywoTn1QdwNPddxPWszn3zFhEot3MfL9fns");
6
- // TODO: Replace with actual HNT feed
7
- export const HNT_PYTH_PRICE_FEED = new PublicKey("6Eg8YdfFJQF2HHonzPUBSCCmyUEhrStg9VBLK957sBe6");
8
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/constants.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAE5C,MAAM,CAAC,MAAM,OAAO,GAAG,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;AAEpF,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;AAErF,MAAM,CAAC,MAAM,WAAW,GAAG,IAAI,SAAS,CACtC,6CAA6C,CAC9C,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GAAG,IAAI,SAAS,CAAC,6CAA6C,CAAC,CAAC;AAErF,qCAAqC;AACrC,MAAM,CAAC,MAAM,mBAAmB,GAAG,IAAI,SAAS,CAC9C,8CAA8C,CAC/C,CAAC"}
@@ -1,79 +0,0 @@
1
- import { Transaction } from "@solana/web3.js";
2
- import { ProgramError } from "./anchorError";
3
- import axios from "axios";
4
- import { sendAndConfirmWithRetry } from "./transaction";
5
- async function promiseAllInOrder(it) {
6
- let ret = [];
7
- for (const i of it) {
8
- ret.push(await i());
9
- }
10
- return ret;
11
- }
12
- /**
13
- * Execute transactions from a remote server (either single or multiple transactions)
14
- * @param provider
15
- * @param url
16
- * @param body
17
- * @param errors
18
- * @returns
19
- */
20
- export async function executeRemoteTxn(provider, url, body, errors = new Map()) {
21
- const txnsToExec = await getAndSignRemoteTxns(provider, url, body);
22
- return executeTxnsInOrder(provider, txnsToExec, errors);
23
- }
24
- export async function signOnlyNeeded(provider, rawTxns) {
25
- const txns = rawTxns.map((t) => Transaction.from(t));
26
- const needToSign = txns.filter((tx) => tx.signatures.some((sig) => sig.publicKey.equals(provider.wallet.publicKey)));
27
- const signedTxns = await provider.wallet.signAllTransactions(needToSign);
28
- const txnsToExec = txns.map((txn, idx) => {
29
- const index = needToSign.indexOf(txn);
30
- if (index >= 0) {
31
- return signedTxns[index].serialize({
32
- requireAllSignatures: false,
33
- verifySignatures: false,
34
- });
35
- }
36
- return Buffer.from(rawTxns[idx]);
37
- });
38
- return txnsToExec;
39
- }
40
- export async function executeTxnsInOrder(provider, txns, errors = new Map()) {
41
- try {
42
- return [
43
- ...(await promiseAllInOrder(txns.map((txn) => async () => {
44
- const { txid } = await sendAndConfirmWithRetry(provider.connection, txn, {
45
- skipPreflight: true,
46
- }, "confirmed");
47
- return txid;
48
- }))),
49
- ];
50
- }
51
- catch (e) {
52
- const wrappedE = ProgramError.parse(e, errors);
53
- throw wrappedE == null ? e : wrappedE;
54
- }
55
- }
56
- /**
57
- * Get and sign transactions from a remote server (either single or multiple transactions)
58
- * @param provider
59
- * @param url
60
- * @param body
61
- * @param errors
62
- * @returns
63
- */
64
- export async function getAndSignRemoteTxns(provider, url, body) {
65
- try {
66
- const resp = await axios.post(url, body, {
67
- responseType: "json",
68
- });
69
- const rawTxns = Array.isArray(resp.data) ? resp.data : [resp.data];
70
- return await signOnlyNeeded(provider, rawTxns.map((t) => t.data));
71
- }
72
- catch (e) {
73
- if (e.response?.data?.message) {
74
- throw new Error(e.response.data.message);
75
- }
76
- throw e;
77
- }
78
- }
79
- //# sourceMappingURL=executeRemoteTxn.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"executeRemoteTxn.js","sourceRoot":"","sources":["../../../src/executeRemoteTxn.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAC9C,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAC7C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,uBAAuB,EAAE,MAAM,eAAe,CAAC;AAExD,KAAK,UAAU,iBAAiB,CAC9B,EAAwB;IAExB,IAAI,GAAG,GAAQ,EAAE,CAAC;IAClB,KAAK,MAAM,CAAC,IAAI,EAAE,EAAE;QAClB,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;KACrB;IAED,OAAO,GAAG,CAAC;AACb,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,CAAC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I,EAAE,OAAO,EAAE;YAC7B,MAAM,IAAI,KAAK,CAAC,CAAC,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;SAC1C;QACD,MAAM,CAAC,CAAC;KACT;AACH,CAAC"}
@@ -1,26 +0,0 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- import { BinaryReader, BinaryWriter } from 'borsh';
3
- // @ts-ignore
4
- import base58 from 'bs58';
5
- export const extendBorsh = () => {
6
- BinaryReader.prototype.readPubkey = function () {
7
- const reader = this;
8
- const array = reader.readFixedArray(32);
9
- return new PublicKey(array);
10
- };
11
- BinaryWriter.prototype.writePubkey = function (value) {
12
- const writer = this;
13
- writer.writeFixedArray(value.toBuffer());
14
- };
15
- BinaryReader.prototype.readPubkeyAsString = function () {
16
- const reader = this;
17
- const array = reader.readFixedArray(32);
18
- return base58.encode(array);
19
- };
20
- BinaryWriter.prototype.writePubkeyAsString = function (value) {
21
- const writer = this;
22
- writer.writeFixedArray(base58.decode(value));
23
- };
24
- };
25
- extendBorsh();
26
- //# sourceMappingURL=extendBorsh.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"extendBorsh.js","sourceRoot":"","sources":["../../../src/extendBorsh.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,OAAO,CAAC;AACnD,aAAa;AACb,OAAO,MAAM,MAAM,MAAM,CAAC;AAI1B,MAAM,CAAC,MAAM,WAAW,GAAG,GAAG,EAAE;IAC7B,YAAY,CAAC,SAAiB,CAAC,UAAU,GAAG;QAC3C,MAAM,MAAM,GAAG,IAA+B,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACxC,OAAO,IAAI,SAAS,CAAC,KAAK,CAAC,CAAC;IAC9B,CAAC,CAAC;IAED,YAAY,CAAC,SAAiB,CAAC,WAAW,GAAG,UAAU,KAAgB;QACtE,MAAM,MAAM,GAAG,IAA+B,CAAC;QAC/C,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;IAC3C,CAAC,CAAC;IAED,YAAY,CAAC,SAAiB,CAAC,kBAAkB,GAAG;QACnD,MAAM,MAAM,GAAG,IAA+B,CAAC;QAC/C,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,EAAE,CAAC,CAAC;QACxC,OAAO,MAAM,CAAC,MAAM,CAAC,KAAK,CAAoB,CAAC;IACjD,CAAC,CAAC;IAED,YAAY,CAAC,SAAiB,CAAC,mBAAmB,GAAG,UACpD,KAAsB;QAEtB,MAAM,MAAM,GAAG,IAA+B,CAAC;QAC/C,MAAM,CAAC,eAAe,CAAC,MAAM,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC,CAAC;AACJ,CAAC,CAAC;AAEF,WAAW,EAAE,CAAC"}
@@ -1,10 +0,0 @@
1
- export * from './extendBorsh';
2
- export * from './transaction';
3
- export * from './anchorError';
4
- export * from './executeRemoteTxn';
5
- export * from './utils';
6
- export * from './token';
7
- export * from './constants';
8
- export { getAsset, getAssets, getAssetProof, getAssetsByOwner, searchAssets, } from './mplAssetAPI';
9
- export { proofArgsAndAccounts } from './proofArgsAndAccounts';
10
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,eAAe,CAAC;AAC9B,cAAc,oBAAoB,CAAC;AACnC,cAAc,SAAS,CAAC;AACxB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAQ5B,OAAO,EACL,QAAQ,EACR,SAAS,EACT,aAAa,EACb,gBAAgB,EAChB,YAAY,GACb,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC"}
@@ -1,167 +0,0 @@
1
- import { PublicKey } from '@solana/web3.js';
2
- import axios from 'axios';
3
- // @ts-ignore
4
- import base58 from 'bs58';
5
- export async function getAsset(url, assetId) {
6
- try {
7
- const response = await axios.post(url, {
8
- jsonrpc: '2.0',
9
- method: 'getAsset',
10
- id: 'rpd-op-123',
11
- params: { id: assetId.toBase58() },
12
- headers: {
13
- 'Cache-Control': 'no-cache',
14
- Pragma: 'no-cache',
15
- Expires: '0',
16
- },
17
- });
18
- const result = response.data.result;
19
- if (result) {
20
- return toAsset(result);
21
- }
22
- }
23
- catch (error) {
24
- console.error(error);
25
- throw error;
26
- }
27
- }
28
- export async function getAssets(url, assetIds) {
29
- try {
30
- if (assetIds.length > 1000) {
31
- throw new Error(`Can only batch 1000 at a time, was given ${assetIds.length}`);
32
- }
33
- const batch = assetIds.map((assetId, i) => ({
34
- jsonrpc: '2.0',
35
- id: `get-asset-${i}`,
36
- method: 'getAsset',
37
- params: {
38
- id: assetId.toBase58(),
39
- },
40
- }));
41
- const response = await axios({
42
- url,
43
- method: 'POST',
44
- headers: {
45
- 'Content-Type': 'application/json',
46
- 'Cache-Control': 'no-cache',
47
- Pragma: 'no-cache',
48
- Expires: '0',
49
- },
50
- data: JSON.stringify(batch),
51
- });
52
- const result = response.data
53
- ? response.data.map((res) => res?.result || undefined)
54
- : [];
55
- return [
56
- ...(result
57
- ? result.map((x) => (x ? toAsset(x) : x))
58
- : []),
59
- ];
60
- }
61
- catch (error) {
62
- console.error(error);
63
- throw error;
64
- }
65
- }
66
- function toAsset(result) {
67
- return {
68
- ...result,
69
- id: new PublicKey(result.id),
70
- grouping: result.grouping &&
71
- result.grouping.map((g) => ({
72
- ...g,
73
- group_value: new PublicKey(g.group_value),
74
- })),
75
- compression: {
76
- ...result.compression,
77
- leafId: result.compression.leaf_id,
78
- dataHash: result.compression.data_hash &&
79
- Buffer.from(base58.decode(result.compression.data_hash)),
80
- creatorHash: result.compression.creator_hash &&
81
- Buffer.from(base58.decode(result.compression.creator_hash)),
82
- assetHash: result.compression.asset_hash &&
83
- Buffer.from(base58.decode(result.compression.asset_hash)),
84
- tree: result.compression.tree && new PublicKey(result.compression.tree),
85
- },
86
- ownership: {
87
- ...result.ownership,
88
- delegate: result.ownership.delegate && new PublicKey(result.ownership.delegate),
89
- owner: result.ownership.owner && new PublicKey(result.ownership.owner),
90
- },
91
- };
92
- }
93
- export async function getAssetProof(url, assetId) {
94
- try {
95
- const response = await axios.post(url, {
96
- jsonrpc: '2.0',
97
- method: 'getAssetProof',
98
- id: 'rpd-op-123',
99
- params: { id: assetId.toBase58() },
100
- headers: {
101
- 'Cache-Control': 'no-cache',
102
- Pragma: 'no-cache',
103
- Expires: '0',
104
- },
105
- });
106
- const result = response.data.result;
107
- if (result) {
108
- return {
109
- root: new PublicKey(result.root),
110
- proof: result.proof.map((p) => new PublicKey(p)),
111
- nodeIndex: result.node_index,
112
- leaf: new PublicKey(result.leaf),
113
- treeId: new PublicKey(result.tree_id),
114
- };
115
- }
116
- }
117
- catch (error) {
118
- console.error(error);
119
- throw error;
120
- }
121
- }
122
- export async function getAssetsByOwner(url, wallet, { sortBy = { sortBy: 'created', sortDirection: 'asc' }, limit = 50, page = 1, before = '', after = '', } = {}) {
123
- try {
124
- const response = await axios.post(url, {
125
- jsonrpc: '2.0',
126
- method: 'getAssetsByOwner',
127
- id: 'rpd-op-123',
128
- params: [wallet, sortBy, limit, page, before, after],
129
- headers: {
130
- 'Cache-Control': 'no-cache',
131
- Pragma: 'no-cache',
132
- Expires: '0',
133
- },
134
- });
135
- return response.data.result?.items.map(toAsset);
136
- }
137
- catch (error) {
138
- console.error(error);
139
- throw error;
140
- }
141
- }
142
- export async function searchAssets(url, { creatorVerified = true, sortBy = { sortBy: 'created', sortDirection: 'asc' }, page = 1, ...rest }) {
143
- try {
144
- const response = await axios.post(url, {
145
- jsonrpc: '2.0',
146
- method: 'searchAssets',
147
- id: 'get-assets-op-1',
148
- params: {
149
- page,
150
- creatorVerified,
151
- sortBy,
152
- ...rest,
153
- },
154
- headers: {
155
- 'Cache-Control': 'no-cache',
156
- Pragma: 'no-cache',
157
- Expires: '0',
158
- },
159
- });
160
- return response.data.result?.items.map(toAsset);
161
- }
162
- catch (error) {
163
- console.error(error);
164
- throw error;
165
- }
166
- }
167
- //# sourceMappingURL=mplAssetAPI.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"mplAssetAPI.js","sourceRoot":"","sources":["../../../src/mplAssetAPI.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,SAAS,EAAE,MAAM,iBAAiB,CAAC;AAC5C,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,aAAa;AACb,OAAO,MAAM,MAAM,MAAM,CAAC;AAuC1B,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,GAAW,EACX,OAAkB;IAElB,IAAI;QACF,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE;YACrC,OAAO,EAAE,KAAK;YACd,MAAM,EAAE,UAAU;YAClB,EAAE,EAAE,YAAY;YAChB,MAAM,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,QAAQ,EAAE,EAAE;YAClC,OAAO,EAAE;gBACP,eAAe,EAAE,UAAU;gBAC3B,MAAM,EAAE,UAAU;gBAClB,OAAO,EAAE,GAAG;aACb;SACF,CAAC,CAAC;QACH,MAAM,MAAM,GAAG,QAAQ,CAAC,IAAI,CAAC,MAAM,CAAC;QACpC,IAAI,MAAM,EAAE;YACV,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC;SACxB;KACF;IAAC,OAAO,KAAK,EAAE;QACd,OAAO,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;QACrB,MAAM,KAAK,CAAC;KACb;AACH,CAAC;AAED,MAAM,CAAC,KAAK,UAAU,SAAS,CAC7B,GAAW,EACX,QAAqB;IAErB,IAAI;QACF,IAAI,QAAQ,CAAC,MAAM,GAAG,IAAI,EAAE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,KAAK,CAAC,CAAC;QACrB,MAAM,KAAK,CAAC;KACb;AACH,CAAC"}
@@ -1,37 +0,0 @@
1
- import { getAsset, getAssetProof } from "./mplAssetAPI";
2
- import { ConcurrentMerkleTreeAccount } from "@solana/spl-account-compression";
3
- export async function proofArgsAndAccounts({ connection, assetId, assetEndpoint, getAssetFn = getAsset, getAssetProofFn = getAssetProof, }) {
4
- // @ts-ignore
5
- const endpoint = assetEndpoint || connection._rpcEndpoint;
6
- const asset = await getAssetFn(endpoint, assetId);
7
- if (!asset) {
8
- throw new Error("No asset with ID " + assetId.toBase58());
9
- }
10
- const assetProof = await getAssetProofFn(endpoint, assetId);
11
- if (!assetProof) {
12
- throw new Error("No asset proof with ID " + assetId.toBase58());
13
- }
14
- const { compression: { leafId }, } = asset;
15
- const { root, proof, leaf, treeId } = assetProof;
16
- const canopy = await (await ConcurrentMerkleTreeAccount.fromAccountAddress(connection, treeId)).getCanopyDepth();
17
- return {
18
- asset,
19
- args: {
20
- dataHash: asset.compression.dataHash.toJSON().data,
21
- creatorHash: asset.compression.creatorHash.toJSON().data,
22
- root: root.toBuffer().toJSON().data,
23
- index: leafId,
24
- },
25
- accounts: {
26
- merkleTree: treeId,
27
- },
28
- remainingAccounts: proof.slice(0, proof.length - canopy).map((p) => {
29
- return {
30
- pubkey: p,
31
- isWritable: false,
32
- isSigner: false,
33
- };
34
- }),
35
- };
36
- }
37
- //# sourceMappingURL=proofArgsAndAccounts.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"proofArgsAndAccounts.js","sourceRoot":"","sources":["../../../src/proofArgsAndAccounts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqB,QAAQ,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,OAAO,EAAE,2BAA2B,EAAE,MAAM,iCAAiC,CAAC;AAa9E,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,EACzC,UAAU,EACV,OAAO,EACP,aAAa,EACb,UAAU,GAAG,QAAQ,EACrB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