mirror of
https://github.com/pezkuwichain/pwap.git
synced 2026-06-09 20:11:02 +00:00
feat: write p2p_user_id to tg_users on Telegram wallet link
TelegramConnect: query tg_users instead of users, resolve visa UUID from p2p_visa table and store as p2p_user_id for cross-platform P2P. P2PIdentityContext: when citizen resolves their UUID, backfill tg_users.p2p_user_id if their wallet is linked to a Telegram account.
This commit is contained in:
@@ -54,6 +54,21 @@ export function P2PIdentityProvider({ children }: { children: ReactNode }) {
|
||||
const uuid = await identityToUUID(fullCitizenNumber);
|
||||
setUserId(uuid);
|
||||
setVisaNumber(null);
|
||||
|
||||
// If this wallet is linked to a Telegram account and p2p_user_id not set yet,
|
||||
// backfill it so mini app users see the same P2P identity
|
||||
if (walletAddress) {
|
||||
supabase
|
||||
.from('tg_users')
|
||||
.select('id, p2p_user_id')
|
||||
.eq('wallet_address', walletAddress)
|
||||
.maybeSingle()
|
||||
.then(({ data: tgUser }) => {
|
||||
if (tgUser && !tgUser.p2p_user_id) {
|
||||
supabase.from('tg_users').update({ p2p_user_id: uuid }).eq('id', tgUser.id);
|
||||
}
|
||||
});
|
||||
}
|
||||
} else if (walletAddress) {
|
||||
// Non-citizen: check for existing visa
|
||||
const { data: visa } = await supabase
|
||||
|
||||
Reference in New Issue
Block a user