zano-native 0.0.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/CHANGELOG.md +90 -0
- package/LICENSE +27 -0
- package/README.md +24 -0
- package/android/build.gradle +40 -0
- package/android/src/main/java/app/edge/rnzano/RnZanoModule.java +73 -0
- package/android/src/main/java/app/edge/rnzano/RnZanoPackage.java +21 -0
- package/android/src/main/jniLibs/arm64-v8a/librnzano.so +0 -0
- package/ios/ZanoModule.h +4 -0
- package/ios/ZanoModule.mm +138 -0
- package/ios/ZanoModule.xcframework/Info.plist +43 -0
- package/ios/ZanoModule.xcframework/ios-arm64/libzano-module.a +0 -0
- package/ios/ZanoModule.xcframework/ios-arm64-simulator/libzano-module.a +0 -0
- package/ios/react-native-zano.xcodeproj/project.pbxproj +1 -0
- package/lib/scripts/build-native-host.d.ts +1 -0
- package/lib/scripts/build-native-host.js +175 -0
- package/lib/scripts/smoke-node.d.ts +1 -0
- package/lib/scripts/smoke-node.js +33 -0
- package/lib/scripts/update-sources.d.ts +1 -0
- package/lib/scripts/update-sources.js +412 -0
- package/lib/scripts/utils/android-tools.d.ts +1 -0
- package/lib/scripts/utils/android-tools.js +25 -0
- package/lib/scripts/utils/closeWalletPatch.d.ts +23 -0
- package/lib/scripts/utils/closeWalletPatch.js +215 -0
- package/lib/scripts/utils/common.d.ts +37 -0
- package/lib/scripts/utils/common.js +186 -0
- package/lib/scripts/utils/ios-tools.d.ts +8 -0
- package/lib/scripts/utils/ios-tools.js +26 -0
- package/lib/scripts/utils/sdkFolders.d.ts +27 -0
- package/lib/scripts/utils/sdkFolders.js +43 -0
- package/lib/src/CppBridge.d.ts +142 -0
- package/lib/src/CppBridge.js +668 -0
- package/lib/src/index.d.ts +4 -0
- package/lib/src/index.js +28 -0
- package/lib/src/load-addon.d.ts +5 -0
- package/lib/src/load-addon.js +50 -0
- package/lib/src/node.d.ts +11 -0
- package/lib/src/node.js +25 -0
- package/lib/src/types.d.ts +292 -0
- package/lib/src/types.js +40 -0
- package/lib/src/walletFilePassword.d.ts +14 -0
- package/lib/src/walletFilePassword.js +74 -0
- package/node.d.ts +5 -0
- package/node.js +2 -0
- package/package.json +105 -0
- package/prebuilds/darwin-arm64/zano.node +0 -0
- package/src/node/zano-napi.cpp +176 -0
- package/src/zano-wrapper/zano-methods.hpp +15 -0
- package/zano-native.podspec +27 -0
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
import { AddressInfo, AsyncCallResponse, BurnAssetParams, CloseResponse, ConnectivityStatus, FeePriority, GetBalancesResponse, GetRecentTransactionsResponse, GetSeedPhraseInfo, JsonRpc, ReturnCode, TransferParams, TryPullResultResponse, WalletDetails, WalletFiles, WalletInfoExtended, WalletStatus } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* The shape of the native C++ module exposed to React Native.
|
|
4
|
+
*
|
|
5
|
+
* You do not normally need this, but it is accessible as
|
|
6
|
+
* `require('react-native').NativeModules.ZanoModule`.
|
|
7
|
+
*
|
|
8
|
+
* Pass this object to the `CppBridge` constructor to re-assemble the API.
|
|
9
|
+
*/
|
|
10
|
+
export interface NativeZanoModule {
|
|
11
|
+
readonly callZano: (name: string, jsonArguments: string[]) => Promise<string>;
|
|
12
|
+
readonly methodNames: string[];
|
|
13
|
+
/**
|
|
14
|
+
* Absent when the iOS module could not create the wallet directory or
|
|
15
|
+
* exclude it from device backups; the `CppBridge` constructor refuses to
|
|
16
|
+
* run without it.
|
|
17
|
+
*/
|
|
18
|
+
readonly documentDirectory?: string;
|
|
19
|
+
}
|
|
20
|
+
export declare class CppBridge {
|
|
21
|
+
private readonly module;
|
|
22
|
+
private readonly documentDirectory;
|
|
23
|
+
private postponedRunConfigured;
|
|
24
|
+
constructor(zanoModule: NativeZanoModule);
|
|
25
|
+
init(rpcAddress: string, logLevel: number): Promise<JsonRpc<ReturnCode>>;
|
|
26
|
+
initWithIpPort(ip: string, port: string, logLevel: number): Promise<JsonRpc<ReturnCode>>;
|
|
27
|
+
reset(): Promise<JsonRpc<ReturnCode>>;
|
|
28
|
+
setLogLevel(logLevel: number): Promise<string>;
|
|
29
|
+
getVersion(): Promise<string>;
|
|
30
|
+
getWalletFiles(): Promise<WalletFiles | {}>;
|
|
31
|
+
getExportPrivateInfo(targetDir: string): Promise<JsonRpc<ReturnCode>>;
|
|
32
|
+
deleteWallet(fileName: string): Promise<JsonRpc<ReturnCode>>;
|
|
33
|
+
getAddressInfo(addr: string): Promise<AddressInfo>;
|
|
34
|
+
getAppconfig(encryptionKey: string): Promise<object>;
|
|
35
|
+
setAppconfig(confStr: string, encryptionKey: string): Promise<JsonRpc<ReturnCode>>;
|
|
36
|
+
generateRandomKey(length: number): Promise<string>;
|
|
37
|
+
getLogsBuffer(): Promise<string>;
|
|
38
|
+
truncateLog(): Promise<JsonRpc<ReturnCode>>;
|
|
39
|
+
getConnectivityStatus(): Promise<ConnectivityStatus>;
|
|
40
|
+
/**
|
|
41
|
+
* Raw native open. Note that once `startWallet` or `generateSeedPhrase`
|
|
42
|
+
* has run, the process-wide postponed-run mode is configured and stays on:
|
|
43
|
+
* a wallet opened here will not sync until `run_wallet` is issued for it
|
|
44
|
+
* (via `syncCall`). Prefer `startWallet`.
|
|
45
|
+
*/
|
|
46
|
+
open(path: string, password: string): Promise<JsonRpc<WalletDetails>>;
|
|
47
|
+
/**
|
|
48
|
+
* Raw native restore. Subject to the same postponed-run caveat as `open`:
|
|
49
|
+
* under postponed mode the restored wallet will not sync until
|
|
50
|
+
* `run_wallet` is issued for it.
|
|
51
|
+
*/
|
|
52
|
+
restore(seed: string, path: string, password: string, seedPassword: string): Promise<JsonRpc<WalletDetails>>;
|
|
53
|
+
/**
|
|
54
|
+
* Raw native generate. Subject to the same postponed-run caveat as `open`:
|
|
55
|
+
* under postponed mode the generated wallet will not sync until
|
|
56
|
+
* `run_wallet` is issued for it.
|
|
57
|
+
*/
|
|
58
|
+
generate(path: string, password: string): Promise<JsonRpc<WalletDetails>>;
|
|
59
|
+
getOpenedWallets(): Promise<JsonRpc<WalletDetails[]>>;
|
|
60
|
+
getWalletStatus(walletId: number): Promise<WalletStatus>;
|
|
61
|
+
closeWallet(walletId: number): Promise<CloseResponse>;
|
|
62
|
+
invoke(walletId: number, params: string): Promise<string>;
|
|
63
|
+
asyncCall(methodName: string, instanceId: number, params: string): Promise<AsyncCallResponse>;
|
|
64
|
+
tryPullResult<T>(arg: number): Promise<TryPullResultResponse<T>>;
|
|
65
|
+
syncCall(methodName: string, instanceId: number, params: string): Promise<string>;
|
|
66
|
+
/**
|
|
67
|
+
* Tells the native library not to start a wallet's refresh worker as part
|
|
68
|
+
* of `open`/`restore`/`generate`; `runWallet` starts it explicitly. The
|
|
69
|
+
* flag is process-wide and sticky, so every open made after this call must
|
|
70
|
+
* be followed by `runWallet` once the wallet should sync -- and one
|
|
71
|
+
* success is enough, so this short-circuits instead of paying a native
|
|
72
|
+
* round trip per wallet start. Requires `init` to have run.
|
|
73
|
+
*/
|
|
74
|
+
private configurePostponedRun;
|
|
75
|
+
/**
|
|
76
|
+
* Starts the refresh worker for an open wallet. Idempotent: the native
|
|
77
|
+
* side skips the spawn when the worker is already running.
|
|
78
|
+
*
|
|
79
|
+
* Public because adopting a wallet is public behavior: `startWallet`
|
|
80
|
+
* rethrows ALREADY_EXISTS for its caller to recover from, and the wallet
|
|
81
|
+
* the caller then adopts was opened with the refresh worker postponed, so
|
|
82
|
+
* it does not sync until this runs.
|
|
83
|
+
*/
|
|
84
|
+
runWallet(walletId: number): Promise<void>;
|
|
85
|
+
isWalletExist(path: string): Promise<boolean>;
|
|
86
|
+
getWalletInfo(walletId: number): Promise<{
|
|
87
|
+
wi: WalletDetails['wi'];
|
|
88
|
+
wi_extended: WalletInfoExtended;
|
|
89
|
+
}>;
|
|
90
|
+
resetWalletPassword(walletId: number, password: string): Promise<string>;
|
|
91
|
+
getCurrentTxFee(priority: FeePriority): Promise<number>;
|
|
92
|
+
getSeedPhraseInfo(seed: string, seedPassword: string): Promise<GetSeedPhraseInfo>;
|
|
93
|
+
generateSeedPhrase(rpcAddress: string, storagePath: string, seedPassword: string, logLevel?: number): Promise<WalletDetails>;
|
|
94
|
+
/**
|
|
95
|
+
* Opens the wallet file at `storagePath`, creating it from the mnemonic if
|
|
96
|
+
* it does not exist.
|
|
97
|
+
*
|
|
98
|
+
* The file on disk is encrypted with a password derived from the mnemonic,
|
|
99
|
+
* never with `seedPassword`. Versions 0.3.0 and earlier used `seedPassword`
|
|
100
|
+
* for both roles, so files written by them were keyed with the seed
|
|
101
|
+
* passphrase -- the empty string for most wallets. A file still encrypted
|
|
102
|
+
* that way is re-keyed in place the first time it opens. A file that no
|
|
103
|
+
* known password opens, or that the SDK cannot parse a wallet out of at
|
|
104
|
+
* all - the leavings of a crash during the file's first write - is
|
|
105
|
+
* deleted and rebuilt from the mnemonic, costing one re-scan - but only
|
|
106
|
+
* for a wallet with no seed passphrase. With one set, the passphrase is
|
|
107
|
+
* far and away the likeliest thing to be wrong, and rebuilding would
|
|
108
|
+
* restore a different wallet over a file that was intact, so that case
|
|
109
|
+
* throws instead.
|
|
110
|
+
*
|
|
111
|
+
* The migration is decided entirely by what the file does, so it is
|
|
112
|
+
* idempotent and self-healing: an interrupted re-key leaves the file on
|
|
113
|
+
* its old password for the next attempt.
|
|
114
|
+
*/
|
|
115
|
+
startWallet(mnemonicSeed: string, seedPassword: string, storagePath: string, opts?: {
|
|
116
|
+
log?: (message: string) => void;
|
|
117
|
+
}): Promise<WalletDetails>;
|
|
118
|
+
stopWallet(walletId: number): Promise<string>;
|
|
119
|
+
removeWallet(walletId: number): Promise<void>;
|
|
120
|
+
walletStatus(walletId: number): Promise<WalletStatus>;
|
|
121
|
+
getBalances(walletId: number): Promise<GetBalancesResponse>;
|
|
122
|
+
/**
|
|
123
|
+
* Fetches a page of wallet history. Uses `get_recent_txs_and_info3`, the
|
|
124
|
+
* HF6-ready endpoint: the v2 variant reports only the deprecated
|
|
125
|
+
* transaction-wide payment id - an empty string for every id created
|
|
126
|
+
* since HF6, when ids moved into individual outputs - and its legacy
|
|
127
|
+
* serializer refuses entries carrying more than one distinct per-output
|
|
128
|
+
* id, which the HF6 migration guide says to expect.
|
|
129
|
+
*/
|
|
130
|
+
getTransactions(walletId: number, offset?: number): Promise<GetRecentTransactionsResponse>;
|
|
131
|
+
whitelistAssets(walletId: number, assetIds: string[]): Promise<void>;
|
|
132
|
+
transfer(walletId: number, opts: TransferParams): Promise<string>;
|
|
133
|
+
burnAsset(walletId: number, opts: BurnAssetParams): Promise<string>;
|
|
134
|
+
/**
|
|
135
|
+
* Validates that a wallet payload really carries a wallet handle.
|
|
136
|
+
* Guards the paths that must not mistake a degenerate payload for an
|
|
137
|
+
* open wallet.
|
|
138
|
+
*/
|
|
139
|
+
private expectWallet;
|
|
140
|
+
private handleRpcResponse;
|
|
141
|
+
private _asyncCallWithRetry;
|
|
142
|
+
}
|