@qorechain/svm 0.4.0 → 0.5.0
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.
- package/LICENSE +201 -0
- package/dist/index.cjs +1 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/package.json +9 -9
package/LICENSE
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
Apache License
|
|
2
|
+
Version 2.0, January 2004
|
|
3
|
+
http://www.apache.org/licenses/
|
|
4
|
+
|
|
5
|
+
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
|
6
|
+
|
|
7
|
+
1. Definitions.
|
|
8
|
+
|
|
9
|
+
"License" shall mean the terms and conditions for use, reproduction,
|
|
10
|
+
and distribution as defined by Sections 1 through 9 of this document.
|
|
11
|
+
|
|
12
|
+
"Licensor" shall mean the copyright owner or entity authorized by
|
|
13
|
+
the copyright owner that is granting the License.
|
|
14
|
+
|
|
15
|
+
"Legal Entity" shall mean the union of the acting entity and all
|
|
16
|
+
other entities that control, are controlled by, or are under common
|
|
17
|
+
control with that entity. For the purposes of this definition,
|
|
18
|
+
"control" means (i) the power, direct or indirect, to cause the
|
|
19
|
+
direction or management of such entity, whether by contract or
|
|
20
|
+
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
|
21
|
+
outstanding shares, or (iii) beneficial ownership of such entity.
|
|
22
|
+
|
|
23
|
+
"You" (or "Your") shall mean an individual or Legal Entity
|
|
24
|
+
exercising permissions granted by this License.
|
|
25
|
+
|
|
26
|
+
"Source" form shall mean the preferred form for making modifications,
|
|
27
|
+
including but not limited to software source code, documentation
|
|
28
|
+
source, and configuration files.
|
|
29
|
+
|
|
30
|
+
"Object" form shall mean any form resulting from mechanical
|
|
31
|
+
transformation or translation of a Source form, including but
|
|
32
|
+
not limited to compiled object code, generated documentation,
|
|
33
|
+
and conversions to other media types.
|
|
34
|
+
|
|
35
|
+
"Work" shall mean the work of authorship, whether in Source or
|
|
36
|
+
Object form, made available under the License, as indicated by a
|
|
37
|
+
copyright notice that is included in or attached to the work
|
|
38
|
+
(an example is provided in the Appendix below).
|
|
39
|
+
|
|
40
|
+
"Derivative Works" shall mean any work, whether in Source or Object
|
|
41
|
+
form, that is based on (or derived from) the Work and for which the
|
|
42
|
+
editorial revisions, annotations, elaborations, or other modifications
|
|
43
|
+
represent, as a whole, an original work of authorship. For the purposes
|
|
44
|
+
of this License, Derivative Works shall not include works that remain
|
|
45
|
+
separable from, or merely link (or bind by name) to the interfaces of,
|
|
46
|
+
the Work and Derivative Works thereof.
|
|
47
|
+
|
|
48
|
+
"Contribution" shall mean any work of authorship, including
|
|
49
|
+
the original version of the Work and any modifications or additions
|
|
50
|
+
to that Work or Derivative Works thereof, that is intentionally
|
|
51
|
+
submitted to Licensor for inclusion in the Work by the copyright owner
|
|
52
|
+
or by an individual or Legal Entity authorized to submit on behalf of
|
|
53
|
+
the copyright owner. For the purposes of this definition, "submitted"
|
|
54
|
+
means any form of electronic, verbal, or written communication sent
|
|
55
|
+
to the Licensor or its representatives, including but not limited to
|
|
56
|
+
communication on electronic mailing lists, source code control systems,
|
|
57
|
+
and issue tracking systems that are managed by, or on behalf of, the
|
|
58
|
+
Licensor for the purpose of discussing and improving the Work, but
|
|
59
|
+
excluding communication that is conspicuously marked or otherwise
|
|
60
|
+
designated in writing by the copyright owner as "Not a Contribution."
|
|
61
|
+
|
|
62
|
+
"Contributor" shall mean Licensor and any individual or Legal Entity
|
|
63
|
+
on behalf of whom a Contribution has been received by Licensor and
|
|
64
|
+
subsequently incorporated within the Work.
|
|
65
|
+
|
|
66
|
+
2. Grant of Copyright License. Subject to the terms and conditions of
|
|
67
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
68
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
69
|
+
copyright license to reproduce, prepare Derivative Works of,
|
|
70
|
+
publicly display, publicly perform, sublicense, and distribute the
|
|
71
|
+
Work and such Derivative Works in Source or Object form.
|
|
72
|
+
|
|
73
|
+
3. Grant of Patent License. Subject to the terms and conditions of
|
|
74
|
+
this License, each Contributor hereby grants to You a perpetual,
|
|
75
|
+
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
|
76
|
+
(except as stated in this section) patent license to make, have made,
|
|
77
|
+
use, offer to sell, sell, import, and otherwise transfer the Work,
|
|
78
|
+
where such license applies only to those patent claims licensable
|
|
79
|
+
by such Contributor that are necessarily infringed by their
|
|
80
|
+
Contribution(s) alone or by combination of their Contribution(s)
|
|
81
|
+
with the Work to which such Contribution(s) was submitted. If You
|
|
82
|
+
institute patent litigation against any entity (including a
|
|
83
|
+
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
|
84
|
+
or a Contribution incorporated within the Work constitutes direct
|
|
85
|
+
or contributory patent infringement, then any patent licenses
|
|
86
|
+
granted to You under this License for that Work shall terminate
|
|
87
|
+
as of the date such litigation is filed.
|
|
88
|
+
|
|
89
|
+
4. Redistribution. You may reproduce and distribute copies of the
|
|
90
|
+
Work or Derivative Works thereof in any medium, with or without
|
|
91
|
+
modifications, and in Source or Object form, provided that You
|
|
92
|
+
meet the following conditions:
|
|
93
|
+
|
|
94
|
+
(a) You must give any other recipients of the Work or Derivative
|
|
95
|
+
Works a copy of this License; and
|
|
96
|
+
|
|
97
|
+
(b) You must cause any modified files to carry prominent notices
|
|
98
|
+
stating that You changed the files; and
|
|
99
|
+
|
|
100
|
+
(c) You must retain, in the Source form of any Derivative Works
|
|
101
|
+
that You distribute, all copyright, patent, trademark, and
|
|
102
|
+
attribution notices from the Source form of the Work, excluding
|
|
103
|
+
those notices that do not pertain to any part of the Derivative
|
|
104
|
+
Works; and
|
|
105
|
+
|
|
106
|
+
(d) If the Work includes a "NOTICE" text file as part of its
|
|
107
|
+
distribution, then any Derivative Works that You distribute must
|
|
108
|
+
include a readable copy of the attribution notices contained
|
|
109
|
+
within such NOTICE file, excluding those notices that do not
|
|
110
|
+
pertain to any part of the Derivative Works, in at least one of
|
|
111
|
+
the following places: within a NOTICE text file distributed as
|
|
112
|
+
part of the Derivative Works; within the Source form or
|
|
113
|
+
documentation, if provided along with the Derivative Works; or,
|
|
114
|
+
within a display generated by the Derivative Works, if and
|
|
115
|
+
wherever such third-party notices normally appear. The contents
|
|
116
|
+
of the NOTICE file are for informational purposes only and do
|
|
117
|
+
not modify the License. You may add Your own attribution notices
|
|
118
|
+
within Derivative Works that You distribute, alongside or as an
|
|
119
|
+
addendum to the NOTICE text from the Work, provided that such
|
|
120
|
+
additional attribution notices cannot be construed as modifying
|
|
121
|
+
the License.
|
|
122
|
+
|
|
123
|
+
You may add Your own copyright statement to Your modifications and
|
|
124
|
+
may provide additional or different license terms and conditions
|
|
125
|
+
for use, reproduction, or distribution of Your modifications, or
|
|
126
|
+
for any such Derivative Works as a whole, provided Your use,
|
|
127
|
+
reproduction, and distribution of the Work otherwise complies with
|
|
128
|
+
the conditions stated in this License.
|
|
129
|
+
|
|
130
|
+
5. Submission of Contributions. Unless You explicitly state otherwise,
|
|
131
|
+
any Contribution intentionally submitted for inclusion in the Work
|
|
132
|
+
by You to the Licensor shall be under the terms and conditions of
|
|
133
|
+
this License, without any additional terms or conditions.
|
|
134
|
+
Notwithstanding the above, nothing herein shall supersede or modify
|
|
135
|
+
the terms of any separate license agreement you may have executed
|
|
136
|
+
with Licensor regarding such Contributions.
|
|
137
|
+
|
|
138
|
+
6. Trademarks. This License does not grant permission to use the trade
|
|
139
|
+
names, trademarks, service marks, or product names of the Licensor,
|
|
140
|
+
except as required for reasonable and customary use in describing the
|
|
141
|
+
origin of the Work and reproducing the content of the NOTICE file.
|
|
142
|
+
|
|
143
|
+
7. Disclaimer of Warranty. Unless required by applicable law or
|
|
144
|
+
agreed to in writing, Licensor provides the Work (and each
|
|
145
|
+
Contributor provides its Contributions) on an "AS IS" BASIS,
|
|
146
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
|
147
|
+
implied, including, without limitation, any warranties or conditions
|
|
148
|
+
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
|
149
|
+
PARTICULAR PURPOSE. You are solely responsible for determining the
|
|
150
|
+
appropriateness of using or redistributing the Work and assume any
|
|
151
|
+
risks associated with Your exercise of permissions under this License.
|
|
152
|
+
|
|
153
|
+
8. Limitation of Liability. In no event and under no legal theory,
|
|
154
|
+
whether in tort (including negligence), contract, or otherwise,
|
|
155
|
+
unless required by applicable law (such as deliberate and grossly
|
|
156
|
+
negligent acts) or agreed to in writing, shall any Contributor be
|
|
157
|
+
liable to You for damages, including any direct, indirect, special,
|
|
158
|
+
incidental, or consequential damages of any character arising as a
|
|
159
|
+
result of this License or out of the use or inability to use the
|
|
160
|
+
Work (including but not limited to damages for loss of goodwill,
|
|
161
|
+
work stoppage, computer failure or malfunction, or any and all
|
|
162
|
+
other commercial damages or losses), even if such Contributor
|
|
163
|
+
has been advised of the possibility of such damages.
|
|
164
|
+
|
|
165
|
+
9. Accepting Warranty or Additional Liability. While redistributing
|
|
166
|
+
the Work or Derivative Works thereof, You may choose to offer,
|
|
167
|
+
and charge a fee for, acceptance of support, warranty, indemnity,
|
|
168
|
+
or other liability obligations and/or rights consistent with this
|
|
169
|
+
License. However, in accepting such obligations, You may act only
|
|
170
|
+
on Your own behalf and on Your sole responsibility, not on behalf
|
|
171
|
+
of any other Contributor, and only if You agree to indemnify,
|
|
172
|
+
defend, and hold each Contributor harmless for any liability
|
|
173
|
+
incurred by, or claims asserted against, such Contributor by reason
|
|
174
|
+
of your accepting any such warranty or additional liability.
|
|
175
|
+
|
|
176
|
+
END OF TERMS AND CONDITIONS
|
|
177
|
+
|
|
178
|
+
APPENDIX: How to apply the Apache License to your work.
|
|
179
|
+
|
|
180
|
+
To apply the Apache License to your work, attach the following
|
|
181
|
+
boilerplate notice, with the fields enclosed by brackets "[]"
|
|
182
|
+
replaced with your own identifying information. (Don't include
|
|
183
|
+
the brackets!) The text should be enclosed in the appropriate
|
|
184
|
+
comment syntax for the file format. We also recommend that a
|
|
185
|
+
file or class name and description of purpose be included on the
|
|
186
|
+
same "printed page" as the copyright notice for easier
|
|
187
|
+
identification within third-party archives.
|
|
188
|
+
|
|
189
|
+
Copyright 2026 QoreChain
|
|
190
|
+
|
|
191
|
+
Licensed under the Apache License, Version 2.0 (the "License");
|
|
192
|
+
you may not use this file except in compliance with the License.
|
|
193
|
+
You may obtain a copy of the License at
|
|
194
|
+
|
|
195
|
+
http://www.apache.org/licenses/LICENSE-2.0
|
|
196
|
+
|
|
197
|
+
Unless required by applicable law or agreed to in writing, software
|
|
198
|
+
distributed under the License is distributed on an "AS IS" BASIS,
|
|
199
|
+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
200
|
+
See the License for the specific language governing permissions and
|
|
201
|
+
limitations under the License.
|
package/dist/index.cjs
CHANGED
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/keys.ts","../src/programs.ts","../src/wallet.ts","../src/errors.ts","../src/subscribe.ts","../src/fees.ts","../src/index.ts"],"names":["Connection","Transaction","SystemProgram","sendAndConfirmTransaction","Keypair","PublicKey","TransactionInstruction","ComputeBudgetProgram","fees"],"mappings":";;;;;AAmCO,IAAM,mBAAA,GAAsB;AA2EnC,SAAS,kBAAkB,IAAA,EAA0C;AACnE,EAAA,IAAI,IAAA,CAAK,UAAA,EAAY,OAAO,IAAA,CAAK,UAAA;AACjC,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,MAAA,IAAU,IAAA,CAAK,WAAW,MAAA,IAAU,mBAAA;AACrD,EAAA,OAAO,IAAIA,kBAAA,CAAW,GAAA,EAAK,IAAA,CAAK,cAAc,WAAW,CAAA;AAC3D;AAQO,SAAS,eAAA,CAAgB,IAAA,GAA+B,EAAC,EAAc;AAC5E,EAAA,MAAM,UAAA,GAA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AA,CACpB,UAAA,EACA,QAAA,GAAiC,EAAC,EACjB;AACjB,EAAA,MAAMC,KAAAA,GAAO,MAAM,UAAA,CAAW,2BAAA;AAAA,IAC5B,QAAA,CAAS,SAAS,CAAA,GAAI,EAAE,wBAAwB,CAAC,GAAG,QAAQ,CAAA,EAAE,GAAI;AAAA,GACpE;AACA,EAAA,IAAI,CAACA,KAAAA,IAAQA,KAAAA,CAAK,MAAA,KAAW,GAAG,OAAO,CAAA;AACvC,EAAA,OAAOA,KAAAA,CAAK,MAAA,CAAO,CAAC,GAAA,EAAK,CAAA,KAAM,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,CAAA,CAAE,iBAAiB,CAAA,EAAG,CAAC,CAAA;AACtE;AAGO,IAAM,IAAA,GAAO;AAAA,EAClB,iBAAA;AAAA,EACA;AACF;;;AC7DO,IAAM,OAAA,GAAU","file":"index.cjs","sourcesContent":["/**\n * Client factory for QoreChain's Solana-compatible JSON-RPC.\n *\n * This is a thin convenience layer over `@solana/web3.js`: it builds (or accepts)\n * a `Connection` bound to the network's SVM RPC endpoint and exposes typed\n * wrappers over the documented Solana-compatible JSON-RPC method set plus\n * transaction build/sign/send helpers.\n *\n * `@solana/web3.js` is a peer dependency; nothing here reimplements it.\n */\n\nimport {\n Connection,\n PublicKey,\n SystemProgram,\n Transaction,\n sendAndConfirmTransaction,\n type AccountInfo,\n type Commitment,\n type ConfirmOptions,\n type GetLatestBlockhashConfig,\n type Keypair,\n type RpcResponseAndContext,\n type SignatureResult,\n type SimulatedTransactionResponse,\n type TokenAccountsFilter,\n} from \"@solana/web3.js\";\n\n/** Subset of a qorechain-sdk network's endpoints relevant to the SVM runtime. */\nexport interface SvmEndpoints {\n /** Solana-compatible JSON-RPC HTTP endpoint. */\n svmRpc: string;\n}\n\n/** Default testnet SVM RPC endpoint (Solana-compatible JSON-RPC, port 8899). */\nexport const DEFAULT_SVM_RPC_URL = \"http://localhost:8899\";\n\n/** Options for {@link createSvmClient}. */\nexport interface CreateSvmClientOptions {\n /** Solana-compatible JSON-RPC HTTP URL. Mutually exclusive with `endpoints`. */\n rpcUrl?: string;\n /** A qorechain-sdk network endpoints object (uses `svmRpc`). */\n endpoints?: SvmEndpoints;\n /** Default commitment level for the connection. */\n commitment?: Commitment;\n /**\n * A preconstructed `Connection`. When provided it is used as-is and `rpcUrl`/\n * `endpoints`/`commitment` are ignored — primarily for testing.\n */\n connection?: Connection;\n}\n\n/** Arguments for building/sending a SOL transfer. */\nexport interface TransferSolArgs {\n /** Funding/source keypair (signer). */\n from: Keypair;\n /** Destination address. */\n to: PublicKey;\n /** Amount in lamports. */\n lamports: number | bigint;\n}\n\n/** A configured QoreChain SVM client bundle. */\nexport interface SvmClient {\n /** The underlying `@solana/web3.js` `Connection`. */\n connection: Connection;\n\n // --- Reads (thin wrappers over the JSON-RPC method set) ---\n /** Lamport balance for an account. */\n getBalance(pubkey: PublicKey, commitment?: Commitment): Promise<number>;\n /** Raw account info, or `null` if the account does not exist. */\n getAccountInfo(\n pubkey: PublicKey,\n commitment?: Commitment,\n ): Promise<AccountInfo<Buffer> | null>;\n /** Latest blockhash and last valid block height. */\n getLatestBlockhash(\n commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,\n ): Promise<{ blockhash: string; lastValidBlockHeight: number }>;\n /** Token accounts owned by `owner`, filtered by mint or program id. */\n getTokenAccountsByOwner(\n owner: PublicKey,\n filter: TokenAccountsFilter,\n commitment?: Commitment,\n ): ReturnType<Connection[\"getTokenAccountsByOwner\"]>;\n /** Confirmed signatures for transactions involving `address`. */\n getSignaturesForAddress(\n address: PublicKey,\n options?: Parameters<Connection[\"getSignaturesForAddress\"]>[1],\n ): ReturnType<Connection[\"getSignaturesForAddress\"]>;\n /** Request an airdrop of `lamports` to `pubkey` (testnet/devnet only). */\n requestAirdrop(pubkey: PublicKey, lamports: number): Promise<string>;\n\n // --- Transactions ---\n /** Build (unsigned, no blockhash) a SOL transfer transaction. */\n buildTransferSol(args: TransferSolArgs): Transaction;\n /** Build, sign, send, and confirm a SOL transfer. */\n transferSol(args: TransferSolArgs, options?: ConfirmOptions): Promise<string>;\n /** Sign, send, and confirm an arbitrary transaction. */\n sendTransaction(\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string>;\n /** Simulate a transaction without submitting it. */\n simulateTransaction(\n tx: Transaction,\n ): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;\n}\n\nfunction resolveConnection(opts: CreateSvmClientOptions): Connection {\n if (opts.connection) return opts.connection;\n const url = opts.rpcUrl ?? opts.endpoints?.svmRpc ?? DEFAULT_SVM_RPC_URL;\n return new Connection(url, opts.commitment ?? \"confirmed\");\n}\n\n/**\n * Create a QoreChain SVM client bundle.\n *\n * With no options it targets the testnet localhost endpoint\n * (`http://localhost:8899`) at `confirmed` commitment.\n */\nexport function createSvmClient(opts: CreateSvmClientOptions = {}): SvmClient {\n const connection = resolveConnection(opts);\n\n const buildTransferSol = (args: TransferSolArgs): Transaction => {\n const tx = new Transaction();\n tx.add(\n SystemProgram.transfer({\n fromPubkey: args.from.publicKey,\n toPubkey: args.to,\n lamports: args.lamports,\n }),\n );\n return tx;\n };\n\n const sendTransaction = (\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string> => sendAndConfirmTransaction(connection, tx, signers, options);\n\n return {\n connection,\n\n getBalance: (pubkey, commitment) => connection.getBalance(pubkey, commitment),\n getAccountInfo: (pubkey, commitment) =>\n connection.getAccountInfo(pubkey, commitment) as Promise<AccountInfo<Buffer> | null>,\n getLatestBlockhash: (commitmentOrConfig) =>\n connection.getLatestBlockhash(commitmentOrConfig),\n getTokenAccountsByOwner: (owner, filter, commitment) =>\n connection.getTokenAccountsByOwner(owner, filter, commitment),\n getSignaturesForAddress: (address, options) =>\n connection.getSignaturesForAddress(address, options),\n requestAirdrop: (pubkey, lamports) => connection.requestAirdrop(pubkey, lamports),\n\n buildTransferSol,\n transferSol: (args, options) =>\n sendTransaction(buildTransferSol(args), [args.from], options),\n sendTransaction,\n simulateTransaction: (tx): Promise<\n RpcResponseAndContext<SimulatedTransactionResponse>\n > =>\n // The single-arg overload signs/derives blockhash as needed for v1\n // legacy transactions.\n (connection.simulateTransaction as (\n t: Transaction,\n ) => Promise<RpcResponseAndContext<SimulatedTransactionResponse>>)(tx),\n };\n}\n\n// Re-export so callers can type their results without a direct dependency on the\n// peer's internal `SignatureResult` import path.\nexport type { SignatureResult };\n","/**\n * Key helpers for QoreChain's Solana-compatible runtime.\n *\n * These are thin wrappers over `@solana/web3.js` so callers don't need a second\n * import path. `@qorechain/sdk`'s `deriveSvmAccount(mnemonic)` provides the\n * 64-byte `secretKey` you can pass straight into {@link svmKeypairFromSecretKey}.\n */\n\nimport { Keypair, PublicKey } from \"@solana/web3.js\";\n\n/**\n * Reconstruct a `@solana/web3.js` `Keypair` from a 64-byte ed25519 secret key\n * (the standard Solana secret-key encoding: 32-byte seed + 32-byte public key).\n *\n * Pair with `@qorechain/sdk`'s `deriveSvmAccount`, which returns this exact\n * 64-byte `secretKey`.\n */\nexport function svmKeypairFromSecretKey(secretKey: Uint8Array): Keypair {\n if (secretKey.length !== 64) {\n throw new Error(\n `svmKeypairFromSecretKey: expected a 64-byte secret key, got ${secretKey.length}`,\n );\n }\n return Keypair.fromSecretKey(secretKey);\n}\n\n/** Return the base58 address for a `Keypair` or a `PublicKey`. */\nexport function svmAddress(key: Keypair | PublicKey): string {\n const pubkey = key instanceof PublicKey ? key : key.publicKey;\n return pubkey.toBase58();\n}\n","/**\n * Well-known native program ids for QoreChain's Solana-compatible runtime, plus\n * thin instruction builders for the Memo and SPL-Token programs and the\n * Associated Token Account program.\n *\n * The program ids are the exact canonical ones used by Solana-compatible\n * runtimes, so standard wallets, explorers, and tooling interoperate directly.\n * The SPL-Token / ATA / Memo instructions are built minimally here (by hand)\n * to keep the dependency surface to a single peer — `@solana/web3.js` — with no\n * `@solana/spl-token` requirement.\n */\n\nimport { PublicKey, TransactionInstruction, type AccountMeta } from \"@solana/web3.js\";\n\n/** System program (account creation, SOL transfers). */\nexport const SYSTEM_PROGRAM_ID = new PublicKey(\"11111111111111111111111111111111\");\n\n/** SPL-Token program. */\nexport const TOKEN_PROGRAM_ID = new PublicKey(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\");\n\n/** Associated Token Account program. */\nexport const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey(\n \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\",\n);\n\n/** SPL Memo program. */\nexport const MEMO_PROGRAM_ID = new PublicKey(\"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr\");\n\n/** Convenience grouping of the well-known program ids. */\nexport const PROGRAM_IDS = {\n system: SYSTEM_PROGRAM_ID,\n token: TOKEN_PROGRAM_ID,\n associatedToken: ASSOCIATED_TOKEN_PROGRAM_ID,\n memo: MEMO_PROGRAM_ID,\n} as const;\n\n/**\n * Build a Memo program instruction carrying `text` (encoded UTF-8).\n *\n * @param text Memo contents.\n * @param signers Optional accounts that must sign the memo; each is included as\n * a read-only signer (the Memo program's convention).\n */\nexport function createMemoInstruction(\n text: string,\n signers: PublicKey[] = [],\n): TransactionInstruction {\n return new TransactionInstruction({\n programId: MEMO_PROGRAM_ID,\n keys: signers.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n data: Buffer.from(text, \"utf8\"),\n });\n}\n\n/** Arguments for {@link createTransferTokenInstruction}. */\nexport interface TransferTokenInstructionArgs {\n /** Source SPL-Token account. */\n source: PublicKey;\n /** Destination SPL-Token account. */\n destination: PublicKey;\n /** Owner/authority of the source account (signer). */\n owner: PublicKey;\n /** Amount in the token's base units. */\n amount: bigint;\n /** Additional multisig signers, if `owner` is a multisig. */\n multiSigners?: PublicKey[];\n}\n\n/**\n * Build an SPL-Token `Transfer` instruction.\n *\n * Layout: 1 byte instruction discriminator (`3` = Transfer) followed by a\n * little-endian u64 amount.\n */\nexport function createTransferTokenInstruction(\n args: TransferTokenInstructionArgs,\n): TransactionInstruction {\n const { source, destination, owner, amount, multiSigners = [] } = args;\n\n const data = Buffer.alloc(9);\n data.writeUInt8(3, 0);\n data.writeBigUInt64LE(amount, 1);\n\n const keys: AccountMeta[] = [\n { pubkey: source, isSigner: false, isWritable: true },\n { pubkey: destination, isSigner: false, isWritable: true },\n {\n pubkey: owner,\n isSigner: multiSigners.length === 0,\n isWritable: false,\n },\n ...multiSigners.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n ];\n\n return new TransactionInstruction({ programId: TOKEN_PROGRAM_ID, keys, data });\n}\n\n/**\n * Derive the deterministic Associated Token Account (ATA) address for an owner\n * and mint under the SPL-Token program.\n */\nexport function getAssociatedTokenAddress(\n mint: PublicKey,\n owner: PublicKey,\n tokenProgramId: PublicKey = TOKEN_PROGRAM_ID,\n): PublicKey {\n const [address] = PublicKey.findProgramAddressSync(\n [owner.toBuffer(), tokenProgramId.toBuffer(), mint.toBuffer()],\n ASSOCIATED_TOKEN_PROGRAM_ID,\n );\n return address;\n}\n\n/** Arguments for {@link createAssociatedTokenAccountInstruction}. */\nexport interface CreateAssociatedTokenAccountInstructionArgs {\n /** Account funding the rent for the new ATA (signer, writable). */\n payer: PublicKey;\n /** Wallet that will own the new ATA. */\n owner: PublicKey;\n /** Token mint. */\n mint: PublicKey;\n /** SPL-Token program id (defaults to the canonical SPL-Token program). */\n tokenProgramId?: PublicKey;\n}\n\n/**\n * Build an instruction that creates the Associated Token Account for\n * `(owner, mint)`. The ATA address is derived deterministically.\n */\nexport function createAssociatedTokenAccountInstruction(\n args: CreateAssociatedTokenAccountInstructionArgs,\n): TransactionInstruction {\n const { payer, owner, mint, tokenProgramId = TOKEN_PROGRAM_ID } = args;\n const ata = getAssociatedTokenAddress(mint, owner, tokenProgramId);\n\n const keys: AccountMeta[] = [\n { pubkey: payer, isSigner: true, isWritable: true },\n { pubkey: ata, isSigner: false, isWritable: true },\n { pubkey: owner, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: false },\n { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },\n { pubkey: tokenProgramId, isSigner: false, isWritable: false },\n ];\n\n // The ATA \"Create\" instruction takes empty data (the idempotent variant uses\n // a single 0x01 byte; this is the plain create).\n return new TransactionInstruction({\n programId: ASSOCIATED_TOKEN_PROGRAM_ID,\n keys,\n data: Buffer.alloc(0),\n });\n}\n\n/**\n * Generic instruction builder for invoking an arbitrary on-chain program.\n *\n * Use this with {@link createSvmClient}'s `sendTransaction` to call a deployed\n * BPF program. Deploy programs with standard Solana tooling (e.g.\n * `solana program deploy`); this package intentionally does not wrap the loader.\n */\nexport function createInvokeInstruction(\n programId: PublicKey,\n keys: AccountMeta[],\n data: Uint8Array,\n): TransactionInstruction {\n return new TransactionInstruction({\n programId,\n keys,\n data: Buffer.from(data),\n });\n}\n","/**\n * SVM browser-wallet integration for QoreChain (Phantom and Wallet-Standard).\n *\n * Adapts an injected Solana provider (Phantom's `window.solana` is the baseline)\n * into a shape usable with `@solana/web3.js`, so apps can sign and send via the\n * existing SVM client.\n *\n * ```ts\n * import { getSvmWallet } from \"@qorechain/svm\";\n * import { createSvmClient } from \"@qorechain/svm\";\n *\n * const wallet = await getSvmWallet();\n * const signed = await wallet.signTransaction(tx);\n * // ...then send with createSvmClient(...).sendRawTransaction(...)\n * ```\n */\n\nimport type { PublicKey, Transaction, VersionedTransaction } from \"@solana/web3.js\";\n\n/** A transaction the wallet can sign (legacy or versioned). */\nexport type SvmSignableTransaction = Transaction | VersionedTransaction;\n\n/**\n * The minimal injected Solana-wallet surface used here. Phantom (and most\n * Wallet-Standard providers) implement at least these. Declared structurally so\n * no wallet types package is required.\n */\nexport interface InjectedSvmWallet {\n /** Phantom marker; present on the Phantom provider. */\n isPhantom?: boolean;\n /** Connect and return the account public key. */\n connect(opts?: { onlyIfTrusted?: boolean }): Promise<{ publicKey: PublicKey }>;\n /** Disconnect the wallet. */\n disconnect?(): Promise<void>;\n /** The connected account public key (populated after `connect`). */\n publicKey?: PublicKey | null;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions. */\n signAllTransactions?<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n}\n\n/** Window augmentation for the default injected Solana provider. */\ninterface SolanaWindow {\n solana?: InjectedSvmWallet;\n}\n\n/** Options for {@link getSvmWallet}. */\nexport interface GetSvmWalletOptions {\n /** The injected provider to use. Defaults to `window.solana` (Phantom). */\n provider?: InjectedSvmWallet;\n /** Pass through to the provider's `connect` (e.g. silent reconnect). */\n onlyIfTrusted?: boolean;\n}\n\n/**\n * A connected SVM wallet adapted for use with `@solana/web3.js`.\n *\n * `signTransaction` / `signAllTransactions` accept and return web3.js\n * `Transaction` / `VersionedTransaction` objects, so they drop into the existing\n * SVM client's send path.\n */\nexport interface SvmWalletConnection {\n /** The connected account public key. */\n publicKey: PublicKey;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions (falls back to sequential signing). */\n signAllTransactions<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n /** The underlying injected provider. */\n provider: InjectedSvmWallet;\n}\n\n/** Resolve the injected Solana provider from options or `window`, or throw. */\nfunction resolveProvider(provider?: InjectedSvmWallet): InjectedSvmWallet {\n if (provider) return provider;\n if (typeof window === \"undefined\") {\n throw new Error(\n \"getSvmWallet: no browser `window` available. Run in a browser, or pass `provider` explicitly.\",\n );\n }\n const injected = (window as unknown as SolanaWindow).solana;\n if (!injected) {\n throw new Error(\n \"getSvmWallet: no injected Solana provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n return injected;\n}\n\n/**\n * Connect to an injected Solana wallet (Phantom by default) and return an\n * adapter usable with `@solana/web3.js`.\n *\n * Browser-only: throws a clear error if no `window` or no injected provider.\n */\nexport async function getSvmWallet(\n opts: GetSvmWalletOptions = {},\n): Promise<SvmWalletConnection> {\n const provider = resolveProvider(opts.provider);\n const { publicKey } = await provider.connect(\n opts.onlyIfTrusted ? { onlyIfTrusted: true } : undefined,\n );\n if (!publicKey) {\n throw new Error(\"getSvmWallet: wallet connected but returned no public key\");\n }\n\n const signTransaction = <T extends SvmSignableTransaction>(tx: T): Promise<T> =>\n provider.signTransaction(tx);\n\n const signAllTransactions = async <T extends SvmSignableTransaction>(\n txs: T[],\n ): Promise<T[]> => {\n if (provider.signAllTransactions) return provider.signAllTransactions(txs);\n // Fall back to signing sequentially for providers without batch support.\n const out: T[] = [];\n for (const tx of txs) out.push(await provider.signTransaction(tx));\n return out;\n };\n\n return { publicKey, signTransaction, signAllTransactions, provider };\n}\n\n/**\n * Detect a Wallet-Standard / Phantom Solana provider on `window`.\n *\n * Returns the injected provider if present, else `undefined`. Phantom's\n * `window.solana` is the baseline; this is a light convenience for apps that\n * want to feature-detect before prompting a connection.\n */\nexport function detectSvmProvider(): InjectedSvmWallet | undefined {\n if (typeof window === \"undefined\") return undefined;\n return (window as unknown as SolanaWindow).solana;\n}\n","/**\n * Human-readable decoding of SVM (Solana-compatible) transaction errors.\n *\n * `@solana/web3.js` throws a `SendTransactionError` (and related shapes) whose\n * useful detail — the failing instruction index, a program's custom error code,\n * and the program logs — is spread across several fields that differ slightly\n * between library versions. {@link decodeSvmError} reads those fields\n * structurally (so it works across versions) and produces a flat summary with\n * the program logs and, where present, the failing instruction index.\n */\n\n/** A decoded SVM error. */\nexport interface DecodedSvmError {\n /** A readable summary message. */\n message: string;\n /** A short, stable kind discriminator. */\n kind: \"instruction_error\" | \"simulation\" | \"send\" | \"unknown\";\n /** Zero-based index of the failing instruction, when determinable. */\n instructionIndex?: number;\n /** A program's custom error code, when present in the logs. */\n customErrorCode?: number;\n /** The program logs, when available. */\n logs?: string[];\n}\n\n/** Read the program logs from the various shapes web3.js uses. */\nfunction extractLogs(err: unknown): string[] | undefined {\n const e = err as { logs?: unknown; transactionLogs?: unknown };\n const logs = e?.logs ?? e?.transactionLogs;\n if (Array.isArray(logs)) return logs as string[];\n return undefined;\n}\n\n/** Read a base message from the various shapes web3.js uses. */\nfunction extractMessage(err: unknown): string {\n const e = err as { transactionMessage?: unknown; message?: unknown };\n if (typeof e?.transactionMessage === \"string\" && e.transactionMessage) {\n return e.transactionMessage;\n }\n if (typeof e?.message === \"string\" && e.message) return e.message;\n return String(err);\n}\n\n/**\n * Parse the failing instruction index and a custom program error code from the\n * program logs, if either is present.\n *\n * Logs commonly contain a line like:\n * \"Program <id> failed: custom program error: 0x1\"\n * and the instruction index can appear as \"Error processing Instruction 2:\".\n */\nfunction parseFromLogs(logs: string[] | undefined): {\n instructionIndex?: number;\n customErrorCode?: number;\n} {\n if (!logs) return {};\n let instructionIndex: number | undefined;\n let customErrorCode: number | undefined;\n for (const line of logs) {\n const instr = /instruction\\s+#?(\\d+)/i.exec(line);\n if (instr) instructionIndex = Number(instr[1]);\n const custom = /custom program error:\\s*(0x[0-9a-fA-F]+|\\d+)/i.exec(line);\n if (custom) {\n customErrorCode = custom[1].startsWith(\"0x\")\n ? parseInt(custom[1], 16)\n : Number(custom[1]);\n }\n }\n return { instructionIndex, customErrorCode };\n}\n\n/**\n * Decode an SVM error thrown by `@solana/web3.js` into a readable, structured\n * form.\n *\n * @param error - The thrown error (a `SendTransactionError` or any value).\n */\nexport function decodeSvmError(error: unknown): DecodedSvmError {\n const logs = extractLogs(error);\n const base = extractMessage(error);\n const { instructionIndex, customErrorCode } = parseFromLogs(logs);\n\n const name = (error as { name?: string })?.name;\n const isSendError =\n name === \"SendTransactionError\" ||\n /simulation failed|transaction simulation/i.test(base);\n\n const parts: string[] = [base];\n if (instructionIndex !== undefined) {\n parts.push(`(failing instruction #${instructionIndex})`);\n }\n if (customErrorCode !== undefined) {\n parts.push(`(custom program error ${customErrorCode})`);\n }\n\n let kind: DecodedSvmError[\"kind\"];\n if (customErrorCode !== undefined || instructionIndex !== undefined) {\n kind = \"instruction_error\";\n } else if (isSendError) {\n kind = \"simulation\";\n } else if (error instanceof Error) {\n kind = \"send\";\n } else {\n kind = \"unknown\";\n }\n\n return {\n message: parts.join(\" \"),\n kind,\n instructionIndex,\n customErrorCode,\n logs,\n };\n}\n","/**\n * Real-time SVM subscriptions over the `@solana/web3.js` `Connection`.\n *\n * The `Connection` owns the websocket and its lifecycle; these helpers are thin\n * wrappers that register a listener and return both the numeric subscription id\n * and an `off()` function that removes it via the matching\n * `remove*Listener` call. This keeps callers from having to remember which\n * removal method pairs with which subscription.\n */\n\nimport type {\n AccountChangeCallback,\n Commitment,\n Connection,\n LogsCallback,\n LogsFilter,\n PublicKey,\n SlotChangeCallback,\n} from \"@solana/web3.js\";\n\n/** A registered subscription: its id and a function to remove it. */\nexport interface SvmSubscription {\n /** The numeric subscription id returned by `@solana/web3.js`. */\n id: number;\n /** Remove the listener (idempotent best-effort). */\n off(): Promise<void>;\n}\n\n/**\n * Subscribe to transaction logs matching `filter`.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param filter - A `LogsFilter` (`\"all\"`, `\"allWithVotes\"`, or a `PublicKey`).\n * @param callback - Invoked with each matching logs notification.\n * @param commitment - Optional commitment level.\n */\nexport function onLogs(\n connection: Connection,\n filter: LogsFilter,\n callback: LogsCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onLogs(filter, callback, commitment);\n return {\n id,\n off: () => connection.removeOnLogsListener(id),\n };\n}\n\n/**\n * Subscribe to changes of an account's data.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param pubkey - The account to watch.\n * @param callback - Invoked with each account change.\n * @param commitment - Optional commitment level.\n */\nexport function onAccountChange(\n connection: Connection,\n pubkey: PublicKey,\n callback: AccountChangeCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onAccountChange(pubkey, callback, commitment);\n return {\n id,\n off: () => connection.removeAccountChangeListener(id),\n };\n}\n\n/**\n * Subscribe to slot changes (new slots as they are processed).\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param callback - Invoked with each slot change.\n */\nexport function onSlotChange(\n connection: Connection,\n callback: SlotChangeCallback,\n): SvmSubscription {\n const id = connection.onSlotChange(callback);\n return {\n id,\n off: () => connection.removeSlotChangeListener(id),\n };\n}\n","/**\n * Compute-budget and priority-fee conveniences over `@solana/web3.js`.\n *\n * {@link withComputeBudget} prepends `ComputeBudgetProgram` instructions to a\n * legacy `Transaction` so it requests a compute-unit limit and pays a per-CU\n * priority price; {@link estimatePriorityFee} reads recent prioritization fees\n * from the RPC to suggest a `microLamports` price.\n */\n\nimport {\n ComputeBudgetProgram,\n type Connection,\n type PublicKey,\n type Transaction,\n} from \"@solana/web3.js\";\n\n/** Compute-budget options for {@link withComputeBudget}. */\nexport interface ComputeBudgetOptions {\n /** Compute-unit limit to request (`setComputeUnitLimit`). */\n units?: number;\n /** Per-compute-unit price in micro-lamports (`setComputeUnitPrice`). */\n microLamports?: number | bigint;\n}\n\n/**\n * Prepend `ComputeBudgetProgram` instructions to `tx` (mutating it in place and\n * returning it). A unit-limit instruction is added when `units` is given, and a\n * unit-price instruction when `microLamports` is given; both are inserted at the\n * front of the instruction list, as required by the runtime.\n *\n * @returns The same `tx`, for chaining.\n */\nexport function withComputeBudget(\n tx: Transaction,\n options: ComputeBudgetOptions,\n): Transaction {\n const { units, microLamports } = options;\n const prepend = [];\n if (microLamports !== undefined) {\n prepend.unshift(\n ComputeBudgetProgram.setComputeUnitPrice({ microLamports }),\n );\n }\n if (units !== undefined) {\n prepend.unshift(ComputeBudgetProgram.setComputeUnitLimit({ units }));\n }\n tx.instructions.unshift(...prepend);\n return tx;\n}\n\n/**\n * Estimate a priority fee (`microLamports` per CU) from the RPC's\n * `getRecentPrioritizationFees`. Returns the maximum recently observed fee,\n * which is a conservative choice for landing a transaction quickly. Returns `0`\n * when the RPC reports no recent fees.\n *\n * @param connection - SVM RPC connection.\n * @param accounts - Optional accounts the tx will lock, scoping the query.\n */\nexport async function estimatePriorityFee(\n connection: Connection,\n accounts: readonly PublicKey[] = [],\n): Promise<number> {\n const fees = await connection.getRecentPrioritizationFees(\n accounts.length > 0 ? { lockedWritableAccounts: [...accounts] } : undefined,\n );\n if (!fees || fees.length === 0) return 0;\n return fees.reduce((max, f) => Math.max(max, f.prioritizationFee), 0);\n}\n\n/** Namespaced compute-budget / fee helpers. */\nexport const fees = {\n withComputeBudget,\n estimatePriorityFee,\n} as const;\n","/**\n * `@qorechain/svm` — a thin, type-safe adapter over\n * [`@solana/web3.js`](https://solana-labs.github.io/solana-web3.js/) for\n * QoreChain's Solana-compatible JSON-RPC.\n *\n * It does not reimplement an SVM client; `@solana/web3.js` is a peer dependency.\n * This package adds QoreChain-specific conveniences: a client factory targeting\n * the SVM RPC endpoint, key helpers, typed read wrappers, SOL transfer\n * build/sign/send, and minimal native-program instruction builders (Memo,\n * SPL-Token, Associated Token Account) plus a generic program-invoke builder.\n */\n\n/** Package version. */\nexport const VERSION = \"0.3.0\";\n\nexport {\n createSvmClient,\n DEFAULT_SVM_RPC_URL,\n type CreateSvmClientOptions,\n type SvmClient,\n type SvmEndpoints,\n type TransferSolArgs,\n type SignatureResult,\n} from \"./client\";\n\nexport { svmKeypairFromSecretKey, svmAddress } from \"./keys\";\n\nexport {\n PROGRAM_IDS,\n SYSTEM_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n ASSOCIATED_TOKEN_PROGRAM_ID,\n MEMO_PROGRAM_ID,\n createMemoInstruction,\n createTransferTokenInstruction,\n createAssociatedTokenAccountInstruction,\n getAssociatedTokenAddress,\n createInvokeInstruction,\n type TransferTokenInstructionArgs,\n type CreateAssociatedTokenAccountInstructionArgs,\n} from \"./programs\";\n\nexport {\n getSvmWallet,\n detectSvmProvider,\n type InjectedSvmWallet,\n type GetSvmWalletOptions,\n type SvmWalletConnection,\n type SvmSignableTransaction,\n} from \"./wallet\";\n\nexport { decodeSvmError, type DecodedSvmError } from \"./errors\";\n\nexport {\n onLogs,\n onAccountChange,\n onSlotChange,\n type SvmSubscription,\n} from \"./subscribe\";\n\nexport {\n fees,\n withComputeBudget,\n estimatePriorityFee,\n type ComputeBudgetOptions,\n} from \"./fees\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/keys.ts","../src/programs.ts","../src/wallet.ts","../src/errors.ts","../src/subscribe.ts","../src/fees.ts","../src/index.ts"],"names":["Connection","Transaction","SystemProgram","sendAndConfirmTransaction","Keypair","PublicKey","TransactionInstruction","ComputeBudgetProgram","fees"],"mappings":";;;;;AAmCO,IAAM,mBAAA,GAAsB;AA2EnC,SAAS,kBAAkB,IAAA,EAA0C;AACnE,EAAA,IAAI,IAAA,CAAK,UAAA,EAAY,OAAO,IAAA,CAAK,UAAA;AACjC,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,MAAA,IAAU,IAAA,CAAK,WAAW,MAAA,IAAU,mBAAA;AACrD,EAAA,OAAO,IAAIA,kBAAA,CAAW,GAAA,EAAK,IAAA,CAAK,cAAc,WAAW,CAAA;AAC3D;AAQO,SAAS,eAAA,CAAgB,IAAA,GAA+B,EAAC,EAAc;AAC5E,EAAA,MAAM,UAAA,GAAa,kBAAkB,IAAI,CAAA;AAEzC,EAAA,MAAM,gBAAA,GAAmB,CAAC,IAAA,KAAuC;AAC/D,IAAA,MAAM,EAAA,GAAK,IAAIC,mBAAA,EAAY;AAC3B,IAAA,EAAA,CAAG,GAAA;AAAA,MACDC,sBAAc,QAAA,CAAS;AAAA,QACrB,UAAA,EAAY,KAAK,IAAA,CAAK,SAAA;AAAA,QACtB,UAAU,IAAA,CAAK,EAAA;AAAA,QACf,UAAU,IAAA,CAAK;AAAA,OAChB;AAAA,KACH;AACA,IAAA,OAAO,EAAA;AAAA,EACT,CAAA;AAEA,EAAA,MAAM,eAAA,GAAkB,CACtB,EAAA,EACA,OAAA,EACA,YACoBC,iCAAA,CAA0B,UAAA,EAAY,EAAA,EAAI,OAAA,EAAS,OAAO,CAAA;AAEhF,EAAA,OAAO;AAAA,IACL,UAAA;AAAA,IAEA,YAAY,CAAC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esContent":["/**\n * Client factory for QoreChain's Solana-compatible JSON-RPC.\n *\n * This is a thin convenience layer over `@solana/web3.js`: it builds (or accepts)\n * a `Connection` bound to the network's SVM RPC endpoint and exposes typed\n * wrappers over the documented Solana-compatible JSON-RPC method set plus\n * transaction build/sign/send helpers.\n *\n * `@solana/web3.js` is a peer dependency; nothing here reimplements it.\n */\n\nimport {\n Connection,\n PublicKey,\n SystemProgram,\n Transaction,\n sendAndConfirmTransaction,\n type AccountInfo,\n type Commitment,\n type ConfirmOptions,\n type GetLatestBlockhashConfig,\n type Keypair,\n type RpcResponseAndContext,\n type SignatureResult,\n type SimulatedTransactionResponse,\n type TokenAccountsFilter,\n} from \"@solana/web3.js\";\n\n/** Subset of a qorechain-sdk network's endpoints relevant to the SVM runtime. */\nexport interface SvmEndpoints {\n /** Solana-compatible JSON-RPC HTTP endpoint. */\n svmRpc: string;\n}\n\n/** Default testnet SVM RPC endpoint (Solana-compatible JSON-RPC, port 8899). */\nexport const DEFAULT_SVM_RPC_URL = \"http://localhost:8899\";\n\n/** Options for {@link createSvmClient}. */\nexport interface CreateSvmClientOptions {\n /** Solana-compatible JSON-RPC HTTP URL. Mutually exclusive with `endpoints`. */\n rpcUrl?: string;\n /** A qorechain-sdk network endpoints object (uses `svmRpc`). */\n endpoints?: SvmEndpoints;\n /** Default commitment level for the connection. */\n commitment?: Commitment;\n /**\n * A preconstructed `Connection`. When provided it is used as-is and `rpcUrl`/\n * `endpoints`/`commitment` are ignored — primarily for testing.\n */\n connection?: Connection;\n}\n\n/** Arguments for building/sending a SOL transfer. */\nexport interface TransferSolArgs {\n /** Funding/source keypair (signer). */\n from: Keypair;\n /** Destination address. */\n to: PublicKey;\n /** Amount in lamports. */\n lamports: number | bigint;\n}\n\n/** A configured QoreChain SVM client bundle. */\nexport interface SvmClient {\n /** The underlying `@solana/web3.js` `Connection`. */\n connection: Connection;\n\n // --- Reads (thin wrappers over the JSON-RPC method set) ---\n /** Lamport balance for an account. */\n getBalance(pubkey: PublicKey, commitment?: Commitment): Promise<number>;\n /** Raw account info, or `null` if the account does not exist. */\n getAccountInfo(\n pubkey: PublicKey,\n commitment?: Commitment,\n ): Promise<AccountInfo<Buffer> | null>;\n /** Latest blockhash and last valid block height. */\n getLatestBlockhash(\n commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,\n ): Promise<{ blockhash: string; lastValidBlockHeight: number }>;\n /** Token accounts owned by `owner`, filtered by mint or program id. */\n getTokenAccountsByOwner(\n owner: PublicKey,\n filter: TokenAccountsFilter,\n commitment?: Commitment,\n ): ReturnType<Connection[\"getTokenAccountsByOwner\"]>;\n /** Confirmed signatures for transactions involving `address`. */\n getSignaturesForAddress(\n address: PublicKey,\n options?: Parameters<Connection[\"getSignaturesForAddress\"]>[1],\n ): ReturnType<Connection[\"getSignaturesForAddress\"]>;\n /** Request an airdrop of `lamports` to `pubkey` (testnet/devnet only). */\n requestAirdrop(pubkey: PublicKey, lamports: number): Promise<string>;\n\n // --- Transactions ---\n /** Build (unsigned, no blockhash) a SOL transfer transaction. */\n buildTransferSol(args: TransferSolArgs): Transaction;\n /** Build, sign, send, and confirm a SOL transfer. */\n transferSol(args: TransferSolArgs, options?: ConfirmOptions): Promise<string>;\n /** Sign, send, and confirm an arbitrary transaction. */\n sendTransaction(\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string>;\n /** Simulate a transaction without submitting it. */\n simulateTransaction(\n tx: Transaction,\n ): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;\n}\n\nfunction resolveConnection(opts: CreateSvmClientOptions): Connection {\n if (opts.connection) return opts.connection;\n const url = opts.rpcUrl ?? opts.endpoints?.svmRpc ?? DEFAULT_SVM_RPC_URL;\n return new Connection(url, opts.commitment ?? \"confirmed\");\n}\n\n/**\n * Create a QoreChain SVM client bundle.\n *\n * With no options it targets the testnet localhost endpoint\n * (`http://localhost:8899`) at `confirmed` commitment.\n */\nexport function createSvmClient(opts: CreateSvmClientOptions = {}): SvmClient {\n const connection = resolveConnection(opts);\n\n const buildTransferSol = (args: TransferSolArgs): Transaction => {\n const tx = new Transaction();\n tx.add(\n SystemProgram.transfer({\n fromPubkey: args.from.publicKey,\n toPubkey: args.to,\n lamports: args.lamports,\n }),\n );\n return tx;\n };\n\n const sendTransaction = (\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string> => sendAndConfirmTransaction(connection, tx, signers, options);\n\n return {\n connection,\n\n getBalance: (pubkey, commitment) => connection.getBalance(pubkey, commitment),\n getAccountInfo: (pubkey, commitment) =>\n connection.getAccountInfo(pubkey, commitment) as Promise<AccountInfo<Buffer> | null>,\n getLatestBlockhash: (commitmentOrConfig) =>\n connection.getLatestBlockhash(commitmentOrConfig),\n getTokenAccountsByOwner: (owner, filter, commitment) =>\n connection.getTokenAccountsByOwner(owner, filter, commitment),\n getSignaturesForAddress: (address, options) =>\n connection.getSignaturesForAddress(address, options),\n requestAirdrop: (pubkey, lamports) => connection.requestAirdrop(pubkey, lamports),\n\n buildTransferSol,\n transferSol: (args, options) =>\n sendTransaction(buildTransferSol(args), [args.from], options),\n sendTransaction,\n simulateTransaction: (tx): Promise<\n RpcResponseAndContext<SimulatedTransactionResponse>\n > =>\n // The single-arg overload signs/derives blockhash as needed for v1\n // legacy transactions.\n (connection.simulateTransaction as (\n t: Transaction,\n ) => Promise<RpcResponseAndContext<SimulatedTransactionResponse>>)(tx),\n };\n}\n\n// Re-export so callers can type their results without a direct dependency on the\n// peer's internal `SignatureResult` import path.\nexport type { SignatureResult };\n","/**\n * Key helpers for QoreChain's Solana-compatible runtime.\n *\n * These are thin wrappers over `@solana/web3.js` so callers don't need a second\n * import path. `@qorechain/sdk`'s `deriveSvmAccount(mnemonic)` provides the\n * 64-byte `secretKey` you can pass straight into {@link svmKeypairFromSecretKey}.\n */\n\nimport { Keypair, PublicKey } from \"@solana/web3.js\";\n\n/**\n * Reconstruct a `@solana/web3.js` `Keypair` from a 64-byte ed25519 secret key\n * (the standard Solana secret-key encoding: 32-byte seed + 32-byte public key).\n *\n * Pair with `@qorechain/sdk`'s `deriveSvmAccount`, which returns this exact\n * 64-byte `secretKey`.\n */\nexport function svmKeypairFromSecretKey(secretKey: Uint8Array): Keypair {\n if (secretKey.length !== 64) {\n throw new Error(\n `svmKeypairFromSecretKey: expected a 64-byte secret key, got ${secretKey.length}`,\n );\n }\n return Keypair.fromSecretKey(secretKey);\n}\n\n/** Return the base58 address for a `Keypair` or a `PublicKey`. */\nexport function svmAddress(key: Keypair | PublicKey): string {\n const pubkey = key instanceof PublicKey ? key : key.publicKey;\n return pubkey.toBase58();\n}\n","/**\n * Well-known native program ids for QoreChain's Solana-compatible runtime, plus\n * thin instruction builders for the Memo and SPL-Token programs and the\n * Associated Token Account program.\n *\n * The program ids are the exact canonical ones used by Solana-compatible\n * runtimes, so standard wallets, explorers, and tooling interoperate directly.\n * The SPL-Token / ATA / Memo instructions are built minimally here (by hand)\n * to keep the dependency surface to a single peer — `@solana/web3.js` — with no\n * `@solana/spl-token` requirement.\n */\n\nimport { PublicKey, TransactionInstruction, type AccountMeta } from \"@solana/web3.js\";\n\n/** System program (account creation, SOL transfers). */\nexport const SYSTEM_PROGRAM_ID = new PublicKey(\"11111111111111111111111111111111\");\n\n/** SPL-Token program. */\nexport const TOKEN_PROGRAM_ID = new PublicKey(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\");\n\n/** Associated Token Account program. */\nexport const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey(\n \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\",\n);\n\n/** SPL Memo program. */\nexport const MEMO_PROGRAM_ID = new PublicKey(\"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr\");\n\n/** Convenience grouping of the well-known program ids. */\nexport const PROGRAM_IDS = {\n system: SYSTEM_PROGRAM_ID,\n token: TOKEN_PROGRAM_ID,\n associatedToken: ASSOCIATED_TOKEN_PROGRAM_ID,\n memo: MEMO_PROGRAM_ID,\n} as const;\n\n/**\n * Build a Memo program instruction carrying `text` (encoded UTF-8).\n *\n * @param text Memo contents.\n * @param signers Optional accounts that must sign the memo; each is included as\n * a read-only signer (the Memo program's convention).\n */\nexport function createMemoInstruction(\n text: string,\n signers: PublicKey[] = [],\n): TransactionInstruction {\n return new TransactionInstruction({\n programId: MEMO_PROGRAM_ID,\n keys: signers.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n data: Buffer.from(text, \"utf8\"),\n });\n}\n\n/** Arguments for {@link createTransferTokenInstruction}. */\nexport interface TransferTokenInstructionArgs {\n /** Source SPL-Token account. */\n source: PublicKey;\n /** Destination SPL-Token account. */\n destination: PublicKey;\n /** Owner/authority of the source account (signer). */\n owner: PublicKey;\n /** Amount in the token's base units. */\n amount: bigint;\n /** Additional multisig signers, if `owner` is a multisig. */\n multiSigners?: PublicKey[];\n}\n\n/**\n * Build an SPL-Token `Transfer` instruction.\n *\n * Layout: 1 byte instruction discriminator (`3` = Transfer) followed by a\n * little-endian u64 amount.\n */\nexport function createTransferTokenInstruction(\n args: TransferTokenInstructionArgs,\n): TransactionInstruction {\n const { source, destination, owner, amount, multiSigners = [] } = args;\n\n const data = Buffer.alloc(9);\n data.writeUInt8(3, 0);\n data.writeBigUInt64LE(amount, 1);\n\n const keys: AccountMeta[] = [\n { pubkey: source, isSigner: false, isWritable: true },\n { pubkey: destination, isSigner: false, isWritable: true },\n {\n pubkey: owner,\n isSigner: multiSigners.length === 0,\n isWritable: false,\n },\n ...multiSigners.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n ];\n\n return new TransactionInstruction({ programId: TOKEN_PROGRAM_ID, keys, data });\n}\n\n/**\n * Derive the deterministic Associated Token Account (ATA) address for an owner\n * and mint under the SPL-Token program.\n */\nexport function getAssociatedTokenAddress(\n mint: PublicKey,\n owner: PublicKey,\n tokenProgramId: PublicKey = TOKEN_PROGRAM_ID,\n): PublicKey {\n const [address] = PublicKey.findProgramAddressSync(\n [owner.toBuffer(), tokenProgramId.toBuffer(), mint.toBuffer()],\n ASSOCIATED_TOKEN_PROGRAM_ID,\n );\n return address;\n}\n\n/** Arguments for {@link createAssociatedTokenAccountInstruction}. */\nexport interface CreateAssociatedTokenAccountInstructionArgs {\n /** Account funding the rent for the new ATA (signer, writable). */\n payer: PublicKey;\n /** Wallet that will own the new ATA. */\n owner: PublicKey;\n /** Token mint. */\n mint: PublicKey;\n /** SPL-Token program id (defaults to the canonical SPL-Token program). */\n tokenProgramId?: PublicKey;\n}\n\n/**\n * Build an instruction that creates the Associated Token Account for\n * `(owner, mint)`. The ATA address is derived deterministically.\n */\nexport function createAssociatedTokenAccountInstruction(\n args: CreateAssociatedTokenAccountInstructionArgs,\n): TransactionInstruction {\n const { payer, owner, mint, tokenProgramId = TOKEN_PROGRAM_ID } = args;\n const ata = getAssociatedTokenAddress(mint, owner, tokenProgramId);\n\n const keys: AccountMeta[] = [\n { pubkey: payer, isSigner: true, isWritable: true },\n { pubkey: ata, isSigner: false, isWritable: true },\n { pubkey: owner, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: false },\n { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },\n { pubkey: tokenProgramId, isSigner: false, isWritable: false },\n ];\n\n // The ATA \"Create\" instruction takes empty data (the idempotent variant uses\n // a single 0x01 byte; this is the plain create).\n return new TransactionInstruction({\n programId: ASSOCIATED_TOKEN_PROGRAM_ID,\n keys,\n data: Buffer.alloc(0),\n });\n}\n\n/**\n * Generic instruction builder for invoking an arbitrary on-chain program.\n *\n * Use this with {@link createSvmClient}'s `sendTransaction` to call a deployed\n * BPF program. Deploy programs with standard Solana tooling (e.g.\n * `solana program deploy`); this package intentionally does not wrap the loader.\n */\nexport function createInvokeInstruction(\n programId: PublicKey,\n keys: AccountMeta[],\n data: Uint8Array,\n): TransactionInstruction {\n return new TransactionInstruction({\n programId,\n keys,\n data: Buffer.from(data),\n });\n}\n","/**\n * SVM browser-wallet integration for QoreChain (Phantom and Wallet-Standard).\n *\n * Adapts an injected Solana provider (Phantom's `window.solana` is the baseline)\n * into a shape usable with `@solana/web3.js`, so apps can sign and send via the\n * existing SVM client.\n *\n * ```ts\n * import { getSvmWallet } from \"@qorechain/svm\";\n * import { createSvmClient } from \"@qorechain/svm\";\n *\n * const wallet = await getSvmWallet();\n * const signed = await wallet.signTransaction(tx);\n * // ...then send with createSvmClient(...).sendRawTransaction(...)\n * ```\n */\n\nimport type { PublicKey, Transaction, VersionedTransaction } from \"@solana/web3.js\";\n\n/** A transaction the wallet can sign (legacy or versioned). */\nexport type SvmSignableTransaction = Transaction | VersionedTransaction;\n\n/**\n * The minimal injected Solana-wallet surface used here. Phantom (and most\n * Wallet-Standard providers) implement at least these. Declared structurally so\n * no wallet types package is required.\n */\nexport interface InjectedSvmWallet {\n /** Phantom marker; present on the Phantom provider. */\n isPhantom?: boolean;\n /** Connect and return the account public key. */\n connect(opts?: { onlyIfTrusted?: boolean }): Promise<{ publicKey: PublicKey }>;\n /** Disconnect the wallet. */\n disconnect?(): Promise<void>;\n /** The connected account public key (populated after `connect`). */\n publicKey?: PublicKey | null;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions. */\n signAllTransactions?<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n}\n\n/** Window augmentation for the default injected Solana provider. */\ninterface SolanaWindow {\n solana?: InjectedSvmWallet;\n}\n\n/** Options for {@link getSvmWallet}. */\nexport interface GetSvmWalletOptions {\n /** The injected provider to use. Defaults to `window.solana` (Phantom). */\n provider?: InjectedSvmWallet;\n /** Pass through to the provider's `connect` (e.g. silent reconnect). */\n onlyIfTrusted?: boolean;\n}\n\n/**\n * A connected SVM wallet adapted for use with `@solana/web3.js`.\n *\n * `signTransaction` / `signAllTransactions` accept and return web3.js\n * `Transaction` / `VersionedTransaction` objects, so they drop into the existing\n * SVM client's send path.\n */\nexport interface SvmWalletConnection {\n /** The connected account public key. */\n publicKey: PublicKey;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions (falls back to sequential signing). */\n signAllTransactions<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n /** The underlying injected provider. */\n provider: InjectedSvmWallet;\n}\n\n/** Resolve the injected Solana provider from options or `window`, or throw. */\nfunction resolveProvider(provider?: InjectedSvmWallet): InjectedSvmWallet {\n if (provider) return provider;\n if (typeof window === \"undefined\") {\n throw new Error(\n \"getSvmWallet: no browser `window` available. Run in a browser, or pass `provider` explicitly.\",\n );\n }\n const injected = (window as unknown as SolanaWindow).solana;\n if (!injected) {\n throw new Error(\n \"getSvmWallet: no injected Solana provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n return injected;\n}\n\n/**\n * Connect to an injected Solana wallet (Phantom by default) and return an\n * adapter usable with `@solana/web3.js`.\n *\n * Browser-only: throws a clear error if no `window` or no injected provider.\n */\nexport async function getSvmWallet(\n opts: GetSvmWalletOptions = {},\n): Promise<SvmWalletConnection> {\n const provider = resolveProvider(opts.provider);\n const { publicKey } = await provider.connect(\n opts.onlyIfTrusted ? { onlyIfTrusted: true } : undefined,\n );\n if (!publicKey) {\n throw new Error(\"getSvmWallet: wallet connected but returned no public key\");\n }\n\n const signTransaction = <T extends SvmSignableTransaction>(tx: T): Promise<T> =>\n provider.signTransaction(tx);\n\n const signAllTransactions = async <T extends SvmSignableTransaction>(\n txs: T[],\n ): Promise<T[]> => {\n if (provider.signAllTransactions) return provider.signAllTransactions(txs);\n // Fall back to signing sequentially for providers without batch support.\n const out: T[] = [];\n for (const tx of txs) out.push(await provider.signTransaction(tx));\n return out;\n };\n\n return { publicKey, signTransaction, signAllTransactions, provider };\n}\n\n/**\n * Detect a Wallet-Standard / Phantom Solana provider on `window`.\n *\n * Returns the injected provider if present, else `undefined`. Phantom's\n * `window.solana` is the baseline; this is a light convenience for apps that\n * want to feature-detect before prompting a connection.\n */\nexport function detectSvmProvider(): InjectedSvmWallet | undefined {\n if (typeof window === \"undefined\") return undefined;\n return (window as unknown as SolanaWindow).solana;\n}\n","/**\n * Human-readable decoding of SVM (Solana-compatible) transaction errors.\n *\n * `@solana/web3.js` throws a `SendTransactionError` (and related shapes) whose\n * useful detail — the failing instruction index, a program's custom error code,\n * and the program logs — is spread across several fields that differ slightly\n * between library versions. {@link decodeSvmError} reads those fields\n * structurally (so it works across versions) and produces a flat summary with\n * the program logs and, where present, the failing instruction index.\n */\n\n/** A decoded SVM error. */\nexport interface DecodedSvmError {\n /** A readable summary message. */\n message: string;\n /** A short, stable kind discriminator. */\n kind: \"instruction_error\" | \"simulation\" | \"send\" | \"unknown\";\n /** Zero-based index of the failing instruction, when determinable. */\n instructionIndex?: number;\n /** A program's custom error code, when present in the logs. */\n customErrorCode?: number;\n /** The program logs, when available. */\n logs?: string[];\n}\n\n/** Read the program logs from the various shapes web3.js uses. */\nfunction extractLogs(err: unknown): string[] | undefined {\n const e = err as { logs?: unknown; transactionLogs?: unknown };\n const logs = e?.logs ?? e?.transactionLogs;\n if (Array.isArray(logs)) return logs as string[];\n return undefined;\n}\n\n/** Read a base message from the various shapes web3.js uses. */\nfunction extractMessage(err: unknown): string {\n const e = err as { transactionMessage?: unknown; message?: unknown };\n if (typeof e?.transactionMessage === \"string\" && e.transactionMessage) {\n return e.transactionMessage;\n }\n if (typeof e?.message === \"string\" && e.message) return e.message;\n return String(err);\n}\n\n/**\n * Parse the failing instruction index and a custom program error code from the\n * program logs, if either is present.\n *\n * Logs commonly contain a line like:\n * \"Program <id> failed: custom program error: 0x1\"\n * and the instruction index can appear as \"Error processing Instruction 2:\".\n */\nfunction parseFromLogs(logs: string[] | undefined): {\n instructionIndex?: number;\n customErrorCode?: number;\n} {\n if (!logs) return {};\n let instructionIndex: number | undefined;\n let customErrorCode: number | undefined;\n for (const line of logs) {\n const instr = /instruction\\s+#?(\\d+)/i.exec(line);\n if (instr) instructionIndex = Number(instr[1]);\n const custom = /custom program error:\\s*(0x[0-9a-fA-F]+|\\d+)/i.exec(line);\n if (custom) {\n customErrorCode = custom[1].startsWith(\"0x\")\n ? parseInt(custom[1], 16)\n : Number(custom[1]);\n }\n }\n return { instructionIndex, customErrorCode };\n}\n\n/**\n * Decode an SVM error thrown by `@solana/web3.js` into a readable, structured\n * form.\n *\n * @param error - The thrown error (a `SendTransactionError` or any value).\n */\nexport function decodeSvmError(error: unknown): DecodedSvmError {\n const logs = extractLogs(error);\n const base = extractMessage(error);\n const { instructionIndex, customErrorCode } = parseFromLogs(logs);\n\n const name = (error as { name?: string })?.name;\n const isSendError =\n name === \"SendTransactionError\" ||\n /simulation failed|transaction simulation/i.test(base);\n\n const parts: string[] = [base];\n if (instructionIndex !== undefined) {\n parts.push(`(failing instruction #${instructionIndex})`);\n }\n if (customErrorCode !== undefined) {\n parts.push(`(custom program error ${customErrorCode})`);\n }\n\n let kind: DecodedSvmError[\"kind\"];\n if (customErrorCode !== undefined || instructionIndex !== undefined) {\n kind = \"instruction_error\";\n } else if (isSendError) {\n kind = \"simulation\";\n } else if (error instanceof Error) {\n kind = \"send\";\n } else {\n kind = \"unknown\";\n }\n\n return {\n message: parts.join(\" \"),\n kind,\n instructionIndex,\n customErrorCode,\n logs,\n };\n}\n","/**\n * Real-time SVM subscriptions over the `@solana/web3.js` `Connection`.\n *\n * The `Connection` owns the websocket and its lifecycle; these helpers are thin\n * wrappers that register a listener and return both the numeric subscription id\n * and an `off()` function that removes it via the matching\n * `remove*Listener` call. This keeps callers from having to remember which\n * removal method pairs with which subscription.\n */\n\nimport type {\n AccountChangeCallback,\n Commitment,\n Connection,\n LogsCallback,\n LogsFilter,\n PublicKey,\n SlotChangeCallback,\n} from \"@solana/web3.js\";\n\n/** A registered subscription: its id and a function to remove it. */\nexport interface SvmSubscription {\n /** The numeric subscription id returned by `@solana/web3.js`. */\n id: number;\n /** Remove the listener (idempotent best-effort). */\n off(): Promise<void>;\n}\n\n/**\n * Subscribe to transaction logs matching `filter`.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param filter - A `LogsFilter` (`\"all\"`, `\"allWithVotes\"`, or a `PublicKey`).\n * @param callback - Invoked with each matching logs notification.\n * @param commitment - Optional commitment level.\n */\nexport function onLogs(\n connection: Connection,\n filter: LogsFilter,\n callback: LogsCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onLogs(filter, callback, commitment);\n return {\n id,\n off: () => connection.removeOnLogsListener(id),\n };\n}\n\n/**\n * Subscribe to changes of an account's data.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param pubkey - The account to watch.\n * @param callback - Invoked with each account change.\n * @param commitment - Optional commitment level.\n */\nexport function onAccountChange(\n connection: Connection,\n pubkey: PublicKey,\n callback: AccountChangeCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onAccountChange(pubkey, callback, commitment);\n return {\n id,\n off: () => connection.removeAccountChangeListener(id),\n };\n}\n\n/**\n * Subscribe to slot changes (new slots as they are processed).\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param callback - Invoked with each slot change.\n */\nexport function onSlotChange(\n connection: Connection,\n callback: SlotChangeCallback,\n): SvmSubscription {\n const id = connection.onSlotChange(callback);\n return {\n id,\n off: () => connection.removeSlotChangeListener(id),\n };\n}\n","/**\n * Compute-budget and priority-fee conveniences over `@solana/web3.js`.\n *\n * {@link withComputeBudget} prepends `ComputeBudgetProgram` instructions to a\n * legacy `Transaction` so it requests a compute-unit limit and pays a per-CU\n * priority price; {@link estimatePriorityFee} reads recent prioritization fees\n * from the RPC to suggest a `microLamports` price.\n */\n\nimport {\n ComputeBudgetProgram,\n type Connection,\n type PublicKey,\n type Transaction,\n} from \"@solana/web3.js\";\n\n/** Compute-budget options for {@link withComputeBudget}. */\nexport interface ComputeBudgetOptions {\n /** Compute-unit limit to request (`setComputeUnitLimit`). */\n units?: number;\n /** Per-compute-unit price in micro-lamports (`setComputeUnitPrice`). */\n microLamports?: number | bigint;\n}\n\n/**\n * Prepend `ComputeBudgetProgram` instructions to `tx` (mutating it in place and\n * returning it). A unit-limit instruction is added when `units` is given, and a\n * unit-price instruction when `microLamports` is given; both are inserted at the\n * front of the instruction list, as required by the runtime.\n *\n * @returns The same `tx`, for chaining.\n */\nexport function withComputeBudget(\n tx: Transaction,\n options: ComputeBudgetOptions,\n): Transaction {\n const { units, microLamports } = options;\n const prepend = [];\n if (microLamports !== undefined) {\n prepend.unshift(\n ComputeBudgetProgram.setComputeUnitPrice({ microLamports }),\n );\n }\n if (units !== undefined) {\n prepend.unshift(ComputeBudgetProgram.setComputeUnitLimit({ units }));\n }\n tx.instructions.unshift(...prepend);\n return tx;\n}\n\n/**\n * Estimate a priority fee (`microLamports` per CU) from the RPC's\n * `getRecentPrioritizationFees`. Returns the maximum recently observed fee,\n * which is a conservative choice for landing a transaction quickly. Returns `0`\n * when the RPC reports no recent fees.\n *\n * @param connection - SVM RPC connection.\n * @param accounts - Optional accounts the tx will lock, scoping the query.\n */\nexport async function estimatePriorityFee(\n connection: Connection,\n accounts: readonly PublicKey[] = [],\n): Promise<number> {\n const fees = await connection.getRecentPrioritizationFees(\n accounts.length > 0 ? { lockedWritableAccounts: [...accounts] } : undefined,\n );\n if (!fees || fees.length === 0) return 0;\n return fees.reduce((max, f) => Math.max(max, f.prioritizationFee), 0);\n}\n\n/** Namespaced compute-budget / fee helpers. */\nexport const fees = {\n withComputeBudget,\n estimatePriorityFee,\n} as const;\n","/**\n * `@qorechain/svm` — a thin, type-safe adapter over\n * [`@solana/web3.js`](https://solana-labs.github.io/solana-web3.js/) for\n * QoreChain's Solana-compatible JSON-RPC.\n *\n * It does not reimplement an SVM client; `@solana/web3.js` is a peer dependency.\n * This package adds QoreChain-specific conveniences: a client factory targeting\n * the SVM RPC endpoint, key helpers, typed read wrappers, SOL transfer\n * build/sign/send, and minimal native-program instruction builders (Memo,\n * SPL-Token, Associated Token Account) plus a generic program-invoke builder.\n */\n\n/** Package version. */\nexport const VERSION = \"0.5.0\";\n\nexport {\n createSvmClient,\n DEFAULT_SVM_RPC_URL,\n type CreateSvmClientOptions,\n type SvmClient,\n type SvmEndpoints,\n type TransferSolArgs,\n type SignatureResult,\n} from \"./client\";\n\nexport { svmKeypairFromSecretKey, svmAddress } from \"./keys\";\n\nexport {\n PROGRAM_IDS,\n SYSTEM_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n ASSOCIATED_TOKEN_PROGRAM_ID,\n MEMO_PROGRAM_ID,\n createMemoInstruction,\n createTransferTokenInstruction,\n createAssociatedTokenAccountInstruction,\n getAssociatedTokenAddress,\n createInvokeInstruction,\n type TransferTokenInstructionArgs,\n type CreateAssociatedTokenAccountInstructionArgs,\n} from \"./programs\";\n\nexport {\n getSvmWallet,\n detectSvmProvider,\n type InjectedSvmWallet,\n type GetSvmWalletOptions,\n type SvmWalletConnection,\n type SvmSignableTransaction,\n} from \"./wallet\";\n\nexport { decodeSvmError, type DecodedSvmError } from \"./errors\";\n\nexport {\n onLogs,\n onAccountChange,\n onSlotChange,\n type SvmSubscription,\n} from \"./subscribe\";\n\nexport {\n fees,\n withComputeBudget,\n estimatePriorityFee,\n type ComputeBudgetOptions,\n} from \"./fees\";\n"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -391,6 +391,6 @@ declare const fees: {
|
|
|
391
391
|
* SPL-Token, Associated Token Account) plus a generic program-invoke builder.
|
|
392
392
|
*/
|
|
393
393
|
/** Package version. */
|
|
394
|
-
declare const VERSION = "0.
|
|
394
|
+
declare const VERSION = "0.5.0";
|
|
395
395
|
|
|
396
396
|
export { ASSOCIATED_TOKEN_PROGRAM_ID, type ComputeBudgetOptions, type CreateAssociatedTokenAccountInstructionArgs, type CreateSvmClientOptions, DEFAULT_SVM_RPC_URL, type DecodedSvmError, type GetSvmWalletOptions, type InjectedSvmWallet, MEMO_PROGRAM_ID, PROGRAM_IDS, SYSTEM_PROGRAM_ID, type SvmClient, type SvmEndpoints, type SvmSignableTransaction, type SvmSubscription, type SvmWalletConnection, TOKEN_PROGRAM_ID, type TransferSolArgs, type TransferTokenInstructionArgs, VERSION, createAssociatedTokenAccountInstruction, createInvokeInstruction, createMemoInstruction, createSvmClient, createTransferTokenInstruction, decodeSvmError, detectSvmProvider, estimatePriorityFee, fees, getAssociatedTokenAddress, getSvmWallet, onAccountChange, onLogs, onSlotChange, svmAddress, svmKeypairFromSecretKey, withComputeBudget };
|
package/dist/index.d.ts
CHANGED
|
@@ -391,6 +391,6 @@ declare const fees: {
|
|
|
391
391
|
* SPL-Token, Associated Token Account) plus a generic program-invoke builder.
|
|
392
392
|
*/
|
|
393
393
|
/** Package version. */
|
|
394
|
-
declare const VERSION = "0.
|
|
394
|
+
declare const VERSION = "0.5.0";
|
|
395
395
|
|
|
396
396
|
export { ASSOCIATED_TOKEN_PROGRAM_ID, type ComputeBudgetOptions, type CreateAssociatedTokenAccountInstructionArgs, type CreateSvmClientOptions, DEFAULT_SVM_RPC_URL, type DecodedSvmError, type GetSvmWalletOptions, type InjectedSvmWallet, MEMO_PROGRAM_ID, PROGRAM_IDS, SYSTEM_PROGRAM_ID, type SvmClient, type SvmEndpoints, type SvmSignableTransaction, type SvmSubscription, type SvmWalletConnection, TOKEN_PROGRAM_ID, type TransferSolArgs, type TransferTokenInstructionArgs, VERSION, createAssociatedTokenAccountInstruction, createInvokeInstruction, createMemoInstruction, createSvmClient, createTransferTokenInstruction, decodeSvmError, detectSvmProvider, estimatePriorityFee, fees, getAssociatedTokenAddress, getSvmWallet, onAccountChange, onLogs, onSlotChange, svmAddress, svmKeypairFromSecretKey, withComputeBudget };
|
package/dist/index.js
CHANGED
|
@@ -267,7 +267,7 @@ var fees = {
|
|
|
267
267
|
};
|
|
268
268
|
|
|
269
269
|
// src/index.ts
|
|
270
|
-
var VERSION = "0.
|
|
270
|
+
var VERSION = "0.5.0";
|
|
271
271
|
|
|
272
272
|
export { ASSOCIATED_TOKEN_PROGRAM_ID, DEFAULT_SVM_RPC_URL, MEMO_PROGRAM_ID, PROGRAM_IDS, SYSTEM_PROGRAM_ID, TOKEN_PROGRAM_ID, VERSION, createAssociatedTokenAccountInstruction, createInvokeInstruction, createMemoInstruction, createSvmClient, createTransferTokenInstruction, decodeSvmError, detectSvmProvider, estimatePriorityFee, fees, getAssociatedTokenAddress, getSvmWallet, onAccountChange, onLogs, onSlotChange, svmAddress, svmKeypairFromSecretKey, withComputeBudget };
|
|
273
273
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/client.ts","../src/keys.ts","../src/programs.ts","../src/wallet.ts","../src/errors.ts","../src/subscribe.ts","../src/fees.ts","../src/index.ts"],"names":["PublicKey","fees"],"mappings":";;;AAmCO,IAAM,mBAAA,GAAsB;AA2EnC,SAAS,kBAAkB,IAAA,EAA0C;AACnE,EAAA,IAAI,IAAA,CAAK,UAAA,EAAY,OAAO,IAAA,CAAK,UAAA;AACjC,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,MAAA,IAAU,IAAA,CAAK,WAAW,MAAA,IAAU,mBAAA;AACrD,EAAA,OAAO,IAAI,UAAA,CAAW,GAAA,EAAK,IAAA,CAAK,cAAc,WAAW,CAAA;AAC3D;AAQO,SAAS,eAAA,CAAgB,IAAA,GAA+B,EAAC,EAAc;AAC5E,EAAA,MAAM,UAAA,GAAa,kBAAkB,IAAI,CAAA;AAEzC,EAAA,MAAM,gBAAA,GAAmB,CAAC,IAAA,KAAuC;AAC/D,IAAA,MAAM,EAAA,GAAK,IAAI,WAAA,EAAY;AAC3B,IAAA,EAAA,CAAG,GAAA;AAAA,MACD,cAAc,QAAA,CAAS;AAAA,QACrB,UAAA,EAAY,KAAK,IAAA,CAAK,SAAA;AAAA,QACtB,UAAU,IAAA,CAAK,EAAA;AAAA,QACf,UAAU,IAAA,CAAK;AAAA,OAChB;AAAA,KACH;AACA,IAAA,OAAO,EAAA;AAAA,EACT,CAAA;AAEA,EAAA,MAAM,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AK,CAAA,CAAE,iBAAiB,CAAA,EAAG,CAAC,CAAA;AACtE;AAGO,IAAM,IAAA,GAAO;AAAA,EAClB,iBAAA;AAAA,EACA;AACF;;;AC7DO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["/**\n * Client factory for QoreChain's Solana-compatible JSON-RPC.\n *\n * This is a thin convenience layer over `@solana/web3.js`: it builds (or accepts)\n * a `Connection` bound to the network's SVM RPC endpoint and exposes typed\n * wrappers over the documented Solana-compatible JSON-RPC method set plus\n * transaction build/sign/send helpers.\n *\n * `@solana/web3.js` is a peer dependency; nothing here reimplements it.\n */\n\nimport {\n Connection,\n PublicKey,\n SystemProgram,\n Transaction,\n sendAndConfirmTransaction,\n type AccountInfo,\n type Commitment,\n type ConfirmOptions,\n type GetLatestBlockhashConfig,\n type Keypair,\n type RpcResponseAndContext,\n type SignatureResult,\n type SimulatedTransactionResponse,\n type TokenAccountsFilter,\n} from \"@solana/web3.js\";\n\n/** Subset of a qorechain-sdk network's endpoints relevant to the SVM runtime. */\nexport interface SvmEndpoints {\n /** Solana-compatible JSON-RPC HTTP endpoint. */\n svmRpc: string;\n}\n\n/** Default testnet SVM RPC endpoint (Solana-compatible JSON-RPC, port 8899). */\nexport const DEFAULT_SVM_RPC_URL = \"http://localhost:8899\";\n\n/** Options for {@link createSvmClient}. */\nexport interface CreateSvmClientOptions {\n /** Solana-compatible JSON-RPC HTTP URL. Mutually exclusive with `endpoints`. */\n rpcUrl?: string;\n /** A qorechain-sdk network endpoints object (uses `svmRpc`). */\n endpoints?: SvmEndpoints;\n /** Default commitment level for the connection. */\n commitment?: Commitment;\n /**\n * A preconstructed `Connection`. When provided it is used as-is and `rpcUrl`/\n * `endpoints`/`commitment` are ignored — primarily for testing.\n */\n connection?: Connection;\n}\n\n/** Arguments for building/sending a SOL transfer. */\nexport interface TransferSolArgs {\n /** Funding/source keypair (signer). */\n from: Keypair;\n /** Destination address. */\n to: PublicKey;\n /** Amount in lamports. */\n lamports: number | bigint;\n}\n\n/** A configured QoreChain SVM client bundle. */\nexport interface SvmClient {\n /** The underlying `@solana/web3.js` `Connection`. */\n connection: Connection;\n\n // --- Reads (thin wrappers over the JSON-RPC method set) ---\n /** Lamport balance for an account. */\n getBalance(pubkey: PublicKey, commitment?: Commitment): Promise<number>;\n /** Raw account info, or `null` if the account does not exist. */\n getAccountInfo(\n pubkey: PublicKey,\n commitment?: Commitment,\n ): Promise<AccountInfo<Buffer> | null>;\n /** Latest blockhash and last valid block height. */\n getLatestBlockhash(\n commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,\n ): Promise<{ blockhash: string; lastValidBlockHeight: number }>;\n /** Token accounts owned by `owner`, filtered by mint or program id. */\n getTokenAccountsByOwner(\n owner: PublicKey,\n filter: TokenAccountsFilter,\n commitment?: Commitment,\n ): ReturnType<Connection[\"getTokenAccountsByOwner\"]>;\n /** Confirmed signatures for transactions involving `address`. */\n getSignaturesForAddress(\n address: PublicKey,\n options?: Parameters<Connection[\"getSignaturesForAddress\"]>[1],\n ): ReturnType<Connection[\"getSignaturesForAddress\"]>;\n /** Request an airdrop of `lamports` to `pubkey` (testnet/devnet only). */\n requestAirdrop(pubkey: PublicKey, lamports: number): Promise<string>;\n\n // --- Transactions ---\n /** Build (unsigned, no blockhash) a SOL transfer transaction. */\n buildTransferSol(args: TransferSolArgs): Transaction;\n /** Build, sign, send, and confirm a SOL transfer. */\n transferSol(args: TransferSolArgs, options?: ConfirmOptions): Promise<string>;\n /** Sign, send, and confirm an arbitrary transaction. */\n sendTransaction(\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string>;\n /** Simulate a transaction without submitting it. */\n simulateTransaction(\n tx: Transaction,\n ): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;\n}\n\nfunction resolveConnection(opts: CreateSvmClientOptions): Connection {\n if (opts.connection) return opts.connection;\n const url = opts.rpcUrl ?? opts.endpoints?.svmRpc ?? DEFAULT_SVM_RPC_URL;\n return new Connection(url, opts.commitment ?? \"confirmed\");\n}\n\n/**\n * Create a QoreChain SVM client bundle.\n *\n * With no options it targets the testnet localhost endpoint\n * (`http://localhost:8899`) at `confirmed` commitment.\n */\nexport function createSvmClient(opts: CreateSvmClientOptions = {}): SvmClient {\n const connection = resolveConnection(opts);\n\n const buildTransferSol = (args: TransferSolArgs): Transaction => {\n const tx = new Transaction();\n tx.add(\n SystemProgram.transfer({\n fromPubkey: args.from.publicKey,\n toPubkey: args.to,\n lamports: args.lamports,\n }),\n );\n return tx;\n };\n\n const sendTransaction = (\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string> => sendAndConfirmTransaction(connection, tx, signers, options);\n\n return {\n connection,\n\n getBalance: (pubkey, commitment) => connection.getBalance(pubkey, commitment),\n getAccountInfo: (pubkey, commitment) =>\n connection.getAccountInfo(pubkey, commitment) as Promise<AccountInfo<Buffer> | null>,\n getLatestBlockhash: (commitmentOrConfig) =>\n connection.getLatestBlockhash(commitmentOrConfig),\n getTokenAccountsByOwner: (owner, filter, commitment) =>\n connection.getTokenAccountsByOwner(owner, filter, commitment),\n getSignaturesForAddress: (address, options) =>\n connection.getSignaturesForAddress(address, options),\n requestAirdrop: (pubkey, lamports) => connection.requestAirdrop(pubkey, lamports),\n\n buildTransferSol,\n transferSol: (args, options) =>\n sendTransaction(buildTransferSol(args), [args.from], options),\n sendTransaction,\n simulateTransaction: (tx): Promise<\n RpcResponseAndContext<SimulatedTransactionResponse>\n > =>\n // The single-arg overload signs/derives blockhash as needed for v1\n // legacy transactions.\n (connection.simulateTransaction as (\n t: Transaction,\n ) => Promise<RpcResponseAndContext<SimulatedTransactionResponse>>)(tx),\n };\n}\n\n// Re-export so callers can type their results without a direct dependency on the\n// peer's internal `SignatureResult` import path.\nexport type { SignatureResult };\n","/**\n * Key helpers for QoreChain's Solana-compatible runtime.\n *\n * These are thin wrappers over `@solana/web3.js` so callers don't need a second\n * import path. `@qorechain/sdk`'s `deriveSvmAccount(mnemonic)` provides the\n * 64-byte `secretKey` you can pass straight into {@link svmKeypairFromSecretKey}.\n */\n\nimport { Keypair, PublicKey } from \"@solana/web3.js\";\n\n/**\n * Reconstruct a `@solana/web3.js` `Keypair` from a 64-byte ed25519 secret key\n * (the standard Solana secret-key encoding: 32-byte seed + 32-byte public key).\n *\n * Pair with `@qorechain/sdk`'s `deriveSvmAccount`, which returns this exact\n * 64-byte `secretKey`.\n */\nexport function svmKeypairFromSecretKey(secretKey: Uint8Array): Keypair {\n if (secretKey.length !== 64) {\n throw new Error(\n `svmKeypairFromSecretKey: expected a 64-byte secret key, got ${secretKey.length}`,\n );\n }\n return Keypair.fromSecretKey(secretKey);\n}\n\n/** Return the base58 address for a `Keypair` or a `PublicKey`. */\nexport function svmAddress(key: Keypair | PublicKey): string {\n const pubkey = key instanceof PublicKey ? key : key.publicKey;\n return pubkey.toBase58();\n}\n","/**\n * Well-known native program ids for QoreChain's Solana-compatible runtime, plus\n * thin instruction builders for the Memo and SPL-Token programs and the\n * Associated Token Account program.\n *\n * The program ids are the exact canonical ones used by Solana-compatible\n * runtimes, so standard wallets, explorers, and tooling interoperate directly.\n * The SPL-Token / ATA / Memo instructions are built minimally here (by hand)\n * to keep the dependency surface to a single peer — `@solana/web3.js` — with no\n * `@solana/spl-token` requirement.\n */\n\nimport { PublicKey, TransactionInstruction, type AccountMeta } from \"@solana/web3.js\";\n\n/** System program (account creation, SOL transfers). */\nexport const SYSTEM_PROGRAM_ID = new PublicKey(\"11111111111111111111111111111111\");\n\n/** SPL-Token program. */\nexport const TOKEN_PROGRAM_ID = new PublicKey(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\");\n\n/** Associated Token Account program. */\nexport const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey(\n \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\",\n);\n\n/** SPL Memo program. */\nexport const MEMO_PROGRAM_ID = new PublicKey(\"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr\");\n\n/** Convenience grouping of the well-known program ids. */\nexport const PROGRAM_IDS = {\n system: SYSTEM_PROGRAM_ID,\n token: TOKEN_PROGRAM_ID,\n associatedToken: ASSOCIATED_TOKEN_PROGRAM_ID,\n memo: MEMO_PROGRAM_ID,\n} as const;\n\n/**\n * Build a Memo program instruction carrying `text` (encoded UTF-8).\n *\n * @param text Memo contents.\n * @param signers Optional accounts that must sign the memo; each is included as\n * a read-only signer (the Memo program's convention).\n */\nexport function createMemoInstruction(\n text: string,\n signers: PublicKey[] = [],\n): TransactionInstruction {\n return new TransactionInstruction({\n programId: MEMO_PROGRAM_ID,\n keys: signers.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n data: Buffer.from(text, \"utf8\"),\n });\n}\n\n/** Arguments for {@link createTransferTokenInstruction}. */\nexport interface TransferTokenInstructionArgs {\n /** Source SPL-Token account. */\n source: PublicKey;\n /** Destination SPL-Token account. */\n destination: PublicKey;\n /** Owner/authority of the source account (signer). */\n owner: PublicKey;\n /** Amount in the token's base units. */\n amount: bigint;\n /** Additional multisig signers, if `owner` is a multisig. */\n multiSigners?: PublicKey[];\n}\n\n/**\n * Build an SPL-Token `Transfer` instruction.\n *\n * Layout: 1 byte instruction discriminator (`3` = Transfer) followed by a\n * little-endian u64 amount.\n */\nexport function createTransferTokenInstruction(\n args: TransferTokenInstructionArgs,\n): TransactionInstruction {\n const { source, destination, owner, amount, multiSigners = [] } = args;\n\n const data = Buffer.alloc(9);\n data.writeUInt8(3, 0);\n data.writeBigUInt64LE(amount, 1);\n\n const keys: AccountMeta[] = [\n { pubkey: source, isSigner: false, isWritable: true },\n { pubkey: destination, isSigner: false, isWritable: true },\n {\n pubkey: owner,\n isSigner: multiSigners.length === 0,\n isWritable: false,\n },\n ...multiSigners.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n ];\n\n return new TransactionInstruction({ programId: TOKEN_PROGRAM_ID, keys, data });\n}\n\n/**\n * Derive the deterministic Associated Token Account (ATA) address for an owner\n * and mint under the SPL-Token program.\n */\nexport function getAssociatedTokenAddress(\n mint: PublicKey,\n owner: PublicKey,\n tokenProgramId: PublicKey = TOKEN_PROGRAM_ID,\n): PublicKey {\n const [address] = PublicKey.findProgramAddressSync(\n [owner.toBuffer(), tokenProgramId.toBuffer(), mint.toBuffer()],\n ASSOCIATED_TOKEN_PROGRAM_ID,\n );\n return address;\n}\n\n/** Arguments for {@link createAssociatedTokenAccountInstruction}. */\nexport interface CreateAssociatedTokenAccountInstructionArgs {\n /** Account funding the rent for the new ATA (signer, writable). */\n payer: PublicKey;\n /** Wallet that will own the new ATA. */\n owner: PublicKey;\n /** Token mint. */\n mint: PublicKey;\n /** SPL-Token program id (defaults to the canonical SPL-Token program). */\n tokenProgramId?: PublicKey;\n}\n\n/**\n * Build an instruction that creates the Associated Token Account for\n * `(owner, mint)`. The ATA address is derived deterministically.\n */\nexport function createAssociatedTokenAccountInstruction(\n args: CreateAssociatedTokenAccountInstructionArgs,\n): TransactionInstruction {\n const { payer, owner, mint, tokenProgramId = TOKEN_PROGRAM_ID } = args;\n const ata = getAssociatedTokenAddress(mint, owner, tokenProgramId);\n\n const keys: AccountMeta[] = [\n { pubkey: payer, isSigner: true, isWritable: true },\n { pubkey: ata, isSigner: false, isWritable: true },\n { pubkey: owner, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: false },\n { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },\n { pubkey: tokenProgramId, isSigner: false, isWritable: false },\n ];\n\n // The ATA \"Create\" instruction takes empty data (the idempotent variant uses\n // a single 0x01 byte; this is the plain create).\n return new TransactionInstruction({\n programId: ASSOCIATED_TOKEN_PROGRAM_ID,\n keys,\n data: Buffer.alloc(0),\n });\n}\n\n/**\n * Generic instruction builder for invoking an arbitrary on-chain program.\n *\n * Use this with {@link createSvmClient}'s `sendTransaction` to call a deployed\n * BPF program. Deploy programs with standard Solana tooling (e.g.\n * `solana program deploy`); this package intentionally does not wrap the loader.\n */\nexport function createInvokeInstruction(\n programId: PublicKey,\n keys: AccountMeta[],\n data: Uint8Array,\n): TransactionInstruction {\n return new TransactionInstruction({\n programId,\n keys,\n data: Buffer.from(data),\n });\n}\n","/**\n * SVM browser-wallet integration for QoreChain (Phantom and Wallet-Standard).\n *\n * Adapts an injected Solana provider (Phantom's `window.solana` is the baseline)\n * into a shape usable with `@solana/web3.js`, so apps can sign and send via the\n * existing SVM client.\n *\n * ```ts\n * import { getSvmWallet } from \"@qorechain/svm\";\n * import { createSvmClient } from \"@qorechain/svm\";\n *\n * const wallet = await getSvmWallet();\n * const signed = await wallet.signTransaction(tx);\n * // ...then send with createSvmClient(...).sendRawTransaction(...)\n * ```\n */\n\nimport type { PublicKey, Transaction, VersionedTransaction } from \"@solana/web3.js\";\n\n/** A transaction the wallet can sign (legacy or versioned). */\nexport type SvmSignableTransaction = Transaction | VersionedTransaction;\n\n/**\n * The minimal injected Solana-wallet surface used here. Phantom (and most\n * Wallet-Standard providers) implement at least these. Declared structurally so\n * no wallet types package is required.\n */\nexport interface InjectedSvmWallet {\n /** Phantom marker; present on the Phantom provider. */\n isPhantom?: boolean;\n /** Connect and return the account public key. */\n connect(opts?: { onlyIfTrusted?: boolean }): Promise<{ publicKey: PublicKey }>;\n /** Disconnect the wallet. */\n disconnect?(): Promise<void>;\n /** The connected account public key (populated after `connect`). */\n publicKey?: PublicKey | null;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions. */\n signAllTransactions?<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n}\n\n/** Window augmentation for the default injected Solana provider. */\ninterface SolanaWindow {\n solana?: InjectedSvmWallet;\n}\n\n/** Options for {@link getSvmWallet}. */\nexport interface GetSvmWalletOptions {\n /** The injected provider to use. Defaults to `window.solana` (Phantom). */\n provider?: InjectedSvmWallet;\n /** Pass through to the provider's `connect` (e.g. silent reconnect). */\n onlyIfTrusted?: boolean;\n}\n\n/**\n * A connected SVM wallet adapted for use with `@solana/web3.js`.\n *\n * `signTransaction` / `signAllTransactions` accept and return web3.js\n * `Transaction` / `VersionedTransaction` objects, so they drop into the existing\n * SVM client's send path.\n */\nexport interface SvmWalletConnection {\n /** The connected account public key. */\n publicKey: PublicKey;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions (falls back to sequential signing). */\n signAllTransactions<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n /** The underlying injected provider. */\n provider: InjectedSvmWallet;\n}\n\n/** Resolve the injected Solana provider from options or `window`, or throw. */\nfunction resolveProvider(provider?: InjectedSvmWallet): InjectedSvmWallet {\n if (provider) return provider;\n if (typeof window === \"undefined\") {\n throw new Error(\n \"getSvmWallet: no browser `window` available. Run in a browser, or pass `provider` explicitly.\",\n );\n }\n const injected = (window as unknown as SolanaWindow).solana;\n if (!injected) {\n throw new Error(\n \"getSvmWallet: no injected Solana provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n return injected;\n}\n\n/**\n * Connect to an injected Solana wallet (Phantom by default) and return an\n * adapter usable with `@solana/web3.js`.\n *\n * Browser-only: throws a clear error if no `window` or no injected provider.\n */\nexport async function getSvmWallet(\n opts: GetSvmWalletOptions = {},\n): Promise<SvmWalletConnection> {\n const provider = resolveProvider(opts.provider);\n const { publicKey } = await provider.connect(\n opts.onlyIfTrusted ? { onlyIfTrusted: true } : undefined,\n );\n if (!publicKey) {\n throw new Error(\"getSvmWallet: wallet connected but returned no public key\");\n }\n\n const signTransaction = <T extends SvmSignableTransaction>(tx: T): Promise<T> =>\n provider.signTransaction(tx);\n\n const signAllTransactions = async <T extends SvmSignableTransaction>(\n txs: T[],\n ): Promise<T[]> => {\n if (provider.signAllTransactions) return provider.signAllTransactions(txs);\n // Fall back to signing sequentially for providers without batch support.\n const out: T[] = [];\n for (const tx of txs) out.push(await provider.signTransaction(tx));\n return out;\n };\n\n return { publicKey, signTransaction, signAllTransactions, provider };\n}\n\n/**\n * Detect a Wallet-Standard / Phantom Solana provider on `window`.\n *\n * Returns the injected provider if present, else `undefined`. Phantom's\n * `window.solana` is the baseline; this is a light convenience for apps that\n * want to feature-detect before prompting a connection.\n */\nexport function detectSvmProvider(): InjectedSvmWallet | undefined {\n if (typeof window === \"undefined\") return undefined;\n return (window as unknown as SolanaWindow).solana;\n}\n","/**\n * Human-readable decoding of SVM (Solana-compatible) transaction errors.\n *\n * `@solana/web3.js` throws a `SendTransactionError` (and related shapes) whose\n * useful detail — the failing instruction index, a program's custom error code,\n * and the program logs — is spread across several fields that differ slightly\n * between library versions. {@link decodeSvmError} reads those fields\n * structurally (so it works across versions) and produces a flat summary with\n * the program logs and, where present, the failing instruction index.\n */\n\n/** A decoded SVM error. */\nexport interface DecodedSvmError {\n /** A readable summary message. */\n message: string;\n /** A short, stable kind discriminator. */\n kind: \"instruction_error\" | \"simulation\" | \"send\" | \"unknown\";\n /** Zero-based index of the failing instruction, when determinable. */\n instructionIndex?: number;\n /** A program's custom error code, when present in the logs. */\n customErrorCode?: number;\n /** The program logs, when available. */\n logs?: string[];\n}\n\n/** Read the program logs from the various shapes web3.js uses. */\nfunction extractLogs(err: unknown): string[] | undefined {\n const e = err as { logs?: unknown; transactionLogs?: unknown };\n const logs = e?.logs ?? e?.transactionLogs;\n if (Array.isArray(logs)) return logs as string[];\n return undefined;\n}\n\n/** Read a base message from the various shapes web3.js uses. */\nfunction extractMessage(err: unknown): string {\n const e = err as { transactionMessage?: unknown; message?: unknown };\n if (typeof e?.transactionMessage === \"string\" && e.transactionMessage) {\n return e.transactionMessage;\n }\n if (typeof e?.message === \"string\" && e.message) return e.message;\n return String(err);\n}\n\n/**\n * Parse the failing instruction index and a custom program error code from the\n * program logs, if either is present.\n *\n * Logs commonly contain a line like:\n * \"Program <id> failed: custom program error: 0x1\"\n * and the instruction index can appear as \"Error processing Instruction 2:\".\n */\nfunction parseFromLogs(logs: string[] | undefined): {\n instructionIndex?: number;\n customErrorCode?: number;\n} {\n if (!logs) return {};\n let instructionIndex: number | undefined;\n let customErrorCode: number | undefined;\n for (const line of logs) {\n const instr = /instruction\\s+#?(\\d+)/i.exec(line);\n if (instr) instructionIndex = Number(instr[1]);\n const custom = /custom program error:\\s*(0x[0-9a-fA-F]+|\\d+)/i.exec(line);\n if (custom) {\n customErrorCode = custom[1].startsWith(\"0x\")\n ? parseInt(custom[1], 16)\n : Number(custom[1]);\n }\n }\n return { instructionIndex, customErrorCode };\n}\n\n/**\n * Decode an SVM error thrown by `@solana/web3.js` into a readable, structured\n * form.\n *\n * @param error - The thrown error (a `SendTransactionError` or any value).\n */\nexport function decodeSvmError(error: unknown): DecodedSvmError {\n const logs = extractLogs(error);\n const base = extractMessage(error);\n const { instructionIndex, customErrorCode } = parseFromLogs(logs);\n\n const name = (error as { name?: string })?.name;\n const isSendError =\n name === \"SendTransactionError\" ||\n /simulation failed|transaction simulation/i.test(base);\n\n const parts: string[] = [base];\n if (instructionIndex !== undefined) {\n parts.push(`(failing instruction #${instructionIndex})`);\n }\n if (customErrorCode !== undefined) {\n parts.push(`(custom program error ${customErrorCode})`);\n }\n\n let kind: DecodedSvmError[\"kind\"];\n if (customErrorCode !== undefined || instructionIndex !== undefined) {\n kind = \"instruction_error\";\n } else if (isSendError) {\n kind = \"simulation\";\n } else if (error instanceof Error) {\n kind = \"send\";\n } else {\n kind = \"unknown\";\n }\n\n return {\n message: parts.join(\" \"),\n kind,\n instructionIndex,\n customErrorCode,\n logs,\n };\n}\n","/**\n * Real-time SVM subscriptions over the `@solana/web3.js` `Connection`.\n *\n * The `Connection` owns the websocket and its lifecycle; these helpers are thin\n * wrappers that register a listener and return both the numeric subscription id\n * and an `off()` function that removes it via the matching\n * `remove*Listener` call. This keeps callers from having to remember which\n * removal method pairs with which subscription.\n */\n\nimport type {\n AccountChangeCallback,\n Commitment,\n Connection,\n LogsCallback,\n LogsFilter,\n PublicKey,\n SlotChangeCallback,\n} from \"@solana/web3.js\";\n\n/** A registered subscription: its id and a function to remove it. */\nexport interface SvmSubscription {\n /** The numeric subscription id returned by `@solana/web3.js`. */\n id: number;\n /** Remove the listener (idempotent best-effort). */\n off(): Promise<void>;\n}\n\n/**\n * Subscribe to transaction logs matching `filter`.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param filter - A `LogsFilter` (`\"all\"`, `\"allWithVotes\"`, or a `PublicKey`).\n * @param callback - Invoked with each matching logs notification.\n * @param commitment - Optional commitment level.\n */\nexport function onLogs(\n connection: Connection,\n filter: LogsFilter,\n callback: LogsCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onLogs(filter, callback, commitment);\n return {\n id,\n off: () => connection.removeOnLogsListener(id),\n };\n}\n\n/**\n * Subscribe to changes of an account's data.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param pubkey - The account to watch.\n * @param callback - Invoked with each account change.\n * @param commitment - Optional commitment level.\n */\nexport function onAccountChange(\n connection: Connection,\n pubkey: PublicKey,\n callback: AccountChangeCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onAccountChange(pubkey, callback, commitment);\n return {\n id,\n off: () => connection.removeAccountChangeListener(id),\n };\n}\n\n/**\n * Subscribe to slot changes (new slots as they are processed).\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param callback - Invoked with each slot change.\n */\nexport function onSlotChange(\n connection: Connection,\n callback: SlotChangeCallback,\n): SvmSubscription {\n const id = connection.onSlotChange(callback);\n return {\n id,\n off: () => connection.removeSlotChangeListener(id),\n };\n}\n","/**\n * Compute-budget and priority-fee conveniences over `@solana/web3.js`.\n *\n * {@link withComputeBudget} prepends `ComputeBudgetProgram` instructions to a\n * legacy `Transaction` so it requests a compute-unit limit and pays a per-CU\n * priority price; {@link estimatePriorityFee} reads recent prioritization fees\n * from the RPC to suggest a `microLamports` price.\n */\n\nimport {\n ComputeBudgetProgram,\n type Connection,\n type PublicKey,\n type Transaction,\n} from \"@solana/web3.js\";\n\n/** Compute-budget options for {@link withComputeBudget}. */\nexport interface ComputeBudgetOptions {\n /** Compute-unit limit to request (`setComputeUnitLimit`). */\n units?: number;\n /** Per-compute-unit price in micro-lamports (`setComputeUnitPrice`). */\n microLamports?: number | bigint;\n}\n\n/**\n * Prepend `ComputeBudgetProgram` instructions to `tx` (mutating it in place and\n * returning it). A unit-limit instruction is added when `units` is given, and a\n * unit-price instruction when `microLamports` is given; both are inserted at the\n * front of the instruction list, as required by the runtime.\n *\n * @returns The same `tx`, for chaining.\n */\nexport function withComputeBudget(\n tx: Transaction,\n options: ComputeBudgetOptions,\n): Transaction {\n const { units, microLamports } = options;\n const prepend = [];\n if (microLamports !== undefined) {\n prepend.unshift(\n ComputeBudgetProgram.setComputeUnitPrice({ microLamports }),\n );\n }\n if (units !== undefined) {\n prepend.unshift(ComputeBudgetProgram.setComputeUnitLimit({ units }));\n }\n tx.instructions.unshift(...prepend);\n return tx;\n}\n\n/**\n * Estimate a priority fee (`microLamports` per CU) from the RPC's\n * `getRecentPrioritizationFees`. Returns the maximum recently observed fee,\n * which is a conservative choice for landing a transaction quickly. Returns `0`\n * when the RPC reports no recent fees.\n *\n * @param connection - SVM RPC connection.\n * @param accounts - Optional accounts the tx will lock, scoping the query.\n */\nexport async function estimatePriorityFee(\n connection: Connection,\n accounts: readonly PublicKey[] = [],\n): Promise<number> {\n const fees = await connection.getRecentPrioritizationFees(\n accounts.length > 0 ? { lockedWritableAccounts: [...accounts] } : undefined,\n );\n if (!fees || fees.length === 0) return 0;\n return fees.reduce((max, f) => Math.max(max, f.prioritizationFee), 0);\n}\n\n/** Namespaced compute-budget / fee helpers. */\nexport const fees = {\n withComputeBudget,\n estimatePriorityFee,\n} as const;\n","/**\n * `@qorechain/svm` — a thin, type-safe adapter over\n * [`@solana/web3.js`](https://solana-labs.github.io/solana-web3.js/) for\n * QoreChain's Solana-compatible JSON-RPC.\n *\n * It does not reimplement an SVM client; `@solana/web3.js` is a peer dependency.\n * This package adds QoreChain-specific conveniences: a client factory targeting\n * the SVM RPC endpoint, key helpers, typed read wrappers, SOL transfer\n * build/sign/send, and minimal native-program instruction builders (Memo,\n * SPL-Token, Associated Token Account) plus a generic program-invoke builder.\n */\n\n/** Package version. */\nexport const VERSION = \"0.3.0\";\n\nexport {\n createSvmClient,\n DEFAULT_SVM_RPC_URL,\n type CreateSvmClientOptions,\n type SvmClient,\n type SvmEndpoints,\n type TransferSolArgs,\n type SignatureResult,\n} from \"./client\";\n\nexport { svmKeypairFromSecretKey, svmAddress } from \"./keys\";\n\nexport {\n PROGRAM_IDS,\n SYSTEM_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n ASSOCIATED_TOKEN_PROGRAM_ID,\n MEMO_PROGRAM_ID,\n createMemoInstruction,\n createTransferTokenInstruction,\n createAssociatedTokenAccountInstruction,\n getAssociatedTokenAddress,\n createInvokeInstruction,\n type TransferTokenInstructionArgs,\n type CreateAssociatedTokenAccountInstructionArgs,\n} from \"./programs\";\n\nexport {\n getSvmWallet,\n detectSvmProvider,\n type InjectedSvmWallet,\n type GetSvmWalletOptions,\n type SvmWalletConnection,\n type SvmSignableTransaction,\n} from \"./wallet\";\n\nexport { decodeSvmError, type DecodedSvmError } from \"./errors\";\n\nexport {\n onLogs,\n onAccountChange,\n onSlotChange,\n type SvmSubscription,\n} from \"./subscribe\";\n\nexport {\n fees,\n withComputeBudget,\n estimatePriorityFee,\n type ComputeBudgetOptions,\n} from \"./fees\";\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/client.ts","../src/keys.ts","../src/programs.ts","../src/wallet.ts","../src/errors.ts","../src/subscribe.ts","../src/fees.ts","../src/index.ts"],"names":["PublicKey","fees"],"mappings":";;;AAmCO,IAAM,mBAAA,GAAsB;AA2EnC,SAAS,kBAAkB,IAAA,EAA0C;AACnE,EAAA,IAAI,IAAA,CAAK,UAAA,EAAY,OAAO,IAAA,CAAK,UAAA;AACjC,EAAA,MAAM,GAAA,GAAM,IAAA,CAAK,MAAA,I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AQ,oBAAA,CAAqB,mBAAA,CAAoB,EAAE,KAAA,EAAO,CAAC,CAAA;AAAA,EACrE;AACA,EAAA,EAAA,CAAG,YAAA,CAAa,OAAA,CAAQ,GAAG,OAAO,CAAA;AAClC,EAAA,OAAO,EAAA;AACT;AAWA,eAAsB,mBAAA,CACpB,UAAA,EACA,QAAA,GAAiC,EAAC,EACjB;AACjB,EAAA,MAAMC,KAAAA,GAAO,MAAM,UAAA,CAAW,2BAAA;AAAA,IAC5B,QAAA,CAAS,SAAS,CAAA,GAAI,EAAE,wBAAwB,CAAC,GAAG,QAAQ,CAAA,EAAE,GAAI;AAAA,GACpE;AACA,EAAA,IAAI,CAACA,KAAAA,IAAQA,KAAAA,CAAK,MAAA,KAAW,GAAG,OAAO,CAAA;AACvC,EAAA,OAAOA,KAAAA,CAAK,MAAA,CAAO,CAAC,GAAA,EAAK,CAAA,KAAM,IAAA,CAAK,GAAA,CAAI,GAAA,EAAK,CAAA,CAAE,iBAAiB,CAAA,EAAG,CAAC,CAAA;AACtE;AAGO,IAAM,IAAA,GAAO;AAAA,EAClB,iBAAA;AAAA,EACA;AACF;;;AC7DO,IAAM,OAAA,GAAU","file":"index.js","sourcesContent":["/**\n * Client factory for QoreChain's Solana-compatible JSON-RPC.\n *\n * This is a thin convenience layer over `@solana/web3.js`: it builds (or accepts)\n * a `Connection` bound to the network's SVM RPC endpoint and exposes typed\n * wrappers over the documented Solana-compatible JSON-RPC method set plus\n * transaction build/sign/send helpers.\n *\n * `@solana/web3.js` is a peer dependency; nothing here reimplements it.\n */\n\nimport {\n Connection,\n PublicKey,\n SystemProgram,\n Transaction,\n sendAndConfirmTransaction,\n type AccountInfo,\n type Commitment,\n type ConfirmOptions,\n type GetLatestBlockhashConfig,\n type Keypair,\n type RpcResponseAndContext,\n type SignatureResult,\n type SimulatedTransactionResponse,\n type TokenAccountsFilter,\n} from \"@solana/web3.js\";\n\n/** Subset of a qorechain-sdk network's endpoints relevant to the SVM runtime. */\nexport interface SvmEndpoints {\n /** Solana-compatible JSON-RPC HTTP endpoint. */\n svmRpc: string;\n}\n\n/** Default testnet SVM RPC endpoint (Solana-compatible JSON-RPC, port 8899). */\nexport const DEFAULT_SVM_RPC_URL = \"http://localhost:8899\";\n\n/** Options for {@link createSvmClient}. */\nexport interface CreateSvmClientOptions {\n /** Solana-compatible JSON-RPC HTTP URL. Mutually exclusive with `endpoints`. */\n rpcUrl?: string;\n /** A qorechain-sdk network endpoints object (uses `svmRpc`). */\n endpoints?: SvmEndpoints;\n /** Default commitment level for the connection. */\n commitment?: Commitment;\n /**\n * A preconstructed `Connection`. When provided it is used as-is and `rpcUrl`/\n * `endpoints`/`commitment` are ignored — primarily for testing.\n */\n connection?: Connection;\n}\n\n/** Arguments for building/sending a SOL transfer. */\nexport interface TransferSolArgs {\n /** Funding/source keypair (signer). */\n from: Keypair;\n /** Destination address. */\n to: PublicKey;\n /** Amount in lamports. */\n lamports: number | bigint;\n}\n\n/** A configured QoreChain SVM client bundle. */\nexport interface SvmClient {\n /** The underlying `@solana/web3.js` `Connection`. */\n connection: Connection;\n\n // --- Reads (thin wrappers over the JSON-RPC method set) ---\n /** Lamport balance for an account. */\n getBalance(pubkey: PublicKey, commitment?: Commitment): Promise<number>;\n /** Raw account info, or `null` if the account does not exist. */\n getAccountInfo(\n pubkey: PublicKey,\n commitment?: Commitment,\n ): Promise<AccountInfo<Buffer> | null>;\n /** Latest blockhash and last valid block height. */\n getLatestBlockhash(\n commitmentOrConfig?: Commitment | GetLatestBlockhashConfig,\n ): Promise<{ blockhash: string; lastValidBlockHeight: number }>;\n /** Token accounts owned by `owner`, filtered by mint or program id. */\n getTokenAccountsByOwner(\n owner: PublicKey,\n filter: TokenAccountsFilter,\n commitment?: Commitment,\n ): ReturnType<Connection[\"getTokenAccountsByOwner\"]>;\n /** Confirmed signatures for transactions involving `address`. */\n getSignaturesForAddress(\n address: PublicKey,\n options?: Parameters<Connection[\"getSignaturesForAddress\"]>[1],\n ): ReturnType<Connection[\"getSignaturesForAddress\"]>;\n /** Request an airdrop of `lamports` to `pubkey` (testnet/devnet only). */\n requestAirdrop(pubkey: PublicKey, lamports: number): Promise<string>;\n\n // --- Transactions ---\n /** Build (unsigned, no blockhash) a SOL transfer transaction. */\n buildTransferSol(args: TransferSolArgs): Transaction;\n /** Build, sign, send, and confirm a SOL transfer. */\n transferSol(args: TransferSolArgs, options?: ConfirmOptions): Promise<string>;\n /** Sign, send, and confirm an arbitrary transaction. */\n sendTransaction(\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string>;\n /** Simulate a transaction without submitting it. */\n simulateTransaction(\n tx: Transaction,\n ): Promise<RpcResponseAndContext<SimulatedTransactionResponse>>;\n}\n\nfunction resolveConnection(opts: CreateSvmClientOptions): Connection {\n if (opts.connection) return opts.connection;\n const url = opts.rpcUrl ?? opts.endpoints?.svmRpc ?? DEFAULT_SVM_RPC_URL;\n return new Connection(url, opts.commitment ?? \"confirmed\");\n}\n\n/**\n * Create a QoreChain SVM client bundle.\n *\n * With no options it targets the testnet localhost endpoint\n * (`http://localhost:8899`) at `confirmed` commitment.\n */\nexport function createSvmClient(opts: CreateSvmClientOptions = {}): SvmClient {\n const connection = resolveConnection(opts);\n\n const buildTransferSol = (args: TransferSolArgs): Transaction => {\n const tx = new Transaction();\n tx.add(\n SystemProgram.transfer({\n fromPubkey: args.from.publicKey,\n toPubkey: args.to,\n lamports: args.lamports,\n }),\n );\n return tx;\n };\n\n const sendTransaction = (\n tx: Transaction,\n signers: Keypair[],\n options?: ConfirmOptions,\n ): Promise<string> => sendAndConfirmTransaction(connection, tx, signers, options);\n\n return {\n connection,\n\n getBalance: (pubkey, commitment) => connection.getBalance(pubkey, commitment),\n getAccountInfo: (pubkey, commitment) =>\n connection.getAccountInfo(pubkey, commitment) as Promise<AccountInfo<Buffer> | null>,\n getLatestBlockhash: (commitmentOrConfig) =>\n connection.getLatestBlockhash(commitmentOrConfig),\n getTokenAccountsByOwner: (owner, filter, commitment) =>\n connection.getTokenAccountsByOwner(owner, filter, commitment),\n getSignaturesForAddress: (address, options) =>\n connection.getSignaturesForAddress(address, options),\n requestAirdrop: (pubkey, lamports) => connection.requestAirdrop(pubkey, lamports),\n\n buildTransferSol,\n transferSol: (args, options) =>\n sendTransaction(buildTransferSol(args), [args.from], options),\n sendTransaction,\n simulateTransaction: (tx): Promise<\n RpcResponseAndContext<SimulatedTransactionResponse>\n > =>\n // The single-arg overload signs/derives blockhash as needed for v1\n // legacy transactions.\n (connection.simulateTransaction as (\n t: Transaction,\n ) => Promise<RpcResponseAndContext<SimulatedTransactionResponse>>)(tx),\n };\n}\n\n// Re-export so callers can type their results without a direct dependency on the\n// peer's internal `SignatureResult` import path.\nexport type { SignatureResult };\n","/**\n * Key helpers for QoreChain's Solana-compatible runtime.\n *\n * These are thin wrappers over `@solana/web3.js` so callers don't need a second\n * import path. `@qorechain/sdk`'s `deriveSvmAccount(mnemonic)` provides the\n * 64-byte `secretKey` you can pass straight into {@link svmKeypairFromSecretKey}.\n */\n\nimport { Keypair, PublicKey } from \"@solana/web3.js\";\n\n/**\n * Reconstruct a `@solana/web3.js` `Keypair` from a 64-byte ed25519 secret key\n * (the standard Solana secret-key encoding: 32-byte seed + 32-byte public key).\n *\n * Pair with `@qorechain/sdk`'s `deriveSvmAccount`, which returns this exact\n * 64-byte `secretKey`.\n */\nexport function svmKeypairFromSecretKey(secretKey: Uint8Array): Keypair {\n if (secretKey.length !== 64) {\n throw new Error(\n `svmKeypairFromSecretKey: expected a 64-byte secret key, got ${secretKey.length}`,\n );\n }\n return Keypair.fromSecretKey(secretKey);\n}\n\n/** Return the base58 address for a `Keypair` or a `PublicKey`. */\nexport function svmAddress(key: Keypair | PublicKey): string {\n const pubkey = key instanceof PublicKey ? key : key.publicKey;\n return pubkey.toBase58();\n}\n","/**\n * Well-known native program ids for QoreChain's Solana-compatible runtime, plus\n * thin instruction builders for the Memo and SPL-Token programs and the\n * Associated Token Account program.\n *\n * The program ids are the exact canonical ones used by Solana-compatible\n * runtimes, so standard wallets, explorers, and tooling interoperate directly.\n * The SPL-Token / ATA / Memo instructions are built minimally here (by hand)\n * to keep the dependency surface to a single peer — `@solana/web3.js` — with no\n * `@solana/spl-token` requirement.\n */\n\nimport { PublicKey, TransactionInstruction, type AccountMeta } from \"@solana/web3.js\";\n\n/** System program (account creation, SOL transfers). */\nexport const SYSTEM_PROGRAM_ID = new PublicKey(\"11111111111111111111111111111111\");\n\n/** SPL-Token program. */\nexport const TOKEN_PROGRAM_ID = new PublicKey(\"TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA\");\n\n/** Associated Token Account program. */\nexport const ASSOCIATED_TOKEN_PROGRAM_ID = new PublicKey(\n \"ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL\",\n);\n\n/** SPL Memo program. */\nexport const MEMO_PROGRAM_ID = new PublicKey(\"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr\");\n\n/** Convenience grouping of the well-known program ids. */\nexport const PROGRAM_IDS = {\n system: SYSTEM_PROGRAM_ID,\n token: TOKEN_PROGRAM_ID,\n associatedToken: ASSOCIATED_TOKEN_PROGRAM_ID,\n memo: MEMO_PROGRAM_ID,\n} as const;\n\n/**\n * Build a Memo program instruction carrying `text` (encoded UTF-8).\n *\n * @param text Memo contents.\n * @param signers Optional accounts that must sign the memo; each is included as\n * a read-only signer (the Memo program's convention).\n */\nexport function createMemoInstruction(\n text: string,\n signers: PublicKey[] = [],\n): TransactionInstruction {\n return new TransactionInstruction({\n programId: MEMO_PROGRAM_ID,\n keys: signers.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n data: Buffer.from(text, \"utf8\"),\n });\n}\n\n/** Arguments for {@link createTransferTokenInstruction}. */\nexport interface TransferTokenInstructionArgs {\n /** Source SPL-Token account. */\n source: PublicKey;\n /** Destination SPL-Token account. */\n destination: PublicKey;\n /** Owner/authority of the source account (signer). */\n owner: PublicKey;\n /** Amount in the token's base units. */\n amount: bigint;\n /** Additional multisig signers, if `owner` is a multisig. */\n multiSigners?: PublicKey[];\n}\n\n/**\n * Build an SPL-Token `Transfer` instruction.\n *\n * Layout: 1 byte instruction discriminator (`3` = Transfer) followed by a\n * little-endian u64 amount.\n */\nexport function createTransferTokenInstruction(\n args: TransferTokenInstructionArgs,\n): TransactionInstruction {\n const { source, destination, owner, amount, multiSigners = [] } = args;\n\n const data = Buffer.alloc(9);\n data.writeUInt8(3, 0);\n data.writeBigUInt64LE(amount, 1);\n\n const keys: AccountMeta[] = [\n { pubkey: source, isSigner: false, isWritable: true },\n { pubkey: destination, isSigner: false, isWritable: true },\n {\n pubkey: owner,\n isSigner: multiSigners.length === 0,\n isWritable: false,\n },\n ...multiSigners.map((pubkey) => ({ pubkey, isSigner: true, isWritable: false })),\n ];\n\n return new TransactionInstruction({ programId: TOKEN_PROGRAM_ID, keys, data });\n}\n\n/**\n * Derive the deterministic Associated Token Account (ATA) address for an owner\n * and mint under the SPL-Token program.\n */\nexport function getAssociatedTokenAddress(\n mint: PublicKey,\n owner: PublicKey,\n tokenProgramId: PublicKey = TOKEN_PROGRAM_ID,\n): PublicKey {\n const [address] = PublicKey.findProgramAddressSync(\n [owner.toBuffer(), tokenProgramId.toBuffer(), mint.toBuffer()],\n ASSOCIATED_TOKEN_PROGRAM_ID,\n );\n return address;\n}\n\n/** Arguments for {@link createAssociatedTokenAccountInstruction}. */\nexport interface CreateAssociatedTokenAccountInstructionArgs {\n /** Account funding the rent for the new ATA (signer, writable). */\n payer: PublicKey;\n /** Wallet that will own the new ATA. */\n owner: PublicKey;\n /** Token mint. */\n mint: PublicKey;\n /** SPL-Token program id (defaults to the canonical SPL-Token program). */\n tokenProgramId?: PublicKey;\n}\n\n/**\n * Build an instruction that creates the Associated Token Account for\n * `(owner, mint)`. The ATA address is derived deterministically.\n */\nexport function createAssociatedTokenAccountInstruction(\n args: CreateAssociatedTokenAccountInstructionArgs,\n): TransactionInstruction {\n const { payer, owner, mint, tokenProgramId = TOKEN_PROGRAM_ID } = args;\n const ata = getAssociatedTokenAddress(mint, owner, tokenProgramId);\n\n const keys: AccountMeta[] = [\n { pubkey: payer, isSigner: true, isWritable: true },\n { pubkey: ata, isSigner: false, isWritable: true },\n { pubkey: owner, isSigner: false, isWritable: false },\n { pubkey: mint, isSigner: false, isWritable: false },\n { pubkey: SYSTEM_PROGRAM_ID, isSigner: false, isWritable: false },\n { pubkey: tokenProgramId, isSigner: false, isWritable: false },\n ];\n\n // The ATA \"Create\" instruction takes empty data (the idempotent variant uses\n // a single 0x01 byte; this is the plain create).\n return new TransactionInstruction({\n programId: ASSOCIATED_TOKEN_PROGRAM_ID,\n keys,\n data: Buffer.alloc(0),\n });\n}\n\n/**\n * Generic instruction builder for invoking an arbitrary on-chain program.\n *\n * Use this with {@link createSvmClient}'s `sendTransaction` to call a deployed\n * BPF program. Deploy programs with standard Solana tooling (e.g.\n * `solana program deploy`); this package intentionally does not wrap the loader.\n */\nexport function createInvokeInstruction(\n programId: PublicKey,\n keys: AccountMeta[],\n data: Uint8Array,\n): TransactionInstruction {\n return new TransactionInstruction({\n programId,\n keys,\n data: Buffer.from(data),\n });\n}\n","/**\n * SVM browser-wallet integration for QoreChain (Phantom and Wallet-Standard).\n *\n * Adapts an injected Solana provider (Phantom's `window.solana` is the baseline)\n * into a shape usable with `@solana/web3.js`, so apps can sign and send via the\n * existing SVM client.\n *\n * ```ts\n * import { getSvmWallet } from \"@qorechain/svm\";\n * import { createSvmClient } from \"@qorechain/svm\";\n *\n * const wallet = await getSvmWallet();\n * const signed = await wallet.signTransaction(tx);\n * // ...then send with createSvmClient(...).sendRawTransaction(...)\n * ```\n */\n\nimport type { PublicKey, Transaction, VersionedTransaction } from \"@solana/web3.js\";\n\n/** A transaction the wallet can sign (legacy or versioned). */\nexport type SvmSignableTransaction = Transaction | VersionedTransaction;\n\n/**\n * The minimal injected Solana-wallet surface used here. Phantom (and most\n * Wallet-Standard providers) implement at least these. Declared structurally so\n * no wallet types package is required.\n */\nexport interface InjectedSvmWallet {\n /** Phantom marker; present on the Phantom provider. */\n isPhantom?: boolean;\n /** Connect and return the account public key. */\n connect(opts?: { onlyIfTrusted?: boolean }): Promise<{ publicKey: PublicKey }>;\n /** Disconnect the wallet. */\n disconnect?(): Promise<void>;\n /** The connected account public key (populated after `connect`). */\n publicKey?: PublicKey | null;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions. */\n signAllTransactions?<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n}\n\n/** Window augmentation for the default injected Solana provider. */\ninterface SolanaWindow {\n solana?: InjectedSvmWallet;\n}\n\n/** Options for {@link getSvmWallet}. */\nexport interface GetSvmWalletOptions {\n /** The injected provider to use. Defaults to `window.solana` (Phantom). */\n provider?: InjectedSvmWallet;\n /** Pass through to the provider's `connect` (e.g. silent reconnect). */\n onlyIfTrusted?: boolean;\n}\n\n/**\n * A connected SVM wallet adapted for use with `@solana/web3.js`.\n *\n * `signTransaction` / `signAllTransactions` accept and return web3.js\n * `Transaction` / `VersionedTransaction` objects, so they drop into the existing\n * SVM client's send path.\n */\nexport interface SvmWalletConnection {\n /** The connected account public key. */\n publicKey: PublicKey;\n /** Sign a single transaction. */\n signTransaction<T extends SvmSignableTransaction>(tx: T): Promise<T>;\n /** Sign multiple transactions (falls back to sequential signing). */\n signAllTransactions<T extends SvmSignableTransaction>(txs: T[]): Promise<T[]>;\n /** The underlying injected provider. */\n provider: InjectedSvmWallet;\n}\n\n/** Resolve the injected Solana provider from options or `window`, or throw. */\nfunction resolveProvider(provider?: InjectedSvmWallet): InjectedSvmWallet {\n if (provider) return provider;\n if (typeof window === \"undefined\") {\n throw new Error(\n \"getSvmWallet: no browser `window` available. Run in a browser, or pass `provider` explicitly.\",\n );\n }\n const injected = (window as unknown as SolanaWindow).solana;\n if (!injected) {\n throw new Error(\n \"getSvmWallet: no injected Solana provider found (window.solana). Install Phantom, or pass `provider`.\",\n );\n }\n return injected;\n}\n\n/**\n * Connect to an injected Solana wallet (Phantom by default) and return an\n * adapter usable with `@solana/web3.js`.\n *\n * Browser-only: throws a clear error if no `window` or no injected provider.\n */\nexport async function getSvmWallet(\n opts: GetSvmWalletOptions = {},\n): Promise<SvmWalletConnection> {\n const provider = resolveProvider(opts.provider);\n const { publicKey } = await provider.connect(\n opts.onlyIfTrusted ? { onlyIfTrusted: true } : undefined,\n );\n if (!publicKey) {\n throw new Error(\"getSvmWallet: wallet connected but returned no public key\");\n }\n\n const signTransaction = <T extends SvmSignableTransaction>(tx: T): Promise<T> =>\n provider.signTransaction(tx);\n\n const signAllTransactions = async <T extends SvmSignableTransaction>(\n txs: T[],\n ): Promise<T[]> => {\n if (provider.signAllTransactions) return provider.signAllTransactions(txs);\n // Fall back to signing sequentially for providers without batch support.\n const out: T[] = [];\n for (const tx of txs) out.push(await provider.signTransaction(tx));\n return out;\n };\n\n return { publicKey, signTransaction, signAllTransactions, provider };\n}\n\n/**\n * Detect a Wallet-Standard / Phantom Solana provider on `window`.\n *\n * Returns the injected provider if present, else `undefined`. Phantom's\n * `window.solana` is the baseline; this is a light convenience for apps that\n * want to feature-detect before prompting a connection.\n */\nexport function detectSvmProvider(): InjectedSvmWallet | undefined {\n if (typeof window === \"undefined\") return undefined;\n return (window as unknown as SolanaWindow).solana;\n}\n","/**\n * Human-readable decoding of SVM (Solana-compatible) transaction errors.\n *\n * `@solana/web3.js` throws a `SendTransactionError` (and related shapes) whose\n * useful detail — the failing instruction index, a program's custom error code,\n * and the program logs — is spread across several fields that differ slightly\n * between library versions. {@link decodeSvmError} reads those fields\n * structurally (so it works across versions) and produces a flat summary with\n * the program logs and, where present, the failing instruction index.\n */\n\n/** A decoded SVM error. */\nexport interface DecodedSvmError {\n /** A readable summary message. */\n message: string;\n /** A short, stable kind discriminator. */\n kind: \"instruction_error\" | \"simulation\" | \"send\" | \"unknown\";\n /** Zero-based index of the failing instruction, when determinable. */\n instructionIndex?: number;\n /** A program's custom error code, when present in the logs. */\n customErrorCode?: number;\n /** The program logs, when available. */\n logs?: string[];\n}\n\n/** Read the program logs from the various shapes web3.js uses. */\nfunction extractLogs(err: unknown): string[] | undefined {\n const e = err as { logs?: unknown; transactionLogs?: unknown };\n const logs = e?.logs ?? e?.transactionLogs;\n if (Array.isArray(logs)) return logs as string[];\n return undefined;\n}\n\n/** Read a base message from the various shapes web3.js uses. */\nfunction extractMessage(err: unknown): string {\n const e = err as { transactionMessage?: unknown; message?: unknown };\n if (typeof e?.transactionMessage === \"string\" && e.transactionMessage) {\n return e.transactionMessage;\n }\n if (typeof e?.message === \"string\" && e.message) return e.message;\n return String(err);\n}\n\n/**\n * Parse the failing instruction index and a custom program error code from the\n * program logs, if either is present.\n *\n * Logs commonly contain a line like:\n * \"Program <id> failed: custom program error: 0x1\"\n * and the instruction index can appear as \"Error processing Instruction 2:\".\n */\nfunction parseFromLogs(logs: string[] | undefined): {\n instructionIndex?: number;\n customErrorCode?: number;\n} {\n if (!logs) return {};\n let instructionIndex: number | undefined;\n let customErrorCode: number | undefined;\n for (const line of logs) {\n const instr = /instruction\\s+#?(\\d+)/i.exec(line);\n if (instr) instructionIndex = Number(instr[1]);\n const custom = /custom program error:\\s*(0x[0-9a-fA-F]+|\\d+)/i.exec(line);\n if (custom) {\n customErrorCode = custom[1].startsWith(\"0x\")\n ? parseInt(custom[1], 16)\n : Number(custom[1]);\n }\n }\n return { instructionIndex, customErrorCode };\n}\n\n/**\n * Decode an SVM error thrown by `@solana/web3.js` into a readable, structured\n * form.\n *\n * @param error - The thrown error (a `SendTransactionError` or any value).\n */\nexport function decodeSvmError(error: unknown): DecodedSvmError {\n const logs = extractLogs(error);\n const base = extractMessage(error);\n const { instructionIndex, customErrorCode } = parseFromLogs(logs);\n\n const name = (error as { name?: string })?.name;\n const isSendError =\n name === \"SendTransactionError\" ||\n /simulation failed|transaction simulation/i.test(base);\n\n const parts: string[] = [base];\n if (instructionIndex !== undefined) {\n parts.push(`(failing instruction #${instructionIndex})`);\n }\n if (customErrorCode !== undefined) {\n parts.push(`(custom program error ${customErrorCode})`);\n }\n\n let kind: DecodedSvmError[\"kind\"];\n if (customErrorCode !== undefined || instructionIndex !== undefined) {\n kind = \"instruction_error\";\n } else if (isSendError) {\n kind = \"simulation\";\n } else if (error instanceof Error) {\n kind = \"send\";\n } else {\n kind = \"unknown\";\n }\n\n return {\n message: parts.join(\" \"),\n kind,\n instructionIndex,\n customErrorCode,\n logs,\n };\n}\n","/**\n * Real-time SVM subscriptions over the `@solana/web3.js` `Connection`.\n *\n * The `Connection` owns the websocket and its lifecycle; these helpers are thin\n * wrappers that register a listener and return both the numeric subscription id\n * and an `off()` function that removes it via the matching\n * `remove*Listener` call. This keeps callers from having to remember which\n * removal method pairs with which subscription.\n */\n\nimport type {\n AccountChangeCallback,\n Commitment,\n Connection,\n LogsCallback,\n LogsFilter,\n PublicKey,\n SlotChangeCallback,\n} from \"@solana/web3.js\";\n\n/** A registered subscription: its id and a function to remove it. */\nexport interface SvmSubscription {\n /** The numeric subscription id returned by `@solana/web3.js`. */\n id: number;\n /** Remove the listener (idempotent best-effort). */\n off(): Promise<void>;\n}\n\n/**\n * Subscribe to transaction logs matching `filter`.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param filter - A `LogsFilter` (`\"all\"`, `\"allWithVotes\"`, or a `PublicKey`).\n * @param callback - Invoked with each matching logs notification.\n * @param commitment - Optional commitment level.\n */\nexport function onLogs(\n connection: Connection,\n filter: LogsFilter,\n callback: LogsCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onLogs(filter, callback, commitment);\n return {\n id,\n off: () => connection.removeOnLogsListener(id),\n };\n}\n\n/**\n * Subscribe to changes of an account's data.\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param pubkey - The account to watch.\n * @param callback - Invoked with each account change.\n * @param commitment - Optional commitment level.\n */\nexport function onAccountChange(\n connection: Connection,\n pubkey: PublicKey,\n callback: AccountChangeCallback,\n commitment?: Commitment,\n): SvmSubscription {\n const id = connection.onAccountChange(pubkey, callback, commitment);\n return {\n id,\n off: () => connection.removeAccountChangeListener(id),\n };\n}\n\n/**\n * Subscribe to slot changes (new slots as they are processed).\n *\n * @param connection - A `@solana/web3.js` `Connection`.\n * @param callback - Invoked with each slot change.\n */\nexport function onSlotChange(\n connection: Connection,\n callback: SlotChangeCallback,\n): SvmSubscription {\n const id = connection.onSlotChange(callback);\n return {\n id,\n off: () => connection.removeSlotChangeListener(id),\n };\n}\n","/**\n * Compute-budget and priority-fee conveniences over `@solana/web3.js`.\n *\n * {@link withComputeBudget} prepends `ComputeBudgetProgram` instructions to a\n * legacy `Transaction` so it requests a compute-unit limit and pays a per-CU\n * priority price; {@link estimatePriorityFee} reads recent prioritization fees\n * from the RPC to suggest a `microLamports` price.\n */\n\nimport {\n ComputeBudgetProgram,\n type Connection,\n type PublicKey,\n type Transaction,\n} from \"@solana/web3.js\";\n\n/** Compute-budget options for {@link withComputeBudget}. */\nexport interface ComputeBudgetOptions {\n /** Compute-unit limit to request (`setComputeUnitLimit`). */\n units?: number;\n /** Per-compute-unit price in micro-lamports (`setComputeUnitPrice`). */\n microLamports?: number | bigint;\n}\n\n/**\n * Prepend `ComputeBudgetProgram` instructions to `tx` (mutating it in place and\n * returning it). A unit-limit instruction is added when `units` is given, and a\n * unit-price instruction when `microLamports` is given; both are inserted at the\n * front of the instruction list, as required by the runtime.\n *\n * @returns The same `tx`, for chaining.\n */\nexport function withComputeBudget(\n tx: Transaction,\n options: ComputeBudgetOptions,\n): Transaction {\n const { units, microLamports } = options;\n const prepend = [];\n if (microLamports !== undefined) {\n prepend.unshift(\n ComputeBudgetProgram.setComputeUnitPrice({ microLamports }),\n );\n }\n if (units !== undefined) {\n prepend.unshift(ComputeBudgetProgram.setComputeUnitLimit({ units }));\n }\n tx.instructions.unshift(...prepend);\n return tx;\n}\n\n/**\n * Estimate a priority fee (`microLamports` per CU) from the RPC's\n * `getRecentPrioritizationFees`. Returns the maximum recently observed fee,\n * which is a conservative choice for landing a transaction quickly. Returns `0`\n * when the RPC reports no recent fees.\n *\n * @param connection - SVM RPC connection.\n * @param accounts - Optional accounts the tx will lock, scoping the query.\n */\nexport async function estimatePriorityFee(\n connection: Connection,\n accounts: readonly PublicKey[] = [],\n): Promise<number> {\n const fees = await connection.getRecentPrioritizationFees(\n accounts.length > 0 ? { lockedWritableAccounts: [...accounts] } : undefined,\n );\n if (!fees || fees.length === 0) return 0;\n return fees.reduce((max, f) => Math.max(max, f.prioritizationFee), 0);\n}\n\n/** Namespaced compute-budget / fee helpers. */\nexport const fees = {\n withComputeBudget,\n estimatePriorityFee,\n} as const;\n","/**\n * `@qorechain/svm` — a thin, type-safe adapter over\n * [`@solana/web3.js`](https://solana-labs.github.io/solana-web3.js/) for\n * QoreChain's Solana-compatible JSON-RPC.\n *\n * It does not reimplement an SVM client; `@solana/web3.js` is a peer dependency.\n * This package adds QoreChain-specific conveniences: a client factory targeting\n * the SVM RPC endpoint, key helpers, typed read wrappers, SOL transfer\n * build/sign/send, and minimal native-program instruction builders (Memo,\n * SPL-Token, Associated Token Account) plus a generic program-invoke builder.\n */\n\n/** Package version. */\nexport const VERSION = \"0.5.0\";\n\nexport {\n createSvmClient,\n DEFAULT_SVM_RPC_URL,\n type CreateSvmClientOptions,\n type SvmClient,\n type SvmEndpoints,\n type TransferSolArgs,\n type SignatureResult,\n} from \"./client\";\n\nexport { svmKeypairFromSecretKey, svmAddress } from \"./keys\";\n\nexport {\n PROGRAM_IDS,\n SYSTEM_PROGRAM_ID,\n TOKEN_PROGRAM_ID,\n ASSOCIATED_TOKEN_PROGRAM_ID,\n MEMO_PROGRAM_ID,\n createMemoInstruction,\n createTransferTokenInstruction,\n createAssociatedTokenAccountInstruction,\n getAssociatedTokenAddress,\n createInvokeInstruction,\n type TransferTokenInstructionArgs,\n type CreateAssociatedTokenAccountInstructionArgs,\n} from \"./programs\";\n\nexport {\n getSvmWallet,\n detectSvmProvider,\n type InjectedSvmWallet,\n type GetSvmWalletOptions,\n type SvmWalletConnection,\n type SvmSignableTransaction,\n} from \"./wallet\";\n\nexport { decodeSvmError, type DecodedSvmError } from \"./errors\";\n\nexport {\n onLogs,\n onAccountChange,\n onSlotChange,\n type SvmSubscription,\n} from \"./subscribe\";\n\nexport {\n fees,\n withComputeBudget,\n estimatePriorityFee,\n type ComputeBudgetOptions,\n} from \"./fees\";\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@qorechain/svm",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
4
4
|
"description": "QoreChain SVM adapter: thin, type-safe conveniences over @solana/web3.js for QoreChain's Solana-compatible JSON-RPC, including SOL transfers, native program IDs, and SPL-Token/Memo instruction helpers.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "QoreChain",
|
|
@@ -19,13 +19,6 @@
|
|
|
19
19
|
"files": [
|
|
20
20
|
"dist"
|
|
21
21
|
],
|
|
22
|
-
"scripts": {
|
|
23
|
-
"build": "tsup",
|
|
24
|
-
"test": "vitest run",
|
|
25
|
-
"test:watch": "vitest",
|
|
26
|
-
"typecheck": "tsc --noEmit",
|
|
27
|
-
"lint": "eslint src test"
|
|
28
|
-
},
|
|
29
22
|
"repository": {
|
|
30
23
|
"type": "git",
|
|
31
24
|
"url": "git+https://github.com/qorechain/qorechain-sdk.git",
|
|
@@ -47,5 +40,12 @@
|
|
|
47
40
|
"tsup": "^8.3.0",
|
|
48
41
|
"typescript": "^5.6.3",
|
|
49
42
|
"vitest": "^2.1.2"
|
|
43
|
+
},
|
|
44
|
+
"scripts": {
|
|
45
|
+
"build": "tsup",
|
|
46
|
+
"test": "vitest run",
|
|
47
|
+
"test:watch": "vitest",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"lint": "eslint src test"
|
|
50
50
|
}
|
|
51
|
-
}
|
|
51
|
+
}
|