From 08aa78ae24370172a0cb7492b1443cdcc9510798 Mon Sep 17 00:00:00 2001 From: Fernando Zavalia <24811313+fzavalia@users.noreply.github.com> Date: Tue, 26 Mar 2024 14:22:26 -0300 Subject: [PATCH] fix: Send target correctly to server (#601) --- src/lib/marketplaceApi.ts | 4 ++-- src/modules/gateway/sagas.ts | 7 ++++--- src/modules/gateway/types.ts | 2 ++ 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/src/lib/marketplaceApi.ts b/src/lib/marketplaceApi.ts index c32b3ba3..2ee01522 100644 --- a/src/lib/marketplaceApi.ts +++ b/src/lib/marketplaceApi.ts @@ -1,10 +1,10 @@ import { AuthIdentity } from 'decentraland-crypto-fetch' -import { WertMessage } from '../modules/gateway/types' +import { WertMessageWithTarget } from '../modules/gateway/types' import { BaseClient } from './BaseClient' export class MarketplaceAPI extends BaseClient { async signWertMessage( - message: WertMessage, + message: WertMessageWithTarget, identity: AuthIdentity ): Promise { try { diff --git a/src/modules/gateway/sagas.ts b/src/modules/gateway/sagas.ts index 5e79de8e..60fe790c 100644 --- a/src/modules/gateway/sagas.ts +++ b/src/modules/gateway/sagas.ts @@ -104,7 +104,8 @@ export function createGatewaySaga(config: GatewaySagasConfig) { function* handleOpenFiatGatewayWidget( action: OpenFiatGatewayWidgetRequestAction ) { - const { data, gateway, listeners } = action.payload + const { gateway, listeners } = action.payload + const { target, ...data } = action.payload.data try { switch (gateway) { case FiatGateway.WERT: @@ -140,7 +141,7 @@ export function createGatewaySaga(config: GatewaySagasConfig) { address: wallet.address, commodity, commodity_amount, - network: network ? network : isDev ? 'sepolia' : 'ethereum', // will be wallet.network + network: network ? network : isDev ? 'sepolia' : 'ethereum', sc_address, sc_input_data } @@ -149,7 +150,7 @@ export function createGatewaySaga(config: GatewaySagasConfig) { const signature: string = yield call( [marketplaceAPI, 'signWertMessage'], - dataToSign, + { ...dataToSign, target }, identity ) diff --git a/src/modules/gateway/types.ts b/src/modules/gateway/types.ts index 038d6072..b9f8fb44 100644 --- a/src/modules/gateway/types.ts +++ b/src/modules/gateway/types.ts @@ -37,6 +37,8 @@ export type WertMessage = { sc_input_data: string } +export type WertMessageWithTarget = WertMessage & { target?: WertTarget } + export type WertConfig = { url: string marketplaceServerURL: string