zh-web-sdk 2.7.1 → 2.7.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.
@@ -0,0 +1,13 @@
1
+ export interface IFundState {
2
+ jwt: string;
3
+ isAppLoaded: boolean;
4
+ isAppActive: boolean;
5
+ }
6
+ export interface IFundAction {
7
+ type: string;
8
+ jwt?: string;
9
+ isAppActive?: boolean;
10
+ isAppLoaded?: boolean;
11
+ }
12
+ declare const fundReducer: (state: IFundState | undefined, action: IFundAction) => IFundState;
13
+ export default fundReducer;
@@ -8,6 +8,6 @@ declare const rootReducer: import("redux").Reducer<import("redux").CombinedState
8
8
  "csp-crypto-withdrawals": import("./crypto-withdrawals").ICryptoWithdrawalsState;
9
9
  "csp-fiat-withdrawals": import("./fiat-withdrawals").IFiatWithdrawalsState;
10
10
  "csp-crypto-sell": import("./crypto-sell").ICryptoSellState;
11
- "fund-with-crypto": import("./fund-with-crypto").IFundWithCryptoState;
11
+ fund: import("./fund").IFundState;
12
12
  }>, import("./crypto-withdrawals").ICryptoWithdrawalsAction | import("./crypto-buy").ICryptoBuyAction>;
13
13
  export default rootReducer;
@@ -8,6 +8,6 @@ declare const store: import("redux").Store<import("redux").EmptyObject & {
8
8
  "csp-crypto-withdrawals": import("../reducers/crypto-withdrawals").ICryptoWithdrawalsState;
9
9
  "csp-fiat-withdrawals": import("../reducers/fiat-withdrawals").IFiatWithdrawalsState;
10
10
  "csp-crypto-sell": import("../reducers/crypto-sell").ICryptoSellState;
11
- "fund-with-crypto": import("../reducers/fund-with-crypto").IFundWithCryptoState;
11
+ fund: import("../reducers/fund").IFundState;
12
12
  }, import("../reducers/crypto-withdrawals").ICryptoWithdrawalsAction | import("../reducers/crypto-buy").ICryptoBuyAction>;
13
13
  export default store;
package/dist/types.d.ts CHANGED
@@ -67,11 +67,11 @@ export interface IInitializeParameters {
67
67
  */
68
68
  cryptoSellJWT?: string;
69
69
  /**
70
- * fundWithCryptoJWT is the JWT that you received from
70
+ * fundJWT is the JWT that you received from
71
71
  * the ZeroHash HTTP API and have specific permissions to
72
- * perform Fund With Crypto operations.
72
+ * perform Fund operations.
73
73
  */
74
- fundWithCryptoJWT?: string;
74
+ fundJWT?: string;
75
75
  /**
76
76
  * zeroHashAppsURL is the base URL for all our Apps.
77
77
  * It defaults to https://web-sdk.zerohash.com/ and will
@@ -231,25 +231,25 @@ export declare enum IncomingMessageType {
231
231
  */
232
232
  CryptoSellFailed = "CRYPTO_SELL_FAILED",
233
233
  /**
234
- * FundWithCryptoAppLoaded is received when the Fund Witch Crypto
234
+ * FundAppLoaded is received when the Fund
235
235
  * app has initialized.
236
236
  */
237
- FundWithCryptoAppLoaded = "FUND_WITH_CRYPTO_APP_LOADED",
237
+ FundAppLoaded = "FUND_APP_LOADED",
238
238
  /**
239
- * FundWithCryptoCloseButtonClicked is received when the close button
240
- * has been clicked in the Fund With Crypto app
239
+ * FundCloseButtonClicked is received when the close button
240
+ * has been clicked in the Fund app
241
241
  */
242
- FundWithCryptoCloseButtonClicked = "FUND_WITH_CRYPTO_CLOSE_BUTTON_CLICKED",
242
+ FundCloseButtonClicked = "FUND_CLOSE_BUTTON_CLICKED",
243
243
  /**
244
- * FundWithCryptoCompleted is received when the
245
- * Fund With Crypto flow has completed successfully.
244
+ * FundCompleted is received when the
245
+ * Fund flow has completed successfully.
246
246
  */
247
- FundWithCryptoCompleted = "FUND_WITH_CRYPTO_COMPLETED",
247
+ FundCompleted = "FUND_COMPLETED",
248
248
  /**
249
- * FundWithCryptoFailed is received when the
250
- * Fund With Crypto flow has failed.
249
+ * FundFailed is received when the
250
+ * Fund flow has failed.
251
251
  */
252
- FundWithCryptoFailed = "FUND_WITH_CRYPTO_FAILED"
252
+ FundFailed = "FUND_FAILED"
253
253
  }
