-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #927 from singnet/update-payment-system
Update payment system
- Loading branch information
Showing
89 changed files
with
961 additions
and
958 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
import { isEmpty } from "lodash"; | ||
import { initSdk } from "../../utility/sdk"; | ||
|
||
export const SET_SDK = "SET_SDK"; | ||
|
||
export const updateSdkInstance = (sdkInstance) => (dispatch) => { | ||
dispatch({ type: SET_SDK, payload: { ...sdkInstance } }); | ||
}; | ||
|
||
export const initializingSdk = (ethereumWalletAddress) => async (dispatch) => { | ||
try { | ||
const sdk = await initSdk(ethereumWalletAddress); | ||
dispatch(updateSdkInstance(sdk)); | ||
return sdk; | ||
} catch (error) { | ||
throw new Error(error); | ||
} | ||
}; | ||
|
||
export const getSdk = () => async (dispatch, getState) => { | ||
let sdk = getState().sdkReducer.sdk; | ||
if (!isEmpty(sdk)) { | ||
return sdk; | ||
} | ||
sdk = await dispatch(initializingSdk()); | ||
return sdk; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { sdkActions } from "../actionCreators"; | ||
|
||
const InitialState = { | ||
sdk: {}, | ||
}; | ||
|
||
const sdkReducer = (state = InitialState, action) => { | ||
switch (action.type) { | ||
case sdkActions.SET_SDK: { | ||
return { ...state, ...action.payload }; | ||
} | ||
default: { | ||
return state; | ||
} | ||
} | ||
}; | ||
|
||
export default sdkReducer; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.