diff --git a/api/resolvers/wallet.js b/api/resolvers/wallet.js
index c73e0dc7..dfec9a62 100644
--- a/api/resolvers/wallet.js
+++ b/api/resolvers/wallet.js
@@ -627,7 +627,7 @@ async function upsertWallet (
}
const { id, ...walletData } = data
- const { autoWithdrawThreshold, autoWithdrawMaxFeePercent, priority } = settings
+ const { autoWithdrawThreshold, autoWithdrawMaxFeePercent, enabled, priority } = settings
const txs = [
models.user.update({
@@ -639,24 +639,13 @@ async function upsertWallet (
})
]
- if (priority) {
- txs.push(
- models.wallet.updateMany({
- where: {
- userId: me.id
- },
- data: {
- priority: 0
- }
- }))
- }
-
if (id) {
txs.push(
models.wallet.update({
where: { id: Number(id), userId: me.id },
data: {
- priority: priority ? 1 : 0,
+ enabled,
+ priority,
[wallet.field]: {
update: {
where: { walletId: Number(id) },
@@ -670,7 +659,8 @@ async function upsertWallet (
txs.push(
models.wallet.create({
data: {
- priority: Number(priority),
+ enabled,
+ priority,
userId: me.id,
type: wallet.type,
[wallet.field]: {
@@ -694,8 +684,8 @@ async function upsertWallet (
data: {
userId: me.id,
wallet: wallet.type,
- level: priority ? 'SUCCESS' : 'INFO',
- message: priority ? 'wallet enabled' : 'wallet disabled'
+ level: enabled ? 'SUCCESS' : 'INFO',
+ message: enabled ? 'wallet enabled' : 'wallet disabled'
}
})
)
diff --git a/api/typeDefs/wallet.js b/api/typeDefs/wallet.js
index faedb976..00fe0cc5 100644
--- a/api/typeDefs/wallet.js
+++ b/api/typeDefs/wallet.js
@@ -30,7 +30,8 @@ export default gql`
id: ID!
createdAt: Date!
type: String!
- priority: Boolean!
+ enabled: Boolean!
+ priority: Int!
wallet: WalletDetails!
}
@@ -55,7 +56,8 @@ export default gql`
input AutowithdrawSettings {
autoWithdrawThreshold: Int!
autoWithdrawMaxFeePercent: Float!
- priority: Boolean!
+ priority: Int
+ enabled: Boolean
}
type Invoice {
diff --git a/components/autowithdraw-shared.js b/components/autowithdraw-shared.js
index d5c844fd..e5f28244 100644
--- a/components/autowithdraw-shared.js
+++ b/components/autowithdraw-shared.js
@@ -8,9 +8,8 @@ function autoWithdrawThreshold ({ me }) {
return isNumber(me?.privates?.autoWithdrawThreshold) ? me?.privates?.autoWithdrawThreshold : 10000
}
-export function autowithdrawInitial ({ me, priority = false }) {
+export function autowithdrawInitial ({ me }) {
return {
- priority,
autoWithdrawThreshold: autoWithdrawThreshold({ me }),
autoWithdrawMaxFeePercent: isNumber(me?.privates?.autoWithdrawMaxFeePercent) ? me?.privates?.autoWithdrawMaxFeePercent : 1
}
@@ -31,8 +30,8 @@ export function AutowithdrawSettings ({ wallet }) {