11import * as wasm from '../wasm.js' ;
22
33export namespace wallet {
4- export function generateMnemonic ( wordCount ?: number , languageCode ?: string ) : string {
4+ export async function generateMnemonic ( wordCount ?: number , languageCode ?: string ) : Promise < string > {
5+ await wasm . ensureInitialized ( ) ;
56 return wasm . WasmSdk . generateMnemonic ( wordCount ?? null , languageCode ?? null ) ;
67 }
78
8- export function validateMnemonic ( mnemonic : string , languageCode ?: string ) : boolean {
9+ export async function validateMnemonic ( mnemonic : string , languageCode ?: string ) : Promise < boolean > {
10+ await wasm . ensureInitialized ( ) ;
911 return wasm . WasmSdk . validateMnemonic ( mnemonic , languageCode ?? null ) ;
1012 }
1113
12- export function mnemonicToSeed ( mnemonic : string , passphrase ?: string ) : Uint8Array {
14+ export async function mnemonicToSeed ( mnemonic : string , passphrase ?: string ) : Promise < Uint8Array > {
15+ await wasm . ensureInitialized ( ) ;
1316 return wasm . WasmSdk . mnemonicToSeed ( mnemonic , passphrase ?? null ) ;
1417 }
1518
16- export function deriveKeyFromSeedPhrase ( mnemonic : string , passphrase : string | null | undefined , network : string ) : any {
19+ export async function deriveKeyFromSeedPhrase ( mnemonic : string , passphrase : string | null | undefined , network : string ) : Promise < any > {
20+ await wasm . ensureInitialized ( ) ;
1721 return wasm . WasmSdk . deriveKeyFromSeedPhrase ( mnemonic , passphrase ?? null , network ) ;
1822 }
1923
20- export function deriveKeyFromSeedWithPath ( mnemonic : string , passphrase : string | null | undefined , path : string , network : string ) : any {
24+ export async function deriveKeyFromSeedWithPath ( mnemonic : string , passphrase : string | null | undefined , path : string , network : string ) : Promise < any > {
25+ await wasm . ensureInitialized ( ) ;
2126 return wasm . WasmSdk . deriveKeyFromSeedWithPath ( mnemonic , passphrase ?? null , path , network ) ;
2227 }
2328
24- export function deriveKeyFromSeedWithExtendedPath ( mnemonic : string , passphrase : string | null | undefined , path : string , network : string ) : any {
29+ export async function deriveKeyFromSeedWithExtendedPath ( mnemonic : string , passphrase : string | null | undefined , path : string , network : string ) : Promise < any > {
30+ await wasm . ensureInitialized ( ) ;
2531 return wasm . WasmSdk . deriveKeyFromSeedWithExtendedPath ( mnemonic , passphrase ?? null , path , network ) ;
2632 }
2733
28- export function deriveDashpayContactKey ( mnemonic : string , passphrase : string | null | undefined , senderIdentityId : string , receiverIdentityId : string , account : number , addressIndex : number , network : string ) : any {
34+ export async function deriveDashpayContactKey ( mnemonic : string , passphrase : string | null | undefined , senderIdentityId : string , receiverIdentityId : string , account : number , addressIndex : number , network : string ) : Promise < any > {
35+ await wasm . ensureInitialized ( ) ;
2936 return wasm . WasmSdk . deriveDashpayContactKey (
3037 mnemonic ,
3138 passphrase ?? null ,
@@ -37,63 +44,78 @@ export namespace wallet {
3744 ) ;
3845 }
3946
40- export function derivationPathBip44Mainnet ( account : number , change : number , index : number ) : any {
47+ export async function derivationPathBip44Mainnet ( account : number , change : number , index : number ) : Promise < any > {
48+ await wasm . ensureInitialized ( ) ;
4149 return wasm . WasmSdk . derivationPathBip44Mainnet ( account , change , index ) ;
4250 }
4351
44- export function derivationPathBip44Testnet ( account : number , change : number , index : number ) : any {
52+ export async function derivationPathBip44Testnet ( account : number , change : number , index : number ) : Promise < any > {
53+ await wasm . ensureInitialized ( ) ;
4554 return wasm . WasmSdk . derivationPathBip44Testnet ( account , change , index ) ;
4655 }
4756
48- export function derivationPathDip9Mainnet ( featureType : number , account : number , index : number ) : any {
57+ export async function derivationPathDip9Mainnet ( featureType : number , account : number , index : number ) : Promise < any > {
58+ await wasm . ensureInitialized ( ) ;
4959 return wasm . WasmSdk . derivationPathDip9Mainnet ( featureType , account , index ) ;
5060 }
5161
52- export function derivationPathDip9Testnet ( featureType : number , account : number , index : number ) : any {
62+ export async function derivationPathDip9Testnet ( featureType : number , account : number , index : number ) : Promise < any > {
63+ await wasm . ensureInitialized ( ) ;
5364 return wasm . WasmSdk . derivationPathDip9Testnet ( featureType , account , index ) ;
5465 }
5566
56- export function derivationPathDip13Mainnet ( account : number ) : any {
67+ export async function derivationPathDip13Mainnet ( account : number ) : Promise < any > {
68+ await wasm . ensureInitialized ( ) ;
5769 return wasm . WasmSdk . derivationPathDip13Mainnet ( account ) ;
5870 }
5971
60- export function derivationPathDip13Testnet ( account : number ) : any {
72+ export async function derivationPathDip13Testnet ( account : number ) : Promise < any > {
73+ await wasm . ensureInitialized ( ) ;
6174 return wasm . WasmSdk . derivationPathDip13Testnet ( account ) ;
6275 }
6376
64- export function deriveChildPublicKey ( xpub : string , index : number , hardened : boolean ) : string {
77+ export async function deriveChildPublicKey ( xpub : string , index : number , hardened : boolean ) : Promise < string > {
78+ await wasm . ensureInitialized ( ) ;
6579 return wasm . WasmSdk . deriveChildPublicKey ( xpub , index , hardened ) ;
6680 }
6781
68- export function xprvToXpub ( xprv : string ) : string {
82+ export async function xprvToXpub ( xprv : string ) : Promise < string > {
83+ await wasm . ensureInitialized ( ) ;
6984 return wasm . WasmSdk . xprvToXpub ( xprv ) ;
7085 }
7186
72- export function generateKeyPair ( network : string ) : any {
87+ export async function generateKeyPair ( network : string ) : Promise < any > {
88+ await wasm . ensureInitialized ( ) ;
7389 return wasm . WasmSdk . generateKeyPair ( network ) ;
7490 }
7591
76- export function generateKeyPairs ( network : string , count : number ) : any [ ] {
92+ export async function generateKeyPairs ( network : string , count : number ) : Promise < any [ ] > {
93+ await wasm . ensureInitialized ( ) ;
7794 return wasm . WasmSdk . generateKeyPairs ( network , count ) ;
7895 }
7996
80- export function keyPairFromWif ( privateKeyWif : string ) : any {
97+ export async function keyPairFromWif ( privateKeyWif : string ) : Promise < any > {
98+ await wasm . ensureInitialized ( ) ;
8199 return wasm . WasmSdk . keyPairFromWif ( privateKeyWif ) ;
82100 }
83101
84- export function keyPairFromHex ( privateKeyHex : string , network : string ) : any {
102+ export async function keyPairFromHex ( privateKeyHex : string , network : string ) : Promise < any > {
103+ await wasm . ensureInitialized ( ) ;
85104 return wasm . WasmSdk . keyPairFromHex ( privateKeyHex , network ) ;
86105 }
87106
88- export function pubkeyToAddress ( pubkeyHex : string , network : string ) : string {
107+ export async function pubkeyToAddress ( pubkeyHex : string , network : string ) : Promise < string > {
108+ await wasm . ensureInitialized ( ) ;
89109 return wasm . WasmSdk . pubkeyToAddress ( pubkeyHex , network ) ;
90110 }
91111
92- export function validateAddress ( address : string , network : string ) : boolean {
112+ export async function validateAddress ( address : string , network : string ) : Promise < boolean > {
113+ await wasm . ensureInitialized ( ) ;
93114 return wasm . WasmSdk . validateAddress ( address , network ) ;
94115 }
95116
96- export function signMessage ( message : string , privateKeyWif : string ) : string {
117+ export async function signMessage ( message : string , privateKeyWif : string ) : Promise < string > {
118+ await wasm . ensureInitialized ( ) ;
97119 return wasm . WasmSdk . signMessage ( message , privateKeyWif ) ;
98120 }
99121}
0 commit comments