zh-web-sdk 2.16.0 → 2.17.0
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 +225 -32
- package/dist/index.js +1 -1
- package/dist/index.js.map +3 -3
- package/package.json +7 -2
- package/.eslintrc.js +0 -12
- package/.github/CHANGELOG_TEMPLATE.md +0 -73
- package/.github/PULL_REQUEST_TEMPLATE.md +0 -10
- package/.github/backup/publish-tag.yaml +0 -14
- package/.github/workflows/build.yaml +0 -13
- package/.github/workflows/pr.yaml +0 -14
- package/.github/workflows/publish.yaml +0 -13
- package/.github/workflows/security.yml +0 -15
- package/.github/workflows/tag.yaml +0 -14
- package/RELEASING.md +0 -39
- package/jest.config.js +0 -8
- package/jest.setup.js +0 -24
- package/scripts/build.js +0 -34
- package/scripts/zip.js +0 -49
- package/src/__tests__/jwt-auth-detection.test.ts +0 -96
- package/src/api/convert-token.ts +0 -23
- package/src/constants.ts +0 -2
- package/src/hooks/__tests__/use-window-size.test.tsx +0 -26
- package/src/hooks/use-window-size.ts +0 -19
- package/src/iframe-container/AppContainer.tsx +0 -495
- package/src/iframe-container/__tests__/AppContainer.test.tsx +0 -300
- package/src/iframe-container/hooks/__tests__/use-style-updates.test.ts +0 -430
- package/src/iframe-container/hooks/use-style-updates.ts +0 -82
- package/src/index.tsx +0 -645
- package/src/redux/actions/index.ts +0 -27
- package/src/redux/reducers/constants.ts +0 -10
- package/src/redux/reducers/crypto-account-link-payouts.ts +0 -60
- package/src/redux/reducers/crypto-account-link.ts +0 -60
- package/src/redux/reducers/crypto-buy.ts +0 -75
- package/src/redux/reducers/crypto-sell.ts +0 -64
- package/src/redux/reducers/crypto-withdrawals.ts +0 -64
- package/src/redux/reducers/fiat-account-link.ts +0 -60
- package/src/redux/reducers/fiat-deposits.ts +0 -64
- package/src/redux/reducers/fiat-withdrawals.ts +0 -64
- package/src/redux/reducers/fund.ts +0 -75
- package/src/redux/reducers/index.ts +0 -35
- package/src/redux/reducers/onboarding.ts +0 -74
- package/src/redux/reducers/pay.ts +0 -64
- package/src/redux/reducers/payouts.ts +0 -64
- package/src/redux/reducers/profile.ts +0 -63
- package/src/redux/store/index.ts +0 -10
- package/src/styles.ts +0 -108
- package/src/types.ts +0 -578
- package/src/utils/auth-to-fund-mapper.ts +0 -174
- package/src/utils/strings.ts +0 -19
- package/src/utils/test-utils.tsx +0 -36
- package/src/utils/world-app-utils.ts +0 -8
- package/src/utils.ts +0 -27
- package/tsconfig.json +0 -26
package/README.md
CHANGED
|
@@ -1,56 +1,249 @@
|
|
|
1
|
-
# ZeroHash
|
|
1
|
+
# ZeroHash Web SDK
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
The ZeroHash Web SDK enables platforms to integrate ZeroHash financial services on web and mobile applications. Access various UI flows including Crypto Buy, Crypto Sell, Crypto Withdrawals, Fiat Deposits, Fiat Withdrawals, and Onboarding through a single SDK instance.
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install zh-web-sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
or
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
yarn add zh-web-sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Quick Start
|
|
18
|
+
|
|
19
|
+
### React Example
|
|
20
|
+
|
|
21
|
+
```typescript
|
|
22
|
+
import React, { useMemo } from 'react';
|
|
23
|
+
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
|
|
24
|
+
|
|
25
|
+
const App = () => {
|
|
26
|
+
// Create SDK instance once - not on every render
|
|
27
|
+
const sdk = useMemo(() => new ZeroHashSDK({
|
|
28
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com"
|
|
29
|
+
}), []);
|
|
30
|
+
|
|
31
|
+
const handleOpenCryptoBuy = () => {
|
|
32
|
+
sdk.openModal({
|
|
33
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
34
|
+
jwt: "<JWT_TOKEN_HERE>"
|
|
35
|
+
});
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
return (
|
|
39
|
+
<button onClick={handleOpenCryptoBuy}>
|
|
40
|
+
Buy Crypto
|
|
41
|
+
</button>
|
|
42
|
+
);
|
|
43
|
+
};
|
|
44
|
+
|
|
45
|
+
export default App;
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
### Vanilla JavaScript Example
|
|
6
49
|
|
|
7
50
|
```javascript
|
|
8
|
-
import { AppIdentifier } from 'zh-web-sdk'
|
|
51
|
+
import ZeroHashSDK, { AppIdentifier } from 'zh-web-sdk';
|
|
52
|
+
|
|
53
|
+
// Initialize SDK once
|
|
54
|
+
const sdk = new ZeroHashSDK({
|
|
55
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com"
|
|
56
|
+
});
|
|
57
|
+
|
|
58
|
+
// Open a modal
|
|
59
|
+
sdk.openModal({
|
|
60
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
61
|
+
jwt: "<JWT_TOKEN_HERE>"
|
|
62
|
+
});
|
|
9
63
|
|
|
10
|
-
|
|
11
|
-
sdk.
|
|
64
|
+
// Close when done
|
|
65
|
+
sdk.closeModal(AppIdentifier.CRYPTO_BUY);
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Environments
|
|
12
69
|
|
|
13
|
-
|
|
70
|
+
The SDK supports multiple environments:
|
|
14
71
|
|
|
15
|
-
|
|
72
|
+
- **Production**: `https://web-sdk.zerohash.com`
|
|
73
|
+
- **Certification/Sandbox**: `https://web-sdk.cert.zerohash.com`
|
|
16
74
|
|
|
17
|
-
|
|
75
|
+
```typescript
|
|
76
|
+
const sdk = new ZeroHashSDK({
|
|
77
|
+
zeroHashAppsURL: "https://web-sdk.cert.zerohash.com" // Use cert environment
|
|
78
|
+
});
|
|
18
79
|
```
|
|
19
80
|
|
|
20
|
-
|
|
81
|
+
## Available App Identifiers
|
|
82
|
+
|
|
83
|
+
The SDK supports the following application flows:
|
|
84
|
+
|
|
85
|
+
| AppIdentifier | Description |
|
|
86
|
+
|--------------|-------------|
|
|
87
|
+
| `ONBOARDING` | User onboarding and KYC |
|
|
88
|
+
| `CRYPTO_BUY` | Purchase cryptocurrency |
|
|
89
|
+
| `CRYPTO_SELL` | Sell cryptocurrency |
|
|
90
|
+
| `CRYPTO_WITHDRAWALS` | Withdraw crypto to external wallets |
|
|
91
|
+
| `FIAT_DEPOSITS` | Deposit fiat currency |
|
|
92
|
+
| `FIAT_WITHDRAWALS` | Withdraw fiat currency |
|
|
93
|
+
| `FUND` | Fund account operations |
|
|
94
|
+
| `PROFILE` | User profile management |
|
|
95
|
+
| `CRYPTO_ACCOUNT_LINK` | Link cryptocurrency accounts |
|
|
96
|
+
| `CRYPTO_ACCOUNT_LINK_PAYOUTS` | Link crypto accounts for payouts |
|
|
97
|
+
| `FIAT_ACCOUNT_LINK` | Link bank accounts |
|
|
98
|
+
| `PAYOUTS` | Payout operations |
|
|
99
|
+
| `PAY` | Payment operations |
|
|
21
100
|
|
|
22
|
-
##
|
|
101
|
+
## API Reference
|
|
102
|
+
|
|
103
|
+
### Constructor
|
|
23
104
|
|
|
24
105
|
```typescript
|
|
25
|
-
|
|
26
|
-
|
|
106
|
+
new ZeroHashSDK(config: IInitializeParameters)
|
|
107
|
+
```
|
|
27
108
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
109
|
+
**Configuration Options:**
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
{
|
|
113
|
+
zeroHashAppsURL: string; // Required: Base URL for ZeroHash apps
|
|
114
|
+
rootQuerySelector?: string; // Optional: Custom DOM element selector
|
|
115
|
+
|
|
116
|
+
// Optional: Set JWTs during initialization
|
|
117
|
+
cryptoBuyJWT?: string;
|
|
118
|
+
cryptoSellJWT?: string;
|
|
119
|
+
cryptoWithdrawalsJWT?: string;
|
|
120
|
+
fiatDepositsJWT?: string;
|
|
121
|
+
fiatWithdrawalsJWT?: string;
|
|
122
|
+
userOnboardingJWT?: string;
|
|
123
|
+
fundJWT?: string;
|
|
124
|
+
profileJWT?: string;
|
|
125
|
+
cryptoAccountLinkJWT?: string;
|
|
126
|
+
cryptoAccountLinkPayoutsJWT?: string;
|
|
127
|
+
fiatAccountLinkJWT?: string;
|
|
128
|
+
payoutsJWT?: string;
|
|
129
|
+
payJWT?: string;
|
|
38
130
|
}
|
|
131
|
+
```
|
|
39
132
|
|
|
40
|
-
|
|
133
|
+
### Methods
|
|
134
|
+
|
|
135
|
+
#### `openModal(params)`
|
|
136
|
+
|
|
137
|
+
Opens a modal for the specified app.
|
|
138
|
+
|
|
139
|
+
```typescript
|
|
140
|
+
sdk.openModal({
|
|
141
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
142
|
+
jwt?: string, // Optional: Set or update JWT
|
|
143
|
+
filters?: Filters, // Optional: Filter options
|
|
144
|
+
navigate?: Page // Optional: Navigation parameters
|
|
145
|
+
});
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
#### `closeModal(appIdentifier)`
|
|
149
|
+
|
|
150
|
+
Closes the modal for the specified app.
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
sdk.closeModal(AppIdentifier.CRYPTO_BUY);
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
#### `setJWT(params)`
|
|
157
|
+
|
|
158
|
+
Set or update the JWT for a specific app.
|
|
159
|
+
|
|
160
|
+
```typescript
|
|
161
|
+
sdk.setJWT({
|
|
162
|
+
jwt: "<JWT_TOKEN>",
|
|
163
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
#### `isModalOpen(appIdentifier)`
|
|
168
|
+
|
|
169
|
+
Check if a modal is currently open.
|
|
170
|
+
|
|
171
|
+
```typescript
|
|
172
|
+
const isOpen = sdk.isModalOpen(AppIdentifier.CRYPTO_BUY);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
#### `setFilters(params)`
|
|
176
|
+
|
|
177
|
+
Set filters for a specific app.
|
|
178
|
+
|
|
179
|
+
```typescript
|
|
180
|
+
sdk.setFilters({
|
|
181
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
182
|
+
filters: {
|
|
183
|
+
getAssets: {
|
|
184
|
+
stablecoin: true
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
});
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## JWT Authentication
|
|
191
|
+
|
|
192
|
+
**⚠️ Security Note**: JWTs should be obtained from your backend server using the ZeroHash API with your API key. Never expose your API key or perform JWT exchanges on the client side.
|
|
193
|
+
|
|
194
|
+
### Two approaches for providing JWTs:
|
|
195
|
+
|
|
196
|
+
**1. During initialization:**
|
|
197
|
+
```typescript
|
|
198
|
+
const sdk = new ZeroHashSDK({
|
|
199
|
+
zeroHashAppsURL: "https://web-sdk.zerohash.com",
|
|
200
|
+
cryptoBuyJWT: jwt
|
|
201
|
+
});
|
|
202
|
+
```
|
|
203
|
+
|
|
204
|
+
**2. When opening a modal:**
|
|
205
|
+
```typescript
|
|
206
|
+
sdk.openModal({
|
|
207
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY,
|
|
208
|
+
jwt: jwt
|
|
209
|
+
});
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
**3. Update JWT later:**
|
|
213
|
+
```typescript
|
|
214
|
+
sdk.setJWT({
|
|
215
|
+
jwt: newJwt,
|
|
216
|
+
appIdentifier: AppIdentifier.CRYPTO_BUY
|
|
217
|
+
});
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## TypeScript Support
|
|
221
|
+
|
|
222
|
+
The SDK is written in TypeScript and includes type definitions. Import types as needed:
|
|
223
|
+
|
|
224
|
+
```typescript
|
|
225
|
+
import ZeroHashSDK, {
|
|
226
|
+
AppIdentifier,
|
|
227
|
+
IInitializeParameters,
|
|
228
|
+
IOpenModalParameters,
|
|
229
|
+
Filters
|
|
230
|
+
} from 'zh-web-sdk';
|
|
41
231
|
```
|
|
42
232
|
|
|
43
233
|
## Versioning
|
|
44
234
|
|
|
45
235
|
The ZeroHash SDK uses [Semantic Versioning 2.0.0](https://semver.org/). Version numbers follow the `MAJOR.MINOR.PATCH` format:
|
|
46
236
|
|
|
47
|
-
- **MAJOR** version increments
|
|
48
|
-
- **MINOR** version increments
|
|
49
|
-
- **PATCH** version increments
|
|
237
|
+
- **MAJOR** version increments for incompatible API changes (e.g., `1.0.0` to `2.0.0`)
|
|
238
|
+
- **MINOR** version increments for backward-compatible new features (e.g., `1.0.0` to `1.1.0`)
|
|
239
|
+
- **PATCH** version increments for backward-compatible bug fixes (e.g., `1.0.0` to `1.0.1`)
|
|
240
|
+
|
|
241
|
+
## Documentation & Support
|
|
242
|
+
|
|
243
|
+
- **Full Documentation**: [ZeroHash SDK Documentation](https://docs.zerohash.com/reference/sdk-overview)
|
|
244
|
+
- **Changelog**: [ZeroHash Documentation Changelog](https://docs.zerohash.com/reference/changelog)
|
|
245
|
+
- **Mobile Usage**: See the [SDK Overview](https://docs.zerohash.com/reference/sdk-overview) for mobile implementation details
|
|
50
246
|
|
|
51
|
-
##
|
|
52
|
-
[zerohash Documentation Changelog](https://docs.zerohash.com/reference/changelog)
|
|
247
|
+
## License
|
|
53
248
|
|
|
54
|
-
|
|
55
|
-
For more details on how to use it on mobile apps, please refer to our full documentation:
|
|
56
|
-
[zerohash SDK Documentation](https://docs.zerohash.com/reference/sdk-overview).
|
|
249
|
+
MIT
|
package/dist/index.js
CHANGED
|
@@ -48,7 +48,7 @@ ${tP(d)}`),super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessa
|
|
|
48
48
|
The error may be correlated with this previous error:
|
|
49
49
|
${Mn.current.stack}
|
|
50
50
|
|
|
51
|
-
`),ln}Ys(()=>{Mn.current=void 0,me.current=void 0,V.current=yo});let cn=(0,pe.useMemo)(()=>pe.default.createElement(b,Do({},yo,{ref:A})),[A,b,yo]);return(0,pe.useMemo)(()=>x?pe.default.createElement(E.Provider,{value:K},cn):cn,[E,cn,K])}let T=pe.default.memo(w);if(T.WrappedComponent=b,T.displayName=w.displayName=m,u){let C=pe.default.forwardRef(function(I,E){return pe.default.createElement(T,Do({},I,{reactReduxForwardedRef:E}))});return C.displayName=m,C.WrappedComponent=b,(0,xg.default)(C,b)}return(0,xg.default)(T,b)}}var gg=A3;var Fc=ve(ft());function E3({store:e,context:t,children:r,serverState:n,stabilityCheck:o="once",noopCheck:i="once"}){let s=(0,Fc.useMemo)(()=>{let c=Xp(e);return{store:e,subscription:c,getServerState:n?()=>n:void 0,stabilityCheck:o,noopCheck:i}},[e,n,o,i]),a=(0,Fc.useMemo)(()=>e.getState(),[e]);Ys(()=>{let{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),a!==e.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,a]);let u=t||br;return Fc.default.createElement(u.Provider,{value:s},r)}var td=E3;_E(rS.useSyncExternalStoreWithSelector);eS(tS.useSyncExternalStore);EE(ig.unstable_batchedUpdates);var ki=ve(ft(),1),T3={sandbox:"https://sdk.sandbox.connect.xyz/auth-web/index.js",production:"https://sdk.connect.xyz/auth-web/index.js"},P3="connect-auth-script",nS="connect-auth",C3=(e="production")=>T3[e],oS=({jwt:e,env:t="production",theme:r,onError:n,onClose:o,onDeposit:i,onEvent:s,...
|
|
51
|
+
`),ln}Ys(()=>{Mn.current=void 0,me.current=void 0,V.current=yo});let cn=(0,pe.useMemo)(()=>pe.default.createElement(b,Do({},yo,{ref:A})),[A,b,yo]);return(0,pe.useMemo)(()=>x?pe.default.createElement(E.Provider,{value:K},cn):cn,[E,cn,K])}let T=pe.default.memo(w);if(T.WrappedComponent=b,T.displayName=w.displayName=m,u){let C=pe.default.forwardRef(function(I,E){return pe.default.createElement(T,Do({},I,{reactReduxForwardedRef:E}))});return C.displayName=m,C.WrappedComponent=b,(0,xg.default)(C,b)}return(0,xg.default)(T,b)}}var gg=A3;var Fc=ve(ft());function E3({store:e,context:t,children:r,serverState:n,stabilityCheck:o="once",noopCheck:i="once"}){let s=(0,Fc.useMemo)(()=>{let c=Xp(e);return{store:e,subscription:c,getServerState:n?()=>n:void 0,stabilityCheck:o,noopCheck:i}},[e,n,o,i]),a=(0,Fc.useMemo)(()=>e.getState(),[e]);Ys(()=>{let{subscription:c}=s;return c.onStateChange=c.notifyNestedSubs,c.trySubscribe(),a!==e.getState()&&c.notifyNestedSubs(),()=>{c.tryUnsubscribe(),c.onStateChange=void 0}},[s,a]);let u=t||br;return Fc.default.createElement(u.Provider,{value:s},r)}var td=E3;_E(rS.useSyncExternalStoreWithSelector);eS(tS.useSyncExternalStore);EE(ig.unstable_batchedUpdates);var ki=ve(ft(),1),T3={sandbox:"https://sdk.sandbox.connect.xyz/auth-web/index.js",production:"https://sdk.connect.xyz/auth-web/index.js"},P3="connect-auth-script",nS="connect-auth",C3=(e="production")=>T3[e],oS=({jwt:e,env:t="production",theme:r,onError:n,onClose:o,onDeposit:i,onEvent:s,onLoaded:a,...u})=>{let c=(0,ki.useRef)(null);return(0,ki.useEffect)(()=>{let l=c.current;l&&(n&&(l.onError=n),o&&(l.onClose=o),i&&(l.onDeposit=i),s&&(l.onEvent=s),a&&(l.onLoaded=a))},[n,o,i,s,a]),(0,ki.useEffect)(()=>{let l=C3(t),f=`${P3}-${t}`;if(document.getElementById(f))return;let p=document.createElement("script");p.id=f,p.src=l,p.type="module",p.async=!0,p.onerror=()=>{console.error(`Failed to load the script for ${nS} from ${t} environment.`)},document.head.appendChild(p)},[t]),ki.default.createElement(nS,{ref:c,jwt:e,env:t,theme:r,...u})};function iS(e){let t=(r,n)=>{window.postMessage({type:r,payload:n},e)};return{onLoaded:()=>{t("STYLE_CONFIG"),t("FUND_APP_LOADED")},onClose:()=>{t("FUND_CLOSE_BUTTON_CLICKED")},onDeposit:r=>{let n=_3(r.data.status.value),o={transactionId:r.data.depositId,fundId:r.data.depositId,assetId:r.data.assetId,networkId:r.data.networkId,amount:r.data.amount,status:r.data.status};t("FUND_CONNECT_DEPOSIT",o),t(n?"FUND_COMPLETED":"FUND_FAILED",o)},onError:r=>{t("STYLE_CONFIG"),t("FUND_ERROR",{errorCode:r.errorCode,reason:r.reason})},onEvent:r=>{r.type==="deposit.submitted"?t("FUND_DEPOSIT_SUBMITTED",{depositId:r.data.depositId}):t("FUND_CONNECT_EVENT",{type:r.type,data:r.data})}}}function _3(e){let t=["completed","success","confirmed","settled","processed"],r=["failed","rejected","cancelled","error"],n=e.toLowerCase();return t.includes(n)?!0:(r.includes(n),!1)}var B3=480,k3=720,sS=()=>{let e=navigator?.userAgent?.toLowerCase(),t=/iphone|ipad|ipod|android|webos|blackberry|windows phone/i.test(e),r="ontouchstart"in window||navigator?.maxTouchPoints>0;return t||r?0:24},Uc=[{id:"MTE_SM",size:B3},{id:"MTE_MD",size:k3}],aS=()=>{for(let e=0;e<Uc.length;e++){let{id:t,size:r}=Uc[e];if(window.matchMedia(`(min-width: ${r}px`).matches)return t}return"ANY"},bg={paddingRight:0,paddingLeft:0,marginRight:"auto",marginLeft:"auto",maxHeight:812},uS={MTE_SM:{width:480},MTE_MD:{width:720},ANY:{width:"100%",height:"100%",maxWidth:"100%",maxHeight:"100%"}},cS={position:"fixed",top:0,left:0,zIndex:999999,display:"flex",justifyContent:"center",alignItems:"center",flexDirection:"column",width:"100vw",height:CSS.supports("height: 100dvh")?"100dvh":window.innerHeight+"px",maxHeight:CSS.supports("height: 100dvh")?"100dvh":window.innerHeight+"px",background:"rgba(0,0,0,0.5)",cursor:"pointer"},lS={padding:0,backgroundColor:"#FFF",height:"calc(100% - 100px)",maxWidth:"calc(100% - 30px)",borderRadius:sS()},fS={width:"100%",height:"100%",border:"none",overflow:"hidden"},pS={width:"100%",height:"100%",border:"none",margin:0,padding:0,overflow:"hidden",borderRadius:sS()};var wg=e=>{gr(e,se,{isAppActive:!0})},Ye=e=>{gr(e,se,{isAppActive:!1})},Ht=e=>{gr(e,fe,{isAppLoaded:!0})},dS=e=>{gr(e,jA,{})},Bt=e=>{gr(e,WA,{})},kt=e=>{gr(e,VA,{})};var Mc=ve(ft()),mS=()=>{let[e,t]=(0,Mc.useState)(0),[r,n]=(0,Mc.useState)(0);return(0,Mc.useLayoutEffect)(()=>{function o(){n(window.innerWidth),t(window.innerHeight)}return window.addEventListener("resize",o),o(),()=>window.removeEventListener("resize",o)},[]),{height:e,width:r}};var hS=()=>window?!!window.WorldApp:!1;var yT=ve(kg(),1);var h6="0.1.1";function y6(){return h6}var Y=class e extends Error{constructor(t,r={}){let n=(()=>{if(r.cause instanceof e){if(r.cause.details)return r.cause.details;if(r.cause.shortMessage)return r.cause.shortMessage}return r.cause?.message?r.cause.message:r.details})(),o=r.cause instanceof e&&r.cause.docsPath||r.docsPath,s=`https://oxlib.sh${o??""}`,a=[t||"An error occurred.",...r.metaMessages?["",...r.metaMessages]:[],...n||o?["",n?`Details: ${n}`:void 0,o?`See: ${s}`:void 0]:[]].filter(u=>typeof u=="string").join(`
|
|
52
52
|
`);super(a,r.cause?{cause:r.cause}:void 0),Object.defineProperty(this,"details",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docs",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"docsPath",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"shortMessage",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"BaseError"}),Object.defineProperty(this,"version",{enumerable:!0,configurable:!0,writable:!0,value:`ox@${y6()}`}),this.cause=r.cause,this.details=n,this.docs=s,this.docsPath=o,this.shortMessage=t}walk(t){return x6(this,t)}};function x6(e,t){return t?.(e)?e:e&&typeof e=="object"&&"cause"in e&&e.cause?x6(e.cause,t):t?null:e}var il={};ms(il,{keccak256:()=>ol,ripemd160:()=>fI,sha256:()=>pI,validate:()=>dI});zg();eo();var Ck=Uint8Array.from([7,4,13,1,10,6,15,3,12,0,9,5,2,14,11,8]),S6=Uint8Array.from(new Array(16).fill(0).map((e,t)=>t)),_k=S6.map(e=>(9*e+5)%16),I6=(()=>{let r=[[S6],[_k]];for(let n=0;n<4;n++)for(let o of r)o.push(o[n].map(i=>Ck[i]));return r})(),T6=I6[0],P6=I6[1],C6=[[11,14,15,12,5,8,7,9,11,13,14,15,6,7,9,8],[12,13,11,15,6,9,9,7,12,15,11,13,7,8,7,7],[13,15,14,11,7,7,6,8,13,14,13,12,5,5,6,9],[14,11,12,14,8,6,5,5,15,12,15,14,9,9,8,6],[15,12,13,13,9,5,8,6,14,11,12,11,8,6,5,5]].map(e=>Uint8Array.from(e)),Bk=T6.map((e,t)=>e.map(r=>C6[t][r])),kk=P6.map((e,t)=>e.map(r=>C6[t][r])),Ok=Uint32Array.from([0,1518500249,1859775393,2400959708,2840853838]),Nk=Uint32Array.from([1352829926,1548603684,1836072691,2053994217,0]);function E6(e,t,r,n){return e===0?t^r^n:e===1?t&r|~t&n:e===2?(t|~r)^n:e===3?t&n|r&~n:t^(r|~n)}var Bd=new Uint32Array(16),kd=class extends aa{constructor(){super(64,20,8,!0),this.h0=1732584193,this.h1=-271733879,this.h2=-1732584194,this.h3=271733878,this.h4=-1009589776}get(){let{h0:t,h1:r,h2:n,h3:o,h4:i}=this;return[t,r,n,o,i]}set(t,r,n,o,i){this.h0=t|0,this.h1=r|0,this.h2=n|0,this.h3=o|0,this.h4=i|0}process(t,r){for(let d=0;d<16;d++,r+=4)Bd[d]=t.getUint32(r,!0);let n=this.h0|0,o=n,i=this.h1|0,s=i,a=this.h2|0,u=a,c=this.h3|0,l=c,f=this.h4|0,p=f;for(let d=0;d<5;d++){let x=4-d,g=Ok[d],b=Nk[d],h=T6[d],m=P6[d],y=Bk[d],w=kk[d];for(let v=0;v<16;v++){let T=jc(n+E6(d,i,a,c)+Bd[h[v]]+g,y[v])+f|0;n=f,f=c,c=jc(a,10)|0,a=i,i=T}for(let v=0;v<16;v++){let T=jc(o+E6(x,s,u,l)+Bd[m[v]]+b,w[v])+p|0;o=p,p=l,l=jc(u,10)|0,u=s,s=T}}this.set(this.h1+a+l|0,this.h2+c+p|0,this.h3+f+o|0,this.h4+n+s|0,this.h0+i+u|0)}roundClean(){ur(Bd)}destroy(){this.destroyed=!0,ur(this.buffer),this.set(0,0,0,0,0)}},_6=sa(()=>new kd);var B6=_6;Nd();jg();var Ld=Ui;var Yr={};ms(Yr,{InvalidBytesBooleanError:()=>Wd,InvalidBytesTypeError:()=>Wi,SizeExceedsPaddingSizeError:()=>Jc,SizeOverflowError:()=>Kc,SliceOffsetOutOfBoundsError:()=>ca,assert:()=>s1,concat:()=>sI,from:()=>ma,fromArray:()=>a1,fromBoolean:()=>aI,fromHex:()=>cr,fromNumber:()=>uI,fromString:()=>Vd,isEqual:()=>cI,padLeft:()=>u1,padRight:()=>c1,random:()=>jd,size:()=>Vt,slice:()=>Gd,toBigInt:()=>qd,toBoolean:()=>Yd,toHex:()=>lI,toNumber:()=>Sr,toString:()=>Kd,trimLeft:()=>nl,trimRight:()=>rl,validate:()=>Jd});Jg();var vn={};ms(vn,{IntegerOutOfRangeError:()=>Dd,InvalidHexBooleanError:()=>$d,InvalidHexTypeError:()=>Xc,InvalidHexValueError:()=>el,InvalidLengthError:()=>n1,SizeExceedsPaddingSizeError:()=>Qc,SizeOverflowError:()=>Zc,SliceOffsetOutOfBoundsError:()=>la,assert:()=>o1,concat:()=>Gt,from:()=>zd,fromBoolean:()=>fa,fromBytes:()=>Be,fromNumber:()=>gt,fromString:()=>pa,isEqual:()=>eI,padLeft:()=>Kr,padRight:()=>Ar,random:()=>tI,size:()=>Fe,slice:()=>Er,toBigInt:()=>tl,toBoolean:()=>nI,toBytes:()=>oI,toNumber:()=>Hd,toString:()=>iI,trimLeft:()=>i1,trimRight:()=>rI,validate:()=>da});Jg();var Zg="#__bigint";function Vk(e,t){return JSON.parse(e,(r,n)=>{let o=n;return typeof o=="string"&&o.endsWith(Zg)?BigInt(o.slice(0,-Zg.length)):typeof t=="function"?t(r,o):o})}Vk.parseError=e=>e;function Hi(e,t,r){return JSON.stringify(e,(n,o)=>typeof t=="function"?t(n,o):typeof o=="bigint"?o.toString()+Zg:o,r)}Hi.parseError=e=>e;function no(e,t){if(Vt(e)>t)throw new Kc({givenSize:Vt(e),maxSize:t})}function Y6(e,t){if(typeof t=="number"&&t>0&&t>Vt(e)-1)throw new ca({offset:t,position:"start",size:Vt(e)})}function K6(e,t,r){if(typeof t=="number"&&typeof r=="number"&&Vt(e)!==r-t)throw new ca({offset:r,position:"end",size:Vt(e)})}var ro={zero:48,nine:57,A:65,F:70,a:97,f:102};function Qg(e){if(e>=ro.zero&&e<=ro.nine)return e-ro.zero;if(e>=ro.A&&e<=ro.F)return e-(ro.A-10);if(e>=ro.a&&e<=ro.f)return e-(ro.a-10)}function Xg(e,t={}){let{dir:r,size:n=32}=t;if(n===0)return e;if(e.length>n)throw new Jc({size:e.length,targetSize:n,type:"Bytes"});let o=new Uint8Array(n);for(let i=0;i<n;i++){let s=r==="right";o[s?i:n-i-1]=e[s?i:e.length-i-1]}return o}function e1(e,t={}){let{dir:r="left"}=t,n=e,o=0;for(let i=0;i<n.length-1&&n[r==="left"?i:n.length-i-1].toString()==="0";i++)o++;return n=r==="left"?n.slice(o):n.slice(0,n.length-o),n}function ji(e,t){if(Fe(e)>t)throw new Zc({givenSize:Fe(e),maxSize:t})}function Z6(e,t){if(typeof t=="number"&&t>0&&t>Fe(e)-1)throw new la({offset:t,position:"start",size:Fe(e)})}function Q6(e,t,r){if(typeof t=="number"&&typeof r=="number"&&Fe(e)!==r-t)throw new la({offset:r,position:"end",size:Fe(e)})}function t1(e,t={}){let{dir:r,size:n=32}=t;if(n===0)return e;let o=e.replace("0x","");if(o.length>n*2)throw new Qc({size:Math.ceil(o.length/2),targetSize:n,type:"Hex"});return`0x${o[r==="right"?"padEnd":"padStart"](n*2,"0")}`}function r1(e,t={}){let{dir:r="left"}=t,n=e.replace("0x",""),o=0;for(let i=0;i<n.length-1&&n[r==="left"?i:n.length-i-1].toString()==="0";i++)o++;return n=r==="left"?n.slice(o):n.slice(0,n.length-o),n==="0"?"0x":r==="right"&&n.length%2===1?`0x${n}0`:`0x${n}`}var Gk=new TextEncoder,qk=Array.from({length:256},(e,t)=>t.toString(16).padStart(2,"0"));function o1(e,t={}){let{strict:r=!1}=t;if(!e)throw new Xc(e);if(typeof e!="string")throw new Xc(e);if(r&&!/^0x[0-9a-fA-F]*$/.test(e))throw new el(e);if(!e.startsWith("0x"))throw new el(e)}o1.parseError=e=>e;function Gt(...e){return`0x${e.reduce((t,r)=>t+r.replace("0x",""),"")}`}Gt.parseError=e=>e;function zd(e){return e instanceof Uint8Array?Be(e):Array.isArray(e)?Be(new Uint8Array(e)):e}zd.parseError=e=>e;function fa(e,t={}){let r=`0x${Number(e)}`;return typeof t.size=="number"?(ji(r,t.size),Kr(r,t.size)):r}fa.parseError=e=>e;function Be(e,t={}){let r="";for(let o=0;o<e.length;o++)r+=qk[e[o]];let n=`0x${r}`;return typeof t.size=="number"?(ji(n,t.size),Ar(n,t.size)):n}Be.parseError=e=>e;function gt(e,t={}){let{signed:r,size:n}=t,o=BigInt(e),i;n?r?i=(1n<<BigInt(n)*8n-1n)-1n:i=2n**(BigInt(n)*8n)-1n:typeof e=="number"&&(i=BigInt(Number.MAX_SAFE_INTEGER));let s=typeof i=="bigint"&&r?-i-1n:0;if(i&&o>i||o<s){let c=typeof e=="bigint"?"n":"";throw new Dd({max:i?`${i}${c}`:void 0,min:`${s}${c}`,signed:r,size:n,value:`${e}${c}`})}let u=`0x${(r&&o<0?(1n<<BigInt(n*8))+BigInt(o):o).toString(16)}`;return n?Kr(u,n):u}gt.parseError=e=>e;function pa(e,t={}){return Be(Gk.encode(e),t)}pa.parseError=e=>e;function eI(e,t){return Fd(cr(e),cr(t))}eI.parseError=e=>e;function Kr(e,t){return t1(e,{dir:"left",size:t})}Kr.parseError=e=>e;function Ar(e,t){return t1(e,{dir:"right",size:t})}Ar.parseError=e=>e;function tI(e){return Be(jd(e))}tI.parseError=e=>e;function Er(e,t,r,n={}){let{strict:o}=n;Z6(e,t);let i=`0x${e.replace("0x","").slice((t??0)*2,(r??e.length)*2)}`;return o&&Q6(i,t,r),i}Er.parseError=e=>e;function Fe(e){return Math.ceil((e.length-2)/2)}Fe.parseError=e=>e;function i1(e){return r1(e,{dir:"left"})}i1.parseError=e=>e;function rI(e){return r1(e,{dir:"right"})}rI.parseError=e=>e;function tl(e,t={}){let{signed:r}=t;t.size&&ji(e,t.size);let n=BigInt(e);if(!r)return n;let o=(e.length-2)/2,i=(1n<<BigInt(o)*8n)-1n,s=i>>1n;return n<=s?n:n-i-1n}tl.parseError=e=>e;function nI(e,t={}){t.size&&ji(e,t.size);let r=i1(e);if(r==="0x")return!1;if(r==="0x1")return!0;throw new $d(e)}nI.parseError=e=>e;function oI(e,t={}){return cr(e,t)}oI.parseError=e=>e;function Hd(e,t={}){let{signed:r,size:n}=t;return Number(!r&&!n?e:tl(e,t))}Hd.parseError=e=>e;function iI(e,t={}){let{size:r}=t,n=cr(e);return r&&(no(n,r),n=rl(n)),new TextDecoder().decode(n)}iI.parseError=e=>e;function da(e,t={}){let{strict:r=!1}=t;try{return o1(e,{strict:r}),!0}catch{return!1}}da.parseError=e=>e;var Dd=class extends Y{constructor({max:t,min:r,signed:n,size:o,value:i}){super(`Number \`${i}\` is not in safe${o?` ${o*8}-bit`:""}${n?" signed":" unsigned"} integer range ${t?`(\`${r}\` to \`${t}\`)`:`(above \`${r}\`)`}`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.IntegerOutOfRangeError"})}},$d=class extends Y{constructor(t){super(`Hex value \`"${t}"\` is not a valid boolean.`,{metaMessages:['The hex value must be `"0x0"` (false) or `"0x1"` (true).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexBooleanError"})}},Xc=class extends Y{constructor(t){super(`Value \`${typeof t=="object"?Hi(t):t}\` of type \`${typeof t}\` is an invalid hex type.`,{metaMessages:['Hex types must be represented as `"0x${string}"`.']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexTypeError"})}},el=class extends Y{constructor(t){super(`Value \`${t}\` is an invalid hex value.`,{metaMessages:['Hex values must start with `"0x"` and contain only hexadecimal characters (0-9, a-f, A-F).']}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidHexValueError"})}},n1=class extends Y{constructor(t){super(`Hex value \`"${t}"\` is an odd length (${t.length-2} nibbles).`,{metaMessages:["It must be an even length."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.InvalidLengthError"})}},Zc=class extends Y{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeOverflowError"})}},la=class extends Y{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SliceOffsetOutOfBoundsError"})}},Qc=class extends Y{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Hex.SizeExceedsPaddingSizeError"})}};var Yk=new TextDecoder,Kk=new TextEncoder;function s1(e){if(!(e instanceof Uint8Array)){if(!e)throw new Wi(e);if(typeof e!="object")throw new Wi(e);if(!("BYTES_PER_ELEMENT"in e))throw new Wi(e);if(e.BYTES_PER_ELEMENT!==1||e.constructor.name!=="Uint8Array")throw new Wi(e)}}s1.parseError=e=>e;function sI(...e){let t=0;for(let n of e)t+=n.length;let r=new Uint8Array(t);for(let n=0,o=0;n<e.length;n++){let i=e[n];r.set(i,o),o+=i.length}return r}sI.parseError=e=>e;function ma(e){return e instanceof Uint8Array?e:typeof e=="string"?cr(e):a1(e)}ma.parseError=e=>e;function a1(e){return e instanceof Uint8Array?e:new Uint8Array(e)}a1.parseError=e=>e;function aI(e,t={}){let{size:r}=t,n=new Uint8Array(1);return n[0]=Number(e),typeof r=="number"?(no(n,r),u1(n,r)):n}aI.parseError=e=>e;function cr(e,t={}){let{size:r}=t,n=e;r&&(ji(e,r),n=Ar(e,r));let o=n.slice(2);o.length%2&&(o=`0${o}`);let i=o.length/2,s=new Uint8Array(i);for(let a=0,u=0;a<i;a++){let c=Qg(o.charCodeAt(u++)),l=Qg(o.charCodeAt(u++));if(c===void 0||l===void 0)throw new Y(`Invalid byte sequence ("${o[u-2]}${o[u-1]}" in "${o}").`);s[a]=c*16+l}return s}cr.parseError=e=>e;function uI(e,t){let r=gt(e,t);return cr(r)}uI.parseError=e=>e;function Vd(e,t={}){let{size:r}=t,n=Kk.encode(e);return typeof r=="number"?(no(n,r),c1(n,r)):n}Vd.parseError=e=>e;function cI(e,t){return Fd(e,t)}cI.parseError=e=>e;function u1(e,t){return Xg(e,{dir:"left",size:t})}u1.parseError=e=>e;function c1(e,t){return Xg(e,{dir:"right",size:t})}c1.parseError=e=>e;function jd(e){return crypto.getRandomValues(new Uint8Array(e))}jd.parseError=e=>e;function Vt(e){return e.length}Vt.parseError=e=>e;function Gd(e,t,r,n={}){let{strict:o}=n;Y6(e,t);let i=e.slice(t,r);return o&&K6(i,t,r),i}Gd.parseError=e=>e;function qd(e,t={}){let{size:r}=t;typeof r<"u"&&no(e,r);let n=Be(e,t);return tl(n,t)}qd.parseError=e=>e;function Yd(e,t={}){let{size:r}=t,n=e;if(typeof r<"u"&&(no(n,r),n=nl(n)),n.length>1||n[0]>1)throw new Wd(n);return!!n[0]}Yd.parseError=e=>e;function lI(e,t={}){return Be(e,t)}lI.parseError=e=>e;function Sr(e,t={}){let{size:r}=t;typeof r<"u"&&no(e,r);let n=Be(e,t);return Hd(n,t)}Sr.parseError=e=>e;function Kd(e,t={}){let{size:r}=t,n=e;return typeof r<"u"&&(no(n,r),n=rl(n)),Yk.decode(n)}Kd.parseError=e=>e;function nl(e){return e1(e,{dir:"left"})}nl.parseError=e=>e;function rl(e){return e1(e,{dir:"right"})}rl.parseError=e=>e;function Jd(e){try{return s1(e),!0}catch{return!1}}Jd.parseError=e=>e;var Wd=class extends Y{constructor(t){super(`Bytes value \`${t}\` is not a valid boolean.`,{metaMessages:["The bytes array must contain a single byte of either a `0` or `1` value."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesBooleanError"})}},Wi=class extends Y{constructor(t){super(`Value \`${typeof t=="object"?Hi(t):t}\` of type \`${typeof t}\` is an invalid Bytes value.`,{metaMessages:["Bytes values must be of type `Bytes`."]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.InvalidBytesTypeError"})}},Kc=class extends Y{constructor({givenSize:t,maxSize:r}){super(`Size cannot exceed \`${r}\` bytes. Given size: \`${t}\` bytes.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeOverflowError"})}},ca=class extends Y{constructor({offset:t,position:r,size:n}){super(`Slice ${r==="start"?"starting":"ending"} at offset \`${t}\` is out-of-bounds (size: \`${n}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SliceOffsetOutOfBoundsError"})}},Jc=class extends Y{constructor({size:t,targetSize:r,type:n}){super(`${n.charAt(0).toUpperCase()}${n.slice(1).toLowerCase()} size (\`${t}\`) exceeds padding size (\`${r}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Bytes.SizeExceedsPaddingSizeError"})}};function ol(e,t={}){let{as:r=typeof e=="string"?"Hex":"Bytes"}=t,n=ua(ma(e));return r==="Bytes"?n:Be(n)}ol.parseError=e=>e;function fI(e,t={}){let{as:r=typeof e=="string"?"Hex":"Bytes"}=t,n=B6(ma(e));return r==="Bytes"?n:Be(n)}fI.parseError=e=>e;function pI(e,t={}){let{as:r=typeof e=="string"?"Hex":"Bytes"}=t,n=Ld(ma(e));return r==="Bytes"?n:Be(n)}pI.parseError=e=>e;function dI(e){return da(e)&&Fe(e)===32}dI.parseError=e=>e;var Zd=class extends Map{constructor(t){super(),Object.defineProperty(this,"maxSize",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.maxSize=t}get(t){let r=super.get(t);return super.has(t)&&r!==void 0&&(this.delete(t),super.set(t,r)),r}set(t,r){if(super.set(t,r),this.maxSize&&this.size>this.maxSize){let n=this.keys().next().value;n&&this.delete(n)}return this}};var Jk={checksum:new Zd(8192)},Qd=Jk.checksum;function hI(e,t={}){let{compressed:r}=t,{prefix:n,x:o,y:i}=e;if(r===!1||typeof o=="bigint"&&typeof i=="bigint"){if(n!==4)throw new Xd({prefix:n,cause:new p1});return}if(r===!0||typeof o=="bigint"&&typeof i>"u"){if(n!==3&&n!==2)throw new Xd({prefix:n,cause:new f1});return}throw new l1({publicKey:e})}function Zk(e){let{x:t,y:r}=e;return{prefix:r%2n===0n?2:3,x:t}}Zk.parseError=e=>e;function Qk(e){let t=(()=>{if(da(e))return m1(e);if(Jd(e))return yI(e);let{prefix:r,x:n,y:o}=e;return typeof n=="bigint"&&typeof o=="bigint"?{prefix:r??4,x:n,y:o}:{prefix:r,x:n}})();return hI(t),t}Qk.parseError=e=>e;function yI(e){return m1(Be(e))}yI.parseError=e=>e;function m1(e){if(e.length!==132&&e.length!==130&&e.length!==68)throw new d1({publicKey:e});if(e.length===130){let n=BigInt(Er(e,0,32)),o=BigInt(Er(e,32,64));return{prefix:4,x:n,y:o}}if(e.length===132){let n=Number(Er(e,0,1)),o=BigInt(Er(e,1,33)),i=BigInt(Er(e,33,65));return{prefix:n,x:o,y:i}}let t=Number(Er(e,0,1)),r=BigInt(Er(e,1,33));return{prefix:t,x:r}}m1.parseError=e=>e;function Xk(e,t={}){return cr(em(e,t))}Xk.parseError=e=>e;function em(e,t={}){hI(e);let{prefix:r,x:n,y:o}=e,{includePrefix:i=!0}=t;return Gt(i?gt(r,{size:1}):"0x",gt(n,{size:32}),typeof o=="bigint"?gt(o,{size:32}):"0x")}em.parseError=e=>e;var l1=class extends Y{constructor({publicKey:t}){super(`Value \`${Hi(t)}\` is not a valid public key.`,{metaMessages:["Public key must contain:","- an `x` and `prefix` value (compressed)","- an `x`, `y`, and `prefix` value (uncompressed)"]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidError"})}},Xd=class extends Y{constructor({prefix:t,cause:r}){super(`Prefix "${t}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidPrefixError"})}},f1=class extends Y{constructor(){super("Prefix must be 2 or 3 for compressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidCompressedPrefixError"})}},p1=class extends Y{constructor(){super("Prefix must be 4 for uncompressed public keys."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidUncompressedPrefixError"})}},d1=class extends Y{constructor({publicKey:t}){super(`Value \`${t}\` is an invalid public key size.`,{metaMessages:["Expected: 33 bytes (compressed + prefix), 64 bytes (uncompressed) or 65 bytes (uncompressed + prefix).",`Received ${Fe(zd(t))} bytes.`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"PublicKey.InvalidSerializedSizeError"})}};var eO=/^0x[a-fA-F0-9]{40}$/;function oo(e,t={}){let{strict:r=!0}=t;if(!eO.test(e))throw new tm({address:e,cause:new h1});if(r){if(e.toLowerCase()===e)return;if(x1(e)!==e)throw new tm({address:e,cause:new y1})}}oo.parseError=e=>e;function x1(e){if(Qd.has(e))return Qd.get(e);oo(e,{strict:!1});let t=e.substring(2).toLowerCase(),r=ol(Vd(t),{as:"Bytes"}),n=t.split("");for(let i=0;i<40;i+=2)r[i>>1]>>4>=8&&n[i]&&(n[i]=n[i].toUpperCase()),(r[i>>1]&15)>=8&&n[i+1]&&(n[i+1]=n[i+1].toUpperCase());let o=`0x${n.join("")}`;return Qd.set(e,o),o}x1.parseError=e=>e;function gI(e,t={}){let{checksum:r=!1}=t;return oo(e),r?x1(e):e}gI.parseError=e=>e;function tO(e,t={}){let r=ol(`0x${em(e).slice(4)}`).substring(26);return gI(`0x${r}`,t)}tO.parseError=e=>e;function rO(e,t){return oo(e,{strict:!1}),oo(t,{strict:!1}),e.toLowerCase()===t.toLowerCase()}rO.parseError=e=>e;var tm=class extends Y{constructor({address:t,cause:r}){super(`Address "${t}" is invalid.`,{cause:r}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidAddressError"})}},h1=class extends Y{constructor(){super("Address is not a 20 byte (40 hexadecimal character) value."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidInputError"})}},y1=class extends Y{constructor(){super("Address does not match its checksum counterpart."),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Address.InvalidChecksumError"})}};var cl={};ms(cl,{ArrayLengthMismatchError:()=>al,BytesSizeMismatchError:()=>ha,DataSizeTooSmallError:()=>om,InvalidArrayError:()=>ul,InvalidTypeError:()=>Gi,LengthMismatchError:()=>fl,ZeroDataError:()=>im,decode:()=>TI,encode:()=>PI,encodePacked:()=>ll,format:()=>CI,from:()=>_I});Hc();var bI=/^(.*)\[([0-9]*)\]$/,wI=/^bytes([1-9]|1[0-9]|2[0-9]|3[0-2])?$/,vI=/^(u?int)(8|16|24|32|40|48|56|64|72|80|88|96|104|112|120|128|136|144|152|160|168|176|184|192|200|208|216|224|232|240|248|256)?$/,Tz=2n**(8n-1n)-1n,Pz=2n**(16n-1n)-1n,Cz=2n**(24n-1n)-1n,_z=2n**(32n-1n)-1n,Bz=2n**(40n-1n)-1n,kz=2n**(48n-1n)-1n,Oz=2n**(56n-1n)-1n,Nz=2n**(64n-1n)-1n,Rz=2n**(72n-1n)-1n,Lz=2n**(80n-1n)-1n,Fz=2n**(88n-1n)-1n,Uz=2n**(96n-1n)-1n,Mz=2n**(104n-1n)-1n,Dz=2n**(112n-1n)-1n,$z=2n**(120n-1n)-1n,zz=2n**(128n-1n)-1n,Hz=2n**(136n-1n)-1n,jz=2n**(144n-1n)-1n,Wz=2n**(152n-1n)-1n,Vz=2n**(160n-1n)-1n,Gz=2n**(168n-1n)-1n,qz=2n**(176n-1n)-1n,Yz=2n**(184n-1n)-1n,Kz=2n**(192n-1n)-1n,Jz=2n**(200n-1n)-1n,Zz=2n**(208n-1n)-1n,Qz=2n**(216n-1n)-1n,Xz=2n**(224n-1n)-1n,e9=2n**(232n-1n)-1n,t9=2n**(240n-1n)-1n,r9=2n**(248n-1n)-1n,n9=2n**(256n-1n)-1n,o9=-(2n**(8n-1n)),i9=-(2n**(16n-1n)),s9=-(2n**(24n-1n)),a9=-(2n**(32n-1n)),u9=-(2n**(40n-1n)),c9=-(2n**(48n-1n)),l9=-(2n**(56n-1n)),f9=-(2n**(64n-1n)),p9=-(2n**(72n-1n)),d9=-(2n**(80n-1n)),m9=-(2n**(88n-1n)),h9=-(2n**(96n-1n)),y9=-(2n**(104n-1n)),x9=-(2n**(112n-1n)),g9=-(2n**(120n-1n)),b9=-(2n**(128n-1n)),w9=-(2n**(136n-1n)),v9=-(2n**(144n-1n)),A9=-(2n**(152n-1n)),E9=-(2n**(160n-1n)),S9=-(2n**(168n-1n)),I9=-(2n**(176n-1n)),T9=-(2n**(184n-1n)),P9=-(2n**(192n-1n)),C9=-(2n**(200n-1n)),_9=-(2n**(208n-1n)),B9=-(2n**(216n-1n)),k9=-(2n**(224n-1n)),O9=-(2n**(232n-1n)),N9=-(2n**(240n-1n)),R9=-(2n**(248n-1n)),L9=-(2n**(256n-1n)),F9=2n**8n-1n,U9=2n**16n-1n,M9=2n**24n-1n,D9=2n**32n-1n,$9=2n**40n-1n,z9=2n**48n-1n,H9=2n**56n-1n,j9=2n**64n-1n,W9=2n**72n-1n,V9=2n**80n-1n,G9=2n**88n-1n,q9=2n**96n-1n,Y9=2n**104n-1n,K9=2n**112n-1n,J9=2n**120n-1n,Z9=2n**128n-1n,Q9=2n**136n-1n,X9=2n**144n-1n,eH=2n**152n-1n,tH=2n**160n-1n,rH=2n**168n-1n,nH=2n**176n-1n,oH=2n**184n-1n,iH=2n**192n-1n,sH=2n**200n-1n,aH=2n**208n-1n,uH=2n**216n-1n,cH=2n**224n-1n,lH=2n**232n-1n,fH=2n**240n-1n,pH=2n**248n-1n,dH=2n**256n-1n;function Vi(e,t,{staticPosition:r}){let n=v1(t.type);if(n){let[o,i]=n;return oO(e,{...t,type:i},{length:o,staticPosition:r})}if(t.type==="tuple")return uO(e,t,{staticPosition:r});if(t.type==="address")return nO(e);if(t.type==="bool")return iO(e);if(t.type.startsWith("bytes"))return sO(e,t,{staticPosition:r});if(t.type.startsWith("uint")||t.type.startsWith("int"))return aO(e,t);if(t.type==="string")return cO(e,{staticPosition:r});throw new Gi(t.type)}var EI=32,b1=32;function nO(e){let t=e.readBytes(32);return[Be(Gd(t,-20)),32]}function oO(e,t,{length:r,staticPosition:n}){if(!r){let s=Sr(e.readBytes(b1)),a=n+s,u=a+EI;e.setPosition(a);let c=Sr(e.readBytes(EI)),l=sl(t),f=0,p=[];for(let d=0;d<c;++d){e.setPosition(u+(l?d*32:f));let[x,g]=Vi(e,t,{staticPosition:u});f+=g,p.push(x)}return e.setPosition(n+32),[p,32]}if(sl(t)){let s=Sr(e.readBytes(b1)),a=n+s,u=[];for(let c=0;c<r;++c){e.setPosition(a+c*32);let[l]=Vi(e,t,{staticPosition:a});u.push(l)}return e.setPosition(n+32),[u,32]}let o=0,i=[];for(let s=0;s<r;++s){let[a,u]=Vi(e,t,{staticPosition:n+o});o+=u,i.push(a)}return[i,o]}function iO(e){return[Yd(e.readBytes(32),{size:32}),32]}function sO(e,t,{staticPosition:r}){let[n,o]=t.type.split("bytes");if(!o){let s=Sr(e.readBytes(32));e.setPosition(r+s);let a=Sr(e.readBytes(32));if(a===0)return e.setPosition(r+32),["0x",32];let u=e.readBytes(a);return e.setPosition(r+32),[Be(u),32]}return[Be(e.readBytes(Number.parseInt(o),32)),32]}function aO(e,t){let r=t.type.startsWith("int"),n=Number.parseInt(t.type.split("int")[1]||"256"),o=e.readBytes(32);return[n>48?qd(o,{signed:r}):Sr(o,{signed:r}),32]}function uO(e,t,{staticPosition:r}){let n=t.components.length===0||t.components.some(({name:s})=>!s),o=n?[]:{},i=0;if(sl(t)){let s=Sr(e.readBytes(b1)),a=r+s;for(let u=0;u<t.components.length;++u){let c=t.components[u];e.setPosition(a+i);let[l,f]=Vi(e,c,{staticPosition:a});i+=f,o[n?u:c?.name]=l}return e.setPosition(r+32),[o,32]}for(let s=0;s<t.components.length;++s){let a=t.components[s],[u,c]=Vi(e,a,{staticPosition:r});o[n?s:a?.name]=u,i+=c}return[o,i]}function cO(e,{staticPosition:t}){let r=Sr(e.readBytes(32)),n=t+r;e.setPosition(n);let o=Sr(e.readBytes(32));if(o===0)return e.setPosition(t+32),["",32];let i=e.readBytes(o,32),s=Kd(nl(i));return e.setPosition(t+32),[s,32]}function SI({parameters:e,values:t}){let r=[];for(let n=0;n<e.length;n++)r.push(w1({parameter:e[n],value:t[n]}));return r}function w1({parameter:e,value:t}){let r=e,n=v1(r.type);if(n){let[o,i]=n;return fO(t,{length:o,parameter:{...r,type:i}})}if(r.type==="tuple")return yO(t,{parameter:r});if(r.type==="address")return lO(t);if(r.type==="bool")return dO(t);if(r.type.startsWith("uint")||r.type.startsWith("int")){let o=r.type.startsWith("int");return mO(t,{signed:o})}if(r.type.startsWith("bytes"))return pO(t,{type:r.type});if(r.type==="string")return hO(t);throw new Gi(r.type)}function rm(e){let t=0;for(let i=0;i<e.length;i++){let{dynamic:s,encoded:a}=e[i];s?t+=32:t+=Fe(a)}let r=[],n=[],o=0;for(let i=0;i<e.length;i++){let{dynamic:s,encoded:a}=e[i];s?(r.push(gt(t+o,{size:32})),n.push(a),o+=Fe(a)):r.push(a)}return Gt(...r,...n)}function lO(e){return oo(e,{strict:!1}),{dynamic:!1,encoded:Kr(e.toLowerCase())}}function fO(e,{length:t,parameter:r}){let n=t===null;if(!Array.isArray(e))throw new ul(e);if(!n&&e.length!==t)throw new al({expectedLength:t,givenLength:e.length,type:`${r.type}[${t}]`});let o=!1,i=[];for(let s=0;s<e.length;s++){let a=w1({parameter:r,value:e[s]});a.dynamic&&(o=!0),i.push(a)}if(n||o){let s=rm(i);if(n){let a=gt(i.length,{size:32});return{dynamic:!0,encoded:i.length>0?Gt(a,s):a}}if(o)return{dynamic:!0,encoded:s}}return{dynamic:!1,encoded:Gt(...i.map(({encoded:s})=>s))}}function pO(e,{type:t}){let[,r]=t.split("bytes"),n=Fe(e);if(!r){let o=e;return n%32!==0&&(o=Ar(o,Math.ceil((e.length-2)/2/32)*32)),{dynamic:!0,encoded:Gt(Kr(gt(n,{size:32})),o)}}if(n!==Number.parseInt(r))throw new ha({expectedSize:Number.parseInt(r),value:e});return{dynamic:!1,encoded:Ar(e)}}function dO(e){if(typeof e!="boolean")throw new Y(`Invalid boolean value: "${e}" (type: ${typeof e}). Expected: \`true\` or \`false\`.`);return{dynamic:!1,encoded:Kr(fa(e))}}function mO(e,{signed:t}){return{dynamic:!1,encoded:gt(e,{size:32,signed:t})}}function hO(e){let t=pa(e),r=Math.ceil(Fe(t)/32),n=[];for(let o=0;o<r;o++)n.push(Ar(Er(t,o*32,(o+1)*32)));return{dynamic:!0,encoded:Gt(Ar(gt(Fe(t),{size:32})),...n)}}function yO(e,{parameter:t}){let r=!1,n=[];for(let o=0;o<t.components.length;o++){let i=t.components[o],s=Array.isArray(e)?o:i.name,a=w1({parameter:i,value:e[s]});n.push(a),a.dynamic&&(r=!0)}return{dynamic:r,encoded:r?rm(n):Gt(...n.map(({encoded:o})=>o))}}function v1(e){let t=e.match(/^(.*)\[(\d+)?\]$/);return t?[t[2]?Number(t[2]):null,t[1]]:void 0}function sl(e){let{type:t}=e;if(t==="string"||t==="bytes"||t.endsWith("[]"))return!0;if(t==="tuple")return e.components?.some(sl);let r=v1(e.type);return!!(r&&sl({...e,type:r[1]}))}var gO={bytes:new Uint8Array,dataView:new DataView(new ArrayBuffer(0)),position:0,positionReadCount:new Map,recursiveReadCount:0,recursiveReadLimit:Number.POSITIVE_INFINITY,assertReadLimit(){if(this.recursiveReadCount>=this.recursiveReadLimit)throw new E1({count:this.recursiveReadCount+1,limit:this.recursiveReadLimit})},assertPosition(e){if(e<0||e>this.bytes.length-1)throw new A1({length:this.bytes.length,position:e})},decrementPosition(e){if(e<0)throw new nm({offset:e});let t=this.position-e;this.assertPosition(t),this.position=t},getReadCount(e){return this.positionReadCount.get(e||this.position)||0},incrementPosition(e){if(e<0)throw new nm({offset:e});let t=this.position+e;this.assertPosition(t),this.position=t},inspectByte(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectBytes(e,t){let r=t??this.position;return this.assertPosition(r+e-1),this.bytes.subarray(r,r+e)},inspectUint8(e){let t=e??this.position;return this.assertPosition(t),this.bytes[t]},inspectUint16(e){let t=e??this.position;return this.assertPosition(t+1),this.dataView.getUint16(t)},inspectUint24(e){let t=e??this.position;return this.assertPosition(t+2),(this.dataView.getUint16(t)<<8)+this.dataView.getUint8(t+2)},inspectUint32(e){let t=e??this.position;return this.assertPosition(t+3),this.dataView.getUint32(t)},pushByte(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushBytes(e){this.assertPosition(this.position+e.length-1),this.bytes.set(e,this.position),this.position+=e.length},pushUint8(e){this.assertPosition(this.position),this.bytes[this.position]=e,this.position++},pushUint16(e){this.assertPosition(this.position+1),this.dataView.setUint16(this.position,e),this.position+=2},pushUint24(e){this.assertPosition(this.position+2),this.dataView.setUint16(this.position,e>>8),this.dataView.setUint8(this.position+2,e&255),this.position+=3},pushUint32(e){this.assertPosition(this.position+3),this.dataView.setUint32(this.position,e),this.position+=4},readByte(){this.assertReadLimit(),this._touch();let e=this.inspectByte();return this.position++,e},readBytes(e,t){this.assertReadLimit(),this._touch();let r=this.inspectBytes(e);return this.position+=t??e,r},readUint8(){this.assertReadLimit(),this._touch();let e=this.inspectUint8();return this.position+=1,e},readUint16(){this.assertReadLimit(),this._touch();let e=this.inspectUint16();return this.position+=2,e},readUint24(){this.assertReadLimit(),this._touch();let e=this.inspectUint24();return this.position+=3,e},readUint32(){this.assertReadLimit(),this._touch();let e=this.inspectUint32();return this.position+=4,e},get remaining(){return this.bytes.length-this.position},setPosition(e){let t=this.position;return this.assertPosition(e),this.position=e,()=>this.position=t},_touch(){if(this.recursiveReadLimit===Number.POSITIVE_INFINITY)return;let e=this.getReadCount();this.positionReadCount.set(this.position,e+1),e>0&&this.recursiveReadCount++}};function II(e,{recursiveReadLimit:t=8192}={}){let r=Object.create(gO);return r.bytes=e,r.dataView=new DataView(e.buffer,e.byteOffset,e.byteLength),r.positionReadCount=new Map,r.recursiveReadLimit=t,r}var nm=class extends Y{constructor({offset:t}){super(`Offset \`${t}\` cannot be negative.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.NegativeOffsetError"})}},A1=class extends Y{constructor({length:t,position:r}){super(`Position \`${r}\` is out of bounds (\`0 < position < ${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.PositionOutOfBoundsError"})}},E1=class extends Y{constructor({count:t,limit:r}){super(`Recursive read limit of \`${r}\` exceeded (recursive read count: \`${t}\`).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"Cursor.RecursiveReadLimitExceededError"})}};function TI(e,t,r={}){let{as:n="Array"}=r,o=typeof t=="string"?cr(t):t,i=II(o);if(Vt(o)===0&&e.length>0)throw new im;if(Vt(o)&&Vt(o)<32)throw new om({data:typeof t=="string"?t:Be(t),parameters:e,size:Vt(o)});let s=0,a=n==="Array"?[]:{};for(let u=0;u<e.length;++u){let c=e[u];i.setPosition(s);let[l,f]=Vi(i,c,{staticPosition:0});s+=f,n==="Array"?a.push(l):a[c.name??u]=l}return a}TI.parseError=e=>e;function PI(e,t){if(e.length!==t.length)throw new fl({expectedLength:e.length,givenLength:t.length});let r=SI({parameters:e,values:t}),n=rm(r);return n.length===0?"0x":n}PI.parseError=e=>e;function ll(e,t){if(e.length!==t.length)throw new fl({expectedLength:e.length,givenLength:t.length});let r=[];for(let n=0;n<e.length;n++){let o=e[n],i=t[n];r.push(ll.encode(o,i))}return Gt(...r)}(function(e){function t(r,n,o=!1){if(r==="address"){let u=n;return oo(u),Kr(u.toLowerCase(),o?32:0)}if(r==="string")return pa(n);if(r==="bytes")return n;if(r==="bool")return Kr(fa(n),o?32:1);let i=r.match(vI);if(i){let[u,c,l="256"]=i,f=Number.parseInt(l)/8;return gt(n,{size:o?32:f,signed:c==="int"})}let s=r.match(wI);if(s){let[u,c]=s;if(Number.parseInt(c)!==(n.length-2)/2)throw new ha({expectedSize:Number.parseInt(c),value:n});return Ar(n,o?32:0)}let a=r.match(bI);if(a&&Array.isArray(n)){let[u,c]=a,l=[];for(let f=0;f<n.length;f++)l.push(t(c,n[f],!0));return l.length===0?"0x":Gt(...l)}throw new Gi(r)}e.encode=t})(ll||(ll={}));ll.parseError=e=>e;function CI(e){return bn(e)}CI.parseError=e=>e;function _I(e){return Array.isArray(e)&&typeof e[0]=="string"?Pd(e):typeof e=="string"?Pd(e):e}_I.parseError=e=>e;var om=class extends Y{constructor({data:t,parameters:r,size:n}){super(`Data size of ${n} bytes is too small for given parameters.`,{metaMessages:[`Params: (${bn(r)})`,`Data: ${t} (${n} bytes)`]}),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.DataSizeTooSmallError"})}},im=class extends Y{constructor(){super('Cannot decode zero data ("0x") with ABI parameters.'),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ZeroDataError"})}},al=class extends Y{constructor({expectedLength:t,givenLength:r,type:n}){super(`Array length mismatch for type \`${n}\`. Expected: \`${t}\`. Given: \`${r}\`.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.ArrayLengthMismatchError"})}},ha=class extends Y{constructor({expectedSize:t,value:r}){super(`Size of bytes "${r}" (bytes${Fe(r)}) does not match expected size (bytes${t}).`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.BytesSizeMismatchError"})}},fl=class extends Y{constructor({expectedLength:t,givenLength:r}){super(["ABI encoding parameters/values length mismatch.",`Expected length (parameters): ${t}`,`Given length (values): ${r}`].join(`
|
|
53
53
|
`)),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.LengthMismatchError"})}},ul=class extends Y{constructor(t){super(`Value \`${t}\` is not a valid array.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidArrayError"})}},Gi=class extends Y{constructor(t){super(`Type \`${t}\` is not a valid ABI Type.`),Object.defineProperty(this,"name",{enumerable:!0,configurable:!0,writable:!0,value:"AbiParameters.InvalidTypeError"})}};function $1(e){return Yr.validate(e)||vn.validate(e)?z1(e):GO(e)}function xT(e){let[t,r]=e.reduce(([n,o],[i,s])=>(n.push(i),o.push(s),[n,o]),[[],[]]);return z1(cl.encodePacked(t,r))}function GO(e){let t=yT.Buffer.from(e);return z1(t)}function z1(e){let t=BigInt(il.keccak256(e,{as:"Hex"}))>>8n,r=t.toString(16);return{hash:t,digest:`0x${r.padStart(64,"0")}`}}var hl=e=>!e||typeof e=="string"?$1(e??""):xT(e.types.map((t,r)=>[t,e.values[r]])),yl=e=>e?typeof e=="string"?e:e.types.map((t,r)=>`${t}(${e.values[r]})`).join(","):"";var gT=e=>{let t,r=new Set,n=(l,f)=>{let p=typeof l=="function"?l(t):l;if(!Object.is(p,t)){let d=t;t=f??(typeof p!="object"||p===null)?p:Object.assign({},t,p),r.forEach(x=>x(t,d))}},o=()=>t,u={setState:n,getState:o,getInitialState:()=>c,subscribe:l=>(r.add(l),()=>r.delete(l)),destroy:()=>{(import.meta.env?import.meta.env.MODE:void 0)!=="production"&&console.warn("[DEPRECATED] The `destroy` method will be unsupported in a future version. Instead use unsubscribe function returned by subscribe. Everything will be garbage-collected if store is garbage-collected."),r.clear()}},c=t=e(n,o,u);return u},bT=e=>e?gT(e):gT;var AT=ve(ft(),1),ET=ve(og(),1),{useDebugValue:qO}=AT.default,{useSyncExternalStoreWithSelector:YO}=ET.default,wT=!1,KO=e=>e;function JO(e,t=KO,r){(import.meta.env?import.meta.env.MODE:void 0)!=="production"&&r&&!wT&&(console.warn("[DEPRECATED] Use `createWithEqualityFn` instead of `create` or use `useStoreWithEqualityFn` instead of `useStore`. They can be imported from 'zustand/traditional'. https://github.com/pmndrs/zustand/discussions/1937"),wT=!0);let n=YO(e.subscribe,e.getState,e.getServerState||e.getInitialState,t,r);return qO(n),n}var vT=e=>{(import.meta.env?import.meta.env.MODE:void 0)!=="production"&&typeof e!="function"&&console.warn("[DEPRECATED] Passing a vanilla store will be unsupported in a future version. Instead use `import { useStore } from 'zustand'`.");let t=typeof e=="function"?bT(e):e,r=(n,o)=>JO(t,n,o);return Object.assign(r,t),r},ST=e=>e?vT(e):vT;var H1=typeof window<"u"&&typeof window.document<"u",j7=typeof process<"u"&&process.versions!=null&&process.versions.node!=null,W7=typeof self=="object"&&self.constructor&&self.constructor.name==="DedicatedWorkerGlobalScope",V7=typeof window<"u"&&window.name==="nodejs"||typeof navigator<"u"&&"userAgent"in navigator&&typeof navigator.userAgent=="string"&&(navigator.userAgent.includes("Node.js")||navigator.userAgent.includes("jsdom")),G7=typeof Deno<"u"&&typeof Deno.version<"u"&&typeof Deno.version.deno<"u";var j1=ve(kg(),1),Rt=(e=>(e.ConnectionFailed="connection_failed",e.VerificationRejected="verification_rejected",e.MaxVerificationsReached="max_verifications_reached",e.CredentialUnavailable="credential_unavailable",e.MalformedRequest="malformed_request",e.InvalidNetwork="invalid_network",e.InclusionProofFailed="inclusion_proof_failed",e.InclusionProofPending="inclusion_proof_pending",e.UnexpectedResponse="unexpected_response",e.FailedByHostApp="failed_by_host_app",e.GenericError="generic_error",e))(Rt||{});var Aa=(e=>(e.Orb="orb",e.SecureDocument="secure_document",e.Document="document",e.Device="device",e))(Aa||{});function ZO(e,t){try{new URL(e)}catch{return{valid:!1,errors:["Failed to parse Bridge URL."]}}let r=new URL(e),n=[];return t&&["localhost","127.0.0.1"].includes(r.hostname)?(console.log("Using staging app_id with localhost bridge_url. Skipping validation."),{valid:!0}):(r.protocol!=="https:"&&n.push("Bridge URL must use HTTPS."),r.port&&n.push("Bridge URL must use the default port (443)."),r.pathname!=="/"&&n.push("Bridge URL must not have a path."),r.search&&n.push("Bridge URL must not have query parameters."),r.hash&&n.push("Bridge URL must not have a fragment."),!r.hostname.endsWith(".worldcoin.org")&&!r.hostname.endsWith(".toolsforhumanity.com")&&console.warn("Bridge URL should be a subdomain of worldcoin.org or toolsforhumanity.com. The user's identity wallet may refuse to connect. This is a temporary measure and may be removed in the future."),n.length?{valid:!1,errors:n}:{valid:!0})}var QO=()=>typeof navigator<"u"&&navigator.product==="ReactNative",XO=()=>H1,eN=()=>{if(typeof globalThis<"u")return globalThis;if(typeof self<"u")return self;if(typeof window<"u")return window;throw new Error("Unable to locate global object")},fm=()=>{let e=eN();if(typeof e.crypto<"u")return e.crypto;throw new Error("Crypto API not available. For React Native, ensure polyfills are set up properly.")},IT="orb",va=e=>j1.Buffer.from(e).toString("base64"),W1=e=>j1.Buffer.from(e,"base64"),tN=e=>{switch(e){case"device":return["orb","device"];case"document":return["document","secure_document","orb"];case"secure_document":return["secure_document","orb"];case"orb":return["orb"];default:throw new Error(`Unknown verification level: ${e}`)}},rN=e=>{switch(e){case"orb":return"orb";case"secure_document":return"secure_document";case"document":return"document";case"device":return"device";default:throw new Error(`Unknown credential_type: ${e}`)}},nN=class{constructor(){this.encoder=new TextEncoder,this.decoder=new TextDecoder}async generateKey(){return{iv:window.crypto.getRandomValues(new Uint8Array(12)),key:await window.crypto.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}}async exportKey(e){return va(await window.crypto.subtle.exportKey("raw",e))}async encryptRequest(e,t,r){return{iv:va(t),payload:va(await window.crypto.subtle.encrypt({name:"AES-GCM",iv:t},e,this.encoder.encode(r)))}}async decryptResponse(e,t,r){return this.decoder.decode(await window.crypto.subtle.decrypt({name:"AES-GCM",iv:t},e,W1(r)))}},oN=class{constructor(){this.encoder=new TextEncoder,this.decoder=new TextDecoder}async generateKey(){let e=fm();return{iv:e.getRandomValues(new Uint8Array(12)),key:await e.subtle.generateKey({name:"AES-GCM",length:256},!0,["encrypt","decrypt"])}}async exportKey(e){let t=fm();return va(await t.subtle.exportKey("raw",e))}async encryptRequest(e,t,r){let n=fm();return{iv:va(t),payload:va(await n.subtle.encrypt({name:"AES-GCM",iv:t},e,this.encoder.encode(r)))}}async decryptResponse(e,t,r){let n=fm();return this.decoder.decode(await n.subtle.decrypt({name:"AES-GCM",iv:t},e,W1(r)))}},wa=null,dm=()=>{if(wa)return wa;if(XO())return wa=new nN,wa;if(QO())return wa=new oN,wa;throw new Error("Unsupported platform")},iN=async()=>dm().generateKey(),sN=async e=>dm().exportKey(e),aN=async(e,t,r)=>dm().encryptRequest(e,t,r),uN=async(e,t,r)=>dm().decryptResponse(e,t,r),pm="https://bridge.worldcoin.org",cN=(e,t)=>({iv:null,key:null,result:null,errorCode:null,requestId:null,connectorURI:null,bridge_url:pm,verificationState:"loading_widget",createClient:async({bridge_url:r,app_id:n,verification_level:o,action_description:i,action:s,signal:a,partner:u})=>{let{key:c,iv:l}=await iN();if(r){let d=ZO(r,n.includes("staging"));if(!d.valid)throw console.error(d.errors.join(`
|
|
54
54
|
`)),e({verificationState:"failed"}),new Error("Invalid bridge_url. Please check the console for more details.")}let f=await fetch(new URL("/request",r??pm),{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(await aN(c,l,JSON.stringify({app_id:n,action_description:i,action:yl(s),signal:hl(a).digest,credential_types:tN(o??IT),verification_level:o??IT})))});if(!f.ok)throw e({verificationState:"failed"}),new Error("Failed to create client");let{request_id:p}=await f.json();e({iv:l,key:c,requestId:p,bridge_url:r??pm,verificationState:"awaiting_connection",connectorURI:`https://world.org/verify?t=wld&i=${p}&k=${encodeURIComponent(await sN(c))}${r&&r!==pm?`&b=${encodeURIComponent(r)}`:""}${u?`&partner=${encodeURIComponent(!0)}`:""}`})},pollForUpdates:async()=>{let r=t().key;if(!r)throw new Error("No keypair found. Please call `createClient` first.");let n=await fetch(new URL(`/response/${t().requestId}`,t().bridge_url));if(!n.ok)return e({errorCode:"connection_failed",verificationState:"failed"});let{response:o,status:i}=await n.json();if(i!="completed")return e({verificationState:i=="retrieved"?"awaiting_app":"awaiting_connection"});let s=JSON.parse(await uN(r,W1(o.iv),o.payload));if("error_code"in s)return e({errorCode:s.error_code,verificationState:"failed"});"credential_type"in s&&(s={verification_level:rN(s.credential_type),...s}),e({result:s,key:null,requestId:null,connectorURI:null,verificationState:"confirmed"})},reset:()=>{e({iv:null,key:null,result:null,errorCode:null,requestId:null,connectorURI:null,verificationState:"loading_widget"})}}),Q7=ST(cN);function D(e,t,r){let n=e[t.name];if(typeof n=="function")return n;let o=e[r];return typeof o=="function"?o:i=>t(e,i)}ke();Z();var Tm=class extends S{constructor(t){super(`Filter type "${t}" is not supported.`,{name:"FilterTypeNotSupportedError"})}};rt();en();Il();tn();uo();ti();var $T="/docs/contract/encodeEventTopics";function In(e){let{abi:t,eventName:r,args:n}=e,o=t[0];if(r){let u=Kt({abi:t,name:r});if(!u)throw new wl(r,{docsPath:$T});o=u}if(o.type!=="event")throw new wl(void 0,{docsPath:$T});let i=Ke(o),s=Qo(i),a=[];if(n&&"inputs"in o){let u=o.inputs?.filter(l=>"indexed"in l&&l.indexed),c=Array.isArray(n)?n:Object.values(n).length>0?u?.map(l=>n[l.name])??[]:[];c.length>0&&(a=u?.map((l,f)=>Array.isArray(c[f])?c[f].map((p,d)=>zT({param:l,value:c[f][d]})):typeof c[f]<"u"&&c[f]!==null?zT({param:l,value:c[f]}):null)??[])}return[s,...a]}function zT({param:e,value:t}){if(e.type==="string"||e.type==="bytes")return de(Pr(t));if(e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/))throw new Tm(e.type);return je([e],[t])}G();function ri(e,{method:t}){let r={};return e.transport.type==="fallback"&&e.transport.onResponse?.(({method:n,response:o,status:i,transport:s})=>{i==="success"&&t===n&&(r[o]=s.request)}),n=>r[n]||e.request}async function Fm(e,t){let{address:r,abi:n,args:o,eventName:i,fromBlock:s,strict:a,toBlock:u}=t,c=ri(e,{method:"eth_newFilter"}),l=i?In({abi:n,args:o,eventName:i}):void 0,f=await e.request({method:"eth_newFilter",params:[{address:r,fromBlock:typeof s=="bigint"?O(s):s,toBlock:typeof u=="bigint"?O(u):u,topics:l}]});return{abi:n,args:o,eventName:i,id:f,request:c(f),strict:!!a,type:"event"}}Br();rn();ke();Z();ni();rs();Ol();var UN=3;function nn(e,{abi:t,address:r,args:n,docsPath:o,functionName:i,sender:s}){let a=e instanceof Cn?e:e instanceof S?e.walk(x=>"data"in x)||e.walk():{},{code:u,data:c,details:l,message:f,shortMessage:p}=a,d=e instanceof Tr?new Xm({functionName:i}):[UN,fo.code].includes(u)&&(c||l||f||p)?new ts({abi:t,data:typeof c=="object"?c.data:c,functionName:i,message:a instanceof oi?l:p??f}):e;return new Qm(d,{abi:t,args:n,contractAddress:r,docsPath:o,functionName:i,sender:s})}Br();Z();Tl();en();function nP(e){let t=de(`0x${e.substring(4)}`).substring(26);return Xi(`0x${t}`)}Jr();Ir();vt();G();async function iP({hash:e,signature:t}){let r=Ue(e)?e:we(e),{secp256k1:n}=await Promise.resolve().then(()=>(D1(),hT));return`0x${(()=>{if(typeof t=="object"&&"r"in t&&"s"in t){let{r:c,s:l,v:f,yParity:p}=t,d=Number(p??f),x=oP(d);return new n.Signature(Pe(c),Pe(l)).addRecoveryBit(x)}let s=Ue(t)?t:we(t);if(Q(s)!==65)throw new Error("invalid signature length");let a=He(`0x${s.slice(130)}`),u=oP(a);return n.Signature.fromCompact(s.substring(2,130)).addRecoveryBit(u)})().recoverPublicKey(r.substring(2)).toHex(!1)}`}function oP(e){if(e===0||e===1)return e;if(e===27)return 0;if(e===28)return 1;throw new Error("Invalid yParityOrV value")}async function rh({hash:e,signature:t}){return nP(await iP({hash:e,signature:t}))}Yt();rt();G();Z();$m();rt();G();function on(e,t="hex"){let r=sP(e),n=Oa(new Uint8Array(r.length));return r.encode(n),t==="hex"?te(n.bytes):n.bytes}function sP(e){return Array.isArray(e)?MN(e.map(t=>sP(t))):DN(e)}function MN(e){let t=e.reduce((o,i)=>o+i.length,0),r=aP(t);return{length:t<=55?1+t:1+r+t,encode(o){t<=55?o.pushByte(192+t):(o.pushByte(247+r),r===1?o.pushUint8(t):r===2?o.pushUint16(t):r===3?o.pushUint24(t):o.pushUint32(t));for(let{encode:i}of e)i(o)}}}function DN(e){let t=typeof e=="string"?Je(e):e,r=aP(t.length);return{length:t.length===1&&t[0]<128?1:t.length<=55?1+t.length:1+r+t.length,encode(o){t.length===1&&t[0]<128?o.pushBytes(t):t.length<=55?(o.pushByte(128+t.length),o.pushBytes(t)):(o.pushByte(183+r),r===1?o.pushUint8(t.length):r===2?o.pushUint16(t.length):r===3?o.pushUint24(t.length):o.pushUint32(t.length),o.pushBytes(t))}}}function aP(e){if(e<2**8)return 1;if(e<2**16)return 2;if(e<2**24)return 3;if(e<2**32)return 4;throw new S("Length is too large.")}en();function uP(e){let{chainId:t,nonce:r,to:n}=e,o=e.contractAddress??e.address,i=de(nt(["0x05",on([t?O(t):"0x",o,r?O(r):"0x"])]));return n==="bytes"?Je(i):i}async function cP(e){let{authorization:t,signature:r}=e;return rh({hash:uP(t),signature:r??t})}G();lb();Bl();Z();Pn();var nh=class extends S{constructor(t,{account:r,docsPath:n,chain:o,data:i,gas:s,gasPrice:a,maxFeePerGas:u,maxPriorityFeePerGas:c,nonce:l,to:f,value:p}){let d=Ua({from:r?.address,to:f,value:typeof p<"u"&&`${jm(p)} ${o?.nativeCurrency?.symbol||"ETH"}`,data:i,gas:s,gasPrice:typeof a<"u"&&`${Lt(a)} gwei`,maxFeePerGas:typeof u<"u"&&`${Lt(u)} gwei`,maxPriorityFeePerGas:typeof c<"u"&&`${Lt(c)} gwei`,nonce:l});super(t.shortMessage,{cause:t,docsPath:n,metaMessages:[...t.metaMessages?[...t.metaMessages," "]:[],"Estimate Gas Arguments:",d].filter(Boolean),name:"EstimateGasExecutionError"}),Object.defineProperty(this,"cause",{enumerable:!0,configurable:!0,writable:!0,value:void 0}),this.cause=t}};is();oh();function lP(e,{docsPath:t,...r}){let n=(()=>{let o=du(e,r);return o instanceof kn?e:o})();return new nh(n,{docsPath:t,...r})}ih();Nl();ah();gu();Br();Bl();Z();var uh=class extends S{constructor(){super("`baseFeeMultiplier` must be greater than 1.",{name:"BaseFeeScalarError"})}},ai=class extends S{constructor(){super("Chain does not support EIP-1559 fees.",{name:"Eip1559FeesNotSupportedError"})}},ch=class extends S{constructor({maxPriorityFeePerGas:t}){super(`\`maxFeePerGas\` cannot be less than the \`maxPriorityFeePerGas\` (${Lt(t)} gwei).`,{name:"MaxFeePerGasTooLowError"})}};vt();Z();var bu=class extends S{constructor({blockHash:t,blockNumber:r}){let n="Block";t&&(n=`Block at hash "${t}"`),r&&(n=`Block at number "${r}"`),super(`${n} could not be found.`,{name:"BlockNotFoundError"})}};G();sh();vt();sh();var db={"0x0":"legacy","0x1":"eip2930","0x2":"eip1559","0x3":"eip4844","0x4":"eip7702"};function ss(e){let t={...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,chainId:e.chainId?He(e.chainId):void 0,gas:e.gas?BigInt(e.gas):void 0,gasPrice:e.gasPrice?BigInt(e.gasPrice):void 0,maxFeePerBlobGas:e.maxFeePerBlobGas?BigInt(e.maxFeePerBlobGas):void 0,maxFeePerGas:e.maxFeePerGas?BigInt(e.maxFeePerGas):void 0,maxPriorityFeePerGas:e.maxPriorityFeePerGas?BigInt(e.maxPriorityFeePerGas):void 0,nonce:e.nonce?He(e.nonce):void 0,to:e.to?e.to:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,type:e.type?db[e.type]:void 0,typeHex:e.type?e.type:void 0,value:e.value?BigInt(e.value):void 0,v:e.v?BigInt(e.v):void 0};return e.authorizationList&&(t.authorizationList=jN(e.authorizationList)),t.yParity=(()=>{if(e.yParity)return Number(e.yParity);if(typeof t.v=="bigint"){if(t.v===0n||t.v===27n)return 0;if(t.v===1n||t.v===28n)return 1;if(t.v>=35n)return t.v%2n===0n?1:0}})(),t.type==="legacy"&&(delete t.accessList,delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas,delete t.yParity),t.type==="eip2930"&&(delete t.maxFeePerBlobGas,delete t.maxFeePerGas,delete t.maxPriorityFeePerGas),t.type==="eip1559"&&delete t.maxFeePerBlobGas,t}var pP=hu("transaction",ss);function jN(e){return e.map(t=>({address:t.address,chainId:Number(t.chainId),nonce:Number(t.nonce),r:t.r,s:t.s,yParity:Number(t.yParity)}))}function Rl(e){let t=(e.transactions??[]).map(r=>typeof r=="string"?r:ss(r));return{...e,baseFeePerGas:e.baseFeePerGas?BigInt(e.baseFeePerGas):null,blobGasUsed:e.blobGasUsed?BigInt(e.blobGasUsed):void 0,difficulty:e.difficulty?BigInt(e.difficulty):void 0,excessBlobGas:e.excessBlobGas?BigInt(e.excessBlobGas):void 0,gasLimit:e.gasLimit?BigInt(e.gasLimit):void 0,gasUsed:e.gasUsed?BigInt(e.gasUsed):void 0,hash:e.hash?e.hash:null,logsBloom:e.logsBloom?e.logsBloom:null,nonce:e.nonce?e.nonce:null,number:e.number?BigInt(e.number):null,size:e.size?BigInt(e.size):void 0,timestamp:e.timestamp?BigInt(e.timestamp):void 0,transactions:t,totalDifficulty:e.totalDifficulty?BigInt(e.totalDifficulty):null}}var dP=hu("block",Rl);async function Et(e,{blockHash:t,blockNumber:r,blockTag:n,includeTransactions:o}={}){let i=n??"latest",s=o??!1,a=r!==void 0?O(r):void 0,u=null;if(t?u=await e.request({method:"eth_getBlockByHash",params:[t,s]},{dedupe:!0}):u=await e.request({method:"eth_getBlockByNumber",params:[a||i,s]},{dedupe:!!a}),!u)throw new bu({blockHash:t,blockNumber:r});return(e.chain?.formatters?.block?.format||Rl)(u)}async function wu(e){let t=await e.request({method:"eth_gasPrice"});return BigInt(t)}async function mP(e,t){return mb(e,t)}async function mb(e,t){let{block:r,chain:n=e.chain,request:o}=t||{};try{let i=n?.fees?.maxPriorityFeePerGas??n?.fees?.defaultPriorityFee;if(typeof i=="function"){let a=r||await D(e,Et,"getBlock")({}),u=await i({block:a,client:e,request:o});if(u===null)throw new Error;return u}if(typeof i<"u")return i;let s=await e.request({method:"eth_maxPriorityFeePerGas"});return Pe(s)}catch{let[i,s]=await Promise.all([r?Promise.resolve(r):D(e,Et,"getBlock")({}),D(e,wu,"getGasPrice")({})]);if(typeof i.baseFeePerGas!="bigint")throw new ai;let a=s-i.baseFeePerGas;return a<0n?0n:a}}async function hP(e,t){return lh(e,t)}async function lh(e,t){let{block:r,chain:n=e.chain,request:o,type:i="eip1559"}=t||{},s=await(async()=>typeof n?.fees?.baseFeeMultiplier=="function"?n.fees.baseFeeMultiplier({block:r,client:e,request:o}):n?.fees?.baseFeeMultiplier??1.2)();if(s<1)throw new uh;let u=10**(s.toString().split(".")[1]?.length??0),c=p=>p*BigInt(Math.ceil(s*u))/BigInt(u),l=r||await D(e,Et,"getBlock")({});if(typeof n?.fees?.estimateFeesPerGas=="function"){let p=await n.fees.estimateFeesPerGas({block:r,client:e,multiply:c,request:o,type:i});if(p!==null)return p}if(i==="eip1559"){if(typeof l.baseFeePerGas!="bigint")throw new ai;let p=typeof o?.maxPriorityFeePerGas=="bigint"?o.maxPriorityFeePerGas:await mb(e,{block:l,chain:n,request:o}),d=c(l.baseFeePerGas);return{maxFeePerGas:o?.maxFeePerGas??d+p,maxPriorityFeePerGas:p}}return{gasPrice:o?.gasPrice??c(await D(e,wu,"getGasPrice")({}))}}vt();G();async function fh(e,{address:t,blockTag:r="latest",blockNumber:n}){let o=await e.request({method:"eth_getTransactionCount",params:[t,typeof n=="bigint"?O(n):r]},{dedupe:!!n});return He(o)}rt();G();function vu(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(i=>Je(i)):e.blobs,o=[];for(let i of n)o.push(Uint8Array.from(t.blobToKzgCommitment(i)));return r==="bytes"?o:o.map(i=>te(i))}rt();G();function Au(e){let{kzg:t}=e,r=e.to??(typeof e.blobs[0]=="string"?"hex":"bytes"),n=typeof e.blobs[0]=="string"?e.blobs.map(s=>Je(s)):e.blobs,o=typeof e.commitments[0]=="string"?e.commitments.map(s=>Je(s)):e.commitments,i=[];for(let s=0;s<n.length;s++){let a=n[s],u=o[s];i.push(Uint8Array.from(t.computeBlobKzgProof(a,u)))}return r==="bytes"?i:i.map(s=>te(s))}G();Jr();rt();G();function yP(e,t){let r=t||"hex",n=Ld(Ue(e,{strict:!1})?Pr(e):e);return r==="bytes"?n:we(n)}function xP(e){let{commitment:t,version:r=1}=e,n=e.to??(typeof t=="string"?"hex":"bytes"),o=yP(t,"bytes");return o.set([r],0),n==="bytes"?o:te(o)}function ph(e){let{commitments:t,version:r}=e,n=e.to??(typeof t[0]=="string"?"hex":"bytes"),o=[];for(let i of t)o.push(xP({commitment:i,to:n,version:r}));return o}Z();var dh=class extends S{constructor({maxSize:t,size:r}){super("Blob size is too large.",{metaMessages:[`Max: ${t} bytes`,`Given: ${r} bytes`],name:"BlobSizeTooLargeError"})}},Eu=class extends S{constructor(){super("Blob data must not be empty.",{name:"EmptyBlobError"})}},mh=class extends S{constructor({hash:t,size:r}){super(`Versioned hash "${t}" size is invalid.`,{metaMessages:["Expected: 32",`Received: ${r}`],name:"InvalidVersionedHashSizeError"})}},hh=class extends S{constructor({hash:t,version:r}){super(`Versioned hash "${t}" version is invalid.`,{metaMessages:[`Expected: ${1}`,`Received: ${r}`],name:"InvalidVersionedHashVersionError"})}};$m();Ir();rt();G();function gP(e){let t=e.to??(typeof e.data=="string"?"hex":"bytes"),r=typeof e.data=="string"?Je(e.data):e.data,n=Q(r);if(!n)throw new Eu;if(n>761855)throw new dh({maxSize:761855,size:n});let o=[],i=!0,s=0;for(;i;){let a=Oa(new Uint8Array(131072)),u=0;for(;u<4096;){let c=r.slice(s,s+31);if(a.pushByte(0),a.pushBytes(c),c.length<31){a.pushByte(128),i=!1;break}u++,s+=31}o.push(a)}return t==="bytes"?o.map(a=>a.bytes):o.map(a=>te(a.bytes))}function yh(e){let{data:t,kzg:r,to:n}=e,o=e.blobs??gP({data:t,to:n}),i=e.commitments??vu({blobs:o,kzg:r,to:n}),s=e.proofs??Au({blobs:o,commitments:i,kzg:r,to:n}),a=[];for(let u=0;u<o.length;u++)a.push({blob:o[u],commitment:i[u],proof:s[u]});return a}gu();Pn();function xh(e){if(e.type)return e.type;if(typeof e.authorizationList<"u")return"eip7702";if(typeof e.blobs<"u"||typeof e.blobVersionedHashes<"u"||typeof e.maxFeePerBlobGas<"u"||typeof e.sidecars<"u")return"eip4844";if(typeof e.maxFeePerGas<"u"||typeof e.maxPriorityFeePerGas<"u")return"eip1559";if(typeof e.gasPrice<"u")return typeof e.accessList<"u"?"eip2930":"legacy";throw new Ym({transaction:e})}vt();async function gh(e){let t=await e.request({method:"eth_chainId"},{dedupe:!0});return He(t)}var GN=["blobVersionedHashes","chainId","fees","gas","nonce","type"],bP=new Map;async function bh(e,t){let{account:r=e.account,blobs:n,chain:o,gas:i,kzg:s,nonce:a,nonceManager:u,parameters:c=GN,type:l}=t,f=r&&Oe(r),p={...t,...f?{from:f?.address}:{}},d;async function x(){return d||(d=await D(e,Et,"getBlock")({blockTag:"latest"}),d)}let g;async function b(){return g||(o?o.id:typeof t.chainId<"u"?t.chainId:(g=await D(e,gh,"getChainId")({}),g))}if(c.includes("nonce")&&typeof a>"u"&&f)if(u){let h=await b();p.nonce=await u.consume({address:f.address,chainId:h,client:e})}else p.nonce=await D(e,fh,"getTransactionCount")({address:f.address,blockTag:"pending"});if((c.includes("blobVersionedHashes")||c.includes("sidecars"))&&n&&s){let h=vu({blobs:n,kzg:s});if(c.includes("blobVersionedHashes")){let m=ph({commitments:h,to:"hex"});p.blobVersionedHashes=m}if(c.includes("sidecars")){let m=Au({blobs:n,commitments:h,kzg:s}),y=yh({blobs:n,commitments:h,proofs:m,to:"hex"});p.sidecars=y}}if(c.includes("chainId")&&(p.chainId=await b()),(c.includes("fees")||c.includes("type"))&&typeof l>"u")try{p.type=xh(p)}catch{let h=bP.get(e.uid);typeof h>"u"&&(h=typeof(await x())?.baseFeePerGas=="bigint",bP.set(e.uid,h)),p.type=h?"eip1559":"legacy"}if(c.includes("fees"))if(p.type!=="legacy"&&p.type!=="eip2930"){if(typeof p.maxFeePerGas>"u"||typeof p.maxPriorityFeePerGas>"u"){let h=await x(),{maxFeePerGas:m,maxPriorityFeePerGas:y}=await lh(e,{block:h,chain:o,request:p});if(typeof t.maxPriorityFeePerGas>"u"&&t.maxFeePerGas&&t.maxFeePerGas<y)throw new ch({maxPriorityFeePerGas:y});p.maxPriorityFeePerGas=y,p.maxFeePerGas=m}}else{if(typeof t.maxFeePerGas<"u"||typeof t.maxPriorityFeePerGas<"u")throw new ai;if(typeof t.gasPrice>"u"){let h=await x(),{gasPrice:m}=await lh(e,{block:h,chain:o,request:p,type:"legacy"});p.gasPrice=m}}return c.includes("gas")&&typeof i>"u"&&(p.gas=await D(e,Su,"estimateGas")({...p,account:f&&{address:f.address,type:"json-rpc"}})),On(p),delete p.parameters,p}G();async function wh(e,{address:t,blockNumber:r,blockTag:n="latest"}){let o=typeof r=="bigint"?O(r):void 0,i=await e.request({method:"eth_getBalance",params:[t,o||n]});return BigInt(i)}async function Su(e,t){let{account:r=e.account}=t,n=r?Oe(r):void 0;try{let E=function(L){let{block:M,request:F,rpcStateOverride:U}=L;return e.request({method:"eth_estimateGas",params:U?[F,M??"latest",U]:M?[F,M]:[F]})},{accessList:o,authorizationList:i,blobs:s,blobVersionedHashes:a,blockNumber:u,blockTag:c,data:l,gas:f,gasPrice:p,maxFeePerBlobGas:d,maxFeePerGas:x,maxPriorityFeePerGas:g,nonce:b,value:h,stateOverride:m,...y}=await bh(e,{...t,parameters:n?.type==="local"?void 0:["blobVersionedHashes"]}),v=(typeof u=="bigint"?O(u):void 0)||c,T=yu(m),P=await(async()=>{if(y.to)return y.to;if(i&&i.length>0)return await cP({authorization:i[0]}).catch(()=>{throw new S("`to` is required. Could not infer from `authorizationList`")})})();On(t);let C=e.chain?.formatters?.transactionRequest?.format,I=(C||si)({...mu(y,{format:C}),from:n?.address,accessList:o,authorizationList:i,blobs:s,blobVersionedHashes:a,data:l,gas:f,gasPrice:p,maxFeePerBlobGas:d,maxFeePerGas:x,maxPriorityFeePerGas:g,nonce:b,to:P,value:h}),k=BigInt(await E({block:v,request:I,rpcStateOverride:T}));if(i){let L=await wh(e,{address:I.from}),M=await Promise.all(i.map(async F=>{let{address:U}=F,W=await E({block:v,request:{authorizationList:void 0,data:l,from:n?.address,to:U,value:O(L)},rpcStateOverride:T}).catch(()=>100000n);return 2n*BigInt(W)}));k+=M.reduce((F,U)=>F+U,0n)}return k}catch(o){throw lP(o,{...t,account:n,chain:e.chain})}}async function wP(e,t){let{abi:r,address:n,args:o,functionName:i,dataSuffix:s,...a}=t,u=Me({abi:r,args:o,functionName:i});try{return await D(e,Su,"estimateGas")({data:`${u}${s?s.replace("0x",""):""}`,to:n,...a})}catch(c){let l=a.account?Oe(a.account):void 0;throw nn(c,{abi:r,address:n,args:o,docsPath:"/docs/contract/estimateContractGas",functionName:i,sender:l?.address})}}ti();ke();Ll();rt();en();Il();ke();Ir();Il();ob();Ra();uo();var vP="/docs/contract/decodeEventLog";function Iu(e){let{abi:t,data:r,strict:n,topics:o}=e,i=n??!0,[s,...a]=o;if(!s)throw new wm({docsPath:vP});let u=t.find(g=>g.type==="event"&&s===Qo(Ke(g)));if(!(u&&"name"in u)||u.type!=="event")throw new Ia(s,{docsPath:vP});let{name:c,inputs:l}=u,f=l?.some(g=>!("name"in g&&g.name)),p=f?[]:{},d=l.map((g,b)=>[g,b]).filter(([g])=>"indexed"in g&&g.indexed);for(let g=0;g<d.length;g++){let[b,h]=d[g],m=a[g];if(!m)throw new An({abiItem:u,param:b});p[f?h:b.name||h]=qN({param:b,value:m})}let x=l.filter(g=>!("indexed"in g&&g.indexed));if(x.length>0){if(r&&r!=="0x")try{let g=kr(x,r);if(g)if(f)for(let b=0;b<l.length;b++)p[b]=p[b]??g.shift();else for(let b=0;b<x.length;b++)p[x[b].name]=g[b]}catch(g){if(i)throw g instanceof Ea||g instanceof ka?new Qr({abiItem:u,data:r,params:x,size:Q(r)}):g}else if(i)throw new Qr({abiItem:u,data:"0x",params:x,size:0})}return{eventName:c,args:Object.values(p).length>0?p:void 0}}function qN({param:e,value:t}){return e.type==="string"||e.type==="bytes"||e.type==="tuple"||e.type.match(/^(.*)\[(\d+)?\]$/)?t:(kr([e],t)||[])[0]}function Tu(e){let{abi:t,args:r,logs:n,strict:o=!0}=e,i=(()=>{if(e.eventName)return Array.isArray(e.eventName)?e.eventName:[e.eventName]})();return n.map(s=>{try{let a=t.find(c=>c.type==="event"&&s.topics[0]===Qo(c));if(!a)return null;let u=Iu({...s,abi:[a],strict:o});return i&&!i.includes(u.eventName)||!YN({args:u.args,inputs:a.inputs,matchArgs:r})?null:{...u,...s}}catch(a){let u,c;if(a instanceof Ia)return null;if(a instanceof Qr||a instanceof An){if(o)return null;u=a.abiItem.name,c=a.abiItem.inputs?.some(l=>!("name"in l&&l.name))}return{...s,args:c?[]:{},eventName:u}}}).filter(Boolean)}function YN(e){let{args:t,inputs:r,matchArgs:n}=e;if(!n)return!0;if(!t)return!1;function o(i,s,a){try{return i.type==="address"?ui(s,a):i.type==="string"||i.type==="bytes"?de(Pr(s))===a:s===a}catch{return!1}}return Array.isArray(t)&&Array.isArray(n)?n.every((i,s)=>{if(i==null)return!0;let a=r[s];return a?(Array.isArray(i)?i:[i]).some(c=>o(a,c,t[s])):!1}):typeof t=="object"&&!Array.isArray(t)&&typeof n=="object"&&!Array.isArray(n)?Object.entries(n).every(([i,s])=>{if(s==null)return!0;let a=r.find(c=>c.name===i);return a?(Array.isArray(s)?s:[s]).some(c=>o(a,c,t[i])):!1}):!1}G();function St(e,{args:t,eventName:r}={}){return{...e,blockHash:e.blockHash?e.blockHash:null,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,logIndex:e.logIndex?Number(e.logIndex):null,transactionHash:e.transactionHash?e.transactionHash:null,transactionIndex:e.transactionIndex?Number(e.transactionIndex):null,...r?{args:t,eventName:r}:{}}}async function Pu(e,{address:t,blockHash:r,fromBlock:n,toBlock:o,event:i,events:s,args:a,strict:u}={}){let c=u??!1,l=s??(i?[i]:void 0),f=[];l&&(f=[l.flatMap(g=>In({abi:[g],eventName:g.name,args:s?void 0:a}))],i&&(f=f[0]));let p;r?p=await e.request({method:"eth_getLogs",params:[{address:t,topics:f,blockHash:r}]}):p=await e.request({method:"eth_getLogs",params:[{address:t,topics:f,fromBlock:typeof n=="bigint"?O(n):n,toBlock:typeof o=="bigint"?O(o):o}]});let d=p.map(x=>St(x));return l?Tu({abi:l,args:a,logs:d,strict:c}):d}async function vh(e,t){let{abi:r,address:n,args:o,blockHash:i,eventName:s,fromBlock:a,toBlock:u,strict:c}=t,l=s?Kt({abi:r,name:s}):void 0,f=l?void 0:r.filter(p=>p.type==="event");return D(e,Pu,"getLogs")({address:n,args:o,blockHash:i,event:l,events:f,fromBlock:a,toBlock:u,strict:c})}ci();rn();Ou();async function ct(e,t){let{abi:r,address:n,args:o,functionName:i,...s}=t,a=Me({abi:r,args:o,functionName:i});try{let{data:u}=await D(e,Ln,"call")({...s,data:a,to:n});return Zt({abi:r,args:o,functionName:i,data:u||"0x"})}catch(u){throw nn(u,{abi:r,address:n,args:o,docsPath:"/docs/contract/readContract",functionName:i})}}Br();ci();rn();Ou();async function nC(e,t){let{abi:r,address:n,args:o,dataSuffix:i,functionName:s,...a}=t,u=a.account?Oe(a.account):e.account,c=Me({abi:r,args:o,functionName:s});try{let{data:l}=await D(e,Ln,"call")({batch:!1,data:`${c}${i?i.replace("0x",""):""}`,to:n,...a,account:u}),f=Zt({abi:r,args:o,functionName:s,data:l||"0x"}),p=r.filter(d=>"name"in d&&d.name===t.functionName);return{result:f,request:{abi:p,address:n,args:o,dataSuffix:i,functionName:s,...a,account:u}}}catch(l){throw nn(l,{abi:r,address:n,args:o,docsPath:"/docs/contract/simulateContract",functionName:s,sender:u?.address})}}ke();Ol();var Lb=new Map,oC=new Map,mR=0;function Xt(e,t,r){let n=++mR,o=()=>Lb.get(e)||[],i=()=>{let l=o();Lb.set(e,l.filter(f=>f.id!==n))},s=()=>{let l=o();if(!l.some(p=>p.id===n))return;let f=oC.get(e);if(l.length===1&&f){let p=f();p instanceof Promise&&p.catch(()=>{})}i()},a=o();if(Lb.set(e,[...a,{id:n,fns:t}]),a&&a.length>0)return s;let u={};for(let l in t)u[l]=(...f)=>{let p=o();if(p.length!==0)for(let d of p)d.fns[l]?.(...f)};let c=r(u);return typeof c=="function"&&oC.set(e,c),s}async function Hl(e){return new Promise(t=>setTimeout(t,e))}function Fn(e,{emitOnBegin:t,initialWaitTime:r,interval:n}){let o=!0,i=()=>o=!1;return(async()=>{let a;t&&(a=await e({unpoll:i}));let u=await r?.(a)??n;await Hl(u);let c=async()=>{o&&(await e({unpoll:i}),await Hl(n),c())};c()})(),i}Jt();var hR=new Map,yR=new Map;function iC(e){let t=(o,i)=>({clear:()=>i.delete(o),get:()=>i.get(o),set:s=>i.set(o,s)}),r=t(e,hR),n=t(e,yR);return{clear:()=>{r.clear(),n.clear()},promise:r,response:n}}async function sC(e,{cacheKey:t,cacheTime:r=Number.POSITIVE_INFINITY}){let n=iC(t),o=n.response.get();if(o&&r>0&&new Date().getTime()-o.created.getTime()<r)return o.data;let i=n.promise.get();i||(i=e(),n.promise.set(i));try{let s=await i;return n.response.set({created:new Date,data:s}),s}finally{n.promise.clear()}}var xR=e=>`blockNumber.${e}`;async function Un(e,{cacheTime:t=e.cacheTime}={}){let r=await sC(()=>e.request({method:"eth_blockNumber"}),{cacheKey:xR(e.uid),cacheTime:t});return BigInt(r)}async function pi(e,{filter:t}){let r="strict"in t&&t.strict,n=await t.request({method:"eth_getFilterChanges",params:[t.id]});if(typeof n[0]=="string")return n;let o=n.map(i=>St(i));return!("abi"in t)||!t.abi?o:Tu({abi:t.abi,logs:o,strict:r})}async function di(e,{filter:t}){return t.request({method:"eth_uninstallFilter",params:[t.id]})}function aC(e,t){let{abi:r,address:n,args:o,batch:i=!0,eventName:s,fromBlock:a,onError:u,onLogs:c,poll:l,pollingInterval:f=e.pollingInterval,strict:p}=t;return(typeof l<"u"?l:typeof a=="bigint"?!0:!(e.transport.type==="webSocket"||e.transport.type==="ipc"||e.transport.type==="fallback"&&(e.transport.transports[0].config.type==="webSocket"||e.transport.transports[0].config.type==="ipc")))?(()=>{let b=p??!1,h=re(["watchContractEvent",n,o,i,e.uid,s,f,b,a]);return Xt(h,{onLogs:c,onError:u},m=>{let y;a!==void 0&&(y=a-1n);let w,v=!1,T=Fn(async()=>{if(!v){try{w=await D(e,Fm,"createContractEventFilter")({abi:r,address:n,args:o,eventName:s,strict:b,fromBlock:a})}catch{}v=!0;return}try{let P;if(w)P=await D(e,pi,"getFilterChanges")({filter:w});else{let C=await D(e,Un,"getBlockNumber")({});y&&y<C?P=await D(e,vh,"getContractEvents")({abi:r,address:n,args:o,eventName:s,fromBlock:y+1n,toBlock:C,strict:b}):P=[],y=C}if(P.length===0)return;if(i)m.onLogs(P);else for(let C of P)m.onLogs([C])}catch(P){w&&P instanceof _n&&(v=!1),m.onError?.(P)}},{emitOnBegin:!0,interval:f});return async()=>{w&&await D(e,di,"uninstallFilter")({filter:w}),T()}})})():(()=>{let b=p??!1,h=re(["watchContractEvent",n,o,i,e.uid,s,f,b]),m=!0,y=()=>m=!1;return Xt(h,{onLogs:c,onError:u},w=>((async()=>{try{let v=(()=>{if(e.transport.type==="fallback"){let C=e.transport.transports.find(A=>A.config.type==="webSocket"||A.config.type==="ipc");return C?C.value:e.transport}return e.transport})(),T=s?In({abi:r,eventName:s,args:o}):[],{unsubscribe:P}=await v.subscribe({params:["logs",{address:n,topics:T}],onData(C){if(!m)return;let A=C.result;try{let{eventName:I,args:E}=Iu({abi:r,data:A.data,topics:A.topics,strict:p}),k=St(A,{args:E,eventName:I});w.onLogs([k])}catch(I){let E,k;if(I instanceof Qr||I instanceof An){if(p)return;E=I.abiItem.name,k=I.abiItem.inputs?.some(M=>!("name"in M&&M.name))}let L=St(A,{args:k?[]:{},eventName:E});w.onLogs([L])}},onError(C){w.onError?.(C)}});y=P,m||y()}catch(v){u?.(v)}})(),()=>y()))})()}async function uC(e,{serializedTransaction:t}){return e.request({method:"eth_sendRawTransaction",params:[t]},{retryCount:0})}vt();sh();var gR={"0x0":"reverted","0x1":"success"};function Fb(e){let t={...e,blockNumber:e.blockNumber?BigInt(e.blockNumber):null,contractAddress:e.contractAddress?e.contractAddress:null,cumulativeGasUsed:e.cumulativeGasUsed?BigInt(e.cumulativeGasUsed):null,effectiveGasPrice:e.effectiveGasPrice?BigInt(e.effectiveGasPrice):null,gasUsed:e.gasUsed?BigInt(e.gasUsed):null,logs:e.logs?e.logs.map(r=>St(r)):null,to:e.to?e.to:null,transactionIndex:e.transactionIndex?He(e.transactionIndex):null,status:e.status?gR[e.status]:null,type:e.type?db[e.type]||e.type:null};return e.blobGasPrice&&(t.blobGasPrice=BigInt(e.blobGasPrice)),e.blobGasUsed&&(t.blobGasUsed=BigInt(e.blobGasUsed)),t}var cC=hu("transactionReceipt",Fb);Br();var jh=256,Wh;function Vh(e=11){if(!Wh||jh+e>256*2){Wh="",jh=0;for(let t=0;t<256;t++)Wh+=(256+Math.random()*256|0).toString(16).substring(1)}return Wh.substring(jh,jh+++e)}function lC(e){let{batch:t,chain:r,ccipRead:n,key:o="base",name:i="Base Client",type:s="base"}=e,a=r?.blockTime??12e3,u=Math.min(Math.max(Math.floor(a/2),500),4e3),c=e.pollingInterval??u,l=e.cacheTime??c,f=e.account?Oe(e.account):void 0,{config:p,request:d,value:x}=e.transport({chain:r,pollingInterval:c}),g={...p,...x},b={account:f,batch:t,cacheTime:l,ccipRead:n,chain:r,key:o,name:i,pollingInterval:c,request:d,transport:g,type:s,uid:Vh()};function h(m){return y=>{let w=y(m);for(let T in b)delete w[T];let v={...m,...w};return Object.assign(v,{extend:h(v)})}}return Object.assign(b,{extend:h(b)})}Z();rs();Ol();G();Nm();var Gh=new Xo(8192);function fC(e,{enabled:t=!0,id:r}){if(!t||!r)return e();if(Gh.get(r))return Gh.get(r);let n=e().finally(()=>Gh.delete(r));return Gh.set(r,n),n}function jl(e,{delay:t=100,retryCount:r=2,shouldRetry:n=()=>!0}={}){return new Promise((o,i)=>{let s=async({count:a=0}={})=>{let u=async({error:c})=>{let l=typeof t=="function"?t({count:a,error:c}):t;l&&await Hl(l),s({count:a+1})};try{let c=await e();o(c)}catch(c){if(a<r&&await n({count:a,error:c}))return u({error:c});i(c)}};s()})}Jt();function pC(e,t={}){return async(r,n={})=>{let{dedupe:o=!1,methods:i,retryDelay:s=150,retryCount:a=3,uid:u}={...t,...n},{method:c}=r;if(i?.exclude?.includes(c))throw new ii(new Error("method not supported"),{method:c});if(i?.include&&!i.include.includes(c))throw new ii(new Error("method not supported"),{method:c});let l=o?Zo(`${u}.${re(r)}`):void 0;return fC(()=>jl(async()=>{try{return await e(r)}catch(f){let p=f;switch(p.code){case Da.code:throw new Da(p);case $a.code:throw new $a(p);case za.code:throw new za(p,{method:r.method});case Ha.code:throw new Ha(p);case fo.code:throw new fo(p);case _n.code:throw new _n(p);case ja.code:throw new ja(p);case Wa.code:throw new Wa(p);case Va.code:throw new Va(p);case ii.code:throw new ii(p,{method:r.method});case ns.code:throw new ns(p);case Ga.code:throw new Ga(p);case os.code:throw new os(p);case qa.code:throw new qa(p);case Ya.code:throw new Ya(p);case Ka.code:throw new Ka(p);case Ja.code:throw new Ja(p);case Za.code:throw new Za(p);case Qa.code:throw new Qa(p);case Xa.code:throw new Xa(p);case eu.code:throw new eu(p);case tu.code:throw new tu(p);case ru.code:throw new ru(p);case nu.code:throw new nu(p);case ou.code:throw new ou(p);case 5e3:throw new os(p);default:throw f instanceof S?f:new th(p)}}},{delay:({count:f,error:p})=>{if(p&&p instanceof Or){let d=p?.headers?.get("Retry-After");if(d?.match(/\d/))return Number.parseInt(d)*1e3}return~~(1<<f)*s},retryCount:a,shouldRetry:({error:f})=>bR(f)}),{enabled:o,id:l})}}function bR(e){return"code"in e&&typeof e.code=="number"?e.code===-1||e.code===ns.code||e.code===fo.code:e instanceof Or&&e.status?e.status===403||e.status===408||e.status===413||e.status===429||e.status===500||e.status===502||e.status===503||e.status===504:!0}function dC({key:e,methods:t,name:r,request:n,retryCount:o=3,retryDelay:i=150,timeout:s,type:a},u){let c=Vh();return{config:{key:e,methods:t,name:r,request:n,retryCount:o,retryDelay:i,timeout:s,type:a},request:pC(n,{methods:t,retryCount:o,retryDelay:i,uid:c}),value:u}}rs();Z();var qh=class extends S{constructor(){super("No URL was provided to the Transport. Please provide a valid RPC URL to the Transport.",{docsPath:"/docs/clients/intro",name:"UrlRequiredError"})}};kb();rs();function mC(e,{errorInstance:t=new Error("timed out"),timeout:r,signal:n}){return new Promise((o,i)=>{(async()=>{let s;try{let a=new AbortController;r>0&&(s=setTimeout(()=>{n?a.abort():i(t)},r)),o(await e({signal:a?.signal||null}))}catch(a){a?.name==="AbortError"&&i(t),i(a)}finally{clearTimeout(s)}})()})}Jt();function wR(){return{current:0,take(){return this.current++},reset(){this.current=0}}}var Ub=wR();function hC(e,t={}){return{async request(r){let{body:n,onRequest:o=t.onRequest,onResponse:i=t.onResponse,timeout:s=t.timeout??1e4}=r,a={...t.fetchOptions??{},...r.fetchOptions??{}},{headers:u,method:c,signal:l}=a;try{let f=await mC(async({signal:d})=>{let x={...a,body:Array.isArray(n)?re(n.map(m=>({jsonrpc:"2.0",id:m.id??Ub.take(),...m}))):re({jsonrpc:"2.0",id:n.id??Ub.take(),...n}),headers:{"Content-Type":"application/json",...u},method:c||"POST",signal:l||(s>0?d:null)},g=new Request(e,x),b=await o?.(g,x)??{...x,url:e};return await fetch(b.url??e,b)},{errorInstance:new kl({body:n,url:e}),timeout:s,signal:!0});i&&await i(f);let p;if(f.headers.get("Content-Type")?.startsWith("application/json"))p=await f.json();else{p=await f.text();try{p=JSON.parse(p||"{}")}catch(d){if(f.ok)throw d;p={error:p}}}if(!f.ok)throw new Or({body:n,details:re(p.error)||f.statusText,headers:f.headers,status:f.status,url:e});return p}catch(f){throw f instanceof Or||f instanceof kl?f:new Or({body:n,cause:f,url:e})}}}}function Mb(e,t={}){let{batch:r,fetchOptions:n,key:o="http",methods:i,name:s="HTTP JSON-RPC",onFetchRequest:a,onFetchResponse:u,retryDelay:c,raw:l}=t;return({chain:f,retryCount:p,timeout:d})=>{let{batchSize:x=1e3,wait:g=0}=typeof r=="object"?r:{},b=t.retryCount??p,h=d??t.timeout??1e4,m=e||f?.rpcUrls.default.http[0];if(!m)throw new qh;let y=hC(m,{fetchOptions:n,onRequest:a,onResponse:u,timeout:h});return dC({key:o,methods:i,name:s,async request({method:w,params:v}){let T={method:w,params:v},{schedule:P}=Mh({id:m,wait:g,shouldSplitBatch(E){return E.length>x},fn:E=>y.request({body:E}),sort:(E,k)=>E.id-k.id}),C=async E=>r?P(E):[await y.request({body:E})],[{error:A,result:I}]=await C(T);if(l)return{error:A,result:I};if(A)throw new oi({body:T,error:A,url:m});return I},retryCount:b,retryDelay:c,timeout:h,type:"http"},{fetchOptions:n,url:m})}}fi();ci();rn();ls();_a();G();Pl();Z();ni();function Nu(e,t){if(!(e instanceof S))return!1;let r=e.walk(n=>n instanceof ts);return r instanceof ts?!!(r.data?.errorName==="ResolverNotFound"||r.data?.errorName==="ResolverWildcardNotSupported"||r.data?.errorName==="ResolverNotContract"||r.data?.errorName==="ResolverError"||r.data?.errorName==="HttpError"||r.reason?.includes("Wildcard on non-extended resolvers is not supported")||t==="reverse"&&r.reason===Um[50]):!1}Hh();Yt();rt();G();en();Jr();function Yh(e){if(e.length!==66||e.indexOf("[")!==0||e.indexOf("]")!==65)return null;let t=`0x${e.slice(1,65)}`;return Ue(t)?t:null}function Ru(e){let t=new Uint8Array(32).fill(0);if(!e)return te(t);let r=e.split(".");for(let n=r.length-1;n>=0;n-=1){let o=Yh(r[n]),i=o?Pr(o):de(Xr(r[n]),"bytes");t=de(ut([t,i]),"bytes")}return te(t)}rt();function yC(e){return`[${e.slice(2)}]`}rt();G();en();function xC(e){let t=new Uint8Array(32).fill(0);return e?Yh(e)||de(Xr(e)):te(t)}function mi(e){let t=e.replace(/^\.|\.$/gm,"");if(t.length===0)return new Uint8Array(1);let r=new Uint8Array(Xr(t).byteLength+2),n=0,o=t.split(".");for(let i=0;i<o.length;i++){let s=Xr(o[i]);s.byteLength>255&&(s=Xr(yC(xC(o[i])))),r[n]=s.length,r.set(s,n+1),n+=s.length+1}return r.byteLength!==n+1?r.slice(0,n+1):r}async function gC(e,t){let{blockNumber:r,blockTag:n,coinType:o,name:i,gatewayUrls:s,strict:a}=t,{chain:u}=e,c=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!u)throw new Error("client chain not configured. universalResolverAddress is required.");return Rr({blockNumber:r,chain:u,contract:"ensUniversalResolver"})})(),l=u?.ensTlds;if(l&&!l.some(f=>i.endsWith(f)))return null;try{let f=Me({abi:Sb,functionName:"addr",...o!=null?{args:[Ru(i),BigInt(o)]}:{args:[Ru(i)]}}),p={address:c,abi:Oh,functionName:"resolve",args:[we(mi(i)),f,s??[ku]],blockNumber:r,blockTag:n},x=await D(e,ct,"readContract")(p);if(x[0]==="0x")return null;let g=Zt({abi:Sb,args:o!=null?[Ru(i),BigInt(o)]:void 0,functionName:"addr",data:x[0]});return g==="0x"||wt(g)==="0x00"?null:g}catch(f){if(a)throw f;if(Nu(f,"resolve"))return null;throw f}}Z();var Kh=class extends S{constructor({data:t}){super("Unable to extract image from metadata. The metadata may be malformed or invalid.",{metaMessages:["- Metadata must be a JSON object with at least an `image`, `image_url` or `image_data` property.","",`Provided data: ${JSON.stringify(t)}`],name:"EnsAvatarInvalidMetadataError"})}},hi=class extends S{constructor({reason:t}){super(`ENS NFT avatar URI is invalid. ${t}`,{name:"EnsAvatarInvalidNftUriError"})}},Lu=class extends S{constructor({uri:t}){super(`Unable to resolve ENS avatar URI "${t}". The URI may be malformed, invalid, or does not respond with a valid image.`,{name:"EnsAvatarUriResolutionError"})}},Jh=class extends S{constructor({namespace:t}){super(`ENS NFT avatar namespace "${t}" is not supported. Must be "erc721" or "erc1155".`,{name:"EnsAvatarUnsupportedNamespaceError"})}};var vR=/(?<protocol>https?:\/\/[^\/]*|ipfs:\/|ipns:\/|ar:\/)?(?<root>\/)?(?<subpath>ipfs\/|ipns\/)?(?<target>[\w\-.]+)(?<subtarget>\/.*)?/,AR=/^(Qm[1-9A-HJ-NP-Za-km-z]{44,}|b[A-Za-z2-7]{58,}|B[A-Z2-7]{58,}|z[1-9A-HJ-NP-Za-km-z]{48,}|F[0-9A-F]{50,})(\/(?<target>[\w\-.]+))?(?<subtarget>\/.*)?$/,ER=/^data:([a-zA-Z\-/+]*);base64,([^"].*)/,SR=/^data:([a-zA-Z\-/+]*)?(;[a-zA-Z0-9].*?)?(,)/;async function IR(e){try{let t=await fetch(e,{method:"HEAD"});return t.status===200?t.headers.get("content-type")?.startsWith("image/"):!1}catch(t){return typeof t=="object"&&typeof t.response<"u"||!globalThis.hasOwnProperty("Image")?!1:new Promise(r=>{let n=new Image;n.onload=()=>{r(!0)},n.onerror=()=>{r(!1)},n.src=e})}}function bC(e,t){return e?e.endsWith("/")?e.slice(0,-1):e:t}function Db({uri:e,gatewayUrls:t}){let r=ER.test(e);if(r)return{uri:e,isOnChain:!0,isEncoded:r};let n=bC(t?.ipfs,"https://ipfs.io"),o=bC(t?.arweave,"https://arweave.net"),i=e.match(vR),{protocol:s,subpath:a,target:u,subtarget:c=""}=i?.groups||{},l=s==="ipns:/"||a==="ipns/",f=s==="ipfs:/"||a==="ipfs/"||AR.test(e);if(e.startsWith("http")&&!l&&!f){let d=e;return t?.arweave&&(d=e.replace(/https:\/\/arweave.net/g,t?.arweave)),{uri:d,isOnChain:!1,isEncoded:!1}}if((l||f)&&u)return{uri:`${n}/${l?"ipns":"ipfs"}/${u}${c}`,isOnChain:!1,isEncoded:!1};if(s==="ar:/"&&u)return{uri:`${o}/${u}${c||""}`,isOnChain:!1,isEncoded:!1};let p=e.replace(SR,"");if(p.startsWith("<svg")&&(p=`data:image/svg+xml;base64,${btoa(p)}`),p.startsWith("data:")||p.startsWith("{"))return{uri:p,isOnChain:!0,isEncoded:!1};throw new Lu({uri:e})}function $b(e){if(typeof e!="object"||!("image"in e)&&!("image_url"in e)&&!("image_data"in e))throw new Kh({data:e});return e.image||e.image_url||e.image_data}async function wC({gatewayUrls:e,uri:t}){try{let r=await fetch(t).then(o=>o.json());return await Zh({gatewayUrls:e,uri:$b(r)})}catch{throw new Lu({uri:t})}}async function Zh({gatewayUrls:e,uri:t}){let{uri:r,isOnChain:n}=Db({uri:t,gatewayUrls:e});if(n||await IR(r))return r;throw new Lu({uri:t})}function vC(e){let t=e;t.startsWith("did:nft:")&&(t=t.replace("did:nft:","").replace(/_/g,"/"));let[r,n,o]=t.split("/"),[i,s]=r.split(":"),[a,u]=n.split(":");if(!i||i.toLowerCase()!=="eip155")throw new hi({reason:"Only EIP-155 supported"});if(!s)throw new hi({reason:"Chain ID not found"});if(!u)throw new hi({reason:"Contract address not found"});if(!o)throw new hi({reason:"Token ID not found"});if(!a)throw new hi({reason:"ERC namespace not found"});return{chainID:Number.parseInt(s),namespace:a.toLowerCase(),contractAddress:u,tokenID:o}}async function AC(e,{nft:t}){if(t.namespace==="erc721")return ct(e,{address:t.contractAddress,abi:[{name:"tokenURI",type:"function",stateMutability:"view",inputs:[{name:"tokenId",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"tokenURI",args:[BigInt(t.tokenID)]});if(t.namespace==="erc1155")return ct(e,{address:t.contractAddress,abi:[{name:"uri",type:"function",stateMutability:"view",inputs:[{name:"_id",type:"uint256"}],outputs:[{name:"",type:"string"}]}],functionName:"uri",args:[BigInt(t.tokenID)]});throw new Jh({namespace:t.namespace})}async function EC(e,{gatewayUrls:t,record:r}){return/eip155:/i.test(r)?TR(e,{gatewayUrls:t,record:r}):Zh({uri:r,gatewayUrls:t})}async function TR(e,{gatewayUrls:t,record:r}){let n=vC(r),o=await AC(e,{nft:n}),{uri:i,isOnChain:s,isEncoded:a}=Db({uri:o,gatewayUrls:t});if(s&&(i.includes("data:application/json;base64,")||i.startsWith("{"))){let c=a?atob(i.replace("data:application/json;base64,","")):i,l=JSON.parse(c);return Zh({uri:$b(l),gatewayUrls:t})}let u=n.tokenID;return n.namespace==="erc1155"&&(u=u.replace("0x","").padStart(64,"0")),wC({gatewayUrls:t,uri:i.replace(/(?:0x)?{id}/,u)})}fi();ci();rn();ls();G();Hh();async function Qh(e,t){let{blockNumber:r,blockTag:n,key:o,name:i,gatewayUrls:s,strict:a}=t,{chain:u}=e,c=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!u)throw new Error("client chain not configured. universalResolverAddress is required.");return Rr({blockNumber:r,chain:u,contract:"ensUniversalResolver"})})(),l=u?.ensTlds;if(l&&!l.some(f=>i.endsWith(f)))return null;try{let f={address:c,abi:Oh,functionName:"resolve",args:[we(mi(i)),Me({abi:Eb,functionName:"text",args:[Ru(i),o]}),s??[ku]],blockNumber:r,blockTag:n},d=await D(e,ct,"readContract")(f);if(d[0]==="0x")return null;let x=Zt({abi:Eb,functionName:"text",data:d[0]});return x===""?null:x}catch(f){if(a)throw f;if(Nu(f,"resolve"))return null;throw f}}async function SC(e,{blockNumber:t,blockTag:r,assetGatewayUrls:n,name:o,gatewayUrls:i,strict:s,universalResolverAddress:a}){let u=await D(e,Qh,"getEnsText")({blockNumber:t,blockTag:r,key:"avatar",name:o,universalResolverAddress:a,gatewayUrls:i,strict:s});if(!u)return null;try{return await EC(e,{record:u,gatewayUrls:n})}catch{return null}}fi();ls();G();async function IC(e,{address:t,blockNumber:r,blockTag:n,gatewayUrls:o,strict:i,universalResolverAddress:s}){let a=s;if(!a){if(!e.chain)throw new Error("client chain not configured. universalResolverAddress is required.");a=Rr({blockNumber:r,chain:e.chain,contract:"ensUniversalResolver"})}let u=`${t.toLowerCase().substring(2)}.addr.reverse`;try{let c={address:a,abi:zP,functionName:"reverse",args:[we(mi(u))],blockNumber:r,blockTag:n},l=D(e,ct,"readContract"),[f,p]=o?await l({...c,args:[...c.args,o]}):await l(c);return t.toLowerCase()!==p.toLowerCase()?null:f}catch(c){if(i)throw c;if(Nu(c,"reverse"))return null;throw c}}ls();G();async function TC(e,t){let{blockNumber:r,blockTag:n,name:o}=t,{chain:i}=e,s=(()=>{if(t.universalResolverAddress)return t.universalResolverAddress;if(!i)throw new Error("client chain not configured. universalResolverAddress is required.");return Rr({blockNumber:r,chain:i,contract:"ensUniversalResolver"})})(),a=i?.ensTlds;if(a&&!a.some(c=>o.endsWith(c)))throw new Error(`${o} is not a valid ENS TLD (${a?.join(", ")}) for chain "${i.name}" (id: ${i.id}).`);let[u]=await D(e,ct,"readContract")({address:s,abi:[{inputs:[{type:"bytes"}],name:"findResolver",outputs:[{type:"address"},{type:"bytes32"}],stateMutability:"view",type:"function"}],functionName:"findResolver",args:[we(mi(o))],blockNumber:r,blockTag:n});return u}Ou();Br();G();Cb();ih();Nl();gu();async function Xh(e,t){let{account:r=e.account,blockNumber:n,blockTag:o="latest",blobs:i,data:s,gas:a,gasPrice:u,maxFeePerBlobGas:c,maxFeePerGas:l,maxPriorityFeePerGas:f,to:p,value:d,...x}=t,g=r?Oe(r):void 0;try{On(t);let h=(typeof n=="bigint"?O(n):void 0)||o,m=e.chain?.formatters?.transactionRequest?.format,w=(m||si)({...mu(x,{format:m}),from:g?.address,blobs:i,data:s,gas:a,gasPrice:u,maxFeePerBlobGas:c,maxFeePerGas:l,maxPriorityFeePerGas:f,to:p,value:d}),v=await e.request({method:"eth_createAccessList",params:[w,h]});return{accessList:v.accessList,gasUsed:BigInt(v.gasUsed)}}catch(b){throw Fh(b,{...t,account:g,chain:e.chain})}}async function PC(e){let t=ri(e,{method:"eth_newBlockFilter"}),r=await e.request({method:"eth_newBlockFilter"});return{id:r,request:t(r),type:"block"}}G();async function e0(e,{address:t,args:r,event:n,events:o,fromBlock:i,strict:s,toBlock:a}={}){let u=o??(n?[n]:void 0),c=ri(e,{method:"eth_newFilter"}),l=[];u&&(l=[u.flatMap(d=>In({abi:[d],eventName:d.name,args:r}))],n&&(l=l[0]));let f=await e.request({method:"eth_newFilter",params:[{address:t,fromBlock:typeof i=="bigint"?O(i):i,toBlock:typeof a=="bigint"?O(a):a,...l.length?{topics:l}:{}}]});return{abi:u,args:r,eventName:n?n.name:void 0,fromBlock:i,id:f,request:c(f),strict:!!s,toBlock:a,type:"event"}}async function t0(e){let t=ri(e,{method:"eth_newPendingTransactionFilter"}),r=await e.request({method:"eth_newPendingTransactionFilter"});return{id:r,request:t(r),type:"transaction"}}async function CC(e){let t=await e.request({method:"eth_blobBaseFee"});return BigInt(t)}vt();G();async function _C(e,{blockHash:t,blockNumber:r,blockTag:n="latest"}={}){let o=r!==void 0?O(r):void 0,i;return t?i=await e.request({method:"eth_getBlockTransactionCountByHash",params:[t]},{dedupe:!0}):i=await e.request({method:"eth_getBlockTransactionCountByNumber",params:[o||n]},{dedupe:!!o}),He(i)}G();async function zb(e,{address:t,blockNumber:r,blockTag:n="latest"}){let o=r!==void 0?O(r):void 0,i=await e.request({method:"eth_getCode",params:[t,o||n]},{dedupe:!!o});if(i!=="0x")return i}Z();var r0=class extends S{constructor({address:t}){super(`No EIP-712 domain found on contract "${t}".`,{metaMessages:["Ensure that:",`- The contract is deployed at the address "${t}".`,"- `eip712Domain()` function exists on the contract.","- `eip712Domain()` function matches signature to ERC-5267 specification."],name:"Eip712DomainNotFoundError"})}};async function BC(e,t){let{address:r,factory:n,factoryData:o}=t;try{let[i,s,a,u,c,l,f]=await D(e,ct,"readContract")({abi:PR,address:r,functionName:"eip712Domain",factory:n,factoryData:o});return{domain:{name:s,version:a,chainId:Number(u),verifyingContract:c,salt:l},extensions:f,fields:i}}catch(i){let s=i;throw s.name==="ContractFunctionExecutionError"&&s.cause.name==="ContractFunctionZeroDataError"?new r0({address:r}):s}}var PR=[{inputs:[],name:"eip712Domain",outputs:[{name:"fields",type:"bytes1"},{name:"name",type:"string"},{name:"version",type:"string"},{name:"chainId",type:"uint256"},{name:"verifyingContract",type:"address"},{name:"salt",type:"bytes32"},{name:"extensions",type:"uint256[]"}],stateMutability:"view",type:"function"}];G();function kC(e){return{baseFeePerGas:e.baseFeePerGas.map(t=>BigInt(t)),gasUsedRatio:e.gasUsedRatio,oldestBlock:BigInt(e.oldestBlock),reward:e.reward?.map(t=>t.map(r=>BigInt(r)))}}async function OC(e,{blockCount:t,blockNumber:r,blockTag:n="latest",rewardPercentiles:o}){let i=typeof r=="bigint"?O(r):void 0,s=await e.request({method:"eth_feeHistory",params:[O(t),i||n,o]},{dedupe:!!i});return kC(s)}async function NC(e,{filter:t}){let r=t.strict??!1,o=(await t.request({method:"eth_getFilterLogs",params:[t.id]})).map(i=>St(i));return t.abi?Tu({abi:t.abi,logs:o,strict:r}):o}G();function RC(e){return{formatters:void 0,fees:void 0,serializers:void 0,...e}}ke();En();Jt();Z();var n0=class extends S{constructor({domain:t}){super(`Invalid domain "${re(t)}".`,{metaMessages:["Must be a valid EIP-712 domain."]})}},o0=class extends S{constructor({primaryType:t,types:r}){super(`Invalid primary type \`${t}\` must be one of \`${JSON.stringify(Object.keys(r))}\`.`,{docsPath:"/api/glossary/Errors#typeddatainvalidprimarytypeerror",metaMessages:["Check that the primary type is a key in `types`."]})}},i0=class extends S{constructor({type:t}){super(`Struct type "${t}" is invalid.`,{metaMessages:["Struct type must not be a Solidity type."],name:"InvalidStructTypeError"})}};Cr();Ir();G();eb();tn();Yt();G();en();function LC(e){let{domain:t={},message:r,primaryType:n}=e,o={EIP712Domain:zC({domain:t}),...e.types};$C({domain:t,message:r,primaryType:n,types:o});let i=["0x1901"];return t&&i.push(CR({domain:t,types:o})),n!=="EIP712Domain"&&i.push(FC({data:r,primaryType:n,types:o})),de(ut(i))}function CR({domain:e,types:t}){return FC({data:e,primaryType:"EIP712Domain",types:t})}function FC({data:e,primaryType:t,types:r}){let n=UC({data:e,primaryType:t,types:r});return de(n)}function UC({data:e,primaryType:t,types:r}){let n=[{type:"bytes32"}],o=[_R({primaryType:t,types:r})];for(let i of r[t]){let[s,a]=DC({types:r,name:i.name,type:i.type,value:e[i.name]});n.push(s),o.push(a)}return je(n,o)}function _R({primaryType:e,types:t}){let r=we(BR({primaryType:e,types:t}));return de(r)}function BR({primaryType:e,types:t}){let r="",n=MC({primaryType:e,types:t});n.delete(e);let o=[e,...Array.from(n).sort()];for(let i of o)r+=`${i}(${t[i].map(({name:s,type:a})=>`${a} ${s}`).join(",")})`;return r}function MC({primaryType:e,types:t},r=new Set){let o=e.match(/^\w*/u)?.[0];if(r.has(o)||t[o]===void 0)return r;r.add(o);for(let i of t[o])MC({primaryType:i.type,types:t},r);return r}function DC({types:e,name:t,type:r,value:n}){if(e[r]!==void 0)return[{type:"bytes32"},de(UC({data:n,primaryType:r,types:e}))];if(r==="bytes")return n=`0x${(n.length%2?"0":"")+n.slice(2)}`,[{type:"bytes32"},de(n)];if(r==="string")return[{type:"bytes32"},de(we(n))];if(r.lastIndexOf("]")===r.length-1){let o=r.slice(0,r.lastIndexOf("[")),i=n.map(s=>DC({name:t,type:o,types:e,value:s}));return[{type:"bytes32"},de(je(i.map(([s])=>s),i.map(([,s])=>s)))]}return[{type:r},n]}function $C(e){let{domain:t,message:r,primaryType:n,types:o}=e,i=(s,a)=>{for(let u of s){let{name:c,type:l}=u,f=a[c],p=l.match(Rm);if(p&&(typeof f=="number"||typeof f=="bigint")){let[g,b,h]=p;O(f,{signed:b==="int",size:Number.parseInt(h)/8})}if(l==="address"&&typeof f=="string"&&!ne(f))throw new xe({address:f});let d=l.match(MT);if(d){let[g,b]=d;if(b&&Q(f)!==Number.parseInt(b))throw new Em({expectedSize:Number.parseInt(b),givenSize:Q(f)})}let x=o[l];x&&(kR(l),i(x,f))}};if(o.EIP712Domain&&t){if(typeof t!="object")throw new n0({domain:t});i(o.EIP712Domain,t)}if(n!=="EIP712Domain")if(o[n])i(o[n],r);else throw new o0({primaryType:n,types:o})}function zC({domain:e}){return[typeof e?.name=="string"&&{name:"name",type:"string"},e?.version&&{name:"version",type:"string"},(typeof e?.chainId=="number"||typeof e?.chainId=="bigint")&&{name:"chainId",type:"uint256"},e?.verifyingContract&&{name:"verifyingContract",type:"address"},e?.salt&&{name:"salt",type:"bytes32"}].filter(Boolean)}function kR(e){if(e==="address"||e==="bool"||e==="string"||e.startsWith("bytes")||e.startsWith("uint")||e.startsWith("int"))throw new i0({type:e})}rn();G();Pn();Yt();_a();G();pb();En();Z();Lh();is();Cr();Ir();ei();vt();function HC(e){let{authorizationList:t}=e;if(t)for(let r of t){let{chainId:n}=r,o=r.address;if(!ne(o))throw new xe({address:o});if(n<0)throw new cs({chainId:n})}s0(e)}function jC(e){let{blobVersionedHashes:t}=e;if(t){if(t.length===0)throw new Eu;for(let r of t){let n=Q(r),o=He(_r(r,0,1));if(n!==32)throw new mh({hash:r,size:n});if(o!==1)throw new hh({hash:r,version:o})}}s0(e)}function s0(e){let{chainId:t,maxPriorityFeePerGas:r,maxFeePerGas:n,to:o}=e;if(t<=0)throw new cs({chainId:t});if(o&&!ne(o))throw new xe({address:o});if(n&&n>xu)throw new Nr({maxFeePerGas:n});if(r&&n&&r>n)throw new Bn({maxFeePerGas:n,maxPriorityFeePerGas:r})}function WC(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:i}=e;if(t<=0)throw new cs({chainId:t});if(i&&!ne(i))throw new xe({address:i});if(r||o)throw new S("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid EIP-2930 Transaction attribute.");if(n&&n>xu)throw new Nr({maxFeePerGas:n})}function VC(e){let{chainId:t,maxPriorityFeePerGas:r,gasPrice:n,maxFeePerGas:o,to:i}=e;if(i&&!ne(i))throw new xe({address:i});if(typeof t<"u"&&t<=0)throw new cs({chainId:t});if(r||o)throw new S("`maxFeePerGas`/`maxPriorityFeePerGas` is not a valid Legacy Transaction attribute.");if(n&&n>xu)throw new Nr({maxFeePerGas:n})}En();Pn();Cr();function Wl(e){if(!e||e.length===0)return[];let t=[];for(let r=0;r<e.length;r++){let{address:n,storageKeys:o}=e[r];for(let i=0;i<o.length;i++)if(o[i].length-2!==64)throw new Km({storageKey:o[i]});if(!ne(n,{strict:!1}))throw new xe({address:n});t.push([n,o])}return t}function GC(e,t){let r=xh(e);return r==="eip1559"?RR(e,t):r==="eip2930"?LR(e,t):r==="eip4844"?NR(e,t):r==="eip7702"?OR(e,t):FR(e,t)}function OR(e,t){let{authorizationList:r,chainId:n,gas:o,nonce:i,to:s,value:a,maxFeePerGas:u,maxPriorityFeePerGas:c,accessList:l,data:f}=e;HC(e);let p=Wl(l),d=qC(r);return nt(["0x04",on([O(n),i?O(i):"0x",c?O(c):"0x",u?O(u):"0x",o?O(o):"0x",s??"0x",a?O(a):"0x",f??"0x",p,d,...Fu(e,t)])])}function NR(e,t){let{chainId:r,gas:n,nonce:o,to:i,value:s,maxFeePerBlobGas:a,maxFeePerGas:u,maxPriorityFeePerGas:c,accessList:l,data:f}=e;jC(e);let p=e.blobVersionedHashes,d=e.sidecars;if(e.blobs&&(typeof p>"u"||typeof d>"u")){let y=typeof e.blobs[0]=="string"?e.blobs:e.blobs.map(T=>te(T)),w=e.kzg,v=vu({blobs:y,kzg:w});if(typeof p>"u"&&(p=ph({commitments:v})),typeof d>"u"){let T=Au({blobs:y,commitments:v,kzg:w});d=yh({blobs:y,commitments:v,proofs:T})}}let x=Wl(l),g=[O(r),o?O(o):"0x",c?O(c):"0x",u?O(u):"0x",n?O(n):"0x",i??"0x",s?O(s):"0x",f??"0x",x,a?O(a):"0x",p??[],...Fu(e,t)],b=[],h=[],m=[];if(d)for(let y=0;y<d.length;y++){let{blob:w,commitment:v,proof:T}=d[y];b.push(w),h.push(v),m.push(T)}return nt(["0x03",d?on([g,b,h,m]):on(g)])}function RR(e,t){let{chainId:r,gas:n,nonce:o,to:i,value:s,maxFeePerGas:a,maxPriorityFeePerGas:u,accessList:c,data:l}=e;s0(e);let f=Wl(c),p=[O(r),o?O(o):"0x",u?O(u):"0x",a?O(a):"0x",n?O(n):"0x",i??"0x",s?O(s):"0x",l??"0x",f,...Fu(e,t)];return nt(["0x02",on(p)])}function LR(e,t){let{chainId:r,gas:n,data:o,nonce:i,to:s,value:a,accessList:u,gasPrice:c}=e;WC(e);let l=Wl(u),f=[O(r),i?O(i):"0x",c?O(c):"0x",n?O(n):"0x",s??"0x",a?O(a):"0x",o??"0x",l,...Fu(e,t)];return nt(["0x01",on(f)])}function FR(e,t){let{chainId:r=0,gas:n,data:o,nonce:i,to:s,value:a,gasPrice:u}=e;VC(e);let c=[i?O(i):"0x",u?O(u):"0x",n?O(n):"0x",s??"0x",a?O(a):"0x",o??"0x"];if(t){let l=(()=>{if(t.v>=35n)return(t.v-35n)/2n>0?t.v:27n+(t.v===35n?0n:1n);if(r>0)return BigInt(r*2)+BigInt(35n+t.v-27n);let d=27n+(t.v===27n?0n:1n);if(t.v!==d)throw new qm({v:t.v});return d})(),f=wt(t.r),p=wt(t.s);c=[...c,O(l),f==="0x00"?"0x":f,p==="0x00"?"0x":p]}else r>0&&(c=[...c,O(r),"0x","0x"]);return on(c)}function Fu(e,t){let r=t??e,{v:n,yParity:o}=r;if(typeof r.r>"u")return[];if(typeof r.s>"u")return[];if(typeof n>"u"&&typeof o>"u")return[];let i=wt(r.r),s=wt(r.s);return[typeof o=="number"?o?O(1):"0x":n===0n?"0x":n===1n?O(1):n===27n?"0x":O(1),i==="0x00"?"0x":i,s==="0x00"?"0x":s]}function qC(e){if(!e||e.length===0)return[];let t=[];for(let r of e){let{chainId:n,nonce:o,...i}=r,s=r.address;t.push([n?we(n):"0x",s,o?we(o):"0x",...Fu({},i)])}return t}vt();en();var YC=`Ethereum Signed Message:
|