Allow users to force-update their linked ETH address

Removed sc_identity_id from Player table because it enforces ETH addresses to be used as the single source of truth for users and prevents conflicts when users update their ETH address in the ledger. sc_identity_id is not needing anywhere in our backend / data model.
This commit is contained in:
Hammad Jutt
2021-06-09 13:01:04 -06:00
committed by Alec LaLonde
parent ba0be9fb09
commit 63eeca916f
13 changed files with 61 additions and 104 deletions

View File

@@ -17,6 +17,7 @@
"bignumber.js": "9.0.1",
"ethers": "5.3.0",
"js-base64": "3.6.1",
"uuid": "8.3.2"
"uuid": "8.3.2",
"sourcecred": "0.9.0"
}
}

View File

@@ -5,3 +5,4 @@ export * as DiscordUtil from './discordHelpers';
export * as numbers from './numbers';
export * from './promiseHelpers';
export * from './rankHelpers';
export * from './sourceCredHelpers';

View File

@@ -0,0 +1,15 @@
import { ethers } from 'ethers';
import { SCIdentity, sourcecred as sc } from 'sourcecred';
export const getLatestEthAddress = (identity: SCIdentity): string | null => {
const ethAddress = identity.aliases.find((alias) => {
const parts = sc.core.graph.NodeAddress.toParts(alias.address);
return parts.indexOf('ethereum') > 0;
})?.description;
if (ethAddress && ethers.utils.isAddress(ethAddress)) {
return ethAddress.toLowerCase();
}
return null;
};