Skip to content

Commit e3ca81b

Browse files
committed
GraphQL code for Spark
1 parent 67b3268 commit e3ca81b

File tree

5 files changed

+79
-0
lines changed

5 files changed

+79
-0
lines changed

api/typeDefs/wallet.js

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,16 @@ const typeDefs = gql`
108108
${shared}
109109
): WalletSendWebLN!
110110
111+
upsertWalletSendSpark(
112+
${shared},
113+
mnemonic: VaultEntryInput!
114+
): WalletSendSpark!
115+
116+
upsertWalletRecvSpark(
117+
${shared},
118+
address: String!
119+
): WalletRecvSpark!
120+
111121
upsertWalletRecvClink(
112122
${shared},
113123
noffer: String!
@@ -153,6 +163,10 @@ const typeDefs = gql`
153163
noffer: String!
154164
): Boolean!
155165
166+
testWalletRecvSpark(
167+
address: String!
168+
): Boolean!
169+
156170
# delete
157171
deleteWallet(id: ID!): Boolean
158172
@@ -228,6 +242,7 @@ const typeDefs = gql`
228242
| WalletSendWebLN
229243
| WalletSendLNC
230244
| WalletSendCLNRest
245+
| WalletSendSpark
231246
| WalletRecvNWC
232247
| WalletRecvLNbits
233248
| WalletRecvPhoenixd
@@ -236,6 +251,7 @@ const typeDefs = gql`
236251
| WalletRecvCLNRest
237252
| WalletRecvLNDGRPC
238253
| WalletRecvClink
254+
| WalletRecvSpark
239255
240256
type WalletSettings {
241257
receiveCreditsBelowSats: Int!
@@ -296,6 +312,11 @@ const typeDefs = gql`
296312
rune: VaultEntry!
297313
}
298314
315+
type WalletSendSpark {
316+
id: ID!
317+
mnemonic: VaultEntry!
318+
}
319+
299320
type WalletRecvNWC {
300321
id: ID!
301322
url: String!
@@ -343,6 +364,11 @@ const typeDefs = gql`
343364
noffer: String!
344365
}
345366
367+
type WalletRecvSpark {
368+
id: ID!
369+
address: String!
370+
}
371+
346372
input AutowithdrawSettings {
347373
autoWithdrawThreshold: Int!
348374
autoWithdrawMaxFeePercent: Float!

wallets/client/fragments/protocol.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -249,6 +249,34 @@ export const UPSERT_WALLET_RECEIVE_CLINK = gql`
249249
}
250250
`
251251

252+
export const UPSERT_WALLET_SEND_SPARK = gql`
253+
mutation upsertWalletSendSpark(
254+
${shared.variables},
255+
$mnemonic: VaultEntryInput!
256+
) {
257+
upsertWalletSendSpark(
258+
${shared.arguments},
259+
mnemonic: $mnemonic
260+
) {
261+
id
262+
}
263+
}
264+
`
265+
266+
export const UPSERT_WALLET_RECEIVE_SPARK = gql`
267+
mutation upsertWalletRecvSpark(
268+
${shared.variables},
269+
$address: String!
270+
) {
271+
upsertWalletRecvSpark(
272+
${shared.arguments},
273+
address: $address
274+
) {
275+
id
276+
}
277+
}
278+
`
279+
252280
// tests
253281

254282
export const TEST_WALLET_RECEIVE_NWC = gql`
@@ -298,3 +326,9 @@ export const TEST_WALLET_RECEIVE_CLINK = gql`
298326
testWalletRecvClink(noffer: $noffer)
299327
}
300328
`
329+
330+
export const TEST_WALLET_RECEIVE_SPARK = gql`
331+
mutation testWalletRecvSpark($address: String!) {
332+
testWalletRecvSpark(address: $address)
333+
}
334+
`

wallets/client/fragments/wallet.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,12 @@ const WALLET_PROTOCOL_FIELDS = gql`
7878
...VaultEntryFields
7979
}
8080
}
81+
... on WalletSendSpark {
82+
id
83+
encryptedMnemonic: mnemonic {
84+
...VaultEntryFields
85+
}
86+
}
8187
... on WalletRecvNWC {
8288
id
8389
url
@@ -117,6 +123,10 @@ const WALLET_PROTOCOL_FIELDS = gql`
117123
id
118124
noffer
119125
}
126+
... on WalletRecvSpark {
127+
id
128+
address
129+
}
120130
}
121131
}
122132
`

wallets/client/hooks/query.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,15 @@ import {
1313
UPSERT_WALLET_RECEIVE_NWC,
1414
UPSERT_WALLET_RECEIVE_PHOENIXD,
1515
UPSERT_WALLET_RECEIVE_CLINK,
16+
UPSERT_WALLET_RECEIVE_SPARK,
1617
UPSERT_WALLET_SEND_BLINK,
1718
UPSERT_WALLET_SEND_LNBITS,
1819
UPSERT_WALLET_SEND_LNC,
1920
UPSERT_WALLET_SEND_NWC,
2021
UPSERT_WALLET_SEND_PHOENIXD,
2122
UPSERT_WALLET_SEND_WEBLN,
2223
UPSERT_WALLET_SEND_CLN_REST,
24+
UPSERT_WALLET_SEND_SPARK,
2325
WALLETS,
2426
UPDATE_WALLET_ENCRYPTION,
2527
RESET_WALLETS,
@@ -34,6 +36,7 @@ import {
3436
TEST_WALLET_RECEIVE_CLN_REST,
3537
TEST_WALLET_RECEIVE_LND_GRPC,
3638
TEST_WALLET_RECEIVE_CLINK,
39+
TEST_WALLET_RECEIVE_SPARK,
3740
DELETE_WALLET
3841
} from '@/wallets/client/fragments'
3942
import { gql, useApolloClient, useMutation, useQuery } from '@apollo/client'
@@ -320,6 +323,8 @@ function protocolUpsertMutation (protocol) {
320323
return protocol.send ? UPSERT_WALLET_SEND_WEBLN : NOOP_MUTATION
321324
case 'CLINK':
322325
return protocol.send ? NOOP_MUTATION : UPSERT_WALLET_RECEIVE_CLINK
326+
case 'SPARK':
327+
return protocol.send ? UPSERT_WALLET_SEND_SPARK : UPSERT_WALLET_RECEIVE_SPARK
323328
default:
324329
return NOOP_MUTATION
325330
}
@@ -345,6 +350,8 @@ function protocolTestMutation (protocol) {
345350
return TEST_WALLET_RECEIVE_LND_GRPC
346351
case 'CLINK':
347352
return TEST_WALLET_RECEIVE_CLINK
353+
case 'SPARK':
354+
return TEST_WALLET_RECEIVE_SPARK
348355
default:
349356
return NOOP_MUTATION
350357
}

wallets/server/resolvers/util.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ export function mapWalletResolveTypes (wallet) {
2121
return 'WalletRecvLNDGRPC'
2222
case 'CLINK':
2323
return 'WalletRecvClink'
24+
case 'SPARK':
25+
return send ? 'WalletSendSpark' : 'WalletRecvSpark'
2426
default:
2527
return null
2628
}

0 commit comments

Comments
 (0)