@hashgraphonline/hashinal-wc 1.0.66 → 1.0.67

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,69 @@
1
+ import { SessionTypes, SignClientTypes } from '@walletconnect/types';
2
+ import { Transaction, LedgerId, TransactionReceipt, ContractFunctionParameters, PrivateKey } from '@hashgraph/sdk';
3
+ import { DAppConnector } from '@hashgraph/hedera-wallet-connect';
4
+ import { FetchMessagesResult, TokenBalance, HederaAccountResponse } from './types';
5
+ import { ILogger } from './logger/logger';
6
+ import * as HashgraphSDK from '@hashgraph/sdk';
7
+ declare class HashinalsWalletConnectSDK {
8
+ private static instance;
9
+ dAppConnector: DAppConnector | undefined;
10
+ private logger;
11
+ private network;
12
+ constructor(logger?: ILogger, network?: LedgerId);
13
+ static getInstance(logger?: ILogger, network?: LedgerId): HashinalsWalletConnectSDK;
14
+ setLogger(logger: ILogger): void;
15
+ setNetwork(network: LedgerId): void;
16
+ getNetwork(): LedgerId;
17
+ setLogLevel(level: 'error' | 'warn' | 'info' | 'debug'): void;
18
+ init(projectId: string, metadata: SignClientTypes.Metadata, network?: LedgerId): Promise<DAppConnector>;
19
+ connect(): Promise<SessionTypes.Struct>;
20
+ disconnect(): Promise<boolean>;
21
+ executeTransaction(tx: Transaction, disableSigner?: boolean): Promise<TransactionReceipt>;
22
+ executeTransactionWithErrorHandling(tx: Transaction, disableSigner: boolean): Promise<{
23
+ result?: TransactionReceipt;
24
+ error?: string;
25
+ }>;
26
+ submitMessageToTopic(topicId: string, message: string, submitKey?: PrivateKey): Promise<TransactionReceipt>;
27
+ transferHbar(fromAccountId: string, toAccountId: string, amount: number): Promise<TransactionReceipt>;
28
+ executeSmartContract(contractId: string, functionName: string, parameters: ContractFunctionParameters, gas?: number): Promise<TransactionReceipt>;
29
+ private handleNewSession;
30
+ private getNetworkPrefix;
31
+ requestAccount(account: string): Promise<HederaAccountResponse>;
32
+ getAccountBalance(): Promise<string>;
33
+ getAccountInfo(): {
34
+ accountId: string;
35
+ network: LedgerId;
36
+ };
37
+ createTopic(memo?: string, adminKey?: string, submitKey?: string): Promise<string>;
38
+ createToken(name: string, symbol: string, initialSupply: number, decimals: number, treasuryAccountId: string, adminKey: string, supplyKey: string): Promise<string>;
39
+ mintNFT(tokenId: string, metadata: string, supplyKey: PrivateKey): Promise<TransactionReceipt>;
40
+ getMessages(topicId: string, lastTimestamp?: number, disableTimestampFilter?: boolean): Promise<FetchMessagesResult>;
41
+ private saveConnectionInfo;
42
+ loadConnectionInfo(): {
43
+ accountId: string | null;
44
+ network: string | null;
45
+ };
46
+ connectWallet(PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata, network?: LedgerId): Promise<{
47
+ accountId: string;
48
+ balance: string;
49
+ session: SessionTypes.Struct;
50
+ }>;
51
+ disconnectWallet(clearStorage?: boolean): Promise<boolean>;
52
+ initAccount(PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata): Promise<{
53
+ accountId: string;
54
+ balance: string;
55
+ } | null>;
56
+ private ensureInitialized;
57
+ static run(): void;
58
+ transferToken(tokenId: string, fromAccountId: string, toAccountId: string, amount: number): Promise<TransactionReceipt>;
59
+ createAccount(initialBalance: number): Promise<TransactionReceipt>;
60
+ associateTokenToAccount(accountId: string, tokenId: string): Promise<TransactionReceipt>;
61
+ dissociateTokenFromAccount(accountId: string, tokenId: string): Promise<TransactionReceipt>;
62
+ updateAccount(accountId: string, maxAutomaticTokenAssociations: number): Promise<TransactionReceipt>;
63
+ approveAllowance(spenderAccountId: string, tokenId: string, amount: number, ownerAccountId: string): Promise<TransactionReceipt>;
64
+ getAccountTokens(accountId: string): Promise<{
65
+ tokens: TokenBalance[];
66
+ }>;
67
+ }
68
+ export * from './types';
69
+ export { HashinalsWalletConnectSDK, HashgraphSDK };
@@ -0,0 +1,14 @@
1
+ export interface ILogger {
2
+ error(message: string, ...args: any[]): void;
3
+ warn(message: string, ...args: any[]): void;
4
+ info(message: string, ...args: any[]): void;
5
+ debug(message: string, ...args: any[]): void;
6
+ }
7
+ export declare class DefaultLogger implements ILogger {
8
+ private logLevel;
9
+ setLogLevel(level: 'error' | 'warn' | 'info' | 'debug'): void;
10
+ error(message: string, ...args: any[]): void;
11
+ warn(message: string, ...args: any[]): void;
12
+ info(message: string, ...args: any[]): void;
13
+ debug(message: string, ...args: any[]): void;
14
+ }
@@ -0,0 +1,179 @@
1
+ import { DAppConnector } from '@hashgraph/hedera-wallet-connect';
2
+ import { default as hashgraph, PrivateKey, Transaction, ContractFunctionParameters, TransactionReceipt } from '@hashgraph/sdk';
3
+ import { SessionTypes, SignClientTypes } from '@walletconnect/types';
4
+ export interface HederaAccountResponse {
5
+ account: string;
6
+ alias: null;
7
+ auto_renew_period: number;
8
+ balance: Balance;
9
+ created_timestamp: string;
10
+ decline_reward: boolean;
11
+ deleted: boolean;
12
+ ethereum_nonce: number;
13
+ evm_address: string;
14
+ expiry_timestamp: string;
15
+ key: Key;
16
+ max_automatic_token_associations: number;
17
+ memo: string;
18
+ pending_reward: number;
19
+ receiver_sig_required: boolean;
20
+ staked_account_id: null;
21
+ staked_node_id: number;
22
+ stake_period_start: string;
23
+ transactions: HBARTransaction[];
24
+ links: Links;
25
+ }
26
+ export interface Balance {
27
+ balance: number;
28
+ timestamp: string;
29
+ tokens: Token[];
30
+ }
31
+ export interface Token {
32
+ token_id: string;
33
+ balance: number;
34
+ }
35
+ export interface Key {
36
+ _type: string;
37
+ key: string;
38
+ }
39
+ export interface Links {
40
+ next: string;
41
+ }
42
+ export interface HBARTransaction {
43
+ bytes: null;
44
+ charged_tx_fee: number;
45
+ consensus_timestamp: string;
46
+ entity_id: null | string;
47
+ max_fee: string;
48
+ memo_base64: string;
49
+ name: Name;
50
+ nft_transfers: NftTransfer[];
51
+ node: string;
52
+ nonce: number;
53
+ parent_consensus_timestamp: null;
54
+ result: Result;
55
+ scheduled: boolean;
56
+ staking_reward_transfers: StakingRewardTransfer[];
57
+ token_transfers: Transfer[];
58
+ transaction_hash: string;
59
+ transaction_id: string;
60
+ transfers: Transfer[];
61
+ valid_duration_seconds: string;
62
+ valid_start_timestamp: string;
63
+ }
64
+ export declare enum Name {
65
+ Contractcall = "CONTRACTCALL",
66
+ Cryptotransfer = "CRYPTOTRANSFER"
67
+ }
68
+ export interface NftTransfer {
69
+ is_approval: boolean;
70
+ receiver_account_id: string;
71
+ sender_account_id: string;
72
+ serial_number: number;
73
+ token_id: string;
74
+ }
75
+ export declare enum Result {
76
+ Success = "SUCCESS"
77
+ }
78
+ export interface StakingRewardTransfer {
79
+ account: string;
80
+ amount: number;
81
+ }
82
+ export interface Transfer {
83
+ token_id?: string;
84
+ account: string;
85
+ amount: number;
86
+ is_approval: boolean;
87
+ }
88
+ export interface Message {
89
+ payer: string;
90
+ created: Date;
91
+ consensus_timestamp: string;
92
+ sequence_number: number;
93
+ [key: string]: any;
94
+ }
95
+ export interface FetchMessagesResult {
96
+ messages: Message[];
97
+ error?: string;
98
+ }
99
+ export interface Account {
100
+ account: string;
101
+ alias: null;
102
+ auto_renew_period: number;
103
+ balance: Balance;
104
+ decline_reward: boolean;
105
+ deleted: boolean;
106
+ ethereum_nonce: null;
107
+ evm_address: null;
108
+ expiry_timestamp: string;
109
+ key: Key;
110
+ max_automatic_token_associations: number;
111
+ memo: string;
112
+ receiver_sig_required: null;
113
+ staked_account_id: null;
114
+ staked_node_id: null;
115
+ stake_period_start: null;
116
+ }
117
+ export interface Balance {
118
+ balance: number;
119
+ timestamp: string;
120
+ tokens: Token[];
121
+ }
122
+ export interface Token {
123
+ token_id: string;
124
+ balance: number;
125
+ }
126
+ export interface Key {
127
+ _type: string;
128
+ key: string;
129
+ }
130
+ export interface TokenBalance {
131
+ tokenId: string;
132
+ balance: string;
133
+ decimals: number;
134
+ created_timestamp: Date;
135
+ formatted_balance: string;
136
+ }
137
+ export type HashinalsWalletConnectSDK = {
138
+ run: () => void;
139
+ init: (projectId: string, metadata: SignClientTypes.Metadata) => Promise<DAppConnector>;
140
+ connect: () => Promise<SessionTypes.Struct>;
141
+ connectWallet(PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata): Promise<{
142
+ accountId: string;
143
+ balance: string;
144
+ session: SessionTypes.Struct;
145
+ }>;
146
+ disconnect: () => Promise<boolean>;
147
+ disconnectWallet: () => Promise<boolean>;
148
+ loadConnectionInfo: () => string | null;
149
+ saveConnectionInfo: (accountId: string) => void;
150
+ executeTransaction: (tx: Transaction, disableSigner: boolean) => Promise<TransactionReceipt>;
151
+ executeTransationWithErrorHandling: (tx: Transaction, disableSigner: boolean) => Promise<{
152
+ result?: TransactionReceipt;
153
+ error?: string;
154
+ }>;
155
+ submitMessageToTopic: (topicId: string, message: string) => Promise<TransactionReceipt>;
156
+ transferHbar: (fromAccountId: string, toAccountId: string, amount: number) => Promise<TransactionReceipt>;
157
+ executeSmartContract: (contractId: string, functionName: string, parameters: ContractFunctionParameters, gas?: number) => Promise<TransactionReceipt>;
158
+ getAccountBalance: () => Promise<string>;
159
+ getAccountInfo: () => string;
160
+ createTopic: (memo?: string, adminKey?: string, submitKey?: string) => Promise<string>;
161
+ createToken: (name: string, symbol: string, initialSupply: number, decimals: number, treasuryAccountId: string, adminKey: string, supplyKey: string) => Promise<string>;
162
+ mintNFT: (tokenId: string, metadata: string, supplyKey: PrivateKey) => Promise<TransactionReceipt>;
163
+ dAppConnector?: DAppConnector;
164
+ getMessages: (topicId: string, collectedMessages: Message[], lastTimestamp?: number, disableTimestampFilter?: boolean, nextUrl?: string) => Promise<FetchMessagesResult>;
165
+ initAccount: (PROJECT_ID: string, APP_METADATA: SignClientTypes.Metadata) => Promise<{
166
+ accountId: string;
167
+ balance: string;
168
+ } | null>;
169
+ transferToken: (tokenId: string, fromAccountId: string, toAccountId: string, amount: number) => Promise<TransactionReceipt>;
170
+ createAccount: (initialBalance: number) => Promise<TransactionReceipt>;
171
+ associateTokenToAccount: (accountId: string, tokenId: string) => Promise<TransactionReceipt>;
172
+ dissociateTokenFromAccount: (accountId: string, tokenId: string) => Promise<TransactionReceipt>;
173
+ updateAccount: (accountId: string, maxAutomaticTokenAssociations: number) => Promise<TransactionReceipt>;
174
+ approveAllowance: (spenderAccountId: string, tokenId: string, amount: number, ownerAccountId: string) => Promise<TransactionReceipt>;
175
+ getAccountTokens: (accountId: string) => Promise<{
176
+ tokens: TokenBalance[];
177
+ }>;
178
+ HashgraphSDK: typeof hashgraph;
179
+ };
@@ -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": "1.0.66",
3
+ "version": "1.0.67",
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": [
@@ -61,7 +61,7 @@
61
61
  "url": "^0.11.4",
62
62
  "util": "^0.12.5",
63
63
  "vite": "^5.4.0",
64
- "vite-plugin-dts": "^4.0.2",
64
+ "vite-plugin-dts": "^4.2.2",
65
65
  "vite-plugin-node-polyfills": "^0.22.0",
66
66
  "vite-plugin-string-replace": "^1.1.3",
67
67
  "webpack": "^5.93.0",