@laceio/sdk 0.1.0 → 0.1.1-canary.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{Ed25519PublicKey-lvu1s54U.cjs → Address-AMKTo-dA.cjs} +17150 -61
- package/dist/{Ed25519PublicKey-CjnuAYRR.js → Address-_c_-9hLC.js} +16955 -264
- package/dist/{Bip32Account-r3KAhCgU.js → Bip32Account-CaW1zC9Y.js} +4 -5
- package/dist/{Bip32Account-Cz3h0ZUa.cjs → Bip32Account-DOaGmKpv.cjs} +4 -5
- package/dist/Cardano-B-gyqBBD.js +311 -0
- package/dist/Cardano-BQ_af0Y3.cjs +322 -0
- package/dist/Ed25519PublicKey-B3QcR0J2.cjs +88 -0
- package/dist/Ed25519PublicKey-DIE19xHg.js +83 -0
- package/dist/InMemoryKeyAgent-Bc_xZY-v.cjs +652 -0
- package/dist/InMemoryKeyAgent-D8T3vtXy.js +631 -0
- package/dist/{PaymentAddress-DhbtuYb7.cjs → PaymentAddress-B4n1KZMx.cjs} +1 -2
- package/dist/{PaymentAddress-xSmGUQ-8.js → PaymentAddress-Cml3EA1n.js} +1 -2
- package/dist/Percent-Cfuw5YyL.cjs +11 -0
- package/dist/Percent-DpvyJ_93.js +5 -0
- package/dist/SodiumBip32Ed25519-BaD-kjyx.cjs +380 -0
- package/dist/SodiumBip32Ed25519-DCikAMsl.js +363 -0
- package/dist/{TransactionBuilder-CeJTNzm-.cjs → TransactionBuilder-BakTJvsJ.cjs} +59 -89
- package/dist/{TransactionBuilder-DGNDM4kt.js → TransactionBuilder-D2ErwVWv.js} +5 -71
- package/dist/_md-6zV2Cme0.cjs +684 -0
- package/dist/_md-gbUqlhqd.js +399 -0
- package/dist/_web-crypto-random-bytes-BvzwTYPG.js +197 -0
- package/dist/acc-module-NL_8mEHH.cjs +27654 -0
- package/dist/acc-module-ur8CkBd1.js +27624 -0
- package/dist/account-call-B7cF8ly4.cjs +293 -0
- package/dist/account-call-BF4rBcNw.js +3 -0
- package/dist/account-call-CoCq3V55.js +252 -0
- package/dist/account-call-DFcD257E.cjs +4 -0
- package/dist/account-guards-BeKbV9D1.cjs +41 -0
- package/dist/account-guards-qnFXuXSE.js +36 -0
- package/dist/{activity-type.stable-ClO9j_PH.cjs → activity-type-BPXxdHBP.cjs} +2 -1
- package/dist/{activity-type.stable-Ml0SOYv9.js → activity-type-C1geyPsH.js} +2 -1
- package/dist/address-OxwXIwbF.js +15502 -0
- package/dist/address-book-address-validator-BqYM0Uyp.cjs +41 -0
- package/dist/{address-book-address-validator-BhqRfmlL.cjs → address-book-address-validator-CGIcqn5W.cjs} +5 -4
- package/dist/{address-book-address-validator-VqIOB8PY.js → address-book-address-validator-FkkYim3z.js} +6 -4
- package/dist/address-book-address-validator-RSx2Jozy.js +39 -0
- package/dist/address-lECYBd9-.cjs +13043 -0
- package/dist/{apply-vkey-witnesses-Ctzk7eye.cjs → apply-vkey-witnesses-1jyczTkw.cjs} +1 -1
- package/dist/{apply-vkey-witnesses-Dfo7XfhL.js → apply-vkey-witnesses-Byb40-yJ.js} +1 -1
- package/dist/artefact-loader-Cqc9eSkL.cjs +182 -0
- package/dist/artefact-loader-D0T2f6F7.js +159 -0
- package/dist/auto-dismiss-failure-on-success-BWJceNXd.cjs +37 -0
- package/dist/auto-dismiss-failure-on-success-Bpod-v4r.js +31 -0
- package/dist/bip32-EPpcFrpH.cjs +3851 -0
- package/dist/{bip32ed25519-D2In8WzR.cjs → bip32ed25519-CRiG-Kjg.cjs} +5 -4
- package/dist/{bip32ed25519-qsLH_eWO.js → bip32ed25519-E-fCUZNv.js} +6 -4
- package/dist/bip39-DZomfqeY.js +9 -0
- package/dist/bip39-MAck9iod.cjs +26 -0
- package/dist/bitcoin-data-provider-D0OT_Uiu.cjs +26 -0
- package/dist/bitcoin-data-provider-LN_8oamW.js +21 -0
- package/dist/bitcoin.cjs +48 -0
- package/dist/bitcoin.d.ts +29805 -1
- package/dist/bitcoin.js +22 -0
- package/dist/{blake2b-BGHUWMsV.js → blake2b-BL-eR5G2.js} +6 -4
- package/dist/{blake2b-DspUqw68.cjs → blake2b-Iy324FwH.cjs} +5 -4
- package/dist/{blockfrost-tx-submit-provider-BUEOmdvc.js → blockfrost-tx-submit-provider-BHDLgOIE.js} +9 -162
- package/dist/{blockfrost-tx-submit-provider-B5dWbdrZ.cjs → blockfrost-tx-submit-provider-BxC19smv.cjs} +7 -171
- package/dist/{blockingWithLatestFrom-BhaE7pnA.js → blockingWithLatestFrom-FUfZFEUG.js} +1 -1
- package/dist/{blockingWithLatestFrom-DkuT3G2a.cjs → blockingWithLatestFrom-bmCPgA3c.cjs} +1 -1
- package/dist/bn-BFq5a4dk.cjs +2553 -0
- package/dist/{SodiumBip32Ed25519-BEfo1Q9m.js → browser-D5jRKv_L.js} +4 -401
- package/dist/bytes.vo-CziaOsba.js +24 -0
- package/dist/bytes.vo-hecRu3YZ.cjs +35 -0
- package/dist/{cardano-network-id-to-network-type-PXvn1ycQ.cjs → cardano-network-id-to-network-type-BwG_d6QP.cjs} +1 -1
- package/dist/{cardano-network-id-to-network-type-DHgKhDAK.js → cardano-network-id-to-network-type-CYJheetp.js} +1 -1
- package/dist/{cardano-network-id.vo-CbNNKd-k.cjs → cardano-network-id.vo-C5VuBXT3.cjs} +2 -2
- package/dist/{cardano-network-id.vo-CTYe-Oix.js → cardano-network-id.vo-CeLJqmb_.js} +2 -2
- package/dist/{cardano-tx-id.vo-BMwemq5x.js → cardano-tx-id.vo-DJ70NC0-.js} +1 -1
- package/dist/{cardano-tx-id.vo-NY-gCOWJ.cjs → cardano-tx-id.vo-lnyO9XaW.cjs} +1 -1
- package/dist/cardano.cjs +31 -24
- package/dist/cardano.d.ts +27602 -8121
- package/dist/cardano.js +21 -13
- package/dist/client-Bw2foG5E.cjs +808 -0
- package/dist/const-BB3MccLt.js +153 -0
- package/dist/{const-BErUlcZw.cjs → const-BWBAzOmN.cjs} +1 -1
- package/dist/const-CSWmOyzn.cjs +42 -0
- package/dist/{const-Dy8Ctnpd.cjs → const-D3mCkwrM.cjs} +5 -5
- package/dist/const-DW7z3R5k.js +13 -0
- package/dist/{const-DeUA7zYl.js → const-DbuUHSzR.js} +5 -5
- package/dist/const-DgBzKfz6.cjs +31995 -0
- package/dist/{const-DVW6DGkZ.js → const-xGSNCtwQ.js} +1 -1
- package/dist/contract-BsIGhsYa.js +171 -0
- package/dist/contract-DD6CGnpB.cjs +189 -0
- package/dist/create-add-accounts-2mQA0ST2.js +102 -0
- package/dist/create-add-accounts-B6mR2NMn.cjs +114 -0
- package/dist/{delegation-tx-builder-CF0VunDW.cjs → delegation-tx-builder-Cp30jtj9.cjs} +9 -8
- package/dist/{delegation-tx-builder-C8LQxU2R.js → delegation-tx-builder-DUMikSTg.js} +9 -7
- package/dist/{deregistration-tx-builder-DcUXA3Ls.cjs → deregistration-tx-builder-B-ZeY-dR.cjs} +10 -9
- package/dist/{deregistration-tx-builder-BOBPP8m_.js → deregistration-tx-builder-CRLrK99U.js} +10 -8
- package/dist/device-commitment-hex.vo-BIUYUNz1.cjs +31 -0
- package/dist/device-commitment-hex.vo-D9FsYLn7.js +26 -0
- package/dist/device-key-BToCoS4D.js +2394 -0
- package/dist/device-key-D6euvxFi.cjs +2489 -0
- package/dist/device-readers-BHJeNR8I.js +3 -0
- package/dist/device-readers-Dw7uTNM5.cjs +167 -0
- package/dist/device-readers-b4g2j3QL.js +144 -0
- package/dist/device-readers-cxcJcWq5.cjs +7 -0
- package/dist/dist-B00GN41m.js +141 -0
- package/dist/dist-BA1xnF9O.cjs +4413 -0
- package/dist/dist-BmHOXLe8.cjs +3814 -0
- package/dist/dist-Br0OVXKt.cjs +535 -0
- package/dist/dist-C1JK9C1I.cjs +3452 -0
- package/dist/dist-DKEViNEI.cjs +1306 -0
- package/dist/dist-Dwqx184a.cjs +43175 -0
- package/dist/dist-MJof_Ky1.cjs +145 -0
- package/dist/dist-p84sVVJ9.cjs +1394 -0
- package/dist/{earn-rewards-tx-builder-BRlTueHS.js → earn-rewards-tx-builder-8G_rouIk.js} +9 -7
- package/dist/{earn-rewards-tx-builder-RgO0QUY8.cjs → earn-rewards-tx-builder-cOUNV58E.cjs} +9 -8
- package/dist/enc-key-circuits-0Dud78IB.js +13 -0
- package/dist/enc-key-circuits-yjPHbuo_.cjs +24 -0
- package/dist/english-BZ_ebp2-.cjs +2057 -0
- package/dist/envelopes-B3QCzo5p.js +2658 -0
- package/dist/envelopes-BdE1xlgz.cjs +2777 -0
- package/dist/errors-BA3b8aVu.cjs +584 -0
- package/dist/errors-pkQdxW-7.js +392 -0
- package/dist/experimental.cjs +6820 -0
- package/dist/experimental.d.ts +63552 -0
- package/dist/experimental.js +6670 -0
- package/dist/fees-6C2uEWFK.js +653 -0
- package/dist/fees-DtC71fOx.cjs +820 -0
- package/dist/gated-call-BrPjKolT.js +3 -0
- package/dist/gated-call-CcsuW9L5.js +691 -0
- package/dist/gated-call-DdDrxEq5.cjs +732 -0
- package/dist/gated-call-Dk7PazhG.cjs +4 -0
- package/dist/grant-rules-B7eDuD5G.cjs +5468 -0
- package/dist/grant-rules-qLrKUIR3.js +5217 -0
- package/dist/grant-status-CDmZpx32.js +296 -0
- package/dist/grant-status-CQtwjLsA.cjs +337 -0
- package/dist/grants-Bnb-3Hkv.cjs +16 -0
- package/dist/grants-CIb6nOV7.cjs +273 -0
- package/dist/grants-CYY0AquW.js +202 -0
- package/dist/grants-DOsFSotP.js +4 -0
- package/dist/{group-cardano-addresses-by-account-C-1GHUu8.cjs → group-cardano-addresses-by-account-BGOtPV-Y.cjs} +4 -40
- package/dist/{group-cardano-addresses-by-account-p4dXmCoj.js → group-cardano-addresses-by-account-TqvESg9x.js} +6 -37
- package/dist/{guarded-transaction-signer-DZSGHp1K.js → guarded-transaction-signer-BbVDE9Nn.js} +12 -18
- package/dist/{guarded-transaction-signer-BLSezbfV.cjs → guarded-transaction-signer-DTLjAkif.cjs} +26 -26
- package/dist/hex-BVtOKJki.cjs +263 -0
- package/dist/hex-CGYJPK_Z.js +192 -0
- package/dist/http-client-B7_kBTYn.js +155 -0
- package/dist/http-client-DYQ_7Rdf.cjs +167 -0
- package/dist/identity-DxPhxkZs.js +239 -0
- package/dist/identity-y41Yle03.cjs +274 -0
- package/dist/in-memory-wallet-integration-5BKiAvPT.js +20861 -0
- package/dist/{in-memory-wallet-integration-CUTa68ET.js → in-memory-wallet-integration-BCOqDgbt.js} +10 -107
- package/dist/in-memory-wallet-integration-Bi8I9Dso.js +128 -0
- package/dist/in-memory-wallet-integration-Bsl2ONua.cjs +239 -0
- package/dist/in-memory-wallet-integration-DZ0CAyvY.cjs +20865 -0
- package/dist/{in-memory-wallet-integration-Dw_S7amX.cjs → in-memory-wallet-integration-DsFm8gLk.cjs} +21 -112
- package/dist/{in-memory-wallet-integration-Z4Bp_DTv.cjs → in-memory-wallet-integration-aW_SF-go.cjs} +8 -5
- package/dist/{in-memory-wallet-integration-B6cbAlvD.js → in-memory-wallet-integration-mIEc8EfR.js} +9 -5
- package/dist/index.cjs +95 -58
- package/dist/index.d.ts +45152 -13448
- package/dist/index.js +55 -28
- package/dist/{init-CVi8J0zk.cjs → init-5SfWgCYD.cjs} +3 -3
- package/dist/{init-Ci7aqWCf2.cjs → init-8NVWbo302.cjs} +2 -2
- package/dist/init-B-C7n6u6.js +5 -0
- package/dist/{init-BFMWRf-L.js → init-B-ppfGO-.js} +1 -1
- package/dist/{init-IiR093Jw.cjs → init-B2OUhY5T.cjs} +2 -2
- package/dist/{init-DXnus199.cjs → init-B6Eg_o6G.cjs} +5 -5
- package/dist/{init-4hDl5bpr.js → init-BAWMHL1k.js} +2 -2
- package/dist/init-BC2CZZOu2.cjs +2002 -0
- package/dist/{init-a228hXnS.cjs → init-BF-a2p6E.cjs} +65 -73
- package/dist/{init-fFirX8OY.cjs → init-BFxlQAD8.cjs} +1 -1
- package/dist/init-BJE1ry0O.js +17 -0
- package/dist/{init-BVnI4z2J.js → init-BPKBVOHU.js} +2 -2
- package/dist/{init-bdqZBd-o.js → init-BSP_xcpB.js} +2 -2
- package/dist/{init-CFNOn3lo.js → init-BSd7mznK.js} +3 -3
- package/dist/{init-MjR4swi6.js → init-BUJTT0MN.js} +36 -43
- package/dist/init-BUpFzYsD.cjs +143 -0
- package/dist/{init-BvpYHyLH.cjs → init-BZ-WyAIL.cjs} +3 -3
- package/dist/init-BZdfdLX7.js +422 -0
- package/dist/{init-CJeOys1w.cjs → init-B_HWNXMD.cjs} +2 -2
- package/dist/init-BbIMt6xU.cjs +6 -0
- package/dist/{init-BYdN1aqE.cjs → init-BewG6swt.cjs} +2 -2
- package/dist/{init-BX0AZAVH2.js → init-Bilqsbng.js} +2 -2
- package/dist/{init-Tpn9VkFu.cjs → init-BpwlQ6wF.cjs} +1 -1
- package/dist/{init-D5-P0HXK.js → init-BtQOzUjX.js} +1 -1
- package/dist/{init-BvGz3qUd2.js → init-CCTscPaY2.js} +2 -2
- package/dist/{init-D4hPipCD.cjs → init-CH0yyBof.cjs} +1 -1
- package/dist/init-CaIkrXal.cjs +121 -0
- package/dist/init-CkZy4IMf.cjs +107 -0
- package/dist/{init-Drr2f_Pr.js → init-CmfcY7SV.js} +1 -1
- package/dist/{init-Kf3_OLv6.js → init-CnJAlks_.js} +1 -1
- package/dist/{init-Cdjt_z-b.cjs → init-CqqmtAIK.cjs} +4 -4
- package/dist/{init-Bb0avZeZ.js → init-Cu2znmIc.js} +5 -5
- package/dist/init-Cz5LAizN.js +2001 -0
- package/dist/init-D4WM3-Mn.cjs +18 -0
- package/dist/init-DMi2FGpf.cjs +424 -0
- package/dist/{init-lcaUSOOG.js → init-DPTJohPd.js} +1 -1
- package/dist/{init-BTYLMF9F2.cjs → init-DexLSprL2.cjs} +258 -61
- package/dist/init-DfKPgD21.js +106 -0
- package/dist/init-DgzRsI-C.js +141 -0
- package/dist/init-Dj4Cn7-P.js +4789 -0
- package/dist/init-DktAnYI0.cjs +2354 -0
- package/dist/{init-DFwhgert.cjs → init-DmyuM9Lo.cjs} +1 -1
- package/dist/{init-CX_zLXc6.js → init-IBnizp1U.js} +5 -5
- package/dist/init-MDKB6tGI2.cjs +4790 -0
- package/dist/{init-DbZ5byj42.js → init-TbB38KNt2.js} +258 -60
- package/dist/init-X6m_cqDy.js +2353 -0
- package/dist/{init-DvVgKCaP2.cjs → init-bzvl1JhF.cjs} +2 -2
- package/dist/{init-BgrY29gW.js → init-dsYkC_0B.js} +4 -4
- package/dist/{init-B5BsI3DR.cjs → init-kvn5FlPS.cjs} +7 -7
- package/dist/init-vfy9DW_E.js +119 -0
- package/dist/{init-BE_6Jyc4.js → init-w7xl6LsP.js} +3 -3
- package/dist/{init-DEsWVyn5.cjs → init-wgiBUmyW.cjs} +1 -1
- package/dist/{is-retriable-error-DWv_ob-f.js → is-retriable-error-CmFR20pe.js} +1 -1
- package/dist/{is-retriable-error-Dtb4JGjd.cjs → is-retriable-error-D2yo0_lS.cjs} +1 -1
- package/dist/jubjub-authoriser-A2c8vmkN.js +84 -0
- package/dist/jubjub-authoriser-D3ZDgzcF.cjs +85 -0
- package/dist/key-source-CcLTx8HK.js +2761 -0
- package/dist/key-source-D2tTAag-.cjs +806 -0
- package/dist/{key-value-store-DTX1quRS.js → key-value-store-DZcNDB3n.js} +1 -1
- package/dist/{key-value-store-B-XRIwaM.cjs → key-value-store-Htj4RgMe.cjs} +1 -1
- package/dist/keyDerivation-DcKRUCVh.cjs +274 -0
- package/dist/keyDerivation-QGesIMbS.js +4077 -0
- package/dist/{lace-context-FpU3iG3f.cjs → lace-context-BN0b_ury.cjs} +4 -4
- package/dist/{lace-context-BQvvxVLm.js → lace-context-DMRJ87Vg.js} +4 -4
- package/dist/lib-BC-62Byh.cjs +2359 -0
- package/dist/lib-JYqcAX0c.js +2354 -0
- package/dist/midnight-account-id.vo--Vcx34Xk.cjs +10 -0
- package/dist/midnight-account-id.vo-BuB8fiVO.js +5 -0
- package/dist/midnight-engine-B7D2hbHo.js +5 -0
- package/dist/midnight-engine-D5ikN_5F.cjs +6 -0
- package/dist/midnight-wallet-BOdFD6SX.cjs +24 -0
- package/dist/midnight-wallet-CAqZrNVe.js +18 -0
- package/dist/midnight.cjs +1412 -0
- package/dist/midnight.d.ts +28609 -0
- package/dist/midnight.js +1355 -0
- package/dist/modules-cardano-BiL9hoM3.js +996 -0
- package/dist/modules-cardano-UeXks3sd.cjs +1109 -0
- package/dist/node-relay-BOuvdZvC.cjs +49 -0
- package/dist/node-relay-CLtc5n1v.js +48 -0
- package/dist/outputs-5qdW8s-f.js +196 -0
- package/dist/outputs-BEM1GPMf.cjs +339 -0
- package/dist/{SodiumBip32Ed25519-BQUcrQWX.cjs → pbkdf2-B1veireP.cjs} +6 -411
- package/dist/pending-operation-CfTUNQVD.cjs +26 -0
- package/dist/pending-operation-Ljijb1Uh.js +21 -0
- package/dist/providers-1on_fwJO.cjs +364 -0
- package/dist/providers-C1MsxfMA.js +341 -0
- package/dist/redacted-4SJPqt-G.js +81 -0
- package/dist/redacted-DwxIDdIF.cjs +86 -0
- package/dist/{reselect-DPML1uFN.cjs → reselect-kP4DaAII.cjs} +1 -1
- package/dist/{retry-config-oNtfdyrG.cjs → retry-config-BGv5q5QM.cjs} +1 -1
- package/dist/{retry-config-VdbuqBsI.js → retry-config-Bu5Yn5ua.js} +1 -1
- package/dist/safe-buffer-CqGpSFCQ.js +43 -0
- package/dist/safe-buffer-DbXbwhUQ.cjs +48 -0
- package/dist/sdk-1SRu8Ype.cjs +1445 -0
- package/dist/sdk-BneJm7ey.js +1249 -0
- package/dist/sdk-init-9TG1ZvHF.cjs +3795 -0
- package/dist/sdk-init-Ce3mD-8F.js +1047 -0
- package/dist/secret-box-CSmRp6Tt.js +3777 -0
- package/dist/secret-box-ZfbYwBgS.cjs +6970 -0
- package/dist/send-proof-progress-DtAcrMP6.cjs +33 -0
- package/dist/send-proof-progress-Dx2cUz1B.js +22 -0
- package/dist/sha2-DaRJZOjk.cjs +390 -0
- package/dist/sha2-c4sB6peD.js +378 -0
- package/dist/side-effects-C3BhLrdP.js +768 -0
- package/dist/side-effects-DG0R-KFc.cjs +804 -0
- package/dist/sign-bitcoin-transaction-with-seed-C7vq9om8.js +147 -0
- package/dist/sign-bitcoin-transaction-with-seed-Ds1dwzan.cjs +158 -0
- package/dist/signer--2I6poMD.js +2 -0
- package/dist/signer-CX21Ups_.cjs +121 -0
- package/dist/signer-Cnn9q9oY.js +92 -0
- package/dist/signer-DbSxjk0F.cjs +7 -0
- package/dist/signer-factory-B5oFuUZ-.cjs +130 -0
- package/dist/signer-factory-BAt8FPNc.cjs +281 -0
- package/dist/signer-factory-BGE4nL4k.js +129 -0
- package/dist/signer-factory-C4pgsiJi.js +281 -0
- package/dist/{signer-factory-DySc1wRX.cjs → signer-factory-D95jQIPV.cjs} +9 -6
- package/dist/{signer-factory-D4HrwFPl.js → signer-factory-PrpsGX-8.js} +10 -6
- package/dist/{slice-BZTQgYSs.js → slice-B-xJcuT1.js} +4 -4
- package/dist/slice-B4QOYaOG.cjs +105 -0
- package/dist/{slice-CtIMw2YT.cjs → slice-B9QKuhi0.cjs} +3 -3
- package/dist/slice-BKnGkAkd.cjs +9031 -0
- package/dist/{slice-Bhwmqn1p.cjs → slice-Bf4enJKZ.cjs} +8 -8
- package/dist/{slice-DaNVz7_l.js → slice-ByNWnxKS.js} +8 -8
- package/dist/{slice-C2UDQrdt.js → slice-C1zOeseG.js} +449 -355
- package/dist/{slice-DFLyKRm5.cjs → slice-C4toRM6A.cjs} +2 -2
- package/dist/{slice-Cx4dULDA.cjs → slice-C8YVv4Qn.cjs} +1 -1
- package/dist/{slice-jnpOgiSZ.cjs → slice-CaMfviYu.cjs} +3 -3
- package/dist/{slice-DFvrwUur.js → slice-CgeRsYRg.js} +6 -6
- package/dist/slice-Cwt8jShq.js +9013 -0
- package/dist/{slice-zNEspZND.js → slice-D0VzpMbY.js} +2 -2
- package/dist/slice-D14F78Ca.js +87 -0
- package/dist/{slice-F6A1YKOF.cjs → slice-DLflttAu.cjs} +479 -366
- package/dist/{slice-C96EdeY1.js → slice-DcO-iNz2.js} +1 -1
- package/dist/{slice-C19quNWM.cjs → slice-DimtxfAT.cjs} +2 -2
- package/dist/{slice-KiNoGwD9.js → slice-DlTEqIoI.js} +1 -1
- package/dist/{slice-ws8PccRX.js → slice-Dn0WojD7.js} +3 -3
- package/dist/{slice-BLSxLmie.cjs → slice-Dongunf7.cjs} +4 -4
- package/dist/{slice-B6vPum19.js → slice-DpufJAjJ.js} +2 -2
- package/dist/{slice-exhhmucR.cjs → slice-DtitVc9L.cjs} +7 -7
- package/dist/{slice-Bjj2t2ut.cjs → slice-WMMMc1Xv.cjs} +2 -2
- package/dist/slice-a8VuIqzS.cjs +378 -0
- package/dist/slice-bRASyM-m.js +354 -0
- package/dist/{slice-CBFrgHSH.js → slice-hNyKbDry.js} +3 -3
- package/dist/{InMemoryKeyAgent-pyB2gA-N.cjs → src-BayYMIjw.cjs} +20 -8228
- package/dist/{InMemoryKeyAgent-D-3HejxN.js → src-CgINPlSx.js} +29 -4811
- package/dist/store-AUlTfcI_.js +37 -0
- package/dist/store-C7AneHEY.cjs +66 -0
- package/dist/submit-BuBCVi-l.cjs +87 -0
- package/dist/submit-D37lxFrK.js +70 -0
- package/dist/submit-bitcoin-tx-DFLnhidO.js +983 -0
- package/dist/submit-bitcoin-tx-sih2hSfb.cjs +1049 -0
- package/dist/{subtractValueQuantities-DfZg6oiG.js → subtractValueQuantities-BuDJVxq6.js} +3 -22
- package/dist/{subtractValueQuantities-C8qDTtgH.cjs → subtractValueQuantities-CqR606HV.cjs} +2 -32
- package/dist/{sync-operation-utils-BrQyWFS_.cjs → sync-operation-utils--Z_IQfyW.cjs} +0 -66
- package/dist/{sync-operation-utils-CAaCGvEN.js → sync-operation-utils-BimBpvI3.js} +1 -37
- package/dist/token-color.vo-CItgoOjw.js +26 -0
- package/dist/token-color.vo-Ca4hUXfh.cjs +37 -0
- package/dist/token-id-mapper-BVau2RXa.js +16 -0
- package/dist/token-id-mapper-CSeLzM4o.cjs +18 -0
- package/dist/{token-id-mapper-pDaTxpw2.js → token-id-mapper-ClBeIdJR.js} +2 -2
- package/dist/{token-id-mapper-DYcd8hhQ.cjs → token-id-mapper-D0wFdbOy.cjs} +2 -2
- package/dist/types-BhzypKMS.cjs +15 -0
- package/dist/types-DTE1ctDB.js +10 -0
- package/dist/types-DXSxXGz0.js +12 -0
- package/dist/types-Dls6Z5gV.cjs +23 -0
- package/dist/{util-P4PX2muj.cjs → util-D1YlKzrc.cjs} +2 -2
- package/dist/{util-CQSJU0wT.js → util-DHxtzUzY.js} +2 -2
- package/dist/{utils-Bv4OHT4S.cjs → utils-DYf4iZKX.cjs} +7 -1
- package/dist/{utils-DrtzChYN.js → utils-DcnoETEP.js} +2 -2
- package/dist/utils-Du0YXRcU.cjs +112 -0
- package/dist/utils-fF_rnZe3.js +65 -0
- package/dist/v8Signatures-ClGpA8mS.cjs +71 -0
- package/dist/{vote-delegation-tx-builder-69gOEkCB.cjs → vote-delegation-tx-builder-BjZxCOd3.cjs} +9 -8
- package/dist/{vote-delegation-tx-builder-BRJ_pf-c.js → vote-delegation-tx-builder-DRJwPXkD.js} +9 -7
- package/dist/watch-FGE4B_Ge.js +13056 -0
- package/dist/watch-imlsRZDp.cjs +52207 -0
- package/package.json +95 -3
- package/dist/Address-4KjeDt_x.cjs +0 -17269
- package/dist/Address-_VPkf7Xh.js +0 -17101
- package/dist/account-guards.stable-BKyYPj4z.cjs +0 -10
- package/dist/account-guards.stable-BdmQ43vC.js +0 -5
- package/dist/init-BR9ZIbED.cjs +0 -378
- package/dist/init-B_k1RUN_.cjs +0 -21
- package/dist/init-Bs3b5ZQH.js +0 -378
- package/dist/init-ChfcrHgG2.cjs +0 -4354
- package/dist/init-D1uUMMpG.js +0 -19
- package/dist/init-DV1OSZiK.js +0 -4352
- package/dist/modules-cardano-BINzpXpk.js +0 -5454
- package/dist/modules-cardano-Dt8OwoQb.cjs +0 -5640
- package/dist/slice-Caf98m0d2.js +0 -107
- package/dist/slice-PM6llajQ2.cjs +0 -125
- /package/dist/{BigIntMath-CoJWXt1h.cjs → BigIntMath-CBciEQn2.cjs} +0 -0
- /package/dist/{BigIntMath-BWUJOsOW.js → BigIntMath-X3EniYDo.js} +0 -0
- /package/dist/{ChainId-sdLmlIRk.cjs → ChainId-CNPSU9nn.cjs} +0 -0
- /package/dist/{ChainId-CKbm87yQ.js → ChainId-CeoG8Sov.js} +0 -0
- /package/dist/{_polyfill-node.process-4fnlkbBi.cjs → _polyfill-node.process-5UxyjoHG.cjs} +0 -0
- /package/dist/{account-id.vo-Xpgnu-av.cjs → account-id.vo-DYZBZQsz.cjs} +0 -0
- /package/dist/{account-id.vo-DP0BtOoF.js → account-id.vo-KDTWJ-W5.js} +0 -0
- /package/dist/{actions-BNagEO6m.cjs → actions-BnHFVSr_.cjs} +0 -0
- /package/dist/{actions-BWTyAr7B.js → actions-Cwj0ApZf.js} +0 -0
- /package/dist/{asyncoption-po7-RiA5.cjs → asyncoption-CYcZNBRM.cjs} +0 -0
- /package/dist/{asyncoption-CzIVH5Y1.js → asyncoption-DZQGfznq.js} +0 -0
- /package/dist/{bignum.vo-DhhZ9HP1.js → bignum.vo-Co6tMH2q.js} +0 -0
- /package/dist/{bignum.vo-CpkrIXjH.cjs → bignum.vo-Du-bpvar.cjs} +0 -0
- /package/dist/{blockchain-network-id.vo-CbgrAY_K.js → blockchain-network-id.vo-C6Jowh8t.js} +0 -0
- /package/dist/{blockchain-network-id.vo-5iC6Kffo.cjs → blockchain-network-id.vo-DEQ14dYj.cjs} +0 -0
- /package/dist/{composite-signer-factory-DABpCe1_.js → composite-signer-factory-D9RWY-1V.js} +0 -0
- /package/dist/{composite-signer-factory-BizuNPP7.cjs → composite-signer-factory-v4Pxn8bA.cjs} +0 -0
- /package/dist/{error-ggOihIfv.cjs → error-B6wj9nPv.cjs} +0 -0
- /package/dist/{error-DHKO2iS4.js → error-CvEYL98P.js} +0 -0
- /package/dist/{esm-browser-DnXNvpcn.cjs → esm-browser-CZbMeVod.cjs} +0 -0
- /package/dist/{esm-browser-BBVQuyQv.js → esm-browser-DpAD_RKv.js} +0 -0
- /package/dist/{feature-flag-key.vo-DoGK5Bfh.js → feature-flag-key.vo-9reURsOQ.js} +0 -0
- /package/dist/{feature-flag-key.vo-CP1Z9s8e.cjs → feature-flag-key.vo-KTIdnzYX.cjs} +0 -0
- /package/dist/{first-state-of-status-Bx4-QQ5m.cjs → first-state-of-status-9ICeDNSa.cjs} +0 -0
- /package/dist/{first-state-of-status-D7XzEuSa.js → first-state-of-status-BscbKj_t.js} +0 -0
- /package/dist/{init-4319psUJ.cjs → init-BT67pd9x.cjs} +0 -0
- /package/dist/{init-AFUM1TSg.js → init-CHk1fvJ2.js} +0 -0
- /package/dist/{init-ZX90nEJe2.js → init-DIyNx6DZ.js} +0 -0
- /package/dist/{init-CTQ2g6Xt.js → init-DtxxFaCx.js} +0 -0
- /package/dist/{init-Dt1Xifg_2.cjs → init-J8QobR93.cjs} +0 -0
- /package/dist/{init-BNewLCqw.cjs → init-xzZPlQwB.cjs} +0 -0
- /package/dist/{is-redux-persist-state-DxJSsvxB.cjs → is-redux-persist-state-C5luvPEH.cjs} +0 -0
- /package/dist/{is-redux-persist-state-Bl2n4VMr.js → is-redux-persist-state-CjcqyCoh.js} +0 -0
- /package/dist/{isNotNil-CZxBMfL5.js → isNotNil-Be7gCY0m.js} +0 -0
- /package/dist/{isNotNil-C_SO1tcC.cjs → isNotNil-CrYIUFry.cjs} +0 -0
- /package/dist/{logging-BvMDKgl0.js → logging-BAMMfn5j.js} +0 -0
- /package/dist/{logging-Bh9ikph3.cjs → logging-CbxgIX9V.cjs} +0 -0
- /package/dist/{metadatum-B-sxBnSY.cjs → metadatum-BGvFqGPt.cjs} +0 -0
- /package/dist/{metadatum-Ego4jVas.js → metadatum-BVocMYy_.js} +0 -0
- /package/dist/{repo-slice-BzZQUTj8.cjs → repo-slice-BB_W-6OL.cjs} +0 -0
- /package/dist/{repo-slice-vCcQJotS.js → repo-slice-BQlssw9M.js} +0 -0
- /package/dist/{reselect-BPkMzw3k.js → reselect-JIgawvPe.js} +0 -0
- /package/dist/{serializable-BxFUShKY.js → serializable-F7OtYl8d.js} +0 -0
- /package/dist/{serializable-DWgkHhv_.cjs → serializable-n3UoxbZc.cjs} +0 -0
- /package/dist/{slice-DY-DNtSi.js → slice-5dGBAz6w.js} +0 -0
- /package/dist/{slice-BEFoeqgr.cjs → slice-BzJgg9FS.cjs} +0 -0
- /package/dist/{src-CPmX4KUh.cjs → src-CeBNkonz.cjs} +0 -0
- /package/dist/{src-XOZXPKxe.js → src-Cv1ifqbe.js} +0 -0
- /package/dist/{time-CQPt4FdU.js → time-ByoKevdZ.js} +0 -0
- /package/dist/{time-Blvoyh9G.cjs → time-qD7edGU0.cjs} +0 -0
- /package/dist/{time.vo-Xln4yGBU.js → time.vo-C17-tYq3.js} +0 -0
- /package/dist/{time.vo-rwWwJzmP.cjs → time.vo-TmYE-_Y2.cjs} +0 -0
- /package/dist/{toEmpty-CzmoZVLN.cjs → toEmpty-Db6V94Mf.cjs} +0 -0
- /package/dist/{toEmpty-DzLd-ZCi.js → toEmpty-Djj-QbpI.js} +0 -0
- /package/dist/{token-id.vo-l8fuSpem.cjs → token-id.vo-CZ622zcZ.cjs} +0 -0
- /package/dist/{token-id.vo-DMKSaMlc.js → token-id.vo-IDI9C_Qm.js} +0 -0
- /package/dist/{types-B61DQoFW.js → types-By-XeXWg.js} +0 -0
- /package/dist/{types-CUC-Kcqh.cjs → types-Cn6WlQV6.cjs} +0 -0
- /package/dist/{util-BV3iGOrz.cjs → util-Cp1h58uD.cjs} +0 -0
- /package/dist/{util-BsQKLorV.js → util-DHppXj7U.js} +0 -0
- /package/dist/{util-selector-CKIyoAOz.js → util-selector-BWmHpo92.js} +0 -0
- /package/dist/{util-selector-C9H5RsNw.cjs → util-selector-glXkO-jR.cjs} +0 -0
- /package/dist/{while-active-CNXeLxre.js → while-active-CDBnUlQA.js} +0 -0
- /package/dist/{while-active-BsDWSNrO.cjs → while-active-I2TlHtm7.cjs} +0 -0
|
@@ -0,0 +1,1306 @@
|
|
|
1
|
+
const require_chunk = require("./chunk-9hOWP6kD.cjs");
|
|
2
|
+
const require__polyfill_buffer_patch = require("./_polyfill-buffer-patch-BycQkEkK.cjs");
|
|
3
|
+
require("./bn-BFq5a4dk.cjs");
|
|
4
|
+
require("./client-Bw2foG5E.cjs");
|
|
5
|
+
const require_dist = require("./dist-Dwqx184a.cjs");
|
|
6
|
+
const require_v8Signatures = require("./v8Signatures-ClGpA8mS.cjs");
|
|
7
|
+
const require_dist$1 = require("./dist-BA1xnF9O.cjs");
|
|
8
|
+
const require_dist$2 = require("./dist-C1JK9C1I.cjs");
|
|
9
|
+
const require_dist$3 = require("./dist-BmHOXLe8.cjs");
|
|
10
|
+
let rxjs = require("rxjs");
|
|
11
|
+
let _midnight_ntwrk_ledger_v8 = require("@midnight-ntwrk/ledger-v8");
|
|
12
|
+
_midnight_ntwrk_ledger_v8 = require_chunk.__toESM(_midnight_ntwrk_ledger_v8);
|
|
13
|
+
let _midnightntwrk_ledger_v9 = require("@midnightntwrk/ledger-v9");
|
|
14
|
+
_midnightntwrk_ledger_v9 = require_chunk.__toESM(_midnightntwrk_ledger_v9);
|
|
15
|
+
//#region ../../packages/module/passport-account/node_modules/@midnightntwrk/wallet-sdk-facade/dist/transaction.js
|
|
16
|
+
require__polyfill_buffer_patch.init__polyfill_buffer_patch();
|
|
17
|
+
/**
|
|
18
|
+
* The key under which a transaction's history entry is stored.
|
|
19
|
+
*
|
|
20
|
+
* Prefer the ledger transaction hash — it's the canonical chain identifier and the value the indexer reports a
|
|
21
|
+
* confirmed tx under. `transactionHash()` is only defined for proven + signed + bound transactions, though; it throws
|
|
22
|
+
* for the other variants, notably the proof-erased transactions the simulator produces. In that case fall back to the
|
|
23
|
+
* hex of the tx's serialized bytes: `serialize()` is total over every variant (it's the same encoding used to submit
|
|
24
|
+
* the tx), so a key is always available — unlike `identifiers[0]`, which is an identifier, not a hash of the
|
|
25
|
+
* transaction.
|
|
26
|
+
*
|
|
27
|
+
* Both the submit (pending) and revert (rejected) sides route through this one function so they can never disagree on
|
|
28
|
+
* the key. The fallback is deterministic: the same transaction object yields the same bytes every time, and the
|
|
29
|
+
* auto-revert path reverts the very object it submitted, so the rejected entry lands on the pending entry in place.
|
|
30
|
+
* (Serialization differs across lifecycle states, so this is only stable for a fixed tx — which is exactly the
|
|
31
|
+
* submit→revert flow.)
|
|
32
|
+
*/
|
|
33
|
+
const txHistoryHash = (tx) => {
|
|
34
|
+
try {
|
|
35
|
+
return String(tx.transactionHash());
|
|
36
|
+
} catch {
|
|
37
|
+
return require__polyfill_buffer_patch.import_buffer.Buffer.from(tx.serialize()).toString("hex");
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
const v9FinalizedTransactionTrait = {
|
|
41
|
+
areAllTxIdsIncluded(tx, txIds) {
|
|
42
|
+
const txIdsSet = require_dist.fromIterable$1(tx.identifiers());
|
|
43
|
+
const expectedIdSet = require_dist.fromIterable$1(txIds);
|
|
44
|
+
return require_dist.isSubset(txIdsSet, expectedIdSet);
|
|
45
|
+
},
|
|
46
|
+
deserialize(serialized) {
|
|
47
|
+
return _midnightntwrk_ledger_v9.Transaction.deserialize("signature", "proof", "binding", serialized);
|
|
48
|
+
},
|
|
49
|
+
firstId(tx) {
|
|
50
|
+
return tx.identifiers()[0];
|
|
51
|
+
},
|
|
52
|
+
hasTTLExpired(tx, creationTime, now) {
|
|
53
|
+
const defaultShieldedGracePeriod = _midnightntwrk_ledger_v9.LedgerParameters.initialParameters().dust.dustGracePeriodSeconds;
|
|
54
|
+
const intentTTLs = require_dist.pipe(tx.intents?.values().toArray() ?? [], require_dist.map$3((i) => i.ttl), require_dist.filterMap$1(require_dist.make$1));
|
|
55
|
+
const hasDustPayments = require_dist.pipe(tx.intents?.values().toArray() ?? [], require_dist.flatMap$2((i) => i.dustActions?.spends ?? []), require_dist.isNonEmptyArray);
|
|
56
|
+
const hasShieldedOffers = tx.guaranteedOffer != null || (tx.fallibleOffer?.size ?? 0) == 0;
|
|
57
|
+
const maybeShieldedTTL = hasDustPayments || hasShieldedOffers ? require_dist.pipe(creationTime, require_dist.addDuration(require_dist.seconds(Number(defaultShieldedGracePeriod))), require_dist.of) : require_dist.empty$2();
|
|
58
|
+
return require_dist.pipe(intentTTLs, require_dist.appendAll(maybeShieldedTTL), (arr) => require_dist.isNonEmptyReadonlyArray(arr) ? require_dist.some(require_dist.min(arr, require_dist.mapInput(require_dist.Date, require_dist.toDate))) : require_dist.none(), require_dist.match$1({
|
|
59
|
+
onNone: () => false,
|
|
60
|
+
onSome: (finalTTL) => require_dist.distance(finalTTL, now) > 0
|
|
61
|
+
}));
|
|
62
|
+
},
|
|
63
|
+
ids(tx) {
|
|
64
|
+
return tx.identifiers();
|
|
65
|
+
},
|
|
66
|
+
isOneIncludedInOther(tx, otherTx) {
|
|
67
|
+
const txIds = require_dist.fromIterable$1(tx.identifiers());
|
|
68
|
+
const otherTxIds = require_dist.fromIterable$1(otherTx.identifiers());
|
|
69
|
+
const smallerSize = require_dist.min$1(require_dist.number)(require_dist.size(txIds), require_dist.size(otherTxIds));
|
|
70
|
+
const intersection$1 = require_dist.intersection(txIds, otherTxIds);
|
|
71
|
+
return require_dist.size(intersection$1) == smallerSize;
|
|
72
|
+
},
|
|
73
|
+
isTx(tx) {
|
|
74
|
+
return tx instanceof _midnightntwrk_ledger_v9.Transaction;
|
|
75
|
+
},
|
|
76
|
+
serialize(tx) {
|
|
77
|
+
return tx.serialize();
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
/**
|
|
81
|
+
* The ledger-v8's reading of a pending transaction.
|
|
82
|
+
*
|
|
83
|
+
* @remarks
|
|
84
|
+
* Structurally the same as ledger-v9's — identifiers, a TTL, bytes — against a different ledger version's classes. It
|
|
85
|
+
* is the classes that make this a separate trait: `instanceof` distinguishes them, each deserializer refuses the
|
|
86
|
+
* other's bytes, and a grace period is read off that version's own initial parameters.
|
|
87
|
+
*/
|
|
88
|
+
const v8FinalizedTransactionTrait = {
|
|
89
|
+
areAllTxIdsIncluded(tx, txIds) {
|
|
90
|
+
return require_dist.isSubset(require_dist.fromIterable$1(tx.identifiers()), require_dist.fromIterable$1(txIds));
|
|
91
|
+
},
|
|
92
|
+
deserialize(serialized) {
|
|
93
|
+
return _midnight_ntwrk_ledger_v8.Transaction.deserialize("signature", "proof", "binding", serialized);
|
|
94
|
+
},
|
|
95
|
+
firstId(tx) {
|
|
96
|
+
return tx.identifiers()[0];
|
|
97
|
+
},
|
|
98
|
+
hasTTLExpired(tx, creationTime, now) {
|
|
99
|
+
const defaultShieldedGracePeriod = _midnight_ntwrk_ledger_v8.LedgerParameters.initialParameters().dust.dustGracePeriodSeconds;
|
|
100
|
+
const intentTTLs = require_dist.pipe(tx.intents?.values().toArray() ?? [], require_dist.map$3((i) => i.ttl), require_dist.filterMap$1(require_dist.make$1));
|
|
101
|
+
const hasDustPayments = require_dist.pipe(tx.intents?.values().toArray() ?? [], require_dist.flatMap$2((i) => i.dustActions?.spends ?? []), require_dist.isNonEmptyArray);
|
|
102
|
+
const hasShieldedOffers = tx.guaranteedOffer != null || (tx.fallibleOffer?.size ?? 0) == 0;
|
|
103
|
+
const maybeShieldedTTL = hasDustPayments || hasShieldedOffers ? require_dist.pipe(creationTime, require_dist.addDuration(require_dist.seconds(Number(defaultShieldedGracePeriod))), require_dist.of) : require_dist.empty$2();
|
|
104
|
+
return require_dist.pipe(intentTTLs, require_dist.appendAll(maybeShieldedTTL), (arr) => require_dist.isNonEmptyReadonlyArray(arr) ? require_dist.some(require_dist.min(arr, require_dist.mapInput(require_dist.Date, require_dist.toDate))) : require_dist.none(), require_dist.match$1({
|
|
105
|
+
onNone: () => false,
|
|
106
|
+
onSome: (finalTTL) => require_dist.distance(finalTTL, now) > 0
|
|
107
|
+
}));
|
|
108
|
+
},
|
|
109
|
+
ids(tx) {
|
|
110
|
+
return tx.identifiers();
|
|
111
|
+
},
|
|
112
|
+
isOneIncludedInOther(tx, otherTx) {
|
|
113
|
+
const txIds = require_dist.fromIterable$1(tx.identifiers());
|
|
114
|
+
const otherTxIds = require_dist.fromIterable$1(otherTx.identifiers());
|
|
115
|
+
const smallerSize = require_dist.min$1(require_dist.number)(require_dist.size(txIds), require_dist.size(otherTxIds));
|
|
116
|
+
return require_dist.size(require_dist.intersection(txIds, otherTxIds)) == smallerSize;
|
|
117
|
+
},
|
|
118
|
+
isTx(tx) {
|
|
119
|
+
return tx instanceof _midnight_ntwrk_ledger_v8.Transaction;
|
|
120
|
+
},
|
|
121
|
+
serialize(tx) {
|
|
122
|
+
return tx.serialize();
|
|
123
|
+
}
|
|
124
|
+
};
|
|
125
|
+
/**
|
|
126
|
+
* Lifts one ledger version's trait onto the handle the facade actually carries.
|
|
127
|
+
*
|
|
128
|
+
* @remarks
|
|
129
|
+
* The router has already chosen this trait by the version stamped on the handle, so unwrapping at the same epoch is a
|
|
130
|
+
* restatement of the choice rather than a second one — but it is where a handle that does not belong is refused
|
|
131
|
+
* rather than handed to a reader that would misread it. A handle it cannot read is reported as not being its
|
|
132
|
+
* transaction at all, which is precisely what `isTx` is for.
|
|
133
|
+
* @param trait The ledger version's own reading of a transaction.
|
|
134
|
+
* @param epoch The range of protocol versions that ledger version answers for.
|
|
135
|
+
* @returns The same reading, in terms of handles.
|
|
136
|
+
*/
|
|
137
|
+
const overHandles = (trait, epoch) => {
|
|
138
|
+
const [stamp] = epoch;
|
|
139
|
+
const carried = (handle) => require_dist.getOrThrow$1(require_dist.WalletTransaction.unwrapWithin(handle, epoch));
|
|
140
|
+
return {
|
|
141
|
+
ids: (tx) => trait.ids(carried(tx)),
|
|
142
|
+
firstId: (tx) => trait.firstId(carried(tx)),
|
|
143
|
+
areAllTxIdsIncluded: (tx, txIds) => trait.areAllTxIdsIncluded(carried(tx), txIds),
|
|
144
|
+
isOneIncludedInOther: (tx, otherTx) => trait.isOneIncludedInOther(carried(tx), carried(otherTx)),
|
|
145
|
+
hasTTLExpired: (tx, creationTime, now) => trait.hasTTLExpired(carried(tx), creationTime, now),
|
|
146
|
+
serialize: (tx) => trait.serialize(carried(tx)),
|
|
147
|
+
deserialize: (serialized) => require_dist.WalletTransaction.adopt("Finalized", trait.deserialize(serialized), stamp),
|
|
148
|
+
isTx: (tx) => require_dist.WalletTransaction.is(tx) && require_dist.match$2(require_dist.WalletTransaction.unwrapWithin(tx, epoch), {
|
|
149
|
+
onLeft: () => false,
|
|
150
|
+
onRight: (carried) => trait.isTx(carried)
|
|
151
|
+
})
|
|
152
|
+
};
|
|
153
|
+
};
|
|
154
|
+
/**
|
|
155
|
+
* The traits pending transactions are read with, split at the protocol version this chain forks at.
|
|
156
|
+
*
|
|
157
|
+
* @remarks
|
|
158
|
+
* One trait per ledger version, each reading the handle it is registered for and refusing the other's. That is what
|
|
159
|
+
* lets a transaction authored before the v9 fork be recognised as stranded once the wallets cross — its bytes can
|
|
160
|
+
* never be included afterwards — instead of waiting out a TTL for an inclusion that can never happen.
|
|
161
|
+
* @param forkVersion The protocol version this chain forks at.
|
|
162
|
+
* @returns The registry the pending transaction service reads with.
|
|
163
|
+
*/
|
|
164
|
+
const finalizedTransactionTraits = (forkVersion) => require_dist.getOrThrow$1(require_dist.makeRegistryFromActivations(forkVersion > require_dist.MinSupportedVersion ? [{
|
|
165
|
+
sinceVersion: require_dist.MinSupportedVersion,
|
|
166
|
+
value: overHandles(v8FinalizedTransactionTrait, require_dist.epochOf(require_dist.MinSupportedVersion, forkVersion))
|
|
167
|
+
}, {
|
|
168
|
+
sinceVersion: forkVersion,
|
|
169
|
+
value: overHandles(v9FinalizedTransactionTrait, require_dist.epochOf(forkVersion, forkVersion))
|
|
170
|
+
}] : [{
|
|
171
|
+
sinceVersion: require_dist.MinSupportedVersion,
|
|
172
|
+
value: overHandles(v9FinalizedTransactionTrait, require_dist.epochOf(require_dist.MinSupportedVersion, require_dist.MinSupportedVersion))
|
|
173
|
+
}]));
|
|
174
|
+
//#endregion
|
|
175
|
+
//#region ../../packages/module/passport-account/node_modules/@midnightntwrk/wallet-sdk-facade/dist/index.js
|
|
176
|
+
/**
|
|
177
|
+
* Why the wallet gave up on a transaction, for the history entry.
|
|
178
|
+
*
|
|
179
|
+
* @remarks
|
|
180
|
+
* A chain rejection speaks for itself through the entry's status; an orphaned transaction has no chain verdict at all,
|
|
181
|
+
* so the entry is the only place the reason can be recorded.
|
|
182
|
+
*/
|
|
183
|
+
const rejectionReason = (result) => result.status === "ORPHANED_BY_FORK" ? "orphaned-by-protocol-upgrade" : void 0;
|
|
184
|
+
/**
|
|
185
|
+
* Full entry schema for transaction history. The common entry data and wallet-specific sections (`shielded`,
|
|
186
|
+
* `unshielded`, `dust`) live on every entry regardless of lifecycle; the `lifecycle` field is the only discriminator.
|
|
187
|
+
* Pass this to `InMemoryTransactionHistoryStorage` to enable serialize/restore.
|
|
188
|
+
*/
|
|
189
|
+
const WalletEntrySchema = require_dist.extendEntrySchema({
|
|
190
|
+
shielded: require_dist.optional(require_dist$2.ShieldedSectionSchema$1),
|
|
191
|
+
unshielded: require_dist.optional(require_dist$3.UnshieldedSectionSchema$1),
|
|
192
|
+
dust: require_dist.optional(require_dist$1.DustSectionSchema$1)
|
|
193
|
+
});
|
|
194
|
+
const isPendingWalletEntry = (entry) => entry.lifecycle.status === "pending";
|
|
195
|
+
const isFinalizedWalletEntry = (entry) => entry.lifecycle.status === "finalized";
|
|
196
|
+
/**
|
|
197
|
+
* Merge two wallet entries arriving under the same hash. Treats the entry as `T × lifecycle` per the storage model:
|
|
198
|
+
*
|
|
199
|
+
* - **Shared scalar facts about the tx** (`protocolVersion`, `status`, `timestamp`, `fees`) — first writer wins. Once any
|
|
200
|
+
* wallet has set the value, later writes are no-ops for these fields. This is correct because the value is the same
|
|
201
|
+
* across all wallets (it's a property of the on-chain tx, not the wallet's view of it).
|
|
202
|
+
* - **`identifiers`** — unioned (each wallet may surface a different identifier subset).
|
|
203
|
+
* - **`lifecycle`** — incoming wins, except that a late rejection cannot overwrite recorded on-chain inclusion.
|
|
204
|
+
* - **Wallet sections** (`shielded`, `unshielded`, `dust`) — combined via per-section merge when both sides have them;
|
|
205
|
+
* otherwise whichever side is present is used.
|
|
206
|
+
*/
|
|
207
|
+
/**
|
|
208
|
+
* Combine two optional values under a merge function: if both sides have it, delegate to `merge`; otherwise return
|
|
209
|
+
* whichever side is present (or `undefined` if neither). Encapsulates the four-way pattern used for every wallet
|
|
210
|
+
* section in {@link mergeWalletEntries}.
|
|
211
|
+
*/
|
|
212
|
+
const mergeOptionalSection = (existing, incoming, merge) => {
|
|
213
|
+
if (existing !== void 0 && incoming !== void 0) return merge(existing, incoming);
|
|
214
|
+
return existing ?? incoming;
|
|
215
|
+
};
|
|
216
|
+
function mergeWalletEntries(existing, incoming) {
|
|
217
|
+
const identifiers = Array.from(new Set([...existing.identifiers, ...incoming.identifiers]));
|
|
218
|
+
const shielded = mergeOptionalSection(existing.shielded, incoming.shielded, require_dist$2.mergeShieldedSections$1);
|
|
219
|
+
const unshielded = mergeOptionalSection(existing.unshielded, incoming.unshielded, require_dist$3.mergeUnshieldedSections$1);
|
|
220
|
+
const dust = mergeOptionalSection(existing.dust, incoming.dust, require_dist$1.mergeDustSections$1);
|
|
221
|
+
return {
|
|
222
|
+
hash: existing.hash,
|
|
223
|
+
identifiers,
|
|
224
|
+
protocolVersion: existing.protocolVersion ?? incoming.protocolVersion,
|
|
225
|
+
status: existing.status ?? incoming.status,
|
|
226
|
+
timestamp: existing.timestamp ?? incoming.timestamp,
|
|
227
|
+
fees: existing.fees ?? incoming.fees,
|
|
228
|
+
lifecycle: existing.lifecycle.status === "finalized" && incoming.lifecycle.status === "rejected" ? existing.lifecycle : incoming.lifecycle,
|
|
229
|
+
...shielded !== void 0 ? { shielded } : {},
|
|
230
|
+
...unshielded !== void 0 ? { unshielded } : {},
|
|
231
|
+
...dust !== void 0 ? { dust } : {}
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Storage key for a tx we're about to submit (record as pending). The hash comes from {@link txHistoryHash}, which the
|
|
236
|
+
* revert side uses too — so a tx keyed here while pending resolves to the same key when later confirmed or reverted.
|
|
237
|
+
*/
|
|
238
|
+
const submitTxHistoryKey = (tx) => ({
|
|
239
|
+
hash: txHistoryHash(tx),
|
|
240
|
+
identifiers: tx.identifiers()
|
|
241
|
+
});
|
|
242
|
+
/**
|
|
243
|
+
* Storage key for a tx we're about to revert (record as rejected). Shares {@link txHistoryHash} with the submit side so
|
|
244
|
+
* the rejected entry lands on the pending entry in place. Returns `undefined` only when the tx has no identifiers at
|
|
245
|
+
* all (nothing to revert).
|
|
246
|
+
*/
|
|
247
|
+
const revertTxHistoryKey = (tx) => {
|
|
248
|
+
const identifiers = tx.identifiers();
|
|
249
|
+
if (identifiers.length === 0) return void 0;
|
|
250
|
+
return {
|
|
251
|
+
hash: txHistoryHash(tx),
|
|
252
|
+
identifiers
|
|
253
|
+
};
|
|
254
|
+
};
|
|
255
|
+
const v9Authoring = {
|
|
256
|
+
sampleSigningKey: () => _midnightntwrk_ledger_v9.sampleSigningKey(),
|
|
257
|
+
signatureVerifyingKey: (signingKey) => _midnightntwrk_ledger_v9.signatureVerifyingKey(signingKey),
|
|
258
|
+
signData: (signingKey, data) => _midnightntwrk_ledger_v9.signData(signingKey, data),
|
|
259
|
+
deserializers: {
|
|
260
|
+
Unproven: (bytes) => _midnightntwrk_ledger_v9.Transaction.deserialize("signature", "pre-proof", "pre-binding", bytes),
|
|
261
|
+
Unbound: (bytes) => _midnightntwrk_ledger_v9.Transaction.deserialize("signature", "proof", "pre-binding", bytes),
|
|
262
|
+
Finalized: (bytes) => _midnightntwrk_ledger_v9.Transaction.deserialize("signature", "proof", "binding", bytes)
|
|
263
|
+
}
|
|
264
|
+
};
|
|
265
|
+
const v8Authoring = {
|
|
266
|
+
sampleSigningKey: () => _midnight_ntwrk_ledger_v8.sampleSigningKey(),
|
|
267
|
+
signatureVerifyingKey: (signingKey) => require_v8Signatures.liftSignatureVerifyingKey(_midnight_ntwrk_ledger_v8.signatureVerifyingKey(signingKey)),
|
|
268
|
+
signData: (signingKey, data) => require_v8Signatures.liftSignature(_midnight_ntwrk_ledger_v8.signData(signingKey, data)),
|
|
269
|
+
deserializers: {
|
|
270
|
+
Unproven: (bytes) => _midnight_ntwrk_ledger_v8.Transaction.deserialize("signature", "pre-proof", "pre-binding", bytes),
|
|
271
|
+
Unbound: (bytes) => _midnight_ntwrk_ledger_v8.Transaction.deserialize("signature", "proof", "pre-binding", bytes),
|
|
272
|
+
Finalized: (bytes) => _midnight_ntwrk_ledger_v8.Transaction.deserialize("signature", "proof", "binding", bytes)
|
|
273
|
+
}
|
|
274
|
+
};
|
|
275
|
+
const TokenKindsToBalance = new class {
|
|
276
|
+
allTokenKinds = [
|
|
277
|
+
"shielded",
|
|
278
|
+
"unshielded",
|
|
279
|
+
"dust"
|
|
280
|
+
];
|
|
281
|
+
toFlags = (tokenKinds) => {
|
|
282
|
+
return require_dist.pipe(tokenKinds, (kinds) => kinds === "all" ? this.allTokenKinds : kinds, (kinds) => ({
|
|
283
|
+
shouldBalanceUnshielded: kinds.includes("unshielded"),
|
|
284
|
+
shouldBalanceShielded: kinds.includes("shielded"),
|
|
285
|
+
shouldBalanceDust: kinds.includes("dust")
|
|
286
|
+
}));
|
|
287
|
+
};
|
|
288
|
+
}();
|
|
289
|
+
const BalancingRecipe = {
|
|
290
|
+
isRecipe: (value) => {
|
|
291
|
+
return typeof value === "object" && value !== null && "type" in value && typeof value.type === "string" && [
|
|
292
|
+
"FINALIZED_TRANSACTION",
|
|
293
|
+
"UNBOUND_TRANSACTION",
|
|
294
|
+
"UNPROVEN_TRANSACTION"
|
|
295
|
+
].includes(value.type);
|
|
296
|
+
},
|
|
297
|
+
getTransactions: (recipe) => {
|
|
298
|
+
switch (recipe.type) {
|
|
299
|
+
case "FINALIZED_TRANSACTION": return [recipe.originalTransaction, recipe.balancingTransaction];
|
|
300
|
+
case "UNBOUND_TRANSACTION": {
|
|
301
|
+
const balancingPart = recipe.balancingTransaction ? [recipe.balancingTransaction] : [];
|
|
302
|
+
return [recipe.baseTransaction, ...balancingPart];
|
|
303
|
+
}
|
|
304
|
+
case "UNPROVEN_TRANSACTION": return [recipe.transaction];
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
};
|
|
308
|
+
/**
|
|
309
|
+
* The lowest of the protocol versions the three wallets have reached.
|
|
310
|
+
*
|
|
311
|
+
* @remarks
|
|
312
|
+
* The three wallets follow the same chain but not in lock-step: each recognises a protocol version change when its own
|
|
313
|
+
* synchronization reaches it, so around a fork they disagree for a while. A transaction spans all three, so the one
|
|
314
|
+
* still behind is what bounds the facade as a whole — the highest version every wallet is known to be at.
|
|
315
|
+
* @param versions The version each wallet has reached.
|
|
316
|
+
* @returns The lowest of the three.
|
|
317
|
+
*/
|
|
318
|
+
const lowestProtocolVersion = (versions) => [
|
|
319
|
+
versions.shielded,
|
|
320
|
+
versions.unshielded,
|
|
321
|
+
versions.dust
|
|
322
|
+
].reduce((lowest, candidate) => candidate < lowest ? candidate : lowest);
|
|
323
|
+
/**
|
|
324
|
+
* The ledger-v9 key objects the wallets' own `start` takes, from whichever material the caller supplied.
|
|
325
|
+
*
|
|
326
|
+
* @remarks
|
|
327
|
+
* Only the ledger-v9 side is needed here: a wallet built from seeds or from both versions' keys already holds what its
|
|
328
|
+
* V1 variant needs, retained when it was built. What `start` supplies is the side the wallet's own API speaks.
|
|
329
|
+
*/
|
|
330
|
+
const v9KeysOf = (material) => "v9" in material ? material.v9 : {
|
|
331
|
+
shielded: _midnightntwrk_ledger_v9.ZswapSecretKeys.fromSeed(material.shielded),
|
|
332
|
+
dust: _midnightntwrk_ledger_v9.DustSecretKey.fromSeed(material.dust)
|
|
333
|
+
};
|
|
334
|
+
/** The three wallets in a fixed order, so {@link protocolPhaseOf} reports them the same way every time. */
|
|
335
|
+
const walletKinds = [
|
|
336
|
+
"shielded",
|
|
337
|
+
"unshielded",
|
|
338
|
+
"dust"
|
|
339
|
+
];
|
|
340
|
+
/**
|
|
341
|
+
* Reads whether the wallets are settled on one side of a protocol boundary, or still crossing it.
|
|
342
|
+
*
|
|
343
|
+
* @remarks
|
|
344
|
+
* Derived entirely from the version each wallet has reported and where the boundary lies — the same two facts every
|
|
345
|
+
* other version-routing decision in the SDK is made from, so this reading cannot disagree with them.
|
|
346
|
+
* @param versions The version each wallet has reached.
|
|
347
|
+
* @param forkVersion The version at which the chain hands over to the next ledger version.
|
|
348
|
+
* @returns The reading. See {@link ProtocolPhase}.
|
|
349
|
+
*/
|
|
350
|
+
const protocolPhaseOf = (versions, forkVersion) => {
|
|
351
|
+
const reported = walletKinds.map((kind) => [kind, versions[kind]]);
|
|
352
|
+
const from = lowestProtocolVersion(versions);
|
|
353
|
+
const epoch = require_dist.epochOf(from, forkVersion);
|
|
354
|
+
const crossed = reported.filter(([, version]) => !require_dist.withinRange(version, epoch));
|
|
355
|
+
if (crossed.length === 0) return {
|
|
356
|
+
_tag: "Settled",
|
|
357
|
+
version: from
|
|
358
|
+
};
|
|
359
|
+
return {
|
|
360
|
+
_tag: "Crossing",
|
|
361
|
+
from,
|
|
362
|
+
to: crossed.reduce((highest, [, version]) => version > highest ? version : highest, crossed[0][1]),
|
|
363
|
+
behind: reported.filter(([, version]) => require_dist.withinRange(version, epoch)).map(([kind]) => kind)
|
|
364
|
+
};
|
|
365
|
+
};
|
|
366
|
+
/** Reads what has become of a transaction from the verdict the pending set holds, if it holds one. */
|
|
367
|
+
const pendingStatusOf = (result) => {
|
|
368
|
+
if (result === void 0) return { _tag: "Submitted" };
|
|
369
|
+
switch (result.status) {
|
|
370
|
+
case "SUCCESS": return {
|
|
371
|
+
_tag: "Confirmed",
|
|
372
|
+
segments: result.segments
|
|
373
|
+
};
|
|
374
|
+
case "FAILURE":
|
|
375
|
+
case "PARTIAL_SUCCESS": return {
|
|
376
|
+
_tag: "Rejected",
|
|
377
|
+
segments: result.segments
|
|
378
|
+
};
|
|
379
|
+
case "ORPHANED_BY_FORK": return {
|
|
380
|
+
_tag: "Orphaned",
|
|
381
|
+
authoredFor: result.authoredFor,
|
|
382
|
+
chainNow: result.chainNow
|
|
383
|
+
};
|
|
384
|
+
}
|
|
385
|
+
};
|
|
386
|
+
/**
|
|
387
|
+
* The pending transactions as an application reads them.
|
|
388
|
+
*
|
|
389
|
+
* @remarks
|
|
390
|
+
* A projection over the pending set the services keep, not a second copy of it: the facts are the same, stated as a
|
|
391
|
+
* list of transactions with a status each rather than as the bag the machinery works in.
|
|
392
|
+
* @param pending The pending set.
|
|
393
|
+
* @returns One entry per transaction, in the order the wallet recorded them.
|
|
394
|
+
*/
|
|
395
|
+
const pendingTransactionsOf = (pending) => pending.all.map((item) => ({
|
|
396
|
+
transaction: item.tx,
|
|
397
|
+
submittedAt: item.creationTime,
|
|
398
|
+
authoredFor: item.protocolVersion,
|
|
399
|
+
status: pendingStatusOf("result" in item ? item.result : void 0)
|
|
400
|
+
}));
|
|
401
|
+
var FacadeState = class {
|
|
402
|
+
shielded;
|
|
403
|
+
unshielded;
|
|
404
|
+
dust;
|
|
405
|
+
pending;
|
|
406
|
+
/** The protocol version each of the three wallets has reached. */
|
|
407
|
+
get protocolVersion() {
|
|
408
|
+
return {
|
|
409
|
+
shielded: this.shielded.protocolVersion,
|
|
410
|
+
unshielded: this.unshielded.protocolVersion,
|
|
411
|
+
dust: this.dust.protocolVersion
|
|
412
|
+
};
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* The protocol version the facade as a whole can act at: the lowest the three wallets have reached.
|
|
416
|
+
*
|
|
417
|
+
* @remarks
|
|
418
|
+
* Around a protocol boundary the three wallets cross at slightly different moments, and a transaction needs all
|
|
419
|
+
* three. This is the version every one of them is known to understand.
|
|
420
|
+
*/
|
|
421
|
+
get activeProtocolVersion() {
|
|
422
|
+
return lowestProtocolVersion(this.protocolVersion);
|
|
423
|
+
}
|
|
424
|
+
/**
|
|
425
|
+
* Whether the three wallets are settled on one side of the protocol boundary, or still crossing it.
|
|
426
|
+
*
|
|
427
|
+
* @remarks
|
|
428
|
+
* Additive, and the reading `protocolVersion` alone cannot give: three versions that differ tell an application
|
|
429
|
+
* nothing about whether the difference matters. See {@link ProtocolPhase}.
|
|
430
|
+
*/
|
|
431
|
+
get protocol() {
|
|
432
|
+
return protocolPhaseOf(this.protocolVersion, this.#forkVersion);
|
|
433
|
+
}
|
|
434
|
+
get isSynced() {
|
|
435
|
+
return this.shielded.state.progress.isStrictlyComplete() && this.dust.state.progress.isStrictlyComplete() && this.unshielded.progress.isStrictlyComplete();
|
|
436
|
+
}
|
|
437
|
+
/** Where the chain hands over from one ledger version to the next, which is what {@link protocol} is read against. */
|
|
438
|
+
#forkVersion;
|
|
439
|
+
constructor(shielded, unshielded, dust, pending, forkVersion = require_dist.MinSupportedVersion) {
|
|
440
|
+
this.shielded = shielded;
|
|
441
|
+
this.unshielded = unshielded;
|
|
442
|
+
this.dust = dust;
|
|
443
|
+
this.pending = pendingTransactionsOf(pending);
|
|
444
|
+
this.#forkVersion = forkVersion;
|
|
445
|
+
}
|
|
446
|
+
};
|
|
447
|
+
const DEFAULT_TTL_MS = 3600 * 1e3;
|
|
448
|
+
/**
|
|
449
|
+
* The fork schedule the facade presets when a configuration names none: {@link ProtocolVersion.V9NativeForkSchedule},
|
|
450
|
+
* ledger-v9 from the version a 2.x node reports.
|
|
451
|
+
*
|
|
452
|
+
* @remarks
|
|
453
|
+
* Where a chain forks is a fact about the chain, which is why each wallet package requires `forks` and presets nothing.
|
|
454
|
+
* The facade is the one place a preset decides nothing the SDK has not already decided: every chain the 2.x node line
|
|
455
|
+
* runs hands over at this version, so an application copying the constant into its configuration only restates it. A
|
|
456
|
+
* chain that hands over elsewhere states its own `forks`, which wins.
|
|
457
|
+
*/
|
|
458
|
+
const DefaultForkSchedule = require_dist.V9NativeForkSchedule;
|
|
459
|
+
var WalletFacade = class WalletFacade {
|
|
460
|
+
static makeDefaultSubmissionService(config) {
|
|
461
|
+
return require_dist.makeDefaultSubmissionService(config);
|
|
462
|
+
}
|
|
463
|
+
static makeDefaultPendingTransactionsService(config) {
|
|
464
|
+
return require_dist.PendingTransactionsServiceImpl.init({
|
|
465
|
+
configuration: config,
|
|
466
|
+
txTraits: finalizedTransactionTraits(config.forks.v9)
|
|
467
|
+
});
|
|
468
|
+
}
|
|
469
|
+
/**
|
|
470
|
+
* Builds the proving service a configuration describes.
|
|
471
|
+
*
|
|
472
|
+
* @remarks
|
|
473
|
+
* Handed the same fork schedule the wallets are built with, because a proving backend is chosen by the epoch a
|
|
474
|
+
* transaction belongs to and the two ends of that question must not be able to compute the boundary differently.
|
|
475
|
+
*/
|
|
476
|
+
static makeDefaultProvingService(config) {
|
|
477
|
+
return require_dist.getOrThrowWith(require_dist.makeDefaultVersionedProvingService(config, config.forks), (error) => new Error(error.message));
|
|
478
|
+
}
|
|
479
|
+
/**
|
|
480
|
+
* Fills in what the facade presets — `forks`, as {@link DefaultForkSchedule} — so that the result is a configuration a
|
|
481
|
+
* wallet package can be built from.
|
|
482
|
+
*
|
|
483
|
+
* @remarks
|
|
484
|
+
* {@link WalletFacade.init} does this itself, once and before anything is built, so the wallets, the default services
|
|
485
|
+
* and the facade's own boundary cannot be given different schedules, and no factory needs to call it. It is public
|
|
486
|
+
* for code outside a factory that needs the configuration the facade will use: an application building a wallet
|
|
487
|
+
* package directly, or reading `forks` back to author a transaction for the right ledger version. Resolving twice
|
|
488
|
+
* is the same as resolving once, so `init` may be handed the result.
|
|
489
|
+
* @example
|
|
490
|
+
* ```typescript
|
|
491
|
+
* const configuration = WalletFacade.resolveConfiguration({ networkId: 'undeployed', ... });
|
|
492
|
+
* const facade = await WalletFacade.init({ configuration, shielded: (config) => ShieldedWallet(config), ... });
|
|
493
|
+
* const authoredForV9 = protocolVersion >= configuration.forks.v9;
|
|
494
|
+
* ```;
|
|
495
|
+
*
|
|
496
|
+
* @param configuration The configuration as given, with or without `forks`.
|
|
497
|
+
* @returns The same configuration with `forks` present: the schedule it named, or {@link DefaultForkSchedule}.
|
|
498
|
+
*/
|
|
499
|
+
static resolveConfiguration(configuration) {
|
|
500
|
+
return {
|
|
501
|
+
...configuration,
|
|
502
|
+
forks: configuration.forks ?? DefaultForkSchedule
|
|
503
|
+
};
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
506
|
+
* Fetches the current Terms and Conditions from the network indexer.
|
|
507
|
+
*
|
|
508
|
+
* This is a static, pre-initialization utility — no wallet instance is required. Wallet builders should call this
|
|
509
|
+
* before or independently of wallet initialization to display the current T&C to end users and obtain the hash for
|
|
510
|
+
* content verification.
|
|
511
|
+
*
|
|
512
|
+
* The returned `hash` is the hex-encoded SHA-256 hash of the document at `url`. Wallet builders are responsible for
|
|
513
|
+
* fetching and rendering the document content via `url` in whatever manner suits their application.
|
|
514
|
+
*
|
|
515
|
+
* @param configuration - An object with an `indexerClientConnection.indexerHttpUrl`. Any wallet configuration that
|
|
516
|
+
* satisfies {@link FetchTermsAndConditionsConfiguration} can be passed directly.
|
|
517
|
+
* @returns A promise resolving to the current {@link TermsAndConditions}, or rejecting if no Terms and Conditions have
|
|
518
|
+
* been set on the network yet.
|
|
519
|
+
*/
|
|
520
|
+
static async fetchTermsAndConditions(configuration) {
|
|
521
|
+
const tc = (await require_dist.runPromise(require_dist.FetchTermsAndConditions, {}, { url: configuration.indexerClientConnection.indexerHttpUrl })).block?.systemParameters?.termsAndConditions;
|
|
522
|
+
if (!tc) throw new Error("Terms and Conditions are not currently set on the network.");
|
|
523
|
+
return tc;
|
|
524
|
+
}
|
|
525
|
+
/**
|
|
526
|
+
* Default initialization for {@link WalletFacade}. It is a static method, which takes an object holding configuration
|
|
527
|
+
* and initialization of necessary components. Specifically - it requires following fields:
|
|
528
|
+
*
|
|
529
|
+
* - `configuration` - holding a configuration, which needs to extend {@link DefaultConfiguration} - this way allows to
|
|
530
|
+
* convey use-case-specific settings in the same way, as the SDK works by default. `forks` may be left out; every
|
|
531
|
+
* factory below is handed a {@link ResolvedConfiguration}, which always has it — what
|
|
532
|
+
* {@link WalletFacade.resolveConfiguration} returns
|
|
533
|
+
* - `shielded` - a function taking the configuration and returning shielded wallet (or a promise with such)
|
|
534
|
+
* implementing {@link ShieldedWalletAPI}
|
|
535
|
+
* - `unshielded` - a function taking the configuration and returning unshielded wallet (or a promise with such)
|
|
536
|
+
* implementing {@link UnshieldedWalletAPI}
|
|
537
|
+
* - `dust` - a function taking the configuration and returning Dust wallet (or a promise with such) implementing
|
|
538
|
+
* {@link DustWalletAPI} There are some optional services/abstractions to provide, too. If not provided - default
|
|
539
|
+
* implementations will be used, each of them is initialized by a function taking the configuration and returning
|
|
540
|
+
* proper implementation (wrapped in a {@link Promise} or not).
|
|
541
|
+
* - `submissionService` - needs to implement {@link SubmissionService} for a {@link ledgerV9.FinalizedTransaction} to
|
|
542
|
+
* submit transactions to the network, default uses Node RPC connection
|
|
543
|
+
* - `pendingTransactionsService` - needs to implement {@link PendingTransactionsService} for a
|
|
544
|
+
* {@link ledgerV9.FinalizedTransaction} to keep track of pending transactions, default uses in-memory
|
|
545
|
+
* implementation
|
|
546
|
+
* - `provingService` - needs to implement {@link VersionedProvingService} to prove it, default uses proving server
|
|
547
|
+
* - `clock` - needs to implement {@link Clock.Clock} for getting current time, default uses system clock
|
|
548
|
+
*/
|
|
549
|
+
static async init(initParams) {
|
|
550
|
+
const configuration = WalletFacade.resolveConfiguration(initParams.configuration);
|
|
551
|
+
const submissionService = await Promise.resolve(initParams.submissionService ? initParams.submissionService(configuration) : WalletFacade.makeDefaultSubmissionService(configuration));
|
|
552
|
+
const pendingTransactionsService = await Promise.resolve(initParams.pendingTransactionsService ? initParams.pendingTransactionsService(configuration) : WalletFacade.makeDefaultPendingTransactionsService(configuration));
|
|
553
|
+
const provingService = await Promise.resolve(initParams.provingService ? initParams.provingService(configuration) : WalletFacade.makeDefaultProvingService(configuration));
|
|
554
|
+
const shielded = await Promise.resolve(initParams.shielded(configuration));
|
|
555
|
+
const unshielded = await Promise.resolve(initParams.unshielded(configuration));
|
|
556
|
+
const dust = await Promise.resolve(initParams.dust(configuration));
|
|
557
|
+
const clock = await Promise.resolve(initParams.clock ? initParams.clock(configuration) : require_dist.systemClock);
|
|
558
|
+
const fetchBlockData = await Promise.resolve(initParams.fetchBlockData ? initParams.fetchBlockData(configuration) : require_dist.makeDefaultBlockDataFetcher(configuration));
|
|
559
|
+
return new WalletFacade(shielded, unshielded, dust, submissionService, pendingTransactionsService, provingService, await Promise.resolve(initParams.validationService ? initParams.validationService(configuration, {
|
|
560
|
+
fetchBlockData,
|
|
561
|
+
clock
|
|
562
|
+
}) : require_dist.makeDefaultVersionedValidationService({
|
|
563
|
+
fetchBlockData,
|
|
564
|
+
networkId: configuration.networkId,
|
|
565
|
+
clock
|
|
566
|
+
}, configuration.forks.v9)), configuration.txHistoryStorage, configuration.forks.v9, clock);
|
|
567
|
+
}
|
|
568
|
+
shielded;
|
|
569
|
+
unshielded;
|
|
570
|
+
dust;
|
|
571
|
+
submissionService;
|
|
572
|
+
pendingTransactionsService;
|
|
573
|
+
provingService;
|
|
574
|
+
validationService;
|
|
575
|
+
#txHistoryStorage;
|
|
576
|
+
clock;
|
|
577
|
+
#pendingSubscription;
|
|
578
|
+
#protocolVersionSubscription;
|
|
579
|
+
/**
|
|
580
|
+
* The protocol version the wallets have all reached, as last observed.
|
|
581
|
+
*
|
|
582
|
+
* @remarks
|
|
583
|
+
* `Option.none()` until the three wallets have each emitted once. A transaction stamped with `none` is never
|
|
584
|
+
* orphaned, so an unobserved version costs a transaction nothing but the ability to be given up on early.
|
|
585
|
+
*/
|
|
586
|
+
#observedProtocolVersion = new rxjs.BehaviorSubject(require_dist.none());
|
|
587
|
+
/** Where the chain hands over from one ledger version to the next, which is what divides the two epochs. */
|
|
588
|
+
#forkVersion;
|
|
589
|
+
/**
|
|
590
|
+
* Constructor is private on purpose - much of initialization of the facade is potentially asynchronous, and adding
|
|
591
|
+
* new parameters is a breaking change to the users Use {@link WalletFacade.init} instead
|
|
592
|
+
*
|
|
593
|
+
* @private
|
|
594
|
+
*/
|
|
595
|
+
constructor(shieldedWallet, unshieldedWallet, dustWallet, submissionService, pendingTransactionsService, provingService, validationService, txHistoryStorage, forkVersion, clock = require_dist.systemClock) {
|
|
596
|
+
this.shielded = shieldedWallet;
|
|
597
|
+
this.unshielded = unshieldedWallet;
|
|
598
|
+
this.dust = dustWallet;
|
|
599
|
+
this.submissionService = submissionService;
|
|
600
|
+
this.pendingTransactionsService = pendingTransactionsService;
|
|
601
|
+
this.provingService = provingService;
|
|
602
|
+
this.validationService = validationService;
|
|
603
|
+
this.#txHistoryStorage = txHistoryStorage;
|
|
604
|
+
this.#forkVersion = forkVersion;
|
|
605
|
+
this.clock = clock;
|
|
606
|
+
this.#pendingSubscription = this.pendingTransactionsService.state().pipe((0, rxjs.concatMap)((pending) => require_dist.allRejected(pending)), (0, rxjs.concatMap)(async (item) => {
|
|
607
|
+
if (!await this.reconcileFinalizedTransaction(item.tx, await this.#txHistoryStorage.getAll())) await this.revert(item.tx, rejectionReason(item.result));
|
|
608
|
+
})).subscribe();
|
|
609
|
+
this.#protocolVersionSubscription = (0, rxjs.combineLatest)([
|
|
610
|
+
this.shielded.state,
|
|
611
|
+
this.unshielded.state,
|
|
612
|
+
this.dust.state
|
|
613
|
+
]).pipe((0, rxjs.map)(([shieldedState, unshieldedState, dustState]) => lowestProtocolVersion({
|
|
614
|
+
shielded: shieldedState.protocolVersion,
|
|
615
|
+
unshielded: unshieldedState.protocolVersion,
|
|
616
|
+
dust: dustState.protocolVersion
|
|
617
|
+
})), (0, rxjs.distinctUntilChanged)(), (0, rxjs.tap)((version) => this.#observedProtocolVersion.next(require_dist.some(version))), (0, rxjs.concatMap)((version) => this.pendingTransactionsService.orphanBeyond(version))).subscribe();
|
|
618
|
+
}
|
|
619
|
+
/**
|
|
620
|
+
* The protocol version the facade is currently acting at.
|
|
621
|
+
*
|
|
622
|
+
* @remarks
|
|
623
|
+
* The lowest the three wallets have reached, once they have all reported; the minimum supported version until then,
|
|
624
|
+
* which is the epoch a wallet with no history belongs to. It is what a transaction the facade builds is stamped
|
|
625
|
+
* with, and what the side of the boundary it accepts transactions from is measured against.
|
|
626
|
+
*/
|
|
627
|
+
currentVersion() {
|
|
628
|
+
return require_dist.getOrElse(this.#observedProtocolVersion.getValue(), () => require_dist.MinSupportedVersion);
|
|
629
|
+
}
|
|
630
|
+
/** The range of protocol versions on the same side of the boundary as a given one. */
|
|
631
|
+
epochOf(version) {
|
|
632
|
+
return require_dist.epochOf(version, this.#forkVersion);
|
|
633
|
+
}
|
|
634
|
+
/** The range of protocol versions on the facade's current side of the boundary. */
|
|
635
|
+
currentEpoch() {
|
|
636
|
+
return this.epochOf(this.currentVersion());
|
|
637
|
+
}
|
|
638
|
+
/**
|
|
639
|
+
* Reads a transaction an application handed in, refusing one built on the other side of the boundary.
|
|
640
|
+
*
|
|
641
|
+
* @remarks
|
|
642
|
+
* The enforcement point for everything that enters the facade — a transaction the wallets built, or one an
|
|
643
|
+
* application authored and sealed with `WalletTransaction.adopt`. Only the current epoch is accepted, because a
|
|
644
|
+
* transaction of the other one cannot be merged, proved or submitted alongside anything the facade would build for
|
|
645
|
+
* it. Both a stranded ledger-v8 transaction after the crossing and a ledger-v9 transaction offered before it are
|
|
646
|
+
* refused here, by name, with the versions written down.
|
|
647
|
+
* @param handle The handle to read.
|
|
648
|
+
* @returns The carried transaction.
|
|
649
|
+
* @throws {@link ProtocolVersionMismatchError} When the transaction was built on the other side of the boundary.
|
|
650
|
+
*/
|
|
651
|
+
accept(handle) {
|
|
652
|
+
return require_dist.getOrThrowWith(require_dist.WalletTransaction.unwrapWithin(handle, this.currentEpoch()), (error) => error);
|
|
653
|
+
}
|
|
654
|
+
/**
|
|
655
|
+
* Seals a transaction the facade or a wallet produced, at the version its bytes were fixed by.
|
|
656
|
+
*
|
|
657
|
+
* @remarks
|
|
658
|
+
* The version is the caller's to state, never read from the facade here, because the two can differ: a crossing can
|
|
659
|
+
* land while a transaction is at the prover, and what comes back is still the bytes of the ledger version that made
|
|
660
|
+
* them. A caller sealing something it has just built passes the version it is building at; a caller sealing
|
|
661
|
+
* something that has travelled through an await passes the version stamped on the handle it started from.
|
|
662
|
+
* @param stage How far along the building of the transaction the sealed handle is.
|
|
663
|
+
* @param transaction The transaction to seal.
|
|
664
|
+
* @param protocolVersion The version the transaction's bytes were fixed by.
|
|
665
|
+
* @returns The sealed handle.
|
|
666
|
+
*/
|
|
667
|
+
seal(stage, transaction, protocolVersion) {
|
|
668
|
+
return require_dist.WalletTransaction.adopt(stage, transaction, protocolVersion);
|
|
669
|
+
}
|
|
670
|
+
/** The ledger primitives the facade signs with on its current side of the boundary. */
|
|
671
|
+
authoring() {
|
|
672
|
+
return this.currentVersion() < this.#forkVersion ? v8Authoring : v9Authoring;
|
|
673
|
+
}
|
|
674
|
+
/**
|
|
675
|
+
* Reads a transaction from bytes that name no protocol version, at the version the facade is acting at.
|
|
676
|
+
*
|
|
677
|
+
* @remarks
|
|
678
|
+
* For bytes that reach the wallet from outside the SDK — a dApp connector's serialized transaction above all, whose
|
|
679
|
+
* contract carries no version alongside them. The bytes cannot say which ledger version wrote them, so this answers
|
|
680
|
+
* with the only version the facade could act at anyway, and reads them with that version's ledger. Bytes the other
|
|
681
|
+
* ledger version wrote are refused here rather than misread, because the markers a stage names are part of what the
|
|
682
|
+
* ledger checks as it reads.
|
|
683
|
+
*
|
|
684
|
+
* The version is the facade's rather than the caller's, which is the point: a caller that reads
|
|
685
|
+
* {@link FacadeState.activeProtocolVersion} and seals a handle itself is answering the same question a moment
|
|
686
|
+
* earlier, with a crossing able to land in between. It is still only the version at the moment of the call — a
|
|
687
|
+
* crossing can land before the handle is used, and {@link ProtocolVersionMismatchError} from the operation that uses
|
|
688
|
+
* it is what says so.
|
|
689
|
+
* @example
|
|
690
|
+
* Balancing a transaction a dApp connector handed over as hex:
|
|
691
|
+
*
|
|
692
|
+
* ```typescript
|
|
693
|
+
* const handle = facade.adoptTransaction(Buffer.from(txHex, 'hex'), 'Unbound');
|
|
694
|
+
* const recipe = await facade.balanceUnboundTransaction(handle, { ttl });
|
|
695
|
+
* ```;
|
|
696
|
+
*
|
|
697
|
+
* @param bytes The transaction's own serialization, as the ledger version that wrote it produced it.
|
|
698
|
+
* @param stage How far along the building of the transaction these bytes are, which decides the markers they are read
|
|
699
|
+
* with.
|
|
700
|
+
* @returns The sealed handle, stamped with the protocol version the facade is acting at.
|
|
701
|
+
* @throws {@link WireFormatError} When the bytes are not a transaction of that version at that stage — which is what
|
|
702
|
+
* a transaction authored on the other side of a protocol boundary looks like from here.
|
|
703
|
+
*/
|
|
704
|
+
adoptTransaction(bytes, stage) {
|
|
705
|
+
const protocolVersion = this.currentVersion();
|
|
706
|
+
return require_dist.getOrThrowWith(require_dist.try_$1({
|
|
707
|
+
try: () => this.authoring().deserializers[stage](bytes),
|
|
708
|
+
catch: (cause) => new require_dist.WireFormatError({
|
|
709
|
+
message: `These bytes are not a transaction of protocol version ${protocolVersion} at stage ${stage} — that is the version this wallet is acting at, and a transaction built for another one has to be built again for it.`,
|
|
710
|
+
cause
|
|
711
|
+
})
|
|
712
|
+
}).pipe(require_dist.map$6((transaction) => require_dist.WalletTransaction.adopt(stage, transaction, protocolVersion))), (error) => error);
|
|
713
|
+
}
|
|
714
|
+
defaultTtl() {
|
|
715
|
+
return new Date(this.clock.now().getTime() + DEFAULT_TTL_MS);
|
|
716
|
+
}
|
|
717
|
+
/**
|
|
718
|
+
* Checks whether a transaction is structurally well-formed before passing it to a balance or submit method.
|
|
719
|
+
*
|
|
720
|
+
* Highly recommended in particular for transactions received from a 3rd party (e.g., a dApp or partner service)
|
|
721
|
+
* before forwarding them to a balance or submit method.
|
|
722
|
+
*
|
|
723
|
+
* TTL expiry, Network ID mismatch, and transaction structure are always enforced regardless of `flags`. All three
|
|
724
|
+
* configurable flags must be supplied explicitly — there are no defaults, so callers must be intentional about each
|
|
725
|
+
* check.
|
|
726
|
+
*
|
|
727
|
+
* Recommended flags per call site:
|
|
728
|
+
*
|
|
729
|
+
* | Method | enforceBalancing | verifySignatures | enforceLimits |
|
|
730
|
+
* | ----------------------------- | ---------------- | ---------------- | ------------- |
|
|
731
|
+
* | `submitTransaction` | `true` | `true` | `true` |
|
|
732
|
+
* | `balanceFinalizedTransaction` | `false` | `true` | `false` |
|
|
733
|
+
* | `balanceUnboundTransaction` | `false` | `false` | `false` |
|
|
734
|
+
* | `balanceUnprovenTransaction` | `false` | `false` | `false` |
|
|
735
|
+
*
|
|
736
|
+
* Real on-chain ledger parameters are always used — `options.blockData` is used if provided, otherwise the service
|
|
737
|
+
* fetches the latest block data via the configured fetcher. Pass `recipe.blockData` to reuse the fetch performed
|
|
738
|
+
* during balancing and avoid a redundant network call.
|
|
739
|
+
*
|
|
740
|
+
* @example
|
|
741
|
+
* ```typescript
|
|
742
|
+
* // Reuse the block data captured during balancing — no extra fetch
|
|
743
|
+
* const recipe = await facade.balanceFinalizedTransaction(tx, secretKeys, options);
|
|
744
|
+
* const finalizedTx = await facade.finalizeRecipe(recipe);
|
|
745
|
+
* await facade.validateTransaction(finalizedTx, {
|
|
746
|
+
* flags: { enforceBalancing: true, verifySignatures: true, enforceLimits: true },
|
|
747
|
+
* blockData: recipe.blockData,
|
|
748
|
+
* });
|
|
749
|
+
* await facade.submitTransaction(finalizedTx);
|
|
750
|
+
*
|
|
751
|
+
* // No recipe to source blockData from — the service fetches automatically
|
|
752
|
+
* await facade.validateTransaction(tx, {
|
|
753
|
+
* flags: { enforceBalancing: false, verifySignatures: false, enforceLimits: false },
|
|
754
|
+
* });
|
|
755
|
+
* ```;
|
|
756
|
+
*
|
|
757
|
+
* @param tx - The transaction to validate (`FinalizedTransaction`, `UnboundTransaction`, or `UnprovenTransaction`).
|
|
758
|
+
* @param options - Strictness flags and optional `blockData` to skip the fetch.
|
|
759
|
+
* @throws {@link WellFormedError} If the transaction fails any enabled check.
|
|
760
|
+
* @throws {@link ValidationFetchError} If the block-data fetch fails.
|
|
761
|
+
*/
|
|
762
|
+
async validateTransaction(tx, options) {
|
|
763
|
+
return this.validationService.validateTx(require_dist.getOrThrowWith(require_dist.WalletTransaction.unwrapWithin(tx, require_dist.epochOf(tx.protocolVersion, this.#forkVersion)), (error) => error), tx.protocolVersion, options);
|
|
764
|
+
}
|
|
765
|
+
/**
|
|
766
|
+
* Merges two unproven transactions of the same epoch, or returns whichever there is.
|
|
767
|
+
*
|
|
768
|
+
* @remarks
|
|
769
|
+
* Both are unwrapped before merging, which is where a pair from different epochs is refused: a merge across the
|
|
770
|
+
* boundary is not a failure to compute, it is unrepresentable, and saying so is the whole point of the stamp.
|
|
771
|
+
*/
|
|
772
|
+
mergeUnprovenTransactions(a, b) {
|
|
773
|
+
if (a && b) return this.seal("Unproven", this.accept(a).merge(this.accept(b)), this.currentVersion());
|
|
774
|
+
return a ?? b;
|
|
775
|
+
}
|
|
776
|
+
async createDustActionTransaction(action, nightUtxos, nightVerifyingKey, signDustRegistration) {
|
|
777
|
+
const ttl = this.defaultTtl();
|
|
778
|
+
const now = this.clock.now();
|
|
779
|
+
const isRegistration = action.type === "registration";
|
|
780
|
+
const dustReceiverAddress = isRegistration ? action.dustReceiverAddress : void 0;
|
|
781
|
+
const split = await this.dust.splitNightUtxosForDustRegistration(now, nightUtxos.map(({ utxo, meta }) => ({
|
|
782
|
+
...utxo,
|
|
783
|
+
ctime: meta.ctime,
|
|
784
|
+
registeredForDustGeneration: meta.registeredForDustGeneration
|
|
785
|
+
})), isRegistration);
|
|
786
|
+
const toUnshieldedUtxoWithMeta = (u) => ({
|
|
787
|
+
utxo: {
|
|
788
|
+
value: u.utxo.value,
|
|
789
|
+
type: u.utxo.type,
|
|
790
|
+
owner: u.utxo.owner,
|
|
791
|
+
intentHash: u.utxo.intentHash,
|
|
792
|
+
outputNo: u.utxo.outputNo
|
|
793
|
+
},
|
|
794
|
+
meta: {
|
|
795
|
+
ctime: u.utxo.ctime,
|
|
796
|
+
registeredForDustGeneration: u.utxo.registeredForDustGeneration
|
|
797
|
+
}
|
|
798
|
+
});
|
|
799
|
+
const guaranteedForUnshielded = split.guaranteedUtxos.map(toUnshieldedUtxoWithMeta);
|
|
800
|
+
const fallibleForUnshielded = split.fallibleUtxos.map(toUnshieldedUtxoWithMeta);
|
|
801
|
+
const txWithOffers = await this.unshielded.rotateUtxos(guaranteedForUnshielded, fallibleForUnshielded, nightVerifyingKey, ttl);
|
|
802
|
+
let txWithDustActions;
|
|
803
|
+
try {
|
|
804
|
+
txWithDustActions = await this.dust.attachDustRegistration(txWithOffers, now, nightVerifyingKey, dustReceiverAddress, split.feePayment);
|
|
805
|
+
} catch (error) {
|
|
806
|
+
await this.unshielded.revertTransaction(txWithOffers);
|
|
807
|
+
throw error;
|
|
808
|
+
}
|
|
809
|
+
const hasUnregisteredGuaranteed = split.guaranteedUtxos.some((u) => !u.utxo.registeredForDustGeneration);
|
|
810
|
+
if (isRegistration && hasUnregisteredGuaranteed) {
|
|
811
|
+
const fee = await this.dust.calculateFee([txWithDustActions]);
|
|
812
|
+
if (split.feePayment < fee) {
|
|
813
|
+
await this.unshielded.revertTransaction(txWithOffers);
|
|
814
|
+
throw Error(`Insufficient generated dust to cover registration fee (have ${split.feePayment}, need ${fee}). Use WalletFacade.waitForGeneratedDust(utxos, ${fee}) before retrying.`);
|
|
815
|
+
}
|
|
816
|
+
}
|
|
817
|
+
try {
|
|
818
|
+
const signedRecipe = await this.signRecipe({
|
|
819
|
+
type: "UNPROVEN_TRANSACTION",
|
|
820
|
+
protocolVersion: this.currentVersion(),
|
|
821
|
+
transaction: txWithDustActions
|
|
822
|
+
}, signDustRegistration);
|
|
823
|
+
if (signedRecipe.type !== "UNPROVEN_TRANSACTION") throw Error("signRecipe returned unexpected recipe type for dust action transaction.");
|
|
824
|
+
return signedRecipe.transaction;
|
|
825
|
+
} catch (error) {
|
|
826
|
+
await this.unshielded.revertTransaction(txWithOffers);
|
|
827
|
+
throw error;
|
|
828
|
+
}
|
|
829
|
+
}
|
|
830
|
+
state() {
|
|
831
|
+
return (0, rxjs.combineLatest)([
|
|
832
|
+
this.shielded.state,
|
|
833
|
+
this.unshielded.state,
|
|
834
|
+
this.dust.state,
|
|
835
|
+
this.pendingTransactionsService.state()
|
|
836
|
+
]).pipe((0, rxjs.map)(([shieldedState, unshieldedState, dustState, pending]) => new FacadeState(shieldedState, unshieldedState, dustState, pending, this.#forkVersion)));
|
|
837
|
+
}
|
|
838
|
+
async waitForSyncedState() {
|
|
839
|
+
const [shieldedState, unshieldedState, dustState, pending] = await Promise.all([
|
|
840
|
+
this.shielded.waitForSyncedState(),
|
|
841
|
+
this.unshielded.waitForSyncedState(),
|
|
842
|
+
this.dust.waitForSyncedState(),
|
|
843
|
+
(0, rxjs.firstValueFrom)(this.pendingTransactionsService.state())
|
|
844
|
+
]);
|
|
845
|
+
return new FacadeState(shieldedState, unshieldedState, dustState, pending, this.#forkVersion);
|
|
846
|
+
}
|
|
847
|
+
/**
|
|
848
|
+
* Submits a finalized transaction to the network and tracks it as pending until finalized or discarded.
|
|
849
|
+
*
|
|
850
|
+
* Call {@link validateTransaction} with `{ enforceBalancing: true, verifySignatures: true, enforceLimits: true }`
|
|
851
|
+
* before this method to surface structural errors with a clear diagnostic instead of a cryptic network rejection.
|
|
852
|
+
*
|
|
853
|
+
* @param tx - The finalized transaction to submit.
|
|
854
|
+
* @returns The transaction identifier.
|
|
855
|
+
* @throws {@link WellFormedError} — call {@link validateTransaction} first to get this error early.
|
|
856
|
+
*/
|
|
857
|
+
async submitTransaction(tx) {
|
|
858
|
+
const carried = this.accept(tx);
|
|
859
|
+
const identifiers = carried.identifiers();
|
|
860
|
+
try {
|
|
861
|
+
await this.pendingTransactionsService.addPendingTransaction(tx, this.#observedProtocolVersion.getValue());
|
|
862
|
+
const key = submitTxHistoryKey(carried);
|
|
863
|
+
await this.#txHistoryStorage.gotPending({
|
|
864
|
+
...key,
|
|
865
|
+
submittedAt: this.clock.now()
|
|
866
|
+
});
|
|
867
|
+
await this.submissionService.submitTransaction(tx, "Finalized");
|
|
868
|
+
return identifiers.at(-1);
|
|
869
|
+
} catch (error) {
|
|
870
|
+
await this.revert(tx);
|
|
871
|
+
throw error;
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
/**
|
|
875
|
+
* Balances a finalized transaction by adding shielded, unshielded, and dust inputs/outputs as needed.
|
|
876
|
+
*
|
|
877
|
+
* Call {@link validateTransaction} with `{ enforceBalancing: false, verifySignatures: true, enforceLimits: false }`
|
|
878
|
+
* before this method to surface structural errors early. `enforceBalancing` is `false` because the transaction is not
|
|
879
|
+
* yet balanced at this stage; `verifySignatures` is `true` because signatures are already present and must be valid.
|
|
880
|
+
*
|
|
881
|
+
* @param tx - The finalized transaction to balance.
|
|
882
|
+
* @param secretKeys - Secret keys for shielded and dust coin selection.
|
|
883
|
+
* @param options - TTL for the balancing transaction, and optional subset of token kinds to balance.
|
|
884
|
+
* @returns A {@link FinalizedTransactionRecipe} containing the original and balancing transactions.
|
|
885
|
+
*/
|
|
886
|
+
async balanceFinalizedTransaction(tx, options) {
|
|
887
|
+
const { ttl, tokenKindsToBalance = "all" } = options;
|
|
888
|
+
const { shouldBalanceDust, shouldBalanceShielded, shouldBalanceUnshielded } = TokenKindsToBalance.toFlags(tokenKindsToBalance);
|
|
889
|
+
const unshieldedBalancingTx = shouldBalanceUnshielded ? await this.unshielded.balanceFinalizedTransaction(tx) : void 0;
|
|
890
|
+
const shieldedBalancingTx = shouldBalanceShielded ? await this.shielded.balanceTransaction(tx) : void 0;
|
|
891
|
+
const mergedBalancingTx = this.mergeUnprovenTransactions(shieldedBalancingTx, unshieldedBalancingTx);
|
|
892
|
+
const dustResult = shouldBalanceDust ? await this.dust.balanceTransactions(mergedBalancingTx ? [tx, mergedBalancingTx] : [tx], ttl) : void 0;
|
|
893
|
+
const feeBalancingTx = dustResult?.transaction;
|
|
894
|
+
const balancingTx = this.mergeUnprovenTransactions(mergedBalancingTx, feeBalancingTx);
|
|
895
|
+
if (!balancingTx) throw new Error("No balancing transaction was created. Please check your transaction.");
|
|
896
|
+
return {
|
|
897
|
+
type: "FINALIZED_TRANSACTION",
|
|
898
|
+
protocolVersion: this.currentVersion(),
|
|
899
|
+
originalTransaction: tx,
|
|
900
|
+
balancingTransaction: balancingTx,
|
|
901
|
+
...dustResult ? { blockData: dustResult.blockData } : {}
|
|
902
|
+
};
|
|
903
|
+
}
|
|
904
|
+
/**
|
|
905
|
+
* Balances an unbound (proven, pre-binding) transaction by adding shielded, unshielded, and dust inputs/outputs.
|
|
906
|
+
*
|
|
907
|
+
* Call {@link validateTransaction} with `{ enforceBalancing: false, verifySignatures: false, enforceLimits: false }`
|
|
908
|
+
* before this method to surface structural errors early. All configurable flags are `false` because the transaction
|
|
909
|
+
* is not yet balanced and signatures are not yet present.
|
|
910
|
+
*
|
|
911
|
+
* @param tx - The unbound transaction to balance.
|
|
912
|
+
* @param secretKeys - Secret keys for shielded and dust coin selection.
|
|
913
|
+
* @param options - TTL for the balancing transaction, and optional subset of token kinds to balance.
|
|
914
|
+
* @returns An {@link UnboundTransactionRecipe} containing the base and optional balancing transactions.
|
|
915
|
+
*/
|
|
916
|
+
async balanceUnboundTransaction(tx, options) {
|
|
917
|
+
const { ttl, tokenKindsToBalance = "all" } = options;
|
|
918
|
+
const { shouldBalanceDust, shouldBalanceShielded, shouldBalanceUnshielded } = TokenKindsToBalance.toFlags(tokenKindsToBalance);
|
|
919
|
+
const shieldedBalancingTx = shouldBalanceShielded ? await this.shielded.balanceTransaction(tx) : void 0;
|
|
920
|
+
const balancedUnshieldedTx = shouldBalanceUnshielded ? await this.unshielded.balanceUnboundTransaction(tx) : void 0;
|
|
921
|
+
const baseTx = balancedUnshieldedTx ?? tx;
|
|
922
|
+
const dustResult = shouldBalanceDust ? await this.dust.balanceTransactions(shieldedBalancingTx ? [baseTx, shieldedBalancingTx] : [baseTx], ttl) : void 0;
|
|
923
|
+
const feeBalancingTransaction = dustResult?.transaction;
|
|
924
|
+
const balancingTransaction = this.mergeUnprovenTransactions(shieldedBalancingTx, feeBalancingTransaction);
|
|
925
|
+
if (!balancingTransaction && !balancedUnshieldedTx) throw new Error("No balancing transaction was created. Please check your transaction.");
|
|
926
|
+
return {
|
|
927
|
+
type: "UNBOUND_TRANSACTION",
|
|
928
|
+
protocolVersion: this.currentVersion(),
|
|
929
|
+
baseTransaction: baseTx,
|
|
930
|
+
balancingTransaction: balancingTransaction ?? void 0,
|
|
931
|
+
...dustResult ? { blockData: dustResult.blockData } : {}
|
|
932
|
+
};
|
|
933
|
+
}
|
|
934
|
+
/**
|
|
935
|
+
* Balances an unproven transaction by adding shielded, unshielded, and dust inputs/outputs.
|
|
936
|
+
*
|
|
937
|
+
* Call {@link validateTransaction} with `{ enforceBalancing: false, verifySignatures: false, enforceLimits: false }`
|
|
938
|
+
* before this method to surface structural errors early. All configurable flags are `false` because the transaction
|
|
939
|
+
* is not yet balanced and signatures are not yet present.
|
|
940
|
+
*
|
|
941
|
+
* @param tx - The unproven transaction to balance.
|
|
942
|
+
* @param secretKeys - Secret keys for shielded and dust coin selection.
|
|
943
|
+
* @param options - TTL for the balancing transaction, and optional subset of token kinds to balance.
|
|
944
|
+
* @returns An {@link UnprovenTransactionRecipe} containing the balanced transaction.
|
|
945
|
+
*/
|
|
946
|
+
async balanceUnprovenTransaction(tx, options) {
|
|
947
|
+
const { ttl, tokenKindsToBalance = "all" } = options;
|
|
948
|
+
const { shouldBalanceDust, shouldBalanceShielded, shouldBalanceUnshielded } = TokenKindsToBalance.toFlags(tokenKindsToBalance);
|
|
949
|
+
const shieldedBalancingTx = shouldBalanceShielded ? await this.shielded.balanceTransaction(tx) : void 0;
|
|
950
|
+
const baseTx = (shouldBalanceUnshielded ? await this.unshielded.balanceUnprovenTransaction(tx) : void 0) ?? tx;
|
|
951
|
+
const mergedTx = this.mergeUnprovenTransactions(baseTx, shieldedBalancingTx);
|
|
952
|
+
const dustResult = shouldBalanceDust ? await this.dust.balanceTransactions([mergedTx], ttl) : void 0;
|
|
953
|
+
const feeBalancingTx = dustResult?.transaction;
|
|
954
|
+
const balancedTx = this.mergeUnprovenTransactions(mergedTx, feeBalancingTx);
|
|
955
|
+
return {
|
|
956
|
+
type: "UNPROVEN_TRANSACTION",
|
|
957
|
+
protocolVersion: this.currentVersion(),
|
|
958
|
+
transaction: balancedTx,
|
|
959
|
+
...dustResult ? { blockData: dustResult.blockData } : {}
|
|
960
|
+
};
|
|
961
|
+
}
|
|
962
|
+
async finalizeRecipe(recipe) {
|
|
963
|
+
return Promise.resolve(recipe).then(async (recipe) => {
|
|
964
|
+
switch (recipe.type) {
|
|
965
|
+
case "FINALIZED_TRANSACTION": {
|
|
966
|
+
const finalizedBalancing = await this.finalizeTransaction(recipe.balancingTransaction);
|
|
967
|
+
return this.seal("Finalized", this.accept(recipe.originalTransaction).merge(this.accept(finalizedBalancing)), recipe.originalTransaction.protocolVersion);
|
|
968
|
+
}
|
|
969
|
+
case "UNBOUND_TRANSACTION": {
|
|
970
|
+
const finalizedBalancingTx = recipe.balancingTransaction ? await this.finalizeTransaction(recipe.balancingTransaction) : void 0;
|
|
971
|
+
const finalizedTransaction = this.accept(recipe.baseTransaction).bind();
|
|
972
|
+
return this.seal("Finalized", finalizedBalancingTx ? finalizedTransaction.merge(this.accept(finalizedBalancingTx)) : finalizedTransaction, recipe.baseTransaction.protocolVersion);
|
|
973
|
+
}
|
|
974
|
+
case "UNPROVEN_TRANSACTION": return await this.finalizeTransaction(recipe.transaction);
|
|
975
|
+
}
|
|
976
|
+
}).then(async (finalizedTx) => {
|
|
977
|
+
await this.pendingTransactionsService.addPendingTransaction(finalizedTx, require_dist.some(finalizedTx.protocolVersion));
|
|
978
|
+
return finalizedTx;
|
|
979
|
+
});
|
|
980
|
+
}
|
|
981
|
+
async signRecipe(recipe, signSegment) {
|
|
982
|
+
switch (recipe.type) {
|
|
983
|
+
case "FINALIZED_TRANSACTION": {
|
|
984
|
+
const signedBalancingTx = await this.signUnprovenTransaction(recipe.balancingTransaction, signSegment);
|
|
985
|
+
const withDustSig = await this.#signDustRegistrationIfPresent(signedBalancingTx, signSegment);
|
|
986
|
+
return {
|
|
987
|
+
type: "FINALIZED_TRANSACTION",
|
|
988
|
+
protocolVersion: recipe.protocolVersion,
|
|
989
|
+
originalTransaction: recipe.originalTransaction,
|
|
990
|
+
balancingTransaction: withDustSig,
|
|
991
|
+
...recipe.blockData ? { blockData: recipe.blockData } : {}
|
|
992
|
+
};
|
|
993
|
+
}
|
|
994
|
+
case "UNBOUND_TRANSACTION": {
|
|
995
|
+
const signedBalancingTx = recipe.balancingTransaction ? await this.signUnprovenTransaction(recipe.balancingTransaction, signSegment).then((tx) => this.#signDustRegistrationIfPresent(tx, signSegment)) : void 0;
|
|
996
|
+
const signedBaseTx = await this.signUnboundTransaction(recipe.baseTransaction, signSegment);
|
|
997
|
+
return {
|
|
998
|
+
type: "UNBOUND_TRANSACTION",
|
|
999
|
+
protocolVersion: recipe.protocolVersion,
|
|
1000
|
+
baseTransaction: signedBaseTx,
|
|
1001
|
+
balancingTransaction: signedBalancingTx,
|
|
1002
|
+
...recipe.blockData ? { blockData: recipe.blockData } : {}
|
|
1003
|
+
};
|
|
1004
|
+
}
|
|
1005
|
+
case "UNPROVEN_TRANSACTION": {
|
|
1006
|
+
const signedTx = await this.signUnprovenTransaction(recipe.transaction, signSegment);
|
|
1007
|
+
const withDustSig = await this.#signDustRegistrationIfPresent(signedTx, signSegment);
|
|
1008
|
+
return {
|
|
1009
|
+
type: "UNPROVEN_TRANSACTION",
|
|
1010
|
+
protocolVersion: recipe.protocolVersion,
|
|
1011
|
+
transaction: withDustSig,
|
|
1012
|
+
...recipe.blockData ? { blockData: recipe.blockData } : {}
|
|
1013
|
+
};
|
|
1014
|
+
}
|
|
1015
|
+
}
|
|
1016
|
+
}
|
|
1017
|
+
async #signDustRegistrationIfPresent(tx, signSegment) {
|
|
1018
|
+
const intent = this.accept(tx).intents?.get(1);
|
|
1019
|
+
const registrations = intent?.dustActions?.registrations ?? [];
|
|
1020
|
+
if (!intent || registrations.length === 0) return tx;
|
|
1021
|
+
const signature = await signSegment(intent.signatureData(1));
|
|
1022
|
+
return await this.dust.addDustRegistrationSignature(tx, signature);
|
|
1023
|
+
}
|
|
1024
|
+
async signUnprovenTransaction(tx, signSegment) {
|
|
1025
|
+
return await this.unshielded.signUnprovenTransaction(tx, signSegment);
|
|
1026
|
+
}
|
|
1027
|
+
async signUnboundTransaction(tx, signSegment) {
|
|
1028
|
+
return await this.unshielded.signUnboundTransaction(tx, signSegment);
|
|
1029
|
+
}
|
|
1030
|
+
/**
|
|
1031
|
+
* Proves and binds an unproven transaction, and records it as pending.
|
|
1032
|
+
*
|
|
1033
|
+
* @remarks
|
|
1034
|
+
* Proved at the version stamped on the transaction itself, which is the version that fixed its bytes, and sealed at
|
|
1035
|
+
* that same version: proving is a long await, so the wallets can move under it, and neither the prover a
|
|
1036
|
+
* transaction is routed to nor the stamp it comes back with may be decided by where they have moved to.
|
|
1037
|
+
*
|
|
1038
|
+
* Where they have moved to decides one thing only, and it is decided again once the proof is back: a crossing while
|
|
1039
|
+
* the transaction was in flight leaves it belonging to an epoch the wallets have left, and no chain they are on can
|
|
1040
|
+
* include it. Such a transaction is refused rather than sealed, and nothing is recorded as pending for it — a
|
|
1041
|
+
* pending entry would only wait out a TTL for an inclusion that cannot happen — while the reservations it made in
|
|
1042
|
+
* the three wallets are given back like those of any other failure here.
|
|
1043
|
+
* @param tx The unproven transaction.
|
|
1044
|
+
* @returns The finalized transaction, stamped with the version it was authored at.
|
|
1045
|
+
* @throws {@link ProtocolVersionMismatchError} When the wallets left the transaction's epoch while it was being
|
|
1046
|
+
* proved, or were never in it.
|
|
1047
|
+
*/
|
|
1048
|
+
async finalizeTransaction(tx) {
|
|
1049
|
+
try {
|
|
1050
|
+
const unboundTx = await this.provingService.prove(this.accept(tx), tx.protocolVersion);
|
|
1051
|
+
this.accept(tx);
|
|
1052
|
+
const finalizedTx = this.seal("Finalized", unboundTx.bind(), tx.protocolVersion);
|
|
1053
|
+
await this.pendingTransactionsService.addPendingTransaction(finalizedTx, require_dist.some(finalizedTx.protocolVersion));
|
|
1054
|
+
return finalizedTx;
|
|
1055
|
+
} catch (error) {
|
|
1056
|
+
await Promise.allSettled([
|
|
1057
|
+
this.shielded.revertTransaction(tx),
|
|
1058
|
+
this.unshielded.revertTransaction(tx),
|
|
1059
|
+
this.dust.revertTransaction(tx)
|
|
1060
|
+
]);
|
|
1061
|
+
throw error;
|
|
1062
|
+
}
|
|
1063
|
+
}
|
|
1064
|
+
/** Estimates the fee for the given transaction only. This lacks the fees of the balancing transaction. */
|
|
1065
|
+
async calculateTransactionFee(tx) {
|
|
1066
|
+
return await this.dust.calculateFee([tx]);
|
|
1067
|
+
}
|
|
1068
|
+
/** Calculates the total fee for the given transaction plus the fee of the balancing transaction. */
|
|
1069
|
+
async estimateTransactionFee(tx, options) {
|
|
1070
|
+
const ttl = options?.ttl ?? this.defaultTtl();
|
|
1071
|
+
return await this.dust.estimateFee([tx], ttl, options?.currentTime);
|
|
1072
|
+
}
|
|
1073
|
+
async transferTransaction(outputs, options) {
|
|
1074
|
+
const { ttl, payFees = true } = options;
|
|
1075
|
+
const unshieldedOutputs = outputs.filter((output) => output.type === "unshielded").flatMap((output) => output.outputs);
|
|
1076
|
+
const shieldedOutputs = outputs.filter((output) => output.type === "shielded").flatMap((output) => output.outputs);
|
|
1077
|
+
if (unshieldedOutputs.length === 0 && shieldedOutputs.length === 0) throw Error("At least one shielded or unshielded output is required.");
|
|
1078
|
+
const shieldedTx = shieldedOutputs.length > 0 ? await this.shielded.transferTransaction(shieldedOutputs) : void 0;
|
|
1079
|
+
const unshieldedTx = unshieldedOutputs.length > 0 ? await this.unshielded.transferTransaction(unshieldedOutputs, ttl) : void 0;
|
|
1080
|
+
const mergedTxs = this.mergeUnprovenTransactions(shieldedTx, unshieldedTx);
|
|
1081
|
+
const dustResult = payFees ? await this.dust.balanceTransactions([mergedTxs], ttl) : void 0;
|
|
1082
|
+
const feeBalancingTx = dustResult?.transaction;
|
|
1083
|
+
const finalTx = this.mergeUnprovenTransactions(mergedTxs, feeBalancingTx);
|
|
1084
|
+
return {
|
|
1085
|
+
type: "UNPROVEN_TRANSACTION",
|
|
1086
|
+
protocolVersion: this.currentVersion(),
|
|
1087
|
+
transaction: finalTx,
|
|
1088
|
+
...dustResult ? { blockData: dustResult.blockData } : {}
|
|
1089
|
+
};
|
|
1090
|
+
}
|
|
1091
|
+
/**
|
|
1092
|
+
* Provides estimate of the fee of issuing registration transaction with provided UTxOs
|
|
1093
|
+
*
|
|
1094
|
+
* @param nightUtxos - Night UTxOs to use for the registration
|
|
1095
|
+
* @returns And object informing about fee at the moment, as well as estimation of dust generation of the UTxO(s),
|
|
1096
|
+
* that would be used for paying the fee. These include data that allows to compute when the fee could be paid
|
|
1097
|
+
*/
|
|
1098
|
+
async estimateRegistration(nightUtxos) {
|
|
1099
|
+
const now = this.clock.now();
|
|
1100
|
+
const dustState = await this.dust.waitForSyncedState();
|
|
1101
|
+
const dustGenerationEstimations = require_dist.pipe(nightUtxos, require_dist.map$3(({ utxo, meta }) => ({
|
|
1102
|
+
...utxo,
|
|
1103
|
+
ctime: meta.ctime,
|
|
1104
|
+
registeredForDustGeneration: meta.registeredForDustGeneration
|
|
1105
|
+
})), (utxosWithMeta) => dustState.estimateDustGeneration(utxosWithMeta, now), (estimatedUtxos) => dustState.splitNightUtxos(estimatedUtxos), (split) => split.guaranteed);
|
|
1106
|
+
const authoring = this.authoring();
|
|
1107
|
+
const fakeSigningKey = authoring.sampleSigningKey();
|
|
1108
|
+
const fakeVerifyingKey = authoring.signatureVerifyingKey(fakeSigningKey);
|
|
1109
|
+
const ttl = this.defaultTtl();
|
|
1110
|
+
const fakeUnsignedTx = await this.dust.createDustGenerationTransaction(void 0, ttl, nightUtxos.map(({ utxo, meta }) => ({
|
|
1111
|
+
...utxo,
|
|
1112
|
+
ctime: meta.ctime,
|
|
1113
|
+
registeredForDustGeneration: meta.registeredForDustGeneration
|
|
1114
|
+
})), fakeVerifyingKey, dustState.address);
|
|
1115
|
+
const intent = this.accept(fakeUnsignedTx).intents?.get(1);
|
|
1116
|
+
if (!intent) throw Error("Dust generation transaction is missing intent segment 1.");
|
|
1117
|
+
const signature = authoring.signData(fakeSigningKey, intent.signatureData(1));
|
|
1118
|
+
const fakeSignedTx = await this.dust.addDustGenerationSignature(fakeUnsignedTx, signature);
|
|
1119
|
+
const finalizedFakeTx = this.seal("Finalized", this.accept(fakeSignedTx).mockProve().bind(), this.currentVersion());
|
|
1120
|
+
return {
|
|
1121
|
+
fee: await this.calculateTransactionFee(finalizedFakeTx),
|
|
1122
|
+
dustGenerationEstimations
|
|
1123
|
+
};
|
|
1124
|
+
}
|
|
1125
|
+
async initSwap(desiredInputs, desiredOutputs, options) {
|
|
1126
|
+
const { ttl, payFees = false } = options;
|
|
1127
|
+
const { shielded: shieldedInputs, unshielded: unshieldedInputs } = desiredInputs;
|
|
1128
|
+
const shieldedOutputs = desiredOutputs.filter((output) => output.type === "shielded").flatMap((output) => output.outputs);
|
|
1129
|
+
const unshieldedOutputs = desiredOutputs.filter((output) => output.type === "unshielded").flatMap((output) => output.outputs);
|
|
1130
|
+
const hasShieldedPart = shieldedInputs && Object.keys(shieldedInputs).length > 0 || shieldedOutputs.length > 0;
|
|
1131
|
+
const hasUnshieldedPart = unshieldedInputs && Object.keys(unshieldedInputs).length > 0 || unshieldedOutputs.length > 0;
|
|
1132
|
+
if (!hasShieldedPart && !hasUnshieldedPart) throw Error("At least one shielded or unshielded swap is required.");
|
|
1133
|
+
const shieldedTx = hasShieldedPart ? await this.shielded.initSwap(shieldedInputs ?? {}, shieldedOutputs) : void 0;
|
|
1134
|
+
const unshieldedTx = hasUnshieldedPart ? await this.unshielded.initSwap(unshieldedInputs ?? {}, unshieldedOutputs, ttl) : void 0;
|
|
1135
|
+
const combinedTx = this.mergeUnprovenTransactions(shieldedTx, unshieldedTx);
|
|
1136
|
+
if (!combinedTx) throw Error("Unexpected transaction state.");
|
|
1137
|
+
const dustResult = payFees ? await this.dust.balanceTransactions([combinedTx], ttl) : void 0;
|
|
1138
|
+
const feeBalancingTx = dustResult?.transaction;
|
|
1139
|
+
const finalTx = this.mergeUnprovenTransactions(combinedTx, feeBalancingTx);
|
|
1140
|
+
return {
|
|
1141
|
+
type: "UNPROVEN_TRANSACTION",
|
|
1142
|
+
protocolVersion: this.currentVersion(),
|
|
1143
|
+
transaction: finalTx,
|
|
1144
|
+
...dustResult ? { blockData: dustResult.blockData } : {}
|
|
1145
|
+
};
|
|
1146
|
+
}
|
|
1147
|
+
async registerNightUtxosForDustGeneration(nightUtxos, nightVerifyingKey, signDustRegistration, dustReceiverAddress) {
|
|
1148
|
+
if (nightUtxos.length === 0) throw Error("At least one Night UTXO is required.");
|
|
1149
|
+
const receiverAddress = dustReceiverAddress ?? await this.dust.getAddress();
|
|
1150
|
+
const dustRegistrationTx = await this.createDustActionTransaction({
|
|
1151
|
+
type: "registration",
|
|
1152
|
+
dustReceiverAddress: receiverAddress
|
|
1153
|
+
}, nightUtxos, nightVerifyingKey, signDustRegistration);
|
|
1154
|
+
return {
|
|
1155
|
+
type: "UNPROVEN_TRANSACTION",
|
|
1156
|
+
protocolVersion: this.currentVersion(),
|
|
1157
|
+
transaction: dustRegistrationTx
|
|
1158
|
+
};
|
|
1159
|
+
}
|
|
1160
|
+
/**
|
|
1161
|
+
* Waits until the dust projected to be generated by the given Night UTxOs reaches `requiredAmount`, re-checking every
|
|
1162
|
+
* second. Pair with {@link estimateRegistration} to pick `requiredAmount`, then call before
|
|
1163
|
+
* {@link registerNightUtxosForDustGeneration} so the registration covers its own fee.
|
|
1164
|
+
*
|
|
1165
|
+
* @param nightUtxos - Night UTxOs to project generation for; the same set passed to the registration.
|
|
1166
|
+
* @param requiredAmount - Dust threshold to wait for. Resolves immediately if `<= 0n`.
|
|
1167
|
+
* @param opts.timeoutMs - Deadline, in ms, for the threshold to be reached. Rejects otherwise. Default `300_000`.
|
|
1168
|
+
* @throws If `nightUtxos` is empty, or if `requiredAmount` is not reached within `opts.timeoutMs`.
|
|
1169
|
+
*/
|
|
1170
|
+
async waitForGeneratedDust(nightUtxos, requiredAmount, opts) {
|
|
1171
|
+
await this.dust.waitForGeneratedDust(nightUtxos.map(({ utxo, meta }) => ({
|
|
1172
|
+
...utxo,
|
|
1173
|
+
ctime: meta.ctime,
|
|
1174
|
+
registeredForDustGeneration: meta.registeredForDustGeneration
|
|
1175
|
+
})), requiredAmount, this.clock, opts);
|
|
1176
|
+
}
|
|
1177
|
+
async deregisterFromDustGeneration(nightUtxos, nightVerifyingKey, signDustRegistration) {
|
|
1178
|
+
const dustDeregistrationTx = await this.createDustActionTransaction({ type: "deregistration" }, nightUtxos, nightVerifyingKey, signDustRegistration);
|
|
1179
|
+
return {
|
|
1180
|
+
type: "UNPROVEN_TRANSACTION",
|
|
1181
|
+
protocolVersion: this.currentVersion(),
|
|
1182
|
+
transaction: dustDeregistrationTx
|
|
1183
|
+
};
|
|
1184
|
+
}
|
|
1185
|
+
async revert(txOrRecipe, reason) {
|
|
1186
|
+
const transactionsToRevert = BalancingRecipe.isRecipe(txOrRecipe) ? BalancingRecipe.getTransactions(txOrRecipe) : [txOrRecipe];
|
|
1187
|
+
await Promise.all(transactionsToRevert.map((tx) => this.revertTransaction(tx, reason)));
|
|
1188
|
+
}
|
|
1189
|
+
/**
|
|
1190
|
+
* The finalized entry recording `tx`, if sync has written one, even under the hash aggregation gave it on-chain. A
|
|
1191
|
+
* transaction whose stamp no epoch can read has no entry, rather than an error, so a verdict on it still resolves.
|
|
1192
|
+
*/
|
|
1193
|
+
finalizedEntryFor(tx, history) {
|
|
1194
|
+
return require_dist.match$1(require_dist.getRight(require_dist.WalletTransaction.unwrapWithin(tx, this.epochOf(tx.protocolVersion))), {
|
|
1195
|
+
onNone: () => void 0,
|
|
1196
|
+
onSome: (carried) => {
|
|
1197
|
+
const key = submitTxHistoryKey(carried);
|
|
1198
|
+
return history.find((entry) => isFinalizedWalletEntry(entry) && require_dist.coversTransaction(entry, key));
|
|
1199
|
+
}
|
|
1200
|
+
});
|
|
1201
|
+
}
|
|
1202
|
+
/** Sync can record inclusion before the independent pending-status poller observes it. */
|
|
1203
|
+
async reconcileFinalizedTransaction(tx, history) {
|
|
1204
|
+
const entry = this.finalizedEntryFor(tx, history);
|
|
1205
|
+
if (entry === void 0) return false;
|
|
1206
|
+
if (entry.status === "FAILURE" || entry.status === "PARTIAL_SUCCESS") await this.revertTransaction(tx);
|
|
1207
|
+
else await this.pendingTransactionsService.clear(tx);
|
|
1208
|
+
return true;
|
|
1209
|
+
}
|
|
1210
|
+
async revertTransaction(tx, reason) {
|
|
1211
|
+
await Promise.all([
|
|
1212
|
+
this.shielded.revertTransaction(tx),
|
|
1213
|
+
this.unshielded.revertTransaction(tx),
|
|
1214
|
+
this.dust.revertTransaction(tx)
|
|
1215
|
+
]).then(async () => {
|
|
1216
|
+
await this.pendingTransactionsService.clear(tx);
|
|
1217
|
+
const key = require_dist.match$1(require_dist.getRight(require_dist.WalletTransaction.unwrapWithin(tx, this.epochOf(tx.protocolVersion))), {
|
|
1218
|
+
onNone: () => void 0,
|
|
1219
|
+
onSome: revertTxHistoryKey
|
|
1220
|
+
});
|
|
1221
|
+
if (key !== void 0) await this.#txHistoryStorage.gotRejected({
|
|
1222
|
+
...key,
|
|
1223
|
+
rejectedAt: this.clock.now(),
|
|
1224
|
+
...reason !== void 0 ? { reason } : {}
|
|
1225
|
+
});
|
|
1226
|
+
});
|
|
1227
|
+
}
|
|
1228
|
+
/**
|
|
1229
|
+
* Starts the wallets and their background synchronization.
|
|
1230
|
+
*
|
|
1231
|
+
* @remarks
|
|
1232
|
+
* Seeds, not key objects. A seed is the only key material that crosses a protocol boundary — every ledger version
|
|
1233
|
+
* derives its own keys from the same seed and arrives at the same identity — so a wallet started from seeds can
|
|
1234
|
+
* follow the chain across a fork, and one started from key objects of a single ledger version cannot. Derive them
|
|
1235
|
+
* once with `WalletSeeds.fromMasterSeed` and hand them over.
|
|
1236
|
+
*
|
|
1237
|
+
* {@link FacadeKeysByEpoch} is the escape hatch for a caller that will not part with a seed. It requires **both**
|
|
1238
|
+
* ledger versions' key objects, because a wallet holding one side could not read the other side of the chain, and
|
|
1239
|
+
* it costs the caller an import of both ledger packages and the same derivation performed twice. A seed costs
|
|
1240
|
+
* neither.
|
|
1241
|
+
* @example
|
|
1242
|
+
* ```typescript
|
|
1243
|
+
* await facade.start(WalletSeeds.fromMasterSeed(masterSeed));
|
|
1244
|
+
* ```;
|
|
1245
|
+
*
|
|
1246
|
+
* @param material The three wallets' seeds, or both ledger versions' key objects.
|
|
1247
|
+
* @param options `manualSync` leaves the dust wallet unstarted in the background; drive it explicitly with
|
|
1248
|
+
* {@link doSync} instead (requires a dust wallet built with the projections sync service, see
|
|
1249
|
+
* `makeEventLessSyncService`).
|
|
1250
|
+
*/
|
|
1251
|
+
async start(material, options = {}) {
|
|
1252
|
+
const keys = v9KeysOf(material);
|
|
1253
|
+
await Promise.all([
|
|
1254
|
+
this.shielded.start(keys.shielded),
|
|
1255
|
+
this.unshielded.start(),
|
|
1256
|
+
!options.manualSync ? this.dust.start(keys.dust) : void 0,
|
|
1257
|
+
this.pendingTransactionsService.start()
|
|
1258
|
+
]);
|
|
1259
|
+
}
|
|
1260
|
+
/**
|
|
1261
|
+
* Runs a single dust synchronization pass and resolves when it completes. Only the dust wallet supports manual sync;
|
|
1262
|
+
* the shielded and unshielded wallets keep syncing in the background via {@link start}.
|
|
1263
|
+
*
|
|
1264
|
+
* @param material The same material {@link start} was given.
|
|
1265
|
+
*/
|
|
1266
|
+
async doSync(material) {
|
|
1267
|
+
await this.dust.stepSync(v9KeysOf(material).dust);
|
|
1268
|
+
}
|
|
1269
|
+
async stop() {
|
|
1270
|
+
await Promise.all([
|
|
1271
|
+
this.shielded.stop(),
|
|
1272
|
+
this.unshielded.stop(),
|
|
1273
|
+
this.dust.stop(),
|
|
1274
|
+
this.submissionService.close(),
|
|
1275
|
+
this.pendingTransactionsService.stop(),
|
|
1276
|
+
Promise.resolve(this.#pendingSubscription?.unsubscribe()),
|
|
1277
|
+
Promise.resolve(this.#protocolVersionSubscription?.unsubscribe())
|
|
1278
|
+
]);
|
|
1279
|
+
}
|
|
1280
|
+
async queryTxHistoryByHash(hash) {
|
|
1281
|
+
return this.#txHistoryStorage.get(hash);
|
|
1282
|
+
}
|
|
1283
|
+
async getAllFromTxHistory() {
|
|
1284
|
+
return [...await this.#txHistoryStorage.getAll()];
|
|
1285
|
+
}
|
|
1286
|
+
};
|
|
1287
|
+
//#endregion
|
|
1288
|
+
exports.BalancingRecipe = BalancingRecipe;
|
|
1289
|
+
Object.defineProperty(exports, "Clock", {
|
|
1290
|
+
enumerable: true,
|
|
1291
|
+
get: function() {
|
|
1292
|
+
return require_dist.Clock_exports;
|
|
1293
|
+
}
|
|
1294
|
+
});
|
|
1295
|
+
exports.DefaultForkSchedule = DefaultForkSchedule;
|
|
1296
|
+
exports.FacadeState = FacadeState;
|
|
1297
|
+
exports.ValidationFetchError = require_dist.ValidationFetchError;
|
|
1298
|
+
exports.WalletEntrySchema = WalletEntrySchema;
|
|
1299
|
+
exports.WalletFacade = WalletFacade;
|
|
1300
|
+
exports.WellFormedError = require_dist.WellFormedError;
|
|
1301
|
+
exports.isFinalizedWalletEntry = isFinalizedWalletEntry;
|
|
1302
|
+
exports.isPendingWalletEntry = isPendingWalletEntry;
|
|
1303
|
+
exports.lowestProtocolVersion = lowestProtocolVersion;
|
|
1304
|
+
exports.mergeWalletEntries = mergeWalletEntries;
|
|
1305
|
+
exports.pendingTransactionsOf = pendingTransactionsOf;
|
|
1306
|
+
exports.protocolPhaseOf = protocolPhaseOf;
|