@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
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { VersionedTransaction } from "@solana/web3.js";
|
|
2
|
+
export const JUPITER_PREDICTION_API_URL = "https://api.jup.ag/prediction/v1";
|
|
3
|
+
export const POLYMARKET_CLOB_API_URL = "https://clob.polymarket.com";
|
|
4
|
+
export class JupiterPredictionApiError extends Error {
|
|
5
|
+
constructor(status, responseBody) {
|
|
6
|
+
const body = typeof responseBody === "object" && responseBody !== null
|
|
7
|
+
? responseBody
|
|
8
|
+
: undefined;
|
|
9
|
+
const message = typeof responseBody === "string" && responseBody
|
|
10
|
+
? responseBody
|
|
11
|
+
: typeof body?.message === "string"
|
|
12
|
+
? body.message
|
|
13
|
+
: typeof body?.error === "string"
|
|
14
|
+
? body.error
|
|
15
|
+
: `Jupiter Prediction API request failed: ${status}`;
|
|
16
|
+
super(message);
|
|
17
|
+
this.name = "JupiterPredictionApiError";
|
|
18
|
+
this.status = status;
|
|
19
|
+
this.code = typeof body?.error === "string" ? body.error : undefined;
|
|
20
|
+
this.responseBody = responseBody;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
/** Typed client for the unsigned Jupiter Prediction transaction API. */
|
|
24
|
+
export class JupiterPredictionClient {
|
|
25
|
+
constructor(config) {
|
|
26
|
+
this.apiKey = config.apiKey;
|
|
27
|
+
this.baseUrl = normalizeBaseUrl(config.baseUrl ?? JUPITER_PREDICTION_API_URL, "baseUrl");
|
|
28
|
+
this.polymarketBaseUrl = normalizeBaseUrl(config.polymarketBaseUrl ?? POLYMARKET_CLOB_API_URL, "polymarketBaseUrl");
|
|
29
|
+
this.fetcher = config.fetch ?? fetch;
|
|
30
|
+
}
|
|
31
|
+
async listEvents(params = {}) {
|
|
32
|
+
const query = new URLSearchParams({ status: params.status ?? "live" });
|
|
33
|
+
if (params.category)
|
|
34
|
+
query.set("category", params.category);
|
|
35
|
+
return (await this.request(`/events?${query}`)).data;
|
|
36
|
+
}
|
|
37
|
+
async getEvent(eventId) {
|
|
38
|
+
return this.request(`/events/${encodeURIComponent(eventId)}`);
|
|
39
|
+
}
|
|
40
|
+
async listPositions(ownerPubkey) {
|
|
41
|
+
return (await this.request(`/positions?ownerPubkey=${encodeURIComponent(ownerPubkey)}`)).data;
|
|
42
|
+
}
|
|
43
|
+
async listHistory(ownerPubkey) {
|
|
44
|
+
return (await this.request(`/history?ownerPubkey=${encodeURIComponent(ownerPubkey)}`)).data;
|
|
45
|
+
}
|
|
46
|
+
async getPosition(positionPubkey) {
|
|
47
|
+
return this.request(`/positions/${encodeURIComponent(positionPubkey)}`);
|
|
48
|
+
}
|
|
49
|
+
async placeOrder(request) {
|
|
50
|
+
return this.request("/orders", { method: "POST", body: request });
|
|
51
|
+
}
|
|
52
|
+
async getOrderStatus(orderPubkey) {
|
|
53
|
+
return this.request(`/orders/status/${encodeURIComponent(orderPubkey)}`);
|
|
54
|
+
}
|
|
55
|
+
async closePosition(positionPubkey, ownerPubkey) {
|
|
56
|
+
return this.request(`/positions/${encodeURIComponent(positionPubkey)}`, {
|
|
57
|
+
method: "DELETE",
|
|
58
|
+
body: { ownerPubkey },
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
async closeAllPositions(ownerPubkey, minSellPriceSlippageBps = 300) {
|
|
62
|
+
return this.request("/positions", {
|
|
63
|
+
method: "DELETE",
|
|
64
|
+
body: { ownerPubkey, minSellPriceSlippageBps },
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
async claimPosition(positionPubkey, ownerPubkey) {
|
|
68
|
+
return this.request(`/positions/${encodeURIComponent(positionPubkey)}/claim`, { method: "POST", body: { ownerPubkey } });
|
|
69
|
+
}
|
|
70
|
+
async getPriceHistory(clobTokenId, interval) {
|
|
71
|
+
const fidelity = {
|
|
72
|
+
"1d": 5,
|
|
73
|
+
"1w": 30,
|
|
74
|
+
"1m": 180,
|
|
75
|
+
max: 180,
|
|
76
|
+
};
|
|
77
|
+
const query = new URLSearchParams({
|
|
78
|
+
market: clobTokenId,
|
|
79
|
+
interval,
|
|
80
|
+
fidelity: String(fidelity[interval]),
|
|
81
|
+
});
|
|
82
|
+
const response = await this.fetcher(`${this.polymarketBaseUrl}/prices-history?${query}`);
|
|
83
|
+
const body = await readResponseBody(response);
|
|
84
|
+
if (!response.ok) {
|
|
85
|
+
throw new JupiterPredictionApiError(response.status, body);
|
|
86
|
+
}
|
|
87
|
+
return body.history ?? [];
|
|
88
|
+
}
|
|
89
|
+
async request(path, options = {}) {
|
|
90
|
+
const response = await this.fetcher(`${this.baseUrl}${path}`, {
|
|
91
|
+
method: options.method ?? "GET",
|
|
92
|
+
headers: {
|
|
93
|
+
"x-api-key": this.apiKey,
|
|
94
|
+
...(options.body === undefined
|
|
95
|
+
? {}
|
|
96
|
+
: { "Content-Type": "application/json" }),
|
|
97
|
+
},
|
|
98
|
+
body: options.body === undefined ? undefined : JSON.stringify(options.body),
|
|
99
|
+
});
|
|
100
|
+
const body = await readResponseBody(response);
|
|
101
|
+
if (!response.ok) {
|
|
102
|
+
throw new JupiterPredictionApiError(response.status, body);
|
|
103
|
+
}
|
|
104
|
+
return body;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
/** Decode an unsigned transaction returned by Jupiter for wallet signing. */
|
|
108
|
+
export function deserializePredictionTransaction(response) {
|
|
109
|
+
if (!response.transaction) {
|
|
110
|
+
throw new TypeError("Prediction transaction must not be empty");
|
|
111
|
+
}
|
|
112
|
+
return VersionedTransaction.deserialize(decodeBase64(response.transaction));
|
|
113
|
+
}
|
|
114
|
+
function normalizeBaseUrl(value, label) {
|
|
115
|
+
const normalized = value.trim().replace(/\/+$/, "");
|
|
116
|
+
if (!normalized)
|
|
117
|
+
throw new TypeError(`${label} must not be empty`);
|
|
118
|
+
return normalized;
|
|
119
|
+
}
|
|
120
|
+
async function readResponseBody(response) {
|
|
121
|
+
const body = await response.text();
|
|
122
|
+
if (!body)
|
|
123
|
+
return {};
|
|
124
|
+
try {
|
|
125
|
+
return JSON.parse(body);
|
|
126
|
+
}
|
|
127
|
+
catch {
|
|
128
|
+
return body;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
function decodeBase64(encoded) {
|
|
132
|
+
if (typeof Buffer !== "undefined") {
|
|
133
|
+
return new Uint8Array(Buffer.from(encoded, "base64"));
|
|
134
|
+
}
|
|
135
|
+
const binary = atob(encoded);
|
|
136
|
+
const bytes = new Uint8Array(binary.length);
|
|
137
|
+
for (let index = 0; index < binary.length; index++) {
|
|
138
|
+
bytes[index] = binary.charCodeAt(index);
|
|
139
|
+
}
|
|
140
|
+
return bytes;
|
|
141
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { Keypair } from "@solana/web3.js";
|
|
2
|
+
export interface PredictionKeyBundle {
|
|
3
|
+
withdrawalId: Uint8Array;
|
|
4
|
+
withdrawalIdHex: string;
|
|
5
|
+
ephemeral: Keypair;
|
|
6
|
+
claimantPublicKey: string;
|
|
7
|
+
claimantSecretKey: string;
|
|
8
|
+
}
|
|
9
|
+
export declare function derivePredictionEphemeralKeypair(spendingKey: Uint8Array, nonce: number): Keypair;
|
|
10
|
+
export declare function derivePredictionWithdrawalId(spendingKey: Uint8Array, nonce: number): Uint8Array;
|
|
11
|
+
export declare function predictionWithdrawalIdToHex(withdrawalId: Uint8Array): string;
|
|
12
|
+
export declare function predictionWithdrawalIdFromHex(value: string): Uint8Array;
|
|
13
|
+
/** Derive every client-held key field needed across a prediction lifecycle. */
|
|
14
|
+
export declare function derivePredictionKeyBundle(spendingKey: Uint8Array, nonce: number): PredictionKeyBundle;
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { sha256 } from "@noble/hashes/sha256";
|
|
2
|
+
import { Keypair } from "@solana/web3.js";
|
|
3
|
+
import { assertBytes, bytesToHex, concatBytes, encodeBase58, hexToBytes, uint32Le, uint64Le, utf8, } from "../identity/encoding.js";
|
|
4
|
+
export function derivePredictionEphemeralKeypair(spendingKey, nonce) {
|
|
5
|
+
assertBytes(spendingKey, 32, "spending key");
|
|
6
|
+
if (!Number.isSafeInteger(nonce) || nonce < 0) {
|
|
7
|
+
throw new RangeError("prediction nonce must be a non-negative safe integer");
|
|
8
|
+
}
|
|
9
|
+
return Keypair.fromSeed(sha256(concatBytes(utf8("prediction_ephemeral"), spendingKey, uint64Le(BigInt(nonce), "prediction nonce"))));
|
|
10
|
+
}
|
|
11
|
+
export function derivePredictionWithdrawalId(spendingKey, nonce) {
|
|
12
|
+
assertBytes(spendingKey, 32, "spending key");
|
|
13
|
+
return sha256(concatBytes(utf8("prediction_withdrawal_v1"), spendingKey, uint32Le(nonce, "prediction nonce")));
|
|
14
|
+
}
|
|
15
|
+
export function predictionWithdrawalIdToHex(withdrawalId) {
|
|
16
|
+
assertBytes(withdrawalId, 32, "prediction withdrawal ID");
|
|
17
|
+
return bytesToHex(withdrawalId);
|
|
18
|
+
}
|
|
19
|
+
export function predictionWithdrawalIdFromHex(value) {
|
|
20
|
+
return hexToBytes(value, 32, "prediction withdrawal ID");
|
|
21
|
+
}
|
|
22
|
+
/** Derive every client-held key field needed across a prediction lifecycle. */
|
|
23
|
+
export function derivePredictionKeyBundle(spendingKey, nonce) {
|
|
24
|
+
const withdrawalId = derivePredictionWithdrawalId(spendingKey, nonce);
|
|
25
|
+
const ephemeral = derivePredictionEphemeralKeypair(spendingKey, nonce);
|
|
26
|
+
return {
|
|
27
|
+
withdrawalId,
|
|
28
|
+
withdrawalIdHex: predictionWithdrawalIdToHex(withdrawalId),
|
|
29
|
+
ephemeral,
|
|
30
|
+
claimantPublicKey: ephemeral.publicKey.toBase58(),
|
|
31
|
+
claimantSecretKey: encodeBase58(ephemeral.secretKey),
|
|
32
|
+
};
|
|
33
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js";
|
|
2
|
+
import { assertBytes, utf8 } from "../identity/encoding.js";
|
|
3
|
+
export function derivePredictionSlotPda(params) {
|
|
4
|
+
assertBytes(params.withdrawalId, 32, "prediction withdrawal ID");
|
|
5
|
+
return PublicKey.findProgramAddressSync([
|
|
6
|
+
utf8("prediction_slot_v1"),
|
|
7
|
+
params.mint.toBytes(),
|
|
8
|
+
params.withdrawalId,
|
|
9
|
+
], params.programId)[0];
|
|
10
|
+
}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import type { PredictionOpenRequest, PredictionOpenResponse, PredictionReissueRequest, PredictionReissueResponse } from "./types.js";
|
|
2
|
+
export declare function submitPredictionOpen(data: PredictionOpenRequest): Promise<PredictionOpenResponse>;
|
|
3
|
+
export declare function submitPredictionReissue(data: PredictionReissueRequest): Promise<PredictionReissueResponse>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { getInternalRelayerClient } from "../relayer/internal.js";
|
|
2
|
+
export function submitPredictionOpen(data) {
|
|
3
|
+
return getInternalRelayerClient().submitPredictionOpen(data);
|
|
4
|
+
}
|
|
5
|
+
export function submitPredictionReissue(data) {
|
|
6
|
+
return getInternalRelayerClient().submitPredictionReissue(data);
|
|
7
|
+
}
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import type { TransactNote } from "../relayer/types.js";
|
|
2
|
+
export interface PredictionOpenRequest {
|
|
3
|
+
notes: TransactNote[];
|
|
4
|
+
/** USDC stake, raw 6-decimal units. */
|
|
5
|
+
depositAmount: string;
|
|
6
|
+
/** 32-byte prediction-slot withdrawal ID, hex. */
|
|
7
|
+
withdrawalId: string;
|
|
8
|
+
/** Deterministic ephemeral wallet and open-proof claimant, base58. */
|
|
9
|
+
claimantPublicKey: string;
|
|
10
|
+
userPublicKey: string;
|
|
11
|
+
}
|
|
12
|
+
export interface PredictionOpenResponse {
|
|
13
|
+
success: boolean;
|
|
14
|
+
message: string;
|
|
15
|
+
data?: {
|
|
16
|
+
txSignature: string;
|
|
17
|
+
ephemeralWallet: string;
|
|
18
|
+
ephemeralTokenAccount: string;
|
|
19
|
+
changeAmount: string;
|
|
20
|
+
fee: string;
|
|
21
|
+
feeBps: number;
|
|
22
|
+
totalDebited: string;
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
export interface PredictionReissueRequest {
|
|
26
|
+
withdrawalId: string;
|
|
27
|
+
claimantSecretKey: string;
|
|
28
|
+
/** Kept for API compatibility; the relayer reads the real chain balance. */
|
|
29
|
+
reissueAmount: string;
|
|
30
|
+
veiloPublicKey: string;
|
|
31
|
+
userPublicKey: string;
|
|
32
|
+
}
|
|
33
|
+
export interface PredictionReissueResponse {
|
|
34
|
+
success: boolean;
|
|
35
|
+
message: string;
|
|
36
|
+
data?: {
|
|
37
|
+
txSignature: string | null;
|
|
38
|
+
reissueAmount: string;
|
|
39
|
+
fee?: string;
|
|
40
|
+
tradeHappened?: boolean;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
export interface PredictionMarketPricing {
|
|
44
|
+
buyYesPriceUsd: number;
|
|
45
|
+
sellYesPriceUsd: number;
|
|
46
|
+
buyNoPriceUsd: number;
|
|
47
|
+
sellNoPriceUsd: number;
|
|
48
|
+
volume: number;
|
|
49
|
+
}
|
|
50
|
+
export interface PredictionMarket {
|
|
51
|
+
provider: string;
|
|
52
|
+
marketId: string;
|
|
53
|
+
status: "open" | "closed" | "cancelled";
|
|
54
|
+
result: string | null;
|
|
55
|
+
title: string;
|
|
56
|
+
openTime: number;
|
|
57
|
+
closeTime: number;
|
|
58
|
+
rulesPrimary?: string;
|
|
59
|
+
imageUrl?: string;
|
|
60
|
+
clobTokenIds?: string[];
|
|
61
|
+
pricing: PredictionMarketPricing;
|
|
62
|
+
}
|
|
63
|
+
export interface PredictionEvent {
|
|
64
|
+
eventId: string;
|
|
65
|
+
isActive: boolean;
|
|
66
|
+
isLive: boolean;
|
|
67
|
+
category: string;
|
|
68
|
+
subcategory: string;
|
|
69
|
+
tags: string[];
|
|
70
|
+
metadata: {
|
|
71
|
+
title: string;
|
|
72
|
+
closeTime: string;
|
|
73
|
+
imageUrl?: string;
|
|
74
|
+
series?: string;
|
|
75
|
+
slug?: string;
|
|
76
|
+
};
|
|
77
|
+
volumeUsd: string;
|
|
78
|
+
volume24hr: string;
|
|
79
|
+
closeCondition?: string;
|
|
80
|
+
markets: PredictionMarket[];
|
|
81
|
+
}
|
|
82
|
+
export interface PredictionPosition {
|
|
83
|
+
pubkey: string;
|
|
84
|
+
owner: string;
|
|
85
|
+
marketId: string;
|
|
86
|
+
isYes: boolean;
|
|
87
|
+
contracts: string;
|
|
88
|
+
contractsDecimal: string;
|
|
89
|
+
totalCostUsd: string;
|
|
90
|
+
sizeUsd: string;
|
|
91
|
+
valueUsd: string;
|
|
92
|
+
avgPriceUsd: string;
|
|
93
|
+
markPriceUsd: string;
|
|
94
|
+
pnlUsd: string;
|
|
95
|
+
pnlUsdPercent: number;
|
|
96
|
+
feesPaidUsd: string;
|
|
97
|
+
claimed: boolean;
|
|
98
|
+
claimable: boolean;
|
|
99
|
+
payoutUsd: string;
|
|
100
|
+
sellPriceUsd: string;
|
|
101
|
+
settlementDate: number;
|
|
102
|
+
eventMetadata: {
|
|
103
|
+
title: string;
|
|
104
|
+
category: string;
|
|
105
|
+
imageUrl?: string;
|
|
106
|
+
};
|
|
107
|
+
marketMetadata: {
|
|
108
|
+
title: string;
|
|
109
|
+
result: string | null;
|
|
110
|
+
status: string;
|
|
111
|
+
};
|
|
112
|
+
}
|
|
113
|
+
export interface PlacePredictionOrderRequest {
|
|
114
|
+
ownerPubkey: string;
|
|
115
|
+
marketId: string;
|
|
116
|
+
isYes: boolean;
|
|
117
|
+
isBuy: true;
|
|
118
|
+
depositAmount: string;
|
|
119
|
+
depositMint: string;
|
|
120
|
+
}
|
|
121
|
+
export interface PredictionTransactionResponse {
|
|
122
|
+
transaction: string;
|
|
123
|
+
txMeta: {
|
|
124
|
+
blockhash: string;
|
|
125
|
+
lastValidBlockHeight: number;
|
|
126
|
+
};
|
|
127
|
+
}
|
|
128
|
+
export interface PlacePredictionOrderResponse extends PredictionTransactionResponse {
|
|
129
|
+
order: {
|
|
130
|
+
orderPubkey: string;
|
|
131
|
+
positionPubkey: string;
|
|
132
|
+
contracts: number;
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
export type PredictionOrderStatus = "pending" | "filled" | "partiallyfilled" | "failed";
|
|
136
|
+
export interface PredictionOrderStatusResponse {
|
|
137
|
+
orderPubkey: string;
|
|
138
|
+
status: PredictionOrderStatus;
|
|
139
|
+
latestEventType: string;
|
|
140
|
+
latestSignature: string;
|
|
141
|
+
history: Array<{
|
|
142
|
+
eventType: string;
|
|
143
|
+
status: string;
|
|
144
|
+
rawStatus: string;
|
|
145
|
+
timestamp: number;
|
|
146
|
+
signature: string;
|
|
147
|
+
}>;
|
|
148
|
+
}
|
|
149
|
+
export interface PredictionHistoryEvent {
|
|
150
|
+
id: number;
|
|
151
|
+
eventType: string;
|
|
152
|
+
signature: string;
|
|
153
|
+
timestamp: number;
|
|
154
|
+
marketId: string;
|
|
155
|
+
isYes: boolean;
|
|
156
|
+
isBuy: boolean;
|
|
157
|
+
contractsDecimal: string;
|
|
158
|
+
avgFillPriceUsd?: string;
|
|
159
|
+
totalCostUsd?: string;
|
|
160
|
+
netProceedsUsd?: string;
|
|
161
|
+
realizedPnl?: string;
|
|
162
|
+
payoutAmountUsd?: string;
|
|
163
|
+
eventMetadata: {
|
|
164
|
+
title: string;
|
|
165
|
+
category?: string;
|
|
166
|
+
imageUrl?: string;
|
|
167
|
+
};
|
|
168
|
+
marketMetadata: {
|
|
169
|
+
title: string;
|
|
170
|
+
result: string | null;
|
|
171
|
+
status: string;
|
|
172
|
+
};
|
|
173
|
+
}
|
|
174
|
+
export type PredictionPriceInterval = "1d" | "1w" | "1m" | "max";
|
|
175
|
+
export interface PredictionPricePoint {
|
|
176
|
+
t: number;
|
|
177
|
+
p: number;
|
|
178
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
package/dist/esm/program.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { Program, Idl, Wallet } from "@coral-xyz/anchor";
|
|
2
2
|
import { Connection, PublicKey } from "@solana/web3.js";
|
|
3
|
+
import { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY2_IDL, PRIVACY_POOL_LEGACY_IDL } from "./idl/index.js";
|
|
3
4
|
export declare const PRIVACY_POOL_IDL: Idl;
|
|
5
|
+
export { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY_IDL, PRIVACY_POOL_LEGACY2_IDL, };
|
|
4
6
|
/** Deployed program ID extracted from the bundled IDL. */
|
|
5
7
|
export declare const PRIVACY_POOL_PROGRAM_ID: PublicKey;
|
|
6
8
|
/**
|
package/dist/esm/program.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Program, AnchorProvider } from "@coral-xyz/anchor";
|
|
2
2
|
import { PublicKey } from "@solana/web3.js";
|
|
3
|
-
import
|
|
3
|
+
import { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY2_IDL, PRIVACY_POOL_LEGACY_IDL, } from "./idl/index.js";
|
|
4
4
|
// Re-export so consumers can access the raw IDL if needed
|
|
5
|
-
export const PRIVACY_POOL_IDL =
|
|
5
|
+
export const PRIVACY_POOL_IDL = PRIVACY_POOL_CURRENT_IDL;
|
|
6
|
+
export { PRIVACY_POOL_CURRENT_IDL, PRIVACY_POOL_IDLS, PRIVACY_POOL_LEGACY_IDL, PRIVACY_POOL_LEGACY2_IDL, };
|
|
6
7
|
/** Deployed program ID extracted from the bundled IDL. */
|
|
7
|
-
export const PRIVACY_POOL_PROGRAM_ID = new PublicKey(
|
|
8
|
+
export const PRIVACY_POOL_PROGRAM_ID = new PublicKey(PRIVACY_POOL_CURRENT_IDL.address);
|
|
8
9
|
/**
|
|
9
10
|
* Create an Anchor `Program` instance for the Veilo Privacy Pool.
|
|
10
11
|
*
|
package/dist/esm/proof.d.ts
CHANGED
|
@@ -1,183 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { SerializedUTXO, InputUTXO } from "./utxo.js";
|
|
3
|
-
/**
|
|
4
|
-
* External data that gets hashed into ext_data_hash.
|
|
5
|
-
* These are public parameters that affect financial flows.
|
|
6
|
-
*/
|
|
7
|
-
export type ExtData = {
|
|
8
|
-
/** Who receives withdrawal (for withdrawals) */
|
|
9
|
-
recipient: PublicKey;
|
|
10
|
-
/** Who submits tx and gets fee */
|
|
11
|
-
relayer: PublicKey;
|
|
12
|
-
/** Fee to relayer in lamports/token units */
|
|
13
|
-
fee: bigint;
|
|
14
|
-
/** Refund to user in lamports/token units (for gas compensation) */
|
|
15
|
-
refund: bigint;
|
|
16
|
-
/** Claimant key committed into the proof */
|
|
17
|
-
claimant: PublicKey;
|
|
18
|
-
};
|
|
19
|
-
/**
|
|
20
|
-
* Transaction circuit inputs (8 public inputs, many private inputs).
|
|
21
|
-
* This structure is used to prepare inputs for the snarkjs prover.
|
|
22
|
-
*/
|
|
23
|
-
export type TransactionCircuitInputs = {
|
|
24
|
-
/** Merkle root of UTXO tree */
|
|
25
|
-
root: Uint8Array;
|
|
26
|
-
/** Net deposit/withdrawal amount (positive = deposit, negative = withdrawal) */
|
|
27
|
-
publicAmount: bigint;
|
|
28
|
-
/** Hash of external data (recipient, relayer, fee, refund) */
|
|
29
|
-
extDataHash: Uint8Array;
|
|
30
|
-
/** Token mint address */
|
|
31
|
-
mintAddress: PublicKey;
|
|
32
|
-
/** Nullifiers for the two input UTXOs */
|
|
33
|
-
inputNullifiers: [Uint8Array, Uint8Array];
|
|
34
|
-
/** Commitments for the two output UTXOs */
|
|
35
|
-
outputCommitments: [Uint8Array, Uint8Array];
|
|
36
|
-
inAmount: [bigint, bigint];
|
|
37
|
-
inPubkey: [bigint, bigint];
|
|
38
|
-
inBlinding: [bigint, bigint];
|
|
39
|
-
inPathIndex: [number, number];
|
|
40
|
-
inPathElements: [bigint[], bigint[]];
|
|
41
|
-
inPrivateKey: [bigint, bigint];
|
|
42
|
-
outAmount: [bigint, bigint];
|
|
43
|
-
outPubkey: [bigint, bigint];
|
|
44
|
-
outBlinding: [bigint, bigint];
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Proof structure matching the on-chain TransactionProof struct.
|
|
48
|
-
* Total size: 256 bytes (64 + 128 + 64)
|
|
49
|
-
*/
|
|
50
|
-
export type TransactionProofStruct = {
|
|
51
|
-
/** G1 point A (64 bytes) */
|
|
52
|
-
proofA: number[];
|
|
53
|
-
/** G2 point B (128 bytes) */
|
|
54
|
-
proofB: number[];
|
|
55
|
-
/** G1 point C (64 bytes) */
|
|
56
|
-
proofC: number[];
|
|
57
|
-
};
|
|
58
|
-
/**
|
|
59
|
-
* Shape of a Groth16 proof produced by snarkjs.
|
|
60
|
-
*/
|
|
61
|
-
export type RawProof = {
|
|
62
|
-
pi_a: [string, string, string];
|
|
63
|
-
pi_b: [[string, string], [string, string], [string, string]];
|
|
64
|
-
pi_c: [string, string, string];
|
|
65
|
-
protocol: string;
|
|
66
|
-
curve: string;
|
|
67
|
-
};
|
|
68
|
-
/**
|
|
69
|
-
* Proof builder function type - takes circuit inputs and returns a raw snarkjs proof.
|
|
70
|
-
*/
|
|
71
|
-
export type TransactionProofBuilder = (inputs: TransactionCircuitInputs) => Promise<RawProof>;
|
|
72
|
-
/**
|
|
73
|
-
* Compute the external data hash.
|
|
74
|
-
* Matches on-chain computation:
|
|
75
|
-
* hash1 = Poseidon(recipient, relayer)
|
|
76
|
-
* hash2 = Poseidon(fee, refund)
|
|
77
|
-
* extDataHash = Poseidon(hash1, hash2, claimant)
|
|
78
|
-
*/
|
|
79
|
-
export declare function computeExtDataHash(extData: ExtData): Uint8Array;
|
|
80
|
-
/**
|
|
81
|
-
* Convert i64 to field element (handles negative via modular arithmetic).
|
|
82
|
-
* For negative values, we add the field modulus to get the equivalent positive representation.
|
|
83
|
-
*/
|
|
84
|
-
export declare function i64ToField(value: bigint): bigint;
|
|
85
|
-
/**
|
|
86
|
-
* Prepare transaction circuit inputs from high-level parameters.
|
|
87
|
-
* This converts the SDK types into the format expected by the circuit.
|
|
88
|
-
*/
|
|
89
|
-
export declare function prepareTransactionInputs(params: {
|
|
90
|
-
inputUTXOs: [InputUTXO, InputUTXO];
|
|
91
|
-
outputUTXOs: [SerializedUTXO, SerializedUTXO];
|
|
92
|
-
root: Uint8Array;
|
|
93
|
-
publicAmount: bigint;
|
|
94
|
-
extData: ExtData;
|
|
95
|
-
mintAddress: PublicKey;
|
|
96
|
-
}): TransactionCircuitInputs;
|
|
97
|
-
/**
|
|
98
|
-
* Turn a snarkjs Groth16 proof into 256 bytes:
|
|
99
|
-
* A(G1) | B(G2) | C(G1)
|
|
100
|
-
* where:
|
|
101
|
-
* A = (ax, ay) -> 64 bytes
|
|
102
|
-
* B = (bx1, bx0, by1, by0) -> 128 bytes (swapped pairs for alt_bn128)
|
|
103
|
-
* C = (cx, cy) -> 64 bytes
|
|
104
|
-
*
|
|
105
|
-
* Each field element is encoded as 32-byte BE to match the on-chain verifier.
|
|
106
|
-
* We ignore the extra projective/z components snarkjs keeps.
|
|
107
|
-
*/
|
|
108
|
-
export declare function packProofToBytes(proof: RawProof): Uint8Array;
|
|
109
|
-
/**
|
|
110
|
-
* Encode a snarkjs proof into the TransactionProofStruct format expected by the on-chain program.
|
|
111
|
-
*/
|
|
112
|
-
export declare function encodeSnarkjsProofToTransactionProof(proof: RawProof): TransactionProofStruct;
|
|
113
|
-
/**
|
|
114
|
-
* Convert TransactionCircuitInputs to the format expected by snarkjs.groth16.fullProve().
|
|
115
|
-
* All values are converted to strings (snarkjs expects string inputs for field elements).
|
|
116
|
-
*/
|
|
117
|
-
export declare function formatInputsForSnarkjs(inputs: TransactionCircuitInputs): Record<string, any>;
|
|
118
|
-
/**
|
|
119
|
-
* Swap circuit inputs. Matches the signal shape declared by swap.circom's
|
|
120
|
-
* main component (see zk-circuits/swap.circom lines 208-238). Unlike the
|
|
121
|
-
* transaction circuit, the swap circuit distinguishes a "change" output
|
|
122
|
-
* (same mint as source) from a "dest" output (dest mint) and takes a
|
|
123
|
-
* swap-specific params hash and swapAmount alongside the usual inputs.
|
|
124
|
-
*/
|
|
125
|
-
export type SwapCircuitInputs = {
|
|
126
|
-
sourceRoot: Uint8Array;
|
|
127
|
-
swapParamsHash: Uint8Array;
|
|
128
|
-
extDataHash: Uint8Array;
|
|
129
|
-
sourceMint: PublicKey;
|
|
130
|
-
destMint: PublicKey;
|
|
131
|
-
inputNullifiers: [Uint8Array, Uint8Array];
|
|
132
|
-
changeCommitment: Uint8Array;
|
|
133
|
-
destCommitment: Uint8Array;
|
|
134
|
-
swapAmount: bigint;
|
|
135
|
-
inAmount: [bigint, bigint];
|
|
136
|
-
inPubkey: [bigint, bigint];
|
|
137
|
-
inBlinding: [bigint, bigint];
|
|
138
|
-
inPathIndex: [number, number];
|
|
139
|
-
inPathElements: [bigint[], bigint[]];
|
|
140
|
-
inPrivateKey: [bigint, bigint];
|
|
141
|
-
changeAmount: bigint;
|
|
142
|
-
changePubkey: bigint;
|
|
143
|
-
changeBlinding: bigint;
|
|
144
|
-
destAmount: bigint;
|
|
145
|
-
destPubkey: bigint;
|
|
146
|
-
destBlinding: bigint;
|
|
147
|
-
minAmountOut: bigint;
|
|
148
|
-
deadline: bigint;
|
|
149
|
-
};
|
|
150
|
-
/**
|
|
151
|
-
* Convert SwapCircuitInputs into the shape expected by
|
|
152
|
-
* snarkjs.groth16.fullProve() for swap.circom. Every value is emitted as a
|
|
153
|
-
* decimal string (or string array) because snarkjs only accepts field
|
|
154
|
-
* elements as strings.
|
|
155
|
-
*
|
|
156
|
-
* Mirrors `generateSwapProof` in
|
|
157
|
-
* relayer-server/src/controllers/swap.helpers.ts so SDK-side swap proofs
|
|
158
|
-
* verify against the same circuit the relayer uses.
|
|
159
|
-
*/
|
|
160
|
-
export declare function formatSwapInputsForSnarkjs(inputs: SwapCircuitInputs): Record<string, any>;
|
|
161
|
-
/**
|
|
162
|
-
* Compute the swap params hash that the swap circuit and on-chain program verify.
|
|
163
|
-
* Mirrors relayer-server/src/controllers/swap.helpers.ts `computeSwapParamsHash`.
|
|
164
|
-
*
|
|
165
|
-
* Circuit formula (swap.circom lines 293-307):
|
|
166
|
-
* mintPairHash = Poseidon(sourceMint, destMint)
|
|
167
|
-
* swapTermsHash = Poseidon(minAmountOut, deadline, destAmount)
|
|
168
|
-
* swapParamsHash = Poseidon(mintPairHash, swapTermsHash)
|
|
169
|
-
*
|
|
170
|
-
* @param sourceMint Source pool mint
|
|
171
|
-
* @param destMint Destination pool mint
|
|
172
|
-
* @param minAmountOut Minimum accepted output amount (slippage protected)
|
|
173
|
-
* @param deadline Unix timestamp deadline (i64, 0 = no deadline)
|
|
174
|
-
* @param destAmount Actual amount committed to destination UTXO (≥ minAmountOut -
|
|
175
|
-
* relayerFee). If omitted, defaults to minAmountOut.
|
|
176
|
-
*/
|
|
177
|
-
export declare function computeSwapParamsHash(sourceMint: PublicKey, destMint: PublicKey, minAmountOut: bigint, deadline: bigint, destAmount?: bigint): Uint8Array;
|
|
178
|
-
/**
|
|
179
|
-
* Compute the swap data hash committed on-chain for Jupiter instruction integrity.
|
|
180
|
-
* SHA-256 of the raw Jupiter swap instruction data bytes.
|
|
181
|
-
* Mirrors relayer-server/src/controllers/swap.helpers.ts `computeSwapDataHash`.
|
|
182
|
-
*/
|
|
183
|
-
export declare function computeSwapDataHash(swapData: Uint8Array | Buffer): Uint8Array;
|
|
1
|
+
export * from "./proofs/index.js";
|