@human.tech/waap-sdk 2.1.0 → 2.2.0-staging-7f56bf
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/.agent/SKILL.md +179 -0
- package/CHANGELOG.md +69 -0
- package/README.md +264 -94
- package/dist/{WaaPError-XLgIXUgh.d.ts → WaaPError-DCJ9WDaR.d.ts} +1 -1
- package/dist/{WaaPError-C5nPcaKk.d.mts → WaaPError-DgDAQQKF.d.mts} +1 -1
- package/dist/{WalletConnect-G-lbqknM.js → WalletConnect-Dn40Omgo.js} +1 -1
- package/dist/{WalletConnect-Deg7_JmH.mjs → WalletConnect-UfxGn2M_.mjs} +1 -1
- package/dist/{esm-B4jz8Emb.mjs → esm-BUfmyWbN.mjs} +1 -1
- package/dist/esm-DFwVZkjo.js +1 -0
- package/dist/evm-BINU4e1N.mjs +2 -0
- package/dist/evm-BXkH-I90.js +2 -0
- package/dist/evm.d.mts +2 -2
- package/dist/evm.d.ts +2 -2
- package/dist/evm.js +1 -1
- package/dist/evm.mjs +1 -1
- package/dist/{index-CdKntlzX.d.mts → index-C0mLQs_a.d.mts} +44 -28
- package/dist/{index-CMSufeMa.d.ts → index-DOIss_GK.d.ts} +44 -28
- package/dist/index.d.mts +46 -10
- package/dist/index.d.ts +46 -10
- package/dist/index.js +4 -1
- package/dist/index.mjs +4 -1
- package/dist/{initializerContext-0oKHzvQG.d.ts → initializerContext-DIrqEE6B.d.ts} +1 -2
- package/dist/{initializerContext-C39PUnGi.d.mts → initializerContext-_YjbVTiL.d.mts} +1 -2
- package/dist/react.d.mts +1 -1
- package/dist/react.d.ts +1 -1
- package/dist/react.js +1 -1
- package/dist/react.mjs +1 -1
- package/dist/{register-QjrsOe7r.d.mts → register-9bEe9ATz.d.mts} +3 -3
- package/dist/register-BXqcetNF.mjs +1 -0
- package/dist/{register-CNgjA0yl.mjs → register-Bg4jW_HM.mjs} +1 -1
- package/dist/{register-4Afr2Jx8.js → register-CRhge1wE.js} +1 -1
- package/dist/{register-CxsUwgKJ.d.ts → register-Mb1D_xW4.d.ts} +5 -17
- package/dist/{register-CBlzg5ln.d.ts → register-PWKDsSRv.d.ts} +3 -3
- package/dist/{register-LmdJdvzn.d.mts → register-XzDVa7r8.d.mts} +5 -17
- package/dist/{register-ozKwGWOb.js → register-oYvnB41B.js} +1 -1
- package/dist/solana.d.mts +4 -4
- package/dist/solana.d.ts +4 -4
- package/dist/solana.js +1 -1
- package/dist/solana.mjs +1 -1
- package/dist/sui.d.mts +4 -4
- package/dist/sui.d.ts +4 -4
- package/dist/sui.js +1 -1
- package/dist/sui.mjs +1 -1
- package/dist/{types-DexmJNke.d.mts → types-BmCqyQtu.d.mts} +36 -15
- package/dist/{types-DexmJNke.d.ts → types-BmCqyQtu.d.ts} +36 -15
- package/dist/ui-Co16lVSp.mjs +1 -0
- package/dist/ui-lJmATPTt.js +1 -0
- package/dist/{useWaapAuth-Z_ONicYr.js → useWaapAuth-BPvve-_3.js} +1 -1
- package/dist/{useWaapAuth-DHIeb4yc.mjs → useWaapAuth-BcmVGb-D.mjs} +1 -1
- package/dist/{useWaapAuth-BrqAhAn2.d.ts → useWaapAuth-DgYO5KxO.d.ts} +2 -2
- package/dist/{useWaapAuth-C5I7QqyW.d.mts → useWaapAuth-vJAk2n_I.d.mts} +2 -2
- package/dist/walletconnect.js +1 -1
- package/dist/walletconnect.mjs +1 -1
- package/package.json +4 -2
- package/dist/esm-D5fDQenf.js +0 -1
- package/dist/evm-Ch-aWWat.js +0 -1
- package/dist/evm-DHVrAmEw.mjs +0 -1
- package/dist/register-DIZnKDHF.mjs +0 -1
- package/dist/ui-16QpbEyG.js +0 -1
- package/dist/ui-BAYRtDQg.mjs +0 -1
package/dist/solana.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,T as t,d as n,m as r,s as i,w as a,x as o}from"./evm-
|
|
1
|
+
import{S as e,T as t,d as n,m as r,s as i,w as a,x as o}from"./evm-BINU4e1N.mjs";import{r as s,s as c}from"./ui-Co16lVSp.mjs";import{t as l}from"./register-Bg4jW_HM.mjs";export{a as WaaPError,c as WaaPSolanaProvider,n as getWaaPIframeDiagnostics,s as initWaaP,s as initWaaPSolana,t as normalizeWaaPError,i as preloadWaaPOnIdle,l as registerWaaPSolanaWallet,o as resolveWalletOrigin,r as subscribeWaaPIframeLifecycle,e as validateWalletOrigin};
|
package/dist/sui.d.mts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as CancelWaaPPreload, c as preloadWaaPOnIdle, d as WaaPIframeLifecyclePhase, f as getWaaPIframeDiagnostics, i as normalizeWaaPError, l as WaaPIframeDiagnostics, n as WaaPErrorCode, o as WaaPIdlePreloadOptions, p as subscribeWaaPIframeLifecycle, r as WaaPOperationMetadata, s as WaaPPreloadTarget, t as WaaPError, u as WaaPIframeLifecycleEvent } from "./WaaPError-
|
|
3
|
-
import {
|
|
4
|
-
import { n as WaaPSuiWallet, t as registerWaaPSuiWallet } from "./register-
|
|
1
|
+
import { T as RequestPermissionTokenResult, _ as validateWalletOrigin, g as resolveWalletOrigin, h as WaaPWalletTargetOptions, m as WaaPEnvironment, w as RequestPermissionTokenParams } from "./types-BmCqyQtu.mjs";
|
|
2
|
+
import { a as CancelWaaPPreload, c as preloadWaaPOnIdle, d as WaaPIframeLifecyclePhase, f as getWaaPIframeDiagnostics, i as normalizeWaaPError, l as WaaPIframeDiagnostics, n as WaaPErrorCode, o as WaaPIdlePreloadOptions, p as subscribeWaaPIframeLifecycle, r as WaaPOperationMetadata, s as WaaPPreloadTarget, t as WaaPError, u as WaaPIframeLifecycleEvent } from "./WaaPError-DgDAQQKF.mjs";
|
|
3
|
+
import { $ as SuiSignTransactionInput, B as InitWaaPSuiOptions, H as SuiChain, J as SuiSignAndExecuteTransactionOutput, U as SuiConnectInput, V as SuiAccount, W as SuiConnectOutput, X as SuiSignPersonalMessageOutput, Y as SuiSignPersonalMessageInput, et as SuiSignTransactionOutput, it as WaaPSuiWalletInterface, q as SuiSignAndExecuteTransactionInput, rt as WaaPSuiWalletFeatures, tt as SuiTransactionInput, v as initWaaPSui } from "./index-C0mLQs_a.mjs";
|
|
4
|
+
import { n as WaaPSuiWallet, t as registerWaaPSuiWallet } from "./register-XzDVa7r8.mjs";
|
|
5
5
|
export { type CancelWaaPPreload, type InitWaaPSuiOptions, type RequestPermissionTokenParams, type RequestPermissionTokenResult, type SuiAccount, type SuiChain, type SuiConnectInput, type SuiConnectOutput, type SuiSignAndExecuteTransactionInput, type SuiSignAndExecuteTransactionOutput, type SuiSignPersonalMessageInput, type SuiSignPersonalMessageOutput, type SuiSignTransactionInput, type SuiSignTransactionOutput, type SuiTransactionInput, type WaaPEnvironment, WaaPError, type WaaPErrorCode, type WaaPIdlePreloadOptions, type WaaPIframeDiagnostics, type WaaPIframeLifecycleEvent, type WaaPIframeLifecyclePhase, type WaaPOperationMetadata, type WaaPPreloadTarget, WaaPSuiWallet, type WaaPSuiWalletFeatures, type WaaPSuiWalletInterface, type WaaPWalletTargetOptions, getWaaPIframeDiagnostics, initWaaPSui as initWaaP, initWaaPSui, normalizeWaaPError, preloadWaaPOnIdle, registerWaaPSuiWallet, resolveWalletOrigin, subscribeWaaPIframeLifecycle, validateWalletOrigin };
|
package/dist/sui.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as CancelWaaPPreload, c as preloadWaaPOnIdle, d as WaaPIframeLifecyclePhase, f as getWaaPIframeDiagnostics, i as normalizeWaaPError, l as WaaPIframeDiagnostics, n as WaaPErrorCode, o as WaaPIdlePreloadOptions, p as subscribeWaaPIframeLifecycle, r as WaaPOperationMetadata, s as WaaPPreloadTarget, t as WaaPError, u as WaaPIframeLifecycleEvent } from "./WaaPError-
|
|
3
|
-
import {
|
|
4
|
-
import { n as WaaPSuiWallet, t as registerWaaPSuiWallet } from "./register-
|
|
1
|
+
import { T as RequestPermissionTokenResult, _ as validateWalletOrigin, g as resolveWalletOrigin, h as WaaPWalletTargetOptions, m as WaaPEnvironment, w as RequestPermissionTokenParams } from "./types-BmCqyQtu.js";
|
|
2
|
+
import { a as CancelWaaPPreload, c as preloadWaaPOnIdle, d as WaaPIframeLifecyclePhase, f as getWaaPIframeDiagnostics, i as normalizeWaaPError, l as WaaPIframeDiagnostics, n as WaaPErrorCode, o as WaaPIdlePreloadOptions, p as subscribeWaaPIframeLifecycle, r as WaaPOperationMetadata, s as WaaPPreloadTarget, t as WaaPError, u as WaaPIframeLifecycleEvent } from "./WaaPError-DCJ9WDaR.js";
|
|
3
|
+
import { $ as SuiSignTransactionInput, B as InitWaaPSuiOptions, H as SuiChain, J as SuiSignAndExecuteTransactionOutput, U as SuiConnectInput, V as SuiAccount, W as SuiConnectOutput, X as SuiSignPersonalMessageOutput, Y as SuiSignPersonalMessageInput, et as SuiSignTransactionOutput, it as WaaPSuiWalletInterface, q as SuiSignAndExecuteTransactionInput, rt as WaaPSuiWalletFeatures, tt as SuiTransactionInput, v as initWaaPSui } from "./index-DOIss_GK.js";
|
|
4
|
+
import { n as WaaPSuiWallet, t as registerWaaPSuiWallet } from "./register-Mb1D_xW4.js";
|
|
5
5
|
export { type CancelWaaPPreload, type InitWaaPSuiOptions, type RequestPermissionTokenParams, type RequestPermissionTokenResult, type SuiAccount, type SuiChain, type SuiConnectInput, type SuiConnectOutput, type SuiSignAndExecuteTransactionInput, type SuiSignAndExecuteTransactionOutput, type SuiSignPersonalMessageInput, type SuiSignPersonalMessageOutput, type SuiSignTransactionInput, type SuiSignTransactionOutput, type SuiTransactionInput, type WaaPEnvironment, WaaPError, type WaaPErrorCode, type WaaPIdlePreloadOptions, type WaaPIframeDiagnostics, type WaaPIframeLifecycleEvent, type WaaPIframeLifecyclePhase, type WaaPOperationMetadata, type WaaPPreloadTarget, WaaPSuiWallet, type WaaPSuiWalletFeatures, type WaaPSuiWalletInterface, type WaaPWalletTargetOptions, getWaaPIframeDiagnostics, initWaaPSui as initWaaP, initWaaPSui, normalizeWaaPError, preloadWaaPOnIdle, registerWaaPSuiWallet, resolveWalletOrigin, subscribeWaaPIframeLifecycle, validateWalletOrigin };
|
package/dist/sui.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./evm-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./evm-BXkH-I90.js"),t=require("./ui-lJmATPTt.js"),n=require("./register-CRhge1wE.js");exports.WaaPError=e.w,exports.WaaPSuiWallet=t.c,exports.getWaaPIframeDiagnostics=e.d,exports.initWaaP=t.a,exports.initWaaPSui=t.a,exports.normalizeWaaPError=e.T,exports.preloadWaaPOnIdle=e.s,exports.registerWaaPSuiWallet=n.t,exports.resolveWalletOrigin=e.x,exports.subscribeWaaPIframeLifecycle=e.m,exports.validateWalletOrigin=e.S;
|
package/dist/sui.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{S as e,T as t,d as n,m as r,s as i,w as a,x as o}from"./evm-
|
|
1
|
+
import{S as e,T as t,d as n,m as r,s as i,w as a,x as o}from"./evm-BINU4e1N.mjs";import{a as s,c}from"./ui-Co16lVSp.mjs";import{t as l}from"./register-BXqcetNF.mjs";export{a as WaaPError,c as WaaPSuiWallet,n as getWaaPIframeDiagnostics,s as initWaaP,s as initWaaPSui,t as normalizeWaaPError,i as preloadWaaPOnIdle,l as registerWaaPSuiWallet,o as resolveWalletOrigin,r as subscribeWaaPIframeLifecycle,e as validateWalletOrigin};
|
|
@@ -52,6 +52,10 @@ declare enum SILK_METHOD {
|
|
|
52
52
|
waap_getAccountStatus = "waap_getAccountStatus",
|
|
53
53
|
waap_getPermissionTokenStatus = "waap_getPermissionTokenStatus",
|
|
54
54
|
waap_clearPermissionToken = "waap_clearPermissionToken",
|
|
55
|
+
waap_getLinkedAddresses = "waap_getLinkedAddresses",
|
|
56
|
+
waap_linkAddress = "waap_linkAddress",
|
|
57
|
+
waap_unlinkAddress = "waap_unlinkAddress",
|
|
58
|
+
waap_getLinkAddressNonce = "waap_getLinkAddressNonce",
|
|
55
59
|
solana_connect = "solana_connect",
|
|
56
60
|
solana_disconnect = "solana_disconnect",
|
|
57
61
|
solana_signMessage = "solana_signMessage",
|
|
@@ -193,18 +197,32 @@ type CredentialType = 'kyc' | 'phone';
|
|
|
193
197
|
* Parameters for waap_requestPermissionToken RPC method.
|
|
194
198
|
* Apps use this to request a Permission Token from the user.
|
|
195
199
|
*/
|
|
196
|
-
interface
|
|
200
|
+
interface RequestPermissionTokenWireParams {
|
|
197
201
|
/** Canonical `evm:<id>`, `sui:<network>`, or `solana:<network>` chain. */
|
|
198
202
|
chain: `evm:${number}` | `sui:${string}` | `solana:${string}`;
|
|
199
|
-
/**
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
/**
|
|
204
|
+
* The mode the token is bound to. Injected by the SDK from the facade the
|
|
205
|
+
* call was made on — `initWaaP` is `tap`, `initWaaPSquid` is `squid` — and
|
|
206
|
+
* never taken from the caller. A token is not redeemable by the other mode,
|
|
207
|
+
* so a caller-supplied value could only ever bind the wrong one.
|
|
208
|
+
*/
|
|
209
|
+
walletMode: 'tap' | 'squid';
|
|
210
|
+
/**
|
|
211
|
+
* Recipient addresses and explicit application scopes. A plain address is
|
|
212
|
+
* recipient-only; application execution uses `target:*` or a chain-specific
|
|
213
|
+
* exact action such as an EVM selector or Sui `module::function`.
|
|
214
|
+
*/
|
|
202
215
|
allowedAddresses: string[];
|
|
203
216
|
/** Optional USD spend limit; omit or use null for address-only scope. */
|
|
204
217
|
requestedAmountUsd?: number | string | null;
|
|
205
218
|
/** Requested expiry duration in seconds (max 7200 = 2 hours) */
|
|
206
219
|
requestedExpirySeconds: number;
|
|
207
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* What an application passes to `requestPermissionToken`. The wallet mode is
|
|
223
|
+
* absent by construction: the facade already determines it.
|
|
224
|
+
*/
|
|
225
|
+
type RequestPermissionTokenParams = Omit<RequestPermissionTokenWireParams, 'walletMode'>;
|
|
208
226
|
/**
|
|
209
227
|
* Result of waap_requestPermissionToken RPC method.
|
|
210
228
|
*/
|
|
@@ -214,6 +232,12 @@ interface RequestPermissionTokenResult {
|
|
|
214
232
|
/** Error message if the request failed */
|
|
215
233
|
error?: string;
|
|
216
234
|
}
|
|
235
|
+
interface LinkedAddressesResult {
|
|
236
|
+
addresses: string[];
|
|
237
|
+
}
|
|
238
|
+
interface LinkAddressNonceResult {
|
|
239
|
+
nonce: string;
|
|
240
|
+
}
|
|
217
241
|
//#endregion
|
|
218
242
|
//#region src/lib/walletTarget.d.ts
|
|
219
243
|
/** Named wallet deployments understood by the browser SDK. */
|
|
@@ -355,6 +379,9 @@ interface SilkEthereumProviderInterface extends EthereumProviderInterface {
|
|
|
355
379
|
requestPermissionToken(params: RequestPermissionTokenParams): Promise<unknown>;
|
|
356
380
|
getPermissionTokenStatus(query: PermissionTokenQuery): Promise<PermissionTokenStatus>;
|
|
357
381
|
clearPermissionToken(query: PermissionTokenQuery): Promise<PermissionTokenClearResult>;
|
|
382
|
+
getLinkedAddresses(): Promise<string[]>;
|
|
383
|
+
linkAddress(address: string): Promise<string[]>;
|
|
384
|
+
unlinkAddress(address: string): Promise<string[]>;
|
|
358
385
|
toggleDarkMode(): Promise<void>;
|
|
359
386
|
/** Mount (if deferred) and complete the wallet handshake ahead of use. */
|
|
360
387
|
preload(): Promise<void>;
|
|
@@ -366,12 +393,6 @@ interface InitSilkOptions extends WaaPWalletTargetOptions {
|
|
|
366
393
|
project?: ProjectConfig;
|
|
367
394
|
config?: CustomConfig;
|
|
368
395
|
walletConnectProjectId?: string;
|
|
369
|
-
/**
|
|
370
|
-
* Wallet session transport. Defaults to fail-closed DPoP. Select `bearer`
|
|
371
|
-
* only for an integration that cannot use the iframe's WebCrypto/IndexedDB
|
|
372
|
-
* DPoP key.
|
|
373
|
-
*/
|
|
374
|
-
sessionProtection?: WaaPSessionProtection;
|
|
375
396
|
/**
|
|
376
397
|
* When true, the wallet iframe is mounted only by `preload()` or the first
|
|
377
398
|
* wallet operation. The default warms it after the browser becomes idle;
|
|
@@ -379,10 +400,10 @@ interface InitSilkOptions extends WaaPWalletTargetOptions {
|
|
|
379
400
|
*/
|
|
380
401
|
deferIframe?: boolean;
|
|
381
402
|
/**
|
|
382
|
-
* When true, eth_sendTransaction resolves with
|
|
383
|
-
*
|
|
384
|
-
* continue in the background
|
|
385
|
-
*
|
|
403
|
+
* When true, eth_sendTransaction resolves with the deterministic hash of the
|
|
404
|
+
* signed transaction as soon as signing completes. Broadcasting and
|
|
405
|
+
* confirmation continue in the background and report through the
|
|
406
|
+
* `waap_tx_*` lifecycle events.
|
|
386
407
|
* Other signing methods (personal_sign, eth_signTypedData_v4, eth_signTransaction)
|
|
387
408
|
* are unaffected — they always resolve with the signature directly.
|
|
388
409
|
* Applies to ALL eth_sendTransaction calls for this SDK instance.
|
|
@@ -394,4 +415,4 @@ interface InitSilkOptions extends WaaPWalletTargetOptions {
|
|
|
394
415
|
}
|
|
395
416
|
type SilkProvider = SilkEthereumProviderInterface;
|
|
396
417
|
//#endregion
|
|
397
|
-
export {
|
|
418
|
+
export { StylesConfig as A, ProjectConfig as C, SilkRequestCancellation as D, SilkRequest as E, SILK_METHOD as M, SilkNotificationData as N, SilkResponse as O, WaaPSessionProtection as P, LinkedAddressesResult as S, RequestPermissionTokenResult as T, validateWalletOrigin as _, PermissionTokenQuery as a, CustomConfig as b, SilkEthereumProviderInterface as c, WaaPAccountStatus as d, WaaPLoginOptions as f, resolveWalletOrigin as g, WaaPWalletTargetOptions as h, PermissionTokenClearResult as i, JSON_RPC_METHOD as j, SocialProvider as k, SilkProvider as l, WaaPEnvironment as m, InitSilkOptions as n, PermissionTokenStatus as o, WaaPSessionExtension as p, LoginResponse as r, RequestArguments as s, EthereumProviderInterface as t, WaaPAccountMode as u, AuthenticationMethod as v, RequestPermissionTokenParams as w, LinkAddressNonceResult as x, CredentialType as y };
|
|
@@ -52,6 +52,10 @@ declare enum SILK_METHOD {
|
|
|
52
52
|
waap_getAccountStatus = "waap_getAccountStatus",
|
|
53
53
|
waap_getPermissionTokenStatus = "waap_getPermissionTokenStatus",
|
|
54
54
|
waap_clearPermissionToken = "waap_clearPermissionToken",
|
|
55
|
+
waap_getLinkedAddresses = "waap_getLinkedAddresses",
|
|
56
|
+
waap_linkAddress = "waap_linkAddress",
|
|
57
|
+
waap_unlinkAddress = "waap_unlinkAddress",
|
|
58
|
+
waap_getLinkAddressNonce = "waap_getLinkAddressNonce",
|
|
55
59
|
solana_connect = "solana_connect",
|
|
56
60
|
solana_disconnect = "solana_disconnect",
|
|
57
61
|
solana_signMessage = "solana_signMessage",
|
|
@@ -193,18 +197,32 @@ type CredentialType = 'kyc' | 'phone';
|
|
|
193
197
|
* Parameters for waap_requestPermissionToken RPC method.
|
|
194
198
|
* Apps use this to request a Permission Token from the user.
|
|
195
199
|
*/
|
|
196
|
-
interface
|
|
200
|
+
interface RequestPermissionTokenWireParams {
|
|
197
201
|
/** Canonical `evm:<id>`, `sui:<network>`, or `solana:<network>` chain. */
|
|
198
202
|
chain: `evm:${number}` | `sui:${string}` | `solana:${string}`;
|
|
199
|
-
/**
|
|
200
|
-
|
|
201
|
-
|
|
203
|
+
/**
|
|
204
|
+
* The mode the token is bound to. Injected by the SDK from the facade the
|
|
205
|
+
* call was made on — `initWaaP` is `tap`, `initWaaPSquid` is `squid` — and
|
|
206
|
+
* never taken from the caller. A token is not redeemable by the other mode,
|
|
207
|
+
* so a caller-supplied value could only ever bind the wrong one.
|
|
208
|
+
*/
|
|
209
|
+
walletMode: 'tap' | 'squid';
|
|
210
|
+
/**
|
|
211
|
+
* Recipient addresses and explicit application scopes. A plain address is
|
|
212
|
+
* recipient-only; application execution uses `target:*` or a chain-specific
|
|
213
|
+
* exact action such as an EVM selector or Sui `module::function`.
|
|
214
|
+
*/
|
|
202
215
|
allowedAddresses: string[];
|
|
203
216
|
/** Optional USD spend limit; omit or use null for address-only scope. */
|
|
204
217
|
requestedAmountUsd?: number | string | null;
|
|
205
218
|
/** Requested expiry duration in seconds (max 7200 = 2 hours) */
|
|
206
219
|
requestedExpirySeconds: number;
|
|
207
220
|
}
|
|
221
|
+
/**
|
|
222
|
+
* What an application passes to `requestPermissionToken`. The wallet mode is
|
|
223
|
+
* absent by construction: the facade already determines it.
|
|
224
|
+
*/
|
|
225
|
+
type RequestPermissionTokenParams = Omit<RequestPermissionTokenWireParams, 'walletMode'>;
|
|
208
226
|
/**
|
|
209
227
|
* Result of waap_requestPermissionToken RPC method.
|
|
210
228
|
*/
|
|
@@ -214,6 +232,12 @@ interface RequestPermissionTokenResult {
|
|
|
214
232
|
/** Error message if the request failed */
|
|
215
233
|
error?: string;
|
|
216
234
|
}
|
|
235
|
+
interface LinkedAddressesResult {
|
|
236
|
+
addresses: string[];
|
|
237
|
+
}
|
|
238
|
+
interface LinkAddressNonceResult {
|
|
239
|
+
nonce: string;
|
|
240
|
+
}
|
|
217
241
|
//#endregion
|
|
218
242
|
//#region src/lib/walletTarget.d.ts
|
|
219
243
|
/** Named wallet deployments understood by the browser SDK. */
|
|
@@ -355,6 +379,9 @@ interface SilkEthereumProviderInterface extends EthereumProviderInterface {
|
|
|
355
379
|
requestPermissionToken(params: RequestPermissionTokenParams): Promise<unknown>;
|
|
356
380
|
getPermissionTokenStatus(query: PermissionTokenQuery): Promise<PermissionTokenStatus>;
|
|
357
381
|
clearPermissionToken(query: PermissionTokenQuery): Promise<PermissionTokenClearResult>;
|
|
382
|
+
getLinkedAddresses(): Promise<string[]>;
|
|
383
|
+
linkAddress(address: string): Promise<string[]>;
|
|
384
|
+
unlinkAddress(address: string): Promise<string[]>;
|
|
358
385
|
toggleDarkMode(): Promise<void>;
|
|
359
386
|
/** Mount (if deferred) and complete the wallet handshake ahead of use. */
|
|
360
387
|
preload(): Promise<void>;
|
|
@@ -366,12 +393,6 @@ interface InitSilkOptions extends WaaPWalletTargetOptions {
|
|
|
366
393
|
project?: ProjectConfig;
|
|
367
394
|
config?: CustomConfig;
|
|
368
395
|
walletConnectProjectId?: string;
|
|
369
|
-
/**
|
|
370
|
-
* Wallet session transport. Defaults to fail-closed DPoP. Select `bearer`
|
|
371
|
-
* only for an integration that cannot use the iframe's WebCrypto/IndexedDB
|
|
372
|
-
* DPoP key.
|
|
373
|
-
*/
|
|
374
|
-
sessionProtection?: WaaPSessionProtection;
|
|
375
396
|
/**
|
|
376
397
|
* When true, the wallet iframe is mounted only by `preload()` or the first
|
|
377
398
|
* wallet operation. The default warms it after the browser becomes idle;
|
|
@@ -379,10 +400,10 @@ interface InitSilkOptions extends WaaPWalletTargetOptions {
|
|
|
379
400
|
*/
|
|
380
401
|
deferIframe?: boolean;
|
|
381
402
|
/**
|
|
382
|
-
* When true, eth_sendTransaction resolves with
|
|
383
|
-
*
|
|
384
|
-
* continue in the background
|
|
385
|
-
*
|
|
403
|
+
* When true, eth_sendTransaction resolves with the deterministic hash of the
|
|
404
|
+
* signed transaction as soon as signing completes. Broadcasting and
|
|
405
|
+
* confirmation continue in the background and report through the
|
|
406
|
+
* `waap_tx_*` lifecycle events.
|
|
386
407
|
* Other signing methods (personal_sign, eth_signTypedData_v4, eth_signTransaction)
|
|
387
408
|
* are unaffected — they always resolve with the signature directly.
|
|
388
409
|
* Applies to ALL eth_sendTransaction calls for this SDK instance.
|
|
@@ -394,4 +415,4 @@ interface InitSilkOptions extends WaaPWalletTargetOptions {
|
|
|
394
415
|
}
|
|
395
416
|
type SilkProvider = SilkEthereumProviderInterface;
|
|
396
417
|
//#endregion
|
|
397
|
-
export {
|
|
418
|
+
export { StylesConfig as A, ProjectConfig as C, SilkRequestCancellation as D, SilkRequest as E, SILK_METHOD as M, SilkNotificationData as N, SilkResponse as O, WaaPSessionProtection as P, LinkedAddressesResult as S, RequestPermissionTokenResult as T, validateWalletOrigin as _, PermissionTokenQuery as a, CustomConfig as b, SilkEthereumProviderInterface as c, WaaPAccountStatus as d, WaaPLoginOptions as f, resolveWalletOrigin as g, WaaPWalletTargetOptions as h, PermissionTokenClearResult as i, JSON_RPC_METHOD as j, SocialProvider as k, SilkProvider as l, WaaPEnvironment as m, InitSilkOptions as n, PermissionTokenStatus as o, WaaPSessionExtension as p, LoginResponse as r, RequestArguments as s, EthereumProviderInterface as t, WaaPAccountMode as u, AuthenticationMethod as v, RequestPermissionTokenParams as w, LinkAddressNonceResult as x, CredentialType as y };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{r as e}from"./esm-BUfmyWbN.mjs";import{t}from"./asyncSigning-CzqBbYDP.mjs";import{T as n,_ as r,a as i,b as a,c as o,f as s,g as c,h as l,n as u,p as d,s as f,t as p,u as m,v as h,w as g,x as _,y as v}from"./evm-BINU4e1N.mjs";import{EventEmitter as y}from"events";const b={"sui:mainnet":`https://sui-rpc.publicnode.com`,"sui:testnet":`https://sui-testnet-rpc.publicnode.com`,"sui:devnet":`https://fullnode.devnet.sui.io`,"sui:localnet":`http://127.0.0.1:9000`},x=e=>b[e],S=e=>e.slice(4);var C=class{constructor(t,n={},r,a=n){this.lastKnownConversion=`pending`,this.name=`WaaP`,this.version=`1.0.0`,this.icon=`data:image/webp;base64,UklGRpoDAABXRUJQVlA4WAoAAAAQAAAAYwAAYwAAQUxQSDMDAAABJyAQSOFmFxERA8TatqpGoimANbEAxlBAPhSgQP9FyXv3vkcFEf134EZS5DREhGvTM8z0ki8stMRvK4cm8bk5rIu3xNbvkgPk4K6ti5IHquRQnLi6KrdBb81hdyF1jTLM1CW425943iba38/djOcG+dg85p/KXGd/g7+xAzJ2VPWTS8R+q65uA1ZcwG3iZ4urjw9Lh4xn83n3gZmQQ3VMVGEO6D403jdr81Ml1OISAAf7RGImBHISwQ5zCJonTuEyOyP7Sga4cDcjMPgXuiK9cUpaGrIDJtH4iAB25utB8O0DDztOKTr8u9hpX0jrx6k8UM5eAlqsynNxlX9tPRLQEtySKwcDOIDnMqEcek1UnylVNac4r0mlypNvhmCNODlhUXuT4fxTQyrDKY0uyV+gi0iiLLpY76A08C/IX8GQoYb8PcVxK7HkZkT5IjAF4gZicOfJW1ovJjyAlYVPlM6BkkHGI0fniAIZIXC0CbAM92BB8SBznU0ITYLr9XkfnKlDgV8170HGMWwitY51+zxcgkftLD4RLh4HSTIa3QzRWKxlaHZTz21s6GLxnBmjogkVilW4kuaMMMGUfgkZ1JhrBSEANrEDMwucAXgbTqIExY3FYRMdtkQRDFjD6BKtJ2GWTopGRY4P9DBkdE4rp9LJHuYhju45oeVZVv3zNmVdZiIOffHDppOz0Q34p0e/+nXy7JmF1846lmF2ZombLt8pgZpbPNeqpJSVJ0bGd4cH8dUNflNPfdQVXUkC95UQS0ZGfDmOJgjs3IyVOExZBEsxONd080gYK/ftQ2nbYaqGW89Hu7M6avmzXEjhO4G8O8ae8gwWtwZsyp8v8j/ys5H7bM+unOfurO4bbbL4v865Nb8s98Ld2X9yg6tLBQanMP8fhplOMMN8fiNDzTvNOMXGuYzejo12vY7s3clhXwgDPuBIcxi9QZftbKVxAjLCcVQdRxGR1QknhCs3GuieMLzfrrC9RhfJgVpcXRn71nZfEjsiYy/Ca1J7ch0clK64ReH3G/s2cekpP+BIx2YteMvSoLy6G9FCgd1nvF/VoVRtJoNJNLQ0RM3BXY9WgPbcHF78swAAVlA4IEAAAACwBQCdASpkAGQAPpFIoUylpCMiIKgAsBIJaW7hc+AAY2upvcReWAa6m9xF5YBrqb3EXlgGngAA/v81aVcAAAAA`,this._accounts=[],this.accountMode=`tap`,this.loginMethod=null,this._chains=[`sui:mainnet`,`sui:testnet`,`sui:devnet`],this.internalEventEmitter=new y,this.changeListeners=new Set,this.initializerPromise=null,this.initializedIframeWindow=null,this.walletMessageManager=new l(t,_(n)),this.ensureIframe=r,this.iframeMounted=!r,this.initializerOptions=a,this.uiMessageManager=new i,this.walletMessageManager.addListener({handleResponse:e=>{this.internalEventEmitter.emit(e.id,e)},handleRequest:t=>{t.method===e.show_modal?this.uiMessageManager.emit(`show_modal`):t.method===e.hide_modal&&this.uiMessageManager.emit(`hide_modal`)},onAccountChanged:async e=>{try{let e=await this.refreshAccounts();this.notifyChange({accounts:e.accounts})}catch(e){console.error(`Failed to refresh Sui accounts:`,e),this._accounts=[],this.notifyChange({accounts:[]})}}})}destroy(){this.walletMessageManager.dispose(),this.internalEventEmitter.removeAllListeners(),this.uiMessageManager.removeAllListeners(),this.changeListeners.clear(),this._accounts=[]}ensureIframeMounted(){if(this.iframeMounted||!this.ensureIframe)return;let e=this.ensureIframe();if(!e)throw Error(`Failed to create WaaP iframe`);this.iframeMounted=!0,this.walletMessageManager.setIframeWindow(e)}async preload(){if(!this.ensureIframe)return;this.ensureIframeMounted();let e=this.walletMessageManager.getIframeWindow();if(!e)throw Error(`WaaP iframe is not mounted`);if(this.initializedIframeWindow===e&&this.initializerPromise)return this.initializerPromise;this.initializedIframeWindow=e,this.initializerPromise=r(e,()=>this.selectAccountMode(this.accountMode,this.initializerOptions));try{await this.initializerPromise}catch(e){throw this.initializerPromise=null,this.initializedIframeWindow=null,e}}async ensureInitialized(){await this.preload()}async refreshAccounts(){try{await this.ensureInitialized();let e=await this.postRequestAndWait({method:`sui_connect`,params:[{silent:!0}],interactionRequired:!1});if(e.error)return this._accounts=[],{accounts:[]};let t=e.data?.accounts||[];return this._accounts=t,{accounts:this._accounts}}catch{return this._accounts=[],{accounts:[]}}}get chains(){return this._chains}get accounts(){return this._accounts}get ui(){return this.uiMessageManager}getAccountStatus(){return{authenticated:this.loginMethod!==null,loginMethod:this.loginMethod,activeMode:this.loginMethod?this.accountMode:null,mode:this.accountMode,conversion:this.loginMethod?this.lastKnownConversion:`not_required`,tap:null,squid:null,accounts:this._accounts[0]?{sui:this._accounts[0].address}:{}}}get session(){return{login:()=>this.login(),logout:()=>this.logout(),getLoginMethod:()=>this.getLoginMethod(),getAccountStatus:()=>this.getCanonicalAccountStatus()}}async getCanonicalAccountStatus(){await this.ensureInitialized();let t=await this.postRequestAndWait({method:e.waap_getAccountStatus,params:[],interactionRequired:!1});if(t.error)throw Error(t.error.message||`Failed to read WaaP status`);let n=t.data;return this.syncLoginMethodFromCanonicalStatus(n),n?.conversion&&(this.lastKnownConversion=n.conversion),n}setAccountMode(e){this.accountMode=e,this.initializerPromise=null,this.initializedIframeWindow=null}async selectAccountMode(t,n={}){await this.walletMessageManager.pingIframe(),await this.postRequestAndWait({method:e.set_signing_mode,params:[c(t,n)],interactionRequired:!1})}setLoginMethod(e){this.loginMethod=e,e===null&&(this._accounts=[],this.notifyChange({accounts:[]}))}getLoginMethod(){return this.loginMethod}async login(){await this.ensureInitialized();let t=await this.restoreSession();if(t)return t;let n=(await this.postRequestAndWait({method:e.login,params:[],interactionRequired:!0})).data;return n!==`waap`&&n!==`human`&&n!==`injected`&&n!==`walletconnect`?(this.loginMethod=null,null):(this.loginMethod=n,n)}async logout(){this.lastKnownConversion=`pending`,await this.ensureInitialized(),await this.postRequestAndWait({method:e.logout,params:[],interactionRequired:!1}),this.loginMethod=null,this._accounts=[],this.notifyChange({accounts:[]})}async connect(e){if(!this.loginMethod){if(e?.silent)throw new g(`not_authenticated`,`Not authenticated: a silent connect cannot open login.`,{operation:{chain:`sui`,method:`sui_connect`}});if(!await this.login())throw new g(`user_rejected`,`User rejected WaaP login during connect().`,{operation:{chain:`sui`,method:`sui_connect`}})}await this.ensureInitialized();let t=await this.postRequestAndWait({method:`sui_connect`,params:[e||{}],interactionRequired:!e?.silent,signal:e?.signal,timeoutMs:e?.timeoutMs});if(t.error)throw Error(t.error.message||`Failed to connect`);let n=t.data?.accounts||[];return this._accounts=n,this.notifyChange({accounts:this._accounts}),e?.silent||this.internalEventEmitter.emit(`connect`),this.internalEventEmitter.emit(`accountsChanged`,this._accounts.map(e=>e.address)),{accounts:this._accounts}}async restoreSession(){try{let e=await this.getCanonicalAccountStatus();if(e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`))return this.loginMethod=e.loginMethod,e.loginMethod}catch{}return null}syncLoginMethodFromCanonicalStatus(e){let t=e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`)?e.loginMethod:null;t!==this.loginMethod&&this.setLoginMethod(t)}async disconnect(){await this.ensureInitialized(),await this.postRequestAndWait({method:`sui_disconnect`,params:[],interactionRequired:!1}),this._accounts=[],this.notifyChange({accounts:[]})}async signPersonalMessage(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.postRequestAndWait({method:`sui_signPersonalMessage`,params:[{message:Array.from(e.message),account:t,chain:e.chain}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(n.error)throw Error(n.error.message||`Failed to sign message`);return{bytes:n.data.bytes,signature:n.data.signature}}async extractTransferAddresses(e,t=!1){try{let{Transaction:n}=await import(`@mysten/sui/transactions`),r=(t?n.fromKind(e):n.from(e)).getData(),i=[];for(let e of r.commands){if(e.$kind!==`TransferObjects`)continue;let t=e.TransferObjects.address;if(t.$kind!==`Input`)continue;let n=t.Input,a=r.inputs[n];if(!a||a.$kind!==`Pure`)continue;let o=Uint8Array.from(atob(a.Pure.bytes),e=>e.charCodeAt(0));if(o.length!==32)continue;let s=`0x`+Array.from(o).map(e=>e.toString(16).padStart(2,`0`)).join(``);i.push(s)}return i}catch{return[]}}async resolveTransactionBytes(e,t=`sui:mainnet`){if(e instanceof Uint8Array)return{bytes:e,kind:`transaction-data`};if(Array.isArray(e))return{bytes:new Uint8Array(e),kind:`transaction-data`};if(typeof e==`string`)try{return{bytes:Uint8Array.from(atob(e),e=>e.charCodeAt(0)),kind:`transaction-data`}}catch{throw Error(`Transaction string must be base64 encoded bytes. If you have a serialized transaction JSON, please build it to bytes first.`)}else if(e&&typeof e==`object`){if(typeof e.build==`function`)try{let{SuiJsonRpcClient:n}=await import(`@mysten/sui/jsonRpc`),r=S(t),i=new n({url:x(t),network:r});return{bytes:await e.build({client:i,onlyTransactionKind:!0}),kind:`transaction-kind`}}catch(e){throw console.warn(`[SuiWallet] Failed to build transaction object:`,e),Error(`Failed to build transaction: ${e instanceof Error?e.message:String(e)}`)}if(typeof e.serialize==`function`)try{let t=await e.serialize();if(typeof t==`string`)return{bytes:Uint8Array.from(atob(t),e=>e.charCodeAt(0)),kind:`transaction-data`};if(t instanceof Uint8Array)return{bytes:t,kind:`transaction-data`}}catch(e){console.warn(`[SuiWallet] serialize() failed:`,e)}if(typeof e.toJSON==`function`)try{let t=await e.toJSON();if(typeof t==`string`)try{return{bytes:Uint8Array.from(atob(t),e=>e.charCodeAt(0)),kind:`transaction-data`}}catch{try{let e=JSON.parse(t);if(e.bytes&&typeof e.bytes==`string`)return{bytes:Uint8Array.from(atob(e.bytes),e=>e.charCodeAt(0)),kind:`transaction-data`}}catch{}}}catch(e){console.warn(`[SuiWallet] toJSON() failed:`,e)}if(typeof e.getData==`function`)try{let t=e.getData();if(t instanceof Uint8Array)return{bytes:t,kind:`transaction-data`}}catch(e){console.warn(`[SuiWallet] getData() failed:`,e)}throw Error(`Unsupported transaction format. Keys: ${Object.keys(e).join(`, `)}`)}else throw Error(`Unsupported transaction format: ${typeof e}. Please pass Uint8Array bytes or a Transaction object.`)}async signTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.resolveTransactionBytes(e.transaction,e.chain),r=await this.postRequestAndWait({method:`sui_signTransaction`,params:[{...n.kind===`transaction-kind`?{transactionKind:Array.from(n.bytes)}:{transaction:Array.from(n.bytes)},account:t,chain:e.chain,withPT:e.withPT}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(r.error)throw Error(r.error.message||`Failed to sign transaction`);return{bytes:r.data.bytes,signature:r.data.signature}}async signAndExecuteTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.resolveTransactionBytes(e.transaction,e.chain),r=await this.extractTransferAddresses(n.bytes,n.kind===`transaction-kind`),i=await this.postRequestAndWait({method:`sui_signAndExecuteTransaction`,params:[{...n.kind===`transaction-kind`?{transactionKind:Array.from(n.bytes)}:{transaction:Array.from(n.bytes)},account:t,chain:e.chain,options:e.options,requestType:e.requestType,withPT:e.withPT,toAddresses:r.length>0?r:void 0}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(i.error)throw Error(i.error.message||`Failed to sign and execute transaction`);return i.data}async switchChain(e){if(await this.ensureInitialized(),!this._chains.includes(e.chain))throw Error(`Chain ${e.chain} is not supported`);let t=await this.postRequestAndWait({method:`sui_switchChain`,params:[e],interactionRequired:!1});if(t.error)throw Error(t.error.message||`Failed to switch chain`);this.notifyChange({chains:this._chains,accounts:this._accounts})}on(e,t){return e===`change`?(this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}):(this.internalEventEmitter.on(e,t),()=>{this.internalEventEmitter.removeListener(e,t)})}removeListener(e,t){if(e===`change`){this.changeListeners.delete(t);return}this.internalEventEmitter.removeListener(e,t)}get features(){return{"standard:connect":{version:`1.0.0`,connect:this.connect.bind(this)},"standard:disconnect":{version:`1.0.0`,disconnect:this.disconnect.bind(this)},"standard:events":{version:`1.0.0`,on:this.on.bind(this)},"sui:signPersonalMessage":{version:`1.1.0`,signPersonalMessage:this.signPersonalMessage.bind(this)},"sui:signTransaction":{version:`2.0.0`,signTransaction:this.signTransaction.bind(this)},"sui:signAndExecuteTransaction":{version:`1.0.0`,signAndExecuteTransaction:this.signAndExecuteTransaction.bind(this)},"sui:signTransactionBlock":{version:`2.0.0`,signTransactionBlock:this.signTransactionBlock.bind(this)},"sui:signAndExecuteTransactionBlock":{version:`1.0.0`,signAndExecuteTransactionBlock:this.signAndExecuteTransactionBlock.bind(this)},"sui:switchChain":{version:`1.0.0`,switchChain:this.switchChain.bind(this)}}}async signTransactionBlock(e){return this.signTransaction({transaction:e.transactionBlock,account:e.account,chain:e.chain,signal:e.signal,timeoutMs:e.timeoutMs,withPT:e.withPT})}async signAndExecuteTransactionBlock(e){return this.signAndExecuteTransaction({transaction:e.transactionBlock,account:e.account,chain:e.chain,options:e.options,requestType:e.requestType,signal:e.signal,timeoutMs:e.timeoutMs,withPT:e.withPT})}async requestPermissionToken(t){await this.ensureInitialized();let n={...t,walletMode:this.accountMode},r=await this.postRequestAndWait({method:e.waap_requestPermissionToken,params:[n],interactionRequired:!0});if(r.error)throw Error(r.error.message||`Failed to request permission token`);return r.data}async getPermissionTokenStatus(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.waap_getPermissionTokenStatus,params:[t],interactionRequired:!1})).data}async clearPermissionToken(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.waap_clearPermissionToken,params:[t],interactionRequired:!1})).data}async requestEmail(){await this.ensureInitialized();let t=await this.postRequestAndWait({method:e.silk_requestEmail,params:[],interactionRequired:!0});if(t.error)throw Error(t.error.message||`Failed to request email`);return t.data}async postRequestAndWait(t){let r;try{t.interactionRequired&&d({layout:t.method===e.login?`auth`:`signing`}),r=await this.walletMessageManager.postSilkRequest({method:t.method,params:t.params,interactionRequired:t.interactionRequired});let n=await m({eventEmitter:this.internalEventEmitter,id:r,method:t.method,interactionRequired:t.interactionRequired,signal:t.signal,timeoutMs:t.timeoutMs,onCancel:()=>{this.walletMessageManager.cancelSilkRequest(r,t.method),t.interactionRequired&&s()}});if(n.error)throw Error(n.error.message);return n}catch(e){throw t.interactionRequired&&r===void 0&&s(),n(e,{chain:`sui`,method:String(t.method),requestId:r})}}notifyChange(e){Array.from(this.changeListeners).forEach(t=>{t(e)})}};function w(e,t,n=!0){let r=()=>(v(e),h(t).contentWindow),i=e.deferIframe===!1,o=e.deferIframe===void 0,c=i?r():null;if(i&&!c)throw Error(`Failed to create WaaP iframe`);let l=new C(c,e,r,{...e,chains:[`sui`]});l.setAccountMode(t),n&&i&&l.preload().catch(()=>void 0);let u=l.destroy.bind(l);if(l.destroy=()=>{u(),a()},n&&o){let e=f(l),t=l.destroy.bind(l);l.destroy=()=>{e(),t()}}return l.ui.on(`show_modal`,()=>{d(),document.querySelectorAll(`[data-dapp-kit][class*="overlay"]`).forEach(e=>{e.style.display=`none`})}),l.ui.on(`hide_modal`,()=>{s(),document.querySelectorAll(`[data-dapp-kit][class*="overlay"]`).forEach(e=>{e.style.display=``})}),l}var T=class{constructor(t,n={},r,a=n){this.lastKnownConversion=`pending`,this.name=`WaaP`,this.version=`1.0.0`,this.icon=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHJlY3Qgd2lkdGg9IjY0IiBoZWlnaHQ9IjY0IiByeD0iMTYiIGZpbGw9IiMxMTE4MmMiLz48cGF0aCBkPSJNMTYgNDhoMzJMMzIgMTZ6IiBmaWxsPSIjN2NkNGZmIi8+PC9zdmc+`,this._accounts=[],this.accountMode=`tap`,this.loginMethod=null,this._chains=[`solana:mainnet`,`solana:devnet`,`solana:testnet`],this.internalEventEmitter=new y,this.changeListeners=new Set,this.initializerPromise=null,this.initializedIframeWindow=null,this.walletMessageManager=new l(t,_(n)),this.ensureIframe=r,this.iframeMounted=!r,this.initializerOptions=a,this.uiMessageManager=new i,this.walletMessageManager.addListener({handleResponse:e=>{this.internalEventEmitter.emit(e.id,e)},handleRequest:t=>{t.method===e.show_modal?this.uiMessageManager.emit(`show_modal`):t.method===e.hide_modal&&this.uiMessageManager.emit(`hide_modal`)},onAccountChanged:async()=>{try{let e=await this.refreshAccounts();this.notifyChange({accounts:e.accounts})}catch(e){console.error(`Failed to refresh Solana accounts:`,e),this._accounts=[],this.notifyChange({accounts:[]})}}})}destroy(){this.walletMessageManager.dispose(),this.internalEventEmitter.removeAllListeners(),this.uiMessageManager.removeAllListeners(),this.changeListeners.clear(),this._accounts=[]}ensureIframeMounted(){if(this.iframeMounted||!this.ensureIframe)return;let e=this.ensureIframe();if(!e)throw Error(`Failed to create WaaP iframe`);this.iframeMounted=!0,this.walletMessageManager.setIframeWindow(e)}async preload(){if(!this.ensureIframe)return;this.ensureIframeMounted();let e=this.walletMessageManager.getIframeWindow();if(!e)throw Error(`WaaP iframe is not mounted`);if(this.initializedIframeWindow===e&&this.initializerPromise)return this.initializerPromise;this.initializedIframeWindow=e,this.initializerPromise=r(e,()=>this.selectAccountMode(this.accountMode,this.initializerOptions));try{await this.initializerPromise}catch(e){throw this.initializerPromise=null,this.initializedIframeWindow=null,e}}async ensureInitialized(){await this.preload()}get chains(){return this._chains}get accounts(){return this._accounts}get features(){return{"standard:connect":{version:`1.0.0`,connect:this.connect.bind(this)},"standard:disconnect":{version:`1.0.0`,disconnect:this.disconnect.bind(this)},"standard:events":{version:`1.0.0`,on:this.on.bind(this)},"solana:signMessage":{version:`1.1.0`,signMessage:this.signStandardMessages.bind(this)},"solana:signTransaction":{version:`1.0.0`,supportedTransactionVersions:[`legacy`,0],signTransaction:this.signStandardTransactions.bind(this)},"solana:signAndSendTransaction":{version:`1.0.0`,supportedTransactionVersions:[`legacy`,0],signAndSendTransaction:this.signAndSendStandardTransactions.bind(this)}}}get ui(){return this.uiMessageManager}getAccountStatus(){return{authenticated:this.loginMethod!==null,loginMethod:this.loginMethod,activeMode:this.loginMethod?this.accountMode:null,mode:this.accountMode,conversion:this.loginMethod?this.lastKnownConversion:`not_required`,tap:null,squid:null,accounts:this._accounts[0]?{solana:this._accounts[0].address}:{}}}get session(){return{login:()=>this.login(),logout:()=>this.logout(),getLoginMethod:()=>this.getLoginMethod(),getAccountStatus:()=>this.getCanonicalAccountStatus()}}async getCanonicalAccountStatus(){await this.ensureInitialized();let t=await this.postRequestAndWait({method:e.waap_getAccountStatus,params:[],interactionRequired:!1});if(t.error)throw Error(t.error.message||`Failed to read WaaP status`);let n=t.data;return this.syncLoginMethodFromCanonicalStatus(n),n?.conversion&&(this.lastKnownConversion=n.conversion),n}setAccountMode(e){this.accountMode=e,this.initializerPromise=null,this.initializedIframeWindow=null}async selectAccountMode(t,n={}){await this.walletMessageManager.pingIframe(),await this.postRequestAndWait({method:e.set_signing_mode,params:[c(t,n)],interactionRequired:!1})}setLoginMethod(e){this.loginMethod=e,e===null&&(this._accounts=[],this.notifyChange({accounts:[]}))}getLoginMethod(){return this.loginMethod}async login(){await this.ensureInitialized();let t=await this.restoreSession();if(t)return t;let n=(await this.postRequestAndWait({method:e.login,params:[],interactionRequired:!0})).data;return n!==`waap`&&n!==`human`&&n!==`injected`&&n!==`walletconnect`?(this.loginMethod=null,null):(this.loginMethod=n,n)}async logout(){this.lastKnownConversion=`pending`,await this.ensureInitialized(),await this.postRequestAndWait({method:e.logout,params:[],interactionRequired:!1}),this.loginMethod=null,this._accounts=[],this.notifyChange({accounts:[]})}async refreshAccounts(){try{await this.ensureInitialized();let e=await this.postRequestAndWait({method:`solana_connect`,params:[{silent:!0}],interactionRequired:!1});if(e.error)return this._accounts=[],{accounts:[]};let t=this.normalizeAccounts(e.data?.accounts||[]);return this._accounts=t,{accounts:this._accounts}}catch{return this._accounts=[],{accounts:[]}}}normalizeAccounts(e){return e.map(e=>({address:e.address,publicKey:e.publicKey instanceof Uint8Array?e.publicKey:new Uint8Array(e.publicKey??[]),chains:e.chains??this._chains,features:e.features??[]}))}async connect(e){if(!this.loginMethod)throw new g(`not_authenticated`,`Not authenticated: call login() before connect().`,{operation:{chain:`solana`,method:`solana_connect`}});await this.ensureInitialized();let t=await this.postRequestAndWait({method:`solana_connect`,params:[e||{}],interactionRequired:!e?.silent,signal:e?.signal,timeoutMs:e?.timeoutMs});if(t.error)throw Error(t.error.message||`Failed to connect`);let n=this.normalizeAccounts(t.data?.accounts||[]);return this._accounts=n,this.notifyChange({accounts:this._accounts}),e?.silent||this.internalEventEmitter.emit(`connect`),this.internalEventEmitter.emit(`accountsChanged`,this._accounts.map(e=>e.address)),{accounts:this._accounts}}async restoreSession(){try{let e=await this.getCanonicalAccountStatus();if(e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`))return this.loginMethod=e.loginMethod,e.loginMethod}catch{}return null}syncLoginMethodFromCanonicalStatus(e){let t=e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`)?e.loginMethod:null;t!==this.loginMethod&&this.setLoginMethod(t)}async disconnect(){await this.ensureInitialized(),await this.postRequestAndWait({method:`solana_disconnect`,params:[],interactionRequired:!1}),this._accounts=[],this.notifyChange({accounts:[]})}async signMessage(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.postRequestAndWait({method:`solana_signMessage`,params:[{message:Array.from(e.message),account:t}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(n.error)throw Error(n.error.message||`Failed to sign message`);return{signedMessage:new Uint8Array(n.data.signedMessage),signature:new Uint8Array(n.data.signature)}}async signTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=this.resolveTransactionBytes(e.transaction),r=await this.postRequestAndWait({method:`solana_signTransaction`,params:[{transaction:Array.from(n),account:t,chain:e.chain,withPT:e.withPT}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(r.error)throw Error(r.error.message||`Failed to sign transaction`);return{signedTransaction:new Uint8Array(r.data.signedTransaction),signature:new Uint8Array(r.data.signature)}}async signAndSendTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=this.resolveTransactionBytes(e.transaction),r=await this.postRequestAndWait({method:`solana_signAndSendTransaction`,params:[{transaction:Array.from(n),account:t,chain:e.chain,options:e.options,withPT:e.withPT}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(r.error)throw Error(r.error.message||`Failed to sign and send transaction`);return{signature:r.data.signature}}async signStandardMessages(...e){let t=[];for(let n of e){let e=await this.signMessage({account:n.account,message:n.message});t.push({...e,signatureType:`ed25519`})}return t}async signStandardTransactions(...e){let t=[];for(let n of e){let e=await this.signTransaction({account:n.account,transaction:n.transaction,chain:this.asSupportedChain(n.chain)});t.push({signedTransaction:e.signedTransaction})}return t}async signAndSendStandardTransactions(...e){let t=[];for(let n of e){let e=await this.signAndSendTransaction({account:n.account,transaction:n.transaction,chain:this.asSupportedChain(n.chain),options:this.broadcastOptions(n.options)});t.push({signature:E(e.signature)})}return t}asSupportedChain(e){if(e!==void 0){if(this._chains.includes(e))return e;throw new g(`unsupported_input`,`Unsupported Solana Wallet Standard chain: ${e}`,{operation:{chain:`solana`,method:`wallet_standard`}})}}broadcastOptions(e){if(e?.preflightCommitment!==void 0||e?.minContextSlot!==void 0||e?.commitment!==void 0)throw new g(`unsupported_input`,`WaaP does not support Wallet Standard RPC commitment options; configure the dapp RPC instead.`,{operation:{chain:`solana`,method:`wallet_standard`}});return e?{skipPreflight:e.skipPreflight,maxRetries:e.maxRetries}:void 0}async requestPermissionToken(t){await this.ensureInitialized();let n={...t,walletMode:this.accountMode},r=await this.postRequestAndWait({method:e.waap_requestPermissionToken,params:[n],interactionRequired:!0});if(r.error)throw Error(r.error.message||`Failed to request permission token`);return r.data}async getPermissionTokenStatus(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.waap_getPermissionTokenStatus,params:[t],interactionRequired:!1})).data}async clearPermissionToken(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.waap_clearPermissionToken,params:[t],interactionRequired:!1})).data}resolveTransactionBytes(e){if(e instanceof Uint8Array)return e;if(Array.isArray(e))return new Uint8Array(e);if(e&&typeof e.serialize==`function`){let t=e.serialize();return t instanceof Uint8Array?t:new Uint8Array(t)}throw Error(`Unsupported transaction format. Pass serialized bytes or a @solana/web3.js Transaction.`)}on(e,t){return e===`change`?(this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}):(this.internalEventEmitter.on(e,t),()=>{this.internalEventEmitter.removeListener(e,t)})}removeListener(e,t){if(e===`change`){this.changeListeners.delete(t);return}this.internalEventEmitter.removeListener(e,t)}async postRequestAndWait(t){let r;try{t.interactionRequired&&d({layout:t.method===e.login?`auth`:`signing`}),r=await this.walletMessageManager.postSilkRequest({method:t.method,params:t.params,interactionRequired:t.interactionRequired});let n=await m({eventEmitter:this.internalEventEmitter,id:r,method:t.method,interactionRequired:t.interactionRequired,signal:t.signal,timeoutMs:t.timeoutMs,onCancel:()=>{this.walletMessageManager.cancelSilkRequest(r,t.method),t.interactionRequired&&s()}});if(n.error)throw Error(n.error.message);return n}catch(e){throw t.interactionRequired&&r===void 0&&s(),n(e,{chain:`solana`,method:String(t.method),requestId:r})}}notifyChange(e){Array.from(this.changeListeners).forEach(t=>{t(e)})}};function E(e){let t=[];for(let n of e){let e=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`.indexOf(n);if(e<0)throw Error(`Invalid base58 transaction signature`);for(let n=0;n<t.length;n+=1)e+=t[n]*58,t[n]=e&255,e>>=8;for(;e>0;)t.push(e&255),e>>=8}let n=0;for(;n<e.length&&e[n]===`1`;)n+=1;return new Uint8Array([...Array(n).fill(0),...t.reverse()])}function D(e={}){let t=()=>(v(e),h(`tap`).contentWindow),n=e.deferIframe===!1,r=e.deferIframe===void 0,i=n?t():null;if(n&&!i)throw Error(`Failed to create WaaP iframe`);let o=new T(i,e,t,{...e,chains:[`solana`]});n&&o.preload().catch(()=>void 0);let c=o.destroy.bind(o);if(o.destroy=()=>{c(),a()},r){let e=f(o),t=o.destroy.bind(o);o.destroy=()=>{e(),t()}}return o.ui.on(`show_modal`,()=>{d()}),o.ui.on(`hide_modal`,()=>{s()}),o}function O(e={}){if(`chains`in e)throw Error("initWaaP accepts one `chain`; use initWaaPMulti({ chains }) for TAP.");switch(e.chain){case`sui`:return w(e,`tap`);case`solana`:return D(e);default:return p(e)}}const k=[`evm`,`sui`,`solana`],A=[`evm`,`sui`,`solana`];function j(n){let r=Array.from(new Set(n.chains??[]));if(r.length===0)throw Error(`initWaaPSquid requires at least one chain facade`);if(r.some(e=>!k.includes(e)))throw Error(`initWaaPSquid received an unsupported chain facade`);let i=r.includes(`evm`),s=r.includes(`sui`),c=r.includes(`solana`),l=u({referralCode:n.referralCode,config:n.config,project:n.project,environment:n.environment,walletOrigin:n.walletOrigin,useStaging:n.useStaging,walletConnectProjectId:n.walletConnectProjectId,asyncTxs:n.asyncTxs,deferIframe:n.deferIframe},`squid`,!1,r,i),d=s?w(n,`squid`,!1):void 0,p=()=>(v(n),h(`squid`).contentWindow),m=c?new T(n.deferIframe===!1?p():null,{useStaging:n.useStaging,environment:n.environment,walletOrigin:n.walletOrigin,referralCode:n.referralCode,project:n.project,config:n.config,deferIframe:n.deferIframe},p,{...n,chains:[`solana`]}):void 0;m?.setAccountMode(`squid`);let _;n.deferIframe===!1?l.preload().catch(()=>void 0):n.deferIframe===void 0&&(_=f(l));let y={state:`absent`},b=null,x=0,S=()=>{b=null,y={state:`absent`}},C=e=>!e.lifecycleId||e.lifecycleId===b,E=()=>y.state===`active`;l.on(t.squidPending,e=>{if(!C(e))return;let t=e?.transactionDigest;y={state:t?`awaiting-network`:`provisioning`,...t?{operationId:t,transactionDigest:t}:{},...e?.message?{message:e.message}:{}}}),l.on(t.squidReady,e=>{C(e)&&(y={state:`active`})}),l.on(t.squidFailed,e=>{C(e)&&(y={state:`failed`,...e?.error?{message:e.error}:{}},b=null)});let D=e=>{if(l.getLoginMethod()===null)throw new g(`not_authenticated`,`Not authenticated: call login() before connecting or signing.`,{operation:{chain:e,method:`connect`}});if(!E())throw new g(`not_connected`,`Squid is not ready: call onboard() after login before connecting or signing.`)},O=l.request.bind(l);if(l.request=async e=>([`eth_requestAccounts`,`eth_accounts`,`eth_sendTransaction`,`eth_signTransaction`,`personal_sign`,`eth_signTypedData_v4`].includes(e.method)&&D(`evm`),O(e)),d){let e=d.connect.bind(d);d.connect=async t=>(D(`sui`),e(t))}if(m){let e=m.connect.bind(m);m.connect=async t=>(D(`solana`),e(t))}let A=async()=>{if(l.getLoginMethod()===null)throw new g(`not_authenticated`,`Not authenticated: call login() before onboarding Squid.`);if(E()||b)return;let t=`squid-${++x}`;b=t,y={state:`provisioning`};try{await l.walletMessageManager.pingIframe(),await o({method:e.enter_lite_mode,params:[window.location.origin,t]},!1,l.walletMessageManager,l.internalEventEmitter)}catch(e){throw b===t&&(b=null,y={state:`failed`,message:e instanceof Error?e.message:String(e)}),e}},j=()=>({...y}),M=e=>{if(y.state===`active`||!e.authenticated||e.activeMode!==`squid`||!e.squid)return;let n={...b?{lifecycleId:b}:{},evm:e.squid.sqd1.evm,sui:e.squid.sqd2.sui,solana:e.squid.sqd2.solana};y={state:`active`},b=null,l.emit(t.squidReady,n)},N=async()=>(await A(),j()),P=l.login.bind(l),F=async e=>{let t=await P(e);return d?.setLoginMethod(t),m?.setLoginMethod(t),(t?await l.session.getAccountStatus().catch(()=>null):null)?.squid&&(await l.reassertIframeAccountMode().catch(()=>void 0),await A()),t&&l.emit(`connect`),t},I=l.logout.bind(l),L=async()=>{await I(),d?.setLoginMethod(null),m?.setLoginMethod(null),S()},R;R={login:F,logout:L,getLoginMethod:()=>l.getLoginMethod(),getAccountStatus:async()=>{let e=await l.session.getAccountStatus();return M(e),e},getSquidStatus:j,on:(e,t)=>(l.on(e,t),R),removeListener:(e,t)=>(l.removeListener(e,t),R)},l.login=R.login,l.logout=R.logout,d&&(d.login=()=>R.login(),d.logout=()=>R.logout()),m&&(m.login=()=>R.login(),m.logout=()=>R.logout());let z={onboard:A,squid:{onboard:A,getStatus:j,onboardWithStatus:N},getSquidStatus:j,session:R,getAccountStatus:()=>{let e=l.getAccountStatus(),t=d?.getAccountStatus(),n=m?.getAccountStatus();return{authenticated:e.authenticated||!!t?.authenticated||!!n?.authenticated,loginMethod:e.loginMethod??t?.loginMethod??n?.loginMethod??null,activeMode:e.authenticated||t?.authenticated||n?.authenticated?`squid`:null,mode:`squid`,conversion:e.conversion,tap:e.tap,squid:e.squid,accounts:{...e.accounts,...t?.accounts,...n?.accounts}}},preload:()=>l.preload(),destroy:()=>{_?.(),S(),l.destroy(),d?.destroy(),m?.destroy(),a()}};return i&&Object.assign(z,{evm:l,ethereum:l}),d&&Object.assign(z,{sui:d}),m&&Object.assign(z,{solana:m}),k.every(e=>r.includes(e))&&Object.assign(z,{auth:l}),z}function M(e){let t=Array.from(new Set(e.chains));if(t.length===0)throw Error(`initWaaPMulti requires at least one chain facade`);if(t.some(e=>!A.includes(e)))throw Error(`initWaaPMulti received an unsupported chain facade`);let n=t.includes(`evm`),r=t.includes(`sui`),i=t.includes(`solana`),o=u({referralCode:e.referralCode,config:e.config,project:e.project,environment:e.environment,walletOrigin:e.walletOrigin,useStaging:e.useStaging,walletConnectProjectId:e.walletConnectProjectId,asyncTxs:e.asyncTxs,deferIframe:e.deferIframe},`tap`,!1,t,n),s=r?w({...e,config:e.config},`tap`,!1):void 0,c=()=>(v(e),h(`tap`).contentWindow),l=i?new T(e.deferIframe===!1?c():null,{useStaging:e.useStaging,environment:e.environment,walletOrigin:e.walletOrigin,referralCode:e.referralCode,project:e.project,config:e.config,deferIframe:e.deferIframe},c,{...e,chains:[`solana`]}):void 0;l?.setAccountMode(`tap`);let d;e.deferIframe===!1?o.preload().catch(()=>void 0):e.deferIframe===void 0&&(d=f(o));let p=o.login.bind(o),m=async e=>{let t=await p(e);return s?.setLoginMethod(t),l?.setLoginMethod(t),t&&o.emit(`connect`),t},g=o.logout.bind(o),_=async()=>{await g(),s?.setLoginMethod(null),l?.setLoginMethod(null)},y;y={login:m,logout:_,getLoginMethod:()=>o.getLoginMethod(),getAccountStatus:()=>o.session.getAccountStatus(),on:(e,t)=>(o.on(e,t),y),removeListener:(e,t)=>(o.removeListener(e,t),y)},o.login=y.login,o.logout=y.logout,s&&(s.login=()=>y.login(),s.logout=()=>y.logout()),l&&(l.login=()=>y.login(),l.logout=()=>y.logout());let b=()=>{let e=o.getAccountStatus(),t=s?.getAccountStatus(),n=l?.getAccountStatus();return{authenticated:e.authenticated||!!t?.authenticated||!!n?.authenticated,loginMethod:e.loginMethod??t?.loginMethod??n?.loginMethod??null,activeMode:e.authenticated||t?.authenticated||n?.authenticated?`tap`:null,mode:`tap`,conversion:e.conversion,tap:e.tap,squid:e.squid,accounts:{...e.accounts,...t?.accounts,...n?.accounts}}},x=o.destroy.bind(o),S=s?.destroy.bind(s),C=l?.destroy.bind(l),E=()=>{d?.(),x(),S?.(),C?.(),a()},D={session:y,getAccountStatus:b,preload:()=>o.preload(),destroy:E};return n&&(o.destroy=E,Object.assign(D,{evm:o,ethereum:o})),s&&(s.destroy=E,Object.assign(D,{sui:s})),l&&(l.destroy=E,Object.assign(D,{solana:l})),D}function N(e={}){return console.warn("[WaaP SDK] `initWaaPSui()` is deprecated. Use `initWaaP({ chain: 'sui' })` instead."),O({...e,chain:`sui`})}function P(e={}){return O({...e,chain:`solana`})}function F(e={}){return M({...e,chains:e.chains??A})}export{N as a,C as c,j as i,M as n,F as o,P as r,T as s,O as t};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./esm-DFwVZkjo.js"),t=require("./asyncSigning-B0KrmKk7.js"),n=require("./evm-BXkH-I90.js");let r=require("events");const i={"sui:mainnet":`https://sui-rpc.publicnode.com`,"sui:testnet":`https://sui-testnet-rpc.publicnode.com`,"sui:devnet":`https://fullnode.devnet.sui.io`,"sui:localnet":`http://127.0.0.1:9000`},a=e=>i[e],o=e=>e.slice(4);var s=class{constructor(t,i={},a,o=i){this.lastKnownConversion=`pending`,this.name=`WaaP`,this.version=`1.0.0`,this.icon=`data:image/webp;base64,UklGRpoDAABXRUJQVlA4WAoAAAAQAAAAYwAAYwAAQUxQSDMDAAABJyAQSOFmFxERA8TatqpGoimANbEAxlBAPhSgQP9FyXv3vkcFEf134EZS5DREhGvTM8z0ki8stMRvK4cm8bk5rIu3xNbvkgPk4K6ti5IHquRQnLi6KrdBb81hdyF1jTLM1CW425943iba38/djOcG+dg85p/KXGd/g7+xAzJ2VPWTS8R+q65uA1ZcwG3iZ4urjw9Lh4xn83n3gZmQQ3VMVGEO6D403jdr81Ml1OISAAf7RGImBHISwQ5zCJonTuEyOyP7Sga4cDcjMPgXuiK9cUpaGrIDJtH4iAB25utB8O0DDztOKTr8u9hpX0jrx6k8UM5eAlqsynNxlX9tPRLQEtySKwcDOIDnMqEcek1UnylVNac4r0mlypNvhmCNODlhUXuT4fxTQyrDKY0uyV+gi0iiLLpY76A08C/IX8GQoYb8PcVxK7HkZkT5IjAF4gZicOfJW1ovJjyAlYVPlM6BkkHGI0fniAIZIXC0CbAM92BB8SBznU0ITYLr9XkfnKlDgV8170HGMWwitY51+zxcgkftLD4RLh4HSTIa3QzRWKxlaHZTz21s6GLxnBmjogkVilW4kuaMMMGUfgkZ1JhrBSEANrEDMwucAXgbTqIExY3FYRMdtkQRDFjD6BKtJ2GWTopGRY4P9DBkdE4rp9LJHuYhju45oeVZVv3zNmVdZiIOffHDppOz0Q34p0e/+nXy7JmF1846lmF2ZombLt8pgZpbPNeqpJSVJ0bGd4cH8dUNflNPfdQVXUkC95UQS0ZGfDmOJgjs3IyVOExZBEsxONd080gYK/ftQ2nbYaqGW89Hu7M6avmzXEjhO4G8O8ae8gwWtwZsyp8v8j/ys5H7bM+unOfurO4bbbL4v865Nb8s98Ld2X9yg6tLBQanMP8fhplOMMN8fiNDzTvNOMXGuYzejo12vY7s3clhXwgDPuBIcxi9QZftbKVxAjLCcVQdRxGR1QknhCs3GuieMLzfrrC9RhfJgVpcXRn71nZfEjsiYy/Ca1J7ch0clK64ReH3G/s2cekpP+BIx2YteMvSoLy6G9FCgd1nvF/VoVRtJoNJNLQ0RM3BXY9WgPbcHF78swAAVlA4IEAAAACwBQCdASpkAGQAPpFIoUylpCMiIKgAsBIJaW7hc+AAY2upvcReWAa6m9xF5YBrqb3EXlgGngAA/v81aVcAAAAA`,this._accounts=[],this.accountMode=`tap`,this.loginMethod=null,this._chains=[`sui:mainnet`,`sui:testnet`,`sui:devnet`],this.internalEventEmitter=new r.EventEmitter,this.changeListeners=new Set,this.initializerPromise=null,this.initializedIframeWindow=null,this.walletMessageManager=new n.h(t,n.x(i)),this.ensureIframe=a,this.iframeMounted=!a,this.initializerOptions=o,this.uiMessageManager=new n.a,this.walletMessageManager.addListener({handleResponse:e=>{this.internalEventEmitter.emit(e.id,e)},handleRequest:t=>{t.method===e.r.show_modal?this.uiMessageManager.emit(`show_modal`):t.method===e.r.hide_modal&&this.uiMessageManager.emit(`hide_modal`)},onAccountChanged:async e=>{try{let e=await this.refreshAccounts();this.notifyChange({accounts:e.accounts})}catch(e){console.error(`Failed to refresh Sui accounts:`,e),this._accounts=[],this.notifyChange({accounts:[]})}}})}destroy(){this.walletMessageManager.dispose(),this.internalEventEmitter.removeAllListeners(),this.uiMessageManager.removeAllListeners(),this.changeListeners.clear(),this._accounts=[]}ensureIframeMounted(){if(this.iframeMounted||!this.ensureIframe)return;let e=this.ensureIframe();if(!e)throw Error(`Failed to create WaaP iframe`);this.iframeMounted=!0,this.walletMessageManager.setIframeWindow(e)}async preload(){if(!this.ensureIframe)return;this.ensureIframeMounted();let e=this.walletMessageManager.getIframeWindow();if(!e)throw Error(`WaaP iframe is not mounted`);if(this.initializedIframeWindow===e&&this.initializerPromise)return this.initializerPromise;this.initializedIframeWindow=e,this.initializerPromise=n._(e,()=>this.selectAccountMode(this.accountMode,this.initializerOptions));try{await this.initializerPromise}catch(e){throw this.initializerPromise=null,this.initializedIframeWindow=null,e}}async ensureInitialized(){await this.preload()}async refreshAccounts(){try{await this.ensureInitialized();let e=await this.postRequestAndWait({method:`sui_connect`,params:[{silent:!0}],interactionRequired:!1});if(e.error)return this._accounts=[],{accounts:[]};let t=e.data?.accounts||[];return this._accounts=t,{accounts:this._accounts}}catch{return this._accounts=[],{accounts:[]}}}get chains(){return this._chains}get accounts(){return this._accounts}get ui(){return this.uiMessageManager}getAccountStatus(){return{authenticated:this.loginMethod!==null,loginMethod:this.loginMethod,activeMode:this.loginMethod?this.accountMode:null,mode:this.accountMode,conversion:this.loginMethod?this.lastKnownConversion:`not_required`,tap:null,squid:null,accounts:this._accounts[0]?{sui:this._accounts[0].address}:{}}}get session(){return{login:()=>this.login(),logout:()=>this.logout(),getLoginMethod:()=>this.getLoginMethod(),getAccountStatus:()=>this.getCanonicalAccountStatus()}}async getCanonicalAccountStatus(){await this.ensureInitialized();let t=await this.postRequestAndWait({method:e.r.waap_getAccountStatus,params:[],interactionRequired:!1});if(t.error)throw Error(t.error.message||`Failed to read WaaP status`);let n=t.data;return this.syncLoginMethodFromCanonicalStatus(n),n?.conversion&&(this.lastKnownConversion=n.conversion),n}setAccountMode(e){this.accountMode=e,this.initializerPromise=null,this.initializedIframeWindow=null}async selectAccountMode(t,r={}){await this.walletMessageManager.pingIframe(),await this.postRequestAndWait({method:e.r.set_signing_mode,params:[n.g(t,r)],interactionRequired:!1})}setLoginMethod(e){this.loginMethod=e,e===null&&(this._accounts=[],this.notifyChange({accounts:[]}))}getLoginMethod(){return this.loginMethod}async login(){await this.ensureInitialized();let t=await this.restoreSession();if(t)return t;let n=(await this.postRequestAndWait({method:e.r.login,params:[],interactionRequired:!0})).data;return n!==`waap`&&n!==`human`&&n!==`injected`&&n!==`walletconnect`?(this.loginMethod=null,null):(this.loginMethod=n,n)}async logout(){this.lastKnownConversion=`pending`,await this.ensureInitialized(),await this.postRequestAndWait({method:e.r.logout,params:[],interactionRequired:!1}),this.loginMethod=null,this._accounts=[],this.notifyChange({accounts:[]})}async connect(e){if(!this.loginMethod){if(e?.silent)throw new n.w(`not_authenticated`,`Not authenticated: a silent connect cannot open login.`,{operation:{chain:`sui`,method:`sui_connect`}});if(!await this.login())throw new n.w(`user_rejected`,`User rejected WaaP login during connect().`,{operation:{chain:`sui`,method:`sui_connect`}})}await this.ensureInitialized();let t=await this.postRequestAndWait({method:`sui_connect`,params:[e||{}],interactionRequired:!e?.silent,signal:e?.signal,timeoutMs:e?.timeoutMs});if(t.error)throw Error(t.error.message||`Failed to connect`);let r=t.data?.accounts||[];return this._accounts=r,this.notifyChange({accounts:this._accounts}),e?.silent||this.internalEventEmitter.emit(`connect`),this.internalEventEmitter.emit(`accountsChanged`,this._accounts.map(e=>e.address)),{accounts:this._accounts}}async restoreSession(){try{let e=await this.getCanonicalAccountStatus();if(e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`))return this.loginMethod=e.loginMethod,e.loginMethod}catch{}return null}syncLoginMethodFromCanonicalStatus(e){let t=e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`)?e.loginMethod:null;t!==this.loginMethod&&this.setLoginMethod(t)}async disconnect(){await this.ensureInitialized(),await this.postRequestAndWait({method:`sui_disconnect`,params:[],interactionRequired:!1}),this._accounts=[],this.notifyChange({accounts:[]})}async signPersonalMessage(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.postRequestAndWait({method:`sui_signPersonalMessage`,params:[{message:Array.from(e.message),account:t,chain:e.chain}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(n.error)throw Error(n.error.message||`Failed to sign message`);return{bytes:n.data.bytes,signature:n.data.signature}}async extractTransferAddresses(e,t=!1){try{let{Transaction:n}=await import(`@mysten/sui/transactions`),r=(t?n.fromKind(e):n.from(e)).getData(),i=[];for(let e of r.commands){if(e.$kind!==`TransferObjects`)continue;let t=e.TransferObjects.address;if(t.$kind!==`Input`)continue;let n=t.Input,a=r.inputs[n];if(!a||a.$kind!==`Pure`)continue;let o=Uint8Array.from(atob(a.Pure.bytes),e=>e.charCodeAt(0));if(o.length!==32)continue;let s=`0x`+Array.from(o).map(e=>e.toString(16).padStart(2,`0`)).join(``);i.push(s)}return i}catch{return[]}}async resolveTransactionBytes(e,t=`sui:mainnet`){if(e instanceof Uint8Array)return{bytes:e,kind:`transaction-data`};if(Array.isArray(e))return{bytes:new Uint8Array(e),kind:`transaction-data`};if(typeof e==`string`)try{return{bytes:Uint8Array.from(atob(e),e=>e.charCodeAt(0)),kind:`transaction-data`}}catch{throw Error(`Transaction string must be base64 encoded bytes. If you have a serialized transaction JSON, please build it to bytes first.`)}else if(e&&typeof e==`object`){if(typeof e.build==`function`)try{let{SuiJsonRpcClient:n}=await import(`@mysten/sui/jsonRpc`),r=o(t),i=new n({url:a(t),network:r});return{bytes:await e.build({client:i,onlyTransactionKind:!0}),kind:`transaction-kind`}}catch(e){throw console.warn(`[SuiWallet] Failed to build transaction object:`,e),Error(`Failed to build transaction: ${e instanceof Error?e.message:String(e)}`)}if(typeof e.serialize==`function`)try{let t=await e.serialize();if(typeof t==`string`)return{bytes:Uint8Array.from(atob(t),e=>e.charCodeAt(0)),kind:`transaction-data`};if(t instanceof Uint8Array)return{bytes:t,kind:`transaction-data`}}catch(e){console.warn(`[SuiWallet] serialize() failed:`,e)}if(typeof e.toJSON==`function`)try{let t=await e.toJSON();if(typeof t==`string`)try{return{bytes:Uint8Array.from(atob(t),e=>e.charCodeAt(0)),kind:`transaction-data`}}catch{try{let e=JSON.parse(t);if(e.bytes&&typeof e.bytes==`string`)return{bytes:Uint8Array.from(atob(e.bytes),e=>e.charCodeAt(0)),kind:`transaction-data`}}catch{}}}catch(e){console.warn(`[SuiWallet] toJSON() failed:`,e)}if(typeof e.getData==`function`)try{let t=e.getData();if(t instanceof Uint8Array)return{bytes:t,kind:`transaction-data`}}catch(e){console.warn(`[SuiWallet] getData() failed:`,e)}throw Error(`Unsupported transaction format. Keys: ${Object.keys(e).join(`, `)}`)}else throw Error(`Unsupported transaction format: ${typeof e}. Please pass Uint8Array bytes or a Transaction object.`)}async signTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.resolveTransactionBytes(e.transaction,e.chain),r=await this.postRequestAndWait({method:`sui_signTransaction`,params:[{...n.kind===`transaction-kind`?{transactionKind:Array.from(n.bytes)}:{transaction:Array.from(n.bytes)},account:t,chain:e.chain,withPT:e.withPT}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(r.error)throw Error(r.error.message||`Failed to sign transaction`);return{bytes:r.data.bytes,signature:r.data.signature}}async signAndExecuteTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.resolveTransactionBytes(e.transaction,e.chain),r=await this.extractTransferAddresses(n.bytes,n.kind===`transaction-kind`),i=await this.postRequestAndWait({method:`sui_signAndExecuteTransaction`,params:[{...n.kind===`transaction-kind`?{transactionKind:Array.from(n.bytes)}:{transaction:Array.from(n.bytes)},account:t,chain:e.chain,options:e.options,requestType:e.requestType,withPT:e.withPT,toAddresses:r.length>0?r:void 0}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(i.error)throw Error(i.error.message||`Failed to sign and execute transaction`);return i.data}async switchChain(e){if(await this.ensureInitialized(),!this._chains.includes(e.chain))throw Error(`Chain ${e.chain} is not supported`);let t=await this.postRequestAndWait({method:`sui_switchChain`,params:[e],interactionRequired:!1});if(t.error)throw Error(t.error.message||`Failed to switch chain`);this.notifyChange({chains:this._chains,accounts:this._accounts})}on(e,t){return e===`change`?(this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}):(this.internalEventEmitter.on(e,t),()=>{this.internalEventEmitter.removeListener(e,t)})}removeListener(e,t){if(e===`change`){this.changeListeners.delete(t);return}this.internalEventEmitter.removeListener(e,t)}get features(){return{"standard:connect":{version:`1.0.0`,connect:this.connect.bind(this)},"standard:disconnect":{version:`1.0.0`,disconnect:this.disconnect.bind(this)},"standard:events":{version:`1.0.0`,on:this.on.bind(this)},"sui:signPersonalMessage":{version:`1.1.0`,signPersonalMessage:this.signPersonalMessage.bind(this)},"sui:signTransaction":{version:`2.0.0`,signTransaction:this.signTransaction.bind(this)},"sui:signAndExecuteTransaction":{version:`1.0.0`,signAndExecuteTransaction:this.signAndExecuteTransaction.bind(this)},"sui:signTransactionBlock":{version:`2.0.0`,signTransactionBlock:this.signTransactionBlock.bind(this)},"sui:signAndExecuteTransactionBlock":{version:`1.0.0`,signAndExecuteTransactionBlock:this.signAndExecuteTransactionBlock.bind(this)},"sui:switchChain":{version:`1.0.0`,switchChain:this.switchChain.bind(this)}}}async signTransactionBlock(e){return this.signTransaction({transaction:e.transactionBlock,account:e.account,chain:e.chain,signal:e.signal,timeoutMs:e.timeoutMs,withPT:e.withPT})}async signAndExecuteTransactionBlock(e){return this.signAndExecuteTransaction({transaction:e.transactionBlock,account:e.account,chain:e.chain,options:e.options,requestType:e.requestType,signal:e.signal,timeoutMs:e.timeoutMs,withPT:e.withPT})}async requestPermissionToken(t){await this.ensureInitialized();let n={...t,walletMode:this.accountMode},r=await this.postRequestAndWait({method:e.r.waap_requestPermissionToken,params:[n],interactionRequired:!0});if(r.error)throw Error(r.error.message||`Failed to request permission token`);return r.data}async getPermissionTokenStatus(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.r.waap_getPermissionTokenStatus,params:[t],interactionRequired:!1})).data}async clearPermissionToken(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.r.waap_clearPermissionToken,params:[t],interactionRequired:!1})).data}async requestEmail(){await this.ensureInitialized();let t=await this.postRequestAndWait({method:e.r.silk_requestEmail,params:[],interactionRequired:!0});if(t.error)throw Error(t.error.message||`Failed to request email`);return t.data}async postRequestAndWait(t){let r;try{t.interactionRequired&&n.p({layout:t.method===e.r.login?`auth`:`signing`}),r=await this.walletMessageManager.postSilkRequest({method:t.method,params:t.params,interactionRequired:t.interactionRequired});let i=await n.u({eventEmitter:this.internalEventEmitter,id:r,method:t.method,interactionRequired:t.interactionRequired,signal:t.signal,timeoutMs:t.timeoutMs,onCancel:()=>{this.walletMessageManager.cancelSilkRequest(r,t.method),t.interactionRequired&&n.f()}});if(i.error)throw Error(i.error.message);return i}catch(e){throw t.interactionRequired&&r===void 0&&n.f(),n.T(e,{chain:`sui`,method:String(t.method),requestId:r})}}notifyChange(e){Array.from(this.changeListeners).forEach(t=>{t(e)})}};function c(e,t,r=!0){let i=()=>(n.y(e),n.v(t).contentWindow),a=e.deferIframe===!1,o=e.deferIframe===void 0,c=a?i():null;if(a&&!c)throw Error(`Failed to create WaaP iframe`);let l=new s(c,e,i,{...e,chains:[`sui`]});l.setAccountMode(t),r&&a&&l.preload().catch(()=>void 0);let u=l.destroy.bind(l);if(l.destroy=()=>{u(),n.b()},r&&o){let e=n.s(l),t=l.destroy.bind(l);l.destroy=()=>{e(),t()}}return l.ui.on(`show_modal`,()=>{n.p(),document.querySelectorAll(`[data-dapp-kit][class*="overlay"]`).forEach(e=>{e.style.display=`none`})}),l.ui.on(`hide_modal`,()=>{n.f(),document.querySelectorAll(`[data-dapp-kit][class*="overlay"]`).forEach(e=>{e.style.display=``})}),l}var l=class{constructor(t,i={},a,o=i){this.lastKnownConversion=`pending`,this.name=`WaaP`,this.version=`1.0.0`,this.icon=`data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHZpZXdCb3g9IjAgMCA2NCA2NCI+PHJlY3Qgd2lkdGg9IjY0IiBoZWlnaHQ9IjY0IiByeD0iMTYiIGZpbGw9IiMxMTE4MmMiLz48cGF0aCBkPSJNMTYgNDhoMzJMMzIgMTZ6IiBmaWxsPSIjN2NkNGZmIi8+PC9zdmc+`,this._accounts=[],this.accountMode=`tap`,this.loginMethod=null,this._chains=[`solana:mainnet`,`solana:devnet`,`solana:testnet`],this.internalEventEmitter=new r.EventEmitter,this.changeListeners=new Set,this.initializerPromise=null,this.initializedIframeWindow=null,this.walletMessageManager=new n.h(t,n.x(i)),this.ensureIframe=a,this.iframeMounted=!a,this.initializerOptions=o,this.uiMessageManager=new n.a,this.walletMessageManager.addListener({handleResponse:e=>{this.internalEventEmitter.emit(e.id,e)},handleRequest:t=>{t.method===e.r.show_modal?this.uiMessageManager.emit(`show_modal`):t.method===e.r.hide_modal&&this.uiMessageManager.emit(`hide_modal`)},onAccountChanged:async()=>{try{let e=await this.refreshAccounts();this.notifyChange({accounts:e.accounts})}catch(e){console.error(`Failed to refresh Solana accounts:`,e),this._accounts=[],this.notifyChange({accounts:[]})}}})}destroy(){this.walletMessageManager.dispose(),this.internalEventEmitter.removeAllListeners(),this.uiMessageManager.removeAllListeners(),this.changeListeners.clear(),this._accounts=[]}ensureIframeMounted(){if(this.iframeMounted||!this.ensureIframe)return;let e=this.ensureIframe();if(!e)throw Error(`Failed to create WaaP iframe`);this.iframeMounted=!0,this.walletMessageManager.setIframeWindow(e)}async preload(){if(!this.ensureIframe)return;this.ensureIframeMounted();let e=this.walletMessageManager.getIframeWindow();if(!e)throw Error(`WaaP iframe is not mounted`);if(this.initializedIframeWindow===e&&this.initializerPromise)return this.initializerPromise;this.initializedIframeWindow=e,this.initializerPromise=n._(e,()=>this.selectAccountMode(this.accountMode,this.initializerOptions));try{await this.initializerPromise}catch(e){throw this.initializerPromise=null,this.initializedIframeWindow=null,e}}async ensureInitialized(){await this.preload()}get chains(){return this._chains}get accounts(){return this._accounts}get features(){return{"standard:connect":{version:`1.0.0`,connect:this.connect.bind(this)},"standard:disconnect":{version:`1.0.0`,disconnect:this.disconnect.bind(this)},"standard:events":{version:`1.0.0`,on:this.on.bind(this)},"solana:signMessage":{version:`1.1.0`,signMessage:this.signStandardMessages.bind(this)},"solana:signTransaction":{version:`1.0.0`,supportedTransactionVersions:[`legacy`,0],signTransaction:this.signStandardTransactions.bind(this)},"solana:signAndSendTransaction":{version:`1.0.0`,supportedTransactionVersions:[`legacy`,0],signAndSendTransaction:this.signAndSendStandardTransactions.bind(this)}}}get ui(){return this.uiMessageManager}getAccountStatus(){return{authenticated:this.loginMethod!==null,loginMethod:this.loginMethod,activeMode:this.loginMethod?this.accountMode:null,mode:this.accountMode,conversion:this.loginMethod?this.lastKnownConversion:`not_required`,tap:null,squid:null,accounts:this._accounts[0]?{solana:this._accounts[0].address}:{}}}get session(){return{login:()=>this.login(),logout:()=>this.logout(),getLoginMethod:()=>this.getLoginMethod(),getAccountStatus:()=>this.getCanonicalAccountStatus()}}async getCanonicalAccountStatus(){await this.ensureInitialized();let t=await this.postRequestAndWait({method:e.r.waap_getAccountStatus,params:[],interactionRequired:!1});if(t.error)throw Error(t.error.message||`Failed to read WaaP status`);let n=t.data;return this.syncLoginMethodFromCanonicalStatus(n),n?.conversion&&(this.lastKnownConversion=n.conversion),n}setAccountMode(e){this.accountMode=e,this.initializerPromise=null,this.initializedIframeWindow=null}async selectAccountMode(t,r={}){await this.walletMessageManager.pingIframe(),await this.postRequestAndWait({method:e.r.set_signing_mode,params:[n.g(t,r)],interactionRequired:!1})}setLoginMethod(e){this.loginMethod=e,e===null&&(this._accounts=[],this.notifyChange({accounts:[]}))}getLoginMethod(){return this.loginMethod}async login(){await this.ensureInitialized();let t=await this.restoreSession();if(t)return t;let n=(await this.postRequestAndWait({method:e.r.login,params:[],interactionRequired:!0})).data;return n!==`waap`&&n!==`human`&&n!==`injected`&&n!==`walletconnect`?(this.loginMethod=null,null):(this.loginMethod=n,n)}async logout(){this.lastKnownConversion=`pending`,await this.ensureInitialized(),await this.postRequestAndWait({method:e.r.logout,params:[],interactionRequired:!1}),this.loginMethod=null,this._accounts=[],this.notifyChange({accounts:[]})}async refreshAccounts(){try{await this.ensureInitialized();let e=await this.postRequestAndWait({method:`solana_connect`,params:[{silent:!0}],interactionRequired:!1});if(e.error)return this._accounts=[],{accounts:[]};let t=this.normalizeAccounts(e.data?.accounts||[]);return this._accounts=t,{accounts:this._accounts}}catch{return this._accounts=[],{accounts:[]}}}normalizeAccounts(e){return e.map(e=>({address:e.address,publicKey:e.publicKey instanceof Uint8Array?e.publicKey:new Uint8Array(e.publicKey??[]),chains:e.chains??this._chains,features:e.features??[]}))}async connect(e){if(!this.loginMethod)throw new n.w(`not_authenticated`,`Not authenticated: call login() before connect().`,{operation:{chain:`solana`,method:`solana_connect`}});await this.ensureInitialized();let t=await this.postRequestAndWait({method:`solana_connect`,params:[e||{}],interactionRequired:!e?.silent,signal:e?.signal,timeoutMs:e?.timeoutMs});if(t.error)throw Error(t.error.message||`Failed to connect`);let r=this.normalizeAccounts(t.data?.accounts||[]);return this._accounts=r,this.notifyChange({accounts:this._accounts}),e?.silent||this.internalEventEmitter.emit(`connect`),this.internalEventEmitter.emit(`accountsChanged`,this._accounts.map(e=>e.address)),{accounts:this._accounts}}async restoreSession(){try{let e=await this.getCanonicalAccountStatus();if(e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`))return this.loginMethod=e.loginMethod,e.loginMethod}catch{}return null}syncLoginMethodFromCanonicalStatus(e){let t=e.authenticated&&(e.loginMethod===`waap`||e.loginMethod===`human`||e.loginMethod===`injected`||e.loginMethod===`walletconnect`)?e.loginMethod:null;t!==this.loginMethod&&this.setLoginMethod(t)}async disconnect(){await this.ensureInitialized(),await this.postRequestAndWait({method:`solana_disconnect`,params:[],interactionRequired:!1}),this._accounts=[],this.notifyChange({accounts:[]})}async signMessage(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=await this.postRequestAndWait({method:`solana_signMessage`,params:[{message:Array.from(e.message),account:t}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(n.error)throw Error(n.error.message||`Failed to sign message`);return{signedMessage:new Uint8Array(n.data.signedMessage),signature:new Uint8Array(n.data.signature)}}async signTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=this.resolveTransactionBytes(e.transaction),r=await this.postRequestAndWait({method:`solana_signTransaction`,params:[{transaction:Array.from(n),account:t,chain:e.chain,withPT:e.withPT}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(r.error)throw Error(r.error.message||`Failed to sign transaction`);return{signedTransaction:new Uint8Array(r.data.signedTransaction),signature:new Uint8Array(r.data.signature)}}async signAndSendTransaction(e){await this.ensureInitialized();let t=e.account.address;if(!this._accounts.some(e=>e.address===t))throw Error(`Account ${t} is not connected`);let n=this.resolveTransactionBytes(e.transaction),r=await this.postRequestAndWait({method:`solana_signAndSendTransaction`,params:[{transaction:Array.from(n),account:t,chain:e.chain,options:e.options,withPT:e.withPT}],interactionRequired:!0,signal:e.signal,timeoutMs:e.timeoutMs});if(r.error)throw Error(r.error.message||`Failed to sign and send transaction`);return{signature:r.data.signature}}async signStandardMessages(...e){let t=[];for(let n of e){let e=await this.signMessage({account:n.account,message:n.message});t.push({...e,signatureType:`ed25519`})}return t}async signStandardTransactions(...e){let t=[];for(let n of e){let e=await this.signTransaction({account:n.account,transaction:n.transaction,chain:this.asSupportedChain(n.chain)});t.push({signedTransaction:e.signedTransaction})}return t}async signAndSendStandardTransactions(...e){let t=[];for(let n of e){let e=await this.signAndSendTransaction({account:n.account,transaction:n.transaction,chain:this.asSupportedChain(n.chain),options:this.broadcastOptions(n.options)});t.push({signature:u(e.signature)})}return t}asSupportedChain(e){if(e!==void 0){if(this._chains.includes(e))return e;throw new n.w(`unsupported_input`,`Unsupported Solana Wallet Standard chain: ${e}`,{operation:{chain:`solana`,method:`wallet_standard`}})}}broadcastOptions(e){if(e?.preflightCommitment!==void 0||e?.minContextSlot!==void 0||e?.commitment!==void 0)throw new n.w(`unsupported_input`,`WaaP does not support Wallet Standard RPC commitment options; configure the dapp RPC instead.`,{operation:{chain:`solana`,method:`wallet_standard`}});return e?{skipPreflight:e.skipPreflight,maxRetries:e.maxRetries}:void 0}async requestPermissionToken(t){await this.ensureInitialized();let n={...t,walletMode:this.accountMode},r=await this.postRequestAndWait({method:e.r.waap_requestPermissionToken,params:[n],interactionRequired:!0});if(r.error)throw Error(r.error.message||`Failed to request permission token`);return r.data}async getPermissionTokenStatus(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.r.waap_getPermissionTokenStatus,params:[t],interactionRequired:!1})).data}async clearPermissionToken(t){return await this.ensureInitialized(),(await this.postRequestAndWait({method:e.r.waap_clearPermissionToken,params:[t],interactionRequired:!1})).data}resolveTransactionBytes(e){if(e instanceof Uint8Array)return e;if(Array.isArray(e))return new Uint8Array(e);if(e&&typeof e.serialize==`function`){let t=e.serialize();return t instanceof Uint8Array?t:new Uint8Array(t)}throw Error(`Unsupported transaction format. Pass serialized bytes or a @solana/web3.js Transaction.`)}on(e,t){return e===`change`?(this.changeListeners.add(t),()=>{this.changeListeners.delete(t)}):(this.internalEventEmitter.on(e,t),()=>{this.internalEventEmitter.removeListener(e,t)})}removeListener(e,t){if(e===`change`){this.changeListeners.delete(t);return}this.internalEventEmitter.removeListener(e,t)}async postRequestAndWait(t){let r;try{t.interactionRequired&&n.p({layout:t.method===e.r.login?`auth`:`signing`}),r=await this.walletMessageManager.postSilkRequest({method:t.method,params:t.params,interactionRequired:t.interactionRequired});let i=await n.u({eventEmitter:this.internalEventEmitter,id:r,method:t.method,interactionRequired:t.interactionRequired,signal:t.signal,timeoutMs:t.timeoutMs,onCancel:()=>{this.walletMessageManager.cancelSilkRequest(r,t.method),t.interactionRequired&&n.f()}});if(i.error)throw Error(i.error.message);return i}catch(e){throw t.interactionRequired&&r===void 0&&n.f(),n.T(e,{chain:`solana`,method:String(t.method),requestId:r})}}notifyChange(e){Array.from(this.changeListeners).forEach(t=>{t(e)})}};function u(e){let t=[];for(let n of e){let e=`123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz`.indexOf(n);if(e<0)throw Error(`Invalid base58 transaction signature`);for(let n=0;n<t.length;n+=1)e+=t[n]*58,t[n]=e&255,e>>=8;for(;e>0;)t.push(e&255),e>>=8}let n=0;for(;n<e.length&&e[n]===`1`;)n+=1;return new Uint8Array([...Array(n).fill(0),...t.reverse()])}function d(e={}){let t=()=>(n.y(e),n.v(`tap`).contentWindow),r=e.deferIframe===!1,i=e.deferIframe===void 0,a=r?t():null;if(r&&!a)throw Error(`Failed to create WaaP iframe`);let o=new l(a,e,t,{...e,chains:[`solana`]});r&&o.preload().catch(()=>void 0);let s=o.destroy.bind(o);if(o.destroy=()=>{s(),n.b()},i){let e=n.s(o),t=o.destroy.bind(o);o.destroy=()=>{e(),t()}}return o.ui.on(`show_modal`,()=>{n.p()}),o.ui.on(`hide_modal`,()=>{n.f()}),o}function f(e={}){if(`chains`in e)throw Error("initWaaP accepts one `chain`; use initWaaPMulti({ chains }) for TAP.");switch(e.chain){case`sui`:return c(e,`tap`);case`solana`:return d(e);default:return n.t(e)}}const p=[`evm`,`sui`,`solana`],m=[`evm`,`sui`,`solana`];function h(r){let i=Array.from(new Set(r.chains??[]));if(i.length===0)throw Error(`initWaaPSquid requires at least one chain facade`);if(i.some(e=>!p.includes(e)))throw Error(`initWaaPSquid received an unsupported chain facade`);let a=i.includes(`evm`),o=i.includes(`sui`),s=i.includes(`solana`),u=n.n({referralCode:r.referralCode,config:r.config,project:r.project,environment:r.environment,walletOrigin:r.walletOrigin,useStaging:r.useStaging,walletConnectProjectId:r.walletConnectProjectId,asyncTxs:r.asyncTxs,deferIframe:r.deferIframe},`squid`,!1,i,a),d=o?c(r,`squid`,!1):void 0,f=()=>(n.y(r),n.v(`squid`).contentWindow),m=s?new l(r.deferIframe===!1?f():null,{useStaging:r.useStaging,environment:r.environment,walletOrigin:r.walletOrigin,referralCode:r.referralCode,project:r.project,config:r.config,deferIframe:r.deferIframe},f,{...r,chains:[`solana`]}):void 0;m?.setAccountMode(`squid`);let h;r.deferIframe===!1?u.preload().catch(()=>void 0):r.deferIframe===void 0&&(h=n.s(u));let g={state:`absent`},_=null,v=0,y=()=>{_=null,g={state:`absent`}},b=e=>!e.lifecycleId||e.lifecycleId===_,x=()=>g.state===`active`;u.on(t.t.squidPending,e=>{if(!b(e))return;let t=e?.transactionDigest;g={state:t?`awaiting-network`:`provisioning`,...t?{operationId:t,transactionDigest:t}:{},...e?.message?{message:e.message}:{}}}),u.on(t.t.squidReady,e=>{b(e)&&(g={state:`active`})}),u.on(t.t.squidFailed,e=>{b(e)&&(g={state:`failed`,...e?.error?{message:e.error}:{}},_=null)});let S=e=>{if(u.getLoginMethod()===null)throw new n.w(`not_authenticated`,`Not authenticated: call login() before connecting or signing.`,{operation:{chain:e,method:`connect`}});if(!x())throw new n.w(`not_connected`,`Squid is not ready: call onboard() after login before connecting or signing.`)},C=u.request.bind(u);if(u.request=async e=>([`eth_requestAccounts`,`eth_accounts`,`eth_sendTransaction`,`eth_signTransaction`,`personal_sign`,`eth_signTypedData_v4`].includes(e.method)&&S(`evm`),C(e)),d){let e=d.connect.bind(d);d.connect=async t=>(S(`sui`),e(t))}if(m){let e=m.connect.bind(m);m.connect=async t=>(S(`solana`),e(t))}let w=async()=>{if(u.getLoginMethod()===null)throw new n.w(`not_authenticated`,`Not authenticated: call login() before onboarding Squid.`);if(x()||_)return;let t=`squid-${++v}`;_=t,g={state:`provisioning`};try{await u.walletMessageManager.pingIframe(),await n.c({method:e.r.enter_lite_mode,params:[window.location.origin,t]},!1,u.walletMessageManager,u.internalEventEmitter)}catch(e){throw _===t&&(_=null,g={state:`failed`,message:e instanceof Error?e.message:String(e)}),e}},T=()=>({...g}),E=e=>{if(g.state===`active`||!e.authenticated||e.activeMode!==`squid`||!e.squid)return;let n={..._?{lifecycleId:_}:{},evm:e.squid.sqd1.evm,sui:e.squid.sqd2.sui,solana:e.squid.sqd2.solana};g={state:`active`},_=null,u.emit(t.t.squidReady,n)},D=async()=>(await w(),T()),O=u.login.bind(u),k=async e=>{let t=await O(e);return d?.setLoginMethod(t),m?.setLoginMethod(t),(t?await u.session.getAccountStatus().catch(()=>null):null)?.squid&&(await u.reassertIframeAccountMode().catch(()=>void 0),await w()),t&&u.emit(`connect`),t},A=u.logout.bind(u),j=async()=>{await A(),d?.setLoginMethod(null),m?.setLoginMethod(null),y()},M;M={login:k,logout:j,getLoginMethod:()=>u.getLoginMethod(),getAccountStatus:async()=>{let e=await u.session.getAccountStatus();return E(e),e},getSquidStatus:T,on:(e,t)=>(u.on(e,t),M),removeListener:(e,t)=>(u.removeListener(e,t),M)},u.login=M.login,u.logout=M.logout,d&&(d.login=()=>M.login(),d.logout=()=>M.logout()),m&&(m.login=()=>M.login(),m.logout=()=>M.logout());let N={onboard:w,squid:{onboard:w,getStatus:T,onboardWithStatus:D},getSquidStatus:T,session:M,getAccountStatus:()=>{let e=u.getAccountStatus(),t=d?.getAccountStatus(),n=m?.getAccountStatus();return{authenticated:e.authenticated||!!t?.authenticated||!!n?.authenticated,loginMethod:e.loginMethod??t?.loginMethod??n?.loginMethod??null,activeMode:e.authenticated||t?.authenticated||n?.authenticated?`squid`:null,mode:`squid`,conversion:e.conversion,tap:e.tap,squid:e.squid,accounts:{...e.accounts,...t?.accounts,...n?.accounts}}},preload:()=>u.preload(),destroy:()=>{h?.(),y(),u.destroy(),d?.destroy(),m?.destroy(),n.b()}};return a&&Object.assign(N,{evm:u,ethereum:u}),d&&Object.assign(N,{sui:d}),m&&Object.assign(N,{solana:m}),p.every(e=>i.includes(e))&&Object.assign(N,{auth:u}),N}function g(e){let t=Array.from(new Set(e.chains));if(t.length===0)throw Error(`initWaaPMulti requires at least one chain facade`);if(t.some(e=>!m.includes(e)))throw Error(`initWaaPMulti received an unsupported chain facade`);let r=t.includes(`evm`),i=t.includes(`sui`),a=t.includes(`solana`),o=n.n({referralCode:e.referralCode,config:e.config,project:e.project,environment:e.environment,walletOrigin:e.walletOrigin,useStaging:e.useStaging,walletConnectProjectId:e.walletConnectProjectId,asyncTxs:e.asyncTxs,deferIframe:e.deferIframe},`tap`,!1,t,r),s=i?c({...e,config:e.config},`tap`,!1):void 0,u=()=>(n.y(e),n.v(`tap`).contentWindow),d=a?new l(e.deferIframe===!1?u():null,{useStaging:e.useStaging,environment:e.environment,walletOrigin:e.walletOrigin,referralCode:e.referralCode,project:e.project,config:e.config,deferIframe:e.deferIframe},u,{...e,chains:[`solana`]}):void 0;d?.setAccountMode(`tap`);let f;e.deferIframe===!1?o.preload().catch(()=>void 0):e.deferIframe===void 0&&(f=n.s(o));let p=o.login.bind(o),h=async e=>{let t=await p(e);return s?.setLoginMethod(t),d?.setLoginMethod(t),t&&o.emit(`connect`),t},g=o.logout.bind(o),_=async()=>{await g(),s?.setLoginMethod(null),d?.setLoginMethod(null)},v;v={login:h,logout:_,getLoginMethod:()=>o.getLoginMethod(),getAccountStatus:()=>o.session.getAccountStatus(),on:(e,t)=>(o.on(e,t),v),removeListener:(e,t)=>(o.removeListener(e,t),v)},o.login=v.login,o.logout=v.logout,s&&(s.login=()=>v.login(),s.logout=()=>v.logout()),d&&(d.login=()=>v.login(),d.logout=()=>v.logout());let y=()=>{let e=o.getAccountStatus(),t=s?.getAccountStatus(),n=d?.getAccountStatus();return{authenticated:e.authenticated||!!t?.authenticated||!!n?.authenticated,loginMethod:e.loginMethod??t?.loginMethod??n?.loginMethod??null,activeMode:e.authenticated||t?.authenticated||n?.authenticated?`tap`:null,mode:`tap`,conversion:e.conversion,tap:e.tap,squid:e.squid,accounts:{...e.accounts,...t?.accounts,...n?.accounts}}},b=o.destroy.bind(o),x=s?.destroy.bind(s),S=d?.destroy.bind(d),C=()=>{f?.(),b(),x?.(),S?.(),n.b()},w={session:v,getAccountStatus:y,preload:()=>o.preload(),destroy:C};return r&&(o.destroy=C,Object.assign(w,{evm:o,ethereum:o})),s&&(s.destroy=C,Object.assign(w,{sui:s})),d&&(d.destroy=C,Object.assign(w,{solana:d})),w}function _(e={}){return console.warn("[WaaP SDK] `initWaaPSui()` is deprecated. Use `initWaaP({ chain: 'sui' })` instead."),f({...e,chain:`sui`})}function v(e={}){return f({...e,chain:`solana`})}function y(e={}){return g({...e,chains:e.chains??m})}Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return _}}),Object.defineProperty(exports,"c",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return g}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return y}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return v}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return f}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
require("./esm-
|
|
1
|
+
require("./esm-DFwVZkjo.js");const e=require("./asyncSigning-B0KrmKk7.js");let t=require("react");function n(e,n){let r=e&&`request`in e?e:void 0,i=r?n:e,[a,o]=(0,t.useState)(new Map),s=(0,t.useRef)(i);return(0,t.useEffect)(()=>{s.current=i},[i]),(0,t.useEffect)(()=>{let e=r||window.waap||window.silk;if(!e){console.warn(`[useWaapTransaction] WaaP provider not found. Make sure initWaaP() was called.`);return}let t=e=>{o(t=>{let n=new Map(t);return n.set(e.txHash,{status:`signed`,txHash:e.txHash,pendingTxId:e.pendingTxId,signature:e.signature,serializedTx:e.serializedTx}),n}),s.current?.onSigned?.(e)},n=e=>{o(t=>{let n=new Map(t),r=n.get(e.txHash);return n.set(e.txHash,{...r??{txHash:e.txHash},status:`tx_pending`,txHash:e.txHash,pendingTxId:e.pendingTxId}),n}),s.current?.onTxPending?.(e)},i=e=>{o(t=>{let n=new Map(t),r=n.get(e.txHash);return n.set(e.txHash,{...r??{txHash:e.txHash},status:`confirmed`,txHash:e.txHash,pendingTxId:e.pendingTxId,receipt:e.receipt}),n}),s.current?.onConfirmed?.(e)},a=e=>{o(t=>{let n=new Map(t),r=n.get(e.txHash);return n.set(e.txHash,{...r??{txHash:e.txHash},status:`failed`,txHash:e.txHash,pendingTxId:e.pendingTxId,error:e.error,stage:e.stage}),n}),s.current?.onFailed?.(e)};return e.on(`waap_sign_complete`,t),e.on(`waap_tx_pending`,n),e.on(`waap_tx_confirmed`,i),e.on(`waap_tx_failed`,a),()=>{e.removeListener?.(`waap_sign_complete`,t),e.removeListener?.(`waap_tx_pending`,n),e.removeListener?.(`waap_tx_confirmed`,i),e.removeListener?.(`waap_tx_failed`,a)}},[r]),{sendTransaction:(0,t.useCallback)(async e=>{let t=r||window.waap||window.silk;if(!t)throw Error(`WaaP provider not found`);return await t.request({method:`eth_sendTransaction`,params:e})},[r]),signTransaction:(0,t.useCallback)(async e=>{let t=r||window.waap||window.silk;if(!t)throw Error(`WaaP provider not found`);return t.request({method:`eth_signTransaction`,params:e})},[r]),pendingTransactions:a,isAnyPending:Array.from(a.values()).some(e=>e.status===`signed`||e.status===`tx_pending`)}}const r=()=>({state:`absent`}),i=(e,t)=>e?.getSquidStatus?.()??t;function a(n){let[a,o]=(0,t.useState)(!1),[s,c]=(0,t.useState)(()=>i(n,r())),[l,u]=(0,t.useState)(null),[d,f]=(0,t.useState)(null),[p,m]=(0,t.useState)(null);return(0,t.useEffect)(()=>{if(!n)return;let t=e=>{let t=i(n,e);return c(t),t};t(r());let a=e=>{let n=e.transactionDigest;t({state:n?`awaiting-network`:`provisioning`,...n?{operationId:n,transactionDigest:n}:{},...e.message?{message:e.message}:{}})},s=e=>{t({state:`active`}).state===`active`&&(u(e.evm),f(e.sui??null),m(e.solana??null))},l=e=>{t({state:`failed`,message:e.error})},d=()=>o(!0),p=e=>{u(e.length>0?e[0]:null)},h=()=>{o(!1),c(r()),u(null),f(null),m(null)};return n.on(e.t.squidPending,a),n.on(e.t.squidReady,s),n.on(e.t.squidFailed,l),n.on(`connect`,d),n.on(`accountsChanged`,p),n.on(`disconnect`,h),()=>{n.removeListener(e.t.squidPending,a),n.removeListener(e.t.squidReady,s),n.removeListener(e.t.squidFailed,l),n.removeListener(`connect`,d),n.removeListener(`accountsChanged`,p),n.removeListener(`disconnect`,h)}},[n]),{isConnected:a,isPending:s.state===`provisioning`||s.state===`awaiting-network`,squidReady:s.state===`active`,error:s.state===`failed`?s.message??null:null,address:l,suiAddress:d,solanaAddress:p,squidStatus:s}}Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return n}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return a}});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import"./esm-
|
|
1
|
+
import"./esm-BUfmyWbN.mjs";import{t as e}from"./asyncSigning-CzqBbYDP.mjs";import{useCallback as t,useEffect as n,useRef as r,useState as i}from"react";function a(e,a){let o=e&&`request`in e?e:void 0,s=o?a:e,[c,l]=i(new Map),u=r(s);return n(()=>{u.current=s},[s]),n(()=>{let e=o||window.waap||window.silk;if(!e){console.warn(`[useWaapTransaction] WaaP provider not found. Make sure initWaaP() was called.`);return}let t=e=>{l(t=>{let n=new Map(t);return n.set(e.txHash,{status:`signed`,txHash:e.txHash,pendingTxId:e.pendingTxId,signature:e.signature,serializedTx:e.serializedTx}),n}),u.current?.onSigned?.(e)},n=e=>{l(t=>{let n=new Map(t),r=n.get(e.txHash);return n.set(e.txHash,{...r??{txHash:e.txHash},status:`tx_pending`,txHash:e.txHash,pendingTxId:e.pendingTxId}),n}),u.current?.onTxPending?.(e)},r=e=>{l(t=>{let n=new Map(t),r=n.get(e.txHash);return n.set(e.txHash,{...r??{txHash:e.txHash},status:`confirmed`,txHash:e.txHash,pendingTxId:e.pendingTxId,receipt:e.receipt}),n}),u.current?.onConfirmed?.(e)},i=e=>{l(t=>{let n=new Map(t),r=n.get(e.txHash);return n.set(e.txHash,{...r??{txHash:e.txHash},status:`failed`,txHash:e.txHash,pendingTxId:e.pendingTxId,error:e.error,stage:e.stage}),n}),u.current?.onFailed?.(e)};return e.on(`waap_sign_complete`,t),e.on(`waap_tx_pending`,n),e.on(`waap_tx_confirmed`,r),e.on(`waap_tx_failed`,i),()=>{e.removeListener?.(`waap_sign_complete`,t),e.removeListener?.(`waap_tx_pending`,n),e.removeListener?.(`waap_tx_confirmed`,r),e.removeListener?.(`waap_tx_failed`,i)}},[o]),{sendTransaction:t(async e=>{let t=o||window.waap||window.silk;if(!t)throw Error(`WaaP provider not found`);return await t.request({method:`eth_sendTransaction`,params:e})},[o]),signTransaction:t(async e=>{let t=o||window.waap||window.silk;if(!t)throw Error(`WaaP provider not found`);return t.request({method:`eth_signTransaction`,params:e})},[o]),pendingTransactions:c,isAnyPending:Array.from(c.values()).some(e=>e.status===`signed`||e.status===`tx_pending`)}}const o=()=>({state:`absent`}),s=(e,t)=>e?.getSquidStatus?.()??t;function c(t){let[r,a]=i(!1),[c,l]=i(()=>s(t,o())),[u,d]=i(null),[f,p]=i(null),[m,h]=i(null);return n(()=>{if(!t)return;let n=e=>{let n=s(t,e);return l(n),n};n(o());let r=e=>{let t=e.transactionDigest;n({state:t?`awaiting-network`:`provisioning`,...t?{operationId:t,transactionDigest:t}:{},...e.message?{message:e.message}:{}})},i=e=>{n({state:`active`}).state===`active`&&(d(e.evm),p(e.sui??null),h(e.solana??null))},c=e=>{n({state:`failed`,message:e.error})},u=()=>a(!0),f=e=>{d(e.length>0?e[0]:null)},m=()=>{a(!1),l(o()),d(null),p(null),h(null)};return t.on(e.squidPending,r),t.on(e.squidReady,i),t.on(e.squidFailed,c),t.on(`connect`,u),t.on(`accountsChanged`,f),t.on(`disconnect`,m),()=>{t.removeListener(e.squidPending,r),t.removeListener(e.squidReady,i),t.removeListener(e.squidFailed,c),t.removeListener(`connect`,u),t.removeListener(`accountsChanged`,f),t.removeListener(`disconnect`,m)}},[t]),{isConnected:r,isPending:c.state===`provisioning`||c.state===`awaiting-network`,squidReady:c.state===`active`,error:c.state===`failed`?c.message??null:null,address:u,suiAddress:f,solanaAddress:m,squidStatus:c}}export{a as n,c as t};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as RequestArguments } from "./types-
|
|
2
|
-
import {
|
|
1
|
+
import { s as RequestArguments } from "./types-BmCqyQtu.js";
|
|
2
|
+
import { u as WaaPSquidStatus } from "./index-DOIss_GK.js";
|
|
3
3
|
//#region ../silk-interface-core/dist/esm/types/asyncSigning.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Types for async transaction feature.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { s as RequestArguments } from "./types-
|
|
2
|
-
import {
|
|
1
|
+
import { s as RequestArguments } from "./types-BmCqyQtu.mjs";
|
|
2
|
+
import { u as WaaPSquidStatus } from "./index-C0mLQs_a.mjs";
|
|
3
3
|
//#region ../silk-interface-core/dist/esm/types/asyncSigning.d.ts
|
|
4
4
|
/**
|
|
5
5
|
* Types for async transaction feature.
|
package/dist/walletconnect.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./WalletConnect-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./WalletConnect-Dn40Omgo.js");exports.SilkWalletConnect=e.t,exports.WaaPWalletConnect=e.t;
|
package/dist/walletconnect.mjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{t as e}from"./WalletConnect-
|
|
1
|
+
import{t as e}from"./WalletConnect-UfxGn2M_.mjs";export{e as SilkWalletConnect,e as WaaPWalletConnect};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@human.tech/waap-sdk",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.2.0-staging-7f56bf",
|
|
4
4
|
"description": "SDK for interacting with WaaP",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"exports": {
|
|
@@ -54,6 +54,7 @@
|
|
|
54
54
|
"files": [
|
|
55
55
|
"/dist",
|
|
56
56
|
"src/global.d.ts",
|
|
57
|
+
".agent",
|
|
57
58
|
"CHANGELOG.md"
|
|
58
59
|
],
|
|
59
60
|
"engines": {
|
|
@@ -94,7 +95,8 @@
|
|
|
94
95
|
"build": "tsdown --config-loader native",
|
|
95
96
|
"build-to-publish": "NODE_ENV=production tsdown --config-loader native",
|
|
96
97
|
"dev": "tsdown --config-loader native --watch",
|
|
97
|
-
"test": "vitest run && pnpm test:types",
|
|
98
|
+
"test": "vitest run && pnpm type-check && pnpm test:types",
|
|
99
|
+
"type-check": "tsc --noEmit",
|
|
98
100
|
"test:types": "pnpm build && pnpm exec tsc --noEmit -p tsconfig.public-api.json"
|
|
99
101
|
}
|
|
100
102
|
}
|
package/dist/esm-D5fDQenf.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
var e;(function(e){e.request=`request`,e.response=`response`,e.notification=`notification`})(e||={});var t;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`,e.eth_accountsChanged=`eth_accountsChanged`,e.sui_connect=`sui_connect`,e.sui_disconnect=`sui_disconnect`,e.sui_getAccounts=`sui_getAccounts`,e.sui_signPersonalMessage=`sui_signPersonalMessage`,e.sui_signTransaction=`sui_signTransaction`,e.sui_signAndExecuteTransaction=`sui_signAndExecuteTransaction`,e.sui_switchChain=`sui_switchChain`,e.show_modal=`show_modal`,e.hide_modal=`hide_modal`,e.login=`login`,e.auto_conn=`auto_conn`,e.logout=`logout`,e.set_points_referral_code=`set_points_referral_code`,e.set_project=`set_project`,e.silk_requestEmail=`silk_requestEmail`,e.silk_requestSbt=`silk_requestSbt`,e.set_custom_config=`set_custom_config`,e.safe=`safe`,e.set_is_mobile=`set_is_mobile`,e.project_init=`project_init`,e.gastank_get_settings=`gastank_get_settings`,e.gastank_update_settings=`gastank_update_settings`,e.gastank_topup=`gastank_topup`,e.customization_get=`customization_get`,e.customization_update=`customization_update`,e.orcid=`orcid`,e.waap_requestPermissionToken=`waap_requestPermissionToken`,e.waap_getAccountStatus=`waap_getAccountStatus`,e.waap_getPermissionTokenStatus=`waap_getPermissionTokenStatus`,e.waap_clearPermissionToken=`waap_clearPermissionToken`,e.solana_connect=`solana_connect`,e.solana_disconnect=`solana_disconnect`,e.solana_signMessage=`solana_signMessage`,e.solana_signTransaction=`solana_signTransaction`,e.solana_signAllTransactions=`solana_signAllTransactions`,e.solana_signAndSendTransaction=`solana_signAndSendTransaction`,e.set_signing_mode=`set_signing_mode`,e.enter_lite_mode=`enter_lite_mode`})(t||={});var n;(function(e){e.eth_requestAccounts=`eth_requestAccounts`,e.eth_accounts=`eth_accounts`,e.eth_sendTransaction=`eth_sendTransaction`,e.eth_signTransaction=`eth_signTransaction`,e.eth_getBalance=`eth_getBalance`,e.personal_sign=`personal_sign`,e.eth_signTypedData_v4=`eth_signTypedData_v4`,e.eth_chainId=`eth_chainId`,e.net_version=`net_version`,e.wallet_switchEthereumChain=`wallet_switchEthereumChain`,e.wallet_addEthereumChain=`wallet_addEthereumChain`,e.eth_estimateGas=`eth_estimateGas`,e.eth_blockNumber=`eth_blockNumber`,e.eth_getCode=`eth_getCode`,e.eth_call=`eth_call`,e.eth_getTransactionReceipt=`eth_getTransactionReceipt`,e.eth_getTransactionByHash=`eth_getTransactionByHash`})(n||={});var r;(function(e){e.ready=`ready`,e.connect=`connect`,e.account_changed=`account_changed`,e.mobile_oauth_success=`mobile_oauth_success`,e.mobile_oauth_error=`mobile_oauth_error`,e.tx_pending=`waap_txPending`,e.tx_2fa_required=`waap_tx2faRequired`,e.tx_signed=`waap_txSigned`,e.tx_confirmed=`waap_txConfirmed`,e.tx_failed=`waap_txFailed`,e.squid_pending=`waap_squid_pending`,e.squid_ready=`waap_squid_ready`,e.squid_failed=`waap_squid_failed`,e.request_cancel=`waap_requestCancel`})(r||={}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return r}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return e}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return t}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|