1
1
import * as wasm from '../wasm.js' ;
2
2
3
3
export 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 ( ) ;
5
6
return wasm . WasmSdk . generateMnemonic ( wordCount ?? null , languageCode ?? null ) ;
6
7
}
7
8
8
- export function validateMnemonic ( mnemonic : string , languageCode ?: string ) : boolean {
9
+ export async function validateMnemonic ( mnemonic : string , languageCode ?: string ) : Promise < boolean > {
10
+ await wasm . ensureInitialized ( ) ;
9
11
return wasm . WasmSdk . validateMnemonic ( mnemonic , languageCode ?? null ) ;
10
12
}
11
13
12
- export function mnemonicToSeed ( mnemonic : string , passphrase ?: string ) : Uint8Array {
14
+ export async function mnemonicToSeed ( mnemonic : string , passphrase ?: string ) : Promise < Uint8Array > {
15
+ await wasm . ensureInitialized ( ) ;
13
16
return wasm . WasmSdk . mnemonicToSeed ( mnemonic , passphrase ?? null ) ;
14
17
}
15
18
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 ( ) ;
17
21
return wasm . WasmSdk . deriveKeyFromSeedPhrase ( mnemonic , passphrase ?? null , network ) ;
18
22
}
19
23
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 ( ) ;
21
26
return wasm . WasmSdk . deriveKeyFromSeedWithPath ( mnemonic , passphrase ?? null , path , network ) ;
22
27
}
23
28
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 ( ) ;
25
31
return wasm . WasmSdk . deriveKeyFromSeedWithExtendedPath ( mnemonic , passphrase ?? null , path , network ) ;
26
32
}
27
33
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 ( ) ;
29
36
return wasm . WasmSdk . deriveDashpayContactKey (
30
37
mnemonic ,
31
38
passphrase ?? null ,
@@ -37,63 +44,78 @@ export namespace wallet {
37
44
) ;
38
45
}
39
46
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 ( ) ;
41
49
return wasm . WasmSdk . derivationPathBip44Mainnet ( account , change , index ) ;
42
50
}
43
51
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 ( ) ;
45
54
return wasm . WasmSdk . derivationPathBip44Testnet ( account , change , index ) ;
46
55
}
47
56
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 ( ) ;
49
59
return wasm . WasmSdk . derivationPathDip9Mainnet ( featureType , account , index ) ;
50
60
}
51
61
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 ( ) ;
53
64
return wasm . WasmSdk . derivationPathDip9Testnet ( featureType , account , index ) ;
54
65
}
55
66
56
- export function derivationPathDip13Mainnet ( account : number ) : any {
67
+ export async function derivationPathDip13Mainnet ( account : number ) : Promise < any > {
68
+ await wasm . ensureInitialized ( ) ;
57
69
return wasm . WasmSdk . derivationPathDip13Mainnet ( account ) ;
58
70
}
59
71
60
- export function derivationPathDip13Testnet ( account : number ) : any {
72
+ export async function derivationPathDip13Testnet ( account : number ) : Promise < any > {
73
+ await wasm . ensureInitialized ( ) ;
61
74
return wasm . WasmSdk . derivationPathDip13Testnet ( account ) ;
62
75
}
63
76
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 ( ) ;
65
79
return wasm . WasmSdk . deriveChildPublicKey ( xpub , index , hardened ) ;
66
80
}
67
81
68
- export function xprvToXpub ( xprv : string ) : string {
82
+ export async function xprvToXpub ( xprv : string ) : Promise < string > {
83
+ await wasm . ensureInitialized ( ) ;
69
84
return wasm . WasmSdk . xprvToXpub ( xprv ) ;
70
85
}
71
86
72
- export function generateKeyPair ( network : string ) : any {
87
+ export async function generateKeyPair ( network : string ) : Promise < any > {
88
+ await wasm . ensureInitialized ( ) ;
73
89
return wasm . WasmSdk . generateKeyPair ( network ) ;
74
90
}
75
91
76
- export function generateKeyPairs ( network : string , count : number ) : any [ ] {
92
+ export async function generateKeyPairs ( network : string , count : number ) : Promise < any [ ] > {
93
+ await wasm . ensureInitialized ( ) ;
77
94
return wasm . WasmSdk . generateKeyPairs ( network , count ) ;
78
95
}
79
96
80
- export function keyPairFromWif ( privateKeyWif : string ) : any {
97
+ export async function keyPairFromWif ( privateKeyWif : string ) : Promise < any > {
98
+ await wasm . ensureInitialized ( ) ;
81
99
return wasm . WasmSdk . keyPairFromWif ( privateKeyWif ) ;
82
100
}
83
101
84
- export function keyPairFromHex ( privateKeyHex : string , network : string ) : any {
102
+ export async function keyPairFromHex ( privateKeyHex : string , network : string ) : Promise < any > {
103
+ await wasm . ensureInitialized ( ) ;
85
104
return wasm . WasmSdk . keyPairFromHex ( privateKeyHex , network ) ;
86
105
}
87
106
88
- export function pubkeyToAddress ( pubkeyHex : string , network : string ) : string {
107
+ export async function pubkeyToAddress ( pubkeyHex : string , network : string ) : Promise < string > {
108
+ await wasm . ensureInitialized ( ) ;
89
109
return wasm . WasmSdk . pubkeyToAddress ( pubkeyHex , network ) ;
90
110
}
91
111
92
- export function validateAddress ( address : string , network : string ) : boolean {
112
+ export async function validateAddress ( address : string , network : string ) : Promise < boolean > {
113
+ await wasm . ensureInitialized ( ) ;
93
114
return wasm . WasmSdk . validateAddress ( address , network ) ;
94
115
}
95
116
96
- export function signMessage ( message : string , privateKeyWif : string ) : string {
117
+ export async function signMessage ( message : string , privateKeyWif : string ) : Promise < string > {
118
+ await wasm . ensureInitialized ( ) ;
97
119
return wasm . WasmSdk . signMessage ( message , privateKeyWif ) ;
98
120
}
99
121
}
0 commit comments