From 92a2272717994c3a968833ab741da007d4b6804c Mon Sep 17 00:00:00 2001 From: minibits-cash Date: Wed, 31 Jan 2024 08:52:49 +0100 Subject: [PATCH] Upgrade cashu-ts lib, improved zaps (fixed) --- package.json | 2 +- src/models/WalletProfileStore.ts | 6 ++---- src/screens/SendScreen.tsx | 6 ++---- src/screens/TopupScreen.tsx | 6 ++---- src/services/keyChain.ts | 10 ++++------ src/services/nostrService.ts | 2 +- 6 files changed, 12 insertions(+), 20 deletions(-) diff --git a/package.json b/package.json index 43ac80e2..d56e04ab 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "minibits_wallet", - "version": "0.1.5-beta.27", + "version": "0.1.5-beta.28", "private": true, "scripts": { "android:clean": "cd android && ./gradlew clean", diff --git a/src/models/WalletProfileStore.ts b/src/models/WalletProfileStore.ts index 6c63d5b0..279f7025 100644 --- a/src/models/WalletProfileStore.ts +++ b/src/models/WalletProfileStore.ts @@ -1,6 +1,5 @@ import {Instance, SnapshotOut, types, flow} from 'mobx-state-tree' -import {KeyChain, MinibitsClient, NostrClient, Wallet} from '../services' -import { UnsignedEvent as NostrUnsignedEvent } from 'nostr-tools/core' +import {KeyChain, MinibitsClient, NostrClient, NostrUnsignedEvent, Wallet} from '../services' import {log} from '../services/logService' import { Err } from '../utils/AppError' import { getRandomUsername } from '../utils/usernames' @@ -53,8 +52,7 @@ export const WalletProfileStoreModel = types name, picture, nip05, - }), - created_at: Math.floor(Date.now() / 1000) + }), } const rootStore = getRootStore(self) diff --git a/src/screens/SendScreen.tsx b/src/screens/SendScreen.tsx index 0edaf10b..0d272802 100644 --- a/src/screens/SendScreen.tsx +++ b/src/screens/SendScreen.tsx @@ -43,8 +43,7 @@ import { import {TransactionStatus, Transaction} from '../models/Transaction' import {useStores} from '../models' import {useHeader} from '../utils/useHeader' -import {Wallet, NostrClient} from '../services' -import { UnsignedEvent as NostrUnsignedEvent } from 'nostr-tools/core' +import {NostrClient, NostrProfile, NostrUnsignedEvent, Wallet} from '../services' import {log} from '../services/logService' import AppError, {Err} from '../utils/AppError' import {translate} from '../i18n' @@ -398,8 +397,7 @@ export const SendScreen: FC> = observer( kind: 4, pubkey: senderPubkey, tags: [['p', receiverPubkey as string], ['from', walletProfileStore.nip05]], - content: encryptedContent, - created_at: Math.floor(Date.now() / 1000) + content: encryptedContent, } const sentEvent: Event | undefined = await NostrClient.publish( diff --git a/src/screens/TopupScreen.tsx b/src/screens/TopupScreen.tsx index 2d907ace..f6724ba1 100644 --- a/src/screens/TopupScreen.tsx +++ b/src/screens/TopupScreen.tsx @@ -34,8 +34,7 @@ import { import {TransactionStatus, Transaction} from '../models/Transaction' import {useStores} from '../models' import {useHeader} from '../utils/useHeader' -import {NostrClient, NostrProfile, Wallet} from '../services' -import { UnsignedEvent as NostrUnsignedEvent } from 'nostr-tools/core' +import {NostrClient, NostrProfile, NostrUnsignedEvent, Wallet} from '../services' import {log} from '../services/logService' import AppError, { Err } from '../utils/AppError' @@ -388,8 +387,7 @@ export const TopupScreen: FC> = observer( kind: 4, pubkey: senderPubkey, tags: [['p', receiverPubkey as string], ['from', walletProfileStore.nip05]], - content: encryptedContent, - created_at: Math.floor(Date.now() / 1000) + content: encryptedContent, } const sentEvent: Event | undefined = await NostrClient.publish( diff --git a/src/services/keyChain.ts b/src/services/keyChain.ts index bad772fd..dccfa1e3 100644 --- a/src/services/keyChain.ts +++ b/src/services/keyChain.ts @@ -2,9 +2,8 @@ import * as _Keychain from 'react-native-keychain' import AppError, {Err} from '../utils/AppError' import QuickCrypto from 'react-native-quick-crypto' import { generateNewMnemonic } from '@cashu/cashu-ts' -import { generateSecretKey, getPublicKey } from 'nostr-tools/pure' -import { bytesToHex } from '@noble/hashes/utils' -import {btoa, atob, fromByteArray} from 'react-native-quick-base64' +import { generatePrivateKey, getPublicKey } from 'nostr-tools' +import {btoa, fromByteArray} from 'react-native-quick-base64' import {log} from './logService' @@ -213,9 +212,8 @@ const removeSeed = async function (): Promise { const generateNostrKeyPair = function () { try { - const privateKeyUint = generateSecretKey() // uintarr - const publicKey = getPublicKey(privateKeyUint) // hex - const privateKey = bytesToHex(privateKeyUint) // hex + const privateKey = generatePrivateKey() // hex string + const publicKey = getPublicKey(privateKey) log.trace('New HEX Nostr keypair created:', publicKey, privateKey) diff --git a/src/services/nostrService.ts b/src/services/nostrService.ts index 68c5ebbf..9d2e6824 100644 --- a/src/services/nostrService.ts +++ b/src/services/nostrService.ts @@ -27,7 +27,7 @@ export { UnsignedEvent as NostrUnsignedEvent, } from 'nostr-tools' -// refresh + export type NostrProfile = { pubkey: string npub: string