@spacesops/wdk-react-native-provider 1.0.0-beta.3
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/LICENSE +176 -0
- package/README.md +841 -0
- package/lib/module/contexts/constants.js +20 -0
- package/lib/module/contexts/constants.js.map +1 -0
- package/lib/module/contexts/reducer.js +87 -0
- package/lib/module/contexts/reducer.js.map +1 -0
- package/lib/module/contexts/types.js +4 -0
- package/lib/module/contexts/types.js.map +1 -0
- package/lib/module/contexts/wallet-context.js +409 -0
- package/lib/module/contexts/wallet-context.js.map +1 -0
- package/lib/module/index.js +15 -0
- package/lib/module/index.js.map +1 -0
- package/lib/module/package.json +1 -0
- package/lib/module/polyfills.js +34 -0
- package/lib/module/polyfills.js.map +1 -0
- package/lib/module/services/wdk-service/bare-api.js +69 -0
- package/lib/module/services/wdk-service/bare-api.js.map +1 -0
- package/lib/module/services/wdk-service/index.js +506 -0
- package/lib/module/services/wdk-service/index.js.map +1 -0
- package/lib/module/services/wdk-service/types.js +48 -0
- package/lib/module/services/wdk-service/types.js.map +1 -0
- package/lib/module/services/wdk-service/wdk-encryption-salt.js +29 -0
- package/lib/module/services/wdk-service/wdk-encryption-salt.js.map +1 -0
- package/lib/module/services/wdk-service/wdk-secret-manager-storage.js +64 -0
- package/lib/module/services/wdk-service/wdk-secret-manager-storage.js.map +1 -0
- package/lib/module/services/wdk-service/wdk-secret-manager-worklet.bundle.js +1 -0
- package/lib/module/services/wdk-service/wdk-worklet.mobile.bundle.js +1 -0
- package/lib/module/spec/hrpc/hrpc.json +66 -0
- package/lib/module/spec/hrpc/index.js +121 -0
- package/lib/module/spec/hrpc/index.js.map +1 -0
- package/lib/module/spec/hrpc/messages.js +291 -0
- package/lib/module/spec/hrpc/messages.js.map +1 -0
- package/lib/module/spec/schema/index.js +291 -0
- package/lib/module/spec/schema/index.js.map +1 -0
- package/lib/module/spec/schema/schema.json +186 -0
- package/lib/module/utils/get-balances-from-balance-map.js +18 -0
- package/lib/module/utils/get-balances-from-balance-map.js.map +1 -0
- package/lib/module/utils/get-transactions-from-transaction-map.js +10 -0
- package/lib/module/utils/get-transactions-from-transaction-map.js.map +1 -0
- package/lib/module/worklet/wdk-secret-manager-worklet.js +106 -0
- package/lib/module/worklet/wdk-secret-manager-worklet.js.map +1 -0
- package/lib/typescript/package.json +1 -0
- package/lib/typescript/src/contexts/constants.d.ts +3 -0
- package/lib/typescript/src/contexts/constants.d.ts.map +1 -0
- package/lib/typescript/src/contexts/reducer.d.ts +38 -0
- package/lib/typescript/src/contexts/reducer.d.ts.map +1 -0
- package/lib/typescript/src/contexts/types.d.ts +40 -0
- package/lib/typescript/src/contexts/types.d.ts.map +1 -0
- package/lib/typescript/src/contexts/wallet-context.d.ts +10 -0
- package/lib/typescript/src/contexts/wallet-context.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +7 -0
- package/lib/typescript/src/index.d.ts.map +1 -0
- package/lib/typescript/src/polyfills.d.ts +7 -0
- package/lib/typescript/src/polyfills.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/bare-api.d.ts +32 -0
- package/lib/typescript/src/services/wdk-service/bare-api.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/index.d.ts +68 -0
- package/lib/typescript/src/services/wdk-service/index.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/types.d.ts +125 -0
- package/lib/typescript/src/services/wdk-service/types.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/wdk-encryption-salt.d.ts +6 -0
- package/lib/typescript/src/services/wdk-service/wdk-encryption-salt.d.ts.map +1 -0
- package/lib/typescript/src/services/wdk-service/wdk-secret-manager-storage.d.ts +13 -0
- package/lib/typescript/src/services/wdk-service/wdk-secret-manager-storage.d.ts.map +1 -0
- package/lib/typescript/src/utils/get-balances-from-balance-map.d.ts +4 -0
- package/lib/typescript/src/utils/get-balances-from-balance-map.d.ts.map +1 -0
- package/lib/typescript/src/utils/get-transactions-from-transaction-map.d.ts +4 -0
- package/lib/typescript/src/utils/get-transactions-from-transaction-map.d.ts.map +1 -0
- package/metro-polyfills.js +89 -0
- package/package.json +152 -0
- package/src/contexts/constants.ts +19 -0
- package/src/contexts/reducer.ts +103 -0
- package/src/contexts/types.ts +51 -0
- package/src/contexts/wallet-context.tsx +411 -0
- package/src/index.tsx +28 -0
- package/src/polyfills.ts +31 -0
- package/src/services/wdk-service/bare-api.ts +88 -0
- package/src/services/wdk-service/index.ts +765 -0
- package/src/services/wdk-service/types.ts +137 -0
- package/src/services/wdk-service/wdk-encryption-salt.ts +30 -0
- package/src/services/wdk-service/wdk-secret-manager-storage.ts +102 -0
- package/src/spec/hrpc/hrpc.json +66 -0
- package/src/spec/hrpc/index.js +228 -0
- package/src/spec/hrpc/messages.js +328 -0
- package/src/spec/schema/index.js +328 -0
- package/src/spec/schema/schema.json +186 -0
- package/src/utils/get-balances-from-balance-map.ts +22 -0
- package/src/utils/get-transactions-from-transaction-map.ts +18 -0
- package/src/worklet/wdk-secret-manager-worklet.js +118 -0
package/package.json
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@spacesops/wdk-react-native-provider",
|
|
3
|
+
"version": "1.0.0-beta.3",
|
|
4
|
+
"description": "React Native library providing wallet context and WDK service integration",
|
|
5
|
+
"main": "./lib/module/index.js",
|
|
6
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"source": "./src/index.tsx",
|
|
10
|
+
"types": "./lib/typescript/src/index.d.ts",
|
|
11
|
+
"default": "./lib/module/index.js"
|
|
12
|
+
},
|
|
13
|
+
"./metro-polyfills": "./metro-polyfills.js",
|
|
14
|
+
"./package.json": "./package.json"
|
|
15
|
+
},
|
|
16
|
+
"files": [
|
|
17
|
+
"src",
|
|
18
|
+
"lib",
|
|
19
|
+
"android",
|
|
20
|
+
"ios",
|
|
21
|
+
"cpp",
|
|
22
|
+
"*.podspec",
|
|
23
|
+
"react-native.config.js",
|
|
24
|
+
"metro-polyfills.js",
|
|
25
|
+
"!ios/build",
|
|
26
|
+
"!android/build",
|
|
27
|
+
"!android/gradle",
|
|
28
|
+
"!android/gradlew",
|
|
29
|
+
"!android/gradlew.bat",
|
|
30
|
+
"!android/local.properties",
|
|
31
|
+
"!**/__tests__",
|
|
32
|
+
"!**/__fixtures__",
|
|
33
|
+
"!**/__mocks__",
|
|
34
|
+
"!**/.*"
|
|
35
|
+
],
|
|
36
|
+
"scripts": {
|
|
37
|
+
"example": "yarn workspace react-native-wdk-context-provider-example",
|
|
38
|
+
"test": "jest --passWithNoTests",
|
|
39
|
+
"typecheck": "tsc",
|
|
40
|
+
"lint": "eslint \"**/*.{js,ts,tsx}\"",
|
|
41
|
+
"clean": "del-cli lib",
|
|
42
|
+
"postinstall": "node scripts/fix-pear-wrk-wdk.js",
|
|
43
|
+
"prepare": "bob build && npm run gen:secret-manager-bundle && npm run gen:worker-bundle",
|
|
44
|
+
"gen:worker-bundle": "npx bare-pack --target ios-arm64 --target ios-arm64-simulator --target ios-x64-simulator --target android-arm --target android-arm64 --target android-ia32 --target android-x64 --linked --imports node_modules/@spacesops/pear-wrk-wdk/pack.imports.json --out lib/module/services/wdk-service/wdk-worklet.mobile.bundle.js node_modules/@spacesops/pear-wrk-wdk/src/wdk-worklet.js",
|
|
45
|
+
"gen:secret-manager-bundle": "npx bare-pack --target ios-arm64 --target ios-arm64-simulator --target ios-x64-simulator --target android-arm --target android-arm64 --target android-ia32 --target android-x64 --linked --out lib/module/services/wdk-service/wdk-secret-manager-worklet.bundle.js src/worklet/wdk-secret-manager-worklet.js"
|
|
46
|
+
},
|
|
47
|
+
"keywords": [
|
|
48
|
+
"react-native",
|
|
49
|
+
"ios",
|
|
50
|
+
"android"
|
|
51
|
+
],
|
|
52
|
+
"repository": {
|
|
53
|
+
"type": "git",
|
|
54
|
+
"url": "git+https://github.com/tetherto/wdk-react-native-provider.git"
|
|
55
|
+
},
|
|
56
|
+
"author": "Tether Team <support@tether.io>",
|
|
57
|
+
"license": "Apache-2.0",
|
|
58
|
+
"bugs": {
|
|
59
|
+
"url": "https://github.com/tetherto/wdk-react-native-provider/issues"
|
|
60
|
+
},
|
|
61
|
+
"homepage": "https://github.com/tetherto/wdk-react-native-provider",
|
|
62
|
+
"publishConfig": {
|
|
63
|
+
"registry": "https://registry.npmjs.org/",
|
|
64
|
+
"access": "public"
|
|
65
|
+
},
|
|
66
|
+
"devDependencies": {
|
|
67
|
+
"@eslint/compat": "^1.3.2",
|
|
68
|
+
"@eslint/eslintrc": "^3.3.1",
|
|
69
|
+
"@eslint/js": "^9.35.0",
|
|
70
|
+
"@react-native/eslint-config": "^0.82.0",
|
|
71
|
+
"@types/b4a": "^1.6.5",
|
|
72
|
+
"@types/jest": "^29.5.14",
|
|
73
|
+
"@types/react": "^19.1.12",
|
|
74
|
+
"del-cli": "^6.0.0",
|
|
75
|
+
"eslint": "^9.35.0",
|
|
76
|
+
"eslint-config-prettier": "^10.1.8",
|
|
77
|
+
"eslint-plugin-ft-flow": "^3.0.11",
|
|
78
|
+
"eslint-plugin-prettier": "^5.5.4",
|
|
79
|
+
"eslint-plugin-react-native": "^5.0.0",
|
|
80
|
+
"jest": "^29.7.0",
|
|
81
|
+
"prettier": "^3.6.2",
|
|
82
|
+
"react-native-builder-bob": "^0.40.13",
|
|
83
|
+
"typescript": "^5.9.2"
|
|
84
|
+
},
|
|
85
|
+
"peerDependencies": {
|
|
86
|
+
"@craftzdog/react-native-buffer": "^6.1.0",
|
|
87
|
+
"@react-native-async-storage/async-storage": "^2.2.0",
|
|
88
|
+
"@spacesops/pear-wrk-wdk": "^1.0.0-beta.7",
|
|
89
|
+
"@tetherto/wdk-secret-manager": "^1.0.0-beta.3",
|
|
90
|
+
"b4a": "^1.7.2",
|
|
91
|
+
"bip39": "^3.1.0",
|
|
92
|
+
"browserify-zlib": "^0.2.0",
|
|
93
|
+
"decimal.js": "^10.6.0",
|
|
94
|
+
"events": "^3.3.0",
|
|
95
|
+
"http2-wrapper": "^2.2.1",
|
|
96
|
+
"https-browserify": "^1.0.0",
|
|
97
|
+
"nice-grpc-web": "^3.3.8",
|
|
98
|
+
"path-browserify": "^1.0.1",
|
|
99
|
+
"process": "^0.11.10",
|
|
100
|
+
"querystring-es3": "^0.2.1",
|
|
101
|
+
"react": ">=19.1.0",
|
|
102
|
+
"react-native": ">=0.81.4",
|
|
103
|
+
"react-native-bare-kit": "^0.10.2",
|
|
104
|
+
"react-native-crypto": "^2.2.1",
|
|
105
|
+
"react-native-device-info": "^14.1.1",
|
|
106
|
+
"react-native-get-random-values": "^1.11.0",
|
|
107
|
+
"react-native-keychain": "^10.0.0",
|
|
108
|
+
"react-native-tcp-socket": "^6.3.0",
|
|
109
|
+
"react-native-url-polyfill": "^2.0.0",
|
|
110
|
+
"sodium-javascript": "^0.8.0",
|
|
111
|
+
"stream-browserify": "^3.0.0",
|
|
112
|
+
"stream-http": "^3.2.0"
|
|
113
|
+
},
|
|
114
|
+
"packageManager": "npm@10.9.0",
|
|
115
|
+
"jest": {
|
|
116
|
+
"preset": "react-native",
|
|
117
|
+
"modulePathIgnorePatterns": [
|
|
118
|
+
"<rootDir>/example/node_modules",
|
|
119
|
+
"<rootDir>/lib/"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
"prettier": {
|
|
123
|
+
"quoteProps": "consistent",
|
|
124
|
+
"singleQuote": true,
|
|
125
|
+
"tabWidth": 2,
|
|
126
|
+
"trailingComma": "es5",
|
|
127
|
+
"useTabs": false
|
|
128
|
+
},
|
|
129
|
+
"react-native-builder-bob": {
|
|
130
|
+
"source": "src",
|
|
131
|
+
"output": "lib",
|
|
132
|
+
"targets": [
|
|
133
|
+
[
|
|
134
|
+
"module",
|
|
135
|
+
{
|
|
136
|
+
"esm": true
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
[
|
|
140
|
+
"typescript",
|
|
141
|
+
{
|
|
142
|
+
"project": "tsconfig.build.json"
|
|
143
|
+
}
|
|
144
|
+
]
|
|
145
|
+
]
|
|
146
|
+
},
|
|
147
|
+
"create-react-native-library": {
|
|
148
|
+
"languages": "js",
|
|
149
|
+
"type": "library",
|
|
150
|
+
"version": "0.54.5"
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { WalletContextState } from './types';
|
|
2
|
+
|
|
3
|
+
export const WALLET_CONTEXT_INITIAL_STATE: WalletContextState = {
|
|
4
|
+
wallet: null,
|
|
5
|
+
balances: {
|
|
6
|
+
list: [],
|
|
7
|
+
map: {},
|
|
8
|
+
isLoading: false,
|
|
9
|
+
},
|
|
10
|
+
transactions: {
|
|
11
|
+
list: [],
|
|
12
|
+
map: {},
|
|
13
|
+
isLoading: false,
|
|
14
|
+
},
|
|
15
|
+
isUnlocked: false,
|
|
16
|
+
isInitialized: false,
|
|
17
|
+
isLoading: false,
|
|
18
|
+
error: null,
|
|
19
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AddressMap,
|
|
3
|
+
BalanceMap,
|
|
4
|
+
TransactionMap,
|
|
5
|
+
Wallet,
|
|
6
|
+
} from '../services/wdk-service/types';
|
|
7
|
+
import getBalancesFromBalanceMap from '../utils/get-balances-from-balance-map';
|
|
8
|
+
import getTransactionsFromTransactionMap from '../utils/get-transactions-from-transaction-map';
|
|
9
|
+
import type { WalletContextState } from './types';
|
|
10
|
+
import { WALLET_CONTEXT_INITIAL_STATE } from './constants';
|
|
11
|
+
|
|
12
|
+
type WalletAction =
|
|
13
|
+
| { type: 'SET_LOADING'; payload: boolean }
|
|
14
|
+
| { type: 'SET_ERROR'; payload: string | null }
|
|
15
|
+
| { type: 'SET_WALLET'; payload: Wallet }
|
|
16
|
+
| { type: 'SET_ADDRESSES'; payload: AddressMap }
|
|
17
|
+
| { type: 'SET_INITIALIZED'; payload: boolean }
|
|
18
|
+
| { type: 'SET_UNLOCKED'; payload: boolean }
|
|
19
|
+
| { type: 'SET_BALANCES'; payload: BalanceMap }
|
|
20
|
+
| { type: 'SET_TRANSACTIONS'; payload: TransactionMap }
|
|
21
|
+
| { type: 'SET_LOADING_BALANCES'; payload: boolean }
|
|
22
|
+
| { type: 'SET_LOADING_TRANSACTIONS'; payload: boolean }
|
|
23
|
+
| { type: 'CLEAR_WALLET' };
|
|
24
|
+
|
|
25
|
+
// Reducer
|
|
26
|
+
function reducer(
|
|
27
|
+
state: WalletContextState,
|
|
28
|
+
action: WalletAction
|
|
29
|
+
): WalletContextState {
|
|
30
|
+
switch (action.type) {
|
|
31
|
+
case 'SET_LOADING':
|
|
32
|
+
return { ...state, isLoading: action.payload };
|
|
33
|
+
|
|
34
|
+
case 'SET_ERROR':
|
|
35
|
+
return { ...state, error: action.payload, isLoading: false };
|
|
36
|
+
|
|
37
|
+
case 'SET_WALLET':
|
|
38
|
+
return {
|
|
39
|
+
...state,
|
|
40
|
+
wallet: action.payload,
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
case 'SET_ADDRESSES':
|
|
44
|
+
return {
|
|
45
|
+
...state,
|
|
46
|
+
addresses: action.payload,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
case 'SET_INITIALIZED':
|
|
50
|
+
return { ...state, isInitialized: action.payload };
|
|
51
|
+
|
|
52
|
+
case 'SET_UNLOCKED':
|
|
53
|
+
return { ...state, isUnlocked: action.payload };
|
|
54
|
+
|
|
55
|
+
case 'SET_BALANCES':
|
|
56
|
+
const balances = getBalancesFromBalanceMap(action.payload);
|
|
57
|
+
|
|
58
|
+
return {
|
|
59
|
+
...state,
|
|
60
|
+
balances: {
|
|
61
|
+
...state.balances,
|
|
62
|
+
list: balances,
|
|
63
|
+
map: action.payload,
|
|
64
|
+
},
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
case 'SET_TRANSACTIONS':
|
|
68
|
+
const transactions = getTransactionsFromTransactionMap(action.payload);
|
|
69
|
+
|
|
70
|
+
return {
|
|
71
|
+
...state,
|
|
72
|
+
transactions: {
|
|
73
|
+
...state.transactions,
|
|
74
|
+
list: transactions,
|
|
75
|
+
map: action.payload,
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
|
|
79
|
+
case 'SET_LOADING_BALANCES':
|
|
80
|
+
return {
|
|
81
|
+
...state,
|
|
82
|
+
balances: { ...state.balances, isLoading: action.payload },
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
case 'SET_LOADING_TRANSACTIONS':
|
|
86
|
+
return {
|
|
87
|
+
...state,
|
|
88
|
+
transactions: { ...state.transactions, isLoading: action.payload },
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
case 'CLEAR_WALLET':
|
|
92
|
+
return {
|
|
93
|
+
...WALLET_CONTEXT_INITIAL_STATE,
|
|
94
|
+
// Keep isInitialized true since WDK worklets remain active
|
|
95
|
+
isInitialized: state.isInitialized,
|
|
96
|
+
};
|
|
97
|
+
|
|
98
|
+
default:
|
|
99
|
+
return state;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
export default reducer;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
AddressMap,
|
|
3
|
+
Amount,
|
|
4
|
+
BalanceMap,
|
|
5
|
+
ChainsConfig,
|
|
6
|
+
Transaction,
|
|
7
|
+
TransactionMap,
|
|
8
|
+
Wallet,
|
|
9
|
+
} from '../services/wdk-service/types';
|
|
10
|
+
|
|
11
|
+
export interface WalletContextState {
|
|
12
|
+
wallet?: Wallet | null;
|
|
13
|
+
addresses?: AddressMap;
|
|
14
|
+
balances: {
|
|
15
|
+
list: Amount[];
|
|
16
|
+
map: BalanceMap;
|
|
17
|
+
isLoading: boolean;
|
|
18
|
+
};
|
|
19
|
+
transactions: {
|
|
20
|
+
list: Transaction[];
|
|
21
|
+
map: TransactionMap;
|
|
22
|
+
isLoading: boolean;
|
|
23
|
+
};
|
|
24
|
+
isLoading: boolean;
|
|
25
|
+
error: string | null;
|
|
26
|
+
isInitialized: boolean;
|
|
27
|
+
isUnlocked: boolean;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
export interface WalletContextType extends WalletContextState {
|
|
31
|
+
createWallet: (params: {
|
|
32
|
+
name: string;
|
|
33
|
+
mnemonic?: string;
|
|
34
|
+
}) => Promise<WalletContextState['wallet']>;
|
|
35
|
+
clearWallet: () => Promise<void>;
|
|
36
|
+
clearError: () => void;
|
|
37
|
+
refreshWalletBalance: () => Promise<void>;
|
|
38
|
+
refreshTransactions: () => Promise<void>;
|
|
39
|
+
unlockWallet: () => Promise<boolean | undefined>;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// Provider configuration
|
|
43
|
+
export interface WalletProviderConfig {
|
|
44
|
+
indexer: {
|
|
45
|
+
apiKey: string;
|
|
46
|
+
url: string;
|
|
47
|
+
version?: string;
|
|
48
|
+
};
|
|
49
|
+
chains: ChainsConfig;
|
|
50
|
+
enableCaching?: boolean;
|
|
51
|
+
}
|