@hashgraphonline/hashinal-wc 2.0.62 → 2.0.63

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.
@@ -0,0 +1,161 @@
1
+ import { SessionTypes, SignClientTypes } from '@walletconnect/types';
2
+ import { Transaction, AccountId, ContractId, LedgerId, TransactionReceipt, ContractFunctionParameters, PrivateKey } from '@hashgraph/sdk';
3
+ import { AppKit } from '@reown/appkit';
4
+ import { DAppConnector } from '@hashgraph/hedera-wallet-connect';
5
+ import { FetchMessagesResult, TokenBalance, HederaAccountResponse, HederaTXResponse, Nft } from './types';
6
+ import { Logger } from './logger';
7
+ import * as HashgraphSDK from '@hashgraph/sdk';
8
+ /**
9
+ * Detect if current device is mobile
10
+ */
11
+ declare function isMobileDevice(): boolean;
12
+ /**
13
+ * Detect if device is iOS
14
+ */
15
+ declare function isIOSDevice(): boolean;
16
+ /**
17
+ * Detect if device is Android
18
+ */
19
+ declare function isAndroidDevice(): boolean;
20
+ /**
21
+ * Get the appropriate app store URL for the current platform
22
+ */
23
+ declare function getHashPackStoreUrl(): string;
24
+ /**
25
+ * Open HashPack app on mobile device.
26
+ * Used primarily for sign requests after a connection is already established.
27
+ *
28
+ * Uses a hidden anchor element to trigger the deep link without navigating
29
+ * away from the current page. This ensures users can return to the dApp
30
+ * after signing in the wallet.
31
+ *
32
+ * @param wcUri - Optional WalletConnect URI to pass to HashPack
33
+ */
34
+ declare function openHashPackOnMobile(wcUri?: string): Promise<void>;
35
+ /**
36
+ * Check if there's a saved return URL from a wallet connection attempt.
37
+ * If found, returns the URL and clears it from storage.
38
+ *
39
+ * dApps should call this on page load and redirect if a URL is returned.
40
+ */
41
+ declare function checkWalletReturnUrl(): string | null;
42
+ declare class HashinalsWalletConnectSDK {
43
+ private static instance;
44
+ private static dAppConnectorInstance;
45
+ private static proxyInstance;
46
+ private logger;
47
+ private network;
48
+ private reownAppKit;
49
+ private reownAppKitKey;
50
+ private extensionCheckInterval;
51
+ private hasCalledExtensionCallback;
52
+ private useAppKit;
53
+ get dAppConnector(): DAppConnector;
54
+ constructor(logger?: Logger, network?: LedgerId);
55
+ static getInstance(logger?: Logger, network?: LedgerId): HashinalsWalletConnectSDK;
56
+ setLogger(logger: Logger): void;
57
+ setNetwork(network: LedgerId): void;
58
+ getNetwork(): LedgerId;
59
+ setReownAppKit(appKit: AppKit | null): void;
60
+ private ensureReownAppKit;
61
+ setLogLevel(level: 'error' | 'warn' | 'info' | 'debug'): void;
62
+ init(projectId: string, metadata: SignClientTypes.Metadata, network?: LedgerId, onSessionIframeCreated?: (session: SessionTypes.Struct) => void, options?: {
63
+ useAppKit?: boolean;
64
+ }): Promise<DAppConnector>;
65
+ connect(options?: {
66
+ pairingTopic?: string;
67
+ onUri?: (uri: string) => void;
68
+ }): Promise<SessionTypes.Struct>;
69
+ private connectUsingReownAppKit;
70
+ disconnect(): Promise<boolean>;
71
+ disconnectAll(): Promise<boolean>;
72
+ /**
73
+ * Triggers the browser extension popup for signing on desktop.
74
+ * This is needed when the signer doesn't have an extensionId set
75
+ * (e.g., when connecting via the Reown AppKit modal).
76
+ */
77
+ private triggerExtensionPopupIfNeeded;
78
+ /**
79
+ * Gets the available desktop browser extension (e.g., HashPack).
80
+ * Returns undefined if no extension is available or on mobile devices.
81
+ */
82
+ private getAvailableDesktopExtension;
83
+ executeTransaction(tx: Transaction, disableSigner?: boolean): Promise<TransactionReceipt>;
84
+ executeTransactionWithErrorHandling(tx: Transaction, disableSigner: boolean): Promise<{
85
+ result?: TransactionReceipt;
86
+ error?: string;
87
+ }>;
88
+ submitMessageToTopic(topicId: string, message: string, submitKey?: PrivateKey): Promise<TransactionReceipt>;
89
+ transferHbar(fromAccountId: string, toAccountId: string, amount: number): Promise<TransactionReceipt>;
90
+ executeSmartContract(contractId: string, functionName: string, parameters: ContractFunctionParameters, gas?: number): Promise<TransactionReceipt>;
91
+ private handleNewSession;
92
+ private getNetworkPrefix;
93
+ requestAccount(account: string): Promise<HederaAccountResponse>;
94
+ getAccountBalance(): Promise<string>;
95
+ getAccountInfo(): {
96
+ accountId: string;
97
+ network: LedgerId;
98
+ };
99
+ createTopic(memo?: string, adminKey?: string, submitKey?: string): Promise<string>;
100
+ createToken(name: string, symbol: string, initialSupply: number, decimals: number, treasuryAccountId: string, adminKey: string, supplyKey: string): Promise<string>;
101
+ mintNFT(tokenId: string, metadata: string, supplyKey: PrivateKey): Promise<TransactionReceipt>;
102
+ getMessages(topicId: string, lastTimestamp?: number, disableTimestampFilter?: boolean, network?: string): Promise<FetchMessagesResult>;
103
+ /**
104
+ * Sign a message with the connected wallet.
105
+ * On mobile devices, this will automatically open the HashPack app
106
+ * to prompt the user to sign the message.
107
+ *
108
+ * @param message - The message to sign
109
+ * @param options - Optional configuration for signing
110
+ * @param options.openWalletOnMobile - Whether to open the wallet app on mobile (default: true)
111
+ * @param options.onMobileRedirect - Callback before redirecting to wallet on mobile
112
+ */
113
+ signMessage(message: string, options?: {
114
+ openWalletOnMobile?: boolean;
115
+ onMobileRedirect?: () => void;
116
+ }): Promise<{
117
+ userSignature: string;
118
+ }>;
119
+ private saveConnectionInfo;
120
+ loadConnectionInfo(): {
121
+ accountId: string | null;
122
+ network: string | null;
123
+ };
124
+ connectWallet(PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata, network?: LedgerId, options?: {
125
+ onUri?: (uri: string) => void;
126
+ useAppKit?: boolean;
127
+ }): Promise<{
128
+ accountId: string;
129
+ balance: string;
130
+ session: SessionTypes.Struct;
131
+ }>;
132
+ disconnectWallet(clearStorage?: boolean): Promise<boolean>;
133
+ initAccount(PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata, networkOverride?: LedgerId, onSessionIframeCreated?: (session: SessionTypes.Struct) => void, options?: {
134
+ useAppKit?: boolean;
135
+ }): Promise<{
136
+ accountId: string;
137
+ balance: string;
138
+ } | null>;
139
+ subscribeToExtensions(callback: (extension: any) => void): () => void;
140
+ connectViaDappBrowser(): Promise<void>;
141
+ private connectToExtension;
142
+ private ensureInitialized;
143
+ static run(): void;
144
+ transferToken(tokenId: string, fromAccountId: string, toAccountId: string, amount: number): Promise<TransactionReceipt>;
145
+ createAccount(initialBalance: number): Promise<TransactionReceipt>;
146
+ associateTokenToAccount(accountId: string, tokenId: string): Promise<TransactionReceipt>;
147
+ dissociateTokenFromAccount(accountId: string, tokenId: string): Promise<TransactionReceipt>;
148
+ updateAccount(accountId: string, maxAutomaticTokenAssociations: number): Promise<TransactionReceipt>;
149
+ approveAllowance(spenderAccountId: string, tokenId: string, amount: number, ownerAccountId: string): Promise<TransactionReceipt>;
150
+ getAccountTokens(accountId: string): Promise<{
151
+ tokens: TokenBalance[];
152
+ }>;
153
+ getTransaction(transactionId: string): Promise<HederaTXResponse | null>;
154
+ getTransactionByTimestamp(timestamp: string): Promise<HederaTXResponse | null>;
155
+ getAccountNFTs(accountId: string, tokenId?: string): Promise<Nft[]>;
156
+ validateNFTOwnership(serialNumber: string, accountId: string, tokenId: string): Promise<Nft | null>;
157
+ readSmartContract(data: string, fromAccount: AccountId, contractId: ContractId, estimate?: boolean, value?: number): Promise<any>;
158
+ }
159
+ export * from './types';
160
+ export * from './sign';
161
+ export { HashinalsWalletConnectSDK, HashgraphSDK, isMobileDevice, isIOSDevice, isAndroidDevice, openHashPackOnMobile, getHashPackStoreUrl, checkWalletReturnUrl, };
@@ -0,0 +1,10 @@
1
+ export type LogLevel = 'error' | 'warn' | 'info' | 'debug';
2
+ export declare class Logger {
3
+ private level;
4
+ setLogLevel(level: LogLevel): void;
5
+ error(message: unknown, ...optionalParams: unknown[]): void;
6
+ warn(message: unknown, ...optionalParams: unknown[]): void;
7
+ info(message: unknown, ...optionalParams: unknown[]): void;
8
+ debug(message: unknown, ...optionalParams: unknown[]): void;
9
+ private shouldLog;
10
+ }
@@ -0,0 +1 @@
1
+ export { base64StringToSignatureMap, prefixMessageToSign, verifyMessageSignature, } from '@hashgraph/hedera-wallet-connect';
@@ -0,0 +1,254 @@
1
+ import { DAppConnector } from '@hashgraph/hedera-wallet-connect';
2
+ import { ContractFunctionParameters, TransactionReceipt, PrivateKey, Transaction, AccountId, ContractId } from '@hashgraph/sdk';
3
+ import { SessionTypes, SignClientTypes } from '@walletconnect/types';
4
+ import * as hashgraph from '@hashgraph/sdk';
5
+ export interface HederaAccountResponse {
6
+ account: string;
7
+ alias: null;
8
+ auto_renew_period: number;
9
+ balance: Balance;
10
+ created_timestamp: string;
11
+ decline_reward: boolean;
12
+ deleted: boolean;
13
+ ethereum_nonce: number;
14
+ evm_address: string;
15
+ expiry_timestamp: string;
16
+ key: Key;
17
+ max_automatic_token_associations: number;
18
+ memo: string;
19
+ pending_reward: number;
20
+ receiver_sig_required: boolean;
21
+ staked_account_id: null;
22
+ staked_node_id: number;
23
+ stake_period_start: string;
24
+ transactions: HBARTransaction[];
25
+ links: Links;
26
+ }
27
+ export interface Balance {
28
+ balance: number;
29
+ timestamp: string;
30
+ tokens: Token[];
31
+ }
32
+ export interface Token {
33
+ token_id: string;
34
+ balance: number;
35
+ }
36
+ export interface Key {
37
+ _type: string;
38
+ key: string;
39
+ }
40
+ export interface Links {
41
+ next: string;
42
+ }
43
+ export interface HBARTransaction {
44
+ bytes: null;
45
+ charged_tx_fee: number;
46
+ consensus_timestamp: string;
47
+ entity_id: null | string;
48
+ max_fee: string;
49
+ memo_base64: string;
50
+ name: Name;
51
+ nft_transfers: NftTransfer[];
52
+ node: string;
53
+ nonce: number;
54
+ parent_consensus_timestamp: null;
55
+ result: Result;
56
+ scheduled: boolean;
57
+ staking_reward_transfers: StakingRewardTransfer[];
58
+ token_transfers: Transfer[];
59
+ transaction_hash: string;
60
+ transaction_id: string;
61
+ transfers: Transfer[];
62
+ valid_duration_seconds: string;
63
+ valid_start_timestamp: string;
64
+ }
65
+ export declare enum Name {
66
+ Contractcall = "CONTRACTCALL",
67
+ Cryptotransfer = "CRYPTOTRANSFER"
68
+ }
69
+ export interface NftTransfer {
70
+ is_approval: boolean;
71
+ receiver_account_id: string;
72
+ sender_account_id: string;
73
+ serial_number: number;
74
+ token_id: string;
75
+ }
76
+ export declare enum Result {
77
+ Success = "SUCCESS"
78
+ }
79
+ export interface StakingRewardTransfer {
80
+ account: string;
81
+ amount: number;
82
+ }
83
+ export interface Transfer {
84
+ token_id?: string;
85
+ account: string;
86
+ amount: number;
87
+ is_approval: boolean;
88
+ }
89
+ export interface Message {
90
+ payer: string;
91
+ created: Date;
92
+ consensus_timestamp: string;
93
+ sequence_number: number;
94
+ [key: string]: any;
95
+ }
96
+ export interface FetchMessagesResult {
97
+ messages: Message[];
98
+ error?: string;
99
+ }
100
+ export interface Account {
101
+ account: string;
102
+ alias: null;
103
+ auto_renew_period: number;
104
+ balance: Balance;
105
+ decline_reward: boolean;
106
+ deleted: boolean;
107
+ ethereum_nonce: null;
108
+ evm_address: null;
109
+ expiry_timestamp: string;
110
+ key: Key;
111
+ max_automatic_token_associations: number;
112
+ memo: string;
113
+ receiver_sig_required: null;
114
+ staked_account_id: null;
115
+ staked_node_id: null;
116
+ stake_period_start: null;
117
+ }
118
+ export interface Balance {
119
+ balance: number;
120
+ timestamp: string;
121
+ tokens: Token[];
122
+ }
123
+ export interface Token {
124
+ token_id: string;
125
+ balance: number;
126
+ }
127
+ export interface Key {
128
+ _type: string;
129
+ key: string;
130
+ }
131
+ export interface TokenBalance {
132
+ tokenId: string;
133
+ balance: string;
134
+ decimals: number;
135
+ created_timestamp: Date;
136
+ formatted_balance: string;
137
+ }
138
+ export interface HederaTXResponse {
139
+ transactions: MirrorNodeTransaction[];
140
+ }
141
+ export interface MirrorNodeTransaction {
142
+ bytes: null;
143
+ charged_tx_fee: number;
144
+ consensus_timestamp: string;
145
+ entity_id: string;
146
+ max_fee: string;
147
+ memo_base64: string;
148
+ name: string;
149
+ node: null | string;
150
+ nonce: number;
151
+ parent_consensus_timestamp: null | string;
152
+ result: string;
153
+ scheduled: boolean;
154
+ transaction_hash: string;
155
+ transaction_id: string;
156
+ transfers: Transfer[];
157
+ token_transfers: TokenTransfer[];
158
+ valid_duration_seconds: null | string;
159
+ valid_start_timestamp: string;
160
+ nft_transfers?: NftTransfer[];
161
+ }
162
+ export interface NftTransfer {
163
+ is_approval: boolean;
164
+ receiver_account_id: string;
165
+ sender_account_id: string;
166
+ serial_number: number;
167
+ token_id: string;
168
+ }
169
+ export interface TokenTransfer {
170
+ token_id: string;
171
+ account: string;
172
+ amount: number;
173
+ }
174
+ export interface HBarNFT {
175
+ nfts: Nft[];
176
+ links: Links;
177
+ }
178
+ export interface Links {
179
+ next: string;
180
+ }
181
+ export interface Nft {
182
+ account_id: string;
183
+ created_timestamp: string;
184
+ delegating_spender: null;
185
+ deleted: boolean;
186
+ metadata: string;
187
+ modified_timestamp: string;
188
+ serial_number: number;
189
+ spender: null;
190
+ token_id: string;
191
+ token_uri?: string;
192
+ owner_of?: string;
193
+ }
194
+ export interface FormattedOwner {
195
+ token_uri?: string;
196
+ chain?: string;
197
+ owner_of?: string;
198
+ token_address?: string;
199
+ token_id?: string;
200
+ account_id?: string;
201
+ serial_number?: number;
202
+ [key: string]: any;
203
+ }
204
+ export type HashinalsWalletConnectSDK = {
205
+ run: () => void;
206
+ init: (projectId: string, metadata: SignClientTypes.Metadata) => Promise<DAppConnector>;
207
+ connect: () => Promise<SessionTypes.Struct>;
208
+ connectWallet(PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata): Promise<{
209
+ accountId: string;
210
+ balance: string;
211
+ session: SessionTypes.Struct;
212
+ }>;
213
+ disconnect: () => Promise<boolean>;
214
+ disconnectAll: () => Promise<boolean>;
215
+ disconnectWallet: () => Promise<boolean>;
216
+ loadConnectionInfo: () => string | null;
217
+ saveConnectionInfo: (accountId: string) => void;
218
+ executeTransaction: (tx: Transaction, disableSigner: boolean) => Promise<TransactionReceipt>;
219
+ executeTransationWithErrorHandling: (tx: Transaction, disableSigner: boolean) => Promise<{
220
+ result?: TransactionReceipt;
221
+ error?: string;
222
+ }>;
223
+ result?: TransactionReceipt;
224
+ error?: string;
225
+ submitMessageToTopic: (topicId: string, message: string) => Promise<TransactionReceipt>;
226
+ transferHbar: (fromAccountId: string, toAccountId: string, amount: number) => Promise<TransactionReceipt>;
227
+ executeSmartContract: (contractId: string, functionName: string, parameters: ContractFunctionParameters, gas?: number) => Promise<TransactionReceipt>;
228
+ getAccountBalance: () => Promise<string>;
229
+ getAccountInfo: () => string;
230
+ createTopic: (memo?: string, adminKey?: string, submitKey?: string) => Promise<string>;
231
+ createToken: (name: string, symbol: string, initialSupply: number, decimals: number, treasuryAccountId: string, adminKey: string, supplyKey: string) => Promise<string>;
232
+ mintNFT: (tokenId: string, metadata: string, supplyKey: PrivateKey) => Promise<TransactionReceipt>;
233
+ dAppConnector?: DAppConnector;
234
+ getMessages: (topicId: string, lastTimestamp?: number, disableTimestampFilter?: boolean) => Promise<FetchMessagesResult>;
235
+ initAccount: (PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata) => Promise<{
236
+ accountId: string;
237
+ balance: string;
238
+ } | null>;
239
+ transferToken: (tokenId: string, fromAccountId: string, toAccountId: string, amount: number) => Promise<TransactionReceipt>;
240
+ createAccount: (initialBalance: number) => Promise<TransactionReceipt>;
241
+ associateTokenToAccount: (accountId: string, tokenId: string) => Promise<TransactionReceipt>;
242
+ dissociateTokenFromAccount: (accountId: string, tokenId: string) => Promise<TransactionReceipt>;
243
+ updateAccount: (accountId: string, maxAutomaticTokenAssociations: number) => Promise<TransactionReceipt>;
244
+ approveAllowance: (spenderAccountId: string, tokenId: string, amount: number, ownerAccountId: string) => Promise<TransactionReceipt>;
245
+ getAccountTokens: (accountId: string) => Promise<{
246
+ tokens: TokenBalance[];
247
+ }>;
248
+ getTransaction: (transactionId: string) => Promise<HederaTXResponse | null>;
249
+ getTransactionByTimestamp: (timestamp: string) => Promise<HederaTXResponse | null>;
250
+ getAccountNFTs: (accountId: string, tokenId?: string) => Promise<Nft[]>;
251
+ validateNFTOwnership: (serialNumber: string, accountId: string, tokenId: string) => Promise<Nft | null>;
252
+ readSmartContract: (data: string, fromAccount: AccountId, contractId: ContractId, estimate?: boolean, value?: number) => Promise<any>;
253
+ HashgraphSDK: typeof hashgraph;
254
+ };
@@ -0,0 +1 @@
1
+ export declare const fetchWithRetry: () => (input: string | Request | URL, init?: import('fetch-retry').RequestInitWithRetry<typeof fetch>) => Promise<Response>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hashgraphonline/hashinal-wc",
3
- "version": "2.0.62",
3
+ "version": "2.0.63",
4
4
  "description": "The official Hashinal Wallet Connect SDK. A set of easy-to-use functions to interact with Hedera through Wallet Connect.",
5
5
  "type": "module",
6
6
  "files": [