Skip to content

Commit

Permalink
Merge pull request #244 from berendsliedrecht/genesis-cache-js
Browse files Browse the repository at this point in the history
genesis cache js
  • Loading branch information
swcurran authored Dec 12, 2023
2 parents a914ef4 + 9695a17 commit f70a6d8
Show file tree
Hide file tree
Showing 12 changed files with 37 additions and 12 deletions.
10 changes: 6 additions & 4 deletions libindy_vdr/include/libindy_vdr.h
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

/* Generated with cbindgen:0.24.5 */
/* Generated with cbindgen:0.26.0 */

/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */

Expand All @@ -25,15 +25,15 @@
*/
#define CERT_DID_SOV 1

#define DEFAULT_ACK_TIMEOUT 20
#define DEFAULT_ACK_TIMEOUT 5

#define DEFAULT_CONN_ACTIVE_TIMEOUT 5

#define DEFAULT_CONN_REQUEST_LIMIT 5
#define DEFAULT_CONN_REQUEST_LIMIT 10

#define DEFAULT_FRESHNESS_TIMEOUT 300

#define DEFAULT_REPLY_TIMEOUT 60
#define DEFAULT_REPLY_TIMEOUT 30

#define DEFAULT_REQUEST_READ_NODES 2

Expand Down Expand Up @@ -479,6 +479,8 @@ ErrorCode indy_vdr_resolve(PoolHandle pool_handle,
void (*cb)(int64_t cb_id, ErrorCode err, const char *response),
int64_t cb_id);

ErrorCode indy_vdr_set_cache_directory(FfiStr path);

ErrorCode indy_vdr_set_config(FfiStr config);

ErrorCode indy_vdr_set_default_logger(void);
Expand Down
5 changes: 5 additions & 0 deletions wrappers/javascript/indy-vdr-nodejs/src/NodeJSIndyVdr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,11 @@ export class NodeJSIndyVdr implements IndyVdr {
this.handleError(this.nativeIndyVdr.indy_vdr_set_config(config))
}

public setCacheDirectory(options: { path: string }): void {
const { path } = serializeArguments(options)
this.handleError(this.nativeIndyVdr.indy_vdr_set_cache_directory(path))
}

public setDefaultLogger(): void {
this.handleError(this.nativeIndyVdr.indy_vdr_set_default_logger())
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import type { ByteBuffer } from '../ffi'

export interface NativeMethods {
indy_vdr_set_config: (arg0: string) => number
indy_vdr_set_cache_directory: (arg0: string) => number
indy_vdr_set_default_logger: () => number
indy_vdr_set_protocol_version: (arg0: number) => number
indy_vdr_set_socks_proxy: (arg0: string) => number
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ FunctionMap IndyVdrTurboModuleHostObject::functionMapping(jsi::Runtime &rt) {
fMap.insert(std::make_pair("version", &indyVdr::version));
fMap.insert(std::make_tuple("getCurrentError", &indyVdr::getCurrentError));
fMap.insert(std::make_tuple("setConfig", &indyVdr::setConfig));
fMap.insert(std::make_tuple("setCacheDirectory", &indyVdr::setCacheDirectory));
fMap.insert(std::make_tuple("setDefaultLogger", &indyVdr::setDefaultLogger));
fMap.insert(
std::make_tuple("setProtocolVersion", &indyVdr::setProtocolVersion));
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#pragma once

/* Generated with cbindgen:0.24.5 */
/* Generated with cbindgen:0.26.0 */

/* Warning, this file is autogenerated by cbindgen. Don't modify this manually. */

Expand All @@ -25,15 +25,15 @@
*/
#define CERT_DID_SOV 1

#define DEFAULT_ACK_TIMEOUT 20
#define DEFAULT_ACK_TIMEOUT 5

#define DEFAULT_CONN_ACTIVE_TIMEOUT 5

#define DEFAULT_CONN_REQUEST_LIMIT 5
#define DEFAULT_CONN_REQUEST_LIMIT 10

#define DEFAULT_FRESHNESS_TIMEOUT 300

#define DEFAULT_REPLY_TIMEOUT 60
#define DEFAULT_REPLY_TIMEOUT 30

#define DEFAULT_REQUEST_READ_NODES 2

Expand Down Expand Up @@ -479,6 +479,8 @@ ErrorCode indy_vdr_resolve(PoolHandle pool_handle,
void (*cb)(int64_t cb_id, ErrorCode err, const char *response),
int64_t cb_id);

ErrorCode indy_vdr_set_cache_directory(FfiStr path);

ErrorCode indy_vdr_set_config(FfiStr config);

ErrorCode indy_vdr_set_default_logger(void);
Expand Down
8 changes: 8 additions & 0 deletions wrappers/javascript/indy-vdr-react-native/cpp/indyVdr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,14 @@ jsi::Value setConfig(jsi::Runtime &rt, jsi::Object options) {
return createReturnValue(rt, code, nullptr);
};

jsi::Value setCacheDirectory(jsi::Runtime &rt, jsi::Object options) {
auto path = jsiToValue<std::string>(rt, options, "path");

ErrorCode code = indy_vdr_set_cache_directory(path.c_str());

return createReturnValue(rt, code, nullptr);
};

jsi::Value setDefaultLogger(jsi::Runtime &rt, jsi::Object options) {
ErrorCode code = indy_vdr_set_default_logger();

Expand Down
1 change: 1 addition & 0 deletions wrappers/javascript/indy-vdr-react-native/cpp/indyVdr.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ namespace indyVdr {
jsi::Value version(jsi::Runtime &rt, jsi::Object options);
jsi::Value getCurrentError(jsi::Runtime &rt, jsi::Object options);
jsi::Value setConfig(jsi::Runtime &rt, jsi::Object options);
jsi::Value setCacheDirectory(jsi::Runtime &rt, jsi::Object options);
jsi::Value setDefaultLogger(jsi::Runtime &rt, jsi::Object options);
jsi::Value setProtocolVersion(jsi::Runtime &rt, jsi::Object options);
jsi::Value setSocksProxy(jsi::Runtime &rt, jsi::Object options);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ export interface NativeBindings {

setConfig(options: { config: string }): ReturnObject<never>

setCacheDirectory(options: { path: string }): ReturnObject<never>

setDefaultLogger(options: Record<string, never>): ReturnObject<never>

setProtocolVersion(options: { version: number }): ReturnObject<never>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ export class ReactNativeIndyVdr implements IndyVdr {
this.indyVdr.setConfig(serializedOptions)
}

public setCacheDirectory(options: { path: string }): void {
const serializedOptions = serializeArguments(options)
this.indyVdr.setCacheDirectory(serializedOptions)
}

public setDefaultLogger(): void {
this.handleError(this.indyVdr.setDefaultLogger({}))
}
Expand Down
2 changes: 2 additions & 0 deletions wrappers/javascript/indy-vdr-shared/src/types/IndyVdr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ export interface IndyVdr {

setConfig(options: { config: Record<string, unknown> }): void

setCacheDirectory(options: { path: string }): void

setDefaultLogger(): void

setProtocolVersion(options: { version: number }): void
Expand Down
3 changes: 0 additions & 3 deletions wrappers/javascript/indy-vdr-shared/src/types/Utility.ts

This file was deleted.

1 change: 0 additions & 1 deletion wrappers/javascript/indy-vdr-shared/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
export * from './builderTypes'
export * from './IndyVdr'
export * from './types'
export * from './Utility'

0 comments on commit f70a6d8

Please sign in to comment.