Skip to content

Commit

Permalink
Merge pull request #327 from shocknet/test
Browse files Browse the repository at this point in the history
nip68 debits
  • Loading branch information
shocknet-justin authored Oct 6, 2024
2 parents 39c81ce + e2390da commit dcc9b17
Show file tree
Hide file tree
Showing 67 changed files with 3,492 additions and 2,019 deletions.
2 changes: 1 addition & 1 deletion .env.development.example
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ VITE_APP_NAME=SWTEST
VITE_NOSTR_PUB_DESTINATION=e306c45ee0a7c772540f1dc88b00f79d2d3910bfd4047e910584998de9c9e2be
VITE_DEFAULT_BRIDGE_URL=https://shocklab.dev
VITE_APP_URL=test.shockwallet.app
VITE_SANCTUM_URL=https://test-auth.shock.network
VITE_SANCTUM_URL=https://auth.shocklab.dev
VITE_KEYLINK_APP_ID=2ff35dfeb1448156e4f4057899cff2b3aa7679914565ce80e2f8fc45dfe61e4e
VITE_ANDROID_APPLICATION_ID=app.shockwallet.test

11 changes: 5 additions & 6 deletions cypress/e2e/startup.cy.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { nip19 } from 'nostr-tools'
import { PUB_NOSTR_PUBLIC_KEY_STORAGE_KEY } from '../../src/constants';

const PUB_NOSTR_PUBLIC_KEY_STORAGE_KEY = "???"
const initialNprofileSats = 2000;


Expand Down Expand Up @@ -43,7 +42,7 @@ describe("has nprofile and default 2000 sats", () => {
cy.populateLocalStorage() // user starts with 2000 sats here
cy.addUser();
cy.visit("")

})

it("Has nprofile in sources page", () => {
Expand All @@ -63,10 +62,10 @@ describe("has nprofile and default 2000 sats", () => {
cy.get("body").focus()
cy.get("#copy-button").should("exist");
cy.get("#copy-button").click();

cy.window().its("navigator.clipboard").invoke("readText").then(prom => {
prom.then((text: string) => {
cy.payInvoice({invoice: text.slice("lightning:".length)})
cy.payInvoice({ invoice: text.slice("lightning:".length) })
cy.visit("")
cy.get("#wallet_balance").contains((initialNprofileSats + invoiceAmount).toString());
cy.get(".SwItem").as("history-item");
Expand Down Expand Up @@ -94,7 +93,7 @@ describe("has nprofile and default 2000 sats", () => {

})


})


Expand Down
10 changes: 5 additions & 5 deletions cypress/support/commands.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { generatePrivateKey, getPublicKey, nip19 } from 'nostr-tools'
import { NOSTR_PRIVATE_KEY_STORAGE_KEY, NOSTR_PUBLIC_KEY_STORAGE_KEY, NOSTR_RELAYS, PUB_NOSTR_PUBLIC_KEY_STORAGE_KEY } from '../../src/constants';
import { generateSecretKey, getPublicKey, nip19 } from 'nostr-tools'
import { NOSTR_PRIVATE_KEY_STORAGE_KEY, NOSTR_PUBLIC_KEY_STORAGE_KEY, NOSTR_RELAYS } from '../../src/constants';
/// <reference types="cypress" />
// ***********************************************
// This example commands.ts shows you how to
Expand Down Expand Up @@ -29,7 +29,7 @@ import { NOSTR_PRIVATE_KEY_STORAGE_KEY, NOSTR_PUBLIC_KEY_STORAGE_KEY, NOSTR_RELA
//



const PUB_NOSTR_PUBLIC_KEY_STORAGE_KEY = "???"
Cypress.Commands.add("emptyDb", () => {
window.localStorage.clear();
cy.request('GET', `http://localhost:18000/api/testing/db/reset`).then(res => {
Expand Down Expand Up @@ -80,10 +80,10 @@ Cypress.Commands.add("populateLocalStorage", () => {
balance: "0"
}
]
const privKey = generatePrivateKey();
const privKey = generateSecretKey();
const pubkKey = getPublicKey(privKey);

win.localStorage.setItem(NOSTR_PRIVATE_KEY_STORAGE_KEY, privKey);
win.localStorage.setItem(NOSTR_PRIVATE_KEY_STORAGE_KEY, Buffer.from(privKey).toString('hex'));
win.localStorage.setItem(NOSTR_PUBLIC_KEY_STORAGE_KEY, pubkKey);
win.localStorage.setItem("TEST_NPROFILE", nprofile);
win.localStorage.setItem("spendFrom", JSON.stringify(spendFrom));
Expand Down
51 changes: 38 additions & 13 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@
"i": "^0.3.7",
"ionicons": "^7.0.0",
"moment": "^2.29.4",
"nostr-tools": "^1.16.0",
"nostr-tools": "github:shocknet/nostr-tools#ef16463592e2f7b5bf18abc86ff974615d64bb7d",
"npm": "^10.3.0",
"qr-scanner": "^1.4.2",
"react": "^18.2.0",
Expand Down
27 changes: 27 additions & 0 deletions src/Api/bridge/autogenerated/ts/http_client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,17 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
UpdateMappingNdebit: async (request: Types.UpdateMappingNdebitRequest): Promise<ResultError | ({ status: 'OK' })> => {
const auth = await params.retrieveNostrAuth()
if (auth === null) throw new Error('retrieveNostrAuth() returned null')
let finalRoute = '/api/v1/noffer/update/ndebit'
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') {
return data
}
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 Down Expand Up @@ -89,4 +100,20 @@ export default (params: ClientParams) => ({
}
return { status: 'ERROR', reason: 'invalid response' }
},
HandleNip05Info: async (query: Types.HandleNip05Info_Query): Promise<ResultError | ({ status: 'OK' }& Types.nip05Names)> => {
const auth = await params.retrieveGuestAuth()
if (auth === null) throw new Error('retrieveGuestAuth() returned null')
let finalRoute = '/.well-known/nostr.json'
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.nip05NamesValidate(result)
if (error === null) { return { status: 'OK', ...result } } else return { status: 'ERROR', reason: error.message }
}
return { status: 'ERROR', reason: 'invalid response' }
},
})
Loading

0 comments on commit dcc9b17

Please sign in to comment.