@veilo/sdk-core 0.4.0 → 0.6.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/LICENSE +15 -0
- package/README.md +449 -1243
- package/accounts.d.ts +2 -0
- package/accounts.js +3 -0
- package/cloak.d.ts +2 -0
- package/cloak.js +3 -0
- package/config.d.ts +2 -2
- package/config.js +2 -3
- package/dist/cjs/accounts/admin.d.ts +84 -0
- package/dist/cjs/accounts/admin.js +208 -0
- package/dist/cjs/accounts/errors.d.ts +6 -0
- package/dist/cjs/accounts/errors.js +98 -0
- package/dist/cjs/accounts/index.d.ts +4 -0
- package/dist/cjs/accounts/index.js +20 -0
- package/dist/cjs/accounts/pdas.d.ts +23 -0
- package/dist/cjs/accounts/pdas.js +44 -0
- package/dist/cjs/accounts/queries.d.ts +41 -0
- package/dist/cjs/accounts/queries.js +95 -0
- package/dist/cjs/client.d.ts +2 -407
- package/dist/cjs/client.js +6 -938
- package/dist/cjs/cloak/client.d.ts +28 -0
- package/dist/cjs/cloak/client.js +68 -0
- package/dist/cjs/cloak/errors.d.ts +13 -0
- package/dist/cjs/cloak/errors.js +25 -0
- package/dist/cjs/cloak/helpers.d.ts +6 -0
- package/dist/cjs/cloak/helpers.js +35 -0
- package/dist/cjs/cloak/index.d.ts +6 -0
- package/dist/cjs/cloak/index.js +24 -0
- package/dist/cjs/cloak/polling.d.ts +7 -0
- package/dist/cjs/cloak/polling.js +66 -0
- package/dist/cjs/cloak/transport.d.ts +15 -0
- package/dist/cjs/cloak/transport.js +119 -0
- package/dist/cjs/cloak/types.d.ts +188 -0
- package/dist/cjs/cloak/types.js +5 -0
- package/dist/cjs/cloak.d.ts +1 -0
- package/dist/cjs/cloak.js +18 -0
- package/dist/cjs/compactNote.d.ts +21 -0
- package/dist/cjs/compactNote.js +31 -7
- package/dist/cjs/events/index.d.ts +6 -0
- package/dist/cjs/events/index.js +22 -0
- package/dist/cjs/events/parsing.d.ts +25 -0
- package/dist/cjs/events/parsing.js +158 -0
- package/dist/cjs/events/position.d.ts +26 -0
- package/dist/cjs/events/position.js +53 -0
- package/dist/cjs/events/recovery.d.ts +87 -0
- package/dist/cjs/events/recovery.js +281 -0
- package/dist/cjs/events/scanning.d.ts +35 -0
- package/dist/cjs/events/scanning.js +98 -0
- package/dist/cjs/events/tree.d.ts +27 -0
- package/dist/cjs/events/tree.js +63 -0
- package/dist/cjs/events/types.d.ts +39 -0
- package/dist/cjs/events.d.ts +1 -77
- package/dist/cjs/events.js +6 -154
- package/dist/cjs/identity/encoding.d.ts +9 -0
- package/dist/cjs/identity/encoding.js +85 -0
- package/dist/cjs/identity/index.d.ts +4 -0
- package/dist/cjs/identity/index.js +20 -0
- package/dist/cjs/identity/noteKey.d.ts +33 -0
- package/dist/cjs/identity/noteKey.js +97 -0
- package/dist/cjs/identity/spending.d.ts +18 -0
- package/dist/cjs/identity/spending.js +46 -0
- package/dist/cjs/identity/viewKey.d.ts +38 -0
- package/dist/cjs/identity/viewKey.js +105 -0
- package/dist/cjs/idl/index.d.ts +18 -0
- package/dist/cjs/idl/index.js +24 -0
- package/dist/cjs/idl/privacy_pool.json +9907 -9907
- package/dist/cjs/idl/privacy_pool_legacy.js +3307 -0
- package/dist/cjs/idl/privacy_pool_legacy.json +2302 -0
- package/dist/cjs/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/cjs/idl/privacy_pool_legacy2.js +3397 -0
- package/dist/cjs/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/cjs/index.d.ts +9 -3
- package/dist/cjs/index.js +15 -2
- package/dist/cjs/notes/amount.d.ts +2 -0
- package/dist/cjs/notes/amount.js +21 -0
- package/dist/cjs/notes/encryption.d.ts +41 -0
- package/dist/cjs/notes/encryption.js +75 -0
- package/dist/cjs/notes/index.d.ts +8 -0
- package/dist/cjs/notes/index.js +24 -0
- package/dist/cjs/notes/mailbox.d.ts +70 -0
- package/dist/cjs/notes/mailbox.js +164 -0
- package/dist/cjs/notes/model.d.ts +91 -0
- package/dist/cjs/notes/model.js +109 -0
- package/dist/cjs/notes/nullifier.d.ts +27 -0
- package/dist/cjs/notes/nullifier.js +45 -0
- package/dist/cjs/notes/recovery.d.ts +20 -0
- package/dist/cjs/notes/recovery.js +48 -0
- package/dist/cjs/notes/selection.d.ts +77 -0
- package/dist/cjs/notes/selection.js +193 -0
- package/dist/cjs/notes/spent.d.ts +60 -0
- package/dist/cjs/notes/spent.js +101 -0
- package/dist/cjs/perps/constants.d.ts +16 -0
- package/dist/cjs/perps/constants.js +52 -0
- package/dist/cjs/perps/index.d.ts +5 -0
- package/dist/cjs/perps/index.js +21 -0
- package/dist/cjs/perps/keys.d.ts +16 -0
- package/dist/cjs/perps/keys.js +43 -0
- package/dist/cjs/perps/pdas.d.ts +29 -0
- package/dist/cjs/perps/pdas.js +55 -0
- package/dist/cjs/perps/relayer.d.ts +9 -0
- package/dist/cjs/perps/relayer.js +35 -0
- package/dist/cjs/perps/types.d.ts +126 -0
- package/dist/cjs/perps/types.js +2 -0
- package/dist/cjs/positions/index.d.ts +4 -0
- package/dist/cjs/positions/index.js +20 -0
- package/dist/cjs/positions/keys.d.ts +29 -0
- package/dist/cjs/positions/keys.js +71 -0
- package/dist/cjs/positions/pdas.d.ts +15 -0
- package/dist/cjs/positions/pdas.js +54 -0
- package/dist/cjs/positions/relayer.d.ts +4 -0
- package/dist/cjs/positions/relayer.js +15 -0
- package/dist/cjs/positions/types.d.ts +97 -0
- package/dist/cjs/positions/types.js +2 -0
- package/dist/cjs/predictions/client.d.ts +41 -0
- package/dist/cjs/predictions/client.js +147 -0
- package/dist/cjs/predictions/index.d.ts +5 -0
- package/dist/cjs/predictions/index.js +21 -0
- package/dist/cjs/predictions/keys.d.ts +14 -0
- package/dist/cjs/predictions/keys.js +40 -0
- package/dist/cjs/predictions/pdas.d.ts +6 -0
- package/dist/cjs/predictions/pdas.js +13 -0
- package/dist/cjs/predictions/relayer.d.ts +3 -0
- package/dist/cjs/predictions/relayer.js +11 -0
- package/dist/cjs/predictions/types.d.ts +178 -0
- package/dist/cjs/predictions/types.js +2 -0
- package/dist/cjs/program.d.ts +2 -0
- package/dist/cjs/program.js +8 -7
- package/dist/cjs/proof.d.ts +1 -183
- package/dist/cjs/proof.js +16 -290
- package/dist/cjs/proofs/encoding.d.ts +17 -0
- package/dist/cjs/proofs/encoding.js +72 -0
- package/dist/cjs/proofs/formatting.d.ts +6 -0
- package/dist/cjs/proofs/formatting.js +34 -0
- package/dist/cjs/proofs/index.d.ts +5 -0
- package/dist/cjs/proofs/index.js +21 -0
- package/dist/cjs/proofs/swap.d.ts +87 -0
- package/dist/cjs/proofs/swap.js +144 -0
- package/dist/cjs/proofs/transaction.d.ts +28 -0
- package/dist/cjs/proofs/transaction.js +110 -0
- package/dist/cjs/proofs/types.d.ts +70 -0
- package/dist/cjs/proofs/types.js +2 -0
- package/dist/cjs/prover.d.ts +30 -4
- package/dist/cjs/prover.js +118 -49
- package/dist/cjs/relayer/api.d.ts +31 -0
- package/dist/cjs/relayer/api.js +86 -0
- package/dist/cjs/relayer/client.d.ts +73 -0
- package/dist/cjs/relayer/client.js +206 -0
- package/dist/cjs/relayer/crypto.d.ts +5 -0
- package/dist/cjs/relayer/crypto.js +26 -0
- package/dist/cjs/relayer/encoding.d.ts +2 -0
- package/dist/cjs/relayer/encoding.js +23 -0
- package/dist/cjs/relayer/errors.d.ts +7 -0
- package/dist/cjs/relayer/errors.js +17 -0
- package/dist/cjs/relayer/index.d.ts +6 -0
- package/dist/cjs/relayer/index.js +19 -0
- package/dist/cjs/relayer/internal-config.d.ts +36 -0
- package/dist/cjs/relayer/internal-config.js +9 -0
- package/dist/cjs/relayer/internal.d.ts +6 -0
- package/dist/cjs/relayer/internal.js +14 -0
- package/dist/cjs/relayer/transport.d.ts +19 -0
- package/dist/cjs/relayer/transport.js +68 -0
- package/dist/{src/relayer.d.ts → cjs/relayer/types.d.ts} +53 -96
- package/dist/cjs/relayer/types.js +5 -0
- package/dist/cjs/relayer.d.ts +1 -318
- package/dist/cjs/relayer.js +15 -254
- package/dist/cjs/shield/alt.js +8 -8
- package/dist/cjs/shield/errors.js +2 -2
- package/dist/cjs/shield/finalize.js +2 -2
- package/dist/cjs/shield/ix.d.ts +1 -1
- package/dist/cjs/shield/owner.js +9 -11
- package/dist/cjs/shield/ports.js +3 -3
- package/dist/cjs/shield/preflight.js +3 -3
- package/dist/cjs/shield/shield.js +20 -19
- package/dist/cjs/shield/types.d.ts +1 -1
- package/dist/cjs/transactions/deposit.d.ts +94 -0
- package/dist/cjs/transactions/deposit.js +234 -0
- package/dist/cjs/transactions/index.d.ts +7 -0
- package/dist/cjs/transactions/index.js +26 -0
- package/dist/cjs/transactions/swap.d.ts +71 -0
- package/dist/cjs/transactions/swap.js +184 -0
- package/dist/cjs/transactions/transact.d.ts +34 -0
- package/dist/cjs/transactions/transact.js +146 -0
- package/dist/cjs/transactions/transfer.d.ts +51 -0
- package/dist/cjs/transactions/transfer.js +106 -0
- package/dist/cjs/transactions/withdraw.d.ts +52 -0
- package/dist/cjs/transactions/withdraw.js +104 -0
- package/dist/cjs/utxo.d.ts +1 -235
- package/dist/cjs/utxo.js +15 -404
- package/dist/esm/accounts/admin.d.ts +84 -0
- package/dist/esm/accounts/admin.js +165 -0
- package/dist/esm/accounts/errors.d.ts +6 -0
- package/dist/esm/accounts/errors.js +95 -0
- package/dist/esm/accounts/index.d.ts +4 -0
- package/dist/esm/accounts/index.js +4 -0
- package/dist/esm/accounts/pdas.d.ts +23 -0
- package/dist/esm/accounts/pdas.js +38 -0
- package/dist/esm/accounts/queries.d.ts +41 -0
- package/dist/esm/accounts/queries.js +88 -0
- package/dist/esm/client.d.ts +2 -407
- package/dist/esm/client.js +3 -891
- package/dist/esm/cloak/client.d.ts +28 -0
- package/dist/esm/cloak/client.js +64 -0
- package/dist/esm/cloak/errors.d.ts +13 -0
- package/dist/esm/cloak/errors.js +21 -0
- package/dist/esm/cloak/helpers.d.ts +6 -0
- package/dist/esm/cloak/helpers.js +31 -0
- package/dist/esm/cloak/index.d.ts +6 -0
- package/dist/esm/cloak/index.js +6 -0
- package/dist/esm/cloak/polling.d.ts +7 -0
- package/dist/esm/cloak/polling.js +63 -0
- package/dist/esm/cloak/transport.d.ts +15 -0
- package/dist/esm/cloak/transport.js +115 -0
- package/dist/esm/cloak/types.d.ts +188 -0
- package/dist/esm/cloak/types.js +4 -0
- package/dist/esm/cloak.d.ts +1 -0
- package/dist/esm/cloak.js +2 -0
- package/dist/esm/compactNote.d.ts +21 -0
- package/dist/esm/compactNote.js +24 -1
- package/dist/esm/events/index.d.ts +6 -0
- package/dist/esm/events/index.js +6 -0
- package/dist/esm/events/parsing.d.ts +25 -0
- package/dist/esm/events/parsing.js +120 -0
- package/dist/esm/events/position.d.ts +26 -0
- package/dist/esm/events/position.js +48 -0
- package/dist/esm/events/recovery.d.ts +87 -0
- package/dist/esm/events/recovery.js +237 -0
- package/dist/esm/events/scanning.d.ts +35 -0
- package/dist/esm/events/scanning.js +92 -0
- package/dist/esm/events/tree.d.ts +27 -0
- package/dist/esm/events/tree.js +58 -0
- package/dist/esm/events/types.d.ts +39 -0
- package/dist/esm/events/types.js +1 -0
- package/dist/esm/events.d.ts +1 -77
- package/dist/esm/events.js +3 -129
- package/dist/esm/identity/encoding.d.ts +9 -0
- package/dist/esm/identity/encoding.js +75 -0
- package/dist/esm/identity/index.d.ts +4 -0
- package/dist/esm/identity/index.js +4 -0
- package/dist/esm/identity/noteKey.d.ts +33 -0
- package/dist/esm/identity/noteKey.js +91 -0
- package/dist/esm/identity/spending.d.ts +18 -0
- package/dist/esm/identity/spending.js +35 -0
- package/dist/esm/identity/viewKey.d.ts +38 -0
- package/dist/esm/identity/viewKey.js +96 -0
- package/dist/esm/idl/index.d.ts +18 -0
- package/dist/esm/idl/index.js +18 -0
- package/dist/esm/idl/privacy_pool.json +9907 -9907
- package/dist/esm/idl/privacy_pool_legacy.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy.js +3305 -0
- package/dist/esm/idl/privacy_pool_legacy.json +2302 -0
- package/dist/esm/idl/privacy_pool_legacy2.d.ts +5 -0
- package/dist/esm/idl/privacy_pool_legacy2.js +3395 -0
- package/dist/esm/idl/privacy_pool_legacy2.json +2376 -0
- package/dist/esm/index.d.ts +9 -3
- package/dist/esm/index.js +10 -3
- package/dist/esm/notes/amount.d.ts +2 -0
- package/dist/esm/notes/amount.js +18 -0
- package/dist/esm/notes/encryption.d.ts +41 -0
- package/dist/esm/notes/encryption.js +67 -0
- package/dist/esm/notes/index.d.ts +8 -0
- package/dist/esm/notes/index.js +8 -0
- package/dist/esm/notes/mailbox.d.ts +70 -0
- package/dist/esm/notes/mailbox.js +154 -0
- package/dist/esm/notes/model.d.ts +91 -0
- package/dist/esm/notes/model.js +99 -0
- package/dist/esm/notes/nullifier.d.ts +27 -0
- package/dist/esm/notes/nullifier.js +40 -0
- package/dist/esm/notes/recovery.d.ts +20 -0
- package/dist/esm/notes/recovery.js +45 -0
- package/dist/esm/notes/selection.d.ts +77 -0
- package/dist/esm/notes/selection.js +188 -0
- package/dist/esm/notes/spent.d.ts +60 -0
- package/dist/esm/notes/spent.js +96 -0
- package/dist/esm/perps/constants.d.ts +16 -0
- package/dist/esm/perps/constants.js +48 -0
- package/dist/esm/perps/index.d.ts +5 -0
- package/dist/esm/perps/index.js +5 -0
- package/dist/esm/perps/keys.d.ts +16 -0
- package/dist/esm/perps/keys.js +35 -0
- package/dist/esm/perps/pdas.d.ts +29 -0
- package/dist/esm/perps/pdas.js +47 -0
- package/dist/esm/perps/relayer.d.ts +9 -0
- package/dist/esm/perps/relayer.js +25 -0
- package/dist/esm/perps/types.d.ts +126 -0
- package/dist/esm/perps/types.js +1 -0
- package/dist/esm/positions/index.d.ts +4 -0
- package/dist/esm/positions/index.js +4 -0
- package/dist/esm/positions/keys.d.ts +29 -0
- package/dist/esm/positions/keys.js +65 -0
- package/dist/esm/positions/pdas.d.ts +15 -0
- package/dist/esm/positions/pdas.js +44 -0
- package/dist/esm/positions/relayer.d.ts +4 -0
- package/dist/esm/positions/relayer.js +10 -0
- package/dist/esm/positions/types.d.ts +97 -0
- package/dist/esm/positions/types.js +1 -0
- package/dist/esm/predictions/client.d.ts +41 -0
- package/dist/esm/predictions/client.js +141 -0
- package/dist/esm/predictions/index.d.ts +5 -0
- package/dist/esm/predictions/index.js +5 -0
- package/dist/esm/predictions/keys.d.ts +14 -0
- package/dist/esm/predictions/keys.js +33 -0
- package/dist/esm/predictions/pdas.d.ts +6 -0
- package/dist/esm/predictions/pdas.js +10 -0
- package/dist/esm/predictions/relayer.d.ts +3 -0
- package/dist/esm/predictions/relayer.js +7 -0
- package/dist/esm/predictions/types.d.ts +178 -0
- package/dist/esm/predictions/types.js +1 -0
- package/dist/esm/program.d.ts +2 -0
- package/dist/esm/program.js +4 -3
- package/dist/esm/proof.d.ts +1 -183
- package/dist/esm/proof.js +2 -281
- package/dist/esm/proofs/encoding.d.ts +17 -0
- package/dist/esm/proofs/encoding.js +68 -0
- package/dist/esm/proofs/formatting.d.ts +6 -0
- package/dist/esm/proofs/formatting.js +31 -0
- package/dist/esm/proofs/index.d.ts +5 -0
- package/dist/esm/proofs/index.js +5 -0
- package/dist/esm/proofs/swap.d.ts +87 -0
- package/dist/esm/proofs/swap.js +138 -0
- package/dist/esm/proofs/transaction.d.ts +28 -0
- package/dist/esm/proofs/transaction.js +105 -0
- package/dist/esm/proofs/types.d.ts +70 -0
- package/dist/esm/proofs/types.js +1 -0
- package/dist/esm/prover.d.ts +30 -4
- package/dist/esm/prover.js +115 -15
- package/dist/esm/relayer/api.d.ts +31 -0
- package/dist/esm/relayer/api.js +55 -0
- package/dist/esm/relayer/client.d.ts +73 -0
- package/dist/esm/relayer/client.js +199 -0
- package/dist/esm/relayer/crypto.d.ts +5 -0
- package/dist/esm/relayer/crypto.js +20 -0
- package/dist/esm/relayer/encoding.d.ts +2 -0
- package/dist/esm/relayer/encoding.js +19 -0
- package/dist/esm/relayer/errors.d.ts +7 -0
- package/dist/esm/relayer/errors.js +13 -0
- package/dist/esm/relayer/index.d.ts +6 -0
- package/dist/esm/relayer/index.js +3 -0
- package/dist/esm/relayer/internal-config.d.ts +36 -0
- package/dist/esm/relayer/internal-config.js +6 -0
- package/dist/esm/relayer/internal.d.ts +6 -0
- package/dist/esm/relayer/internal.js +10 -0
- package/dist/esm/relayer/transport.d.ts +19 -0
- package/dist/esm/relayer/transport.js +64 -0
- package/dist/esm/relayer/types.d.ts +275 -0
- package/dist/esm/relayer/types.js +4 -0
- package/dist/esm/relayer.d.ts +1 -318
- package/dist/esm/relayer.js +2 -249
- package/dist/esm/shield/alt.js +1 -1
- package/dist/esm/shield/errors.js +1 -1
- package/dist/esm/shield/finalize.js +1 -1
- package/dist/esm/shield/ix.d.ts +1 -1
- package/dist/esm/shield/owner.js +3 -5
- package/dist/esm/shield/ports.js +1 -1
- package/dist/esm/shield/preflight.js +1 -1
- package/dist/esm/shield/shield.js +4 -3
- package/dist/esm/shield/types.d.ts +1 -1
- package/dist/esm/transactions/deposit.d.ts +94 -0
- package/dist/esm/transactions/deposit.js +198 -0
- package/dist/esm/transactions/index.d.ts +7 -0
- package/dist/esm/transactions/index.js +7 -0
- package/dist/esm/transactions/swap.d.ts +71 -0
- package/dist/esm/transactions/swap.js +144 -0
- package/dist/esm/transactions/transact.d.ts +34 -0
- package/dist/esm/transactions/transact.js +110 -0
- package/dist/esm/transactions/transfer.d.ts +51 -0
- package/dist/esm/transactions/transfer.js +103 -0
- package/dist/esm/transactions/withdraw.d.ts +52 -0
- package/dist/esm/transactions/withdraw.js +101 -0
- package/dist/esm/utxo.d.ts +1 -235
- package/dist/esm/utxo.js +2 -382
- package/identity.d.ts +2 -0
- package/identity.js +3 -0
- package/idl.d.ts +2 -0
- package/idl.js +3 -0
- package/notes.d.ts +2 -0
- package/notes.js +3 -0
- package/package.json +131 -11
- package/perps.d.ts +2 -0
- package/perps.js +3 -0
- package/poseidon.d.ts +2 -2
- package/poseidon.js +2 -3
- package/positions.d.ts +2 -0
- package/positions.js +3 -0
- package/predictions.d.ts +2 -0
- package/predictions.js +3 -0
- package/proof.d.ts +2 -2
- package/proof.js +2 -3
- package/prover.d.ts +2 -2
- package/prover.js +2 -3
- package/relayer.d.ts +2 -0
- package/relayer.js +3 -0
- package/shield.d.ts +2 -2
- package/shield.js +2 -3
- package/transactions.d.ts +2 -0
- package/transactions.js +3 -0
- package/SHIELD_INTEGRATION.md +0 -143
- package/dist/src/client.d.ts +0 -407
- package/dist/src/client.js +0 -951
- package/dist/src/compactNote.d.ts +0 -107
- package/dist/src/compactNote.js +0 -167
- package/dist/src/config.d.ts +0 -82
- package/dist/src/config.js +0 -57
- package/dist/src/events.d.ts +0 -77
- package/dist/src/events.js +0 -167
- package/dist/src/idl/privacy_pool.js +0 -15218
- package/dist/src/index.d.ts +0 -16
- package/dist/src/index.js +0 -67
- package/dist/src/merkle.d.ts +0 -77
- package/dist/src/merkle.js +0 -156
- package/dist/src/poseidon.d.ts +0 -29
- package/dist/src/poseidon.js +0 -100
- package/dist/src/program.d.ts +0 -37
- package/dist/src/program.js +0 -61
- package/dist/src/proof.d.ts +0 -183
- package/dist/src/proof.js +0 -292
- package/dist/src/prover.d.ts +0 -54
- package/dist/src/prover.js +0 -112
- package/dist/src/random.d.ts +0 -16
- package/dist/src/random.js +0 -28
- package/dist/src/relayer.js +0 -257
- package/dist/src/retry.d.ts +0 -32
- package/dist/src/retry.js +0 -75
- package/dist/src/shield/alt.d.ts +0 -87
- package/dist/src/shield/alt.js +0 -194
- package/dist/src/shield/computeBudget.d.ts +0 -61
- package/dist/src/shield/computeBudget.js +0 -64
- package/dist/src/shield/errors.d.ts +0 -58
- package/dist/src/shield/errors.js +0 -121
- package/dist/src/shield/finalize.d.ts +0 -45
- package/dist/src/shield/finalize.js +0 -119
- package/dist/src/shield/index.d.ts +0 -35
- package/dist/src/shield/index.js +0 -68
- package/dist/src/shield/ix.d.ts +0 -54
- package/dist/src/shield/ix.js +0 -119
- package/dist/src/shield/owner.d.ts +0 -36
- package/dist/src/shield/owner.js +0 -126
- package/dist/src/shield/ports.d.ts +0 -43
- package/dist/src/shield/ports.js +0 -153
- package/dist/src/shield/preflight.d.ts +0 -30
- package/dist/src/shield/preflight.js +0 -154
- package/dist/src/shield/shield.d.ts +0 -68
- package/dist/src/shield/shield.js +0 -499
- package/dist/src/shield/types.d.ts +0 -202
- package/dist/src/utxo.d.ts +0 -235
- package/dist/src/utxo.js +0 -407
- package/dist/tests/compact-note.test.d.ts +0 -1
- package/dist/tests/compact-note.test.js +0 -173
- package/dist/tests/config.test.d.ts +0 -1
- package/dist/tests/config.test.js +0 -102
- package/dist/tests/edge-cases.test.d.ts +0 -1
- package/dist/tests/edge-cases.test.js +0 -220
- package/dist/tests/encryption.test.d.ts +0 -1
- package/dist/tests/encryption.test.js +0 -215
- package/dist/tests/events.test.d.ts +0 -1
- package/dist/tests/events.test.js +0 -78
- package/dist/tests/multi-tree.test.d.ts +0 -1
- package/dist/tests/multi-tree.test.js +0 -405
- package/dist/tests/pda.test.d.ts +0 -1
- package/dist/tests/pda.test.js +0 -229
- package/dist/tests/poseidon-builder-parity.test.d.ts +0 -1
- package/dist/tests/poseidon-builder-parity.test.js +0 -72
- package/dist/tests/poseidon.test.d.ts +0 -1
- package/dist/tests/poseidon.test.js +0 -142
- package/dist/tests/proof.test.d.ts +0 -1
- package/dist/tests/proof.test.js +0 -296
- package/dist/tests/relayer.test.d.ts +0 -1
- package/dist/tests/relayer.test.js +0 -271
- package/dist/tests/sdk.integration.test.d.ts +0 -1
- package/dist/tests/sdk.integration.test.js +0 -330
- package/dist/tests/shield-owner.test.d.ts +0 -1
- package/dist/tests/shield-owner.test.js +0 -89
- package/dist/tests/shield-preflight.test.d.ts +0 -1
- package/dist/tests/shield-preflight.test.js +0 -87
- package/dist/tests/shield-realproof.test.d.ts +0 -1
- package/dist/tests/shield-realproof.test.js +0 -272
- package/dist/tests/shield.test.d.ts +0 -1
- package/dist/tests/shield.test.js +0 -403
- package/dist/tests/utxo.test.d.ts +0 -1
- package/dist/tests/utxo.test.js +0 -140
- /package/dist/{src/shield → cjs/events}/types.js +0 -0
- /package/dist/{src/idl/privacy_pool.d.ts → cjs/idl/privacy_pool_legacy.d.ts} +0 -0
package/dist/cjs/relayer.d.ts
CHANGED
|
@@ -1,318 +1 @@
|
|
|
1
|
-
export
|
|
2
|
-
/** Base URL of the relayer. Defaults to Veilo's production service. */
|
|
3
|
-
relayerUrl?: string;
|
|
4
|
-
/** API key sent as x-api-key header */
|
|
5
|
-
apiKey: string;
|
|
6
|
-
/** Relayer's NaCl box public key (base64-encoded, 32 bytes) */
|
|
7
|
-
relayerPublicKey: string;
|
|
8
|
-
/** Optional JWT auth token for authenticated endpoints */
|
|
9
|
-
authToken?: string;
|
|
10
|
-
}
|
|
11
|
-
/** Structured error thrown by VeiloRelayerClient on API failures. */
|
|
12
|
-
export declare class VeiloApiError extends Error {
|
|
13
|
-
code: string;
|
|
14
|
-
status: number;
|
|
15
|
-
details?: unknown;
|
|
16
|
-
constructor(code: string, message: string, status: number, details?: unknown);
|
|
17
|
-
}
|
|
18
|
-
/** Retry configuration for the relayer HTTP client. */
|
|
19
|
-
export interface RetryPolicy {
|
|
20
|
-
/** Max number of retry attempts (default: 3) */
|
|
21
|
-
maxRetries: number;
|
|
22
|
-
/** Base delay in ms for exponential backoff (default: 1000) */
|
|
23
|
-
baseDelayMs: number;
|
|
24
|
-
/** HTTP status codes that trigger a retry (default: [429, 502, 503, 504]) */
|
|
25
|
-
retryableStatuses: number[];
|
|
26
|
-
}
|
|
27
|
-
export interface RelayerEncryptedNote {
|
|
28
|
-
noteId: string;
|
|
29
|
-
commitment: string;
|
|
30
|
-
ephemeralPublicKey: string;
|
|
31
|
-
encryptedBlob: string;
|
|
32
|
-
timestamp: number;
|
|
33
|
-
blockHeight?: number;
|
|
34
|
-
txSignature?: string;
|
|
35
|
-
spent?: boolean;
|
|
36
|
-
onchainId?: string;
|
|
37
|
-
spentTx?: string;
|
|
38
|
-
spentAt?: number;
|
|
39
|
-
compactEphemeralKey?: string | null;
|
|
40
|
-
compactBlob?: string | null;
|
|
41
|
-
viewTag?: number | null;
|
|
42
|
-
leafIndex?: number | null;
|
|
43
|
-
mintAddress?: string | null;
|
|
44
|
-
treeId?: number | null;
|
|
45
|
-
}
|
|
46
|
-
export interface QueryNotesRequest {
|
|
47
|
-
lastCheckedTimestamp?: number;
|
|
48
|
-
limit?: number;
|
|
49
|
-
offset?: number;
|
|
50
|
-
walletPublicKey?: string;
|
|
51
|
-
}
|
|
52
|
-
export interface QueryNotesResponse {
|
|
53
|
-
success: boolean;
|
|
54
|
-
notes: RelayerEncryptedNote[];
|
|
55
|
-
total: number;
|
|
56
|
-
limit: number;
|
|
57
|
-
offset: number;
|
|
58
|
-
}
|
|
59
|
-
export interface SaveEncryptedNoteRequest {
|
|
60
|
-
commitment: string;
|
|
61
|
-
ephemeralPublicKey: string;
|
|
62
|
-
encryptedBlob: string;
|
|
63
|
-
timestamp: number;
|
|
64
|
-
blockHeight?: number;
|
|
65
|
-
txSignature?: string;
|
|
66
|
-
recipientWalletPublicKey?: string;
|
|
67
|
-
compactEphemeralKey?: string | null;
|
|
68
|
-
compactBlob?: string | null;
|
|
69
|
-
viewTag?: number | null;
|
|
70
|
-
leafIndex?: number;
|
|
71
|
-
newRoot?: string;
|
|
72
|
-
mintAddress?: string;
|
|
73
|
-
treeId?: number;
|
|
74
|
-
amountRaw?: string;
|
|
75
|
-
}
|
|
76
|
-
export interface SaveEncryptedNoteResponse {
|
|
77
|
-
success: boolean;
|
|
78
|
-
noteId?: string;
|
|
79
|
-
message?: string;
|
|
80
|
-
error?: string;
|
|
81
|
-
}
|
|
82
|
-
export interface MerkleRootResponse {
|
|
83
|
-
success: boolean;
|
|
84
|
-
data: {
|
|
85
|
-
root: string;
|
|
86
|
-
nextIndex: number;
|
|
87
|
-
treeId: number;
|
|
88
|
-
onChainTreeId: number;
|
|
89
|
-
mintAddress: string;
|
|
90
|
-
};
|
|
91
|
-
}
|
|
92
|
-
export interface MerkleTreeResponse {
|
|
93
|
-
success: boolean;
|
|
94
|
-
data: {
|
|
95
|
-
treeId: number;
|
|
96
|
-
onChainTreeId: number;
|
|
97
|
-
mintAddress: string;
|
|
98
|
-
height: number;
|
|
99
|
-
nextIndex: number;
|
|
100
|
-
root: string;
|
|
101
|
-
totalCommitments: number;
|
|
102
|
-
leaves: Array<{
|
|
103
|
-
commitment: string;
|
|
104
|
-
index: number;
|
|
105
|
-
txSignature: string;
|
|
106
|
-
slot: number;
|
|
107
|
-
timestamp: string;
|
|
108
|
-
}>;
|
|
109
|
-
reconstructionInfo: {
|
|
110
|
-
instructions: string;
|
|
111
|
-
treeHeight: number;
|
|
112
|
-
hashFunction?: string;
|
|
113
|
-
};
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
export interface TransactNote {
|
|
117
|
-
commitment: string;
|
|
118
|
-
privateKey: string;
|
|
119
|
-
publicKey: string;
|
|
120
|
-
blinding: string;
|
|
121
|
-
amount: string;
|
|
122
|
-
nullifier: string;
|
|
123
|
-
leafIndex?: number;
|
|
124
|
-
noteId?: string;
|
|
125
|
-
}
|
|
126
|
-
export interface WithdrawRequest {
|
|
127
|
-
notes: TransactNote[];
|
|
128
|
-
recipient: string;
|
|
129
|
-
amount: string;
|
|
130
|
-
userPublicKey: string;
|
|
131
|
-
mintAddress: string;
|
|
132
|
-
}
|
|
133
|
-
export interface WithdrawResponse {
|
|
134
|
-
success: boolean;
|
|
135
|
-
message: string;
|
|
136
|
-
data?: {
|
|
137
|
-
withdrawRecipient: string;
|
|
138
|
-
withdrawAmount: number;
|
|
139
|
-
changeAmount: number;
|
|
140
|
-
changeNote: {
|
|
141
|
-
commitment: string;
|
|
142
|
-
privateKey: string;
|
|
143
|
-
publicKey: string;
|
|
144
|
-
blinding: string;
|
|
145
|
-
amount: string;
|
|
146
|
-
nullifier: string;
|
|
147
|
-
};
|
|
148
|
-
spentNoteIds?: string[];
|
|
149
|
-
txSignature?: string;
|
|
150
|
-
};
|
|
151
|
-
}
|
|
152
|
-
export interface PrivateTransferRequest {
|
|
153
|
-
notes: TransactNote[];
|
|
154
|
-
amount: string;
|
|
155
|
-
recipientUsername: string;
|
|
156
|
-
userPublicKey?: string;
|
|
157
|
-
mintAddress?: string;
|
|
158
|
-
}
|
|
159
|
-
export interface PrivateTransferResponse {
|
|
160
|
-
success: boolean;
|
|
161
|
-
message: string;
|
|
162
|
-
data?: {
|
|
163
|
-
recipient: string;
|
|
164
|
-
transferAmount: number;
|
|
165
|
-
senderChangeAmount: number;
|
|
166
|
-
txSignature: string;
|
|
167
|
-
recipientNote: {
|
|
168
|
-
commitment: string;
|
|
169
|
-
amount: string;
|
|
170
|
-
leafIndex: number;
|
|
171
|
-
savedNoteId: string;
|
|
172
|
-
};
|
|
173
|
-
senderChangeNote: {
|
|
174
|
-
commitment: string;
|
|
175
|
-
privateKey: string;
|
|
176
|
-
publicKey: string;
|
|
177
|
-
blinding: string;
|
|
178
|
-
amount: string;
|
|
179
|
-
leafIndex: number;
|
|
180
|
-
savedNoteId: string;
|
|
181
|
-
} | null;
|
|
182
|
-
};
|
|
183
|
-
}
|
|
184
|
-
export interface PrivateSwapRequest {
|
|
185
|
-
notes: TransactNote[];
|
|
186
|
-
sourceMintAddress: string;
|
|
187
|
-
destMintAddress: string;
|
|
188
|
-
sourceJupiterMint?: string;
|
|
189
|
-
destJupiterMint?: string;
|
|
190
|
-
swapAmountRaw: string;
|
|
191
|
-
minAmountOut: string;
|
|
192
|
-
slippageBps: number;
|
|
193
|
-
userPublicKey: string;
|
|
194
|
-
veiloPublicKey: string;
|
|
195
|
-
}
|
|
196
|
-
export interface PrivateSwapResponse {
|
|
197
|
-
success: boolean;
|
|
198
|
-
message: string;
|
|
199
|
-
data?: {
|
|
200
|
-
txSignature: string;
|
|
201
|
-
swapAmountRaw: string;
|
|
202
|
-
outputAmount: string;
|
|
203
|
-
minAmountOut: string;
|
|
204
|
-
changeAmount: string;
|
|
205
|
-
};
|
|
206
|
-
}
|
|
207
|
-
export interface ChallengeResponse {
|
|
208
|
-
success: boolean;
|
|
209
|
-
challenge: string;
|
|
210
|
-
expiresAt: number;
|
|
211
|
-
}
|
|
212
|
-
export interface RegisterRequest {
|
|
213
|
-
username: string;
|
|
214
|
-
walletPublicKey: string;
|
|
215
|
-
signature: string;
|
|
216
|
-
challenge: string;
|
|
217
|
-
veiloPublicKey: string;
|
|
218
|
-
}
|
|
219
|
-
export interface RegisterResponse {
|
|
220
|
-
success: boolean;
|
|
221
|
-
token: string;
|
|
222
|
-
message?: string;
|
|
223
|
-
}
|
|
224
|
-
export interface RestoreRequest {
|
|
225
|
-
walletPublicKey: string;
|
|
226
|
-
signature: string;
|
|
227
|
-
challenge: string;
|
|
228
|
-
}
|
|
229
|
-
export interface RestoreResponse {
|
|
230
|
-
success: boolean;
|
|
231
|
-
token: string;
|
|
232
|
-
username: string;
|
|
233
|
-
veiloPublicKey: string;
|
|
234
|
-
}
|
|
235
|
-
export interface CheckUsernameResponse {
|
|
236
|
-
success: boolean;
|
|
237
|
-
available: boolean;
|
|
238
|
-
}
|
|
239
|
-
export interface VeiloPublicKeyResponse {
|
|
240
|
-
success: boolean;
|
|
241
|
-
username: string;
|
|
242
|
-
pubK: string;
|
|
243
|
-
veiloPublicKey: string;
|
|
244
|
-
}
|
|
245
|
-
export interface PreRegisterKeyResponse {
|
|
246
|
-
success: boolean;
|
|
247
|
-
veiloPublicKey: string;
|
|
248
|
-
}
|
|
249
|
-
export interface DeleteUserDataResponse {
|
|
250
|
-
success: boolean;
|
|
251
|
-
message: string;
|
|
252
|
-
deletedCount?: number;
|
|
253
|
-
}
|
|
254
|
-
/**
|
|
255
|
-
* HTTP client for the Veilo relayer API.
|
|
256
|
-
*
|
|
257
|
-
* Handles auth, notes, merkle, and encrypted transact endpoints with
|
|
258
|
-
* automatic retry on transient failures and NaCl box payload encryption.
|
|
259
|
-
*
|
|
260
|
-
* @example
|
|
261
|
-
* ```ts
|
|
262
|
-
* const client = new VeiloRelayerClient({
|
|
263
|
-
* apiKey: "your-api-key",
|
|
264
|
-
* relayerPublicKey: "<base64 NaCl public key>",
|
|
265
|
-
* });
|
|
266
|
-
* const root = await client.getMerkleRoot("So111...");
|
|
267
|
-
* ```
|
|
268
|
-
*/
|
|
269
|
-
export declare class VeiloRelayerClient {
|
|
270
|
-
private readonly baseUrl;
|
|
271
|
-
private readonly apiKey;
|
|
272
|
-
private readonly relayerPubKey;
|
|
273
|
-
private authToken;
|
|
274
|
-
private readonly retry;
|
|
275
|
-
constructor(config: VeiloRelayerConfig, retry?: Partial<RetryPolicy>);
|
|
276
|
-
/** Update the auth token (e.g. after register/restore). */
|
|
277
|
-
setAuthToken(token: string): void;
|
|
278
|
-
private headers;
|
|
279
|
-
private request;
|
|
280
|
-
private encrypt;
|
|
281
|
-
/** Request a signature challenge for wallet authentication. */
|
|
282
|
-
getChallenge(walletPublicKey: string): Promise<ChallengeResponse>;
|
|
283
|
-
/** Register a new account with a signed challenge. Returns a JWT auth token. */
|
|
284
|
-
register(data: RegisterRequest): Promise<RegisterResponse>;
|
|
285
|
-
/** Restore an existing account using a signed challenge. Returns a JWT auth token. */
|
|
286
|
-
restore(data: RestoreRequest): Promise<RestoreResponse>;
|
|
287
|
-
/** Check whether a username is available for registration. */
|
|
288
|
-
checkUsername(username: string): Promise<CheckUsernameResponse>;
|
|
289
|
-
/** Look up a user's Veilo public key by username or wallet public key. */
|
|
290
|
-
getVeiloPublicKey(params: {
|
|
291
|
-
username: string;
|
|
292
|
-
publicKey?: never;
|
|
293
|
-
} | {
|
|
294
|
-
publicKey: string;
|
|
295
|
-
username?: never;
|
|
296
|
-
}): Promise<VeiloPublicKeyResponse>;
|
|
297
|
-
/**
|
|
298
|
-
* Provision (or retrieve) the Veilo spend key paired with a Solana address.
|
|
299
|
-
* Public and idempotent; the response contains public key material only.
|
|
300
|
-
*/
|
|
301
|
-
preRegisterKey(solanaAddress: string): Promise<PreRegisterKeyResponse>;
|
|
302
|
-
/** Save an encrypted note to the relayer's database. */
|
|
303
|
-
saveEncryptedNote(data: SaveEncryptedNoteRequest): Promise<SaveEncryptedNoteResponse>;
|
|
304
|
-
/** Query encrypted notes for the authenticated user. Requires auth token. */
|
|
305
|
-
queryEncryptedNotes(params?: QueryNotesRequest): Promise<QueryNotesResponse>;
|
|
306
|
-
/** Delete all stored data for the authenticated user. Requires auth token. */
|
|
307
|
-
deleteUserData(): Promise<DeleteUserDataResponse>;
|
|
308
|
-
/** Fetch the current Merkle root for a pool, optionally filtered by mint and tree ID. */
|
|
309
|
-
getMerkleRoot(mintAddress?: string, treeId?: number): Promise<MerkleRootResponse>;
|
|
310
|
-
/** Fetch the full Merkle tree (all leaves) for a pool. */
|
|
311
|
-
getMerkleTree(mintAddress?: string, treeId?: number): Promise<MerkleTreeResponse>;
|
|
312
|
-
/** Submit an encrypted withdrawal request to the relayer. Not retried on failure. */
|
|
313
|
-
submitWithdraw(data: WithdrawRequest): Promise<WithdrawResponse>;
|
|
314
|
-
/** Submit an encrypted private transfer request. Not retried on failure. */
|
|
315
|
-
submitPrivateTransfer(data: PrivateTransferRequest): Promise<PrivateTransferResponse>;
|
|
316
|
-
/** Submit an encrypted private swap request. Not retried on failure. */
|
|
317
|
-
submitPrivateSwap(data: PrivateSwapRequest): Promise<PrivateSwapResponse>;
|
|
318
|
-
}
|
|
1
|
+
export * from "./relayer/index.js";
|
package/dist/cjs/relayer.js
CHANGED
|
@@ -1,257 +1,18 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
4
15
|
};
|
|
5
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
const DEFAULT_RELAYER_URL = "https://relayer-server.onrender.com";
|
|
9
|
-
// =============================================================================
|
|
10
|
-
// Structured Error
|
|
11
|
-
// =============================================================================
|
|
12
|
-
/** Structured error thrown by VeiloRelayerClient on API failures. */
|
|
13
|
-
class VeiloApiError extends Error {
|
|
14
|
-
constructor(code, message, status, details) {
|
|
15
|
-
super(message);
|
|
16
|
-
this.name = "VeiloApiError";
|
|
17
|
-
this.code = code;
|
|
18
|
-
this.status = status;
|
|
19
|
-
this.details = details;
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
exports.VeiloApiError = VeiloApiError;
|
|
23
|
-
const DEFAULT_RETRY = {
|
|
24
|
-
maxRetries: 3,
|
|
25
|
-
baseDelayMs: 1000,
|
|
26
|
-
retryableStatuses: [429, 502, 503, 504],
|
|
27
|
-
};
|
|
28
|
-
// =============================================================================
|
|
29
|
-
// Base64 helpers (no dependency on tweetnacl-util)
|
|
30
|
-
// =============================================================================
|
|
31
|
-
function toBase64(bytes) {
|
|
32
|
-
if (typeof Buffer !== "undefined") {
|
|
33
|
-
return Buffer.from(bytes).toString("base64");
|
|
34
|
-
}
|
|
35
|
-
return btoa(String.fromCharCode(...bytes));
|
|
36
|
-
}
|
|
37
|
-
function fromBase64(str) {
|
|
38
|
-
if (typeof Buffer !== "undefined") {
|
|
39
|
-
return new Uint8Array(Buffer.from(str, "base64"));
|
|
40
|
-
}
|
|
41
|
-
const binary = atob(str);
|
|
42
|
-
const bytes = new Uint8Array(binary.length);
|
|
43
|
-
for (let i = 0; i < binary.length; i++)
|
|
44
|
-
bytes[i] = binary.charCodeAt(i);
|
|
45
|
-
return bytes;
|
|
46
|
-
}
|
|
47
|
-
// =============================================================================
|
|
48
|
-
// Encryption
|
|
49
|
-
// =============================================================================
|
|
50
|
-
/**
|
|
51
|
-
* Encrypt a JSON-serializable payload for the relayer using NaCl box.
|
|
52
|
-
* Layout: [ephemeralPubKey (32)] [nonce (24)] [ciphertext (...)]
|
|
53
|
-
*/
|
|
54
|
-
function encryptForRelayer(data, relayerPublicKey) {
|
|
55
|
-
const ephemeral = tweetnacl_1.default.box.keyPair();
|
|
56
|
-
const message = new TextEncoder().encode(JSON.stringify(data));
|
|
57
|
-
const nonce = tweetnacl_1.default.randomBytes(tweetnacl_1.default.box.nonceLength);
|
|
58
|
-
const ciphertext = tweetnacl_1.default.box(message, nonce, relayerPublicKey, ephemeral.secretKey);
|
|
59
|
-
const payload = new Uint8Array(ephemeral.publicKey.length + nonce.length + ciphertext.length);
|
|
60
|
-
payload.set(ephemeral.publicKey, 0);
|
|
61
|
-
payload.set(nonce, ephemeral.publicKey.length);
|
|
62
|
-
payload.set(ciphertext, ephemeral.publicKey.length + nonce.length);
|
|
63
|
-
return toBase64(payload);
|
|
64
|
-
}
|
|
65
|
-
// =============================================================================
|
|
66
|
-
// Relayer Client
|
|
67
|
-
// =============================================================================
|
|
68
|
-
/**
|
|
69
|
-
* HTTP client for the Veilo relayer API.
|
|
70
|
-
*
|
|
71
|
-
* Handles auth, notes, merkle, and encrypted transact endpoints with
|
|
72
|
-
* automatic retry on transient failures and NaCl box payload encryption.
|
|
73
|
-
*
|
|
74
|
-
* @example
|
|
75
|
-
* ```ts
|
|
76
|
-
* const client = new VeiloRelayerClient({
|
|
77
|
-
* apiKey: "your-api-key",
|
|
78
|
-
* relayerPublicKey: "<base64 NaCl public key>",
|
|
79
|
-
* });
|
|
80
|
-
* const root = await client.getMerkleRoot("So111...");
|
|
81
|
-
* ```
|
|
82
|
-
*/
|
|
83
|
-
class VeiloRelayerClient {
|
|
84
|
-
constructor(config, retry) {
|
|
85
|
-
this.baseUrl = (config.relayerUrl?.trim() || DEFAULT_RELAYER_URL).replace(/\/+$/, "");
|
|
86
|
-
this.apiKey = config.apiKey;
|
|
87
|
-
this.relayerPubKey = fromBase64(config.relayerPublicKey);
|
|
88
|
-
this.authToken = config.authToken;
|
|
89
|
-
this.retry = { ...DEFAULT_RETRY, ...retry };
|
|
90
|
-
}
|
|
91
|
-
/** Update the auth token (e.g. after register/restore). */
|
|
92
|
-
setAuthToken(token) {
|
|
93
|
-
this.authToken = token;
|
|
94
|
-
}
|
|
95
|
-
// ---------------------------------------------------------------------------
|
|
96
|
-
// Internal helpers
|
|
97
|
-
// ---------------------------------------------------------------------------
|
|
98
|
-
headers(authenticated) {
|
|
99
|
-
const h = {
|
|
100
|
-
"Content-Type": "application/json",
|
|
101
|
-
};
|
|
102
|
-
if (this.apiKey)
|
|
103
|
-
h["x-api-key"] = this.apiKey;
|
|
104
|
-
if (authenticated && this.authToken) {
|
|
105
|
-
h["Authorization"] = `Bearer ${this.authToken}`;
|
|
106
|
-
}
|
|
107
|
-
return h;
|
|
108
|
-
}
|
|
109
|
-
async request(method, path, opts = {}) {
|
|
110
|
-
const url = `${this.baseUrl}/api${path}`;
|
|
111
|
-
const { body, authenticated = false, retryable = true } = opts;
|
|
112
|
-
const maxAttempts = retryable ? this.retry.maxRetries + 1 : 1;
|
|
113
|
-
let lastError;
|
|
114
|
-
for (let attempt = 0; attempt < maxAttempts; attempt++) {
|
|
115
|
-
if (attempt > 0) {
|
|
116
|
-
const delay = this.retry.baseDelayMs * Math.pow(2, attempt - 1) +
|
|
117
|
-
Math.random() * 200;
|
|
118
|
-
await new Promise((r) => setTimeout(r, delay));
|
|
119
|
-
}
|
|
120
|
-
let res;
|
|
121
|
-
try {
|
|
122
|
-
res = await fetch(url, {
|
|
123
|
-
method,
|
|
124
|
-
headers: this.headers(authenticated),
|
|
125
|
-
body: body != null ? JSON.stringify(body) : undefined,
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
catch (err) {
|
|
129
|
-
lastError = new VeiloApiError("NETWORK_ERROR", err.message || "Network request failed", 0);
|
|
130
|
-
continue;
|
|
131
|
-
}
|
|
132
|
-
const data = await res.json().catch(() => ({}));
|
|
133
|
-
if (res.ok && data.success !== false) {
|
|
134
|
-
return data;
|
|
135
|
-
}
|
|
136
|
-
lastError = new VeiloApiError(data.error || "UNKNOWN", data.message || data.error || `Request failed: ${res.status}`, res.status, data);
|
|
137
|
-
// Only retry on transient statuses
|
|
138
|
-
if (!this.retry.retryableStatuses.includes(res.status)) {
|
|
139
|
-
throw lastError;
|
|
140
|
-
}
|
|
141
|
-
}
|
|
142
|
-
throw lastError;
|
|
143
|
-
}
|
|
144
|
-
encrypt(data) {
|
|
145
|
-
return encryptForRelayer({
|
|
146
|
-
...data,
|
|
147
|
-
timestamp: Date.now(),
|
|
148
|
-
nonce: toBase64(tweetnacl_1.default.randomBytes(32)),
|
|
149
|
-
}, this.relayerPubKey);
|
|
150
|
-
}
|
|
151
|
-
// ---------------------------------------------------------------------------
|
|
152
|
-
// Auth
|
|
153
|
-
// ---------------------------------------------------------------------------
|
|
154
|
-
/** Request a signature challenge for wallet authentication. */
|
|
155
|
-
async getChallenge(walletPublicKey) {
|
|
156
|
-
return this.request("POST", "/auth/challenge", {
|
|
157
|
-
body: { walletPublicKey },
|
|
158
|
-
});
|
|
159
|
-
}
|
|
160
|
-
/** Register a new account with a signed challenge. Returns a JWT auth token. */
|
|
161
|
-
async register(data) {
|
|
162
|
-
return this.request("POST", "/auth/register", { body: data });
|
|
163
|
-
}
|
|
164
|
-
/** Restore an existing account using a signed challenge. Returns a JWT auth token. */
|
|
165
|
-
async restore(data) {
|
|
166
|
-
return this.request("POST", "/auth/restore", { body: data });
|
|
167
|
-
}
|
|
168
|
-
/** Check whether a username is available for registration. */
|
|
169
|
-
async checkUsername(username) {
|
|
170
|
-
return this.request("GET", `/auth/checkUsername?username=${encodeURIComponent(username)}`);
|
|
171
|
-
}
|
|
172
|
-
/** Look up a user's Veilo public key by username or wallet public key. */
|
|
173
|
-
async getVeiloPublicKey(params) {
|
|
174
|
-
const query = "username" in params && params.username
|
|
175
|
-
? `username=${encodeURIComponent(params.username)}`
|
|
176
|
-
: `publicKey=${encodeURIComponent(params.publicKey)}`;
|
|
177
|
-
return this.request("GET", `/auth/veiloPublicKey?${query}`);
|
|
178
|
-
}
|
|
179
|
-
/**
|
|
180
|
-
* Provision (or retrieve) the Veilo spend key paired with a Solana address.
|
|
181
|
-
* Public and idempotent; the response contains public key material only.
|
|
182
|
-
*/
|
|
183
|
-
async preRegisterKey(solanaAddress) {
|
|
184
|
-
return this.request("POST", "/auth/pre-register-key", {
|
|
185
|
-
body: { solanaAddress },
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
// ---------------------------------------------------------------------------
|
|
189
|
-
// Notes
|
|
190
|
-
// ---------------------------------------------------------------------------
|
|
191
|
-
/** Save an encrypted note to the relayer's database. */
|
|
192
|
-
async saveEncryptedNote(data) {
|
|
193
|
-
return this.request("POST", "/notes/save", { body: data });
|
|
194
|
-
}
|
|
195
|
-
/** Query encrypted notes for the authenticated user. Requires auth token. */
|
|
196
|
-
async queryEncryptedNotes(params = {}) {
|
|
197
|
-
return this.request("POST", "/notes/query", {
|
|
198
|
-
body: params,
|
|
199
|
-
authenticated: true,
|
|
200
|
-
});
|
|
201
|
-
}
|
|
202
|
-
/** Delete all stored data for the authenticated user. Requires auth token. */
|
|
203
|
-
async deleteUserData() {
|
|
204
|
-
return this.request("POST", "/notes/delete", { authenticated: true });
|
|
205
|
-
}
|
|
206
|
-
// ---------------------------------------------------------------------------
|
|
207
|
-
// Merkle
|
|
208
|
-
// ---------------------------------------------------------------------------
|
|
209
|
-
/** Fetch the current Merkle root for a pool, optionally filtered by mint and tree ID. */
|
|
210
|
-
async getMerkleRoot(mintAddress, treeId) {
|
|
211
|
-
const params = new URLSearchParams();
|
|
212
|
-
if (mintAddress)
|
|
213
|
-
params.append("mintAddress", mintAddress);
|
|
214
|
-
if (treeId !== undefined)
|
|
215
|
-
params.append("treeId", treeId.toString());
|
|
216
|
-
const qs = params.toString();
|
|
217
|
-
return this.request("GET", `/merkle/root${qs ? `?${qs}` : ""}`);
|
|
218
|
-
}
|
|
219
|
-
/** Fetch the full Merkle tree (all leaves) for a pool. */
|
|
220
|
-
async getMerkleTree(mintAddress, treeId) {
|
|
221
|
-
const params = new URLSearchParams();
|
|
222
|
-
if (mintAddress)
|
|
223
|
-
params.append("mintAddress", mintAddress);
|
|
224
|
-
if (treeId !== undefined)
|
|
225
|
-
params.append("treeId", treeId.toString());
|
|
226
|
-
const qs = params.toString();
|
|
227
|
-
return this.request("GET", `/merkle/tree${qs ? `?${qs}` : ""}`);
|
|
228
|
-
}
|
|
229
|
-
// ---------------------------------------------------------------------------
|
|
230
|
-
// Transact (encrypted payloads)
|
|
231
|
-
// ---------------------------------------------------------------------------
|
|
232
|
-
/** Submit an encrypted withdrawal request to the relayer. Not retried on failure. */
|
|
233
|
-
async submitWithdraw(data) {
|
|
234
|
-
const encryptedPayload = this.encrypt(data);
|
|
235
|
-
return this.request("POST", "/transact/withdra", {
|
|
236
|
-
body: { encryptedPayload },
|
|
237
|
-
retryable: false,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
/** Submit an encrypted private transfer request. Not retried on failure. */
|
|
241
|
-
async submitPrivateTransfer(data) {
|
|
242
|
-
const encryptedPayload = this.encrypt(data);
|
|
243
|
-
return this.request("POST", "/transact/private-transfer", {
|
|
244
|
-
body: { encryptedPayload },
|
|
245
|
-
retryable: false,
|
|
246
|
-
});
|
|
247
|
-
}
|
|
248
|
-
/** Submit an encrypted private swap request. Not retried on failure. */
|
|
249
|
-
async submitPrivateSwap(data) {
|
|
250
|
-
const encryptedPayload = this.encrypt(data);
|
|
251
|
-
return this.request("POST", "/transact/private-swap", {
|
|
252
|
-
body: { encryptedPayload },
|
|
253
|
-
retryable: false,
|
|
254
|
-
});
|
|
255
|
-
}
|
|
256
|
-
}
|
|
257
|
-
exports.VeiloRelayerClient = VeiloRelayerClient;
|
|
17
|
+
// Backward-compatible entry point. Relayer responsibilities live in src/relayer.
|
|
18
|
+
__exportStar(require("./relayer/index.js"), exports);
|
package/dist/cjs/shield/alt.js
CHANGED
|
@@ -8,7 +8,7 @@ exports.expectedDepositAltKeys = expectedDepositAltKeys;
|
|
|
8
8
|
exports.auditDepositAlt = auditDepositAlt;
|
|
9
9
|
const web3_js_1 = require("@solana/web3.js");
|
|
10
10
|
const spl_token_1 = require("@solana/spl-token");
|
|
11
|
-
const
|
|
11
|
+
const pdas_js_1 = require("../accounts/pdas.js");
|
|
12
12
|
const program_js_1 = require("../program.js");
|
|
13
13
|
const config_js_1 = require("../config.js");
|
|
14
14
|
const errors_js_1 = require("./errors.js");
|
|
@@ -107,21 +107,21 @@ function explicitAlt(account) {
|
|
|
107
107
|
*/
|
|
108
108
|
function requiredAltKeys(params) {
|
|
109
109
|
const programId = params.programId ?? program_js_1.PRIVACY_POOL_PROGRAM_ID;
|
|
110
|
-
const { config, vault, nullifiers } = (0,
|
|
110
|
+
const { config, vault, nullifiers } = (0, pdas_js_1.getPoolPdas)(programId, params.mint);
|
|
111
111
|
const keys = [
|
|
112
112
|
{ label: "programId", address: programId },
|
|
113
113
|
{ label: "computeBudgetProgram", address: web3_js_1.ComputeBudgetProgram.programId },
|
|
114
114
|
{ label: "systemProgram", address: web3_js_1.SystemProgram.programId },
|
|
115
|
-
{ label: "globalConfig", address: (0,
|
|
115
|
+
{ label: "globalConfig", address: (0, pdas_js_1.getGlobalConfigPda)(programId) },
|
|
116
116
|
{ label: "config", address: config },
|
|
117
117
|
{ label: "vault", address: vault },
|
|
118
118
|
{ label: "nullifiers", address: nullifiers },
|
|
119
|
-
{ label: "inputTree(0)", address: (0,
|
|
119
|
+
{ label: "inputTree(0)", address: (0, pdas_js_1.getNoteTreePda)(programId, params.mint, 0) },
|
|
120
120
|
];
|
|
121
121
|
if (params.outputTreeId !== 0) {
|
|
122
122
|
keys.push({
|
|
123
123
|
label: `outputTree(${params.outputTreeId})`,
|
|
124
|
-
address: (0,
|
|
124
|
+
address: (0, pdas_js_1.getNoteTreePda)(programId, params.mint, params.outputTreeId),
|
|
125
125
|
});
|
|
126
126
|
}
|
|
127
127
|
if (!params.mint.equals(config_js_1.NATIVE_SOL_MINT)) {
|
|
@@ -155,16 +155,16 @@ async function expectedDepositAltKeys(params) {
|
|
|
155
155
|
{ label: "computeBudgetProgram", address: web3_js_1.ComputeBudgetProgram.programId },
|
|
156
156
|
{ label: "systemProgram", address: web3_js_1.SystemProgram.programId },
|
|
157
157
|
{ label: "tokenProgram", address: spl_token_1.TOKEN_PROGRAM_ID },
|
|
158
|
-
{ label: "globalConfig", address: (0,
|
|
158
|
+
{ label: "globalConfig", address: (0, pdas_js_1.getGlobalConfigPda)(programId) },
|
|
159
159
|
];
|
|
160
160
|
for (const mint of mints) {
|
|
161
161
|
const label = mint.equals(config_js_1.NATIVE_SOL_MINT) ? "SOL" : mint.toBase58().slice(0, 4);
|
|
162
|
-
const { config, vault, nullifiers } = (0,
|
|
162
|
+
const { config, vault, nullifiers } = (0, pdas_js_1.getPoolPdas)(programId, mint);
|
|
163
163
|
out.push({ label: `${label}.config`, address: config }, { label: `${label}.vault`, address: vault }, { label: `${label}.nullifiers`, address: nullifiers });
|
|
164
164
|
for (let t = 0; t <= maxTreeId; t++) {
|
|
165
165
|
out.push({
|
|
166
166
|
label: `${label}.tree(${t})`,
|
|
167
|
-
address: (0,
|
|
167
|
+
address: (0, pdas_js_1.getNoteTreePda)(programId, mint, t),
|
|
168
168
|
});
|
|
169
169
|
}
|
|
170
170
|
if (!mint.equals(config_js_1.NATIVE_SOL_MINT)) {
|
|
@@ -3,7 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.ShieldError = void 0;
|
|
4
4
|
exports.extractProgramCode = extractProgramCode;
|
|
5
5
|
exports.mapShieldError = mapShieldError;
|
|
6
|
-
const
|
|
6
|
+
const errors_js_1 = require("../accounts/errors.js");
|
|
7
7
|
class ShieldError extends Error {
|
|
8
8
|
constructor(code, message, opts = {}) {
|
|
9
9
|
super(message);
|
|
@@ -52,7 +52,7 @@ function mapShieldError(error) {
|
|
|
52
52
|
const err = error;
|
|
53
53
|
const raw = (err?.message ?? String(err ?? "")).toLowerCase();
|
|
54
54
|
const programCode = extractProgramCode(err);
|
|
55
|
-
const readable = (0,
|
|
55
|
+
const readable = (0, errors_js_1.parseOnChainError)(err);
|
|
56
56
|
if (programCode !== null) {
|
|
57
57
|
switch (programCode) {
|
|
58
58
|
case 6000:
|
|
@@ -36,7 +36,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
36
36
|
exports.finalizeShield = finalizeShield;
|
|
37
37
|
const anchor = __importStar(require("@coral-xyz/anchor"));
|
|
38
38
|
const program_js_1 = require("../program.js");
|
|
39
|
-
const
|
|
39
|
+
const mailbox_js_1 = require("../notes/mailbox.js");
|
|
40
40
|
const poseidon_js_1 = require("../poseidon.js");
|
|
41
41
|
const errors_js_1 = require("./errors.js");
|
|
42
42
|
/**
|
|
@@ -101,7 +101,7 @@ async function finalizeShield(params) {
|
|
|
101
101
|
// sender→recipient association into the relayer's database AND removing the
|
|
102
102
|
// note from the chain-recovery feed. For shield-to-someone-else, chain-only
|
|
103
103
|
// discovery is usually the better default — see the plan's Phase 3 note.
|
|
104
|
-
const blob = (0,
|
|
104
|
+
const blob = (0, mailbox_js_1.encryptBlindMailboxNote)(owner.noteViewingKey.toBytes(), {
|
|
105
105
|
blinding: (0, poseidon_js_1.bigIntToBytesBE)(note.blinding),
|
|
106
106
|
leafIndex,
|
|
107
107
|
commitment: note.commitment,
|
package/dist/cjs/shield/ix.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
|
|
2
|
-
import type { TransactionProofStruct } from "../
|
|
2
|
+
import type { TransactionProofStruct } from "../proofs/types.js";
|
|
3
3
|
/**
|
|
4
4
|
* `transact` instruction assembly, driven by the IDL rather than by a
|
|
5
5
|
* hand-written account list.
|