Iโm confused about the code in the link() function:
static async link(account, options) {
const web3 = await MoralisWeb3.enableWeb3(options);
const data = options?.signingMessage || MoralisWeb3.getSigningData();
const user = await ParseUser.currentAsync();
const ethAddress = account.toLowerCase();
const EthAddress = ParseObject.extend('_EthAddress');
const query = new ParseQuery(EthAddress);
const ethAddressRecord = await query.get(ethAddress).catch(() => null);
if (!ethAddressRecord) {
const signature = await web3.eth.personal.sign(data, account, '');
const authData = { id: ethAddress, signature, data };
await user.linkWith('moralisEth', { authData });
}
user.set('accounts', uniq([ethAddress].concat(user.get('accounts') ?? [])));
user.set('ethAddress', ethAddress);
await user.save(null, options);
return user;
}
Could you please shortly explain what the if block is about? if the address is not found on the server it is linked?, but if it is found there is also code being executed afterwards, how come?