@dolaned/wallet-sdk-ts
Version:
Wallet SDK for the Nexa blockchain
94 lines (82 loc) • 2.94 kB
text/typescript
// @ts-ignore
import { version } from '../package.json';
import Wallet from "./wallet/Wallet";
/**
* Guards against multiple instances of the wallet SDK being loaded.
* This prevents conflicts and ensures only one version is active at a time.
* @param version - The version string to check
* @throws {Error} When multiple instances are detected
*/
function versionGuard(version: string): void {
if (version !== undefined) {
let message = 'More than one instance of Wallet SDK' +
'Please make sure to require Wallet SDK and check that submodules do' +
' not also include their own Wallet SDK dependency.';
throw new Error(message);
}
}
versionGuard((global as any)._walletSdk_ver);
(global as any)._walletSdk_ver = `v${version}`;
/**
* Wallet SDK - A TypeScript SDK for the Nexa blockchain
*
* This SDK provides comprehensive wallet functionality including:
* - Creating and managing wallets from seed phrases or private keys
* - Account management with different account types
* - Transaction building and signing
* - Token operations and management
* - Message signing and verification
*
* @example
* ```typescript
* import { Wallet } from 'wallet-sdk-ts';
*
* // Create a new wallet
* const wallet = Wallet.create();
*
* // Or restore from seed phrase
* const wallet = Wallet.fromSeedPhrase('your seed phrase here');
*
* // Initialize and discover accounts
* await wallet.initialize();
* ```
*/
const walletSdk = {
versionGuard,
version: `v${version}`,
Wallet
}
export default walletSdk
export { default as Wallet } from './wallet/Wallet'
export { default as WatchOnlyWallet } from './wallet/WatchOnlyWallet'
// Export utility enums and types
export { AccountType, TxTokenType } from './utils/WalletUtils'
// Export account interfaces and classes
export { BaseAccount } from './wallet/accounts/interfaces/BaseAccountInterface'
export { default as DefaultAccount } from './wallet/accounts/models/DefaultAccount'
export { default as DappAccount } from './wallet/accounts/models/DappAccount'
export { default as VaultAccount } from './wallet/accounts/models/VaultAccount'
export { default as AccountStore } from './wallet/accounts/AccountStore'
// Export transaction creators
export { default as WalletTransactionCreator } from './wallet/transactions/WalletTransactionCreator'
export { default as WatchOnlyTransactionCreator } from './wallet/transactions/WatchOnlyTransactionCreator'
// Export network provider
export { rostrumProvider } from './network/RostrumProvider'
// Export entity types and interfaces
export type {
AccountKeys,
AccountIndexes,
AddressKey,
Balance,
WatchOnlyAddress,
TxStatus,
HodlStatus
} from './models/wallet.entities'
export type {
TxEntityState,
TxTemplateData,
TxOptions,
TokenAction,
PermissionLabel,
TransactionEntity
} from './models/transaction.entities'