From 259ebef971af9226f927dbdefaf59b0d503c08bd Mon Sep 17 00:00:00 2001 From: ekzyis Date: Tue, 16 Jul 2024 14:17:38 +0200 Subject: [PATCH] Fix generateMutation * remove resolverName property from wallet defs * move function into lib/wallet * use function in generateMutation on client to fix wrongly generated mutation --- api/resolvers/wallet.js | 7 +------ api/typeDefs/wallet.js | 3 ++- lib/wallet.js | 5 +++++ wallets/cln/server.js | 1 - wallets/index.js | 5 ++++- wallets/lightning-address/server.js | 1 - wallets/lnd/server.js | 1 - 7 files changed, 12 insertions(+), 11 deletions(-) diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js index 7af04f4e..dd1d8847 100644 --- a/api/resolvers/wallet.js +++ b/api/resolvers/wallet.js @@ -16,15 +16,10 @@ import { checkInvoice } from 'worker/wallet' import * as lnd from 'wallets/lnd' import * as lnAddr from 'wallets/lightning-address' import * as cln from 'wallets/cln' -import { fetchLnAddrInvoice } from '@/lib/wallet' +import { fetchLnAddrInvoice, generateResolverName } from '@/lib/wallet' export const SERVER_WALLET_DEFS = [lnd, lnAddr, cln] -export function generateResolverName (walletField) { - const capitalized = walletField[0].toUpperCase() + walletField.slice(1) - return `upsertWallet${capitalized}` -} - function injectResolvers (resolvers) { console.group('injected GraphQL resolvers:') for ( diff --git a/api/typeDefs/wallet.js b/api/typeDefs/wallet.js index 78f104c0..50769b06 100644 --- a/api/typeDefs/wallet.js +++ b/api/typeDefs/wallet.js @@ -1,5 +1,6 @@ import { gql } from 'graphql-tag' -import { SERVER_WALLET_DEFS, generateResolverName } from '@/api/resolvers/wallet' +import { SERVER_WALLET_DEFS } from '@/api/resolvers/wallet' +import { generateResolverName } from '@/lib/wallet' function injectTypeDefs (typeDefs) { console.group('injected GraphQL type defs:') diff --git a/lib/wallet.js b/lib/wallet.js index 6b872cc3..fba35541 100644 --- a/lib/wallet.js +++ b/lib/wallet.js @@ -60,3 +60,8 @@ export async function fetchLnAddrInvoice ({ addr, amount, maxFee, comment, ...pa return res } + +export function generateResolverName (walletField) { + const capitalized = walletField[0].toUpperCase() + walletField.slice(1) + return `upsertWallet${capitalized}` +} diff --git a/wallets/cln/server.js b/wallets/cln/server.js index eb2bb676..64fe379b 100644 --- a/wallets/cln/server.js +++ b/wallets/cln/server.js @@ -3,7 +3,6 @@ import { ensureB64 } from '@/lib/format' export const server = { walletType: 'CLN', walletField: 'walletCLN', - resolverName: 'upsertWalletCLN', testConnect: async ( { socket, rune, cert }, { me, models, addWalletLog, cln: { createInvoice } } diff --git a/wallets/index.js b/wallets/index.js index ca9e4762..05c6ca65 100644 --- a/wallets/index.js +++ b/wallets/index.js @@ -16,6 +16,7 @@ import { REMOVE_WALLET, WALLET_BY_TYPE } from '@/fragments/wallet' import { autowithdrawInitial } from '@/components/autowithdraw-shared' import { useShowModal } from '@/components/modal' import { useToast } from '../components/toast' +import { generateResolverName } from '@/lib/wallet' // wallet definitions export const WALLET_DEFS = [lnbits, nwc, lnc, lnd, lnAddr, cln] @@ -224,7 +225,9 @@ function useServerConfig (wallet) { } function generateMutation (wallet) { - const { resolverName } = wallet.server + const { walletField } = wallet.server + + const resolverName = generateResolverName(walletField) let headerArgs = '$id: ID, ' headerArgs += wallet.fields.map(f => { diff --git a/wallets/lightning-address/server.js b/wallets/lightning-address/server.js index da8de66e..b06099cf 100644 --- a/wallets/lightning-address/server.js +++ b/wallets/lightning-address/server.js @@ -4,7 +4,6 @@ import { fetchLnAddrInvoice } from '@/lib/wallet' export const server = { walletType: 'LIGHTNING_ADDRESS', walletField: 'walletLightningAddress', - resolverName: 'upsertWalletLNAddr', testConnect: async ( { address }, { me, models, addWalletLog } diff --git a/wallets/lnd/server.js b/wallets/lnd/server.js index 0233a9b5..9ba31a41 100644 --- a/wallets/lnd/server.js +++ b/wallets/lnd/server.js @@ -4,7 +4,6 @@ import { datePivot } from '@/lib/time' export const server = { walletType: 'LND', walletField: 'walletLND', - resolverName: 'upsertWalletLND', testConnect: async ( { cert, macaroon, socket }, { me, models, addWalletLog, lnService: { authenticatedLndGrpc, createInvoice } }