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