Skip to content

Commit e70cc5b

Browse files
committed
Expose appendCertificateToTx in the JS API
1 parent fb9a868 commit e70cc5b

File tree

3 files changed

+30
-0
lines changed

3 files changed

+30
-0
lines changed

cardano-wasm/lib-wrapper/unsigned-tx.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,13 @@ declare interface UnsignedTx {
2727
*/
2828
addSimpleTxOut(destAddr: string, lovelaceAmount: bigint): UnsignedTx;
2929

30+
/**
31+
* Appends a certificate (in CBOR hex string format) to the transaction.
32+
* @param certCbor The certificate in CBOR hex string format.
33+
* @returns The `UnsignedTx` object with the added certificate.
34+
*/
35+
appendCertificateToTx(certCbor: string): UnsignedTx;
36+
3037
/**
3138
* Sets the fee for the transaction.
3239
* @param lovelaceAmount The fee amount in lovelaces.

cardano-wasm/src-lib/Cardano/Wasm/Api/Info.hs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,16 @@ apiInfo =
302302
, methodReturnType = Fluent
303303
, methodReturnDoc = "The `UnsignedTx` object with the added output."
304304
}
305+
, MethodInfoEntry $
306+
MethodInfo
307+
{ methodName = "appendCertificateToTx"
308+
, methodDoc = "Appends a certificate (in CBOR hex string format) to the transaction."
309+
, methodParams =
310+
[ ParamInfo "certCbor" TSString "The certificate in CBOR hex string format."
311+
]
312+
, methodReturnType = Fluent
313+
, methodReturnDoc = "The `UnsignedTx` object with the added certificate."
314+
}
305315
, MethodInfoEntry $
306316
MethodInfo
307317
{ methodName = "setFee"

cardano-wasm/src-wasm/Cardano/Wasm/Internal/JavaScript/Bridge.hs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -353,6 +353,9 @@ foreign export javascript "addTxInput"
353353
foreign export javascript "addSimpleTxOut"
354354
addSimpleTxOut :: JSUnsignedTx -> JSString -> JSCoin -> IO JSUnsignedTx
355355

356+
foreign export javascript "appendCertificateToTx"
357+
appendCertificateToTx :: JSUnsignedTx -> JSString -> IO JSUnsignedTx
358+
356359
foreign export javascript "setFee"
357360
setFee :: JSUnsignedTx -> JSCoin -> IO JSUnsignedTx
358361

@@ -394,6 +397,16 @@ addSimpleTxOut jsUnsignedTx jsDestAddr jsCoin =
394397
<*> fromJSVal jsCoin
395398
)
396399

400+
-- | Append a certificate (in CBOR hex string format) to an unsigned transaction.
401+
appendCertificateToTx :: HasCallStack => JSUnsignedTx -> JSString -> IO JSUnsignedTx
402+
appendCertificateToTx jsUnsignedTx jsCertCbor =
403+
toJSVal
404+
=<< join
405+
( Wasm.appendCertificateToTxImpl
406+
<$> fromJSVal jsUnsignedTx
407+
<*> fromJSVal jsCertCbor
408+
)
409+
397410
-- | Set the transaction fee for an unsigned transaction.
398411
setFee :: HasCallStack => JSUnsignedTx -> JSCoin -> IO JSUnsignedTx
399412
setFee jsUnsignedTx jsCoin =

0 commit comments

Comments
 (0)