-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2 from DappyKit/feat/improvements-1
feat: callback with signature
- Loading branch information
Showing
18 changed files
with
365 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- '**' | ||
|
||
jobs: | ||
test: | ||
name: Run tests | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Check out code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 18 | ||
|
||
- name: Install dependencies | ||
run: npm ci | ||
|
||
- name: Lint check | ||
run: npm run lint:check | ||
|
||
- name: Check types | ||
run: npm run check:types |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
import { Request, Response, NextFunction } from 'express' | ||
import { getAppBySignerAddress } from '../../../db/app' | ||
import { isAnyEthAddress, prepareEthAddress } from '../../../utils/eth' | ||
import { IExistsResponse } from './interface/IExistsResponse' | ||
|
||
export function getAppExistsParams(req: Request): { applicationAddress: string } { | ||
const { applicationAddress } = req.query | ||
|
||
if (!applicationAddress) { | ||
throw new Error('"applicationAddress" is required') | ||
} | ||
|
||
if (!isAnyEthAddress(applicationAddress)) { | ||
throw new Error('Invalid "applicationAddress"') | ||
} | ||
|
||
return { applicationAddress: prepareEthAddress(applicationAddress as string) } | ||
} | ||
|
||
/** | ||
* Checks if the app with the address already exists. | ||
* @param req Request | ||
* @param res Response | ||
* @param next Next function | ||
*/ | ||
export default async (req: Request, res: Response<IExistsResponse>, next: NextFunction): Promise<void> => { | ||
try { | ||
const { applicationAddress } = getAppExistsParams(req) | ||
|
||
const isExists = Boolean(await getAppBySignerAddress(applicationAddress)) | ||
|
||
res.json({ | ||
status: 'ok', | ||
isExists, | ||
}) | ||
} catch (e) { | ||
next(e) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
export interface IExistsResponse { | ||
status: string | ||
isExists: boolean | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/** | ||
* Error message for invalid challenge answer. | ||
*/ | ||
export const INVALID_CHALLENGE_ANSWER = 'Invalid answer for the challenge' | ||
/** | ||
* Error message for user rejection. | ||
*/ | ||
export const USER_REJECTED_REQUEST = 'User rejected the request' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.