zh-web-sdk 2.3.2 → 2.3.4
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/README.md +16 -19
- package/dist/index.d.ts +1 -1
- package/dist/index.js +5 -5
- package/dist/index.js.map +4 -4
- package/dist/redux/reducers/fiat-deposits.d.ts +13 -0
- package/dist/redux/reducers/index.d.ts +1 -1
- package/dist/redux/store/index.d.ts +1 -1
- package/dist/types.d.ts +9 -9
- package/package.json +1 -1
- package/src/iframe-container/AppContainer.tsx +2 -2
- package/src/index.tsx +10 -10
- package/src/redux/reducers/fiat-deposits.ts +64 -0
- package/src/redux/reducers/index.ts +3 -3
- package/src/types.ts +15 -15
- package/dist/redux/reducers/ach-deposits.d.ts +0 -13
- package/src/redux/reducers/ach-deposits.ts +0 -64
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export interface IFiatDepositsState {
|
|
2
|
+
jwt: string;
|
|
3
|
+
isAppLoaded: boolean;
|
|
4
|
+
isAppActive: boolean;
|
|
5
|
+
}
|
|
6
|
+
export interface IFiatDepositsAction {
|
|
7
|
+
type: string;
|
|
8
|
+
jwt?: string;
|
|
9
|
+
isAppActive?: boolean;
|
|
10
|
+
isAppLoaded?: boolean;
|
|
11
|
+
}
|
|
12
|
+
declare const fiatDepositsReducer: (state: IFiatDepositsState | undefined, action: IFiatDepositsAction) => IFiatDepositsState;
|
|
13
|
+
export default fiatDepositsReducer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const rootReducer: import("redux").Reducer<import("redux").CombinedState<{
|
|
2
2
|
"crypto-withdrawals": import("./crypto-withdrawals").ICryptoWithdrawalsState;
|
|
3
3
|
onboarding: import("./onboarding").IOnboardingState;
|
|
4
|
-
"
|
|
4
|
+
"fiat-deposits": import("./fiat-deposits").IFiatDepositsState;
|
|
5
5
|
"fiat-withdrawals": import("./fiat-withdrawals").IFiatWithdrawalsState;
|
|
6
6
|
"crypto-buy": import("./crypto-buy").ICryptoBuyState;
|
|
7
7
|
"crypto-sell": import("./crypto-sell").ICryptoSellState;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
declare const store: import("redux").Store<import("redux").EmptyObject & {
|
|
2
2
|
"crypto-withdrawals": import("../reducers/crypto-withdrawals").ICryptoWithdrawalsState;
|
|
3
3
|
onboarding: import("../reducers/onboarding").IOnboardingState;
|
|
4
|
-
"
|
|
4
|
+
"fiat-deposits": import("../reducers/fiat-deposits").IFiatDepositsState;
|
|
5
5
|
"fiat-withdrawals": import("../reducers/fiat-withdrawals").IFiatWithdrawalsState;
|
|
6
6
|
"crypto-buy": import("../reducers/crypto-buy").ICryptoBuyState;
|
|
7
7
|
"crypto-sell": import("../reducers/crypto-sell").ICryptoSellState;
|
package/dist/types.d.ts
CHANGED
|
@@ -43,11 +43,11 @@ export interface IInitializeParameters {
|
|
|
43
43
|
*/
|
|
44
44
|
cryptoWithdrawalsJWT?: string;
|
|
45
45
|
/**
|
|
46
|
-
*
|
|
46
|
+
* fiatDepositsJWT is the JWT that you received from
|
|
47
47
|
* the ZeroHash HTTP API and have specific permissions to
|
|
48
|
-
* perform
|
|
48
|
+
* perform Fiat Deposits.
|
|
49
49
|
*/
|
|
50
|
-
|
|
50
|
+
fiatDepositsJWT?: string;
|
|
51
51
|
/**
|
|
52
52
|
* fiatWithdrawalsJWT is the JWT that you received from
|
|
53
53
|
* the ZeroHash HTTP API and have specific permissions to
|
|
@@ -120,15 +120,15 @@ export declare enum IncomingMessageType {
|
|
|
120
120
|
*/
|
|
121
121
|
CryptoWithdrawalsCloseButtonClicked = "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
|
|
122
122
|
/**
|
|
123
|
-
*
|
|
123
|
+
* FiatDepositsAppLoaded is received when the Fiat
|
|
124
124
|
* deposits app has initialized.
|
|
125
125
|
*/
|
|
126
|
-
|
|
126
|
+
FiatDepositsAppLoaded = "FIAT_DEPOSITS_APP_LOADED",
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
129
|
-
* has been clicked in the
|
|
128
|
+
* FiatDepositsCloseButtonClicked is received when the close button
|
|
129
|
+
* has been clicked in the Fiat Deposits app
|
|
130
130
|
*/
|
|
131
|
-
|
|
131
|
+
FiatDepositsCloseButtonClicked = "FIAT_DEPOSITS_CLOSE_BUTTON_CLICKED",
|
|
132
132
|
/**
|
|
133
133
|
* FiatWithdrawalsAppLoaded is received when the Fiat
|
|
134
134
|
* withdrawals app has initialized.
|
|
@@ -193,7 +193,7 @@ export interface IZeroHashSDK {
|
|
|
193
193
|
export declare enum AppIdentifier {
|
|
194
194
|
ONBOARDING = "onboarding",
|
|
195
195
|
CRYPTO_WITHDRAWALS = "crypto-withdrawals",
|
|
196
|
-
|
|
196
|
+
FIAT_DEPOSITS = "fiat-deposits",
|
|
197
197
|
FIAT_WITHDRAWALS = "fiat-withdrawals",
|
|
198
198
|
CRYPTO_BUY = "crypto-buy",
|
|
199
199
|
CRYPTO_SELL = "crypto-sell"
|
package/package.json
CHANGED
|
@@ -34,7 +34,7 @@ interface AppContainerMappedProps {
|
|
|
34
34
|
isAppLoaded: boolean;
|
|
35
35
|
jwt: string;
|
|
36
36
|
};
|
|
37
|
-
[AppIdentifier.
|
|
37
|
+
[AppIdentifier.FIAT_DEPOSITS]: {
|
|
38
38
|
isAppActive: boolean;
|
|
39
39
|
isAppLoaded: boolean;
|
|
40
40
|
jwt: string;
|
|
@@ -61,7 +61,7 @@ const appLoadTime = Date.now();
|
|
|
61
61
|
const mapAppToTitle = {
|
|
62
62
|
[AppIdentifier.ONBOARDING]: "Onboarding",
|
|
63
63
|
[AppIdentifier.CRYPTO_WITHDRAWALS]: "Crypto Withdrawals",
|
|
64
|
-
[AppIdentifier.
|
|
64
|
+
[AppIdentifier.FIAT_DEPOSITS]: "Fiat Deposits",
|
|
65
65
|
[AppIdentifier.FIAT_WITHDRAWALS]: "Fiat Withdrawals",
|
|
66
66
|
[AppIdentifier.CRYPTO_BUY]: "Crypto Buy",
|
|
67
67
|
[AppIdentifier.CRYPTO_SELL]: "Crypto Sell",
|
package/src/index.tsx
CHANGED
|
@@ -45,12 +45,12 @@ const appsMessageHandlers: {
|
|
|
45
45
|
[IncomingMessageType.CryptoWithdrawalsAppLoaded]: () => {
|
|
46
46
|
appLoaded(AppIdentifier.CRYPTO_WITHDRAWALS);
|
|
47
47
|
},
|
|
48
|
-
//
|
|
49
|
-
[IncomingMessageType.
|
|
50
|
-
closeModal(AppIdentifier.
|
|
48
|
+
// Fiat Deposits message handlers
|
|
49
|
+
[IncomingMessageType.FiatDepositsCloseButtonClicked]: () => {
|
|
50
|
+
closeModal(AppIdentifier.FIAT_DEPOSITS);
|
|
51
51
|
},
|
|
52
|
-
[IncomingMessageType.
|
|
53
|
-
appLoaded(AppIdentifier.
|
|
52
|
+
[IncomingMessageType.FiatDepositsAppLoaded]: () => {
|
|
53
|
+
appLoaded(AppIdentifier.FIAT_DEPOSITS);
|
|
54
54
|
},
|
|
55
55
|
// Fiat Withdrawals message handlers
|
|
56
56
|
[IncomingMessageType.FiatWithdrawalsCloseButtonClicked]: () => {
|
|
@@ -107,7 +107,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
|
|
|
107
107
|
private initializedApps: Map<AppIdentifier, boolean> = new Map([
|
|
108
108
|
[AppIdentifier.CRYPTO_WITHDRAWALS, false],
|
|
109
109
|
[AppIdentifier.ONBOARDING, false],
|
|
110
|
-
[AppIdentifier.
|
|
110
|
+
[AppIdentifier.FIAT_DEPOSITS, false],
|
|
111
111
|
[AppIdentifier.FIAT_WITHDRAWALS, false],
|
|
112
112
|
[AppIdentifier.CRYPTO_BUY, false],
|
|
113
113
|
[AppIdentifier.CRYPTO_SELL, false],
|
|
@@ -123,7 +123,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
|
|
|
123
123
|
rootQuerySelector,
|
|
124
124
|
userOnboardingJWT,
|
|
125
125
|
cryptoWithdrawalsJWT,
|
|
126
|
-
|
|
126
|
+
fiatDepositsJWT,
|
|
127
127
|
fiatWithdrawalsJWT,
|
|
128
128
|
cryptoBuyJWT,
|
|
129
129
|
cryptoSellJWT,
|
|
@@ -152,10 +152,10 @@ export class ZeroHashSDK implements IZeroHashSDK {
|
|
|
152
152
|
appIdentifier: AppIdentifier.CRYPTO_WITHDRAWALS,
|
|
153
153
|
});
|
|
154
154
|
}
|
|
155
|
-
if (
|
|
155
|
+
if (fiatDepositsJWT) {
|
|
156
156
|
this.setJWT({
|
|
157
|
-
jwt:
|
|
158
|
-
appIdentifier: AppIdentifier.
|
|
157
|
+
jwt: fiatDepositsJWT,
|
|
158
|
+
appIdentifier: AppIdentifier.FIAT_DEPOSITS,
|
|
159
159
|
});
|
|
160
160
|
}
|
|
161
161
|
if (fiatWithdrawalsJWT) {
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AppIdentifier } from "../../types";
|
|
2
|
+
import { appIdentifierToActionPrefixMap } from "../../types";
|
|
3
|
+
import {
|
|
4
|
+
ACTION_SET_JWT,
|
|
5
|
+
ACTION_SET_MODAL_STATE,
|
|
6
|
+
ACTION_APP_LOADED
|
|
7
|
+
} from "./constants";
|
|
8
|
+
|
|
9
|
+
export interface IFiatDepositsState {
|
|
10
|
+
jwt: string;
|
|
11
|
+
isAppLoaded: boolean;
|
|
12
|
+
isAppActive: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export interface IFiatDepositsAction {
|
|
16
|
+
type: string;
|
|
17
|
+
jwt?: string;
|
|
18
|
+
isAppActive?: boolean;
|
|
19
|
+
isAppLoaded?: boolean;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const INITIAL_STATE: IFiatDepositsState = {
|
|
23
|
+
jwt: "",
|
|
24
|
+
isAppActive: false,
|
|
25
|
+
isAppLoaded: false
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
const applySetIsAppActive = (state: IFiatDepositsState, action: IFiatDepositsAction): IFiatDepositsState => {
|
|
29
|
+
return {
|
|
30
|
+
...state,
|
|
31
|
+
isAppActive: !!action.isAppActive,
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
const applySetSendJWTToApp = (state: IFiatDepositsState, action: IFiatDepositsAction): IFiatDepositsState => {
|
|
36
|
+
return {
|
|
37
|
+
...state,
|
|
38
|
+
isAppLoaded: !!action.isAppLoaded,
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
const applySetJWT = (state: IFiatDepositsState, action: IFiatDepositsAction): IFiatDepositsState => {
|
|
43
|
+
return {
|
|
44
|
+
...state,
|
|
45
|
+
jwt: action.jwt as string,
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const reducerMap: { [actionType: string]: (state: IFiatDepositsState, action: IFiatDepositsAction) => IFiatDepositsState } = {
|
|
50
|
+
// Fiat Deposits reducer
|
|
51
|
+
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.FIAT_DEPOSITS)}${ACTION_SET_JWT}`]: applySetJWT,
|
|
52
|
+
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.FIAT_DEPOSITS)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
|
|
53
|
+
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.FIAT_DEPOSITS)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
|
|
54
|
+
};
|
|
55
|
+
|
|
56
|
+
const fiatDepositsReducer = (state = INITIAL_STATE, action: IFiatDepositsAction) => {
|
|
57
|
+
if (!!action.type && !!reducerMap[action.type]) {
|
|
58
|
+
return reducerMap[action.type](state, action);
|
|
59
|
+
} else {
|
|
60
|
+
return state;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
export default fiatDepositsReducer;
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {combineReducers} from "redux";
|
|
1
|
+
import { combineReducers } from "redux";
|
|
2
2
|
import cryptoWithdrawalsReducer from './crypto-withdrawals'
|
|
3
3
|
import onboardingReducer from "./onboarding";
|
|
4
|
-
import
|
|
4
|
+
import fiatDepositsReducer from "./fiat-deposits";
|
|
5
5
|
import fiatWithdrawalsReducer from "./fiat-withdrawals";
|
|
6
6
|
import cryptoBuyReducer from "./crypto-buy";
|
|
7
7
|
import cryptoSellReducer from "./crypto-sell";
|
|
@@ -9,7 +9,7 @@ import cryptoSellReducer from "./crypto-sell";
|
|
|
9
9
|
const rootReducer = combineReducers({
|
|
10
10
|
["crypto-withdrawals"]: cryptoWithdrawalsReducer,
|
|
11
11
|
["onboarding"]: onboardingReducer,
|
|
12
|
-
["
|
|
12
|
+
["fiat-deposits"]: fiatDepositsReducer,
|
|
13
13
|
["fiat-withdrawals"]: fiatWithdrawalsReducer,
|
|
14
14
|
["crypto-buy"]: cryptoBuyReducer,
|
|
15
15
|
["crypto-sell"]: cryptoSellReducer,
|
package/src/types.ts
CHANGED
|
@@ -45,11 +45,11 @@ export interface IInitializeParameters {
|
|
|
45
45
|
*/
|
|
46
46
|
cryptoWithdrawalsJWT?: string
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* fiatDepositsJWT is the JWT that you received from
|
|
49
49
|
* the ZeroHash HTTP API and have specific permissions to
|
|
50
|
-
* perform
|
|
50
|
+
* perform Fiat Deposits.
|
|
51
51
|
*/
|
|
52
|
-
|
|
52
|
+
fiatDepositsJWT?: string
|
|
53
53
|
/**
|
|
54
54
|
* fiatWithdrawalsJWT is the JWT that you received from
|
|
55
55
|
* the ZeroHash HTTP API and have specific permissions to
|
|
@@ -125,15 +125,15 @@ export enum IncomingMessageType {
|
|
|
125
125
|
*/
|
|
126
126
|
CryptoWithdrawalsCloseButtonClicked = "CRYPTO_WITHDRAWALS_CLOSE_BUTTON_CLICKED",
|
|
127
127
|
/**
|
|
128
|
-
*
|
|
128
|
+
* FiatDepositsAppLoaded is received when the Fiat
|
|
129
129
|
* deposits app has initialized.
|
|
130
130
|
*/
|
|
131
|
-
|
|
131
|
+
FiatDepositsAppLoaded = "FIAT_DEPOSITS_APP_LOADED",
|
|
132
132
|
/**
|
|
133
|
-
*
|
|
134
|
-
* has been clicked in the
|
|
133
|
+
* FiatDepositsCloseButtonClicked is received when the close button
|
|
134
|
+
* has been clicked in the Fiat Deposits app
|
|
135
135
|
*/
|
|
136
|
-
|
|
136
|
+
FiatDepositsCloseButtonClicked = "FIAT_DEPOSITS_CLOSE_BUTTON_CLICKED",
|
|
137
137
|
/**
|
|
138
138
|
* FiatWithdrawalsAppLoaded is received when the Fiat
|
|
139
139
|
* withdrawals app has initialized.
|
|
@@ -202,7 +202,7 @@ export interface IZeroHashSDK {
|
|
|
202
202
|
export enum AppIdentifier {
|
|
203
203
|
ONBOARDING = "onboarding",
|
|
204
204
|
CRYPTO_WITHDRAWALS = "crypto-withdrawals",
|
|
205
|
-
|
|
205
|
+
FIAT_DEPOSITS = "fiat-deposits",
|
|
206
206
|
FIAT_WITHDRAWALS = "fiat-withdrawals",
|
|
207
207
|
CRYPTO_BUY = "crypto-buy",
|
|
208
208
|
CRYPTO_SELL = "crypto-sell",
|
|
@@ -213,12 +213,12 @@ export enum AppIdentifier {
|
|
|
213
213
|
*/
|
|
214
214
|
export const appIdentifierToActionPrefixMap = new Map(
|
|
215
215
|
[
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
216
|
+
[AppIdentifier.ONBOARDING, "ONBOARDING_"],
|
|
217
|
+
[AppIdentifier.CRYPTO_WITHDRAWALS, "CRYPTO_WITHDRAWALS_"],
|
|
218
|
+
[AppIdentifier.FIAT_DEPOSITS, "FIAT_DEPOSITS_"],
|
|
219
|
+
[AppIdentifier.FIAT_WITHDRAWALS, "FIAT_WITHDRAWALS_"],
|
|
220
|
+
[AppIdentifier.CRYPTO_BUY, "CRYPTO_BUY_"],
|
|
221
|
+
[AppIdentifier.CRYPTO_SELL, "CRYPTO_SELL_"],
|
|
222
222
|
])
|
|
223
223
|
|
|
224
224
|
export interface ISetJWTParameters {
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
export interface IAchDepositsState {
|
|
2
|
-
jwt: string;
|
|
3
|
-
isAppLoaded: boolean;
|
|
4
|
-
isAppActive: boolean;
|
|
5
|
-
}
|
|
6
|
-
export interface IAchDepositsAction {
|
|
7
|
-
type: string;
|
|
8
|
-
jwt?: string;
|
|
9
|
-
isAppActive?: boolean;
|
|
10
|
-
isAppLoaded?: boolean;
|
|
11
|
-
}
|
|
12
|
-
declare const achDepositsReducer: (state: IAchDepositsState | undefined, action: IAchDepositsAction) => IAchDepositsState;
|
|
13
|
-
export default achDepositsReducer;
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import { AppIdentifier } from "../../types";
|
|
2
|
-
import { appIdentifierToActionPrefixMap } from "../../types";
|
|
3
|
-
import {
|
|
4
|
-
ACTION_SET_JWT,
|
|
5
|
-
ACTION_SET_MODAL_STATE,
|
|
6
|
-
ACTION_APP_LOADED
|
|
7
|
-
} from "./constants";
|
|
8
|
-
|
|
9
|
-
export interface IAchDepositsState {
|
|
10
|
-
jwt: string;
|
|
11
|
-
isAppLoaded: boolean;
|
|
12
|
-
isAppActive: boolean;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
export interface IAchDepositsAction {
|
|
16
|
-
type: string;
|
|
17
|
-
jwt?: string;
|
|
18
|
-
isAppActive?: boolean;
|
|
19
|
-
isAppLoaded?: boolean;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
const INITIAL_STATE: IAchDepositsState = {
|
|
23
|
-
jwt: "",
|
|
24
|
-
isAppActive: false,
|
|
25
|
-
isAppLoaded: false
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
const applySetIsAppActive = (state: IAchDepositsState, action: IAchDepositsAction) : IAchDepositsState => {
|
|
29
|
-
return {
|
|
30
|
-
...state,
|
|
31
|
-
isAppActive: !!action.isAppActive,
|
|
32
|
-
}
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
const applySetSendJWTToApp = (state: IAchDepositsState, action: IAchDepositsAction) : IAchDepositsState => {
|
|
36
|
-
return {
|
|
37
|
-
...state,
|
|
38
|
-
isAppLoaded: !!action.isAppLoaded,
|
|
39
|
-
}
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
const applySetJWT = (state: IAchDepositsState, action: IAchDepositsAction) : IAchDepositsState => {
|
|
43
|
-
return {
|
|
44
|
-
...state,
|
|
45
|
-
jwt: action.jwt as string,
|
|
46
|
-
}
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
const reducerMap: { [actionType: string]: (state: IAchDepositsState, action: IAchDepositsAction) => IAchDepositsState } = {
|
|
50
|
-
// ACH Deposits reducer
|
|
51
|
-
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.ACH_DEPOSITS)}${ACTION_SET_JWT}`]: applySetJWT,
|
|
52
|
-
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.ACH_DEPOSITS)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
|
|
53
|
-
[`${appIdentifierToActionPrefixMap.get(AppIdentifier.ACH_DEPOSITS)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
|
|
54
|
-
};
|
|
55
|
-
|
|
56
|
-
const achDepositsReducer = (state = INITIAL_STATE, action: IAchDepositsAction) => {
|
|
57
|
-
if (!!action.type && !!reducerMap[action.type]) {
|
|
58
|
-
return reducerMap[action.type](state, action);
|
|
59
|
-
} else {
|
|
60
|
-
return state;
|
|
61
|
-
}
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
export default achDepositsReducer;
|