@solana/web3-compat 0.0.9 → 0.0.11

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,536 +0,0 @@
1
- 'use strict';
2
-
3
- var web3_js = require('@solana/web3.js');
4
- var compat = require('@solana/compat');
5
- var kit = require('@solana/kit');
6
- var transactionConfirmation = require('@solana/transaction-confirmation');
7
-
8
- var __defProp = Object.defineProperty;
9
- var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
10
- function toAddress(input) {
11
- const pubkey = input instanceof web3_js.PublicKey ? input : new web3_js.PublicKey(input);
12
- return compat.fromLegacyPublicKey(pubkey);
13
- }
14
- __name(toAddress, "toAddress");
15
- function toPublicKey(input) {
16
- if (input instanceof web3_js.PublicKey) {
17
- return input;
18
- }
19
- if (typeof input === "string") {
20
- return new web3_js.PublicKey(input);
21
- }
22
- return new web3_js.PublicKey(input);
23
- }
24
- __name(toPublicKey, "toPublicKey");
25
- async function toKitSigner(keypair, config = {}) {
26
- const secretKey = new Uint8Array(64);
27
- secretKey.set(keypair.secretKey);
28
- secretKey.set(keypair.publicKey.toBytes(), 32);
29
- return await kit.createKeyPairSignerFromBytes(secretKey, config.extractable ?? false);
30
- }
31
- __name(toKitSigner, "toKitSigner");
32
- function toWeb3Instruction(kitInstruction) {
33
- const keys = kitInstruction.accounts?.map((account) => {
34
- const role = account.role;
35
- const isSigner = role === kit.AccountRole.READONLY_SIGNER || role === kit.AccountRole.WRITABLE_SIGNER;
36
- const isWritable = role === kit.AccountRole.WRITABLE || role === kit.AccountRole.WRITABLE_SIGNER;
37
- return {
38
- isSigner,
39
- isWritable,
40
- pubkey: toPublicKey(account.address)
41
- };
42
- }) ?? [];
43
- const data = kitInstruction.data ? Buffer.from(kitInstruction.data) : Buffer.alloc(0);
44
- return new web3_js.TransactionInstruction({
45
- data,
46
- keys,
47
- programId: toPublicKey(kitInstruction.programAddress)
48
- });
49
- }
50
- __name(toWeb3Instruction, "toWeb3Instruction");
51
- function fromWeb3Instruction(legacyInstruction) {
52
- return compat.fromLegacyTransactionInstruction(legacyInstruction);
53
- }
54
- __name(fromWeb3Instruction, "fromWeb3Instruction");
55
- function createChainedAbortController(parent) {
56
- const controller = new AbortController();
57
- if (!parent) {
58
- return controller;
59
- }
60
- if (parent.aborted) {
61
- controller.abort(parent.reason);
62
- return controller;
63
- }
64
- const onAbort = /* @__PURE__ */ __name(() => {
65
- controller.abort(parent.reason);
66
- parent.removeEventListener("abort", onAbort);
67
- }, "onAbort");
68
- parent.addEventListener("abort", onAbort, { once: true });
69
- return controller;
70
- }
71
- __name(createChainedAbortController, "createChainedAbortController");
72
- function toBigint(value) {
73
- if (value === void 0) {
74
- return void 0;
75
- }
76
- return typeof value === "bigint" ? value : BigInt(Math.floor(value));
77
- }
78
- __name(toBigint, "toBigint");
79
- var DEFAULT_SIMULATION_CONFIG = Object.freeze({
80
- encoding: "base64",
81
- replaceRecentBlockhash: true,
82
- sigVerify: false
83
- });
84
- function createSolanaRpcClient(config) {
85
- const endpoint = config.endpoint;
86
- const websocketEndpoint = config.websocketEndpoint ?? endpoint;
87
- const commitment = config.commitment ?? "confirmed";
88
- const rpc = kit.createSolanaRpc(endpoint, config.rpcConfig);
89
- const rpcSubscriptions = kit.createSolanaRpcSubscriptions(websocketEndpoint, config.rpcSubscriptionsConfig);
90
- async function sendAndConfirmTransaction2(transaction, options = {}) {
91
- const abortController = createChainedAbortController(options.abortSignal);
92
- const targetCommitment = options.commitment ?? commitment;
93
- const wireTransaction = kit.getBase64EncodedWireTransaction(transaction);
94
- const response = await rpc.sendTransaction(wireTransaction, {
95
- encoding: "base64",
96
- maxRetries: toBigint(options.maxRetries),
97
- minContextSlot: toBigint(options.minContextSlot),
98
- preflightCommitment: targetCommitment,
99
- skipPreflight: options.skipPreflight
100
- }).send({ abortSignal: abortController.signal });
101
- const getBlockHeightExceedencePromise = transactionConfirmation.createBlockHeightExceedencePromiseFactory({
102
- rpc,
103
- rpcSubscriptions
104
- });
105
- const getRecentSignatureConfirmationPromise = transactionConfirmation.createRecentSignatureConfirmationPromiseFactory({
106
- rpc,
107
- rpcSubscriptions
108
- });
109
- await transactionConfirmation.waitForRecentTransactionConfirmation({
110
- abortSignal: abortController.signal,
111
- commitment: targetCommitment,
112
- getBlockHeightExceedencePromise,
113
- getRecentSignatureConfirmationPromise,
114
- transaction
115
- });
116
- return response;
117
- }
118
- __name(sendAndConfirmTransaction2, "sendAndConfirmTransaction");
119
- async function simulateTransaction(transaction, options = {}) {
120
- const wireTransaction = kit.getBase64EncodedWireTransaction(transaction);
121
- const baseConfig = options.config ?? {};
122
- const mergedConfig = {
123
- ...DEFAULT_SIMULATION_CONFIG,
124
- ...baseConfig,
125
- commitment: baseConfig.commitment ?? options.commitment ?? commitment
126
- };
127
- const normalizedConfig = mergedConfig.sigVerify === true && mergedConfig.replaceRecentBlockhash !== false ? { ...mergedConfig, replaceRecentBlockhash: false } : mergedConfig;
128
- return rpc.simulateTransaction(wireTransaction, normalizedConfig).send({ abortSignal: options.abortSignal });
129
- }
130
- __name(simulateTransaction, "simulateTransaction");
131
- return {
132
- commitment,
133
- endpoint,
134
- rpc,
135
- rpcSubscriptions,
136
- sendAndConfirmTransaction: sendAndConfirmTransaction2,
137
- simulateTransaction,
138
- websocketEndpoint
139
- };
140
- }
141
- __name(createSolanaRpcClient, "createSolanaRpcClient");
142
- var DEFAULT_COMMITMENT = "confirmed";
143
- var DEFAULT_SIMULATION_CONFIG2 = Object.freeze({
144
- encoding: "base64",
145
- replaceRecentBlockhash: true,
146
- sigVerify: false
147
- });
148
- function normalizeCommitment(commitment) {
149
- if (commitment === void 0 || commitment === null) {
150
- return void 0;
151
- }
152
- if (commitment === "recent") {
153
- return "processed";
154
- }
155
- if (commitment === "singleGossip") {
156
- return "processed";
157
- }
158
- if (commitment === "single") {
159
- return "confirmed";
160
- }
161
- if (commitment === "max") {
162
- return "finalized";
163
- }
164
- return commitment;
165
- }
166
- __name(normalizeCommitment, "normalizeCommitment");
167
- function toBigInt(value) {
168
- if (value === void 0) return void 0;
169
- return typeof value === "bigint" ? value : BigInt(Math.trunc(value));
170
- }
171
- __name(toBigInt, "toBigInt");
172
- function toAccountInfo(info, dataSlice) {
173
- const { data, executable, lamports, owner, rentEpoch } = info;
174
- const [content, encoding] = Array.isArray(data) ? data : [data, "base64"];
175
- let buffer = encoding === "base64" ? Buffer.from(content, "base64") : Buffer.from(content);
176
- if (dataSlice) {
177
- const start = dataSlice.offset ?? 0;
178
- const end = start + (dataSlice.length ?? buffer.length);
179
- buffer = buffer.subarray(start, end);
180
- }
181
- return {
182
- data: buffer,
183
- executable,
184
- lamports: typeof lamports === "number" ? lamports : Number(lamports),
185
- owner: new web3_js.PublicKey(owner),
186
- rentEpoch: typeof rentEpoch === "number" ? rentEpoch : Number(rentEpoch)
187
- };
188
- }
189
- __name(toAccountInfo, "toAccountInfo");
190
- function fromKitAccount(value) {
191
- const account = value ?? {};
192
- const data = account.data;
193
- const lamports = account.lamports;
194
- const ownerValue = account.owner;
195
- const rentEpoch = account.rentEpoch;
196
- const owner = typeof ownerValue === "string" ? ownerValue : ownerValue instanceof web3_js.PublicKey ? ownerValue.toBase58() : typeof ownerValue === "object" && ownerValue !== null && "toString" in ownerValue ? String(ownerValue) : "11111111111111111111111111111111";
197
- return {
198
- data: data ?? ["", "base64"],
199
- executable: Boolean(account.executable),
200
- lamports: lamports ?? 0,
201
- owner,
202
- rentEpoch: rentEpoch ?? 0
203
- };
204
- }
205
- __name(fromKitAccount, "fromKitAccount");
206
- function toKitAddressFromInput(input) {
207
- return toAddress(input instanceof web3_js.PublicKey ? input : input);
208
- }
209
- __name(toKitAddressFromInput, "toKitAddressFromInput");
210
- function toBase64WireTransaction(raw) {
211
- if (raw instanceof web3_js.Transaction || raw instanceof web3_js.VersionedTransaction) {
212
- const bytes = raw.serialize({
213
- requireAllSignatures: false,
214
- verifySignatures: false
215
- });
216
- return Buffer.from(bytes).toString("base64");
217
- }
218
- if (raw instanceof Uint8Array) {
219
- return Buffer.from(raw).toString("base64");
220
- }
221
- if (raw instanceof Buffer) {
222
- return raw.toString("base64");
223
- }
224
- const uint8 = Uint8Array.from(raw);
225
- return Buffer.from(uint8).toString("base64");
226
- }
227
- __name(toBase64WireTransaction, "toBase64WireTransaction");
228
- var Connection = class {
229
- static {
230
- __name(this, "Connection");
231
- }
232
- commitment;
233
- rpcEndpoint;
234
- #client;
235
- constructor(endpoint, commitmentOrConfig) {
236
- const commitment = typeof commitmentOrConfig === "string" ? normalizeCommitment(commitmentOrConfig) : normalizeCommitment(commitmentOrConfig?.commitment) ?? DEFAULT_COMMITMENT;
237
- const websocketEndpoint = typeof commitmentOrConfig === "object" && commitmentOrConfig !== null ? commitmentOrConfig.wsEndpoint : void 0;
238
- this.commitment = commitment;
239
- this.rpcEndpoint = endpoint;
240
- this.#client = createSolanaRpcClient({
241
- endpoint,
242
- websocketEndpoint,
243
- commitment: commitment ?? DEFAULT_COMMITMENT
244
- });
245
- }
246
- async getLatestBlockhash(commitmentOrConfig) {
247
- const baseCommitment = typeof commitmentOrConfig === "string" ? commitmentOrConfig : commitmentOrConfig?.commitment;
248
- const commitment = normalizeCommitment(baseCommitment) ?? this.commitment ?? DEFAULT_COMMITMENT;
249
- const minContextSlot = typeof commitmentOrConfig === "object" ? toBigInt(commitmentOrConfig.minContextSlot) : void 0;
250
- const requestOptions = {
251
- commitment
252
- };
253
- if (minContextSlot !== void 0) {
254
- requestOptions.minContextSlot = minContextSlot;
255
- }
256
- if (typeof commitmentOrConfig === "object" && commitmentOrConfig?.maxSupportedTransactionVersion !== void 0) {
257
- requestOptions.maxSupportedTransactionVersion = commitmentOrConfig.maxSupportedTransactionVersion;
258
- }
259
- const response = await this.#client.rpc.getLatestBlockhash(requestOptions).send();
260
- return {
261
- blockhash: response.value.blockhash,
262
- lastValidBlockHeight: Number(response.value.lastValidBlockHeight)
263
- };
264
- }
265
- async getBalance(publicKey, commitment) {
266
- const address = toKitAddressFromInput(publicKey);
267
- const chosenCommitment = normalizeCommitment(commitment) ?? this.commitment ?? DEFAULT_COMMITMENT;
268
- const result = await this.#client.rpc.getBalance(address, { commitment: chosenCommitment }).send();
269
- return typeof result.value === "number" ? result.value : Number(result.value);
270
- }
271
- async getAccountInfo(publicKey, commitmentOrConfig) {
272
- const address = toKitAddressFromInput(publicKey);
273
- let localCommitment;
274
- let minContextSlot;
275
- let dataSlice;
276
- let encoding;
277
- if (typeof commitmentOrConfig === "string") {
278
- localCommitment = normalizeCommitment(commitmentOrConfig);
279
- } else if (commitmentOrConfig) {
280
- localCommitment = normalizeCommitment(commitmentOrConfig.commitment);
281
- if (commitmentOrConfig.minContextSlot !== void 0) {
282
- minContextSlot = toBigInt(commitmentOrConfig.minContextSlot);
283
- }
284
- dataSlice = commitmentOrConfig.dataSlice;
285
- encoding = commitmentOrConfig.encoding;
286
- }
287
- const requestOptions = {
288
- commitment: localCommitment ?? this.commitment ?? DEFAULT_COMMITMENT
289
- };
290
- if (minContextSlot !== void 0) {
291
- requestOptions.minContextSlot = minContextSlot;
292
- }
293
- if (encoding) {
294
- requestOptions.encoding = encoding;
295
- }
296
- if (dataSlice) {
297
- requestOptions.dataSlice = {
298
- length: dataSlice.length,
299
- offset: dataSlice.offset
300
- };
301
- }
302
- const response = await this.#client.rpc.getAccountInfo(address, requestOptions).send();
303
- if (!response.value) {
304
- return null;
305
- }
306
- const accountInfo = toAccountInfo(fromKitAccount(response.value), dataSlice);
307
- return accountInfo;
308
- }
309
- async getProgramAccounts(programId, commitmentOrConfig) {
310
- const id = toKitAddressFromInput(programId);
311
- let localCommitment;
312
- let dataSlice;
313
- let filters;
314
- let encoding;
315
- let minContextSlot;
316
- let withContext = false;
317
- if (typeof commitmentOrConfig === "string") {
318
- localCommitment = normalizeCommitment(commitmentOrConfig);
319
- } else if (commitmentOrConfig) {
320
- localCommitment = normalizeCommitment(commitmentOrConfig.commitment);
321
- dataSlice = commitmentOrConfig.dataSlice;
322
- filters = commitmentOrConfig.filters;
323
- encoding = commitmentOrConfig.encoding;
324
- minContextSlot = toBigInt(commitmentOrConfig.minContextSlot);
325
- withContext = Boolean(commitmentOrConfig.withContext);
326
- }
327
- const requestOptions = {
328
- commitment: localCommitment ?? this.commitment ?? DEFAULT_COMMITMENT,
329
- withContext
330
- };
331
- if (dataSlice) {
332
- requestOptions.dataSlice = {
333
- length: dataSlice.length,
334
- offset: dataSlice.offset
335
- };
336
- }
337
- if (encoding) {
338
- requestOptions.encoding = encoding;
339
- }
340
- if (filters) {
341
- requestOptions.filters = filters.map((filter) => filter);
342
- }
343
- if (minContextSlot !== void 0) {
344
- requestOptions.minContextSlot = minContextSlot;
345
- }
346
- const result = await this.#client.rpc.getProgramAccounts(id, requestOptions).send();
347
- const mapProgramAccount = /* @__PURE__ */ __name((entry) => {
348
- const pubkey = new web3_js.PublicKey(entry.pubkey);
349
- return {
350
- account: toAccountInfo(fromKitAccount(entry.account), dataSlice),
351
- pubkey
352
- };
353
- }, "mapProgramAccount");
354
- if (withContext && typeof result.context !== "undefined") {
355
- const contextual = result;
356
- return {
357
- context: {
358
- apiVersion: contextual.context.apiVersion,
359
- slot: Number(contextual.context.slot)
360
- },
361
- value: contextual.value.map(mapProgramAccount)
362
- };
363
- }
364
- return result.map(mapProgramAccount);
365
- }
366
- async getSignatureStatuses(signatures, config) {
367
- const targetCommitment = normalizeCommitment(config?.commitment) ?? this.commitment ?? DEFAULT_COMMITMENT;
368
- const kitSignatures = signatures.map((signature) => signature);
369
- const response = await this.#client.rpc.getSignatureStatuses(kitSignatures, {
370
- commitment: targetCommitment,
371
- searchTransactionHistory: config?.searchTransactionHistory
372
- }).send();
373
- const context = response.context;
374
- const normalizedContext = {
375
- apiVersion: context?.apiVersion,
376
- slot: typeof context?.slot === "bigint" ? Number(context.slot) : context?.slot ?? 0
377
- };
378
- const normalizedValues = response.value.map(
379
- (status) => {
380
- if (!status) {
381
- return null;
382
- }
383
- const record = status;
384
- const slot = record.slot;
385
- const confirmations = record.confirmations;
386
- const normalizedConfirmations = confirmations === null ? null : confirmations === void 0 ? null : typeof confirmations === "bigint" ? Number(confirmations) : confirmations;
387
- return {
388
- err: record.err ?? null,
389
- confirmations: normalizedConfirmations,
390
- confirmationStatus: record.confirmationStatus,
391
- slot: slot === void 0 ? 0 : typeof slot === "bigint" ? Number(slot) : slot
392
- };
393
- }
394
- );
395
- return {
396
- context: normalizedContext,
397
- value: normalizedValues
398
- };
399
- }
400
- async sendRawTransaction(rawTransaction, options) {
401
- const wire = toBase64WireTransaction(rawTransaction);
402
- const preflightCommitment = normalizeCommitment(
403
- options?.preflightCommitment ?? options?.commitment
404
- ) ?? this.commitment ?? DEFAULT_COMMITMENT;
405
- const maxRetries = options?.maxRetries === void 0 ? void 0 : toBigInt(options.maxRetries);
406
- const minContextSlot = options?.minContextSlot === void 0 ? void 0 : toBigInt(options.minContextSlot);
407
- const plan = this.#client.rpc.sendTransaction(wire, {
408
- encoding: "base64",
409
- maxRetries,
410
- minContextSlot,
411
- preflightCommitment,
412
- skipPreflight: options?.skipPreflight
413
- });
414
- return await plan.send();
415
- }
416
- async confirmTransaction(signature, commitment) {
417
- const normalizedCommitment = normalizeCommitment(commitment);
418
- const response = await this.getSignatureStatuses([signature], {
419
- commitment: normalizedCommitment ?? this.commitment ?? DEFAULT_COMMITMENT,
420
- searchTransactionHistory: true
421
- });
422
- return {
423
- context: response.context,
424
- value: response.value[0] ?? null
425
- };
426
- }
427
- async simulateTransaction(transaction, config) {
428
- const wire = toBase64WireTransaction(transaction);
429
- const commitment = normalizeCommitment(config?.commitment) ?? this.commitment ?? DEFAULT_COMMITMENT;
430
- const baseConfig = {
431
- ...config ?? {},
432
- commitment
433
- };
434
- const mergedConfig = {
435
- ...DEFAULT_SIMULATION_CONFIG2,
436
- ...baseConfig,
437
- commitment
438
- };
439
- const normalizedConfig = mergedConfig.sigVerify === true && mergedConfig.replaceRecentBlockhash !== false ? { ...mergedConfig, replaceRecentBlockhash: false } : mergedConfig;
440
- const response = await this.#client.rpc.simulateTransaction(wire, normalizedConfig).send();
441
- return {
442
- context: {
443
- apiVersion: response.context?.apiVersion,
444
- slot: Number(response.context?.slot ?? 0)
445
- },
446
- value: response.value
447
- };
448
- }
449
- };
450
- var TRANSFER_INSTRUCTION_INDEX = 2;
451
- var SystemProgram = Object.freeze({
452
- ...web3_js.SystemProgram,
453
- transfer({ fromPubkey, toPubkey, lamports }) {
454
- const data = Buffer.alloc(12);
455
- data.writeUInt32LE(TRANSFER_INSTRUCTION_INDEX, 0);
456
- data.writeBigUInt64LE(BigInt(lamports), 4);
457
- return new web3_js.TransactionInstruction({
458
- data,
459
- keys: [
460
- { isSigner: true, isWritable: true, pubkey: fromPubkey },
461
- { isSigner: false, isWritable: true, pubkey: toPubkey }
462
- ],
463
- programId: web3_js.SystemProgram.programId
464
- });
465
- }
466
- });
467
- var LAMPORTS_PER_SOL = web3_js.LAMPORTS_PER_SOL;
468
- function serializeTransactionBytes(input) {
469
- if (input instanceof web3_js.VersionedTransaction) {
470
- return input.serialize();
471
- }
472
- return input.serialize({ requireAllSignatures: false });
473
- }
474
- __name(serializeTransactionBytes, "serializeTransactionBytes");
475
- function compileFromCompat(transaction) {
476
- const bytes = serializeTransactionBytes(transaction);
477
- return Buffer.from(bytes).toString("base64");
478
- }
479
- __name(compileFromCompat, "compileFromCompat");
480
- function applySigners(transaction, signers = []) {
481
- if (!signers.length) {
482
- return;
483
- }
484
- if (transaction instanceof web3_js.VersionedTransaction) {
485
- transaction.sign([...signers]);
486
- } else {
487
- transaction.partialSign(...signers);
488
- }
489
- }
490
- __name(applySigners, "applySigners");
491
- async function sendAndConfirmTransaction(connection, transaction, signers = [], options = {}) {
492
- applySigners(transaction, signers);
493
- const serialized = compileFromCompat(transaction);
494
- const raw = Buffer.from(serialized, "base64");
495
- const signature = await connection.sendRawTransaction(raw, options);
496
- const commitment = options.commitment ?? connection.commitment ?? "confirmed";
497
- const confirmation = await connection.confirmTransaction(signature, commitment);
498
- if (confirmation.value?.err) {
499
- throw new Error("Transaction failed");
500
- }
501
- return signature;
502
- }
503
- __name(sendAndConfirmTransaction, "sendAndConfirmTransaction");
504
-
505
- Object.defineProperty(exports, "Keypair", {
506
- enumerable: true,
507
- get: function () { return web3_js.Keypair; }
508
- });
509
- Object.defineProperty(exports, "PublicKey", {
510
- enumerable: true,
511
- get: function () { return web3_js.PublicKey; }
512
- });
513
- Object.defineProperty(exports, "Transaction", {
514
- enumerable: true,
515
- get: function () { return web3_js.Transaction; }
516
- });
517
- Object.defineProperty(exports, "TransactionInstruction", {
518
- enumerable: true,
519
- get: function () { return web3_js.TransactionInstruction; }
520
- });
521
- Object.defineProperty(exports, "VersionedTransaction", {
522
- enumerable: true,
523
- get: function () { return web3_js.VersionedTransaction; }
524
- });
525
- exports.Connection = Connection;
526
- exports.LAMPORTS_PER_SOL = LAMPORTS_PER_SOL;
527
- exports.SystemProgram = SystemProgram;
528
- exports.compileFromCompat = compileFromCompat;
529
- exports.fromWeb3Instruction = fromWeb3Instruction;
530
- exports.sendAndConfirmTransaction = sendAndConfirmTransaction;
531
- exports.toAddress = toAddress;
532
- exports.toKitSigner = toKitSigner;
533
- exports.toPublicKey = toPublicKey;
534
- exports.toWeb3Instruction = toWeb3Instruction;
535
- //# sourceMappingURL=index.browser.cjs.map
536
- //# sourceMappingURL=index.browser.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/bridges.ts","../../client/src/rpc/createSolanaRpcClient.ts","../src/connection.ts","../src/programs/system-program.ts","../src/utils.ts"],"names":["PublicKey","fromLegacyPublicKey","createKeyPairSignerFromBytes","AccountRole","TransactionInstruction","fromLegacyTransactionInstruction","createSolanaRpc","createSolanaRpcSubscriptions","sendAndConfirmTransaction","getBase64EncodedWireTransaction","createBlockHeightExceedencePromiseFactory","createRecentSignatureConfirmationPromiseFactory","waitForRecentTransactionConfirmation","DEFAULT_SIMULATION_CONFIG","Transaction","VersionedTransaction","Web3SystemProgram","WEB3_LAMPORTS_PER_SOL","VersionedTransactionClass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AkB,WAAW,CAAA;AAChD,EAAA,MAAM,GAAA,GAAM,MAAA,CAAO,IAAA,CAAK,UAAA,EAAY,QAAQ,CAAA;AAC5C,EAAA,MAAM,SAAA,GAAY,MAAM,UAAA,CAAW,kBAAA,CAAmB,KAAK,OAAO,CAAA;AAClE,EAAA,MAAM,UAAA,GAAa,OAAA,CAAQ,UAAA,IAAc,UAAA,CAAW,UAAA,IAAc,WAAA;AAClE,EAAA,MAAM,YAAA,GAAe,MAAM,UAAA,CAAW,kBAAA,CAAmB,WAAW,UAAU,CAAA;AAC9E,EAAA,IAAI,YAAA,CAAa,OAAO,GAAA,EAAK;AAC5B,IAAA,MAAM,IAAI,MAAM,oBAAoB,CAAA;AAAA,EACrC;AACA,EAAA,OAAO,SAAA;AACR;AAhBsB,MAAA,CAAA,yBAAA,EAAA,2BAAA,CAAA","file":"index.browser.cjs","sourcesContent":["import type { Address } from '@solana/addresses';\nimport { fromLegacyPublicKey, fromLegacyTransactionInstruction } from '@solana/compat';\nimport { AccountRole, createKeyPairSignerFromBytes, type Instruction, type KeyPairSigner } from '@solana/kit';\nimport { type Keypair, PublicKey, type PublicKeyInitData, TransactionInstruction } from '@solana/web3.js';\n\ntype WithOptionalExtractable = Readonly<{\n\textractable?: boolean;\n}>;\n\nexport type ToKitSignerConfig = WithOptionalExtractable;\n\nexport function toAddress<TAddress extends string = string>(input: PublicKey | PublicKeyInitData): Address<TAddress> {\n\tconst pubkey = input instanceof PublicKey ? input : new PublicKey(input);\n\treturn fromLegacyPublicKey(pubkey);\n}\n\nexport function toPublicKey(input: Address | PublicKeyInitData): PublicKey {\n\tif (input instanceof PublicKey) {\n\t\treturn input;\n\t}\n\tif (typeof input === 'string') {\n\t\treturn new PublicKey(input);\n\t}\n\treturn new PublicKey(input);\n}\n\nexport async function toKitSigner(keypair: Keypair, config: ToKitSignerConfig = {}): Promise<KeyPairSigner> {\n\tconst secretKey = new Uint8Array(64);\n\tsecretKey.set(keypair.secretKey);\n\tsecretKey.set(keypair.publicKey.toBytes(), 32);\n\treturn await createKeyPairSignerFromBytes(secretKey, config.extractable ?? false);\n}\n\nexport function toWeb3Instruction(kitInstruction: Instruction): TransactionInstruction {\n\tconst keys =\n\t\tkitInstruction.accounts?.map((account) => {\n\t\t\tconst role = account.role;\n\t\t\tconst isSigner = role === AccountRole.READONLY_SIGNER || role === AccountRole.WRITABLE_SIGNER;\n\t\t\tconst isWritable = role === AccountRole.WRITABLE || role === AccountRole.WRITABLE_SIGNER;\n\t\t\treturn {\n\t\t\t\tisSigner,\n\t\t\t\tisWritable,\n\t\t\t\tpubkey: toPublicKey(account.address),\n\t\t\t};\n\t\t}) ?? [];\n\n\tconst data = kitInstruction.data ? Buffer.from(kitInstruction.data) : Buffer.alloc(0);\n\treturn new TransactionInstruction({\n\t\tdata,\n\t\tkeys,\n\t\tprogramId: toPublicKey(kitInstruction.programAddress),\n\t});\n}\n\nexport function fromWeb3Instruction(legacyInstruction: TransactionInstruction): Instruction {\n\treturn fromLegacyTransactionInstruction(legacyInstruction);\n}\n","import {\n\ttype ClusterUrl,\n\ttype Commitment,\n\tcreateSolanaRpc,\n\tcreateSolanaRpcSubscriptions,\n\tgetBase64EncodedWireTransaction,\n\ttype SendableTransaction,\n\ttype Signature,\n\ttype Transaction,\n} from '@solana/kit';\nimport type { TransactionWithLastValidBlockHeight } from '@solana/transaction-confirmation';\nimport {\n\tcreateBlockHeightExceedencePromiseFactory,\n\tcreateRecentSignatureConfirmationPromiseFactory,\n\twaitForRecentTransactionConfirmation,\n} from '@solana/transaction-confirmation';\n\ntype SolanaRpcInstance = ReturnType<typeof createSolanaRpc>;\ntype SolanaRpcSubscriptionsInstance = ReturnType<typeof createSolanaRpcSubscriptions>;\n\ntype ConfirmableTransaction = SendableTransaction & Transaction & TransactionWithLastValidBlockHeight;\n\ntype SimulateTransactionPlan = ReturnType<SolanaRpcInstance['simulateTransaction']>;\ntype SimulateTransactionConfig = Parameters<SolanaRpcInstance['simulateTransaction']>[1];\ntype SimulateTransactionResult = Awaited<ReturnType<SimulateTransactionPlan['send']>>;\n\nexport type SendAndConfirmTransactionOptions = Readonly<{\n\tabortSignal?: AbortSignal;\n\tcommitment?: Commitment;\n\tmaxRetries?: bigint | number;\n\tminContextSlot?: bigint | number;\n\tskipPreflight?: boolean;\n}>;\n\nexport type SimulateTransactionOptions = Readonly<{\n\tabortSignal?: AbortSignal;\n\tcommitment?: Commitment;\n\tconfig?: SimulateTransactionConfig;\n}>;\n\nexport type SolanaRpcClient = Readonly<{\n\tcommitment: Commitment;\n\tendpoint: ClusterUrl;\n\trpc: SolanaRpcInstance;\n\trpcSubscriptions: SolanaRpcSubscriptionsInstance;\n\tsendAndConfirmTransaction(\n\t\ttransaction: ConfirmableTransaction,\n\t\toptions?: SendAndConfirmTransactionOptions,\n\t): Promise<Signature>;\n\tsimulateTransaction(\n\t\ttransaction: SendableTransaction & Transaction,\n\t\toptions?: SimulateTransactionOptions,\n\t): Promise<SimulateTransactionResult>;\n\twebsocketEndpoint: ClusterUrl;\n}>;\n\nexport type CreateSolanaRpcClientConfig = Readonly<{\n\tcommitment?: Commitment;\n\tendpoint: ClusterUrl;\n\trpcConfig?: Parameters<typeof createSolanaRpc>[1];\n\trpcSubscriptionsConfig?: Parameters<typeof createSolanaRpcSubscriptions>[1];\n\twebsocketEndpoint?: ClusterUrl;\n}>;\n\nfunction createChainedAbortController(parent?: AbortSignal): AbortController {\n\tconst controller = new AbortController();\n\tif (!parent) {\n\t\treturn controller;\n\t}\n\tif (parent.aborted) {\n\t\tcontroller.abort(parent.reason);\n\t\treturn controller;\n\t}\n\tconst onAbort = () => {\n\t\tcontroller.abort(parent.reason);\n\t\tparent.removeEventListener('abort', onAbort);\n\t};\n\tparent.addEventListener('abort', onAbort, { once: true });\n\treturn controller;\n}\n\nfunction toBigint(value?: number | bigint): bigint | undefined {\n\tif (value === undefined) {\n\t\treturn undefined;\n\t}\n\treturn typeof value === 'bigint' ? value : BigInt(Math.floor(value));\n}\n\nconst DEFAULT_SIMULATION_CONFIG = Object.freeze({\n\tencoding: 'base64' as const,\n\treplaceRecentBlockhash: true as const,\n\tsigVerify: false as const,\n});\n\n/**\n * Creates a lightweight RPC client that wires up JSON-RPC, subscriptions, and common helpers.\n */\nexport function createSolanaRpcClient(config: CreateSolanaRpcClientConfig): SolanaRpcClient {\n\tconst endpoint = config.endpoint;\n\tconst websocketEndpoint = config.websocketEndpoint ?? endpoint;\n\tconst commitment = config.commitment ?? 'confirmed';\n\tconst rpc = createSolanaRpc(endpoint, config.rpcConfig);\n\tconst rpcSubscriptions = createSolanaRpcSubscriptions(websocketEndpoint, config.rpcSubscriptionsConfig);\n\n\tasync function sendAndConfirmTransaction(\n\t\ttransaction: ConfirmableTransaction,\n\t\toptions: SendAndConfirmTransactionOptions = {},\n\t): Promise<Signature> {\n\t\tconst abortController = createChainedAbortController(options.abortSignal);\n\t\tconst targetCommitment = options.commitment ?? commitment;\n\t\tconst wireTransaction = getBase64EncodedWireTransaction(transaction);\n\t\tconst response = await rpc\n\t\t\t.sendTransaction(wireTransaction, {\n\t\t\t\tencoding: 'base64',\n\t\t\t\tmaxRetries: toBigint(options.maxRetries),\n\t\t\t\tminContextSlot: toBigint(options.minContextSlot),\n\t\t\t\tpreflightCommitment: targetCommitment,\n\t\t\t\tskipPreflight: options.skipPreflight,\n\t\t\t})\n\t\t\t.send({ abortSignal: abortController.signal });\n\n\t\tconst getBlockHeightExceedencePromise = createBlockHeightExceedencePromiseFactory({\n\t\t\trpc: rpc as Parameters<typeof createBlockHeightExceedencePromiseFactory>[0]['rpc'],\n\t\t\trpcSubscriptions: rpcSubscriptions as Parameters<\n\t\t\t\ttypeof createBlockHeightExceedencePromiseFactory\n\t\t\t>[0]['rpcSubscriptions'],\n\t\t});\n\t\tconst getRecentSignatureConfirmationPromise = createRecentSignatureConfirmationPromiseFactory({\n\t\t\trpc: rpc as Parameters<typeof createRecentSignatureConfirmationPromiseFactory>[0]['rpc'],\n\t\t\trpcSubscriptions: rpcSubscriptions as Parameters<\n\t\t\t\ttypeof createRecentSignatureConfirmationPromiseFactory\n\t\t\t>[0]['rpcSubscriptions'],\n\t\t});\n\n\t\tawait waitForRecentTransactionConfirmation({\n\t\t\tabortSignal: abortController.signal,\n\t\t\tcommitment: targetCommitment,\n\t\t\tgetBlockHeightExceedencePromise,\n\t\t\tgetRecentSignatureConfirmationPromise,\n\t\t\ttransaction,\n\t\t});\n\n\t\treturn response;\n\t}\n\n\tasync function simulateTransaction(\n\t\ttransaction: SendableTransaction & Transaction,\n\t\toptions: SimulateTransactionOptions = {},\n\t): Promise<SimulateTransactionResult> {\n\t\tconst wireTransaction = getBase64EncodedWireTransaction(transaction);\n\t\tconst baseConfig = (options.config ?? {}) as SimulateTransactionConfig;\n\t\tconst mergedConfig = {\n\t\t\t...DEFAULT_SIMULATION_CONFIG,\n\t\t\t...baseConfig,\n\t\t\tcommitment: baseConfig.commitment ?? options.commitment ?? commitment,\n\t\t};\n\t\tconst normalizedConfig =\n\t\t\tmergedConfig.sigVerify === true && mergedConfig.replaceRecentBlockhash !== false\n\t\t\t\t? { ...mergedConfig, replaceRecentBlockhash: false }\n\t\t\t\t: mergedConfig;\n\t\treturn rpc\n\t\t\t.simulateTransaction(wireTransaction, normalizedConfig as SimulateTransactionConfig)\n\t\t\t.send({ abortSignal: options.abortSignal });\n\t}\n\n\treturn {\n\t\tcommitment,\n\t\tendpoint,\n\t\trpc,\n\t\trpcSubscriptions,\n\t\tsendAndConfirmTransaction,\n\t\tsimulateTransaction,\n\t\twebsocketEndpoint,\n\t};\n}\n","import type { Address } from '@solana/addresses';\nimport { createSolanaRpcClient, type SolanaRpcClient } from '@solana/client';\nimport type { Commitment as KitCommitment, Signature } from '@solana/kit';\nimport type { Base64EncodedWireTransaction } from '@solana/transactions';\nimport {\n\ttype AccountInfo,\n\ttype ConnectionConfig,\n\ttype DataSlice,\n\ttype Commitment as LegacyCommitment,\n\tPublicKey,\n\ttype SendOptions,\n\ttype SignatureStatus,\n\ttype SignatureStatusConfig,\n\ttype SimulatedTransactionResponse,\n\ttype SimulateTransactionConfig,\n\tTransaction,\n\ttype TransactionSignature,\n\tVersionedTransaction,\n} from '@solana/web3.js';\n\nimport { toAddress as toKitAddress } from './bridges';\n\ntype NormalizedCommitment = 'processed' | 'confirmed' | 'finalized';\n\ntype RpcContext = Readonly<{\n\tapiVersion?: string;\n\tslot: number;\n}>;\n\ntype AccountInfoConfig = Readonly<{\n\tcommitment?: LegacyCommitment;\n\tdataSlice?: DataSlice;\n\tencoding?: 'base64';\n\tminContextSlot?: number;\n}>;\n\ntype ProgramAccountsConfig = Readonly<{\n\tcommitment?: LegacyCommitment;\n\tdataSlice?: DataSlice;\n\tencoding?: 'base64' | 'base64+zstd';\n\tfilters?: ReadonlyArray<unknown>;\n\tminContextSlot?: number;\n\twithContext?: boolean;\n}>;\n\ntype ConnectionCommitmentInput =\n\t| LegacyCommitment\n\t| (ConnectionConfig & {\n\t\t\tcommitment?: LegacyCommitment;\n\t })\n\t| undefined;\n\ntype RpcResponseWithContext<T> = Readonly<{\n\tcontext: RpcContext;\n\tvalue: T;\n}>;\n\ntype RawTransactionInput = number[] | Uint8Array | Buffer | Transaction | VersionedTransaction;\n\ntype RpcAccount = Readonly<{\n\tdata: readonly [string, string] | string;\n\texecutable: boolean;\n\tlamports: number | bigint;\n\towner: string;\n\trentEpoch: number | bigint;\n}>;\n\ntype ProgramAccountWire = Readonly<{\n\taccount: RpcAccount;\n\tpubkey: string;\n}>;\n\ntype ProgramAccountsWithContext = Readonly<{\n\tcontext: Readonly<{\n\t\tapiVersion?: string;\n\t\tslot: number | bigint;\n\t}>;\n\tvalue: readonly ProgramAccountWire[];\n}>;\n\ntype SignatureStatusConfigWithCommitment = SignatureStatusConfig & {\n\tcommitment?: LegacyCommitment;\n};\n\nconst DEFAULT_COMMITMENT: NormalizedCommitment = 'confirmed';\n\nconst DEFAULT_SIMULATION_CONFIG = Object.freeze({\n\tencoding: 'base64' as const,\n\treplaceRecentBlockhash: true as const,\n\tsigVerify: false as const,\n});\n\nfunction normalizeCommitment(commitment?: LegacyCommitment | null): NormalizedCommitment | undefined {\n\tif (commitment === undefined || commitment === null) {\n\t\treturn undefined;\n\t}\n\tif (commitment === 'recent') {\n\t\treturn 'processed';\n\t}\n\tif (commitment === 'singleGossip') {\n\t\treturn 'processed';\n\t}\n\tif (commitment === 'single') {\n\t\treturn 'confirmed';\n\t}\n\tif (commitment === 'max') {\n\t\treturn 'finalized';\n\t}\n\treturn commitment as NormalizedCommitment;\n}\n\nfunction toBigInt(value: number | bigint | undefined): bigint | undefined {\n\tif (value === undefined) return undefined;\n\treturn typeof value === 'bigint' ? value : BigInt(Math.trunc(value));\n}\n\nfunction toAccountInfo(info: RpcAccount, dataSlice?: DataSlice): AccountInfo<Buffer> {\n\tconst { data, executable, lamports, owner, rentEpoch } = info;\n\tconst [content, encoding] = Array.isArray(data) ? data : [data, 'base64'];\n\tlet buffer = encoding === 'base64' ? Buffer.from(content, 'base64') : Buffer.from(content);\n\tif (dataSlice) {\n\t\tconst start = dataSlice.offset ?? 0;\n\t\tconst end = start + (dataSlice.length ?? buffer.length);\n\t\tbuffer = buffer.subarray(start, end);\n\t}\n\treturn {\n\t\tdata: buffer,\n\t\texecutable,\n\t\tlamports: typeof lamports === 'number' ? lamports : Number(lamports),\n\t\towner: new PublicKey(owner),\n\t\trentEpoch: typeof rentEpoch === 'number' ? rentEpoch : Number(rentEpoch),\n\t};\n}\n\nfunction fromKitAccount(value: unknown): RpcAccount {\n\tconst account = (value ?? {}) as Record<string, unknown>;\n\tconst data = account.data as string | readonly [string, string] | undefined;\n\tconst lamports = account.lamports as number | bigint | undefined;\n\tconst ownerValue = account.owner as unknown;\n\tconst rentEpoch = account.rentEpoch as number | bigint | undefined;\n\tconst owner =\n\t\ttypeof ownerValue === 'string'\n\t\t\t? ownerValue\n\t\t\t: ownerValue instanceof PublicKey\n\t\t\t\t? ownerValue.toBase58()\n\t\t\t\t: typeof ownerValue === 'object' && ownerValue !== null && 'toString' in ownerValue\n\t\t\t\t\t? String(ownerValue)\n\t\t\t\t\t: '11111111111111111111111111111111';\n\treturn {\n\t\tdata: data ?? ['', 'base64'],\n\t\texecutable: Boolean(account.executable),\n\t\tlamports: lamports ?? 0,\n\t\towner,\n\t\trentEpoch: rentEpoch ?? 0,\n\t};\n}\n\nfunction toKitAddressFromInput(input: PublicKey | string): Address<string> {\n\treturn toKitAddress(input instanceof PublicKey ? input : input);\n}\n\nfunction toBase64WireTransaction(raw: RawTransactionInput): Base64EncodedWireTransaction {\n\tif (raw instanceof Transaction || raw instanceof VersionedTransaction) {\n\t\tconst bytes = raw.serialize({\n\t\t\trequireAllSignatures: false,\n\t\t\tverifySignatures: false,\n\t\t});\n\t\treturn Buffer.from(bytes).toString('base64') as Base64EncodedWireTransaction;\n\t}\n\tif (raw instanceof Uint8Array) {\n\t\treturn Buffer.from(raw).toString('base64') as Base64EncodedWireTransaction;\n\t}\n\tif (raw instanceof Buffer) {\n\t\treturn raw.toString('base64') as Base64EncodedWireTransaction;\n\t}\n\tconst uint8 = Uint8Array.from(raw);\n\treturn Buffer.from(uint8).toString('base64') as Base64EncodedWireTransaction;\n}\n\nexport class Connection {\n\treadonly commitment?: NormalizedCommitment;\n\treadonly rpcEndpoint: string;\n\n\t#client: SolanaRpcClient;\n\n\tconstructor(endpoint: string, commitmentOrConfig?: ConnectionCommitmentInput) {\n\t\tconst commitment =\n\t\t\ttypeof commitmentOrConfig === 'string'\n\t\t\t\t? normalizeCommitment(commitmentOrConfig)\n\t\t\t\t: (normalizeCommitment(commitmentOrConfig?.commitment) ?? DEFAULT_COMMITMENT);\n\n\t\tconst websocketEndpoint =\n\t\t\ttypeof commitmentOrConfig === 'object' && commitmentOrConfig !== null\n\t\t\t\t? commitmentOrConfig.wsEndpoint\n\t\t\t\t: undefined;\n\n\t\tthis.commitment = commitment;\n\t\tthis.rpcEndpoint = endpoint;\n\t\tthis.#client = createSolanaRpcClient({\n\t\t\tendpoint,\n\t\t\twebsocketEndpoint,\n\t\t\tcommitment: (commitment ?? DEFAULT_COMMITMENT) as KitCommitment,\n\t\t});\n\t}\n\n\tasync getLatestBlockhash(\n\t\tcommitmentOrConfig?:\n\t\t\t| LegacyCommitment\n\t\t\t| {\n\t\t\t\t\tcommitment?: LegacyCommitment;\n\t\t\t\t\tmaxSupportedTransactionVersion?: number;\n\t\t\t\t\tminContextSlot?: number;\n\t\t\t },\n\t): Promise<{\n\t\tblockhash: string;\n\t\tlastValidBlockHeight: number;\n\t}> {\n\t\tconst baseCommitment =\n\t\t\ttypeof commitmentOrConfig === 'string' ? commitmentOrConfig : commitmentOrConfig?.commitment;\n\t\tconst commitment = normalizeCommitment(baseCommitment) ?? this.commitment ?? DEFAULT_COMMITMENT;\n\t\tconst minContextSlot =\n\t\t\ttypeof commitmentOrConfig === 'object' ? toBigInt(commitmentOrConfig.minContextSlot) : undefined;\n\t\tconst requestOptions: Record<string, unknown> = {\n\t\t\tcommitment: commitment as KitCommitment,\n\t\t};\n\t\tif (minContextSlot !== undefined) {\n\t\t\trequestOptions.minContextSlot = minContextSlot;\n\t\t}\n\t\tif (\n\t\t\ttypeof commitmentOrConfig === 'object' &&\n\t\t\tcommitmentOrConfig?.maxSupportedTransactionVersion !== undefined\n\t\t) {\n\t\t\trequestOptions.maxSupportedTransactionVersion = commitmentOrConfig.maxSupportedTransactionVersion;\n\t\t}\n\t\tconst response = await this.#client.rpc.getLatestBlockhash(requestOptions as never).send();\n\n\t\treturn {\n\t\t\tblockhash: response.value.blockhash,\n\t\t\tlastValidBlockHeight: Number(response.value.lastValidBlockHeight),\n\t\t};\n\t}\n\n\tasync getBalance(publicKey: PublicKey | string, commitment?: LegacyCommitment): Promise<number> {\n\t\tconst address = toKitAddressFromInput(publicKey);\n\t\tconst chosenCommitment = normalizeCommitment(commitment) ?? this.commitment ?? DEFAULT_COMMITMENT;\n\t\tconst result = await this.#client.rpc\n\t\t\t.getBalance(address, { commitment: chosenCommitment as KitCommitment })\n\t\t\t.send();\n\t\treturn typeof result.value === 'number' ? result.value : Number(result.value);\n\t}\n\n\tasync getAccountInfo<TAccountData = Buffer>(\n\t\tpublicKey: PublicKey | string,\n\t\tcommitmentOrConfig?: AccountInfoConfig | LegacyCommitment,\n\t): Promise<AccountInfo<TAccountData> | null> {\n\t\tconst address = toKitAddressFromInput(publicKey);\n\t\tlet localCommitment: NormalizedCommitment | undefined;\n\t\tlet minContextSlot: bigint | undefined;\n\t\tlet dataSlice: DataSlice | undefined;\n\t\tlet encoding: 'base64' | undefined;\n\t\tif (typeof commitmentOrConfig === 'string') {\n\t\t\tlocalCommitment = normalizeCommitment(commitmentOrConfig);\n\t\t} else if (commitmentOrConfig) {\n\t\t\tlocalCommitment = normalizeCommitment(commitmentOrConfig.commitment);\n\t\t\tif (commitmentOrConfig.minContextSlot !== undefined) {\n\t\t\t\tminContextSlot = toBigInt(commitmentOrConfig.minContextSlot);\n\t\t\t}\n\t\t\tdataSlice = commitmentOrConfig.dataSlice;\n\t\t\tencoding = commitmentOrConfig.encoding;\n\t\t}\n\n\t\tconst requestOptions: Record<string, unknown> = {\n\t\t\tcommitment: (localCommitment ?? this.commitment ?? DEFAULT_COMMITMENT) as KitCommitment,\n\t\t};\n\t\tif (minContextSlot !== undefined) {\n\t\t\trequestOptions.minContextSlot = minContextSlot;\n\t\t}\n\t\tif (encoding) {\n\t\t\trequestOptions.encoding = encoding;\n\t\t}\n\t\tif (dataSlice) {\n\t\t\trequestOptions.dataSlice = {\n\t\t\t\tlength: dataSlice.length,\n\t\t\t\toffset: dataSlice.offset,\n\t\t\t};\n\t\t}\n\n\t\tconst response = await this.#client.rpc.getAccountInfo(address, requestOptions as never).send();\n\n\t\tif (!response.value) {\n\t\t\treturn null;\n\t\t}\n\t\tconst accountInfo = toAccountInfo(fromKitAccount(response.value), dataSlice);\n\n\t\treturn accountInfo as AccountInfo<TAccountData>;\n\t}\n\n\tasync getProgramAccounts(\n\t\tprogramId: PublicKey | string,\n\t\tcommitmentOrConfig?: LegacyCommitment | ProgramAccountsConfig,\n\t): Promise<\n\t\t| Array<{\n\t\t\t\taccount: AccountInfo<Buffer | object>;\n\t\t\t\tpubkey: PublicKey;\n\t\t }>\n\t\t| RpcResponseWithContext<\n\t\t\t\tArray<{\n\t\t\t\t\taccount: AccountInfo<Buffer | object>;\n\t\t\t\t\tpubkey: PublicKey;\n\t\t\t\t}>\n\t\t >\n\t> {\n\t\tconst id = toKitAddressFromInput(programId);\n\t\tlet localCommitment: NormalizedCommitment | undefined;\n\t\tlet dataSlice: DataSlice | undefined;\n\t\tlet filters: ReadonlyArray<unknown> | undefined;\n\t\tlet encoding: 'base64' | 'base64+zstd' | undefined;\n\t\tlet minContextSlot: bigint | undefined;\n\t\tlet withContext = false;\n\t\tif (typeof commitmentOrConfig === 'string') {\n\t\t\tlocalCommitment = normalizeCommitment(commitmentOrConfig);\n\t\t} else if (commitmentOrConfig) {\n\t\t\tlocalCommitment = normalizeCommitment(commitmentOrConfig.commitment);\n\t\t\tdataSlice = commitmentOrConfig.dataSlice;\n\t\t\tfilters = commitmentOrConfig.filters;\n\t\t\tencoding = commitmentOrConfig.encoding;\n\t\t\tminContextSlot = toBigInt(commitmentOrConfig.minContextSlot);\n\t\t\twithContext = Boolean(commitmentOrConfig.withContext);\n\t\t}\n\n\t\tconst requestOptions: Record<string, unknown> = {\n\t\t\tcommitment: (localCommitment ?? this.commitment ?? DEFAULT_COMMITMENT) as KitCommitment,\n\t\t\twithContext,\n\t\t};\n\t\tif (dataSlice) {\n\t\t\trequestOptions.dataSlice = {\n\t\t\t\tlength: dataSlice.length,\n\t\t\t\toffset: dataSlice.offset,\n\t\t\t};\n\t\t}\n\t\tif (encoding) {\n\t\t\trequestOptions.encoding = encoding;\n\t\t}\n\t\tif (filters) {\n\t\t\trequestOptions.filters = filters.map((filter) => filter as never);\n\t\t}\n\t\tif (minContextSlot !== undefined) {\n\t\t\trequestOptions.minContextSlot = minContextSlot;\n\t\t}\n\n\t\tconst result = await this.#client.rpc.getProgramAccounts(id, requestOptions as never).send();\n\n\t\tconst mapProgramAccount = (entry: ProgramAccountWire) => {\n\t\t\tconst pubkey = new PublicKey(entry.pubkey);\n\t\t\treturn {\n\t\t\t\taccount: toAccountInfo(fromKitAccount(entry.account), dataSlice),\n\t\t\t\tpubkey,\n\t\t\t};\n\t\t};\n\n\t\tif (withContext && typeof (result as unknown as ProgramAccountsWithContext).context !== 'undefined') {\n\t\t\tconst contextual = result as unknown as ProgramAccountsWithContext;\n\t\t\treturn {\n\t\t\t\tcontext: {\n\t\t\t\t\tapiVersion: contextual.context.apiVersion,\n\t\t\t\t\tslot: Number(contextual.context.slot),\n\t\t\t\t},\n\t\t\t\tvalue: contextual.value.map(mapProgramAccount),\n\t\t\t};\n\t\t}\n\n\t\treturn (result as unknown as readonly ProgramAccountWire[]).map(mapProgramAccount);\n\t}\n\n\tasync getSignatureStatuses(\n\t\tsignatures: readonly TransactionSignature[],\n\t\tconfig?: SignatureStatusConfigWithCommitment,\n\t): Promise<RpcResponseWithContext<(SignatureStatus | null)[]>> {\n\t\tconst targetCommitment = normalizeCommitment(config?.commitment) ?? this.commitment ?? DEFAULT_COMMITMENT;\n\t\tconst kitSignatures = signatures.map((signature) => signature as unknown as Signature);\n\t\tconst response = await this.#client.rpc\n\t\t\t.getSignatureStatuses(kitSignatures, {\n\t\t\t\tcommitment: targetCommitment as KitCommitment,\n\t\t\t\tsearchTransactionHistory: config?.searchTransactionHistory,\n\t\t\t} as never)\n\t\t\t.send();\n\n\t\tconst context = response.context as { slot: number | bigint; apiVersion?: string };\n\t\tconst normalizedContext: RpcContext = {\n\t\t\tapiVersion: context?.apiVersion,\n\t\t\tslot: typeof context?.slot === 'bigint' ? Number(context.slot) : (context?.slot ?? 0),\n\t\t};\n\n\t\tconst normalizedValues = (response.value as readonly (SignatureStatus | null | Record<string, unknown>)[]).map(\n\t\t\t(status) => {\n\t\t\t\tif (!status) {\n\t\t\t\t\treturn null;\n\t\t\t\t}\n\t\t\t\tconst record = status as Record<string, unknown>;\n\t\t\t\tconst slot = record.slot as number | bigint | undefined;\n\t\t\t\tconst confirmations = record.confirmations as number | bigint | null | undefined;\n\t\t\t\tconst normalizedConfirmations =\n\t\t\t\t\tconfirmations === null\n\t\t\t\t\t\t? null\n\t\t\t\t\t\t: confirmations === undefined\n\t\t\t\t\t\t\t? null\n\t\t\t\t\t\t\t: typeof confirmations === 'bigint'\n\t\t\t\t\t\t\t\t? Number(confirmations)\n\t\t\t\t\t\t\t\t: confirmations;\n\t\t\t\treturn {\n\t\t\t\t\terr: (record.err ?? null) as SignatureStatus['err'],\n\t\t\t\t\tconfirmations: normalizedConfirmations,\n\t\t\t\t\tconfirmationStatus: record.confirmationStatus as SignatureStatus['confirmationStatus'],\n\t\t\t\t\tslot: slot === undefined ? 0 : typeof slot === 'bigint' ? Number(slot) : slot,\n\t\t\t\t} satisfies SignatureStatus;\n\t\t\t},\n\t\t);\n\n\t\treturn {\n\t\t\tcontext: normalizedContext,\n\t\t\tvalue: normalizedValues as (SignatureStatus | null)[],\n\t\t};\n\t}\n\tasync sendRawTransaction(rawTransaction: RawTransactionInput, options?: SendOptions): Promise<string> {\n\t\tconst wire = toBase64WireTransaction(rawTransaction);\n\n\t\tconst preflightCommitment =\n\t\t\tnormalizeCommitment(\n\t\t\t\toptions?.preflightCommitment ??\n\t\t\t\t\t(options as (SendOptions & { commitment?: LegacyCommitment }) | undefined)?.commitment,\n\t\t\t) ??\n\t\t\tthis.commitment ??\n\t\t\tDEFAULT_COMMITMENT;\n\t\tconst maxRetries = options?.maxRetries === undefined ? undefined : toBigInt(options.maxRetries);\n\t\tconst minContextSlot = options?.minContextSlot === undefined ? undefined : toBigInt(options.minContextSlot);\n\t\tconst plan = this.#client.rpc.sendTransaction(wire, {\n\t\t\tencoding: 'base64',\n\t\t\tmaxRetries,\n\t\t\tminContextSlot,\n\t\t\tpreflightCommitment: preflightCommitment as KitCommitment,\n\t\t\tskipPreflight: options?.skipPreflight,\n\t\t});\n\n\t\treturn await plan.send();\n\t}\n\n\tasync confirmTransaction(\n\t\tsignature: TransactionSignature,\n\t\tcommitment?: LegacyCommitment,\n\t): Promise<RpcResponseWithContext<SignatureStatus | null>> {\n\t\tconst normalizedCommitment = normalizeCommitment(commitment);\n\t\tconst response = await this.getSignatureStatuses([signature], {\n\t\t\tcommitment: normalizedCommitment ?? this.commitment ?? DEFAULT_COMMITMENT,\n\t\t\tsearchTransactionHistory: true,\n\t\t});\n\n\t\treturn {\n\t\t\tcontext: response.context,\n\t\t\tvalue: response.value[0] ?? null,\n\t\t};\n\t}\n\n\tasync simulateTransaction(\n\t\ttransaction: RawTransactionInput,\n\t\tconfig?: SimulateTransactionConfig,\n\t): Promise<RpcResponseWithContext<SimulatedTransactionResponse>> {\n\t\tconst wire = toBase64WireTransaction(transaction);\n\t\tconst commitment = normalizeCommitment(config?.commitment) ?? this.commitment ?? DEFAULT_COMMITMENT;\n\t\tconst baseConfig = {\n\t\t\t...(config ?? {}),\n\t\t\tcommitment,\n\t\t};\n\t\tconst mergedConfig = {\n\t\t\t...DEFAULT_SIMULATION_CONFIG,\n\t\t\t...baseConfig,\n\t\t\tcommitment: commitment as KitCommitment,\n\t\t};\n\t\tconst normalizedConfig =\n\t\t\tmergedConfig.sigVerify === true && mergedConfig.replaceRecentBlockhash !== false\n\t\t\t\t? { ...mergedConfig, replaceRecentBlockhash: false }\n\t\t\t\t: mergedConfig;\n\n\t\tconst response = await this.#client.rpc.simulateTransaction(wire, normalizedConfig as never).send();\n\n\t\treturn {\n\t\t\tcontext: {\n\t\t\t\tapiVersion: (response.context as Record<string, unknown>)?.apiVersion as string | undefined,\n\t\t\t\tslot: Number((response.context as Record<string, unknown>)?.slot ?? 0),\n\t\t\t},\n\t\t\tvalue: response.value as unknown as SimulatedTransactionResponse,\n\t\t};\n\t}\n}\n","import { type PublicKey, TransactionInstruction, SystemProgram as Web3SystemProgram } from '@solana/web3.js';\n\ntype TransferParams = Readonly<{\n\tfromPubkey: PublicKey;\n\tlamports: number | bigint;\n\ttoPubkey: PublicKey;\n}>;\n\nconst TRANSFER_INSTRUCTION_INDEX = 2;\n\nexport const SystemProgram = Object.freeze({\n\t...Web3SystemProgram,\n\ttransfer({ fromPubkey, toPubkey, lamports }: TransferParams): TransactionInstruction {\n\t\tconst data = Buffer.alloc(12);\n\t\tdata.writeUInt32LE(TRANSFER_INSTRUCTION_INDEX, 0);\n\t\tdata.writeBigUInt64LE(BigInt(lamports), 4);\n\t\treturn new TransactionInstruction({\n\t\t\tdata,\n\t\t\tkeys: [\n\t\t\t\t{ isSigner: true, isWritable: true, pubkey: fromPubkey },\n\t\t\t\t{ isSigner: false, isWritable: true, pubkey: toPubkey },\n\t\t\t],\n\t\t\tprogramId: Web3SystemProgram.programId,\n\t\t});\n\t},\n});\n","import type {\n\tCommitment,\n\tTransaction as LegacyTransaction,\n\tVersionedTransaction as LegacyVersionedTransaction,\n\tSendOptions,\n\tSigner,\n} from '@solana/web3.js';\nimport {\n\tVersionedTransaction as VersionedTransactionClass,\n\tLAMPORTS_PER_SOL as WEB3_LAMPORTS_PER_SOL,\n} from '@solana/web3.js';\nimport type { Connection } from './connection';\n\nexport const LAMPORTS_PER_SOL = WEB3_LAMPORTS_PER_SOL;\n\ntype SendAndConfirmOptions = SendOptions & {\n\tcommitment?: Commitment;\n};\n\nfunction serializeTransactionBytes(input: LegacyTransaction | LegacyVersionedTransaction): Uint8Array {\n\tif (input instanceof VersionedTransactionClass) {\n\t\treturn input.serialize();\n\t}\n\treturn (input as LegacyTransaction).serialize({ requireAllSignatures: false });\n}\n\nexport function compileFromCompat(transaction: LegacyTransaction | LegacyVersionedTransaction): string {\n\tconst bytes = serializeTransactionBytes(transaction);\n\treturn Buffer.from(bytes).toString('base64');\n}\n\nfunction applySigners(\n\ttransaction: LegacyTransaction | LegacyVersionedTransaction,\n\tsigners: readonly Signer[] = [],\n): void {\n\tif (!signers.length) {\n\t\treturn;\n\t}\n\tif (transaction instanceof VersionedTransactionClass) {\n\t\ttransaction.sign([...signers]);\n\t} else {\n\t\t(transaction as LegacyTransaction).partialSign(...signers);\n\t}\n}\n\nexport async function sendAndConfirmTransaction(\n\tconnection: Connection,\n\ttransaction: LegacyTransaction | LegacyVersionedTransaction,\n\tsigners: readonly Signer[] = [],\n\toptions: SendAndConfirmOptions = {},\n): Promise<string> {\n\tapplySigners(transaction, signers);\n\tconst serialized = compileFromCompat(transaction);\n\tconst raw = Buffer.from(serialized, 'base64');\n\tconst signature = await connection.sendRawTransaction(raw, options);\n\tconst commitment = options.commitment ?? connection.commitment ?? 'confirmed';\n\tconst confirmation = await connection.confirmTransaction(signature, commitment);\n\tif (confirmation.value?.err) {\n\t\tthrow new Error('Transaction failed');\n\t}\n\treturn signature;\n}\n"]}