From 5f3a40a4203cca83c48138fa975dac8aaea42483 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Wed, 7 Apr 2021 14:27:57 +0800 Subject: [PATCH] CoinSwap: websocket + multi-coin - For the active swap, switch from polling to websocket. The returned data is now the Charge data from the commerce, so some parsing will be required. - Only save the 'chargeCode' to the wallet. The other data can be repopulated from this. --- dist/bundle.es.js | 8 ++++---- dist/flow-typed/CoinSwap.js | 26 +++++++++++++------------- flow-typed/CoinSwap.js | 26 +++++++++++++------------- src/redux/actions/sync.js | 10 +++++----- 4 files changed, 35 insertions(+), 35 deletions(-) diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 6767b7d..9474043 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1752,13 +1752,13 @@ function extractUserState(rawObj) { following, tags, blocked, - coin_swaps, + coin_swap_codes, settings, app_welcome_version, sharing_3P } = rawObj.value; - return _extends$1({}, subscriptions ? { subscriptions } : {}, following ? { following } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, coin_swaps ? { coin_swaps } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {}); + return _extends$1({}, subscriptions ? { subscriptions } : {}, following ? { following } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, coin_swap_codes ? { coin_swap_codes } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {}); } return {}; @@ -1771,7 +1771,7 @@ function doPopulateSharedUserState(sharedSettings) { following, tags, blocked, - coin_swaps, + coin_swap_codes, settings, app_welcome_version, sharing_3P @@ -1783,7 +1783,7 @@ function doPopulateSharedUserState(sharedSettings) { following, tags, blocked, - coinSwaps: coin_swaps, + coinSwapCodes: coin_swap_codes, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P diff --git a/dist/flow-typed/CoinSwap.js b/dist/flow-typed/CoinSwap.js index 59e796f..6695616 100644 --- a/dist/flow-typed/CoinSwap.js +++ b/dist/flow-typed/CoinSwap.js @@ -1,28 +1,28 @@ declare type CoinSwapInfo = { - coin: string, - sendAddress: string, - sendAmount: number, + chargeCode: string, + coins: Array, + sendAddresses: { [string]: string}, + sendAmounts: { [string]: number }, lbcAmount: number, + status?: { + status: string, + receipt_txid: string, + lbc_txid: string, + }, } declare type CoinSwapState = { - coinSwaps: Array + coinSwaps: Array, }; -declare type CoinSwapAction = { +declare type CoinSwapAddAction = { type: string, - data: { - coin: string, - sendAddress: string, - sendAmount: number, - lbcAmount: number, - - }, + data: CoinSwapInfo, }; declare type CoinSwapRemoveAction = { type: string, data: { - sendAddress: string, + chargeCode: string, }, }; diff --git a/flow-typed/CoinSwap.js b/flow-typed/CoinSwap.js index 59e796f..6695616 100644 --- a/flow-typed/CoinSwap.js +++ b/flow-typed/CoinSwap.js @@ -1,28 +1,28 @@ declare type CoinSwapInfo = { - coin: string, - sendAddress: string, - sendAmount: number, + chargeCode: string, + coins: Array, + sendAddresses: { [string]: string}, + sendAmounts: { [string]: number }, lbcAmount: number, + status?: { + status: string, + receipt_txid: string, + lbc_txid: string, + }, } declare type CoinSwapState = { - coinSwaps: Array + coinSwaps: Array, }; -declare type CoinSwapAction = { +declare type CoinSwapAddAction = { type: string, - data: { - coin: string, - sendAddress: string, - sendAmount: number, - lbcAmount: number, - - }, + data: CoinSwapInfo, }; declare type CoinSwapRemoveAction = { type: string, data: { - sendAddress: string, + chargeCode: string, }, }; diff --git a/src/redux/actions/sync.js b/src/redux/actions/sync.js index ff6128b..14c7f00 100644 --- a/src/redux/actions/sync.js +++ b/src/redux/actions/sync.js @@ -9,7 +9,7 @@ type SharedData = { following?: Array<{ uri: string, notificationsDisabled: boolean }>, tags?: Array, blocked?: Array, - coin_swaps?: Array, + coin_swap_codes?: Array, settings?: any, app_welcome_version?: number, sharing_3P?: boolean, @@ -23,7 +23,7 @@ function extractUserState(rawObj: SharedData) { following, tags, blocked, - coin_swaps, + coin_swap_codes, settings, app_welcome_version, sharing_3P, @@ -34,7 +34,7 @@ function extractUserState(rawObj: SharedData) { ...(following ? { following } : {}), ...(tags ? { tags } : {}), ...(blocked ? { blocked } : {}), - ...(coin_swaps ? { coin_swaps } : {}), + ...(coin_swap_codes ? { coin_swap_codes } : {}), ...(settings ? { settings } : {}), ...(app_welcome_version ? { app_welcome_version } : {}), ...(sharing_3P ? { sharing_3P } : {}), @@ -51,7 +51,7 @@ export function doPopulateSharedUserState(sharedSettings: any) { following, tags, blocked, - coin_swaps, + coin_swap_codes, settings, app_welcome_version, sharing_3P, @@ -63,7 +63,7 @@ export function doPopulateSharedUserState(sharedSettings: any) { following, tags, blocked, - coinSwaps: coin_swaps, + coinSwapCodes: coin_swap_codes, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P,