@augustdigital/sdk 8.3.2 → 8.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +207 -117
- package/lib/abis/ERC20_Bytes32.d.ts +4 -0
- package/lib/abis/ERC20_Bytes32.js +4 -0
- package/lib/abis/ERC4626.d.ts +1 -0
- package/lib/abis/ERC4626.js +1 -0
- package/lib/abis/ERC721.d.ts +1 -0
- package/lib/abis/ERC721.js +1 -0
- package/lib/abis/FeeOracle.js +1 -0
- package/lib/abis/LendingPool.js +1 -0
- package/lib/abis/LendingPoolV2.js +1 -0
- package/lib/abis/Multicall3.js +3 -0
- package/lib/abis/OFT.d.ts +20 -0
- package/lib/abis/OFT.js +20 -0
- package/lib/abis/SmartAccount.d.ts +1 -0
- package/lib/abis/SmartAccount.js +3 -0
- package/lib/abis/SwapRouter.d.ts +1 -0
- package/lib/abis/SwapRouter.js +1 -0
- package/lib/abis/UniversalSignatureValidator.js +3 -0
- package/lib/abis/index.d.ts +5 -0
- package/lib/abis/index.js +5 -0
- package/lib/adapters/evm/getters.d.ts +17 -2
- package/lib/adapters/evm/getters.js +35 -3
- package/lib/adapters/evm/index.d.ts +266 -4
- package/lib/adapters/evm/index.js +270 -1
- package/lib/adapters/evm/utils.d.ts +6 -0
- package/lib/adapters/evm/utils.js +7 -0
- package/lib/adapters/solana/constants.d.ts +1 -1
- package/lib/adapters/solana/constants.js +4 -1
- package/lib/adapters/solana/getters.d.ts +9 -1
- package/lib/adapters/solana/getters.js +21 -0
- package/lib/adapters/solana/idl/vault-idl.js +9 -0
- package/lib/adapters/solana/index.d.ts +59 -4
- package/lib/adapters/solana/index.js +61 -0
- package/lib/adapters/solana/types.d.ts +1 -1
- package/lib/adapters/solana/utils.d.ts +31 -3
- package/lib/adapters/solana/utils.js +79 -4
- package/lib/adapters/solana/vault.actions.d.ts +23 -4
- package/lib/adapters/solana/vault.actions.js +47 -3
- package/lib/adapters/stellar/actions.d.ts +26 -1
- package/lib/adapters/stellar/actions.js +33 -0
- package/lib/adapters/stellar/constants.d.ts +26 -0
- package/lib/adapters/stellar/constants.js +29 -0
- package/lib/adapters/stellar/getters.d.ts +56 -0
- package/lib/adapters/stellar/getters.js +81 -0
- package/lib/adapters/stellar/index.d.ts +70 -0
- package/lib/adapters/stellar/index.js +71 -0
- package/lib/adapters/stellar/soroban.d.ts +21 -1
- package/lib/adapters/stellar/soroban.js +47 -1
- package/lib/adapters/stellar/submit.d.ts +29 -0
- package/lib/adapters/stellar/submit.js +90 -5
- package/lib/adapters/stellar/types.d.ts +27 -0
- package/lib/adapters/stellar/types.js +3 -0
- package/lib/adapters/stellar/utils.d.ts +10 -0
- package/lib/adapters/stellar/utils.js +10 -0
- package/lib/adapters/sui/getters.d.ts +7 -1
- package/lib/adapters/sui/getters.js +6 -0
- package/lib/adapters/sui/index.d.ts +16 -1
- package/lib/adapters/sui/index.js +17 -0
- package/lib/adapters/sui/transformer.d.ts +8 -2
- package/lib/adapters/sui/transformer.js +7 -0
- package/lib/adapters/sui/types.d.ts +1 -1
- package/lib/adapters/sui/utils.d.ts +6 -0
- package/lib/adapters/sui/utils.js +6 -0
- package/lib/core/analytics/chain-name.d.ts +8 -0
- package/lib/core/analytics/chain-name.js +8 -0
- package/lib/core/analytics/constants.d.ts +4 -0
- package/lib/core/analytics/constants.js +4 -0
- package/lib/core/analytics/env.d.ts +25 -0
- package/lib/core/analytics/env.js +26 -0
- package/lib/core/analytics/index.d.ts +26 -0
- package/lib/core/analytics/index.js +35 -0
- package/lib/core/analytics/instrumentation.d.ts +26 -0
- package/lib/core/analytics/instrumentation.js +66 -2
- package/lib/core/analytics/method-taxonomy.d.ts +16 -0
- package/lib/core/analytics/method-taxonomy.js +18 -0
- package/lib/core/analytics/metrics.d.ts +23 -0
- package/lib/core/analytics/metrics.js +40 -0
- package/lib/core/analytics/sanitize.d.ts +38 -0
- package/lib/core/analytics/sanitize.js +46 -0
- package/lib/core/analytics/sentry-runtime.d.ts +11 -0
- package/lib/core/analytics/sentry-runtime.js +20 -1
- package/lib/core/analytics/sentry.d.ts +47 -2
- package/lib/core/analytics/sentry.js +115 -2
- package/lib/core/analytics/types.d.ts +28 -1
- package/lib/core/analytics/user-identity.d.ts +36 -2
- package/lib/core/analytics/user-identity.js +43 -1
- package/lib/core/analytics/version.d.ts +6 -1
- package/lib/core/analytics/version.js +6 -1
- package/lib/core/auth/verify.js +5 -0
- package/lib/core/base.class.d.ts +78 -3
- package/lib/core/base.class.js +66 -4
- package/lib/core/cache.d.ts +5 -0
- package/lib/core/cache.js +6 -0
- package/lib/core/constants/adapters.d.ts +16 -1
- package/lib/core/constants/adapters.js +28 -8
- package/lib/core/constants/core.d.ts +14 -1
- package/lib/core/constants/core.js +18 -0
- package/lib/core/constants/swap-router.d.ts +83 -1
- package/lib/core/constants/swap-router.js +91 -1
- package/lib/core/constants/vaults.d.ts +57 -1
- package/lib/core/constants/vaults.js +66 -1
- package/lib/core/constants/web3.d.ts +4 -1
- package/lib/core/constants/web3.js +15 -5
- package/lib/core/errors/index.d.ts +38 -2
- package/lib/core/errors/index.js +38 -0
- package/lib/core/fetcher.d.ts +136 -2
- package/lib/core/fetcher.js +229 -25
- package/lib/core/helpers/adapters.d.ts +10 -1
- package/lib/core/helpers/adapters.js +11 -0
- package/lib/core/helpers/chain-address.d.ts +10 -0
- package/lib/core/helpers/chain-address.js +11 -0
- package/lib/core/helpers/core.d.ts +49 -4
- package/lib/core/helpers/core.js +74 -7
- package/lib/core/helpers/explorer-link.d.ts +15 -1
- package/lib/core/helpers/explorer-link.js +14 -0
- package/lib/core/helpers/signer.d.ts +27 -1
- package/lib/core/helpers/signer.js +39 -0
- package/lib/core/helpers/swap-router.d.ts +33 -1
- package/lib/core/helpers/swap-router.js +32 -0
- package/lib/core/helpers/vault-version.d.ts +2 -1
- package/lib/core/helpers/vault-version.js +2 -0
- package/lib/core/helpers/vaults.d.ts +9 -1
- package/lib/core/helpers/vaults.js +22 -8
- package/lib/core/helpers/web3.d.ts +154 -2
- package/lib/core/helpers/web3.js +192 -15
- package/lib/core/logger/index.d.ts +55 -0
- package/lib/core/logger/index.js +19 -0
- package/lib/core/logger/slack.d.ts +3 -0
- package/lib/core/logger/slack.js +3 -0
- package/lib/core/vault-metadata.d.ts +7 -1
- package/lib/core/vault-metadata.js +6 -0
- package/lib/core/version-check.d.ts +52 -0
- package/lib/core/version-check.js +82 -1
- package/lib/evm/methods/crossChainVault.d.ts +90 -0
- package/lib/evm/methods/crossChainVault.js +187 -2
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +1 -0
- package/lib/evm/methods/index.js +1 -0
- package/lib/evm/types/crossChain.d.ts +202 -0
- package/lib/evm/types/crossChain.js +12 -1
- package/lib/index.d.ts +16 -0
- package/lib/index.js +19 -0
- package/lib/main.d.ts +289 -6
- package/lib/main.js +312 -0
- package/lib/modules/api/index.d.ts +1 -0
- package/lib/modules/api/index.js +6 -0
- package/lib/modules/api/main.d.ts +52 -0
- package/lib/modules/api/main.js +130 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +17 -2
- package/lib/modules/sub-accounts/fetcher.js +15 -0
- package/lib/modules/sub-accounts/main.d.ts +35 -2
- package/lib/modules/sub-accounts/main.js +39 -1
- package/lib/modules/sub-accounts/utils.d.ts +4 -1
- package/lib/modules/sub-accounts/utils.js +3 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +21 -3
- package/lib/modules/vaults/adapter.helpers.js +34 -0
- package/lib/modules/vaults/fetcher.d.ts +45 -0
- package/lib/modules/vaults/fetcher.js +91 -4
- package/lib/modules/vaults/getters.d.ts +295 -0
- package/lib/modules/vaults/getters.js +567 -26
- package/lib/modules/vaults/index.d.ts +12 -0
- package/lib/modules/vaults/index.js +12 -0
- package/lib/modules/vaults/main.d.ts +292 -4
- package/lib/modules/vaults/main.js +382 -8
- package/lib/modules/vaults/read.actions.d.ts +170 -2
- package/lib/modules/vaults/read.actions.js +143 -0
- package/lib/modules/vaults/types.d.ts +34 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +48 -1
- package/lib/modules/vaults/utils/call-data-decoder.js +56 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +39 -0
- package/lib/modules/vaults/utils/date-utils.js +47 -1
- package/lib/modules/vaults/utils.d.ts +85 -0
- package/lib/modules/vaults/utils.js +139 -7
- package/lib/modules/vaults/write.actions.d.ts +363 -3
- package/lib/modules/vaults/write.actions.js +399 -3
- package/lib/polyfills.js +4 -2
- package/lib/sdk.d.ts +23847 -0
- package/lib/services/coingecko/fetcher.d.ts +15 -1
- package/lib/services/coingecko/fetcher.js +30 -9
- package/lib/services/debank/fetcher.d.ts +15 -1
- package/lib/services/debank/fetcher.js +12 -0
- package/lib/services/debank/utils.d.ts +1 -1
- package/lib/services/debank/utils.js +18 -1
- package/lib/services/layerzero/deposits.d.ts +12 -1
- package/lib/services/layerzero/deposits.js +34 -11
- package/lib/services/layerzero/redeems.d.ts +11 -1
- package/lib/services/layerzero/redeems.js +13 -0
- package/lib/services/layerzero/utils.d.ts +8 -0
- package/lib/services/layerzero/utils.js +11 -0
- package/lib/services/octavfi/fetcher.d.ts +8 -1
- package/lib/services/octavfi/fetcher.js +25 -0
- package/lib/services/octavfi/types.d.ts +1 -1
- package/lib/services/octavfi/utils.d.ts +14 -2
- package/lib/services/octavfi/utils.js +44 -10
- package/lib/services/subgraph/fetcher.js +4 -2
- package/lib/services/subgraph/vaults.d.ts +12 -0
- package/lib/services/subgraph/vaults.js +119 -2
- package/lib/services/swap-quotes/index.d.ts +80 -0
- package/lib/services/swap-quotes/index.js +27 -1
- package/lib/services/swap-quotes/paraswap.d.ts +25 -0
- package/lib/services/swap-quotes/paraswap.js +22 -0
- package/lib/types/pools.d.ts +5 -2
- package/lib/types/staking.d.ts +1 -1
- package/lib/types/sub-accounts.d.ts +1 -1
- package/lib/types/subgraph.d.ts +10 -1
- package/lib/types/typed-contract.d.ts +64 -0
- package/lib/types/vaults.d.ts +163 -2
- package/lib/types/vaults.js +10 -0
- package/lib/types/web3.d.ts +9 -1
- package/lib/types/web3.js +1 -0
- package/lib/types/webserver.d.ts +47 -2
- package/package.json +6 -5
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Shared Soroban RPC utilities
|
|
4
|
+
*
|
|
5
|
+
* Common transaction building and read-only query helpers used by
|
|
6
|
+
* actions, submit, and getters modules.
|
|
7
|
+
*/
|
|
2
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
9
|
exports.createServer = createServer;
|
|
4
10
|
exports.resolveNetworkConfig = resolveNetworkConfig;
|
|
@@ -13,12 +19,19 @@ function createServer(rpcUrl) {
|
|
|
13
19
|
allowHttp: rpcUrl.startsWith('http://'),
|
|
14
20
|
});
|
|
15
21
|
}
|
|
22
|
+
/**
|
|
23
|
+
* Resolve RPC URL and network passphrase for a Stellar network.
|
|
24
|
+
*/
|
|
16
25
|
function resolveNetworkConfig(network) {
|
|
17
26
|
return {
|
|
18
27
|
rpcUrl: constants_1.SOROBAN_RPC_URLS[network],
|
|
19
28
|
passphrase: constants_1.NETWORK_PASSPHRASES[network],
|
|
20
29
|
};
|
|
21
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Validate and convert a string amount to a non-negative BigInt.
|
|
33
|
+
* Throws a descriptive error if the value is not a valid non-negative integer string.
|
|
34
|
+
*/
|
|
22
35
|
function toBigIntAmount(value, label) {
|
|
23
36
|
if (value === '') {
|
|
24
37
|
throw new core_1.AugustValidationError('INVALID_INPUT', `Invalid ${label}: value must not be empty`);
|
|
@@ -35,6 +48,11 @@ function toBigIntAmount(value, label) {
|
|
|
35
48
|
}
|
|
36
49
|
return result;
|
|
37
50
|
}
|
|
51
|
+
/**
|
|
52
|
+
* Query a read-only Soroban contract function via simulation.
|
|
53
|
+
* Uses a throwaway source account — simulation is off-chain and has no on-chain side effects.
|
|
54
|
+
* Returns the ScVal result, or null if the call fails.
|
|
55
|
+
*/
|
|
38
56
|
function extractSimulationError(simulated) {
|
|
39
57
|
return 'error' in simulated
|
|
40
58
|
? String(simulated.error)
|
|
@@ -46,6 +64,8 @@ async function queryContract(config, contractId, method, args = []) {
|
|
|
46
64
|
const contract = new stellar_sdk_1.Contract(contractId);
|
|
47
65
|
const sourceKeypair = stellar_sdk_1.Keypair.random();
|
|
48
66
|
const account = new stellar_sdk_1.Account(sourceKeypair.publicKey(), '0');
|
|
67
|
+
// Minimal fee — simulation is off-chain; these values don't affect execution cost.
|
|
68
|
+
// Short timeout to avoid blocking vault listing if Soroban RPC is slow.
|
|
49
69
|
const tx = new stellar_sdk_1.TransactionBuilder(account, {
|
|
50
70
|
fee: '100',
|
|
51
71
|
networkPassphrase: config.passphrase,
|
|
@@ -76,9 +96,22 @@ async function queryContract(config, contractId, method, args = []) {
|
|
|
76
96
|
return null;
|
|
77
97
|
}
|
|
78
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Read the network's wall-clock time (unix seconds) from the latest closed
|
|
101
|
+
* ledger, or null if the RPC can't report it.
|
|
102
|
+
*
|
|
103
|
+
* Soroban validators reject a transaction whose `maxTime` precedes the ledger
|
|
104
|
+
* close time (`txTOO_LATE`). Anchoring `maxTime` to the *network* clock instead
|
|
105
|
+
* of the signer's `Date.now()` immunises the deadline against a skewed device
|
|
106
|
+
* clock — a machine lagging behind real time was silently building
|
|
107
|
+
* already-expired transactions. Best-effort: on any RPC failure the caller
|
|
108
|
+
* falls back to the local clock, so this never regresses the prior behaviour.
|
|
109
|
+
*/
|
|
79
110
|
async function getNetworkCloseTime(server) {
|
|
80
111
|
try {
|
|
81
112
|
const { sequence } = await server.getLatestLedger();
|
|
113
|
+
// `latestLedgerCloseTime` on the response envelope is the freshest network
|
|
114
|
+
// time; the single-ledger page is just the cheapest valid request shape.
|
|
82
115
|
const page = await server.getLedgers({
|
|
83
116
|
startLedger: sequence,
|
|
84
117
|
pagination: { limit: 1 },
|
|
@@ -92,18 +125,29 @@ async function getNetworkCloseTime(server) {
|
|
|
92
125
|
return null;
|
|
93
126
|
}
|
|
94
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* Build an unsigned Soroban contract invocation transaction.
|
|
130
|
+
* Fetches the real source account from the network (the account must exist and be funded).
|
|
131
|
+
* Simulates via Soroban RPC to attach resource footprint and auth entries,
|
|
132
|
+
* using MAX_FEE_STROOPS as the fee ceiling and incorporating the simulated resource fee.
|
|
133
|
+
*/
|
|
95
134
|
async function buildSorobanTx(config, sourceAddress, contractId, method, args) {
|
|
96
135
|
const server = createServer(config.rpcUrl);
|
|
136
|
+
// Read the network clock in parallel with the account fetch — it overlaps the
|
|
137
|
+
// account round-trip, so it adds no latency on the happy path.
|
|
97
138
|
const networkCloseTimePromise = getNetworkCloseTime(server);
|
|
98
139
|
let account;
|
|
99
140
|
try {
|
|
100
141
|
account = await server.getAccount(sourceAddress);
|
|
101
142
|
}
|
|
102
143
|
catch (err) {
|
|
144
|
+
// Soroban rpc currently throws plain `Error("Account not found: ...")`
|
|
145
|
+
// for unfunded accounts; check `NotFoundError` too so this survives an
|
|
146
|
+
// SDK refactor to typed errors.
|
|
103
147
|
const msg = err instanceof Error ? err.message : String(err);
|
|
104
148
|
const isAccountNotFound = err instanceof stellar_sdk_1.NotFoundError || /Account not found/.test(msg);
|
|
105
149
|
if (isAccountNotFound) {
|
|
106
|
-
throw new core_1.AugustValidationError('
|
|
150
|
+
throw new core_1.AugustValidationError('ACCOUNT_NOT_FUNDED', `Stellar account ${sourceAddress} is not funded. Send at least 1 XLM to this address to activate it before depositing or redeeming.`, { cause: err, context: { sourceAddress, method, contractId } });
|
|
107
151
|
}
|
|
108
152
|
throw err;
|
|
109
153
|
}
|
|
@@ -114,9 +158,11 @@ async function buildSorobanTx(config, sourceAddress, contractId, method, args) {
|
|
|
114
158
|
}).addOperation(contract.call(method, ...args));
|
|
115
159
|
const networkCloseTime = await networkCloseTimePromise;
|
|
116
160
|
if (networkCloseTime !== null) {
|
|
161
|
+
// Absolute deadline anchored to the network clock — survives signer skew.
|
|
117
162
|
builder.setTimebounds(0, networkCloseTime + constants_1.TX_TIMEOUT_SECONDS);
|
|
118
163
|
}
|
|
119
164
|
else {
|
|
165
|
+
// RPC couldn't report network time; fall back to the local-clock window.
|
|
120
166
|
builder.setTimeout(constants_1.TX_TIMEOUT_SECONDS);
|
|
121
167
|
}
|
|
122
168
|
const tx = builder.build();
|
|
@@ -1,2 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellar Transaction Submission
|
|
3
|
+
*
|
|
4
|
+
* Submits signed Soroban transactions and polls for confirmation.
|
|
5
|
+
*/
|
|
1
6
|
import type { IStellarNetwork } from './types';
|
|
7
|
+
/**
|
|
8
|
+
* Submit a signed Soroban transaction and poll until confirmed.
|
|
9
|
+
*
|
|
10
|
+
* @param signedXdr - Base64-encoded XDR of the signed transaction
|
|
11
|
+
* @param network - Stellar network name
|
|
12
|
+
* @returns The transaction hash once the network confirms it as successful
|
|
13
|
+
* @throws {@link AugustTimeoutError} when the transaction is not confirmed
|
|
14
|
+
* within the poll budget (`MAX_POLL_ATTEMPTS`).
|
|
15
|
+
* @throws {@link AugustSDKError} when the RPC rejects the submission or the
|
|
16
|
+
* transaction confirms as failed. Its `context` carries `{ network, status }`
|
|
17
|
+
* plus, when the result XDR decodes, a `resultCode` string holding the
|
|
18
|
+
* transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
|
|
19
|
+
* is `undefined` when the code cannot be decoded.
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* try {
|
|
23
|
+
* const hash = await submitStellarTransaction(signedXdr, 'mainnet');
|
|
24
|
+
* } catch (err) {
|
|
25
|
+
* if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
|
|
26
|
+
* // stale sequence number — rebuild the transaction and resubmit
|
|
27
|
+
* }
|
|
28
|
+
* }
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
2
31
|
export declare function submitStellarTransaction(signedXdr: string, network: IStellarNetwork): Promise<string>;
|
|
@@ -1,23 +1,97 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Stellar Transaction Submission
|
|
4
|
+
*
|
|
5
|
+
* Submits signed Soroban transactions and polls for confirmation.
|
|
6
|
+
*/
|
|
2
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
8
|
exports.submitStellarTransaction = submitStellarTransaction;
|
|
4
9
|
const stellar_sdk_1 = require("@stellar/stellar-sdk");
|
|
5
10
|
const core_1 = require("../../core");
|
|
6
11
|
const soroban_1 = require("./soroban");
|
|
7
12
|
const constants_1 = require("./constants");
|
|
13
|
+
/**
|
|
14
|
+
* Best-effort decode of the transaction-level result code (the XDR union
|
|
15
|
+
* discriminant, e.g. `"txBadSeq"`, `"txTooLate"`) from a Soroban
|
|
16
|
+
* `TransactionResult`. Typed `unknown` and probed structurally so it stays
|
|
17
|
+
* robust to RPC/SDK shape drift; returns `undefined` for anything that isn't a
|
|
18
|
+
* decoded union, so callers fall back to the stringified XDR in the message.
|
|
19
|
+
*/
|
|
20
|
+
function extractTxResultCode(result) {
|
|
21
|
+
try {
|
|
22
|
+
const decoded = result;
|
|
23
|
+
if (typeof decoded?.result !== 'function')
|
|
24
|
+
return undefined;
|
|
25
|
+
// `|| undefined`: an empty discriminant shares the clean "no code" path.
|
|
26
|
+
return decoded.result().switch().name || undefined;
|
|
27
|
+
}
|
|
28
|
+
catch (e) {
|
|
29
|
+
// Only reached on a malformed / shape-drifted union (the non-union case
|
|
30
|
+
// already returned above). Breadcrumb it so decoder rot stays detectable;
|
|
31
|
+
// the caller still throws with the stringified XDR in the message.
|
|
32
|
+
core_1.Logger.log.warn('extractTxResultCode', { decodeError: String(e) });
|
|
33
|
+
return undefined;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* `JSON.stringify` that never throws. A real `xdr.TransactionResult` can hold
|
|
38
|
+
* `bigint` fields (e.g. `feeCharged`), which make `JSON.stringify` throw a
|
|
39
|
+
* `TypeError` — that would escape and replace the `AugustSDKError` this detail
|
|
40
|
+
* is only meant to enrich. Returns `''` on failure so the caller falls back to
|
|
41
|
+
* the status; the decoded `resultCode` still carries the precise reason.
|
|
42
|
+
*/
|
|
43
|
+
function safeStringify(value) {
|
|
44
|
+
try {
|
|
45
|
+
return JSON.stringify(value) ?? '';
|
|
46
|
+
}
|
|
47
|
+
catch {
|
|
48
|
+
return '';
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Submit a signed Soroban transaction and poll until confirmed.
|
|
53
|
+
*
|
|
54
|
+
* @param signedXdr - Base64-encoded XDR of the signed transaction
|
|
55
|
+
* @param network - Stellar network name
|
|
56
|
+
* @returns The transaction hash once the network confirms it as successful
|
|
57
|
+
* @throws {@link AugustTimeoutError} when the transaction is not confirmed
|
|
58
|
+
* within the poll budget (`MAX_POLL_ATTEMPTS`).
|
|
59
|
+
* @throws {@link AugustSDKError} when the RPC rejects the submission or the
|
|
60
|
+
* transaction confirms as failed. Its `context` carries `{ network, status }`
|
|
61
|
+
* plus, when the result XDR decodes, a `resultCode` string holding the
|
|
62
|
+
* transaction-level reason (e.g. `"txBadSeq"`, `"txTooLate"`); `resultCode`
|
|
63
|
+
* is `undefined` when the code cannot be decoded.
|
|
64
|
+
* @example
|
|
65
|
+
* ```ts
|
|
66
|
+
* try {
|
|
67
|
+
* const hash = await submitStellarTransaction(signedXdr, 'mainnet');
|
|
68
|
+
* } catch (err) {
|
|
69
|
+
* if (err instanceof AugustSDKError && err.context?.resultCode === 'txBadSeq') {
|
|
70
|
+
* // stale sequence number — rebuild the transaction and resubmit
|
|
71
|
+
* }
|
|
72
|
+
* }
|
|
73
|
+
* ```
|
|
74
|
+
*/
|
|
8
75
|
async function submitStellarTransaction(signedXdr, network) {
|
|
9
76
|
const { rpcUrl, passphrase } = (0, soroban_1.resolveNetworkConfig)(network);
|
|
10
77
|
const server = (0, soroban_1.createServer)(rpcUrl);
|
|
11
78
|
const tx = stellar_sdk_1.TransactionBuilder.fromXDR(signedXdr, passphrase);
|
|
12
79
|
const sendResult = await server.sendTransaction(tx);
|
|
13
80
|
if (sendResult.status === 'ERROR') {
|
|
14
|
-
const
|
|
81
|
+
const errorResult = 'errorResult' in sendResult ? sendResult.errorResult : undefined;
|
|
82
|
+
const resultCode = extractTxResultCode(errorResult);
|
|
83
|
+
const detail = errorResult ? safeStringify(errorResult) : '';
|
|
15
84
|
const msg = `Transaction submission failed: ${detail || sendResult.status}`;
|
|
16
|
-
core_1.Logger.log.error('submitStellarTransaction', msg, { network });
|
|
85
|
+
core_1.Logger.log.error('submitStellarTransaction', msg, { network, resultCode });
|
|
17
86
|
throw new core_1.AugustSDKError('UNKNOWN', msg, {
|
|
18
|
-
context: { network, status: sendResult.status },
|
|
87
|
+
context: { network, status: sendResult.status, resultCode },
|
|
19
88
|
});
|
|
20
89
|
}
|
|
90
|
+
// Only PENDING (and DUPLICATE) mean the tx was accepted by the RPC.
|
|
91
|
+
// DUPLICATE means this exact transaction was already submitted — it may
|
|
92
|
+
// already be confirmed or still pending from a prior submission.
|
|
93
|
+
// TRY_AGAIN_LATER and any other status should be surfaced immediately
|
|
94
|
+
// so callers can retry submission instead of waiting for a poll timeout.
|
|
21
95
|
if (sendResult.status !== 'PENDING' && sendResult.status !== 'DUPLICATE') {
|
|
22
96
|
const msg = `Transaction not accepted by RPC (status: ${sendResult.status}). ` +
|
|
23
97
|
'This may be retryable — the RPC node could be overloaded.';
|
|
@@ -26,6 +100,8 @@ async function submitStellarTransaction(signedXdr, network) {
|
|
|
26
100
|
context: { network, status: sendResult.status },
|
|
27
101
|
});
|
|
28
102
|
}
|
|
103
|
+
// Geometric backoff (start POLL_INTERVAL_MS, ×POLL_INTERVAL_BACKOFF up to
|
|
104
|
+
// POLL_INTERVAL_MAX_MS) — fast on the happy path, gentler on slow ledgers.
|
|
29
105
|
let getResult = await server.getTransaction(sendResult.hash);
|
|
30
106
|
let polls = 0;
|
|
31
107
|
let nextDelay = constants_1.POLL_INTERVAL_MS;
|
|
@@ -47,14 +123,23 @@ async function submitStellarTransaction(signedXdr, network) {
|
|
|
47
123
|
if (getResult.status === 'SUCCESS') {
|
|
48
124
|
return sendResult.hash;
|
|
49
125
|
}
|
|
50
|
-
const
|
|
126
|
+
const resultXdr = 'resultXdr' in getResult ? getResult.resultXdr : undefined;
|
|
127
|
+
const resultCode = extractTxResultCode(resultXdr);
|
|
128
|
+
const detail = resultXdr ? safeStringify(resultXdr) : '';
|
|
129
|
+
const failDetail = detail ? ` (${detail})` : '';
|
|
51
130
|
const msg = `Transaction failed: ${getResult.status}${failDetail}`;
|
|
52
131
|
core_1.Logger.log.error('submitStellarTransaction', msg, {
|
|
53
132
|
hash: sendResult.hash,
|
|
54
133
|
network,
|
|
134
|
+
resultCode,
|
|
55
135
|
});
|
|
56
136
|
throw new core_1.AugustSDKError('UNKNOWN', msg, {
|
|
57
|
-
context: {
|
|
137
|
+
context: {
|
|
138
|
+
hash: sendResult.hash,
|
|
139
|
+
network,
|
|
140
|
+
status: getResult.status,
|
|
141
|
+
resultCode,
|
|
142
|
+
},
|
|
58
143
|
});
|
|
59
144
|
}
|
|
60
145
|
//# sourceMappingURL=submit.js.map
|
|
@@ -1,19 +1,46 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellar Vault Types
|
|
3
|
+
*/
|
|
1
4
|
import type { IStellarNetwork } from '../../types/web3';
|
|
2
5
|
export type { IStellarNetwork };
|
|
6
|
+
/** Parameters for building an unsigned Stellar vault deposit transaction. */
|
|
3
7
|
export interface IStellarDepositParams {
|
|
4
8
|
contractId: string;
|
|
5
9
|
amount: string;
|
|
6
10
|
senderAddress: string;
|
|
7
11
|
network: IStellarNetwork;
|
|
8
12
|
}
|
|
13
|
+
/** Parameters for building an unsigned Stellar vault redeem transaction. */
|
|
9
14
|
export interface IStellarRedeemParams {
|
|
10
15
|
contractId: string;
|
|
11
16
|
shares: string;
|
|
12
17
|
receiverAddress: string;
|
|
13
18
|
network: IStellarNetwork;
|
|
14
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* User vault position returned by on-chain balance queries.
|
|
22
|
+
*
|
|
23
|
+
* `decimals` carries the share-token scale used to interpret `shares`. When the
|
|
24
|
+
* on-chain `decimals()` read fails, it falls back to STELLAR_FALLBACK_DECIMALS
|
|
25
|
+
* (7) and `decimalsFromFallback` is set to `true`. Callers that size a redeem
|
|
26
|
+
* from this position MUST check `decimalsFromFallback` and refuse to settle
|
|
27
|
+
* when it is `true` — trusting a fabricated 7 against an ERC4626 offset vault
|
|
28
|
+
* (share decimals = asset + offset) under-redeems by `10^offset`. See
|
|
29
|
+
* AUGUST-6381.
|
|
30
|
+
*/
|
|
15
31
|
export interface IStellarUserPosition {
|
|
32
|
+
/** Raw share balance in smallest unit, as a non-negative integer string */
|
|
16
33
|
shares: string;
|
|
34
|
+
/** Share-token decimals; may be the fallback — see `decimalsFromFallback`. */
|
|
17
35
|
decimals: number;
|
|
36
|
+
/**
|
|
37
|
+
* `true` when `decimals` is the fallback (the on-chain `decimals()` read
|
|
38
|
+
* failed), `false` when it is the authoritative on-chain value. Treat `true`
|
|
39
|
+
* as a decimals read failure: do not trust `decimals` to scale or redeem.
|
|
40
|
+
*
|
|
41
|
+
* Optional for source back-compat (a consumer's existing object literal still
|
|
42
|
+
* compiles), but `getStellarUserPosition` always populates it — so a position
|
|
43
|
+
* obtained from the SDK never omits it.
|
|
44
|
+
*/
|
|
18
45
|
decimalsFromFallback?: boolean;
|
|
19
46
|
}
|
|
@@ -1,11 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Stellar Utilities
|
|
3
|
+
*/
|
|
1
4
|
import type { IStellarNetwork } from './types';
|
|
2
5
|
import { isStellarAddress } from '../../core/helpers/chain-address';
|
|
3
6
|
export { isStellarAddress };
|
|
7
|
+
/**
|
|
8
|
+
* Get the Stellar explorer URL for a given address or transaction.
|
|
9
|
+
*/
|
|
4
10
|
export declare function getExplorerLink({ id, type, network, }: {
|
|
5
11
|
id: string;
|
|
6
12
|
type?: 'contract' | 'account' | 'tx';
|
|
7
13
|
network?: IStellarNetwork;
|
|
8
14
|
}): string;
|
|
15
|
+
/**
|
|
16
|
+
* Throw if the given address is a Stellar address.
|
|
17
|
+
* Used as a guard in vault operations that don't yet support Stellar.
|
|
18
|
+
*/
|
|
9
19
|
export declare function assertNotStellar(address: string, operation: string): void;
|
|
10
20
|
export declare const StellarUtils: {
|
|
11
21
|
isStellarAddress: typeof isStellarAddress;
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Stellar Utilities
|
|
4
|
+
*/
|
|
2
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
6
|
exports.StellarUtils = exports.isStellarAddress = void 0;
|
|
4
7
|
exports.getExplorerLink = getExplorerLink;
|
|
@@ -6,11 +9,18 @@ exports.assertNotStellar = assertNotStellar;
|
|
|
6
9
|
const core_1 = require("../../core");
|
|
7
10
|
const chain_address_1 = require("../../core/helpers/chain-address");
|
|
8
11
|
Object.defineProperty(exports, "isStellarAddress", { enumerable: true, get: function () { return chain_address_1.isStellarAddress; } });
|
|
12
|
+
/**
|
|
13
|
+
* Get the Stellar explorer URL for a given address or transaction.
|
|
14
|
+
*/
|
|
9
15
|
function getExplorerLink({ id, type = 'contract', network = 'mainnet', }) {
|
|
10
16
|
const baseUrl = 'https://stellar.expert/explorer';
|
|
11
17
|
const net = network === 'mainnet' ? 'public' : 'testnet';
|
|
12
18
|
return `${baseUrl}/${net}/${type}/${id}`;
|
|
13
19
|
}
|
|
20
|
+
/**
|
|
21
|
+
* Throw if the given address is a Stellar address.
|
|
22
|
+
* Used as a guard in vault operations that don't yet support Stellar.
|
|
23
|
+
*/
|
|
14
24
|
function assertNotStellar(address, operation) {
|
|
15
25
|
if ((0, chain_address_1.isStellarAddress)(address)) {
|
|
16
26
|
throw new core_1.AugustValidationError('INVALID_CHAIN', `${operation} is not yet supported for Stellar vaults: ${address}`);
|
|
@@ -1,3 +1,9 @@
|
|
|
1
|
-
import { IEmberVault, IFetchEmberVaultsOptions } from './types';
|
|
1
|
+
import type { IEmberVault, IFetchEmberVaultsOptions } from './types';
|
|
2
|
+
/**
|
|
3
|
+
* Fetch Ember vaults from API
|
|
4
|
+
*/
|
|
2
5
|
export declare function getEmberVaults(options?: IFetchEmberVaultsOptions): Promise<IEmberVault[]>;
|
|
6
|
+
/**
|
|
7
|
+
* Fetch Ember TVL data
|
|
8
|
+
*/
|
|
3
9
|
export declare function getEmberTVL(limit?: number): Promise<number>;
|
|
@@ -5,6 +5,9 @@ exports.getEmberTVL = getEmberTVL;
|
|
|
5
5
|
const constants_1 = require("./constants");
|
|
6
6
|
const core_1 = require("../../core");
|
|
7
7
|
const logger_1 = require("../../core/logger");
|
|
8
|
+
/**
|
|
9
|
+
* Fetch Ember vaults from API
|
|
10
|
+
*/
|
|
8
11
|
async function getEmberVaults(options) {
|
|
9
12
|
try {
|
|
10
13
|
const params = new URLSearchParams();
|
|
@@ -28,6 +31,9 @@ async function getEmberVaults(options) {
|
|
|
28
31
|
return [];
|
|
29
32
|
}
|
|
30
33
|
}
|
|
34
|
+
/**
|
|
35
|
+
* Fetch Ember TVL data
|
|
36
|
+
*/
|
|
31
37
|
async function getEmberTVL(limit = 1) {
|
|
32
38
|
try {
|
|
33
39
|
const params = new URLSearchParams();
|
|
@@ -1,8 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sui Adapter for August SDK
|
|
3
|
+
*
|
|
4
|
+
* @module SuiAdapter
|
|
5
|
+
*/
|
|
1
6
|
import * as SuiConstants from './constants';
|
|
2
7
|
import * as SuiGetters from './getters';
|
|
3
8
|
import * as SuiUtils from './utils';
|
|
4
9
|
import { transformEmberVaultToIVault, transformEmberVaultsToIVaults } from './transformer';
|
|
5
|
-
import { IEmberVault, IFetchEmberVaultsOptions } from './types';
|
|
10
|
+
import type { IEmberVault, IFetchEmberVaultsOptions } from './types';
|
|
6
11
|
export declare const Sui: {
|
|
7
12
|
utils: typeof SuiUtils;
|
|
8
13
|
constants: typeof SuiConstants;
|
|
@@ -12,6 +17,16 @@ export declare const Sui: {
|
|
|
12
17
|
transformEmberVaultsToIVaults: typeof transformEmberVaultsToIVaults;
|
|
13
18
|
};
|
|
14
19
|
};
|
|
20
|
+
/**
|
|
21
|
+
* Sui Adapter for August SDK
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* To access the Sui adapter instance
|
|
25
|
+
* ```
|
|
26
|
+
* const sdk = new AugustSDK()
|
|
27
|
+
* sdk.sui.getEmberVaults()
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
15
30
|
declare class SuiAdapter {
|
|
16
31
|
private _apiBaseUrl;
|
|
17
32
|
private _chainId;
|
|
@@ -34,6 +34,11 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
36
|
exports.Sui = void 0;
|
|
37
|
+
/**
|
|
38
|
+
* Sui Adapter for August SDK
|
|
39
|
+
*
|
|
40
|
+
* @module SuiAdapter
|
|
41
|
+
*/
|
|
37
42
|
const SuiConstants = __importStar(require("./constants"));
|
|
38
43
|
const SuiGetters = __importStar(require("./getters"));
|
|
39
44
|
const SuiUtils = __importStar(require("./utils"));
|
|
@@ -44,7 +49,19 @@ exports.Sui = {
|
|
|
44
49
|
getters: SuiGetters,
|
|
45
50
|
transformer: { transformEmberVaultToIVault: transformer_1.transformEmberVaultToIVault, transformEmberVaultsToIVaults: transformer_1.transformEmberVaultsToIVaults },
|
|
46
51
|
};
|
|
52
|
+
/**
|
|
53
|
+
* Sui Adapter for August SDK
|
|
54
|
+
*
|
|
55
|
+
* @example
|
|
56
|
+
* To access the Sui adapter instance
|
|
57
|
+
* ```
|
|
58
|
+
* const sdk = new AugustSDK()
|
|
59
|
+
* sdk.sui.getEmberVaults()
|
|
60
|
+
* ```
|
|
61
|
+
*/
|
|
47
62
|
class SuiAdapter {
|
|
63
|
+
_apiBaseUrl;
|
|
64
|
+
_chainId;
|
|
48
65
|
constructor(apiBaseUrl = SuiConstants.EMBER_API_BASE_URL, chainId = SuiConstants.SUI_CHAIN_ID) {
|
|
49
66
|
this._apiBaseUrl = apiBaseUrl;
|
|
50
67
|
this._chainId = chainId;
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
-
import { IVault } from '../../types';
|
|
2
|
-
import { IEmberVault } from './types';
|
|
1
|
+
import type { IVault } from '../../types';
|
|
2
|
+
import type { IEmberVault } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Transform Ember vault to IVault format
|
|
5
|
+
*/
|
|
3
6
|
export declare function transformEmberVaultToIVault(emberVault: IEmberVault): IVault;
|
|
7
|
+
/**
|
|
8
|
+
* Transform multiple Ember vaults
|
|
9
|
+
*/
|
|
4
10
|
export declare function transformEmberVaultsToIVaults(emberVaults: IEmberVault[]): IVault[];
|
|
@@ -5,6 +5,9 @@ exports.transformEmberVaultsToIVaults = transformEmberVaultsToIVaults;
|
|
|
5
5
|
const core_1 = require("../../core");
|
|
6
6
|
const constants_1 = require("./constants");
|
|
7
7
|
const utils_1 = require("./utils");
|
|
8
|
+
/**
|
|
9
|
+
* Transform Ember vault to IVault format
|
|
10
|
+
*/
|
|
8
11
|
function transformEmberVaultToIVault(emberVault) {
|
|
9
12
|
const depositTokenDecimals = emberVault.depositCoin?.decimals || constants_1.EMBER_DEFAULTS.DECIMALS;
|
|
10
13
|
const receiptTokenDecimals = emberVault.receiptCoin?.decimals || constants_1.EMBER_DEFAULTS.DECIMALS;
|
|
@@ -56,6 +59,7 @@ function transformEmberVaultToIVault(emberVault) {
|
|
|
56
59
|
multiplier: 0,
|
|
57
60
|
multipliers: [],
|
|
58
61
|
additionalPoints: [],
|
|
62
|
+
additionalPointsDetailed: [],
|
|
59
63
|
},
|
|
60
64
|
version: constants_1.EMBER_DEFAULTS.VERSION,
|
|
61
65
|
description: emberVault.description || '',
|
|
@@ -94,6 +98,9 @@ function transformEmberVaultToIVault(emberVault) {
|
|
|
94
98
|
};
|
|
95
99
|
return returnObj;
|
|
96
100
|
}
|
|
101
|
+
/**
|
|
102
|
+
* Transform multiple Ember vaults
|
|
103
|
+
*/
|
|
97
104
|
function transformEmberVaultsToIVaults(emberVaults) {
|
|
98
105
|
return emberVaults.map(transformEmberVaultToIVault);
|
|
99
106
|
}
|
|
@@ -1,4 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Convert E9 format to regular number
|
|
3
|
+
*/
|
|
1
4
|
export declare function convertFromE9(value: string | number): number;
|
|
5
|
+
/**
|
|
6
|
+
* Calculate capacity utilization percentage
|
|
7
|
+
*/
|
|
2
8
|
export declare function calculateUtilization(current: string | number, maximum: string | number): number;
|
|
3
9
|
export { isSuiAddress } from '../../core/helpers/chain-address';
|
|
4
10
|
export declare function isSuiVault(chainId: number): boolean;
|
|
@@ -5,9 +5,15 @@ exports.convertFromE9 = convertFromE9;
|
|
|
5
5
|
exports.calculateUtilization = calculateUtilization;
|
|
6
6
|
exports.isSuiVault = isSuiVault;
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
|
+
/**
|
|
9
|
+
* Convert E9 format to regular number
|
|
10
|
+
*/
|
|
8
11
|
function convertFromE9(value) {
|
|
9
12
|
return Number(value) / constants_1.EMBER_DEFAULTS.E9_DIVISOR;
|
|
10
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Calculate capacity utilization percentage
|
|
16
|
+
*/
|
|
11
17
|
function calculateUtilization(current, maximum) {
|
|
12
18
|
const currentValue = Number(current) || 0;
|
|
13
19
|
const maxValue = Number(maximum) || 0;
|
|
@@ -1 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Map a numeric `chainId` to a stable lowercase slug for use as a Sentry tag
|
|
3
|
+
* value. Resolves both EVM chains ({@link NETWORKS}) and synthetic non-EVM
|
|
4
|
+
* chain IDs ({@link SPECIAL_CHAINS}); unknown IDs return `'unknown:<id>'`.
|
|
5
|
+
*
|
|
6
|
+
* @param chainId - Numeric chain ID, including negative IDs for non-EVM chains.
|
|
7
|
+
* @returns Slugified chain label (e.g. `'ethereum'`, `'arbitrum-one'`, `'solana'`).
|
|
8
|
+
*/
|
|
1
9
|
export declare function chainIdToTagValue(chainId: number | undefined): string;
|
|
@@ -2,6 +2,14 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.chainIdToTagValue = chainIdToTagValue;
|
|
4
4
|
const web3_1 = require("../constants/web3");
|
|
5
|
+
/**
|
|
6
|
+
* Map a numeric `chainId` to a stable lowercase slug for use as a Sentry tag
|
|
7
|
+
* value. Resolves both EVM chains ({@link NETWORKS}) and synthetic non-EVM
|
|
8
|
+
* chain IDs ({@link SPECIAL_CHAINS}); unknown IDs return `'unknown:<id>'`.
|
|
9
|
+
*
|
|
10
|
+
* @param chainId - Numeric chain ID, including negative IDs for non-EVM chains.
|
|
11
|
+
* @returns Slugified chain label (e.g. `'ethereum'`, `'arbitrum-one'`, `'solana'`).
|
|
12
|
+
*/
|
|
5
13
|
function chainIdToTagValue(chainId) {
|
|
6
14
|
if (chainId === undefined || chainId === null || Number.isNaN(chainId)) {
|
|
7
15
|
return 'unknown';
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.SENTRY_DSN = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* Sentry DSN for SDK analytics.
|
|
6
|
+
* This is an internal constant - not exposed to SDK users.
|
|
7
|
+
*/
|
|
4
8
|
exports.SENTRY_DSN = 'https://d73b6a85fe14960b8dac8ac61a743a94@o4507215496609792.ingest.de.sentry.io/4510699327389776';
|
|
5
9
|
//# sourceMappingURL=constants.js.map
|
|
@@ -1,4 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment-variable gates for analytics. Pure functions — safe to import
|
|
3
|
+
* anywhere, no Sentry side effects. Tested directly in `analytics.test.js`.
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Read a process env var without crashing in browsers or in bundles where
|
|
7
|
+
* `process.env` is a frozen / proxied object that throws on missing keys.
|
|
8
|
+
*/
|
|
1
9
|
export declare function readEnv(name: string): string | undefined;
|
|
10
|
+
/**
|
|
11
|
+
* `AUGUST_SDK_FORCE_ANALYTICS=1` bypasses the dev/test and localhost gates.
|
|
12
|
+
* Used by our own smoke-test script and by partners deliberately exercising
|
|
13
|
+
* telemetry in a non-prod environment.
|
|
14
|
+
*/
|
|
2
15
|
export declare function isAnalyticsForcedOnViaEnv(): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* `AUGUST_SDK_DISABLE_ANALYTICS=1` is the env equivalent of passing
|
|
18
|
+
* `analytics: { enabled: false }`. Useful when partners can't easily plumb
|
|
19
|
+
* config through (CI runners, ops scripts).
|
|
20
|
+
*/
|
|
3
21
|
export declare function isAnalyticsDisabledViaEnv(): boolean;
|
|
22
|
+
/**
|
|
23
|
+
* True when `NODE_ENV` is `'development'` or `'test'`. The SDK auto-disables
|
|
24
|
+
* analytics in these environments so partners' local dev runs and Jest suites
|
|
25
|
+
* don't pollute the production Sentry project.
|
|
26
|
+
*
|
|
27
|
+
* `NODE_ENV` undefined / `'production'` / `'staging'` / anything else → false.
|
|
28
|
+
*/
|
|
4
29
|
export declare function isNodeDevOrTestEnv(): boolean;
|