254
254
  /**
255
255
  * IncomingMessage defines the structure of an incoming
@@ -291,7 +291,7 @@ export declare enum AppIdentifier {
291
291
  CSP_CRYPTO_WITHDRAWALS = "csp-crypto-withdrawals",
292
292
  CSP_FIAT_WITHDRAWALS = "csp-fiat-withdrawals",
293
293
  CSP_CRYPTO_SELL = "csp-crypto-sell",
294
- FUND_WITH_CRYPTO = "fund-with-crypto"
294
+ FUND = "fund"
295
295
  }
296
296
  /**
297
297
  * Map that maps the app AppIdentifier to the redux action prefix
@@ -302,8 +302,9 @@ export interface ISetJWTParameters {
302
302
  appIdentifier: AppIdentifier;
303
303
  }
304
304
  export interface Filters {
305
- getAssets: {
306
- deposit_address_creation: string;
305
+ getAssets?: {
306
+ deposit_address_creation?: string;
307
+ stablecoin?: boolean;
307
308
  };
308
309
  }
309
310
  export interface IOpenModalParameters {
@@ -313,10 +314,5 @@ export interface IOpenModalParameters {
313
314
  }
314
315
  export interface ISetFiltersParameters {
315
316
  appIdentifier: AppIdentifier;
316
- filters: {
317
- getAssets: {
318
- deposit_address_creation?: string;
319
- stablecoin?: boolean;
320
- };
321
- };
317
+ filters?: Filters;
322
318
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zh-web-sdk",
3
- "version": "2.7.1",
3
+ "version": "2.7.3",
4
4
  "private": false,
5
5
  "description": "ZeroHash Web SDK",
6
6
  "homepage": "https://github.com/seedcx/zh-web-sdk",
@@ -83,7 +83,7 @@ interface AppContainerMappedProps {
83
83
  jwt: string;
84
84
  filters?: Filters;
85
85
  };
86
- [AppIdentifier.FUND_WITH_CRYPTO]: {
86
+ [AppIdentifier.FUND]: {
87
87
  isAppActive: boolean;
88
88
  isAppLoaded: boolean;
89
89
  jwt: string;
@@ -103,7 +103,7 @@ const mapAppToTitle = {
103
103
  [AppIdentifier.CSP_CRYPTO_WITHDRAWALS]: "CBP Crypto Withdrawals",
104
104
  [AppIdentifier.CSP_FIAT_WITHDRAWALS]: "CBP Fiat Withdrawals",
105
105
  [AppIdentifier.CSP_CRYPTO_SELL]: "Crypto Sell",
106
- [AppIdentifier.FUND_WITH_CRYPTO]: "Fund With Crypto",
106
+ [AppIdentifier.FUND]: "Fund"
107
107
  };
108
108
 
109
109
  const AppContainer = ({
package/src/index.tsx CHANGED
@@ -113,18 +113,18 @@ const appsMessageHandlers: {
113
113
  [IncomingMessageType.CryptoSellFailed]: () => {
114
114
  appFailed(AppIdentifier.CRYPTO_SELL);
115
115
  },
116
- // Fund with crypto message handlers
117
- [IncomingMessageType.FundWithCryptoAppLoaded]: () => {
118
- appLoaded(AppIdentifier.FUND_WITH_CRYPTO);
116
+ // Fund message handlers
117
+ [IncomingMessageType.FundAppLoaded]: () => {
118
+ appLoaded(AppIdentifier.FUND);
119
119
  },
120
- [IncomingMessageType.FundWithCryptoCloseButtonClicked]: () => {
121
- closeModal(AppIdentifier.FUND_WITH_CRYPTO);
120
+ [IncomingMessageType.FundCloseButtonClicked]: () => {
121
+ closeModal(AppIdentifier.FUND);
122
122
  },
123
- [IncomingMessageType.FundWithCryptoCompleted]: () => {
124
- appCompleted(AppIdentifier.FUND_WITH_CRYPTO);
123
+ [IncomingMessageType.FundCompleted]: () => {
124
+ appCompleted(AppIdentifier.FUND);
125
125
  },
126
- [IncomingMessageType.FundWithCryptoFailed]: () => {
127
- appFailed(AppIdentifier.FUND_WITH_CRYPTO);
126
+ [IncomingMessageType.FundFailed]: () => {
127
+ appFailed(AppIdentifier.FUND);
128
128
  },
129
129
  };
130
130
 
@@ -164,7 +164,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
164
164
  [AppIdentifier.FIAT_WITHDRAWALS, false],
165
165
  [AppIdentifier.CRYPTO_BUY, false],
166
166
  [AppIdentifier.CRYPTO_SELL, false],
167
- [AppIdentifier.FUND_WITH_CRYPTO, false],
167
+ [AppIdentifier.FUND, false],
168
168
  ]);
169
169
 
170
170
  /**
@@ -181,7 +181,7 @@ export class ZeroHashSDK implements IZeroHashSDK {
181
181
  fiatWithdrawalsJWT,
182
182
  cryptoBuyJWT,
183
183
  cryptoSellJWT,
184
- fundWithCryptoJWT,
184
+ fundJWT,
185
185
  zeroHashAppsURL,
186
186
  }: IInitializeParameters) {
187
187
  // The || is for backwards compatibility
@@ -231,10 +231,10 @@ export class ZeroHashSDK implements IZeroHashSDK {
231
231
  appIdentifier: AppIdentifier.CRYPTO_SELL,
232
232
  });
233
233
  }
234
- if (fundWithCryptoJWT) {
234
+ if (fundJWT) {
235
235
  this.setJWT({
236
- jwt: fundWithCryptoJWT,
237
- appIdentifier: AppIdentifier.FUND_WITH_CRYPTO,
236
+ jwt: fundJWT,
237
+ appIdentifier: AppIdentifier.FUND,
238
238
  });
239
239
  }
240
240
  }
@@ -0,0 +1,63 @@
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 IFundState {
10
+ jwt: string;
11
+ isAppLoaded: boolean;
12
+ isAppActive: boolean;
13
+ }
14
+
15
+ export interface IFundAction {
16
+ type: string;
17
+ jwt?: string;
18
+ isAppActive?: boolean;
19
+ isAppLoaded?: boolean;
20
+ }
21
+
22
+ const INITIAL_STATE: IFundState = {
23
+ jwt: "",
24
+ isAppActive: false,
25
+ isAppLoaded: false
26
+ }
27
+
28
+ const applySetIsAppActive = (state: IFundState, action: IFundAction) : IFundState => {
29
+ return {
30
+ ...state,
31
+ isAppActive: !!action.isAppActive,
32
+ }
33
+ }
34
+
35
+ const applySetSendJWTToApp = (state: IFundState, action: IFundAction) : IFundState => {
36
+ return {
37
+ ...state,
38
+ isAppLoaded: !!action.isAppLoaded,
39
+ }
40
+ }
41
+
42
+ const applySetJWT = (state: IFundState, action: IFundAction) : IFundState => {
43
+ return {
44
+ ...state,
45
+ jwt: action.jwt as string,
46
+ }
47
+ }
48
+
49
+ const reducerMap: { [actionType: string]: (state: IFundState, action: IFundAction) => IFundState } = {
50
+ [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FUND)}${ACTION_SET_JWT}`]: applySetJWT,
51
+ [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FUND)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
52
+ [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FUND)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
53
+ };
54
+
55
+ const fundReducer = (state = INITIAL_STATE, action: IFundAction) => {
56
+ if (!!action.type && !!reducerMap[action.type]) {
57
+ return reducerMap[action.type](state, action);
58
+ } else {
59
+ return state;
60
+ }
61
+ }
62
+
63
+ export default fundReducer;
@@ -5,7 +5,7 @@ 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";
8
- import fundWithCryptoReducer from "./fund-with-crypto";
8
+ import fundReducer from "./fund";
9
9
 
10
10
  const rootReducer = combineReducers({
11
11
  ["crypto-withdrawals"]: cryptoWithdrawalsReducer,
@@ -17,7 +17,7 @@ const rootReducer = combineReducers({
17
17
  ["csp-crypto-withdrawals"]: cryptoWithdrawalsReducer,
18
18
  ["csp-fiat-withdrawals"]: fiatWithdrawalsReducer,
19
19
  ["csp-crypto-sell"]: cryptoSellReducer,
20
- ["fund-with-crypto"]: fundWithCryptoReducer,
20
+ ["fund"]: fundReducer,
21
21
  });
22
22
 
23
23
  export default rootReducer;
package/src/types.ts CHANGED
@@ -69,11 +69,11 @@ export interface IInitializeParameters {
69
69
  */
