@revibase/transaction-manager 0.0.1 → 0.0.3

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/README.md CHANGED
@@ -1,61 +1,85 @@
1
- ## Installation
2
-
3
- ```bash
4
- npm install @revibase/wallet
5
- ```
1
+ # @revibase/transaction-manager
6
2
 
7
- ## Quick Start
3
+ Transaction verification and processing for the Revibase multi-wallet system.
8
4
 
9
- This SDK requires a Helius RPC endpoint to connect to the Solana network.
10
- You can get one from Helius or any other Solana RPC provider that supports Helius features. (DAS API & Photon RPC)
11
-
12
- ## Initialize the SDK
5
+ ## Installation
13
6
 
14
7
  ```bash
15
- import { initializeMultiWallet } from "@revibase/wallet";
16
-
17
- initializeMultiWallet({
18
- rpcEndpoint: INSERT_YOUR_HELIUS_RPC_ENDPOINT_HERE
19
- });
8
+ npm install @revibase/transaction-manager
20
9
  ```
21
10
 
22
- ## Use with Solana Wallet Adapter
23
-
24
- Once initialized, it is now compatible with the Solana Wallet Adapter.
25
- Simply integrate it into your existing Solana wallet flow.
26
-
27
- ## Example
28
-
29
- ```bash
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import { verifyTransaction } from "@revibase/transaction-manager";
15
+ import { createSolanaRpc, getBase58Decoder } from "gill";
16
+ import { ed25519 } from "@noble/curves/ed25519.js";
17
+
18
+ const rpc = createSolanaRpc("https://api.mainnet-beta.solana.com");
19
+ const transactionManagerConfig = {
20
+ publicKey: "YOUR_TRANSACTION_MANAGER_PUBLIC_KEY",
21
+ url: "https://your-transaction-manager.com/sign",
22
+ };
23
+
24
+ export async function sign(request: Request) {
25
+ const { publicKey, payload } = await request.json();
26
+
27
+ if (publicKey !== transactionManagerConfig.publicKey) {
28
+ return new Response(
29
+ JSON.stringify({ error: "Invalid transaction manager public key" }),
30
+ {
31
+ status: 400,
32
+ headers: { "Content-Type": "application/json" },
33
+ },
34
+ );
35
+ }
36
+
37
+ /**
38
+ * Load your transaction manager private key (Ed25519).
39
+ *
40
+ * Rough example only: `ed25519.sign(messageBytes, privateKey)` expects a 32-byte private key.
41
+ * In production, store/fetch this from secure storage (KMS/HSM), not source code.
42
+ */
43
+ const privateKey = await loadTransactionManagerPrivateKey(publicKey);
44
+
45
+ const signatures: string[] = [];
46
+
47
+ for (const payloadItem of payload) {
48
+ const { messageBytes, verificationResults } = await verifyTransaction(
49
+ rpc,
50
+ transactionManagerConfig,
51
+ payloadItem,
52
+ );
53
+
54
+ /**
55
+ * Add custom allow/deny policy (example):
56
+ * Only allow transfer intents (reject config changes, url edits, account creation, etc.).
57
+ *
58
+ * `verificationResults` contains:
59
+ * - `instructions`: the instruction(s) that will be send on chain
60
+ * - `verifiedSigners`: verified signers metadata
61
+ *
62
+ * make use of those parameters to build your own transaction signing policies
63
+ */
64
+
65
+ // Sign the Solana transaction MESSAGE bytes (Ed25519) and return base58 signatures.
66
+ const signatureBytes = ed25519.sign(messageBytes, privateKey);
67
+ signatures.push(getBase58Decoder().decode(signatureBytes));
68
+ }
69
+
70
+ return new Response(JSON.stringify({ signatures }), {
71
+ headers: { "Content-Type": "application/json" },
72
+ });
73
+ }
30
74
 
31
- import { useEffect } from "react";
32
- import { initializeMultiWallet } from "@revibase/wallet";
33
- import { ConnectionProvider, WalletProvider } from "@solana/wallet-adapter-react";
34
- import { WalletModalProvider, WalletMultiButton } from "@solana/wallet-adapter-react-ui";
35
-
36
-
37
- export default function App() {
38
-
39
- useEffect(() => {
40
- initializeMultiWallet({
41
- rpcEndpoint: INSERT_YOUR_HELIUS_RPC_ENDPOINT_HERE
42
- });
43
- }, []);
44
-
45
-
46
- return (
47
- <ConnectionProvider endpoint={INSERT_YOUR_HELIUS_RPC_ENDPOINT_HERE}>
48
- <WalletProvider wallets={[]} autoConnect>
49
- <WalletModalProvider>
50
- <div>
51
- <WalletMultiButton />
52
- {...}
53
- </div>
54
- </WalletModalProvider>
55
- </WalletProvider>
56
- </ConnectionProvider>
57
- );
75
+ async function loadTransactionManagerPrivateKey(
76
+ publicKey: string,
77
+ ): Promise<Uint8Array<ArrayBuffer>> {
78
+ // fetch the corresponding private key for your transaction manager public key
79
+ // - return a 32-byte Ed25519 private key, e.g. from env/KMS.
58
80
  }
81
+ ```
59
82
 
83
+ ## License
60
84
 
