@streamflow/common 7.5.3 → 8.0.0-alpha.p284.726ba98

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 (38) hide show
  1. package/dist/cjs/index.cjs +90 -0
  2. package/dist/cjs/index.cjs.map +1 -0
  3. package/dist/cjs/index.d.cts +66 -0
  4. package/dist/cjs/solana/index.cjs +1039 -0
  5. package/dist/cjs/solana/index.cjs.map +1 -0
  6. package/dist/{esm/solana/utils.d.ts → cjs/solana/index.d.cts} +79 -27
  7. package/dist/esm/index.d.ts +66 -3
  8. package/dist/esm/index.js +76 -3
  9. package/dist/esm/index.js.map +1 -0
  10. package/dist/esm/solana/index.d.ts +239 -5
  11. package/dist/esm/solana/index.js +1008 -5
  12. package/dist/esm/solana/index.js.map +1 -0
  13. package/package.json +25 -15
  14. package/dist/cjs/index.js +0 -19
  15. package/dist/cjs/lib/assertions.js +0 -13
  16. package/dist/cjs/lib/utils.js +0 -62
  17. package/dist/cjs/solana/account-filters.js +0 -19
  18. package/dist/cjs/solana/index.js +0 -21
  19. package/dist/cjs/solana/instructions.js +0 -22
  20. package/dist/cjs/solana/public-key.js +0 -13
  21. package/dist/cjs/solana/types.js +0 -11
  22. package/dist/cjs/solana/utils.js +0 -478
  23. package/dist/cjs/types.js +0 -40
  24. package/dist/esm/lib/assertions.d.ts +0 -1
  25. package/dist/esm/lib/assertions.js +0 -9
  26. package/dist/esm/lib/utils.d.ts +0 -28
  27. package/dist/esm/lib/utils.js +0 -51
  28. package/dist/esm/solana/account-filters.d.ts +0 -2
  29. package/dist/esm/solana/account-filters.js +0 -15
  30. package/dist/esm/solana/instructions.d.ts +0 -3
  31. package/dist/esm/solana/instructions.js +0 -18
  32. package/dist/esm/solana/public-key.d.ts +0 -7
  33. package/dist/esm/solana/public-key.js +0 -9
  34. package/dist/esm/solana/types.d.ts +0 -39
  35. package/dist/esm/solana/types.js +0 -7
  36. package/dist/esm/solana/utils.js +0 -450
  37. package/dist/esm/types.d.ts +0 -32
  38. package/dist/esm/types.js +0 -38
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../../../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.js","../../../solana/account-filters.ts","../../../solana/instructions.ts","../../../solana/public-key.ts","../../../solana/types.ts","../../../../../node_modules/.pnpm/eventemitter3@5.0.1/node_modules/eventemitter3/index.mjs","../../../../../node_modules/.pnpm/p-timeout@6.1.2/node_modules/p-timeout/index.js","../../../../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/lower-bound.js","../../../../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/priority-queue.js","../../../../../node_modules/.pnpm/p-queue@8.0.1/node_modules/p-queue/dist/index.js","../../../lib/utils.ts","../../../solana/utils.ts"],"names":["EventEmitter","getAssociatedTokenAddress","NATIVE_MINT","createAssociatedTokenAccountInstruction","SystemProgram","createSyncNativeInstruction","PublicKey","_queue","Keypair","TransactionMessage","VersionedTransaction","bs58","SendTransactionError","ComputeBudgetProgram","TOKEN_PROGRAM_ID","TOKEN_2022_PROGRAM_ID","unpackMint"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,IAAA,qBAAA,GAAA,UAAA,CAAA;AAAA,EAAA,kFAAA,CAAA,OAAA,EAAA,MAAA,EAAA;AAEA,IAAI,IAAA,GAAA,GAAM,OAAO,SAAU,CAAA,cAAA;AAA3B,IAAA,IACI,MAAS,GAAA,GAAA;AASb,IAAA,SAAS,MAAS,GAAA;AAAA;AASlB,IAAA,IAAI,OAAO,MAAQ,EAAA;AACjB,MAAO,MAAA,CAAA,SAAA,mBAAmB,MAAA,CAAA,MAAA,CAAO,IAAI,CAAA;AAMrC,MAAA,IAAI,CAAC,IAAI,MAAO,EAAA,CAAE,WAAoB,MAAA,GAAA,KAAA;AAAA;AAYxC,IAAS,SAAA,EAAA,CAAG,EAAI,EAAA,OAA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EAAE,KAAO,EAAA,YAAA,EAAc,CAAC,CAAA;AAAA;AAG5E,EAAO,OAAA,GAAA;AACT;AAWA,eAAsB,iBAAA,CACpB,UACA,EAAA,OAAA,EACA,UACoD,EAAA;AACpD,EAAA,MAAM,WAAc,GAAA,MAAM,UAAW,CAAA,cAAA,CAAe,SAAS,UAAU,CAAA;AACvE,EAAA,IAAI,YAAY,WAAa,EAAA,KAAA;AAC7B,EAAI,IAAA,CAAC,WAAW,MAAO,CAAAC,yBAAgB,KAAK,CAAC,SAAA,EAAW,MAAO,CAAAC,8BAAqB,CAAG,EAAA;AACrF,IAAY,SAAA,GAAAD,yBAAA;AAAA;AAEd,EAAO,OAAA;AAAA,IACL,IAAM,EAAAE,mBAAA,CAAW,OAAS,EAAA,WAAA,EAAa,SAAS,CAAA;AAAA,IAChD,cAAgB,EAAA;AAAA,GAClB;AACF;AAYA,eAAsB,8BAAA,CACpB,UACA,EAAA,OAAA,EACA,UACyC,EAAA;AACzC,EAAA,MAAM,SAAY,GAAA,EAAA;AAClB,EAAA,MAAM,UAAqD,EAAC;AAE5D,EAAA,KAAA,IAAS,IAAI,CAAG,EAAA,CAAA,GAAI,OAAQ,CAAA,MAAA,EAAQ,KAAK,SAAW,EAAA;AAClD,IAAA,MAAM,KAAQ,GAAA,OAAA,CAAQ,KAAM,CAAA,CAAA,EAAG,IAAI,SAAS,CAAA;AAC5C,IAAA,OAAA,CAAQ,IAAK,CAAA,UAAA,CAAW,uBAAwB,CAAA,KAAA,EAAO,UAAU,CAAC,CAAA;AAAA;AAGpE,EAAA,MAAM,OAAU,GAAA,MAAM,OAAQ,CAAA,GAAA,CAAI,OAAO,CAAA;AACzC,EAAA,OAAO,QAAQ,IAAK,EAAA;AACtB","file":"index.cjs","sourcesContent":["'use strict';\n\nvar has = Object.prototype.hasOwnProperty\n , prefix = '~';\n\n/**\n * Constructor to create a storage for our `EE` objects.\n * An `Events` instance is a plain object whose properties are event names.\n *\n * @constructor\n * @private\n */\nfunction Events() {}\n\n//\n// We try to not inherit from `Object.prototype`. In some engines creating an\n// instance in this way is faster than calling `Object.create(null)` directly.\n// If `Object.create(null)` is not supported we prefix the event names with a\n// character to make sure that the built-in object properties are not\n// overridden or used as an attack vector.\n//\nif (Object.create) {\n Events.prototype = Object.create(null);\n\n //\n // This hack is needed because the `__proto__` property is still inherited in\n // some old browsers like Android 4, iPhone 5.1, Opera 11 and Safari 5.\n //\n if (!new Events().__proto__) prefix = false;\n}\n\n/**\n * Representation of a single event listener.\n *\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} [once=false] Specify if the listener is a one-time listener.\n * @constructor\n * @private\n */\nfunction EE(fn, context, once) {\n this.fn = fn;\n this.context = context;\n this.once = once || false;\n}\n\n/**\n * Add a listener for a given event.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} context The context to invoke the listener with.\n * @param {Boolean} once Specify if the listener is a one-time listener.\n * @returns {EventEmitter}\n * @private\n */\nfunction addListener(emitter, event, fn, context, once) {\n if (typeof fn !== 'function') {\n throw new TypeError('The listener must be a function');\n }\n\n var listener = new EE(fn, context || emitter, once)\n , evt = prefix ? prefix + event : event;\n\n if (!emitter._events[evt]) emitter._events[evt] = listener, emitter._eventsCount++;\n else if (!emitter._events[evt].fn) emitter._events[evt].push(listener);\n else emitter._events[evt] = [emitter._events[evt], listener];\n\n return emitter;\n}\n\n/**\n * Clear event by name.\n *\n * @param {EventEmitter} emitter Reference to the `EventEmitter` instance.\n * @param {(String|Symbol)} evt The Event name.\n * @private\n */\nfunction clearEvent(emitter, evt) {\n if (--emitter._eventsCount === 0) emitter._events = new Events();\n else delete emitter._events[evt];\n}\n\n/**\n * Minimal `EventEmitter` interface that is molded against the Node.js\n * `EventEmitter` interface.\n *\n * @constructor\n * @public\n */\nfunction EventEmitter() {\n this._events = new Events();\n this._eventsCount = 0;\n}\n\n/**\n * Return an array listing the events for which the emitter has registered\n * listeners.\n *\n * @returns {Array}\n * @public\n */\nEventEmitter.prototype.eventNames = function eventNames() {\n var names = []\n , events\n , name;\n\n if (this._eventsCount === 0) return names;\n\n for (name in (events = this._events)) {\n if (has.call(events, name)) names.push(prefix ? name.slice(1) : name);\n }\n\n if (Object.getOwnPropertySymbols) {\n return names.concat(Object.getOwnPropertySymbols(events));\n }\n\n return names;\n};\n\n/**\n * Return the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Array} The registered listeners.\n * @public\n */\nEventEmitter.prototype.listeners = function listeners(event) {\n var evt = prefix ? prefix + event : event\n , handlers = this._events[evt];\n\n if (!handlers) return [];\n if (handlers.fn) return [handlers.fn];\n\n for (var i = 0, l = handlers.length, ee = new Array(l); i < l; i++) {\n ee[i] = handlers[i].fn;\n }\n\n return ee;\n};\n\n/**\n * Return the number of listeners listening to a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Number} The number of listeners.\n * @public\n */\nEventEmitter.prototype.listenerCount = function listenerCount(event) {\n var evt = prefix ? prefix + event : event\n , listeners = this._events[evt];\n\n if (!listeners) return 0;\n if (listeners.fn) return 1;\n return listeners.length;\n};\n\n/**\n * Calls each of the listeners registered for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @returns {Boolean} `true` if the event had listeners, else `false`.\n * @public\n */\nEventEmitter.prototype.emit = function emit(event, a1, a2, a3, a4, a5) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return false;\n\n var listeners = this._events[evt]\n , len = arguments.length\n , args\n , i;\n\n if (listeners.fn) {\n if (listeners.once) this.removeListener(event, listeners.fn, undefined, true);\n\n switch (len) {\n case 1: return listeners.fn.call(listeners.context), true;\n case 2: return listeners.fn.call(listeners.context, a1), true;\n case 3: return listeners.fn.call(listeners.context, a1, a2), true;\n case 4: return listeners.fn.call(listeners.context, a1, a2, a3), true;\n case 5: return listeners.fn.call(listeners.context, a1, a2, a3, a4), true;\n case 6: return listeners.fn.call(listeners.context, a1, a2, a3, a4, a5), true;\n }\n\n for (i = 1, args = new Array(len -1); i < len; i++) {\n args[i - 1] = arguments[i];\n }\n\n listeners.fn.apply(listeners.context, args);\n } else {\n var length = listeners.length\n , j;\n\n for (i = 0; i < length; i++) {\n if (listeners[i].once) this.removeListener(event, listeners[i].fn, undefined, true);\n\n switch (len) {\n case 1: listeners[i].fn.call(listeners[i].context); break;\n case 2: listeners[i].fn.call(listeners[i].context, a1); break;\n case 3: listeners[i].fn.call(listeners[i].context, a1, a2); break;\n case 4: listeners[i].fn.call(listeners[i].context, a1, a2, a3); break;\n default:\n if (!args) for (j = 1, args = new Array(len -1); j < len; j++) {\n args[j - 1] = arguments[j];\n }\n\n listeners[i].fn.apply(listeners[i].context, args);\n }\n }\n }\n\n return true;\n};\n\n/**\n * Add a listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.on = function on(event, fn, context) {\n return addListener(this, event, fn, context, false);\n};\n\n/**\n * Add a one-time listener for a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn The listener function.\n * @param {*} [context=this] The context to invoke the listener with.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.once = function once(event, fn, context) {\n return addListener(this, event, fn, context, true);\n};\n\n/**\n * Remove the listeners of a given event.\n *\n * @param {(String|Symbol)} event The event name.\n * @param {Function} fn Only remove the listeners that match this function.\n * @param {*} context Only remove the listeners that have this context.\n * @param {Boolean} once Only remove one-time listeners.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeListener = function removeListener(event, fn, context, once) {\n var evt = prefix ? prefix + event : event;\n\n if (!this._events[evt]) return this;\n if (!fn) {\n clearEvent(this, evt);\n return this;\n }\n\n var listeners = this._events[evt];\n\n if (listeners.fn) {\n if (\n listeners.fn === fn &&\n (!once || listeners.once) &&\n (!context || listeners.context === context)\n ) {\n clearEvent(this, evt);\n }\n } else {\n for (var i = 0, events = [], length = listeners.length; i < length; i++) {\n if (\n listeners[i].fn !== fn ||\n (once && !listeners[i].once) ||\n (context && listeners[i].context !== context)\n ) {\n events.push(listeners[i]);\n }\n }\n\n //\n // Reset the array, or remove it completely if we have no more listeners.\n //\n if (events.length) this._events[evt] = events.length === 1 ? events[0] : events;\n else clearEvent(this, evt);\n }\n\n return this;\n};\n\n/**\n * Remove all listeners, or those of the specified event.\n *\n * @param {(String|Symbol)} [event] The event name.\n * @returns {EventEmitter} `this`.\n * @public\n */\nEventEmitter.prototype.removeAllListeners = function removeAllListeners(event) {\n var evt;\n\n if (event) {\n evt = prefix ? prefix + event : event;\n if (this._events[evt]) clearEvent(this, evt);\n } else {\n this._events = new Events();\n this._eventsCount = 0;\n }\n\n return this;\n};\n\n//\n// Alias methods names because people roll like that.\n//\nEventEmitter.prototype.off = EventEmitter.prototype.removeListener;\nEventEmitter.prototype.addListener = EventEmitter.prototype.on;\n\n//\n// Expose the prefix.\n//\nEventEmitter.prefixed = prefix;\n\n//\n// Allow `EventEmitter` to be imported as module namespace.\n//\nEventEmitter.EventEmitter = EventEmitter;\n\n//\n// Expose the module.\n//\nif ('undefined' !== typeof module) {\n module.exports = EventEmitter;\n}\n","import type { MemcmpFilter, PublicKey } from \"@solana/web3.js\";\n\nexport const getFilters = <T extends Record<string, number | PublicKey>>(\n criteria: T,\n byteOffsets: Record<keyof T, number>,\n): MemcmpFilter[] => {\n return Object.entries(criteria).reduce((acc, [key, value]) => {\n const criteriaKey = key as keyof typeof criteria;\n const effectiveByteOffset = byteOffsets[criteriaKey];\n if (criteria[criteriaKey] && effectiveByteOffset) {\n acc.push({\n memcmp: {\n offset: effectiveByteOffset,\n bytes: value.toString(),\n },\n });\n }\n return acc;\n }, [] as MemcmpFilter[]);\n};\n","import {\n getAssociatedTokenAddress,\n NATIVE_MINT,\n createAssociatedTokenAccountInstruction,\n createSyncNativeInstruction,\n} from \"@solana/spl-token\";\nimport type { Connection, PublicKey, TransactionInstruction } from \"@solana/web3.js\";\nimport { SystemProgram } from \"@solana/web3.js\";\nimport type BN from \"bn.js\";\n\nexport const prepareWrappedAccount = async (\n connection: Connection,\n senderAddress: PublicKey,\n amount: BN,\n): Promise<TransactionInstruction[]> => {\n const tokenAccount = await getAssociatedTokenAddress(NATIVE_MINT, senderAddress, true);\n\n const accInfo = await connection.getParsedAccountInfo(tokenAccount);\n\n const instructions =\n (accInfo.value?.lamports ?? 0) > 0\n ? []\n : [createAssociatedTokenAccountInstruction(senderAddress, tokenAccount, senderAddress, NATIVE_MINT)];\n\n return [\n ...instructions,\n SystemProgram.transfer({\n fromPubkey: senderAddress,\n toPubkey: tokenAccount,\n lamports: amount.toNumber(),\n }),\n createSyncNativeInstruction(tokenAccount),\n ];\n};\n","import { PublicKey } from \"@solana/web3.js\";\n\n/**\n * Converts a string or PublicKey to a PublicKey object.\n * @param address - The input address as a string or PublicKey.\n * @returns The PublicKey object.\n */\nexport const pk = (address: string | PublicKey): PublicKey => {\n return typeof address === \"string\" ? new PublicKey(address) : address;\n};\n","import type { AccountInfo, BlockhashWithExpiryBlockHeight, Commitment, Context, PublicKey } from \"@solana/web3.js\";\nimport type PQueue from \"p-queue\";\n\nexport interface ITransactionSolanaExt {\n computePrice?: number;\n computeLimit?: number;\n}\n\nexport interface Account {\n pubkey: PublicKey;\n account: AccountInfo<Buffer>;\n}\n\nexport interface CheckAssociatedTokenAccountsData {\n sender: PublicKey;\n recipient: PublicKey;\n partner: PublicKey;\n streamflowTreasury: PublicKey;\n mint: PublicKey;\n}\n\nexport interface AtaParams {\n mint: PublicKey;\n owner: PublicKey;\n programId?: PublicKey;\n}\n\nexport interface ConfirmationParams {\n hash: BlockhashWithExpiryBlockHeight;\n context: Context;\n commitment?: Commitment;\n}\n\nexport interface ThrottleParams {\n sendRate?: number;\n sendThrottler?: PQueue;\n waitBeforeConfirming?: number | undefined;\n}\n\nexport interface IProgramAccount<T> {\n publicKey: PublicKey;\n account: T;\n}\n\nexport class TransactionFailedError extends Error {\n constructor(m: string) {\n super(m);\n Object.setPrototypeOf(this, TransactionFailedError.prototype);\n this.name = \"TransactionFailedError\";\n }\n}\n","import EventEmitter from './index.js'\n\nexport { EventEmitter }\nexport default EventEmitter\n","export class TimeoutError extends Error {\n\tconstructor(message) {\n\t\tsuper(message);\n\t\tthis.name = 'TimeoutError';\n\t}\n}\n\n/**\nAn error to be thrown when the request is aborted by AbortController.\nDOMException is thrown instead of this Error when DOMException is available.\n*/\nexport class AbortError extends Error {\n\tconstructor(message) {\n\t\tsuper();\n\t\tthis.name = 'AbortError';\n\t\tthis.message = message;\n\t}\n}\n\n/**\nTODO: Remove AbortError and just throw DOMException when targeting Node 18.\n*/\nconst getDOMException = errorMessage => globalThis.DOMException === undefined\n\t? new AbortError(errorMessage)\n\t: new DOMException(errorMessage);\n\n/**\nTODO: Remove below function and just 'reject(signal.reason)' when targeting Node 18.\n*/\nconst getAbortedReason = signal => {\n\tconst reason = signal.reason === undefined\n\t\t? getDOMException('This operation was aborted.')\n\t\t: signal.reason;\n\n\treturn reason instanceof Error ? reason : getDOMException(reason);\n};\n\nexport default function pTimeout(promise, options) {\n\tconst {\n\t\tmilliseconds,\n\t\tfallback,\n\t\tmessage,\n\t\tcustomTimers = {setTimeout, clearTimeout},\n\t} = options;\n\n\tlet timer;\n\n\tconst wrappedPromise = new Promise((resolve, reject) => {\n\t\tif (typeof milliseconds !== 'number' || Math.sign(milliseconds) !== 1) {\n\t\t\tthrow new TypeError(`Expected \\`milliseconds\\` to be a positive number, got \\`${milliseconds}\\``);\n\t\t}\n\n\t\tif (options.signal) {\n\t\t\tconst {signal} = options;\n\t\t\tif (signal.aborted) {\n\t\t\t\treject(getAbortedReason(signal));\n\t\t\t}\n\n\t\t\tsignal.addEventListener('abort', () => {\n\t\t\t\treject(getAbortedReason(signal));\n\t\t\t});\n\t\t}\n\n\t\tif (milliseconds === Number.POSITIVE_INFINITY) {\n\t\t\tpromise.then(resolve, reject);\n\t\t\treturn;\n\t\t}\n\n\t\t// We create the error outside of `setTimeout` to preserve the stack trace.\n\t\tconst timeoutError = new TimeoutError();\n\n\t\ttimer = customTimers.setTimeout.call(undefined, () => {\n\t\t\tif (fallback) {\n\t\t\t\ttry {\n\t\t\t\t\tresolve(fallback());\n\t\t\t\t} catch (error) {\n\t\t\t\t\treject(error);\n\t\t\t\t}\n\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tif (typeof promise.cancel === 'function') {\n\t\t\t\tpromise.cancel();\n\t\t\t}\n\n\t\t\tif (message === false) {\n\t\t\t\tresolve();\n\t\t\t} else if (message instanceof Error) {\n\t\t\t\treject(message);\n\t\t\t} else {\n\t\t\t\ttimeoutError.message = message ?? `Promise timed out after ${milliseconds} milliseconds`;\n\t\t\t\treject(timeoutError);\n\t\t\t}\n\t\t}, milliseconds);\n\n\t\t(async () => {\n\t\t\ttry {\n\t\t\t\tresolve(await promise);\n\t\t\t} catch (error) {\n\t\t\t\treject(error);\n\t\t\t}\n\t\t})();\n\t});\n\n\tconst cancelablePromise = wrappedPromise.finally(() => {\n\t\tcancelablePromise.clear();\n\t});\n\n\tcancelablePromise.clear = () => {\n\t\tcustomTimers.clearTimeout.call(undefined, timer);\n\t\ttimer = undefined;\n\t};\n\n\treturn cancelablePromise;\n}\n","// Port of lower_bound from https://en.cppreference.com/w/cpp/algorithm/lower_bound\n// Used to compute insertion index to keep queue sorted after insertion\nexport default function lowerBound(array, value, comparator) {\n let first = 0;\n let count = array.length;\n while (count > 0) {\n const step = Math.trunc(count / 2);\n let it = first + step;\n if (comparator(array[it], value) <= 0) {\n first = ++it;\n count -= step + 1;\n }\n else {\n count = step;\n }\n }\n return first;\n}\n","import lowerBound from './lower-bound.js';\nexport default class PriorityQueue {\n #queue = [];\n enqueue(run, options) {\n options = {\n priority: 0,\n ...options,\n };\n const element = {\n priority: options.priority,\n run,\n };\n if (this.size && this.#queue[this.size - 1].priority >= options.priority) {\n this.#queue.push(element);\n return;\n }\n const index = lowerBound(this.#queue, element, (a, b) => b.priority - a.priority);\n this.#queue.splice(index, 0, element);\n }\n dequeue() {\n const item = this.#queue.shift();\n return item?.run;\n }\n filter(options) {\n return this.#queue.filter((element) => element.priority === options.priority).map((element) => element.run);\n }\n get size() {\n return this.#queue.length;\n }\n}\n","import { EventEmitter } from 'eventemitter3';\nimport pTimeout, { TimeoutError } from 'p-timeout';\nimport PriorityQueue from './priority-queue.js';\n/**\nPromise queue with concurrency control.\n*/\nexport default class PQueue extends EventEmitter {\n #carryoverConcurrencyCount;\n #isIntervalIgnored;\n #intervalCount = 0;\n #intervalCap;\n #interval;\n #intervalEnd = 0;\n #intervalId;\n #timeoutId;\n #queue;\n #queueClass;\n #pending = 0;\n // The `!` is needed because of https://github.com/microsoft/TypeScript/issues/32194\n #concurrency;\n #isPaused;\n #throwOnTimeout;\n /**\n Per-operation timeout in milliseconds. Operations fulfill once `timeout` elapses if they haven't already.\n\n Applies to each future operation.\n */\n timeout;\n // TODO: The `throwOnTimeout` option should affect the return types of `add()` and `addAll()`\n constructor(options) {\n super();\n // eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n options = {\n carryoverConcurrencyCount: false,\n intervalCap: Number.POSITIVE_INFINITY,\n interval: 0,\n concurrency: Number.POSITIVE_INFINITY,\n autoStart: true,\n queueClass: PriorityQueue,\n ...options,\n };\n if (!(typeof options.intervalCap === 'number' && options.intervalCap >= 1)) {\n throw new TypeError(`Expected \\`intervalCap\\` to be a number from 1 and up, got \\`${options.intervalCap?.toString() ?? ''}\\` (${typeof options.intervalCap})`);\n }\n if (options.interval === undefined || !(Number.isFinite(options.interval) && options.interval >= 0)) {\n throw new TypeError(`Expected \\`interval\\` to be a finite number >= 0, got \\`${options.interval?.toString() ?? ''}\\` (${typeof options.interval})`);\n }\n this.#carryoverConcurrencyCount = options.carryoverConcurrencyCount;\n this.#isIntervalIgnored = options.intervalCap === Number.POSITIVE_INFINITY || options.interval === 0;\n this.#intervalCap = options.intervalCap;\n this.#interval = options.interval;\n this.#queue = new options.queueClass();\n this.#queueClass = options.queueClass;\n this.concurrency = options.concurrency;\n this.timeout = options.timeout;\n this.#throwOnTimeout = options.throwOnTimeout === true;\n this.#isPaused = options.autoStart === false;\n }\n get #doesIntervalAllowAnother() {\n return this.#isIntervalIgnored || this.#intervalCount < this.#intervalCap;\n }\n get #doesConcurrentAllowAnother() {\n return this.#pending < this.#concurrency;\n }\n #next() {\n this.#pending--;\n this.#tryToStartAnother();\n this.emit('next');\n }\n #onResumeInterval() {\n this.#onInterval();\n this.#initializeIntervalIfNeeded();\n this.#timeoutId = undefined;\n }\n get #isIntervalPaused() {\n const now = Date.now();\n if (this.#intervalId === undefined) {\n const delay = this.#intervalEnd - now;\n if (delay < 0) {\n // Act as the interval was done\n // We don't need to resume it here because it will be resumed on line 160\n this.#intervalCount = (this.#carryoverConcurrencyCount) ? this.#pending : 0;\n }\n else {\n // Act as the interval is pending\n if (this.#timeoutId === undefined) {\n this.#timeoutId = setTimeout(() => {\n this.#onResumeInterval();\n }, delay);\n }\n return true;\n }\n }\n return false;\n }\n #tryToStartAnother() {\n if (this.#queue.size === 0) {\n // We can clear the interval (\"pause\")\n // Because we can redo it later (\"resume\")\n if (this.#intervalId) {\n clearInterval(this.#intervalId);\n }\n this.#intervalId = undefined;\n this.emit('empty');\n if (this.#pending === 0) {\n this.emit('idle');\n }\n return false;\n }\n if (!this.#isPaused) {\n const canInitializeInterval = !this.#isIntervalPaused;\n if (this.#doesIntervalAllowAnother && this.#doesConcurrentAllowAnother) {\n const job = this.#queue.dequeue();\n if (!job) {\n return false;\n }\n this.emit('active');\n job();\n if (canInitializeInterval) {\n this.#initializeIntervalIfNeeded();\n }\n return true;\n }\n }\n return false;\n }\n #initializeIntervalIfNeeded() {\n if (this.#isIntervalIgnored || this.#intervalId !== undefined) {\n return;\n }\n this.#intervalId = setInterval(() => {\n this.#onInterval();\n }, this.#interval);\n this.#intervalEnd = Date.now() + this.#interval;\n }\n #onInterval() {\n if (this.#intervalCount === 0 && this.#pending === 0 && this.#intervalId) {\n clearInterval(this.#intervalId);\n this.#intervalId = undefined;\n }\n this.#intervalCount = this.#carryoverConcurrencyCount ? this.#pending : 0;\n this.#processQueue();\n }\n /**\n Executes all queued functions until it reaches the limit.\n */\n #processQueue() {\n // eslint-disable-next-line no-empty\n while (this.#tryToStartAnother()) { }\n }\n get concurrency() {\n return this.#concurrency;\n }\n set concurrency(newConcurrency) {\n if (!(typeof newConcurrency === 'number' && newConcurrency >= 1)) {\n throw new TypeError(`Expected \\`concurrency\\` to be a number from 1 and up, got \\`${newConcurrency}\\` (${typeof newConcurrency})`);\n }\n this.#concurrency = newConcurrency;\n this.#processQueue();\n }\n async #throwOnAbort(signal) {\n return new Promise((_resolve, reject) => {\n signal.addEventListener('abort', () => {\n reject(signal.reason);\n }, { once: true });\n });\n }\n async add(function_, options = {}) {\n options = {\n timeout: this.timeout,\n throwOnTimeout: this.#throwOnTimeout,\n ...options,\n };\n return new Promise((resolve, reject) => {\n this.#queue.enqueue(async () => {\n this.#pending++;\n this.#intervalCount++;\n try {\n options.signal?.throwIfAborted();\n let operation = function_({ signal: options.signal });\n if (options.timeout) {\n operation = pTimeout(Promise.resolve(operation), { milliseconds: options.timeout });\n }\n if (options.signal) {\n operation = Promise.race([operation, this.#throwOnAbort(options.signal)]);\n }\n const result = await operation;\n resolve(result);\n this.emit('completed', result);\n }\n catch (error) {\n if (error instanceof TimeoutError && !options.throwOnTimeout) {\n resolve();\n return;\n }\n reject(error);\n this.emit('error', error);\n }\n finally {\n this.#next();\n }\n }, options);\n this.emit('add');\n this.#tryToStartAnother();\n });\n }\n async addAll(functions, options) {\n return Promise.all(functions.map(async (function_) => this.add(function_, options)));\n }\n /**\n Start (or resume) executing enqueued tasks within concurrency limit. No need to call this if queue is not paused (via `options.autoStart = false` or by `.pause()` method.)\n */\n start() {\n if (!this.#isPaused) {\n return this;\n }\n this.#isPaused = false;\n this.#processQueue();\n return this;\n }\n /**\n Put queue execution on hold.\n */\n pause() {\n this.#isPaused = true;\n }\n /**\n Clear the queue.\n */\n clear() {\n this.#queue = new this.#queueClass();\n }\n /**\n Can be called multiple times. Useful if you for example add additional items at a later time.\n\n @returns A promise that settles when the queue becomes empty.\n */\n async onEmpty() {\n // Instantly resolve if the queue is empty\n if (this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('empty');\n }\n /**\n @returns A promise that settles when the queue size is less than the given limit: `queue.size < limit`.\n\n If you want to avoid having the queue grow beyond a certain size you can `await queue.onSizeLessThan()` before adding a new item.\n\n Note that this only limits the number of items waiting to start. There could still be up to `concurrency` jobs already running that this call does not include in its calculation.\n */\n async onSizeLessThan(limit) {\n // Instantly resolve if the queue is empty.\n if (this.#queue.size < limit) {\n return;\n }\n await this.#onEvent('next', () => this.#queue.size < limit);\n }\n /**\n The difference with `.onEmpty` is that `.onIdle` guarantees that all work from the queue has finished. `.onEmpty` merely signals that the queue is empty, but it could mean that some promises haven't completed yet.\n\n @returns A promise that settles when the queue becomes empty, and all promises have completed; `queue.size === 0 && queue.pending === 0`.\n */\n async onIdle() {\n // Instantly resolve if none pending and if nothing else is queued\n if (this.#pending === 0 && this.#queue.size === 0) {\n return;\n }\n await this.#onEvent('idle');\n }\n async #onEvent(event, filter) {\n return new Promise(resolve => {\n const listener = () => {\n if (filter && !filter()) {\n return;\n }\n this.off(event, listener);\n resolve();\n };\n this.on(event, listener);\n });\n }\n /**\n Size of the queue, the number of queued items waiting to run.\n */\n get size() {\n return this.#queue.size;\n }\n /**\n Size of the queue, filtered by the given options.\n\n For example, this can be used to find the number of items remaining in the queue with a specific priority level.\n */\n sizeBy(options) {\n // eslint-disable-next-line unicorn/no-array-callback-reference\n return this.#queue.filter(options).length;\n }\n /**\n Number of running items (no longer in the queue).\n */\n get pending() {\n return this.#pending;\n }\n /**\n Whether the queue is currently paused.\n */\n get isPaused() {\n return this.#isPaused;\n }\n}\n","import BN from \"bn.js\";\n\nimport { ContractError } from \"../types.js\";\n\n/**\n * Used for conversion of token amounts to their Big Number representation.\n * Get Big Number representation in the smallest units from the same value in the highest units.\n * @param {number} value - Number of tokens you want to convert to its BN representation.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getBN = (value: number, decimals: number): BN => {\n const decimalPart = value - Math.trunc(value);\n const integerPart = new BN(Math.trunc(value));\n\n const decimalE = new BN(decimalPart * 1e9);\n\n const sum = integerPart.mul(new BN(1e9)).add(decimalE);\n const resultE = sum.mul(new BN(10).pow(new BN(decimals)));\n return resultE.div(new BN(1e9));\n};\n\n/**\n * Used for token amounts conversion from their Big Number representation to number.\n * Get value in the highest units from BN representation of the same value in the smallest units.\n * @param {BN} value - Big Number representation of value in the smallest units.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getNumberFromBN = (value: BN, decimals: number): number =>\n value.gt(new BN(2 ** 53 - 1)) ? value.div(new BN(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;\n\n/**\n * Used to make on chain calls to the contract and wrap raised errors if any\n * @param func function that interacts with the contract\n * @param callback callback that may be used to extract error code\n * @returns {T}\n */\nexport async function handleContractError<T>(\n func: () => Promise<T>,\n callback?: (err: Error) => string | null,\n): Promise<T> {\n try {\n return await func();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (err: any) {\n if (err instanceof Error) {\n if (callback) {\n throw new ContractError(err, callback(err));\n }\n throw new ContractError(err);\n }\n throw err;\n }\n}\n\n/**\n * Pause async function execution for given amount of milliseconds\n * @param ms millisecond to sleep for\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport const divCeilN = (n: bigint, d: bigint): bigint => n / d + (n % d ? BigInt(1) : BigInt(0));\n","import {\n createAssociatedTokenAccountInstruction,\n getAssociatedTokenAddress,\n unpackMint,\n type Mint,\n TOKEN_PROGRAM_ID,\n TOKEN_2022_PROGRAM_ID,\n} from \"@solana/spl-token\";\nimport type { SignerWalletAdapter } from \"@solana/wallet-adapter-base\";\nimport bs58 from \"bs58\";\nimport PQueue from \"p-queue\";\nimport {\n ComputeBudgetProgram,\n Keypair,\n type PublicKey,\n SendTransactionError,\n type Transaction,\n type TransactionInstruction,\n TransactionMessage,\n VersionedTransaction,\n type AccountInfo,\n type BlockhashWithExpiryBlockHeight,\n type Commitment,\n type Connection,\n type Context,\n type RpcResponseAndContext,\n type SignatureStatus,\n type SimulatedTransactionResponse,\n} from \"@solana/web3.js\";\n\nimport {\n type Account,\n type AtaParams,\n type ConfirmationParams,\n type ITransactionSolanaExt,\n type ThrottleParams,\n TransactionFailedError,\n} from \"./types.js\";\nimport { sleep } from \"../lib/utils.js\";\n\nconst SIMULATE_TRIES = 3;\n\nexport const buildSendThrottler = (sendRate: number, sendInterval = 1000): PQueue => {\n return new PQueue({ concurrency: sendRate, intervalCap: 1, interval: sendInterval });\n};\n\n/**\n * Wrapper function for Solana web3 getProgramAccounts with slightly better call interface\n * @param {Connection} connection - Solana web3 connection object.\n * @param {PublicKey} wallet - PublicKey to compare against.\n * @param {number} offset - Offset of bits of the PublicKey in the account binary.\n * @param {PublicKey} programId - Solana program ID.\n * @return {Promise<Account[]>} - Array of resulting accounts.\n */\nexport async function getProgramAccounts(\n connection: Connection,\n wallet: PublicKey,\n offset: number,\n programId: PublicKey,\n): Promise<Account[]> {\n const programAccounts = await connection?.getProgramAccounts(programId, {\n filters: [\n {\n memcmp: {\n offset,\n bytes: wallet.toBase58(),\n },\n },\n ],\n });\n\n return [...programAccounts];\n}\n\n/**\n * Utility function to check if the transaction initiator is a Wallet object\n * @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question\n * @return {boolean} - Returns true if parameter is a Wallet.\n */\nexport function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is SignerWalletAdapter {\n return (<SignerWalletAdapter>walletOrKeypair).signTransaction !== undefined;\n}\n\n/**\n * Utility function to check if the transaction initiator a Keypair object, tries to mitigate version mismatch issues\n * @param walletOrKeypair {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question\n * @returns {boolean} - Returns true if parameter is a Keypair.\n */\nexport function isSignerKeypair(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is Keypair {\n return (\n walletOrKeypair instanceof Keypair ||\n walletOrKeypair.constructor === Keypair ||\n walletOrKeypair.constructor.name === Keypair.prototype.constructor.name\n );\n}\n\n/**\n * Utility function to check whether given transaction is Versioned\n * @param tx {Transaction | VersionedTransaction} - Transaction to check\n * @returns {boolean} - Returns true if transaction is Versioned.\n */\nexport function isTransactionVersioned(tx: Transaction | VersionedTransaction): tx is VersionedTransaction {\n return \"message\" in tx;\n}\n\n/**\n * Creates a Transaction with given instructions and optionally signs it.\n * @param connection - Solana client connection\n * @param ixs - Instructions to add to the Transaction\n * @param payer - PublicKey of payer\n * @param commitment - optional Commitment that will be used to fetch latest blockhash\n * @param partialSigners - optional signers that will be used to partially sign a Transaction\n * @returns Transaction and Blockhash\n */\nexport async function prepareTransaction(\n connection: Connection,\n ixs: TransactionInstruction[],\n payer: PublicKey | undefined | null,\n commitment?: Commitment,\n ...partialSigners: (Keypair | undefined)[]\n): Promise<{\n tx: VersionedTransaction;\n hash: BlockhashWithExpiryBlockHeight;\n context: Context;\n}> {\n if (!payer) {\n throw new Error(\"Payer public key is not provided!\");\n }\n\n const { value: hash, context } = await connection.getLatestBlockhashAndContext(commitment);\n const messageV0 = new TransactionMessage({\n payerKey: payer,\n recentBlockhash: hash.blockhash,\n instructions: ixs,\n }).compileToV0Message();\n const tx = new VersionedTransaction(messageV0);\n const signers: Keypair[] = partialSigners.filter((item): item is Keypair => !!item);\n tx.sign(signers);\n\n return { tx, context, hash };\n}\n\nexport async function signTransaction<T extends Transaction | VersionedTransaction>(\n invoker: Keypair | SignerWalletAdapter,\n tx: T,\n): Promise<T> {\n let signedTx: T;\n if (isSignerWallet(invoker)) {\n signedTx = await invoker.signTransaction(tx);\n } else {\n if (isTransactionVersioned(tx)) {\n tx.sign([invoker]);\n } else {\n tx.partialSign(invoker);\n }\n signedTx = tx;\n }\n return signedTx;\n}\n\n/**\n * Signs, sends and confirms Transaction\n * @param connection - Solana client connection\n * @param invoker - Keypair used as signer\n * @param tx - Transaction instance\n * @param confirmationParams - Confirmation Params that will be used for execution\n * @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much\n * @returns Transaction signature\n */\nexport async function signAndExecuteTransaction(\n connection: Connection,\n invoker: Keypair | SignerWalletAdapter,\n tx: Transaction | VersionedTransaction,\n confirmationParams: ConfirmationParams,\n throttleParams: ThrottleParams,\n): Promise<string> {\n const signedTx = await signTransaction(invoker, tx);\n\n return executeTransaction(connection, signedTx, confirmationParams, throttleParams);\n}\n\n/**\n * Sends and confirms Transaction\n * Uses custom confirmation logic that:\n * - simulates tx before sending separately\n * - sends transaction without preFlight checks but with some valuable flags https://twitter.com/jordaaash/status/1774892862049800524?s=46&t=bhZ10V0r7IX5Lk5kKzxfGw\n * - rebroadcasts a tx every 500 ms\n * - after broadcasting check whether tx has executed once\n * - catch errors for every actionable item, throw only the ones that signal that tx has failed\n * - otherwise there is a chance of marking a landed tx as failed if it was broadcasted at least once\n * @param connection - Solana client connection\n * @param tx - Transaction instance\n * @param confirmationParams - Confirmation Params that will be used for execution\n * @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much\n * @returns Transaction signature\n */\nexport async function executeTransaction(\n connection: Connection,\n tx: Transaction | VersionedTransaction,\n confirmationParams: ConfirmationParams,\n throttleParams: ThrottleParams,\n): Promise<string> {\n if (tx.signatures.length === 0) {\n throw Error(\"Error with transaction parameters.\");\n }\n await simulateTransaction(connection, tx);\n\n return sendAndConfirmTransaction(connection, tx, confirmationParams, throttleParams);\n}\n\n/**\n * Launches a PromisePool with all transaction being executed at the same time, allows to throttle all TXs through one Queue\n * @param connection - Solana client connection\n * @param txs - Transactions\n * @param confirmationParams - Confirmation Params that will be used for execution\n * @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much\n * @param throttleParams.sendRate - rate\n * @param throttleParams.sendThrottler - throttler instance\n * @returns Raw Promise Results - should be handled by the consumer and unwrapped accordingly\n */\nexport async function executeMultipleTransactions(\n connection: Connection,\n txs: (Transaction | VersionedTransaction)[],\n confirmationParams: ConfirmationParams,\n { sendRate = 1, sendThrottler, ...throttlingParams }: ThrottleParams,\n): Promise<PromiseSettledResult<string>[]> {\n if (!sendThrottler) {\n sendThrottler = buildSendThrottler(sendRate);\n }\n return Promise.allSettled(\n txs.map((tx) =>\n executeTransaction(connection, tx, confirmationParams, {\n ...throttlingParams,\n sendRate: sendRate,\n sendThrottler: sendThrottler,\n }),\n ),\n );\n}\n\n/**\n * Sends and confirm transaction in a loop, constantly re-broadcsting the tx until Blockheight expires.\n * - we add additional 30 bocks to account for validators in an PRC pool divergence\n * @param connection - Solana client connection\n * @param tx - Transaction instance\n * @param confirmationParams - Confirmation Params that will be used for execution\n * @param confirmationParams.hash - blockhash information, the same hash should be used in the Transaction\n * @param confirmationParams.context - context at which blockhash has been retrieve\n * @param confirmationParams.commitment - optional commitment that will be used for simulation and confirmation\n * @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much\n * @param throttleParams.sendRate - rate\n * @param throttleParams.sendThrottler - throttler instance\n */\nexport async function sendAndConfirmTransaction(\n connection: Connection,\n tx: Transaction | VersionedTransaction,\n { hash, context, commitment }: ConfirmationParams,\n { sendRate = 1, sendThrottler, waitBeforeConfirming }: ThrottleParams,\n): Promise<string> {\n const isVersioned = isTransactionVersioned(tx);\n\n let signature: string;\n if (isVersioned) {\n signature = bs58.encode(tx.signatures[0]!);\n } else {\n signature = bs58.encode(tx.signature!);\n }\n\n if (!sendThrottler) {\n sendThrottler = buildSendThrottler(sendRate);\n }\n\n let blockheight = await connection.getBlockHeight(commitment);\n let transactionSent = false;\n const rawTransaction = tx.serialize();\n while (blockheight < hash.lastValidBlockHeight + 15) {\n try {\n if (blockheight < hash.lastValidBlockHeight || !transactionSent) {\n await sendThrottler.add(async () =>\n connection.sendRawTransaction(rawTransaction, {\n maxRetries: 0,\n minContextSlot: context.slot,\n preflightCommitment: commitment,\n skipPreflight: true,\n }),\n );\n transactionSent = true;\n }\n } catch (e) {\n if (\n transactionSent ||\n (e instanceof SendTransactionError && e.message.includes(\"Minimum context slot has not been reached\"))\n ) {\n await sleep(500);\n continue;\n }\n throw e;\n }\n // Wait at least 5 slots (~400ms before confirming)\n await sleep(waitBeforeConfirming ?? 2000);\n try {\n const value = await confirmAndEnsureTransaction(connection, signature);\n if (value) {\n return signature;\n }\n } catch (e) {\n if (e instanceof TransactionFailedError) {\n throw e;\n }\n await sleep(500);\n }\n try {\n blockheight = await connection.getBlockHeight(commitment);\n } catch (_e) {\n await sleep(500);\n }\n }\n throw new Error(`Transaction ${signature} expired.`);\n}\n\nexport async function simulateTransaction(\n connection: Connection,\n tx: Transaction | VersionedTransaction,\n): Promise<RpcResponseAndContext<SimulatedTransactionResponse>> {\n let res: RpcResponseAndContext<SimulatedTransactionResponse>;\n for (let i = 0; i < SIMULATE_TRIES; i++) {\n if (isTransactionVersioned(tx)) {\n res = await connection.simulateTransaction(tx);\n } else {\n res = await connection.simulateTransaction(tx);\n }\n if (res.value.err) {\n const errMessage = JSON.stringify(res.value.err);\n if (!errMessage.includes(\"BlockhashNotFound\") || i === SIMULATE_TRIES - 1) {\n throw new SendTransactionError({\n action: \"simulate\",\n signature: \"\",\n transactionMessage: `failed to simulate transaction: ${typeof res.value.err === \"string\" ? res.value.err : errMessage}`,\n logs: res.value.logs ?? undefined,\n });\n }\n continue;\n }\n return res;\n }\n\n throw new SendTransactionError({\n action: \"simulate\",\n signature: \"\",\n transactionMessage: \"failed to simulate transaction\",\n });\n}\n\n/**\n * Confirms and validates transaction success once\n * @param connection - Solana client connection\n * @param signature - Transaction signature\n * @param ignoreError - return status even if tx failed\n * @returns Transaction Status\n */\nexport async function confirmAndEnsureTransaction(\n connection: Connection,\n signature: string,\n ignoreError?: boolean,\n): Promise<SignatureStatus | null> {\n const response = await connection.getSignatureStatuses([signature]);\n if (!response || response.value.length === 0 || response.value[0] === null) {\n return null;\n }\n const value = response.value[0];\n if (!value) {\n return null;\n }\n if (!ignoreError && value.err) {\n // That's how solana-web3js does it, `err` here is an object that won't really be handled\n throw new TransactionFailedError(`Raw transaction ${signature} failed (${JSON.stringify({ err: value.err })})`);\n }\n switch (connection.commitment) {\n case \"confirmed\":\n case \"single\":\n case \"singleGossip\": {\n if (value.confirmationStatus === \"processed\") {\n return null;\n }\n break;\n }\n case \"finalized\":\n case \"max\":\n case \"root\": {\n if (value.confirmationStatus === \"processed\" || value.confirmationStatus === \"confirmed\") {\n return null;\n }\n break;\n }\n // exhaust enums to ensure full coverage\n case \"processed\":\n case \"recent\":\n }\n return value;\n}\n\n/**\n * Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve\n * @param {PublicKey} mint - SPL token Mint address.\n * @param {PublicKey} owner - Owner of the Associated Token Address\n * @param {PublicKey} programId - Program ID of the mint\n * @return {Promise<PublicKey>} - Associated Token Address\n */\nexport function ata(mint: PublicKey, owner: PublicKey, programId?: PublicKey): Promise<PublicKey> {\n return getAssociatedTokenAddress(mint, owner, true, programId);\n}\n\n/**\n * Function that checks whether ATA exists for each provided owner\n * @param connection - Solana client connection\n * @param paramsBatch - Array of Params for each ATA account: {mint, owner}\n * @returns Array of boolean where each member corresponds to an owner\n */\nexport async function ataBatchExist(connection: Connection, paramsBatch: AtaParams[]): Promise<boolean[]> {\n const tokenAccounts = await Promise.all(\n paramsBatch.map(async ({ mint, owner, programId }) => {\n return ata(mint, owner, programId);\n }),\n );\n const response = await connection.getMultipleAccountsInfo(tokenAccounts);\n return response.map((accInfo) => !!accInfo);\n}\n\nexport async function enrichAtaParams(connection: Connection, paramsBatch: AtaParams[]): Promise<AtaParams[]> {\n const programIdByMint: { [key: string]: PublicKey } = {};\n return Promise.all(\n paramsBatch.map(async (params) => {\n if (params.programId) {\n return params;\n }\n const mintStr = params.mint.toString();\n if (!(mintStr in programIdByMint)) {\n const { tokenProgramId } = await getMintAndProgram(connection, params.mint);\n programIdByMint[mintStr] = tokenProgramId;\n }\n params.programId = programIdByMint[mintStr];\n return params;\n }),\n );\n}\n\n/**\n * Generates a Transaction to create ATA for an array of owners\n * @param connection - Solana client connection\n * @param payer - Transaction invoker, should be a signer\n * @param paramsBatch - Array of Params for an each ATA account: {mint, owner}\n * @param commitment - optional commitment that will be used to fetch Blockhash\n * @returns Unsigned Transaction with create ATA instructions\n */\nexport async function generateCreateAtaBatchTx(\n connection: Connection,\n payer: PublicKey,\n paramsBatch: AtaParams[],\n commitment?: Commitment,\n): Promise<{\n tx: VersionedTransaction;\n hash: BlockhashWithExpiryBlockHeight;\n context: Context;\n}> {\n paramsBatch = await enrichAtaParams(connection, paramsBatch);\n const ixs: TransactionInstruction[] = await Promise.all(\n paramsBatch.map(async ({ mint, owner, programId }) => {\n return createAssociatedTokenAccountInstruction(payer, await ata(mint, owner), owner, mint, programId);\n }),\n );\n const { value: hash, context } = await connection.getLatestBlockhashAndContext({ commitment });\n const messageV0 = new TransactionMessage({\n payerKey: payer,\n recentBlockhash: hash.blockhash,\n instructions: ixs,\n }).compileToV0Message();\n const tx = new VersionedTransaction(messageV0);\n return { tx, hash, context };\n}\n\n/**\n * Creates ATA for an array of owners\n * @param connection - Solana client connection\n * @param invoker - Transaction invoker and payer\n * @param paramsBatch - Array of Params for an each ATA account: {mint, owner}\n * @param commitment - optional commitment that will be used to fetch Blockhash\n * @param rate - throttle rate for tx sending\n * @returns Transaction signature\n */\nexport async function createAtaBatch(\n connection: Connection,\n invoker: Keypair | SignerWalletAdapter,\n paramsBatch: AtaParams[],\n commitment?: Commitment,\n rate?: number,\n): Promise<string> {\n const { tx, hash, context } = await generateCreateAtaBatchTx(\n connection,\n invoker.publicKey!,\n await enrichAtaParams(connection, paramsBatch),\n commitment,\n );\n return signAndExecuteTransaction(connection, invoker, tx, { hash, context, commitment }, { sendRate: rate });\n}\n\n/**\n * Utility function that checks whether associated token accounts exist and return instructions to populate them if not\n * @param connection - Solana client connection\n * @param owners - Array of ATA owners\n * @param mint - Mint for which ATA will be checked\n * @param invoker - Transaction invoker and payer\n * @param programId - Program ID of the Mint\n * @returns Array of Transaction Instructions that should be added to a transaction\n */\nexport async function checkOrCreateAtaBatch(\n connection: Connection,\n owners: PublicKey[],\n mint: PublicKey,\n invoker: SignerWalletAdapter | Keypair,\n programId?: PublicKey,\n): Promise<TransactionInstruction[]> {\n const ixs: TransactionInstruction[] = [];\n if (!programId) {\n programId = (await getMintAndProgram(connection, mint)).tokenProgramId;\n }\n // TODO: optimize fetching and maps/arrays\n const atas: PublicKey[] = [];\n for (const owner of owners) {\n atas.push(await ata(mint, owner, programId));\n }\n const response = await connection.getMultipleAccountsInfo(atas);\n for (let i = 0; i < response.length; i++) {\n if (!response[i]) {\n ixs.push(createAssociatedTokenAccountInstruction(invoker.publicKey!, atas[i]!, owners[i]!, mint, programId));\n }\n }\n return ixs;\n}\n\n/**\n * Create Base instructions for Solana\n * - sets compute price if `computePrice` is provided\n * - sets compute limit if `computeLimit` is provided\n */\nexport function prepareBaseInstructions(\n connection: Connection,\n { computePrice, computeLimit }: ITransactionSolanaExt,\n): TransactionInstruction[] {\n const ixs: TransactionInstruction[] = [];\n\n if (computePrice) {\n ixs.push(ComputeBudgetProgram.setComputeUnitPrice({ microLamports: computePrice }));\n }\n if (computeLimit) {\n ixs.push(ComputeBudgetProgram.setComputeUnitLimit({ units: computeLimit }));\n }\n\n return ixs;\n}\n\n/**\n * Retrieve information about a mint and its program ID, support all Token Programs.\n *\n * @param connection Connection to use\n * @param address Mint account\n * @param commitment Desired level of commitment for querying the state\n *\n * @return Mint information\n */\nexport async function getMintAndProgram(\n connection: Connection,\n address: PublicKey,\n commitment?: Commitment,\n): Promise<{ mint: Mint; tokenProgramId: PublicKey }> {\n const accountInfo = await connection.getAccountInfo(address, commitment);\n let programId = accountInfo?.owner;\n if (!programId?.equals(TOKEN_PROGRAM_ID) && !programId?.equals(TOKEN_2022_PROGRAM_ID)) {\n programId = TOKEN_PROGRAM_ID;\n }\n return {\n mint: unpackMint(address, accountInfo, programId),\n tokenProgramId: programId!,\n };\n}\n\n/**\n * Split fetching of Multiple Accounts Info into batches of 100\n * as the maximum number of accounts that can be fetched in a single call is 100\n *\n * @param connection Connection to use\n * @param pubKeys Array of public keys to fetch account info for\n * @param commitment Desired level of commitment for querying the state\n *\n * @return Array of AccountInfo objects\n */\nexport async function getMultipleAccountsInfoBatched(\n connection: Connection,\n pubKeys: PublicKey[],\n commitment?: Commitment,\n): Promise<(AccountInfo<Buffer> | null)[]> {\n const batchSize = 99;\n const batches: Promise<(AccountInfo<Buffer> | null)[]>[] = [];\n\n for (let i = 0; i < pubKeys.length; i += batchSize) {\n const batch = pubKeys.slice(i, i + batchSize);\n batches.push(connection.getMultipleAccountsInfo(batch, commitment));\n }\n\n const results = await Promise.all(batches);\n return results.flat();\n}\n"]}
@@ -1,9 +1,59 @@
1
- import { Mint } from "@solana/spl-token";
2
- import { SignerWalletAdapter } from "@solana/wallet-adapter-base";
3
- import { BlockhashWithExpiryBlockHeight, Commitment, Connection, Keypair, PublicKey, Transaction, TransactionInstruction, SignatureStatus, VersionedTransaction, Context, RpcResponseAndContext, SimulatedTransactionResponse, AccountInfo } from "@solana/web3.js";
4
- import PQueue from "p-queue";
5
- import { Account, AtaParams, ConfirmationParams, ITransactionSolanaExt, ThrottleParams } from "./types.js";
6
- export declare const buildSendThrottler: (sendRate: number, sendInterval?: number) => PQueue;
1
+ import { PublicKey, MemcmpFilter, Connection, TransactionInstruction, AccountInfo, BlockhashWithExpiryBlockHeight, Context, Commitment, Keypair, Transaction, VersionedTransaction, RpcResponseAndContext, SimulatedTransactionResponse, SignatureStatus } from '@solana/web3.js';
2
+ import BN from 'bn.js';
3
+ import PQueue from 'p-queue';
4
+ import { Mint } from '@solana/spl-token';
5
+ import { SignerWalletAdapter } from '@solana/wallet-adapter-base';
6
+
7
+ declare const getFilters: <T extends Record<string, number | PublicKey>>(criteria: T, byteOffsets: Record<keyof T, number>) => MemcmpFilter[];
8
+
9
+ declare const prepareWrappedAccount: (connection: Connection, senderAddress: PublicKey, amount: BN) => Promise<TransactionInstruction[]>;
10
+
11
+ /**
12
+ * Converts a string or PublicKey to a PublicKey object.
13
+ * @param address - The input address as a string or PublicKey.
14
+ * @returns The PublicKey object.
15
+ */
16
+ declare const pk: (address: string | PublicKey) => PublicKey;
17
+
18
+ interface ITransactionSolanaExt {
19
+ computePrice?: number;
20
+ computeLimit?: number;
21
+ }
22
+ interface Account {
23
+ pubkey: PublicKey;
24
+ account: AccountInfo<Buffer>;
25
+ }
26
+ interface CheckAssociatedTokenAccountsData {
27
+ sender: PublicKey;
28
+ recipient: PublicKey;
29
+ partner: PublicKey;
30
+ streamflowTreasury: PublicKey;
31
+ mint: PublicKey;
32
+ }
33
+ interface AtaParams {
34
+ mint: PublicKey;
35
+ owner: PublicKey;
36
+ programId?: PublicKey;
37
+ }
38
+ interface ConfirmationParams {
39
+ hash: BlockhashWithExpiryBlockHeight;
40
+ context: Context;
41
+ commitment?: Commitment;
42
+ }
43
+ interface ThrottleParams {
44
+ sendRate?: number;
45
+ sendThrottler?: PQueue;
46
+ waitBeforeConfirming?: number | undefined;
47
+ }
48
+ interface IProgramAccount<T> {
49
+ publicKey: PublicKey;
50
+ account: T;
51
+ }
52
+ declare class TransactionFailedError extends Error {
53
+ constructor(m: string);
54
+ }
55
+
56
+ declare const buildSendThrottler: (sendRate: number, sendInterval?: number) => PQueue;
7
57
  /**
8
58
  * Wrapper function for Solana web3 getProgramAccounts with slightly better call interface
9
59
  * @param {Connection} connection - Solana web3 connection object.
@@ -12,25 +62,25 @@ export declare const buildSendThrottler: (sendRate: number, sendInterval?: numbe
12
62
  * @param {PublicKey} programId - Solana program ID.
13
63
  * @return {Promise<Account[]>} - Array of resulting accounts.
14
64
  */
