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

Backpack issues resolve #25

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions backend/native/backpack-api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
"@coral-xyz/zeus": "*",
"@metaplex-foundation/js": "0.16.1",
"@metaplex-foundation/mpl-token-metadata": "^2.8.1",
"@noble/secp256k1": "^2.0.0",
"@saberhq/anchor-contrib": "^1.14.11",
"@saberhq/merkle-distributor": "^0.3.5",
"@saberhq/solana-contrib": "^1.14.11",
Expand Down
6 changes: 5 additions & 1 deletion backend/native/backpack-api/src/db/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,8 @@ const transformUser = (
*/
export const createUser = async (
username: string,
firstname: string,
lastname: string,
blockchainPublicKeys: Array<{ blockchain: Blockchain; publicKey: string }>,
waitlistId?: string | null,
referrerId?: string
Expand All @@ -323,12 +325,14 @@ export const createUser = async (
},
],
});

//zeus-automatically generated file
const response = await chain("mutation")({
insert_auth_users_one: [
{
object: {
username: username,
firstname: firstname,
lastname: lastname,
public_keys: {
data: blockchainPublicKeys.map((b) => ({
blockchain: b.blockchain,
Expand Down
8 changes: 6 additions & 2 deletions backend/native/backpack-api/src/routes/v1/users.ts
Original file line number Diff line number Diff line change
Expand Up @@ -124,9 +124,11 @@ router.get("/jwt/xnft", extractUserId, async (req, res) => {
* Create a new user.
*/
router.post("/", async (req, res) => {
const { username, waitlistId, blockchainPublicKeys } =
console.log("Hi there");
const { username, waitlistId, blockchainPublicKeys, firstname, lastname } =
CreateUserWithPublicKeys.parse(req.body);

console.log(firstname);
console.log(lastname);
// Validate all the signatures
for (const blockchainPublicKey of blockchainPublicKeys) {
const signedMessage = getCreateMessage(blockchainPublicKey.publicKey);
Expand Down Expand Up @@ -182,6 +184,8 @@ router.post("/", async (req, res) => {

const user = await createUser(
username,
firstname,
lastname,
blockchainPublicKeys.map((b) => ({
...b,
// Cast blockchain to correct type
Expand Down
2 changes: 2 additions & 0 deletions backend/native/backpack-api/src/validation/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ export const BaseCreateUser = z.object({
/^[a-z0-9_]{3,15}$/,
"should be between 3-15 characters and can only contain numbers, letters, and underscores."
),
firstname: z.string(),
lastname: z.string(),
inviteCode: z
.string()
.regex(
Expand Down
14 changes: 14 additions & 0 deletions backend/native/zeus/src/zeus/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -763,8 +763,10 @@ export const AllTypesProps: Record<string, any> = {
_or: "auth_users_bool_exp",
created_at: "timestamptz_comparison_exp",
dropzone_public_key: "auth_public_keys_bool_exp",
firstname: "String_comparison_exp",
id: "uuid_comparison_exp",
invitation: "auth_invitations_bool_exp",
lastname: "String_comparison_exp",
public_keys: "auth_public_keys_bool_exp",
public_keys_aggregate: "auth_public_keys_aggregate_bool_exp",
referred_users: "auth_users_bool_exp",
Expand All @@ -784,12 +786,16 @@ export const AllTypesProps: Record<string, any> = {
},
auth_users_max_order_by: {
created_at: "order_by",
firstname: "order_by",
id: "order_by",
lastname: "order_by",
username: "order_by",
},
auth_users_min_order_by: {
created_at: "order_by",
firstname: "order_by",
id: "order_by",
lastname: "order_by",
username: "order_by",
},
auth_users_obj_rel_insert_input: {
Expand All @@ -804,8 +810,10 @@ export const AllTypesProps: Record<string, any> = {
auth_users_order_by: {
created_at: "order_by",
dropzone_public_key_aggregate: "auth_public_keys_aggregate_order_by",
firstname: "order_by",
id: "order_by",
invitation: "auth_invitations_order_by",
lastname: "order_by",
public_keys_aggregate: "auth_public_keys_aggregate_order_by",
referred_users_aggregate: "auth_users_aggregate_order_by",
referrer: "auth_users_order_by",
Expand Down Expand Up @@ -2084,8 +2092,10 @@ export const ReturnTypes: Record<string, any> = {
auth_users: {
created_at: "timestamptz",
dropzone_public_key: "auth_public_keys",
firstname: "String",
id: "uuid",
invitation: "auth_invitations",
lastname: "String",
public_keys: "auth_public_keys",
public_keys_aggregate: "auth_public_keys_aggregate",
referred_users: "auth_users",
Expand All @@ -2104,12 +2114,16 @@ export const ReturnTypes: Record<string, any> = {
},
auth_users_max_fields: {
created_at: "timestamptz",
firstname: "String",
id: "uuid",
lastname: "String",
username: "citext",
},
auth_users_min_fields: {
created_at: "timestamptz",
firstname: "String",
id: "uuid",
lastname: "String",
username: "citext",
},
auth_users_mutation_response: {
Expand Down
Loading