From ced12950d74bcaa09dac45224d996abb76a28b6a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miroslav=20Bajto=C5=A1?= Date: Wed, 4 Oct 2023 16:58:52 +0200 Subject: [PATCH] feat: accept participant address in ETH 0x format MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Miroslav Bajtoš --- lib/preprocess.js | 5 +++++ test/preprocess.js | 5 +++++ 2 files changed, 10 insertions(+) diff --git a/lib/preprocess.js b/lib/preprocess.js index 9733a9ce..b7fdc519 100644 --- a/lib/preprocess.js +++ b/lib/preprocess.js @@ -59,6 +59,11 @@ const fetchMeasurements = async (web3Storage, cid) => { } export const parseParticipantAddress = filWalletAddress => { + // ETH addresses don't need any conversion + if (filWalletAddress.startsWith('0x')) { + return filWalletAddress + } + if (!filWalletAddress || filWalletAddress.startsWith('f1') || filWalletAddress.startsWith('t1')) { // As a temporary fix to allow us to build & test the fraud detection pipeline, // we assign measurements from f1/t1 addresses to the same 0x participant. diff --git a/test/preprocess.js b/test/preprocess.js index aa53bc90..5202f0d4 100644 --- a/test/preprocess.js +++ b/test/preprocess.js @@ -86,4 +86,9 @@ describe('preprocess', () => { const converted = parseParticipantAddress('t17uoq6tp427uzv7fztkbsnn64iwotfrristwpryy') assert.strictEqual(converted, '0xf100Ac342b7DE48e5c89f7029624eE6c3Cde68aC') }) + + it('accepts ETH 0x address', () => { + const converted = parseParticipantAddress('0x3356fd7D01F001f5FdA3dc032e8bA14E54C2a1a1') + assert.strictEqual(converted, '0x3356fd7D01F001f5FdA3dc032e8bA14E54C2a1a1') + }) })