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

feat: update to PubKey Protocol v1 sdk #4

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
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
10 changes: 5 additions & 5 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -59,16 +59,16 @@ JWT_SECRET=
HOST=127.0.0.1
# Port to listen on
PORT=3000
# PubKey Protocol Signer (Byte array as a comma-separated list of numbers with brackets: '[1,2,3]')
# FEESyimdmwzSQA99FqCVMn8rYYQdnRBguXh8AWdwJUcc
PUBKEY_PROTOCOL_SIGNER_SECRET_KEY='[152,222,146,61,189,252,198,154,44,101,236,177,170,27,231,52,185,128,234,101,214,247,206,97,166,183,126,170,165,179,147,21,211,103,95,129,144,43,47,17,229,174,40,46,25,82,14,6,95,118,169,245,129,172,149,69,220,91,111,240,248,63,102,37]'
# PubKey Protocol Signer Minimal Balance (in SOL)
PUBKEY_PROTOCOL_SIGNER_MINIMAL_BALANCE=1
# Session Secret (generate a random string with `openssl rand -hex 32`)
SESSION_SECRET=
# Solana Cluster endpoints
SOLANA_ENDPOINT=
SOLANA_ENDPOINT_PUBLIC=
# Solana Fee Payer (Byte array as a comma-separated list of numbers with brackets: '[1,2,3]')
# FEESyimdmwzSQA99FqCVMn8rYYQdnRBguXh8AWdwJUcc
SOLANA_FEE_PAYER_SECRET_KEY='[152,222,146,61,189,252,198,154,44,101,236,177,170,27,231,52,185,128,234,101,214,247,206,97,166,183,126,170,165,179,147,21,211,103,95,129,144,43,47,17,229,174,40,46,25,82,14,6,95,118,169,245,129,172,149,69,220,91,111,240,248,63,102,37]'
# Solana Fee Payer Minimal Balance (in SOL)
SOLANA_FEE_PAYER_MINIMAL_BALANCE=1
# The URL of the Web UI, used to redirect to the Web UI after login.
# In a typical deployment, this is the same as the API_URL with the '/api' suffix removed (the default).
# This means you will probably only need to set this if you are running a local development setup.
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,10 @@ env:
HOST: 127.0.0.1
JWT_SECRET: 1dfe5003518560c6362eab48f8220edf8708bbc67efbd4ed8cdf621965e938ee
PORT: 3000
PUBKEY_PROTOCOL_SIGNER_SECRET_KEY: '[152,222,146,61,189,252,198,154,44,101,236,177,170,27,231,52,185,128,234,101,214,247,206,97,166,183,126,170,165,179,147,21,211,103,95,129,144,43,47,17,229,174,40,46,25,82,14,6,95,118,169,245,129,172,149,69,220,91,111,240,248,63,102,37]'
SESSION_SECRET: 1dfe5003518560c6362eab48f8220edf8708bbc67efbd4ed8cdf621965e938ee
SOLANA_ENDPOINT: 'https://api.devnet.solana.com'
SOLANA_ENDPOINT_PUBLIC: 'https://api.devnet.solana.com'
SOLANA_FEE_PAYER_SECRET_KEY: '[152,222,146,61,189,252,198,154,44,101,236,177,170,27,231,52,185,128,234,101,214,247,206,97,166,183,126,170,165,179,147,21,211,103,95,129,144,43,47,17,229,174,40,46,25,82,14,6,95,118,169,245,129,172,149,69,220,91,111,240,248,63,102,37]'
jobs:
main-e2e:
runs-on: ubuntu-22.04
Expand Down
2 changes: 1 addition & 1 deletion api-schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ type AppConfig {
authSolanaEnabled: Boolean!
authTelegramEnabled: Boolean!
authTwitterEnabled: Boolean!
pubkeyProtocolSigner: String!
solanaEndpoint: String!
solanaFeePayer: String!
}

