@solana/web3-compat 0.0.16 → 0.0.18
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/dist/index.browser.mjs +1 -1
- package/dist/index.native.mjs +1 -1
- package/dist/types/client/src/client/actions.d.ts +3 -1
- package/dist/types/client/src/client/actions.d.ts.map +1 -1
- package/dist/types/client/src/client/createClient.d.ts.map +1 -1
- package/dist/types/client/src/client/createClientHelpers.d.ts +2 -1
- package/dist/types/client/src/client/createClientHelpers.d.ts.map +1 -1
- package/dist/types/client/src/client/defaultClient.d.ts +2 -1
- package/dist/types/client/src/client/defaultClient.d.ts.map +1 -1
- package/dist/types/client/src/client/watchers.d.ts +2 -1
- package/dist/types/client/src/client/watchers.d.ts.map +1 -1
- package/dist/types/client/src/controllers/wsolController.d.ts +30 -0
- package/dist/types/client/src/controllers/wsolController.d.ts.map +1 -0
- package/dist/types/client/src/features/sol.d.ts +118 -2
- package/dist/types/client/src/features/sol.d.ts.map +1 -1
- package/dist/types/client/src/features/spl.d.ts +165 -2
- package/dist/types/client/src/features/spl.d.ts.map +1 -1
- package/dist/types/client/src/features/stake.d.ts +208 -2
- package/dist/types/client/src/features/stake.d.ts.map +1 -1
- package/dist/types/client/src/features/transactions.d.ts +2 -1
- package/dist/types/client/src/features/transactions.d.ts.map +1 -1
- package/dist/types/client/src/features/wsol.d.ts +254 -0
- package/dist/types/client/src/features/wsol.d.ts.map +1 -0
- package/dist/types/client/src/index.d.ts +5 -1
- package/dist/types/client/src/index.d.ts.map +1 -1
- package/dist/types/client/src/rpc/types.d.ts +8 -0
- package/dist/types/client/src/rpc/types.d.ts.map +1 -0
- package/dist/types/client/src/signers/walletTransactionSigner.d.ts +1 -1
- package/dist/types/client/src/signers/walletTransactionSigner.d.ts.map +1 -1
- package/dist/types/client/src/types.d.ts +6 -64
- package/dist/types/client/src/types.d.ts.map +1 -1
- package/dist/types/client/src/wallet/connectors.d.ts +1 -1
- package/dist/types/client/src/wallet/connectors.d.ts.map +1 -1
- package/dist/types/client/src/wallet/registry.d.ts +1 -1
- package/dist/types/client/src/wallet/registry.d.ts.map +1 -1
- package/dist/types/client/src/wallet/standard.d.ts +1 -1
- package/dist/types/client/src/wallet/standard.d.ts.map +1 -1
- package/dist/types/client/src/wallet/types.d.ts +60 -0
- package/dist/types/client/src/wallet/types.d.ts.map +1 -0
- package/package.json +2 -2
package/dist/index.browser.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {SystemProgram,TransactionInstruction,PublicKey,Transaction,VersionedTransaction,LAMPORTS_PER_SOL}from'@solana/web3.js';export{Keypair,PublicKey,Transaction,TransactionInstruction,VersionedTransaction}from'@solana/web3.js';import {fromLegacyPublicKey,fromLegacyTransactionInstruction}from'@solana/compat';import {createSolanaRpc,createSolanaRpcSubscriptions,getBase64EncodedWireTransaction,createKeyPairSignerFromBytes,AccountRole}from'@solana/kit';import {createBlockHeightExceedencePromiseFactory,createRecentSignatureConfirmationPromiseFactory,waitForRecentTransactionConfirmation}from'@solana/transaction-confirmation';var z=Object.defineProperty;var s=(e,n)=>z(e,"name",{value:n,configurable:true});function x(e){let n=e instanceof PublicKey?e:new PublicKey(e);return fromLegacyPublicKey(n)}s(x,"toAddress");function h(e){return e instanceof PublicKey?e:typeof e=="string"?new PublicKey(e):new PublicKey(e)}s(h,"toPublicKey");async function U(e,n={}){let t=new Uint8Array(64);return t.set(e.secretKey),t.set(e.publicKey.toBytes(),32),await createKeyPairSignerFromBytes(t,n.extractable??false)}s(U,"toKitSigner");function _(e){let n=e.accounts?.map(a=>{let o=a.role,i=o===AccountRole.READONLY_SIGNER||o===AccountRole.WRITABLE_SIGNER,r=o===AccountRole.WRITABLE||o===AccountRole.WRITABLE_SIGNER;return {isSigner:i,isWritable:r,pubkey:h(a.address)}})??[],t=e.data?Buffer.from(e.data):Buffer.alloc(0);return new TransactionInstruction({data:t,keys:n,programId:h(e.programAddress)})}s(_,"toWeb3Instruction");function H(e){return fromLegacyTransactionInstruction(e)}s(H,"fromWeb3Instruction");function X(e){let n=new AbortController;if(!e)return n;if(e.aborted)return n.abort(e.reason),n;let t=s(()=>{n.abort(e.reason),e.removeEventListener("abort",t);},"onAbort");return e.addEventListener("abort",t,{once:true}),n}s(X,"createChainedAbortController");function w(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.floor(e))}s(w,"toBigint");var Y=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function A(e){let n=e.endpoint,t=e.websocketEndpoint??n,a=e.commitment??"confirmed",o=createSolanaRpc(n,e.rpcConfig),i=createSolanaRpcSubscriptions(t,e.rpcSubscriptionsConfig);async function r(l,c={}){let p=X(c.abortSignal),u=c.commitment??a,f=getBase64EncodedWireTransaction(l),d=await o.sendTransaction(f,{encoding:"base64",maxRetries:w(c.maxRetries),minContextSlot:w(c.minContextSlot),preflightCommitment:u,skipPreflight:c.skipPreflight}).send({abortSignal:p.signal}),R=createBlockHeightExceedencePromiseFactory({rpc:o,rpcSubscriptions:i}),V=createRecentSignatureConfirmationPromiseFactory({rpc:o,rpcSubscriptions:i});return await waitForRecentTransactionConfirmation({abortSignal:p.signal,commitment:u,getBlockHeightExceedencePromise:R,getRecentSignatureConfirmationPromise:V,transaction:l}),d}s(r,"sendAndConfirmTransaction");async function m(l,c={}){let p=getBase64EncodedWireTransaction(l),u=c.config??{},f={...Y,...u,commitment:u.commitment??c.commitment??a},d=f.sigVerify===true&&f.replaceRecentBlockhash!==false?{...f,replaceRecentBlockhash:false}:f;return o.simulateTransaction(p,d).send({abortSignal:c.abortSignal})}return s(m,"simulateTransaction"),{commitment:a,endpoint:n,rpc:o,rpcSubscriptions:i,sendAndConfirmTransaction:r,simulateTransaction:m,websocketEndpoint:t}}s(A,"createSolanaRpcClient");var S="confirmed",$=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function y(e){if(e!=null)return e==="recent"||e==="singleGossip"?"processed":e==="single"?"confirmed":e==="max"?"finalized":e}s(y,"normalizeCommitment");function C(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.trunc(e))}s(C,"toBigInt");function
|
|
1
|
+
import {SystemProgram,TransactionInstruction,PublicKey,Transaction,VersionedTransaction,LAMPORTS_PER_SOL}from'@solana/web3.js';export{Keypair,PublicKey,Transaction,TransactionInstruction,VersionedTransaction}from'@solana/web3.js';import {fromLegacyPublicKey,fromLegacyTransactionInstruction}from'@solana/compat';import {createSolanaRpc,createSolanaRpcSubscriptions,getBase64EncodedWireTransaction,createKeyPairSignerFromBytes,AccountRole}from'@solana/kit';import {createBlockHeightExceedencePromiseFactory,createRecentSignatureConfirmationPromiseFactory,waitForRecentTransactionConfirmation}from'@solana/transaction-confirmation';var z=Object.defineProperty;var s=(e,n)=>z(e,"name",{value:n,configurable:true});function x(e){let n=e instanceof PublicKey?e:new PublicKey(e);return fromLegacyPublicKey(n)}s(x,"toAddress");function h(e){return e instanceof PublicKey?e:typeof e=="string"?new PublicKey(e):new PublicKey(e)}s(h,"toPublicKey");async function U(e,n={}){let t=new Uint8Array(64);return t.set(e.secretKey),t.set(e.publicKey.toBytes(),32),await createKeyPairSignerFromBytes(t,n.extractable??false)}s(U,"toKitSigner");function _(e){let n=e.accounts?.map(a=>{let o=a.role,i=o===AccountRole.READONLY_SIGNER||o===AccountRole.WRITABLE_SIGNER,r=o===AccountRole.WRITABLE||o===AccountRole.WRITABLE_SIGNER;return {isSigner:i,isWritable:r,pubkey:h(a.address)}})??[],t=e.data?Buffer.from(e.data):Buffer.alloc(0);return new TransactionInstruction({data:t,keys:n,programId:h(e.programAddress)})}s(_,"toWeb3Instruction");function H(e){return fromLegacyTransactionInstruction(e)}s(H,"fromWeb3Instruction");function X(e){let n=new AbortController;if(!e)return n;if(e.aborted)return n.abort(e.reason),n;let t=s(()=>{n.abort(e.reason),e.removeEventListener("abort",t);},"onAbort");return e.addEventListener("abort",t,{once:true}),n}s(X,"createChainedAbortController");function w(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.floor(e))}s(w,"toBigint");var Y=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function A(e){let n=e.endpoint,t=e.websocketEndpoint??n,a=e.commitment??"confirmed",o=createSolanaRpc(n,e.rpcConfig),i=createSolanaRpcSubscriptions(t,e.rpcSubscriptionsConfig);async function r(l,c={}){let p=X(c.abortSignal),u=c.commitment??a,f=getBase64EncodedWireTransaction(l),d=await o.sendTransaction(f,{encoding:"base64",maxRetries:w(c.maxRetries),minContextSlot:w(c.minContextSlot),preflightCommitment:u,skipPreflight:c.skipPreflight}).send({abortSignal:p.signal}),R=createBlockHeightExceedencePromiseFactory({rpc:o,rpcSubscriptions:i}),V=createRecentSignatureConfirmationPromiseFactory({rpc:o,rpcSubscriptions:i});return await waitForRecentTransactionConfirmation({abortSignal:p.signal,commitment:u,getBlockHeightExceedencePromise:R,getRecentSignatureConfirmationPromise:V,transaction:l}),d}s(r,"sendAndConfirmTransaction");async function m(l,c={}){let p=getBase64EncodedWireTransaction(l),u=c.config??{},f={...Y,...u,commitment:u.commitment??c.commitment??a},d=f.sigVerify===true&&f.replaceRecentBlockhash!==false?{...f,replaceRecentBlockhash:false}:f;return o.simulateTransaction(p,d).send({abortSignal:c.abortSignal})}return s(m,"simulateTransaction"),{commitment:a,endpoint:n,rpc:o,rpcSubscriptions:i,sendAndConfirmTransaction:r,simulateTransaction:m,websocketEndpoint:t}}s(A,"createSolanaRpcClient");var S="confirmed",$=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function y(e){if(e!=null)return e==="recent"||e==="singleGossip"?"processed":e==="single"?"confirmed":e==="max"?"finalized":e}s(y,"normalizeCommitment");function C(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.trunc(e))}s(C,"toBigInt");function W(e,n){let{data:t,executable:a,lamports:o,owner:i,rentEpoch:r}=e,[m,l]=Array.isArray(t)?t:[t,"base64"],c=l==="base64"?Buffer.from(m,"base64"):Buffer.from(m);if(n){let p=n.offset??0,u=p+(n.length??c.length);c=c.subarray(p,u);}return {data:c,executable:a,lamports:typeof o=="number"?o:Number(o),owner:new PublicKey(i),rentEpoch:typeof r=="number"?r:Number(r)}}s(W,"toAccountInfo");function B(e){let n=e??{},t=n.data,a=n.lamports,o=n.owner,i=n.rentEpoch,r=typeof o=="string"?o:o instanceof PublicKey?o.toBase58():typeof o=="object"&&o!==null&&"toString"in o?String(o):"11111111111111111111111111111111";return {data:t??["","base64"],executable:!!n.executable,lamports:a??0,owner:r,rentEpoch:i??0}}s(B,"fromKitAccount");function P(e){return x((e))}s(P,"toKitAddressFromInput");function L(e){if(e instanceof Transaction||e instanceof VersionedTransaction){let t=e.serialize({requireAllSignatures:false,verifySignatures:false});return Buffer.from(t).toString("base64")}if(e instanceof Uint8Array)return Buffer.from(e).toString("base64");if(e instanceof Buffer)return e.toString("base64");let n=Uint8Array.from(e);return Buffer.from(n).toString("base64")}s(L,"toBase64WireTransaction");var k=class{static{s(this,"Connection");}commitment;rpcEndpoint;#e;constructor(n,t){let a=typeof t=="string"?y(t):y(t?.commitment)??S,o=typeof t=="object"&&t!==null?t.wsEndpoint:void 0;this.commitment=a,this.rpcEndpoint=n,this.#e=A({endpoint:n,websocketEndpoint:o,commitment:a??S});}async getLatestBlockhash(n){let t=typeof n=="string"?n:n?.commitment,a=y(t)??this.commitment??S,o=typeof n=="object"?C(n.minContextSlot):void 0,i={commitment:a};o!==void 0&&(i.minContextSlot=o),typeof n=="object"&&n?.maxSupportedTransactionVersion!==void 0&&(i.maxSupportedTransactionVersion=n.maxSupportedTransactionVersion);let r=await this.#e.rpc.getLatestBlockhash(i).send();return {blockhash:r.value.blockhash,lastValidBlockHeight:Number(r.value.lastValidBlockHeight)}}async getBalance(n,t){let a=P(n),o=y(t)??this.commitment??S,i=await this.#e.rpc.getBalance(a,{commitment:o}).send();return typeof i.value=="number"?i.value:Number(i.value)}async getAccountInfo(n,t){let a=P(n),o,i,r,m;typeof t=="string"?o=y(t):t&&(o=y(t.commitment),t.minContextSlot!==void 0&&(i=C(t.minContextSlot)),r=t.dataSlice,m=t.encoding);let l={commitment:o??this.commitment??S};i!==void 0&&(l.minContextSlot=i),m&&(l.encoding=m),r&&(l.dataSlice={length:r.length,offset:r.offset});let c=await this.#e.rpc.getAccountInfo(a,l).send();return c.value?W(B(c.value),r):null}async getProgramAccounts(n,t){let a=P(n),o,i,r,m,l,c=false;typeof t=="string"?o=y(t):t&&(o=y(t.commitment),i=t.dataSlice,r=t.filters,m=t.encoding,l=C(t.minContextSlot),c=!!t.withContext);let p={commitment:o??this.commitment??S,withContext:c};i&&(p.dataSlice={length:i.length,offset:i.offset}),m&&(p.encoding=m),r&&(p.filters=r.map(d=>d)),l!==void 0&&(p.minContextSlot=l);let u=await this.#e.rpc.getProgramAccounts(a,p).send(),f=s(d=>{let R=new PublicKey(d.pubkey);return {account:W(B(d.account),i),pubkey:R}},"mapProgramAccount");if(c&&typeof u.context<"u"){let d=u;return {context:{apiVersion:d.context.apiVersion,slot:Number(d.context.slot)},value:d.value.map(f)}}return u.map(f)}async getSignatureStatuses(n,t){let a=y(t?.commitment)??this.commitment??S,o=n.map(c=>c),i=await this.#e.rpc.getSignatureStatuses(o,{commitment:a,searchTransactionHistory:t?.searchTransactionHistory}).send(),r=i.context,m={apiVersion:r?.apiVersion,slot:typeof r?.slot=="bigint"?Number(r.slot):r?.slot??0},l=i.value.map(c=>{if(!c)return null;let p=c,u=p.slot,f=p.confirmations,d=f===null||f===void 0?null:typeof f=="bigint"?Number(f):f;return {err:p.err??null,confirmations:d,confirmationStatus:p.confirmationStatus,slot:u===void 0?0:typeof u=="bigint"?Number(u):u}});return {context:m,value:l}}async sendRawTransaction(n,t){let a=L(n),o=y(t?.preflightCommitment??t?.commitment)??this.commitment??S,i=t?.maxRetries===void 0?void 0:C(t.maxRetries),r=t?.minContextSlot===void 0?void 0:C(t.minContextSlot);return await this.#e.rpc.sendTransaction(a,{encoding:"base64",maxRetries:i,minContextSlot:r,preflightCommitment:o,skipPreflight:t?.skipPreflight}).send()}async confirmTransaction(n,t){let a=y(t),o=await this.getSignatureStatuses([n],{commitment:a??this.commitment??S,searchTransactionHistory:true});return {context:o.context,value:o.value[0]??null}}async simulateTransaction(n,t){let a=L(n),o=y(t?.commitment)??this.commitment??S,i={...t??{},commitment:o},r={...$,...i,commitment:o},m=r.sigVerify===true&&r.replaceRecentBlockhash!==false?{...r,replaceRecentBlockhash:false}:r,l=await this.#e.rpc.simulateTransaction(a,m).send();return {context:{apiVersion:l.context?.apiVersion,slot:Number(l.context?.slot??0)},value:l.value}}};var te=2,ne=Object.freeze({...SystemProgram,transfer({fromPubkey:e,toPubkey:n,lamports:t}){let a=Buffer.alloc(12);return a.writeUInt32LE(te,0),a.writeBigUInt64LE(BigInt(t),4),new TransactionInstruction({data:a,keys:[{isSigner:true,isWritable:true,pubkey:e},{isSigner:false,isWritable:true,pubkey:n}],programId:SystemProgram.programId})}});var re=LAMPORTS_PER_SOL;function ae(e){return e instanceof VersionedTransaction?e.serialize():e.serialize({requireAllSignatures:false})}s(ae,"serializeTransactionBytes");function N(e){let n=ae(e);return Buffer.from(n).toString("base64")}s(N,"compileFromCompat");function ie(e,n=[]){n.length&&(e instanceof VersionedTransaction?e.sign([...n]):e.partialSign(...n));}s(ie,"applySigners");async function se(e,n,t=[],a={}){ie(n,t);let o=N(n),i=Buffer.from(o,"base64"),r=await e.sendRawTransaction(i,a),m=a.commitment??e.commitment??"confirmed";if((await e.confirmTransaction(r,m)).value?.err)throw new Error("Transaction failed");return r}s(se,"sendAndConfirmTransaction");export{k as Connection,re as LAMPORTS_PER_SOL,ne as SystemProgram,N as compileFromCompat,H as fromWeb3Instruction,se as sendAndConfirmTransaction,x as toAddress,U as toKitSigner,h as toPublicKey,_ as toWeb3Instruction};//# sourceMappingURL=index.browser.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.browser.mjs.map
|
package/dist/index.native.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import {SystemProgram,TransactionInstruction,PublicKey,Transaction,VersionedTransaction,LAMPORTS_PER_SOL}from'@solana/web3.js';export{Keypair,PublicKey,Transaction,TransactionInstruction,VersionedTransaction}from'@solana/web3.js';import {fromLegacyPublicKey,fromLegacyTransactionInstruction}from'@solana/compat';import {createSolanaRpc,createSolanaRpcSubscriptions,getBase64EncodedWireTransaction,createKeyPairSignerFromBytes,AccountRole}from'@solana/kit';import {createBlockHeightExceedencePromiseFactory,createRecentSignatureConfirmationPromiseFactory,waitForRecentTransactionConfirmation}from'@solana/transaction-confirmation';var z=Object.defineProperty;var s=(e,n)=>z(e,"name",{value:n,configurable:true});function x(e){let n=e instanceof PublicKey?e:new PublicKey(e);return fromLegacyPublicKey(n)}s(x,"toAddress");function h(e){return e instanceof PublicKey?e:typeof e=="string"?new PublicKey(e):new PublicKey(e)}s(h,"toPublicKey");async function U(e,n={}){let t=new Uint8Array(64);return t.set(e.secretKey),t.set(e.publicKey.toBytes(),32),await createKeyPairSignerFromBytes(t,n.extractable??false)}s(U,"toKitSigner");function _(e){let n=e.accounts?.map(a=>{let o=a.role,i=o===AccountRole.READONLY_SIGNER||o===AccountRole.WRITABLE_SIGNER,r=o===AccountRole.WRITABLE||o===AccountRole.WRITABLE_SIGNER;return {isSigner:i,isWritable:r,pubkey:h(a.address)}})??[],t=e.data?Buffer.from(e.data):Buffer.alloc(0);return new TransactionInstruction({data:t,keys:n,programId:h(e.programAddress)})}s(_,"toWeb3Instruction");function H(e){return fromLegacyTransactionInstruction(e)}s(H,"fromWeb3Instruction");function X(e){let n=new AbortController;if(!e)return n;if(e.aborted)return n.abort(e.reason),n;let t=s(()=>{n.abort(e.reason),e.removeEventListener("abort",t);},"onAbort");return e.addEventListener("abort",t,{once:true}),n}s(X,"createChainedAbortController");function w(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.floor(e))}s(w,"toBigint");var Y=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function A(e){let n=e.endpoint,t=e.websocketEndpoint??n,a=e.commitment??"confirmed",o=createSolanaRpc(n,e.rpcConfig),i=createSolanaRpcSubscriptions(t,e.rpcSubscriptionsConfig);async function r(l,c={}){let p=X(c.abortSignal),u=c.commitment??a,f=getBase64EncodedWireTransaction(l),d=await o.sendTransaction(f,{encoding:"base64",maxRetries:w(c.maxRetries),minContextSlot:w(c.minContextSlot),preflightCommitment:u,skipPreflight:c.skipPreflight}).send({abortSignal:p.signal}),R=createBlockHeightExceedencePromiseFactory({rpc:o,rpcSubscriptions:i}),V=createRecentSignatureConfirmationPromiseFactory({rpc:o,rpcSubscriptions:i});return await waitForRecentTransactionConfirmation({abortSignal:p.signal,commitment:u,getBlockHeightExceedencePromise:R,getRecentSignatureConfirmationPromise:V,transaction:l}),d}s(r,"sendAndConfirmTransaction");async function m(l,c={}){let p=getBase64EncodedWireTransaction(l),u=c.config??{},f={...Y,...u,commitment:u.commitment??c.commitment??a},d=f.sigVerify===true&&f.replaceRecentBlockhash!==false?{...f,replaceRecentBlockhash:false}:f;return o.simulateTransaction(p,d).send({abortSignal:c.abortSignal})}return s(m,"simulateTransaction"),{commitment:a,endpoint:n,rpc:o,rpcSubscriptions:i,sendAndConfirmTransaction:r,simulateTransaction:m,websocketEndpoint:t}}s(A,"createSolanaRpcClient");var S="confirmed",$=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function y(e){if(e!=null)return e==="recent"||e==="singleGossip"?"processed":e==="single"?"confirmed":e==="max"?"finalized":e}s(y,"normalizeCommitment");function C(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.trunc(e))}s(C,"toBigInt");function
|
|
1
|
+
import {SystemProgram,TransactionInstruction,PublicKey,Transaction,VersionedTransaction,LAMPORTS_PER_SOL}from'@solana/web3.js';export{Keypair,PublicKey,Transaction,TransactionInstruction,VersionedTransaction}from'@solana/web3.js';import {fromLegacyPublicKey,fromLegacyTransactionInstruction}from'@solana/compat';import {createSolanaRpc,createSolanaRpcSubscriptions,getBase64EncodedWireTransaction,createKeyPairSignerFromBytes,AccountRole}from'@solana/kit';import {createBlockHeightExceedencePromiseFactory,createRecentSignatureConfirmationPromiseFactory,waitForRecentTransactionConfirmation}from'@solana/transaction-confirmation';var z=Object.defineProperty;var s=(e,n)=>z(e,"name",{value:n,configurable:true});function x(e){let n=e instanceof PublicKey?e:new PublicKey(e);return fromLegacyPublicKey(n)}s(x,"toAddress");function h(e){return e instanceof PublicKey?e:typeof e=="string"?new PublicKey(e):new PublicKey(e)}s(h,"toPublicKey");async function U(e,n={}){let t=new Uint8Array(64);return t.set(e.secretKey),t.set(e.publicKey.toBytes(),32),await createKeyPairSignerFromBytes(t,n.extractable??false)}s(U,"toKitSigner");function _(e){let n=e.accounts?.map(a=>{let o=a.role,i=o===AccountRole.READONLY_SIGNER||o===AccountRole.WRITABLE_SIGNER,r=o===AccountRole.WRITABLE||o===AccountRole.WRITABLE_SIGNER;return {isSigner:i,isWritable:r,pubkey:h(a.address)}})??[],t=e.data?Buffer.from(e.data):Buffer.alloc(0);return new TransactionInstruction({data:t,keys:n,programId:h(e.programAddress)})}s(_,"toWeb3Instruction");function H(e){return fromLegacyTransactionInstruction(e)}s(H,"fromWeb3Instruction");function X(e){let n=new AbortController;if(!e)return n;if(e.aborted)return n.abort(e.reason),n;let t=s(()=>{n.abort(e.reason),e.removeEventListener("abort",t);},"onAbort");return e.addEventListener("abort",t,{once:true}),n}s(X,"createChainedAbortController");function w(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.floor(e))}s(w,"toBigint");var Y=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function A(e){let n=e.endpoint,t=e.websocketEndpoint??n,a=e.commitment??"confirmed",o=createSolanaRpc(n,e.rpcConfig),i=createSolanaRpcSubscriptions(t,e.rpcSubscriptionsConfig);async function r(l,c={}){let p=X(c.abortSignal),u=c.commitment??a,f=getBase64EncodedWireTransaction(l),d=await o.sendTransaction(f,{encoding:"base64",maxRetries:w(c.maxRetries),minContextSlot:w(c.minContextSlot),preflightCommitment:u,skipPreflight:c.skipPreflight}).send({abortSignal:p.signal}),R=createBlockHeightExceedencePromiseFactory({rpc:o,rpcSubscriptions:i}),V=createRecentSignatureConfirmationPromiseFactory({rpc:o,rpcSubscriptions:i});return await waitForRecentTransactionConfirmation({abortSignal:p.signal,commitment:u,getBlockHeightExceedencePromise:R,getRecentSignatureConfirmationPromise:V,transaction:l}),d}s(r,"sendAndConfirmTransaction");async function m(l,c={}){let p=getBase64EncodedWireTransaction(l),u=c.config??{},f={...Y,...u,commitment:u.commitment??c.commitment??a},d=f.sigVerify===true&&f.replaceRecentBlockhash!==false?{...f,replaceRecentBlockhash:false}:f;return o.simulateTransaction(p,d).send({abortSignal:c.abortSignal})}return s(m,"simulateTransaction"),{commitment:a,endpoint:n,rpc:o,rpcSubscriptions:i,sendAndConfirmTransaction:r,simulateTransaction:m,websocketEndpoint:t}}s(A,"createSolanaRpcClient");var S="confirmed",$=Object.freeze({encoding:"base64",replaceRecentBlockhash:true,sigVerify:false});function y(e){if(e!=null)return e==="recent"||e==="singleGossip"?"processed":e==="single"?"confirmed":e==="max"?"finalized":e}s(y,"normalizeCommitment");function C(e){if(e!==void 0)return typeof e=="bigint"?e:BigInt(Math.trunc(e))}s(C,"toBigInt");function W(e,n){let{data:t,executable:a,lamports:o,owner:i,rentEpoch:r}=e,[m,l]=Array.isArray(t)?t:[t,"base64"],c=l==="base64"?Buffer.from(m,"base64"):Buffer.from(m);if(n){let p=n.offset??0,u=p+(n.length??c.length);c=c.subarray(p,u);}return {data:c,executable:a,lamports:typeof o=="number"?o:Number(o),owner:new PublicKey(i),rentEpoch:typeof r=="number"?r:Number(r)}}s(W,"toAccountInfo");function B(e){let n=e??{},t=n.data,a=n.lamports,o=n.owner,i=n.rentEpoch,r=typeof o=="string"?o:o instanceof PublicKey?o.toBase58():typeof o=="object"&&o!==null&&"toString"in o?String(o):"11111111111111111111111111111111";return {data:t??["","base64"],executable:!!n.executable,lamports:a??0,owner:r,rentEpoch:i??0}}s(B,"fromKitAccount");function P(e){return x((e))}s(P,"toKitAddressFromInput");function L(e){if(e instanceof Transaction||e instanceof VersionedTransaction){let t=e.serialize({requireAllSignatures:false,verifySignatures:false});return Buffer.from(t).toString("base64")}if(e instanceof Uint8Array)return Buffer.from(e).toString("base64");if(e instanceof Buffer)return e.toString("base64");let n=Uint8Array.from(e);return Buffer.from(n).toString("base64")}s(L,"toBase64WireTransaction");var k=class{static{s(this,"Connection");}commitment;rpcEndpoint;#e;constructor(n,t){let a=typeof t=="string"?y(t):y(t?.commitment)??S,o=typeof t=="object"&&t!==null?t.wsEndpoint:void 0;this.commitment=a,this.rpcEndpoint=n,this.#e=A({endpoint:n,websocketEndpoint:o,commitment:a??S});}async getLatestBlockhash(n){let t=typeof n=="string"?n:n?.commitment,a=y(t)??this.commitment??S,o=typeof n=="object"?C(n.minContextSlot):void 0,i={commitment:a};o!==void 0&&(i.minContextSlot=o),typeof n=="object"&&n?.maxSupportedTransactionVersion!==void 0&&(i.maxSupportedTransactionVersion=n.maxSupportedTransactionVersion);let r=await this.#e.rpc.getLatestBlockhash(i).send();return {blockhash:r.value.blockhash,lastValidBlockHeight:Number(r.value.lastValidBlockHeight)}}async getBalance(n,t){let a=P(n),o=y(t)??this.commitment??S,i=await this.#e.rpc.getBalance(a,{commitment:o}).send();return typeof i.value=="number"?i.value:Number(i.value)}async getAccountInfo(n,t){let a=P(n),o,i,r,m;typeof t=="string"?o=y(t):t&&(o=y(t.commitment),t.minContextSlot!==void 0&&(i=C(t.minContextSlot)),r=t.dataSlice,m=t.encoding);let l={commitment:o??this.commitment??S};i!==void 0&&(l.minContextSlot=i),m&&(l.encoding=m),r&&(l.dataSlice={length:r.length,offset:r.offset});let c=await this.#e.rpc.getAccountInfo(a,l).send();return c.value?W(B(c.value),r):null}async getProgramAccounts(n,t){let a=P(n),o,i,r,m,l,c=false;typeof t=="string"?o=y(t):t&&(o=y(t.commitment),i=t.dataSlice,r=t.filters,m=t.encoding,l=C(t.minContextSlot),c=!!t.withContext);let p={commitment:o??this.commitment??S,withContext:c};i&&(p.dataSlice={length:i.length,offset:i.offset}),m&&(p.encoding=m),r&&(p.filters=r.map(d=>d)),l!==void 0&&(p.minContextSlot=l);let u=await this.#e.rpc.getProgramAccounts(a,p).send(),f=s(d=>{let R=new PublicKey(d.pubkey);return {account:W(B(d.account),i),pubkey:R}},"mapProgramAccount");if(c&&typeof u.context<"u"){let d=u;return {context:{apiVersion:d.context.apiVersion,slot:Number(d.context.slot)},value:d.value.map(f)}}return u.map(f)}async getSignatureStatuses(n,t){let a=y(t?.commitment)??this.commitment??S,o=n.map(c=>c),i=await this.#e.rpc.getSignatureStatuses(o,{commitment:a,searchTransactionHistory:t?.searchTransactionHistory}).send(),r=i.context,m={apiVersion:r?.apiVersion,slot:typeof r?.slot=="bigint"?Number(r.slot):r?.slot??0},l=i.value.map(c=>{if(!c)return null;let p=c,u=p.slot,f=p.confirmations,d=f===null||f===void 0?null:typeof f=="bigint"?Number(f):f;return {err:p.err??null,confirmations:d,confirmationStatus:p.confirmationStatus,slot:u===void 0?0:typeof u=="bigint"?Number(u):u}});return {context:m,value:l}}async sendRawTransaction(n,t){let a=L(n),o=y(t?.preflightCommitment??t?.commitment)??this.commitment??S,i=t?.maxRetries===void 0?void 0:C(t.maxRetries),r=t?.minContextSlot===void 0?void 0:C(t.minContextSlot);return await this.#e.rpc.sendTransaction(a,{encoding:"base64",maxRetries:i,minContextSlot:r,preflightCommitment:o,skipPreflight:t?.skipPreflight}).send()}async confirmTransaction(n,t){let a=y(t),o=await this.getSignatureStatuses([n],{commitment:a??this.commitment??S,searchTransactionHistory:true});return {context:o.context,value:o.value[0]??null}}async simulateTransaction(n,t){let a=L(n),o=y(t?.commitment)??this.commitment??S,i={...t??{},commitment:o},r={...$,...i,commitment:o},m=r.sigVerify===true&&r.replaceRecentBlockhash!==false?{...r,replaceRecentBlockhash:false}:r,l=await this.#e.rpc.simulateTransaction(a,m).send();return {context:{apiVersion:l.context?.apiVersion,slot:Number(l.context?.slot??0)},value:l.value}}};var te=2,ne=Object.freeze({...SystemProgram,transfer({fromPubkey:e,toPubkey:n,lamports:t}){let a=Buffer.alloc(12);return a.writeUInt32LE(te,0),a.writeBigUInt64LE(BigInt(t),4),new TransactionInstruction({data:a,keys:[{isSigner:true,isWritable:true,pubkey:e},{isSigner:false,isWritable:true,pubkey:n}],programId:SystemProgram.programId})}});var re=LAMPORTS_PER_SOL;function ae(e){return e instanceof VersionedTransaction?e.serialize():e.serialize({requireAllSignatures:false})}s(ae,"serializeTransactionBytes");function N(e){let n=ae(e);return Buffer.from(n).toString("base64")}s(N,"compileFromCompat");function ie(e,n=[]){n.length&&(e instanceof VersionedTransaction?e.sign([...n]):e.partialSign(...n));}s(ie,"applySigners");async function se(e,n,t=[],a={}){ie(n,t);let o=N(n),i=Buffer.from(o,"base64"),r=await e.sendRawTransaction(i,a),m=a.commitment??e.commitment??"confirmed";if((await e.confirmTransaction(r,m)).value?.err)throw new Error("Transaction failed");return r}s(se,"sendAndConfirmTransaction");export{k as Connection,re as LAMPORTS_PER_SOL,ne as SystemProgram,N as compileFromCompat,H as fromWeb3Instruction,se as sendAndConfirmTransaction,x as toAddress,U as toKitSigner,h as toPublicKey,_ as toWeb3Instruction};//# sourceMappingURL=index.native.mjs.map
|
|
2
2
|
//# sourceMappingURL=index.native.mjs.map
|
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import { createLogger } from '../logging/logger';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
|
+
import type { ClientActions, ClientStore } from '../types';
|
|
4
|
+
import type { WalletRegistry } from '../wallet/types';
|
|
3
5
|
type MutableRuntime = SolanaClientRuntime;
|
|
4
6
|
type ActionDeps = Readonly<{
|
|
5
7
|
connectors: WalletRegistry;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/actions.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AAE9D,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"actions.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/actions.ts"],"names":[],"mappings":"AAmBA,OAAO,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AAE9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAA0B,aAAa,EAAe,WAAW,EAAoB,MAAM,UAAU,CAAC;AAElH,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,iBAAiB,CAAC;AAErE,KAAK,cAAc,GAAG,mBAAmB,CAAC;AAE1C,KAAK,UAAU,GAAG,QAAQ,CAAC;IAC1B,UAAU,EAAE,cAAc,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,WAAW,CAAC;CACnB,CAAC,CAAC;AAiBH;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,UAAU,GAAG,aAAa,CA8hB5G"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/createClient.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createClient.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/createClient.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAe,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAS9E;;;;;GAKG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,kBAAkB,GAAG,YAAY,CAyFrE"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
-
import type {
|
|
1
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
2
|
+
import type { ClientHelpers, ClientStore } from '../types';
|
|
2
3
|
export declare function createClientHelpers(runtime: SolanaClientRuntime, store: ClientStore): ClientHelpers;
|
|
3
4
|
//# sourceMappingURL=createClientHelpers.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createClientHelpers.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/createClientHelpers.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"createClientHelpers.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/createClientHelpers.ts"],"names":[],"mappings":"AAOA,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AAMxD,OAAO,KAAK,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AAkG3D,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,mBAAmB,EAAE,KAAK,EAAE,WAAW,GAAG,aAAa,CA2EnG"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ClusterUrl, Commitment } from '@solana/kit';
|
|
2
|
-
import type { SolanaClient, SolanaClientConfig
|
|
2
|
+
import type { SolanaClient, SolanaClientConfig } from '../types';
|
|
3
3
|
import { type ClusterMoniker } from '../utils/cluster';
|
|
4
|
+
import type { WalletConnector } from '../wallet/types';
|
|
4
5
|
type BasePassthrough = Omit<SolanaClientConfig, 'endpoint' | 'websocketEndpoint' | 'walletConnectors'>;
|
|
5
6
|
export type CreateDefaultClientOptions = Readonly<BasePassthrough & {
|
|
6
7
|
cluster?: ClusterMoniker;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"defaultClient.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/defaultClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,
|
|
1
|
+
{"version":3,"file":"defaultClient.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/defaultClient.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,KAAK,EAAE,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AACjE,OAAO,EAAE,KAAK,cAAc,EAAkB,MAAM,kBAAkB,CAAC;AAEvE,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAGvD,KAAK,eAAe,GAAG,IAAI,CAAC,kBAAkB,EAAE,UAAU,GAAG,mBAAmB,GAAG,kBAAkB,CAAC,CAAC;AAEvG,MAAM,MAAM,0BAA0B,GAAG,QAAQ,CAChD,eAAe,GAAG;IACjB,OAAO,CAAC,EAAE,cAAc,CAAC;IACzB,UAAU,CAAC,EAAE,UAAU,CAAC;IACxB;;OAEG;IACH,GAAG,CAAC,EAAE,UAAU,CAAC;IACjB;;OAEG;IACH,QAAQ,CAAC,EAAE,UAAU,CAAC;IACtB;;OAEG;IACH,SAAS,CAAC,EAAE,UAAU,CAAC;IACvB,gBAAgB,CAAC,EAAE,SAAS,eAAe,EAAE,GAAG,SAAS,CAAC;CAC1D,CACD,CAAC;AAEF,wBAAgB,uBAAuB,IAAI,SAAS,eAAe,EAAE,CAEpE;AAQD,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,0BAA0B,GAAG,kBAAuB,GAAG,kBAAkB,CA0BpH;AAED,wBAAgB,mBAAmB,CAAC,MAAM,GAAE,0BAA+B,GAAG,YAAY,CAEzF"}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { createLogger } from '../logging/logger';
|
|
2
|
-
import type {
|
|
2
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
|
+
import type { ClientStore, ClientWatchers } from '../types';
|
|
3
4
|
type WatcherDeps = Readonly<{
|
|
4
5
|
logger?: ReturnType<typeof createLogger>;
|
|
5
6
|
runtime: SolanaClientRuntime;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"watchers.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/watchers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAIX,WAAW,EACX,cAAc,
|
|
1
|
+
{"version":3,"file":"watchers.d.ts","sourceRoot":"","sources":["../../../../../../client/src/client/watchers.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAe,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACxD,OAAO,KAAK,EAIX,WAAW,EACX,cAAc,EAGd,MAAM,UAAU,CAAC;AAKlB,KAAK,WAAW,GAAG,QAAQ,CAAC;IAC3B,MAAM,CAAC,EAAE,UAAU,CAAC,OAAO,YAAY,CAAC,CAAC;IACzC,OAAO,EAAE,mBAAmB,CAAC;IAC7B,KAAK,EAAE,WAAW,CAAC;CACnB,CAAC,CAAC;AAEH;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,KAAK,EAAE,EAAE,WAAW,GAAG,cAAc,CAsOnG"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
import type { SolTransferSendOptions } from '../features/sol';
|
|
2
|
+
import type { WsolHelper, WsolUnwrapPrepareConfig, WsolWrapPrepareConfig } from '../features/wsol';
|
|
3
|
+
import { type AsyncState } from '../state/asyncState';
|
|
4
|
+
type WsolWrapSignature = Awaited<ReturnType<WsolHelper['sendWrap']>>;
|
|
5
|
+
type WsolUnwrapSignature = Awaited<ReturnType<WsolHelper['sendUnwrap']>>;
|
|
6
|
+
type Listener = () => void;
|
|
7
|
+
export type WsolControllerConfig = Readonly<{
|
|
8
|
+
authorityProvider?: () => WsolWrapPrepareConfig['authority'] | undefined;
|
|
9
|
+
helper: WsolHelper;
|
|
10
|
+
}>;
|
|
11
|
+
export type WsolWrapInput = Omit<WsolWrapPrepareConfig, 'authority'> & {
|
|
12
|
+
authority?: WsolWrapPrepareConfig['authority'];
|
|
13
|
+
};
|
|
14
|
+
export type WsolUnwrapInput = Omit<WsolUnwrapPrepareConfig, 'authority'> & {
|
|
15
|
+
authority?: WsolUnwrapPrepareConfig['authority'];
|
|
16
|
+
};
|
|
17
|
+
export type WsolController = Readonly<{
|
|
18
|
+
getHelper(): WsolHelper;
|
|
19
|
+
getWrapState(): AsyncState<WsolWrapSignature>;
|
|
20
|
+
getUnwrapState(): AsyncState<WsolUnwrapSignature>;
|
|
21
|
+
resetWrap(): void;
|
|
22
|
+
resetUnwrap(): void;
|
|
23
|
+
wrap(config: WsolWrapInput, options?: SolTransferSendOptions): Promise<WsolWrapSignature>;
|
|
24
|
+
unwrap(config: WsolUnwrapInput, options?: SolTransferSendOptions): Promise<WsolUnwrapSignature>;
|
|
25
|
+
subscribeWrap(listener: Listener): () => void;
|
|
26
|
+
subscribeUnwrap(listener: Listener): () => void;
|
|
27
|
+
}>;
|
|
28
|
+
export declare function createWsolController(config: WsolControllerConfig): WsolController;
|
|
29
|
+
export {};
|
|
30
|
+
//# sourceMappingURL=wsolController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"wsolController.d.ts","sourceRoot":"","sources":["../../../../../../client/src/controllers/wsolController.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,iBAAiB,CAAC;AAC9D,OAAO,KAAK,EAAE,UAAU,EAAE,uBAAuB,EAAE,qBAAqB,EAAE,MAAM,kBAAkB,CAAC;AACnG,OAAO,EAAE,KAAK,UAAU,EAA6C,MAAM,qBAAqB,CAAC;AAEjG,KAAK,iBAAiB,GAAG,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;AACrE,KAAK,mBAAmB,GAAG,OAAO,CA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
|
|
@@ -1,41 +1,157 @@
|
|
|
1
1
|
import { type Address, type Blockhash, type Commitment, type Slot, signature, signTransactionMessageWithSigners, type TransactionPlan, type TransactionSigner, type TransactionVersion } from '@solana/kit';
|
|
2
|
-
import type { SolanaClientRuntime
|
|
2
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
|
+
import type { WalletSession } from '../wallet/types';
|
|
4
|
+
/**
|
|
5
|
+
* Blockhash and last valid block height for transaction lifetime.
|
|
6
|
+
* Used to ensure transactions expire after a certain block height.
|
|
7
|
+
*/
|
|
3
8
|
type BlockhashLifetime = Readonly<{
|
|
4
9
|
blockhash: Blockhash;
|
|
5
10
|
lastValidBlockHeight: bigint;
|
|
6
11
|
}>;
|
|
12
|
+
/**
|
|
13
|
+
* Amount of SOL to transfer. Can be specified as:
|
|
14
|
+
* - `bigint`: Raw lamports (1 SOL = 1_000_000_000 lamports)
|
|
15
|
+
* - `number`: SOL amount as decimal (e.g., 1.5 for 1.5 SOL)
|
|
16
|
+
* - `string`: SOL amount as string (e.g., "1.5" for 1.5 SOL)
|
|
17
|
+
*/
|
|
7
18
|
type SolTransferAmount = bigint | number | string;
|
|
19
|
+
/**
|
|
20
|
+
* Authority that signs the SOL transfer transaction.
|
|
21
|
+
* Can be either a connected wallet session or a raw transaction signer.
|
|
22
|
+
*/
|
|
8
23
|
type SolTransferAuthority = TransactionSigner<string> | WalletSession;
|
|
9
24
|
type SignableSolTransactionMessage = Parameters<typeof signTransactionMessageWithSigners>[0];
|
|
25
|
+
/**
|
|
26
|
+
* Configuration for preparing a SOL transfer transaction.
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* ```ts
|
|
30
|
+
* const config: SolTransferPrepareConfig = {
|
|
31
|
+
* amount: 1_000_000_000n, // 1 SOL in lamports
|
|
32
|
+
* authority: walletSession,
|
|
33
|
+
* destination: 'RecipientAddress...',
|
|
34
|
+
* commitment: 'confirmed',
|
|
35
|
+
* };
|
|
36
|
+
* ```
|
|
37
|
+
*/
|
|
10
38
|
export type SolTransferPrepareConfig = Readonly<{
|
|
39
|
+
/** Amount of SOL to transfer in lamports, decimal SOL, or string SOL. */
|
|
11
40
|
amount: SolTransferAmount;
|
|
41
|
+
/** Authority that signs the transaction. Can be a WalletSession or raw TransactionSigner. */
|
|
12
42
|
authority: SolTransferAuthority;
|
|
43
|
+
/** Commitment level for fetching blockhash and sending transaction. Defaults to client commitment. */
|
|
13
44
|
commitment?: Commitment;
|
|
45
|
+
/** Destination wallet address to receive the SOL. */
|
|
14
46
|
destination: Address | string;
|
|
47
|
+
/** Optional pre-fetched blockhash lifetime. If not provided, one will be fetched. */
|
|
15
48
|
lifetime?: BlockhashLifetime;
|
|
49
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
16
50
|
transactionVersion?: TransactionVersion;
|
|
17
51
|
}>;
|
|
52
|
+
/**
|
|
53
|
+
* Options for sending a SOL transfer transaction.
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* ```ts
|
|
57
|
+
* const options: SolTransferSendOptions = {
|
|
58
|
+
* commitment: 'confirmed',
|
|
59
|
+
* maxRetries: 3,
|
|
60
|
+
* skipPreflight: false,
|
|
61
|
+
* };
|
|
62
|
+
* ```
|
|
63
|
+
*/
|
|
18
64
|
export type SolTransferSendOptions = Readonly<{
|
|
65
|
+
/** AbortSignal to cancel the transaction. */
|
|
19
66
|
abortSignal?: AbortSignal;
|
|
67
|
+
/** Commitment level for transaction confirmation. */
|
|
20
68
|
commitment?: Commitment;
|
|
69
|
+
/** Maximum number of times to retry sending the transaction. */
|
|
21
70
|
maxRetries?: bigint | number;
|
|
71
|
+
/** Minimum slot that the request can be evaluated at. */
|
|
22
72
|
minContextSlot?: Slot;
|
|
73
|
+
/** If true, skip the preflight transaction checks. */
|
|
23
74
|
skipPreflight?: boolean;
|
|
24
75
|
}>;
|
|
76
|
+
/**
|
|
77
|
+
* A prepared SOL transfer transaction ready to be signed and sent.
|
|
78
|
+
* Contains the transaction message, signer, and metadata needed for submission.
|
|
79
|
+
*/
|
|
25
80
|
type PreparedSolTransfer = Readonly<{
|
|
81
|
+
/** Commitment level used for this transaction. */
|
|
26
82
|
commitment?: Commitment;
|
|
83
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
27
84
|
lifetime: BlockhashLifetime;
|
|
85
|
+
/** The unsigned transaction message. */
|
|
28
86
|
message: SignableSolTransactionMessage;
|
|
87
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
29
88
|
mode: 'partial' | 'send';
|
|
89
|
+
/** The transaction signer. */
|
|
30
90
|
signer: TransactionSigner;
|
|
91
|
+
/** Transaction plan for execution. */
|
|
31
92
|
plan?: TransactionPlan;
|
|
32
93
|
}>;
|
|
94
|
+
/**
|
|
95
|
+
* Helper interface for native SOL transfers using the System Program.
|
|
96
|
+
* Provides methods to prepare, sign, and send SOL transfer transactions.
|
|
97
|
+
*
|
|
98
|
+
* @example
|
|
99
|
+
* ```ts
|
|
100
|
+
* import { createSolTransferHelper } from '@solana/client';
|
|
101
|
+
*
|
|
102
|
+
* const helper = createSolTransferHelper(runtime);
|
|
103
|
+
*
|
|
104
|
+
* // Simple transfer
|
|
105
|
+
* const signature = await helper.sendTransfer({
|
|
106
|
+
* amount: 1_000_000_000n, // 1 SOL
|
|
107
|
+
* authority: walletSession,
|
|
108
|
+
* destination: 'RecipientAddress...',
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* // Or prepare and send separately
|
|
112
|
+
* const prepared = await helper.prepareTransfer({ ... });
|
|
113
|
+
* const signature = await helper.sendPreparedTransfer(prepared);
|
|
114
|
+
* ```
|
|
115
|
+
*/
|
|
33
116
|
export type SolTransferHelper = Readonly<{
|
|
117
|
+
/**
|
|
118
|
+
* Prepares a SOL transfer transaction without sending it.
|
|
119
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
120
|
+
*/
|
|
34
121
|
prepareTransfer(config: SolTransferPrepareConfig): Promise<PreparedSolTransfer>;
|
|
122
|
+
/**
|
|
123
|
+
* Sends a previously prepared SOL transfer transaction.
|
|
124
|
+
* Use this after prepareTransfer() to submit the transaction.
|
|
125
|
+
*/
|
|
35
126
|
sendPreparedTransfer(prepared: PreparedSolTransfer, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
127
|
+
/**
|
|
128
|
+
* Prepares and sends a SOL transfer in one call.
|
|
129
|
+
* This is the simplest way to transfer SOL.
|
|
130
|
+
*/
|
|
36
131
|
sendTransfer(config: SolTransferPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
37
132
|
}>;
|
|
38
|
-
/**
|
|
133
|
+
/**
|
|
134
|
+
* Creates helpers for building and submitting native SOL transfers via the System Program.
|
|
135
|
+
*
|
|
136
|
+
* @param runtime - The Solana client runtime with RPC connection.
|
|
137
|
+
* @returns A SolTransferHelper with methods to prepare and send SOL transfers.
|
|
138
|
+
*
|
|
139
|
+
* @example
|
|
140
|
+
* ```ts
|
|
141
|
+
* import { createClient } from '@solana/client';
|
|
142
|
+
*
|
|
143
|
+
* const client = createClient({ cluster: 'devnet' });
|
|
144
|
+
* const helper = client.helpers.sol;
|
|
145
|
+
*
|
|
146
|
+
* // Transfer 0.5 SOL
|
|
147
|
+
* const sig = await helper.sendTransfer({
|
|
148
|
+
* amount: 0.5, // Can use decimal SOL
|
|
149
|
+
* authority: session,
|
|
150
|
+
* destination: 'RecipientAddress...',
|
|
151
|
+
* });
|
|
152
|
+
* console.log('Transfer signature:', sig);
|
|
153
|
+
* ```
|
|
154
|
+
*/
|
|
39
155
|
export declare function createSolTransferHelper(runtime: SolanaClientRuntime): SolTransferHelper;
|
|
40
156
|
export {};
|
|
41
157
|
//# sourceMappingURL=sol.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sol.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/sol.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,OAAO,EAGZ,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sBAAsB,GAC9B,OAAO,CAAC,UAAU,CAAC,OAAO,SAAS,CAAC,CAAC,CAAC;CACzC,CAAC,CAAC;AAEH;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,uBAAuB,CAAC,OAAO,EAAE,mBAAmB,GAAG,iBAAiB,CAyFvF"}
|
|
@@ -1,59 +1,222 @@
|
|
|
1
1
|
import { type Address, type Blockhash, type Commitment, signature, signTransactionMessageWithSigners, type TransactionPlan, type TransactionSigner, type TransactionVersion } from '@solana/kit';
|
|
2
|
-
import type { SolanaClientRuntime
|
|
2
|
+
import type { SolanaClientRuntime } from '../rpc/types';
|
|
3
|
+
import type { WalletSession } from '../wallet/types';
|
|
3
4
|
import type { SolTransferSendOptions } from './sol';
|
|
5
|
+
/**
|
|
6
|
+
* Blockhash and last valid block height for transaction lifetime.
|
|
7
|
+
* Used to ensure transactions expire after a certain block height.
|
|
8
|
+
*/
|
|
4
9
|
type BlockhashLifetime = Readonly<{
|
|
5
10
|
blockhash: Blockhash;
|
|
6
11
|
lastValidBlockHeight: bigint;
|
|
7
12
|
}>;
|
|
13
|
+
/**
|
|
14
|
+
* Authority that signs SPL token transfer transactions.
|
|
15
|
+
* Can be either a connected wallet session or a raw transaction signer.
|
|
16
|
+
*/
|
|
8
17
|
type SplTokenAuthority = TransactionSigner<string> | WalletSession;
|
|
9
18
|
type SignableSplTransactionMessage = Parameters<typeof signTransactionMessageWithSigners>[0];
|
|
19
|
+
/**
|
|
20
|
+
* Configuration for creating an SPL token helper.
|
|
21
|
+
* Each helper instance is bound to a specific token mint.
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* ```ts
|
|
25
|
+
* const config: SplTokenHelperConfig = {
|
|
26
|
+
* mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v', // USDC
|
|
27
|
+
* decimals: 6, // Optional: provide to skip on-chain lookup
|
|
28
|
+
* commitment: 'confirmed',
|
|
29
|
+
* };
|
|
30
|
+
* ```
|
|
31
|
+
*/
|
|
10
32
|
export type SplTokenHelperConfig = Readonly<{
|
|
33
|
+
/** Associated Token Program address. Defaults to standard ATA program. */
|
|
11
34
|
associatedTokenProgram?: Address | string;
|
|
35
|
+
/** Commitment level for RPC calls. */
|
|
12
36
|
commitment?: Commitment;
|
|
37
|
+
/** Token decimals. If not provided, will be fetched from the mint account. */
|
|
13
38
|
decimals?: number;
|
|
39
|
+
/** The SPL token mint address. */
|
|
14
40
|
mint: Address | string;
|
|
41
|
+
/** Token Program address. Defaults to standard Token Program. */
|
|
15
42
|
tokenProgram?: Address | string;
|
|
16
43
|
}>;
|
|
44
|
+
/**
|
|
45
|
+
* SPL token balance information for an owner's Associated Token Account.
|
|
46
|
+
*
|
|
47
|
+
* @example
|
|
48
|
+
* ```ts
|
|
49
|
+
* const balance: SplTokenBalance = {
|
|
50
|
+
* amount: 1000000n, // Raw token amount in base units
|
|
51
|
+
* ataAddress: 'TokenAccountAddress...',
|
|
52
|
+
* decimals: 6,
|
|
53
|
+
* exists: true,
|
|
54
|
+
* uiAmount: '1.0', // Human-readable amount
|
|
55
|
+
* };
|
|
56
|
+
* ```
|
|
57
|
+
*/
|
|
17
58
|
export type SplTokenBalance = Readonly<{
|
|
59
|
+
/** Token amount in base units (smallest denomination). */
|
|
18
60
|
amount: bigint;
|
|
61
|
+
/** The Associated Token Account address. */
|
|
19
62
|
ataAddress: Address;
|
|
63
|
+
/** Number of decimals for this token. */
|
|
20
64
|
decimals: number;
|
|
65
|
+
/** Whether the token account exists on-chain. */
|
|
21
66
|
exists: boolean;
|
|
67
|
+
/** Human-readable token amount as a string. */
|
|
22
68
|
uiAmount: string;
|
|
23
69
|
}>;
|
|
70
|
+
/**
|
|
71
|
+
* Configuration for preparing an SPL token transfer transaction.
|
|
72
|
+
*
|
|
73
|
+
* @example
|
|
74
|
+
* ```ts
|
|
75
|
+
* const config: SplTransferPrepareConfig = {
|
|
76
|
+
* amount: '10.5', // Transfer 10.5 tokens
|
|
77
|
+
* authority: walletSession,
|
|
78
|
+
* destinationOwner: 'RecipientWalletAddress...',
|
|
79
|
+
* ensureDestinationAta: true, // Create ATA if needed
|
|
80
|
+
* };
|
|
81
|
+
* ```
|
|
82
|
+
*/
|
|
24
83
|
export type SplTransferPrepareConfig = Readonly<{
|
|
84
|
+
/** Amount to transfer. Interpreted based on amountInBaseUnits flag. */
|
|
25
85
|
amount: bigint | number | string;
|
|
86
|
+
/** If true, amount is in base units (raw). If false (default), amount is in decimal tokens. */
|
|
26
87
|
amountInBaseUnits?: boolean;
|
|
88
|
+
/** Authority that signs the transaction. Can be a WalletSession or raw TransactionSigner. */
|
|
27
89
|
authority: SplTokenAuthority;
|
|
90
|
+
/** Commitment level for RPC calls. */
|
|
28
91
|
commitment?: Commitment;
|
|
92
|
+
/** Wallet address of the recipient (not their token account). */
|
|
29
93
|
destinationOwner: Address | string;
|
|
94
|
+
/** Optional: explicit destination token account. If not provided, ATA is derived. */
|
|
30
95
|
destinationToken?: Address | string;
|
|
96
|
+
/** If true (default), creates the destination ATA if it doesn't exist. */
|
|
31
97
|
ensureDestinationAta?: boolean;
|
|
98
|
+
/** Optional pre-fetched blockhash lifetime. */
|
|
32
99
|
lifetime?: BlockhashLifetime;
|
|
100
|
+
/** Source wallet owner. Defaults to authority address. */
|
|
33
101
|
sourceOwner?: Address | string;
|
|
102
|
+
/** Optional: explicit source token account. If not provided, ATA is derived. */
|
|
34
103
|
sourceToken?: Address | string;
|
|
104
|
+
/** Transaction version. Defaults to 0 (legacy). */
|
|
35
105
|
transactionVersion?: TransactionVersion;
|
|
36
106
|
}>;
|
|
107
|
+
/**
|
|
108
|
+
* A prepared SPL token transfer transaction ready to be signed and sent.
|
|
109
|
+
* Contains all the information needed to submit the transaction.
|
|
110
|
+
*/
|
|
37
111
|
type PreparedSplTransfer = Readonly<{
|
|
112
|
+
/** Token amount in base units. */
|
|
38
113
|
amount: bigint;
|
|
114
|
+
/** Commitment level used. */
|
|
39
115
|
commitment?: Commitment;
|
|
116
|
+
/** Token decimals. */
|
|
40
117
|
decimals: number;
|
|
118
|
+
/** Destination Associated Token Account address. */
|
|
41
119
|
destinationAta: Address;
|
|
120
|
+
/** Blockhash lifetime for transaction expiration. */
|
|
42
121
|
lifetime: BlockhashLifetime;
|
|
122
|
+
/** The unsigned transaction message. */
|
|
43
123
|
message: SignableSplTransactionMessage;
|
|
124
|
+
/** Signing mode: 'send' for wallets that sign+send, 'partial' for separate signing. */
|
|
44
125
|
mode: 'partial' | 'send';
|
|
126
|
+
/** The transaction signer. */
|
|
45
127
|
signer: TransactionSigner;
|
|
128
|
+
/** Source Associated Token Account address. */
|
|
46
129
|
sourceAta: Address;
|
|
130
|
+
/** Transaction plan for execution. */
|
|
47
131
|
plan?: TransactionPlan;
|
|
48
132
|
}>;
|
|
133
|
+
/**
|
|
134
|
+
* Helper interface for SPL token operations including balance queries and transfers.
|
|
135
|
+
* Each helper instance is bound to a specific token mint.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* ```ts
|
|
139
|
+
* import { createSplTokenHelper } from '@solana/client';
|
|
140
|
+
*
|
|
141
|
+
* // Create helper for USDC
|
|
142
|
+
* const usdc = createSplTokenHelper(runtime, {
|
|
143
|
+
* mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
144
|
+
* decimals: 6,
|
|
145
|
+
* });
|
|
146
|
+
*
|
|
147
|
+
* // Check balance
|
|
148
|
+
* const balance = await usdc.fetchBalance(walletAddress);
|
|
149
|
+
* console.log(`Balance: ${balance.uiAmount} USDC`);
|
|
150
|
+
*
|
|
151
|
+
* // Transfer tokens
|
|
152
|
+
* const sig = await usdc.sendTransfer({
|
|
153
|
+
* amount: 10, // 10 USDC
|
|
154
|
+
* authority: walletSession,
|
|
155
|
+
* destinationOwner: recipientAddress,
|
|
156
|
+
* });
|
|
157
|
+
* ```
|
|
158
|
+
*/
|
|
49
159
|
export type SplTokenHelper = Readonly<{
|
|
160
|
+
/**
|
|
161
|
+
* Derives the Associated Token Account (ATA) address for an owner.
|
|
162
|
+
* The ATA is a deterministic address based on the owner and mint.
|
|
163
|
+
*/
|
|
50
164
|
deriveAssociatedTokenAddress(owner: Address | string): Promise<Address>;
|
|
165
|
+
/**
|
|
166
|
+
* Fetches the token balance for an owner's Associated Token Account.
|
|
167
|
+
* Returns balance info including whether the account exists.
|
|
168
|
+
*/
|
|
51
169
|
fetchBalance(owner: Address | string, commitment?: Commitment): Promise<SplTokenBalance>;
|
|
170
|
+
/**
|
|
171
|
+
* Prepares a token transfer transaction without sending it.
|
|
172
|
+
* Use this when you need to inspect or modify the transaction before sending.
|
|
173
|
+
*/
|
|
52
174
|
prepareTransfer(config: SplTransferPrepareConfig): Promise<PreparedSplTransfer>;
|
|
175
|
+
/**
|
|
176
|
+
* Sends a previously prepared token transfer transaction.
|
|
177
|
+
* Use this after prepareTransfer() to submit the transaction.
|
|
178
|
+
*/
|
|
53
179
|
sendPreparedTransfer(prepared: PreparedSplTransfer, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
180
|
+
/**
|
|
181
|
+
* Prepares and sends a token transfer in one call.
|
|
182
|
+
* Automatically creates the destination ATA if it doesn't exist (configurable).
|
|
183
|
+
*/
|
|
54
184
|
sendTransfer(config: SplTransferPrepareConfig, options?: SolTransferSendOptions): Promise<ReturnType<typeof signature>>;
|
|
55
185
|
}>;
|
|
56
|
-
/**
|
|
186
|
+
/**
|
|
187
|
+
* Creates helpers for SPL token operations bound to a specific token mint.
|
|
188
|
+
* Supports balance queries, ATA derivation, and token transfers.
|
|
189
|
+
*
|
|
190
|
+
* @param runtime - The Solana client runtime with RPC connection.
|
|
191
|
+
* @param config - Configuration specifying the token mint and optional settings.
|
|
192
|
+
* @returns An SplTokenHelper with methods for token operations.
|
|
193
|
+
*
|
|
194
|
+
* @example
|
|
195
|
+
* ```ts
|
|
196
|
+
* import { createClient } from '@solana/client';
|
|
197
|
+
*
|
|
198
|
+
* const client = createClient({ cluster: 'mainnet-beta' });
|
|
199
|
+
*
|
|
200
|
+
* // Create a helper for USDC
|
|
201
|
+
* const usdc = client.helpers.spl({
|
|
202
|
+
* mint: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
203
|
+
* decimals: 6, // Skip on-chain lookup
|
|
204
|
+
* });
|
|
205
|
+
*
|
|
206
|
+
* // Get token balance
|
|
207
|
+
* const balance = await usdc.fetchBalance(myWallet);
|
|
208
|
+
* if (balance.exists) {
|
|
209
|
+
* console.log(`USDC balance: ${balance.uiAmount}`);
|
|
210
|
+
* }
|
|
211
|
+
*
|
|
212
|
+
* // Transfer tokens
|
|
213
|
+
* const sig = await usdc.sendTransfer({
|
|
214
|
+
* amount: '25.50', // Can use string decimals
|
|
215
|
+
* authority: session,
|
|
216
|
+
* destinationOwner: recipientWallet,
|
|
217
|
+
* });
|
|
218
|
+
* ```
|
|
219
|
+
*/
|
|
57
220
|
export declare function createSplTokenHelper(runtime: SolanaClientRuntime, config: SplTokenHelperConfig): SplTokenHelper;
|
|
58
221
|
export {};
|
|
59
222
|
//# sourceMappingURL=spl.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"spl.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/spl.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,OAAO,EAGZ,KAAK,SAAS,EACd,KAAK,UAAU,EAWf,SAAS,EACT,iCAAiC,EAEjC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,EACvB,MAAM,aAAa,CAAC;
|
|
1
|
+
{"version":3,"file":"spl.d.ts","sourceRoot":"","sources":["../../../../../../client/src/features/spl.ts"],"names":[],"mappings":"AACA,OAAO,EACN,KAAK,OAAO,EAGZ,KAAK,SAAS,EACd,KAAK,UAAU,EAWf,SAAS,EACT,iCAAiC,EAEjC,KAAK,eAAe,EACpB,KAAK,iBAAiB,EACtB,KAAK,kBAAkB,E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