Skip to content

Commit

Permalink
fix: update spendNotes return type (#58)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexlwn123 authored Oct 1, 2024
1 parent 242fbf7 commit 0eced7f
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 7 deletions.
27 changes: 20 additions & 7 deletions packages/core-web/src/services/MintService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import {
Duration,
JSONObject,
JSONValue,
MintSpendNotesResponse,
ReissueExternalNotesState,
} from '../types/wallet'

Expand Down Expand Up @@ -51,18 +52,30 @@ export class MintService {
tryCancelAfter: number | Duration = 0,
includeInvite: boolean = false,
extraMeta: JSONValue = {},
): Promise<JSONValue> {
): Promise<MintSpendNotesResponse> {
const duration =
typeof tryCancelAfter === 'number'
? { nanos: 0, secs: tryCancelAfter }
: tryCancelAfter

return await this.client.rpcSingle('mint', 'spend_notes', {
min_amount: minAmount,
try_cancel_after: duration,
include_invite: includeInvite,
extra_meta: extraMeta,
})
const res = await this.client.rpcSingle<Array<string>>(
'mint',
'spend_notes',
{
min_amount: minAmount,
try_cancel_after: duration,
include_invite: includeInvite,
extra_meta: extraMeta,
},
)
console.error('res', res)
const notes = res[1]
const operationId = res[0]

return {
notes,
operation_id: operationId,
}
}

async validateNotes(oobNotes: string): Promise<number> {
Expand Down
6 changes: 6 additions & 0 deletions packages/core-web/src/types/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,11 @@ type Duration = {
secs: number
}

type MintSpendNotesResponse = {
notes: string
operation_id: string
}

export {
JSONValue,
JSONObject,
Expand All @@ -124,4 +129,5 @@ export {
CancelFunction,
ReissueExternalNotesState,
Duration,
MintSpendNotesResponse,
}

0 comments on commit 0eced7f

Please sign in to comment.