Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(rn): do not try to deserialize again if it is a stream #234

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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