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.
This commit is contained in:
infiinte-persistence 2021-04-07 14:27:57 +08:00 committed by Sean Yesmunt
parent 8335c9d2de
commit 5f3a40a420
4 changed files with 35 additions and 35 deletions

8
dist/bundle.es.js vendored
View file

@ -1752,13 +1752,13 @@ function extractUserState(rawObj) {
following, following,
tags, tags,
blocked, blocked,
coin_swaps, coin_swap_codes,
settings, settings,
app_welcome_version, app_welcome_version,
sharing_3P sharing_3P
} = rawObj.value; } = 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 {}; return {};
@ -1771,7 +1771,7 @@ function doPopulateSharedUserState(sharedSettings) {
following, following,
tags, tags,
blocked, blocked,
coin_swaps, coin_swap_codes,
settings, settings,
app_welcome_version, app_welcome_version,
sharing_3P sharing_3P
@ -1783,7 +1783,7 @@ function doPopulateSharedUserState(sharedSettings) {
following, following,
tags, tags,
blocked, blocked,
coinSwaps: coin_swaps, coinSwapCodes: coin_swap_codes,
settings, settings,
welcomeVersion: app_welcome_version, welcomeVersion: app_welcome_version,
allowAnalytics: sharing_3P allowAnalytics: sharing_3P

View file

@ -1,28 +1,28 @@
declare type CoinSwapInfo = { declare type CoinSwapInfo = {
coin: string, chargeCode: string,
sendAddress: string, coins: Array<string>,
sendAmount: number, sendAddresses: { [string]: string},
sendAmounts: { [string]: number },
lbcAmount: number, lbcAmount: number,
status?: {
status: string,
receipt_txid: string,
lbc_txid: string,
},
} }
declare type CoinSwapState = { declare type CoinSwapState = {
coinSwaps: Array<CoinSwapInfo> coinSwaps: Array<CoinSwapInfo>,
}; };
declare type CoinSwapAction = { declare type CoinSwapAddAction = {
type: string, type: string,
data: { data: CoinSwapInfo,
coin: string,
sendAddress: string,
sendAmount: number,
lbcAmount: number,
},
}; };
declare type CoinSwapRemoveAction = { declare type CoinSwapRemoveAction = {
type: string, type: string,
data: { data: {
sendAddress: string, chargeCode: string,
}, },
}; };

View file

@ -1,28 +1,28 @@
declare type CoinSwapInfo = { declare type CoinSwapInfo = {
coin: string, chargeCode: string,
sendAddress: string, coins: Array<string>,
sendAmount: number, sendAddresses: { [string]: string},
sendAmounts: { [string]: number },
lbcAmount: number, lbcAmount: number,
status?: {
status: string,
receipt_txid: string,
lbc_txid: string,
},
} }
declare type CoinSwapState = { declare type CoinSwapState = {
coinSwaps: Array<CoinSwapInfo> coinSwaps: Array<CoinSwapInfo>,
}; };
declare type CoinSwapAction = { declare type CoinSwapAddAction = {
type: string, type: string,
data: { data: CoinSwapInfo,
coin: string,
sendAddress: string,
sendAmount: number,
lbcAmount: number,
},
}; };
declare type CoinSwapRemoveAction = { declare type CoinSwapRemoveAction = {
type: string, type: string,
data: { data: {
sendAddress: string, chargeCode: string,
}, },
}; };

View file

@ -9,7 +9,7 @@ type SharedData = {
following?: Array<{ uri: string, notificationsDisabled: boolean }>, following?: Array<{ uri: string, notificationsDisabled: boolean }>,
tags?: Array<string>, tags?: Array<string>,
blocked?: Array<string>, blocked?: Array<string>,
coin_swaps?: Array<CoinSwapInfo>, coin_swap_codes?: Array<string>,
settings?: any, settings?: any,
app_welcome_version?: number, app_welcome_version?: number,
sharing_3P?: boolean, sharing_3P?: boolean,
@ -23,7 +23,7 @@ function extractUserState(rawObj: SharedData) {
following, following,
tags, tags,
blocked, blocked,
coin_swaps, coin_swap_codes,
settings, settings,
app_welcome_version, app_welcome_version,
sharing_3P, sharing_3P,
@ -34,7 +34,7 @@ function extractUserState(rawObj: SharedData) {
...(following ? { following } : {}), ...(following ? { following } : {}),
...(tags ? { tags } : {}), ...(tags ? { tags } : {}),
...(blocked ? { blocked } : {}), ...(blocked ? { blocked } : {}),
...(coin_swaps ? { coin_swaps } : {}), ...(coin_swap_codes ? { coin_swap_codes } : {}),
...(settings ? { settings } : {}), ...(settings ? { settings } : {}),
...(app_welcome_version ? { app_welcome_version } : {}), ...(app_welcome_version ? { app_welcome_version } : {}),
...(sharing_3P ? { sharing_3P } : {}), ...(sharing_3P ? { sharing_3P } : {}),
@ -51,7 +51,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
following, following,
tags, tags,
blocked, blocked,
coin_swaps, coin_swap_codes,
settings, settings,
app_welcome_version, app_welcome_version,
sharing_3P, sharing_3P,
@ -63,7 +63,7 @@ export function doPopulateSharedUserState(sharedSettings: any) {
following, following,
tags, tags,
blocked, blocked,
coinSwaps: coin_swaps, coinSwapCodes: coin_swap_codes,
settings, settings,
welcomeVersion: app_welcome_version, welcomeVersion: app_welcome_version,
allowAnalytics: sharing_3P, allowAnalytics: sharing_3P,