stxer 0.4.0 → 0.4.1

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.
@@ -1 +1 @@
1
- {"version":3,"file":"stxer.cjs.production.min.js","sources":["../src/BatchAPI.ts","../src/simulation.ts","../src/clarity-api.ts","../src/BatchProcessor.ts"],"sourcesContent":["/**\n * WARNING:\n *\n * this file will be used in cross-runtime environments (browser, cloudflare workers, XLinkSDK, etc.),\n * so please be careful when adding `import`s to it.\n */\n\nimport {\n type ClarityValue,\n type ContractPrincipalCV,\n deserializeCV,\n serializeCV,\n} from '@stacks/transactions';\n\nexport interface BatchReads {\n variables?: {\n contract: ContractPrincipalCV;\n variableName: string;\n }[];\n maps?: {\n contract: ContractPrincipalCV;\n mapName: string;\n mapKey: ClarityValue;\n }[];\n readonly?: {\n contract: ContractPrincipalCV;\n functionName: string;\n functionArgs: ClarityValue[];\n }[];\n index_block_hash?: string;\n}\n\nexport interface BatchReadsResult {\n tip: string;\n vars: (ClarityValue | Error)[];\n maps: (ClarityValue | Error)[];\n readonly: (ClarityValue | Error)[];\n}\n\nexport interface BatchApiOptions {\n stxerApi?: string;\n}\n\nconst DEFAULT_STXER_API = 'https://api.stxer.xyz';\n\nfunction convertResults(\n rs: ({ Ok: string } | { Err: string })[],\n): (ClarityValue | Error)[] {\n const results: (ClarityValue | Error)[] = [];\n for (const v of rs) {\n if ('Ok' in v) {\n results.push(deserializeCV(v.Ok));\n } else {\n results.push(new Error(v.Err));\n }\n }\n return results;\n}\n\nexport async function batchRead(\n reads: BatchReads,\n options: BatchApiOptions = {}\n): Promise<BatchReadsResult> {\n const ibh =\n reads.index_block_hash == null\n ? undefined\n : reads.index_block_hash.startsWith('0x')\n ? reads.index_block_hash.substring(2)\n : reads.index_block_hash;\n\n const payload: {\n tip?: string;\n vars: string[][];\n maps: string[][];\n readonly: string[][];\n } = { vars: [], maps: [], readonly: [], tip: ibh };\n\n if (reads.variables != null) {\n for (const variable of reads.variables) {\n payload.vars.push([serializeCV(variable.contract), variable.variableName]);\n }\n }\n\n if (reads.maps != null) {\n for (const map of reads.maps) {\n payload.maps.push([\n serializeCV(map.contract),\n map.mapName,\n serializeCV(map.mapKey),\n ]);\n }\n }\n\n if (reads.readonly != null) {\n for (const ro of reads.readonly) {\n payload.readonly.push([\n serializeCV(ro.contract),\n ro.functionName,\n ...ro.functionArgs.map(v => serializeCV(v)),\n ]);\n }\n }\n\n const url = `${options.stxerApi ?? DEFAULT_STXER_API}/sidecar/v2/batch`;\n const data = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(payload),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n const text = await data.text();\n if (!text.includes('Ok') && !text.includes('Err')) {\n throw new Error(\n `Requesting batch reads failed: ${text}, url: ${url}, payload: ${JSON.stringify(\n payload,\n )}`,\n );\n }\n\n const rs = JSON.parse(text) as {\n tip: string;\n vars: ({ Ok: string } | { Err: string })[];\n maps: ({ Ok: string } | { Err: string })[];\n readonly: ({ Ok: string } | { Err: string })[];\n };\n\n return {\n tip: rs.tip,\n vars: convertResults(rs.vars),\n maps: convertResults(rs.maps),\n readonly: convertResults(rs.readonly),\n };\n}","import { type AccountDataResponse, getNodeInfo, richFetch } from 'ts-clarity';\nimport type { Block } from '@stacks/stacks-blockchain-api-types';\nimport {\n STACKS_MAINNET,\n STACKS_TESTNET,\n type StacksNetworkName,\n} from '@stacks/network';\nimport {\n type ClarityValue,\n ClarityVersion,\n PostConditionMode,\n type StacksTransactionWire,\n bufferCV,\n contractPrincipalCV,\n deserializeTransaction,\n makeUnsignedContractCall,\n makeUnsignedContractDeploy,\n makeUnsignedSTXTokenTransfer,\n serializeCVBytes,\n stringAsciiCV,\n tupleCV,\n uintCV,\n} from '@stacks/transactions';\nimport { c32addressDecode } from 'c32check';\n\nfunction runTx(tx: StacksTransactionWire) {\n // type 0: run transaction\n return tupleCV({ type: uintCV(0), data: bufferCV(tx.serializeBytes()) });\n}\n\nexport interface SimulationEval {\n contract_id: string;\n code: string;\n}\n\nexport function runEval({ contract_id, code }: SimulationEval) {\n const [contract_address, contract_name] = contract_id.split('.');\n // type 1: eval arbitrary code inside a contract\n return tupleCV({\n type: uintCV(1),\n data: bufferCV(\n serializeCVBytes(\n tupleCV({\n contract: contractPrincipalCV(contract_address, contract_name),\n code: stringAsciiCV(code),\n })\n )\n ),\n });\n}\n\nexport async function runSimulation(\n apiEndpoint: string,\n block_hash: string,\n block_height: number,\n txs: (StacksTransactionWire | SimulationEval)[]\n) {\n // Convert 'sim-v1' to Uint8Array\n const header = new TextEncoder().encode('sim-v1');\n // Create 8 bytes for block height\n const heightBytes = new Uint8Array(8);\n // Convert block height to bytes\n const view = new DataView(heightBytes.buffer);\n view.setBigUint64(0, BigInt(block_height), false); // false for big-endian\n\n // Convert block hash to bytes\n const hashHex = block_hash.startsWith('0x')\n ? block_hash.substring(2)\n : block_hash;\n // Replace non-null assertion with null check\n const matches = hashHex.match(/.{1,2}/g);\n if (!matches) {\n throw new Error('Invalid block hash format');\n }\n const hashBytes = new Uint8Array(\n matches.map((byte) => Number.parseInt(byte, 16))\n );\n\n // Convert transactions to bytes\n const txBytes = txs\n .map((t) => ('contract_id' in t && 'code' in t ? runEval(t) : runTx(t)))\n .map((t) => serializeCVBytes(t));\n\n // Combine all byte arrays\n const totalLength =\n header.length +\n heightBytes.length +\n hashBytes.length +\n txBytes.reduce((acc, curr) => acc + curr.length, 0);\n const body = new Uint8Array(totalLength);\n\n let offset = 0;\n body.set(header, offset);\n offset += header.length;\n body.set(heightBytes, offset);\n offset += heightBytes.length;\n body.set(hashBytes, offset);\n offset += hashBytes.length;\n for (const tx of txBytes) {\n body.set(tx, offset);\n offset += tx.length;\n }\n\n const rs = await fetch(apiEndpoint, {\n method: 'POST',\n body,\n }).then(async (rs) => {\n const response = await rs.text();\n if (!response.startsWith('{')) {\n throw new Error(`failed to submit simulation: ${response}`);\n }\n return JSON.parse(response) as { id: string };\n });\n return rs.id;\n}\n\ninterface SimulationBuilderOptions {\n apiEndpoint?: string;\n stacksNodeAPI?: string;\n network?: StacksNetworkName | string;\n}\n\nexport class SimulationBuilder {\n private apiEndpoint: string;\n private stacksNodeAPI: string;\n private network: StacksNetworkName | string;\n\n private constructor(options: SimulationBuilderOptions = {}) {\n this.apiEndpoint = options.apiEndpoint ?? 'https://api.stxer.xyz';\n this.stacksNodeAPI = options.stacksNodeAPI ?? 'https://api.hiro.so';\n this.network = options.network ?? 'mainnet';\n }\n\n public static new(options?: SimulationBuilderOptions) {\n return new SimulationBuilder(options);\n }\n\n // biome-ignore lint/style/useNumberNamespace: <explanation>\n private block = NaN;\n private sender = '';\n private steps: (\n | {\n // inline simulation\n simulationId: string;\n }\n | {\n // contract call\n contract_id: string;\n function_name: string;\n function_args?: ClarityValue[];\n sender: string;\n fee: number;\n }\n | {\n // contract deploy\n contract_name: string;\n source_code: string;\n deployer: string;\n fee: number;\n clarity_version: ClarityVersion;\n }\n | {\n // STX transfer\n recipient: string;\n amount: number;\n sender: string;\n fee: number;\n }\n | SimulationEval\n )[] = [];\n\n public useBlockHeight(block: number) {\n this.block = block;\n return this;\n }\n public withSender(address: string) {\n this.sender = address;\n return this;\n }\n public inlineSimulation(simulationId: string) {\n this.steps.push({\n simulationId,\n })\n return this;\n }\n public addSTXTransfer(params: {\n recipient: string;\n amount: number;\n sender?: string;\n fee?: number;\n }) {\n if (params.sender == null && this.sender === '') {\n throw new Error(\n 'Please specify a sender with useSender or adding a sender paramenter'\n );\n }\n this.steps.push({\n ...params,\n sender: params.sender ?? this.sender,\n fee: params.fee ?? 0,\n });\n return this;\n }\n public addContractCall(params: {\n contract_id: string;\n function_name: string;\n function_args?: ClarityValue[];\n sender?: string;\n fee?: number;\n }) {\n if (params.sender == null && this.sender === '') {\n throw new Error(\n 'Please specify a sender with useSender or adding a sender paramenter'\n );\n }\n this.steps.push({\n ...params,\n sender: params.sender ?? this.sender,\n fee: params.fee ?? 0,\n });\n return this;\n }\n public addContractDeploy(params: {\n contract_name: string;\n source_code: string;\n deployer?: string;\n fee?: number;\n clarity_version?: ClarityVersion;\n }) {\n if (params.deployer == null && this.sender === '') {\n throw new Error(\n 'Please specify a deployer with useSender or adding a deployer paramenter'\n );\n }\n this.steps.push({\n ...params,\n deployer: params.deployer ?? this.sender,\n fee: params.fee ?? 0,\n clarity_version: params.clarity_version ?? ClarityVersion.Clarity3,\n });\n return this;\n }\n public addEvalCode(inside_contract_id: string, code: string) {\n this.steps.push({\n contract_id: inside_contract_id,\n code,\n });\n return this;\n }\n public addMapRead(contract_id: string, map: string, key: string) {\n this.steps.push({\n contract_id,\n code: `(map-get ${map} ${key})`,\n });\n return this;\n }\n public addVarRead(contract_id: string, variable: string) {\n this.steps.push({\n contract_id,\n code: `(var-get ${variable})`,\n });\n return this;\n }\n\n private async getBlockInfo() {\n if (Number.isNaN(this.block)) {\n const { stacks_tip_height } = await getNodeInfo({\n stacksEndpoint: this.stacksNodeAPI,\n });\n this.block = stacks_tip_height;\n }\n const info: Block = await richFetch(\n `${this.stacksNodeAPI}/extended/v1/block/by_height/${this.block}?unanchored=true`\n ).then((r) => r.json());\n if (\n info.height !== this.block ||\n typeof info.hash !== 'string' ||\n !info.hash.startsWith('0x')\n ) {\n throw new Error(\n `failed to get block info for block height ${this.block}`\n );\n }\n return {\n block_height: this.block,\n block_hash: info.hash.substring(2),\n index_block_hash: info.index_block_hash.substring(2),\n };\n }\n\n public async run() {\n console.log(\n `--------------------------------\nThis product can never exist without your support!\n\nWe receive sponsorship funds with:\nSP212Y5JKN59YP3GYG07K3S8W5SSGE4KH6B5STXER\n\nFeedbacks and feature requests are welcome.\nTo get in touch: contact@stxer.xyz\n--------------------------------`\n );\n const block = await this.getBlockInfo();\n console.log(\n `Using block height ${block.block_height} hash 0x${block.block_hash} to run simulation.`\n );\n const txs: (StacksTransactionWire | SimulationEval)[] = [];\n const nonce_by_address = new Map<string, number>();\n const nextNonce = async (sender: string) => {\n const nonce = nonce_by_address.get(sender);\n if (nonce == null) {\n const url = `${this.stacksNodeAPI\n }/v2/accounts/${sender}?proof=${false}&tip=${block.index_block_hash}`;\n const account: AccountDataResponse = await richFetch(url).then((r) =>\n r.json()\n );\n nonce_by_address.set(sender, account.nonce + 1);\n return account.nonce;\n }\n nonce_by_address.set(sender, nonce + 1);\n return nonce;\n };\n let network = this.network === 'mainnet' ? STACKS_MAINNET : STACKS_TESTNET;\n if (this.stacksNodeAPI) {\n network = {\n ...network,\n client: {\n ...network.client,\n baseUrl: this.stacksNodeAPI,\n },\n };\n }\n for (const step of this.steps) {\n if ('simulationId' in step) {\n const previousSimulation: {steps: ({tx: string} | {code: string, contract: string})[]} = await fetch(`https://api.stxer.xyz/simulations/${step.simulationId}/request`).then(x => x.json())\n for (const step of previousSimulation.steps) {\n if ('tx' in step) {\n txs.push(deserializeTransaction(step.tx));\n } else if ('code' in step && 'contract' in step) {\n txs.push({\n contract_id: step.contract,\n code: step.code,\n });\n }\n }\n } else if ('sender' in step && 'function_name' in step) {\n const nonce = await nextNonce(step.sender);\n const [contractAddress, contractName] = step.contract_id.split('.');\n const tx = await makeUnsignedContractCall({\n contractAddress,\n contractName,\n functionName: step.function_name,\n functionArgs: step.function_args ?? [],\n nonce,\n network,\n publicKey: '',\n postConditionMode: PostConditionMode.Allow,\n fee: step.fee,\n });\n tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];\n txs.push(tx);\n } else if ('sender' in step && 'recipient' in step) {\n const nonce = await nextNonce(step.sender);\n const tx = await makeUnsignedSTXTokenTransfer({\n recipient: step.recipient,\n amount: step.amount,\n nonce,\n network,\n publicKey: '',\n fee: step.fee,\n });\n tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];\n txs.push(tx);\n } else if ('deployer' in step) {\n const nonce = await nextNonce(step.deployer);\n const tx = await makeUnsignedContractDeploy({\n contractName: step.contract_name,\n codeBody: step.source_code,\n nonce,\n network,\n publicKey: '',\n postConditionMode: PostConditionMode.Allow,\n fee: step.fee,\n });\n tx.auth.spendingCondition.signer = c32addressDecode(step.deployer)[1];\n txs.push(tx);\n } else if ('code' in step) {\n txs.push(step);\n } else {\n // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>\n console.log(`Invalid simulation step:`, step);\n }\n }\n const id = await runSimulation(\n `${this.apiEndpoint}/simulations`,\n block.block_hash,\n block.block_height,\n txs\n );\n console.log(\n `Simulation will be available at: https://stxer.xyz/simulations/${this.network}/${id}`\n );\n return id;\n }\n\n public pipe(transform: (builder: SimulationBuilder) => SimulationBuilder): SimulationBuilder {\n return transform(this);\n }\n}\n","import {\n ClarityType,\n type ClarityValue,\n type OptionalCV,\n} from '@stacks/transactions';\nimport type {\n ClarityAbiFunction,\n ClarityAbiMap,\n ClarityAbiVariable,\n TContractPrincipal,\n TPrincipal,\n} from 'clarity-abi';\nimport { decodeAbi, encodeAbi } from 'ts-clarity';\nimport type {\n InferReadonlyCallParameterType,\n InferReadonlyCallResultType,\n InferMapValueType,\n InferReadMapParameterType,\n InferReadVariableParameterType,\n InferVariableType,\n} from 'ts-clarity';\nimport { BatchProcessor } from './BatchProcessor';\n\n// Shared processor instance with default settings\nconst defaultProcessor = new BatchProcessor({\n batchDelayMs: 100,\n});\n\nexport type ReadonlyCallRuntimeOptions = {\n sender?: TPrincipal;\n contract: TContractPrincipal;\n stacksEndpoint?: string;\n indexBlockHash?: string;\n batchProcessor?: BatchProcessor;\n};\n\nexport type ReadMapRuntimeParameters = {\n contract: TContractPrincipal;\n stacksEndpoint?: string;\n proof?: boolean;\n indexBlockHash?: string;\n batchProcessor?: BatchProcessor;\n};\n\nexport type ReadVariableRuntimeParameterType = {\n contract: TContractPrincipal;\n stacksEndpoint?: string;\n proof?: boolean;\n indexBlockHash?: string;\n batchProcessor?: BatchProcessor;\n};\n\nexport async function callReadonly<\n Functions extends readonly ClarityAbiFunction[] | readonly unknown[],\n FunctionName extends string,\n>(\n params: InferReadonlyCallParameterType<Functions, FunctionName> &\n ReadonlyCallRuntimeOptions,\n): Promise<InferReadonlyCallResultType<Functions, FunctionName>> {\n const processor = params.batchProcessor ?? defaultProcessor;\n const [deployer, contractName] = params.contract.split('.', 2);\n const fn = String(params.functionName);\n \n const functionDef = (params.abi as readonly ClarityAbiFunction[]).find(\n (def) => def.name === params.functionName,\n );\n if (!functionDef) {\n throw new Error(`failed to find function definition for ${params.functionName}`);\n }\n \n const argsKV = (params as unknown as { args: Record<string, unknown> }).args;\n const args: ClarityValue[] = [];\n for (const argDef of functionDef.args) {\n args.push(encodeAbi(argDef.type, argsKV[argDef.name]));\n }\n\n return new Promise((resolve, reject) => {\n processor.enqueue({\n request: {\n mode: 'readonly',\n contractAddress: deployer,\n contractName: contractName,\n functionName: fn,\n functionArgs: args,\n },\n tip: params.indexBlockHash,\n resolve: (result: ClarityValue | OptionalCV) => {\n try {\n const decoded = decodeAbi(functionDef.outputs.type, result);\n resolve(decoded as InferReadonlyCallResultType<Functions, FunctionName>);\n } catch (error) {\n reject(error);\n }\n },\n reject,\n });\n });\n}\n\nexport async function readMap<\n Maps extends readonly ClarityAbiMap[] | readonly unknown[] = readonly ClarityAbiMap[],\n MapName extends string = string,\n>(\n params: InferReadMapParameterType<Maps, MapName> & ReadMapRuntimeParameters,\n): Promise<InferMapValueType<Maps, MapName> | null> {\n const processor = params.batchProcessor ?? defaultProcessor;\n const [deployer, contractName] = params.contract.split('.', 2);\n \n const mapDef = (params.abi as readonly ClarityAbiMap[]).find(\n (m) => m.name === params.mapName,\n );\n if (!mapDef) {\n throw new Error(`failed to find map definition for ${params.mapName}`);\n }\n \n const key: ClarityValue = encodeAbi(mapDef.key, params.key);\n\n return new Promise((resolve, reject) => {\n processor.enqueue({\n request: {\n mode: 'mapEntry',\n contractAddress: deployer,\n contractName: contractName,\n mapName: params.mapName,\n mapKey: key,\n },\n tip: params.indexBlockHash,\n resolve: (result: ClarityValue | OptionalCV) => {\n try {\n if (result.type === ClarityType.OptionalNone) {\n resolve(null);\n return;\n }\n if (result.type !== ClarityType.OptionalSome) {\n throw new Error(`unexpected map value: ${result}`);\n }\n const someCV = result as { type: ClarityType.OptionalSome; value: ClarityValue };\n const decoded = decodeAbi(mapDef.value, someCV.value);\n resolve(decoded as InferMapValueType<Maps, MapName>);\n } catch (error) {\n reject(error);\n }\n },\n reject,\n });\n });\n}\n\nexport async function readVariable<\n Variables extends readonly ClarityAbiVariable[] | readonly unknown[] = readonly ClarityAbiVariable[],\n VariableName extends string = string,\n>(\n params: InferReadVariableParameterType<Variables, VariableName> &\n ReadVariableRuntimeParameterType,\n): Promise<InferVariableType<Variables, VariableName>> {\n const processor = params.batchProcessor ?? defaultProcessor;\n const [deployer, contractName] = params.contract.split('.', 2);\n \n const varDef = (params.abi as readonly ClarityAbiVariable[]).find(\n (def) => def.name === params.variableName,\n );\n if (!varDef) {\n throw new Error(`failed to find variable definition for ${params.variableName}`);\n }\n\n return new Promise((resolve, reject) => {\n processor.enqueue({\n request: {\n mode: 'variable',\n contractAddress: deployer,\n contractName: contractName,\n variableName: params.variableName,\n },\n tip: params.indexBlockHash,\n resolve: (result: ClarityValue | OptionalCV) => {\n try {\n const decoded = decodeAbi(varDef.type, result);\n resolve(decoded as InferVariableType<Variables, VariableName>);\n } catch (error) {\n reject(error);\n }\n },\n reject,\n });\n });\n}","/**\n * WARNING:\n *\n * this file will be used in cross-runtime environments (browser, cloudflare workers, XLinkSDK, etc.),\n * so please be careful when adding `import`s to it.\n */\n\nimport {\n type ClarityValue,\n type OptionalCV,\n contractPrincipalCV,\n} from '@stacks/transactions';\nimport { type BatchReads, batchRead } from './BatchAPI';\n\nexport interface ReadOnlyRequest {\n mode: 'readonly';\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n}\n\nexport interface MapEntryRequest {\n mode: 'mapEntry';\n contractAddress: string;\n contractName: string;\n mapName: string;\n mapKey: ClarityValue;\n}\n\nexport interface VariableRequest {\n mode: 'variable';\n contractAddress: string;\n contractName: string;\n variableName: string;\n}\n\nexport type BatchRequest = MapEntryRequest | VariableRequest | ReadOnlyRequest;\n\nexport interface QueuedRequest {\n request: BatchRequest;\n tip?: string;\n resolve: (value: ClarityValue | OptionalCV) => void;\n reject: (error: Error) => void;\n}\n\nexport class BatchProcessor {\n private queues = new Map<string, QueuedRequest[]>();\n private timeoutIds = new Map<string, ReturnType<typeof setTimeout>>();\n\n private readonly stxerAPIEndpoint: string;\n private readonly batchDelayMs: number;\n\n constructor(options: { stxerAPIEndpoint?: string; batchDelayMs: number }) {\n this.stxerAPIEndpoint = options.stxerAPIEndpoint ?? 'https://api.stxer.xyz';\n this.batchDelayMs = options.batchDelayMs;\n }\n\n private getQueueKey(tip?: string): string {\n return tip ?? '_undefined';\n }\n\n enqueue(request: QueuedRequest): void {\n const queueKey = this.getQueueKey(request.tip);\n\n const queue = this.queues.get(queueKey) ?? [];\n if (!this.queues.has(queueKey)) {\n this.queues.set(queueKey, queue);\n }\n queue.push(request);\n\n if (!this.timeoutIds.has(queueKey)) {\n const timeoutId = setTimeout(\n () => this.processBatch(queueKey),\n this.batchDelayMs,\n );\n this.timeoutIds.set(queueKey, timeoutId);\n }\n }\n\n private async processBatch(queueKey: string): Promise<void> {\n const currentQueue = this.queues.get(queueKey) ?? [];\n this.queues.delete(queueKey);\n\n const timeoutId = this.timeoutIds.get(queueKey);\n if (timeoutId) {\n clearTimeout(timeoutId);\n this.timeoutIds.delete(queueKey);\n }\n\n if (currentQueue.length === 0) return;\n\n try {\n const readonlyRequests = currentQueue.filter(\n (q): q is QueuedRequest & { request: ReadOnlyRequest } =>\n q.request.mode === 'readonly',\n );\n const mapRequests = currentQueue.filter(\n (q): q is QueuedRequest & { request: MapEntryRequest } =>\n q.request.mode === 'mapEntry',\n );\n const variableRequests = currentQueue.filter(\n (q): q is QueuedRequest & { request: VariableRequest } =>\n q.request.mode === 'variable',\n );\n\n const tip = queueKey === '_undefined' ? undefined : queueKey;\n\n const batchRequest: BatchReads = {\n readonly: readonlyRequests.map(({ request }) => ({\n contract: contractPrincipalCV(\n request.contractAddress,\n request.contractName,\n ),\n functionName: request.functionName,\n functionArgs: request.functionArgs,\n })),\n maps: mapRequests.map(({ request }) => ({\n contract: contractPrincipalCV(\n request.contractAddress,\n request.contractName,\n ),\n mapName: request.mapName,\n mapKey: request.mapKey,\n })),\n variables: variableRequests.map(({ request }) => ({\n contract: contractPrincipalCV(\n request.contractAddress,\n request.contractName,\n ),\n variableName: request.variableName,\n })),\n index_block_hash: tip,\n };\n\n const results = await batchRead(batchRequest, {\n stxerApi: this.stxerAPIEndpoint,\n });\n\n // Handle readonly results\n for (const [index, result] of results.readonly.entries()) {\n if (result instanceof Error) {\n readonlyRequests[index].reject(result);\n } else {\n readonlyRequests[index].resolve(result);\n }\n }\n\n // Handle variable results\n for (const [index, result] of results.vars.entries()) {\n if (result instanceof Error) {\n variableRequests[index].reject(result);\n } else {\n variableRequests[index].resolve(result);\n }\n }\n\n // Handle map results\n for (const [index, result] of results.maps.entries()) {\n if (result instanceof Error) {\n mapRequests[index].reject(result);\n } else {\n mapRequests[index].resolve(result);\n }\n }\n } catch (error) {\n for (const item of currentQueue) {\n item.reject(error as Error);\n }\n }\n }\n} "],"names":["convertResults","rs","_step","results","_iterator","_createForOfIteratorHelperLoose","done","v","value","push","deserializeCV","Ok","Error","Err","batchRead","_x","_x2","_batchRead","apply","this","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","reads","options","ibh","index_block_hash","undefined","startsWith","substring","payload","vars","maps","readonly","tip","variables","_iterator2","_step2","serializeCV","variable","contract","variableName","_iterator3","_step3","map","mapName","mapKey","_iterator4","_step4","ro","functionName","concat","functionArgs","url","_options$stxerApi","stxerApi","_context","next","fetch","method","body","JSON","stringify","headers","data","sent","text","includes","parse","abrupt","stop","runTx","tx","tupleCV","type","uintCV","bufferCV","serializeBytes","runEval","_ref","code","_contract_id$split","contract_id","split","contract_address","contract_name","serializeCVBytes","contractPrincipalCV","stringAsciiCV","runSimulation","_x3","_x4","_runSimulation","_callee5","apiEndpoint","block_hash","block_height","txs","header","heightBytes","hashHex","matches","hashBytes","txBytes","totalLength","offset","wrap","_context5","prev","TextEncoder","encode","Uint8Array","DataView","buffer","setBigUint64","BigInt","match","byte","Number","parseInt","t","length","reduce","acc","curr","set","then","_ref3","_callee4","response","_context4","_x6","id","SimulationBuilder","_options$apiEndpoint","_options$stacksNodeAP","_options$network","stacksNodeAPI","network","block","NaN","sender","steps","_proto","prototype","useBlockHeight","withSender","address","inlineSimulation","simulationId","addSTXTransfer","params","_params$sender","_params$fee","_extends","fee","addContractCall","_params$sender2","_params$fee2","addContractDeploy","_params$deployer","_params$fee3","_params$clarity_versi","deployer","clarity_version","ClarityVersion","Clarity3","addEvalCode","inside_contract_id","addMapRead","key","addVarRead","getBlockInfo","_getBlockInfo","info","isNaN","getNodeInfo","stacksEndpoint","stacks_tip_height","richFetch","r","json","height","hash","run","_run","_callee3","nonce_by_address","nextNonce","step","_step$function_args","nonce","_step$contract_id$spl","contractAddress","contractName","_nonce","_tx","_nonce2","_tx2","_this","_context3","console","log","Map","_ref2","_callee2","account","_context2","get","_x5","STACKS_MAINNET","STACKS_TESTNET","client","baseUrl","x","deserializeTransaction","makeUnsignedContractCall","function_name","function_args","publicKey","postConditionMode","PostConditionMode","Allow","auth","spendingCondition","signer","c32addressDecode","makeUnsignedSTXTokenTransfer","recipient","amount","makeUnsignedContractDeploy","codeBody","source_code","pipe","transform","defaultProcessor","BatchProcessor","_options$stxerAPIEndp","queues","timeoutIds","stxerAPIEndpoint","batchDelayMs","getQueueKey","enqueue","request","_this$queues$get","queueKey","queue","has","timeoutId","setTimeout","processBatch","_processBatch","_this$queues$get2","currentQueue","readonlyRequests","mapRequests","variableRequests","batchRequest","_step$value","index","result","_step2$value","_index","_result","_step3$value","_index2","_result2","clearTimeout","filter","q","mode","entries","reject","resolve","t0","_callReadonly","_params$batchProcesso","processor","_params$contract$spli","fn","functionDef","argsKV","args","argDef","batchProcessor","String","abi","find","def","name","encodeAbi","Promise","indexBlockHash","decoded","decodeAbi","outputs","error","_readMap","_params$batchProcesso2","_params$contract$spli2","mapDef","m","ClarityType","OptionalNone","OptionalSome","_readVariable","_params$batchProcesso3","_params$contract$spli3","varDef","callReadonly","readMap","readVariable"],"mappings":"i1PA6CA,SAASA,EACPC,GAGA,IADA,IACkBC,EADZC,EAAoC,GAC1CC,EAAAC,EAAgBJ,KAAEC,EAAAE,KAAAE,MAAE,CAAA,IAATC,EAACL,EAAAM,MAERL,EAAQM,KADN,OAAQF,EACGG,EAAAA,cAAcH,EAAEI,IAEhB,IAAIC,MAAML,EAAEM,KAE7B,CACA,OAAOV,CACT,CAEA,SAAsBW,EAASC,EAAAC,GAAA,OAAAC,EAAAC,MAAAC,KAAAC,UAAA,CA2E9B,SAAAH,IAAA,OAAAA,EAAAI,EAAAC,IAAAC,MA3EM,SAAAC,EACLC,EACAC,wGAgBA,YAhBAA,IAAAA,EAA2B,CAAA,GAErBC,EACsB,MAA1BF,EAAMG,sBACFC,EACAJ,EAAMG,iBAAiBE,WAAW,MAChCL,EAAMG,iBAAiBG,UAAU,GACjCN,EAAMG,iBAERI,EAKF,CAAEC,KAAM,GAAIC,KAAM,GAAIC,SAAU,GAAIC,IAAKT,GAEtB,MAAnBF,EAAMY,UACR,IAAAC,EAAAjC,EAAuBoB,EAAMY,aAASE,EAAAD,KAAAhC,MACpC0B,EAAQC,KAAKxB,KAAK,CAAC+B,EAAWA,aADrBC,EAAQF,EAAA/B,OACuBkC,UAAWD,EAASE,eAIhE,GAAkB,MAAdlB,EAAMS,KACR,IAAAU,EAAAvC,EAAkBoB,EAAMS,QAAIW,EAAAD,KAAAtC,MAC1B0B,EAAQE,KAAKzB,KAAK,CAChB+B,EAAWA,aAFJM,EAAGD,EAAArC,OAEMkC,UAChBI,EAAIC,QACJP,EAAWA,YAACM,EAAIE,UAKtB,GAAsB,MAAlBvB,EAAMU,SACR,IAAAc,EAAA5C,EAAiBoB,EAAMU,YAAQe,EAAAD,KAAA3C,MAC7B0B,EAAQG,SAAS1B,KAAI,CACn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,cAAAA,EAAA5F,KAAA4F,EAAA/I,MAAA,KAAA,EAOjC,GALK6N,EAAiC,OAAxB6B,EAAG5J,EAAOsI,gBAAcsB,EAAIxE,EAAgByE,EAC1B7J,EAAO/G,SAAS2C,MAAM,IAAK,GAArDgF,EAAQiJ,EAAElH,GAAAA,EAAYkH,EAAA,GAEvBC,EAAU9J,EAAOwI,IAAsCC,MAC3D,SAACC,GAAG,OAAKA,EAAIC,OAAS3I,EAAO9G,gBAEpB,CAAA+J,EAAA/I,KAAA,EAAA,KAAA,CAAA,MACH,IAAI/C,MAAK,0CAA2C6I,EAAO9G,cAAe,KAAA,EAAA,OAAA+J,EAAAnI,OAG3E,SAAA,IAAI+N,SAAQ,SAAClB,EAASD,GAC3BK,EAAUnC,QAAQ,CAChBC,QAAS,CACP2B,KAAM,WACN9E,gBAAiB9B,EACjB+B,aAAcA,EACdzJ,aAAc8G,EAAO9G,cAEvBP,IAAKqH,EAAO8I,eACZnB,QAAS,SAACb,GACR,IACE,IAAMiC,EAAUC,EAASA,UAACc,EAAO3O,KAAM2L,GACvCa,EAAQoB,EACT,CAAC,MAAOG,GACPxB,EAAOwB,EACT,CACD,EACDxB,OAAAA,GAEH,KAAC,KAAA,EAAA,IAAA,MAAA,OAAAzE,EAAAlI,OAAA,GAAAoH,EACH,MAAA1K,MAAAC,KAAAC,UAAA,sEArIqBoS,SAAYzS,GAAA,OAAAuQ,EAAApQ,MAAAC,KAAAC,UAAA,kBA+CZqS,SAAOzS,GAAA,OAAA4R,EAAA1R,MAAAC,KAAAC,UAAA,uBAiDPsS,SAAY9N,GAAA,OAAAwN,EAAAlS,MAAAC,KAAAC,UAAA"}
1
+ {"version":3,"file":"stxer.cjs.production.min.js","sources":["../src/BatchAPI.ts","../src/simulation.ts","../src/clarity-api.ts","../src/BatchProcessor.ts"],"sourcesContent":["/**\n * WARNING:\n *\n * this file will be used in cross-runtime environments (browser, cloudflare workers, XLinkSDK, etc.),\n * so please be careful when adding `import`s to it.\n */\n\nimport {\n type ClarityValue,\n type ContractPrincipalCV,\n deserializeCV,\n serializeCV,\n} from '@stacks/transactions';\n\nexport interface BatchReads {\n variables?: {\n contract: ContractPrincipalCV;\n variableName: string;\n }[];\n maps?: {\n contract: ContractPrincipalCV;\n mapName: string;\n mapKey: ClarityValue;\n }[];\n readonly?: {\n contract: ContractPrincipalCV;\n functionName: string;\n functionArgs: ClarityValue[];\n }[];\n index_block_hash?: string;\n}\n\nexport interface BatchReadsResult {\n tip: string;\n vars: (ClarityValue | Error)[];\n maps: (ClarityValue | Error)[];\n readonly: (ClarityValue | Error)[];\n}\n\nexport interface BatchApiOptions {\n stxerApi?: string;\n}\n\nconst DEFAULT_STXER_API = 'https://api.stxer.xyz';\n\nfunction convertResults(\n rs: ({ Ok: string } | { Err: string })[],\n): (ClarityValue | Error)[] {\n const results: (ClarityValue | Error)[] = [];\n for (const v of rs) {\n if ('Ok' in v) {\n results.push(deserializeCV(v.Ok));\n } else {\n results.push(new Error(v.Err));\n }\n }\n return results;\n}\n\nexport async function batchRead(\n reads: BatchReads,\n options: BatchApiOptions = {}\n): Promise<BatchReadsResult> {\n const ibh =\n reads.index_block_hash == null\n ? undefined\n : reads.index_block_hash.startsWith('0x')\n ? reads.index_block_hash.substring(2)\n : reads.index_block_hash;\n\n const payload: {\n tip?: string;\n vars: string[][];\n maps: string[][];\n readonly: string[][];\n } = { vars: [], maps: [], readonly: [], tip: ibh };\n\n if (reads.variables != null) {\n for (const variable of reads.variables) {\n payload.vars.push([serializeCV(variable.contract), variable.variableName]);\n }\n }\n\n if (reads.maps != null) {\n for (const map of reads.maps) {\n payload.maps.push([\n serializeCV(map.contract),\n map.mapName,\n serializeCV(map.mapKey),\n ]);\n }\n }\n\n if (reads.readonly != null) {\n for (const ro of reads.readonly) {\n payload.readonly.push([\n serializeCV(ro.contract),\n ro.functionName,\n ...ro.functionArgs.map(v => serializeCV(v)),\n ]);\n }\n }\n\n const url = `${options.stxerApi ?? DEFAULT_STXER_API}/sidecar/v2/batch`;\n const data = await fetch(url, {\n method: 'POST',\n body: JSON.stringify(payload),\n headers: {\n 'Content-Type': 'application/json',\n },\n });\n\n const text = await data.text();\n if (!text.includes('Ok') && !text.includes('Err')) {\n throw new Error(\n `Requesting batch reads failed: ${text}, url: ${url}, payload: ${JSON.stringify(\n payload,\n )}`,\n );\n }\n\n const rs = JSON.parse(text) as {\n tip: string;\n vars: ({ Ok: string } | { Err: string })[];\n maps: ({ Ok: string } | { Err: string })[];\n readonly: ({ Ok: string } | { Err: string })[];\n };\n\n return {\n tip: rs.tip,\n vars: convertResults(rs.vars),\n maps: convertResults(rs.maps),\n readonly: convertResults(rs.readonly),\n };\n}","import { type AccountDataResponse, getNodeInfo, richFetch } from 'ts-clarity';\nimport type { Block } from '@stacks/stacks-blockchain-api-types';\nimport {\n STACKS_MAINNET,\n STACKS_TESTNET,\n type StacksNetworkName,\n} from '@stacks/network';\nimport {\n type ClarityValue,\n ClarityVersion,\n PostConditionMode,\n type StacksTransactionWire,\n bufferCV,\n contractPrincipalCV,\n deserializeTransaction,\n makeUnsignedContractCall,\n makeUnsignedContractDeploy,\n makeUnsignedSTXTokenTransfer,\n serializeCVBytes,\n stringAsciiCV,\n tupleCV,\n uintCV,\n} from '@stacks/transactions';\nimport { c32addressDecode } from 'c32check';\n\nfunction runTx(tx: StacksTransactionWire) {\n // type 0: run transaction\n return tupleCV({ type: uintCV(0), data: bufferCV(tx.serializeBytes()) });\n}\n\nexport interface SimulationEval {\n contract_id: string;\n code: string;\n}\n\nexport function runEval({ contract_id, code }: SimulationEval) {\n const [contract_address, contract_name] = contract_id.split('.');\n // type 1: eval arbitrary code inside a contract\n return tupleCV({\n type: uintCV(1),\n data: bufferCV(\n serializeCVBytes(\n tupleCV({\n contract: contractPrincipalCV(contract_address, contract_name),\n code: stringAsciiCV(code),\n })\n )\n ),\n });\n}\n\nexport async function runSimulation(\n apiEndpoint: string,\n block_hash: string,\n block_height: number,\n txs: (StacksTransactionWire | SimulationEval)[]\n) {\n // Convert 'sim-v1' to Uint8Array\n const header = new TextEncoder().encode('sim-v1');\n // Create 8 bytes for block height\n const heightBytes = new Uint8Array(8);\n // Convert block height to bytes\n const view = new DataView(heightBytes.buffer);\n view.setBigUint64(0, BigInt(block_height), false); // false for big-endian\n\n // Convert block hash to bytes\n const hashHex = block_hash.startsWith('0x')\n ? block_hash.substring(2)\n : block_hash;\n // Replace non-null assertion with null check\n const matches = hashHex.match(/.{1,2}/g);\n if (!matches) {\n throw new Error('Invalid block hash format');\n }\n const hashBytes = new Uint8Array(\n matches.map((byte) => Number.parseInt(byte, 16))\n );\n\n // Convert transactions to bytes\n const txBytes = txs\n .map((t) => ('contract_id' in t && 'code' in t ? runEval(t) : runTx(t)))\n .map((t) => serializeCVBytes(t));\n\n // Combine all byte arrays\n const totalLength =\n header.length +\n heightBytes.length +\n hashBytes.length +\n txBytes.reduce((acc, curr) => acc + curr.length, 0);\n const body = new Uint8Array(totalLength);\n\n let offset = 0;\n body.set(header, offset);\n offset += header.length;\n body.set(heightBytes, offset);\n offset += heightBytes.length;\n body.set(hashBytes, offset);\n offset += hashBytes.length;\n for (const tx of txBytes) {\n body.set(tx, offset);\n offset += tx.length;\n }\n\n const rs = await fetch(apiEndpoint, {\n method: 'POST',\n body,\n }).then(async (rs) => {\n const response = await rs.text();\n if (!response.startsWith('{')) {\n throw new Error(`failed to submit simulation: ${response}`);\n }\n return JSON.parse(response) as { id: string };\n });\n return rs.id;\n}\n\ninterface SimulationBuilderOptions {\n apiEndpoint?: string;\n stacksNodeAPI?: string;\n network?: StacksNetworkName | string;\n}\n\nexport class SimulationBuilder {\n private apiEndpoint: string;\n private stacksNodeAPI: string;\n private network: StacksNetworkName | string;\n\n private constructor(options: SimulationBuilderOptions = {}) {\n this.apiEndpoint = options.apiEndpoint ?? 'https://api.stxer.xyz';\n this.stacksNodeAPI = options.stacksNodeAPI ?? 'https://api.hiro.so';\n this.network = options.network ?? 'mainnet';\n }\n\n public static new(options?: SimulationBuilderOptions) {\n return new SimulationBuilder(options);\n }\n\n // biome-ignore lint/style/useNumberNamespace: <explanation>\n private block = NaN;\n private sender = '';\n private steps: (\n | {\n // inline simulation\n simulationId: string;\n }\n | {\n // contract call\n contract_id: string;\n function_name: string;\n function_args?: ClarityValue[];\n sender: string;\n fee: number;\n }\n | {\n // contract deploy\n contract_name: string;\n source_code: string;\n deployer: string;\n fee: number;\n clarity_version: ClarityVersion;\n }\n | {\n // STX transfer\n recipient: string;\n amount: number;\n sender: string;\n fee: number;\n }\n | SimulationEval\n )[] = [];\n\n public useBlockHeight(block: number) {\n this.block = block;\n return this;\n }\n public withSender(address: string) {\n this.sender = address;\n return this;\n }\n public inlineSimulation(simulationId: string) {\n this.steps.push({\n simulationId,\n })\n return this;\n }\n public addSTXTransfer(params: {\n recipient: string;\n amount: number;\n sender?: string;\n fee?: number;\n }) {\n if (params.sender == null && this.sender === '') {\n throw new Error(\n 'Please specify a sender with useSender or adding a sender paramenter'\n );\n }\n this.steps.push({\n ...params,\n sender: params.sender ?? this.sender,\n fee: params.fee ?? 0,\n });\n return this;\n }\n public addContractCall(params: {\n contract_id: string;\n function_name: string;\n function_args?: ClarityValue[];\n sender?: string;\n fee?: number;\n }) {\n if (params.sender == null && this.sender === '') {\n throw new Error(\n 'Please specify a sender with useSender or adding a sender paramenter'\n );\n }\n this.steps.push({\n ...params,\n sender: params.sender ?? this.sender,\n fee: params.fee ?? 0,\n });\n return this;\n }\n public addContractDeploy(params: {\n contract_name: string;\n source_code: string;\n deployer?: string;\n fee?: number;\n clarity_version?: ClarityVersion;\n }) {\n if (params.deployer == null && this.sender === '') {\n throw new Error(\n 'Please specify a deployer with useSender or adding a deployer paramenter'\n );\n }\n this.steps.push({\n ...params,\n deployer: params.deployer ?? this.sender,\n fee: params.fee ?? 0,\n clarity_version: params.clarity_version ?? ClarityVersion.Clarity3,\n });\n return this;\n }\n public addEvalCode(inside_contract_id: string, code: string) {\n this.steps.push({\n contract_id: inside_contract_id,\n code,\n });\n return this;\n }\n public addMapRead(contract_id: string, map: string, key: string) {\n this.steps.push({\n contract_id,\n code: `(map-get ${map} ${key})`,\n });\n return this;\n }\n public addVarRead(contract_id: string, variable: string) {\n this.steps.push({\n contract_id,\n code: `(var-get ${variable})`,\n });\n return this;\n }\n\n private async getBlockInfo() {\n if (Number.isNaN(this.block)) {\n const { stacks_tip_height } = await getNodeInfo({\n stacksEndpoint: this.stacksNodeAPI,\n });\n this.block = stacks_tip_height;\n }\n const info: Block = await richFetch(\n `${this.stacksNodeAPI}/extended/v1/block/by_height/${this.block}?unanchored=true`\n ).then((r) => r.json());\n if (\n info.height !== this.block ||\n typeof info.hash !== 'string' ||\n !info.hash.startsWith('0x')\n ) {\n throw new Error(\n `failed to get block info for block height ${this.block}`\n );\n }\n return {\n block_height: this.block,\n block_hash: info.hash.substring(2),\n index_block_hash: info.index_block_hash.substring(2),\n };\n }\n\n public async run() {\n console.log(\n `--------------------------------\nThis product can never exist without your support!\n\nWe receive sponsorship funds with:\nSP212Y5JKN59YP3GYG07K3S8W5SSGE4KH6B5STXER\n\nFeedbacks and feature requests are welcome.\nTo get in touch: contact@stxer.xyz\n--------------------------------`\n );\n const block = await this.getBlockInfo();\n console.log(\n `Using block height ${block.block_height} hash 0x${block.block_hash} to run simulation.`\n );\n const txs: (StacksTransactionWire | SimulationEval)[] = [];\n const nonce_by_address = new Map<string, number>();\n const nextNonce = async (sender: string) => {\n const nonce = nonce_by_address.get(sender);\n if (nonce == null) {\n const url = `${this.stacksNodeAPI\n }/v2/accounts/${sender}?proof=${false}&tip=${block.index_block_hash}`;\n const account: AccountDataResponse = await richFetch(url).then((r) =>\n r.json()\n );\n nonce_by_address.set(sender, account.nonce + 1);\n return account.nonce;\n }\n nonce_by_address.set(sender, nonce + 1);\n return nonce;\n };\n let network = this.network === 'mainnet' ? STACKS_MAINNET : STACKS_TESTNET;\n if (this.stacksNodeAPI) {\n network = {\n ...network,\n client: {\n ...network.client,\n baseUrl: this.stacksNodeAPI,\n },\n };\n }\n for (const step of this.steps) {\n if ('simulationId' in step) {\n const previousSimulation: {steps: ({tx: string} | {code: string, contract: string})[]} = await fetch(`https://api.stxer.xyz/simulations/${step.simulationId}/request`).then(x => x.json())\n for (const step of previousSimulation.steps) {\n if ('tx' in step) {\n txs.push(deserializeTransaction(step.tx));\n } else if ('code' in step && 'contract' in step) {\n txs.push({\n contract_id: step.contract,\n code: step.code,\n });\n }\n }\n } else if ('sender' in step && 'function_name' in step) {\n const nonce = await nextNonce(step.sender);\n const [contractAddress, contractName] = step.contract_id.split('.');\n const tx = await makeUnsignedContractCall({\n contractAddress,\n contractName,\n functionName: step.function_name,\n functionArgs: step.function_args ?? [],\n nonce,\n network,\n publicKey: '',\n postConditionMode: PostConditionMode.Allow,\n fee: step.fee,\n });\n tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];\n txs.push(tx);\n } else if ('sender' in step && 'recipient' in step) {\n const nonce = await nextNonce(step.sender);\n const tx = await makeUnsignedSTXTokenTransfer({\n recipient: step.recipient,\n amount: step.amount,\n nonce,\n network,\n publicKey: '',\n fee: step.fee,\n });\n tx.auth.spendingCondition.signer = c32addressDecode(step.sender)[1];\n txs.push(tx);\n } else if ('deployer' in step) {\n const nonce = await nextNonce(step.deployer);\n const tx = await makeUnsignedContractDeploy({\n contractName: step.contract_name,\n codeBody: step.source_code,\n nonce,\n network,\n publicKey: '',\n postConditionMode: PostConditionMode.Allow,\n fee: step.fee,\n });\n tx.auth.spendingCondition.signer = c32addressDecode(step.deployer)[1];\n txs.push(tx);\n } else if ('code' in step) {\n txs.push(step);\n } else {\n // biome-ignore lint/style/noUnusedTemplateLiteral: <explanation>\n console.log(`Invalid simulation step:`, step);\n }\n }\n const id = await runSimulation(\n `${this.apiEndpoint}/simulations`,\n block.block_hash,\n block.block_height,\n txs\n );\n console.log(\n `Simulation will be available at: https://stxer.xyz/simulations/${this.network}/${id}`\n );\n return id;\n }\n\n public pipe(transform: (builder: SimulationBuilder) => SimulationBuilder): SimulationBuilder {\n return transform(this);\n }\n}\n","import {\n ClarityType,\n type ClarityValue,\n type OptionalCV,\n} from '@stacks/transactions';\nimport type {\n ClarityAbiFunction,\n ClarityAbiMap,\n ClarityAbiVariable,\n TContractPrincipal,\n TPrincipal,\n} from 'clarity-abi';\nimport { decodeAbi, encodeAbi } from 'ts-clarity';\nimport type {\n InferReadonlyCallParameterType,\n InferReadonlyCallResultType,\n InferMapValueType,\n InferReadMapParameterType,\n InferReadVariableParameterType,\n InferVariableType,\n} from 'ts-clarity';\nimport { BatchProcessor } from './BatchProcessor';\n\n// Shared processor instance with default settings\nconst defaultProcessor = new BatchProcessor({\n batchDelayMs: 100,\n});\n\nexport type ReadonlyCallRuntimeOptions = {\n sender?: TPrincipal;\n contract: TContractPrincipal;\n stacksEndpoint?: string;\n indexBlockHash?: string;\n batchProcessor?: BatchProcessor;\n};\n\nexport type ReadMapRuntimeParameters = {\n contract: TContractPrincipal;\n stacksEndpoint?: string;\n proof?: boolean;\n indexBlockHash?: string;\n batchProcessor?: BatchProcessor;\n};\n\nexport type ReadVariableRuntimeParameterType = {\n contract: TContractPrincipal;\n stacksEndpoint?: string;\n proof?: boolean;\n indexBlockHash?: string;\n batchProcessor?: BatchProcessor;\n};\n\nexport async function callReadonly<\n Functions extends readonly ClarityAbiFunction[] | readonly unknown[],\n FunctionName extends string,\n>(\n params: InferReadonlyCallParameterType<Functions, FunctionName> &\n ReadonlyCallRuntimeOptions,\n): Promise<InferReadonlyCallResultType<Functions, FunctionName>> {\n const processor = params.batchProcessor ?? defaultProcessor;\n const [deployer, contractName] = params.contract.split('.', 2);\n const fn = String(params.functionName);\n \n const functionDef = (params.abi as readonly ClarityAbiFunction[]).find(\n (def) => def.name === params.functionName,\n );\n if (!functionDef) {\n throw new Error(`failed to find function definition for ${params.functionName}`);\n }\n \n const argsKV = (params as unknown as { args: Record<string, unknown> }).args;\n const args: ClarityValue[] = [];\n for (const argDef of functionDef.args) {\n args.push(encodeAbi(argDef.type, argsKV[argDef.name]));\n }\n\n return new Promise((resolve, reject) => {\n processor.enqueue({\n request: {\n mode: 'readonly',\n contractAddress: deployer,\n contractName: contractName,\n functionName: fn,\n functionArgs: args,\n },\n tip: params.indexBlockHash,\n resolve: (result: ClarityValue | OptionalCV) => {\n try {\n const decoded = decodeAbi(functionDef.outputs.type, result);\n resolve(decoded as InferReadonlyCallResultType<Functions, FunctionName>);\n } catch (error) {\n reject(error);\n }\n },\n reject,\n });\n });\n}\n\nexport async function readMap<\n Maps extends readonly ClarityAbiMap[] | readonly unknown[] = readonly ClarityAbiMap[],\n MapName extends string = string,\n>(\n params: InferReadMapParameterType<Maps, MapName> & ReadMapRuntimeParameters,\n): Promise<InferMapValueType<Maps, MapName> | null> {\n const processor = params.batchProcessor ?? defaultProcessor;\n const [deployer, contractName] = params.contract.split('.', 2);\n \n const mapDef = (params.abi as readonly ClarityAbiMap[]).find(\n (m) => m.name === params.mapName,\n );\n if (!mapDef) {\n throw new Error(`failed to find map definition for ${params.mapName}`);\n }\n \n const key: ClarityValue = encodeAbi(mapDef.key, params.key);\n\n return new Promise((resolve, reject) => {\n processor.enqueue({\n request: {\n mode: 'mapEntry',\n contractAddress: deployer,\n contractName: contractName,\n mapName: params.mapName,\n mapKey: key,\n },\n tip: params.indexBlockHash,\n resolve: (result: ClarityValue | OptionalCV) => {\n try {\n if (result.type === ClarityType.OptionalNone) {\n resolve(null);\n return;\n }\n if (result.type !== ClarityType.OptionalSome) {\n throw new Error(`unexpected map value: ${result}`);\n }\n const someCV = result as { type: ClarityType.OptionalSome; value: ClarityValue };\n const decoded = decodeAbi(mapDef.value, someCV.value);\n resolve(decoded as InferMapValueType<Maps, MapName>);\n } catch (error) {\n reject(error);\n }\n },\n reject,\n });\n });\n}\n\nexport async function readVariable<\n Variables extends readonly ClarityAbiVariable[] | readonly unknown[] = readonly ClarityAbiVariable[],\n VariableName extends string = string,\n>(\n params: InferReadVariableParameterType<Variables, VariableName> &\n ReadVariableRuntimeParameterType,\n): Promise<InferVariableType<Variables, VariableName>> {\n const processor = params.batchProcessor ?? defaultProcessor;\n const [deployer, contractName] = params.contract.split('.', 2);\n \n const varDef = (params.abi as readonly ClarityAbiVariable[]).find(\n (def) => def.name === params.variableName,\n );\n if (!varDef) {\n throw new Error(`failed to find variable definition for ${params.variableName}`);\n }\n\n return new Promise((resolve, reject) => {\n processor.enqueue({\n request: {\n mode: 'variable',\n contractAddress: deployer,\n contractName: contractName,\n variableName: params.variableName,\n },\n tip: params.indexBlockHash,\n resolve: (result: ClarityValue | OptionalCV) => {\n try {\n const decoded = decodeAbi(varDef.type, result);\n resolve(decoded as InferVariableType<Variables, VariableName>);\n } catch (error) {\n reject(error);\n }\n },\n reject,\n });\n });\n}","/**\n * WARNING:\n *\n * this file will be used in cross-runtime environments (browser, cloudflare workers, XLinkSDK, etc.),\n * so please be careful when adding `import`s to it.\n */\n\nimport {\n type ClarityValue,\n type OptionalCV,\n contractPrincipalCV,\n} from '@stacks/transactions';\nimport { type BatchReads, batchRead } from './BatchAPI';\n\nexport interface ReadOnlyRequest {\n mode: 'readonly';\n contractAddress: string;\n contractName: string;\n functionName: string;\n functionArgs: ClarityValue[];\n}\n\nexport interface MapEntryRequest {\n mode: 'mapEntry';\n contractAddress: string;\n contractName: string;\n mapName: string;\n mapKey: ClarityValue;\n}\n\nexport interface VariableRequest {\n mode: 'variable';\n contractAddress: string;\n contractName: string;\n variableName: string;\n}\n\nexport type BatchRequest = MapEntryRequest | VariableRequest | ReadOnlyRequest;\n\nexport interface QueuedRequest {\n request: BatchRequest;\n tip?: string;\n resolve: (value: ClarityValue | OptionalCV) => void;\n reject: (error: Error) => void;\n}\n\nexport class BatchProcessor {\n private queues = new Map<string, QueuedRequest[]>();\n private timeoutIds = new Map<string, ReturnType<typeof setTimeout>>();\n\n private readonly stxerAPIEndpoint: string;\n private readonly batchDelayMs: number;\n\n constructor(options: { stxerAPIEndpoint?: string; batchDelayMs: number }) {\n this.stxerAPIEndpoint = options.stxerAPIEndpoint ?? 'https://api.stxer.xyz';\n this.batchDelayMs = options.batchDelayMs;\n }\n\n private getQueueKey(tip?: string): string {\n return tip ?? '_undefined';\n }\n\n read(request: BatchRequest): Promise<ClarityValue | OptionalCV> {\n return new Promise((resolve, reject) => {\n this.enqueue({ request, resolve, reject });\n });\n }\n\n enqueue(request: QueuedRequest): void {\n const queueKey = this.getQueueKey(request.tip);\n\n const queue = this.queues.get(queueKey) ?? [];\n if (!this.queues.has(queueKey)) {\n this.queues.set(queueKey, queue);\n }\n queue.push(request);\n\n if (!this.timeoutIds.has(queueKey)) {\n const timeoutId = setTimeout(\n () => this.processBatch(queueKey),\n this.batchDelayMs,\n );\n this.timeoutIds.set(queueKey, timeoutId);\n }\n }\n\n private async processBatch(queueKey: string): Promise<void> {\n const currentQueue = this.queues.get(queueKey) ?? [];\n this.queues.delete(queueKey);\n\n const timeoutId = this.timeoutIds.get(queueKey);\n if (timeoutId) {\n clearTimeout(timeoutId);\n this.timeoutIds.delete(queueKey);\n }\n\n if (currentQueue.length === 0) return;\n\n try {\n const readonlyRequests = currentQueue.filter(\n (q): q is QueuedRequest & { request: ReadOnlyRequest } =>\n q.request.mode === 'readonly',\n );\n const mapRequests = currentQueue.filter(\n (q): q is QueuedRequest & { request: MapEntryRequest } =>\n q.request.mode === 'mapEntry',\n );\n const variableRequests = currentQueue.filter(\n (q): q is QueuedRequest & { request: VariableRequest } =>\n q.request.mode === 'variable',\n );\n\n const tip = queueKey === '_undefined' ? undefined : queueKey;\n\n const batchRequest: BatchReads = {\n readonly: readonlyRequests.map(({ request }) => ({\n contract: contractPrincipalCV(\n request.contractAddress,\n request.contractName,\n ),\n functionName: request.functionName,\n functionArgs: request.functionArgs,\n })),\n maps: mapRequests.map(({ request }) => ({\n contract: contractPrincipalCV(\n request.contractAddress,\n request.contractName,\n ),\n mapName: request.mapName,\n mapKey: request.mapKey,\n })),\n variables: variableRequests.map(({ request }) => ({\n contract: contractPrincipalCV(\n request.contractAddress,\n request.contractName,\n ),\n variableName: request.variableName,\n })),\n index_block_hash: tip,\n };\n\n const results = await batchRead(batchRequest, {\n stxerApi: this.stxerAPIEndpoint,\n });\n\n // Handle readonly results\n for (const [index, result] of results.readonly.entries()) {\n if (result instanceof Error) {\n readonlyRequests[index].reject(result);\n } else {\n readonlyRequests[index].resolve(result);\n }\n }\n\n // Handle variable results\n for (const [index, result] of results.vars.entries()) {\n if (result instanceof Error) {\n variableRequests[index].reject(result);\n } else {\n variableRequests[index].resolve(result);\n }\n }\n\n // Handle map results\n for (const [index, result] of results.maps.entries()) {\n if (result instanceof Error) {\n mapRequests[index].reject(result);\n } else {\n mapRequests[index].resolve(result);\n }\n }\n } catch (error) {\n for (const item of currentQueue) {\n item.reject(error as Error);\n }\n }\n }\n} "],"names":["convertResults","rs","_step","results","_iterator","_createForOfIteratorHelperLoose","done","v","value","push","deserializeCV","Ok","Error","Err","batchRead","_x","_x2","_batchRead","apply","this","arguments","_asyncToGenerator","_regeneratorRuntime","mark","_callee","reads","options","ibh","index_block_hash","undefined","startsWith","substring","payload","vars","maps","readonly","tip","variables","_iterator2","_step2","serializeCV","variable","contract","variableName","_iterator3","_step3","map","mapName","mapKey","_iterator4","_step4","ro","functionName","concat","functionArgs","url","_options$stxerApi","stxerApi","_context","next","fetch","method","body","JSON","stringify","headers","data","sent","text","includes","parse","abrupt","stop","runTx","tx","tupleCV","type","uintCV","bufferCV","serializeBytes","runEval","_ref","code","_contract_id$split","contract_id","split","contract_address","contract_name","serializeCVBytes","contractPrincipalCV","stringAsciiCV","runSimulation","_x3","_x4","_runSimulation","_callee5","apiEndpoint","block_hash","block_height","txs","header","heightBytes","hashHex","matches","hashBytes","txBytes","totalLength","offset","wrap","_context5","prev","TextEncoder","encode","Uint8Array","DataView","buffer","setBigUint64","BigInt","match","byte","Number","parseInt","t","length","reduce","acc","curr","set","then","_ref3","_callee4","response","_context4","_x6","id","SimulationBuilder","_options$apiEndpoint","_options$stacksNodeAP","_options$network","stacksNodeAPI","network","block","NaN","sender","steps","_proto","prototype","useBlockHeight","withSender","address","inlineSimulation","simulationId","addSTXTransfer","params","_params$sender","_params$fee","_extends","fee","addContractCall","_params$sender2","_params$fee2","addContractDeploy","_params$deployer","_params$fee3","_params$clarity_versi","deployer","clarity_version","ClarityVersion","Clarity3","addEvalCode","inside_contract_id","addMapRead","key","addVarRead","getBlockInfo","_getBlockInfo","info","isNaN","getNodeInfo","stacksEndpoint","stacks_tip_height","richFetch","r","json","height","hash","run","_run","_callee3","nonce_by_address","nextNonce","step","_step$function_args","nonce","_step$contract_id$spl","contractAddress","contractName","_nonce","_tx","_nonce2","_tx2","_this","_context3","console","log","Map","_ref2","_callee2","account","_context2","get","_x5","STACKS_MAINNET","STACKS_TESTNET","client","baseUrl","x","deserializeTransaction","makeUnsignedContractCall","function_name","function_args","publicKey","postConditionMode","PostConditionMode","Allow","auth","spendingCondition","signer","c32addressDecode","makeUnsignedSTXTokenTransfer","recipient","amount","makeUnsignedContractDeploy","codeBody","source_code","pipe","transform","defaultProcessor","BatchProcessor","_options$stxerAPIEndp","queues","timeoutIds","stxerAPIEndpoint","batchDelayMs","getQueueKey","read","request","Promise","resolve","reject","enqueue","_this$queues$get","_this2","queueKey","queue","has","timeoutId","setTimeout","processBatch","_processBatch","_this$queues$get2","currentQueue","readonlyRequests","mapRequests","variableRequests","batchRequest","_step$value","index","result","_step2$value","_index","_result","_step3$value","_index2","_result2","clearTimeout","filter","q","mode","entries","t0","_callReadonly","_params$batchProcesso","processor","_params$contract$spli","fn","functionDef","argsKV","args","argDef","batchProcessor","String","abi","find","def","name","encodeAbi","indexBlockHash","decoded","decodeAbi","outputs","error","_readMap","_params$batchProcesso2","_params$contract$spli2","mapDef","m","ClarityType","OptionalNone","OptionalSome","_readVariable","_params$batchProcesso3","_params$contract$spli3","varDef","callReadonly","readMap","readVariable"],"mappings":"i1PA6CA,SAASA,EACPC,GAGA,IADA,IACkBC,EADZC,EAAoC,GAC1CC,EAAAC,EAAgBJ,KAAEC,EAAAE,K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,KAAA,EAOjC,GALKgO,EAAiC,OAAxB4B,EAAG9J,EAAOyI,gBAAcqB,EAAI1E,EAAgB2E,EAC1B/J,EAAO/G,SAAS2C,MAAM,IAAK,GAArDgF,EAAQmJ,EAAEpH,GAAAA,EAAYoH,EAAA,GAEvBC,EAAUhK,EAAO2I,IAAsCC,MAC3D,SAACC,GAAG,OAAKA,EAAIC,OAAS9I,EAAO9G,gBAEpB,CAAA+J,EAAA/I,KAAA,EAAA,KAAA,CAAA,MACH,IAAI/C,MAAK,0CAA2C6I,EAAO9G,cAAe,KAAA,EAAA,OAAA+J,EAAAnI,OAG3E,SAAA,IAAIgL,SAAQ,SAACC,EAASC,GAC3BkC,EAAUjC,QAAQ,CAChBJ,QAAS,CACPgC,KAAM,WACNnF,gBAAiB9B,EACjB+B,aAAcA,EACdzJ,aAAc8G,EAAO9G,cAEvBP,IAAKqH,EAAOgJ,eACZjD,QAAS,SAACoB,GACR,IACE,IAAM8B,EAAUC,EAASA,UAACc,EAAO7O,KAAMgM,GACvCpB,EAAQkD,EACT,CAAC,MAAOG,GACPpD,EAAOoD,EACT,CACD,EACDpD,OAAAA,GAEH,KAAC,KAAA,EAAA,IAAA,MAAA,OAAA/C,EAAAlI,OAAA,GAAAoH,EACH,MAAA1K,MAAAC,KAAAC,UAAA,sEArIqBsS,SAAY3S,GAAA,OAAA0Q,EAAAvQ,MAAAC,KAAAC,UAAA,kBA+CZuS,SAAO3S,GAAA,OAAA8R,EAAA5R,MAAAC,KAAAC,UAAA,uBAiDPwS,SAAYhO,GAAA,OAAA0N,EAAApS,MAAAC,KAAAC,UAAA"}
package/dist/stxer.esm.js CHANGED
@@ -917,9 +917,19 @@ var BatchProcessor = /*#__PURE__*/function () {
917
917
  _proto.getQueueKey = function getQueueKey(tip) {
918
918
  return tip != null ? tip : '_undefined';
919
919
  };
920
+ _proto.read = function read(request) {
921
+ var _this = this;
922
+ return new Promise(function (resolve, reject) {
923
+ _this.enqueue({
924
+ request: request,
925
+ resolve: resolve,
926
+ reject: reject
927
+ });
928
+ });
929
+ };
920
930
  _proto.enqueue = function enqueue(request) {
921
931
  var _this$queues$get,
922
- _this = this;
932
+ _this2 = this;
923
933
  var queueKey = this.getQueueKey(request.tip);
924
934
  var queue = (_this$queues$get = this.queues.get(queueKey)) != null ? _this$queues$get : [];
925
935
  if (!this.queues.has(queueKey)) {
@@ -928,7 +938,7 @@ var BatchProcessor = /*#__PURE__*/function () {
928
938
  queue.push(request);
929
939
  if (!this.timeoutIds.has(queueKey)) {
930
940
  var timeoutId = setTimeout(function () {
931
- return _this.processBatch(queueKey);
941
+ return _this2.processBatch(queueKey);
932
942
  }, this.batchDelayMs);
933
943
  this.timeoutIds.set(queueKey, timeoutId);
934
944
  }