@umbra-privacy/sdk 2.1.1 → 4.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 +817 -1072
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +25 -276
- package/dist/index.d.ts +25 -276
- package/dist/index.js +322 -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 +3 -3
- 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,83 @@
|
|
|
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 = `
|
|
33
|
+
Umbra Protocol – User Consent & Acknowledgement
|
|
34
|
+
|
|
35
|
+
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.
|
|
36
|
+
|
|
37
|
+
By using the Umbra protocol, you acknowledge and agree that:
|
|
38
|
+
|
|
39
|
+
1. You are solely responsible for managing your wallet, private keys, privacy settings, viewing key disclosures, and any transactions or interactions you authorize.
|
|
40
|
+
2.Blockchain transactions are generally irreversible, and smart contracts may contain bugs, vulnerabilities, or unintended behavior.
|
|
41
|
+
3. Errors, misuse, misconfiguration, third-party tools, relayers, or loss of keys may result in permanent and unrecoverable loss of assets or privacy.
|
|
42
|
+
4. Privacy features are designed to enhance confidentiality but do not guarantee absolute or unconditional anonymity.
|
|
43
|
+
5. Transactions may involve independent relayers or third-party infrastructure that Umbra does not operate, control, or supervise.
|
|
44
|
+
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.
|
|
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
|
+
`;
|
|
47
|
+
var FEE_OFFSETS = {
|
|
48
|
+
/**
|
|
49
|
+
* Offset used in `FeeVault` PDA derivation for the unified protocol fees pool.
|
|
50
|
+
*
|
|
51
|
+
* @remarks
|
|
52
|
+
* Passed as the final seed to `findProtocolFeeVaultPda` and
|
|
53
|
+
* `findRelayerFeeVaultPda`. Currently `0n`.
|
|
54
|
+
*
|
|
55
|
+
* @readonly
|
|
56
|
+
*/
|
|
57
|
+
PROTOCOL_FEES_POOL: 0n,
|
|
58
|
+
/**
|
|
59
|
+
* Offset used in `FeeSchedule` PDA derivation.
|
|
60
|
+
*
|
|
61
|
+
* @remarks
|
|
62
|
+
* Passed as the final seed to `findFeeSchedulePda`. Currently `0n`.
|
|
63
|
+
*
|
|
64
|
+
* @readonly
|
|
65
|
+
*/
|
|
66
|
+
PROTOCOL_FEES_CONFIG: 0n,
|
|
67
|
+
/**
|
|
68
|
+
* Offset used in relayer fee configuration PDA derivation.
|
|
69
|
+
*
|
|
70
|
+
* @remarks
|
|
71
|
+
* Passed as the offset seed when looking up the relayer's fee configuration account.
|
|
72
|
+
* Currently `0n`.
|
|
73
|
+
*
|
|
74
|
+
* @readonly
|
|
75
|
+
*/
|
|
76
|
+
RELAYER_FEES_CONFIG: 0n
|
|
77
|
+
};
|
|
78
|
+
var BPS_DIVISOR = 16384n;
|
|
79
|
+
|
|
80
|
+
// src/common/storage.ts
|
|
32
81
|
function getDefaultMasterSeedStorage() {
|
|
33
82
|
let cachedSeed = null;
|
|
34
83
|
return {
|
|
@@ -49,8 +98,7 @@ var MASTER_SEED_DOMAIN = new TextEncoder().encode("Umbra Privacy - MasterSeedGen
|
|
|
49
98
|
var SEED_PERSONALIZATION = new TextEncoder().encode("umbra/1.0.0|kmac256/1.0.0|kdf/1.0.0|seed");
|
|
50
99
|
function getDefaultMasterSeedGenerator(signer) {
|
|
51
100
|
return async () => {
|
|
52
|
-
const
|
|
53
|
-
const messageBytes = new TextEncoder().encode(message);
|
|
101
|
+
const messageBytes = new TextEncoder().encode(UMBRA_MESSAGE_TO_SIGN);
|
|
54
102
|
const signature = await signer.signMessage(messageBytes);
|
|
55
103
|
const seed = kmac256(
|
|
56
104
|
MASTER_SEED_DOMAIN,
|
|
@@ -96,7 +144,10 @@ function notificationValueToEncodedAccount(address, value) {
|
|
|
96
144
|
__name(notificationValueToEncodedAccount, "notificationValueToEncodedAccount");
|
|
97
145
|
function checkAborted(signal) {
|
|
98
146
|
if (signal?.aborted) {
|
|
99
|
-
throw new ComputationMonitorError(
|
|
147
|
+
throw new ComputationMonitorError(
|
|
148
|
+
"timeout",
|
|
149
|
+
"Computation monitoring cancelled via AbortSignal"
|
|
150
|
+
);
|
|
100
151
|
}
|
|
101
152
|
}
|
|
102
153
|
__name(checkAborted, "checkAborted");
|
|
@@ -158,6 +209,13 @@ function buildPrunedResult(startTime, queuedSlot, currentSlot, onProgress) {
|
|
|
158
209
|
};
|
|
159
210
|
}
|
|
160
211
|
__name(buildPrunedResult, "buildPrunedResult");
|
|
212
|
+
function buildTimedOutResult(startTime) {
|
|
213
|
+
return {
|
|
214
|
+
status: "timed-out",
|
|
215
|
+
elapsedMs: Date.now() - startTime
|
|
216
|
+
};
|
|
217
|
+
}
|
|
218
|
+
__name(buildTimedOutResult, "buildTimedOutResult");
|
|
161
219
|
function getWebsocketComputationMonitor(config, deps) {
|
|
162
220
|
const { rpcUrl, rpcSubscriptionsUrl } = config;
|
|
163
221
|
const {
|
|
@@ -166,7 +224,7 @@ function getWebsocketComputationMonitor(config, deps) {
|
|
|
166
224
|
} = deps ?? {};
|
|
167
225
|
const rpc = createRpc(rpcUrl);
|
|
168
226
|
const rpcSubscriptions = createRpcSubscriptions(rpcSubscriptionsUrl);
|
|
169
|
-
async function
|
|
227
|
+
async function prepareMonitor(computationAddress, options) {
|
|
170
228
|
const {
|
|
171
229
|
maxSlotWindow = DEFAULT_MAX_SLOT_WINDOW,
|
|
172
230
|
safetyTimeoutMs = DEFAULT_SAFETY_TIMEOUT_MS,
|
|
@@ -175,126 +233,128 @@ function getWebsocketComputationMonitor(config, deps) {
|
|
|
175
233
|
commitment = "confirmed",
|
|
176
234
|
signal: externalSignal
|
|
177
235
|
} = 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
236
|
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);
|
|
237
|
+
let cleaned = false;
|
|
238
|
+
function cleanup() {
|
|
239
|
+
if (cleaned) return;
|
|
240
|
+
cleaned = true;
|
|
241
|
+
abortController.abort();
|
|
225
242
|
}
|
|
243
|
+
__name(cleanup, "cleanup");
|
|
244
|
+
let notifications;
|
|
226
245
|
try {
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
246
|
+
notifications = await rpcSubscriptions.accountNotifications(computationAddress, { encoding: "base64", commitment }).subscribe({ abortSignal: abortController.signal });
|
|
247
|
+
} catch (error) {
|
|
248
|
+
cleanup();
|
|
249
|
+
throw new ComputationMonitorError(
|
|
250
|
+
"subscription",
|
|
251
|
+
"Failed to establish WebSocket subscription",
|
|
252
|
+
error instanceof Error ? error : void 0
|
|
253
|
+
);
|
|
254
|
+
}
|
|
255
|
+
async function awaitComputation() {
|
|
256
|
+
const startTime = Date.now();
|
|
257
|
+
let queuedSlot = null;
|
|
258
|
+
let receivedFirstNotification = false;
|
|
259
|
+
checkAborted(externalSignal);
|
|
260
|
+
const safetyTimeoutId = setTimeout(() => abortController.abort(), safetyTimeoutMs);
|
|
261
|
+
const onExternalAbort = /* @__PURE__ */ __name(() => abortController.abort(), "onExternalAbort");
|
|
262
|
+
externalSignal?.addEventListener("abort", onExternalAbort, { once: true });
|
|
263
|
+
let slotCheckIntervalId = null;
|
|
264
|
+
let pruneDetected = null;
|
|
265
|
+
try {
|
|
266
|
+
for await (const notification of notifications) {
|
|
267
|
+
try {
|
|
268
|
+
const encodedAccount = notificationValueToEncodedAccount(
|
|
242
269
|
computationAddress,
|
|
243
|
-
|
|
244
|
-
queuedSlot,
|
|
245
|
-
shouldRetrieveSignature,
|
|
246
|
-
onProgress
|
|
270
|
+
notification.value
|
|
247
271
|
);
|
|
272
|
+
const decoded = decodeComputationAccount(encodedAccount);
|
|
273
|
+
if (!receivedFirstNotification) {
|
|
274
|
+
receivedFirstNotification = true;
|
|
275
|
+
queuedSlot = decoded.data.slot;
|
|
276
|
+
const capturedQueuedSlot = queuedSlot;
|
|
277
|
+
slotCheckIntervalId = setInterval(async () => {
|
|
278
|
+
try {
|
|
279
|
+
const currentSlot = await fetchCurrentSlot(rpc, commitment);
|
|
280
|
+
if (isSlotWindowExceeded(capturedQueuedSlot, currentSlot, maxSlotWindow)) {
|
|
281
|
+
pruneDetected = buildPrunedResult(
|
|
282
|
+
startTime,
|
|
283
|
+
capturedQueuedSlot,
|
|
284
|
+
currentSlot,
|
|
285
|
+
onProgress
|
|
286
|
+
);
|
|
287
|
+
abortController.abort();
|
|
288
|
+
}
|
|
289
|
+
} catch {
|
|
290
|
+
}
|
|
291
|
+
}, 5e3);
|
|
292
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
293
|
+
return buildFinalizedResult(
|
|
294
|
+
rpc,
|
|
295
|
+
computationAddress,
|
|
296
|
+
startTime,
|
|
297
|
+
queuedSlot,
|
|
298
|
+
shouldRetrieveSignature,
|
|
299
|
+
onProgress
|
|
300
|
+
);
|
|
301
|
+
}
|
|
302
|
+
continue;
|
|
303
|
+
}
|
|
304
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
305
|
+
return buildFinalizedResult(
|
|
306
|
+
rpc,
|
|
307
|
+
computationAddress,
|
|
308
|
+
startTime,
|
|
309
|
+
queuedSlot,
|
|
310
|
+
shouldRetrieveSignature,
|
|
311
|
+
onProgress
|
|
312
|
+
);
|
|
313
|
+
}
|
|
314
|
+
} catch {
|
|
315
|
+
continue;
|
|
248
316
|
}
|
|
249
|
-
} catch {
|
|
250
|
-
continue;
|
|
251
317
|
}
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
267
|
-
if (abortController.signal.aborted) {
|
|
318
|
+
if (pruneDetected) {
|
|
319
|
+
return pruneDetected;
|
|
320
|
+
}
|
|
321
|
+
return buildTimedOutResult(startTime);
|
|
322
|
+
} catch (error) {
|
|
323
|
+
if (error instanceof ComputationMonitorError) {
|
|
324
|
+
throw error;
|
|
325
|
+
}
|
|
326
|
+
if (pruneDetected) {
|
|
327
|
+
return pruneDetected;
|
|
328
|
+
}
|
|
329
|
+
if (abortController.signal.aborted) {
|
|
330
|
+
return buildTimedOutResult(startTime);
|
|
331
|
+
}
|
|
268
332
|
throw new ComputationMonitorError(
|
|
269
|
-
"
|
|
270
|
-
|
|
333
|
+
"subscription",
|
|
334
|
+
"WebSocket subscription failed",
|
|
335
|
+
error instanceof Error ? error : void 0
|
|
271
336
|
);
|
|
337
|
+
} finally {
|
|
338
|
+
clearTimeout(safetyTimeoutId);
|
|
339
|
+
if (slotCheckIntervalId !== null) {
|
|
340
|
+
clearInterval(slotCheckIntervalId);
|
|
341
|
+
}
|
|
342
|
+
externalSignal?.removeEventListener("abort", onExternalAbort);
|
|
343
|
+
cleanup();
|
|
272
344
|
}
|
|
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
345
|
}
|
|
346
|
+
__name(awaitComputation, "awaitComputation");
|
|
347
|
+
return { awaitComputation, cleanup };
|
|
286
348
|
}
|
|
287
|
-
__name(
|
|
288
|
-
return {
|
|
289
|
-
awaitComputation: monitorComputation
|
|
290
|
-
};
|
|
349
|
+
__name(prepareMonitor, "prepareMonitor");
|
|
350
|
+
return { prepareMonitor };
|
|
291
351
|
}
|
|
292
352
|
__name(getWebsocketComputationMonitor, "getWebsocketComputationMonitor");
|
|
293
353
|
function getPollingComputationMonitor(config, deps) {
|
|
294
354
|
const { rpcUrl } = config;
|
|
295
355
|
const { createRpc = createSolanaRpc } = deps ?? {};
|
|
296
356
|
const rpc = createRpc(rpcUrl);
|
|
297
|
-
async function
|
|
357
|
+
async function prepareMonitor(computationAddress, options) {
|
|
298
358
|
const {
|
|
299
359
|
maxSlotWindow = DEFAULT_MAX_SLOT_WINDOW,
|
|
300
360
|
safetyTimeoutMs = DEFAULT_SAFETY_TIMEOUT_MS,
|
|
@@ -304,360 +364,77 @@ function getPollingComputationMonitor(config, deps) {
|
|
|
304
364
|
commitment = "confirmed",
|
|
305
365
|
signal: externalSignal
|
|
306
366
|
} = 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);
|
|
367
|
+
let aborted = false;
|
|
368
|
+
function cleanup() {
|
|
369
|
+
aborted = true;
|
|
370
|
+
}
|
|
371
|
+
__name(cleanup, "cleanup");
|
|
372
|
+
async function awaitComputation() {
|
|
373
|
+
const startTime = Date.now();
|
|
374
|
+
let queuedSlot = null;
|
|
375
|
+
let receivedFirstDecode = false;
|
|
376
|
+
while (Date.now() - startTime < safetyTimeoutMs) {
|
|
377
|
+
if (aborted) {
|
|
378
|
+
return buildTimedOutResult(startTime);
|
|
341
379
|
}
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
380
|
+
checkAborted(externalSignal);
|
|
381
|
+
try {
|
|
382
|
+
const [maybeAccount, currentSlot] = await Promise.all([
|
|
383
|
+
fetchEncodedAccount(rpc, computationAddress, { commitment }),
|
|
384
|
+
fetchCurrentSlot(rpc, commitment)
|
|
385
|
+
]);
|
|
386
|
+
if (!maybeAccount.exists) {
|
|
387
|
+
await sleep(pollingIntervalMs);
|
|
388
|
+
continue;
|
|
389
|
+
}
|
|
390
|
+
const decoded = decodeComputationAccount(maybeAccount);
|
|
391
|
+
if (queuedSlot === null) {
|
|
392
|
+
queuedSlot = decoded.data.slot;
|
|
393
|
+
}
|
|
394
|
+
if (!receivedFirstDecode) {
|
|
395
|
+
receivedFirstDecode = true;
|
|
396
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
397
|
+
return buildFinalizedResult(
|
|
398
|
+
rpc,
|
|
399
|
+
computationAddress,
|
|
400
|
+
startTime,
|
|
401
|
+
queuedSlot,
|
|
402
|
+
shouldRetrieveSignature,
|
|
403
|
+
onProgress
|
|
404
|
+
);
|
|
405
|
+
}
|
|
406
|
+
await sleep(pollingIntervalMs);
|
|
407
|
+
continue;
|
|
408
|
+
}
|
|
409
|
+
if (decoded.data.status === ComputationStatus.Finalized) {
|
|
410
|
+
return buildFinalizedResult(
|
|
411
|
+
rpc,
|
|
412
|
+
computationAddress,
|
|
413
|
+
startTime,
|
|
414
|
+
queuedSlot,
|
|
415
|
+
shouldRetrieveSignature,
|
|
416
|
+
onProgress
|
|
417
|
+
);
|
|
418
|
+
}
|
|
419
|
+
if (isSlotWindowExceeded(queuedSlot, currentSlot, maxSlotWindow)) {
|
|
420
|
+
return buildPrunedResult(startTime, queuedSlot, currentSlot, onProgress);
|
|
421
|
+
}
|
|
422
|
+
} catch (error) {
|
|
423
|
+
if (error instanceof ComputationMonitorError) {
|
|
424
|
+
throw error;
|
|
425
|
+
}
|
|
345
426
|
}
|
|
427
|
+
await sleep(pollingIntervalMs);
|
|
346
428
|
}
|
|
347
|
-
|
|
429
|
+
return buildTimedOutResult(startTime);
|
|
348
430
|
}
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
`Safety timeout: computation monitoring exceeded ${String(safetyTimeoutMs)}ms`
|
|
352
|
-
);
|
|
431
|
+
__name(awaitComputation, "awaitComputation");
|
|
432
|
+
return { awaitComputation, cleanup };
|
|
353
433
|
}
|
|
354
|
-
__name(
|
|
355
|
-
return {
|
|
356
|
-
awaitComputation: monitorComputation
|
|
357
|
-
};
|
|
434
|
+
__name(prepareMonitor, "prepareMonitor");
|
|
435
|
+
return { prepareMonitor };
|
|
358
436
|
}
|
|
359
437
|
__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
438
|
|
|
662
439
|
// src/umbra/client.ts
|
|
663
440
|
var notImplementedGenerator = /* @__PURE__ */ __name(async () => {
|
|
@@ -701,15 +478,15 @@ async function getUmbraClient(args, deps) {
|
|
|
701
478
|
rpcUrl,
|
|
702
479
|
rpcSubscriptionsUrl
|
|
703
480
|
});
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
apiEndpoint: indexerApiEndpoint
|
|
712
|
-
}
|
|
481
|
+
let fetchMerkleProof;
|
|
482
|
+
let fetchBatchMerkleProof;
|
|
483
|
+
let fetchUtxoData;
|
|
484
|
+
if (indexerApiEndpoint !== void 0 && indexerApiEndpoint !== "") {
|
|
485
|
+
const { getMerkleProofFetcher, getBatchMerkleProofFetcher, getUtxoDataFetcher } = await import('./indexer-NHZDFABY.js');
|
|
486
|
+
fetchMerkleProof = getMerkleProofFetcher({ apiEndpoint: indexerApiEndpoint });
|
|
487
|
+
fetchBatchMerkleProof = getBatchMerkleProofFetcher({ apiEndpoint: indexerApiEndpoint });
|
|
488
|
+
fetchUtxoData = getUtxoDataFetcher({ apiEndpoint: indexerApiEndpoint });
|
|
489
|
+
}
|
|
713
490
|
const defaultMasterSeedStorage = getDefaultMasterSeedStorage();
|
|
714
491
|
const defaultMasterSeedGenerator = getDefaultMasterSeedGenerator(signer);
|
|
715
492
|
const masterSeedLoad = deps?.masterSeedStorage?.load ?? defaultMasterSeedStorage.load;
|
|
@@ -806,54 +583,6 @@ async function getUmbraClient(args, deps) {
|
|
|
806
583
|
}
|
|
807
584
|
__name(getUmbraClient, "getUmbraClient");
|
|
808
585
|
|
|
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
586
|
// src/umbra/fee-provider.ts
|
|
858
587
|
var TREE_DEPTH = 4;
|
|
859
588
|
var MAX_LEAVES = 1 << TREE_DEPTH;
|
|
@@ -5849,71 +5578,85 @@ async function signTransactionMessage(signer, transactionMessage) {
|
|
|
5849
5578
|
__name(signTransactionMessage, "signTransactionMessage");
|
|
5850
5579
|
async function forwardAndMonitor(config, signedTransaction, callbacks, awaitCallback) {
|
|
5851
5580
|
const { transactionForwarder, computationMonitor } = config;
|
|
5852
|
-
|
|
5853
|
-
|
|
5854
|
-
|
|
5855
|
-
|
|
5856
|
-
|
|
5857
|
-
|
|
5858
|
-
|
|
5859
|
-
|
|
5860
|
-
|
|
5861
|
-
|
|
5862
|
-
|
|
5863
|
-
|
|
5864
|
-
|
|
5865
|
-
|
|
5581
|
+
const txSignature = getSignatureFromTransaction(
|
|
5582
|
+
signedTransaction
|
|
5583
|
+
);
|
|
5584
|
+
let prepared;
|
|
5585
|
+
if (awaitCallback !== void 0) {
|
|
5586
|
+
if (computationMonitor === void 0) {
|
|
5587
|
+
throw new Error(
|
|
5588
|
+
"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."
|
|
5589
|
+
);
|
|
5590
|
+
}
|
|
5591
|
+
const baseMonitorOptions = {
|
|
5592
|
+
maxSlotWindow: awaitCallback.maxSlotWindow,
|
|
5593
|
+
safetyTimeoutMs: awaitCallback.safetyTimeoutMs,
|
|
5594
|
+
onProgress: awaitCallback.onProgress,
|
|
5595
|
+
commitment: awaitCallback.computationMonitorCommitment ?? "confirmed",
|
|
5596
|
+
retrieveCallbackSignature: awaitCallback.retrieveCallbackSignature ?? false
|
|
5597
|
+
};
|
|
5598
|
+
prepared = await computationMonitor.prepareMonitor(
|
|
5599
|
+
awaitCallback.computationAccountAddress,
|
|
5600
|
+
baseMonitorOptions
|
|
5866
5601
|
);
|
|
5867
5602
|
}
|
|
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);
|
|
5603
|
+
try {
|
|
5604
|
+
if (callbacks?.pre !== void 0) {
|
|
5605
|
+
await callbacks.pre(signedTransaction);
|
|
5606
|
+
}
|
|
5607
|
+
await transactionForwarder.forwardSequentially([signedTransaction]);
|
|
5608
|
+
if (callbacks?.post !== void 0) {
|
|
5609
|
+
await callbacks.post(signedTransaction, txSignature);
|
|
5610
|
+
}
|
|
5611
|
+
if (prepared === void 0 || awaitCallback === void 0) {
|
|
5612
|
+
return { signature: txSignature, signedTransaction };
|
|
5613
|
+
}
|
|
5614
|
+
const callbackResult = await prepared.awaitComputation();
|
|
5615
|
+
let rentClaimSignature;
|
|
5616
|
+
let rentClaimError;
|
|
5617
|
+
if (awaitCallback.reclaimComputationRent !== false) {
|
|
5618
|
+
if (awaitCallback.computationOffset === void 0 || awaitCallback.clusterOffset === void 0) {
|
|
5619
|
+
rentClaimError = "Rent reclaim skipped: computationOffset or clusterOffset was not provided by the service";
|
|
5620
|
+
} else {
|
|
5621
|
+
try {
|
|
5622
|
+
const noopSigner = createNoopSigner(config.signer.address);
|
|
5623
|
+
const rentClaimIx = getClaimComputationRentInstruction({
|
|
5624
|
+
signer: noopSigner,
|
|
5625
|
+
comp: awaitCallback.computationAccountAddress,
|
|
5626
|
+
compOffset: awaitCallback.computationOffset,
|
|
5627
|
+
clusterOffset: awaitCallback.clusterOffset
|
|
5628
|
+
});
|
|
5629
|
+
const rentClaimBlockhash = await config.getLatestBlockhash({
|
|
5630
|
+
commitment: awaitCallback.rentReclaimBlockhashCommitment ?? "confirmed"
|
|
5631
|
+
});
|
|
5632
|
+
const rentClaimTxMsg = buildTransactionMessage(config.signer, rentClaimBlockhash, [
|
|
5633
|
+
rentClaimIx
|
|
5634
|
+
]);
|
|
5635
|
+
const rentClaimTx = await signTransactionMessage(config.signer, rentClaimTxMsg);
|
|
5636
|
+
rentClaimSignature = await config.transactionForwarder.fireAndForget(rentClaimTx);
|
|
5637
|
+
} catch (error) {
|
|
5638
|
+
rentClaimError = error instanceof Error ? error.message : String(error);
|
|
5639
|
+
}
|
|
5907
5640
|
}
|
|
5908
5641
|
}
|
|
5642
|
+
return {
|
|
5643
|
+
signature: txSignature,
|
|
5644
|
+
signedTransaction,
|
|
5645
|
+
callbackResult,
|
|
5646
|
+
rentClaimSignature,
|
|
5647
|
+
rentClaimError
|
|
5648
|
+
};
|
|
5649
|
+
} finally {
|
|
5650
|
+
prepared?.cleanup();
|
|
5909
5651
|
}
|
|
5910
|
-
return { signature: txSignature, signedTransaction, callbackResult, rentClaimSignature, rentClaimError };
|
|
5911
5652
|
}
|
|
5912
5653
|
__name(forwardAndMonitor, "forwardAndMonitor");
|
|
5913
5654
|
async function executeComputationTransaction(config, options, awaitCallback) {
|
|
5914
5655
|
const { signer, getLatestBlockhash } = config;
|
|
5915
5656
|
const { instruction, preInstructions, altEntry, callbacks, blockhashCommitment } = options;
|
|
5916
|
-
const latestBlockhash = await getLatestBlockhash({
|
|
5657
|
+
const latestBlockhash = await getLatestBlockhash({
|
|
5658
|
+
commitment: blockhashCommitment ?? "confirmed"
|
|
5659
|
+
});
|
|
5917
5660
|
const allInstructions = preInstructions === void 0 ? [instruction] : [...preInstructions, instruction];
|
|
5918
5661
|
const transactionMessage = buildTransactionMessage(
|
|
5919
5662
|
signer,
|
|
@@ -5970,6 +5713,7 @@ function getPublicBalanceToEncryptedBalanceDirectDepositorFunction(args, deps) {
|
|
|
5970
5713
|
if ("callbackResult" in result) {
|
|
5971
5714
|
return {
|
|
5972
5715
|
queueSignature: result.signature,
|
|
5716
|
+
callbackStatus: result.callbackResult.status,
|
|
5973
5717
|
callbackSignature: "callbackSignature" in result.callbackResult ? result.callbackResult.callbackSignature : void 0,
|
|
5974
5718
|
callbackElapsedMs: result.callbackResult.elapsedMs,
|
|
5975
5719
|
rentClaimSignature: result.rentClaimSignature,
|
|
@@ -7101,6 +6845,7 @@ function getEncryptedBalanceToSelfClaimableUtxoCreatorFunction(args, deps) {
|
|
|
7101
6845
|
return {
|
|
7102
6846
|
signedTransaction: result2.signedTransaction,
|
|
7103
6847
|
signature: result2.signature,
|
|
6848
|
+
callbackStatus: callbackResult?.status,
|
|
7104
6849
|
callbackSignature,
|
|
7105
6850
|
callbackElapsedMs: callbackResult?.elapsedMs,
|
|
7106
6851
|
rentClaimSignature,
|
|
@@ -7279,6 +7024,7 @@ function getEncryptedBalanceToSelfClaimableUtxoCreatorFunction(args, deps) {
|
|
|
7279
7024
|
closeProofAccountSignature: closeResult?.signature,
|
|
7280
7025
|
createProofAccountSignature: proofAccountResult.signature,
|
|
7281
7026
|
queueSignature: utxoResult.signature,
|
|
7027
|
+
callbackStatus: utxoResult.callbackStatus,
|
|
7282
7028
|
callbackSignature: utxoResult.callbackSignature,
|
|
7283
7029
|
callbackElapsedMs: utxoResult.callbackElapsedMs,
|
|
7284
7030
|
rentClaimSignature: utxoResult.rentClaimSignature,
|
|
@@ -8091,6 +7837,7 @@ function getEncryptedBalanceToReceiverClaimableUtxoCreatorFunction(args, deps) {
|
|
|
8091
7837
|
return {
|
|
8092
7838
|
signedTransaction: result2.signedTransaction,
|
|
8093
7839
|
signature: result2.signature,
|
|
7840
|
+
callbackStatus: callbackResult?.status,
|
|
8094
7841
|
callbackSignature,
|
|
8095
7842
|
callbackElapsedMs: callbackResult?.elapsedMs,
|
|
8096
7843
|
rentClaimSignature,
|
|
@@ -8265,6 +8012,7 @@ function getEncryptedBalanceToReceiverClaimableUtxoCreatorFunction(args, deps) {
|
|
|
8265
8012
|
closeProofAccountSignature: closeResult?.signature,
|
|
8266
8013
|
createProofAccountSignature: proofAccountResult.signature,
|
|
8267
8014
|
queueSignature: utxoResult.signature,
|
|
8015
|
+
callbackStatus: utxoResult.callbackStatus,
|
|
8268
8016
|
callbackSignature: utxoResult.callbackSignature,
|
|
8269
8017
|
callbackElapsedMs: utxoResult.callbackElapsedMs,
|
|
8270
8018
|
rentClaimSignature: utxoResult.rentClaimSignature,
|
|
@@ -10483,6 +10231,7 @@ function getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction(args, deps)
|
|
|
10483
10231
|
if ("callbackResult" in result) {
|
|
10484
10232
|
return {
|
|
10485
10233
|
queueSignature: result.signature,
|
|
10234
|
+
callbackStatus: result.callbackResult.status,
|
|
10486
10235
|
callbackSignature: "callbackSignature" in result.callbackResult ? result.callbackResult.callbackSignature : void 0,
|
|
10487
10236
|
callbackElapsedMs: result.callbackResult.elapsedMs,
|
|
10488
10237
|
rentClaimSignature: result.rentClaimSignature,
|
|
@@ -10643,6 +10392,6 @@ function getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction(args, deps)
|
|
|
10643
10392
|
}
|
|
10644
10393
|
__name(getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction, "getEncryptedBalanceToPublicBalanceDirectWithdrawerFunction");
|
|
10645
10394
|
|
|
10646
|
-
export { BPS_DIVISOR, DEFAULT_MAX_SLOT_WINDOW, DEFAULT_POLLING_INTERVAL_MS, DEFAULT_SAFETY_TIMEOUT_MS, DEFAULT_SIGNATURE_RETRIEVAL_LIMIT, FEE_OFFSETS,
|
|
10395
|
+
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
10396
|
//# sourceMappingURL=index.js.map
|
|
10648
10397
|
//# sourceMappingURL=index.js.map
|