@chainberry/trust-wallet-core 2.5.0 → 2.5.2
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/ChainberryTrustWalletCoreModule.podspec +9 -2
- package/README.md +42 -5
- package/android/src/androidTest/java/com/chainberry/trustwalletcore/AddressDerivationConformanceTest.kt +4 -4
- package/android/src/androidTest/java/com/chainberry/trustwalletcore/SigningConformanceTest.kt +2 -2
- package/android/src/main/java/com/chainberry/trustwalletcore/ChainSigning.kt +393 -18
- package/android/src/main/java/com/chainberry/trustwalletcore/ChainberryTrustWalletCoreModule.kt +101 -18
- package/android/src/main/java/com/chainberry/trustwalletcore/NativeWalletStore.kt +128 -18
- package/android/src/test/java/com/chainberry/trustwalletcore/NativeWalletStoreTest.kt +92 -4
- package/ios/ChainSigning.swift +430 -40
- package/ios/ChainberryTrustWalletCoreModule.swift +131 -20
- package/ios/ConformanceTests/AddressDerivationConformanceTests.swift +39 -0
- package/ios/ConformanceTests/SigningConformanceTests.swift +292 -0
- package/ios/NativeWalletStore.swift +73 -6
- package/package.json +1 -1
- package/src/index.ts +24 -10
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@chainberry/trust-wallet-core",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.2",
|
|
4
4
|
"description": "Expo native module wrapping Trust Wallet Core for native-only HD wallet custody, address derivation, and transaction signing (Ethereum, BNB, Polygon, Solana, Tron, TON, Bitcoin, Bitcoin Cash, Litecoin, XRP) — mnemonic/private keys never cross the JS bridge",
|
|
5
5
|
"main": "src/index.ts",
|
|
6
6
|
"types": "src/index.ts",
|
package/src/index.ts
CHANGED
|
@@ -23,11 +23,17 @@ export type Chain =
|
|
|
23
23
|
| "bitcoincash"
|
|
24
24
|
| "dogecoin"
|
|
25
25
|
| "litecoin"
|
|
26
|
-
| "xrp"
|
|
26
|
+
| "xrp"
|
|
27
|
+
| "cosmos"
|
|
28
|
+
| "aptos"
|
|
29
|
+
| "tezos";
|
|
27
30
|
|
|
28
31
|
export type WalletSummary = {
|
|
29
32
|
walletId: string;
|
|
30
33
|
addresses: Record<Chain, string>;
|
|
34
|
+
/** Fixed at creation time and persisted as immutable native wallet metadata — the
|
|
35
|
+
* authoritative source `signTransaction` derives/signs with for this wallet. */
|
|
36
|
+
isTestnet: boolean;
|
|
31
37
|
};
|
|
32
38
|
|
|
33
39
|
export type SignResult = {
|
|
@@ -43,15 +49,23 @@ const TrustWalletCore = requireNativeModule("TrustWalletCore");
|
|
|
43
49
|
* would derive addresses from a seed different from the one actually used to sign.
|
|
44
50
|
* `isTestnet` selects the address format for BTC/LTC/BCH (every other chain's address is
|
|
45
51
|
* identical on mainnet and testnet) — callers should pass `IS_TESTNET` from
|
|
46
|
-
* `@/constants/wallet-env`.
|
|
47
|
-
|
|
52
|
+
* `@/constants/wallet-env`. The value passed here is permanent: it's persisted as immutable
|
|
53
|
+
* per-wallet metadata and later read back by `signTransaction` for this wallet — it cannot be
|
|
54
|
+
* changed or overridden after creation. */
|
|
55
|
+
export async function createWallet(
|
|
56
|
+
strength: 128 | 256 = 128,
|
|
57
|
+
isTestnet = false,
|
|
58
|
+
): Promise<WalletSummary> {
|
|
48
59
|
return TrustWalletCore.createWallet(strength, isTestnet);
|
|
49
60
|
}
|
|
50
61
|
|
|
51
62
|
/** One-time mnemonic exposure from the caller — persisted natively immediately, never
|
|
52
63
|
* retained in JS after this call returns. No BIP-39 passphrase support (see `createWallet`).
|
|
53
|
-
* `isTestnet` — see `createWallet
|
|
54
|
-
export async function importWallet(
|
|
64
|
+
* `isTestnet` — see `createWallet` (same permanence guarantee applies). */
|
|
65
|
+
export async function importWallet(
|
|
66
|
+
mnemonic: string,
|
|
67
|
+
isTestnet = false,
|
|
68
|
+
): Promise<WalletSummary> {
|
|
55
69
|
return TrustWalletCore.importWallet(mnemonic, isTestnet);
|
|
56
70
|
}
|
|
57
71
|
|
|
@@ -65,16 +79,16 @@ export async function deleteWallet(walletId: string): Promise<void> {
|
|
|
65
79
|
}
|
|
66
80
|
|
|
67
81
|
/** Triggers the native biometry/passcode prompt, then signs entirely in-process —
|
|
68
|
-
* only signed transaction bytes/hex cross back.
|
|
69
|
-
*
|
|
70
|
-
* `
|
|
82
|
+
* only signed transaction bytes/hex cross back. Network mode (mainnet/testnet) is not
|
|
83
|
+
* accepted here: the native module reads it from the wallet's own persisted record (set once,
|
|
84
|
+
* at `createWallet`/`importWallet` time), so it can never drift from what created the
|
|
85
|
+
* wallet's addresses. */
|
|
71
86
|
export async function signTransaction(
|
|
72
87
|
walletId: string,
|
|
73
88
|
chain: Chain,
|
|
74
89
|
unsignedTx: Record<string, unknown>,
|
|
75
|
-
isTestnet = false,
|
|
76
90
|
): Promise<SignResult> {
|
|
77
|
-
return TrustWalletCore.signTransaction(walletId, chain, unsignedTx
|
|
91
|
+
return TrustWalletCore.signTransaction(walletId, chain, unsignedTx);
|
|
78
92
|
}
|
|
79
93
|
|
|
80
94
|
/** The one sanctioned mnemonic exposure — explicit backup/reveal flow only, gated behind
|