"""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@ export class ApiCoreConfigService {
authSolanaEnabled: this.authSolanaEnabled,
authTelegramEnabled: this.authTelegramEnabled,
authTwitterEnabled: this.authTwitterEnabled,
pubkeyProtocolSigner: this.pubkeyProtocolSigner.publicKey.toString(),
solanaEndpoint: this.solanaEndpointPublic,
solanaFeePayer: this.solanaFeePayer.publicKey.toString(),
}
}

Expand Down Expand Up @@ -242,6 +242,14 @@ export class ApiCoreConfigService {
return '/api'
}

get pubkeyProtocolSigner(): Keypair {
return this.service.get<Keypair>('pubkeyProtocolSigner') as Keypair
}

get pubkeyProtocolSignerMinimalBalance(): number {
return this.service.get<number>('pubkeyProtocolSignerMinimalBalance') as number
}

get sessionSecret() {
return this.service.get<string>('sessionSecret') as string
}
Expand All @@ -254,14 +262,6 @@ export class ApiCoreConfigService {
return this.service.get<string>('solanaEndpointPublic') as string
}

get solanaFeePayer(): Keypair {
return this.service.get<Keypair>('solanaFeePayer') as Keypair
}

get solanaFeePayerMinimalBalance(): number {
return this.service.get<number>('solanaFeePayerMinimalBalance') as number
}

get webUrl(): string {
return this.service.get<string>('webUrl') as string
}
Expand Down
14 changes: 8 additions & 6 deletions libs/api/core/data-access/src/lib/config/configuration.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { getKeypairFromByteArray } from '@pubkey-protocol/sdk'
import { Keypair } from '@solana/web3.js'

// Remove trailing slashes from the URLs to avoid double slashes
Expand Down Expand Up @@ -63,10 +64,10 @@ export interface ApiCoreConfig {
jwtSecret: string
port: number
sessionSecret: string
pubkeyProtocolSigner: Keypair
pubkeyProtocolSignerMinimalBalance: number
solanaEndpoint: string
solanaEndpointPublic: string
solanaFeePayer: Keypair
solanaFeePayerMinimalBalance: number
webUrl: string
}

Expand Down Expand Up @@ -105,12 +106,13 @@ export function configuration(): ApiCoreConfig {
host: process.env['HOST'] as string,
jwtSecret: process.env['JWT_SECRET'] as string,
port: parseInt(process.env['PORT'] as string, 10) || 3000,
pubkeyProtocolSigner: getKeypairFromByteArray(
JSON.parse(process.env['PUBKEY_PROTOCOL_SIGNER_SECRET_KEY'] as string),
),
pubkeyProtocolSignerMinimalBalance:
parseFloat(process.env['PUBKEY_PROTOCOL_SIGNER_MINIMAL_BALANCE'] as string) || 1,
solanaEndpoint: process.env['SOLANA_ENDPOINT'] as string,
solanaEndpointPublic: process.env['SOLANA_ENDPOINT_PUBLIC'] as string,
solanaFeePayer: Keypair.fromSecretKey(
Uint8Array.from(JSON.parse(process.env['SOLANA_FEE_PAYER_SECRET_KEY'] as string)),
),
solanaFeePayerMinimalBalance: parseFloat(process.env['SOLANA_FEE_PAYER_MINIMAL_BALANCE'] as string) || 1,
sessionSecret: process.env['SESSION_SECRET'] as string,
webUrl: WEB_URL,
}
Expand Down
4 changes: 2 additions & 2 deletions libs/api/core/data-access/src/lib/config/validation-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ export const validationSchema = Joi.object({
HOST: Joi.string().default('0.0.0.0'),
NODE_ENV: Joi.string().valid('development', 'production', 'test', 'provision').default('development'),
PORT: Joi.number().default(3000),
PUBKEY_PROTOCOL_SIGNER_SECRET_KEY: Joi.string().required(),
PUBKEY_PROTOCOL_SIGNER_MINIMAL_BALANCE: Joi.number().default(1),
SESSION_SECRET: Joi.string().required(),
SOLANA_ENDPOINT: Joi.string().required().default(clusterApiUrl('devnet')),
SOLANA_ENDPOINT_PUBLIC: Joi.string().required().default(clusterApiUrl('devnet')),
SOLANA_FEE_PAYER_SECRET_KEY: Joi.string().required(),
SOLANA_FEE_PAYER_MINIMAL_BALANCE: Joi.number().default(1),
SYNC_DRY_RUN: Joi.boolean().default(false),
})
4 changes: 2 additions & 2 deletions libs/api/core/data-access/src/lib/entity/app-config.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export class AppConfig {
@Field()
authTwitterEnabled!: boolean
@Field()
solanaEndpoint!: string
pubkeyProtocolSigner!: string
@Field()
solanaFeePayer!: string
solanaEndpoint!: string
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getRequestDetails,
slugifyId,
} from '@pubkey-network/api-core-data-access'
import { PubKeyProfile } from '@pubkey-program-library/anchor'
import { PubKeyProfile } from '@pubkey-protocol/sdk'
import { ApiIdentitySolanaService } from './api-identity-solana.service'
import { IdentityRequestChallengeInput } from './dto/identity-request-challenge-input'
import { IdentityVerifyChallengeInput } from './dto/identity-verify-challenge-input'
Expand Down
Loading
Loading