@umbra-privacy/sdk 2.1.1 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-GP26R377.js → chunk-AUNYA6JP.js} +2 -2
- package/dist/chunk-AUNYA6JP.js.map +1 -0
- package/dist/{chunk-BL6WXLPV.cjs → chunk-KCHHJKQN.cjs} +2 -2
- package/dist/chunk-KCHHJKQN.cjs.map +1 -0
- package/dist/{chunk-KMRROOME.js → chunk-YA66JLHI.js} +9 -4
- package/dist/chunk-YA66JLHI.js.map +1 -0
- package/dist/{chunk-3LS5P32X.cjs → chunk-YFUGKMNS.cjs} +9 -4
- package/dist/chunk-YFUGKMNS.cjs.map +1 -0
- package/dist/{client-Cb53GYes.d.cts → client-Baxe29tj.d.cts} +128 -51
- package/dist/{client-CJ5S6Qln.d.ts → client-Cqv_5hHQ.d.ts} +128 -51
- package/dist/constants/index.cjs +1 -1
- package/dist/constants/index.js +1 -1
- package/dist/crypto/index.cjs +142 -142
- package/dist/crypto/index.d.cts +1 -1
- package/dist/crypto/index.d.ts +1 -1
- package/dist/crypto/index.js +1 -1
- package/dist/errors/index.cjs +28 -28
- package/dist/errors/index.d.cts +1 -1
- package/dist/errors/index.d.ts +1 -1
- package/dist/errors/index.js +1 -1
- package/dist/{errors-DAIrstEL.d.cts → errors-BqAlwXfh.d.cts} +3 -5
- package/dist/{errors-DPNMfyh0.d.ts → errors-Crx4Jf9K.d.ts} +3 -5
- package/dist/{index-B5wNTNZr.d.cts → index-BRLHQNe9.d.cts} +27 -12
- package/dist/{index-Cd76ZBHA.d.ts → index-gpTrCX61.d.ts} +27 -12
- package/dist/index.cjs +816 -1072
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -263
- package/dist/index.d.ts +12 -263
- package/dist/index.js +321 -573
- package/dist/index.js.map +1 -1
- package/dist/indexer-NHZDFABY.js +311 -0
- package/dist/indexer-NHZDFABY.js.map +1 -0
- package/dist/indexer-XOUBVRNU.cjs +316 -0
- package/dist/indexer-XOUBVRNU.cjs.map +1 -0
- package/dist/interfaces/index.d.cts +2 -2
- package/dist/interfaces/index.d.ts +2 -2
- package/dist/solana/index.d.cts +2 -2
- package/dist/solana/index.d.ts +2 -2
- package/dist/{transaction-forwarder-Dme9whAc.d.ts → transaction-forwarder-Cv3OlsaZ.d.ts} +1 -1
- package/dist/{transaction-forwarder-0GZRKXIr.d.cts → transaction-forwarder-DH07CEkG.d.cts} +1 -1
- package/package.json +1 -1
- package/dist/chunk-3LS5P32X.cjs.map +0 -1
- package/dist/chunk-BL6WXLPV.cjs.map +0 -1
- package/dist/chunk-GP26R377.js.map +0 -1
- package/dist/chunk-KMRROOME.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,34 +1,82 @@
|
|
|
1
1
|
export { RelayerError, getUmbraRelayer, pollClaimUntilTerminal } from './chunk-4RHXVBNI.js';
|
|
2
2
|
import { getNetworkConfig, getNetworkSpecifier, getDefaultSchemeVersion, getDefaultAlgorithmVersion, getDefaultProtocolVersion, createSetComputeUnitLimitInstruction, TOKEN_2022_PROGRAM_ID, SPL_TOKEN_PROGRAM_ID } from './chunk-FQDYYTPG.js';
|
|
3
|
-
import { getPoseidonAggregator, getPoseidonHasher, getAesDecryptor, getUserAccountX25519KeypairDeriver, deriveNullifierFromModifiedGenerationIndex, deriveRandomSecretFromModifiedGenerationIndex, deriveKeystreamBlindingFactor, getRescueEncryptorFromPrivateKey, getRescueKeyGeneratorFromPrivateKey, getRescueCommitmentGenerator, getModuloPowCurve25519Function, getPolynomialEvaluatorFunction, getMasterViewingKeyDeriver, getMasterViewingKeyBlindingFactorDeriver, getPoseidonPrivateKeyDeriver, getPoseidonBlindingFactorDeriver, getSecondViewingKeyDeriver, getPoseidonEncryptor, getPoseidonKeystreamGenerator, getUserCommitmentGeneratorFunction, getKeystreamCommitmentGenerator, getFiatShamirChallengeGeneratorFunction, expandModifiedGenerationIndex, getEphemeralUtxoMasterViewingKeyDeriver, getEphemeralUtxoMasterViewingKeyBlindingFactorDeriver, getEphemeralUtxoPoseidonPrivateKeyDeriver, getEphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriver, getMasterViewingKeyX25519KeypairDeriver, getMintX25519KeypairDeriver, getPoseidonKeystreamBlindingFactorDeriver, getUtxoCommitmentHashGenerator, getChallengePowersFunction, getAesEncryptor, deriveProofAccountOffsetFromModifiedGenerationIndex, deriveRandomFactorForPolynomialCommitmentFromModifiedGenerationIndex, deriveRescueEncryptionCommitmentBlindingFactorFromModifiedGenerationIndex, getRescueCommitmentBlindingFactorDeriver, getPolynomialCommitmentFactorDeriver, getRescueEncryptorWithNonceFromPrivateKey, getRescueDecryptorFromPrivateKey } from './chunk-
|
|
4
|
-
export { AES_AUTH_TAG_LENGTH, AES_IV_LENGTH, AES_KEY_LENGTH, AES_METADATA_OVERHEAD, ALPHA, ALPHA_INVERSE, BASE85_LIMB_MAX, BLOCK_SIZE, CIPHER_ROUND_COUNT, FIELD_ELEMENT_BYTE_LENGTH, FIELD_PRIME, GROTH16_G1_BYTE_LENGTH, GROTH16_G2_BYTE_LENGTH, HASH_CAPACITY, HASH_DIGEST_LENGTH, HASH_RATE, HASH_ROUND_COUNT, HASH_STATE_SIZE, MASTER_VIEWING_KEY_MAX, MAX_AGGREGATOR_INPUTS, MAX_POSEIDON_INPUTS, MAX_PRF_SEEDS, NONCE_BYTES, OPTIONAL_DATA_BYTE_LENGTH, PRECOMPUTED_FIELD_INVERSES, REDUCTION_CONST, SAMPLE_BUFFER_BYTE_LENGTH, SECRET_BYTES, SHAKE256_CIPHER_SEED, X25519_BYTE_LENGTH, ZK_PROOF_BYTE_LENGTH, assertAesCiphertextWithMetadata, assertAesKey, assertAesPlaintext, assertBase85Limb, assertCurve25519KeypairResult, assertDailyViewingKey, assertEd25519Keypair, assertGenerationSeed, assertGroth16ProofA, assertGroth16ProofB, assertGroth16ProofC, assertHourlyViewingKey, assertKeccak256Hash, assertKeccak512Hash, assertMasterSeed, assertMasterViewingKey, assertMintViewingKey, assertMinuteViewingKey, assertMonthlyViewingKey, assertOptionalData32, assertPoseidonCiphertext, assertPoseidonCounter, assertPoseidonHash, assertPoseidonKey, assertPoseidonKeystream, assertPoseidonPlaintext, assertRcCiphertext, assertRcCounter, assertRcEncryptionNonce, assertRcKey, assertRcPlaintext, assertSecondViewingKey, assertSharedSecret, assertX25519Bytes, assertX25519Keypair, assertX25519PrivateKey, assertX25519PublicKey, assertYearlyViewingKey, assertZkProofBytes, buildPersonalizationString, defaultAesDecryptor, defaultAesEncryptor, deriveBn254FieldElementFromKeccak512, deriveEphemeralMasterViewingKey, deriveEphemeralMasterViewingKeyBlindingFactor, deriveEphemeralPoseidonPrivateKey, deriveEphemeralPoseidonPrivateKeyBlindingFactor, deriveKeystreamBlindingFactor, deriveModifiedGenerationIndexForReceiverClaim, deriveModifiedGenerationIndexForSenderClaim, deriveNullifierFromModifiedGenerationIndex, deriveProofAccountOffsetFromModifiedGenerationIndex, deriveRandomFactorForPolynomialCommitmentFromModifiedGenerationIndex, deriveRandomSecretFromModifiedGenerationIndex, deriveRescueEncryptionCommitmentBlindingFactorFromModifiedGenerationIndex, expandModifiedGenerationIndex, getAesDecryptor, getAesEncryptor, getBn254FieldElementFromKeccak512Deriver, getChallengePowersFunction, getDailyViewingKeyDeriver, getEphemeralMasterSeedDeriver, getEphemeralRescueCommitmentBlindingFactorDeriver, getEphemeralUtxoH2RandomSecretDeriver, getEphemeralUtxoMasterViewingKeyBlindingFactorDeriver, getEphemeralUtxoMasterViewingKeyDeriver, getEphemeralUtxoNullifierDeriver, getEphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriver, getEphemeralUtxoPoseidonPrivateKeyDeriver, getFiatShamirChallengeGeneratorFunction, getFieldArithmetic, getHourlyViewingKeyDeriver, getKeystreamCommitmentGenerator, getMasterSeedBasedFieldElementDeriver, getMasterViewingKeyBlindingFactorDeriver, getMasterViewingKeyDeriver, getMasterViewingKeyX25519KeypairDeriver, getMintViewingKeyDeriver, getMintX25519KeypairDeriver, getMinuteViewingKeyDeriver, getModuloPowCurve25519Function, getMonthlyViewingKeyDeriver, getPersonalizationStringBuilder, getPolynomialCommitmentFactorDeriver, getPolynomialEvaluatorFunction, getPoseidonAggregator, getPoseidonBlindingFactorDeriver, getPoseidonDecryptor, getPoseidonEncryptor, getPoseidonHasher, getPoseidonKeystreamBlindingFactorDeriver, getPoseidonKeystreamGenerator, getPoseidonPrf, getPoseidonPrivateKeyDeriver, getPseudorandomU512Deriver, getRescueCipher, getRescueCipherFromKeyPair, getRescueCipherInstance, getRescueCommitmentBlindingFactorDeriver, getRescueCommitmentGenerator, getRescueDecryptorFromPrivateKey, getRescueEncryptorFromPrivateKey, getRescueEncryptorWithNonceFromPrivateKey, getRescueKeyGeneratorFromPrivateKey, getRescuePrimeHashFunction, getSecondViewingKeyDeriver, getUserAccountX25519KeypairDeriver, getUserCommitmentGeneratorFunction, getUtxoCommitmentHashGenerator, getYearlyViewingKeyDeriver } from './chunk-
|
|
3
|
+
import { getPoseidonAggregator, getPoseidonHasher, getAesDecryptor, getUserAccountX25519KeypairDeriver, deriveNullifierFromModifiedGenerationIndex, deriveRandomSecretFromModifiedGenerationIndex, deriveKeystreamBlindingFactor, getRescueEncryptorFromPrivateKey, getRescueKeyGeneratorFromPrivateKey, getRescueCommitmentGenerator, getModuloPowCurve25519Function, getPolynomialEvaluatorFunction, getMasterViewingKeyDeriver, getMasterViewingKeyBlindingFactorDeriver, getPoseidonPrivateKeyDeriver, getPoseidonBlindingFactorDeriver, getSecondViewingKeyDeriver, getPoseidonEncryptor, getPoseidonKeystreamGenerator, getUserCommitmentGeneratorFunction, getKeystreamCommitmentGenerator, getFiatShamirChallengeGeneratorFunction, expandModifiedGenerationIndex, getEphemeralUtxoMasterViewingKeyDeriver, getEphemeralUtxoMasterViewingKeyBlindingFactorDeriver, getEphemeralUtxoPoseidonPrivateKeyDeriver, getEphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriver, getMasterViewingKeyX25519KeypairDeriver, getMintX25519KeypairDeriver, getPoseidonKeystreamBlindingFactorDeriver, getUtxoCommitmentHashGenerator, getChallengePowersFunction, getAesEncryptor, deriveProofAccountOffsetFromModifiedGenerationIndex, deriveRandomFactorForPolynomialCommitmentFromModifiedGenerationIndex, deriveRescueEncryptionCommitmentBlindingFactorFromModifiedGenerationIndex, getRescueCommitmentBlindingFactorDeriver, getPolynomialCommitmentFactorDeriver, getRescueEncryptorWithNonceFromPrivateKey, getRescueDecryptorFromPrivateKey } from './chunk-YA66JLHI.js';
|
|
4
|
+
export { AES_AUTH_TAG_LENGTH, AES_IV_LENGTH, AES_KEY_LENGTH, AES_METADATA_OVERHEAD, ALPHA, ALPHA_INVERSE, BASE85_LIMB_MAX, BLOCK_SIZE, CIPHER_ROUND_COUNT, FIELD_ELEMENT_BYTE_LENGTH, FIELD_PRIME, GROTH16_G1_BYTE_LENGTH, GROTH16_G2_BYTE_LENGTH, HASH_CAPACITY, HASH_DIGEST_LENGTH, HASH_RATE, HASH_ROUND_COUNT, HASH_STATE_SIZE, MASTER_VIEWING_KEY_MAX, MAX_AGGREGATOR_INPUTS, MAX_POSEIDON_INPUTS, MAX_PRF_SEEDS, NONCE_BYTES, OPTIONAL_DATA_BYTE_LENGTH, PRECOMPUTED_FIELD_INVERSES, REDUCTION_CONST, SAMPLE_BUFFER_BYTE_LENGTH, SECRET_BYTES, SHAKE256_CIPHER_SEED, X25519_BYTE_LENGTH, ZK_PROOF_BYTE_LENGTH, assertAesCiphertextWithMetadata, assertAesKey, assertAesPlaintext, assertBase85Limb, assertCurve25519KeypairResult, assertDailyViewingKey, assertEd25519Keypair, assertGenerationSeed, assertGroth16ProofA, assertGroth16ProofB, assertGroth16ProofC, assertHourlyViewingKey, assertKeccak256Hash, assertKeccak512Hash, assertMasterSeed, assertMasterViewingKey, assertMintViewingKey, assertMinuteViewingKey, assertMonthlyViewingKey, assertOptionalData32, assertPoseidonCiphertext, assertPoseidonCounter, assertPoseidonHash, assertPoseidonKey, assertPoseidonKeystream, assertPoseidonPlaintext, assertRcCiphertext, assertRcCounter, assertRcEncryptionNonce, assertRcKey, assertRcPlaintext, assertSecondViewingKey, assertSharedSecret, assertX25519Bytes, assertX25519Keypair, assertX25519PrivateKey, assertX25519PublicKey, assertYearlyViewingKey, assertZkProofBytes, buildPersonalizationString, defaultAesDecryptor, defaultAesEncryptor, deriveBn254FieldElementFromKeccak512, deriveEphemeralMasterViewingKey, deriveEphemeralMasterViewingKeyBlindingFactor, deriveEphemeralPoseidonPrivateKey, deriveEphemeralPoseidonPrivateKeyBlindingFactor, deriveKeystreamBlindingFactor, deriveModifiedGenerationIndexForReceiverClaim, deriveModifiedGenerationIndexForSenderClaim, deriveNullifierFromModifiedGenerationIndex, deriveProofAccountOffsetFromModifiedGenerationIndex, deriveRandomFactorForPolynomialCommitmentFromModifiedGenerationIndex, deriveRandomSecretFromModifiedGenerationIndex, deriveRescueEncryptionCommitmentBlindingFactorFromModifiedGenerationIndex, expandModifiedGenerationIndex, getAesDecryptor, getAesEncryptor, getBn254FieldElementFromKeccak512Deriver, getChallengePowersFunction, getDailyViewingKeyDeriver, getEphemeralMasterSeedDeriver, getEphemeralRescueCommitmentBlindingFactorDeriver, getEphemeralUtxoH2RandomSecretDeriver, getEphemeralUtxoMasterViewingKeyBlindingFactorDeriver, getEphemeralUtxoMasterViewingKeyDeriver, getEphemeralUtxoNullifierDeriver, getEphemeralUtxoPoseidonPrivateKeyBlindingFactorDeriver, getEphemeralUtxoPoseidonPrivateKeyDeriver, getFiatShamirChallengeGeneratorFunction, getFieldArithmetic, getHourlyViewingKeyDeriver, getKeystreamCommitmentGenerator, getMasterSeedBasedFieldElementDeriver, getMasterViewingKeyBlindingFactorDeriver, getMasterViewingKeyDeriver, getMasterViewingKeyX25519KeypairDeriver, getMintViewingKeyDeriver, getMintX25519KeypairDeriver, getMinuteViewingKeyDeriver, getModuloPowCurve25519Function, getMonthlyViewingKeyDeriver, getPersonalizationStringBuilder, getPolynomialCommitmentFactorDeriver, getPolynomialEvaluatorFunction, getPoseidonAggregator, getPoseidonBlindingFactorDeriver, getPoseidonDecryptor, getPoseidonEncryptor, getPoseidonHasher, getPoseidonKeystreamBlindingFactorDeriver, getPoseidonKeystreamGenerator, getPoseidonPrf, getPoseidonPrivateKeyDeriver, getPseudorandomU512Deriver, getRescueCipher, getRescueCipherFromKeyPair, getRescueCipherInstance, getRescueCommitmentBlindingFactorDeriver, getRescueCommitmentGenerator, getRescueDecryptorFromPrivateKey, getRescueEncryptorFromPrivateKey, getRescueEncryptorWithNonceFromPrivateKey, getRescueKeyGeneratorFromPrivateKey, getRescuePrimeHashFunction, getSecondViewingKeyDeriver, getUserAccountX25519KeypairDeriver, getUserCommitmentGeneratorFunction, getUtxoCommitmentHashGenerator, getYearlyViewingKeyDeriver } from './chunk-YA66JLHI.js';
|
|
5
5
|
import { splitAddressToLowHigh, createBn254FieldElement, createPoseidonKey, splitU256IntoTwoU128s, createRcPlaintext, splitX25519PublicKeyIntoTwoU128s, convertU256ToBase85Limbs, createU256, createCurve25519FieldElement, bigintToBinaryArrayLSB, generateRandomU256, generateRandomU128, createU64, extractClusterOffsetFromMxeAccount, generateRandomU64, extractTransferFeeConfig, calculateTransferFee, generateComputationOffset, extractUtcComponents, getByteAt } from './chunk-UXMQI6B7.js';
|
|
6
6
|
import { findEncryptedUserAccountPda, findArciumInfrastructurePdas, findUserComplianceGrantPda, findNetworkComplianceGrantPda, findSharedComplianceGrantPda, findEncryptedTokenAccountPda, findStealthPoolPda, findUtxoInputBufferPda, findPublicUtxoInputBufferPda } from './chunk-KH3YTDKA.js';
|
|
7
7
|
import './chunk-EEKF4553.js';
|
|
8
|
-
import { ComputationMonitorError, FetchUtxosError, ClaimUtxoError, RpcError, ConversionError, TransactionSigningError, TransactionError, EncryptedDepositError, CreateUtxoError, QueryError, RegistrationError, MasterSeedSigningRejectedError, EncryptedWithdrawalError } from './chunk-
|
|
9
|
-
export { ClaimUtxoError, ComputationMonitorError, ConversionError, CreateUtxoError, EncryptedDepositError, EncryptedWithdrawalError, FetchUtxosError, QueryError, RegistrationError, isClaimUtxoError, isComputationMonitorError, isConversionError, isCreateUtxoError, isEncryptedDepositError, isEncryptedWithdrawalError, isFetchUtxosError, isQueryError, isRegistrationError } from './chunk-
|
|
8
|
+
import { ComputationMonitorError, FetchUtxosError, ClaimUtxoError, RpcError, ConversionError, TransactionSigningError, TransactionError, EncryptedDepositError, CreateUtxoError, QueryError, RegistrationError, MasterSeedSigningRejectedError, EncryptedWithdrawalError } from './chunk-AUNYA6JP.js';
|
|
9
|
+
export { ClaimUtxoError, ComputationMonitorError, ConversionError, CreateUtxoError, EncryptedDepositError, EncryptedWithdrawalError, FetchUtxosError, QueryError, RegistrationError, isClaimUtxoError, isComputationMonitorError, isConversionError, isCreateUtxoError, isEncryptedDepositError, isEncryptedWithdrawalError, isFetchUtxosError, isQueryError, isRegistrationError } from './chunk-AUNYA6JP.js';
|
|
10
10
|
import { computeBn254LimbwiseSumInverse, computeBn254ModularInverse } from './chunk-OFDWNWCL.js';
|
|
11
11
|
export { bn254Add, bn254ModuloPow, bn254Mul, bn254Sub, computeBn254LimbwiseSumInverse, computeBn254ModularInverse } from './chunk-OFDWNWCL.js';
|
|
12
12
|
import { bn254FieldElementSampler, getBn254ModularInverter, computeBn254LimbwiseSumInverse as computeBn254LimbwiseSumInverse$1 } from './chunk-WN75ORDT.js';
|
|
13
13
|
export { bn254FieldElementSampler, curve25519FieldElementSampler, curve25519ModuloAdd, curve25519ModuloInv, curve25519ModuloMul, curve25519ModuloPow, curve25519ModuloSub, getBn254FieldElementSampler, getBn254ModularAdder, getBn254ModularInverter, getBn254ModularMultiplier, getBn254ModularNegator, getBn254ModularSubtractor, getCurve25519FieldElementSampler, getCurve25519ModularAddFunction, getCurve25519ModularInvFunction, getCurve25519ModularMulFunction, getCurve25519ModularPowFunction, getCurve25519ModularSubFunction } from './chunk-WN75ORDT.js';
|
|
14
14
|
import './chunk-UOFYS6M3.js';
|
|
15
|
-
import {
|
|
15
|
+
import { decodeU64LeBytesToU64, decodeU128LeBytesToU128, encodeU256ToU256BeBytes, decodeU256BeBytesToU256, encodeU128ToU128LeBytes, encodeU256ToU256LeBytes, decodeU256LeBytesToU256, encodeU64ToU64LeBytes } from './chunk-FQX6ZYGJ.js';
|
|
16
16
|
import { CryptographyError } from './chunk-5KPQXPQM.js';
|
|
17
17
|
import './chunk-4TZVXB5G.js';
|
|
18
18
|
import { getRpcAccountInfoProvider, getRpcBlockhashProvider, getWebsocketTransactionForwarder, getRpcEpochInfoProvider, lookupAltEntry, buildAltAddressesRecord } from './chunk-HA5FLM63.js';
|
|
19
19
|
export { createInMemorySigner, createSignerFromKeyPair, createSignerFromPrivateKeyBytes, createSignerFromWalletAccount, getPollingTransactionForwarder, getRpcAccountInfoProvider, getRpcBlockhashProvider, getRpcEpochInfoProvider, getWebsocketTransactionForwarder } from './chunk-HA5FLM63.js';
|
|
20
20
|
import { base64ToUint8Array, sleep } from './chunk-TLR7A64G.js';
|
|
21
21
|
import { assertTransactionSignature, assertYear, assertMonth, assertDay, assertHour, assertMinute, assertSecond } from './chunk-DD2WCK4C.js';
|
|
22
|
-
import { assertMasterSeed,
|
|
22
|
+
import { assertMasterSeed, assertAesKey, assertX25519PrivateKey, assertU128, assertU256, MathematicsAssertionError, assertU256LeBytes, assertU64, assertBn254FieldElement, assertCurve25519FieldElement, assertRcEncryptionNonce, assertU512BeBytes, assertGroth16ProofA, assertGroth16ProofB, assertGroth16ProofC, assertOptionalData32, assertBase85Limb, assertPoseidonPlaintext, assertPoseidonKey, assertRcPlaintext, assertRcCiphertext, assertRcKey, assertAesPlaintext, assertX25519PublicKey, CURVE25519_FIELD_PRIME } from './chunk-CFTW5WNG.js';
|
|
23
23
|
import { __name } from './chunk-7QVYU63E.js';
|
|
24
24
|
import { kmac256 } from '@noble/hashes/sha3-addons.js';
|
|
25
25
|
import { createSolanaRpcSubscriptions, createSolanaRpc, getAddressDecoder, createKeyPairSignerFromPrivateKeyBytes, createNoopSigner, pipe, createTransactionMessage, setTransactionMessageFeePayer, setTransactionMessageLifetimeUsingBlockhash, appendTransactionMessageInstructions, partiallySignTransactionMessageWithSigners, compressTransactionMessageUsingAddressLookupTables, getSignatureFromTransaction, getAddressEncoder, compileTransaction, fetchEncodedAccount } from '@solana/kit';
|
|
26
26
|
import { getClaimComputationRentInstruction, decodeComputationAccount, ComputationStatus } from '@umbra-privacy/arcium-codama';
|
|
27
|
-
import { ReadServiceClient } from '@umbra-privacy/indexer-read-service-client';
|
|
28
27
|
import { x25519 } from '@noble/curves/ed25519.js';
|
|
29
28
|
import { keccak_256 } from '@noble/hashes/sha3.js';
|
|
30
29
|
import { getCreateUserGrantInstructionAsync, getDeleteUserGrantInstructionAsync, getReencryptUserGrantV11InstructionAsync, getReencryptNetworkGrantForNetworkBalanceV11InstructionAsync, getReencryptNetworkGrantForSharedBalanceV11InstructionAsync, decodeEncryptedTokenAccount, getConvertNetworkBalanceToSharedBalanceV11InstructionAsync, getReencryptSharedBalanceV11InstructionAsync, decodeEncryptedUserAccount, getResetSharedEncryptedTokenAccountQueueV11InstructionAsync, getResetNetworkEncryptedTokenAccountQueueV11InstructionAsync, getDepositFromPublicBalanceIntoExistingSharedBalanceV11InstructionAsync, getDepositFromPublicBalanceIntoNewSharedBalanceV11InstructionAsync, getDepositFromPublicBalanceIntoExistingNetworkBalanceV11InstructionAsync, getDepositFromPublicBalanceIntoNewNetworkBalanceV11InstructionAsync, getCloseStealthPoolDepositInputBufferInstructionAsync, getCreateStealthPoolDepositInputBufferInstructionAsync, getDepositIntoStealthPoolFromSharedBalanceV11InstructionAsync, getClosePublicStealthPoolDepositInputBufferInstructionAsync, getCreatePublicStealthPoolDepositInputBufferInstructionAsync, getDepositIntoStealthPoolFromPublicBalanceInstructionAsync, getClaimStagedSolFromPoolInstructionAsync, getClaimStagedSplFromPoolInstructionAsync, getEncryptedUserAccountSize, ENCRYPTED_USER_ACCOUNT_DISCRIMINATOR, getInitialiseEncryptedUserAccountInstructionAsync, getRegisterTokenPublicKeyInstructionAsync, getRegisterUserForAnonymousUsageV11InstructionAsync, getUpdateRandomGenerationSeedInstructionAsync, getUpdateTokenAccountRandomGenerationSeedInstructionAsync, getWithdrawFromSharedBalanceIntoPublicBalanceV11InstructionAsync } from '@umbra-privacy/umbra-codama';
|
|
31
30
|
|
|
31
|
+
// src/umbra/constants.ts
|
|
32
|
+
var UMBRA_MESSAGE_TO_SIGN = `Umbra Protocol – User Consent & Acknowledgement
|
|
33
|
+
|
|
34
|
+
Please read carefully before continuing. Umbra is a non-custodial, open-source protocol. Umbra does not hold, control, manage, or access your digital assets, private keys, viewing keys, transactions, or personal data. All interactions with the Umbra protocol occur through autonomous smart contracts and wallet-signed transactions executed directly on the blockchain.
|
|
35
|
+
|
|
36
|
+
By using the Umbra protocol, you acknowledge and agree that:
|
|
37
|
+
|
|
38
|
+
1. You are solely responsible for managing your wallet, private keys, privacy settings, viewing key disclosures, and any transactions or interactions you authorize.
|
|
39
|
+
2. Blockchain transactions are generally irreversible, and smart contracts may contain bugs, vulnerabilities, or unintended behavior.
|
|
40
|
+
3. Errors, misuse, misconfiguration, third-party tools, relayers, or loss of keys may result in permanent and unrecoverable loss of assets or privacy.
|
|
41
|
+
4. Privacy features are designed to enhance confidentiality but do not guarantee absolute or unconditional anonymity.
|
|
42
|
+
5. Transactions may involve independent relayers or third-party infrastructure that Umbra does not operate, control, or supervise.
|
|
43
|
+
6. By clicking "I Agree", you confirm that you have read, understood, and accepted all applicable terms, policies, risk disclosures, notices, and other documentation governing your access to and use of the Umbra protocol, as published or made available by Umbra from time to time.
|
|
44
|
+
|
|
45
|
+
You acknowledge that such documentation may be updated or modified, and that continued access to or use of the Umbra Protocol constitutes acceptance of the then-current versions. If you do not agree, do not proceed and discontinue use of the Umbra protocol.`;
|
|
46
|
+
var FEE_OFFSETS = {
|
|
47
|
+
/**
|
|
48
|
+
* Offset used in `FeeVault` PDA derivation for the unified protocol fees pool.
|
|
49
|
+
*
|
|
50
|
+
* @remarks
|
|
51
|
+
* Passed as the final seed to `findProtocolFeeVaultPda` and
|
|
52
|
+
* `findRelayerFeeVaultPda`. Currently `0n`.
|
|
53
|
+
*
|
|
54
|
+
* @readonly
|
|
55
|
+
*/
|
|
56
|
+
PROTOCOL_FEES_POOL: 0n,
|
|
57
|
+
/**
|
|
58
|
+
* Offset used in `FeeSchedule` PDA derivation.
|
|
59
|
+
*
|
|
60
|
+
* @remarks
|
|
61
|
+
* Passed as the final seed to `findFeeSchedulePda`. Currently `0n`.
|
|
62
|
+
*
|
|
63
|
+
* @readonly
|
|
64
|
+
*/
|
|
65
|
+
PROTOCOL_FEES_CONFIG: 0n,
|
|
66
|
+
/**
|
|
67
|
+
* Offset used in relayer fee configuration PDA derivation.
|
|
68
|
+
*
|
|
69
|
+
* @remarks
|
|
70
|
+
* Passed as the offset seed when looking up the relayer's fee configuration account.
|
|
71
|
+
* Currently `0n`.
|
|
72
|
+
*
|
|
73
|
+
* @readonly
|
|
74
|
+
*/
|
|
75
|
+
RELAYER_FEES_CONFIG: 0n
|
|
76
|
+
};
|
|
77
|
+
var BPS_DIVISOR = 16384n;
|
|
78
|
+
|
|
79
|
+
// src/common/storage.ts
|
|
32
80
|
function getDefaultMasterSeedStorage() {
|
|
33
81
|
let cachedSeed = null;
|
|
34
82
|
return {
|
|
@@ -49,8 +97,7 @@ var MASTER_SEED_DOMAIN = new TextEncoder().encode("Umbra Privacy - MasterSeedGen
|
|
|
49
97
|
var SEED_PERSONALIZATION = new TextEncoder().encode("umbra/1.0.0|kmac256/1.0.0|kdf/1.0.0|seed");
|
|
50
98
|
function getDefaultMasterSeedGenerator(signer) {
|
|
51
99
|
return async () => {
|
|
52
|
-
const
|
|
53
|
-
const messageBytes = new TextEncoder().encode(message);
|
|
100
|
+
const messageBytes = new TextEncoder().encode(UMBRA_MESSAGE_TO_SIGN);
|
|
54
101
|
const signature = await signer.signMessage(messageBytes);
|
|
55
102
|
const seed = kmac256(
|
|
56
103
|
MASTER_SEED_DOMAIN,
|
|
@@ -96,7 +143,10 @@ function notificationValueToEncodedAccount(address, value) {
|
|
|
96
143
|
__name(notificationValueToEncodedAccount, "notificationValueToEncodedAccount");
|
|
97
144
|
function checkAborted(signal) {
|
|
98
145
|
if (signal?.aborted) {
|
|
99
|
-
throw new ComputationMonitorError(
|
|
146
|
+
throw new ComputationMonitorError(
|
|
147
|
+
"timeout",
|
|
148
|
+
"Computation monitoring cancelled via AbortSignal"
|
|
149
|
+
);
|
|
100
150
|
}
|
|
101
151
|
}
|
|
102
152
|
__name(checkAborted, "checkAborted");
|
|
@@ -158,6 +208,13 @@ function buildPrunedResult(startTime, queuedSlot, currentSlot, onProgress) {
|
|
|
158
208
|
};
|
|
159
209
|
}
|
|
160
210
|
__name(buildPrunedResult, "buildPrunedResult");
|
|
211
|
+
function buildTimedOutResult(startTime) {
|
|
212
|
+
return {
|
|
213
|
+
status: "timed-out",
|
|
214
|
+
elapsedMs: Date.now() - startTime
|
|
215
|
+
};
|
|
216
|
+
}
|
|
217
|
+
__name(buildTimedOutResult, "buildTimedOutResult");
|
|
161
218
|
function getWebsocketComputationMonitor(config, deps) {
|
|
162
219
|
const { rpcUrl, rpcSubscriptionsUrl } = config;
|
|
163
220
|
const {
|
|
@@ -166,7 +223,7 @@ function getWebsocketComputationMonitor(config, deps) {
|
|
|
166
223
|
} = deps ?? {};
|
|
167
224
|
const rpc = createRpc(rpcUrl);
|
|
168
225
|
const rpcSubscriptions = createRpcSubscriptions(rpcSubscriptionsUrl);
|
|
169
|
-
async function
|
|
226
|
+
async function prepareMonitor(computationAddress, options) {
|
|
170
227
|
const {
|
|
171
228
|
maxSlotWindow = DEFAULT_MAX_SLOT_WINDOW,
|
|
172
229
|
safetyTimeoutMs = DEFAULT_SAFETY_TIMEOUT_MS,
|
|
@@ -175,126 +232,128 @@ function getWebsocketComputationMonitor(config, deps) {
|
|
|
175
232
|
commitment = "confirmed",
|
|
176
233
|
signal: externalSignal
|
|
177
234
|
} = options ?? {};
|
|
178
|
-
const startTime = Date.now();
|
|
179
|
-
let queuedSlot = null;
|
|
180
|
-
try {
|
|
181
|
-
const currentAccount = await fetchEncodedAccount(rpc, computationAddress, { commitment });
|
|
182
|
-
if (currentAccount.exists) {
|
|
183
|
-
const decoded = decodeComputationAccount(currentAccount);
|
|
184
|
-
queuedSlot = decoded.data.slot;
|
|
185
|
-
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
186
|
-
return buildFinalizedResult(
|
|
187
|
-
rpc,
|
|
188
|
-
computationAddress,
|
|
189
|
-
startTime,
|
|
190
|
-
queuedSlot,
|
|
191
|
-
shouldRetrieveSignature,
|
|
192
|
-
onProgress
|
|
193
|
-
);
|
|
194
|
-
}
|
|
195
|
-
onProgress?.({ type: "queued", queuedSlot });
|
|
196
|
-
const currentSlot = await fetchCurrentSlot(rpc, commitment);
|
|
197
|
-
if (isSlotWindowExceeded(queuedSlot, currentSlot, maxSlotWindow)) {
|
|
198
|
-
return buildPrunedResult(startTime, queuedSlot, currentSlot, onProgress);
|
|
199
|
-
}
|
|
200
|
-
}
|
|
201
|
-
} catch (error) {
|
|
202
|
-
if (error instanceof ComputationMonitorError) {
|
|
203
|
-
throw error;
|
|
204
|
-
}
|
|
205
|
-
}
|
|
206
|
-
checkAborted(externalSignal);
|
|
207
235
|
const abortController = new AbortController();
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
if (queuedSlot !== null) {
|
|
214
|
-
const capturedQueuedSlot = queuedSlot;
|
|
215
|
-
slotCheckIntervalId = setInterval(async () => {
|
|
216
|
-
try {
|
|
217
|
-
const currentSlot = await fetchCurrentSlot(rpc, commitment);
|
|
218
|
-
if (isSlotWindowExceeded(capturedQueuedSlot, currentSlot, maxSlotWindow)) {
|
|
219
|
-
pruneDetected = buildPrunedResult(startTime, capturedQueuedSlot, currentSlot, onProgress);
|
|
220
|
-
abortController.abort();
|
|
221
|
-
}
|
|
222
|
-
} catch {
|
|
223
|
-
}
|
|
224
|
-
}, 5e3);
|
|
236
|
+
let cleaned = false;
|
|
237
|
+
function cleanup() {
|
|
238
|
+
if (cleaned) return;
|
|
239
|
+
cleaned = true;
|
|
240
|
+
abortController.abort();
|
|
225
241
|
}
|
|
242
|
+
__name(cleanup, "cleanup");
|
|
243
|
+
let notifications;
|
|
226
244
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
245
|
+
notifications = await rpcSubscriptions.accountNotifications(computationAddress, { encoding: "base64", commitment }).subscribe({ abortSignal: abortController.signal });
|
|
246
|
+
} catch (error) {
|
|
247
|
+
cleanup();
|
|
248
|
+
throw new ComputationMonitorError(
|
|
249
|
+
"subscription",
|
|
250
|
+
"Failed to establish WebSocket subscription",
|
|
251
|
+
error instanceof Error ? error : void 0
|
|
252
|
+
);
|
|
253
|
+
}
|
|
254
|
+
async function awaitComputation() {
|
|
255
|
+
const startTime = Date.now();
|
|
256
|
+
let queuedSlot = null;
|
|
257
|
+
let receivedFirstNotification = false;
|
|
258
|
+
checkAborted(externalSignal);
|
|
259
|
+
const safetyTimeoutId = setTimeout(() => abortController.abort(), safetyTimeoutMs);
|
|
260
|
+
const onExternalAbort = /* @__PURE__ */ __name(() => abortController.abort(), "onExternalAbort");
|
|
261
|
+
externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
262
|
+
let slotCheckIntervalId = null;
|
|
263
|
+
let pruneDetected = null;
|
|
264
|
+
try {
|
|
265
|
+
for await (const notification of notifications) {
|
|
266
|
+
try {
|
|
267
|
+
const encodedAccount = notificationValueToEncodedAccount(
|
|
242
268
|
computationAddress,
|
|
243
|
-
|
|
244
|
-
queuedSlot,
|
|
245
|
-
shouldRetrieveSignature,
|
|
246
|
-
onProgress
|
|
269
|
+
notification.value
|
|
247
270
|
);
|
|
271
|
+
const decoded = decodeComputationAccount(encodedAccount);
|
|
272
|
+
if (!receivedFirstNotification) {
|
|
273
|
+
receivedFirstNotification = true;
|
|
274
|
+
queuedSlot = decoded.data.slot;
|
|
275
|
+
const capturedQueuedSlot = queuedSlot;
|
|
276
|
+
slotCheckIntervalId = setInterval(async () => {
|
|
277
|
+
try {
|
|
278
|
+
const currentSlot = await fetchCurrentSlot(rpc, commitment);
|
|
279
|
+
if (isSlotWindowExceeded(capturedQueuedSlot, currentSlot, maxSlotWindow)) {
|
|
280
|
+
pruneDetected = buildPrunedResult(
|
|
281
|
+
startTime,
|
|
282
|
+
capturedQueuedSlot,
|
|
283
|
+
currentSlot,
|
|
284
|
+
onProgress
|
|
285
|
+
);
|
|
286
|
+
abortController.abort();
|
|
287
|
+
}
|
|
288
|
+
} catch {
|
|
289
|
+
}
|
|
290
|
+
}, 5e3);
|
|
291
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
292
|
+
return buildFinalizedResult(
|
|
293
|
+
rpc,
|
|
294
|
+
computationAddress,
|
|
295
|
+
startTime,
|
|
296
|
+
queuedSlot,
|
|
297
|
+
shouldRetrieveSignature,
|
|
298
|
+
onProgress
|
|
299
|
+
);
|
|
300
|
+
}
|
|
301
|
+
continue;
|
|
302
|
+
}
|
|
303
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
304
|
+
return buildFinalizedResult(
|
|
305
|
+
rpc,
|
|
306
|
+
computationAddress,
|
|
307
|
+
startTime,
|
|
308
|
+
queuedSlot,
|
|
309
|
+
shouldRetrieveSignature,
|
|
310
|
+
onProgress
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
} catch {
|
|
314
|
+
continue;
|
|
248
315
|
}
|
|
249
|
-
} catch {
|
|
250
|
-
continue;
|
|
251
316
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
if (abortController.signal.aborted) {
|
|
317
|
+
if (pruneDetected) {
|
|
318
|
+
return pruneDetected;
|
|
319
|
+
}
|
|
320
|
+
return buildTimedOutResult(startTime);
|
|
321
|
+
} catch (error) {
|
|
322
|
+
if (error instanceof ComputationMonitorError) {
|
|
323
|
+
throw error;
|
|
324
|
+
}
|
|
325
|
+
if (pruneDetected) {
|
|
326
|
+
return pruneDetected;
|
|
327
|
+
}
|
|
328
|
+
if (abortController.signal.aborted) {
|
|
329
|
+
return buildTimedOutResult(startTime);
|
|
330
|
+
}
|
|
268
331
|
throw new ComputationMonitorError(
|
|
269
|
-
"
|
|
270
|
-
|
|
332
|
+
"subscription",
|
|
333
|
+
"WebSocket subscription failed",
|
|
334
|
+
error instanceof Error ? error : void 0
|
|
271
335
|
);
|
|
336
|
+
} finally {
|
|
337
|
+
clearTimeout(safetyTimeoutId);
|
|
338
|
+
if (slotCheckIntervalId !== null) {
|
|
339
|
+
clearInterval(slotCheckIntervalId);
|
|
340
|
+
}
|
|
341
|
+
externalSignal?.removeEventListener("abort", onExternalAbort);
|
|
342
|
+
cleanup();
|
|
272
343
|
}
|
|
273
|
-
throw new ComputationMonitorError(
|
|
274
|
-
"subscription",
|
|
275
|
-
"WebSocket subscription failed",
|
|
276
|
-
error instanceof Error ? error : void 0
|
|
277
|
-
);
|
|
278
|
-
} finally {
|
|
279
|
-
clearTimeout(safetyTimeoutId);
|
|
280
|
-
if (slotCheckIntervalId !== null) {
|
|
281
|
-
clearInterval(slotCheckIntervalId);
|
|
282
|
-
}
|
|
283
|
-
externalSignal?.removeEventListener("abort", onExternalAbort);
|
|
284
|
-
abortController.abort();
|
|
285
344
|
}
|
|
345
|
+
__name(awaitComputation, "awaitComputation");
|
|
346
|
+
return { awaitComputation, cleanup };
|
|
286
347
|
}
|
|
287
|
-
__name(
|
|
288
|
-
return {
|
|
289
|
-
awaitComputation: monitorComputation
|
|
290
|
-
};
|
|
348
|
+
__name(prepareMonitor, "prepareMonitor");
|
|
349
|
+
return { prepareMonitor };
|
|
291
350
|
}
|
|
292
351
|
__name(getWebsocketComputationMonitor, "getWebsocketComputationMonitor");
|
|
293
352
|
function getPollingComputationMonitor(config, deps) {
|
|
294
353
|
const { rpcUrl } = config;
|
|
295
354
|
const { createRpc = createSolanaRpc } = deps ?? {};
|
|
296
355
|
const rpc = createRpc(rpcUrl);
|
|
297
|
-
async function
|
|
356
|
+
async function prepareMonitor(computationAddress, options) {
|
|
298
357
|
const {
|
|
299
358
|
maxSlotWindow = DEFAULT_MAX_SLOT_WINDOW,
|
|
300
359
|
safetyTimeoutMs = DEFAULT_SAFETY_TIMEOUT_MS,
|
|
@@ -304,360 +363,77 @@ function getPollingComputationMonitor(config, deps) {
|
|
|
304
363
|
commitment = "confirmed",
|
|
305
364
|
signal: externalSignal
|
|
306
365
|
} = options ?? {};
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
if (
|
|
318
|
-
|
|
319
|
-
continue;
|
|
320
|
-
}
|
|
321
|
-
const decoded = decodeComputationAccount(maybeAccount);
|
|
322
|
-
if (queuedSlot === null) {
|
|
323
|
-
queuedSlot = decoded.data.slot;
|
|
324
|
-
}
|
|
325
|
-
if (!queuedEventFired && decoded.data.status === ComputationStatus.Queued) {
|
|
326
|
-
onProgress?.({ type: "queued", queuedSlot });
|
|
327
|
-
queuedEventFired = true;
|
|
328
|
-
}
|
|
329
|
-
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
330
|
-
return buildFinalizedResult(
|
|
331
|
-
rpc,
|
|
332
|
-
computationAddress,
|
|
333
|
-
startTime,
|
|
334
|
-
queuedSlot,
|
|
335
|
-
shouldRetrieveSignature,
|
|
336
|
-
onProgress
|
|
337
|
-
);
|
|
338
|
-
}
|
|
339
|
-
if (isSlotWindowExceeded(queuedSlot, currentSlot, maxSlotWindow)) {
|
|
340
|
-
return buildPrunedResult(startTime, queuedSlot, currentSlot, onProgress);
|
|
366
|
+
let aborted = false;
|
|
367
|
+
function cleanup() {
|
|
368
|
+
aborted = true;
|
|
369
|
+
}
|
|
370
|
+
__name(cleanup, "cleanup");
|
|
371
|
+
async function awaitComputation() {
|
|
372
|
+
const startTime = Date.now();
|
|
373
|
+
let queuedSlot = null;
|
|
374
|
+
let receivedFirstDecode = false;
|
|
375
|
+
while (Date.now() - startTime < safetyTimeoutMs) {
|
|
376
|
+
if (aborted) {
|
|
377
|
+
return buildTimedOutResult(startTime);
|
|
341
378
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
379
|
+
checkAborted(externalSignal);
|
|
380
|
+
try {
|
|
381
|
+
const [maybeAccount, currentSlot] = await Promise.all([
|
|
382
|
+
fetchEncodedAccount(rpc, computationAddress, { commitment }),
|
|
383
|
+
fetchCurrentSlot(rpc, commitment)
|
|
384
|
+
]);
|
|
385
|
+
if (!maybeAccount.exists) {
|
|
386
|
+
await sleep(pollingIntervalMs);
|
|
387
|
+
continue;
|
|
388
|
+
}
|
|
389
|
+
const decoded = decodeComputationAccount(maybeAccount);
|
|
390
|
+
if (queuedSlot === null) {
|
|
391
|
+
queuedSlot = decoded.data.slot;
|
|
392
|
+
}
|
|
393
|
+
if (!receivedFirstDecode) {
|
|
394
|
+
receivedFirstDecode = true;
|
|
395
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
396
|
+
return buildFinalizedResult(
|
|
397
|
+
rpc,
|
|
398
|
+
computationAddress,
|
|
399
|
+
startTime,
|
|
400
|
+
queuedSlot,
|
|
401
|
+
shouldRetrieveSignature,
|
|
402
|
+
onProgress
|
|
403
|
+
);
|
|
404
|
+
}
|
|
405
|
+
await sleep(pollingIntervalMs);
|
|
406
|
+
continue;
|
|
407
|
+
}
|
|
408
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
409
|
+
return buildFinalizedResult(
|
|
410
|
+
rpc,
|
|
411
|
+
computationAddress,
|
|
412
|
+
startTime,
|
|
413
|
+
queuedSlot,
|
|
414
|
+
shouldRetrieveSignature,
|
|
415
|
+
onProgress
|
|
416
|
+
);
|
|
417
|
+
}
|
|
418
|
+
if (isSlotWindowExceeded(queuedSlot, currentSlot, maxSlotWindow)) {
|
|
419
|
+
return buildPrunedResult(startTime, queuedSlot, currentSlot, onProgress);
|
|
420
|
+
}
|
|
421
|
+
} catch (error) {
|
|
422
|
+
if (error instanceof ComputationMonitorError) {
|
|
423
|
+
throw error;
|
|
424
|
+
}
|
|
345
425
|
}
|
|
426
|
+
await sleep(pollingIntervalMs);
|
|
346
427
|
}
|
|
347
|
-
|
|
428
|
+
return buildTimedOutResult(startTime);
|
|
348
429
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
`Safety timeout: computation monitoring exceeded ${String(safetyTimeoutMs)}ms`
|
|
352
|
-
);
|
|
430
|
+
__name(awaitComputation, "awaitComputation");
|
|
431
|
+
return { awaitComputation, cleanup };
|
|
353
432
|
}
|
|
354
|
-
__name(
|
|
355
|
-
return {
|
|
356
|
-
awaitComputation: monitorComputation
|
|
357
|
-
};
|
|
433
|
+
__name(prepareMonitor, "prepareMonitor");
|
|
434
|
+
return { prepareMonitor };
|
|
358
435
|
}
|
|
359
436
|
__name(getPollingComputationMonitor, "getPollingComputationMonitor");
|
|
360
|
-
var DEFAULT_UTXO_LIMIT = 1000n;
|
|
361
|
-
var MAX_UTXO_LIMIT = 5000n;
|
|
362
|
-
var IndexerError = class _IndexerError extends Error {
|
|
363
|
-
static {
|
|
364
|
-
__name(this, "IndexerError");
|
|
365
|
-
}
|
|
366
|
-
/**
|
|
367
|
-
* The indexer operation that failed.
|
|
368
|
-
*
|
|
369
|
-
* @remarks
|
|
370
|
-
* This is a short camelCase label identifying which high-level operation
|
|
371
|
-
* triggered the error (e.g. `"fetchMerkleProof"`, `"fetchUtxoData"`,
|
|
372
|
-
* `"base64Conversion"`).
|
|
373
|
-
*
|
|
374
|
-
* @readonly
|
|
375
|
-
*/
|
|
376
|
-
operation;
|
|
377
|
-
/**
|
|
378
|
-
* HTTP status code if available.
|
|
379
|
-
*
|
|
380
|
-
* @remarks
|
|
381
|
-
* Present when the server responded with an HTTP error (4xx or 5xx).
|
|
382
|
-
* `undefined` for transport-level failures such as network timeouts or
|
|
383
|
-
* DNS resolution failures.
|
|
384
|
-
*
|
|
385
|
-
* @readonly
|
|
386
|
-
*/
|
|
387
|
-
statusCode;
|
|
388
|
-
/**
|
|
389
|
-
* Creates a new IndexerError.
|
|
390
|
-
*
|
|
391
|
-
* @param operation - The operation that failed (e.g. `"fetchMerkleProof"`)
|
|
392
|
-
* @param message - Descriptive error message for display to users or logs
|
|
393
|
-
* @param statusCode - Optional HTTP status code (undefined for network failures)
|
|
394
|
-
* @param cause - Optional underlying error that triggered this one
|
|
395
|
-
*/
|
|
396
|
-
constructor(operation, message, statusCode, cause) {
|
|
397
|
-
super(`Indexer operation '${operation}' failed: ${message}`);
|
|
398
|
-
this.name = "IndexerError";
|
|
399
|
-
this.operation = operation;
|
|
400
|
-
this.statusCode = statusCode;
|
|
401
|
-
this.cause = cause;
|
|
402
|
-
if (Error.captureStackTrace !== void 0) {
|
|
403
|
-
Error.captureStackTrace(this, _IndexerError);
|
|
404
|
-
}
|
|
405
|
-
}
|
|
406
|
-
};
|
|
407
|
-
function base64ToBytes(base64) {
|
|
408
|
-
if (typeof Buffer !== "undefined") {
|
|
409
|
-
return Buffer.from(base64, "base64");
|
|
410
|
-
}
|
|
411
|
-
const binaryString = atob(base64);
|
|
412
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
413
|
-
for (let index = 0; index < binaryString.length; index++) {
|
|
414
|
-
bytes[index] = binaryString.codePointAt(index) ?? 0;
|
|
415
|
-
}
|
|
416
|
-
return bytes;
|
|
417
|
-
}
|
|
418
|
-
__name(base64ToBytes, "base64ToBytes");
|
|
419
|
-
function base64ToU256LeBytes(base64) {
|
|
420
|
-
const bytes = base64ToBytes(base64);
|
|
421
|
-
if (bytes.length !== 32) {
|
|
422
|
-
throw new IndexerError(
|
|
423
|
-
"base64Conversion",
|
|
424
|
-
`Invalid byte length: expected 32 bytes, got ${String(bytes.length)}`
|
|
425
|
-
);
|
|
426
|
-
}
|
|
427
|
-
assertU256LeBytes(bytes);
|
|
428
|
-
return bytes;
|
|
429
|
-
}
|
|
430
|
-
__name(base64ToU256LeBytes, "base64ToU256LeBytes");
|
|
431
|
-
function base64ToX25519PublicKey(base64) {
|
|
432
|
-
const bytes = base64ToBytes(base64);
|
|
433
|
-
if (bytes.length !== 32) {
|
|
434
|
-
throw new IndexerError(
|
|
435
|
-
"base64Conversion",
|
|
436
|
-
`Invalid X25519 public key length: expected 32 bytes, got ${String(bytes.length)}`
|
|
437
|
-
);
|
|
438
|
-
}
|
|
439
|
-
return bytes;
|
|
440
|
-
}
|
|
441
|
-
__name(base64ToX25519PublicKey, "base64ToX25519PublicKey");
|
|
442
|
-
function base64ToAesCiphertext(base64) {
|
|
443
|
-
return base64ToBytes(base64);
|
|
444
|
-
}
|
|
445
|
-
__name(base64ToAesCiphertext, "base64ToAesCiphertext");
|
|
446
|
-
function splitAddressBase64(base64) {
|
|
447
|
-
const bytes = base64ToBytes(base64);
|
|
448
|
-
if (bytes.length !== 32) {
|
|
449
|
-
throw new IndexerError(
|
|
450
|
-
"addressSplit",
|
|
451
|
-
`Invalid address length: expected 32 bytes, got ${String(bytes.length)}`
|
|
452
|
-
);
|
|
453
|
-
}
|
|
454
|
-
const lowBytes = bytes.slice(0, 16);
|
|
455
|
-
const highBytes = bytes.slice(16, 32);
|
|
456
|
-
assertU128LeBytes(lowBytes);
|
|
457
|
-
assertU128LeBytes(highBytes);
|
|
458
|
-
return {
|
|
459
|
-
low: decodeU128LeBytesToU128(lowBytes),
|
|
460
|
-
high: decodeU128LeBytesToU128(highBytes)
|
|
461
|
-
};
|
|
462
|
-
}
|
|
463
|
-
__name(splitAddressBase64, "splitAddressBase64");
|
|
464
|
-
function getMerkleProofFetcher(args, deps) {
|
|
465
|
-
const { apiEndpoint } = args;
|
|
466
|
-
const client = new ReadServiceClient({ endpoint: apiEndpoint, fetch: deps?.fetch });
|
|
467
|
-
return /* @__PURE__ */ __name(async function fetchMerkleProof(treeIndex, insertionIndices) {
|
|
468
|
-
if (insertionIndices.length === 0) {
|
|
469
|
-
return /* @__PURE__ */ new Map();
|
|
470
|
-
}
|
|
471
|
-
if (treeIndex < 0n) {
|
|
472
|
-
throw new IndexerError(
|
|
473
|
-
"fetchMerkleProof",
|
|
474
|
-
`Invalid tree index: ${String(treeIndex)}. Must be non-negative.`
|
|
475
|
-
);
|
|
476
|
-
}
|
|
477
|
-
const results = /* @__PURE__ */ new Map();
|
|
478
|
-
const fetchPromises = insertionIndices.map(async (insertionIndex) => {
|
|
479
|
-
if (insertionIndex < 0n) {
|
|
480
|
-
throw new IndexerError(
|
|
481
|
-
"fetchMerkleProof",
|
|
482
|
-
`Invalid insertion index: ${String(insertionIndex)}. Must be non-negative.`
|
|
483
|
-
);
|
|
484
|
-
}
|
|
485
|
-
let data;
|
|
486
|
-
try {
|
|
487
|
-
data = await client.getProof(treeIndex, insertionIndex);
|
|
488
|
-
} catch (error) {
|
|
489
|
-
throw new IndexerError(
|
|
490
|
-
"fetchMerkleProof",
|
|
491
|
-
`Failed to fetch proof for leaf ${String(insertionIndex)}: ${error instanceof Error ? error.message : String(error)}`,
|
|
492
|
-
void 0,
|
|
493
|
-
error instanceof Error ? error : void 0
|
|
494
|
-
);
|
|
495
|
-
}
|
|
496
|
-
const merkleRoot = base64ToU256LeBytes(data.root);
|
|
497
|
-
const merklePath = data.proof.map((hash) => base64ToU256LeBytes(hash));
|
|
498
|
-
const leaf = base64ToU256LeBytes(data.leaf);
|
|
499
|
-
return {
|
|
500
|
-
insertionIndex,
|
|
501
|
-
data: {
|
|
502
|
-
merkleRoot,
|
|
503
|
-
treeIndex: data.tree_index,
|
|
504
|
-
insertionIndex: data.insertion_index,
|
|
505
|
-
merklePath,
|
|
506
|
-
leaf
|
|
507
|
-
}
|
|
508
|
-
};
|
|
509
|
-
});
|
|
510
|
-
const proofResults = await Promise.all(fetchPromises);
|
|
511
|
-
for (const { insertionIndex, data } of proofResults) {
|
|
512
|
-
results.set(insertionIndex, data);
|
|
513
|
-
}
|
|
514
|
-
return results;
|
|
515
|
-
}, "fetchMerkleProof");
|
|
516
|
-
}
|
|
517
|
-
__name(getMerkleProofFetcher, "getMerkleProofFetcher");
|
|
518
|
-
function getBatchMerkleProofFetcher(args, deps) {
|
|
519
|
-
const { apiEndpoint } = args;
|
|
520
|
-
const client = new ReadServiceClient({ endpoint: apiEndpoint, fetch: deps?.fetch });
|
|
521
|
-
return /* @__PURE__ */ __name(async function fetchBatchMerkleProof(treeIndex, insertionIndices) {
|
|
522
|
-
if (insertionIndices.length === 0) {
|
|
523
|
-
return { root: new Uint8Array(32), proofs: /* @__PURE__ */ new Map() };
|
|
524
|
-
}
|
|
525
|
-
if (treeIndex < 0n) {
|
|
526
|
-
throw new IndexerError(
|
|
527
|
-
"fetchBatchMerkleProof",
|
|
528
|
-
`Invalid tree index: ${String(treeIndex)}. Must be non-negative.`
|
|
529
|
-
);
|
|
530
|
-
}
|
|
531
|
-
for (const idx of insertionIndices) {
|
|
532
|
-
if (idx < 0n) {
|
|
533
|
-
throw new IndexerError(
|
|
534
|
-
"fetchBatchMerkleProof",
|
|
535
|
-
`Invalid insertion index: ${String(idx)}. Must be non-negative.`
|
|
536
|
-
);
|
|
537
|
-
}
|
|
538
|
-
}
|
|
539
|
-
let data;
|
|
540
|
-
try {
|
|
541
|
-
data = await client.getBatchProof(
|
|
542
|
-
treeIndex,
|
|
543
|
-
insertionIndices.map((idx) => BigInt(idx))
|
|
544
|
-
);
|
|
545
|
-
} catch (error) {
|
|
546
|
-
throw new IndexerError(
|
|
547
|
-
"fetchBatchMerkleProof",
|
|
548
|
-
`Failed to fetch batch proofs: ${error instanceof Error ? error.message : String(error)}`,
|
|
549
|
-
void 0,
|
|
550
|
-
error instanceof Error ? error : void 0
|
|
551
|
-
);
|
|
552
|
-
}
|
|
553
|
-
const root = base64ToU256LeBytes(data.root);
|
|
554
|
-
const proofs = /* @__PURE__ */ new Map();
|
|
555
|
-
for (const entry of data.proofs) {
|
|
556
|
-
proofs.set(entry.insertion_index, {
|
|
557
|
-
merklePath: entry.proof.map((hash) => base64ToU256LeBytes(hash)),
|
|
558
|
-
leaf: base64ToU256LeBytes(entry.leaf)
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
return { root, proofs };
|
|
562
|
-
}, "fetchBatchMerkleProof");
|
|
563
|
-
}
|
|
564
|
-
__name(getBatchMerkleProofFetcher, "getBatchMerkleProofFetcher");
|
|
565
|
-
function getUtxoDataFetcher(args, deps) {
|
|
566
|
-
const { apiEndpoint } = args;
|
|
567
|
-
const client = new ReadServiceClient({ endpoint: apiEndpoint, fetch: deps?.fetch });
|
|
568
|
-
return /* @__PURE__ */ __name(async function fetchUtxoData(startIndex, endIndex, limit) {
|
|
569
|
-
if (startIndex < 0n) {
|
|
570
|
-
throw new IndexerError(
|
|
571
|
-
"fetchUtxoData",
|
|
572
|
-
`Invalid start index: ${String(startIndex)}. Must be non-negative.`
|
|
573
|
-
);
|
|
574
|
-
}
|
|
575
|
-
if (endIndex !== void 0 && endIndex < startIndex) {
|
|
576
|
-
throw new IndexerError(
|
|
577
|
-
"fetchUtxoData",
|
|
578
|
-
`Invalid end index: ${String(endIndex)}. Must be >= start index (${String(startIndex)}).`
|
|
579
|
-
);
|
|
580
|
-
}
|
|
581
|
-
const effectiveLimit = limit ?? DEFAULT_UTXO_LIMIT;
|
|
582
|
-
if (effectiveLimit < 1n || effectiveLimit > MAX_UTXO_LIMIT) {
|
|
583
|
-
throw new IndexerError(
|
|
584
|
-
"fetchUtxoData",
|
|
585
|
-
`Invalid limit: ${String(effectiveLimit)}. Must be between 1 and ${String(MAX_UTXO_LIMIT)}.`
|
|
586
|
-
);
|
|
587
|
-
}
|
|
588
|
-
let response;
|
|
589
|
-
try {
|
|
590
|
-
response = await client.getUtxoData({
|
|
591
|
-
start: startIndex,
|
|
592
|
-
end: endIndex,
|
|
593
|
-
limit: effectiveLimit
|
|
594
|
-
});
|
|
595
|
-
} catch (error) {
|
|
596
|
-
throw new IndexerError(
|
|
597
|
-
"fetchUtxoData",
|
|
598
|
-
`Network error: ${error instanceof Error ? error.message : String(error)}`,
|
|
599
|
-
void 0,
|
|
600
|
-
error instanceof Error ? error : void 0
|
|
601
|
-
);
|
|
602
|
-
}
|
|
603
|
-
const items = /* @__PURE__ */ new Map();
|
|
604
|
-
for (const item of response.items) {
|
|
605
|
-
try {
|
|
606
|
-
const senderAddress = splitAddressBase64(item.h1_sender_address);
|
|
607
|
-
const mintAddress = splitAddressBase64(item.h1_mint_address);
|
|
608
|
-
const timestamp = {
|
|
609
|
-
year: item.h1_year,
|
|
610
|
-
month: item.h1_month,
|
|
611
|
-
day: item.h1_day,
|
|
612
|
-
hour: item.h1_hour,
|
|
613
|
-
minute: item.h1_minute,
|
|
614
|
-
second: item.h1_second
|
|
615
|
-
};
|
|
616
|
-
const h1Components = {
|
|
617
|
-
version: BigInt(item.h1_version),
|
|
618
|
-
commitmentIndex: BigInt(item.h1_commitment_index),
|
|
619
|
-
senderAddressLow: senderAddress.low,
|
|
620
|
-
senderAddressHigh: senderAddress.high,
|
|
621
|
-
relayerFixedSolFees: item.h1_relayer_fixed_sol_fees,
|
|
622
|
-
mintAddressLow: mintAddress.low,
|
|
623
|
-
mintAddressHigh: mintAddress.high,
|
|
624
|
-
timestamp,
|
|
625
|
-
poolVolumeSpl: item.h1_pool_volume_spl,
|
|
626
|
-
poolVolumeSol: item.h1_pool_volume_sol
|
|
627
|
-
};
|
|
628
|
-
const utxoItem = {
|
|
629
|
-
absoluteIndex: item.absolute_index,
|
|
630
|
-
treeIndex: item.tree_index,
|
|
631
|
-
insertionIndex: item.insertion_index,
|
|
632
|
-
finalCommitment: base64ToU256LeBytes(item.final_commitment),
|
|
633
|
-
h1Components,
|
|
634
|
-
h1Hash: base64ToU256LeBytes(item.h1_hash),
|
|
635
|
-
h2Hash: base64ToU256LeBytes(item.h2_hash),
|
|
636
|
-
aesEncryptedData: base64ToAesCiphertext(item.aes_encrypted_data),
|
|
637
|
-
depositorX25519PublicKey: base64ToX25519PublicKey(item.depositor_x25519_public_key),
|
|
638
|
-
timestamp: item.timestamp,
|
|
639
|
-
slot: item.slot,
|
|
640
|
-
eventType: item.event_type
|
|
641
|
-
};
|
|
642
|
-
items.set(item.insertion_index, utxoItem);
|
|
643
|
-
} catch (error) {
|
|
644
|
-
throw new IndexerError(
|
|
645
|
-
"fetchUtxoData",
|
|
646
|
-
`Failed to parse UTXO data for index ${String(item.absolute_index)}: ${error instanceof Error ? error.message : String(error)}`,
|
|
647
|
-
void 0,
|
|
648
|
-
error instanceof Error ? error : void 0
|
|
649
|
-
);
|
|
650
|
-
}
|
|
651
|
-
}
|
|
652
|
-
return {
|
|
653
|
-
items,
|
|
654
|
-
hasMore: response.has_more,
|
|
655
|
-
nextCursor: response.next_cursor ?? void 0,
|
|
656
|
-
totalCount: response.total_count
|
|
657
|
-
};
|
|
658
|
-
}, "fetchUtxoData");
|
|
659
|
-
}
|
|
660
|
-
__name(getUtxoDataFetcher, "getUtxoDataFetcher");
|
|
661
437
|
|
|
662
438
|
// src/umbra/client.ts
|
|
663
439
|
var notImplementedGenerator = /* @__PURE__ */ __name(async () => {
|
|
@@ -701,15 +477,15 @@ async function getUmbraClient(args, deps) {
|
|
|
701
477
|
rpcUrl,
|
|
702
478
|
rpcSubscriptionsUrl
|
|
703
479
|
});
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
apiEndpoint: indexerApiEndpoint
|
|
712
|
-
}
|
|
480
|
+
let fetchMerkleProof;
|
|
481
|
+
let fetchBatchMerkleProof;
|
|
482
|
+
let fetchUtxoData;
|
|
483
|
+
if (indexerApiEndpoint !== void 0 && indexerApiEndpoint !== "") {
|
|
484
|
+
const { getMerkleProofFetcher, getBatchMerkleProofFetcher, getUtxoDataFetcher } = await import('./indexer-NHZDFABY.js');
|
|
485
|
+
fetchMerkleProof = getMerkleProofFetcher({ apiEndpoint: indexerApiEndpoint });
|
|
486
|
+
fetchBatchMerkleProof = getBatchMerkleProofFetcher({ apiEndpoint: indexerApiEndpoint });
|
|
487
|
+
fetchUtxoData = getUtxoDataFetcher({ apiEndpoint: indexerApiEndpoint });
|
|
488
|
+
}
|
|
713
489
|
const defaultMasterSeedStorage = getDefaultMasterSeedStorage();
|
|
714
490
|
const defaultMasterSeedGenerator = getDefaultMasterSeedGenerator(signer);
|
|
715
491
|
const masterSeedLoad = deps?.masterSeedStorage?.load ?? defaultMasterSeedStorage.load;
|
|
@@ -806,54 +582,6 @@ async function getUmbraClient(args, deps) {
|
|
|
806
582
|
}
|
|
807
583
|
__name(getUmbraClient, "getUmbraClient");
|
|
808
584
|
|
|
809
|
-
// src/umbra/constants.ts
|
|
810
|
-
var UMBRA_MESSAGE_TO_SIGN = `Umbra Protocol – User Consent & Acknowledgement
|
|
811
|
-
|
|
812
|
-
Please read carefully before continuing. Umbra is a non-custodial, open-source protocol. Umbra does not hold, control, manage, or access your digital assets, private keys, viewing keys, transactions, or personal data. All interactions with the Umbra protocol occur through autonomous smart contracts and wallet-signed transactions executed directly on the blockchain.
|
|
813
|
-
|
|
814
|
-
By using the Umbra protocol, you acknowledge and agree that:
|
|
815
|
-
|
|
816
|
-
1. You are solely responsible for managing your wallet, private keys, privacy settings, viewing key disclosures, and any transactions or interactions you authorize.
|
|
817
|
-
2. Blockchain transactions are generally irreversible, and smart contracts may contain bugs, vulnerabilities, or unintended behavior.
|
|
818
|
-
3. Errors, misuse, misconfiguration, third-party tools, relayers, or loss of keys may result in permanent and unrecoverable loss of assets or privacy.
|
|
819
|
-
4. Privacy features are designed to enhance confidentiality but do not guarantee absolute or unconditional anonymity.
|
|
820
|
-
5. Transactions may involve independent relayers or third-party infrastructure that Umbra does not operate, control, or supervise.
|
|
821
|
-
6. By clicking "I Agree", you confirm that you have read, understood, and accepted all applicable terms, policies, risk disclosures, notices, and other documentation governing your access to and use of the Umbra protocol, as published or made available by Umbra from time to time.
|
|
822
|
-
|
|
823
|
-
You acknowledge that such documentation may be updated or modified, and that continued access to or use of the Umbra Protocol constitutes acceptance of the then-current versions. If you do not agree, do not proceed and discontinue use of the Umbra protocol.`;
|
|
824
|
-
var FEE_OFFSETS = {
|
|
825
|
-
/**
|
|
826
|
-
* Offset used in `FeeVault` PDA derivation for the unified protocol fees pool.
|
|
827
|
-
*
|
|
828
|
-
* @remarks
|
|
829
|
-
* Passed as the final seed to `findProtocolFeeVaultPda` and
|
|
830
|
-
* `findRelayerFeeVaultPda`. Currently `0n`.
|
|
831
|
-
*
|
|
832
|
-
* @readonly
|
|
833
|
-
*/
|
|
834
|
-
PROTOCOL_FEES_POOL: 0n,
|
|
835
|
-
/**
|
|
836
|
-
* Offset used in `FeeSchedule` PDA derivation.
|
|
837
|
-
*
|
|
838
|
-
* @remarks
|
|
839
|
-
* Passed as the final seed to `findFeeSchedulePda`. Currently `0n`.
|
|
840
|
-
*
|
|
841
|
-
* @readonly
|
|
842
|
-
*/
|
|
843
|
-
PROTOCOL_FEES_CONFIG: 0n,
|
|
844
|
-
/**
|
|
845
|
-
* Offset used in relayer fee configuration PDA derivation.
|
|
846
|
-
*
|
|
847
|
-
* @remarks
|
|
848
|
-
* Passed as the offset seed when looking up the relayer's fee configuration account.
|
|
849
|
-
* Currently `0n`.
|
|
850
|
-
*
|
|
851
|
-
* @readonly
|
|
852
|
-
*/
|
|
853
|
-
RELAYER_FEES_CONFIG: 0n
|
|
854
|
-
};
|
|
855
|
-
var BPS_DIVISOR = 16384n;
|
|
856
|
-
|
|
857
585
|
// src/umbra/fee-provider.ts
|
|
858
586
|
var TREE_DEPTH = 4;
|
|
859
587
|
var MAX_LEAVES = 1 << TREE_DEPTH;
|
|
@@ -5849,71 +5577,85 @@ async function signTransactionMessage(signer, transactionMessage) {
|
|
|
5849
5577
|
__name(signTransactionMessage, "signTransactionMessage");
|
|
5850
5578
|
async function forwardAndMonitor(config, signedTransaction, callbacks, awaitCallback) {
|
|
5851
5579
|
const { transactionForwarder, computationMonitor } = config;
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5580
|
+
const txSignature = getSignatureFromTransaction(
|
|
5581
|
+
signedTransaction
|
|
5582
|
+
);
|
|
5583
|
+
let prepared;
|
|
5584
|
+
if (awaitCallback !== void 0) {
|
|
5585
|
+
if (computationMonitor === void 0) {
|
|
5586
|
+
throw new Error(
|
|
5587
|
+
"awaitCallback was provided but no computationMonitor is configured on the client. Pass a computationMonitor when creating the Umbra client, or omit awaitCallback to use fire-and-forget mode."
|
|
5588
|
+
);
|
|
5589
|
+
}
|
|
5590
|
+
const baseMonitorOptions = {
|
|
5591
|
+
maxSlotWindow: awaitCallback.maxSlotWindow,
|
|
5592
|
+
safetyTimeoutMs: awaitCallback.safetyTimeoutMs,
|
|
5593
|
+
onProgress: awaitCallback.onProgress,
|
|
5594
|
+
commitment: awaitCallback.computationMonitorCommitment ?? "confirmed",
|
|
5595
|
+
retrieveCallbackSignature: awaitCallback.retrieveCallbackSignature ?? false
|
|
5596
|
+
};
|
|
5597
|
+
prepared = await computationMonitor.prepareMonitor(
|
|
5598
|
+
awaitCallback.computationAccountAddress,
|
|
5599
|
+
baseMonitorOptions
|
|
5866
5600
|
);
|
|
5867
5601
|
}
|
|
5868
|
-
|
|
5869
|
-
|
|
5870
|
-
|
|
5871
|
-
|
|
5872
|
-
|
|
5873
|
-
|
|
5874
|
-
|
|
5875
|
-
|
|
5876
|
-
|
|
5877
|
-
|
|
5878
|
-
|
|
5879
|
-
|
|
5880
|
-
|
|
5881
|
-
|
|
5882
|
-
|
|
5883
|
-
|
|
5884
|
-
|
|
5885
|
-
|
|
5886
|
-
|
|
5887
|
-
|
|
5888
|
-
|
|
5889
|
-
|
|
5890
|
-
|
|
5891
|
-
|
|
5892
|
-
|
|
5893
|
-
|
|
5894
|
-
|
|
5895
|
-
|
|
5896
|
-
|
|
5897
|
-
|
|
5898
|
-
|
|
5899
|
-
|
|
5900
|
-
|
|
5901
|
-
|
|
5902
|
-
)
|
|
5903
|
-
|
|
5904
|
-
|
|
5905
|
-
} catch (error) {
|
|
5906
|
-
rentClaimError = error instanceof Error ? error.message : String(error);
|
|
5602
|
+
try {
|
|
5603
|
+
if (callbacks?.pre !== void 0) {
|
|
5604
|
+
await callbacks.pre(signedTransaction);
|
|
5605
|
+
}
|
|
5606
|
+
await transactionForwarder.forwardSequentially([signedTransaction]);
|
|
5607
|
+
if (callbacks?.post !== void 0) {
|
|
5608
|
+
await callbacks.post(signedTransaction, txSignature);
|
|
5609
|
+
}
|
|
5610
|
+
if (prepared === void 0 || awaitCallback === void 0) {
|
|
5611
|
+
return { signature: txSignature, signedTransaction };
|
|
5612
|
+
}
|
|
5613
|
+
const callbackResult = await prepared.awaitComputation();
|
|
5614
|
+
let rentClaimSignature;
|
|
5615
|
+
let rentClaimError;
|
|
5616
|
+
if (awaitCallback.reclaimComputationRent !== false) {
|
|
5617
|
+
if (awaitCallback.computationOffset === void 0 || awaitCallback.clusterOffset === void 0) {
|
|
5618
|
+
rentClaimError = "Rent reclaim skipped: computationOffset or clusterOffset was not provided by the service";
|
|
5619
|
+
} else {
|
|
5620
|
+
try {
|
|
5621
|
+
const noopSigner = createNoopSigner(config.signer.address);
|
|
5622
|
+
const rentClaimIx = getClaimComputationRentInstruction({
|
|
5623
|
+
signer: noopSigner,
|
|
5624
|
+
comp: awaitCallback.computationAccountAddress,
|
|
5625
|
+
compOffset: awaitCallback.computationOffset,
|
|
5626
|
+
clusterOffset: awaitCallback.clusterOffset
|
|
5627
|
+
});
|
|
5628
|
+
const rentClaimBlockhash = await config.getLatestBlockhash({
|
|
5629
|
+
commitment: awaitCallback.rentReclaimBlockhashCommitment ?? "confirmed"
|
|
5630
|
+
});
|
|
5631
|
+
const rentClaimTxMsg = buildTransactionMessage(config.signer, rentClaimBlockhash, [
|
|
5632
|
+
rentClaimIx
|
|
5633
|
+
]);
|
|
5634
|
+
const rentClaimTx = await signTransactionMessage(config.signer, rentClaimTxMsg);
|
|
5635
|
+
rentClaimSignature = await config.transactionForwarder.fireAndForget(rentClaimTx);
|
|
5636
|
+
} catch (error) {
|
|
5637
|
+
rentClaimError = error instanceof Error ? error.message : String(error);
|
|
5638
|
+
}
|
|
5907
5639
|
}
|
|
5908
5640
|
}
|
|
5641
|
+
return {
|
|
5642
|
+
signature: txSignature,
|
|
5643
|
+
signedTransaction,
|
|
5644
|
+
callbackResult,
|
|
5645
|
+
rentClaimSignature,
|
|
5646
|
+
rentClaimError
|
|
5647
|
+
};
|
|
5648
|
+
} finally {
|
|
5649
|
+
prepared?.cleanup();
|
|
5909
5650
|
}
|
|
5910
|
-
return { signature: txSignature, signedTransaction, callbackResult, rentClaimSignature, rentClaimError };
|
|
5911
5651
|
}
|
|
5912
5652
|
__name(forwardAndMonitor, "forwardAndMonitor");
|
|
5913
5653
|
async function executeComputationTransaction(config, options, awaitCallback) {
|
|
5914
5654
|
const { signer, getLatestBlockhash } = config;
|
|
5915
5655
|
const { instruction, preInstructions, altEntry, callbacks, blockhashCommitment } = options;
|
|
5916
|
-
const latestBlockhash = await getLatestBlockhash({
|
|
5656
|
+
const latestBlockhash = await getLatestBlockhash({
|
|
5657
|
+
commitment: blockhashCommitment ?? "confirmed"
|
|
5658
|
+
});
|
|
5917
5659
|
const allInstructions = preInstructions === void 0 ? [instruction] : [...preInstructions, instruction];
|
|
5918
5660
|
const transactionMessage = buildTransactionMessage(
|
|
5919
5661
|
signer,
|
|
@@ -5970,6 +5712,7 @@ function getPublicBalanceToEncryptedBalanceDirectDepositorFunction(args, deps) {
|
|
|
5970
5712
|
if ("callbackResult" in result) {
|
|
5971
5713
|
return {
|
|
5972
5714
|
queueSignature: result.signature,
|
|
5715
|
+
callbackStatus: result.callbackResult.status,
|
|
5973
5716
|
callbackSignature: "callbackSignature" in result.callbackResult ? result.callbackResult.callbackSignature : void 0,
|
|
5974
5717
|
callbackElapsedMs: result.callbackResult.elapsedMs,
|
|
5975
5718
|
rentClaimSignature: result.rentClaimSignature,
|
|
@@ -7101,6 +6844,7 @@ function getEncryptedBalanceToSelfClaimableUtxoCreatorFunction(args, deps) {
|
|
|
7101
6844
|
return {
|
|
7102
6845
|
signedTransaction: result2.signedTransaction,
|
|
7103
6846
|
signature: result2.signature,
|
|
6847
|
+
callbackStatus: callbackResult?.status,
|
|
7104
6848
|
callbackSignature,
|
|
7105
6849
|
callbackElapsedMs: callbackResult?.elapsedMs,
|
|
7106
6850
|
rentClaimSignature,
|
|
@@ -7279,6 +7023,7 @@ function getEncryptedBalanceToSelfClaimableUtxoCreatorFunction(args, deps) {
|
|
|
7279
7023
|
closeProofAccountSignature: closeResult?.signature,
|
|
7280
7024
|
createProofAccountSignature: proofAccountResult.signature,
|
|
7281
7025
|
queueSignature: utxoResult.signature,
|
|
7026
|
+
callbackStatus: utxoResult.callbackStatus,
|
|
7282
7027
|
callbackSignature: utxoResult.callbackSignature,
|
|
7283
7028
|
callbackElapsedMs: utxoResult.callbackElapsedMs,
|
|
7284
7029
|
rentClaimSignature: utxoResult.rentClaimSignature,
|
|
@@ -8091,6 +7836,7 @@ function getEncryptedBalanceToReceiverClaimableUtxoCreatorFunction(args, deps) {
|
|
|
8091
7836
|
return {
|
|
8092
7837
|
signedTransaction: result2.signedTransaction,
|
|
8093
7838
|
signature: result2.signature,
|
|
7839
|
+
callbackStatus: callbackResult?.status,
|
|
8094
7840
|
callbackSignature,
|
|
8095
7841
|
callbackElapsedMs: callbackResult?.elapsedMs,
|
|
8096
7842
|
rentClaimSignature,
|
|
@@ -8265,6 +8011,7 @@ function getEncryptedBalanceToReceiverClaimableUtxoCreatorFunction(args, deps) {
|
|
|
8265
8011
|
closeProofAccountSignature: closeResult?.signature,
|
|
8266
8012
|
createProofAccountSignature: proofAccountResult.signature,
|
|
8267
8013
|
queueSignature: utxoResult.signature,
|
|
8014
|
+
callbackStatus: utxoResult.callbackStatus,
|
|
8268
8015
|
callbackSignature: utxoResult.callbackSignature,
|
|
8269
8016
|
callbackElapsedMs: utxoResult.callbackElapsedMs,
|
|
8270
8017
|
rentClaimSignature: utxoResult.rentClaimSignature,
|
|
@@ -10483,6 +10230,7 @@ function getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction(args, deps)
|
|
|
10483
10230
|
if ("callbackResult" in result) {
|
|
10484
10231
|
return {
|
|
10485
10232
|
queueSignature: result.signature,
|
|
10233
|
+
callbackStatus: result.callbackResult.status,
|
|
10486
10234
|
callbackSignature: "callbackSignature" in result.callbackResult ? result.callbackResult.callbackSignature : void 0,
|
|
10487
10235
|
callbackElapsedMs: result.callbackResult.elapsedMs,
|
|
10488
10236
|
rentClaimSignature: result.rentClaimSignature,
|
|
@@ -10643,6 +10391,6 @@ function getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction(args, deps)
|
|
|
10643
10391
|
}
|
|
10644
10392
|
__name(getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction, "getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction");
|
|
10645
10393
|
|
|
10646
|
-
export { BPS_DIVISOR, DEFAULT_MAX_SLOT_WINDOW, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_SAFETY_TIMEOUT_MS, DEFAULT_SIGNATURE_RETRIEVAL_LIMIT, FEE_OFFSETS,
|
|
10394
|
+
export { BPS_DIVISOR, DEFAULT_MAX_SLOT_WINDOW, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_SAFETY_TIMEOUT_MS, DEFAULT_SIGNATURE_RETRIEVAL_LIMIT, FEE_OFFSETS, UMBRA_MESSAGE_TO_SIGN, buildTransactionMessage, calculateFee, enrichWithMerkleProof, executeComputationTransaction, extractMerklePath, extractSignatures, feeSlabResultToInstructionFields, forwardAndMonitor, getClaimableUtxoScannerFunction, getComplianceGrantIssuerFunction, getComplianceGrantRevokerFunction, getDefaultKeyLoader, getDefaultKeyStorer, getDefaultMasterSeedGenerator, getDefaultMasterSeedStorage, getEncryptedBalanceQuerierFunction, getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction, getEncryptedBalanceToReceiverClaimableUtxoCreatorFunction, getEncryptedBalanceToSelfClaimableUtxoCreatorFunction, getHardcodedClaimUtxoProtocolFeeProvider, getHardcodedClaimUtxoRelayerFeeProvider, getHardcodedCreateUtxoProtocolFeeProvider, getHardcodedDepositProtocolFeeProvider, getHardcodedWithdrawalProtocolFeeProvider, getMasterViewingKeyRotatorFunction, getMintEncryptionKeyRotatorFunction, getNetworkCiphertextReencryptorForNetworkGrantFunction, getNetworkComplianceGrantQuerierFunction, getNetworkEncryptionToSharedEncryptionConverterFunction, getPollingComputationMonitor, getPublicBalanceToEncryptedBalanceDirectDepositorFunction, getPublicBalanceToReceiverClaimableUtxoCreatorFunction, getPublicBalanceToSelfClaimableUtxoCreatorFunction, getReceiverClaimableUtxoToEncryptedBalanceClaimerFunction, getSelfClaimableUtxoToEncryptedBalanceClaimerFunction, getSelfClaimableUtxoToPublicBalanceClaimerFunction, getSharedCiphertextReencryptorForNetworkGrantFunction, getSharedCiphertextReencryptorForUserGrantFunction, getSharedComplianceGrantQuerierFunction, getStagedSolRecovererFunction, getStagedSplRecovererFunction, getTokenEntropySeedRotatorFunction, getUmbraClient, getUserAccountQuerierFunction, getUserComplianceGrantQuerierFunction, getUserEncryptionKeyRotatorFunction, getUserEntropySeedRotatorFunction, getUserRegistrationFunction, getWebsocketComputationMonitor, leafIndexToPathIndices, protocolFeeSlabResultToInstructionFields, relayerFeeSlabResultToInstructionFields, signTransactionMessage };
|
|
10647
10395
|
//# sourceMappingURL=index.js.map
|
|
10648
10396
|
//# sourceMappingURL=index.js.map
|