Skip to content

Commit 2cb40db

Browse files
committed
GraphQL code for Spark
1 parent cb74f0f commit 2cb40db

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
@@ -119,6 +119,16 @@ const typeDefs = gql`
119119
noffer: String!
120120
): WalletRecvClink!
121121
122+
upsertWalletSendSpark(
123+
${shared},
124+
mnemonic: VaultEntryInput!
125+
): WalletSendSpark!
126+
127+
upsertWalletRecvSpark(
128+
${shared},
129+
address: String!
130+
): WalletRecvSpark!
131+
122132
# tests
123133
testWalletRecvNWC(
124134
url: String!
@@ -159,6 +169,10 @@ const typeDefs = gql`
159169
noffer: String!
160170
): Boolean!
161171
172+
testWalletRecvSpark(
173+
address: String!
174+
): Boolean!
175+
162176
# delete
163177
deleteWallet(id: ID!): Boolean
164178
@@ -235,6 +249,7 @@ const typeDefs = gql`
235249
| WalletSendLNC
236250
| WalletSendCLNRest
237251
| WalletSendClink
252+
| WalletSendSpark
238253
| WalletRecvNWC
239254
| WalletRecvLNbits
240255
| WalletRecvPhoenixd
@@ -243,6 +258,7 @@ const typeDefs = gql`
243258
| WalletRecvCLNRest
244259
| WalletRecvLNDGRPC
245260
| WalletRecvClink
261+
| WalletRecvSpark
246262
247263
type WalletSettings {
248264
receiveCreditsBelowSats: Int!
@@ -309,6 +325,11 @@ const typeDefs = gql`
309325
secretKey: VaultEntry!
310326
}
311327
328+
type WalletSendSpark {
329+
id: ID!
330+
mnemonic: VaultEntry!
331+
}
332+
312333
type WalletRecvNWC {
313334
id: ID!
314335
url: String!
@@ -356,6 +377,11 @@ const typeDefs = gql`
356377
noffer: String!
357378
}
358379
380+
type WalletRecvSpark {
381+
id: ID!
382+
address: String!
383+
}
384+
359385
input AutowithdrawSettings {
360386
autoWithdrawThreshold: Int!
361387
autoWithdrawMaxFeePercent: Float!

wallets/client/fragments/protocol.js

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,34 @@ export const UPSERT_WALLET_RECEIVE_CLINK = gql`
265265
}
266266
`
267267

268+
export const UPSERT_WALLET_SEND_SPARK = gql`
269+
mutation upsertWalletSendSpark(
270+
${shared.variables},
271+
$mnemonic: VaultEntryInput!
272+
) {
273+
upsertWalletSendSpark(
274+
${shared.arguments},
275+
mnemonic: $mnemonic
276+
) {
277+
id
278+
}
279+
}
280+
`
281+
282+
export const UPSERT_WALLET_RECEIVE_SPARK = gql`
283+
mutation upsertWalletRecvSpark(
284+
${shared.variables},
285+
$address: String!
286+
) {
287+
upsertWalletRecvSpark(
288+
${shared.arguments},
289+
address: $address
290+
) {
291+
id
292+
}
293+
}
294+
`
295+
268296
// tests
269297

270298
export const TEST_WALLET_RECEIVE_NWC = gql`
@@ -314,3 +342,9 @@ export const TEST_WALLET_RECEIVE_CLINK = gql`
314342
testWalletRecvClink(noffer: $noffer)
315343
}
316344
`
345+
346+
export const TEST_WALLET_RECEIVE_SPARK = gql`
347+
mutation testWalletRecvSpark($address: String!) {
348+
testWalletRecvSpark(address: $address)
349+
}
350+
`

wallets/client/fragments/wallet.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,12 @@ const WALLET_PROTOCOL_FIELDS = gql`
8787
...VaultEntryFields
8888
}
8989
}
90+
... on WalletSendSpark {
91+
id
92+
encryptedMnemonic: mnemonic {
93+
...VaultEntryFields
94+
}
95+
}
9096
... on WalletRecvNWC {
9197
id
9298
url
@@ -126,6 +132,10 @@ const WALLET_PROTOCOL_FIELDS = gql`
126132
id
127133
noffer
128134
}
135+
... on WalletRecvSpark {
136+
id
137+
address
138+
}
129139
}
130140
}
131141
`

wallets/client/hooks/query.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ 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,
@@ -21,6 +22,7 @@ import {
2122
UPSERT_WALLET_SEND_WEBLN,
2223
UPSERT_WALLET_SEND_CLN_REST,
2324
UPSERT_WALLET_SEND_CLINK,
25+
UPSERT_WALLET_SEND_SPARK,
2426
WALLETS,
2527
UPDATE_WALLET_ENCRYPTION,
2628
RESET_WALLETS,
@@ -35,6 +37,7 @@ import {
3537
TEST_WALLET_RECEIVE_CLN_REST,
3638
TEST_WALLET_RECEIVE_LND_GRPC,
3739
TEST_WALLET_RECEIVE_CLINK,
40+
TEST_WALLET_RECEIVE_SPARK,
3841
DELETE_WALLET
3942
} from '@/wallets/client/fragments'
4043
import { gql, useApolloClient, useMutation, useQuery } from '@apollo/client'
@@ -321,6 +324,8 @@ function protocolUpsertMutation (protocol) {
321324
return protocol.send ? UPSERT_WALLET_SEND_WEBLN : NOOP_MUTATION
322325
case 'CLINK':
323326
return protocol.send ? UPSERT_WALLET_SEND_CLINK : UPSERT_WALLET_RECEIVE_CLINK
327+
case 'SPARK':
328+
return protocol.send ? UPSERT_WALLET_SEND_SPARK : UPSERT_WALLET_RECEIVE_SPARK
324329
default:
325330
return NOOP_MUTATION
326331
}
@@ -346,6 +351,8 @@ function protocolTestMutation (protocol) {
346351
return TEST_WALLET_RECEIVE_LND_GRPC
347352
case 'CLINK':
348353
return TEST_WALLET_RECEIVE_CLINK
354+
case 'SPARK':
355+
return TEST_WALLET_RECEIVE_SPARK
349356
default:
350357
return NOOP_MUTATION
351358
}

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 send ? 'WalletSendClink' : 'WalletRecvClink'
24+
case 'SPARK':
25+
return send ? 'WalletSendSpark' : 'WalletRecvSpark'
2426
default:
2527
return null
2628
}

0 commit comments

Comments
 (0)