diff --git a/android/src/main/java/io/emurgo/rnhaskellshelley/HaskellShelleyModule.java b/android/src/main/java/io/emurgo/rnhaskellshelley/HaskellShelleyModule.java index 5edec59..a5c3b89 100644 --- a/android/src/main/java/io/emurgo/rnhaskellshelley/HaskellShelleyModule.java +++ b/android/src/main/java/io/emurgo/rnhaskellshelley/HaskellShelleyModule.java @@ -4272,6 +4272,28 @@ public final void csl_bridge_fixedTransactionRawAuxiliaryData(String self, Promi .pour(promise); } + @ReactMethod + public final void csl_bridge_fixedTransactionTransactionHash(String self, Promise promise) { + Native.I + .csl_bridge_fixedTransactionTransactionHash(new RPtr(self)) + .map(RPtr::toJs) + .pour(promise); + } + + @ReactMethod + public final void csl_bridge_fixedTransactionAddVkeyWitness(String self, String vkeyWitness, Promise promise) { + Native.I + .csl_bridge_fixedTransactionAddVkeyWitness(new RPtr(self), new RPtr(vkeyWitness)) + .pour(promise); + } + + @ReactMethod + public final void csl_bridge_fixedTransactionAddBootstrapWitness(String self, String bootstrapWitness, Promise promise) { + Native.I + .csl_bridge_fixedTransactionAddBootstrapWitness(new RPtr(self), new RPtr(bootstrapWitness)) + .pour(promise); + } + @ReactMethod public final void csl_bridge_fixedTransactionSignAndAddVkeySignature(String self, String privateKey, Promise promise) { Native.I @@ -4383,6 +4405,45 @@ public final void csl_bridge_fixedTransactionBodyOriginalBytes(String self, Prom } + @ReactMethod + public final void csl_bridge_fixedTxWitnessesSetTxWitnessesSet(String self, Promise promise) { + Native.I + .csl_bridge_fixedTxWitnessesSetTxWitnessesSet(new RPtr(self)) + .map(RPtr::toJs) + .pour(promise); + } + + @ReactMethod + public final void csl_bridge_fixedTxWitnessesSetAddVkeyWitness(String self, String vkeyWitness, Promise promise) { + Native.I + .csl_bridge_fixedTxWitnessesSetAddVkeyWitness(new RPtr(self), new RPtr(vkeyWitness)) + .pour(promise); + } + + @ReactMethod + public final void csl_bridge_fixedTxWitnessesSetAddBootstrapWitness(String self, String bootstrapWitness, Promise promise) { + Native.I + .csl_bridge_fixedTxWitnessesSetAddBootstrapWitness(new RPtr(self), new RPtr(bootstrapWitness)) + .pour(promise); + } + + @ReactMethod + public final void csl_bridge_fixedTxWitnessesSetToBytes(String self, Promise promise) { + Native.I + .csl_bridge_fixedTxWitnessesSetToBytes(new RPtr(self)) + .map(bytes -> Base64.encodeToString(bytes, Base64.DEFAULT)) + .pour(promise); + } + + @ReactMethod + public final void csl_bridge_fixedTxWitnessesSetFromBytes(String data, Promise promise) { + Native.I + .csl_bridge_fixedTxWitnessesSetFromBytes(Base64.decode(data, Base64.DEFAULT)) + .map(RPtr::toJs) + .pour(promise); + } + + @ReactMethod public final void csl_bridge_fixedVersionedBlockFromBytes(String bytes, Promise promise) { Native.I diff --git a/android/src/main/java/io/emurgo/rnhaskellshelley/Native.java b/android/src/main/java/io/emurgo/rnhaskellshelley/Native.java index 3ae92f1..3d3cd12 100644 --- a/android/src/main/java/io/emurgo/rnhaskellshelley/Native.java +++ b/android/src/main/java/io/emurgo/rnhaskellshelley/Native.java @@ -606,6 +606,9 @@ private Native() { } public final native Result csl_bridge_fixedTransactionSetAuxiliaryData(RPtr self, byte[] rawAuxiliaryData); public final native Result csl_bridge_fixedTransactionAuxiliaryData(RPtr self); public final native Result csl_bridge_fixedTransactionRawAuxiliaryData(RPtr self); + public final native Result csl_bridge_fixedTransactionTransactionHash(RPtr self); + public final native Result csl_bridge_fixedTransactionAddVkeyWitness(RPtr self, RPtr vkeyWitness); + public final native Result csl_bridge_fixedTransactionAddBootstrapWitness(RPtr self, RPtr bootstrapWitness); public final native Result csl_bridge_fixedTransactionSignAndAddVkeySignature(RPtr self, RPtr privateKey); public final native Result csl_bridge_fixedTransactionSignAndAddIcarusBootstrapSignature(RPtr self, RPtr addr, RPtr privateKey); public final native Result csl_bridge_fixedTransactionSignAndAddDaedalusBootstrapSignature(RPtr self, RPtr addr, RPtr privateKey); @@ -623,6 +626,12 @@ private Native() { } public final native Result csl_bridge_fixedTransactionBodyTxHash(RPtr self); public final native Result csl_bridge_fixedTransactionBodyOriginalBytes(RPtr self); + public final native Result csl_bridge_fixedTxWitnessesSetTxWitnessesSet(RPtr self); + public final native Result csl_bridge_fixedTxWitnessesSetAddVkeyWitness(RPtr self, RPtr vkeyWitness); + public final native Result csl_bridge_fixedTxWitnessesSetAddBootstrapWitness(RPtr self, RPtr bootstrapWitness); + public final native Result csl_bridge_fixedTxWitnessesSetToBytes(RPtr self); + public final native Result csl_bridge_fixedTxWitnessesSetFromBytes(byte[] data); + public final native Result csl_bridge_fixedVersionedBlockFromBytes(byte[] bytes); public final native Result csl_bridge_fixedVersionedBlockFromHex(String hexStr); public final native Result csl_bridge_fixedVersionedBlockBlock(RPtr self); diff --git a/index.d.ts b/index.d.ts index a0c9df9..46068cd 100644 --- a/index.d.ts +++ b/index.d.ts @@ -3195,6 +3195,21 @@ export class FixedTransaction extends Ptr { */ raw_auxiliary_data: () => Promise>; + /** + * @returns {Promise} + */ + transaction_hash: () => Promise; + + /** + * @param {Vkeywitness} vkey_witness + */ + add_vkey_witness: (vkey_witness: Vkeywitness) => Promise; + + /** + * @param {BootstrapWitness} bootstrap_witness + */ + add_bootstrap_witness: (bootstrap_witness: BootstrapWitness) => Promise; + /** * @param {PrivateKey} private_key * @returns {Promise} @@ -3286,6 +3301,36 @@ export class FixedTransactionBody extends Ptr { } +export class FixedTxWitnessesSet extends Ptr { + /** + * @returns {Promise} + */ + tx_witnesses_set: () => Promise; + + /** + * @param {Vkeywitness} vkey_witness + */ + add_vkey_witness: (vkey_witness: Vkeywitness) => Promise; + + /** + * @param {BootstrapWitness} bootstrap_witness + */ + add_bootstrap_witness: (bootstrap_witness: BootstrapWitness) => Promise; + + /** + * @returns {Promise} + */ + to_bytes: () => Promise; + + /** + * @param {Uint8Array} data + * @returns {Promise} + */ + static from_bytes: (data: Uint8Array) => Promise; + +} + + export class FixedVersionedBlock extends Ptr { /** * @param {Uint8Array} bytes diff --git a/index.js b/index.js index 292354e..9c30d80 100644 --- a/index.js +++ b/index.js @@ -3127,6 +3127,23 @@ export class FixedTransaction extends Ptr { return uint8ArrayFromB64(ret); } + async transaction_hash() { + const ret = await HaskellShelley.csl_bridge_fixedTransactionTransactionHash(this.ptr); + return Ptr._wrap(ret, TransactionHash); + } + + add_vkey_witness(vkey_witness) { + const vkey_witnessPtr = Ptr._assertClass(vkey_witness, Vkeywitness); + const ret = HaskellShelley.csl_bridge_fixedTransactionAddVkeyWitness(this.ptr, vkey_witnessPtr); + return ret; + } + + add_bootstrap_witness(bootstrap_witness) { + const bootstrap_witnessPtr = Ptr._assertClass(bootstrap_witness, BootstrapWitness); + const ret = HaskellShelley.csl_bridge_fixedTransactionAddBootstrapWitness(this.ptr, bootstrap_witnessPtr); + return ret; + } + sign_and_add_vkey_signature(private_key) { const private_keyPtr = Ptr._assertClass(private_key, PrivateKey); const ret = HaskellShelley.csl_bridge_fixedTransactionSignAndAddVkeySignature(this.ptr, private_keyPtr); @@ -3214,6 +3231,37 @@ export class FixedTransactionBody extends Ptr { } +export class FixedTxWitnessesSet extends Ptr { + async tx_witnesses_set() { + const ret = await HaskellShelley.csl_bridge_fixedTxWitnessesSetTxWitnessesSet(this.ptr); + return Ptr._wrap(ret, TransactionWitnessSet); + } + + add_vkey_witness(vkey_witness) { + const vkey_witnessPtr = Ptr._assertClass(vkey_witness, Vkeywitness); + const ret = HaskellShelley.csl_bridge_fixedTxWitnessesSetAddVkeyWitness(this.ptr, vkey_witnessPtr); + return ret; + } + + add_bootstrap_witness(bootstrap_witness) { + const bootstrap_witnessPtr = Ptr._assertClass(bootstrap_witness, BootstrapWitness); + const ret = HaskellShelley.csl_bridge_fixedTxWitnessesSetAddBootstrapWitness(this.ptr, bootstrap_witnessPtr); + return ret; + } + + async to_bytes() { + const ret = await HaskellShelley.csl_bridge_fixedTxWitnessesSetToBytes(this.ptr); + return uint8ArrayFromB64(ret); + } + + static async from_bytes(data) { + const ret = await HaskellShelley.csl_bridge_fixedTxWitnessesSetFromBytes(b64FromUint8Array(data)); + return Ptr._wrap(ret, FixedTxWitnessesSet); + } + +} + + export class FixedVersionedBlock extends Ptr { static async from_bytes(bytes) { const ret = await HaskellShelley.csl_bridge_fixedVersionedBlockFromBytes(b64FromUint8Array(bytes)); diff --git a/ios/HaskellShelley.m b/ios/HaskellShelley.m index 3efd625..4a608f2 100644 --- a/ios/HaskellShelley.m +++ b/ios/HaskellShelley.m @@ -6076,6 +6076,37 @@ + (void)csl_bridge_initialize }] exec:selfPtr andResolve:resolve orReject:reject]; } +RCT_EXPORT_METHOD(csl_bridge_fixedTransactionTransactionHash:(nonnull NSString *)selfPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSString* selfPtr, CharPtr* error) { + RPtr result; + RPtr self = [selfPtr rPtr]; + return csl_bridge_fixed_transaction_transaction_hash(self, &result, error) + ? [NSString stringFromPtr:result] + : nil; + }] exec:selfPtr andResolve:resolve orReject:reject]; +} + +RCT_EXPORT_METHOD(csl_bridge_fixedTransactionAddVkeyWitness:(nonnull NSString *)selfPtr withVkeyWitness:(nonnull NSString *)vkeyWitnessPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSArray* params, CharPtr* error) { + RPtr self = [[params objectAtIndex:0] rPtr]; + RPtr vkeyWitness = [[params objectAtIndex:1] rPtr]; + csl_bridge_fixed_transaction_add_vkey_witness(self, vkeyWitness, error); + return nil; + }] exec:@[selfPtr, vkeyWitnessPtr] andResolve:resolve orReject:reject]; +} + +RCT_EXPORT_METHOD(csl_bridge_fixedTransactionAddBootstrapWitness:(nonnull NSString *)selfPtr withBootstrapWitness:(nonnull NSString *)bootstrapWitnessPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSArray* params, CharPtr* error) { + RPtr self = [[params objectAtIndex:0] rPtr]; + RPtr bootstrapWitness = [[params objectAtIndex:1] rPtr]; + csl_bridge_fixed_transaction_add_bootstrap_witness(self, bootstrapWitness, error); + return nil; + }] exec:@[selfPtr, bootstrapWitnessPtr] andResolve:resolve orReject:reject]; +} + RCT_EXPORT_METHOD(csl_bridge_fixedTransactionSignAndAddVkeySignature:(nonnull NSString *)selfPtr withPrivateKey:(nonnull NSString *)privateKeyPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) { [[CSLCSafeOperation new:^NSString*(NSArray* params, CharPtr* error) { @@ -6231,6 +6262,60 @@ + (void)csl_bridge_initialize } +RCT_EXPORT_METHOD(csl_bridge_fixedTxWitnessesSetTxWitnessesSet:(nonnull NSString *)selfPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSString* selfPtr, CharPtr* error) { + RPtr result; + RPtr self = [selfPtr rPtr]; + return csl_bridge_fixed_tx_witnesses_set_tx_witnesses_set(self, &result, error) + ? [NSString stringFromPtr:result] + : nil; + }] exec:selfPtr andResolve:resolve orReject:reject]; +} + +RCT_EXPORT_METHOD(csl_bridge_fixedTxWitnessesSetAddVkeyWitness:(nonnull NSString *)selfPtr withVkeyWitness:(nonnull NSString *)vkeyWitnessPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSArray* params, CharPtr* error) { + RPtr self = [[params objectAtIndex:0] rPtr]; + RPtr vkeyWitness = [[params objectAtIndex:1] rPtr]; + csl_bridge_fixed_tx_witnesses_set_add_vkey_witness(self, vkeyWitness, error); + return nil; + }] exec:@[selfPtr, vkeyWitnessPtr] andResolve:resolve orReject:reject]; +} + +RCT_EXPORT_METHOD(csl_bridge_fixedTxWitnessesSetAddBootstrapWitness:(nonnull NSString *)selfPtr withBootstrapWitness:(nonnull NSString *)bootstrapWitnessPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSArray* params, CharPtr* error) { + RPtr self = [[params objectAtIndex:0] rPtr]; + RPtr bootstrapWitness = [[params objectAtIndex:1] rPtr]; + csl_bridge_fixed_tx_witnesses_set_add_bootstrap_witness(self, bootstrapWitness, error); + return nil; + }] exec:@[selfPtr, bootstrapWitnessPtr] andResolve:resolve orReject:reject]; +} + +RCT_EXPORT_METHOD(csl_bridge_fixedTxWitnessesSetToBytes:(nonnull NSString *)selfPtr withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSString* selfPtr, CharPtr* error) { + DataPtr result; + RPtr self = [selfPtr rPtr]; + return csl_bridge_fixed_tx_witnesses_set_to_bytes(self, &result, error) + ? [[NSData fromDataPtr:&result] base64] + : nil; + }] exec:selfPtr andResolve:resolve orReject:reject]; +} + +RCT_EXPORT_METHOD(csl_bridge_fixedTxWitnessesSetFromBytes:(nonnull NSString *)dataVal withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) +{ + [[CSLCSafeOperation new:^NSString*(NSString* dataVal, CharPtr* error) { + RPtr result; + NSData* dataData = [NSData fromBase64:dataVal]; + return csl_bridge_fixed_tx_witnesses_set_from_bytes((uint8_t*)dataData.bytes, dataData.length, &result, error) + ? [NSString stringFromPtr:result] + : nil; + }] exec:dataVal andResolve:resolve orReject:reject]; +} + + RCT_EXPORT_METHOD(csl_bridge_fixedVersionedBlockFromBytes:(nonnull NSString *)bytesVal withResolve:(RCTPromiseResolveBlock)resolve andReject:(RCTPromiseRejectBlock)reject) { [[CSLCSafeOperation new:^NSString*(NSString* bytesVal, CharPtr* error) { diff --git a/package.json b/package.json index 4ca5abb..637891b 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@emurgo/csl-mobile-bridge", "title": "CSL mobile bridge", - "version": "6.1.0-beta.1", + "version": "6.1.0", "description": "React-native bindings for Emurgo's cardano-serialization-lib (Cardano haskell Shelley)", "main": "index.js", "files": [ diff --git a/rust/Cargo.lock b/rust/Cargo.lock index 002695d..a0b7781 100644 --- a/rust/Cargo.lock +++ b/rust/Cargo.lock @@ -87,9 +87,9 @@ checksum = "dfb24e866b15a1af2a1b663f10c6b6b8f397a84aadb828f12e5b289ec23a3a3c" [[package]] name = "cardano-serialization-lib" -version = "12.1.0-beta.1" +version = "12.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f550f90b4e8d1dc1e56e95a8a562286361e01c402ccadc882d3d6ed9bd8e212d" +checksum = "abfd14f5a2250d86a3c673a70c49851c21207ee8537f9f11b3dba9cc67095ef7" dependencies = [ "bech32", "cbor_event", diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 2516f8e..acdbebc 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -11,7 +11,7 @@ cbindgen = "=0.14.1" cryptoxide = { git = "https://github.com/emurgo/cryptoxide", tag="0.4.4"} [dependencies] -cardano-serialization-lib = "=12.1.0-beta.1" +cardano-serialization-lib = "=12.1.0" byteorder = "1.4.3" base64 = "0.20.0" # tag = "2.3.1" diff --git a/rust/src/android/bridge.rs b/rust/src/android/bridge.rs index 2cbc8df..2cdcc71 100644 --- a/rust/src/android/bridge.rs +++ b/rust/src/android/bridge.rs @@ -73,6 +73,7 @@ use cardano_serialization_lib::FixedBlock; use cardano_serialization_lib::FixedTransaction; use cardano_serialization_lib::FixedTransactionBodies; use cardano_serialization_lib::FixedTransactionBody; +use cardano_serialization_lib::FixedTxWitnessesSet; use cardano_serialization_lib::FixedVersionedBlock; use cardano_serialization_lib::GeneralTransactionMetadata; use cardano_serialization_lib::GenesisDelegateHash; @@ -7371,6 +7372,49 @@ pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fix } +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTransactionTransactionHash(env: JNIEnv, _: JObject, self_ptr: JRPtr) -> jobject { + handle_exception_result(|| { + let self_jrptr = self_ptr.rptr(&env)?; + let self_rptr = self_jrptr.typed_ref::()?; + let result = self_rptr.transaction_hash(); + result.rptr().jptr(&env) + }) + .jresult(&env) +} + + +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTransactionAddVkeyWitness(env: JNIEnv, _: JObject, self_ptr: JRPtr, vkey_witness_ptr: JRPtr) -> jobject { + handle_exception_result(|| { + let self_jrptr = self_ptr.rptr(&env)?; + let self_rptr = self_jrptr.typed_ref::()?; + let vkey_witness_jrptr = vkey_witness_ptr.rptr(&env)?; + let vkey_witness = vkey_witness_jrptr.typed_ref::()?; + self_rptr.add_vkey_witness(vkey_witness); + Ok(JObject::null()) + }) + .jresult(&env) +} + + +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTransactionAddBootstrapWitness(env: JNIEnv, _: JObject, self_ptr: JRPtr, bootstrap_witness_ptr: JRPtr) -> jobject { + handle_exception_result(|| { + let self_jrptr = self_ptr.rptr(&env)?; + let self_rptr = self_jrptr.typed_ref::()?; + let bootstrap_witness_jrptr = bootstrap_witness_ptr.rptr(&env)?; + let bootstrap_witness = bootstrap_witness_jrptr.typed_ref::()?; + self_rptr.add_bootstrap_witness(bootstrap_witness); + Ok(JObject::null()) + }) + .jresult(&env) +} + + #[allow(non_snake_case)] #[no_mangle] pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTransactionSignAndAddVkeySignature(env: JNIEnv, _: JObject, self_ptr: JRPtr, private_key_ptr: JRPtr) -> jobject { @@ -7563,6 +7607,75 @@ pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fix +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTxWitnessesSetTxWitnessesSet(env: JNIEnv, _: JObject, self_ptr: JRPtr) -> jobject { + handle_exception_result(|| { + let self_jrptr = self_ptr.rptr(&env)?; + let self_rptr = self_jrptr.typed_ref::()?; + let result = self_rptr.tx_witnesses_set(); + result.rptr().jptr(&env) + }) + .jresult(&env) +} + + +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTxWitnessesSetAddVkeyWitness(env: JNIEnv, _: JObject, self_ptr: JRPtr, vkey_witness_ptr: JRPtr) -> jobject { + handle_exception_result(|| { + let self_jrptr = self_ptr.rptr(&env)?; + let self_rptr = self_jrptr.typed_ref::()?; + let vkey_witness_jrptr = vkey_witness_ptr.rptr(&env)?; + let vkey_witness = vkey_witness_jrptr.typed_ref::()?; + self_rptr.add_vkey_witness(vkey_witness); + Ok(JObject::null()) + }) + .jresult(&env) +} + + +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTxWitnessesSetAddBootstrapWitness(env: JNIEnv, _: JObject, self_ptr: JRPtr, bootstrap_witness_ptr: JRPtr) -> jobject { + handle_exception_result(|| { + let self_jrptr = self_ptr.rptr(&env)?; + let self_rptr = self_jrptr.typed_ref::()?; + let bootstrap_witness_jrptr = bootstrap_witness_ptr.rptr(&env)?; + let bootstrap_witness = bootstrap_witness_jrptr.typed_ref::()?; + self_rptr.add_bootstrap_witness(bootstrap_witness); + Ok(JObject::null()) + }) + .jresult(&env) +} + + +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTxWitnessesSetToBytes(env: JNIEnv, _: JObject, self_ptr: JRPtr) -> jobject { + handle_exception_result(|| { + let self_jrptr = self_ptr.rptr(&env)?; + let self_rptr = self_jrptr.typed_ref::()?; + let result = self_rptr.to_bytes(); + Ok(JObject::from_raw(env.byte_array_from_slice(&result).into_result()?)) + }) + .jresult(&env) +} + + +#[allow(non_snake_case)] +#[no_mangle] +pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedTxWitnessesSetFromBytes(env: JNIEnv, _: JObject, data_jarray: jbyteArray) -> jobject { + handle_exception_result(|| { + let data = env.convert_byte_array(data_jarray).into_result()?; + let result = FixedTxWitnessesSet::from_bytes(data).into_result()?; + result.rptr().jptr(&env) + }) + .jresult(&env) +} + + + #[allow(non_snake_case)] #[no_mangle] pub unsafe extern "C" fn Java_io_emurgo_rnhaskellshelley_Native_csl_1bridge_1fixedVersionedBlockFromBytes(env: JNIEnv, _: JObject, bytes_jarray: jbyteArray) -> jobject { diff --git a/rust/src/ios/bridge.rs b/rust/src/ios/bridge.rs index 5d774a3..95e70e7 100644 --- a/rust/src/ios/bridge.rs +++ b/rust/src/ios/bridge.rs @@ -66,6 +66,7 @@ use cardano_serialization_lib::FixedBlock; use cardano_serialization_lib::FixedTransaction; use cardano_serialization_lib::FixedTransactionBodies; use cardano_serialization_lib::FixedTransactionBody; +use cardano_serialization_lib::FixedTxWitnessesSet; use cardano_serialization_lib::FixedVersionedBlock; use cardano_serialization_lib::GeneralTransactionMetadata; use cardano_serialization_lib::GenesisDelegateHash; @@ -6326,6 +6327,41 @@ pub unsafe extern "C" fn csl_bridge_fixed_transaction_raw_auxiliary_data(self_rp } +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_transaction_transaction_hash(self_rptr: RPtr, result: &mut RPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let self_ref = self_rptr.typed_ref::()?; + let result = self_ref.transaction_hash(); + Ok::(result.rptr()) + }) + .response(result, error) +} + + +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_transaction_add_vkey_witness(self_rptr: RPtr, vkey_witness_rptr: RPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let self_ref = self_rptr.typed_ref::()?; + let vkey_witness = vkey_witness_rptr.typed_ref::()?; + self_ref.add_vkey_witness(vkey_witness); + Ok(()) + }) + .response(&mut (), error) +} + + +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_transaction_add_bootstrap_witness(self_rptr: RPtr, bootstrap_witness_rptr: RPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let self_ref = self_rptr.typed_ref::()?; + let bootstrap_witness = bootstrap_witness_rptr.typed_ref::()?; + self_ref.add_bootstrap_witness(bootstrap_witness); + Ok(()) + }) + .response(&mut (), error) +} + + #[no_mangle] pub unsafe extern "C" fn csl_bridge_fixed_transaction_sign_and_add_vkey_signature(self_rptr: RPtr, private_key_rptr: RPtr, error: &mut CharPtr) -> bool { handle_exception_result(|| { @@ -6489,6 +6525,64 @@ pub unsafe extern "C" fn csl_bridge_fixed_transaction_body_original_bytes(self_r +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_tx_witnesses_set_tx_witnesses_set(self_rptr: RPtr, result: &mut RPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let self_ref = self_rptr.typed_ref::()?; + let result = self_ref.tx_witnesses_set(); + Ok::(result.rptr()) + }) + .response(result, error) +} + + +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_tx_witnesses_set_add_vkey_witness(self_rptr: RPtr, vkey_witness_rptr: RPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let self_ref = self_rptr.typed_ref::()?; + let vkey_witness = vkey_witness_rptr.typed_ref::()?; + self_ref.add_vkey_witness(vkey_witness); + Ok(()) + }) + .response(&mut (), error) +} + + +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_tx_witnesses_set_add_bootstrap_witness(self_rptr: RPtr, bootstrap_witness_rptr: RPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let self_ref = self_rptr.typed_ref::()?; + let bootstrap_witness = bootstrap_witness_rptr.typed_ref::()?; + self_ref.add_bootstrap_witness(bootstrap_witness); + Ok(()) + }) + .response(&mut (), error) +} + + +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_tx_witnesses_set_to_bytes(self_rptr: RPtr, result: &mut DataPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let self_ref = self_rptr.typed_ref::()?; + let result = self_ref.to_bytes(); + Ok::(result.into()) + }) + .response(result, error) +} + + +#[no_mangle] +pub unsafe extern "C" fn csl_bridge_fixed_tx_witnesses_set_from_bytes(data_data: *const u8, data_len: usize, result: &mut RPtr, error: &mut CharPtr) -> bool { + handle_exception_result(|| { + let data = from_raw_parts(data_data, data_len).to_vec(); + let result = FixedTxWitnessesSet::from_bytes(data).into_result()?; + Ok::(result.rptr()) + }) + .response(result, error) +} + + + #[no_mangle] pub unsafe extern "C" fn csl_bridge_fixed_versioned_block_from_bytes(bytes_data: *const u8, bytes_len: usize, result: &mut RPtr, error: &mut CharPtr) -> bool { handle_exception_result(|| { diff --git a/rust/src/ptr_impl.rs b/rust/src/ptr_impl.rs index b6827e8..835a38d 100644 --- a/rust/src/ptr_impl.rs +++ b/rust/src/ptr_impl.rs @@ -51,6 +51,7 @@ use cardano_serialization_lib::FixedBlock; use cardano_serialization_lib::FixedTransaction; use cardano_serialization_lib::FixedTransactionBodies; use cardano_serialization_lib::FixedTransactionBody; +use cardano_serialization_lib::FixedTxWitnessesSet; use cardano_serialization_lib::FixedVersionedBlock; use cardano_serialization_lib::GeneralTransactionMetadata; use cardano_serialization_lib::GenesisDelegateHash; @@ -250,6 +251,7 @@ impl RPtrRepresentable for FixedBlock {} impl RPtrRepresentable for FixedTransaction {} impl RPtrRepresentable for FixedTransactionBodies {} impl RPtrRepresentable for FixedTransactionBody {} +impl RPtrRepresentable for FixedTxWitnessesSet {} impl RPtrRepresentable for FixedVersionedBlock {} impl RPtrRepresentable for GeneralTransactionMetadata {} impl RPtrRepresentable for GenesisDelegateHash {}