diff --git a/signer-service/src/api/controllers/googleSpreadSheet.controller.js b/signer-service/src/api/controllers/googleSpreadSheet.controller.js index 2c005bd2..f851ecd4 100644 --- a/signer-service/src/api/controllers/googleSpreadSheet.controller.js +++ b/signer-service/src/api/controllers/googleSpreadSheet.controller.js @@ -3,10 +3,14 @@ require('dotenv').config(); const { spreadsheet } = require('../../config/vars'); const { initGoogleSpreadsheet, getOrCreateSheet, appendData } = require('../services/spreadsheet.service'); -exports.storeDataInGoogleSpreadsheet = async (req, res, spreadsheetId, sheetHeaderValues) => { +exports.storeDataInGoogleSpreadsheet = async (req, res, spreadsheetId) => { try { // We expect the data to be an object that matches our schema const data = req.body; + // Identify header values based on substrate vs evm offramp. + const sheetHeaderValues = req.body.offramperAddress.includes('0x') + ? DUMP_SHEET_HEADER_VALUES_EVM + : DUMP_SHEET_HEADER_VALUES_ASSETHUB; // Try dumping transactions to spreadsheet const sheet = await initGoogleSpreadsheet(spreadsheetId, spreadsheet.googleCredentials).then((doc) => diff --git a/signer-service/src/api/controllers/storage.controller.js b/signer-service/src/api/controllers/storage.controller.js index ae8338b7..17aac66f 100644 --- a/signer-service/src/api/controllers/storage.controller.js +++ b/signer-service/src/api/controllers/storage.controller.js @@ -1,10 +1,10 @@ const { spreadsheet } = require('../../config/vars'); const { storeDataInGoogleSpreadsheet } = require('./googleSpreadSheet.controller'); -// These are the headers for the Google Spreadsheet -const DUMP_SHEET_HEADER_VALUES = [ +// These are the headers for the Google Spreadsheet for polygon offramp +const DUMP_SHEET_HEADER_VALUES_EVM = [ 'timestamp', - 'polygonAddress', + 'offramperAddress', 'stellarEphemeralPublicKey', 'pendulumEphemeralPublicKey', 'nablaApprovalTx', @@ -20,7 +20,22 @@ const DUMP_SHEET_HEADER_VALUES = [ 'squidRouterReceiverHash', ]; -exports.DUMP_SHEET_HEADER_VALUES = DUMP_SHEET_HEADER_VALUES; +const DUMP_SHEET_HEADER_VALUES_ASSETHUB = [ + 'timestamp', + 'offramperAddress', + 'stellarEphemeralPublicKey', + 'pendulumEphemeralPublicKey', + 'nablaApprovalTx', + 'nablaSwapTx', + 'spacewalkRedeemTx', + 'stellarOfframpTx', + 'stellarCleanupTx', + 'inputAmount', + 'inputTokenType', + 'outputAmount', + 'outputTokenType', +]; +exports.DUMP_SHEET_HEADER_VALUES_ASSETHUB = DUMP_SHEET_HEADER_VALUES_ASSETHUB; +exports.DUMP_SHEET_HEADER_VALUES_EVM = DUMP_SHEET_HEADER_VALUES_EVM; -exports.storeData = async (req, res) => - storeDataInGoogleSpreadsheet(req, res, spreadsheet.storageSheetId, DUMP_SHEET_HEADER_VALUES); +exports.storeData = async (req, res) => storeDataInGoogleSpreadsheet(req, res, spreadsheet.storageSheetId); diff --git a/src/hooks/offramp/useSEP24/useAnchorWindowHandler.ts b/src/hooks/offramp/useSEP24/useAnchorWindowHandler.ts index f8c28bf4..600256ad 100644 --- a/src/hooks/offramp/useSEP24/useAnchorWindowHandler.ts +++ b/src/hooks/offramp/useSEP24/useAnchorWindowHandler.ts @@ -11,6 +11,7 @@ import { showToast, ToastMessage } from '../../../helpers/notifications'; import { UseSEP24StateReturn } from './useSEP24State'; import { useTrackSEP24Events } from './useTrackSEP24Events'; +import { useVortexAccount } from '../../useVortexAccount'; const handleAmountMismatch = (setOfframpingStarted: (started: boolean) => void): void => { setOfframpingStarted(false); @@ -25,6 +26,7 @@ const handleError = (error: unknown, setOfframpingStarted: (started: boolean) => export const useAnchorWindowHandler = (sep24State: UseSEP24StateReturn, cleanupFn: () => void) => { const { trackKYCStarted, trackKYCCompleted } = useTrackSEP24Events(); const { firstSep24Response, anchorSessionParams, executionInput } = sep24State; + const { address } = useVortexAccount(); return useCallback( async ( @@ -58,6 +60,7 @@ export const useAnchorWindowHandler = (sep24State: UseSEP24StateReturn, cleanupF sepResult: secondSep24Response, network: selectedNetwork, pendulumNode, + offramperAddress: address!, }); trackKYCCompleted(initialState, selectedNetwork); diff --git a/src/services/offrampingFlow.ts b/src/services/offrampingFlow.ts index 54f281f6..c9f79721 100644 --- a/src/services/offrampingFlow.ts +++ b/src/services/offrampingFlow.ts @@ -83,6 +83,7 @@ export interface InitiateStateArguments { sepResult: SepResult; network: Networks; pendulumNode: { ss58Format: number; api: ApiPromise; decimals: number }; + offramperAddress: string; } export interface OfframpingState { @@ -118,6 +119,7 @@ export interface OfframpingState { nablaSwapTransaction: string; }; network: Networks; + offramperAddress: string; } export type StateTransitionFunction = ( @@ -172,6 +174,7 @@ export async function constructInitialState({ sepResult, network, pendulumNode, + offramperAddress, }: InitiateStateArguments) { const { seed: pendulumEphemeralSeed, address: pendulumEphemeralAddress } = await createPendulumEphemeralSeed( pendulumNode, @@ -216,6 +219,7 @@ export async function constructInitialState({ sepResult, network, pendulumEphemeralAddress, + offramperAddress, }; storageService.set(OFFRAMPING_STATE_LOCAL_STORAGE_KEY, initialState); diff --git a/src/services/phases/signedTransactions.ts b/src/services/phases/signedTransactions.ts index 4bfd21da..38f1e441 100644 --- a/src/services/phases/signedTransactions.ts +++ b/src/services/phases/signedTransactions.ts @@ -69,15 +69,11 @@ export async function prepareTransactions(state: OfframpingState, context: Execu const pendulumEphemeralKeypair = keyring.addFromUri(pendulumEphemeralSeed); const pendulumEphemeralPublicKey = pendulumEphemeralKeypair.address; - // Get the Polygon account connected by the user - const polygonAccount = getAccount(context.wagmiConfig); - const polygonAddress = polygonAccount.address; - // Try to store the data in the backend try { const data = { timestamp: new Date().toISOString(), - polygonAddress: polygonAddress || '', + offramperAddress: state.offramperAddress, stellarEphemeralPublicKey, pendulumEphemeralPublicKey, nablaApprovalTx: transactions.nablaApproveTransaction, diff --git a/src/services/storage/remote.ts b/src/services/storage/remote.ts index 4c4e402b..4b48cc67 100644 --- a/src/services/storage/remote.ts +++ b/src/services/storage/remote.ts @@ -3,7 +3,7 @@ import { SIGNING_SERVICE_URL } from '../../constants/constants'; // These are the headers for the Google Spreadsheet interface DumpData { timestamp: string; - polygonAddress: string; + offramperAddress: string; stellarEphemeralPublicKey: string; pendulumEphemeralPublicKey: string; nablaApprovalTx: string;