From 8335c9d2de40590a3eee59b4bf975c7c8c4a05b6 Mon Sep 17 00:00:00 2001 From: infiinte-persistence Date: Sun, 4 Apr 2021 13:58:12 +0800 Subject: [PATCH] Save CoinSwapInfo instead of just the swap address. User should be able to retrieve the expected send/receive amount, otherwise they might be sending insufficient amounts. This change also includes the coin type, as we might be supporting other coins beyond BTC. --- dist/bundle.es.js | 8 ++++---- dist/flow-typed/CoinSwap.js | 28 ++++++++++++++++++++++++++++ flow-typed/CoinSwap.js | 28 ++++++++++++++++++++++++++++ src/redux/actions/sync.js | 10 +++++----- 4 files changed, 65 insertions(+), 9 deletions(-) create mode 100644 dist/flow-typed/CoinSwap.js create mode 100644 flow-typed/CoinSwap.js diff --git a/dist/bundle.es.js b/dist/bundle.es.js index 1f3e06b..6767b7d 100644 --- a/dist/bundle.es.js +++ b/dist/bundle.es.js @@ -1752,13 +1752,13 @@ function extractUserState(rawObj) { following, tags, blocked, - btc_addresses, + coin_swaps, settings, app_welcome_version, sharing_3P } = rawObj.value; - return _extends$1({}, subscriptions ? { subscriptions } : {}, following ? { following } : {}, tags ? { tags } : {}, blocked ? { blocked } : {}, btc_addresses ? { btc_addresses } : {}, settings ? { settings } : {}, app_welcome_version ? { app_welcome_version } : {}, sharing_3P ? { sharing_3P } : {}); + 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 {}; @@ -1771,7 +1771,7 @@ function doPopulateSharedUserState(sharedSettings) { following, tags, blocked, - btc_addresses, + coin_swaps, settings, app_welcome_version, sharing_3P @@ -1783,7 +1783,7 @@ function doPopulateSharedUserState(sharedSettings) { following, tags, blocked, - btcAddresses: btc_addresses, + coinSwaps: coin_swaps, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P diff --git a/dist/flow-typed/CoinSwap.js b/dist/flow-typed/CoinSwap.js new file mode 100644 index 0000000..59e796f --- /dev/null +++ b/dist/flow-typed/CoinSwap.js @@ -0,0 +1,28 @@ +declare type CoinSwapInfo = { + coin: string, + sendAddress: string, + sendAmount: number, + lbcAmount: number, +} + +declare type CoinSwapState = { + coinSwaps: Array +}; + +declare type CoinSwapAction = { + type: string, + data: { + coin: string, + sendAddress: string, + sendAmount: number, + lbcAmount: number, + + }, +}; + +declare type CoinSwapRemoveAction = { + type: string, + data: { + sendAddress: string, + }, +}; diff --git a/flow-typed/CoinSwap.js b/flow-typed/CoinSwap.js new file mode 100644 index 0000000..59e796f --- /dev/null +++ b/flow-typed/CoinSwap.js @@ -0,0 +1,28 @@ +declare type CoinSwapInfo = { + coin: string, + sendAddress: string, + sendAmount: number, + lbcAmount: number, +} + +declare type CoinSwapState = { + coinSwaps: Array +}; + +declare type CoinSwapAction = { + type: string, + data: { + coin: string, + sendAddress: string, + sendAmount: number, + lbcAmount: number, + + }, +}; + +declare type CoinSwapRemoveAction = { + type: string, + data: { + sendAddress: string, + }, +}; diff --git a/src/redux/actions/sync.js b/src/redux/actions/sync.js index 97d5ba6..ff6128b 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, - btc_addresses?: Array, + coin_swaps?: Array, settings?: any, app_welcome_version?: number, sharing_3P?: boolean, @@ -23,7 +23,7 @@ function extractUserState(rawObj: SharedData) { following, tags, blocked, - btc_addresses, + coin_swaps, settings, app_welcome_version, sharing_3P, @@ -34,7 +34,7 @@ function extractUserState(rawObj: SharedData) { ...(following ? { following } : {}), ...(tags ? { tags } : {}), ...(blocked ? { blocked } : {}), - ...(btc_addresses ? { btc_addresses } : {}), + ...(coin_swaps ? { coin_swaps } : {}), ...(settings ? { settings } : {}), ...(app_welcome_version ? { app_welcome_version } : {}), ...(sharing_3P ? { sharing_3P } : {}), @@ -51,7 +51,7 @@ export function doPopulateSharedUserState(sharedSettings: any) { following, tags, blocked, - btc_addresses, + coin_swaps, settings, app_welcome_version, sharing_3P, @@ -63,7 +63,7 @@ export function doPopulateSharedUserState(sharedSettings: any) { following, tags, blocked, - btcAddresses: btc_addresses, + coinSwaps: coin_swaps, settings, welcomeVersion: app_welcome_version, allowAnalytics: sharing_3P,