@@ -17,7 +17,10 @@ import {
1717 type Asset ,
1818 type TenantMutationResponse ,
1919 type CreateTenantInput ,
20- TenantSettingKey
20+ TenantSettingKey ,
21+ type UpdatePeerMutationResponse ,
22+ type UpdatePeerInput ,
23+ type DeletePeerMutationResponse
2124} from './generated/graphql'
2225import { v4 as uuid } from 'uuid'
2326
@@ -79,6 +82,8 @@ export function createRequesters(
7982 staticIlpAddress : string ,
8083 assetId : string
8184 ) => Promise < Peer | null >
85+ updatePeer : ( input : UpdatePeerInput ) => Promise < UpdatePeerMutationResponse >
86+ deletePeer : ( peerId : string ) => Promise < DeletePeerMutationResponse >
8287} {
8388 return {
8489 createAsset : ( code , scale , liquidityThreshold ) =>
@@ -129,7 +134,10 @@ export function createRequesters(
129134 getAssetByCodeAndScale ( apolloClient , code , scale ) ,
130135 getWalletAddressByURL : ( url ) => getWalletAddressByURL ( apolloClient , url ) ,
131136 getPeerByAddressAndAsset : ( staticIlpAddress , assetId ) =>
132- getPeerByAddressAndAsset ( apolloClient , staticIlpAddress , assetId )
137+ getPeerByAddressAndAsset ( apolloClient , staticIlpAddress , assetId ) ,
138+ updatePeer : ( input : UpdatePeerInput ) =>
139+ updatePeer ( apolloClient , logger , input ) ,
140+ deletePeer : ( peerId : string ) => deletePeer ( apolloClient , logger , peerId )
133141 }
134142}
135143
@@ -280,6 +288,62 @@ export async function createPeer(
280288 } )
281289}
282290
291+ export async function updatePeer (
292+ apolloClient : ApolloClient < NormalizedCacheObject > ,
293+ logger : Logger ,
294+ input : UpdatePeerInput
295+ ) : Promise < UpdatePeerMutationResponse > {
296+ const updatePeerMutation = gql `
297+ mutation UpdatePeer($input: UpdatePeerInput!) {
298+ updatePeer(input: $input) {
299+ peer {
300+ id
301+ }
302+ }
303+ }
304+ `
305+
306+ return apolloClient
307+ . mutate ( {
308+ mutation : updatePeerMutation ,
309+ variables : { input }
310+ } )
311+ . then ( ( { data } ) : UpdatePeerMutationResponse => {
312+ logger . debug ( data )
313+ if ( ! data ?. updatePeer ) {
314+ throw new Error ( 'Data was empty' )
315+ }
316+ return data . updatePeer
317+ } )
318+ }
319+
320+ export async function deletePeer (
321+ apolloClient : ApolloClient < NormalizedCacheObject > ,
322+ logger : Logger ,
323+ peerId : string
324+ ) : Promise < DeletePeerMutationResponse > {
325+ const mutation = gql `
326+ mutation DeletePeer($input: DeletePeerInput!) {
327+ deletePeer(input: $input) {
328+ success
329+ }
330+ }
331+ `
332+
333+ return apolloClient
334+ . mutate ( {
335+ mutation,
336+ variables : { input : { id : peerId } }
337+ } )
338+ . then ( ( { data } ) : DeletePeerMutationResponse => {
339+ logger . debug ( data )
340+ if ( ! data ?. deletePeer ) {
341+ throw new Error ( 'Data was empty' )
342+ }
343+ return data . deletePeer
344+ } )
345+ }
346+
283347export async function createAutoPeer (
284348 apolloClient : ApolloClient < NormalizedCacheObject > ,
285349 logger : Logger ,
0 commit comments