61
- ```
85
+ MIT
package/dist/index.cjs CHANGED
@@ -1,7 +1,7 @@
1
- 'use strict';var core=require('@revibase/core');var Zt=1,qt=2,Jt=3,Qt=4,en=5,tn=6,nn=7,rn=8,on=9,an=10,sn=-32700,cn=-32603,un=-32602,dn=-32601,_n=-32600,An=-32019,In=-32018,Rn=-32017,En=-32016,ln=-32015,Tn=-32014,gn=-32013,Sn=-32012,fn=-32011,Nn=-32010,On=-32009,Dn=-32008,Cn=-32007,mn=-32006,pn=-32005,hn=-32004,Ln=-32003,Mn=-32002,yn=-32001,W=28e5,K=2800001,Un=2800002,be=2800003,ve=2800004,Pe=2800005,Be=2800006,we=2800007,Fe=2800008,ze=2800009,xe=2800010,ke=2800011,Ve=323e4,$=32300001,Ge=3230002,He=3230003,Y=3230004,bn=361e4,vn=3610001,Pn=3610002,Bn=3610003,wn=3610004,Fn=3610005,zn=3610006,xn=3610007,kn=3611e3,Vn=3704e3,Gn=3704001,Hn=3704002,Wn=3704003,Kn=3704004,$n=4128e3,Yn=4128001,Xn=4128002,jn=4615e3,Zn=4615001,qn=4615002,Jn=4615003,Qn=4615004,er=4615005,tr=4615006,nr=4615007,rr=4615008,or=4615009,ir=4615010,ar=4615011,sr=4615012,cr=4615013,ur=4615014,dr=4615015,_r=4615016,Ar=4615017,Ir=4615018,Rr=4615019,Er=4615020,lr=4615021,Tr=4615022,gr=4615023,Sr=4615024,fr=4615025,Nr=4615026,Or=4615027,Dr=4615028,Cr=4615029,mr=4615030,pr=4615031,hr=4615032,Lr=4615033,Mr=4615034,yr=4615035,Ur=4615036,br=4615037,vr=4615038,Pr=4615039,Br=4615040,wr=4615041,Fr=4615042,zr=4615043,xr=4615044,kr=4615045,Vr=4615046,Gr=4615047,Hr=4615048,Wr=4615049,Kr=4615050,$r=4615051,Yr=4615052,Xr=4615053,jr=4615054,Zr=5508e3,qr=5508001,Jr=5508002,Qr=5508003,eo=5508004,to=5508005,no=5508006,ro=5508007,oo=5508008,io=5508009,ao=5508010,so=5508011,We=5663e3,Ke=5663001,X=5663002,j=5663003,$e=5663004,Z=5663005,q=5663006,J=5663007,Q=5663008,Ye=5663009,co=5663010,uo=5663011,Xe=5663012,_o=5663013,Ao=5663014,je=5663015,Ze=5663016,ee=5663017,Io=5663018,Ro=5663019,qe=5663020,te=5663021,Je=5663022,Eo=705e4,lo=7050001,To=7050002,go=7050003,So=7050004,fo=7050005,No=7050006,Oo=7050007,Do=7050008,Co=7050009,mo=7050010,po=7050011,ho=7050012,Lo=7050013,Mo=7050014,yo=7050015,Uo=7050016,bo=7050017,vo=7050018,Po=7050019,Bo=7050020,wo=7050021,Fo=7050022,zo=7050023,xo=7050024,ko=7050025,Vo=7050026,Go=7050027,Ho=7050028,Wo=7050029,Ko=7050030,$o=7050031,Yo=7050032,Xo=7050033,jo=7050034,Zo=7050035,qo=7050036,Jo=7618e3,Qo=7618001,ei=7618002,ti=7618003,ne=8078e3,re=8078001,Qe=8078002,et=8078003,tt=8078004,nt=8078005,rt=8078006,ni=8078007,ri=8078008,oi=8078009,ii=8078010,ai=8078011,z=8078012,oe=8078013,ie=8078014,si=8078015,ci=8078016,ui=8078017,di=8078018,_i=8078019,ot=8078020,it=8078021,Ai=8078022,at=8078023,Ii=81e5,Ri=8100001,Ei=8100002,li=8100003,Ti=819e4,gi=8190001,Si=8190002,fi=8190003,Ni=8190004,Oi=99e5,Di=9900001,Ci=9900002,mi=9900003,pi=9900004,hi=9900005,Li=9900006;function st(e){return Array.isArray(e)?"%5B"+e.map(st).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function Mi([e,t]){return `${e}=${st(t)}`}function yi(e){let t=Object.entries(e).map(Mi).join("&");return Buffer.from(t,"utf8").toString("base64")}var Ui={[Ve]:"Account not found at address: $address",[Y]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[He]:"Expected decoded account at address: $address",[Ge]:"Failed to decode account data at address: $address",[$]:"Accounts not found at addresses: $addresses",[ze]:"Unable to find a viable program address bump seed.",[Un]:"$putativeAddress is not a base58-encoded address.",[W]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[be]:"The `CryptoKey` must be an `Ed25519` public key.",[ke]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Fe]:"Invalid seeds; point must fall off the Ed25519 curve.",[ve]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[Be]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[we]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[Pe]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[xe]:"Program address cannot end with PDA marker.",[K]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Qt]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Zt]:"The network has progressed past the last block for which this transaction could have been committed.",[ne]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Ai]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[ot]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[nt]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[rt]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[tt]:"Encoder and decoder must either both be fixed-size or variable-size.",[ri]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Qe]:"Expected a fixed-size codec, got a variable-size one.",[oe]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[et]:"Expected a variable-size codec, got a fixed-size one.",[_i]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[re]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[di]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[oi]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[ii]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[si]:"Invalid literal union variant. Expected one of [$variants], got $value.",[ni]:"Expected [$codecDescription] to have $expected items, got $actual.",[z]:"Invalid value $value for base $base with alphabet $alphabet.",[ci]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[ai]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[ie]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[it]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[ui]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[at]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[kn]:"No random values implementation could be found.",[or]:"instruction requires an uninitialized account",[gr]:"instruction tries to borrow reference for an account which is already borrowed",[Sr]:"instruction left account with an outstanding borrowed reference",[lr]:"program other than the account's owner changed the size of the account data",[er]:"account data too small for instruction",[Tr]:"instruction expected an executable account",[Vr]:"An account does not have enough lamports to be rent-exempt",[Hr]:"Program arithmetic overflowed",[kr]:"Failed to serialize or deserialize account data: $encodedData",[jr]:"Builtin programs must consume compute units",[hr]:"Cross-program invocation call depth too deep",[vr]:"Computational budget exceeded",[Nr]:"custom program error: #$code",[Ar]:"instruction contains duplicate accounts",[fr]:"instruction modifications of multiply-passed account differ",[mr]:"executable accounts must be rent exempt",[Dr]:"instruction changed executable accounts data",[Cr]:"instruction changed the balance of an executable account",[Ir]:"instruction changed executable bit of an account",[ur]:"instruction modified data of an account it does not own",[cr]:"instruction spent from the balance of an account it does not own",[Zn]:"generic instruction error",[Kr]:"Provided owner is not allowed",[zr]:"Account is immutable",[xr]:"Incorrect authority provided",[nr]:"incorrect program id for instruction",[tr]:"insufficient funds for instruction",[Qn]:"invalid account data for instruction",[Gr]:"Invalid account owner",[qn]:"invalid program argument",[Or]:"program returned invalid error code",[Jn]:"invalid instruction data",[br]:"Failed to reallocate account data",[Ur]:"Provided seeds do not result in a valid address",[$r]:"Accounts data allocations exceeded the maximum allowed per transaction",[Yr]:"Max accounts exceeded",[Xr]:"Max instruction trace length exceeded",[yr]:"Length of the seed is too long for address generation",[Lr]:"An account required by the instruction is missing",[rr]:"missing required signature for instruction",[sr]:"instruction illegally modified the program id of an account",[Er]:"insufficient account keys for instruction",[Pr]:"Cross-program invocation with unauthorized signer or writable account",[Br]:"Failed to create program execution environment",[Fr]:"Program failed to compile",[wr]:"Program failed to complete",[_r]:"instruction modified data of a read-only account",[dr]:"instruction changed the balance of a read-only account",[Mr]:"Cross-program invocation reentrancy not allowed for this instruction",[Rr]:"instruction modified rent epoch of an account",[ar]:"sum of account balances before and after instruction do not match",[ir]:"instruction requires an initialized account",[jn]:"",[pr]:"Unsupported program id",[Wr]:"Unsupported sysvar",[hi]:"Invalid instruction plan kind: $kind.",[ei]:"The provided instruction plan is empty.",[ti]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Jo]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[Li]:"Invalid transaction plan kind: $kind.",[Qo]:"No more instructions to pack; the message packer has completed the instruction plan.",[$n]:"The instruction does not have any accounts.",[Yn]:"The instruction does not have any data.",[Xn]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[en]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[qt]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Ci]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[pi]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Di]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Oi]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[mi]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[cn]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[un]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[_n]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[dn]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[sn]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Sn]:"$__serverMessage",[yn]:"$__serverMessage",[hn]:"$__serverMessage",[Tn]:"$__serverMessage",[Rn]:"Epoch rewards period still active at slot $slot",[Nn]:"$__serverMessage",[On]:"$__serverMessage",[An]:"Failed to query long-term storage; please try again",[En]:"Minimum context slot has not been reached",[pn]:"Node is unhealthy; behind by $numSlotsBehind slots",[Dn]:"No snapshot",[Mn]:"Transaction simulation failed",[In]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[Cn]:"$__serverMessage",[fn]:"Transaction history is not available from this node",[mn]:"$__serverMessage",[gn]:"Transaction signature length mismatch",[Ln]:"Transaction signature verification failure",[ln]:"$__serverMessage",[Vn]:"Key pair bytes must be of length 64, got $byteLength.",[Gn]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Hn]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Kn]:"The provided private key does not match the provided public key.",[Wn]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[tn]:"Lamports value must be in the range [0, 2e64-1]",[nn]:"`$value` cannot be parsed as a `BigInt`",[an]:"$message",[rn]:"`$value` cannot be parsed as a `Number`",[Jt]:"No nonce account could be found at address `$nonceAccountAddress`",[Ti]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Si]:"WebSocket was closed before payload could be added to the send buffer",[fi]:"WebSocket connection closed",[Ni]:"WebSocket failed to connect",[gi]:"Failed to obtain a subscription id from the server",[li]:"Could not find an API plan for RPC method: `$method`",[Ii]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[Ei]:"HTTP error ($statusCode): $message",[Ri]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Zr]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[qr]:"The provided value does not implement the `KeyPairSigner` interface",[Qr]:"The provided value does not implement the `MessageModifyingSigner` interface",[eo]:"The provided value does not implement the `MessagePartialSigner` interface",[Jr]:"The provided value does not implement any of the `MessageSigner` interfaces",[no]:"The provided value does not implement the `TransactionModifyingSigner` interface",[ro]:"The provided value does not implement the `TransactionPartialSigner` interface",[oo]:"The provided value does not implement the `TransactionSendingSigner` interface",[to]:"The provided value does not implement any of the `TransactionSigner` interfaces",[io]:"More than one `TransactionSendingSigner` was identified.",[ao]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[so]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[xn]:"Cannot export a non-extractable key.",[vn]:"No digest implementation could be found.",[bn]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Pn]:`This runtime does not support the generation of Ed25519 key pairs.
1
+ 'use strict';var core=require('@revibase/core'),sha2_js=require('@noble/hashes/sha2.js'),jose=require('jose');var Qt=1,en=2,tn=3,nn=4,rn=5,on=6,an=7,sn=8,cn=9,un=10,dn=-32700,_n=-32603,An=-32602,In=-32601,Rn=-32600,En=-32019,ln=-32018,Tn=-32017,gn=-32016,Sn=-32015,fn=-32014,Nn=-32013,Dn=-32012,On=-32011,Cn=-32010,mn=-32009,pn=-32008,hn=-32007,Ln=-32006,Mn=-32005,Un=-32004,yn=-32003,bn=-32002,vn=-32001,K=28e5,$=2800001,Pn=2800002,Fe=2800003,ze=2800004,xe=2800005,ke=2800006,Ve=2800007,Ge=2800008,He=2800009,We=2800010,Ke=2800011,$e=323e4,Y=32300001,Ye=3230002,Xe=3230003,X=3230004,Bn=361e4,wn=3610001,Fn=3610002,zn=3610003,xn=3610004,kn=3610005,Vn=3610006,Gn=3610007,Hn=3611e3,Wn=3704e3,Kn=3704001,$n=3704002,Yn=3704003,Xn=3704004,jn=4128e3,Zn=4128001,qn=4128002,Jn=4615e3,Qn=4615001,er=4615002,tr=4615003,nr=4615004,rr=4615005,or=4615006,ir=4615007,ar=4615008,sr=4615009,cr=4615010,ur=4615011,dr=4615012,_r=4615013,Ar=4615014,Ir=4615015,Rr=4615016,Er=4615017,lr=4615018,Tr=4615019,gr=4615020,Sr=4615021,fr=4615022,Nr=4615023,Dr=4615024,Or=4615025,Cr=4615026,mr=4615027,pr=4615028,hr=4615029,Lr=4615030,Mr=4615031,Ur=4615032,yr=4615033,br=4615034,vr=4615035,Pr=4615036,Br=4615037,wr=4615038,Fr=4615039,zr=4615040,xr=4615041,kr=4615042,Vr=4615043,Gr=4615044,Hr=4615045,Wr=4615046,Kr=4615047,$r=4615048,Yr=4615049,Xr=4615050,jr=4615051,Zr=4615052,qr=4615053,Jr=4615054,Qr=5508e3,eo=5508001,to=5508002,no=5508003,ro=5508004,oo=5508005,io=5508006,ao=5508007,so=5508008,co=5508009,uo=5508010,_o=5508011,je=5663e3,Ze=5663001,j=5663002,Z=5663003,qe=5663004,q=5663005,J=5663006,Q=5663007,ee=5663008,Je=5663009,Ao=5663010,Io=5663011,Qe=5663012,Ro=5663013,Eo=5663014,et=5663015,tt=5663016,te=5663017,lo=5663018,To=5663019,nt=5663020,ne=5663021,rt=5663022,go=705e4,So=7050001,fo=7050002,No=7050003,Do=7050004,Oo=7050005,Co=7050006,mo=7050007,po=7050008,ho=7050009,Lo=7050010,Mo=7050011,Uo=7050012,yo=7050013,bo=7050014,vo=7050015,Po=7050016,Bo=7050017,wo=7050018,Fo=7050019,zo=7050020,xo=7050021,ko=7050022,Vo=7050023,Go=7050024,Ho=7050025,Wo=7050026,Ko=7050027,$o=7050028,Yo=7050029,Xo=7050030,jo=7050031,Zo=7050032,qo=7050033,Jo=7050034,Qo=7050035,ei=7050036,ti=7618e3,ni=7618001,ri=7618002,oi=7618003,re=8078e3,oe=8078001,ot=8078002,it=8078003,at=8078004,st=8078005,ct=8078006,ii=8078007,ai=8078008,si=8078009,ci=8078010,ui=8078011,z=8078012,ie=8078013,ae=8078014,di=8078015,_i=8078016,Ai=8078017,Ii=8078018,Ri=8078019,ut=8078020,dt=8078021,Ei=8078022,_t=8078023,li=81e5,Ti=8100001,gi=8100002,Si=8100003,fi=819e4,Ni=8190001,Di=8190002,Oi=8190003,Ci=8190004,mi=99e5,pi=9900001,hi=9900002,Li=9900003,Mi=9900004,Ui=9900005,yi=9900006;function At(e){return Array.isArray(e)?"%5B"+e.map(At).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function bi([e,t]){return `${e}=${At(t)}`}function vi(e){let t=Object.entries(e).map(bi).join("&");return Buffer.from(t,"utf8").toString("base64")}var Pi={[$e]:"Account not found at address: $address",[X]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[Xe]:"Expected decoded account at address: $address",[Ye]:"Failed to decode account data at address: $address",[Y]:"Accounts not found at addresses: $addresses",[He]:"Unable to find a viable program address bump seed.",[Pn]:"$putativeAddress is not a base58-encoded address.",[K]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Fe]:"The `CryptoKey` must be an `Ed25519` public key.",[Ke]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[Ge]:"Invalid seeds; point must fall off the Ed25519 curve.",[ze]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[ke]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[Ve]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[xe]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[We]:"Program address cannot end with PDA marker.",[$]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[nn]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Qt]:"The network has progressed past the last block for which this transaction could have been committed.",[re]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Ei]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[ut]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[st]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[ct]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[at]:"Encoder and decoder must either both be fixed-size or variable-size.",[ai]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[ot]:"Expected a fixed-size codec, got a variable-size one.",[ie]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[it]:"Expected a variable-size codec, got a fixed-size one.",[Ri]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[oe]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[Ii]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[si]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[ci]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[di]:"Invalid literal union variant. Expected one of [$variants], got $value.",[ii]:"Expected [$codecDescription] to have $expected items, got $actual.",[z]:"Invalid value $value for base $base with alphabet $alphabet.",[_i]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[ui]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[ae]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[dt]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[Ai]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[_t]:"This decoder expected a byte array of exactly $expectedLength bytes, but $numExcessBytes unexpected excess bytes remained after decoding. Are you sure that you have chosen the correct decoder for this data?",[Hn]:"No random values implementation could be found.",[sr]:"instruction requires an uninitialized account",[Nr]:"instruction tries to borrow reference for an account which is already borrowed",[Dr]:"instruction left account with an outstanding borrowed reference",[Sr]:"program other than the account's owner changed the size of the account data",[rr]:"account data too small for instruction",[fr]:"instruction expected an executable account",[Wr]:"An account does not have enough lamports to be rent-exempt",[$r]:"Program arithmetic overflowed",[Hr]:"Failed to serialize or deserialize account data: $encodedData",[Jr]:"Builtin programs must consume compute units",[Ur]:"Cross-program invocation call depth too deep",[wr]:"Computational budget exceeded",[Cr]:"custom program error: #$code",[Er]:"instruction contains duplicate accounts",[Or]:"instruction modifications of multiply-passed account differ",[Lr]:"executable accounts must be rent exempt",[pr]:"instruction changed executable accounts data",[hr]:"instruction changed the balance of an executable account",[lr]:"instruction changed executable bit of an account",[Ar]:"instruction modified data of an account it does not own",[_r]:"instruction spent from the balance of an account it does not own",[Qn]:"generic instruction error",[Xr]:"Provided owner is not allowed",[Vr]:"Account is immutable",[Gr]:"Incorrect authority provided",[ir]:"incorrect program id for instruction",[or]:"insufficient funds for instruction",[nr]:"invalid account data for instruction",[Kr]:"Invalid account owner",[er]:"invalid program argument",[mr]:"program returned invalid error code",[tr]:"invalid instruction data",[Br]:"Failed to reallocate account data",[Pr]:"Provided seeds do not result in a valid address",[jr]:"Accounts data allocations exceeded the maximum allowed per transaction",[Zr]:"Max accounts exceeded",[qr]:"Max instruction trace length exceeded",[vr]:"Length of the seed is too long for address generation",[yr]:"An account required by the instruction is missing",[ar]:"missing required signature for instruction",[dr]:"instruction illegally modified the program id of an account",[gr]:"insufficient account keys for instruction",[Fr]:"Cross-program invocation with unauthorized signer or writable account",[zr]:"Failed to create program execution environment",[kr]:"Program failed to compile",[xr]:"Program failed to complete",[Rr]:"instruction modified data of a read-only account",[Ir]:"instruction changed the balance of a read-only account",[br]:"Cross-program invocation reentrancy not allowed for this instruction",[Tr]:"instruction modified rent epoch of an account",[ur]:"sum of account balances before and after instruction do not match",[cr]:"instruction requires an initialized account",[Jn]:"",[Mr]:"Unsupported program id",[Yr]:"Unsupported sysvar",[Ui]:"Invalid instruction plan kind: $kind.",[ri]:"The provided instruction plan is empty.",[oi]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[ti]:"The provided message has insufficient capacity to accommodate the next instruction(s) in this plan. Expected at least $numBytesRequired free byte(s), got $numFreeBytes byte(s).",[yi]:"Invalid transaction plan kind: $kind.",[ni]:"No more instructions to pack; the message packer has completed the instruction plan.",[jn]:"The instruction does not have any accounts.",[Zn]:"The instruction does not have any data.",[qn]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[rn]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[en]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[hi]:"Invariant violation: Found no abortable iterable cache entry for key `$cacheKey`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Mi]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[pi]:"Invariant violation: WebSocket message iterator state is corrupt; iterated without first resolving existing message promise. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[mi]:"Invariant violation: WebSocket message iterator is missing state storage. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[Li]:"Invariant violation: Switch statement non-exhaustive. Received unexpected value `$unexpectedValue`. It should be impossible to hit this error; please file an issue at https://sola.na/web3invariant",[_n]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[An]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Rn]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[In]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[dn]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[Dn]:"$__serverMessage",[vn]:"$__serverMessage",[Un]:"$__serverMessage",[fn]:"$__serverMessage",[Tn]:"Epoch rewards period still active at slot $slot",[Cn]:"$__serverMessage",[mn]:"$__serverMessage",[En]:"Failed to query long-term storage; please try again",[gn]:"Minimum context slot has not been reached",[Mn]:"Node is unhealthy; behind by $numSlotsBehind slots",[pn]:"No snapshot",[bn]:"Transaction simulation failed",[ln]:"Rewards cannot be found because slot $slot is not the epoch boundary. This may be due to gap in the queried node's local ledger or long-term storage",[hn]:"$__serverMessage",[On]:"Transaction history is not available from this node",[Ln]:"$__serverMessage",[Nn]:"Transaction signature length mismatch",[yn]:"Transaction signature verification failure",[Sn]:"$__serverMessage",[Wn]:"Key pair bytes must be of length 64, got $byteLength.",[Kn]:"Expected private key bytes with length 32. Actual length: $actualLength.",[$n]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Xn]:"The provided private key does not match the provided public key.",[Yn]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[on]:"Lamports value must be in the range [0, 2e64-1]",[an]:"`$value` cannot be parsed as a `BigInt`",[un]:"$message",[sn]:"`$value` cannot be parsed as a `Number`",[tn]:"No nonce account could be found at address `$nonceAccountAddress`",[fi]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Di]:"WebSocket was closed before payload could be added to the send buffer",[Oi]:"WebSocket connection closed",[Ci]:"WebSocket failed to connect",[Ni]:"Failed to obtain a subscription id from the server",[Si]:"Could not find an API plan for RPC method: `$method`",[li]:"The $argumentLabel argument to the `$methodName` RPC method$optionalPathLabel was `$value`. This number is unsafe for use with the Solana JSON-RPC because it exceeds `Number.MAX_SAFE_INTEGER`.",[gi]:"HTTP error ($statusCode): $message",[Ti]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[Qr]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[eo]:"The provided value does not implement the `KeyPairSigner` interface",[no]:"The provided value does not implement the `MessageModifyingSigner` interface",[ro]:"The provided value does not implement the `MessagePartialSigner` interface",[to]:"The provided value does not implement any of the `MessageSigner` interfaces",[io]:"The provided value does not implement the `TransactionModifyingSigner` interface",[ao]:"The provided value does not implement the `TransactionPartialSigner` interface",[so]:"The provided value does not implement the `TransactionSendingSigner` interface",[oo]:"The provided value does not implement any of the `TransactionSigner` interfaces",[co]:"More than one `TransactionSendingSigner` was identified.",[uo]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[_o]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Gn]:"Cannot export a non-extractable key.",[wn]:"No digest implementation could be found.",[Bn]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[Fn]:`This runtime does not support the generation of Ed25519 key pairs.
2
2
 
