import { currentCluster , isKeypair , makeKeypair , PostDirectRequest , PostRequest , pubkeyOf , toSolanaKeyMaterial , } from '../lib/util' ; import * as service from '../service/post' ; import { keyToIdentifier } from '@identity.com/sol-did-client' ; import { PublicKey } from '@solana/web3.js' ; import { SolanaUtil } from '../lib/solana/solanaUtil' ; param request export const post = async ( request ) : Promise < void > => { const connection = SolanaUtil . getConnection ( request . cluster ) ; const payer = toSolanaKeyMaterial ( request . payer ) ; const payerOrUndefined = isKeypair ( payer ) ? payer : undefined ; const signer = makeKeypair ( request . signer ) ; const senderDID = request . senderDID || ( await keyToIdentifier ( pubkeyOf ( payer ) , currentCluster ( request . cluster ) ) ) ; return service . post ( connection , senderDID , new PublicKey ( request . channel ) , request . message , signer , payerOrUndefined , request . signCallback , request . cluster ) ; } ; param request export const postDirect = async ( request ) : Promise < void > => { const connection = SolanaUtil . getConnection ( request . cluster ) ; const payer = toSolanaKeyMaterial ( request . payer ) ; const payerOrUndefined = isKeypair ( payer ) ? payer : undefined ; const signer = makeKeypair ( request . signer ) ; const senderDID = request . senderDID || ( await keyToIdentifier ( pubkeyOf ( payer ) , currentCluster ( request . cluster ) ) ) ; return service . postDirect ( connection , senderDID , request . recipientDID , request . message , signer , payerOrUndefined , request . signCallback , request . cluster ) ; } ;