mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-05 19:28:26 +00:00
Migrate to the new NOSTR relay server
This commit is contained in:
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "minibits_wallet",
|
||||
"version": "0.1.7-beta.16",
|
||||
"version": "0.1.7-beta.17",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
"android:clean": "cd android && ./gradlew clean",
|
||||
|
||||
@@ -8,7 +8,7 @@ import {PaymentRequestsStoreModel} from './PaymentRequestsStore'
|
||||
import {ProofsStoreModel} from './ProofsStore'
|
||||
import {RelaysStoreModel} from './RelaysStore'
|
||||
|
||||
export const rootStoreModelVersion = 13 // Update this if model changes require migrations defined in setupRootStore.ts
|
||||
export const rootStoreModelVersion = 14 // Update this if model changes require migrations defined in setupRootStore.ts
|
||||
|
||||
/**
|
||||
* A RootStore model.
|
||||
|
||||
@@ -85,6 +85,41 @@ export const WalletProfileStoreModel = types
|
||||
return false // silent
|
||||
}
|
||||
}),
|
||||
migrateToNewRelay: flow(function* migrateToNewRelay() {
|
||||
try {
|
||||
const {pubkey, name, picture, nip05, lud16} = self
|
||||
|
||||
// announce to new minibits relay
|
||||
const profileEvent: NostrUnsignedEvent = {
|
||||
kind: 0,
|
||||
pubkey,
|
||||
tags: [],
|
||||
content: JSON.stringify({
|
||||
name,
|
||||
picture,
|
||||
nip05,
|
||||
lud16,
|
||||
}),
|
||||
created_at: Math.floor(Date.now() / 1000)
|
||||
}
|
||||
|
||||
const rootStore = getRootStore(self)
|
||||
const relaysToPublish: string[] = NostrClient.getMinibitsRelays()
|
||||
|
||||
log.debug('[publishToRelays]', 'Migrate profile to new relay', {profileEvent, relaysToPublish})
|
||||
|
||||
const publishedEvent: Event | undefined = yield NostrClient.publish(
|
||||
profileEvent,
|
||||
relaysToPublish
|
||||
)
|
||||
|
||||
return publishedEvent
|
||||
|
||||
} catch (e: any) {
|
||||
log.error(e.name, e.message)
|
||||
return false // silent
|
||||
}
|
||||
}),
|
||||
}))
|
||||
.actions(self => ({
|
||||
hydrate: flow(function* hydrate(profileRecord: WalletProfileRecord) {
|
||||
|
||||
@@ -284,7 +284,18 @@ async function _runMigrations(rootStore: RootStore) {
|
||||
|
||||
rootStore.setVersion(rootStoreModelVersion)
|
||||
log.info(`Completed rootStore migrations to the version v${rootStoreModelVersion}`)
|
||||
}
|
||||
}
|
||||
|
||||
if(currentVersion < 14) {
|
||||
log.trace(`Starting rootStore migrations from version v${currentVersion} -> v14`)
|
||||
try {
|
||||
await walletProfileStore.migrateToNewRelay()
|
||||
} catch (e: any) {
|
||||
log.warn('[setupRootStore]', e.message)
|
||||
}
|
||||
log.info(`Completed rootStore migrations to the version v${rootStoreModelVersion}`)
|
||||
rootStore.setVersion(rootStoreModelVersion)
|
||||
}
|
||||
|
||||
} catch (e: any) {
|
||||
throw new AppError(
|
||||
|
||||
Reference in New Issue
Block a user