Skip to content

Commit

Permalink
fix(ts): annoying ts bugs fixed by dylan
Browse files Browse the repository at this point in the history
  • Loading branch information
Sean Han committed Nov 6, 2021
1 parent 183b5eb commit 812cd6d
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,11 @@ export default ({ coreSagas }) => {
const walletConnectSagas = sagas({ coreSagas })

return function* walletConnectSaga() {
// @ts-ignore
yield takeLatest(A.handleSessionCallRequest.type, walletConnectSagas.handleSessionCallRequest)
// @ts-ignore
yield takeLatest(A.handleSessionDisconnect.type, walletConnectSagas.handleSessionDisconnect)
// @ts-ignore
yield takeLatest(A.handleSessionRequest.type, walletConnectSagas.handleSessionRequest)
// @ts-ignore
yield takeLatest(A.initWalletConnect.type, walletConnectSagas.initWalletConnect)
// @ts-ignore
yield takeLatest(A.respondToSessionRequest.type, walletConnectSagas.respondToSessionRequest)
// @ts-ignore
yield takeLatest(A.respondToTxSendRequest.type, walletConnectSagas.respondToTxSendRequest)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ export default ({ coreSagas }) => {
let rpc

// session call request from dapp
const handleSessionCallRequest = function* ({ payload }) {
const handleSessionCallRequest = function* ({
payload
}: ReturnType<typeof A.handleSessionCallRequest>) {
switch (true) {
case payload.data.method === RequestMethodType.ETH_SEND_TX:
return yield put(
Expand All @@ -27,7 +29,9 @@ export default ({ coreSagas }) => {
}

// session failed, ended by dapp or rejected by user
const handleSessionDisconnect = function* ({ payload }) {
const handleSessionDisconnect = function* ({
payload
}: ReturnType<typeof A.handleSessionDisconnect>) {
// connection has ended
yield put(
A.setStep({
Expand All @@ -39,7 +43,7 @@ export default ({ coreSagas }) => {
}

// session request from dapp
const handleSessionRequest = function* ({ payload }) {
const handleSessionRequest = function* ({ payload }: ReturnType<typeof A.handleSessionRequest>) {
// show user session accept/reject screen
yield put(
A.setStep({
Expand Down Expand Up @@ -107,15 +111,17 @@ export default ({ coreSagas }) => {
}
}

const initWalletConnect = function* ({ payload }) {
const initWalletConnect = function* ({ payload }: ReturnType<typeof A.initWalletConnect>) {
const rpcTask = yield fork(startRpcConnection, { uri: payload })

// listen for user requested disconnect
yield take(A.handleSessionDisconnect.type)
yield cancel(rpcTask)
}

const respondToSessionRequest = function* ({ payload }) {
const respondToSessionRequest = function* ({
payload
}: ReturnType<typeof A.respondToSessionRequest>) {
try {
yield put(A.setStep({ name: WalletConnectStep.LOADING }))

Expand Down Expand Up @@ -146,7 +152,9 @@ export default ({ coreSagas }) => {
}
}

const respondToTxSendRequest = function* ({ payload }) {
const respondToTxSendRequest = function* ({
payload
}: ReturnType<typeof A.respondToTxSendRequest>) {
try {
yield put(A.setStep({ name: WalletConnectStep.LOADING }))

Expand All @@ -156,7 +164,7 @@ export default ({ coreSagas }) => {
// user rejected transaction
rpc.rejectRequest({
error: { message: 'Transaction rejected by user.' },
id: payload.data.requestDetails.id
id: payload.requestDetails.id
})

yield put(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ const walletConnectSlice = createSlice({
name: 'walletConnect',
reducers: {
handleSessionCallRequest: (state, action: PayloadAction<T.RequestMessagePayload>) => {},
// handleSessionCallRequest: {
// prepare: ({ data, error }: { data: any, error: any }) => ({ payload: { data, error } }),
// reducer: () => {}
// },
handleSessionDisconnect: (state, action) => {},
handleSessionRequest: (state, action) => {},
initWalletConnect: (state, action: PayloadAction<string>) => {},
Expand Down

0 comments on commit 812cd6d

Please sign in to comment.