@revibase/lite 0.6.0 → 0.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +1 -1
- package/package.json +2 -3
package/dist/index.cjs
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
'use strict';var core=require('@revibase/core'),jose=require('jose'),server=require('@simplewebauthn/server'),jsonCanonicalize=require('json-canonicalize');var vo=1,Po=2,Bo=3,Fo=4,zo=5,ko=6,xo=7,Wo=8,Go=9,Vo=10,Ho=-32700,Ko=-32603,$o=-32602,jo=-32601,Yo=-32600,qo=-32019,Xo=-32018,Zo=-32017,Jo=-32016,Qo=-32015,ei=-32014,ti=-32013,ni=-32012,ri=-32011,oi=-32010,ii=-32009,ai=-32008,si=-32007,ci=-32006,di=-32005,ui=-32004,li=-32003,Ii=-32002,_i=-32001,nt=28e5,rt=2800001,Ai=2800002,Qt=2800003,en=2800004,tn=2800005,nn=2800006,rn=2800007,on=2800008,an=2800009,sn=2800010,cn=2800011,dn=323e4,ot=32300001,it=3230002,un=3230003,at=3230004,Ei=361e4,ln=3610001,In=3610002,_n=3610003,An=3610004,En=3610005,st=3610006,gi=3610007,gn=3611e3,Ri=3704e3,Ti=3704001,fi=3704002,Di=3704003,Si=3704004,pi=4128e3,mi=4128001,Ni=4128002,Ci=4615e3,Rn=4615001,Oi=4615002,hi=4615003,yi=4615004,Mi=4615005,Li=4615006,bi=4615007,Ui=4615008,wi=4615009,vi=4615010,Pi=4615011,Bi=4615012,Fi=4615013,zi=4615014,ki=4615015,xi=4615016,Wi=4615017,Gi=4615018,Vi=4615019,Hi=4615020,Ki=4615021,$i=4615022,ji=4615023,Yi=4615024,qi=4615025,Xi=4615026,Zi=4615027,Ji=4615028,Qi=4615029,ea=4615030,ta=4615031,na=4615032,ra=4615033,oa=4615034,ia=4615035,aa=4615036,sa=4615037,ca=4615038,da=4615039,ua=4615040,la=4615041,Ia=4615042,_a=4615043,Aa=4615044,Ea=4615045,ga=4615046,Ra=4615047,Ta=4615048,fa=4615049,Da=4615050,Sa=4615051,pa=4615052,ma=4615053,Na=4615054,ct=5508e3,Tn=5508001,fn=5508002,Dn=5508003,Sn=5508004,pn=5508005,mn=5508006,Nn=5508007,Cn=5508008,On=5508009,hn=5508010,Ca=5508011,dt=5663e3,Me=5663001,ut=5663002,lt=5663003,It=5663004,yn=5663005,Mn=5663006,Ln=5663007,bn=5663008,_t=5663009,Oa=5663010,ha=5663011,At=5663012,ya=5663013,Ma=5663014,Un=5663015,Et=5663016,wn=5663017,vn=5663018,Pn=5663019,Bn=5663020,gt=5663021,Fn=5663022,zn=705e4,La=7050001,ba=7050002,Ua=7050003,wa=7050004,va=7050005,Pa=7050006,Ba=7050007,Fa=7050008,za=7050009,ka=7050010,xa=7050011,Wa=7050012,Ga=7050013,Va=7050014,Ha=7050015,Ka=7050016,$a=7050017,ja=7050018,Ya=7050019,qa=7050020,Xa=7050021,Za=7050022,Ja=7050023,Qa=7050024,es=7050025,ts=7050026,ns=7050027,rs=7050028,os=7050029,is=7050030,as=7050031,ss=7050032,cs=7050033,ds=7050034,us=7050035,ls=7050036,Is=7618e3,_s=7618001,As=7618002,Es=7618003,Rt=8078e3,Tt=8078001,ft=8078002,kn=8078003,xn=8078004,Wn=8078005,Gn=8078006,Dt=8078007,Vn=8078008,Hn=8078009,Kn=8078010,St=8078011,Ae=8078012,$n=8078013,jn=8078014,Yn=8078015,qn=8078016,pt=8078017,mt=8078018,gs=8078019,Xn=8078020,Zn=8078021,Jn=8078022,Qn=8078023,Rs=81e5,Ts=8100001,fs=8100002,Ds=8100003,Ss=819e4,ps=8190001,ms=8190002,Ns=8190003,Cs=8190004,Os=99e5,hs=9900001,ys=9900002,Ms=9900003,Ls=9900004,bs=9900005,Us=9900006;function er(e){return Array.isArray(e)?"%5B"+e.map(er).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function ws([e,t]){return `${e}=${er(t)}`}function vs(e){let t=Object.entries(e).map(ws).join("&");return Buffer.from(t,"utf8").toString("base64")}var Ps={[dn]:"Account not found at address: $address",[at]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[un]:"Expected decoded account at address: $address",[it]:"Failed to decode account data at address: $address",[ot]:"Accounts not found at addresses: $addresses",[an]:"Unable to find a viable program address bump seed.",[Ai]:"$putativeAddress is not a base58-encoded address.",[nt]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Qt]:"The `CryptoKey` must be an `Ed25519` public key.",[cn]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[on]:"Invalid seeds; point must fall off the Ed25519 curve.",[en]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[nn]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[rn]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[tn]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[sn]:"Program address cannot end with PDA marker.",[rt]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Fo]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[vo]:"The network has progressed past the last block for which this transaction could have been committed.",[Rt]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Jn]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[Xn]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[Wn]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Gn]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[xn]:"Encoder and decoder must either both be fixed-size or variable-size.",[Vn]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[ft]:"Expected a fixed-size codec, got a variable-size one.",[$n]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[kn]:"Expected a variable-size codec, got a fixed-size one.",[gs]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Tt]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[mt]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Hn]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Kn]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[Yn]:"Invalid literal union variant. Expected one of [$variants], got $value.",[Dt]:"Expected [$codecDescription] to have $expected items, got $actual.",[Ae]:"Invalid value $value for base $base with alphabet $alphabet.",[qn]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[St]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[jn]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Zn]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[pt]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Qn]:"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?",[gn]:"No random values implementation could be found.",[wi]:"instruction requires an uninitialized account",[ji]:"instruction tries to borrow reference for an account which is already borrowed",[Yi]:"instruction left account with an outstanding borrowed reference",[Ki]:"program other than the account's owner changed the size of the account data",[Mi]:"account data too small for instruction",[$i]:"instruction expected an executable account",[ga]:"An account does not have enough lamports to be rent-exempt",[Ta]:"Program arithmetic overflowed",[Ea]:"Failed to serialize or deserialize account data: $encodedData",[Na]:"Builtin programs must consume compute units",[na]:"Cross-program invocation call depth too deep",[ca]:"Computational budget exceeded",[Xi]:"custom program error: #$code",[Wi]:"instruction contains duplicate accounts",[qi]:"instruction modifications of multiply-passed account differ",[ea]:"executable accounts must be rent exempt",[Ji]:"instruction changed executable accounts data",[Qi]:"instruction changed the balance of an executable account",[Gi]:"instruction changed executable bit of an account",[zi]:"instruction modified data of an account it does not own",[Fi]:"instruction spent from the balance of an account it does not own",[Rn]:"generic instruction error",[Da]:"Provided owner is not allowed",[_a]:"Account is immutable",[Aa]:"Incorrect authority provided",[bi]:"incorrect program id for instruction",[Li]:"insufficient funds for instruction",[yi]:"invalid account data for instruction",[Ra]:"Invalid account owner",[Oi]:"invalid program argument",[Zi]:"program returned invalid error code",[hi]:"invalid instruction data",[sa]:"Failed to reallocate account data",[aa]:"Provided seeds do not result in a valid address",[Sa]:"Accounts data allocations exceeded the maximum allowed per transaction",[pa]:"Max accounts exceeded",[ma]:"Max instruction trace length exceeded",[ia]:"Length of the seed is too long for address generation",[ra]:"An account required by the instruction is missing",[Ui]:"missing required signature for instruction",[Bi]:"instruction illegally modified the program id of an account",[Hi]:"insufficient account keys for instruction",[da]:"Cross-program invocation with unauthorized signer or writable account",[ua]:"Failed to create program execution environment",[Ia]:"Program failed to compile",[la]:"Program failed to complete",[xi]:"instruction modified data of a read-only account",[ki]:"instruction changed the balance of a read-only account",[oa]:"Cross-program invocation reentrancy not allowed for this instruction",[Vi]:"instruction modified rent epoch of an account",[Pi]:"sum of account balances before and after instruction do not match",[vi]:"instruction requires an initialized account",[Ci]:"",[ta]:"Unsupported program id",[fa]:"Unsupported sysvar",[bs]:"Invalid instruction plan kind: $kind.",[As]:"The provided instruction plan is empty.",[Es]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[Is]:"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).",[Us]:"Invalid transaction plan kind: $kind.",[_s]:"No more instructions to pack; the message packer has completed the instruction plan.",[pi]:"The instruction does not have any accounts.",[mi]:"The instruction does not have any data.",[Ni]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[zo]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[Po]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[ys]:"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",[Ls]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[hs]:"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",[Os]:"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",[Ms]:"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",[Ko]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[$o]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[Yo]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[jo]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Ho]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[ni]:"$__serverMessage",[_i]:"$__serverMessage",[ui]:"$__serverMessage",[ei]:"$__serverMessage",[Zo]:"Epoch rewards period still active at slot $slot",[oi]:"$__serverMessage",[ii]:"$__serverMessage",[qo]:"Failed to query long-term storage; please try again",[Jo]:"Minimum context slot has not been reached",[di]:"Node is unhealthy; behind by $numSlotsBehind slots",[ai]:"No snapshot",[Ii]:"Transaction simulation failed",[Xo]:"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",[si]:"$__serverMessage",[ri]:"Transaction history is not available from this node",[ci]:"$__serverMessage",[ti]:"Transaction signature length mismatch",[li]:"Transaction signature verification failure",[Qo]:"$__serverMessage",[Ri]:"Key pair bytes must be of length 64, got $byteLength.",[Ti]:"Expected private key bytes with length 32. Actual length: $actualLength.",[fi]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[Si]:"The provided private key does not match the provided public key.",[Di]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[ko]:"Lamports value must be in the range [0, 2e64-1]",[xo]:"`$value` cannot be parsed as a `BigInt`",[Vo]:"$message",[Wo]:"`$value` cannot be parsed as a `Number`",[Bo]:"No nonce account could be found at address `$nonceAccountAddress`",[Ss]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[ms]:"WebSocket was closed before payload could be added to the send buffer",[Ns]:"WebSocket connection closed",[Cs]:"WebSocket failed to connect",[ps]:"Failed to obtain a subscription id from the server",[Ds]:"Could not find an API plan for RPC method: `$method`",[Rs]:"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`.",[fs]:"HTTP error ($statusCode): $message",[Ts]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[ct]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Tn]:"The provided value does not implement the `KeyPairSigner` interface",[Dn]:"The provided value does not implement the `MessageModifyingSigner` interface",[Sn]:"The provided value does not implement the `MessagePartialSigner` interface",[fn]:"The provided value does not implement any of the `MessageSigner` interfaces",[mn]:"The provided value does not implement the `TransactionModifyingSigner` interface",[Nn]:"The provided value does not implement the `TransactionPartialSigner` interface",[Cn]:"The provided value does not implement the `TransactionSendingSigner` interface",[pn]:"The provided value does not implement any of the `TransactionSigner` interfaces",[On]:"More than one `TransactionSendingSigner` was identified.",[hn]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[Ca]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[gi]:"Cannot export a non-extractable key.",[ln]:"No digest implementation could be found.",[Ei]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[In]:`This runtime does not support the generation of Ed25519 key pairs.
|
|
1
|
+
'use strict';var core=require('@revibase/core'),jose=require('jose'),server=require('@simplewebauthn/server');var Uo=1,wo=2,vo=3,Po=4,Bo=5,Fo=6,zo=7,ko=8,xo=9,Wo=10,Go=-32700,Vo=-32603,Ho=-32602,Ko=-32601,$o=-32600,jo=-32019,Yo=-32018,qo=-32017,Xo=-32016,Zo=-32015,Jo=-32014,Qo=-32013,ei=-32012,ti=-32011,ni=-32010,ri=-32009,oi=-32008,ii=-32007,ai=-32006,si=-32005,ci=-32004,ui=-32003,di=-32002,li=-32001,tt=28e5,nt=2800001,Ii=2800002,Jt=2800003,Qt=2800004,en=2800005,tn=2800006,nn=2800007,rn=2800008,on=2800009,an=2800010,sn=2800011,cn=323e4,rt=32300001,ot=3230002,un=3230003,it=3230004,_i=361e4,dn=3610001,ln=3610002,In=3610003,_n=3610004,An=3610005,at=3610006,Ai=3610007,En=3611e3,Ei=3704e3,gi=3704001,Ri=3704002,Ti=3704003,fi=3704004,Di=4128e3,Si=4128001,pi=4128002,mi=4615e3,gn=4615001,Ni=4615002,Ci=4615003,Oi=4615004,hi=4615005,yi=4615006,Mi=4615007,Li=4615008,bi=4615009,Ui=4615010,wi=4615011,vi=4615012,Pi=4615013,Bi=4615014,Fi=4615015,zi=4615016,ki=4615017,xi=4615018,Wi=4615019,Gi=4615020,Vi=4615021,Hi=4615022,Ki=4615023,$i=4615024,ji=4615025,Yi=4615026,qi=4615027,Xi=4615028,Zi=4615029,Ji=4615030,Qi=4615031,ea=4615032,ta=4615033,na=4615034,ra=4615035,oa=4615036,ia=4615037,aa=4615038,sa=4615039,ca=4615040,ua=4615041,da=4615042,la=4615043,Ia=4615044,_a=4615045,Aa=4615046,Ea=4615047,ga=4615048,Ra=4615049,Ta=4615050,fa=4615051,Da=4615052,Sa=4615053,pa=4615054,st=5508e3,Rn=5508001,Tn=5508002,fn=5508003,Dn=5508004,Sn=5508005,pn=5508006,mn=5508007,Nn=5508008,Cn=5508009,On=5508010,ma=5508011,ct=5663e3,Me=5663001,ut=5663002,dt=5663003,lt=5663004,hn=5663005,yn=5663006,Mn=5663007,Ln=5663008,It=5663009,Na=5663010,Ca=5663011,_t=5663012,Oa=5663013,ha=5663014,bn=5663015,At=5663016,Un=5663017,wn=5663018,vn=5663019,Pn=5663020,Et=5663021,Bn=5663022,Fn=705e4,ya=7050001,Ma=7050002,La=7050003,ba=7050004,Ua=7050005,wa=7050006,va=7050007,Pa=7050008,Ba=7050009,Fa=7050010,za=7050011,ka=7050012,xa=7050013,Wa=7050014,Ga=7050015,Va=7050016,Ha=7050017,Ka=7050018,$a=7050019,ja=7050020,Ya=7050021,qa=7050022,Xa=7050023,Za=7050024,Ja=7050025,Qa=7050026,es=7050027,ts=7050028,ns=7050029,rs=7050030,os=7050031,is=7050032,as=7050033,ss=7050034,cs=7050035,us=7050036,ds=7618e3,ls=7618001,Is=7618002,_s=7618003,gt=8078e3,Rt=8078001,Tt=8078002,zn=8078003,kn=8078004,xn=8078005,Wn=8078006,ft=8078007,Gn=8078008,Vn=8078009,Hn=8078010,Dt=8078011,Ae=8078012,Kn=8078013,$n=8078014,jn=8078015,Yn=8078016,St=8078017,pt=8078018,As=8078019,qn=8078020,Xn=8078021,Zn=8078022,Jn=8078023,Es=81e5,gs=8100001,Rs=8100002,Ts=8100003,fs=819e4,Ds=8190001,Ss=8190002,ps=8190003,ms=8190004,Ns=99e5,Cs=9900001,Os=9900002,hs=9900003,ys=9900004,Ms=9900005,Ls=9900006;function Qn(e){return Array.isArray(e)?"%5B"+e.map(Qn).join("%2C%20")+"%5D":typeof e=="bigint"?`${e}n`:encodeURIComponent(String(e!=null&&Object.getPrototypeOf(e)===null?{...e}:e))}function bs([e,t]){return `${e}=${Qn(t)}`}function Us(e){let t=Object.entries(e).map(bs).join("&");return Buffer.from(t,"utf8").toString("base64")}var ws={[cn]:"Account not found at address: $address",[it]:"Not all accounts were decoded. Encoded accounts found at addresses: $addresses.",[un]:"Expected decoded account at address: $address",[ot]:"Failed to decode account data at address: $address",[rt]:"Accounts not found at addresses: $addresses",[on]:"Unable to find a viable program address bump seed.",[Ii]:"$putativeAddress is not a base58-encoded address.",[tt]:"Expected base58 encoded address to decode to a byte array of length 32. Actual length: $actualLength.",[Jt]:"The `CryptoKey` must be an `Ed25519` public key.",[sn]:"$putativeOffCurveAddress is not a base58-encoded off-curve address.",[rn]:"Invalid seeds; point must fall off the Ed25519 curve.",[Qt]:"Expected given program derived address to have the following format: [Address, ProgramDerivedAddressBump].",[tn]:"A maximum of $maxSeeds seeds, including the bump seed, may be supplied when creating an address. Received: $actual.",[nn]:"The seed at index $index with length $actual exceeds the maximum length of $maxSeedLength bytes.",[en]:"Expected program derived address bump to be in the range [0, 255], got: $bump.",[an]:"Program address cannot end with PDA marker.",[nt]:"Expected base58-encoded address string of length in the range [32, 44]. Actual length: $actualLength.",[Po]:"Expected base58-encoded blockash string of length in the range [32, 44]. Actual length: $actualLength.",[Uo]:"The network has progressed past the last block for which this transaction could have been committed.",[gt]:"Codec [$codecDescription] cannot decode empty byte arrays.",[Zn]:"Enum codec cannot use lexical values [$stringValues] as discriminators. Either remove all lexical values or set `useValuesAsDiscriminators` to `false`.",[qn]:"Sentinel [$hexSentinel] must not be present in encoded bytes [$hexEncodedBytes].",[xn]:"Encoder and decoder must have the same fixed size, got [$encoderFixedSize] and [$decoderFixedSize].",[Wn]:"Encoder and decoder must have the same max size, got [$encoderMaxSize] and [$decoderMaxSize].",[kn]:"Encoder and decoder must either both be fixed-size or variable-size.",[Gn]:"Enum discriminator out of range. Expected a number in [$formattedValidDiscriminators], got $discriminator.",[Tt]:"Expected a fixed-size codec, got a variable-size one.",[Kn]:"Codec [$codecDescription] expected a positive byte length, got $bytesLength.",[zn]:"Expected a variable-size codec, got a fixed-size one.",[As]:"Codec [$codecDescription] expected zero-value [$hexZeroValue] to have the same size as the provided fixed-size item [$expectedSize bytes].",[Rt]:"Codec [$codecDescription] expected $expected bytes, got $bytesLength.",[pt]:"Expected byte array constant [$hexConstant] to be present in data [$hexData] at offset [$offset].",[Vn]:"Invalid discriminated union variant. Expected one of [$variants], got $value.",[Hn]:"Invalid enum variant. Expected one of [$stringValues] or a number in [$formattedNumericalValues], got $variant.",[jn]:"Invalid literal union variant. Expected one of [$variants], got $value.",[ft]:"Expected [$codecDescription] to have $expected items, got $actual.",[Ae]:"Invalid value $value for base $base with alphabet $alphabet.",[Yn]:"Literal union discriminator out of range. Expected a number between $minRange and $maxRange, got $discriminator.",[Dt]:"Codec [$codecDescription] expected number to be in the range [$min, $max], got $value.",[$n]:"Codec [$codecDescription] expected offset to be in the range [0, $bytesLength], got $offset.",[Xn]:"Expected sentinel [$hexSentinel] to be present in decoded bytes [$hexDecodedBytes].",[St]:"Union variant out of range. Expected an index between $minRange and $maxRange, got $variant.",[Jn]:"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?",[En]:"No random values implementation could be found.",[bi]:"instruction requires an uninitialized account",[Ki]:"instruction tries to borrow reference for an account which is already borrowed",[$i]:"instruction left account with an outstanding borrowed reference",[Vi]:"program other than the account's owner changed the size of the account data",[hi]:"account data too small for instruction",[Hi]:"instruction expected an executable account",[Aa]:"An account does not have enough lamports to be rent-exempt",[ga]:"Program arithmetic overflowed",[_a]:"Failed to serialize or deserialize account data: $encodedData",[pa]:"Builtin programs must consume compute units",[ea]:"Cross-program invocation call depth too deep",[aa]:"Computational budget exceeded",[Yi]:"custom program error: #$code",[ki]:"instruction contains duplicate accounts",[ji]:"instruction modifications of multiply-passed account differ",[Ji]:"executable accounts must be rent exempt",[Xi]:"instruction changed executable accounts data",[Zi]:"instruction changed the balance of an executable account",[xi]:"instruction changed executable bit of an account",[Bi]:"instruction modified data of an account it does not own",[Pi]:"instruction spent from the balance of an account it does not own",[gn]:"generic instruction error",[Ta]:"Provided owner is not allowed",[la]:"Account is immutable",[Ia]:"Incorrect authority provided",[Mi]:"incorrect program id for instruction",[yi]:"insufficient funds for instruction",[Oi]:"invalid account data for instruction",[Ea]:"Invalid account owner",[Ni]:"invalid program argument",[qi]:"program returned invalid error code",[Ci]:"invalid instruction data",[ia]:"Failed to reallocate account data",[oa]:"Provided seeds do not result in a valid address",[fa]:"Accounts data allocations exceeded the maximum allowed per transaction",[Da]:"Max accounts exceeded",[Sa]:"Max instruction trace length exceeded",[ra]:"Length of the seed is too long for address generation",[ta]:"An account required by the instruction is missing",[Li]:"missing required signature for instruction",[vi]:"instruction illegally modified the program id of an account",[Gi]:"insufficient account keys for instruction",[sa]:"Cross-program invocation with unauthorized signer or writable account",[ca]:"Failed to create program execution environment",[da]:"Program failed to compile",[ua]:"Program failed to complete",[zi]:"instruction modified data of a read-only account",[Fi]:"instruction changed the balance of a read-only account",[na]:"Cross-program invocation reentrancy not allowed for this instruction",[Wi]:"instruction modified rent epoch of an account",[wi]:"sum of account balances before and after instruction do not match",[Ui]:"instruction requires an initialized account",[mi]:"",[Qi]:"Unsupported program id",[Ra]:"Unsupported sysvar",[Ms]:"Invalid instruction plan kind: $kind.",[Is]:"The provided instruction plan is empty.",[_s]:"The provided transaction plan failed to execute. See the `transactionPlanResult` attribute and the `cause` error for more details.",[ds]:"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).",[Ls]:"Invalid transaction plan kind: $kind.",[ls]:"No more instructions to pack; the message packer has completed the instruction plan.",[Di]:"The instruction does not have any accounts.",[Si]:"The instruction does not have any data.",[pi]:"Expected instruction to have progress address $expectedProgramAddress, got $actualProgramAddress.",[Bo]:"Expected base58 encoded blockhash to decode to a byte array of length 32. Actual length: $actualLength.",[wo]:"The nonce `$expectedNonceValue` is no longer valid. It has advanced to `$actualNonceValue`",[Os]:"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",[ys]:"Invariant violation: This data publisher does not publish to the channel named `$channelName`. Supported channels include $supportedChannelNames.",[Cs]:"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",[Ns]:"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",[hs]:"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",[Vo]:"JSON-RPC error: Internal JSON-RPC error ($__serverMessage)",[Ho]:"JSON-RPC error: Invalid method parameter(s) ($__serverMessage)",[$o]:"JSON-RPC error: The JSON sent is not a valid `Request` object ($__serverMessage)",[Ko]:"JSON-RPC error: The method does not exist / is not available ($__serverMessage)",[Go]:"JSON-RPC error: An error occurred on the server while parsing the JSON text ($__serverMessage)",[ei]:"$__serverMessage",[li]:"$__serverMessage",[ci]:"$__serverMessage",[Jo]:"$__serverMessage",[qo]:"Epoch rewards period still active at slot $slot",[ni]:"$__serverMessage",[ri]:"$__serverMessage",[jo]:"Failed to query long-term storage; please try again",[Xo]:"Minimum context slot has not been reached",[si]:"Node is unhealthy; behind by $numSlotsBehind slots",[oi]:"No snapshot",[di]:"Transaction simulation failed",[Yo]:"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",[ii]:"$__serverMessage",[ti]:"Transaction history is not available from this node",[ai]:"$__serverMessage",[Qo]:"Transaction signature length mismatch",[ui]:"Transaction signature verification failure",[Zo]:"$__serverMessage",[Ei]:"Key pair bytes must be of length 64, got $byteLength.",[gi]:"Expected private key bytes with length 32. Actual length: $actualLength.",[Ri]:"Expected base58-encoded signature to decode to a byte array of length 64. Actual length: $actualLength.",[fi]:"The provided private key does not match the provided public key.",[Ti]:"Expected base58-encoded signature string of length in the range [64, 88]. Actual length: $actualLength.",[Fo]:"Lamports value must be in the range [0, 2e64-1]",[zo]:"`$value` cannot be parsed as a `BigInt`",[Wo]:"$message",[ko]:"`$value` cannot be parsed as a `Number`",[vo]:"No nonce account could be found at address `$nonceAccountAddress`",[fs]:"The notification name must end in 'Notifications' and the API must supply a subscription plan creator function for the notification '$notificationName'.",[Ss]:"WebSocket was closed before payload could be added to the send buffer",[ps]:"WebSocket connection closed",[ms]:"WebSocket failed to connect",[Ds]:"Failed to obtain a subscription id from the server",[Ts]:"Could not find an API plan for RPC method: `$method`",[Es]:"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`.",[Rs]:"HTTP error ($statusCode): $message",[gs]:"HTTP header(s) forbidden: $headers. Learn more at https://developer.mozilla.org/en-US/docs/Glossary/Forbidden_header_name.",[st]:"Multiple distinct signers were identified for address `$address`. Please ensure that you are using the same signer instance for each address.",[Rn]:"The provided value does not implement the `KeyPairSigner` interface",[fn]:"The provided value does not implement the `MessageModifyingSigner` interface",[Dn]:"The provided value does not implement the `MessagePartialSigner` interface",[Tn]:"The provided value does not implement any of the `MessageSigner` interfaces",[pn]:"The provided value does not implement the `TransactionModifyingSigner` interface",[mn]:"The provided value does not implement the `TransactionPartialSigner` interface",[Nn]:"The provided value does not implement the `TransactionSendingSigner` interface",[Sn]:"The provided value does not implement any of the `TransactionSigner` interfaces",[Cn]:"More than one `TransactionSendingSigner` was identified.",[On]:"No `TransactionSendingSigner` was identified. Please provide a valid `TransactionWithSingleSendingSigner` transaction.",[ma]:"Wallet account signers do not support signing multiple messages/transactions in a single operation",[Ai]:"Cannot export a non-extractable key.",[dn]:"No digest implementation could be found.",[_i]:"Cryptographic operations are only allowed in secure browser contexts. Read more here: https://developer.mozilla.org/en-US/docs/Web/Security/Secure_Contexts.",[ln]:`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.`,[_n]:"No signature verification implementation could be found.",[An]:"No key generation implementation could be found.",[En]:"No signing implementation could be found.",[st]:"No key export implementation could be found.",[Go]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Ka]:"Transaction processing left an account with an outstanding borrowed reference",[La]:"Account in use",[ba]:"Account loaded twice",[Ua]:"Attempt to debit an account but found no record of a prior credit.",[Ja]:"Transaction loads an address table account that doesn't exist",[Ba]:"This transaction has already been processed",[Fa]:"Blockhash not found",[za]:"Loader call chain is too deep",[Ha]:"Transactions are currently disabled due to cluster maintenance",[is]:"Transaction contains a duplicate instruction ($index) that is not allowed",[va]:"Insufficient funds for fee",[as]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[Pa]:"This account may not be used to pay transaction fees",[xa]:"Transaction contains an invalid account reference",[es]:"Transaction loads an address table account with invalid data",[ts]:"Transaction address table lookup uses an invalid index",[Qa]:"Transaction loads an address table account with an invalid owner",[cs]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[Ga]:"This program may not be used for executing instructions",[ns]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[Ya]:"Transaction loads a writable account that cannot be written",[ss]:"Transaction exceeded max loaded accounts data size cap",[ka]:"Transaction requires a fee but has no signature present",[wa]:"Attempt to load a program that does not exist",[us]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[ds]:"ResanitizationNeeded",[Va]:"Transaction failed to sanitize accounts offsets correctly",[Wa]:"Transaction did not pass signature verification",[Za]:"Transaction locked too many accounts",[ls]:"Sum of account balances before and after transaction do not match",[zn]:"The transaction failed with the error `$errorName`",[ja]:"Transaction version is unsupported",[Xa]:"Transaction would exceed account data limit within the block",[os]:"Transaction would exceed total account data limit",[qa]:"Transaction would exceed max account limit within the block",[$a]:"Transaction would exceed max Block Cost Limit",[rs]:"Transaction would exceed max Vote Cost Limit",[Un]:"Attempted to sign a transaction with an address that is not a signer for it",[Oa]:"Transaction is missing an address at index: $index.",[Et]:"Transaction has no expected signers therefore it cannot be encoded",[Bn]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[ut]:"Transaction does not have a blockhash lifetime",[lt]:"Transaction is not a durable nonce transaction",[yn]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[Mn]:"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",[bn]:"No fee payer set in CompiledTransaction",[Ln]:"Could not find program address at index $index",[vn]:"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",[Pn]:"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",[ha]:"Transaction is missing a fee payer.",[At]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[Ma]:"Transaction first instruction is not advance nonce account instruction.",[ya]:"Transaction with no instructions cannot be durable nonce transaction.",[dt]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Me]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[wn]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[_t]:"Transaction is missing signatures for addresses: $addresses.",[It]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[gt]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[Fn]:"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."},x="i",z="t";function Bs(e,t={}){let n=Ps[e];if(n.length===0)return "";let r;function o(a){if(r[z]===2){let s=n.slice(r[x]+1,a);i.push(s in t?`${t[s]}`:`$${s}`);}else r[z]===1&&i.push(n.slice(r[x],a));}let i=[];return n.split("").forEach((a,s)=>{if(s===0){r={[x]:0,[z]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[z]){case 0:c={[x]:s,[z]:1};break;case 1:a==="\\"?c={[x]:s,[z]:0}:a==="$"&&(c={[x]:s,[z]:2});break;case 2:a==="\\"?c={[x]:s,[z]:0}:a==="$"?c={[x]:s,[z]:2}:a.match(/\w/)||(c={[x]:s,[z]:1});break}c&&(r!==c&&o(s),r=c);}),o(),i.join("")}function Fs(e,t={}){if(process.env.NODE_ENV!=="production")return Bs(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${vs(t)}'`),`${n}\``}}var E=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=Fs(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function zs(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var ks=(e,t)=>zs(e.length<=t?e:e.slice(0,t),t);function re(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((o,i)=>o===r[i])}function j(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function D(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(j(t,e));return e.write(t,n,0),n}})}function N(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function L(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function Nt(e){if(!L(e))throw new E(ft)}function xs(e){return !L(e)}function tr(e,t,n=0){if(t.length-n<=0)throw new E(Rt,{codecDescription:e})}function Le(e,t,n,r=0){let o=n.length-r;if(o<t)throw new E(Tt,{bytesLength:o,codecDescription:e,expected:t})}function nr(e,t){let n=(a,s,c)=>{let d=e.encode(a);return c=t.write(d.length,s,c),s.set(d,c),c+d.length};if(L(t)&&L(e))return D({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=L(t)?t.fixedSize:t.maxSize??null,o=L(e)?e.fixedSize:e.maxSize??null,i=r!==null&&o!==null?r+o:null;return D({...e,...i!==null?{maxSize:i}:{},getSizeFromValue:a=>{let s=j(a,e);return j(s,t)+s},write:n})}function Y(e,t){return D({fixedSize:t,write:(n,r,o)=>{let i=e.encode(n),a=i.length>t?i.slice(0,t):i;return r.set(a,o),o+t}})}function Q(e,t){return N({fixedSize:t,read:(n,r)=>{Le("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),L(e)&&(n=ks(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function h(e,t){return D({...xs(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function q(e,t){return N({...e,read:(n,r)=>{let[o,i]=e.read(n,r);return [t(o,n,r),i]}})}function ar(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new E(Ae,{alphabet:e,base:e.length,value:n})}var Ws=e=>D({getSizeFromValue:t=>{let[n,r]=rr(t,e[0]);if(!r)return t.length;let o=or(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(ar(e,t),t==="")return r;let[o,i]=rr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=or(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}}),Gs=e=>N({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,d)=>c*256n+BigInt(d),0n),s=Vs(a,e);return [i+s,t.length]}});function rr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function or(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Vs(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var sr="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ee=()=>Ws(sr),Ee=()=>Gs(sr);var Hs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=()=>D({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){ar(Hs,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),U=()=>N({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});var ir=globalThis.TextEncoder,be=()=>{let e;return D({getSizeFromValue:t=>(e||=new ir).encode(t).length,write:(t,n,r)=>{let o=(e||=new ir).encode(t);return n.set(o,r),r+o.length}})};function cr(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new E(it,{address:e.address})}}function Ks(e){return !("exists"in e)||"exists"in e&&e.exists}function dr(e){let t=e.filter(n=>Ks(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new E(at,{addresses:n})}}function ur(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=b().encode(t.data[0]);return Object.freeze({...lr(t),address:e,data:n,exists:true})}function $s(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...lr(t),address:e,data:n,exists:true})}function lr(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function Ir(e,t,n={}){let{abortSignal:r,...o}=n,i=await e.getAccountInfo(t,{...o,encoding:"base64"}).send({abortSignal:r});return ur(t,i.value)}async function _r(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?$s(t[s],a):ur(t[s],a))}function Ct(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new E(ot,{addresses:n})}}function Ar(){if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.verify!="function")throw new E(st)}var Ot,ht;function yt(){return Ot||(Ot=ee()),Ot}function js(){return ht||(ht=Ee()),ht}function gr(e){if(e.length<32||e.length>44)return false;let t=yt();try{return t.encode(e).byteLength===32}catch{return false}}function Ue(e){if(e.length<32||e.length>44)throw new E(rt,{actualLength:e.length});let r=yt().encode(e).byteLength;if(r!==32)throw new E(nt,{actualLength:r})}function S(e){return Ue(e),e}function W(){return h(Y(yt(),32),e=>S(e))}function G(){return Q(js(),32)}function we(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}async function Rr(e){let t=W().encode(e);return await crypto.subtle.importKey("raw",t,{name:"Ed25519"},true,["verify"])}function Tr(e,t,n,r){if(r<t||r>n)throw new E(St,{codecDescription:e,max:n,min:t,value:r})}function fr(e){return e?.endian!==1}function Mt(e){return D({fixedSize:e.size,write(t,n,r){e.range&&Tr(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,fr(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function ve(e){return N({fixedSize:e.size,read(t,n=0){tr(e.name,t,n),Le(e.name,e.size,t,n);let r=new DataView(Ys(t,n,e.size));return [e.get(r,fr(e.config)),n+e.size]}})}function Ys(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var V=()=>D({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{Tr("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let i=Number(e)>>o*7;if(i===0)break;let a=127&i;r[o]=a,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}});var Dr=(e={})=>ve({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2});var ge=(e={})=>Mt({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Re=(e={})=>ve({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var Te=(e={})=>Mt({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),oe=(e={})=>ve({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var P=()=>Mt({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),H=()=>ve({get:e=>e.getUint8(0),name:"u8",size:1});function qs(e,t,n){if(t!==n)throw new E(Dt,{actual:n,codecDescription:e,expected:t})}function Xs(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function ie(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function fe(e){return L(e)?e.fixedSize:null}function ae(e){return L(e)?e.fixedSize:e.maxSize??null}function K(e,t={}){let n=t.size??ge(),r=Pe(n,fe(e)),o=Pe(n,ae(e))??void 0;return D({...r!==null?{fixedSize:r}:{getSizeFromValue:i=>(typeof n=="object"?j(i.length,n):0)+[...i].reduce((s,c)=>s+j(c,e),0),maxSize:o},write:(i,a,s)=>(typeof n=="number"&&qs("array",n,i.length),typeof n=="object"&&(s=n.write(i.length,a,s)),i.forEach(c=>{s=e.write(c,a,s);}),s)})}function Be(e,t={}){let n=t.size??Re(),r=fe(e),o=Pe(n,r),i=Pe(n,ae(e))??void 0;return N({...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[l,I]=e.read(a,s);s=I,c.push(l);}return [c,s]}let[d,u]=typeof n=="number"?[n,s]:n.read(a,s);s=u;for(let l=0;l<d;l+=1){let[I,_]=e.read(a,s);s=_,c.push(I);}return [c,s]}})}function Pe(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function Sr(e={}){return q(e.size??H(),t=>Number(t)===1)}function De(){return D({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}var Zs=()=>N({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}});function bt(e){return D({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function pr(e){return N({fixedSize:e.length,read:(t,n)=>{let r=Zs();if(!re(t,e,n))throw new E(mt,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function Fe(e){let t=ie(e.map(fe)),n=ie(e.map(ae))??void 0;return N({...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 Ut(e,t){let n=Nr(e),r=(i,a,s)=>{let c=t(i);return Lt(e,c),e[c].write(i,a,s)};if(n!==null)return D({fixedSize:n,write:r});let o=Cr(e);return D({...o!==null?{maxSize:o}:{},getSizeFromValue:i=>{let a=t(i);return Lt(e,a),j(i,e[a])},write:r})}function mr(e,t){let n=Nr(e),r=(i,a)=>{let s=t(i,a);return Lt(e,s),e[s].read(i,a)};if(n!==null)return N({fixedSize:n,read:r});let o=Cr(e);return N({...o!==null?{maxSize:o}:{},read:r})}function Lt(e,t){if(typeof e[t]>"u")throw new E(pt,{maxRange:e.length-1,minRange:0,variant:t})}function Nr(e){if(e.length===0)return 0;if(!L(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>L(r)&&r.fixedSize===t)?t:null}function Cr(e){return Xs(e.map(t=>ae(t)))}function ze(){return N({fixedSize:0,read:(e,t)=>[void 0,t]})}function w(e){let t=e.map(([,o])=>o),n=ie(t.map(fe)),r=ie(t.map(ae))??void 0;return D({...n===null?{getSizeFromValue:o=>e.map(([i,a])=>j(o[i],a)).reduce((i,a)=>i+a,0),maxSize:r}:{fixedSize:n},write:(o,i,a)=>(e.forEach(([s,c])=>{a=c.write(o[s],i,a);}),a)})}function Se(e){let t=e.map(([,o])=>o),n=ie(t.map(fe)),r=ie(t.map(ae))??void 0;return N({...n===null?{maxSize:r}:{fixedSize:n},read:(o,i)=>{let a={};return e.forEach(([s,c])=>{let[d,u]=c.read(o,i);i=u,a[s]=d;}),[a,i]}})}var Js=e=>({__option:"Some",value:e}),Qs=()=>({__option:"None"});function Or(e,t={}){let n=t.prefix===null?q(ze(),()=>false):Sr({size:t.prefix??H()}),r=t.noneValue==="zeroes"?(Nt(e),Q(ze(),e.fixedSize)):t.noneValue?pr(t.noneValue):ze();return mr([q(Fe([n,r]),()=>Qs()),q(Fe([n,e]),([,o])=>Js(o))],(o,i)=>{if(t.prefix===null&&!t.noneValue)return +(i<o.length);if(t.prefix===null&&t.noneValue!=null){let a=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return re(o,a,i)?0:1}return Number(n.read(o,i)[0])})}function pe(e,...t){return t.reduce((n,r)=>r(n),e)}var y=(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))(y||{});var ec=1;function Z(e){return e>=2}function se(e){return (e&ec)!==0}function wt(e,t){return e|t}function hr(e){return gr(e)}function yr(){return G()}function vr(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&hr(e.lifetimeConstraint.blockhash)}function ke(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)})}function rc(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new E(Ae,{alphabet:e,base:e.length,value:n})}var oc=e=>D({getSizeFromValue:t=>{let[n,r]=Mr(t,e[0]);if(!r)return t.length;let o=Lr(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(rc(e,t),t==="")return r;let[o,i]=Mr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=Lr(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}});function Mr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function Lr(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}var ic="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ac=()=>oc(ic);var vt;function sc(){if(!vt){let e=K(P(),{size:V()});vt=w([["lookupTableAddress",W()],["writableIndexes",e],["readonlyIndexes",e]]);}return vt}var Pt;function Bt(){return Pt||(Pt=P()),Pt}function cc(){return w([["numSignerAccounts",Bt()],["numReadonlySignerAccounts",Bt()],["numReadonlyNonSignerAccounts",Bt()]])}var Ft;function dc(){return Ft||(Ft=h(w([["programAddressIndex",P()],["accountIndices",K(P(),{size:V()})],["data",nr(De(),V())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),Ft}var uc=0,lc=128;function Ic(){return D({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new E(It,{actualVersion:e});if(e>uc)throw new E(gt,{unsupportedVersion:e});return t.set([e|lc],n),n+1}})}function br(){return w(Pr())}function Ur(){return h(w([...Pr(),["addressTableLookups",_c()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function Pr(){let e=Ut([bt(new Uint8Array(32)),Y(ac(),32)],t=>t===void 0?0:1);return [["version",Ic()],["header",cc()],["staticAccounts",K(W(),{size:V()})],["lifetimeToken",e],["instructions",K(dc(),{size:V()})]]}function _c(){return K(sc(),{size:V()})}function Br(){return D({getSizeFromValue:e=>e.version==="legacy"?br().getSizeFromValue(e):Ur().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?br().write(e,t,n):Ur().write(e,t,n)})}function wr(e,t,n){e[t]=n(e[t]??{role:y.READONLY});}var p=Symbol("AddressMapTypeProperty");function Ac(e,t){let n={[e]:{[p]:0,role:y.WRITABLE_SIGNER}},r=new Set;for(let o of t){wr(n,o.programAddress,a=>{if(r.add(o.programAddress),p in a){if(se(a.role))switch(a[p]){case 0:throw new E(dt,{programAddress:o.programAddress});default:throw new E(Me,{programAddress:o.programAddress})}if(a[p]===2)return a}return {[p]:2,role:y.READONLY}});let i;if(o.accounts)for(let a of o.accounts)wr(n,a.address,s=>{let{address:c,...d}=a;if(p in s)switch(s[p]){case 0:return s;case 1:{let u=wt(s.role,d.role);if("lookupTableAddress"in d){if(s.lookupTableAddress!==d.lookupTableAddress&&(i||=we())(d.lookupTableAddress,s.lookupTableAddress)<0)return {[p]:1,...d,role:u}}else if(Z(d.role))return {[p]:2,role:u};return s.role!==u?{...s,role:u}:s}case 2:{let u=wt(s.role,d.role);if(r.has(a.address)){if(se(d.role))throw new E(Me,{programAddress:a.address});return s.role!==u?{...s,role:u}:s}else return "lookupTableAddress"in d&&!Z(s.role)?{...d,[p]:1,role:u}:s.role!==u?{...s,role:u}:s}}return "lookupTableAddress"in d?{...d,[p]:1}:{...d,[p]:2}});}return n}function Ec(e){let t;return Object.entries(e).sort(([r,o],[i,a])=>{if(o[p]!==a[p]){if(o[p]===0)return -1;if(a[p]===0)return 1;if(o[p]===2)return -1;if(a[p]===2)return 1}let s=Z(o.role);if(s!==Z(a.role))return s?-1:1;let c=se(o.role);return c!==se(a.role)?c?-1:1:(t||=we(),o[p]===1&&a[p]===1&&o.lookupTableAddress!==a.lookupTableAddress?t(o.lookupTableAddress,a.lookupTableAddress):t(r,i))}).map(([r,o])=>({address:r,...o}))}function gc(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===y.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(we()).map(n=>({lookupTableAddress:n,...t[n]}))}function Rc(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let i=se(o.role);Z(o.role)?(r++,i||n++):i||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function Tc(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function fc(e,t){let n=Tc(t);return e.map(({accounts:r,data:o,programAddress:i})=>({programAddressIndex:n[i],...r?{accountIndices:r.map(({address:a})=>n[a])}:null,...o?{data:o}:null}))}function Dc(e){return "nonce"in e?e.nonce:e.blockhash}function Sc(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function Fr(e){let t=Ac(e.feePayer.address,e.instructions),n=Ec(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:gc(n)}:null,...r?{lifetimeToken:Dc(r)}:null,header:Rc(n),instructions:fc(e.instructions,n),staticAccounts:Sc(n),version:e.version}}function pc(e,t,n){for(let[r,o]of Object.entries(n))for(let i=0;i<o.length;i++)if(e===o[i])return {address:e,addressIndex:i,lookupTableAddress:r,role:t}}function zt(e,t){let n=new Set(e.instructions.map(a=>a.programAddress)),r=new Set(Object.values(t).flatMap(a=>a).filter(a=>!n.has(a))),o=[],i=false;for(let a of e.instructions){if(!a.accounts){o.push(a);continue}let s=[],c=false;for(let d of a.accounts){if("lookupTableAddress"in d||!r.has(d.address)||Z(d.role)){s.push(d);continue}let u=pc(d.address,d.role,t);s.push(Object.freeze(u)),c=true,i=true;}o.push(Object.freeze(c?{...a,accounts:s}:a));}return Object.freeze(i?{...e,instructions:o}:e)}function xe(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var mc="SysvarRecentB1ockHashes11111111111111111111",Nc="11111111111111111111111111111111";function Cc(e){return e.programAddress===Nc&&e.data!=null&&Oc(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===y.WRITABLE&&e.accounts[1].address===mc&&e.accounts[1].role===y.READONLY&&e.accounts[2].address!=null&&Z(e.accounts[2].role)}function Oc(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function kt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&Cc(e.instructions[0])}function We(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function Ge(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}var hc=Object.freeze({name:"Ed25519"});async function zr(e,t,n){return Ar(),await crypto.subtle.verify(hc,e,t,n)}function yc(e){let t=Object.values(e);if(t.length===0)throw new E(Et);return t.map(n=>n||new Uint8Array(64).fill(0))}function Mc(){return h(K(Y(De(),64),{size:V()}),yc)}function Wt(){return w([["signatures",Mc()],["messageBytes",De()]])}function te(e){let t=Fr(e),n=Br().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let a of r)o[a]=null;let i;return vr(e)?i={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:kt(e)&&(i={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...i?{lifetimeConstraint:i}:void 0,messageBytes:n,signatures:Object.freeze(o)})}var xt;function Ve(e){xt||(xt=Ee());let t=Object.values(e.signatures)[0];if(!t)throw new E(At);return xt.decode(t)}function Gt(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new E(_t,{addresses:t})}function ne(e){let t=Wt().encode(e);return U().decode(t)}function Vt(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new E(ct,{address:n.address})}),Object.values(t)}function He(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function me(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function kr(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function Ke(e){return me(e)||He(e)||kr(e)}function Uc(e){return Vt((e.accounts??[]).flatMap(t=>"signer"in t?t.signer:[]))}function wc(e){return Vt([...e.feePayer&&Ke(e.feePayer)?[e.feePayer]:[],...e.instructions.flatMap(Uc)])}function $e(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}async function xr(e,t){let{partialSigners:n,modifyingSigners:r}=vc(Vt(wc(e).filter(Ke)),{identifySendingSigner:false});return await Fc(e,r,n,t)}async function je(e,t){let n=await xr(e,t);return Gt(n),n}function vc(e,t={}){let r=t.identifySendingSigner??true?Pc(e):null,o=e.filter(s=>s!==r&&(He(s)||me(s))),i=Bc(o),a=o.filter(me).filter(s=>!i.includes(s));return Object.freeze({modifyingSigners:i,partialSigners:a,sendingSigner:r})}function Pc(e){let t=e.filter(kr);if(t.length===0)return null;let n=t.filter(r=>!He(r)&&!me(r));return n.length>0?n[0]:t[0]}function Bc(e){let t=e.filter(He);if(t.length===0)return [];let n=t.filter(r=>!me(r));return n.length>0?n:[t[0]]}async function Fc(e,t=[],n=[],r){let o=te(e),i=await t.reduce(async(s,c)=>{let[d]=await c.modifyAndSignTransactions([await s],r);return Object.freeze(d)},Promise.resolve(o));let a=await Promise.all(n.map(async s=>{let[c]=await s.signTransactions([i],r);return c}));return Object.freeze({...i,signatures:Object.freeze(a.reduce((s,c)=>({...s,...c}),i.signatures??{}))})}async function Wr(e,t,n){if(e.length===0)return {};let r=await _r(t,e,n);return dr(r),Ct(r),r.reduce((o,i)=>({...o,[i.address]:i.data.addresses}),{})}var Ye="ComputeBudget111111111111111111111111111111";var Ht=2;function Kt(){return h(w([["discriminator",P()],["units",ge()]]),e=>({...e,discriminator:Ht}))}function ce(e,t){let n=Ye,r={...e};return Object.freeze({data:Kt().encode(r),programAddress:n})}var $t=3;function jt(){return h(w([["discriminator",P()],["microLamports",Te()]]),e=>({...e,discriminator:$t}))}function Ne(e,t){let n=Ye,r={...e};return Object.freeze({data:jt().encode(r),programAddress:n})}async function Yt(e,t,n){let r=await Rr(e);return typeof n=="string"&&(n=new TextEncoder().encode(n)),typeof t=="string"&&(t=ee().encode(t)),zr(r,t,n)}var Gr="https://auth.revibase.com",Vr="revibase.com",Ce="https://api.revibase.com",qe="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z",Hr="https://mainnet.block-engine.jito.wtf/api/v1/bundles",Kr="https://bundles.jito.wtf/api/v1/bundles/tip_floor";var B=class e extends Error{code;constructor(t,n){super(t),this.name="RevibaseError",this.code=n,Object.setPrototypeOf(this,e.prototype);}},Xe=class e extends B{constructor(t="Popup blocked. Please enable popups."){super(t,"POPUP_BLOCKED"),this.name="RevibasePopupBlockedError",Object.setPrototypeOf(this,e.prototype);}},k=class e extends B{constructor(t="Popup was closed by the user"){super(t,"POPUP_CLOSED"),this.name="RevibasePopupClosedError",Object.setPrototypeOf(this,e.prototype);}},Oe=class e extends B{constructor(t="Authentication timed out"){super(t,"TIMEOUT"),this.name="RevibaseTimeoutError",Object.setPrototypeOf(this,e.prototype);}},Ze=class e extends B{constructor(t="An authorization flow is already in progress"){super(t,"FLOW_IN_PROGRESS"),this.name="RevibaseFlowInProgressError",Object.setPrototypeOf(this,e.prototype);}},Je=class e extends B{constructor(t="Aborted"){super(t,"ABORTED"),this.name="RevibaseAbortedError",Object.setPrototypeOf(this,e.prototype);}},$r=class e extends B{constructor(t="Popup is not open. Call startRequest first."){super(t,"POPUP_NOT_OPEN"),this.name="RevibasePopupNotOpenError",Object.setPrototypeOf(this,e.prototype);}},F=class e extends B{constructor(t){super(t,"AUTH_FAILED"),this.name="RevibaseAuthError",Object.setPrototypeOf(this,e.prototype);}},he=class e extends B{constructor(t){super(t,"API_FAILED"),this.name="RevibaseApiError",Object.setPrototypeOf(this,e.prototype);}},Qe=class e extends B{constructor(t="Provider can only be used in a browser environment"){super(t,"ENVIRONMENT"),this.name="RevibaseEnvironmentError",Object.setPrototypeOf(this,e.prototype);}};var jr=180*1e3,qt=2e3,Yr=2e4,qr=async e=>{let t=await fetch("/api/sendJitoBundle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new he(n.error??"Send jito bundle failed");return n},Xr=async()=>{let e=await fetch("/api/estimateJitoTips"),t=await e.json();if(!e.ok)throw new he(t.error??"Estimate jito tips failed");return t},Zr=async e=>{let t=await fetch("/api/clientAuthorization",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new F(n.error??"Authorization failed");return n};function Jr(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,o,i,a,s;if(r)o=t,i=n,a=0,s=0;else {let d=window.screenLeft??window.screenX??0,u=window.screenTop??window.screenY??0,l=window.innerWidth??document.documentElement.clientWidth??window.screen.width,I=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,i=600,s=Math.round(d+(l-o)/2),a=Math.round(u+(I-i)/2);}let c=["popup=yes",`width=${o}`,`height=${i}`,`top=${a}`,`left=${s}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e,"_blank",c)}function Qr(e,t,n){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let r=window.matchMedia("(max-width: 768px)").matches,o=window.scrollY,i={overflow:document.body.style.overflow,position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,right:document.body.style.right,width:document.body.style.width},a=()=>{document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${o}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%";},s=()=>{document.body.style.overflow=i.overflow,document.body.style.position=i.position,document.body.style.top=i.top,document.body.style.left=i.left,document.body.style.right=i.right,document.body.style.width=i.width,window.scrollTo(0,o);};a();let c=document.createElement("div");c.setAttribute("data-provider-frame-root","true"),Object.assign(c.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",contain:"layout style paint"}),document.body.appendChild(c);let d=c.attachShadow({mode:"closed"}),u=document.createElement("div");Object.assign(u.style,{all:"initial",position:"fixed",inset:"0",display:"flex",alignItems:r?"flex-end":"center",justifyContent:"center",background:"rgba(0,0,0,0.45)",zIndex:"2147483647",pointerEvents:"auto",overscrollBehavior:"contain",touchAction:"none",WebkitTapHighlightColor:"transparent",paddingBottom:"env(safe-area-inset-bottom)",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'}),d.appendChild(u);let l=document.createElement("div");Object.assign(l.style,{all:"initial",position:"relative",display:"flex",width:r?"100%":"500px",height:r?"90dvh":"600px",maxWidth:"100vw",maxHeight:"100dvh",borderRadius:r?"16px 16px 0 0":"16px",overflow:"hidden",boxShadow:"0 24px 80px rgba(0,0,0,0.35)",background:"#fff",pointerEvents:"auto"}),u.appendChild(l);let I=document.createElement("iframe");I.src=e,I.title="Authorization",I.setAttribute("tabindex","0"),I.allow=[`publickey-credentials-get ${new URL(e).origin}`].join("; "),I.sandbox=["allow-scripts","allow-same-origin"].join(" "),Object.assign(I.style,{width:"100%",height:"100%",border:"0",background:"#fff",display:"block"}),l.appendChild(I);let _=document.createElement("button");_.type="button",_.setAttribute("aria-label","Close"),_.innerHTML="×",Object.assign(_.style,{all:"initial",position:"absolute",top:r?"12px":"14px",right:r?"12px":"14px",width:"44px",height:"44px",display:"grid",placeItems:"center",borderRadius:"9999px",background:"rgba(255,255,255,0.96)",color:"#111",fontSize:"28px",lineHeight:"1",cursor:"pointer",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:"2",userSelect:"none",WebkitUserSelect:"none"}),l.appendChild(_),requestAnimationFrame(()=>{try{I.focus();}catch{}});let g=T=>{T.key==="Escape"&&m();};document.addEventListener("keydown",g);let f=false,A=()=>{if(!f){f=true;try{t?.removeEventListener("abort",C);}catch{}try{document.removeEventListener("keydown",g);}catch{}try{I.src="about:blank",I.removeAttribute("src");}catch{}try{c.remove();}catch{}s();}},m=()=>{n?.(),A();};_.addEventListener("click",T=>{T.preventDefault(),T.stopPropagation(),m();}),u.addEventListener("click",T=>{T.target===u&&m();});let C=()=>{m();};return t&&(t.aborted?C():t.addEventListener("abort",C,{once:true})),{iframe:I,close:A}}var eo=class{onClientAuthorizationCallback;onSendJitoBundleCallback;onEstimateJitoTipsCallback;providerOrigin;rpId;uiMode;render;popUp=null;frame=null;rendered=null;constructor(t){let{rpId:n,rpcEndpoint:r,providerOrigin:o,ui:i,onClientAuthorizationCallback:a,onSendJitoBundleCallback:s,onEstimateJitoTipsCallback:c}=t;core.initialize({rpcEndpoint:r}),this.onClientAuthorizationCallback=a??Zr,this.onSendJitoBundleCallback=s??qr,this.onEstimateJitoTipsCallback=c??Xr,this.providerOrigin=o??Gr,this.rpId=n??Vr,this.uiMode=i?.mode??"iframe",this.render=i?.render;}async sendRequestToPopupProvider({onConnectedCallback:t,onSuccessCallback:n,signal:r}){if(typeof window>"u")throw new Qe;if(this.popUp||this.frame||this.rendered)throw new Ze;let o=U().decode(crypto.getRandomValues(new Uint8Array(16))),i=window.location.origin,a=`${this.providerOrigin}?clientOrigin=${encodeURIComponent(i)}&rid=${encodeURIComponent(o)}`,s;if(this.render)this.rendered=this.render(a);else if(this.uiMode==="iframe"){let c=new AbortController,d=()=>c.abort(),u=r;u&&(u.aborted?c.abort():(u.addEventListener("abort",d,{once:true}),s=()=>u.removeEventListener("abort",d))),this.frame=Qr(a,c.signal,()=>c.abort()),r=c.signal;}else if(this.popUp=Jr(a),!this.popUp)throw new Xe;return new Promise((c,d)=>{setTimeout(()=>{this.attachTransport({rid:o,clientOrigin:i,onConnectedCallback:t,onSuccessCallback:n,signal:r,resolve:c,reject:d});},0);}).finally(()=>{try{s?.();}catch{}})}attachTransport(t){let{rid:n,clientOrigin:r,onConnectedCallback:o,onSuccessCallback:i,signal:a,reject:s,resolve:c}=t,d=()=>{A(new Je);};a?.addEventListener("abort",d,{once:true});let u=null,l=false,I=null,_=null,g=null,f=()=>{window.removeEventListener("message",C),a?.removeEventListener("abort",d),I&&(clearInterval(I),I=null),_&&(clearTimeout(_),_=null),g&&(clearTimeout(g),g=null);try{u?.close();}catch{}u=null;try{this.popUp&&!this.popUp.closed&&this.popUp.close();}catch{}try{this.frame?.close();}catch{}try{this.rendered?.close();}catch{}this.popUp=null,this.frame=null,this.rendered=null;},A=T=>{l||(l=true,f(),s(T));},m=T=>{l||(l=true,f(),i(T).then(O=>{c(O);}).catch(O=>{s(O);}));};_=setTimeout(()=>{A(new Oe("Popup connection timed out after 20s"));},Yr);let C=T=>{if(l||u||T.origin!==this.providerOrigin)return;let O=T.data;if(!O||O.type!=="popup-connect"||O.rid!==n)return;_&&(clearTimeout(_),_=null);let M=new MessageChannel;u=M.port1,u.start();let J=Date.now();I=setInterval(()=>{if(l){I&&(clearInterval(I),I=null);return}if(this.rendered?.isClosed){if(this.rendered.isClosed()){A(new k("Provider UI was closed"));return}}else if(!this.rendered){if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected){A(new k("Provider iframe was closed"));return}}else if(this.popUp?.closed){A(new k("Popup was closed"));return}}if(!u){A(new k("Message channel lost"));return}if(Date.now()-J>qt*2){A(new k("Lost connection to popup (heartbeat timeout)"));return}try{u.postMessage({type:"ping"});}catch{A(new k("Failed to send heartbeat"));}},qt),u.onmessage=v=>{if(l)return;let $=v.data;switch($.type){case "pong":J=Date.now();break;case "popup-complete":$.payload?m($.payload):A(new F("Invalid completion payload"));break;case "popup-rejected":A(new F("User rejected the operation"));break;case "popup-error":A(new F($.error||"Unknown popup error"));break;case "popup-closed":A(new k("User closed popup"));break;default:console.warn("Unknown message type from popup:",$);}},u.onmessageerror=()=>{A(new F("Message deserialization error"));};try{this.rendered?this.rendered.targetWindow.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]):this.uiMode==="iframe"?this.frame?.iframe.contentWindow?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]):this.popUp?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]);}catch(v){A(new F(`Failed to initialize popup: ${v}`));return}o(n,r).then(v=>{if(l||!u)return;if(this.rendered?.isClosed){if(this.rendered.isClosed())return}else if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected)return}else if(this.popUp?.closed)return;try{u.postMessage({type:"popup-start",payload:v});}catch(wo){A(new F(`Failed to send request to popup: ${wo}`));return}g&&(clearTimeout(g),g=null);let $=Math.max(0,v.request.validTill-Date.now());g=setTimeout(()=>{A(new Oe("Request expired"));},$);}).catch(v=>{A(v);});};window.addEventListener("message",C);}};function to(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
|
|
5
|
+
For a list of runtimes that currently support Ed25519 operations, visit https://github.com/WICG/webcrypto-secure-curves/issues/20.`,[In]:"No signature verification implementation could be found.",[_n]:"No key generation implementation could be found.",[An]:"No signing implementation could be found.",[at]:"No key export implementation could be found.",[xo]:"Timestamp value must be in the range [-(2n ** 63n), (2n ** 63n) - 1]. `$value` given",[Va]:"Transaction processing left an account with an outstanding borrowed reference",[ya]:"Account in use",[Ma]:"Account loaded twice",[La]:"Attempt to debit an account but found no record of a prior credit.",[Xa]:"Transaction loads an address table account that doesn't exist",[va]:"This transaction has already been processed",[Pa]:"Blockhash not found",[Ba]:"Loader call chain is too deep",[Ga]:"Transactions are currently disabled due to cluster maintenance",[rs]:"Transaction contains a duplicate instruction ($index) that is not allowed",[Ua]:"Insufficient funds for fee",[os]:"Transaction results in an account ($accountIndex) with insufficient funds for rent",[wa]:"This account may not be used to pay transaction fees",[za]:"Transaction contains an invalid account reference",[Ja]:"Transaction loads an address table account with invalid data",[Qa]:"Transaction address table lookup uses an invalid index",[Za]:"Transaction loads an address table account with an invalid owner",[as]:"LoadedAccountsDataSizeLimit set for transaction must be greater than 0.",[xa]:"This program may not be used for executing instructions",[es]:"Transaction leaves an account with a lower balance than rent-exempt minimum",[$a]:"Transaction loads a writable account that cannot be written",[is]:"Transaction exceeded max loaded accounts data size cap",[Fa]:"Transaction requires a fee but has no signature present",[ba]:"Attempt to load a program that does not exist",[cs]:"Execution of the program referenced by account at index $accountIndex is temporarily restricted.",[ss]:"ResanitizationNeeded",[Wa]:"Transaction failed to sanitize accounts offsets correctly",[ka]:"Transaction did not pass signature verification",[qa]:"Transaction locked too many accounts",[us]:"Sum of account balances before and after transaction do not match",[Fn]:"The transaction failed with the error `$errorName`",[Ka]:"Transaction version is unsupported",[Ya]:"Transaction would exceed account data limit within the block",[ns]:"Transaction would exceed total account data limit",[ja]:"Transaction would exceed max account limit within the block",[Ha]:"Transaction would exceed max Block Cost Limit",[ts]:"Transaction would exceed max Vote Cost Limit",[bn]:"Attempted to sign a transaction with an address that is not a signer for it",[Na]:"Transaction is missing an address at index: $index.",[At]:"Transaction has no expected signers therefore it cannot be encoded",[Pn]:"Transaction size $transactionSize exceeds limit of $transactionSizeLimit bytes",[ut]:"Transaction does not have a blockhash lifetime",[dt]:"Transaction is not a durable nonce transaction",[hn]:"Contents of these address lookup tables unknown: $lookupTableAddresses",[yn]:"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",[Ln]:"No fee payer set in CompiledTransaction",[Mn]:"Could not find program address at index $index",[wn]:"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",[vn]:"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",[Ca]:"Transaction is missing a fee payer.",[_t]:"Could not determine this transaction's signature. Make sure that the transaction has been signed by its fee payer.",[ha]:"Transaction first instruction is not advance nonce account instruction.",[Oa]:"Transaction with no instructions cannot be durable nonce transaction.",[ct]:"This transaction includes an address (`$programAddress`) which is both invoked and set as the fee payer. Program addresses may not pay fees",[Me]:"This transaction includes an address (`$programAddress`) which is both invoked and marked writable. Program addresses may not be writable",[Un]:"The transaction message expected the transaction to have $numRequiredSignatures signatures, got $signaturesLength.",[It]:"Transaction is missing signatures for addresses: $addresses.",[lt]:"Transaction version must be in the range [0, 127]. `$actualVersion` given",[Et]:"This version of Kit does not support decoding transactions with version $unsupportedVersion. The current max supported version is 0.",[Bn]:"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."},x="i",z="t";function vs(e,t={}){let n=ws[e];if(n.length===0)return "";let r;function o(a){if(r[z]===2){let s=n.slice(r[x]+1,a);i.push(s in t?`${t[s]}`:`$${s}`);}else r[z]===1&&i.push(n.slice(r[x],a));}let i=[];return n.split("").forEach((a,s)=>{if(s===0){r={[x]:0,[z]:n[0]==="\\"?0:n[0]==="$"?2:1};return}let c;switch(r[z]){case 0:c={[x]:s,[z]:1};break;case 1:a==="\\"?c={[x]:s,[z]:0}:a==="$"&&(c={[x]:s,[z]:2});break;case 2:a==="\\"?c={[x]:s,[z]:0}:a==="$"?c={[x]:s,[z]:2}:a.match(/\w/)||(c={[x]:s,[z]:1});break}c&&(r!==c&&o(s),r=c);}),o(),i.join("")}function Ps(e,t={}){if(process.env.NODE_ENV!=="production")return vs(e,t);{let n=`Solana error #${e}; Decode this error by running \`npx @solana/errors decode -- ${e}`;return Object.keys(t).length&&(n+=` '${Us(t)}'`),`${n}\``}}var E=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=Ps(e,n);super(o,r),this.context=n===void 0?{}:n,this.context.__code=e,this.name="SolanaError";}};function Bs(e,t){if(e.length>=t)return e;let n=new Uint8Array(t).fill(0);return n.set(e),n}var Fs=(e,t)=>Bs(e.length<=t?e:e.slice(0,t),t);function re(e,t,n){let r=n===0&&e.length===t.length?e:e.slice(n,n+t.length);return r.length!==t.length?false:t.every((o,i)=>o===r[i])}function j(e,t){return "fixedSize"in t?t.fixedSize:t.getSizeFromValue(e)}function D(e){return Object.freeze({...e,encode:t=>{let n=new Uint8Array(j(t,e));return e.write(t,n,0),n}})}function N(e){return Object.freeze({...e,decode:(t,n=0)=>e.read(t,n)[0]})}function L(e){return "fixedSize"in e&&typeof e.fixedSize=="number"}function mt(e){if(!L(e))throw new E(Tt)}function zs(e){return !L(e)}function er(e,t,n=0){if(t.length-n<=0)throw new E(gt,{codecDescription:e})}function Le(e,t,n,r=0){let o=n.length-r;if(o<t)throw new E(Rt,{bytesLength:o,codecDescription:e,expected:t})}function tr(e,t){let n=(a,s,c)=>{let u=e.encode(a);return c=t.write(u.length,s,c),s.set(u,c),c+u.length};if(L(t)&&L(e))return D({...e,fixedSize:t.fixedSize+e.fixedSize,write:n});let r=L(t)?t.fixedSize:t.maxSize??null,o=L(e)?e.fixedSize:e.maxSize??null,i=r!==null&&o!==null?r+o:null;return D({...e,...i!==null?{maxSize:i}:{},getSizeFromValue:a=>{let s=j(a,e);return j(s,t)+s},write:n})}function Y(e,t){return D({fixedSize:t,write:(n,r,o)=>{let i=e.encode(n),a=i.length>t?i.slice(0,t):i;return r.set(a,o),o+t}})}function Q(e,t){return N({fixedSize:t,read:(n,r)=>{Le("fixCodecSize",t,n,r),(r>0||n.length>t)&&(n=n.slice(r,r+t)),L(e)&&(n=Fs(n,e.fixedSize));let[o]=e.read(n,0);return [o,r+t]}})}function h(e,t){return D({...zs(e)?{...e,getSizeFromValue:n=>e.getSizeFromValue(t(n))}:e,write:(n,r,o)=>e.write(t(n),r,o)})}function q(e,t){return N({...e,read:(n,r)=>{let[o,i]=e.read(n,r);return [t(o,n,r),i]}})}function or(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new E(Ae,{alphabet:e,base:e.length,value:n})}var ks=e=>D({getSizeFromValue:t=>{let[n,r]=nr(t,e[0]);if(!r)return t.length;let o=rr(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(or(e,t),t==="")return r;let[o,i]=nr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=rr(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}}),xs=e=>N({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=Ws(a,e);return [i+s,t.length]}});function nr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function rr(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}function Ws(e,t){let n=BigInt(t.length),r=[];for(;e>0n;)r.unshift(t[Number(e%n)]),e/=n;return r.join("")}var ir="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",ee=()=>ks(ir),Ee=()=>xs(ir);var Gs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",b=()=>D({getSizeFromValue:e=>Buffer.from(e,"base64").length,write(e,t,n){or(Gs,e.replace(/=/g,""));let r=Buffer.from(e,"base64");return t.set(r,n),r.length+n}}),U=()=>N({read:(e,t=0)=>[Buffer.from(e,t).toString("base64"),e.length]});function ar(e,t){try{return "exists"in e&&!e.exists?e:Object.freeze({...e,data:t.decode(e.data)})}catch{throw new E(ot,{address:e.address})}}function Vs(e){return !("exists"in e)||"exists"in e&&e.exists}function sr(e){let t=e.filter(n=>Vs(n)&&n.data instanceof Uint8Array);if(t.length>0){let n=t.map(r=>r.address);throw new E(it,{addresses:n})}}function cr(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=b().encode(t.data[0]);return Object.freeze({...ur(t),address:e,data:n,exists:true})}function Hs(e,t){if(!t)return Object.freeze({address:e,exists:false});let n=t.data.parsed.info;return Object.freeze({...ur(t),address:e,data:n,exists:true})}function ur(e){return Object.freeze({executable:e.executable,lamports:e.lamports,programAddress:e.owner,space:e.space})}async function dr(e,t,n={}){let{abortSignal:r,...o}=n,i=await e.getAccountInfo(t,{...o,encoding:"base64"}).send({abortSignal:r});return cr(t,i.value)}async function lr(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?Hs(t[s],a):cr(t[s],a))}function Nt(e){let t=e.filter(n=>!n.exists);if(t.length>0){let n=t.map(r=>r.address);throw new E(rt,{addresses:n})}}function Ir(){if(typeof globalThis.crypto>"u"||typeof globalThis.crypto.subtle?.verify!="function")throw new E(at)}var Ct,Ot;function ht(){return Ct||(Ct=ee()),Ct}function Ks(){return Ot||(Ot=Ee()),Ot}function Ar(e){if(e.length<32||e.length>44)return false;let t=ht();try{return t.encode(e).byteLength===32}catch{return false}}function be(e){if(e.length<32||e.length>44)throw new E(nt,{actualLength:e.length});let r=ht().encode(e).byteLength;if(r!==32)throw new E(tt,{actualLength:r})}function S(e){return be(e),e}function W(){return h(Y(ht(),32),e=>S(e))}function G(){return Q(Ks(),32)}function Ue(){return new Intl.Collator("en",{caseFirst:"lower",ignorePunctuation:false,localeMatcher:"best fit",numeric:false,sensitivity:"variant",usage:"sort"}).compare}async function Er(e){let t=W().encode(e);return await crypto.subtle.importKey("raw",t,{name:"Ed25519"},true,["verify"])}function gr(e,t,n,r){if(r<t||r>n)throw new E(Dt,{codecDescription:e,max:n,min:t,value:r})}function Rr(e){return e?.endian!==1}function yt(e){return D({fixedSize:e.size,write(t,n,r){e.range&&gr(e.name,e.range[0],e.range[1],t);let o=new ArrayBuffer(e.size);return e.set(new DataView(o),t,Rr(e.config)),n.set(new Uint8Array(o),r),r+e.size}})}function we(e){return N({fixedSize:e.size,read(t,n=0){er(e.name,t,n),Le(e.name,e.size,t,n);let r=new DataView($s(t,n,e.size));return [e.get(r,Rr(e.config)),n+e.size]}})}function $s(e,t,n){let r=e.byteOffset+(t??0),o=n??e.byteLength;return e.buffer.slice(r,r+o)}var V=()=>D({getSizeFromValue:e=>e<=127?1:e<=16383?2:3,maxSize:3,write:(e,t,n)=>{gr("shortU16",0,65535,e);let r=[0];for(let o=0;;o+=1){let i=Number(e)>>o*7;if(i===0)break;let a=127&i;r[o]=a,o>0&&(r[o-1]|=128);}return t.set(r,n),n+r.length}});var Tr=(e={})=>we({config:e,get:(t,n)=>t.getUint16(0,n),name:"u16",size:2});var ge=(e={})=>yt({config:e,name:"u32",range:[0,4294967295],set:(t,n,r)=>t.setUint32(0,Number(n),r),size:4}),Re=(e={})=>we({config:e,get:(t,n)=>t.getUint32(0,n),name:"u32",size:4});var Te=(e={})=>yt({config:e,name:"u64",range:[0n,BigInt("0xffffffffffffffff")],set:(t,n,r)=>t.setBigUint64(0,BigInt(n),r),size:8}),oe=(e={})=>we({config:e,get:(t,n)=>t.getBigUint64(0,n),name:"u64",size:8});var P=()=>yt({name:"u8",range:[0,255],set:(e,t)=>e.setUint8(0,Number(t)),size:1}),H=()=>we({get:e=>e.getUint8(0),name:"u8",size:1});function js(e,t,n){if(t!==n)throw new E(ft,{actual:n,codecDescription:e,expected:t})}function Ys(e){return e.reduce((t,n)=>t===null||n===null?null:Math.max(t,n),0)}function ie(e){return e.reduce((t,n)=>t===null||n===null?null:t+n,0)}function fe(e){return L(e)?e.fixedSize:null}function ae(e){return L(e)?e.fixedSize:e.maxSize??null}function K(e,t={}){let n=t.size??ge(),r=ve(n,fe(e)),o=ve(n,ae(e))??void 0;return D({...r!==null?{fixedSize:r}:{getSizeFromValue:i=>(typeof n=="object"?j(i.length,n):0)+[...i].reduce((s,c)=>s+j(c,e),0),maxSize:o},write:(i,a,s)=>(typeof n=="number"&&js("array",n,i.length),typeof n=="object"&&(s=n.write(i.length,a,s)),i.forEach(c=>{s=e.write(c,a,s);}),s)})}function Pe(e,t={}){let n=t.size??Re(),r=fe(e),o=ve(n,r),i=ve(n,ae(e))??void 0;return N({...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[l,I]=e.read(a,s);s=I,c.push(l);}return [c,s]}let[u,d]=typeof n=="number"?[n,s]:n.read(a,s);s=d;for(let l=0;l<u;l+=1){let[I,_]=e.read(a,s);s=_,c.push(I);}return [c,s]}})}function ve(e,t){return typeof e!="number"?null:e===0?0:t===null?null:t*e}function fr(e={}){return q(e.size??H(),t=>Number(t)===1)}function De(){return D({getSizeFromValue:e=>e.length,write:(e,t,n)=>(t.set(e,n),n+e.length)})}var qs=()=>N({read(e,t){return [e.slice(t).reduce((r,o)=>r+o.toString(16).padStart(2,"0"),""),e.length]}});function Lt(e){return D({fixedSize:e.length,write:(t,n,r)=>(n.set(e,r),r+e.length)})}function Dr(e){return N({fixedSize:e.length,read:(t,n)=>{let r=qs();if(!re(t,e,n))throw new E(pt,{constant:e,data:t,hexConstant:r.decode(e),hexData:r.decode(t),offset:n});return [void 0,n+e.length]}})}function Be(e){let t=ie(e.map(fe)),n=ie(e.map(ae))??void 0;return N({...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 bt(e,t){let n=pr(e),r=(i,a,s)=>{let c=t(i);return Mt(e,c),e[c].write(i,a,s)};if(n!==null)return D({fixedSize:n,write:r});let o=mr(e);return D({...o!==null?{maxSize:o}:{},getSizeFromValue:i=>{let a=t(i);return Mt(e,a),j(i,e[a])},write:r})}function Sr(e,t){let n=pr(e),r=(i,a)=>{let s=t(i,a);return Mt(e,s),e[s].read(i,a)};if(n!==null)return N({fixedSize:n,read:r});let o=mr(e);return N({...o!==null?{maxSize:o}:{},read:r})}function Mt(e,t){if(typeof e[t]>"u")throw new E(St,{maxRange:e.length-1,minRange:0,variant:t})}function pr(e){if(e.length===0)return 0;if(!L(e[0]))return null;let t=e[0].fixedSize;return e.every(r=>L(r)&&r.fixedSize===t)?t:null}function mr(e){return Ys(e.map(t=>ae(t)))}function Fe(){return N({fixedSize:0,read:(e,t)=>[void 0,t]})}function w(e){let t=e.map(([,o])=>o),n=ie(t.map(fe)),r=ie(t.map(ae))??void 0;return D({...n===null?{getSizeFromValue:o=>e.map(([i,a])=>j(o[i],a)).reduce((i,a)=>i+a,0),maxSize:r}:{fixedSize:n},write:(o,i,a)=>(e.forEach(([s,c])=>{a=c.write(o[s],i,a);}),a)})}function Se(e){let t=e.map(([,o])=>o),n=ie(t.map(fe)),r=ie(t.map(ae))??void 0;return N({...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]}})}var Xs=e=>({__option:"Some",value:e}),Zs=()=>({__option:"None"});function Nr(e,t={}){let n=t.prefix===null?q(Fe(),()=>false):fr({size:t.prefix??H()}),r=t.noneValue==="zeroes"?(mt(e),Q(Fe(),e.fixedSize)):t.noneValue?Dr(t.noneValue):Fe();return Sr([q(Be([n,r]),()=>Zs()),q(Be([n,e]),([,o])=>Xs(o))],(o,i)=>{if(t.prefix===null&&!t.noneValue)return +(i<o.length);if(t.prefix===null&&t.noneValue!=null){let a=t.noneValue==="zeroes"?new Uint8Array(r.fixedSize).fill(0):t.noneValue;return re(o,a,i)?0:1}return Number(n.read(o,i)[0])})}function pe(e,...t){return t.reduce((n,r)=>r(n),e)}var y=(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))(y||{});var Js=1;function Z(e){return e>=2}function se(e){return (e&Js)!==0}function Ut(e,t){return e|t}function Cr(e){return Ar(e)}function Or(){return G()}function Ur(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.blockhash=="string"&&typeof e.lifetimeConstraint.lastValidBlockHeight=="bigint"&&Cr(e.lifetimeConstraint.blockhash)}function ze(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)})}function tc(e,t,n=t){if(!t.match(new RegExp(`^[${e}]*$`)))throw new E(Ae,{alphabet:e,base:e.length,value:n})}var nc=e=>D({getSizeFromValue:t=>{let[n,r]=hr(t,e[0]);if(!r)return t.length;let o=yr(r,e);return n.length+Math.ceil(o.toString(16).length/2)},write(t,n,r){if(tc(e,t),t==="")return r;let[o,i]=hr(t,e[0]);if(!i)return n.set(new Uint8Array(o.length).fill(0),r),r+o.length;let a=yr(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}});function hr(e,t){let[n,r]=e.split(new RegExp(`((?!${t}).*)`));return [n,r]}function yr(e,t){let n=BigInt(t.length),r=0n;for(let o of e)r*=n,r+=BigInt(t.indexOf(o));return r}var rc="123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz",oc=()=>nc(rc);var wt;function ic(){if(!wt){let e=K(P(),{size:V()});wt=w([["lookupTableAddress",W()],["writableIndexes",e],["readonlyIndexes",e]]);}return wt}var vt;function Pt(){return vt||(vt=P()),vt}function ac(){return w([["numSignerAccounts",Pt()],["numReadonlySignerAccounts",Pt()],["numReadonlyNonSignerAccounts",Pt()]])}var Bt;function sc(){return Bt||(Bt=h(w([["programAddressIndex",P()],["accountIndices",K(P(),{size:V()})],["data",tr(De(),V())]]),e=>e.accountIndices!==void 0&&e.data!==void 0?e:{...e,accountIndices:e.accountIndices??[],data:e.data??new Uint8Array(0)})),Bt}var cc=0,uc=128;function dc(){return D({getSizeFromValue:e=>e==="legacy"?0:1,maxSize:1,write:(e,t,n)=>{if(e==="legacy")return n;if(e<0||e>127)throw new E(lt,{actualVersion:e});if(e>cc)throw new E(Et,{unsupportedVersion:e});return t.set([e|uc],n),n+1}})}function Mr(){return w(wr())}function Lr(){return h(w([...wr(),["addressTableLookups",lc()]]),e=>e.version==="legacy"?e:{...e,addressTableLookups:e.addressTableLookups??[]})}function wr(){let e=bt([Lt(new Uint8Array(32)),Y(oc(),32)],t=>t===void 0?0:1);return [["version",dc()],["header",ac()],["staticAccounts",K(W(),{size:V()})],["lifetimeToken",e],["instructions",K(sc(),{size:V()})]]}function lc(){return K(ic(),{size:V()})}function vr(){return D({getSizeFromValue:e=>e.version==="legacy"?Mr().getSizeFromValue(e):Lr().getSizeFromValue(e),write:(e,t,n)=>e.version==="legacy"?Mr().write(e,t,n):Lr().write(e,t,n)})}function br(e,t,n){e[t]=n(e[t]??{role:y.READONLY});}var p=Symbol("AddressMapTypeProperty");function Ic(e,t){let n={[e]:{[p]:0,role:y.WRITABLE_SIGNER}},r=new Set;for(let o of t){br(n,o.programAddress,a=>{if(r.add(o.programAddress),p in a){if(se(a.role))switch(a[p]){case 0:throw new E(ct,{programAddress:o.programAddress});default:throw new E(Me,{programAddress:o.programAddress})}if(a[p]===2)return a}return {[p]:2,role:y.READONLY}});let i;if(o.accounts)for(let a of o.accounts)br(n,a.address,s=>{let{address:c,...u}=a;if(p in s)switch(s[p]){case 0:return s;case 1:{let d=Ut(s.role,u.role);if("lookupTableAddress"in u){if(s.lookupTableAddress!==u.lookupTableAddress&&(i||=Ue())(u.lookupTableAddress,s.lookupTableAddress)<0)return {[p]:1,...u,role:d}}else if(Z(u.role))return {[p]:2,role:d};return s.role!==d?{...s,role:d}:s}case 2:{let d=Ut(s.role,u.role);if(r.has(a.address)){if(se(u.role))throw new E(Me,{programAddress:a.address});return s.role!==d?{...s,role:d}:s}else return "lookupTableAddress"in u&&!Z(s.role)?{...u,[p]:1,role:d}:s.role!==d?{...s,role:d}:s}}return "lookupTableAddress"in u?{...u,[p]:1}:{...u,[p]:2}});}return n}function _c(e){let t;return Object.entries(e).sort(([r,o],[i,a])=>{if(o[p]!==a[p]){if(o[p]===0)return -1;if(a[p]===0)return 1;if(o[p]===2)return -1;if(a[p]===2)return 1}let s=Z(o.role);if(s!==Z(a.role))return s?-1:1;let c=se(o.role);return c!==se(a.role)?c?-1:1:(t||=Ue(),o[p]===1&&a[p]===1&&o.lookupTableAddress!==a.lookupTableAddress?t(o.lookupTableAddress,a.lookupTableAddress):t(r,i))}).map(([r,o])=>({address:r,...o}))}function Ac(e){let t={};for(let n of e){if(!("lookupTableAddress"in n))continue;let r=t[n.lookupTableAddress]||={readonlyIndexes:[],writableIndexes:[]};n.role===y.WRITABLE?r.writableIndexes.push(n.addressIndex):r.readonlyIndexes.push(n.addressIndex);}return Object.keys(t).sort(Ue()).map(n=>({lookupTableAddress:n,...t[n]}))}function Ec(e){let t=0,n=0,r=0;for(let o of e){if("lookupTableAddress"in o)break;let i=se(o.role);Z(o.role)?(r++,i||n++):i||t++;}return {numReadonlyNonSignerAccounts:t,numReadonlySignerAccounts:n,numSignerAccounts:r}}function gc(e){let t={};for(let[n,r]of e.entries())t[r.address]=n;return t}function Rc(e,t){let n=gc(t);return e.map(({accounts:r,data:o,programAddress:i})=>({programAddressIndex:n[i],...r?{accountIndices:r.map(({address:a})=>n[a])}:null,...o?{data:o}:null}))}function Tc(e){return "nonce"in e?e.nonce:e.blockhash}function fc(e){let t=e.findIndex(r=>"lookupTableAddress"in r);return (t===-1?e:e.slice(0,t)).map(({address:r})=>r)}function Pr(e){let t=Ic(e.feePayer.address,e.instructions),n=_c(t),r=e.lifetimeConstraint;return {...e.version!=="legacy"?{addressTableLookups:Ac(n)}:null,...r?{lifetimeToken:Tc(r)}:null,header:Ec(n),instructions:Rc(e.instructions,n),staticAccounts:fc(n),version:e.version}}function Dc(e,t,n){for(let[r,o]of Object.entries(n))for(let i=0;i<o.length;i++)if(e===o[i])return {address:e,addressIndex:i,lookupTableAddress:r,role:t}}function Ft(e,t){let n=new Set(e.instructions.map(a=>a.programAddress)),r=new Set(Object.values(t).flatMap(a=>a).filter(a=>!n.has(a))),o=[],i=false;for(let a of e.instructions){if(!a.accounts){o.push(a);continue}let s=[],c=false;for(let u of a.accounts){if("lookupTableAddress"in u||!r.has(u.address)||Z(u.role)){s.push(u);continue}let d=Dc(u.address,u.role,t);s.push(Object.freeze(d)),c=true,i=true;}o.push(Object.freeze(c?{...a,accounts:s}:a));}return Object.freeze(i?{...e,instructions:o}:e)}function ke(e){return Object.freeze({instructions:Object.freeze([]),version:e.version})}var Sc="SysvarRecentB1ockHashes11111111111111111111",pc="11111111111111111111111111111111";function mc(e){return e.programAddress===pc&&e.data!=null&&Nc(e.data)&&e.accounts?.length===3&&e.accounts[0].address!=null&&e.accounts[0].role===y.WRITABLE&&e.accounts[1].address===Sc&&e.accounts[1].role===y.READONLY&&e.accounts[2].address!=null&&Z(e.accounts[2].role)}function Nc(e){return e.byteLength===4&&e[0]===4&&e[1]===0&&e[2]===0&&e[3]===0}function zt(e){return "lifetimeConstraint"in e&&typeof e.lifetimeConstraint.nonce=="string"&&e.instructions[0]!=null&&mc(e.instructions[0])}function xe(e,t){return Object.freeze({...t,instructions:Object.freeze([...t.instructions,...e])})}function We(e,t){return Object.freeze({...t,instructions:Object.freeze([...e,...t.instructions])})}var Cc=Object.freeze({name:"Ed25519"});async function Br(e,t,n){return Ir(),await crypto.subtle.verify(Cc,e,t,n)}function Oc(e){let t=Object.values(e);if(t.length===0)throw new E(At);return t.map(n=>n||new Uint8Array(64).fill(0))}function hc(){return h(K(Y(De(),64),{size:V()}),Oc)}function xt(){return w([["signatures",hc()],["messageBytes",De()]])}function te(e){let t=Pr(e),n=vr().encode(t),r=t.staticAccounts.slice(0,t.header.numSignerAccounts),o={};for(let a of r)o[a]=null;let i;return Ur(e)?i={blockhash:e.lifetimeConstraint.blockhash,lastValidBlockHeight:e.lifetimeConstraint.lastValidBlockHeight}:zt(e)&&(i={nonce:e.lifetimeConstraint.nonce,nonceAccountAddress:e.instructions[0].accounts[0].address}),Object.freeze({...i?{lifetimeConstraint:i}:void 0,messageBytes:n,signatures:Object.freeze(o)})}var kt;function Ge(e){kt||(kt=Ee());let t=Object.values(e.signatures)[0];if(!t)throw new E(_t);return kt.decode(t)}function Wt(e){let t=[];if(Object.entries(e.signatures).forEach(([n,r])=>{r||t.push(n);}),t.length>0)throw new E(It,{addresses:t})}function ne(e){let t=xt().encode(e);return U().decode(t)}function Gt(e){let t={};return e.forEach(n=>{if(!t[n.address])t[n.address]=n;else if(t[n.address]!==n)throw new E(st,{address:n.address})}),Object.values(t)}function Ve(e){return "modifyAndSignTransactions"in e&&typeof e.modifyAndSignTransactions=="function"}function me(e){return "signTransactions"in e&&typeof e.signTransactions=="function"}function Fr(e){return "signAndSendTransactions"in e&&typeof e.signAndSendTransactions=="function"}function He(e){return me(e)||Ve(e)||Fr(e)}function Lc(e){return Gt((e.accounts??[]).flatMap(t=>"signer"in t?t.signer:[]))}function bc(e){return Gt([...e.feePayer&&He(e.feePayer)?[e.feePayer]:[],...e.instructions.flatMap(Lc)])}function Ke(e,t){Object.freeze(e);let n={...t,feePayer:e};return Object.freeze(n),n}async function zr(e,t){let{partialSigners:n,modifyingSigners:r}=Uc(Gt(bc(e).filter(He)),{identifySendingSigner:false});return await Pc(e,r,n,t)}async function $e(e,t){let n=await zr(e,t);return Wt(n),n}function Uc(e,t={}){let r=t.identifySendingSigner??true?wc(e):null,o=e.filter(s=>s!==r&&(Ve(s)||me(s))),i=vc(o),a=o.filter(me).filter(s=>!i.includes(s));return Object.freeze({modifyingSigners:i,partialSigners:a,sendingSigner:r})}function wc(e){let t=e.filter(Fr);if(t.length===0)return null;let n=t.filter(r=>!Ve(r)&&!me(r));return n.length>0?n[0]:t[0]}function vc(e){let t=e.filter(Ve);if(t.length===0)return [];let n=t.filter(r=>!me(r));return n.length>0?n:[t[0]]}async function Pc(e,t=[],n=[],r){let o=te(e),i=await t.reduce(async(s,c)=>{let[u]=await c.modifyAndSignTransactions([await s],r);return Object.freeze(u)},Promise.resolve(o));let a=await Promise.all(n.map(async s=>{let[c]=await s.signTransactions([i],r);return c}));return Object.freeze({...i,signatures:Object.freeze(a.reduce((s,c)=>({...s,...c}),i.signatures??{}))})}async function kr(e,t,n){if(e.length===0)return {};let r=await lr(t,e,n);return sr(r),Nt(r),r.reduce((o,i)=>({...o,[i.address]:i.data.addresses}),{})}var je="ComputeBudget111111111111111111111111111111";var Vt=2;function Ht(){return h(w([["discriminator",P()],["units",ge()]]),e=>({...e,discriminator:Vt}))}function ce(e,t){let n=je,r={...e};return Object.freeze({data:Ht().encode(r),programAddress:n})}var Kt=3;function $t(){return h(w([["discriminator",P()],["microLamports",Te()]]),e=>({...e,discriminator:Kt}))}function Ne(e,t){let n=je,r={...e};return Object.freeze({data:$t().encode(r),programAddress:n})}async function jt(e,t,n){let r=await Er(e);return typeof n=="string"&&(n=new TextEncoder().encode(n)),typeof t=="string"&&(t=ee().encode(t)),Br(r,t,n)}var xr="https://auth.revibase.com",Wr="revibase.com",Ce="https://api.revibase.com",Ye="2c1LgZfCun82niPCgfg2cTMZmAiahraTjY4KNb1BSU4Z",Gr="https://mainnet.block-engine.jito.wtf/api/v1/bundles",Vr="https://bundles.jito.wtf/api/v1/bundles/tip_floor";var B=class e extends Error{code;constructor(t,n){super(t),this.name="RevibaseError",this.code=n,Object.setPrototypeOf(this,e.prototype);}},qe=class e extends B{constructor(t="Popup blocked. Please enable popups."){super(t,"POPUP_BLOCKED"),this.name="RevibasePopupBlockedError",Object.setPrototypeOf(this,e.prototype);}},k=class e extends B{constructor(t="Popup was closed by the user"){super(t,"POPUP_CLOSED"),this.name="RevibasePopupClosedError",Object.setPrototypeOf(this,e.prototype);}},Oe=class e extends B{constructor(t="Authentication timed out"){super(t,"TIMEOUT"),this.name="RevibaseTimeoutError",Object.setPrototypeOf(this,e.prototype);}},Xe=class e extends B{constructor(t="An authorization flow is already in progress"){super(t,"FLOW_IN_PROGRESS"),this.name="RevibaseFlowInProgressError",Object.setPrototypeOf(this,e.prototype);}},Ze=class e extends B{constructor(t="Aborted"){super(t,"ABORTED"),this.name="RevibaseAbortedError",Object.setPrototypeOf(this,e.prototype);}},Hr=class e extends B{constructor(t="Popup is not open. Call startRequest first."){super(t,"POPUP_NOT_OPEN"),this.name="RevibasePopupNotOpenError",Object.setPrototypeOf(this,e.prototype);}},F=class e extends B{constructor(t){super(t,"AUTH_FAILED"),this.name="RevibaseAuthError",Object.setPrototypeOf(this,e.prototype);}},he=class e extends B{constructor(t){super(t,"API_FAILED"),this.name="RevibaseApiError",Object.setPrototypeOf(this,e.prototype);}},Je=class e extends B{constructor(t="Provider can only be used in a browser environment"){super(t,"ENVIRONMENT"),this.name="RevibaseEnvironmentError",Object.setPrototypeOf(this,e.prototype);}};var Kr=180*1e3,Yt=2e3,$r=2e4,jr=async e=>{let t=await fetch("/api/sendJitoBundle",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new he(n.error??"Send jito bundle failed");return n},Yr=async()=>{let e=await fetch("/api/estimateJitoTips"),t=await e.json();if(!e.ok)throw new he(t.error??"Estimate jito tips failed");return t},qr=async e=>{let t=await fetch("/api/clientAuthorization",{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(e)}),n=await t.json();if(!t.ok)throw new F(n.error??"Authorization failed");return n};function Xr(e){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let t=window.innerWidth||window.screen.availWidth,n=window.innerHeight||window.screen.availHeight,r=t<=768,o,i,a,s;if(r)o=t,i=n,a=0,s=0;else {let u=window.screenLeft??window.screenX??0,d=window.screenTop??window.screenY??0,l=window.innerWidth??document.documentElement.clientWidth??window.screen.width,I=window.innerHeight??document.documentElement.clientHeight??window.screen.height;o=500,i=600,s=Math.round(u+(l-o)/2),a=Math.round(d+(I-i)/2);}let c=["popup=yes",`width=${o}`,`height=${i}`,`top=${a}`,`left=${s}`,"toolbar=no","location=no","status=no","menubar=no","scrollbars=yes","resizable=yes"].join(",");return window.open(e,"_blank",c)}function Zr(e,t,n){if(typeof window>"u")throw new Error("Function can only be called in a browser environment");let r=window.matchMedia("(max-width: 768px)").matches,o=window.scrollY,i={overflow:document.body.style.overflow,position:document.body.style.position,top:document.body.style.top,left:document.body.style.left,right:document.body.style.right,width:document.body.style.width},a=()=>{document.body.style.overflow="hidden",document.body.style.position="fixed",document.body.style.top=`-${o}px`,document.body.style.left="0",document.body.style.right="0",document.body.style.width="100%";},s=()=>{document.body.style.overflow=i.overflow,document.body.style.position=i.position,document.body.style.top=i.top,document.body.style.left=i.left,document.body.style.right=i.right,document.body.style.width=i.width,window.scrollTo(0,o);};a();let c=document.createElement("div");c.setAttribute("data-provider-frame-root","true"),Object.assign(c.style,{position:"fixed",inset:"0",zIndex:"2147483647",pointerEvents:"none",contain:"layout style paint"}),document.body.appendChild(c);let u=c.attachShadow({mode:"closed"}),d=document.createElement("div");Object.assign(d.style,{all:"initial",position:"fixed",inset:"0",display:"flex",alignItems:r?"flex-end":"center",justifyContent:"center",background:"rgba(0,0,0,0.45)",zIndex:"2147483647",pointerEvents:"auto",overscrollBehavior:"contain",touchAction:"none",WebkitTapHighlightColor:"transparent",paddingBottom:"env(safe-area-inset-bottom)",fontFamily:'Inter, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif'}),u.appendChild(d);let l=document.createElement("div");Object.assign(l.style,{all:"initial",position:"relative",display:"flex",width:r?"100%":"500px",height:r?"90dvh":"600px",maxWidth:"100vw",maxHeight:"100dvh",borderRadius:r?"16px 16px 0 0":"16px",overflow:"hidden",boxShadow:"0 24px 80px rgba(0,0,0,0.35)",background:"#fff",pointerEvents:"auto"}),d.appendChild(l);let I=document.createElement("iframe");I.src=e,I.title="Authorization",I.setAttribute("tabindex","0"),I.allow=[`publickey-credentials-get ${new URL(e).origin}`].join("; "),I.sandbox=["allow-scripts","allow-same-origin"].join(" "),Object.assign(I.style,{width:"100%",height:"100%",border:"0",background:"#fff",display:"block"}),l.appendChild(I);let _=document.createElement("button");_.type="button",_.setAttribute("aria-label","Close"),_.innerHTML="×",Object.assign(_.style,{all:"initial",position:"absolute",top:r?"12px":"14px",right:r?"12px":"14px",width:"44px",height:"44px",display:"grid",placeItems:"center",borderRadius:"9999px",background:"rgba(255,255,255,0.96)",color:"#111",fontSize:"28px",lineHeight:"1",cursor:"pointer",boxShadow:"0 8px 24px rgba(0,0,0,0.25)",zIndex:"2",userSelect:"none",WebkitUserSelect:"none"}),l.appendChild(_),requestAnimationFrame(()=>{try{I.focus();}catch{}});let g=T=>{T.key==="Escape"&&m();};document.addEventListener("keydown",g);let f=false,A=()=>{if(!f){f=true;try{t?.removeEventListener("abort",C);}catch{}try{document.removeEventListener("keydown",g);}catch{}try{I.src="about:blank",I.removeAttribute("src");}catch{}try{c.remove();}catch{}s();}},m=()=>{n?.(),A();};_.addEventListener("click",T=>{T.preventDefault(),T.stopPropagation(),m();}),d.addEventListener("click",T=>{T.target===d&&m();});let C=()=>{m();};return t&&(t.aborted?C():t.addEventListener("abort",C,{once:true})),{iframe:I,close:A}}var Jr=class{onClientAuthorizationCallback;onSendJitoBundleCallback;onEstimateJitoTipsCallback;providerOrigin;rpId;uiMode;render;popUp=null;frame=null;rendered=null;constructor(t){let{rpId:n,rpcEndpoint:r,providerOrigin:o,ui:i,onClientAuthorizationCallback:a,onSendJitoBundleCallback:s,onEstimateJitoTipsCallback:c}=t;core.initialize({rpcEndpoint:r}),this.onClientAuthorizationCallback=a??qr,this.onSendJitoBundleCallback=s??jr,this.onEstimateJitoTipsCallback=c??Yr,this.providerOrigin=o??xr,this.rpId=n??Wr,this.uiMode=i?.mode??"iframe",this.render=i?.render;}async sendRequestToPopupProvider({onConnectedCallback:t,onSuccessCallback:n,signal:r}){if(typeof window>"u")throw new Je;if(this.popUp||this.frame||this.rendered)throw new Xe;let o=U().decode(crypto.getRandomValues(new Uint8Array(16))),i=window.location.origin,a=`${this.providerOrigin}?clientOrigin=${encodeURIComponent(i)}&rid=${encodeURIComponent(o)}`,s;if(this.render)this.rendered=this.render(a);else if(this.uiMode==="iframe"){let c=new AbortController,u=()=>c.abort(),d=r;d&&(d.aborted?c.abort():(d.addEventListener("abort",u,{once:true}),s=()=>d.removeEventListener("abort",u))),this.frame=Zr(a,c.signal,()=>c.abort()),r=c.signal;}else if(this.popUp=Xr(a),!this.popUp)throw new qe;return new Promise((c,u)=>{setTimeout(()=>{this.attachTransport({rid:o,clientOrigin:i,onConnectedCallback:t,onSuccessCallback:n,signal:r,resolve:c,reject:u});},0);}).finally(()=>{try{s?.();}catch{}})}attachTransport(t){let{rid:n,clientOrigin:r,onConnectedCallback:o,onSuccessCallback:i,signal:a,reject:s,resolve:c}=t,u=()=>{A(new Ze);};a?.addEventListener("abort",u,{once:true});let d=null,l=false,I=null,_=null,g=null,f=()=>{window.removeEventListener("message",C),a?.removeEventListener("abort",u),I&&(clearInterval(I),I=null),_&&(clearTimeout(_),_=null),g&&(clearTimeout(g),g=null);try{d?.close();}catch{}d=null;try{this.popUp&&!this.popUp.closed&&this.popUp.close();}catch{}try{this.frame?.close();}catch{}try{this.rendered?.close();}catch{}this.popUp=null,this.frame=null,this.rendered=null;},A=T=>{l||(l=true,f(),s(T));},m=T=>{l||(l=true,f(),i(T).then(O=>{c(O);}).catch(O=>{s(O);}));};_=setTimeout(()=>{A(new Oe("Popup connection timed out after 20s"));},$r);let C=T=>{if(l||d||T.origin!==this.providerOrigin)return;let O=T.data;if(!O||O.type!=="popup-connect"||O.rid!==n)return;_&&(clearTimeout(_),_=null);let M=new MessageChannel;d=M.port1,d.start();let J=Date.now();I=setInterval(()=>{if(l){I&&(clearInterval(I),I=null);return}if(this.rendered?.isClosed){if(this.rendered.isClosed()){A(new k("Provider UI was closed"));return}}else if(!this.rendered){if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected){A(new k("Provider iframe was closed"));return}}else if(this.popUp?.closed){A(new k("Popup was closed"));return}}if(!d){A(new k("Message channel lost"));return}if(Date.now()-J>Yt*2){A(new k("Lost connection to popup (heartbeat timeout)"));return}try{d.postMessage({type:"ping"});}catch{A(new k("Failed to send heartbeat"));}},Yt),d.onmessage=v=>{if(l)return;let $=v.data;switch($.type){case "pong":J=Date.now();break;case "popup-complete":$.payload?m($.payload):A(new F("Invalid completion payload"));break;case "popup-rejected":A(new F("User rejected the operation"));break;case "popup-error":A(new F($.error||"Unknown popup error"));break;case "popup-closed":A(new k("User closed popup"));break;default:console.warn("Unknown message type from popup:",$);}},d.onmessageerror=()=>{A(new F("Message deserialization error"));};try{this.rendered?this.rendered.targetWindow.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]):this.uiMode==="iframe"?this.frame?.iframe.contentWindow?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]):this.popUp?.postMessage({type:"popup-init",rid:n},this.providerOrigin,[M.port2]);}catch(v){A(new F(`Failed to initialize popup: ${v}`));return}o(n,r).then(v=>{if(l||!d)return;if(this.rendered?.isClosed){if(this.rendered.isClosed())return}else if(this.uiMode==="iframe"){if(!this.frame?.iframe.isConnected)return}else if(this.popUp?.closed)return;try{d.postMessage({type:"popup-start",payload:v});}catch(bo){A(new F(`Failed to send request to popup: ${bo}`));return}g&&(clearTimeout(g),g=null);let $=Math.max(0,v.request.validTill-Date.now());g=setTimeout(()=>{A(new Oe("Request expired"));},$);}).catch(v=>{A(v);});};window.addEventListener("message",C);}};function Qr(e){let t=e.domain?`${e.domain} wants you to sign in with your account.`:"Sign in with your account.",n=[];return e.nonce&&n.push(`Nonce: ${e.nonce}`),n.length>0?`${t}
|
|
6
6
|
|
|
7
7
|
${n.join(`
|
|
8
|
-
`)}`:t}function
|
|
8
|
+
`)}`:t}function mu(e){let t=e?.message||"";return t==="Failed to fetch"||t.includes("Load failed")||t.includes("NetworkError")||t.includes("ERR_NETWORK")}async function R(e,t=3,n=500,r=5e3){let o=null;for(let i=0;i<t;i++)try{return await e()}catch(a){if(o=a instanceof Error?a:new Error(String(a)),!mu(o))throw o;if(i===t-1)break;let s=Math.min(n*Math.pow(2,i),r);await new Promise(c=>setTimeout(c,s));}throw o}async function eo({data:e,url:t,options:n}){let i=Nu(t),{pendingApprovalsCallback:a,signal:s}=n??{};for(let c=0;c<10;c++){if(s?.aborted)throw Error("Aborted");let u,d;try{d=await Cu(i,s),d.send(JSON.stringify({type:"message",data:e})),await Ou(d,(l,I)=>{if(l==="error"){let _=I&&typeof I=="object"&&typeof I.error=="string"?I.error:"Unknown error",g=new Error(_);throw g.noRetry=!0,g}return l==="signatures"?(u=I.signatures,!0):(l==="pending_transaction_approval"?a?.onPendingApprovalsCallback?.(I.validTill):l==="transaction_approved"&&a?.onPendingApprovalsSuccess?.(),!1)},s);}catch(l){if(l&&typeof l=="object"&&l.noRetry)throw new Error(`${l.message}`);if(l&&typeof l=="object"&&l.name==="AbortError")throw l}finally{try{d?.close();}catch{}}if(u?.length)return u[0];c<9&&await new Promise(l=>setTimeout(l,400));}throw new Error("Transaction manager: missing signatures")}function Nu(e){let t=new URL(e);return t.protocol==="https:"?t.protocol="wss:":t.protocol==="http:"&&(t.protocol="ws:"),t.toString()}function Cu(e,t){return new Promise((n,r)=>{let o=new WebSocket(e),i=()=>{try{o.close();}catch{}};t?.addEventListener("abort",i,{once:true}),o.onopen=()=>{t?.removeEventListener("abort",i),n(o);},o.onerror=()=>{t?.removeEventListener("abort",i),r(new Error("WebSocket connection failed"));};})}async function Ou(e,t,n){return new Promise((r,o)=>{let i=false,a=()=>{n?.removeEventListener("abort",c),e.removeEventListener("message",u),e.removeEventListener("error",d),e.removeEventListener("close",l);},s=I=>{i||(i=true,a(),I());},c=()=>{try{e.close();}catch{}};n?.addEventListener("abort",c);let u=I=>{if(typeof I.data!="string")return;let _;try{_=JSON.parse(I.data);}catch{return}let g=typeof _.event=="string"?_.event:"message",f=_.data;try{t(g,f)&&s(()=>r());}catch(A){s(()=>o(A));}},d=()=>{s(()=>o(new Error("Transaction manager request failed")));},l=()=>{s(()=>r());};e.addEventListener("message",u),e.addEventListener("error",d),e.addEventListener("close",l);})}async function to(e,t,n){let{startRequest:r}=t.data.payload;if(!r.data.requireTwoFactorAuthentication)return null;let i=(await R(async()=>core.fetchSettingsAccountData(await core.getSettingsFromIndex(e.settingsIndexWithAddress.index)))).members.find(u=>u.role===core.UserRole.TransactionManager);if(!i)throw new Error("No transaction manager found.");let a=core.convertMemberKeyToString(i.pubkey),s=await R(()=>core.fetchUserAccountData(S(a),i.userAddressTreeIndex));if(s.transactionManagerUrl.__option==="None")throw new Error("No transaction manager url found.");let c=await eo({data:{publicKey:a,payload:t},url:s.transactionManagerUrl.value,options:n});return {publicKey:a,signature:c}}async function H_(e,t){let n=async(o,i)=>{let a={phase:"start",rid:o,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"message",payload:Qr({domain:i,nonce:U().decode(crypto.getRandomValues(new Uint8Array(16)))}),requireTwoFactorAuthentication:t?.requireTwoFactorAuthentication??false},clientOrigin:i},{signature:s,validTill:c}=await R(()=>e.onClientAuthorizationCallback(a));return {request:{...a,rid:o,validTill:c},signature:s}},r=async o=>{let i=core.UserInfoSchema.parse(o.data.payload.additionalInfo),a=await to(i,o,t);return await e.onClientAuthorizationCallback(a?{...o,data:{...o.data,payload:{...o.data.payload,transactionManager:a}}}:o),{user:i}};return e.sendRequestToPopupProvider({onConnectedCallback:n,onSuccessCallback:r,signal:t?.signal})}var ue="11111111111111111111111111111111";var no=0,ro=1,oo=2,io=3,ao=4,so=5,co=6,uo=7,lo=8;process.env.NODE_ENV!=="production"&&({[no]:"an account with the same address already exists",[so]:"provided address does not match addressed derived from seed",[io]:"cannot allocate account data of this length",[oo]:"cannot assign account to this program id",[ao]:"length of requested seed is too long",[uo]:"stored nonce is still in recent_blockhashes",[co]:"advancing stored nonce requires a populated RecentBlockhashes sysvar",[lo]:"specified nonce does not match stored nonce",[ro]:"account does not have enough SOL to perform the operation"});var qt="TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA";function Io(){return Se([["discriminator",Re()],["deactivationSlot",oe()],["lastExtendedSlot",oe()],["lastExtendedSlotStartIndex",H()],["authority",Nr(G(),{noneValue:"zeroes"})],["padding",Tr()],["addresses",Pe(G(),{size:"remainder"})]])}function _o(e){return ar(e,Io())}async function Xt(e,t,n){let r=await dr(e,t,n);return _o(r)}async function Qe({instructions:e,payer:t,addressesByLookupTableAddress:n}){let r=await R(()=>core.getSolanaRpc().getLatestBlockhash().send()),o=await pe(ke({version:0}),i=>xe(e,i),i=>Ke(t,i),i=>ze(r.value,i),i=>n?Ft(i,n):i,async i=>{let[a,s]=await Promise.all([Bu(i),Fu(core.getSolanaRpc(),i.instructions.flatMap(u=>u.accounts??[]))]),c=Math.ceil((Number(a)??0)*1.1);return We([...c>2e5?[ce({units:c})]:[],...s>0?[Ne({microLamports:s})]:[]],i)},async i=>await R(async()=>$e(await i)));return await R(()=>core.getSolanaRpc().sendTransaction(ne(o),{skipPreflight:!0,encoding:"base64"}).send()),Ge(o)}async function Eo(e,t){let n=await Ao(t,true),r=await Pu(n.map(ne),core.getSolanaRpcEndpoint()),o=await Ao(t.map((i,a)=>({...i,unitsConsumed:r[a]})));return await R(()=>e.onSendJitoBundleCallback(o.map(ne))),Ge(o[o.length-1])}async function Pu(e,t){let r=await(await R(()=>fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify({jsonrpc:"2.0",id:"2",method:"simulateBundle",params:[{encodedTransactions:e},{skipSigVerify:!0,replaceRecentBlockhash:!0,preExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]})),postExecutionAccountsConfigs:e.map(()=>({encoding:"base64",addresses:[]}))}]})}))).json();if(!r.result||r.error)throw new Error(`Unable to simulate bundle: ${JSON.stringify(r.error??r.result)}`);if(typeof r.result.value.summary!="string"&&r.result.value.summary.failed){let{TransactionFailure:o}=r.result.value.summary.failed.error,[,i]=o;throw new Error(`Simulation failed: ${i}`)}return r.result.value.transactionResults.map(o=>o.unitsConsumed)}async function Ao(e,t=false){let n=t?{blockhash:Or().decode(crypto.getRandomValues(new Uint8Array(32))),lastValidBlockHeight:BigInt(Number.MAX_SAFE_INTEGER)}:(await R(()=>core.getSolanaRpc().getLatestBlockhash().send())).value;return await Promise.all(e.map(async r=>await pe(ke({version:0}),i=>xe(r.instructions,i),i=>Ke(r.payer,i),i=>ze(n,i),i=>r.addressesByLookupTableAddress?Ft(i,r.addressesByLookupTableAddress):i,i=>{let a=Math.ceil((r.unitsConsumed??0)*1.1);return a>2e5?We([ce({units:a})],i):i},async i=>t?te(i):await R(()=>$e(i)))))}async function Bu(e){let t=We([ce({units:8e5}),Ne({microLamports:1e4})],e),n=te(t),r=await R(()=>core.getSolanaRpc().simulateTransaction(ne(n),{encoding:"base64"}).send());if(r.value.err){if(r.value.logs){let i=["Transaction simulation failed:","",...r.value.logs].join(`
|
|
9
9
|
`);throw new Error(i)}let o=["Transaction simulation failed:","",r.value.err.toString()].join(`
|
|
10
|
-
`);throw new Error(o)}return r.value.unitsConsumed}async function kd(e,t){let r=(await R(()=>e.getRecentPrioritizationFees(t.filter(i=>i.role===y.WRITABLE||i.role===y.WRITABLE_SIGNER).map(i=>i.address)).send())).map(i=>Number(i.prioritizationFee));r.sort((i,a)=>i-a);let o=Math.floor(r.length/2);return r.length%2===0?Math.round((r[o-1]+r[o])/2):r[o]}var fo=new Map;async function ue(){let e=fo.get(Ce);if(e)return e;let t=await R(()=>fetch(`${Ce}/getRandomPayer`));if(!t.ok)throw new Error(`Failed to get random payer: ${t.statusText}`);let{randomPayer:n}=await t.json(),r=Gd(S(n),`${Ce}/sign`);return fo.set(Ce,r),r}function Gd(e,t){return {address:e,async signTransactions(r){let o={publicKey:e,transactions:r.map(s=>U().decode(Wt().encode(s)))},i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok)throw new Error(`Failed to sign transactions: ${i.statusText}`);let a=await i.json();if("error"in a)throw new Error(a.error);return a.signatures.map(s=>({[e]:ee().encode(s)}))}}}async function le(e){let{transactionManagerAddress:t,transactionMessageBytes:n,userAddressTreeIndex:r,authResponses:o,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:s,abortSignal:c,cachedAccounts:d}=e,u=s;if(c&&!u){let _=new AbortController;c.aborted?_.abort():c.addEventListener("abort",()=>_.abort(),{once:true}),u=_;}let l;if(t){let _=(await R(()=>core.fetchUserAccountData(t,r,d))).transactionManagerUrl;l=_.__option==="Some"?_.value:null;}return t&&l?core.createTransactionManagerSigner({address:t,url:l,authResponses:o,transactionMessageBytes:n,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:u}):null}async function Ie(e){if(!e)return await R(()=>Wr([S(qe)],core.getSolanaRpc()));if(qe in e)return e;let t=await R(()=>Zt(core.getSolanaRpc(),S(qe)));return t.exists?{...e,[t.address]:t.data.addresses}:e}async function Do(e,t){let{authResponse:n,settings:r,additionalSigners:o,options:i,payer:a,settingsAddressTreeIndex:s}=t,{startRequest:c,signer:d}=n;if(c.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionMessageBytes:l}=c.data.payload;if(u!=="execute"&&u!=="create_with_preauthorized_execution")throw new Error("Transaction action type must be 'execute' or 'create_with_preauthorized_execution'");let I=new Map,[_,g,f]=await Promise.all([a??ue(),R(()=>core.fetchSettingsAccountData(r,s,I)),core.getSignedSecp256r1Key(n)]),A=core.retrieveTransactionManager(d,g),[m,C]=await Promise.all([le({authResponses:[n],transactionManagerAddress:A?.transactionManagerAddress,userAddressTreeIndex:A?.userAddressTreeIndex,transactionMessageBytes:b().encode(l),onPendingApprovalsCallback:i?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:i?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:i?.signal,cachedAccounts:I}),R(()=>e.onEstimateJitoTipsCallback())]),T=await core.prepareTransactionBundle({compressed:g.isCompressed,settings:r,settingsAddressTreeIndex:s,transactionMessageBytes:b().encode(l),creator:m??f,executor:m?f:void 0,jitoBundlesTipAmount:C,additionalSigners:o,payer:_,cachedAccounts:I}),O=await Promise.all(T.map(async M=>({...M,addressesByLookupTableAddress:await Ie(M.addressesByLookupTableAddress)})));return Ro(e,O)}async function So(e){let{authResponse:t,settings:n,payer:r,additionalSigners:o,settingsAddressTreeIndex:i,options:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:d,transactionMessageBytes:u}=s.data.payload;if(d!=="sync")throw new Error("Transaction action type must be 'sync'");let l=new Map,[I,_,g]=await Promise.all([r??ue(),R(()=>core.fetchSettingsAccountData(n,i,l)),core.getSignedSecp256r1Key(t)]),f=core.retrieveTransactionManager(c,_),A=await le({authResponses:[t],transactionManagerAddress:f?.transactionManagerAddress,userAddressTreeIndex:f?.userAddressTreeIndex,transactionMessageBytes:b().encode(u),onPendingApprovalsCallback:a?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:a?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:a?.signal,cachedAccounts:l}),m=A?[g,A]:[g],{instructions:C,addressesByLookupTableAddress:T}=await core.prepareTransactionSync({compressed:_.isCompressed,signers:m,payer:I,transactionMessageBytes:b().encode(u),settings:n,settingsAddressTreeIndex:i,cachedAccounts:l,additionalSigners:o});return et({instructions:C,payer:I,addressesByLookupTableAddress:await Ie(T)})}async function po(e){let{authResponse:t,settings:n,settingsAddressTreeIndex:r,options:o,payer:i,addressesByLookupTableAddress:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:d,transactionAddress:u,transactionMessageBytes:l}=s.data.payload;if(d!=="transfer_intent")throw new Error("Transaction action type must be 'transfer_intent'");let I=b().encode(l),_=oe().decode(I.slice(0,8)),g=G().decode(I.slice(8,40)),f=G().decode(I.slice(40,72)),A=new Map,[m,C,T]=await Promise.all([i??ue(),R(()=>core.fetchSettingsAccountData(n,r,A)),core.getSignedSecp256r1Key(t)]),O=core.retrieveTransactionManager(c,C),M=await le({authResponses:[t],transactionManagerAddress:O?.transactionManagerAddress,userAddressTreeIndex:O?.userAddressTreeIndex,transactionMessageBytes:b().encode(l),onPendingApprovalsCallback:o?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:o?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:o?.signal,cachedAccounts:A}),J=M?[T,M]:[T],v=f!==de?await core.tokenTransferIntent({payer:m,settings:n,settingsAddressTreeIndex:r,amount:_,signers:J,destination:g,mint:f,tokenProgram:S(u),compressed:C.isCompressed,cachedAccounts:A}):await core.nativeTransferIntent({payer:m,settings:n,settingsAddressTreeIndex:r,amount:_,signers:J,destination:g,compressed:C.isCompressed,cachedAccounts:A});return et({instructions:v,payer:m,addressesByLookupTableAddress:await Ie(a)})}async function mo(e,t=30,n=2e3){for(let r=0;r<t;r++){let i=(await R(()=>core.getSolanaRpc().getSignatureStatuses([e]).send())).value[0];if(i?.confirmationStatus==="confirmed"||i?.confirmationStatus==="finalized")return e;await new Promise(a=>setTimeout(a,n));}throw new Error("Transaction confirmation timeout")}async function tt(e,t){let{user:n,request:r,additionalSigners:o,options:i,payer:a,addressesByLookupTableAddress:s}=t,{confirmTransaction:c=true}=i??{},d=r.data.type==="transaction"&&r.data.payload.startRequest.data.payload.transactionActionType!=="transfer_intent"?r.data.payload.startRequest.data.payload.transactionAddress:n.settingsIndexWithAddress?.index?await core.getSettingsFromIndex(n.settingsIndexWithAddress.index):null;if(!d)throw Error("User is not delegated to any wallet");let u;switch(r.data.payload.startRequest.data.payload.transactionActionType){case "transfer_intent":u=await po({authResponse:r.data.payload,settings:S(d),options:i,payer:a,addressesByLookupTableAddress:s});break;case "execute":case "create_with_preauthorized_execution":u=await Do(e,{authResponse:r.data.payload,settings:S(d),additionalSigners:o,options:i,payer:a});break;case "sync":u=await So({authResponse:r.data.payload,settings:S(d),additionalSigners:o,options:i,payer:a});break;default:throw Error("Invalid Transaction Action Type for send tx payload.")}return c&&await mo(u),u}async function Sv(e,t,n){let{instructions:r,signer:o,addressesByLookupTableAddress:i,settingsIndexWithAddress:a,additionalSigners:s,payer:c}=t,d=async(l,I)=>{let _=core.prepareTransactionMessage({payer:S(o.walletAddress),instructions:r,addressesByLookupTableAddress:i}),g=a??o.settingsIndexWithAddress,f=await core.getSettingsFromIndex(g.index),m=(await R(()=>core.fetchSettingsAccountData(f,g.settingsAddressTreeIndex))).members.some(J=>J.role===core.UserRole.TransactionManager),C={transactionMessageBytes:U().decode(_),transactionAddress:f,transactionActionType:m?"execute":"create_with_preauthorized_execution"},T={phase:"start",rid:l,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:C},clientOrigin:I,signer:o.publicKey},{signature:O,validTill:M}=await R(()=>e.onClientAuthorizationCallback(T));return {request:{...T,rid:l,validTill:M},signature:O}},u=async l=>{let{signature:I}=await e.onClientAuthorizationCallback(l),_=core.UserInfoSchema.parse(l.data.payload.additionalInfo),g=await tt(e,{user:_,request:{...l,data:{...l.data,payload:{...l.data.payload,client:{...l.data.payload.client,jws:I}}}},options:n,additionalSigners:s,addressesByLookupTableAddress:i,payer:c});return {user:_,txSig:g}};return e.sendRequestToPopupProvider({onConnectedCallback:d,onSuccessCallback:u,signal:n?.signal})}async function yv(e,t,n){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{mint:r,tokenProgram:o=Xt,amount:i,destination:a,signer:s,payer:c,addressesByLookupTableAddress:d}=t,u=async(I,_)=>{let g={transactionActionType:"transfer_intent",transactionAddress:r?o:de,transactionMessageBytes:U().decode(new Uint8Array([...Te().encode(i),...W().encode(S(a)),...W().encode(S(r??de))]))},f={phase:"start",rid:I,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:g},clientOrigin:_,signer:s?.publicKey},{signature:A,validTill:m}=await R(()=>e.onClientAuthorizationCallback(f));return {request:{...f,rid:I,validTill:m},signature:A}},l=async I=>{let{signature:_}=await e.onClientAuthorizationCallback(I),g=core.UserInfoSchema.parse(I.data.payload.additionalInfo);return {txSig:await tt(e,{user:g,request:{...I,data:{...I.data,payload:{...I.data.payload,client:{...I.data.payload.client,jws:_}}}},options:n,addressesByLookupTableAddress:d,payer:c}),user:g}};return e.sendRequestToPopupProvider({onConnectedCallback:u,onSuccessCallback:l,signal:n?.signal})}async function No(e,t,n){if(!t.includes(e.clientOrigin))throw new Error("Invalid client origin");let r=Date.now()+jr,o=core.convertBase64StringToJWK(n);if(!o.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationStartRequestChallenge({...e,validTill:r})).setProtectedHeader({alg:o.alg}).sign(o),validTill:r}}function _e(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 yo(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>o.startRequest.validTill)throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!_e(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!_e(c.payload,new Uint8Array([...core.getSecp256r1MessageHash(e.data.payload.authResponse),...be().encode(jsonCanonicalize.canonicalize(o.device.deviceProfile))])))throw new Error("Invalid device signature")}let i=core.createMessageChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid),{verified:a}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(i),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!a)throw new Error("Invalid user siganture");if(r){if(!o.startRequest.data.requireTwoFactorAuthentication)throw new Error("Two factor authentication is required.");if(!o.transactionManager)throw new Error("Missing signature from transaction manager.");let c=(await core.fetchUserAccountByFilters(await core.getDomainConfigAddress({rpId:o.startRequest.rpId}),{credentialId:o.authResponse.id}))?.wallets.find(l=>l.isDelegate);if(!c)throw new Error("User does not have a delegated wallet");let u=(await core.fetchSettingsAccountData(await core.getSettingsFromIndex(c.index))).members.find(l=>l.role===core.UserRole.TransactionManager);if(!u)throw new Error("No transaction manager found.");if(o.transactionManager.publicKey!==core.convertMemberKeyToString(u.pubkey))throw new Error("Transaction manager mismatch.");if(!await Yt(S(o.transactionManager.publicKey),o.transactionManager.signature,i))throw new Error("Invalid transaction manager signature.")}return {ok:true}}async function bo(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="transaction")throw new Error("Invalid request type.");if(Date.now()>Math.min(o.startRequest.validTill,o.estimatedSlotHashExpiry))throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!_e(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!_e(c.payload,new Uint8Array([...core.getSecp256r1MessageHash(e.data.payload.authResponse),...be().encode(jsonCanonicalize.canonicalize(o.device.deviceProfile))])))throw new Error("Invalid device signature")}{let{challenge:s}=await core.createTransactionChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid,o.slotHash,o.slotNumber,o.estimatedSlotHashExpiry),{verified:c}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(s),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!c)throw new Error("Invalid user siganture")}let i=core.convertBase64StringToJWK(r);if(!i.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationCompleteRequestChallenge(e)).setProtectedHeader({alg:i.alg}).sign(i)}}var Uo=false;function Bu(e){Uo||e&&(core.initialize({rpcEndpoint:e}),Uo=true);}async function iP({request:e,publicKey:t,allowedClientOrigins:n,privateKey:r,requireTwoFactorAuthentication:o}){if(Bu(o?.rpcEndpoint),e.phase==="start"){if(e.data.type==="message"&&!!o!==e.data.requireTwoFactorAuthentication)throw new Error("Require 2fa check mismatch");return await No(e,n,r)}else if(e.phase==="complete"){if(e.data.type==="message")return await yo(e,t,n,!!o);if(e.data.type==="transaction")return await bo(e,t,n,r);throw new Error("Invalid request type")}else throw new Error("Invalid request phase")}async function cP(e="landed_tips_75th_percentile",t=Kr){let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch Jito tips: ${n.status} ${n.statusText}`);let r=await n.json();if(!Array.isArray(r)||!r[0]||typeof r[0][e]!="number")throw new Error("Invalid Jito tips response format");return Math.round(r[0][e]*1e9)}async function lP(e,t,n=Hr){let i=JSON.stringify({jsonrpc:"2.0",id:1,method:"sendBundle",params:[e,{encoding:"base64"}]}),a=null;for(let c=0;c<=5&&(a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-jito-auth":t}:{}},body:i}),!(a.status!==429||c===5));c++){let d=Math.min(1e4,250*2**c);await Fu(d);}if(!a)throw new Error("Failed to send bundles: no response");let s=await a.json();if(s.error)throw new Error(`Error sending bundles: ${JSON.stringify(s.error,null,2)}`);if(!s.result)throw new Error("No bundle ID returned from Jito");return s.result}var Fu=e=>new Promise(t=>setTimeout(t,e));/*! Bundled license information:
|
|
10
|
+
`);throw new Error(o)}return r.value.unitsConsumed}async function Fu(e,t){let r=(await R(()=>e.getRecentPrioritizationFees(t.filter(i=>i.role===y.WRITABLE||i.role===y.WRITABLE_SIGNER).map(i=>i.address)).send())).map(i=>Number(i.prioritizationFee));r.sort((i,a)=>i-a);let o=Math.floor(r.length/2);return r.length%2===0?Math.round((r[o-1]+r[o])/2):r[o]}var Ro=new Map;async function de(){let e=Ro.get(Ce);if(e)return e;let t=await R(()=>fetch(`${Ce}/getRandomPayer`));if(!t.ok)throw new Error(`Failed to get random payer: ${t.statusText}`);let{randomPayer:n}=await t.json(),r=xu(S(n),`${Ce}/sign`);return Ro.set(Ce,r),r}function xu(e,t){return {address:e,async signTransactions(r){let o={publicKey:e,transactions:r.map(s=>U().decode(xt().encode(s)))},i=await fetch(t,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(o)});if(!i.ok)throw new Error(`Failed to sign transactions: ${i.statusText}`);let a=await i.json();if("error"in a)throw new Error(a.error);return a.signatures.map(s=>({[e]:ee().encode(s)}))}}}async function le(e){let{transactionManagerAddress:t,transactionMessageBytes:n,userAddressTreeIndex:r,authResponses:o,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:s,abortSignal:c,cachedAccounts:u}=e,d=s;if(c&&!d){let _=new AbortController;c.aborted?_.abort():c.addEventListener("abort",()=>_.abort(),{once:true}),d=_;}let l;if(t){let _=(await R(()=>core.fetchUserAccountData(t,r,u))).transactionManagerUrl;l=_.__option==="Some"?_.value:null;}return t&&l?core.createTransactionManagerSigner({address:t,url:l,authResponses:o,transactionMessageBytes:n,onPendingApprovalsCallback:i,onPendingApprovalsSuccess:a,abortController:d}):null}async function Ie(e){if(!e)return await R(()=>kr([S(Ye)],core.getSolanaRpc()));if(Ye in e)return e;let t=await R(()=>Xt(core.getSolanaRpc(),S(Ye)));return t.exists?{...e,[t.address]:t.data.addresses}:e}async function To(e,t){let{authResponse:n,settings:r,additionalSigners:o,options:i,payer:a,settingsAddressTreeIndex:s}=t,{startRequest:c,signer:u}=n;if(c.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:d,transactionMessageBytes:l}=c.data.payload;if(d!=="execute"&&d!=="create_with_preauthorized_execution")throw new Error("Transaction action type must be 'execute' or 'create_with_preauthorized_execution'");let I=new Map,[_,g,f]=await Promise.all([a??de(),R(()=>core.fetchSettingsAccountData(r,s,I)),core.getSignedSecp256r1Key(n)]),A=core.retrieveTransactionManager(u,g),[m,C]=await Promise.all([le({authResponses:[n],transactionManagerAddress:A?.transactionManagerAddress,userAddressTreeIndex:A?.userAddressTreeIndex,transactionMessageBytes:b().encode(l),onPendingApprovalsCallback:i?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:i?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:i?.signal,cachedAccounts:I}),R(()=>e.onEstimateJitoTipsCallback())]),T=await core.prepareTransactionBundle({compressed:g.isCompressed,settings:r,settingsAddressTreeIndex:s,transactionMessageBytes:b().encode(l),creator:m??f,executor:m?f:void 0,jitoBundlesTipAmount:C,additionalSigners:o,payer:_,cachedAccounts:I}),O=await Promise.all(T.map(async M=>({...M,addressesByLookupTableAddress:await Ie(M.addressesByLookupTableAddress)})));return Eo(e,O)}async function fo(e){let{authResponse:t,settings:n,payer:r,additionalSigners:o,settingsAddressTreeIndex:i,options:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionMessageBytes:d}=s.data.payload;if(u!=="sync")throw new Error("Transaction action type must be 'sync'");let l=new Map,[I,_,g]=await Promise.all([r??de(),R(()=>core.fetchSettingsAccountData(n,i,l)),core.getSignedSecp256r1Key(t)]),f=core.retrieveTransactionManager(c,_),A=await le({authResponses:[t],transactionManagerAddress:f?.transactionManagerAddress,userAddressTreeIndex:f?.userAddressTreeIndex,transactionMessageBytes:b().encode(d),onPendingApprovalsCallback:a?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:a?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:a?.signal,cachedAccounts:l}),m=A?[g,A]:[g],{instructions:C,addressesByLookupTableAddress:T}=await core.prepareTransactionSync({compressed:_.isCompressed,signers:m,payer:I,transactionMessageBytes:b().encode(d),settings:n,settingsAddressTreeIndex:i,cachedAccounts:l,additionalSigners:o});return Qe({instructions:C,payer:I,addressesByLookupTableAddress:await Ie(T)})}async function Do(e){let{authResponse:t,settings:n,settingsAddressTreeIndex:r,options:o,payer:i,addressesByLookupTableAddress:a}=e,{startRequest:s,signer:c}=t;if(s.data.type!=="transaction")throw new Error("Invalid request type.");let{transactionActionType:u,transactionAddress:d,transactionMessageBytes:l}=s.data.payload;if(u!=="transfer_intent")throw new Error("Transaction action type must be 'transfer_intent'");let I=b().encode(l),_=oe().decode(I.slice(0,8)),g=G().decode(I.slice(8,40)),f=G().decode(I.slice(40,72)),A=new Map,[m,C,T]=await Promise.all([i??de(),R(()=>core.fetchSettingsAccountData(n,r,A)),core.getSignedSecp256r1Key(t)]),O=core.retrieveTransactionManager(c,C),M=await le({authResponses:[t],transactionManagerAddress:O?.transactionManagerAddress,userAddressTreeIndex:O?.userAddressTreeIndex,transactionMessageBytes:b().encode(l),onPendingApprovalsCallback:o?.pendingApprovalsCallback?.onPendingApprovalsCallback,onPendingApprovalsSuccess:o?.pendingApprovalsCallback?.onPendingApprovalsSuccess,abortSignal:o?.signal,cachedAccounts:A}),J=M?[T,M]:[T],v=f!==ue?await core.tokenTransferIntent({payer:m,settings:n,settingsAddressTreeIndex:r,amount:_,signers:J,destination:g,mint:f,tokenProgram:S(d),compressed:C.isCompressed,cachedAccounts:A}):await core.nativeTransferIntent({payer:m,settings:n,settingsAddressTreeIndex:r,amount:_,signers:J,destination:g,compressed:C.isCompressed,cachedAccounts:A});return Qe({instructions:v,payer:m,addressesByLookupTableAddress:await Ie(a)})}async function So(e,t=30,n=2e3){for(let r=0;r<t;r++){let i=(await R(()=>core.getSolanaRpc().getSignatureStatuses([e]).send())).value[0];if(i?.confirmationStatus==="confirmed"||i?.confirmationStatus==="finalized")return e;await new Promise(a=>setTimeout(a,n));}throw new Error("Transaction confirmation timeout")}async function et(e,t){let{user:n,request:r,additionalSigners:o,options:i,payer:a,addressesByLookupTableAddress:s}=t,{confirmTransaction:c=true}=i??{},u=r.data.type==="transaction"&&r.data.payload.startRequest.data.payload.transactionActionType!=="transfer_intent"?r.data.payload.startRequest.data.payload.transactionAddress:n.settingsIndexWithAddress?.index?await core.getSettingsFromIndex(n.settingsIndexWithAddress.index):null;if(!u)throw Error("User is not delegated to any wallet");let d;switch(r.data.payload.startRequest.data.payload.transactionActionType){case "transfer_intent":d=await Do({authResponse:r.data.payload,settings:S(u),options:i,payer:a,addressesByLookupTableAddress:s});break;case "execute":case "create_with_preauthorized_execution":d=await To(e,{authResponse:r.data.payload,settings:S(u),additionalSigners:o,options:i,payer:a});break;case "sync":d=await fo({authResponse:r.data.payload,settings:S(u),additionalSigners:o,options:i,payer:a});break;default:throw Error("Invalid Transaction Action Type for send tx payload.")}return c&&await So(d),d}async function Tv(e,t,n){let{instructions:r,signer:o,addressesByLookupTableAddress:i,settingsIndexWithAddress:a,additionalSigners:s,payer:c}=t,u=async(l,I)=>{let _=core.prepareTransactionMessage({payer:S(o.walletAddress),instructions:r,addressesByLookupTableAddress:i}),g=a??o.settingsIndexWithAddress,f=await core.getSettingsFromIndex(g.index),m=(await R(()=>core.fetchSettingsAccountData(f,g.settingsAddressTreeIndex))).members.some(J=>J.role===core.UserRole.TransactionManager),C={transactionMessageBytes:U().decode(_),transactionAddress:f,transactionActionType:m?"execute":"create_with_preauthorized_execution"},T={phase:"start",rid:l,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:C},clientOrigin:I,signer:o.publicKey},{signature:O,validTill:M}=await R(()=>e.onClientAuthorizationCallback(T));return {request:{...T,rid:l,validTill:M},signature:O}},d=async l=>{let{signature:I}=await e.onClientAuthorizationCallback(l),_=core.UserInfoSchema.parse(l.data.payload.additionalInfo),g=await et(e,{user:_,request:{...l,data:{...l.data,payload:{...l.data.payload,client:{...l.data.payload.client,jws:I}}}},options:n,additionalSigners:s,addressesByLookupTableAddress:i,payer:c});return {user:_,txSig:g}};return e.sendRequestToPopupProvider({onConnectedCallback:u,onSuccessCallback:d,signal:n?.signal})}async function Cv(e,t,n){if(t.amount<=0)throw new Error("Transfer amount must be greater than 0");if(!t.destination||typeof t.destination!="string")throw new Error("Destination address is required");let{mint:r,tokenProgram:o=qt,amount:i,destination:a,signer:s,payer:c,addressesByLookupTableAddress:u}=t,d=async(I,_)=>{let g={transactionActionType:"transfer_intent",transactionAddress:r?o:ue,transactionMessageBytes:U().decode(new Uint8Array([...Te().encode(i),...W().encode(S(a)),...W().encode(S(r??ue))]))},f={phase:"start",rid:I,providerOrigin:e.providerOrigin,rpId:e.rpId,data:{type:"transaction",payload:g},clientOrigin:_,signer:s?.publicKey},{signature:A,validTill:m}=await R(()=>e.onClientAuthorizationCallback(f));return {request:{...f,rid:I,validTill:m},signature:A}},l=async I=>{let{signature:_}=await e.onClientAuthorizationCallback(I),g=core.UserInfoSchema.parse(I.data.payload.additionalInfo);return {txSig:await et(e,{user:g,request:{...I,data:{...I.data,payload:{...I.data.payload,client:{...I.data.payload.client,jws:_}}}},options:n,addressesByLookupTableAddress:u,payer:c}),user:g}};return e.sendRequestToPopupProvider({onConnectedCallback:d,onSuccessCallback:l,signal:n?.signal})}async function po(e,t,n){if(!t.includes(e.clientOrigin))throw new Error("Invalid client origin");let r=Date.now()+Kr,o=core.convertBase64StringToJWK(n);if(!o.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationStartRequestChallenge({...e,validTill:r})).setProtectedHeader({alg:o.alg}).sign(o),validTill:r}}function _e(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 Oo(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="message")throw new Error("Invalid request type.");if(Date.now()>o.startRequest.validTill)throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!_e(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!_e(c.payload,core.getDeviceMessageHash(o.authResponse,o.device.deviceProfile)))throw new Error("Invalid device signature")}let i=core.createMessageChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid),{verified:a}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(i),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!a)throw new Error("Invalid user siganture");if(r){if(!o.startRequest.data.requireTwoFactorAuthentication)throw new Error("Two factor authentication is required.");if(!o.transactionManager)throw new Error("Missing signature from transaction manager.");let c=(await core.fetchUserAccountByFilters(await core.getDomainConfigAddress({rpId:o.startRequest.rpId}),{credentialId:o.authResponse.id}))?.wallets.find(l=>l.isDelegate);if(!c)throw new Error("User does not have a delegated wallet");let d=(await core.fetchSettingsAccountData(await core.getSettingsFromIndex(c.index))).members.find(l=>l.role===core.UserRole.TransactionManager);if(!d)throw new Error("No transaction manager found.");if(o.transactionManager.publicKey!==core.convertMemberKeyToString(d.pubkey))throw new Error("Transaction manager mismatch.");if(!await jt(S(o.transactionManager.publicKey),o.transactionManager.signature,i))throw new Error("Invalid transaction manager signature.")}return {ok:true}}async function Mo(e,t,n,r){let{payload:o}=e.data;if(o.startRequest.data.type!=="transaction")throw new Error("Invalid request type.");if(Date.now()>Math.min(o.startRequest.validTill,o.estimatedSlotHashExpiry))throw new Error("Request expired.");if(!n.includes(o.startRequest.clientOrigin)||!n.includes(o.client.clientOrigin)||o.startRequest.clientOrigin!==o.client.clientOrigin)throw new Error("Invalid client origin");{let s=await jose.importJWK(core.convertBase64StringToJWK(t)),c=await jose.compactVerify(e.data.payload.client.jws,s);if(!_e(c.payload,core.createClientAuthorizationStartRequestChallenge(e.data.payload.startRequest)))throw new Error("Invalid client signature")}{if(o.device.jwk!==o.device.deviceProfile.devicePublicKey)throw new Error("Device publickey mismatch");let s=await jose.importJWK(core.convertBase64StringToJWK(o.device.jwk)),c=await jose.compactVerify(o.device.jws,s);if(!_e(c.payload,core.getDeviceMessageHash(o.authResponse,o.device.deviceProfile)))throw new Error("Invalid device signature")}{let{challenge:s}=await core.createTransactionChallenge(o.startRequest.data.payload,o.startRequest.clientOrigin,o.device.jwk,o.startRequest.rid,o.slotHash,o.slotNumber,o.estimatedSlotHashExpiry),{verified:c}=await server.verifyAuthenticationResponse({response:o.authResponse,expectedChallenge:core.bufferToBase64URLString(s),expectedRPID:o.startRequest.rpId,expectedOrigin:o.startRequest.providerOrigin,requireUserVerification:false,credential:{counter:0,id:o.authResponse.id,publicKey:core.convertPubkeyCompressedToCose(o.signer)}});if(!c)throw new Error("Invalid user siganture")}let i=core.convertBase64StringToJWK(r);if(!i.alg)throw new Error("Property alg in JWK is missing.");return {ok:true,signature:await new jose.CompactSign(core.createClientAuthorizationCompleteRequestChallenge(e)).setProtectedHeader({alg:i.alg}).sign(i)}}var Lo=false;function Ud(e){Lo||e&&(core.initialize({rpcEndpoint:e}),Lo=true);}async function Qv({request:e,publicKey:t,allowedClientOrigins:n,privateKey:r,requireTwoFactorAuthentication:o}){if(Ud(o?.rpcEndpoint),e.phase==="start"){if(e.data.type==="message"&&!!o!==e.data.requireTwoFactorAuthentication)throw new Error("Require 2fa check mismatch");return await po(e,n,r)}else if(e.phase==="complete"){if(e.data.type==="message")return await Oo(e,t,n,!!o);if(e.data.type==="transaction")return await Mo(e,t,n,r);throw new Error("Invalid request type")}else throw new Error("Invalid request phase")}async function nP(e="landed_tips_75th_percentile",t=Vr){let n=await fetch(t);if(!n.ok)throw new Error(`Failed to fetch Jito tips: ${n.status} ${n.statusText}`);let r=await n.json();if(!Array.isArray(r)||!r[0]||typeof r[0][e]!="number")throw new Error("Invalid Jito tips response format");return Math.round(r[0][e]*1e9)}async function iP(e,t,n=Gr){let i=JSON.stringify({jsonrpc:"2.0",id:1,method:"sendBundle",params:[e,{encoding:"base64"}]}),a=null;for(let c=0;c<=5&&(a=await fetch(n,{method:"POST",headers:{"Content-Type":"application/json",...t?{"x-jito-auth":t}:{}},body:i}),!(a.status!==429||c===5));c++){let u=Math.min(1e4,250*2**c);await wd(u);}if(!a)throw new Error("Failed to send bundles: no response");let s=await a.json();if(s.error)throw new Error(`Error sending bundles: ${JSON.stringify(s.error,null,2)}`);if(!s.result)throw new Error("No bundle ID returned from Jito");return s.result}var wd=e=>new Promise(t=>setTimeout(t,e));/*! Bundled license information:
|
|
11
11
|
|
|
12
12
|
@noble/curves/utils.js:
|
|
13
13
|
(*! noble-curves - MIT License (c) 2022 Paul Miller (paulmillr.com) *)
|
|
14
|
-
*/exports.RevibaseAbortedError=
|
|
14
|
+
*/exports.RevibaseAbortedError=Ze;exports.RevibaseApiError=he;exports.RevibaseAuthError=F;exports.RevibaseEnvironmentError=Je;exports.RevibaseError=B;exports.RevibaseFlowInProgressError=Xe;exports.RevibasePopupBlockedError=qe;exports.RevibasePopupClosedError=k;exports.RevibasePopupNotOpenError=Hr;exports.RevibaseProvider=Jr;exports.RevibaseTimeoutError=Oe;exports.executeTransaction=Tv;exports.processClientAuthCallback=Qv;exports.processEstimateJitoTipsCallback=nP;exports.processSendJitoBundleCallback=iP;exports.signIn=H_;exports.transferTokens=Cv;//# sourceMappingURL=index.cjs.map
|
|
15
15
|
//# sourceMappingURL=index.cjs.map
|