70
70
  cryptoSellJWT?: string
71
71
  /**
72
- * fundWithCryptoJWT is the JWT that you received from
72
+ * fundJWT is the JWT that you received from
73
73
  * the ZeroHash HTTP API and have specific permissions to
74
- * perform Fund With Crypto operations.
74
+ * perform Fund operations.
75
75
  */
76
- fundWithCryptoJWT?: string
76
+ fundJWT?: string
77
77
  /**
78
78
  * zeroHashAppsURL is the base URL for all our Apps.
79
79
  * It defaults to https://web-sdk.zerohash.com/ and will
@@ -236,25 +236,25 @@ export enum IncomingMessageType {
236
236
  */
237
237
  CryptoSellFailed = "CRYPTO_SELL_FAILED",
238
238
  /**
239
- * FundWithCryptoAppLoaded is received when the Fund Witch Crypto
239
+ * FundAppLoaded is received when the Fund
240
240
  * app has initialized.
241
241
  */
242
- FundWithCryptoAppLoaded = "FUND_WITH_CRYPTO_APP_LOADED",
242
+ FundAppLoaded = "FUND_APP_LOADED",
243
243
  /**
244
- * FundWithCryptoCloseButtonClicked is received when the close button
245
- * has been clicked in the Fund With Crypto app
244
+ * FundCloseButtonClicked is received when the close button
245
+ * has been clicked in the Fund app
246
246
  */
