Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: wallet not being set (user is not created) #48

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

14 changes: 5 additions & 9 deletions src/adapters/supabase/helpers/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ export class Wallet extends Super {
public async upsertWalletAddress(context: Context, address: string) {
const payload = context.payload;

let userData = await this._checkIfUserExists(payload.sender.id);
if (!userData) {
userData = await this._registerNewUser(payload.sender);
}

const registeredWalletData = await this._getRegisteredWalletData(address);

if (!registeredWalletData) {
Expand Down Expand Up @@ -76,15 +81,6 @@ export class Wallet extends Super {
return data as UserRow;
}

private async _getUserData(payload: Context["payload"]) {
let userData = await this._checkIfUserExists(payload.sender.id);
if (!userData) {
const user = payload.sender;
userData = await this._registerNewUser(user);
}
return userData;
}

private async _registerNewUser(user: Context["payload"]["sender"]) {
const { data: userData, error: userError } = await this.supabase
.from("users")
Expand Down