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