Skip to content

Commit

Permalink
fix: add PSET creation
Browse files Browse the repository at this point in the history
Signed-off-by: Luca Vaccaro <[email protected]>
  • Loading branch information
lvaccaro committed Jan 10, 2025
1 parent d22ddef commit c3e8a80
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 0 deletions.
11 changes: 11 additions & 0 deletions android/src/main/java/io/lwkrn/LwkRnModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,17 @@ class LwkRnModule(reactContext: ReactApplicationContext) :

/* Pset */

@ReactMethod
fun createPset(base64: String, result: Promise) {
try {
val id = randomId()
_psets[id] = Pset(base64)
result.resolve(id)
} catch (error: Throwable) {
result.reject("Pset createPset error", error.localizedMessage, error)
}
}

@ReactMethod
fun psetAsString(psetId: String, result: Promise) {
try {
Expand Down
5 changes: 5 additions & 0 deletions ios/LwkRnModule.mm
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ @interface RCT_EXTERN_MODULE(LwkRnModule, NSObject)
)

/** Pset Methods */
RCT_EXTERN_METHOD(
createPset: (nonnull NSString)base64
resolve: (RCTPromiseResolveBlock)resolve
reject:(RCTPromiseRejectBlock)reject
)
RCT_EXTERN_METHOD(
psetAsString: (nonnull NSString)psetId
resolve: (RCTPromiseResolveBlock)resolve
Expand Down
14 changes: 14 additions & 0 deletions ios/LwkRnModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,20 @@ class LwkRnModule: NSObject {

/* Pset */
@objc
func createPset(_
base64: String,
resolve: RCTPromiseResolveBlock,
reject: RCTPromiseRejectBlock
) -> Void {
do {
let id = randomId()
_psets[id] = try Pset(base64: base64)
resolve(id)
} catch {
reject("Pset createPset error", error.localizedDescription, error)
}
}
@objc
func psetAsString(_
psetId: String,
resolve: RCTPromiseResolveBlock,
Expand Down
1 change: 1 addition & 0 deletions src/classes/NativeLoader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ export interface NativeLwk {
txAsString(txId: string): string;

// Pset
createPset(base64: string): string;
psetAsString(psetId: string): string;
psetExtractTx(psetId: string): string;
psetIssuanceAsset(id: string, index: number): string;
Expand Down
5 changes: 5 additions & 0 deletions src/classes/Pset.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ export class Pset extends NativeLoader {
return this;
}

async create(base64: string): Promise<Pset> {
this.id = await this._lwk.createPset(base64);
return this;
}

async extractTx(): Promise<Transaction> {
let id = await this._lwk.psetExtractTx(this.id);
return new Transaction().from(id);
Expand Down

0 comments on commit c3e8a80

Please sign in to comment.