@vultisig/walletcore-native 0.1.1
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.
- package/android/build.gradle +68 -0
- package/android/src/main/java/expo/modules/walletcore/ExpoWalletCoreModule.kt +349 -0
- package/expo-module.config.json +5 -0
- package/ios/ExpoWalletCore.podspec +17 -0
- package/ios/ExpoWalletCoreModule.swift +547 -0
- package/package.json +26 -0
- package/src/ExpoWalletCoreModule.ts +226 -0
- package/src/index.ts +947 -0
|
@@ -0,0 +1,226 @@
|
|
|
1
|
+
import { requireNativeModule } from 'expo-modules-core'
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* TypeScript declarations for the ExpoWalletCore native module.
|
|
5
|
+
*
|
|
6
|
+
* Uses handle-based opaque references for objects (PublicKey, HDWallet, etc.).
|
|
7
|
+
* Callers must free handles explicitly via the corresponding free* methods.
|
|
8
|
+
*/
|
|
9
|
+
|
|
10
|
+
interface ExpoWalletCoreModuleType {
|
|
11
|
+
// ---------------------------------------------------------------------------
|
|
12
|
+
// CoinType — enum values
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
|
|
15
|
+
/** Get the numeric CoinType value for a coin name. */
|
|
16
|
+
coinTypeValue(name: string): number
|
|
17
|
+
|
|
18
|
+
// ---------------------------------------------------------------------------
|
|
19
|
+
// CoinTypeExt — static methods on CoinType
|
|
20
|
+
// ---------------------------------------------------------------------------
|
|
21
|
+
|
|
22
|
+
/** Get the default derivation path for a CoinType. */
|
|
23
|
+
derivationPath(coinType: number): string
|
|
24
|
+
|
|
25
|
+
/** Derive an address from a public key handle for a CoinType. */
|
|
26
|
+
deriveAddressFromPublicKey(coinType: number, publicKeyHandle: number): string
|
|
27
|
+
|
|
28
|
+
/** Get the chain ID for a CoinType (EVM chains). */
|
|
29
|
+
chainId(coinType: number): string
|
|
30
|
+
|
|
31
|
+
/** Get the SS58 address prefix for a CoinType. */
|
|
32
|
+
ss58Prefix(coinType: number): number
|
|
33
|
+
|
|
34
|
+
// ---------------------------------------------------------------------------
|
|
35
|
+
// PublicKey
|
|
36
|
+
// ---------------------------------------------------------------------------
|
|
37
|
+
|
|
38
|
+
/** Create a PublicKey from raw bytes. Returns a handle. */
|
|
39
|
+
publicKeyCreateWithData(dataBase64: string, typeValue: number): number
|
|
40
|
+
|
|
41
|
+
/** Get the raw public key bytes. Returns base64. */
|
|
42
|
+
publicKeyData(handle: number): string
|
|
43
|
+
|
|
44
|
+
/** Get the uncompressed public key. Returns a new handle. */
|
|
45
|
+
publicKeyUncompressed(handle: number): number
|
|
46
|
+
|
|
47
|
+
/** Get the compressed public key. Returns a new handle. */
|
|
48
|
+
publicKeyCompressed(handle: number): number
|
|
49
|
+
|
|
50
|
+
/** Verify a signature with this public key. */
|
|
51
|
+
publicKeyVerify(handle: number, signatureBase64: string, messageBase64: string): boolean
|
|
52
|
+
|
|
53
|
+
/** Verify a DER-encoded signature. */
|
|
54
|
+
publicKeyVerifyAsDER(handle: number, signatureBase64: string, messageBase64: string): boolean
|
|
55
|
+
|
|
56
|
+
/** Free a PublicKey handle. */
|
|
57
|
+
freePublicKey(handle: number): void
|
|
58
|
+
|
|
59
|
+
// ---------------------------------------------------------------------------
|
|
60
|
+
// AnyAddress
|
|
61
|
+
// ---------------------------------------------------------------------------
|
|
62
|
+
|
|
63
|
+
/** Check if an address is valid for a CoinType. */
|
|
64
|
+
anyAddressIsValid(address: string, coinType: number): boolean
|
|
65
|
+
|
|
66
|
+
/** Check if a Bech32 address is valid. */
|
|
67
|
+
anyAddressIsValidBech32(address: string, coinType: number, hrp: string): boolean
|
|
68
|
+
|
|
69
|
+
/** Check if an SS58 address is valid. */
|
|
70
|
+
anyAddressIsValidSS58(address: string, coinType: number, ss58Prefix: number): boolean
|
|
71
|
+
|
|
72
|
+
/** Create an AnyAddress from a string. Returns the description (formatted address). */
|
|
73
|
+
anyAddressCreateWithString(address: string, coinType: number): string
|
|
74
|
+
|
|
75
|
+
/** Create a Bech32 address from a public key. Returns the description string. */
|
|
76
|
+
anyAddressCreateBech32WithPublicKey(publicKeyHandle: number, coinType: number, hrp: string): string
|
|
77
|
+
|
|
78
|
+
/** Create a Bech32 address from a string address. Returns the description string. */
|
|
79
|
+
anyAddressCreateBech32(address: string, coinType: number, hrp: string): string
|
|
80
|
+
|
|
81
|
+
/** Get the raw data of an address. Returns base64. */
|
|
82
|
+
anyAddressData(address: string, coinType: number): string
|
|
83
|
+
|
|
84
|
+
// ---------------------------------------------------------------------------
|
|
85
|
+
// TransactionCompiler
|
|
86
|
+
// ---------------------------------------------------------------------------
|
|
87
|
+
|
|
88
|
+
/** Get the pre-image hashes for a transaction. Returns base64-encoded proto. */
|
|
89
|
+
preImageHashes(coinType: number, txInputDataBase64: string): string
|
|
90
|
+
|
|
91
|
+
/** Compile a transaction with signatures. Returns base64-encoded compiled tx. */
|
|
92
|
+
compileWithSignatures(
|
|
93
|
+
coinType: number,
|
|
94
|
+
txInputDataBase64: string,
|
|
95
|
+
signaturesBase64: string[],
|
|
96
|
+
publicKeysBase64: string[]
|
|
97
|
+
): string
|
|
98
|
+
|
|
99
|
+
// ---------------------------------------------------------------------------
|
|
100
|
+
// AnySigner
|
|
101
|
+
// ---------------------------------------------------------------------------
|
|
102
|
+
|
|
103
|
+
/** Plan a transaction. Returns base64-encoded plan proto. */
|
|
104
|
+
anySignerPlan(txInputDataBase64: string, coinType: number): string
|
|
105
|
+
|
|
106
|
+
// ---------------------------------------------------------------------------
|
|
107
|
+
// HDWallet
|
|
108
|
+
// ---------------------------------------------------------------------------
|
|
109
|
+
|
|
110
|
+
/** Create an HDWallet from a mnemonic. Returns a handle. */
|
|
111
|
+
hdWalletCreate(mnemonic: string, passphrase: string): number
|
|
112
|
+
|
|
113
|
+
/** Get the master key for a curve. Returns a PrivateKey handle. */
|
|
114
|
+
hdWalletGetMasterKey(handle: number, curveValue: number): number
|
|
115
|
+
|
|
116
|
+
/** Get the key for a specific coin. Returns a PrivateKey handle. */
|
|
117
|
+
hdWalletGetKeyForCoin(handle: number, coinType: number): number
|
|
118
|
+
|
|
119
|
+
/** Get a key with a specific Derivation enum value. Returns a PrivateKey handle. */
|
|
120
|
+
hdWalletGetKeyDerivation(handle: number, coinType: number, derivationValue: number): number
|
|
121
|
+
|
|
122
|
+
/** Get address with a specific Derivation enum value. */
|
|
123
|
+
hdWalletGetAddressDerivation(handle: number, coinType: number, derivationValue: number): string
|
|
124
|
+
|
|
125
|
+
/** Get a key for a specific derivation path. Returns a PrivateKey handle. */
|
|
126
|
+
hdWalletGetKey(handle: number, coinType: number, derivationPath: string): number
|
|
127
|
+
|
|
128
|
+
/** Get the default address for a coin. */
|
|
129
|
+
hdWalletGetAddressForCoin(handle: number, coinType: number): string
|
|
130
|
+
|
|
131
|
+
/** Get the extended private key. */
|
|
132
|
+
hdWalletGetExtendedPrivateKey(
|
|
133
|
+
handle: number,
|
|
134
|
+
purposeValue: number,
|
|
135
|
+
coinType: number,
|
|
136
|
+
versionValue: number
|
|
137
|
+
): string
|
|
138
|
+
|
|
139
|
+
/** Free an HDWallet handle. */
|
|
140
|
+
freeHDWallet(handle: number): void
|
|
141
|
+
|
|
142
|
+
// ---------------------------------------------------------------------------
|
|
143
|
+
// PrivateKey
|
|
144
|
+
// ---------------------------------------------------------------------------
|
|
145
|
+
|
|
146
|
+
/** Create a random PrivateKey. Returns a handle. */
|
|
147
|
+
privateKeyCreate(): number
|
|
148
|
+
|
|
149
|
+
/** Get raw private key bytes. Returns base64. */
|
|
150
|
+
privateKeyData(handle: number): string
|
|
151
|
+
|
|
152
|
+
/** Get secp256k1 public key. Returns a PublicKey handle. */
|
|
153
|
+
privateKeyGetPublicKeySecp256k1(handle: number, compressed: boolean): number
|
|
154
|
+
|
|
155
|
+
/** Get ed25519 public key. Returns a PublicKey handle. */
|
|
156
|
+
privateKeyGetPublicKeyEd25519(handle: number): number
|
|
157
|
+
|
|
158
|
+
/** Free a PrivateKey handle. */
|
|
159
|
+
freePrivateKey(handle: number): void
|
|
160
|
+
|
|
161
|
+
// ---------------------------------------------------------------------------
|
|
162
|
+
// HexCoding
|
|
163
|
+
// ---------------------------------------------------------------------------
|
|
164
|
+
|
|
165
|
+
/** Decode a hex string to bytes. Returns base64. */
|
|
166
|
+
hexDecode(hex: string): string
|
|
167
|
+
|
|
168
|
+
/** Encode bytes to hex. */
|
|
169
|
+
hexEncode(dataBase64: string): string
|
|
170
|
+
|
|
171
|
+
// ---------------------------------------------------------------------------
|
|
172
|
+
// Bech32
|
|
173
|
+
// ---------------------------------------------------------------------------
|
|
174
|
+
|
|
175
|
+
/** Encode data with Bech32. */
|
|
176
|
+
bech32Encode(hrp: string, dataBase64: string): string
|
|
177
|
+
|
|
178
|
+
// ---------------------------------------------------------------------------
|
|
179
|
+
// BitcoinScript
|
|
180
|
+
// ---------------------------------------------------------------------------
|
|
181
|
+
|
|
182
|
+
/** Build a P2WPKH script. Returns base64. */
|
|
183
|
+
bitcoinScriptBuildPayToWitnessPubkeyHash(hashBase64: string): string
|
|
184
|
+
|
|
185
|
+
/** Build a P2PKH script. Returns base64. */
|
|
186
|
+
bitcoinScriptBuildPayToPublicKeyHash(hashBase64: string): string
|
|
187
|
+
|
|
188
|
+
/** Get the lock script for an address. Returns base64. */
|
|
189
|
+
bitcoinScriptLockScriptForAddress(address: string, coinType: number): string
|
|
190
|
+
|
|
191
|
+
/** Get the hash type for a coin. */
|
|
192
|
+
bitcoinScriptHashTypeForCoin(coinType: number): number
|
|
193
|
+
|
|
194
|
+
// ---------------------------------------------------------------------------
|
|
195
|
+
// EthereumAbi
|
|
196
|
+
// ---------------------------------------------------------------------------
|
|
197
|
+
|
|
198
|
+
/** Encode an ABI function call. Returns base64. */
|
|
199
|
+
ethereumAbiEncode(functionName: string, params: string): string
|
|
200
|
+
|
|
201
|
+
/** Encode a typed data message (EIP-712). Returns hex string. */
|
|
202
|
+
ethereumAbiEncodeTyped(messageJson: string): string
|
|
203
|
+
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
// Mnemonic
|
|
206
|
+
// ---------------------------------------------------------------------------
|
|
207
|
+
|
|
208
|
+
/** Check if a mnemonic phrase is valid. */
|
|
209
|
+
mnemonicIsValid(mnemonic: string): boolean
|
|
210
|
+
|
|
211
|
+
// ---------------------------------------------------------------------------
|
|
212
|
+
// TONAddressConverter
|
|
213
|
+
// ---------------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
/** Convert a TON address to user-friendly format. */
|
|
216
|
+
tonAddressToUserFriendly(address: string): string
|
|
217
|
+
|
|
218
|
+
// ---------------------------------------------------------------------------
|
|
219
|
+
// SolanaAddress
|
|
220
|
+
// ---------------------------------------------------------------------------
|
|
221
|
+
|
|
222
|
+
/** Get the default token address for a Solana address + token mint. */
|
|
223
|
+
solanaAddressDefaultTokenAddress(address: string, tokenMintAddress: string): string
|
|
224
|
+
}
|
|
225
|
+
|
|
226
|
+
export default requireNativeModule<ExpoWalletCoreModuleType>('ExpoWalletCore')
|