@laceio/sdk 0.1.1-canary.2 → 0.1.1
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/{TransactionBuilder-CCjOn7NA.cjs → TransactionBuilder-DrB3NVTi.cjs} +0 -42
- package/dist/{TransactionBuilder-CIzdw18M.js → TransactionBuilder-V6aLx4SV.js} +1 -1
- package/dist/{_polyfill-buffer-patch-CM8X7JiY.cjs → _polyfill-buffer-patch-BnPVerlG.cjs} +2 -21
- package/dist/account-guards.stable-B1DSSh9D.cjs +10 -0
- package/dist/account-guards.stable-JRQ5qx2V.js +5 -0
- package/dist/{activity-type-Ch6ljxBy.cjs → activity-type.stable-BJEfeLxL.cjs} +1 -2
- package/dist/{activity-type-GsJGWs-3.js → activity-type.stable-C76_hWd7.js} +1 -2
- package/dist/{address-book-address-validator-ByIZOdO-.js → address-book-address-validator-DIUolI-s.js} +2 -2
- package/dist/{address-book-address-validator-BjOWerRE.cjs → address-book-address-validator-DNwQGlOB.cjs} +2 -2
- package/dist/bitcoin.cjs +0 -45
- package/dist/bitcoin.d.ts +1 -29782
- package/dist/bitcoin.js +0 -20
- package/dist/{blockfrost-tx-submit-provider-CLNQ5ycR.cjs → blockfrost-tx-submit-provider-BAIzV5o3.cjs} +167 -3
- package/dist/{blockfrost-tx-submit-provider-CBWQ0wK9.js → blockfrost-tx-submit-provider-DPTrapz-.js} +157 -5
- package/dist/{secret-box-DrjLZuS1.cjs → bytes.vo-Ck5u40RA.cjs} +35 -1
- package/dist/{secret-box-DUR0ACYz.js → bytes.vo-TgiwogWF.js} +25 -3
- package/dist/{cardano-network-id.vo-wfLiAxpY.js → cardano-network-id.vo-CK1tNQDg.js} +1 -1
- package/dist/{cardano-network-id.vo-BEvFd_74.cjs → cardano-network-id.vo-DSxrFk9S.cjs} +1 -1
- package/dist/cardano.cjs +18 -22
- package/dist/cardano.d.ts +3982 -18409
- package/dist/cardano.js +11 -16
- package/dist/codecs-B7X9pAsK.cjs +1945 -0
- package/dist/codecs-CC1Xjntz.js +1882 -0
- package/dist/{const-oMF-TLow.cjs → const-BDEg2Trq.cjs} +4 -4
- package/dist/{const-iwzZEE_w.cjs → const-BY8B3_0_.cjs} +1 -1
- package/dist/{const-CBGn60yu.js → const-C84qHkjp.js} +4 -4
- package/dist/{const-CjmfjBP3.js → const-DXk2tFyv.js} +1 -1
- package/dist/{delegation-tx-builder-BR6bt1fE.js → delegation-tx-builder-CGVqlaFE.js} +5 -5
- package/dist/{delegation-tx-builder-DVwGfiV0.cjs → delegation-tx-builder-CRpLP6jH.cjs} +6 -6
- package/dist/{deregistration-tx-builder-BhJRGj1M.js → deregistration-tx-builder-B-CrUyX6.js} +5 -5
- package/dist/{deregistration-tx-builder-Cv_09HGf.cjs → deregistration-tx-builder-DZGwB4cz.cjs} +6 -6
- package/dist/{earn-rewards-tx-builder-RYzKsZ6-.js → earn-rewards-tx-builder-BDbTDZmD.js} +5 -5
- package/dist/{earn-rewards-tx-builder-52gJiJYa.cjs → earn-rewards-tx-builder-D5sUT5v8.cjs} +6 -6
- package/dist/{group-cardano-addresses-by-account-D06r7daZ.cjs → group-cardano-addresses-by-account-B533oVXR.cjs} +35 -19
- package/dist/{group-cardano-addresses-by-account-CxCqFDrX.js → group-cardano-addresses-by-account-RHKoEskR.js} +35 -19
- package/dist/{guarded-transaction-signer-BhnTBjf6.cjs → guarded-transaction-signer-Bxl6_XNd.cjs} +18 -17
- package/dist/{guarded-transaction-signer-BSEx83R-.js → guarded-transaction-signer-CpKLj8Kp.js} +15 -8
- package/dist/{in-memory-wallet-integration-CH4rcg92.cjs → in-memory-wallet-integration-CnLYeX4-.cjs} +108 -17
- package/dist/{in-memory-wallet-integration-BKu985Jz.js → in-memory-wallet-integration-Croiuopx.js} +104 -7
- package/dist/{in-memory-wallet-integration-B0blZBxM.js → in-memory-wallet-integration-D-qn65Kx.js} +2 -5
- package/dist/{in-memory-wallet-integration-CwPCDMIe.cjs → in-memory-wallet-integration-DVh9sRXa.cjs} +2 -3
- package/dist/index.cjs +47 -84
- package/dist/index.d.ts +13618 -40268
- package/dist/index.js +24 -52
- package/dist/{init-DUF4ar8P.cjs → init-B64zCLxG.cjs} +4 -4
- package/dist/{init-Y3mkB4XS.js → init-BAJJzBza.js} +2 -2
- package/dist/{init-BTzOjA8x.cjs → init-BJVU54pI.cjs} +1 -1
- package/dist/{init-D6BxBs7e.cjs → init-BKhH6mVR.cjs} +1 -1
- package/dist/{init-EP0CUWNK.cjs → init-BsCBAGWf.cjs} +2 -2
- package/dist/{init-Dy-05ktr.cjs → init-BtzMZ7Pk.cjs} +1 -1
- package/dist/init-Bv53hpLM.js +19 -0
- package/dist/{init-BopV9ed4.cjs → init-C-jErzp5.cjs} +2 -2
- package/dist/{init-CjT-WZcW.cjs → init-C4Bkib9u.cjs} +59 -49
- package/dist/{init-BEjCRHxU.cjs → init-C7IeJwQR.cjs} +61 -258
- package/dist/{init-C-G32J12.cjs → init-CB__aLD7.cjs} +2 -2
- package/dist/{init-CyAY4Lzl.js → init-CFYsq82V.js} +1 -1
- package/dist/{init-0zzs9aqU.js → init-CLHuAMB-.js} +4 -4
- package/dist/{init-DA7zmptx.js → init-CNLGJJRx.js} +1 -1
- package/dist/{init-B-YE57gg.js → init-CR6tpw1B.js} +33 -25
- package/dist/init-CRbjI7p1.js +3494 -0
- package/dist/{init-CSDpdu0Q.cjs → init-CSHwHnfg.cjs} +2 -2
- package/dist/{init-CNM5m7M2.js → init-Cg9XdAru.js} +4 -4
- package/dist/{init-B3-1ghyx.js → init-CigestoM.js} +2 -2
- package/dist/{init-Dv3zKj0r.cjs → init-D6DBUsD3.cjs} +4 -4
- package/dist/init-DAna1KCg.cjs +3495 -0
- package/dist/{init-D74mn8nH2.js → init-DDdhguVC.js} +2 -2
- package/dist/init-DGe47B22.cjs +364 -0
- package/dist/init-DMtyvYfC.cjs +21 -0
- package/dist/{init-BrdVzxei.cjs → init-DX4WyB0R.cjs} +3 -3
- package/dist/{init-C8URA2OX.js → init-DcYY6zMD.js} +1 -1
- package/dist/{init-DFMiP2ZH.cjs → init-DkIc5nqF.cjs} +1 -1
- package/dist/{init-vqxOQNZi.js → init-Dku4b2lG.js} +1 -1
- package/dist/{init-NdhG_VrF.cjs → init-DxUHsN53.cjs} +6 -6
- package/dist/{init-COMH3Hfo.js → init-FMGDET-9.js} +60 -259
- package/dist/{init-DrkOb-wd.cjs → init-LfyMo-sS.cjs} +2 -2
- package/dist/{init-NCjgwCZy.js → init-Rxohwpmu.js} +2 -2
- package/dist/init-TkPDD750.js +363 -0
- package/dist/{init-C2RgrfZe.js → init-TkPq_Ny_.js} +1 -1
- package/dist/{init-5KcGcBb5.cjs → init-U8c9yHYx.cjs} +1 -1
- package/dist/{init-CX0AMQUn.js → init-aJHl-7AO.js} +2 -2
- package/dist/{init-rmt7-fQE.cjs → init-anYu6XB7.cjs} +2 -2
- package/dist/{init-Fw89ZmrR.js → init-w9GEs73W.js} +2 -2
- package/dist/{init-Dnsv155v.js → init-y2Ra0vZP.js} +3 -3
- package/dist/{init-DFjT8YvT.js → init-zSzCjoor.js} +4 -4
- package/dist/{is-retriable-error-BUiVJDwH.js → is-retriable-error-BU0e3hVI.js} +1 -1
- package/dist/{is-retriable-error-Dpt860if.cjs → is-retriable-error-CeeuHqDa.cjs} +1 -1
- package/dist/{lace-context-BZciB9c7.js → lace-context-CZcNHr4M.js} +4 -4
- package/dist/{lace-context-DgR6vLli.cjs → lace-context-fJTDghdp.cjs} +4 -4
- package/dist/{libsodium-wrappers-BhbOA8dQ.js → libsodium-wrappers-UH0LaOUE.js} +1647 -3
- package/dist/modules-cardano-BDvuL4Xx.js +5248 -0
- package/dist/modules-cardano-D2G3De2P.cjs +5432 -0
- package/dist/{retry-config-Dmgt28wM.js → retry-config-BcUmMS--.js} +1 -1
- package/dist/{retry-config-BaCfVC1H.cjs → retry-config-DC5IMaH7.cjs} +1 -1
- package/dist/{seam-cardano-B_etH4F4.js → seam-cardano-CATqBEyK.js} +1 -1
- package/dist/{signer-factory-B7PMe3lQ.js → signer-factory-9URFliA5.js} +3 -6
- package/dist/{signer-factory-DduwpsQj.cjs → signer-factory-BWGUmnvm.cjs} +3 -4
- package/dist/{slice-CqVNnz-j.js → slice-B2PhoWAg.js} +125 -316
- package/dist/{slice-DyNs7oWp.js → slice-BNu73oBa.js} +2 -2
- package/dist/{slice-GwiiJRoq.js → slice-CB4SnzMm.js} +3 -3
- package/dist/slice-CGVHXHDt.cjs +125 -0
- package/dist/{slice-CU80pbiu.js → slice-CnyWevM9.js} +3 -3
- package/dist/{slice-CwyYrh1H.js → slice-CobanYgn.js} +2 -2
- package/dist/{slice-7G2xxYKJ.cjs → slice-CuHUaPZx.cjs} +3 -3
- package/dist/{slice-DayJvMRD.cjs → slice-D11m2EKl.cjs} +1 -1
- package/dist/{slice-Bg6HEr3K.cjs → slice-DGcNrbPR.cjs} +4 -4
- package/dist/{slice-B4CdYoPu.cjs → slice-DZmQJNV8.cjs} +2 -2
- package/dist/slice-DhvF7L6X.js +107 -0
- package/dist/{slice-C9TT5KhY.cjs → slice-Do2R2CYW.cjs} +6 -6
- package/dist/{slice-Bs2aMERu.cjs → slice-DtaO72qY.cjs} +3 -3
- package/dist/{slice-C34iOOUH.cjs → slice-HeHCv3bl.cjs} +7 -7
- package/dist/{slice-D-9aPKG-.js → slice-d0p6-xj5.js} +6 -6
- package/dist/{slice-CK07EBCo.js → slice-eIwcwKHI.js} +4 -4
- package/dist/{slice-DBpJ2QGf.js → slice-maaskdUn.js} +6 -6
- package/dist/{slice-6sP0Qs5V.cjs → slice-mxLQ_FeY.cjs} +127 -343
- package/dist/{slice-DnG-yvpI.cjs → slice-oqm_r1cS.cjs} +2 -2
- package/dist/{slice-Da426sf9.js → slice-zJ9XVYjZ.js} +1 -1
- package/dist/{sync-operation-utils-KT5Y9yFK.js → sync-operation-utils-BYXLO80m.js} +52 -1
- package/dist/{sync-operation-utils-C9kcmjKH.cjs → sync-operation-utils-SdPbwFoD.cjs} +87 -0
- package/dist/{token-id-mapper-qx7XfH0b.js → token-id-mapper-B2ivlLv3.js} +2 -2
- package/dist/{token-id-mapper-IApjwuJb.cjs → token-id-mapper-DsPAL6Nh.cjs} +2 -2
- package/dist/{util-D1e0skzp.js → util-BaLzwa32.js} +1 -1
- package/dist/{util-BeG7WXzM.cjs → util-CGzqQ8IV.cjs} +1 -1
- package/dist/{utils-DsElZgCI.cjs → utils-5JvjbqH3.cjs} +1 -7
- package/dist/{utils-BfBEUvWA.js → utils-o8aMjfln.js} +2 -2
- package/dist/{vote-delegation-tx-builder-CtdIgaIt.cjs → vote-delegation-tx-builder-BpEMSti4.cjs} +6 -6
- package/dist/{vote-delegation-tx-builder-CQjGvVNZ.js → vote-delegation-tx-builder-CmKv6GoG.js} +5 -5
- package/package.json +4 -96
- package/dist/_polyfill-buffer-patch-yNxN4d5E.js +0 -1467
- package/dist/_web-crypto-random-bytes-Bo-GTcRS.js +0 -197
- package/dist/acc-module-4iIUv6My.cjs +0 -27654
- package/dist/acc-module-Cmj8EsIb.js +0 -27624
- package/dist/account-BlYkEmcs.cjs +0 -11
- package/dist/account-DVX0F5_M.js +0 -6
- package/dist/account-call-D68oF6bh.js +0 -267
- package/dist/account-call-DIIa2rK_.cjs +0 -314
- package/dist/account-call-NgLhYein.cjs +0 -4
- package/dist/account-call-n-Nkp35e.js +0 -3
- package/dist/account-guards-BtjTGxDZ.cjs +0 -42
- package/dist/account-guards-D9Lu5T3W.js +0 -36
- package/dist/account-tokens-CtN2BaFy.js +0 -16
- package/dist/account-tokens-DXr8DlpW.cjs +0 -21
- package/dist/address-B9ntKL8K.js +0 -13761
- package/dist/address-BXp-mY8H.cjs +0 -11270
- package/dist/address-book-address-validator-DK0dnsRS.cjs +0 -41
- package/dist/address-book-address-validator-Di_ywo8M.js +0 -39
- package/dist/artefact-loader-54uK5RAa.js +0 -160
- package/dist/artefact-loader-DZPYrq-6.cjs +0 -183
- package/dist/auto-dismiss-failure-on-success-C-qoJuid.cjs +0 -37
- package/dist/auto-dismiss-failure-on-success-s8MGDEIu.js +0 -31
- package/dist/bip32-D6wd_QMn.cjs +0 -3851
- package/dist/bitcoin-data-provider-BYPSmuZS.js +0 -21
- package/dist/bitcoin-data-provider-w1oEDSU3.cjs +0 -26
- package/dist/bn-d3nSOIf7.cjs +0 -2553
- package/dist/browser-B1eMbDwh.js +0 -7468
- package/dist/bytes.vo-BB7_4JK6.js +0 -23
- package/dist/bytes.vo-BNRquqaO.cjs +0 -34
- package/dist/cardano-DfPwhwm-.js +0 -3
- package/dist/client-DXBLHk7K.cjs +0 -808
- package/dist/codecs-Cswkg7Tm.cjs +0 -4051
- package/dist/codecs-Dc1Krpbt.js +0 -3903
- package/dist/const-BfEnY8fg.js +0 -153
- package/dist/const-BhYOdznB.cjs +0 -42
- package/dist/const-CUnCl5U0.js +0 -13
- package/dist/const-DLrX5SD9.cjs +0 -31995
- package/dist/contract-C_CBwwiC.cjs +0 -189
- package/dist/contract-s_x-9-lz.js +0 -171
- package/dist/create-add-accounts-Brqk84vF.js +0 -102
- package/dist/create-add-accounts-DzXIh7Ot.cjs +0 -114
- package/dist/device-commitment-hex.vo-5wFtQvDS.js +0 -26
- package/dist/device-commitment-hex.vo-CT3RmAug.cjs +0 -31
- package/dist/device-readers-70i7tQqU.cjs +0 -8
- package/dist/device-readers-B7--ezKM.js +0 -4
- package/dist/device-readers-BWOmz9eD.js +0 -145
- package/dist/device-readers-CIgYZN7f.cjs +0 -168
- package/dist/dist-BMi5ZjEq.cjs +0 -43175
- package/dist/dist-BtIq4XFn.cjs +0 -535
- package/dist/dist-C3SHC_Ho.cjs +0 -1394
- package/dist/dist-CykEjYEX.cjs +0 -3814
- package/dist/dist-Dcsxh3be.cjs +0 -3452
- package/dist/dist-DqJfSlTd.cjs +0 -4413
- package/dist/dist-nTZ70qj7.cjs +0 -1306
- package/dist/enc-key-circuits-C8fGAMEF.cjs +0 -24
- package/dist/enc-key-circuits-DA2Xs3vZ.js +0 -13
- package/dist/english-Byb9M0E_.cjs +0 -2057
- package/dist/envelopes-BkH1Qdxk.js +0 -1620
- package/dist/envelopes-ETZEJS_O.cjs +0 -1721
- package/dist/errors-BZ8hnhCM.cjs +0 -584
- package/dist/errors-DIJTAsLa.js +0 -392
- package/dist/esm-HBSUQw3w.js +0 -384
- package/dist/esm-LZuaZjMf.cjs +0 -389
- package/dist/experimental.cjs +0 -7073
- package/dist/experimental.d.ts +0 -84347
- package/dist/experimental.js +0 -6915
- package/dist/gated-call-Boy6rXdC.js +0 -3
- package/dist/gated-call-DJWY299W.cjs +0 -736
- package/dist/gated-call-DjoRPqn1.js +0 -695
- package/dist/gated-call-SomdJ5nj.cjs +0 -4
- package/dist/grant-circuits-_1x--moV.cjs +0 -49
- package/dist/grant-circuits-swuzEdUl.js +0 -26
- package/dist/grant-rules-7Zqi_3BN.cjs +0 -7114
- package/dist/grant-rules-_xJHAT2M.js +0 -6833
- package/dist/grant-status-B2y49iIu.js +0 -2688
- package/dist/grant-status-DOr3t_u8.cjs +0 -2820
- package/dist/grants--b0LQQzZ.cjs +0 -266
- package/dist/grants-BIs6qm3b.js +0 -213
- package/dist/grants-CSgfYlOO.js +0 -5
- package/dist/grants-D61131nK.cjs +0 -17
- package/dist/hex-D9ITYbwt.cjs +0 -263
- package/dist/hex-mkXcV3pN.js +0 -191
- package/dist/http-client-B3N-TMxu.cjs +0 -167
- package/dist/http-client-TRlhDZGh.js +0 -155
- package/dist/identity-BMLuufva.cjs +0 -263
- package/dist/identity-DII6f-h7.js +0 -233
- package/dist/in-memory-wallet-integration-B2xzxORj.cjs +0 -20741
- package/dist/in-memory-wallet-integration-CUKesGG1.js +0 -130
- package/dist/in-memory-wallet-integration-CoPx69lQ.cjs +0 -240
- package/dist/in-memory-wallet-integration-TM9bBphA.js +0 -20738
- package/dist/init-B5X_sGj9.cjs +0 -6
- package/dist/init-BJn-8_hf.js +0 -141
- package/dist/init-Bp6yJk31.js +0 -1142
- package/dist/init-Bu4iXcTH.cjs +0 -34
- package/dist/init-C00gw1zi.js +0 -422
- package/dist/init-CIjZaQvL.js +0 -3584
- package/dist/init-CR7BfztQ.cjs +0 -18
- package/dist/init-Cp8EJGbm.js +0 -5
- package/dist/init-CpIadSUb.js +0 -33
- package/dist/init-D5UiYI12.cjs +0 -106
- package/dist/init-DAikR9qU.js +0 -1177
- package/dist/init-DGjXwWs2.cjs +0 -143
- package/dist/init-DHrCbpkW.cjs +0 -121
- package/dist/init-DU5yYX5u.js +0 -2374
- package/dist/init-DWvkFDkc.cjs +0 -1176
- package/dist/init-DY1unoGb.cjs +0 -1141
- package/dist/init-DlqJuHhl.js +0 -119
- package/dist/init-DuYENxci.js +0 -17
- package/dist/init-E7c40ddW.cjs +0 -3585
- package/dist/init-GsT2AEa4.cjs +0 -424
- package/dist/init-KQnIdm39.js +0 -104
- package/dist/init-ZjNDDC-T.cjs +0 -2375
- package/dist/jubjub-authoriser-BxE3oN2y.js +0 -86
- package/dist/jubjub-authoriser-C6SDEP9I.cjs +0 -87
- package/dist/key-source-5oUBFiC7.cjs +0 -583
- package/dist/key-source-B08HukZg.js +0 -2550
- package/dist/keyDerivation-D3k9XyHg.js +0 -4077
- package/dist/keyDerivation-u0nBA93T.cjs +0 -274
- package/dist/lib--iqvW4O_.js +0 -2354
- package/dist/lib-Yk6Upl5D.cjs +0 -2359
- package/dist/midnight-account-id.vo-0x9X-r3l.cjs +0 -10
- package/dist/midnight-account-id.vo-DjCAGcqc.js +0 -5
- package/dist/midnight-engine-DpemplKO.js +0 -5
- package/dist/midnight-engine-xU1wotne.cjs +0 -6
- package/dist/midnight-wallet-DIsAlSn6.js +0 -18
- package/dist/midnight-wallet-XTZc2li7.cjs +0 -24
- package/dist/midnight.cjs +0 -1406
- package/dist/midnight.d.ts +0 -28586
- package/dist/midnight.js +0 -1350
- package/dist/modules-cardano-CtWLntet.cjs +0 -1108
- package/dist/modules-cardano-D2dkeKHY.js +0 -995
- package/dist/node-relay-Cv0cNknM.js +0 -48
- package/dist/node-relay-DblH5fKv.cjs +0 -49
- package/dist/outputs-Bd2yZVjx.js +0 -720
- package/dist/outputs-CJoQBIA2.cjs +0 -990
- package/dist/pbkdf2-CIW-oWrm.cjs +0 -1337
- package/dist/pending-operation-B0_P78Jo.cjs +0 -26
- package/dist/pending-operation-BIS6mpjB.js +0 -21
- package/dist/providers-BLgJ0uQs.cjs +0 -366
- package/dist/providers-CwnT4vEE.js +0 -343
- package/dist/redacted-BmE2aXqr.js +0 -81
- package/dist/redacted-CRZJLS3w.cjs +0 -86
- package/dist/safe-buffer-B_vMqJWU.js +0 -43
- package/dist/safe-buffer-DYOwEfHB.cjs +0 -48
- package/dist/sdk-DIcjlgLF.js +0 -1241
- package/dist/sdk-Dgal10kG.cjs +0 -1439
- package/dist/sdk-init-BKkqFtWZ.cjs +0 -3791
- package/dist/sdk-init-DNd-oQXp.js +0 -1044
- package/dist/send-proof-progress-DTK3ZuYB.js +0 -22
- package/dist/send-proof-progress-dDoqIohG.cjs +0 -33
- package/dist/side-effects-BnqYz7Nl.js +0 -768
- package/dist/side-effects-CngaeXi0.cjs +0 -804
- package/dist/sign-bitcoin-transaction-with-seed-D4z62-jV.js +0 -147
- package/dist/sign-bitcoin-transaction-with-seed-DsLYXnCY.cjs +0 -158
- package/dist/signer-3fk8lZtE.cjs +0 -7
- package/dist/signer-CsL28DrK.cjs +0 -121
- package/dist/signer-DGluibtn.js +0 -92
- package/dist/signer-RqB5pu3K.js +0 -2
- package/dist/signer-factory-BA7WFJVZ.js +0 -282
- package/dist/signer-factory-CORIG4Yl.cjs +0 -130
- package/dist/signer-factory-Cd2TwD50.js +0 -129
- package/dist/signer-factory-Cwd6o-lG.cjs +0 -281
- package/dist/slice-BOyAAaj0.cjs +0 -378
- package/dist/slice-BnTJeMOb.js +0 -354
- package/dist/slice-C4uXUT7S.js +0 -9013
- package/dist/slice-CxKWDuBP.js +0 -87
- package/dist/slice-DQv_RhsI.cjs +0 -9031
- package/dist/slice-HjLXJyQG2.cjs +0 -105
- package/dist/src-BDzYIksE.cjs +0 -20637
- package/dist/src-BFoefPv_.js +0 -20755
- package/dist/store-B1Lq3cEf.cjs +0 -66
- package/dist/store-DuBG8qh5.js +0 -37
- package/dist/submit-BBYjnZu8.cjs +0 -87
- package/dist/submit-D_yxYM_T.js +0 -70
- package/dist/submit-bitcoin-tx-BkZIeF4b.js +0 -983
- package/dist/submit-bitcoin-tx-DZNQgihl.cjs +0 -1049
- package/dist/token-id-mapper-Bnds3xKH.cjs +0 -18
- package/dist/token-id-mapper-CnKHQ8DV.js +0 -16
- package/dist/tokens-Cevp7rdU.cjs +0 -62
- package/dist/tokens-Diw4MLRM.js +0 -44
- package/dist/types-B8uiJn-X.js +0 -12
- package/dist/types-CJT6XF2c.js +0 -10
- package/dist/types-CLRUYpfe.cjs +0 -23
- package/dist/types-DWbVZpnF.cjs +0 -15
- package/dist/types-T0cjaR75.js +0 -33
- package/dist/types-Zj78LtYu.cjs +0 -50
- package/dist/unwrap-provider-result-BZSiwabU.js +0 -32
- package/dist/unwrap-provider-result-ZqfBsTkk.cjs +0 -39
- package/dist/utils-BfMdr_1w.cjs +0 -112
- package/dist/utils-CvAW5Yw7.js +0 -65
- package/dist/v8Signatures-CO_Uloy7.cjs +0 -71
- package/dist/watch-Cz1J42um.cjs +0 -52205
- package/dist/watch-Z53L4yoK.js +0 -13054
- /package/dist/{account-id.vo-DwqFjK5u.cjs → account-id.vo-LvCBVn5r.cjs} +0 -0
- /package/dist/{account-id.vo-OPz2v-JZ.js → account-id.vo-MYSI7YFm.js} +0 -0
- /package/dist/{actions-iLXdgL5Y.js → actions-9QSQR-GB.js} +0 -0
- /package/dist/{actions-B2BJ4RTy.cjs → actions-DdGbj7c7.cjs} +0 -0
- /package/dist/{apply-vkey-witnesses-ZnFS0jnJ.cjs → apply-vkey-witnesses-CLzVSWxl.cjs} +0 -0
- /package/dist/{apply-vkey-witnesses-BKx3lcs0.js → apply-vkey-witnesses-ClZbpk5w.js} +0 -0
- /package/dist/{asyncoption-CruEYOBI.js → asyncoption-Cw07zPH7.js} +0 -0
- /package/dist/{asyncoption-i0VbqVTq.cjs → asyncoption-DYoGuQfP.cjs} +0 -0
- /package/dist/{bignum.vo-CEXOIew0.js → bignum.vo-B0rK_PQ1.js} +0 -0
- /package/dist/{bignum.vo-hx2kuqlA.cjs → bignum.vo-DsG3kNiZ.cjs} +0 -0
- /package/dist/{bip32ed25519-B7Yat217.cjs → bip32ed25519-1ApqeAZk.cjs} +0 -0
- /package/dist/{bip32ed25519-FQ8qvdcq.js → bip32ed25519-DetAdGwD.js} +0 -0
- /package/dist/{blake2b-DEeVUdKR.cjs → blake2b-B9tftbvG.cjs} +0 -0
- /package/dist/{blake2b-BiQTw3GC.js → blake2b-DOEVc57D.js} +0 -0
- /package/dist/{blockchain-network-id.vo-BAKEwGjG.cjs → blockchain-network-id.vo-BXpZhvvQ.cjs} +0 -0
- /package/dist/{blockchain-network-id.vo-CiVykuqG.js → blockchain-network-id.vo-DNRkuT5B.js} +0 -0
- /package/dist/{blockingWithLatestFrom-Cd8c8EPG.js → blockingWithLatestFrom-C5wp_uA-.js} +0 -0
- /package/dist/{blockingWithLatestFrom-D8kBPBMX.cjs → blockingWithLatestFrom-DY8OPg0w.cjs} +0 -0
- /package/dist/{cardano-network-id-to-network-type-C0ufJOyE.cjs → cardano-network-id-to-network-type-BDTF-HmK.cjs} +0 -0
- /package/dist/{cardano-network-id-to-network-type-BWwzeEtM.js → cardano-network-id-to-network-type-CrZfUcyP.js} +0 -0
- /package/dist/{cardano-tx-id.vo-D3ASTIMd.cjs → cardano-tx-id.vo-BPhV-AmZ.cjs} +0 -0
- /package/dist/{cardano-tx-id.vo-BXLo1b7Q.js → cardano-tx-id.vo-DF9NzZXk.js} +0 -0
- /package/dist/{composite-signer-factory-m5cVs9h_.cjs → composite-signer-factory-BpF1mIYA.cjs} +0 -0
- /package/dist/{composite-signer-factory-CR8YHA1y.js → composite-signer-factory-_46QsNBz.js} +0 -0
- /package/dist/{error-DIZOY2Lw.js → error-BCp9NkPi.js} +0 -0
- /package/dist/{error-Cb3EnD0u.cjs → error-CNIquqT5.cjs} +0 -0
- /package/dist/{esm-browser-MG97cre9.js → esm-browser-C93Q-EOI.js} +0 -0
- /package/dist/{esm-browser-bweqfBlL.cjs → esm-browser-DTc9IK3D.cjs} +0 -0
- /package/dist/{feature-flag-key.vo-RlfHL3hq.cjs → feature-flag-key.vo-BPz-ZAp6.cjs} +0 -0
- /package/dist/{feature-flag-key.vo-DN_-4-sG.js → feature-flag-key.vo-ofrB6ZVQ.js} +0 -0
- /package/dist/{first-state-of-status-unPynOuM.js → first-state-of-status-DQnMT3ya.js} +0 -0
- /package/dist/{first-state-of-status-CbT7hPa4.cjs → first-state-of-status-OROkXcRv.cjs} +0 -0
- /package/dist/{init-zUoRG_EC2.cjs → init-C5CEZ1m0.cjs} +0 -0
- /package/dist/{init-DHaMxHM1.js → init-CKipPE_c.js} +0 -0
- /package/dist/{init-Atisw4x2.cjs → init-DFQQ9dTW.cjs} +0 -0
- /package/dist/{init-829HRYcz.js → init-Es3wHW7D.js} +0 -0
- /package/dist/{init-BgNobbNq.cjs → init-IAk_CkGa.cjs} +0 -0
- /package/dist/{init-atCFur0v.js → init-cqN3uX2j.js} +0 -0
- /package/dist/{is-redux-persist-state-BCFnSm36.cjs → is-redux-persist-state-CTn3WZVh.cjs} +0 -0
- /package/dist/{is-redux-persist-state-yBfq0h_E.js → is-redux-persist-state-Cxcd0_bM.js} +0 -0
- /package/dist/{key-value-store--W3SrMaw.js → key-value-store-8cMzeNyG.js} +0 -0
- /package/dist/{key-value-store-C2Xt5Emp.cjs → key-value-store-DUAepXQf.cjs} +0 -0
- /package/dist/{repo-slice-RxFm0zDZ.js → repo-slice-DwyMhCR1.js} +0 -0
- /package/dist/{repo-slice-7X4AYYVm.cjs → repo-slice-WxetRhMY.cjs} +0 -0
- /package/dist/{reselect-CGoLzEPv.js → reselect-C06X06oX.js} +0 -0
- /package/dist/{reselect-Bd94u0K-.cjs → reselect-CRDqmQY9.cjs} +0 -0
- /package/dist/{serializable-BHdKIgk3.js → serializable-B8GahgE1.js} +0 -0
- /package/dist/{serializable-BxHkoPdk.cjs → serializable-CRdnFaLZ.cjs} +0 -0
- /package/dist/{slice-obCSLm1x.js → slice-B87b52iM.js} +0 -0
- /package/dist/{slice-Bk0Sv05J.js → slice-Be7hj4Iy.js} +0 -0
- /package/dist/{slice-BiRsDKOK.cjs → slice-D11FHQuQ.cjs} +0 -0
- /package/dist/{slice-Dqw1ecum.cjs → slice-FioKeHtA.cjs} +0 -0
- /package/dist/{src-Cqp0B2M_.cjs → src-BTPIvlDI.cjs} +0 -0
- /package/dist/{src-BlxEp6Mm.js → src-vq1wS9sZ.js} +0 -0
- /package/dist/{time.vo-D3wWRw9L.cjs → time.vo-CQ8pSXz2.cjs} +0 -0
- /package/dist/{time.vo-tNheinXm.js → time.vo-DkYYGYp6.js} +0 -0
- /package/dist/{toEmpty-8Zax1MPd.js → toEmpty-CgAl3097.js} +0 -0
- /package/dist/{toEmpty-CYAbupM4.cjs → toEmpty-DAMmNB5r.cjs} +0 -0
- /package/dist/{token-id.vo-DXv5uS9n.cjs → token-id.vo-BxG9TG0O.cjs} +0 -0
- /package/dist/{token-id.vo-Bvwhr3ZE.js → token-id.vo-ClsroxHO.js} +0 -0
- /package/dist/{util-CzeB3hfa.cjs → util-CmdAhheh.cjs} +0 -0
- /package/dist/{util-C8a4fA9p.js → util-DxzlYNS5.js} +0 -0
- /package/dist/{util-selector-BWPH68_l.cjs → util-selector-BcAncU4L.cjs} +0 -0
- /package/dist/{util-selector-BSTsxgne.js → util-selector-CcK-GAdE.js} +0 -0
- /package/dist/{while-active-B0lWy_6l.js → while-active-BpppWuCs.js} +0 -0
- /package/dist/{while-active-Dsowp0Fi.cjs → while-active-Dhc2LwOm.cjs} +0 -0
|
@@ -1,695 +0,0 @@
|
|
|
1
|
-
import { n as HexBytes, t as ByteArray } from "./bytes.vo-BB7_4JK6.js";
|
|
2
|
-
import { d as DeviceEntryNotFoundError, l as CreationArtefactMismatchError, o as AuthorityNotRetiredError, s as AuthorityRetiredError, t as AccountContractMissingError } from "./errors-DIJTAsLa.js";
|
|
3
|
-
import { t as GRANTEE_WITHDRAWAL_CIRCUITS } from "./grant-circuits-swuzEdUl.js";
|
|
4
|
-
import { n as submitTx, r as submitWithDustRetry, t as assertSubmitted } from "./submit-D_yxYM_T.js";
|
|
5
|
-
import { a as pureCircuits, i as ledger, r as expectedVk, t as Contract } from "./acc-module-Cmj8EsIb.js";
|
|
6
|
-
import { n as JubjubDevice, r as authArgs } from "./signer-DGluibtn.js";
|
|
7
|
-
//#region ../../packages/contract/passport/src/value-objects/use-counter.vo.ts
|
|
8
|
-
/** Types a bigint as an authoriser's use counter. It checks nothing. */
|
|
9
|
-
const UseCounter = (value) => value;
|
|
10
|
-
//#endregion
|
|
11
|
-
//#region ../../packages/contract/passport/src/value-objects/device-epoch.vo.ts
|
|
12
|
-
/** Types a bigint as a device authoriser's epoch. It checks nothing. */
|
|
13
|
-
const DeviceEpoch = (value) => value;
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region ../../packages/module/passport-account/src/acc/verifier-key-insert.ts
|
|
16
|
-
/**
|
|
17
|
-
* The operation version the vendored contract's verifier keys belong to.
|
|
18
|
-
* The compiler this module pins emits keys under the v7 header, which the
|
|
19
|
-
* ledger files under operation version 'v4'; the midnight-js maintenance
|
|
20
|
-
* helpers still assume 'v3' and refuse these keys before a transaction
|
|
21
|
-
* exists, so the insert is built against the ledger directly.
|
|
22
|
-
*/
|
|
23
|
-
const VERIFIER_KEY_OPERATION_VERSION = "v4";
|
|
24
|
-
/** The header every verifier key of the pinned compiler starts with. */
|
|
25
|
-
const VERIFIER_KEY_HEADER = "midnight:verifier-key[v7]:";
|
|
26
|
-
const headerOf = (verifierKey) => new TextDecoder().decode(verifierKey.subarray(0, 26));
|
|
27
|
-
/**
|
|
28
|
-
* Refuses a verifier key under any other header, naming the operation.
|
|
29
|
-
* The ledger would refuse it too, but only once a transaction is being
|
|
30
|
-
* built, after the key has been downloaded and a wave planned around it.
|
|
31
|
-
*/
|
|
32
|
-
const assertVerifierKeyHeader = (operation, verifierKey) => {
|
|
33
|
-
const header = headerOf(verifierKey);
|
|
34
|
-
if (header !== VERIFIER_KEY_HEADER) throw new Error(`The verifier key of '${operation}' is not a ${VERIFIER_KEY_HEADER} key, got '${header}'`);
|
|
35
|
-
};
|
|
36
|
-
/**
|
|
37
|
-
* The maintenance update entry that installs one operation's verifier
|
|
38
|
-
* key under the operation version the pinned compiler's keys belong to.
|
|
39
|
-
*/
|
|
40
|
-
const verifierKeyInsert = (ledger, operation, verifierKey) => {
|
|
41
|
-
assertVerifierKeyHeader(operation, verifierKey);
|
|
42
|
-
return new ledger.VerifierKeyInsert(operation, new ledger.ContractOperationVersionedVerifierKey(VERIFIER_KEY_OPERATION_VERSION, verifierKey));
|
|
43
|
-
};
|
|
44
|
-
//#endregion
|
|
45
|
-
//#region ../../packages/module/passport-account/src/acc/wave-plan.ts
|
|
46
|
-
/**
|
|
47
|
-
* Most verifier key bytes one transaction may carry. A deploy or
|
|
48
|
-
* maintenance update above it is refused by the node for exhausting the
|
|
49
|
-
* block limits, so the roster is split into waves packed under this
|
|
50
|
-
* figure. The budget is a packing heuristic over the measured key sizes,
|
|
51
|
-
* not the node's own weight check.
|
|
52
|
-
*/
|
|
53
|
-
const VERIFIER_BYTE_BUDGET = 15e3;
|
|
54
|
-
const sizeOf = (sizes, operation) => {
|
|
55
|
-
const size = sizes.get(operation);
|
|
56
|
-
if (size === void 0) throw new Error(`No verifier key size for operation '${operation}'`);
|
|
57
|
-
return size;
|
|
58
|
-
};
|
|
59
|
-
const assertBudget = (budget) => {
|
|
60
|
-
if (!Number.isFinite(budget) || budget <= 0) throw new Error(`The verifier byte budget must be a positive number, got ${budget}`);
|
|
61
|
-
};
|
|
62
|
-
/**
|
|
63
|
-
* Packs the operations greedily, in order, into batches no larger than
|
|
64
|
-
* the budget. Greedy over one fixed order keeps the plan deterministic
|
|
65
|
-
* for a given roster and key set, so a retry computes the same waves.
|
|
66
|
-
*/
|
|
67
|
-
const packOperations = (operations, sizes, budget) => {
|
|
68
|
-
const batches = [];
|
|
69
|
-
let current = {
|
|
70
|
-
operations: [],
|
|
71
|
-
verifierBytes: 0
|
|
72
|
-
};
|
|
73
|
-
for (const operation of operations) {
|
|
74
|
-
const size = sizeOf(sizes, operation);
|
|
75
|
-
if (size > budget) throw new Error(`The verifier key of '${operation}' (${size} bytes) exceeds the ${budget} byte wave budget`);
|
|
76
|
-
if (current.verifierBytes + size > budget) {
|
|
77
|
-
batches.push(current);
|
|
78
|
-
current = {
|
|
79
|
-
operations: [],
|
|
80
|
-
verifierBytes: 0
|
|
81
|
-
};
|
|
82
|
-
}
|
|
83
|
-
current.operations.push(operation);
|
|
84
|
-
current.verifierBytes += size;
|
|
85
|
-
}
|
|
86
|
-
if (current.operations.length > 0) batches.push(current);
|
|
87
|
-
return batches;
|
|
88
|
-
};
|
|
89
|
-
/**
|
|
90
|
-
* The maintenance waves for the given batches. Retirement rides on the
|
|
91
|
-
* last of them, the last update that needs the authority; with nothing
|
|
92
|
-
* left to install, a retire-only update is the whole of it.
|
|
93
|
-
*/
|
|
94
|
-
const toMaintenanceWaves = (batches, shouldRetire) => {
|
|
95
|
-
const waves = batches.map((batch) => ({
|
|
96
|
-
kind: "maintenance",
|
|
97
|
-
...batch,
|
|
98
|
-
retiresAuthority: false
|
|
99
|
-
}));
|
|
100
|
-
if (!shouldRetire) return waves;
|
|
101
|
-
const last = waves.at(-1);
|
|
102
|
-
if (last) last.retiresAuthority = true;
|
|
103
|
-
else waves.push({
|
|
104
|
-
kind: "maintenance",
|
|
105
|
-
operations: [],
|
|
106
|
-
verifierBytes: 0,
|
|
107
|
-
retiresAuthority: true
|
|
108
|
-
});
|
|
109
|
-
return waves;
|
|
110
|
-
};
|
|
111
|
-
/**
|
|
112
|
-
* Plans a fresh deployment: the deploy carries the longest prefix of the
|
|
113
|
-
* roster under the budget, and every later wave is one maintenance update
|
|
114
|
-
* with the next batch. The order is the roster's, so the activation
|
|
115
|
-
* circuit lands in the deploy and the account is usable as early as the
|
|
116
|
-
* waves allow.
|
|
117
|
-
*/
|
|
118
|
-
const planDeployWaves = (operations, sizes, { retireAuthority, budget = VERIFIER_BYTE_BUDGET }) => {
|
|
119
|
-
assertBudget(budget);
|
|
120
|
-
const [deploy, ...rest] = packOperations(operations, sizes, budget);
|
|
121
|
-
if (!deploy) throw new Error("A deployment needs at least one operation");
|
|
122
|
-
return [{
|
|
123
|
-
kind: "deploy",
|
|
124
|
-
...deploy,
|
|
125
|
-
retiresAuthority: false
|
|
126
|
-
}, ...toMaintenanceWaves(rest, retireAuthority)];
|
|
127
|
-
};
|
|
128
|
-
/**
|
|
129
|
-
* Plans the waves a deployed contract still needs: the roster operations
|
|
130
|
-
* not yet installed, packed as maintenance updates, and the retirement
|
|
131
|
-
* when the account is to be locked and its authority is still live.
|
|
132
|
-
* Installed operations are read from chain rather than from any local
|
|
133
|
-
* count, so a wave that landed without being recorded is never sent
|
|
134
|
-
* twice.
|
|
135
|
-
*
|
|
136
|
-
* @throws {@link AuthorityRetiredError} when operations are missing but
|
|
137
|
-
* the authority is already retired: nothing can install them any more.
|
|
138
|
-
*/
|
|
139
|
-
const planResumeWaves = ({ operations, sizes, installed, isAuthorityRetired, retireAuthority, budget = VERIFIER_BYTE_BUDGET }) => {
|
|
140
|
-
assertBudget(budget);
|
|
141
|
-
const installedSet = new Set(installed);
|
|
142
|
-
const missing = operations.filter((operation) => !installedSet.has(operation));
|
|
143
|
-
if (isAuthorityRetired) {
|
|
144
|
-
if (missing.length > 0) throw new AuthorityRetiredError(`The maintenance authority is retired and ${missing.length} operations are not installed: ${missing.join(", ")}`);
|
|
145
|
-
return [];
|
|
146
|
-
}
|
|
147
|
-
return toMaintenanceWaves(packOperations(missing, sizes, budget), retireAuthority);
|
|
148
|
-
};
|
|
149
|
-
//#endregion
|
|
150
|
-
//#region ../../packages/module/passport-account/src/acc/deploy.ts
|
|
151
|
-
/** Every impure circuit of the jubjub arm, activation included. */
|
|
152
|
-
const JUBJUB_ARM_CIRCUITS = ["activate_initial_device", ...[
|
|
153
|
-
"withdraw_unshielded",
|
|
154
|
-
"append_inbox",
|
|
155
|
-
"withdraw_shielded",
|
|
156
|
-
"withdraw_shielded_to_contract",
|
|
157
|
-
"rotate_enc_key",
|
|
158
|
-
"add_device",
|
|
159
|
-
"remove_device"
|
|
160
|
-
]].map((base) => `${base}_with_jubjub`);
|
|
161
|
-
/** Permissionless deposit circuits shared by all arms. */
|
|
162
|
-
const SHARED_CIRCUITS = ["deposit_unshielded", "deposit_shielded"];
|
|
163
|
-
/**
|
|
164
|
-
* The scoped grant circuits: the lifecycle a jubjub device authorises,
|
|
165
|
-
* then the withdrawals of a jubjub grantee and of a secp256k1 grantee.
|
|
166
|
-
*/
|
|
167
|
-
const GRANT_CIRCUITS = [
|
|
168
|
-
...[
|
|
169
|
-
"issue_grant",
|
|
170
|
-
"revoke_grant",
|
|
171
|
-
"revoke_all_grants"
|
|
172
|
-
].map((base) => `${base}_with_jubjub`),
|
|
173
|
-
...GRANTEE_WITHDRAWAL_CIRCUITS["jubjub-schnorr"],
|
|
174
|
-
...GRANTEE_WITHDRAWAL_CIRCUITS["secp256k1-ecdsa"]
|
|
175
|
-
];
|
|
176
|
-
/**
|
|
177
|
-
* The complete operation set this module deploys, in installation order:
|
|
178
|
-
* the deposits, the jubjub device arm and the grant circuits. The device
|
|
179
|
-
* arm is jubjub only: the compiled contract also carries k256 and P-256
|
|
180
|
-
* device arms, their grant lifecycles and the recovery circuits, and none
|
|
181
|
-
* of their verifier keys are installed, so on an account deployed here
|
|
182
|
-
* only jubjub devices can ever authorise. A grant may name a jubjub or a
|
|
183
|
-
* secp256k1 grantee, so the withdrawals of both grantee arms are
|
|
184
|
-
* installed.
|
|
185
|
-
*/
|
|
186
|
-
const DEPLOYED_OPERATIONS = [
|
|
187
|
-
...SHARED_CIRCUITS,
|
|
188
|
-
...JUBJUB_ARM_CIRCUITS,
|
|
189
|
-
...GRANT_CIRCUITS
|
|
190
|
-
];
|
|
191
|
-
const ACTIVATE_INITIAL_DEVICE_CIRCUIT = "activate_initial_device_with_jubjub";
|
|
192
|
-
const SALT_LENGTH = 32;
|
|
193
|
-
const RECOVERY_WRAP_LENGTH = 64;
|
|
194
|
-
const PRIVATE_STATE_ID_LENGTH$1 = 8;
|
|
195
|
-
/** Three days, the veto window published with the throwaway recovery. */
|
|
196
|
-
const VETO_WINDOW_SECONDS = 259200n;
|
|
197
|
-
const DEPLOY_TX_TTL_MS = 6e4;
|
|
198
|
-
/** How long a landed wave may take to show in the indexer's state. */
|
|
199
|
-
const AUTHORITY_POLL_ATTEMPTS = 60;
|
|
200
|
-
const AUTHORITY_POLL_DELAY_MS = 2e3;
|
|
201
|
-
/** How long a landed deploy may take to appear in the indexer at all. */
|
|
202
|
-
const INDEXED_POLL_ATTEMPTS = 30;
|
|
203
|
-
const defaultSleep = async (ms) => new Promise((resolve) => {
|
|
204
|
-
setTimeout(resolve, ms);
|
|
205
|
-
});
|
|
206
|
-
/**
|
|
207
|
-
* The contract's witness implementations over {@link AccountPrivateState}.
|
|
208
|
-
* `held_coin` serves the exact qualified coin a shielded spend consumes;
|
|
209
|
-
* a color the store has not captured cannot be spent by a conforming
|
|
210
|
-
* client, so the witness refuses it.
|
|
211
|
-
*/
|
|
212
|
-
const accountWitnesses = { held_coin: (context, color) => {
|
|
213
|
-
const key = HexBytes.fromByteArray(color);
|
|
214
|
-
const stored = context.privateState.coins[key];
|
|
215
|
-
if (!stored) throw new Error(`held_coin witness: no coin for color ${key} in the local store`);
|
|
216
|
-
return [context.privateState, {
|
|
217
|
-
nonce: ByteArray.fromHex(HexBytes(stored.nonceHex)),
|
|
218
|
-
color: ByteArray.fromHex(HexBytes(stored.colorHex)),
|
|
219
|
-
value: BigInt(stored.value),
|
|
220
|
-
mt_index: BigInt(stored.mtIndex)
|
|
221
|
-
}];
|
|
222
|
-
} };
|
|
223
|
-
/** The private state a handle starts from: no captured coins yet. */
|
|
224
|
-
const initialAccountPrivateState = () => ({ coins: {} });
|
|
225
|
-
const transactionTtl = () => new Date(Date.now() + DEPLOY_TX_TTL_MS);
|
|
226
|
-
const defaultRandomBytes = (length) => crypto.getRandomValues(new Uint8Array(length));
|
|
227
|
-
const importChainModules = async () => Promise.all([
|
|
228
|
-
import("@midnight-ntwrk/midnight-js-contracts"),
|
|
229
|
-
import("@midnightntwrk/ledger-v9"),
|
|
230
|
-
import("@midnight-ntwrk/midnight-js-network-id"),
|
|
231
|
-
import("@midnight-ntwrk/compact-js/effect/CompiledContract")
|
|
232
|
-
]);
|
|
233
|
-
/**
|
|
234
|
-
* Names the verifier keys this build installs: the lowercase hex sha256
|
|
235
|
-
* over each roster operation's name and the sha256 pin of its verifier
|
|
236
|
-
* key, in installation order. A deployment records it once the deploy
|
|
237
|
-
* lands, and a resume compares it before any wave, so an account never
|
|
238
|
-
* holds verifier keys of two builds.
|
|
239
|
-
*/
|
|
240
|
-
const deployedVerifierKeysDigest = async () => {
|
|
241
|
-
const pins = DEPLOYED_OPERATIONS.map((operation) => {
|
|
242
|
-
const pin = expectedVk[operation];
|
|
243
|
-
if (!pin) throw new Error(`No verifier key pin for '${operation}'`);
|
|
244
|
-
return `${operation}:${pin}`;
|
|
245
|
-
});
|
|
246
|
-
const digest = await crypto.subtle.digest("SHA-256", new TextEncoder().encode(pins.join("\n")));
|
|
247
|
-
return HexBytes.fromByteArray(new Uint8Array(digest));
|
|
248
|
-
};
|
|
249
|
-
/**
|
|
250
|
-
* The verifier key of every roster operation, downloaded through the zk
|
|
251
|
-
* config provider so each one is checked against its pin and its header,
|
|
252
|
-
* and the sizes the wave plan is computed from. The plan follows the
|
|
253
|
-
* real keys, so a roster or key-size change re-plans itself.
|
|
254
|
-
*/
|
|
255
|
-
const loadVerifierKeys = async (providers, operations) => {
|
|
256
|
-
const zkConfig = providers.zkConfigProvider;
|
|
257
|
-
const keys = new Map(await Promise.all(operations.map(async (operation) => {
|
|
258
|
-
const key = await zkConfig.getVerifierKey(operation);
|
|
259
|
-
assertVerifierKeyHeader(operation, key);
|
|
260
|
-
return [operation, key];
|
|
261
|
-
})));
|
|
262
|
-
return {
|
|
263
|
-
keys,
|
|
264
|
-
sizes: new Map([...keys].map(([operation, key]) => [operation, key.length]))
|
|
265
|
-
};
|
|
266
|
-
};
|
|
267
|
-
const queryContractState = async ({ providers, address }) => providers.publicDataProvider.queryContractState(address);
|
|
268
|
-
/** The contract state as the indexer serves it, which must exist. */
|
|
269
|
-
const readProvidedState = async (chain) => {
|
|
270
|
-
const state = await queryContractState(chain);
|
|
271
|
-
if (!state) throw new AccountContractMissingError(`No live Account Custody Contract found at ${chain.address}.`);
|
|
272
|
-
return state;
|
|
273
|
-
};
|
|
274
|
-
/**
|
|
275
|
-
* The contract state as it stands on chain, read as the ledger's class.
|
|
276
|
-
* The public data provider hands back a compact-runtime state; the two
|
|
277
|
-
* bridge by serialisation.
|
|
278
|
-
*/
|
|
279
|
-
const readContractState = async (chain) => chain.ledger.ContractState.deserialize((await readProvidedState(chain)).serialize());
|
|
280
|
-
/**
|
|
281
|
-
* Blocks until the indexer serves the contract the deploy created. The
|
|
282
|
-
* deploy is final once its submission settles, but the indexer can lag
|
|
283
|
-
* the block it landed in, and the first wave reads the authority counter
|
|
284
|
-
* from it.
|
|
285
|
-
*/
|
|
286
|
-
const awaitContractIndexed = async (chain, sleep) => {
|
|
287
|
-
for (let attempt = 0; attempt < INDEXED_POLL_ATTEMPTS; attempt++) {
|
|
288
|
-
if (await queryContractState(chain)) return;
|
|
289
|
-
await sleep(AUTHORITY_POLL_DELAY_MS);
|
|
290
|
-
}
|
|
291
|
-
throw new AccountContractMissingError(`The Account Custody Contract deployed at ${chain.address} never appeared in the indexer.`);
|
|
292
|
-
};
|
|
293
|
-
/**
|
|
294
|
-
* Blocks until the chain shows the counter a wave advanced the authority
|
|
295
|
-
* to. The next update must be built against the advanced counter, and
|
|
296
|
-
* the indexer can lag the block the wave landed in.
|
|
297
|
-
*/
|
|
298
|
-
const awaitAuthorityCounter = async (chain, expected, sleep) => {
|
|
299
|
-
for (let attempt = 0; attempt < AUTHORITY_POLL_ATTEMPTS; attempt++) {
|
|
300
|
-
const { maintenanceAuthority } = await readContractState(chain);
|
|
301
|
-
if (maintenanceAuthority.counter >= expected) return;
|
|
302
|
-
await sleep(AUTHORITY_POLL_DELAY_MS);
|
|
303
|
-
}
|
|
304
|
-
throw new Error(`The maintenance authority counter of ${chain.address} never reached ${expected}`);
|
|
305
|
-
};
|
|
306
|
-
const verifierKeyOf = (verifierKeys, operation) => {
|
|
307
|
-
const key = verifierKeys.get(operation);
|
|
308
|
-
if (!key) throw new Error(`No verifier key loaded for '${operation}'`);
|
|
309
|
-
return key;
|
|
310
|
-
};
|
|
311
|
-
/**
|
|
312
|
-
* Submits the maintenance waves in order, each one update carrying its
|
|
313
|
-
* batch of verifier key inserts, signed by the maintenance authority key.
|
|
314
|
-
* The counter is read from chain before every update because each
|
|
315
|
-
* applied update advances it, and a wave that retires the authority
|
|
316
|
-
* installs the unsatisfiable committee at the counter its own application
|
|
317
|
-
* leaves behind.
|
|
318
|
-
*/
|
|
319
|
-
const installWaves = async ({ providers, ledger, address, networkId, waves, verifierKeys, authorityKey, sleep }) => {
|
|
320
|
-
const chain = {
|
|
321
|
-
providers,
|
|
322
|
-
ledger,
|
|
323
|
-
address
|
|
324
|
-
};
|
|
325
|
-
for (const [index, wave] of waves.entries()) {
|
|
326
|
-
const { maintenanceAuthority } = await readContractState(chain);
|
|
327
|
-
const counter = maintenanceAuthority.counter;
|
|
328
|
-
const updates = wave.operations.map((operation) => verifierKeyInsert(ledger, operation, verifierKeyOf(verifierKeys, operation)));
|
|
329
|
-
if (wave.retiresAuthority) updates.push(new ledger.ReplaceAuthority(new ledger.ContractMaintenanceAuthority([], 1, counter + 1n)));
|
|
330
|
-
const update = new ledger.MaintenanceUpdate(address, updates, counter);
|
|
331
|
-
const signed = update.addSignature(0n, ledger.signData(authorityKey, update.dataToSign));
|
|
332
|
-
const waveTx = ledger.Transaction.fromParts(networkId.getNetworkId(), void 0, void 0, ledger.Intent.new(transactionTtl()).addMaintenanceUpdate(signed));
|
|
333
|
-
assertSubmitted(`Verifier key wave ${index + 1} of ${waves.length}`, await submitTx(providers, { unprovenTx: waveTx }));
|
|
334
|
-
await awaitAuthorityCounter(chain, counter + 1n, sleep);
|
|
335
|
-
}
|
|
336
|
-
};
|
|
337
|
-
/**
|
|
338
|
-
* Connects to the deployed contract and returns the account with its
|
|
339
|
-
* activation call. The connection checks the pinned circuits' keys on
|
|
340
|
-
* chain, so it runs only once every wave is in.
|
|
341
|
-
*/
|
|
342
|
-
const toDeployedAccount = async ({ providers, findContract, compiledContract, address, publicKey, salt, privateStateId, isActivated }) => {
|
|
343
|
-
const found = await findContract(providers, {
|
|
344
|
-
contractAddress: address,
|
|
345
|
-
compiledContract,
|
|
346
|
-
privateStateId,
|
|
347
|
-
initialPrivateState: initialAccountPrivateState()
|
|
348
|
-
});
|
|
349
|
-
return {
|
|
350
|
-
address,
|
|
351
|
-
salt,
|
|
352
|
-
isActivated,
|
|
353
|
-
activate: async () => {
|
|
354
|
-
const finalized = await submitWithDustRetry(async () => found.callTx[ACTIVATE_INITIAL_DEVICE_CIRCUIT](publicKey, salt));
|
|
355
|
-
assertSubmitted("Account activation", finalized);
|
|
356
|
-
return finalized;
|
|
357
|
-
}
|
|
358
|
-
};
|
|
359
|
-
};
|
|
360
|
-
const compileAccountContract = (CompiledContract) => CompiledContract.make("account", Contract).pipe(CompiledContract.withWitnesses(accountWitnesses));
|
|
361
|
-
const privateStateIdFrom = (randomBytes) => `account-${HexBytes.fromByteArray(randomBytes(PRIVATE_STATE_ID_LENGTH$1))}`;
|
|
362
|
-
/**
|
|
363
|
-
* The state the deploy carries: the constructor's data and maintenance
|
|
364
|
-
* authority with only the first wave's operations, each one's verifier
|
|
365
|
-
* key set from the downloaded, header-checked bytes. The pipeline's own
|
|
366
|
-
* state is not reused as is because compact-js fills verifier keys only
|
|
367
|
-
* for the circuits the zk config provider lists, the manifest-pinned
|
|
368
|
-
* ones, so the deposits would land without a key.
|
|
369
|
-
*/
|
|
370
|
-
const toDeployedState = ({ ledger, fullState, operations, verifierKeys }) => {
|
|
371
|
-
const deployedState = new ledger.ContractState();
|
|
372
|
-
deployedState.data = fullState.data;
|
|
373
|
-
deployedState.maintenanceAuthority = fullState.maintenanceAuthority;
|
|
374
|
-
for (const name of operations) {
|
|
375
|
-
const operation = fullState.operation(name);
|
|
376
|
-
if (!operation) throw new Error(`Compiled account contract has no operation '${name}'`);
|
|
377
|
-
operation.verifierKey = verifierKeyOf(verifierKeys, name);
|
|
378
|
-
deployedState.setOperation(name, operation);
|
|
379
|
-
}
|
|
380
|
-
return deployedState;
|
|
381
|
-
};
|
|
382
|
-
/**
|
|
383
|
-
* Deploys a fresh Account Custody Contract carrying the deposits, the
|
|
384
|
-
* jubjub device arm and the grant circuits, including the secp256k1
|
|
385
|
-
* grantee withdrawals, and returns its address, the boot salt, and the
|
|
386
|
-
* activation call.
|
|
387
|
-
*
|
|
388
|
-
* The constructor cannot insert the initial device entry (the contract
|
|
389
|
-
* address does not exist yet inside it), so it stores a salted boot
|
|
390
|
-
* commitment over the authoriser's public key with no device entry yet;
|
|
391
|
-
* `activate` presents the same key and salt to install the real entry
|
|
392
|
-
* once every wave is in.
|
|
393
|
-
*
|
|
394
|
-
* The constructor also publishes the account's recovery material: a
|
|
395
|
-
* recovery public key, the wrap its secret is sealed under, and the veto
|
|
396
|
-
* window a recovery must survive. This module offers no recovery, so it
|
|
397
|
-
* publishes a throwaway: a fresh jubjub key whose secret is discarded
|
|
398
|
-
* here and a three day window. No secret is sealed, so the wrap is left
|
|
399
|
-
* empty: all zero bytes are the unambiguous "no container" encoding,
|
|
400
|
-
* whereas random bytes would be indistinguishable on chain from a sealed
|
|
401
|
-
* viewing secret. Nobody holds the secret, so the account is recoverable
|
|
402
|
-
* by nobody, exactly as before the contract gained the field.
|
|
403
|
-
*
|
|
404
|
-
* The roster's verifier keys exceed what one transaction may carry, so
|
|
405
|
-
* the deployment runs in waves: the deploy carries the budgeted prefix of
|
|
406
|
-
* the roster, and each later wave is one maintenance update inserting
|
|
407
|
-
* the next batch, signed by the maintenance authority the deploy minted.
|
|
408
|
-
* `onDeployed` is called between the deploy and the first update with
|
|
409
|
-
* what a retry needs ({@link PendingDeployment}), so an interruption
|
|
410
|
-
* leaves a deployment {@link resumeAccountDeployment} can finish.
|
|
411
|
-
*
|
|
412
|
-
* The maintenance authority's signing key is total custody: it can
|
|
413
|
-
* replace any operation's verifier key and release the account's assets
|
|
414
|
-
* around the device seam. `lockAccount` decides its fate, explicitly:
|
|
415
|
-
*
|
|
416
|
-
* - `true`: the last wave also replaces the authority with an
|
|
417
|
-
* unsatisfiable one (empty committee at threshold 1). No maintenance
|
|
418
|
-
* update can ever be signed again, so the device seam becomes the only
|
|
419
|
-
* way to move the account's assets. The cost is that the account can
|
|
420
|
-
* never receive a future arm's circuits.
|
|
421
|
-
* - `false`: the deploy-time authority stays live on-chain, but this
|
|
422
|
-
* implementation discards its signing key once the account is
|
|
423
|
-
* activated; the key is held only for the duration of the flow and in
|
|
424
|
-
* the pending record a retry reads. Keeping the authority live is the
|
|
425
|
-
* caller's informed choice, accepted knowing the key amounts to full
|
|
426
|
-
* custody wherever it survives.
|
|
427
|
-
*/
|
|
428
|
-
const deployAccount = async ({ providers, authoriser, encPublicKey, lockAccount, onDeployed, randomBytes = defaultRandomBytes, sleep = defaultSleep }) => {
|
|
429
|
-
const [contracts, ledger, networkId, CompiledContract] = await importChainModules();
|
|
430
|
-
const publicKey = await authoriser.devicePublicKey();
|
|
431
|
-
const salt = randomBytes(SALT_LENGTH);
|
|
432
|
-
const bootCommitment = pureCircuits.derive_boot_commitment_with_jubjub(salt, publicKey);
|
|
433
|
-
const recoveryPublicKey = JubjubDevice.generate().pk;
|
|
434
|
-
const recoveryWrap = new Uint8Array(RECOVERY_WRAP_LENGTH);
|
|
435
|
-
const privateStateId = privateStateIdFrom(randomBytes);
|
|
436
|
-
const compiledContract = compileAccountContract(CompiledContract);
|
|
437
|
-
const createDeployTransaction = contracts.createUnprovenDeployTx;
|
|
438
|
-
const deployData = await createDeployTransaction(providers, {
|
|
439
|
-
compiledContract,
|
|
440
|
-
initialPrivateState: initialAccountPrivateState(),
|
|
441
|
-
args: [
|
|
442
|
-
bootCommitment,
|
|
443
|
-
encPublicKey,
|
|
444
|
-
recoveryPublicKey,
|
|
445
|
-
recoveryWrap,
|
|
446
|
-
VETO_WINDOW_SECONDS
|
|
447
|
-
]
|
|
448
|
-
});
|
|
449
|
-
const fullState = ledger.ContractState.deserialize(deployData.public.initialContractState.serialize());
|
|
450
|
-
const { keys: verifierKeys, sizes } = await loadVerifierKeys(providers, DEPLOYED_OPERATIONS);
|
|
451
|
-
const verifierKeysDigest = await deployedVerifierKeysDigest();
|
|
452
|
-
const [deployWave, ...maintenanceWaves] = planDeployWaves(DEPLOYED_OPERATIONS, sizes, { retireAuthority: lockAccount });
|
|
453
|
-
const deploy = new ledger.ContractDeploy(toDeployedState({
|
|
454
|
-
ledger,
|
|
455
|
-
fullState,
|
|
456
|
-
operations: deployWave.operations,
|
|
457
|
-
verifierKeys
|
|
458
|
-
}));
|
|
459
|
-
const address = String(deploy.address);
|
|
460
|
-
assertSubmitted("Account deploy", await submitTx(providers, { unprovenTx: ledger.Transaction.fromParts(networkId.getNetworkId(), void 0, void 0, ledger.Intent.new(transactionTtl()).addDeploy(deploy)) }));
|
|
461
|
-
const authorityKey = deployData.private.signingKey;
|
|
462
|
-
await onDeployed(address, {
|
|
463
|
-
operations: [...DEPLOYED_OPERATIONS],
|
|
464
|
-
lockAccount,
|
|
465
|
-
verifierKeysDigest,
|
|
466
|
-
saltHex: HexBytes.fromByteArray(salt),
|
|
467
|
-
authorityKey
|
|
468
|
-
});
|
|
469
|
-
await awaitContractIndexed({
|
|
470
|
-
providers,
|
|
471
|
-
ledger,
|
|
472
|
-
address
|
|
473
|
-
}, sleep);
|
|
474
|
-
await installWaves({
|
|
475
|
-
providers,
|
|
476
|
-
ledger,
|
|
477
|
-
address,
|
|
478
|
-
networkId,
|
|
479
|
-
waves: maintenanceWaves,
|
|
480
|
-
verifierKeys,
|
|
481
|
-
authorityKey,
|
|
482
|
-
sleep
|
|
483
|
-
});
|
|
484
|
-
return toDeployedAccount({
|
|
485
|
-
providers,
|
|
486
|
-
findContract: contracts.findDeployedContract,
|
|
487
|
-
compiledContract,
|
|
488
|
-
address,
|
|
489
|
-
publicKey,
|
|
490
|
-
salt,
|
|
491
|
-
privateStateId,
|
|
492
|
-
isActivated: false
|
|
493
|
-
});
|
|
494
|
-
};
|
|
495
|
-
/**
|
|
496
|
-
* Finishes a deployment whose waves were interrupted. The operations the
|
|
497
|
-
* contract already holds are read from chain, the waves still missing
|
|
498
|
-
* are planned from the pending roster and submitted, and the account is
|
|
499
|
-
* returned with its activation call; a deployment that only missed its
|
|
500
|
-
* activation plans no wave at all. A deployment the chain shows already
|
|
501
|
-
* activated, because the creation died between its activation and its
|
|
502
|
-
* final record write, installs nothing and is returned as activated. The
|
|
503
|
-
* lock choice is the one made when the deployment began; a locked
|
|
504
|
-
* deployment the chain shows activated is checked to have retired its
|
|
505
|
-
* authority, since the flow retires it before it activates. A deployment
|
|
506
|
-
* recorded under other verifier key pins than this build installs is
|
|
507
|
-
* refused before the chain is read.
|
|
508
|
-
*
|
|
509
|
-
* @throws {@link CreationArtefactMismatchError} when the recorded
|
|
510
|
-
* verifier key digest is missing or is not this build's.
|
|
511
|
-
* @throws {@link AuthorityNotRetiredError} when the deployment was to lock
|
|
512
|
-
* the account and the chain shows it activated with the authority live.
|
|
513
|
-
* @throws {@link AuthorityRetiredError} when operations are missing but
|
|
514
|
-
* the authority has already been retired, which no update can mend.
|
|
515
|
-
* @throws {@link AccountContractMissingError} when the address holds no
|
|
516
|
-
* live contract.
|
|
517
|
-
*/
|
|
518
|
-
const resumeAccountDeployment = async ({ providers, authoriser, address, pending, randomBytes = defaultRandomBytes, sleep = defaultSleep }) => {
|
|
519
|
-
if (pending.verifierKeysDigest !== await deployedVerifierKeysDigest()) throw new CreationArtefactMismatchError(`The unfinished creation of the account at ${address} was started under other verifier key pins than this build installs, so it cannot be resumed.`);
|
|
520
|
-
const [contracts, ledger$1, networkId, CompiledContract] = await importChainModules();
|
|
521
|
-
const publicKey = await authoriser.devicePublicKey();
|
|
522
|
-
const chain = {
|
|
523
|
-
providers,
|
|
524
|
-
ledger: ledger$1,
|
|
525
|
-
address
|
|
526
|
-
};
|
|
527
|
-
const provided = await readProvidedState(chain);
|
|
528
|
-
const isActivated = ledger(provided.data).booted;
|
|
529
|
-
const onChain = ledger$1.ContractState.deserialize(provided.serialize());
|
|
530
|
-
const isAuthorityRetired = onChain.maintenanceAuthority.committee.length === 0;
|
|
531
|
-
if (isActivated && pending.lockAccount && !isAuthorityRetired) throw new AuthorityNotRetiredError(`The account at ${address} was created to be locked and is activated, but its maintenance authority is still live.`);
|
|
532
|
-
if (!isActivated) {
|
|
533
|
-
const { keys: verifierKeys, sizes } = await loadVerifierKeys(providers, pending.operations);
|
|
534
|
-
const waves = planResumeWaves({
|
|
535
|
-
operations: pending.operations,
|
|
536
|
-
sizes,
|
|
537
|
-
installed: onChain.operations().map(String),
|
|
538
|
-
isAuthorityRetired,
|
|
539
|
-
retireAuthority: pending.lockAccount
|
|
540
|
-
});
|
|
541
|
-
await installWaves({
|
|
542
|
-
...chain,
|
|
543
|
-
networkId,
|
|
544
|
-
waves,
|
|
545
|
-
verifierKeys,
|
|
546
|
-
authorityKey: pending.authorityKey,
|
|
547
|
-
sleep
|
|
548
|
-
});
|
|
549
|
-
}
|
|
550
|
-
return toDeployedAccount({
|
|
551
|
-
providers,
|
|
552
|
-
findContract: contracts.findDeployedContract,
|
|
553
|
-
compiledContract: compileAccountContract(CompiledContract),
|
|
554
|
-
address,
|
|
555
|
-
publicKey,
|
|
556
|
-
salt: ByteArray.fromHex(HexBytes(pending.saltHex)),
|
|
557
|
-
privateStateId: privateStateIdFrom(randomBytes),
|
|
558
|
-
isActivated
|
|
559
|
-
});
|
|
560
|
-
};
|
|
561
|
-
//#endregion
|
|
562
|
-
//#region ../../packages/module/passport-account/src/acc/use-counter.ts
|
|
563
|
-
/** How far past the last known counter the rescan probes. */
|
|
564
|
-
const RESCAN_LIMIT = 4096n;
|
|
565
|
-
/**
|
|
566
|
-
* Candidates batched per deviceCommitments call. 64 keeps a typical rescan
|
|
567
|
-
* (small counter drift) at one ceremony while it caps a full-window miss at
|
|
568
|
-
* 64 ceremonies instead of 4096, and the per-chunk membership check stops
|
|
569
|
-
* the scan before the remaining commitments are ever computed.
|
|
570
|
-
*/
|
|
571
|
-
const RESCAN_CHUNK = 64n;
|
|
572
|
-
const isLiveEntry = (ledgerState, commitmentHex) => ledgerState.devices.member(ByteArray.fromHex(HexBytes(commitmentHex)));
|
|
573
|
-
const probeInBatches = async (deviceCommitments, { ledgerState, address, epoch, from, to }) => {
|
|
574
|
-
for (let chunkStart = from; chunkStart < to; chunkStart += RESCAN_CHUNK) {
|
|
575
|
-
const counters = [];
|
|
576
|
-
const chunkEnd = chunkStart + RESCAN_CHUNK < to ? chunkStart + RESCAN_CHUNK : to;
|
|
577
|
-
for (let candidate = chunkStart; candidate < chunkEnd; candidate++) counters.push(UseCounter(candidate));
|
|
578
|
-
const commitments = await deviceCommitments(address, epoch, counters);
|
|
579
|
-
for (const [index, useCounter] of counters.entries()) {
|
|
580
|
-
const commitmentHex = commitments[index];
|
|
581
|
-
if (isLiveEntry(ledgerState, commitmentHex)) return {
|
|
582
|
-
useCounter,
|
|
583
|
-
commitmentHex
|
|
584
|
-
};
|
|
585
|
-
}
|
|
586
|
-
}
|
|
587
|
-
};
|
|
588
|
-
const probeOneByOne = async ({ ledgerState, authoriser, address, epoch, from, to }) => {
|
|
589
|
-
for (let candidate = from; candidate < to; candidate++) {
|
|
590
|
-
const useCounter = UseCounter(candidate);
|
|
591
|
-
const commitmentHex = await authoriser.deviceCommitment(address, epoch, useCounter);
|
|
592
|
-
if (isLiveEntry(ledgerState, commitmentHex)) return {
|
|
593
|
-
useCounter,
|
|
594
|
-
commitmentHex
|
|
595
|
-
};
|
|
596
|
-
}
|
|
597
|
-
};
|
|
598
|
-
const probeWindow = async (props) => {
|
|
599
|
-
const { deviceCommitments } = props.authoriser;
|
|
600
|
-
return deviceCommitments ? probeInBatches(deviceCommitments, props) : probeOneByOne(props);
|
|
601
|
-
};
|
|
602
|
-
/**
|
|
603
|
-
* Recovers the device's current use counter from chain. The Account
|
|
604
|
-
* Custody Contract stores one rolling entry per device, positioned at the
|
|
605
|
-
* counter of its next authorisation, so the local counter can fall behind
|
|
606
|
-
* after out-of-band calls or lost state. Candidate counters are probed
|
|
607
|
-
* from the last known value (0 when unknown): the commitment computed for
|
|
608
|
-
* each candidate is tested for membership in the on-chain device set, and
|
|
609
|
-
* the first live entry wins. That window ends after RESCAN_LIMIT
|
|
610
|
-
* candidates, and only then are the counters below the anchor probed,
|
|
611
|
-
* from 0 up to it: a device removed and re-enrolled gets a fresh entry at
|
|
612
|
-
* a low counter while the persisted anchor still holds the old high one,
|
|
613
|
-
* and without the second pass such a device reads as revoked. A device
|
|
614
|
-
* with no entry in either pass is not registered on the account, has been
|
|
615
|
-
* revoked, or holds a counter beyond the probed window (a synced passkey
|
|
616
|
-
* used heavily on another device can outrun RESCAN_LIMIT between
|
|
617
|
-
* sign-ins here); the miss raises DeviceEntryNotFoundError, which names
|
|
618
|
-
* that ambiguity. An authoriser exposing deviceCommitments is probed in
|
|
619
|
-
* RESCAN_CHUNK batches so one key ceremony covers a whole chunk of
|
|
620
|
-
* candidates; otherwise each candidate costs one deviceCommitment call.
|
|
621
|
-
*/
|
|
622
|
-
const resolveUseCounter = async ({ ledgerState, authoriser, address, knownUseCounter }) => {
|
|
623
|
-
const epoch = DeviceEpoch(ledgerState.device_epoch);
|
|
624
|
-
const anchor = knownUseCounter ?? 0n;
|
|
625
|
-
const probe = async (from, to) => probeWindow({
|
|
626
|
-
ledgerState,
|
|
627
|
-
authoriser,
|
|
628
|
-
address,
|
|
629
|
-
epoch,
|
|
630
|
-
from,
|
|
631
|
-
to
|
|
632
|
-
});
|
|
633
|
-
const ahead = await probe(anchor, anchor + RESCAN_LIMIT);
|
|
634
|
-
if (ahead) return ahead;
|
|
635
|
-
const behind = await probe(0n, anchor);
|
|
636
|
-
if (behind) return behind;
|
|
637
|
-
throw new DeviceEntryNotFoundError(`No live device entry on the ledger within ${RESCAN_LIMIT} counters of the last known one (${anchor}), nor below it; the device is not registered on this account, or its counter has moved beyond the probed window.`);
|
|
638
|
-
};
|
|
639
|
-
//#endregion
|
|
640
|
-
//#region ../../packages/module/passport-account/src/acc/gated-call.ts
|
|
641
|
-
const PRIVATE_STATE_ID_LENGTH = 8;
|
|
642
|
-
/**
|
|
643
|
-
* Connects to a deployed Account Custody Contract and returns the handle
|
|
644
|
-
* gated calls run through. The private state starts without the account
|
|
645
|
-
* encryption secret: the device-management and grant lifecycle circuits
|
|
646
|
-
* consume no witnesses, so no coin or encryption key material is needed.
|
|
647
|
-
* Shielded flows will seed the viewing secret when they arrive.
|
|
648
|
-
*/
|
|
649
|
-
const connectAccountHandle = async (providers, contractAddress) => {
|
|
650
|
-
const [contracts, CompiledContract] = await Promise.all([import("@midnight-ntwrk/midnight-js-contracts"), import("@midnight-ntwrk/compact-js/effect/CompiledContract")]);
|
|
651
|
-
const compiledContract = CompiledContract.make("account", Contract).pipe(CompiledContract.withWitnesses(accountWitnesses));
|
|
652
|
-
const findContract = contracts.findDeployedContract;
|
|
653
|
-
return findContract(providers, {
|
|
654
|
-
contractAddress,
|
|
655
|
-
compiledContract,
|
|
656
|
-
privateStateId: `account-${HexBytes.fromByteArray(crypto.getRandomValues(new Uint8Array(PRIVATE_STATE_ID_LENGTH)))}`,
|
|
657
|
-
initialPrivateState: initialAccountPrivateState()
|
|
658
|
-
});
|
|
659
|
-
};
|
|
660
|
-
/**
|
|
661
|
-
* Executes one authorised circuit call against a deployed Account Custody
|
|
662
|
-
* Contract: resolves the device's current use counter from the ledger,
|
|
663
|
-
* has the authoriser sign the call over the observed auth nonce, submits
|
|
664
|
-
* the circuit with the authorising material appended as its trailing
|
|
665
|
-
* arguments (pk, use counter, announcement, closing scalar, grind nonce),
|
|
666
|
-
* and returns the counter the device holds after the accepted call: the
|
|
667
|
-
* consumed one plus one.
|
|
668
|
-
*
|
|
669
|
-
* A transaction that lands with a failing status rejects instead of
|
|
670
|
-
* returning: the contract applied nothing, so no counter may advance and
|
|
671
|
-
* no roster change may be recorded for it.
|
|
672
|
-
*/
|
|
673
|
-
const executeGatedCall = async ({ handle, authoriser, circuit, args, address, ledgerState, knownUseCounter }) => {
|
|
674
|
-
const call = handle.callTx[circuit];
|
|
675
|
-
if (!call) throw new Error(`Account contract handle has no circuit '${circuit}'`);
|
|
676
|
-
const { useCounter } = await resolveUseCounter({
|
|
677
|
-
ledgerState,
|
|
678
|
-
authoriser,
|
|
679
|
-
address,
|
|
680
|
-
knownUseCounter
|
|
681
|
-
});
|
|
682
|
-
const authorisation = await authoriser.authorise({
|
|
683
|
-
account: address,
|
|
684
|
-
circuit,
|
|
685
|
-
args,
|
|
686
|
-
witnessValues: [],
|
|
687
|
-
authNonce: ledgerState.auth_nonce,
|
|
688
|
-
useCounter
|
|
689
|
-
});
|
|
690
|
-
const finalized = await submitWithDustRetry(async () => call(...args, ...authArgs(authorisation)));
|
|
691
|
-
assertSubmitted(`Call to ${circuit}`, finalized);
|
|
692
|
-
return UseCounter(useCounter + 1n);
|
|
693
|
-
};
|
|
694
|
-
//#endregion
|
|
695
|
-
export { resumeAccountDeployment as a, deployAccount as i, executeGatedCall as n, DeviceEpoch as o, resolveUseCounter as r, UseCounter as s, connectAccountHandle as t };
|