@@ -17,7 +17,10 @@ import {
17
17
type Asset ,
18
18
type TenantMutationResponse ,
19
19
type CreateTenantInput ,
20
- TenantSettingKey
20
+ TenantSettingKey ,
21
+ type UpdatePeerMutationResponse ,
22
+ type UpdatePeerInput ,
23
+ type DeletePeerMutationResponse
21
24
} from './generated/graphql'
22
25
import { v4 as uuid } from 'uuid'
23
26
@@ -79,6 +82,8 @@ export function createRequesters(
79
82
staticIlpAddress : string ,
80
83
assetId : string
81
84
) => Promise < Peer | null >
85
+ updatePeer : ( input : UpdatePeerInput ) => Promise < UpdatePeerMutationResponse >
86
+ deletePeer : ( peerId : string ) => Promise < DeletePeerMutationResponse >
82
87
} {
83
88
return {
84
89
createAsset : ( code , scale , liquidityThreshold ) =>
@@ -129,7 +134,10 @@ export function createRequesters(
129
134
getAssetByCodeAndScale ( apolloClient , code , scale ) ,
130
135
getWalletAddressByURL : ( url ) => getWalletAddressByURL ( apolloClient , url ) ,
131
136
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 )
133
141
}
134
142
}
135
143
@@ -280,6 +288,62 @@ export async function createPeer(
280
288
} )
281
289
}
282
290
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
+
283
347
export async function createAutoPeer (
284
348
apolloClient : ApolloClient < NormalizedCacheObject > ,
285
349
logger : Logger ,
0 commit comments