3
3
  Install @solana/webcrypto-ed25519-polyfill and call its \`install\` function before generating keys in environments that do not support Ed25519.
4
4
 
5
- For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[Bn]:"No signature verification implementation could be found.",[wn]:"No key generation implementation could be found.",[Fn]:"No signing implementation could be found.",[zn]:"No key export implementation could be found.",[on]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Uo]:"Transaction processing left an account with an outstanding borrowed reference",[lo]:"Account in use",[To]:"Account loaded twice",[go]:"Attempt to debit an account but found no record of a prior credit.",[zo]:"Transaction loads an address table account that doesn't exist",[Oo]:"This transaction has already been processed",[Do]:"Blockhash not found",[Co]:"Loader call chain is too deep",[yo]:"Transactions are currently disabled due to cluster maintenance",[Ko]:"Transaction contains a duplicate instruction ($index) that is not allowed",[fo]:"Insufficient funds for fee",[$o]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[No]:"This account may not be used to pay transaction fees",[po]:"Transaction contains an invalid account reference",[ko]:"Transaction loads an address table account with invalid data",[Vo]:"Transaction address table lookup uses an invalid index",[xo]:"Transaction loads an address table account with an invalid owner",[Xo]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Lo]:"This program may not be used for executing instructions",[Go]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Po]:"Transaction loads a writable account that cannot be written",[Yo]:"Transaction exceeded max loaded accounts data size cap",[mo]:"Transaction requires a fee but has no signature present",[So]:"Attempt to load a program that does not exist",[Zo]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[jo]:"ResanitizationNeeded",[Mo]:"Transaction failed to sanitize accounts offsets correctly",[ho]:"Transaction did not pass signature verification",[Fo]:"Transaction locked too many accounts",[qo]:"Sum of account balances before and after transaction do not match",[Eo]:"The transaction failed with the error `$errorName`",[vo]:"Transaction version is unsupported",[wo]:"Transaction would exceed account data limit within the block",[Wo]:"Transaction would exceed total account data limit",[Bo]:"Transaction would exceed max account limit within the block",[bo]:"Transaction would exceed max Block Cost Limit",[Ho]:"Transaction would exceed max Vote Cost Limit",[je]:"Attempted to sign a transaction with an address that is not a signer for it",[co]:"Transaction is missing an address at index: $index.",[Ze]:"Transaction has no expected signers therefore it cannot be encoded",[qe]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[X]:"Transaction does not have a blockhash lifetime",[j]:"Transaction is not a durable nonce transaction",[Z]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[q]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[Q]:"No fee payer set in CompiledTransaction",[J]:"Could not find program address at index $index",[Io]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[Ro]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[uo]:"Transaction is missing a fee payer.",[Xe]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Ao]:"Transaction first instruction is not advance nonce account instruction.",[_o]:"Transaction with no instructions cannot be durable nonce transaction.",[We]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Ke]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[ee]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[Ye]:"Transaction is missing signatures for addresses: $addresses.",[$e]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[te]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[Je]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},f="i",T="t";function bi(e,t={}){let n=Ui[e];if(n.length===0)return "";let r;function o(i){if(r[T]===2){let s=n.slice(r[f]+1,i);a.push(s in t?`${t[s]}`:`$${s}`);}else r[T]===1&&a.push(n.slice(r[f],i));}let a=[];return n.split("").forEach((i,s)=>{if(s===0){r={[f]:0,[T]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[T]){case 0:c={[f]:s,[T]:1};break;case 1:i==="\\"?c={[f]:s,[T]:0}:i==="$"&&(c={[f]:s,[T]:2});break;case 2:i==="\\"?c={[f]:s,[T]:0}:i==="$"?c={[f]:s,[T]:2}:i.match(/\w/)||(c={[f]:s,[T]:1});break}c&&(r!==c&&o(s),r=c);}),o(),a.join("")}function vi(e,t={}){if(process.env.NODE_ENV!=="production")return bi(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${yi(t)}'`),`${n}\``}}var _=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([a,i])=>{a==="cause"?r={cause:i.value}:(n===void 0&&(n={}),Object.defineProperty(n,a,i));});let o=vi(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function Pi(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var Bi=(e,t)=>Pi(e.length<=t?e:e.slice(0,t),t);function ut(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function y(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(ut(t,e));return e.write(t,n,0),n}})}function A(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function N(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function dt(e,t,n=0){if(t.length-n<=0)throw new _(ne,{codecDescription:e})}function v(e,t,n,r=0){let o=n.length-r;if(o<t)throw new _(re,{bytesLength:o,codecDescription:e,expected:t})}function ct(e,t,n){if(t<0||t>n)throw new _(ie,{bytesLength:n,codecDescription:e,offset:t})}function _t(e,t){let n=(i,s)=>{let[c,u]=t.read(i,s),d=Number(c);return s=u,(s>0||i.length>d)&&(i=i.slice(s,s+d)),v("addDecoderSizePrefix",d,i),[e.decode(i),s+d]};if(N(t)&&N(e))return A({...e,fixedSize:t.fixedSize+e.fixedSize,read:n});let r=N(t)?t.fixedSize:t.maxSize??null,o=N(e)?e.fixedSize:e.maxSize??null,a=r!==null&&o!==null?r+o:null;return A({...e,...a!==null?{maxSize:a}:{},read:n})}function p(e,t){return A({fixedSize:t,read:(n,r)=>{v("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),N(e)&&(n=Bi(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function wi(e,t){return A({...e,read:(n,r)=>{let o=u=>Fi(u,n.length),a=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;ct("offsetDecoder",a,n.length);let[i,s]=e.read(n,a),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:a,postOffset:s,preOffset:r,wrapBytes:o}):s;return ct("offsetDecoder",c,n.length),[i,c]}})}function Fi(e,t){return t===0?0:(e%t+t)%t}function zi(e,t){if(N(e)){let n=t(e.fixedSize);if(n<0)throw new _(oe,{bytesLength:n,codecDescription:"resizeDecoder"});return A({...e,fixedSize:n})}return e}function At(e,t){return wi(zi(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function U(e,t){return A({...e,read:(n,r)=>{let[o,a]=e.read(n,r);return [t(o,n,r),a]}})}function Et(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new _(z,{alphabet:e,base:e.length,value:n})}var xi=e=>y({getSizeFromValue:t=>{let[n,r]=It(t,e[0]);if(!r)return t.length;let o=Rt(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(Et(e,t),t==="")return r;let[o,a]=It(t,e[0]);if(!a)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let i=Rt(a,e),s=[];for(;i>0n;)s.unshift(Number(i%256n)),i/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),ki=e=>A({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=Vi(i,e);return [a+s,t.length]}});function It(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Rt(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Vi(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var lt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",h=()=>xi(lt),Tt=()=>ki(lt);var Gi="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=()=>y({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){Et(Gi,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}});function Hi(e){return !("exists"in e)||"exists"in e&&e.exists}function gt(e){let t=e.filter(n=>Hi(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new _(Y,{addresses:n})}}function Wi(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=b().encode(t.data[0]);return Object.freeze({...St(t),address:e,data:n,exists:true})}function Ki(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...St(t),address:e,data:n,exists:true})}function St(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function ft(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((i,s)=>i&&typeof i=="object"&&"parsed"in i.data?Ki(t[s],i):Wi(t[s],i))}function Nt(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new _($,{addresses:n})}}var ae,se;function $i(){return ae||(ae=h()),ae}function Yi(){return se||(se=Tt()),se}function x(e){if(e.length<32||e.length>44)throw new _(K,{actualLength:e.length});let r=$i().encode(e).byteLength;if(r!==32)throw new _(W,{actualLength:r})}function B(e){return x(e),e}function w(){return p(Yi(),32)}function Xi(e){return e?.endian!==1}function Ot(e){return A({fixedSize:e.size,read(t,n=0){dt(e.name,t,n),v(e.name,e.size,t,n);let r=new DataView(ji(t,n,e.size));return [e.get(r,Xi(e.config)),n+e.size]}})}function ji(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var g=()=>A({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){let o=r-1,a=e[t+o],i=127&a;if(n|=i<<o*7,(a&128)===0)break}return [n,t+r]}});var Dt=(e={})=>Ot({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var C=()=>Ot({get:e=>e.getUint8(0),name:"u8",size:1});function k(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function de(e){return N(e)?e.fixedSize:null}function _e(e){return N(e)?e.fixedSize:e.maxSize??null}function O(e,t={}){let n=t.size??Dt(),r=de(e),o=Ct(n,r),a=Ct(n,_e(e))??void 0;return A({...o!==null?{fixedSize:o}:{maxSize:a},read:(i,s)=>{let c=[];if(typeof n=="object"&&i.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<i.length;){let[I,l]=e.read(i,s);s=l,c.push(I);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(i,s);s=d;for(let I=0;I<u;I+=1){let[l,S]=e.read(i,s);s=S,c.push(l);}return [c,s]}})}function Ct(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function F(){return A({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function mt(e){let t=k(e.map(de)),n=k(e.map(_e))??void 0;return A({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let a=[];return e.forEach(i=>{let[s,c]=i.read(r,o);a.push(s),o=c;}),[a,o]}})}function L(e){let t=e.map(([,o])=>o),n=k(t.map(de)),r=k(t.map(_e))??void 0;return A({...n===null?{maxSize:r}:{fixedSize:n},read:(o,a)=>{let i={};return e.forEach(([s,c])=>{let[u,d]=c.read(o,a);a=d,i[s]=u;}),[i,a]}})}function pt(e,...t){return t.reduce((n,r)=>r(n),e)}var R=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(R||{});function ht(e){return e>=2}function ta(e,t){return "lifetimeConstraint"in t&&t.lifetimeConstraint&&"blockhash"in t.lifetimeConstraint&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight?t:Object.freeze({...t,lifetimeConstraint:Object.freeze(e)})}var na=e=>A({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let a=e[0].repeat(o);if(o===r.length)return [a,t.length];let i=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=ra(i,e);return [a+s,t.length]}});function ra(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var oa="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var ia=()=>na(oa);var Ae;function aa(){if(!Ae){let e=O(C(),{size:g()});Ae=L([["lookupTableAddress",w()],["writableIndexes",e],["readonlyIndexes",e]]);}return Ae}var Ie;function Re(){return Ie||(Ie=C()),Ie}function sa(){return L([["numSignerAccounts",Re()],["numReadonlySignerAccounts",Re()],["numReadonlyNonSignerAccounts",Re()]])}var Ee;function ca(){return Ee||(Ee=U(L([["programAddressIndex",C()],["accountIndices",O(C(),{size:g()})],["data",_t(F(),g())]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:n,...r}=e;return {...r,...t.length?{accountIndices:t}:null,...n.byteLength?{data:n}:null}})),Ee}var ua=0,Lt=128;function le(){return A({maxSize:1,read:(e,t)=>{let n=e[t];if((n&Lt)===0)return ["legacy",t];{let r=n^Lt;if(r>ua)throw new _(te,{unsupportedVersion:r});return [r,t+1]}}})}function da(){return [["version",le()],["header",sa()],["staticAccounts",O(w(),{size:g()})],["lifetimeToken",p(ia(),32)],["instructions",O(ca(),{size:g()})],["addressTableLookups",_a()]]}function _a(){return O(aa(),{size:g()})}function yt(){return U(L(da()),({addressTableLookups:e,...t})=>t.version==="legacy"||!e?.length?t:{...t,addressTableLookups:e})}function Aa(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var Ut="SysvarRecentB1ockHashes11111111111111111111",bt="11111111111111111111111111111111";function Mt(e,t){return {accounts:[{address:e,role:R.WRITABLE},{address:Ut,role:R.READONLY},{address:t,role:R.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:bt}}function Te(e){return e.programAddress===bt&&e.data!=null&&Ia(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===R.WRITABLE&&e.accounts[1].address===Ut&&e.accounts[1].role===R.READONLY&&e.accounts[2].address!=null&&ht(e.accounts[2].role)}function Ia(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function vt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&Te(e.instructions[0])}function Ra(e,t,n){return e.accounts[0].address===t&&e.accounts[2].address===n}function Ea({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:n},r){let o,a=r.instructions[0];if(a&&Te(a))if(Ra(a,t,n)){if(vt(r)&&r.lifetimeConstraint.nonce===e)return r;o=[a,...r.instructions.slice(1)];}else o=[Object.freeze(Mt(t,n)),...r.instructions.slice(1)];else o=[Object.freeze(Mt(t,n)),...r.instructions];return Object.freeze({...r,instructions:Object.freeze(o),lifetimeConstraint:Object.freeze({nonce:e})})}function la(e,t){if("feePayer"in t&&e===t.feePayer?.address&&Ta(t.feePayer))return t;let n={...t,feePayer:Object.freeze({address:e})};return Object.freeze(n),n}function Ta(e){return !!e&&"address"in e&&typeof e.address=="string"&&Object.keys(e).length===1}function ga(e,t){return Sa([e],t)}function Sa(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function fa(e){let{header:t}=e,n=t.numSignerAccounts-t.numReadonlySignerAccounts,r=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,o=[],a=0;for(let i=0;i<n;i++)o.push({address:e.staticAccounts[a],role:R.WRITABLE_SIGNER}),a++;for(let i=0;i<t.numReadonlySignerAccounts;i++)o.push({address:e.staticAccounts[a],role:R.READONLY_SIGNER}),a++;for(let i=0;i<r;i++)o.push({address:e.staticAccounts[a],role:R.WRITABLE}),a++;for(let i=0;i<t.numReadonlyNonSignerAccounts;i++)o.push({address:e.staticAccounts[a],role:R.READONLY}),a++;return o}function Na(e,t){let r=e.map(i=>i.lookupTableAddress).filter(i=>t[i]===void 0);if(r.length>0)throw new _(Z,{lookupTableAddresses:r});let o=[],a=[];for(let i of e){let s=t[i.lookupTableAddress],c=i.readonlyIndexes,u=i.writableIndexes,d=Math.max(...c,...u);if(d>=s.length)throw new _(q,{highestKnownIndex:s.length-1,highestRequestedIndex:d,lookupTableAddress:i.lookupTableAddress});let I=c.map(S=>({address:s[S],addressIndex:S,lookupTableAddress:i.lookupTableAddress,role:R.READONLY}));o.push(...I);let l=u.map(S=>({address:s[S],addressIndex:S,lookupTableAddress:i.lookupTableAddress,role:R.WRITABLE}));a.push(...l);}return [...a,...o]}function Oa(e,t){let n=t[e.programAddressIndex]?.address;if(!n)throw new _(J,{index:e.programAddressIndex});let r=e.accountIndices?.map(a=>t[a]),{data:o}=e;return Object.freeze({programAddress:n,...r&&r.length?{accounts:Object.freeze(r)}:{},...o&&o.length?{data:o}:{}})}function Da(e,t,n){if(!t||!Te(t))return {blockhash:e,lastValidBlockHeight:n??2n**64n-1n};{let r=t.accounts[0].address;x(r);let o=t.accounts[2].address;return x(o),{nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:o}}}function Pt(e,t){let n=e.staticAccounts[0];if(!n)throw new _(Q);let r=fa(e),o="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?Na(e.addressTableLookups,t?.addressesByLookupTableAddress??{}):[],a=[...r,...o],i=e.instructions.map(u=>Oa(u,a)),s=i[0],c=Da(e.lifetimeToken,s,t?.lastValidBlockHeight);return pt(Aa({version:e.version}),u=>la(n,u),u=>i.reduce((d,I)=>ga(I,d),u),u=>"blockhash"in c?ta(c,u):Ea(c,u))}function Bt(){return U(L([["signatures",O(p(F(),64),{size:g()})],["messageBytes",F()]]),Ca)}function Ca(e){let{messageBytes:t,signatures:n}=e,r=mt([le(),At(C(),2),O(w(),{size:g()})]),[o,a,i]=r.decode(t),s=i.slice(0,a);if(s.length!==n.length)throw new _(ee,{numRequiredSignatures:a,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((u,d)=>{let I=n[d];I.every(l=>l===0)?c[u]=null:c[u]=I;}),{messageBytes:t,signatures:Object.freeze(c)}}async function ge(e,t,n){if(e.length===0)return {};let r=await ft(t,e,n);return gt(r),Nt(r),r.reduce((o,a)=>({...o,[a.address]:a.data.addresses}),{})}var V="ComputeBudget111111111111111111111111111111";var wt="MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";var Se="Secp256r1SigVerify1111111111111111111111111",Ft=new Set([V,core.MULTI_WALLET_PROGRAM_ADDRESS,Se,wt]),G="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z";function zt(){return {[B(G)]:["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL","11111111111111111111111111111111","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb","metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","Sysvar1nstructions1111111111111111111111111","auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg","SysvarS1otHashes111111111111111111111111111","3C6AdJiD9qxMqZTmB53b5HC5Yfq2Bb57XAzYDzu4YDcj","BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY","noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV","cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK","GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy","SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7","35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","HwXnGK3tPkkVY6P439H2p68AxpeuWXd5PcrAxFpbmfbA","compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU","oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto","cpi15BoVPKgEPw5o8wc2T816GE7b378nMXnhH3Xbq4y","bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi","oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg","cpi2yGapXUR3As5SjnHBAVvmApNiLsbeZpF3euWnW6B","bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb","oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ","cpi3mbwMpSX8FAGMZVP85AwxqCaQMfEk9Em1v8QK9Rf","bmt4d3p1a4YQgk9PeZv5s4DBUmbF5NxqYpk9HGjQsd8","oq4ypwvVGzCUMoiKKHWh4S1SgZJ9vCvKpcz6RT6A8dq","cpi4yyPDc4bCgHAnsenunGA8Y77j3XEDyjgfyCKgcoc","bmt5yU97jC88YXTuSukYHa8Z5Bi2ZDUtmzfkDTA2mG2","oq5oh5ZR3yGomuQgFduNDzjtGvVWfDRGLuDVjv9a96P","cpi5ZTjdgYpZ1Xr7B1cMLLUE81oTtJbNNAyKary2nV6","amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx","ACXg8a7VaqecBWrSbdu73W4Pg9gsqXJ3EXAqkHyhvVXg","r18WwUxfG8kQ69bQPAB2jV6zGNKy3GosFGctjQoV4ti","cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m","2cLqZJrYMuCzKdSZBoWxZ3tXoeCMmMyDiuy6UBaKnbmK","5tgzUZaVtfnnSEBgmBDtJj6PdgYCnA1uaEGEUi3y5Njg","2yaSthpW4U4VZvBhwPfGA7HwC9v9Rfq3SNRZvJkKcrNe"].map(B)}}var Ns=3e5,kt=new Map;function Vt(e,t){if(e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return false;return true}async function Gt(e,t,n,r){let o=new Uint8Array(h().encode(e)),a=new Uint8Array(h().encode(n)),i=await crypto.subtle.importKey("raw",a,{name:"Ed25519"},false,["verify"]);if(!await crypto.subtle.verify({name:"Ed25519"},i,o,t))throw new Error(r)}async function Ht(e,t){e&&await Gt(e.signature,t,e.publicKey,`Auth Provider signature verification failed for auth provider id: "${e.publicKey}".`);}async function Wt(e,t){await Gt(e.signature,t,e.publicKey,`Device signature verification failed for device id: "${e.publicKey}".`);}async function Os(e){let t=Date.now(),n=kt.get(e);if(n&&t-n.timestamp<Ns)return {publicKey:n.publicKey};let r=await fetch(`${e}/.well-known/revibase.json`);if(!r.ok)throw new Error(`Failed to fetch well-known for ${e}`);let o=await r.json();if(!o?.publicKey)throw new Error(`Invalid well-known response from ${e}`);return kt.set(e,{publicKey:o.publicKey,timestamp:t}),o}async function Kt(e,t){let{publicKey:n}=await Os(e.clientOrigin),r=await crypto.subtle.importKey("jwk",n,{name:"Ed25519"},true,["verify"]),o=new Uint8Array(h().encode(e.signature));if(!await crypto.subtle.verify({name:"Ed25519"},r,o,new Uint8Array(t)))throw new Error(`Client signature verification failed for client: "${e.clientOrigin}".`)}async function $t(e,t){let{authResponse:n,transactionPayload:r,slotHash:o,slotNumber:a,deviceSignature:i,clientSignature:s,nonce:c}=e,{response:u}=n,d=core.base64URLStringToBuffer(u.clientDataJSON),I=JSON.parse(new TextDecoder().decode(d)),{challenge:l}=await core.createTransactionChallenge(r,s.clientOrigin,i.publicKey,c,o,a),S=new Uint8Array(core.base64URLStringToBuffer(I.challenge));if(!Vt(S,l))throw new Error("Invalid challenge");let jt=core.getSecp256r1MessageHash(n);if(!Vt(jt,t))throw new Error("Invalid message hash")}async function Yt(e){let t=await crypto.subtle.digest("SHA-256",e);return new Uint8Array(t)}function Ms(e,t){if(e.length!==t.length)return false;for(let n=0;n<e.length;n++)if(e[n]!==t[n])return false;return true}async function D(e,t,n){if(!e)return [];let r=e.find(a=>a.instructionIndex===t-1)?.data;if(!r)return [];let{payload:o}=core.getSecp256r1VerifyInstructionDataDecoder().decode(r);return Promise.all(n.map(async a=>{let i=o[a.verifyArgs.signedMessageIndex],s=await Yt(new Uint8Array(i.message));return {signer:new core.Secp256r1Key(new Uint8Array(i.publicKey)).toString(),messageHash:s}}))}function fe(e){return e.map(t=>({signer:core.convertMemberKeyToString(t.memberKey),messageHash:new Uint8Array(t.messageHash)}))}async function m(e,t,n,r){if(!r)throw new Error("Transaction Auth Response is missing");if(n.length!==r.length)throw new Error("Signer and auth response length mismatch");let o=await core.getWalletAddressFromSettings(B(t)),a=await Promise.all(n.map(async({signer:i,messageHash:s},c)=>{let u=r[c],{clientSignature:d,deviceSignature:I,authProviderSignature:l}=u;return await Promise.all([$t(u,s),Ht(l,s),Kt(d,s),Wt(I,s)]),{signer:i,client:d.clientOrigin,device:I.publicKey,authProvider:l?.publicKey,walletAddress:o}}));return {instructions:e,verifiedSigners:a}}async function Ne(e,t){let n=await Yt(t);return Ms(new Uint8Array(e.finalBufferHash),n)}async function M(e,t){let n=e?.data?.data;if(!n||n.__option==="None")throw new Error(t);return core.getSettingsFromIndex(n.value.index)}async function Oe(e,t){let n=core.vaultTransactionMessageDeserialize(t);return (await Ce(n,e)).instructions}function De(e,t){if(!e)throw new Error("Invalid instruction accounts.");let n=3+(t.addressTableLookups?.length??0),r=e.slice(n);return t.instructions.map(o=>({accounts:[...o.accountIndices].map(a=>r[a]),data:o.data,programAddress:r[o.programAddressIndex].address}))}async function Ce(e,t){let r="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?e.addressTableLookups.map(a=>a.lookupTableAddress):[],o=r.length>0?await ys(r,t):{};return Pt(e,{addressesByLookupTableAddress:o})}async function ys(e,t){if(e.some(r=>r.toString()===G)){let r=e.filter(o=>o.toString()!==G);return {...zt(),...await ge(r,t)}}return ge(e,t)}async function me(e,t,n,r){if(!e.data)throw new Error("Invalid instruction data.");let o=core.getChangeConfigCompressedInstructionDataDecoder().decode(e.data),a=await M(o.settingsMutArgs,"Invalid instruction data. Settings not found."),i=await D(t,n,o.secp256r1VerifyArgs);return m([e],a,i,r)}async function pe(e,t,n,r){if(!e.data)throw new Error("Invalid instruction data.");if(!e.accounts)throw new Error("Invalid instruction accounts.");let o=core.getChangeConfigInstructionDataDecoder().decode(e.data),a=await D(t,n,o.secp256r1VerifyArgs);return m([e],e.accounts[0].address.toString(),a,r)}async function he(e,t,n,r,o){if(!t.data)throw new Error("Invalid instruction data.");let i=(e===core.MultiWalletInstruction.NativeTransferIntentCompressed?core.getNativeTransferIntentCompressedInstructionDataDecoder():core.getTokenTransferIntentCompressedInstructionDataDecoder()).decode(t.data),s=await M(i.settingsMutArgs,"Invalid instruction data. Settings not found."),c=await D(n,r,i.secp256r1VerifyArgs);return m([t],s,c,o)}async function Le(e,t,n,r,o){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let i=(e===core.MultiWalletInstruction.NativeTransferIntent?core.getNativeTransferIntentInstructionDataDecoder():core.getTokenTransferIntentInstructionDataDecoder()).decode(t.data),s=await D(n,r,i.secp256r1VerifyArgs);return m([t],t.accounts[0].address.toString(),s,o)}function Me(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getCreateUserAccountsInstructionDataDecoder().decode(e.data);for(let r of n.createUserArgs){if(r.member.toString()!==t.publicKey)throw new Error(`Public Key does not match ${t.publicKey}`);if(r.transactionManagerUrl?.__option==="None")throw new Error("Transaction endpoint cannot be empty");if(r.transactionManagerUrl?.value!==t.url)throw new Error(`Transaction endpoint not equal to ${t.url}`)}return null}function ye(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getEditTransactionManagerUrlInstructionDataDecoder().decode(e.data);if(core.convertMemberKeyToString(n.userMutArgs.data.member)!==t.publicKey)throw new Error(`Public Key does not match ${t.publicKey}`);if(n.transactionManagerUrl!==t.url)throw new Error(`Transaction endpoint not equal to ${t.url}`);return null}async function Ue(e,t,n,r,o,a,i,s){if(!t.accounts)throw new Error("Invalid instruction accounts");if(!t.data)throw new Error("Invalid instruction data");Ws(t,r);let c=n===core.MultiWalletInstruction.TransactionBufferCreate||n===core.MultiWalletInstruction.TransactionBufferCreateCompressed,u=n===core.MultiWalletInstruction.TransactionBufferCreateCompressed||n===core.MultiWalletInstruction.TransactionExecuteSyncCompressed,d;return c?d=await Ks(e,t,u,s):d=await Xs(t,u,i,o),m(d.instructionsToVerify,d.settingsAddress,d.signers,a)}function Ws(e,t){let n=e.accounts?.find(r=>r.address.toString()===t.publicKey);if(n&&n.role!==R.READONLY_SIGNER)throw new Error("Transaction Manager should be readonly signer.")}async function Ks(e,t,n,r){if(!r)throw new Error("Missing transaction message bytes");if(!t.data||!t.accounts)throw new Error("Invalid instruction");let o=new Uint8Array(b().encode(r));return n?$s(e,t,o):Ys(e,t,o)}async function $s(e,t,n){let r=core.getTransactionBufferCreateCompressedInstructionDataDecoder().decode(t.data),o=await M(r.settingsReadonlyArgs,"Settings account is required for compressed transaction buffer create"),a=fe(r.args.expectedSecp256r1Signers);if(!await Ne(r.args,n))throw new Error("Hash mismatch.");let s=await Oe(e,n);return {settingsAddress:o,signers:a,instructionsToVerify:s}}async function Ys(e,t,n){let r=core.getTransactionBufferCreateInstructionDataDecoder().decode(t.data),o=t.accounts[0].address.toString(),a=fe(r.args.expectedSecp256r1Signers);if(!await Ne(r.args,n))throw new Error("Hash mismatch.");let s=await Oe(e,n);return {settingsAddress:o,signers:a,instructionsToVerify:s}}async function Xs(e,t,n,r){if(!e.data||!e.accounts)throw new Error("Invalid instruction");return t?js(e,n,r):Zs(e,n,r)}async function js(e,t,n){let r=core.getTransactionExecuteSyncCompressedInstructionDataDecoder().decode(e.data),o=await M(r.settingsMutArgs,"Settings account is required for compressed transaction execute"),a=await D(t,n,r.secp256r1VerifyArgs),i=De(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:a,instructionsToVerify:i}}async function Zs(e,t,n){let r=core.getTransactionExecuteSyncInstructionDataDecoder().decode(e.data),o=e.accounts[0].address.toString(),a=await D(t,n,r.secp256r1VerifyArgs),i=De(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:a,instructionsToVerify:i}}async function Qs(e,t,n,r,o){let{messageBytes:a}=Bt().decode(b().encode(n)),i=yt().decode(a),{instructions:s}=await Ce(i,e),c=ec(s);return (await Promise.all(s.map((d,I)=>tc(e,d,t,I,r,c,o)))).filter(d=>d!==null)}function ec(e){return e.map((t,n)=>({instruction:t,idx:n})).filter(({instruction:t})=>t.programAddress.toString()===Se).map(({idx:t,instruction:n})=>({instructionIndex:t,data:n.data}))}async function tc(e,t,n,r,o,a,i){let s=t.programAddress.toString();if(!Ft.has(s))throw new Error("Instruction rejected by Transaction Manager.");if(s!==core.MULTI_WALLET_PROGRAM_ADDRESS.toString())return null;if(!t.data)throw new Error("Invalid instruction data.");let c=core.identifyMultiWalletInstruction({data:t.data});return nc(e,t,c,n,r,o,a,i)}async function nc(e,t,n,r,o,a,i,s){switch(n){case core.MultiWalletInstruction.DecompressSettingsAccount:case core.MultiWalletInstruction.TransactionBufferClose:case core.MultiWalletInstruction.TransactionBufferCloseCompressed:return null;case core.MultiWalletInstruction.ChangeConfig:return pe(t,i,o,a);case core.MultiWalletInstruction.ChangeConfigCompressed:return me(t,i,o,a);case core.MultiWalletInstruction.CreateUserAccounts:return Me(t,r);case core.MultiWalletInstruction.EditTransactionManagerUrl:return ye(t,r);case core.MultiWalletInstruction.NativeTransferIntent:case core.MultiWalletInstruction.TokenTransferIntent:return Le(n,t,i,o,a);case core.MultiWalletInstruction.NativeTransferIntentCompressed:case core.MultiWalletInstruction.TokenTransferIntentCompressed:return he(n,t,i,o,a);case core.MultiWalletInstruction.TransactionBufferCreate:case core.MultiWalletInstruction.TransactionBufferCreateCompressed:case core.MultiWalletInstruction.TransactionExecuteSync:case core.MultiWalletInstruction.TransactionExecuteSyncCompressed:return Ue(e,t,n,r,o,a,i,s);default:throw new Error("Instruction rejected by transaction manager.")}}
6
- exports.verifyTransaction=Qs;//# sourceMappingURL=index.cjs.map
5
+ For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[zn]:"No signature verification implementation could be found.",[xn]:"No key generation implementation could be found.",[kn]:"No signing implementation could be found.",[Vn]:"No key export implementation could be found.",[cn]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Po]:"Transaction processing left an account with an outstanding borrowed reference",[So]:"Account in use",[fo]:"Account loaded twice",[No]:"Attempt to debit an account but found no record of a prior credit.",[Vo]:"Transaction loads an address table account that doesn't exist",[mo]:"This transaction has already been processed",[po]:"Blockhash not found",[ho]:"Loader call chain is too deep",[vo]:"Transactions are currently disabled due to cluster maintenance",[Xo]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Oo]:"Insufficient funds for fee",[jo]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Co]:"This account may not be used to pay transaction fees",[Mo]:"Transaction contains an invalid account reference",[Ho]:"Transaction loads an address table account with invalid data",[Wo]:"Transaction address table lookup uses an invalid index",[Go]:"Transaction loads an address table account with an invalid owner",[qo]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[yo]:"This program may not be used for executing instructions",[Ko]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Fo]:"Transaction loads a writable account that cannot be written",[Zo]:"Transaction exceeded max loaded accounts data size cap",[Lo]:"Transaction requires a fee but has no signature present",[Do]:"Attempt to load a program that does not exist",[Qo]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[Jo]:"ResanitizationNeeded",[bo]:"Transaction failed to sanitize accounts offsets correctly",[Uo]:"Transaction did not pass signature verification",[ko]:"Transaction locked too many accounts",[ei]:"Sum of account balances before and after transaction do not match",[go]:"The transaction failed with the error `$errorName`",[wo]:"Transaction version is unsupported",[xo]:"Transaction would exceed account data limit within the block",[Yo]:"Transaction would exceed total account data limit",[zo]:"Transaction would exceed max account limit within the block",[Bo]:"Transaction would exceed max Block Cost Limit",[$o]:"Transaction would exceed max Vote Cost Limit",[et]:"Attempted to sign a transaction with an address that is not a signer for it",[Ao]:"Transaction is missing an address at index: $index.",[tt]:"Transaction has no expected signers therefore it cannot be encoded",[nt]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[j]:"Transaction does not have a blockhash lifetime",[Z]:"Transaction is not a durable nonce transaction",[q]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[J]:"Lookup of address at index $highestRequestedIndex failed for lookup table `$lookupTableAddress`. Highest known index is $highestKnownIndex. The lookup table may have been extended since its contents were retrieved",[ee]:"No fee payer set in CompiledTransaction",[Q]:"Could not find program address at index $index",[lo]:"Failed to estimate the compute unit consumption for this transaction message. This is likely because simulating the transaction failed. Inspect the `cause` property of this error to learn more",[To]:"Transaction failed when it was simulated in order to estimate the compute unit consumption. The compute unit estimate provided is for a transaction that failed when simulated and may not be representative of the compute units this transaction would consume if successful. Inspect the `cause` property of this error to learn more",[Io]:"Transaction is missing a fee payer.",[Qe]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Eo]:"Transaction first instruction is not advance nonce account instruction.",[Ro]:"Transaction with no instructions cannot be durable nonce transaction.",[je]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Ze]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[te]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[Je]:"Transaction is missing signatures for addresses: $addresses.",[qe]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[ne]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[rt]:"The transaction has a durable nonce lifetime (with nonce `$nonce`), but the nonce account address is in a lookup table. The lifetime constraint cannot be constructed without fetching the lookup tables for the transaction."},f="i",g="t";function Bi(e,t={}){let n=Pi[e];if(n.length===0)return "";let r;function o(a){if(r[g]===2){let s=n.slice(r[f]+1,a);i.push(s in t?`${t[s]}`:`$${s}`);}else r[g]===1&&i.push(n.slice(r[f],a));}let i=[];return n.split("").forEach((a,s)=>{if(s===0){r={[f]:0,[g]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[g]){case 0:c={[f]:s,[g]:1};break;case 1:a==="\\"?c={[f]:s,[g]:0}:a==="$"&&(c={[f]:s,[g]:2});break;case 2:a==="\\"?c={[f]:s,[g]:0}:a==="$"?c={[f]:s,[g]:2}:a.match(/\w/)||(c={[f]:s,[g]:1});break}c&&(r!==c&&o(s),r=c);}),o(),i.join("")}function wi(e,t={}){if(process.env.NODE_ENV!=="production")return Bi(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${vi(t)}'`),`${n}\``}}var A=class extends Error{cause=this.cause;context;constructor(...[e,t]){let n,r;t&&Object.entries(Object.getOwnPropertyDescriptors(t)).forEach(([i,a])=>{i==="cause"?r={cause:a.value}:(n===void 0&&(n={}),Object.defineProperty(n,i,a));});let o=wi(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function Fi(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var zi=(e,t)=>Fi(e.length<=t?e:e.slice(0,t),t);function Rt(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function M(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(Rt(t,e));return e.write(t,n,0),n}})}function I(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function N(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function Et(e,t,n=0){if(t.length-n<=0)throw new A(re,{codecDescription:e})}function v(e,t,n,r=0){let o=n.length-r;if(o<t)throw new A(oe,{bytesLength:o,codecDescription:e,expected:t})}function It(e,t,n){if(t<0||t>n)throw new A(ae,{bytesLength:n,codecDescription:e,offset:t})}function lt(e,t){let n=(a,s)=>{let[c,u]=t.read(a,s),d=Number(c);return s=u,(s>0||a.length>d)&&(a=a.slice(s,s+d)),v("addDecoderSizePrefix",d,a),[e.decode(a),s+d]};if(N(t)&&N(e))return I({...e,fixedSize:t.fixedSize+e.fixedSize,read:n});let r=N(t)?t.fixedSize:t.maxSize??null,o=N(e)?e.fixedSize:e.maxSize??null,i=r!==null&&o!==null?r+o:null;return I({...e,...i!==null?{maxSize:i}:{},read:n})}function p(e,t){return I({fixedSize:t,read:(n,r)=>{v("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),N(e)&&(n=zi(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function xi(e,t){return I({...e,read:(n,r)=>{let o=u=>ki(u,n.length),i=t.preOffset?t.preOffset({bytes:n,preOffset:r,wrapBytes:o}):r;It("offsetDecoder",i,n.length);let[a,s]=e.read(n,i),c=t.postOffset?t.postOffset({bytes:n,newPreOffset:i,postOffset:s,preOffset:r,wrapBytes:o}):s;return It("offsetDecoder",c,n.length),[a,c]}})}function ki(e,t){return t===0?0:(e%t+t)%t}function Vi(e,t){if(N(e)){let n=t(e.fixedSize);if(n<0)throw new A(ie,{bytesLength:n,codecDescription:"resizeDecoder"});return I({...e,fixedSize:n})}return e}function Tt(e,t){return xi(Vi(e,n=>n+t),{postOffset:({postOffset:n})=>n+t})}function U(e,t){return I({...e,read:(n,r)=>{let[o,i]=e.read(n,r);return [t(o,n,r),i]}})}function ft(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new A(z,{alphabet:e,base:e.length,value:n})}var Gi=e=>M({getSizeFromValue:t=>{let[n,r]=gt(t,e[0]);if(!r)return t.length;let o=St(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(ft(e,t),t==="")return r;let[o,i]=gt(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=St(i,e),s=[];for(;a>0n;)s.unshift(Number(a%256n)),a/=256n;let c=[...Array(o.length).fill(0),...s];return n.set(c,r),r+c.length}}),Hi=e=>I({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let i=e[0].repeat(o);if(o===r.length)return [i,t.length];let a=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=Wi(a,e);return [i+s,t.length]}});function gt(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function St(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Wi(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var Nt="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",se=()=>Gi(Nt),Dt=()=>Hi(Nt);var Ki="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",y=()=>M({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){ft(Ki,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}});var $i=e=>e.replace(/\u0000/g,"");var Yi=globalThis.TextDecoder;var Ot=()=>{let e;return I({read(t,n){let r=(e||=new Yi).decode(t.slice(n));return [$i(r),t.length]}})};function Xi(e){return !("exists"in e)||"exists"in e&&e.exists}function Ct(e){let t=e.filter(n=>Xi(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new A(X,{addresses:n})}}function ji(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=y().encode(t.data[0]);return Object.freeze({...mt(t),address:e,data:n,exists:true})}function Zi(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...mt(t),address:e,data:n,exists:true})}function mt(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function pt(e,t,n={}){let{abortSignal:r,...o}=n;return (await e.getMultipleAccounts(t,{...o,encoding:"jsonParsed"}).send({abortSignal:r})).value.map((a,s)=>a&&typeof a=="object"&&"parsed"in a.data?Zi(t[s],a):ji(t[s],a))}function ht(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new A(Y,{addresses:n})}}var ce,ue;function qi(){return ce||(ce=se()),ce}function Ji(){return ue||(ue=Dt()),ue}function x(e){if(e.length<32||e.length>44)throw new A($,{actualLength:e.length});let r=qi().encode(e).byteLength;if(r!==32)throw new A(K,{actualLength:r})}function B(e){return x(e),e}function w(){return p(Ji(),32)}function Qi(e){return e?.endian!==1}function Lt(e){return I({fixedSize:e.size,read(t,n=0){Et(e.name,t,n),v(e.name,e.size,t,n);let r=new DataView(ea(t,n,e.size));return [e.get(r,Qi(e.config)),n+e.size]}})}function ea(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var S=()=>I({maxSize:3,read:(e,t)=>{let n=0,r=0;for(;++r;){let o=r-1,i=e[t+o],a=127&i;if(n|=a<<o*7,(i&128)===0)break}return [n,t+r]}});var Mt=(e={})=>Lt({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var C=()=>Lt({get:e=>e.getUint8(0),name:"u8",size:1});function k(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function Ae(e){return N(e)?e.fixedSize:null}function Ie(e){return N(e)?e.fixedSize:e.maxSize??null}function D(e,t={}){let n=t.size??Mt(),r=Ae(e),o=Ut(n,r),i=Ut(n,Ie(e))??void 0;return I({...o!==null?{fixedSize:o}:{maxSize:i},read:(a,s)=>{let c=[];if(typeof n=="object"&&a.slice(s).length===0)return [c,s];if(n==="remainder"){for(;s<a.length;){let[_,R]=e.read(a,s);s=R,c.push(_);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(a,s);s=d;for(let _=0;_<u;_+=1){let[R,T]=e.read(a,s);s=T,c.push(R);}return [c,s]}})}function Ut(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function F(){return I({read:(e,t)=>{let n=e.slice(t);return [n,t+n.length]}})}function yt(e){let t=k(e.map(Ae)),n=k(e.map(Ie))??void 0;return I({...t===null?{maxSize:n}:{fixedSize:t},read:(r,o)=>{let i=[];return e.forEach(a=>{let[s,c]=a.read(r,o);i.push(s),o=c;}),[i,o]}})}function h(e){let t=e.map(([,o])=>o),n=k(t.map(Ae)),r=k(t.map(Ie))??void 0;return I({...n===null?{maxSize:r}:{fixedSize:n},read:(o,i)=>{let a={};return e.forEach(([s,c])=>{let[u,d]=c.read(o,i);i=d,a[s]=u;}),[a,i]}})}function bt(e,...t){return t.reduce((n,r)=>r(n),e)}var E=(e=>(e[e.WRITABLE_SIGNER=3]="WRITABLE_SIGNER",e[e.READONLY_SIGNER=2]="READONLY_SIGNER",e[e.WRITABLE=1]="WRITABLE",e[e.READONLY=0]="READONLY",e))(E||{});function vt(e){return e>=2}function aa(e,t){return "lifetimeConstraint"in t&&t.lifetimeConstraint&&"blockhash"in t.lifetimeConstraint&&t.lifetimeConstraint.blockhash===e.blockhash&&t.lifetimeConstraint.lastValidBlockHeight===e.lastValidBlockHeight?t:Object.freeze({...t,lifetimeConstraint:Object.freeze(e)})}var sa=e=>I({read(t,n){let r=n===0?t:t.slice(n);if(r.length===0)return ["",0];let o=r.findIndex(c=>c!==0);o=o===-1?r.length:o;let i=e[0].repeat(o);if(o===r.length)return [i,t.length];let a=r.slice(o).reduce((c,u)=>c*256n+BigInt(u),0n),s=ca(a,e);return [i+s,t.length]}});function ca(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var ua="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";var da=()=>sa(ua);var Re;function _a(){if(!Re){let e=D(C(),{size:S()});Re=h([["lookupTableAddress",w()],["writableIndexes",e],["readonlyIndexes",e]]);}return Re}var Ee;function le(){return Ee||(Ee=C()),Ee}function Aa(){return h([["numSignerAccounts",le()],["numReadonlySignerAccounts",le()],["numReadonlyNonSignerAccounts",le()]])}var Te;function Ia(){return Te||(Te=U(h([["programAddressIndex",C()],["accountIndices",D(C(),{size:S()})],["data",lt(F(),S())]]),e=>{if(e.accountIndices.length&&e.data.byteLength)return e;let{accountIndices:t,data:n,...r}=e;return {...r,...t.length?{accountIndices:t}:null,...n.byteLength?{data:n}:null}})),Te}var Ra=0,Pt=128;function ge(){return I({maxSize:1,read:(e,t)=>{let n=e[t];if((n&Pt)===0)return ["legacy",t];{let r=n^Pt;if(r>Ra)throw new A(ne,{unsupportedVersion:r});return [r,t+1]}}})}function Ea(){return [["version",ge()],["header",Aa()],["staticAccounts",D(w(),{size:S()})],["lifetimeToken",p(da(),32)],["instructions",D(Ia(),{size:S()})],["addressTableLookups",la()]]}function la(){return D(_a(),{size:S()})}function wt(){return U(h(Ea()),({addressTableLookups:e,...t})=>t.version==="legacy"||!e?.length?t:{...t,addressTableLookups:e})}function Ta(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var Ft="SysvarRecentB1ockHashes11111111111111111111",zt="11111111111111111111111111111111";function Bt(e,t){return {accounts:[{address:e,role:E.WRITABLE},{address:Ft,role:E.READONLY},{address:t,role:E.READONLY_SIGNER}],data:new Uint8Array([4,0,0,0]),programAddress:zt}}function Se(e){return e.programAddress===zt&&e.data!=null&&ga(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===E.WRITABLE&&e.accounts[1].address===Ft&&e.accounts[1].role===E.READONLY&&e.accounts[2].address!=null&&vt(e.accounts[2].role)}function ga(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function xt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&Se(e.instructions[0])}function Sa(e,t,n){return e.accounts[0].address===t&&e.accounts[2].address===n}function fa({nonce:e,nonceAccountAddress:t,nonceAuthorityAddress:n},r){let o,i=r.instructions[0];if(i&&Se(i))if(Sa(i,t,n)){if(xt(r)&&r.lifetimeConstraint.nonce===e)return r;o=[i,...r.instructions.slice(1)];}else o=[Object.freeze(Bt(t,n)),...r.instructions.slice(1)];else o=[Object.freeze(Bt(t,n)),...r.instructions];return Object.freeze({...r,instructions:Object.freeze(o),lifetimeConstraint:Object.freeze({nonce:e})})}function Na(e,t){if("feePayer"in t&&e===t.feePayer?.address&&Da(t.feePayer))return t;let n={...t,feePayer:Object.freeze({address:e})};return Object.freeze(n),n}function Da(e){return !!e&&"address"in e&&typeof e.address=="string"&&Object.keys(e).length===1}function Oa(e,t){return Ca([e],t)}function Ca(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function ma(e){let{header:t}=e,n=t.numSignerAccounts-t.numReadonlySignerAccounts,r=e.staticAccounts.length-t.numSignerAccounts-t.numReadonlyNonSignerAccounts,o=[],i=0;for(let a=0;a<n;a++)o.push({address:e.staticAccounts[i],role:E.WRITABLE_SIGNER}),i++;for(let a=0;a<t.numReadonlySignerAccounts;a++)o.push({address:e.staticAccounts[i],role:E.READONLY_SIGNER}),i++;for(let a=0;a<r;a++)o.push({address:e.staticAccounts[i],role:E.WRITABLE}),i++;for(let a=0;a<t.numReadonlyNonSignerAccounts;a++)o.push({address:e.staticAccounts[i],role:E.READONLY}),i++;return o}function pa(e,t){let r=e.map(a=>a.lookupTableAddress).filter(a=>t[a]===void 0);if(r.length>0)throw new A(q,{lookupTableAddresses:r});let o=[],i=[];for(let a of e){let s=t[a.lookupTableAddress],c=a.readonlyIndexes,u=a.writableIndexes,d=Math.max(...c,...u);if(d>=s.length)throw new A(J,{highestKnownIndex:s.length-1,highestRequestedIndex:d,lookupTableAddress:a.lookupTableAddress});let _=c.map(T=>({address:s[T],addressIndex:T,lookupTableAddress:a.lookupTableAddress,role:E.READONLY}));o.push(..._);let R=u.map(T=>({address:s[T],addressIndex:T,lookupTableAddress:a.lookupTableAddress,role:E.WRITABLE}));i.push(...R);}return [...i,...o]}function ha(e,t){let n=t[e.programAddressIndex]?.address;if(!n)throw new A(Q,{index:e.programAddressIndex});let r=e.accountIndices?.map(i=>t[i]),{data:o}=e;return Object.freeze({programAddress:n,...r&&r.length?{accounts:Object.freeze(r)}:{},...o&&o.length?{data:o}:{}})}function La(e,t,n){if(!t||!Se(t))return {blockhash:e,lastValidBlockHeight:n??2n**64n-1n};{let r=t.accounts[0].address;x(r);let o=t.accounts[2].address;return x(o),{nonce:e,nonceAccountAddress:r,nonceAuthorityAddress:o}}}function kt(e,t){let n=e.staticAccounts[0];if(!n)throw new A(ee);let r=ma(e),o="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?pa(e.addressTableLookups,t?.addressesByLookupTableAddress??{}):[],i=[...r,...o],a=e.instructions.map(u=>ha(u,i)),s=a[0],c=La(e.lifetimeToken,s,t?.lastValidBlockHeight);return bt(Ta({version:e.version}),u=>Na(n,u),u=>a.reduce((d,_)=>Oa(_,d),u),u=>"blockhash"in c?aa(c,u):fa(c,u))}function Vt(){return U(h([["signatures",D(p(F(),64),{size:S()})],["messageBytes",F()]]),Ma)}function Ma(e){let{messageBytes:t,signatures:n}=e,r=yt([ge(),Tt(C(),2),D(w(),{size:S()})]),[o,i,a]=r.decode(t),s=a.slice(0,i);if(s.length!==n.length)throw new A(te,{numRequiredSignatures:i,signaturesLength:n.length,signerAddresses:s});let c={};return s.forEach((u,d)=>{let _=n[d];_.every(R=>R===0)?c[u]=null:c[u]=_;}),{messageBytes:t,signatures:Object.freeze(c)}}async function fe(e,t,n){if(e.length===0)return {};let r=await pt(t,e,n);return Ct(r),ht(r),r.reduce((o,i)=>({...o,[i.address]:i.data.addresses}),{})}var V="ComputeBudget111111111111111111111111111111";var Gt="MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr";var Ne="Secp256r1SigVerify1111111111111111111111111",Ht=new Set([V,core.MULTI_WALLET_PROGRAM_ADDRESS,Ne,Gt]),G="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z";function Wt(){return {[B(G)]:["ATokenGPvbdGVxr1b2hvZbsiqW5xWH25efTNsLJA8knL","11111111111111111111111111111111","TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA","TokenzQdBNbLqP5VEhdkAS6EPFLC1PHnBqCXEpPxuEb","metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s","Sysvar1nstructions1111111111111111111111111","auth9SigNpDKz4sJJ1DfCTuZrZNSAgh9sFD3rboVmgg","SysvarS1otHashes111111111111111111111111111","3C6AdJiD9qxMqZTmB53b5HC5Yfq2Bb57XAzYDzu4YDcj","BGUMAp9Gq7iTEuizy4pqaxsTyUCBK68MDfK752saRPUY","noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV","cmtDvXumGCrqC1Age74AVPhSRVXJMd8PJS91L8KbNCK","GXtd2izAiMJPwMEjfgTRH3d7k9mjn4Jq3JrWFv9gySYy","SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7","35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh","HwXnGK3tPkkVY6P439H2p68AxpeuWXd5PcrAxFpbmfbA","compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq","bmt1LryLZUMmF7ZtqESaw7wifBXLfXHQYoE4GAmrahU","oq1na8gojfdUhsfCpyjNt6h4JaDWtHf1yQj4koBWfto","cpi15BoVPKgEPw5o8wc2T816GE7b378nMXnhH3Xbq4y","bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi","oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg","cpi2yGapXUR3As5SjnHBAVvmApNiLsbeZpF3euWnW6B","bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb","oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ","cpi3mbwMpSX8FAGMZVP85AwxqCaQMfEk9Em1v8QK9Rf","bmt4d3p1a4YQgk9PeZv5s4DBUmbF5NxqYpk9HGjQsd8","oq4ypwvVGzCUMoiKKHWh4S1SgZJ9vCvKpcz6RT6A8dq","cpi4yyPDc4bCgHAnsenunGA8Y77j3XEDyjgfyCKgcoc","bmt5yU97jC88YXTuSukYHa8Z5Bi2ZDUtmzfkDTA2mG2","oq5oh5ZR3yGomuQgFduNDzjtGvVWfDRGLuDVjv9a96P","cpi5ZTjdgYpZ1Xr7B1cMLLUE81oTtJbNNAyKary2nV6","amt2kaJA14v3urZbZvnc5v2np8jqvc4Z8zDep5wbtzx","ACXg8a7VaqecBWrSbdu73W4Pg9gsqXJ3EXAqkHyhvVXg","r18WwUxfG8kQ69bQPAB2jV6zGNKy3GosFGctjQoV4ti","cTokenmWW8bLPjZEBAUgYy3zKxQZW6VKi7bqNFEVv3m","2cLqZJrYMuCzKdSZBoWxZ3tXoeCMmMyDiuy6UBaKnbmK","5tgzUZaVtfnnSEBgmBDtJj6PdgYCnA1uaEGEUi3y5Njg","2yaSthpW4U4VZvBhwPfGA7HwC9v9Rfq3SNRZvJkKcrNe"].map(B)}}var Kt=new Map;async function $t(e,t){let n=Date.now(),r=Kt.get(e);if(r&&n-r.cachedAt<3e5)return r;let o=t?`${t.origin}?origin=${encodeURIComponent(e)}`:`${e}/.well-known/revibase.json`,i=await fetch(o);if(!i.ok)throw new Error(`Failed to fetch .well-known/revibase.json for ${e}`);let a=await i.json();if(!a?.jwk)throw new Error(`Invalid .well-known response from ${e}`);let s={clientJwk:a.jwk,trustedDeviceJwks:a.trustedDevices,cachedAt:n};return Kt.set(e,s),s}function b(e,t){if(e.length!==t.length)return false;let n=0;for(let r=0;r<e.length;r++)n|=e[r]^t[r];return n===0}async function Xt(e,t){if(e)try{let n=await jose.importJWK(core.convertBase64UrlStringToJWK(e.jwk)),r=await jose.compactVerify(e.jws,n);if(!b(r.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Auth provider signature verification failed")}}async function jt(e,t){try{let n=await jose.importJWK(core.convertBase64UrlStringToJWK(e.jwk)),r=await jose.compactVerify(e.jws,n);if(!b(r.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Device signature verification failed")}}async function Zt(e,t,n){let r=await $t(e.clientOrigin,n);try{let o=await jose.importJWK(core.convertBase64UrlStringToJWK(r.clientJwk)),i=await jose.compactVerify(e.jws,o);if(!b(i.payload,t))throw new Error("Invalid Payload")}catch{throw new Error("Client signature verification failed ")}return r}async function qt(e,t){let{authResponse:n,transactionPayload:r,slotHash:o,slotNumber:i,device:a,client:s,nonce:c}=e,{response:u}=n,d=core.base64URLStringToBuffer(u.clientDataJSON),_=JSON.parse(Ot().decode(d)),{challenge:R}=await core.createTransactionChallenge(r,s.clientOrigin,a.jwk,c,o,i),T=new Uint8Array(core.base64URLStringToBuffer(_.challenge));if(!b(T,R))throw new Error("Invalid challenge");let W=core.getSecp256r1MessageHash(n);if(!b(W,t))throw new Error("Invalid message hash")}async function me(e,t){let n=sha2_js.sha256(t);return b(new Uint8Array(e.finalBufferHash),n)}async function O(e,t,n){if(!e)return [];let r=e.find(i=>i.instructionIndex===t-1)?.data;if(!r)return [];let{payload:o}=core.getSecp256r1VerifyInstructionDataDecoder().decode(r);return Promise.all(n.map(async i=>{let a=o[i.verifyArgs.signedMessageIndex],s=sha2_js.sha256(new Uint8Array(a.message));return {signer:new core.Secp256r1Key(new Uint8Array(a.publicKey)).toString(),messageHash:s}}))}function pe(e){return e.map(t=>({signer:core.convertMemberKeyToString(t.memberKey),messageHash:new Uint8Array(t.messageHash)}))}async function m(e,t,n,r,o){if(!r)throw new Error("Transaction Auth Response is missing");if(n.length!==r.length)throw new Error(`Signer count mismatch. Expected ${n.length} auth responses, got ${r.length}`);let i=await core.getWalletAddressFromSettings(B(t)),a=await Promise.all(n.map(async({signer:s,messageHash:c},u)=>{let d=r[u],{client:_,device:R,authProvider:T}=d,[W]=await Promise.all([Zt(_,c,o),qt(d,c),Xt(T,c),jt(R,c)]);return {signer:s,walletAddress:i,client:{origin:_.clientOrigin,...W},device:R.jwk,authProvider:T?.jwk}}));return {instructions:e,verifiedSigners:a}}async function L(e,t){let n=e?.data?.data;if(!n||n.__option==="None")throw new Error(t);return core.getSettingsFromIndex(n.value.index)}async function he(e,t){let n=core.vaultTransactionMessageDeserialize(t);return (await Me(n,e)).instructions}function Le(e,t){if(!e)throw new Error("Invalid instruction accounts.");let n=3+(t.addressTableLookups?.length??0),r=e.slice(n);return t.instructions.map(o=>({accounts:[...o.accountIndices].map(i=>r[i]),data:o.data,programAddress:r[o.programAddressIndex].address}))}async function Me(e,t){let r="addressTableLookups"in e&&e.addressTableLookups!==void 0&&e.addressTableLookups.length>0?e.addressTableLookups.map(i=>i.lookupTableAddress):[],o=r.length>0?await Ps(r,t):{};return kt(e,{addressesByLookupTableAddress:o})}async function Ps(e,t){if(e.some(r=>r.toString()===G)){let r=e.filter(o=>o.toString()!==G);return {...Wt(),...await fe(r,t)}}return fe(e,t)}async function Ue(e,t,n,r,o){if(!e.data)throw new Error("Invalid instruction data.");let i=core.getChangeConfigCompressedInstructionDataDecoder().decode(e.data),a=await L(i.settingsMutArgs,"Invalid instruction data. Settings not found."),s=await O(t,n,i.secp256r1VerifyArgs);return m([e],a,s,r,o)}async function ye(e,t,n,r,o){if(!e.data)throw new Error("Invalid instruction data.");if(!e.accounts)throw new Error("Invalid instruction accounts.");let i=core.getChangeConfigInstructionDataDecoder().decode(e.data),a=e.accounts[0].address.toString(),s=await O(t,n,i.secp256r1VerifyArgs);return m([e],a,s,r,o)}async function be(e,t,n,r,o,i){if(!t.data)throw new Error("Invalid instruction data.");let s=(e===core.MultiWalletInstruction.NativeTransferIntentCompressed?core.getNativeTransferIntentCompressedInstructionDataDecoder():core.getTokenTransferIntentCompressedInstructionDataDecoder()).decode(t.data),c=await L(s.settingsMutArgs,"Invalid instruction data. Settings not found."),u=await O(n,r,s.secp256r1VerifyArgs);return m([t],c,u,o,i)}async function ve(e,t,n,r,o,i){if(!t.data)throw new Error("Invalid instruction data.");if(!t.accounts)throw new Error("Invalid instruction accounts.");let s=(e===core.MultiWalletInstruction.NativeTransferIntent?core.getNativeTransferIntentInstructionDataDecoder():core.getTokenTransferIntentInstructionDataDecoder()).decode(t.data),c=t.accounts[0].address.toString(),u=await O(n,r,s.secp256r1VerifyArgs);return m([t],c,u,o,i)}function Pe(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getCreateUserAccountsInstructionDataDecoder().decode(e.data);for(let r of n.createUserArgs){if(r.member.toString()!==t.publicKey)throw new Error(`Member public key mismatch. Expected: ${t.publicKey}, got: ${r.member.toString()}`);if(r.transactionManagerUrl?.__option==="None")throw new Error("Transaction manager URL cannot be empty when creating user accounts");if(r.transactionManagerUrl?.value!==t.url)throw new Error(`Transaction manager URL mismatch. Expected: ${t.url}, got: ${r.transactionManagerUrl?.value}`)}return null}function Be(e,t){if(!e.data)throw new Error("Invalid instruction data");let n=core.getEditTransactionManagerUrlInstructionDataDecoder().decode(e.data),r=core.convertMemberKeyToString(n.userMutArgs.data.member);if(r!==t.publicKey)throw new Error(`Member public key mismatch. Expected: ${t.publicKey}, got: ${r}`);if(n.transactionManagerUrl!==t.url)throw new Error(`Transaction manager URL mismatch. Expected: ${t.url}, got: ${n.transactionManagerUrl}`);return null}async function we(e,t,n,r,o,i,a,s,c){if(!t.accounts)throw new Error("Invalid instruction accounts");if(!t.data)throw new Error("Invalid instruction data");Xs(t,r);let u=n===core.MultiWalletInstruction.TransactionBufferCreate||n===core.MultiWalletInstruction.TransactionBufferCreateCompressed,d=n===core.MultiWalletInstruction.TransactionBufferCreateCompressed||n===core.MultiWalletInstruction.TransactionExecuteSyncCompressed,_;return u?_=await js(e,t,d,s):_=await Js(t,d,a,o),m(_.instructionsToVerify,_.settingsAddress,_.signers,i,c)}function Xs(e,t){let n=e.accounts?.find(r=>r.address.toString()===t.publicKey);if(n&&n.role!==E.READONLY_SIGNER)throw new Error("Transaction Manager should be readonly signer.")}async function js(e,t,n,r){if(!r)throw new Error("Missing transaction message bytes");if(!t.data||!t.accounts)throw new Error("Invalid instruction");let o=new Uint8Array(y().encode(r));return n?Zs(e,t,o):qs(e,t,o)}async function Zs(e,t,n){let r=core.getTransactionBufferCreateCompressedInstructionDataDecoder().decode(t.data),o=await L(r.settingsReadonlyArgs,"Settings account is required for compressed transaction buffer create"),i=pe(r.args.expectedSecp256r1Signers);if(!await me(r.args,n))throw new Error("Hash mismatch.");let s=await he(e,n);return {settingsAddress:o,signers:i,instructionsToVerify:s}}async function qs(e,t,n){let r=core.getTransactionBufferCreateInstructionDataDecoder().decode(t.data),o=t.accounts[0].address.toString(),i=pe(r.args.expectedSecp256r1Signers);if(!await me(r.args,n))throw new Error("Hash mismatch.");let s=await he(e,n);return {settingsAddress:o,signers:i,instructionsToVerify:s}}async function Js(e,t,n,r){if(!e.data||!e.accounts)throw new Error("Invalid instruction");return t?Qs(e,n,r):ec(e,n,r)}async function Qs(e,t,n){let r=core.getTransactionExecuteSyncCompressedInstructionDataDecoder().decode(e.data),o=await L(r.settingsMutArgs,"Settings account is required for compressed transaction execute"),i=await O(t,n,r.secp256r1VerifyArgs),a=Le(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:i,instructionsToVerify:a}}async function ec(e,t,n){let r=core.getTransactionExecuteSyncInstructionDataDecoder().decode(e.data),o=e.accounts[0].address.toString(),i=await O(t,n,r.secp256r1VerifyArgs),a=Le(e.accounts,r.transactionMessage);return {settingsAddress:o,signers:i,instructionsToVerify:a}}async function rc(e,t,n,r){let{transaction:o,transactionMessageBytes:i,authResponses:a}=n,{messageBytes:s}=Vt().decode(y().encode(o)),c=wt().decode(s),{instructions:u}=await Me(c,e),d=oc(u),_=(await Promise.all(u.map((R,T)=>ic(e,R,t,T,a,d,i,r)))).filter(R=>R!==null);return {transactionMessage:s,verificationResults:_}}function oc(e){return e.map((t,n)=>({instruction:t,instructionIndex:n})).filter(({instruction:t})=>t.programAddress.toString()===Ne).map(({instructionIndex:t,instruction:n})=>({instructionIndex:t,data:n.data}))}async function ic(e,t,n,r,o,i,a,s){let c=t.programAddress.toString();if(!Ht.has(c))throw new Error("Instruction rejected by Transaction Manager.");if(c!==core.MULTI_WALLET_PROGRAM_ADDRESS.toString())return null;if(!t.data)throw new Error("Invalid instruction data.");let u=core.identifyMultiWalletInstruction({data:t.data});return ac(e,t,u,n,r,o,i,a,s)}async function ac(e,t,n,r,o,i,a,s,c){switch(n){case core.MultiWalletInstruction.DecompressSettingsAccount:case core.MultiWalletInstruction.TransactionBufferClose:case core.MultiWalletInstruction.TransactionBufferCloseCompressed:return null;case core.MultiWalletInstruction.ChangeConfig:return ye(t,a,o,i,c);case core.MultiWalletInstruction.ChangeConfigCompressed:return Ue(t,a,o,i,c);case core.MultiWalletInstruction.CreateUserAccounts:return Pe(t,r);case core.MultiWalletInstruction.EditTransactionManagerUrl:return Be(t,r);case core.MultiWalletInstruction.NativeTransferIntent:case core.MultiWalletInstruction.TokenTransferIntent:return ve(n,t,a,o,i,c);case core.MultiWalletInstruction.NativeTransferIntentCompressed:case core.MultiWalletInstruction.TokenTransferIntentCompressed:return be(n,t,a,o,i,c);case core.MultiWalletInstruction.TransactionBufferCreate:case core.MultiWalletInstruction.TransactionBufferCreateCompressed:case core.MultiWalletInstruction.TransactionExecuteSync:case core.MultiWalletInstruction.TransactionExecuteSyncCompressed:return we(e,t,n,r,o,i,a,s,c);default:throw new Error("Instruction rejected by transaction manager.")}}
6
+ exports.verifyTransaction=rc;//# sourceMappingURL=index.cjs.map
7
7
  //# sourceMappingURL=index.cjs.map