Skip to content
This repository has been archived by the owner on Feb 1, 2024. It is now read-only.

Commit

Permalink
feat: add generate wallet key method (#50)
Browse files Browse the repository at this point in the history
Signed-off-by: Timo Glastra <[email protected]>
  • Loading branch information
TimoGlastra authored Jul 3, 2022
1 parent bfc645b commit c130ae2
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 2 deletions.
11 changes: 11 additions & 0 deletions android/src/main/java/com/reactlibrary/IndySdkModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -1011,6 +1011,17 @@ public void generateNonce(Promise promise) {
}
}

@ReactMethod
public void generateWalletKey(String configJson, Promise promise) {
try {
String walletKey = Wallet.generateWalletKey(configJson).get();
promise.resolve(walletKey);
} catch (Exception e) {
IndySdkRejectResponse rejectResponse = new IndySdkRejectResponse(e);
promise.reject(rejectResponse.getCode(), rejectResponse.toJson(), e);
}
}

@ReactMethod
public void createRevocationState(
int blobStorageReaderHandle,
Expand Down
4 changes: 4 additions & 0 deletions ios/IndySdk.m
Original file line number Diff line number Diff line change
Expand Up @@ -306,6 +306,10 @@ @interface RCT_EXTERN_MODULE(IndySdk, NSObject)
RCT_EXTERN_METHOD(generateNonce: (RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(generateWalletKey: (NSString *) configJson
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)

RCT_EXTERN_METHOD(createRevocationState: (nonnull NSNumber *)blobStorageReaderHandle
revRegDef:(NSString *)revRegDef
revRegDelta:(NSString *)revRegDelta
Expand Down
10 changes: 8 additions & 2 deletions ios/IndySdk.swift
Original file line number Diff line number Diff line change
Expand Up @@ -507,11 +507,17 @@ class IndySdk : NSObject {
)
}

@objc func generateNonce(_ resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock) {
@objc func generateNonce(_ resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock) {
IndyAnoncreds.generateNonce(completionWithString(resolve, reject));
}

@objc func generateWalletKey(_ configJson: String,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock) {
IndyWallet.generateKey(forConfig: configJson, completion: completionWithString(resolve, reject));
}

@objc func createRevocationState(_ blobStorageReaderHandle: NSNumber, revRegDef: String, revRegDelta: String, timestamp: NSNumber, credRevId: String,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock) -> Void {
Expand Down
4 changes: 4 additions & 0 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -750,6 +750,10 @@ const indy = {
return IndySdk.generateNonce()
},

async generateWalletKey(config?: { seed?: string } = {}) {
return IndySdk.generateWalletKey(JSON.stringify(config))
},

async appendTxnAuthorAgreementAcceptanceToRequest(
request: LedgerRequest,
text: string,
Expand Down

0 comments on commit c130ae2

Please sign in to comment.