mirror of
https://github.com/minibits-cash/minibits_wallet.git
synced 2026-10-06 03:38:24 +00:00
Extend mint model with input_fee_ppk
This commit is contained in:
+4
-1
@@ -43,6 +43,7 @@ export type MintProofsCounter = {
|
||||
keyset: string
|
||||
counter: number
|
||||
unit: MintUnit
|
||||
input_fee_ppk: number
|
||||
inFlightFrom?: number // starting counter index for pending split request sent to mint (for recovery from failure to receive proofs)
|
||||
inFlightTo?: number // last counter index for pending split request sent to mint
|
||||
inFlightTid?: number // related tx id
|
||||
@@ -63,6 +64,7 @@ export const MintModel = types
|
||||
keyset: types.string,
|
||||
unit: types.optional(types.frozen<MintUnit>(), 'sat'),
|
||||
counter: types.number,
|
||||
input_fee_ppk: types.optional(types.number, 0),
|
||||
inFlightFrom: types.maybe(types.number),
|
||||
inFlightTo: types.maybe(types.number),
|
||||
inFlightTid: types.maybe(types.number)
|
||||
@@ -94,7 +96,7 @@ export const MintModel = types
|
||||
},
|
||||
}))
|
||||
.actions(self => ({
|
||||
getOrCreateProofsCounter(keysetId: string, unit?: MintUnit) {
|
||||
getOrCreateProofsCounter(keysetId: string, unit?: MintUnit, input_fee_ppk?: number) {
|
||||
log.trace('[getOrCreateProofsCounter]', keysetId, unit)
|
||||
const counter = self.proofsCounters.find(c => c.keyset === keysetId)
|
||||
|
||||
@@ -107,6 +109,7 @@ export const MintModel = types
|
||||
keyset: keysetId,
|
||||
unit,
|
||||
counter: 0,
|
||||
input_fee_ppk: input_fee_ppk || 0,
|
||||
}
|
||||
|
||||
self.proofsCounters.push(newCounter)
|
||||
|
||||
@@ -45,7 +45,8 @@ import { MintUnit, MintUnits } from '../services/wallet/currency'
|
||||
}
|
||||
|
||||
// create default wallet instance then download and cache up to date mint keys in that instance
|
||||
const activeKeysets: MintKeyset[] = yield MintClient.getMintKeysets(mintUrl)
|
||||
const allKeysets: MintKeyset[] = yield MintClient.getMintKeysets(mintUrl)
|
||||
const activeKeysets = allKeysets.filter(keyset => keyset.active === true)
|
||||
|
||||
if(!activeKeysets || activeKeysets.length === 0) {
|
||||
throw new AppError(Err.VALIDATION_ERROR, 'Mint has no active keysets and is not operational', {mintUrl})
|
||||
@@ -69,7 +70,7 @@ import { MintUnit, MintUnits } from '../services/wallet/currency'
|
||||
}
|
||||
|
||||
mintInstance.addUnit(keyset.unit as MintUnit) // add supported units by mint
|
||||
mintInstance.getOrCreateProofsCounter(keyset.id, keyset.unit as MintUnit) // create proofsCounters
|
||||
mintInstance.getOrCreateProofsCounter(keyset.id, keyset.unit as MintUnit, keyset.input_fee_ppk || 0) // create proofsCounters
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +101,7 @@ import { MintUnit, MintUnits } from '../services/wallet/currency'
|
||||
}
|
||||
|
||||
mintInstance.addUnit(keyset.unit as MintUnit) // add supported units by mint if not yet exist
|
||||
mintInstance.getOrCreateProofsCounter(keyset.id, keyset.unit as MintUnit) // create proofsCounters if not yet exist
|
||||
mintInstance.getOrCreateProofsCounter(keyset.id, keyset.unit as MintUnit, keyset.input_fee_ppk || 0) // create proofsCounters if not yet exist
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user