diff --git a/src/core/currency/wallet/currency-wallet-cleaners.ts b/src/core/currency/wallet/currency-wallet-cleaners.ts index 95a6f87ad..bbc90a79a 100644 --- a/src/core/currency/wallet/currency-wallet-cleaners.ts +++ b/src/core/currency/wallet/currency-wallet-cleaners.ts @@ -15,6 +15,7 @@ import { EdgeAssetAmount, EdgeFiatAmount, EdgeMetadata, + EdgeSwapInfo, EdgeTxAction, EdgeTxActionFiat, EdgeTxActionFiatType, @@ -234,12 +235,25 @@ export const asEdgeTxActionSwapType: Cleaner = asValue( 'swapOrderCancel' ) +export const asEdgeSwapInfo = asObject({ + pluginId: asString, + displayName: asString, + isDex: asOptional(asBoolean), + orderUri: asOptional(asString), // The orderId would be appended to this + supportEmail: asString +}) + export const asEdgeTxActionSwap = asObject({ + swapInfo: asEdgeSwapInfo, type: asEdgeTxActionSwapType, orderId: asOptional(asString), + orderUri: asOptional(asString), + isEstimate: asOptional(asBoolean), canBePartial: asOptional(asBoolean), sourceAsset: asEdgeAssetAmount, - destAsset: asEdgeAssetAmount + destAsset: asEdgeAssetAmount, + payoutWalletId: asString, + payoutAddress: asString }) export const asEdgeTxActionStakeType: Cleaner = asValue( diff --git a/src/types/types.ts b/src/types/types.ts index dc3843df8..80a0f673c 100644 --- a/src/types/types.ts +++ b/src/types/types.ts @@ -268,11 +268,17 @@ export type EdgeTxActionSwapType = | 'swapOrderCancel' export interface EdgeTxActionSwap { + swapInfo: EdgeSwapInfo + type: EdgeTxActionSwapType orderId?: string + orderUri?: string + isEstimate?: boolean canBePartial?: boolean sourceAsset: EdgeAssetAmount destAsset: EdgeAssetAmount + payoutAddress: string + payoutWalletId: string } export type EdgeTxActionStakeType = @@ -1196,6 +1202,7 @@ export interface EdgeSwapInfo { readonly displayName: string readonly isDex?: boolean + /** @deprecated Use orderUri in EdgeTxAction */ readonly orderUri?: string // The orderId would be appended to this readonly supportEmail: string } @@ -1232,6 +1239,7 @@ export interface EdgeSwapResult { export interface EdgeSwapApproveOptions { metadata?: EdgeMetadata + savedAction?: EdgeTxAction } /** diff --git a/test/core/currency/wallet/currency-wallet.test.ts b/test/core/currency/wallet/currency-wallet.test.ts index 2833a3ee7..8b764b822 100644 --- a/test/core/currency/wallet/currency-wallet.test.ts +++ b/test/core/currency/wallet/currency-wallet.test.ts @@ -437,6 +437,13 @@ describe('currency wallets', function () { // Perform the spend: const metadata: EdgeMetadata = { name: 'me' } const savedAction: EdgeTxAction = { + swapInfo: { + pluginId: 'myplugin', + displayName: 'My Plugin', + supportEmail: 'support@myemail.com' + }, + payoutAddress: '0xpayoutaddress', + payoutWalletId: '0xwalletid', type: 'swap', orderId: 'myorderid', canBePartial: false, @@ -504,6 +511,13 @@ describe('currency wallets', function () { } ]) expect(txs[0].savedAction).deep.equals({ + swapInfo: { + pluginId: 'myplugin', + displayName: 'My Plugin', + supportEmail: 'support@myemail.com' + }, + payoutAddress: '0xpayoutaddress', + payoutWalletId: '0xwalletid', type: 'swap', orderId: 'myorderid', canBePartial: false, @@ -532,6 +546,13 @@ describe('currency wallets', function () { amountFiat: 0.75 } const savedAction: EdgeTxAction = { + swapInfo: { + pluginId: 'myplugin', + displayName: 'My Plugin', + supportEmail: 'support@myemail.com' + }, + payoutAddress: '0xpayoutaddress', + payoutWalletId: '0xwalletid', type: 'swap', orderId: 'myorderid', canBePartial: false, @@ -559,6 +580,13 @@ describe('currency wallets', function () { ...metadata }) expect(txs[0].savedAction).deep.equals({ + swapInfo: { + pluginId: 'myplugin', + displayName: 'My Plugin', + supportEmail: 'support@myemail.com' + }, + payoutAddress: '0xpayoutaddress', + payoutWalletId: '0xwalletid', type: 'swap', orderId: 'myorderid', canBePartial: false,