Skip to content

Commit

Permalink
Merge pull request #294 from snake-eaterr/bridge-integration-nip98
Browse files Browse the repository at this point in the history
Bridge integration nip98
  • Loading branch information
shocknet-justin authored Sep 17, 2024
2 parents b73124b + 0b7d468 commit 79177a1
Show file tree
Hide file tree
Showing 16 changed files with 1,622 additions and 1,292 deletions.
4 changes: 0 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions src/Api/bridge/autogenerated/ts/http_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type ResultError = { status: 'ERROR', reason: string }
export type ClientParams = {
baseUrl: string
retrieveGuestAuth: () => Promise<string | null>
retrieveNostrAuth: () => Promise<string | null>
encryptCallback: (plain: any) => Promise<any>
decryptCallback: (encrypted: any) => Promise<any>
deviceId: string
Expand All @@ -26,6 +27,20 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
GetOrCreateNofferName: async (request: Types.GetOrCreateNofferNameRequest): Promise<ResultError | ({ status: 'OK' }& Types.GetOrCreateNofferNameResponse)> => {
const auth = await params.retrieveNostrAuth()
if (auth === null) throw new Error('retrieveNostrAuth() returned null')
let finalRoute = '/api/v1/noffer/vanity'
const { data } = await axios.post(params.baseUrl + finalRoute, request, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.GetOrCreateNofferNameResponseValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
HandleLnurlPay: async (query: Types.HandleLnurlPay_Query): Promise<ResultError | ({ status: 'OK' }& Types.HandleLnurlPayResponse)> => {
const auth = await params.retrieveGuestAuth()
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
Expand All @@ -42,6 +57,23 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
HandleLnurlPayUsername: async (query: Types.HandleLnurlPayUsername_Query, routeParams: Types.HandleLnurlPayUsername_RouteParams): Promise<ResultError | ({ status: 'OK' }& Types.HandleLnurlPayResponse)> => {
const auth = await params.retrieveGuestAuth()
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
let finalRoute = '/api/lnurl_pay/:address_name'
finalRoute = finalRoute.replace(':address_name', routeParams['address_name'])
const q = (new URLSearchParams(query)).toString()
finalRoute = finalRoute + (q === '' ? '' : '?' + q)
const { data } = await axios.get(params.baseUrl + finalRoute, { headers: { 'authorization': auth } })
if (data.status === 'ERROR' && typeof data.reason === 'string') return data
if (data.status === 'OK') {
const result = data
if(!params.checkResult) return { status: 'OK', ...result }
const error = Types.HandleLnurlPayResponseValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
HandleLnurlAddress: async (routeParams: Types.HandleLnurlAddress_RouteParams): Promise<ResultError | ({ status: 'OK' }& Types.LnurlPayInfoResponse)> => {
const auth = await params.retrieveGuestAuth()
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
Expand Down
Loading

0 comments on commit 79177a1

Please sign in to comment.