15
- export declare function getProgramAccounts(connection: Connection, wallet: PublicKey, offset: number, programId: PublicKey): Promise<Account[]>;
65
+ declare function getProgramAccounts(connection: Connection, wallet: PublicKey, offset: number, programId: PublicKey): Promise<Account[]>;
16
66
  /**
17
67
  * Utility function to check if the transaction initiator is a Wallet object
18
68
  * @param {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
19
69
  * @return {boolean} - Returns true if parameter is a Wallet.
20
70
  */
21
- export declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is SignerWalletAdapter;
71
+ declare function isSignerWallet(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is SignerWalletAdapter;
22
72
  /**
23
73
  * Utility function to check if the transaction initiator a Keypair object, tries to mitigate version mismatch issues
24
74
  * @param walletOrKeypair {Keypair | SignerWalletAdapter} walletOrKeypair - Wallet or Keypair in question
25
75
  * @returns {boolean} - Returns true if parameter is a Keypair.
26
76
  */
27
- export declare function isSignerKeypair(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is Keypair;
77
+ declare function isSignerKeypair(walletOrKeypair: Keypair | SignerWalletAdapter): walletOrKeypair is Keypair;
28
78
  /**
29
79
  * Utility function to check whether given transaction is Versioned
30
80
  * @param tx {Transaction | VersionedTransaction} - Transaction to check
31
81
  * @returns {boolean} - Returns true if transaction is Versioned.
32
82
  */
33
- export declare function isTransactionVersioned(tx: Transaction | VersionedTransaction): tx is VersionedTransaction;
83
+ declare function isTransactionVersioned(tx: Transaction | VersionedTransaction): tx is VersionedTransaction;
34
84
  /**
35
85
  * Creates a Transaction with given instructions and optionally signs it.
36
86
  * @param connection - Solana client connection
@@ -40,12 +90,12 @@ export declare function isTransactionVersioned(tx: Transaction | VersionedTransa
40
90
  * @param partialSigners - optional signers that will be used to partially sign a Transaction
41
91
  * @returns Transaction and Blockhash
42
92
  */
43
- export declare function prepareTransaction(connection: Connection, ixs: TransactionInstruction[], payer: PublicKey | undefined | null, commitment?: Commitment, ...partialSigners: (Keypair | undefined)[]): Promise<{
93
+ declare function prepareTransaction(connection: Connection, ixs: TransactionInstruction[], payer: PublicKey | undefined | null, commitment?: Commitment, ...partialSigners: (Keypair | undefined)[]): Promise<{
44
94
  tx: VersionedTransaction;
45
95
  hash: BlockhashWithExpiryBlockHeight;
46
96
  context: Context;
47
97
  }>;
48
- export declare function signTransaction<T extends Transaction | VersionedTransaction>(invoker: Keypair | SignerWalletAdapter, tx: T): Promise<T>;
98
+ declare function signTransaction<T extends Transaction | VersionedTransaction>(invoker: Keypair | SignerWalletAdapter, tx: T): Promise<T>;
49
99
  /**
50
100
  * Signs, sends and confirms Transaction
51
101
  * @param connection - Solana client connection
@@ -55,7 +105,7 @@ export declare function signTransaction<T extends Transaction | VersionedTransac
55
105
  * @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much
56
106
  * @returns Transaction signature
57
107
  */
58
- export declare function signAndExecuteTransaction(connection: Connection, invoker: Keypair | SignerWalletAdapter, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams, throttleParams: ThrottleParams): Promise<string>;
108
+ declare function signAndExecuteTransaction(connection: Connection, invoker: Keypair | SignerWalletAdapter, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams, throttleParams: ThrottleParams): Promise<string>;
59
109
  /**
60
110
  * Sends and confirms Transaction
61
111
  * Uses custom confirmation logic that:
@@ -71,7 +121,7 @@ export declare function signAndExecuteTransaction(connection: Connection, invoke
71
121
  * @param throttleParams - rate or throttler instance to throttle TX sending - to not spam the blockchain too much
72
122
  * @returns Transaction signature
73
123
  */
74
- export declare function executeTransaction(connection: Connection, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams, throttleParams: ThrottleParams): Promise<string>;
124
+ declare function executeTransaction(connection: Connection, tx: Transaction | VersionedTransaction, confirmationParams: ConfirmationParams, throttleParams: ThrottleParams): Promise<string>;
75
125
  /**
76
126
  * Launches a PromisePool with all transaction being executed at the same time, allows to throttle all TXs through one Queue
77
127
  * @param connection - Solana client connection
@@ -82,7 +132,7 @@ export declare function executeTransaction(connection: Connection, tx: Transacti
82
132
  * @param throttleParams.sendThrottler - throttler instance
83
133
  * @returns Raw Promise Results - should be handled by the consumer and unwrapped accordingly
84
134
  */
85
- export declare function executeMultipleTransactions(connection: Connection, txs: (Transaction | VersionedTransaction)[], confirmationParams: ConfirmationParams, { sendRate, sendThrottler, ...throttlingParams }: ThrottleParams): Promise<PromiseSettledResult<string>[]>;
135
+ declare function executeMultipleTransactions(connection: Connection, txs: (Transaction | VersionedTransaction)[], confirmationParams: ConfirmationParams, { sendRate, sendThrottler, ...throttlingParams }: ThrottleParams): Promise<PromiseSettledResult<string>[]>;
86
136
  /**
87
137
  * Sends and confirm transaction in a loop, constantly re-broadcsting the tx until Blockheight expires.
88
138
  * - we add additional 30 bocks to account for validators in an PRC pool divergence
@@ -96,8 +146,8 @@ export declare function executeMultipleTransactions(connection: Connection, txs:
96
146
  * @param throttleParams.sendRate - rate
97
147
  * @param throttleParams.sendThrottler - throttler instance
98
148
  */
99
- export declare function sendAndConfirmTransaction(connection: Connection, tx: Transaction | VersionedTransaction, { hash, context, commitment }: ConfirmationParams, { sendRate, sendThrottler, waitBeforeConfirming }: ThrottleParams): Promise<string>;
100
- export declare function simulateTransaction(connection: Connection, tx: Transaction | VersionedTransaction): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
149
+ declare function sendAndConfirmTransaction(connection: Connection, tx: Transaction | VersionedTransaction, { hash, context, commitment }: ConfirmationParams, { sendRate, sendThrottler, waitBeforeConfirming }: ThrottleParams): Promise<string>;
150
+ declare function simulateTransaction(connection: Connection, tx: Transaction | VersionedTransaction): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;
101
151
  /**
102
152
  * Confirms and validates transaction success once
103
153
  * @param connection - Solana client connection
@@ -105,7 +155,7 @@ export declare function simulateTransaction(connection: Connection, tx: Transact
105
155
  * @param ignoreError - return status even if tx failed
106
156
  * @returns Transaction Status
107
157
  */
108
- export declare function confirmAndEnsureTransaction(connection: Connection, signature: string, ignoreError?: boolean): Promise<SignatureStatus | null>;
158
+ declare function confirmAndEnsureTransaction(connection: Connection, signature: string, ignoreError?: boolean): Promise<SignatureStatus | null>;
109
159
  /**
110
160
  * Shorthand call signature for getAssociatedTokenAddress, with allowance for address to be offCurve
111
161
  * @param {PublicKey} mint - SPL token Mint address.
@@ -113,15 +163,15 @@ export declare function confirmAndEnsureTransaction(connection: Connection, sign
113
163
  * @param {PublicKey} programId - Program ID of the mint
114
164
  * @return {Promise<PublicKey>} - Associated Token Address
115
165
  */
116
- export declare function ata(mint: PublicKey, owner: PublicKey, programId?: PublicKey): Promise<PublicKey>;
166
+ declare function ata(mint: PublicKey, owner: PublicKey, programId?: PublicKey): Promise<PublicKey>;
117
167
  /**
118
168
  * Function that checks whether ATA exists for each provided owner
119
169
  * @param connection - Solana client connection
120
170
  * @param paramsBatch - Array of Params for each ATA account: {mint, owner}
121
171
  * @returns Array of boolean where each member corresponds to an owner
122
172
  */
123
- export declare function ataBatchExist(connection: Connection, paramsBatch: AtaParams[]): Promise<boolean[]>;
124
- export declare function enrichAtaParams(connection: Connection, paramsBatch: AtaParams[]): Promise<AtaParams[]>;
173
+ declare function ataBatchExist(connection: Connection, paramsBatch: AtaParams[]): Promise<boolean[]>;
174
+ declare function enrichAtaParams(connection: Connection, paramsBatch: AtaParams[]): Promise<AtaParams[]>;
125
175
  /**
126
176
  * Generates a Transaction to create ATA for an array of owners
127
177
  * @param connection - Solana client connection
@@ -130,7 +180,7 @@ export declare function enrichAtaParams(connection: Connection, paramsBatch: Ata
130
180
  * @param commitment - optional commitment that will be used to fetch Blockhash
131
181
  * @returns Unsigned Transaction with create ATA instructions
132
182
  */
133
- export declare function generateCreateAtaBatchTx(connection: Connection, payer: PublicKey, paramsBatch: AtaParams[], commitment?: Commitment): Promise<{
183
+ declare function generateCreateAtaBatchTx(connection: Connection, payer: PublicKey, paramsBatch: AtaParams[], commitment?: Commitment): Promise<{
134
184
  tx: VersionedTransaction;
135
185
  hash: BlockhashWithExpiryBlockHeight;
136
186
  context: Context;
@@ -144,7 +194,7 @@ export declare function generateCreateAtaBatchTx(connection: Connection, payer:
144
194
  * @param rate - throttle rate for tx sending
145
195
  * @returns Transaction signature
146
196
  */
147
- export declare function createAtaBatch(connection: Connection, invoker: Keypair | SignerWalletAdapter, paramsBatch: AtaParams[], commitment?: Commitment, rate?: number): Promise<string>;
197
+ declare function createAtaBatch(connection: Connection, invoker: Keypair | SignerWalletAdapter, paramsBatch: AtaParams[], commitment?: Commitment, rate?: number): Promise<string>;
148
198
  /**
149
199
  * Utility function that checks whether associated token accounts exist and return instructions to populate them if not
150
200
  * @param connection - Solana client connection
@@ -154,13 +204,13 @@ export declare function createAtaBatch(connection: Connection, invoker: Keypair
154
204
  * @param programId - Program ID of the Mint
155
205
  * @returns Array of Transaction Instructions that should be added to a transaction
156
206
  */
157
- export declare function checkOrCreateAtaBatch(connection: Connection, owners: PublicKey[], mint: PublicKey, invoker: SignerWalletAdapter | Keypair, programId?: PublicKey): Promise<TransactionInstruction[]>;
207
+ declare function checkOrCreateAtaBatch(connection: Connection, owners: PublicKey[], mint: PublicKey, invoker: SignerWalletAdapter | Keypair, programId?: PublicKey): Promise<TransactionInstruction[]>;
158
208
  /**
159
209
  * Create Base instructions for Solana
160
210
  * - sets compute price if `computePrice` is provided
161
211
  * - sets compute limit if `computeLimit` is provided
162
212
  */
163
- export declare function prepareBaseInstructions(connection: Connection, { computePrice, computeLimit }: ITransactionSolanaExt): TransactionInstruction[];
213
+ declare function prepareBaseInstructions(connection: Connection, { computePrice, computeLimit }: ITransactionSolanaExt): TransactionInstruction[];
164
214
  /**
165
215
  * Retrieve information about a mint and its program ID, support all Token Programs.
166
216
  *
@@ -170,7 +220,7 @@ export declare function prepareBaseInstructions(connection: Connection, { comput
170
220
  *
171
221
  * @return Mint information
172
222
  */
173
- export declare function getMintAndProgram(connection: Connection, address: PublicKey, commitment?: Commitment): Promise<{
223
+ declare function getMintAndProgram(connection: Connection, address: PublicKey, commitment?: Commitment): Promise<{
174
224
  mint: Mint;
175
225
  tokenProgramId: PublicKey;
176
226
  }>;
@@ -184,4 +234,6 @@ export declare function getMintAndProgram(connection: Connection, address: Publi
184
234
  *
185
235
  * @return Array of AccountInfo objects
186
236
  */
187
- export declare function getMultipleAccountsInfoBatched(connection: Connection, pubKeys: PublicKey[], commitment?: Commitment): Promise<(AccountInfo<Buffer> | null)[]>;
237
+ declare function getMultipleAccountsInfoBatched(connection: Connection, pubKeys: PublicKey[], commitment?: Commitment): Promise<(AccountInfo<Buffer> | null)[]>;
238
+
239
+ export { type Account, type AtaParams, type CheckAssociatedTokenAccountsData, type ConfirmationParams, type IProgramAccount, type ITransactionSolanaExt, type ThrottleParams, TransactionFailedError, ata, ataBatchExist, buildSendThrottler, checkOrCreateAtaBatch, confirmAndEnsureTransaction, createAtaBatch, enrichAtaParams, executeMultipleTransactions, executeTransaction, generateCreateAtaBatchTx, getFilters, getMintAndProgram, getMultipleAccountsInfoBatched, getProgramAccounts, isSignerKeypair, isSignerWallet, isTransactionVersioned, pk, prepareBaseInstructions, prepareTransaction, prepareWrappedAccount, sendAndConfirmTransaction, signAndExecuteTransaction, signTransaction, simulateTransaction };
@@ -1,3 +1,66 @@
1
- export * from "./types.js";
2
- export * from "./lib/assertions.js";
3
- export * from "./lib/utils.js";
1
+ import { TransactionInstruction } from '@solana/web3.js';
2
+ import BN from 'bn.js';
3
+
4
+ interface ITransactionResult {
5
+ ixs: TransactionInstruction[];
6
+ txId: string;
7
+ }
8
+ declare enum ICluster {
9
+ Mainnet = "mainnet",
10
+ Devnet = "devnet",
11
+ Testnet = "testnet",
12
+ Local = "local"
13
+ }
14
+ declare enum IChain {
15
+ Solana = "Solana",
16
+ Aptos = "Aptos",
17
+ Ethereum = "Ethereum",
18
+ BNB = "BNB",
19
+ Polygon = "Polygon",
20
+ Sui = "Sui"
21
+ }
22
+ /**
23
+ * Error wrapper for calls made to the contract on chain
24
+ */
25
+ declare class ContractError extends Error {
26
+ contractErrorCode: string | null;
27
+ description: string | null;
28
+ /**
29
+ * Constructs the Error Wrapper
30
+ * @param error Original error raised probably by the chain SDK
31
+ * @param code extracted code from the error if managed to parse it
32
+ */
33
+ constructor(error: Error, code?: string | null, description?: string | null);
34
+ }
35
+
36
+ declare const invariant: (condition: any, message?: string | (() => string)) => asserts condition;
37
+
38
+ /**
39
+ * Used for conversion of token amounts to their Big Number representation.
40
+ * Get Big Number representation in the smallest units from the same value in the highest units.
41
+ * @param {number} value - Number of tokens you want to convert to its BN representation.
42
+ * @param {number} decimals - Number of decimals the token has.
43
+ */
44
+ declare const getBN: (value: number, decimals: number) => BN;
45
+ /**
46
+ * Used for token amounts conversion from their Big Number representation to number.
47
+ * Get value in the highest units from BN representation of the same value in the smallest units.
48
+ * @param {BN} value - Big Number representation of value in the smallest units.
49
+ * @param {number} decimals - Number of decimals the token has.
50
+ */
51
+ declare const getNumberFromBN: (value: BN, decimals: number) => number;
52
+ /**
53
+ * Used to make on chain calls to the contract and wrap raised errors if any
54
+ * @param func function that interacts with the contract
55
+ * @param callback callback that may be used to extract error code
56
+ * @returns {T}
57
+ */
58
+ declare function handleContractError<T>(func: () => Promise<T>, callback?: (err: Error) => string | null): Promise<T>;
59
+ /**
60
+ * Pause async function execution for given amount of milliseconds
61
+ * @param ms millisecond to sleep for
62
+ */
63
+ declare function sleep(ms: number): Promise<void>;
64
+ declare const divCeilN: (n: bigint, d: bigint) => bigint;
65
+
66
+ export { ContractError, IChain, ICluster, type ITransactionResult, divCeilN, getBN, getNumberFromBN, handleContractError, invariant, sleep };
package/dist/esm/index.js CHANGED
@@ -1,3 +1,76 @@
1
- export * from "./types.js";
2
- export * from "./lib/assertions.js";
3
- export * from "./lib/utils.js";
1
+ import '@solana/web3.js';
2
+ import BN from 'bn.js';
3
+
4
+ // types.ts
5
+ var ICluster = /* @__PURE__ */ ((ICluster2) => {
6
+ ICluster2["Mainnet"] = "mainnet";
7
+ ICluster2["Devnet"] = "devnet";
8
+ ICluster2["Testnet"] = "testnet";
9
+ ICluster2["Local"] = "local";
10
+ return ICluster2;
11
+ })(ICluster || {});
12
+ var IChain = /* @__PURE__ */ ((IChain2) => {
13
+ IChain2["Solana"] = "Solana";
14
+ IChain2["Aptos"] = "Aptos";
15
+ IChain2["Ethereum"] = "Ethereum";
16
+ IChain2["BNB"] = "BNB";
17
+ IChain2["Polygon"] = "Polygon";
18
+ IChain2["Sui"] = "Sui";
19
+ return IChain2;
20
+ })(IChain || {});
21
+ var ContractError = class _ContractError extends Error {
22
+ /**
23
+ * Constructs the Error Wrapper
24
+ * @param error Original error raised probably by the chain SDK
25
+ * @param code extracted code from the error if managed to parse it
26
+ */
27
+ constructor(error, code, description) {
28
+ super(error.message);
29
+ this.contractErrorCode = code ?? null;
30
+ this.description = description ?? null;
31
+ Object.setPrototypeOf(this, _ContractError.prototype);
32
+ this.name = "ContractError";
33
+ this.stack = error.stack;
34
+ }
35
+ };
36
+
37
+ // lib/assertions.ts
38
+ var prefix = "Assertion failed";
39
+ var invariant = (condition, message) => {
40
+ if (condition) {
41
+ return;
42
+ }
43
+ const provided = typeof message === "function" ? message() : message;
44
+ const value = provided ? `${prefix}: ${provided}` : prefix;
45
+ throw new Error(value);
46
+ };
47
+ var getBN = (value, decimals) => {
48
+ const decimalPart = value - Math.trunc(value);
49
+ const integerPart = new BN(Math.trunc(value));
50
+ const decimalE = new BN(decimalPart * 1e9);
51
+ const sum = integerPart.mul(new BN(1e9)).add(decimalE);
52
+ const resultE = sum.mul(new BN(10).pow(new BN(decimals)));
53
+ return resultE.div(new BN(1e9));
54
+ };
55
+ var getNumberFromBN = (value, decimals) => value.gt(new BN(2 ** 53 - 1)) ? value.div(new BN(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;
56
+ async function handleContractError(func, callback) {
57
+ try {
58
+ return await func();
59
+ } catch (err) {
60
+ if (err instanceof Error) {
61
+ if (callback) {
62
+ throw new ContractError(err, callback(err));
63
+ }
64
+ throw new ContractError(err);
65
+ }
66
+ throw err;
67
+ }
68
+ }
69
+ function sleep(ms) {
70
+ return new Promise((resolve) => setTimeout(resolve, ms));
71
+ }
72
+ var divCeilN = (n, d) => n / d + (n % d ? BigInt(1) : BigInt(0));
73
+
74
+ export { ContractError, IChain, ICluster, divCeilN, getBN, getNumberFromBN, handleContractError, invariant, sleep };
75
+ //# sourceMappingURL=index.js.map
76
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../types.ts","../../lib/assertions.ts","../../lib/utils.ts"],"names":["ICluster","IChain"],"mappings":";;;;AAQY,IAAA,QAAA,qBAAAA,SAAL,KAAA;AACL,EAAAA,UAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAAA,UAAA,QAAS,CAAA,GAAA,QAAA;AACT,EAAAA,UAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAAA,UAAA,OAAQ,CAAA,GAAA,OAAA;AAJE,EAAAA,OAAAA,SAAAA;AAAA,CAAA,EAAA,QAAA,IAAA,EAAA;AAOA,IAAA,MAAA,qBAAAC,OAAL,KAAA;AACL,EAAAA,QAAA,QAAS,CAAA,GAAA,QAAA;AACT,EAAAA,QAAA,OAAQ,CAAA,GAAA,OAAA;AACR,EAAAA,QAAA,UAAW,CAAA,GAAA,UAAA;AACX,EAAAA,QAAA,KAAM,CAAA,GAAA,KAAA;AACN,EAAAA,QAAA,SAAU,CAAA,GAAA,SAAA;AACV,EAAAA,QAAA,KAAM,CAAA,GAAA,KAAA;AANI,EAAAA,OAAAA,OAAAA;AAAA,CAAA,EAAA,MAAA,IAAA,EAAA;AAYC,IAAA,aAAA,GAAN,MAAM,cAAA,SAAsB,KAAM,CAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAUvC,WAAA,CAAY,KAAc,EAAA,IAAA,EAAsB,WAA6B,EAAA;AAC3E,IAAA,KAAA,CAAM,MAAM,OAAO,CAAA;AACnB,IAAA,IAAA,CAAK,oBAAoB,IAAQ,IAAA,IAAA;AACjC,IAA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eAAA,GAAkB,CAAC,KAAA,EAAW,QACzC,KAAA,KAAA,CAAM,EAAG,CAAA,IAAI,EAAG,CAAA,CAAA,IAAK,EAAK,GAAA,CAAC,CAAC,CAAA,GAAI,MAAM,GAAI,CAAA,IAAI,EAAG,CAAA,EAAA,IAAM,QAAQ,CAAC,CAAE,CAAA,QAAA,EAAa,GAAA,KAAA,CAAM,QAAS,EAAA,GAAI,EAAM,IAAA;AAQ1G,eAAsB,mBAAA,CACpB,MACA,QACY,EAAA;AACZ,EAAI,IAAA;AACF,IAAA,OAAO,MAAM,IAAK,EAAA;AAAA,WAEX,GAAU,EAAA;AACjB,IAAA,IAAI,eAAe,KAAO,EAAA;AACxB,MAAA,IAAI,QAAU,EAAA;AACZ,QAAA,MAAM,IAAI,aAAA,CAAc,GAAK,EAAA,QAAA,CAAS,GAAG,CAAC,CAAA;AAAA;AAE5C,MAAM,MAAA,IAAI,cAAc,GAAG,CAAA;AAAA;AAE7B,IAAM,MAAA,GAAA;AAAA;AAEV;AAMO,SAAS,MAAM,EAA2B,EAAA;AAC/C,EAAA,OAAO,IAAI,OAAQ,CAAA,CAAC,YAAY,UAAW,CAAA,OAAA,EAAS,EAAE,CAAC,CAAA;AACzD;AAEO,IAAM,QAAW,GAAA,CAAC,CAAW,EAAA,CAAA,KAAsB,CAAI,GAAA,CAAA,IAAK,CAAI,GAAA,CAAA,GAAI,MAAO,CAAA,CAAC,CAAI,GAAA,MAAA,CAAO,CAAC,CAAA","file":"index.js","sourcesContent":["import { type TransactionInstruction } from \"@solana/web3.js\";\n\nexport interface ITransactionResult {\n ixs: TransactionInstruction[];\n txId: string;\n}\n\n// Utility types\nexport enum ICluster {\n Mainnet = \"mainnet\",\n Devnet = \"devnet\",\n Testnet = \"testnet\",\n Local = \"local\",\n}\n\nexport enum IChain {\n Solana = \"Solana\",\n Aptos = \"Aptos\",\n Ethereum = \"Ethereum\",\n BNB = \"BNB\",\n Polygon = \"Polygon\",\n Sui = \"Sui\",\n}\n\n/**\n * Error wrapper for calls made to the contract on chain\n */\nexport class ContractError extends Error {\n public contractErrorCode: string | null;\n\n public description: string | null;\n\n /**\n * Constructs the Error Wrapper\n * @param error Original error raised probably by the chain SDK\n * @param code extracted code from the error if managed to parse it\n */\n constructor(error: Error, code?: string | null, description?: string | null) {\n super(error.message); // Call the base class constructor with the error message\n this.contractErrorCode = code ?? null;\n this.description = description ?? null;\n // Copy properties from the original error\n Object.setPrototypeOf(this, ContractError.prototype);\n this.name = \"ContractError\"; // Set the name property\n this.stack = error.stack;\n }\n}\n","const prefix = \"Assertion failed\";\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport const invariant: (condition: any, message?: string | (() => string)) => asserts condition = (\n condition,\n message,\n) => {\n if (condition) {\n return;\n }\n const provided: string | undefined = typeof message === \"function\" ? message() : message;\n const value: string = provided ? `${prefix}: ${provided}` : prefix;\n throw new Error(value);\n};\n","import BN from \"bn.js\";\n\nimport { ContractError } from \"../types.js\";\n\n/**\n * Used for conversion of token amounts to their Big Number representation.\n * Get Big Number representation in the smallest units from the same value in the highest units.\n * @param {number} value - Number of tokens you want to convert to its BN representation.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getBN = (value: number, decimals: number): BN => {\n const decimalPart = value - Math.trunc(value);\n const integerPart = new BN(Math.trunc(value));\n\n const decimalE = new BN(decimalPart * 1e9);\n\n const sum = integerPart.mul(new BN(1e9)).add(decimalE);\n const resultE = sum.mul(new BN(10).pow(new BN(decimals)));\n return resultE.div(new BN(1e9));\n};\n\n/**\n * Used for token amounts conversion from their Big Number representation to number.\n * Get value in the highest units from BN representation of the same value in the smallest units.\n * @param {BN} value - Big Number representation of value in the smallest units.\n * @param {number} decimals - Number of decimals the token has.\n */\nexport const getNumberFromBN = (value: BN, decimals: number): number =>\n value.gt(new BN(2 ** 53 - 1)) ? value.div(new BN(10 ** decimals)).toNumber() : value.toNumber() / 10 ** decimals;\n\n/**\n * Used to make on chain calls to the contract and wrap raised errors if any\n * @param func function that interacts with the contract\n * @param callback callback that may be used to extract error code\n * @returns {T}\n */\nexport async function handleContractError<T>(\n func: () => Promise<T>,\n callback?: (err: Error) => string | null,\n): Promise<T> {\n try {\n return await func();\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n } catch (err: any) {\n if (err instanceof Error) {\n if (callback) {\n throw new ContractError(err, callback(err));\n }\n throw new ContractError(err);\n }\n throw err;\n }\n}\n\n/**\n * Pause async function execution for given amount of milliseconds\n * @param ms millisecond to sleep for\n */\nexport function sleep(ms: number): Promise<void> {\n return new Promise((resolve) => setTimeout(resolve, ms));\n}\n\nexport const divCeilN = (n: bigint, d: bigint): bigint => n / d + (n % d ? BigInt(1) : BigInt(0));\n"]}