@human.tech/waap-sdk 1.3.0 → 2.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,59 +0,0 @@
1
- /**
2
- * WalletMessageManager handles messages between the wallet (in the Silk iframe)
3
- * and the wallet SDK (in the top frame). It is used by EthereumProvider
4
- * to communicate with the wallet.
5
- */
6
- import { SilkRequest, SilkResponse, SILK_METHOD, SilkNotificationData } from '@human.tech/waap-interface-core';
7
- type PostSilkRequestArgs = {
8
- method: keyof typeof SILK_METHOD;
9
- params: any[];
10
- interactionRequired: boolean;
11
- silkOptions?: {
12
- async?: boolean;
13
- };
14
- };
15
- /**
16
- * Async transaction notification from iframe
17
- */
18
- interface AsyncTxNotification {
19
- type: string;
20
- payload: any;
21
- }
22
- /**
23
- * Listener interface for WalletMessageManager
24
- */
25
- interface MessageListenerConfig {
26
- handleResponse: (response: SilkResponse) => void;
27
- handleRequest: (request: SilkRequest) => void;
28
- onReceiveConnectNotif?: () => void;
29
- onAccountChanged?: (newAccount: string) => void;
30
- onAsyncTxNotification?: (notification: AsyncTxNotification) => void;
31
- }
32
- declare class WalletMessageManager {
33
- private iframeWindow;
34
- private walletOrigin;
35
- constructor(iframeWindow: Window, useStaging: boolean);
36
- /**
37
- * Post a Silk notification to the given iframeWindow
38
- */
39
- postSilkNotification(data: SilkNotificationData): void;
40
- postReadyNotification(): void;
41
- postConnectNotification(): void;
42
- /**
43
- * Post a 'ready' notification to the iframe, and wait
44
- * for the iframe to respond with a 'ready' notification.
45
- */
46
- pingIframe(): Promise<void>;
47
- /**
48
- * Post a SilkRequest to the iframeWindow. Don't wait for a response.
49
- */
50
- postSilkRequest(req: PostSilkRequestArgs): Promise<string>;
51
- /**
52
- * Add a message listener to the window in which this is called (which should be the top frame).
53
- * It handles all messages from the Silk iframe posted to the top frame.
54
- * @param config - Configuration that includes callbacks for handling specific messages.
55
- */
56
- addListener(config: MessageListenerConfig): void;
57
- }
58
- export { WalletMessageManager, PostSilkRequestArgs };
59
- export default WalletMessageManager;
@@ -1,108 +0,0 @@
1
- /**
2
- * A Ethereum provder API (from EIP 1193) for Silk.
3
- * https://eips.ethereum.org/EIPS/eip-1193
4
- */
5
- /**
6
- * Resources:
7
- * - EIP-2255: Wallet Permissions System: https://eips.ethereum.org/EIPS/eip-2255
8
- */
9
- import { EventEmitter } from 'events';
10
- import { CustomConfig, CredentialType, ProjectConfig, RequestPermissionTokenParams } from '@human.tech/waap-interface-core';
11
- import { EthereumProviderInterface, LoginResponse, RequestArguments, SilkEthereumProviderInterface } from './types.js';
12
- import { UIMessageManager } from '../UIMessageManager.js';
13
- import WalletMessageManager from '../WalletMessageManager.js';
14
- declare class EthereumProvider extends EventEmitter implements SilkEthereumProviderInterface {
15
- readonly isSilk = true;
16
- readonly isWaaP = true;
17
- connected: boolean;
18
- walletMessageManager: WalletMessageManager;
19
- uiMessageManager: UIMessageManager;
20
- config: CustomConfig;
21
- private currentAccount;
22
- private walletConnectProvider;
23
- /**
24
- * When true, eth_sendTransaction resolves with the pre-calculated tx hash
25
- * after signing. Broadcasting continues in the background with events.
26
- */
27
- private asyncTxs;
28
- /**
29
- * When true, sends `asyncSigning: true` in silkOptions instead of `async: true`.
30
- * This mimics the v1 SDK protocol for backward compatibility testing.
31
- * @internal
32
- */
33
- private legacyAsyncSigning;
34
- private persistedMethods;
35
- /**
36
- * We use the internalEventEmitter to emit as events
37
- * Silk messages posted to the window.
38
- */
39
- internalEventEmitter: EventEmitter;
40
- /**
41
- * @param iframeWindow - The contentWindow of the iframe of the Silk website.
42
- * @param referralCode - Silk points referral code
43
- * @param customConfig - Silk custom UI configuration
44
- * @param project - Silk project configuration
45
- * @param useStaging - Whether to use the staging environment
46
- * @param asyncTxs - When true, eth_sendTransaction resolves with tx hash after signing
47
- * @param legacyAsyncSigning - When true, sends asyncSigning in silkOptions (v1 compat)
48
- */
49
- constructor(iframeWindow: Window, referralCode?: string, customConfig?: CustomConfig, project?: ProjectConfig, useStaging?: boolean, asyncTxs?: boolean, legacyAsyncSigning?: boolean);
50
- private initializeWalletConnect;
51
- enable(): Promise<unknown>;
52
- isConnected(): boolean;
53
- request(args: RequestArguments): Promise<unknown>;
54
- login(customProvider?: EthereumProviderInterface): Promise<LoginResponse>;
55
- logout(): Promise<unknown>;
56
- private cleanupInvalidLoginState;
57
- /**
58
- * Helper method to set up window.waap for WaaP
59
- */
60
- private setupWaaP;
61
- /**
62
- * Helper method to set up window.silk for injected wallets (e.g., MetaMask)
63
- */
64
- private setupInjectedWallet;
65
- /**
66
- * Helper method to set up window.silk for WalletConnect
67
- */
68
- private setupWalletConnect;
69
- /**
70
- * Helper method to set up window.silk for auto-connect with injected wallets
71
- */
72
- private setupAutoConnectInjected;
73
- /**
74
- * Helper method to set up window.silk for auto-connect with WalletConnect
75
- */
76
- private setupAutoConnectWalletConnect;
77
- /**
78
- * Attempts to auto-connect using previously stored login method
79
- * @param method - The RPC method being called
80
- * @returns Promise<unknown> if auto-connect succeeds, null if it should fall through to normal flow
81
- */
82
- private attemptAutoConnect;
83
- getLoginMethod(): LoginResponse;
84
- toggleDarkMode(): Promise<void>;
85
- safe(): Promise<void>;
86
- orcid(): Promise<void>;
87
- /**
88
- * INTERNAL METHOD: Gas tank administration operations
89
- * This method is ONLY accessible from the Dev Portal domain
90
- * It's not included in the public typing to hide it from regular dApps
91
- */
92
- portal(feature: 'gastank' | 'customization' | 'project', operation: 'get' | 'update' | 'topup' | 'init', payload?: any): Promise<unknown>;
93
- requestEmail(): Promise<unknown>;
94
- /**
95
- * Request a Permission Token from the user.
96
- * Allows pre-authorized transactions without individual confirmations.
97
- * @param params - Permission token parameters (allowed addresses, chain, limits, expiry)
98
- * @returns Promise<RequestPermissionTokenResult>
99
- */
100
- requestPermissionToken(params: RequestPermissionTokenParams): Promise<unknown>;
101
- /**
102
- * Prompt the user to mint a Zeronym SBT.
103
- * @returns string or null - The address of the owner of the SBT, or null
104
- * if the user already minted the SBT.
105
- */
106
- requestSBT(type: CredentialType): Promise<unknown>;
107
- }
108
- export { EthereumProvider };
@@ -1,26 +0,0 @@
1
- /**
2
- * A Ethereum provder API (from EIP 1193) for Silk.
3
- * https://eips.ethereum.org/EIPS/eip-1193
4
- */
5
- /**
6
- * Resources:
7
- * - EIP-2255: Wallet Permissions System: https://eips.ethereum.org/EIPS/eip-2255
8
- */
9
- import { CredentialType, CustomConfig } from '@human.tech/waap-interface-core';
10
- import { EventEmitter } from 'events';
11
- import { EthereumProviderInterface, RequestArguments } from './types.js';
12
- declare class EthereumProviderExtension extends EventEmitter implements EthereumProviderInterface {
13
- readonly isSilk = true;
14
- connected: boolean;
15
- config: CustomConfig;
16
- constructor(customConfig?: CustomConfig);
17
- sendToExtension(args: RequestArguments): Promise<unknown>;
18
- request(args: RequestArguments): Promise<unknown>;
19
- enable(): Promise<unknown>;
20
- isConnected(): boolean;
21
- login(): Promise<unknown>;
22
- requestSBT(type: CredentialType): Promise<unknown>;
23
- toggleDarkMode(): Promise<void>;
24
- safe(): Promise<unknown>;
25
- }
26
- export { EthereumProviderExtension };
@@ -1,17 +0,0 @@
1
- import { EventEmitter } from 'events';
2
- import { rpcMethodRequiresUI } from '@human.tech/waap-constants';
3
- import WalletMessageManager from '../WalletMessageManager.js';
4
- import { RequestArguments } from './types.js';
5
- /**
6
- * Options passed to iframe for transaction behavior
7
- */
8
- interface SilkOptions {
9
- async?: boolean;
10
- withPT?: boolean;
11
- }
12
- /**
13
- * Send request to wallet in iframe, and upon receiving the wallet's response
14
- * or error, hide modal and return wallet's response or throw wallet's error.
15
- */
16
- declare function handleWalletRequestAndResponse(args: RequestArguments, interactionRequired: boolean, walletMessageManager: WalletMessageManager, internalProviderEventEmitter: EventEmitter, silkOptions?: SilkOptions): Promise<unknown>;
17
- export { rpcMethodRequiresUI, handleWalletRequestAndResponse };
@@ -1,49 +0,0 @@
1
- import { CustomConfig, ProjectConfig, CredentialType, RequestPermissionTokenParams } from '@human.tech/waap-interface-core';
2
- export type ArrayOneOrMore<T> = {
3
- 0: T;
4
- } & Array<T>;
5
- export interface RequestArguments {
6
- method: string;
7
- params?: unknown[] | object;
8
- async?: boolean;
9
- withPT?: boolean;
10
- }
11
- export interface EthereumProviderInterface {
12
- enable(): Promise<unknown>;
13
- isConnected(): boolean;
14
- request(args: RequestArguments): Promise<unknown>;
15
- on(event: string, listener: (...args: any[]) => void): this;
16
- removeListener(event: string, listener: (...args: any[]) => void): this;
17
- }
18
- export type LoginResponse = 'waap' | 'human' | 'injected' | 'walletconnect' | null;
19
- export interface SilkEthereumProviderInterface extends EthereumProviderInterface {
20
- isSilk: boolean;
21
- connected: boolean;
22
- login(customProvider?: any): Promise<LoginResponse>;
23
- logout(): Promise<unknown>;
24
- getLoginMethod(): LoginResponse;
25
- requestEmail(): Promise<unknown>;
26
- requestSBT(type: CredentialType): Promise<unknown>;
27
- requestPermissionToken(params: RequestPermissionTokenParams): Promise<unknown>;
28
- toggleDarkMode(): Promise<void>;
29
- }
30
- export interface InitSilkOptions {
31
- referralCode?: string;
32
- project?: ProjectConfig;
33
- config?: CustomConfig;
34
- useStaging?: boolean;
35
- walletConnectProjectId?: string;
36
- /**
37
- * When true, eth_sendTransaction resolves with the pre-calculated tx hash
38
- * immediately after signing. Broadcasting and confirmation continue in the
39
- * background with events (waap_sign_complete, waap_tx_pending, waap_tx_confirmed, waap_tx_failed).
40
- * Other signing methods (personal_sign, eth_signTypedData_v4, eth_signTransaction)
41
- * are unaffected — they always resolve with the signature directly.
42
- * Applies to ALL eth_sendTransaction calls for this SDK instance.
43
- * Default: false
44
- */
45
- asyncTxs?: boolean;
46
- /** @deprecated Use `asyncTxs` instead. */
47
- asyncSigning?: boolean;
48
- }
49
- export type SilkProvider = SilkEthereumProviderInterface;
@@ -1,4 +0,0 @@
1
- import { CustomConfig } from '@human.tech/waap-interface-core';
2
- export declare function isMetaMask(provider: any): boolean;
3
- export declare function isSafeTransaction(params?: unknown[] | object): boolean;
4
- export declare const defaultConfig: CustomConfig;
@@ -1,203 +0,0 @@
1
- /**
2
- * WaaP Sui Wallet - Implements Sui Wallet Standard.
3
- *
4
- * This wallet adapter allows dApps using @mysten/dapp-kit to discover
5
- * and interact with WaaP wallet for Sui blockchain operations.
6
- *
7
- * @see https://docs.sui.io/standards/wallet-standard
8
- */
9
- import { UIMessageManager } from '../UIMessageManager.js';
10
- import type { SuiAccount, SuiChain, SuiConnectInput, SuiConnectOutput, SuiSignPersonalMessageInput, SuiSignPersonalMessageOutput, SuiSignAndExecuteTransactionInput, SuiSignAndExecuteTransactionOutput, SuiSignTransactionBlockInput, SuiSignTransactionBlockOutput, SuiSignAndExecuteTransactionBlockInput, SuiSignAndExecuteTransactionBlockOutput, SuiWalletEventListener, WaaPSuiWalletInterface, WalletIcon, InitWaaPSuiOptions } from './types.js';
11
- /**
12
- * WaaP Sui Wallet implementation.
13
- *
14
- * Implements the Sui Wallet Standard to allow dApps to:
15
- * - Connect/disconnect
16
- * - Sign personal messages
17
- * - (Future) Sign and execute transactions
18
- */
19
- export declare class WaaPSuiWallet implements WaaPSuiWalletInterface {
20
- readonly name = "WaaP";
21
- readonly version = "1.0.0";
22
- readonly icon: WalletIcon;
23
- private _accounts;
24
- private _chains;
25
- private walletMessageManager;
26
- private uiMessageManager;
27
- private internalEventEmitter;
28
- private changeListeners;
29
- /**
30
- * Creates a new WaaPSuiWallet instance.
31
- *
32
- * @param iframeWindow - The contentWindow of the WaaP iframe
33
- * @param options - Initialization options
34
- */
35
- constructor(iframeWindow: Window, options?: InitWaaPSuiOptions);
36
- /**
37
- * Refresh accounts by making a silent connect request.
38
- * Used internally when account changes are detected.
39
- */
40
- private refreshAccounts;
41
- /**
42
- * Supported chains.
43
- */
44
- get chains(): readonly SuiChain[];
45
- /**
46
- * Connected accounts.
47
- */
48
- get accounts(): readonly SuiAccount[];
49
- /**
50
- * UI message manager for showing/hiding modal.
51
- */
52
- get ui(): UIMessageManager;
53
- /**
54
- * Connect to the wallet.
55
- */
56
- connect(input?: SuiConnectInput): Promise<SuiConnectOutput>;
57
- /**
58
- * Disconnect from the wallet.
59
- */
60
- disconnect(): Promise<void>;
61
- /**
62
- * Sign a personal message.
63
- *
64
- * @param input - Sign personal message input
65
- * @returns Signed message result with bytes and signature
66
- */
67
- signPersonalMessage(input: SuiSignPersonalMessageInput): Promise<SuiSignPersonalMessageOutput>;
68
- /**
69
- * Extract the destination addresses from BCS-serialized Sui transaction bytes.
70
- *
71
- * Unlike EVM transactions where `to` is a top-level field, Sui transaction
72
- * destinations are embedded in BCS-encoded programmable transaction blocks.
73
- * We deserialize with Transaction.from() and inspect TransferObjects commands.
74
- *
75
- * Only TransferObjects destinations are extracted — MoveCall package addresses
76
- * are not user-facing recipients and should not be validated against a PT's
77
- * allowedAddresses list.
78
- *
79
- * Returns an empty array if no TransferObjects are found or deserialization fails.
80
- */
81
- private extractTransferAddresses;
82
- /**
83
- * Helper to resolve transaction bytes from various input formats.
84
- * If the input is a Transaction/TransactionBlock object, it builds it.
85
- */
86
- private resolveTransactionBytes;
87
- /**
88
- * Sign a transaction.
89
- *
90
- * @param input - Sign transaction input with transaction
91
- * @returns Signed transaction result with bytes and signature
92
- */
93
- signTransaction(input: {
94
- transaction: unknown;
95
- account: SuiAccount;
96
- chain?: SuiChain;
97
- }): Promise<{
98
- bytes: string;
99
- signature: string;
100
- }>;
101
- /**
102
- * Sign and execute a transaction.
103
- *
104
- * @param input - Sign and execute transaction input
105
- */
106
- signAndExecuteTransaction(input: SuiSignAndExecuteTransactionInput): Promise<SuiSignAndExecuteTransactionOutput>;
107
- /**
108
- * Switch the active chain.
109
- */
110
- switchChain(input: {
111
- chain: SuiChain;
112
- }): Promise<void>;
113
- /**
114
- * Subscribe to wallet change events.
115
- *
116
- * @param event - Event name (currently only 'change')
117
- * @param listener - Event listener callback
118
- * @returns Unsubscribe function
119
- */
120
- on(event: 'change', listener: SuiWalletEventListener): () => void;
121
- /**
122
- * Wallet Standard features property.
123
- * Required by @mysten/wallet-standard registerWallet.
124
- */
125
- get features(): {
126
- readonly 'standard:connect': {
127
- readonly version: "1.0.0";
128
- readonly connect: (input?: SuiConnectInput) => Promise<SuiConnectOutput>;
129
- };
130
- readonly 'standard:disconnect': {
131
- readonly version: "1.0.0";
132
- readonly disconnect: () => Promise<void>;
133
- };
134
- readonly 'standard:events': {
135
- readonly version: "1.0.0";
136
- readonly on: (event: "change", listener: SuiWalletEventListener) => () => void;
137
- };
138
- readonly 'sui:signPersonalMessage': {
139
- readonly version: "1.1.0";
140
- readonly signPersonalMessage: (input: SuiSignPersonalMessageInput) => Promise<SuiSignPersonalMessageOutput>;
141
- };
142
- readonly 'sui:signTransaction': {
143
- readonly version: "2.0.0";
144
- readonly signTransaction: (input: {
145
- transaction: unknown;
146
- account: SuiAccount;
147
- chain?: SuiChain;
148
- }) => Promise<{
149
- bytes: string;
150
- signature: string;
151
- }>;
152
- };
153
- readonly 'sui:signAndExecuteTransaction': {
154
- readonly version: "1.0.0";
155
- readonly signAndExecuteTransaction: (input: SuiSignAndExecuteTransactionInput) => Promise<SuiSignAndExecuteTransactionOutput>;
156
- };
157
- readonly 'sui:signTransactionBlock': {
158
- readonly version: "2.0.0";
159
- readonly signTransactionBlock: (input: SuiSignTransactionBlockInput) => Promise<SuiSignTransactionBlockOutput>;
160
- };
161
- readonly 'sui:signAndExecuteTransactionBlock': {
162
- readonly version: "1.0.0";
163
- readonly signAndExecuteTransactionBlock: (input: SuiSignAndExecuteTransactionBlockInput) => Promise<SuiSignAndExecuteTransactionBlockOutput>;
164
- };
165
- readonly 'sui:switchChain': {
166
- readonly version: "1.0.0";
167
- readonly switchChain: (input: {
168
- chain: SuiChain;
169
- }) => Promise<void>;
170
- };
171
- };
172
- /**
173
- * Legacy method for signing a transaction block.
174
- * Maps to signTransaction.
175
- */
176
- signTransactionBlock(input: SuiSignTransactionBlockInput): Promise<SuiSignTransactionBlockOutput>;
177
- /**
178
- * Legacy method for signing and executing a transaction block.
179
- * Maps to signAndExecuteTransaction.
180
- */
181
- signAndExecuteTransactionBlock(input: SuiSignAndExecuteTransactionBlockInput): Promise<SuiSignAndExecuteTransactionBlockOutput>;
182
- /**
183
- * Request a Permission Token from the user.
184
- * Allows pre-authorised batches of Sui transactions without individual confirmations.
185
- *
186
- * @param params - Allowed addresses, chainId (e.g. "sui:mainnet"), spend limit, expiry
187
- */
188
- requestPermissionToken(params: import('./types.js').RequestPermissionTokenParams): Promise<import('./types.js').RequestPermissionTokenResult>;
189
- /**
190
- * Request the user's email address.
191
- *
192
- * @returns Promise resolving to the user's email address
193
- */
194
- requestEmail(): Promise<string>;
195
- /**
196
- * Post a request to the iframe and wait for response.
197
- */
198
- private postRequestAndWait;
199
- /**
200
- * Notify all change listeners.
201
- */
202
- private notifyChange;
203
- }
@@ -1,7 +0,0 @@
1
- /**
2
- * Sui Wallet Standard integration for WaaP.
3
- */
4
- export { WaaPSuiWallet } from './SuiWallet.js';
5
- export { initWaaPSui } from './init.js';
6
- export { registerWaaPSuiWallet } from './register.js';
7
- export type { SuiAccount, SuiChain, SuiConnectInput, SuiConnectOutput, SuiSignPersonalMessageInput, SuiSignPersonalMessageOutput, SuiSignTransactionInput, SuiSignTransactionOutput, SuiWalletChangeProperties, SuiWalletEventListener, WaaPSuiWalletInterface, WaaPSuiWalletFeatures, InitWaaPSuiOptions, WalletIcon, RequestPermissionTokenParams, RequestPermissionTokenResult } from './types.js';
@@ -1,30 +0,0 @@
1
- /**
2
- * Initialization function for WaaP Sui Wallet.
3
- */
4
- import type { InitWaaPSuiOptions, WaaPSuiWalletInterface } from './types.js';
5
- /**
6
- * Initialize WaaP Sui Wallet.
7
- *
8
- * This creates the WaaP iframe (if needed) and returns a SuiWallet instance
9
- * that implements the Sui Wallet Standard.
10
- *
11
- * @param options - Initialization options
12
- * @returns WaaPSuiWallet instance
13
- *
14
- * @example
15
- * ```typescript
16
- * import { initWaaPSui } from '@silk-wallet/silk-wallet-sdk'
17
- *
18
- * const suiWallet = initWaaPSui()
19
- *
20
- * // Connect to get accounts
21
- * const { accounts } = await suiWallet.connect()
22
- *
23
- * // Sign a message
24
- * const result = await suiWallet.signPersonalMessage({
25
- * message: new TextEncoder().encode('Hello, Sui!'),
26
- * account: accounts[0]
27
- * })
28
- * ```
29
- */
30
- export declare function initWaaPSui(options?: InitWaaPSuiOptions): WaaPSuiWalletInterface;
@@ -1,39 +0,0 @@
1
- /**
2
- * WaaP Sui Wallet Registration
3
- *
4
- * Registers the WaaP Sui wallet with the Wallet Standard registry,
5
- * making it discoverable by dApps using @mysten/dapp-kit.
6
- *
7
- * @see https://docs.sui.io/standards/wallet-standard
8
- */
9
- import type { InitWaaPSuiOptions, WaaPSuiWalletInterface } from './types.js';
10
- /**
11
- * Register WaaP Sui Wallet with the Wallet Standard.
12
- *
13
- * This makes the wallet discoverable by dApps using @mysten/dapp-kit.
14
- * The wallet will appear in the wallet selection UI of any dApp
15
- * that uses the Sui Wallet Standard.
16
- *
17
- * @param iframeWindow - The contentWindow of the WaaP iframe
18
- * @param options - Initialization options
19
- * @returns The registered WaaPSuiWallet instance
20
- *
21
- * @example
22
- * ```typescript
23
- * import { registerWaaPSuiWallet } from '@silk-wallet/silk-wallet-sdk'
24
- *
25
- * // Get the iframe element
26
- * const iframe = document.getElementById('waap-wallet-iframe') as HTMLIFrameElement
27
- *
28
- * // Register the wallet (makes it discoverable by dApps)
29
- * const wallet = registerWaaPSuiWallet(iframe.contentWindow!, { useStaging: false })
30
- *
31
- * // The wallet is now available in dapp-kit's wallet list
32
- * ```
33
- */
34
- export declare function registerWaaPSuiWallet(iframeWindow: Window, options?: InitWaaPSuiOptions): WaaPSuiWalletInterface;
35
- /**
36
- * Unregister callback type returned by registerWallet.
37
- * Can be called to remove the wallet from the registry.
38
- */
39
- export type UnregisterWallet = () => void;