Skip to content

Commit

Permalink
fix(rn): do not try to deserialize again if it is a stream (#234)
Browse files Browse the repository at this point in the history
  • Loading branch information
berendsliedrecht authored Nov 1, 2023
1 parent aa7645b commit c1678df
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { Callback, CallbackWithResponse, ReturnObject } from './serialize'
import type { Transactions } from '@hyperledger/indy-vdr-shared'

export type PoolHandle = number
export type RequestHandle = number
Expand Down Expand Up @@ -127,7 +128,7 @@ export interface NativeBindings {

poolGetStatus(options: { poolHandle: PoolHandle; cb: CallbackWithResponse<string> }): ReturnObject<never>

poolGetTransactions(options: { poolHandle: PoolHandle; cb: CallbackWithResponse<string> }): ReturnObject<never>
poolGetTransactions(options: { poolHandle: PoolHandle; cb: CallbackWithResponse<Transactions> }): ReturnObject<never>

poolGetVerifiers(options: { poolHandle: PoolHandle; cb: CallbackWithResponse<string> }): ReturnObject<never>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ export class ReactNativeIndyVdr implements IndyVdr {
isStream = false
): Promise<Return | null> => {
return new Promise((resolve, reject) => {
const _cb: CallbackWithResponse = ({ value, errorCode }) => {
const cb: CallbackWithResponse = ({ value, errorCode }) => {
if (errorCode !== 0) reject(new IndyVdrError(JSON.parse(this.getCurrentError()) as IndyVdrErrorObject))

// this is required to add array brackets, and commas, to an invalid json object that
Expand All @@ -89,7 +89,7 @@ export class ReactNativeIndyVdr implements IndyVdr {
}
}

method(_cb)
method(cb)
})
}

Expand Down Expand Up @@ -255,10 +255,10 @@ export class ReactNativeIndyVdr implements IndyVdr {
public async poolGetTransactions(options: { poolHandle: PoolHandle }): Promise<Transactions> {
const { poolHandle } = serializeArguments(options)
const result = handleInvalidNullResponse(
await this.promisifyWithResponse<string>((cb) => this.indyVdr.poolGetTransactions({ cb, poolHandle }), true)
await this.promisifyWithResponse<Transactions>((cb) => this.indyVdr.poolGetTransactions({ cb, poolHandle }), true)
)

return JSON.parse(result) as Transactions
return result
}

public async poolGetVerifiers(options: { poolHandle: PoolHandle }): Promise<Verifiers> {
Expand Down

0 comments on commit c1678df

Please sign in to comment.