import Gun from 'gun' ; import 'gun/lib/then' ; import type { PublishedAESKey } from '../../../crypto/crypto-alpha-40' ; import { gun2 } from '../version.2' ; deprecated interface ApplicationStateInGunVersion1 { maskbook : { posts : { [ salt ] : { [ receiversUsername ] : PublishedAESKey ; } ; } ; } ; } function typeHelper ( ) { return new Gun < ApplicationStateInGunVersion1 > ( ) ; } deprecated export const gun1 = ( gun2 as any as ReturnType < typeof typeHelper > ) . get ( 'maskbook' ) ; param salt param myUsername deprecated export async function queryVersion1PostAESKey ( salt , myUsername ) { const result = await gun1 . get ( 'posts' ) . get ( salt ) . get ( myUsername ) . then ! ( ) ; if ( result ?. encryptedKey && result . salt ) return result ; return undefined ; } export async function getVersion1PostByHash ( postSalt ) { return ( gun1 . get ( 'posts' ) . get ( postSalt ) . then ! ( ) ) ; }