247
- FundWithCryptoCloseButtonClicked = "FUND_WITH_CRYPTO_CLOSE_BUTTON_CLICKED",
247
+ FundCloseButtonClicked = "FUND_CLOSE_BUTTON_CLICKED",
248
248
  /**
249
- * FundWithCryptoCompleted is received when the
250
- * Fund With Crypto flow has completed successfully.
249
+ * FundCompleted is received when the
250
+ * Fund flow has completed successfully.
251
251
  */
252
- FundWithCryptoCompleted = "FUND_WITH_CRYPTO_COMPLETED",
252
+ FundCompleted = "FUND_COMPLETED",
253
253
  /**
254
- * FundWithCryptoFailed is received when the
255
- * Fund With Crypto flow has failed.
254
+ * FundFailed is received when the
255
+ * Fund flow has failed.
256
256
  */
257
- FundWithCryptoFailed = "FUND_WITH_CRYPTO_FAILED",
257
+ FundFailed = "FUND_FAILED",
258
258
  }
259
259
 
260
260
  /**
@@ -300,7 +300,7 @@ export enum AppIdentifier {
300
300
  CSP_CRYPTO_WITHDRAWALS = "csp-crypto-withdrawals",
301
301
  CSP_FIAT_WITHDRAWALS = "csp-fiat-withdrawals",
302
302
  CSP_CRYPTO_SELL = "csp-crypto-sell",
303
- FUND_WITH_CRYPTO = "fund-with-crypto"
303
+ FUND = "fund"
304
304
  }
305
305
 
306
306
  /**
@@ -318,7 +318,7 @@ export const appIdentifierToActionPrefixMap = new Map(
318
318
  [AppIdentifier.CSP_FIAT_WITHDRAWALS, "FIAT_WITHDRAWALS_"], // CSP apps uses the same events as "regular" flow
319
319
  [AppIdentifier.CSP_CRYPTO_SELL, "CRYPTO_SELL_"],
320
320
  [AppIdentifier.CSP_CRYPTO_SELL, "CRYPTO_SELL_"],
321
- [AppIdentifier.FUND_WITH_CRYPTO, "FUND_WITH_CRYPTO_"],
321
+ [AppIdentifier.FUND, "FUND_"],
322
322
  ])
323
323
 
324
324
  export interface ISetJWTParameters {
@@ -327,8 +327,9 @@ export interface ISetJWTParameters {
327
327
  }
328
328
 
329
329
  export interface Filters {
330
- getAssets: {
331
- deposit_address_creation: string
330
+ getAssets?: {
331
+ deposit_address_creation?: string
332
+ stablecoin?: boolean
332
333
  }
333
334
  }
334
335
 
@@ -340,10 +341,5 @@ export interface IOpenModalParameters {
340
341
 
341
342
  export interface ISetFiltersParameters {
342
343
  appIdentifier: AppIdentifier;
343
- filters: {
344
- getAssets: {
345
- deposit_address_creation?: string;
346
- stablecoin?: boolean;
347
- }
348
- }
344
+ filters?: Filters
349
345
  }
@@ -1,13 +0,0 @@
1
- export interface IFundWithCryptoState {
2
- jwt: string;
3
- isAppLoaded: boolean;
4
- isAppActive: boolean;
5
- }
6
- export interface IFundWithCryptoAction {
7
- type: string;
8
- jwt?: string;
9
- isAppActive?: boolean;
10
- isAppLoaded?: boolean;
11
- }
12
- declare const fundWithCryptoReducer: (state: IFundWithCryptoState | undefined, action: IFundWithCryptoAction) => IFundWithCryptoState;
13
- export default fundWithCryptoReducer;
@@ -1,63 +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 IFundWithCryptoState {
10
- jwt: string;
11
- isAppLoaded: boolean;
12
- isAppActive: boolean;
13
- }
14
-
15
- export interface IFundWithCryptoAction {
16
- type: string;
17
- jwt?: string;
18
- isAppActive?: boolean;
19
- isAppLoaded?: boolean;
20
- }
21
-
22
- const INITIAL_STATE: IFundWithCryptoState = {
23
- jwt: "",
24
- isAppActive: false,
25
- isAppLoaded: false
26
- }
27
-
28
- const applySetIsAppActive = (state: IFundWithCryptoState, action: IFundWithCryptoAction) : IFundWithCryptoState => {
29
- return {
30
- ...state,
31
- isAppActive: !!action.isAppActive,
32
- }
33
- }
34
-
35
- const applySetSendJWTToApp = (state: IFundWithCryptoState, action: IFundWithCryptoAction) : IFundWithCryptoState => {
36
- return {
37
- ...state,
38
- isAppLoaded: !!action.isAppLoaded,
39
- }
40
- }
41
-
42
- const applySetJWT = (state: IFundWithCryptoState, action: IFundWithCryptoAction) : IFundWithCryptoState => {
43
- return {
44
- ...state,
45
- jwt: action.jwt as string,
46
- }
47
- }
48
-
49
- const reducerMap: { [actionType: string]: (state: IFundWithCryptoState, action: IFundWithCryptoAction) => IFundWithCryptoState } = {
50
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FUND_WITH_CRYPTO)}${ACTION_SET_JWT}`]: applySetJWT,
51
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FUND_WITH_CRYPTO)}${ACTION_SET_MODAL_STATE}`]: applySetIsAppActive,
52
- [`${appIdentifierToActionPrefixMap.get(AppIdentifier.FUND_WITH_CRYPTO)}${ACTION_APP_LOADED}`]: applySetSendJWTToApp,
53
- };
54
-
55
- const fundWithCryptoReducer = (state = INITIAL_STATE, action: IFundWithCryptoAction) => {
56
- if (!!action.type && !!reducerMap[action.type]) {
57
- return reducerMap[action.type](state, action);
58
- } else {
59
- return state;
60
- }
61
- }
62
-
63
- export default fundWithCryptoReducer;