upshift-sdk 8.20.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +349 -0
- package/lib/abis/AddressResolver.d.ts +28 -0
- package/lib/abis/AddressResolver.js +23 -0
- package/lib/abis/ChainlinkV3.d.ts +87 -0
- package/lib/abis/ChainlinkV3.js +117 -0
- package/lib/abis/ERC20.d.ts +168 -0
- package/lib/abis/ERC20.js +226 -0
- package/lib/abis/ERC20_Bytes32.d.ts +139 -0
- package/lib/abis/ERC20_Bytes32.js +196 -0
- package/lib/abis/ERC4626.d.ts +364 -0
- package/lib/abis/ERC4626.js +507 -0
- package/lib/abis/ERC721.d.ts +231 -0
- package/lib/abis/ERC721.js +321 -0
- package/lib/abis/FeeOracle.d.ts +120 -0
- package/lib/abis/FeeOracle.js +162 -0
- package/lib/abis/LendingPool.d.ts +1393 -0
- package/lib/abis/LendingPool.js +1807 -0
- package/lib/abis/LendingPoolV2.d.ts +1413 -0
- package/lib/abis/LendingPoolV2.js +1833 -0
- package/lib/abis/LendingPoolV3.d.ts +1677 -0
- package/lib/abis/LendingPoolV3.js +1160 -0
- package/lib/abis/Loan.d.ts +837 -0
- package/lib/abis/Loan.js +1080 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.d.ts +137 -0
- package/lib/abis/MultiAssetNativeDepositWrapper.js +125 -0
- package/lib/abis/Multicall3.d.ts +30 -0
- package/lib/abis/Multicall3.js +97 -0
- package/lib/abis/OFT.d.ts +116 -0
- package/lib/abis/OFT.js +85 -0
- package/lib/abis/PoolAdapter.d.ts +36 -0
- package/lib/abis/PoolAdapter.js +51 -0
- package/lib/abis/RewardDistributor.d.ts +267 -0
- package/lib/abis/RewardDistributor.js +352 -0
- package/lib/abis/RwaRedeemSubaccount.d.ts +747 -0
- package/lib/abis/RwaRedeemSubaccount.js +548 -0
- package/lib/abis/SmartAccount.d.ts +17 -0
- package/lib/abis/SmartAccount.js +19 -0
- package/lib/abis/SwapRouter.d.ts +1043 -0
- package/lib/abis/SwapRouter.js +740 -0
- package/lib/abis/TextResolver.d.ts +16 -0
- package/lib/abis/TextResolver.js +16 -0
- package/lib/abis/TokenizedVaultV2.d.ts +1364 -0
- package/lib/abis/TokenizedVaultV2.js +1041 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.d.ts +1456 -0
- package/lib/abis/TokenizedVaultV2DepositWithPermit.js +1878 -0
- package/lib/abis/TokenizedVaultV2Receipt.d.ts +1568 -0
- package/lib/abis/TokenizedVaultV2Receipt.js +1061 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.d.ts +454 -0
- package/lib/abis/TokenizedVaultV2SenderAllocationWhitelist.js +327 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.d.ts +1466 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAllocation.js +1092 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.d.ts +274 -0
- package/lib/abis/TokenizedVaultV2WhitelistedAssets.js +167 -0
- package/lib/abis/UniversalResolverResolve.d.ts +69 -0
- package/lib/abis/UniversalResolverResolve.js +35 -0
- package/lib/abis/UniversalSignatureValidator.d.ts +17 -0
- package/lib/abis/UniversalSignatureValidator.js +30 -0
- package/lib/abis/WrapperAdapter.d.ts +71 -0
- package/lib/abis/WrapperAdapter.js +77 -0
- package/lib/abis/index.d.ts +34 -0
- package/lib/abis/index.js +51 -0
- package/lib/adapters/evm/getters.d.ts +19 -0
- package/lib/adapters/evm/getters.js +209 -0
- package/lib/adapters/evm/index.d.ts +353 -0
- package/lib/adapters/evm/index.js +434 -0
- package/lib/adapters/evm/utils.d.ts +8 -0
- package/lib/adapters/evm/utils.js +51 -0
- package/lib/adapters/solana/constants.d.ts +33 -0
- package/lib/adapters/solana/constants.js +52 -0
- package/lib/adapters/solana/getters.d.ts +11 -0
- package/lib/adapters/solana/getters.js +165 -0
- package/lib/adapters/solana/idl/vault-idl.d.ts +272 -0
- package/lib/adapters/solana/idl/vault-idl.js +1084 -0
- package/lib/adapters/solana/index.d.ts +233 -0
- package/lib/adapters/solana/index.js +291 -0
- package/lib/adapters/solana/types.d.ts +67 -0
- package/lib/adapters/solana/types.js +3 -0
- package/lib/adapters/solana/utils.d.ts +141 -0
- package/lib/adapters/solana/utils.js +595 -0
- package/lib/adapters/solana/vault.actions.d.ts +57 -0
- package/lib/adapters/solana/vault.actions.js +379 -0
- package/lib/adapters/stellar/actions.d.ts +28 -0
- package/lib/adapters/stellar/actions.js +77 -0
- package/lib/adapters/stellar/constants.d.ts +43 -0
- package/lib/adapters/stellar/constants.js +53 -0
- package/lib/adapters/stellar/getters.d.ts +68 -0
- package/lib/adapters/stellar/getters.js +290 -0
- package/lib/adapters/stellar/index.d.ts +114 -0
- package/lib/adapters/stellar/index.js +175 -0
- package/lib/adapters/stellar/soroban.d.ts +123 -0
- package/lib/adapters/stellar/soroban.js +613 -0
- package/lib/adapters/stellar/submit.d.ts +34 -0
- package/lib/adapters/stellar/submit.js +149 -0
- package/lib/adapters/stellar/types.d.ts +58 -0
- package/lib/adapters/stellar/types.js +6 -0
- package/lib/adapters/stellar/utils.d.ts +24 -0
- package/lib/adapters/stellar/utils.js +34 -0
- package/lib/adapters/sui/constants.d.ts +14 -0
- package/lib/adapters/sui/constants.js +29 -0
- package/lib/adapters/sui/getters.d.ts +9 -0
- package/lib/adapters/sui/getters.js +60 -0
- package/lib/adapters/sui/index.d.ts +45 -0
- package/lib/adapters/sui/index.js +101 -0
- package/lib/adapters/sui/transformer.d.ts +10 -0
- package/lib/adapters/sui/transformer.js +107 -0
- package/lib/adapters/sui/types.d.ts +66 -0
- package/lib/adapters/sui/types.js +3 -0
- package/lib/adapters/sui/utils.d.ts +10 -0
- package/lib/adapters/sui/utils.js +29 -0
- package/lib/core/analytics/chain-name.d.ts +9 -0
- package/lib/core/analytics/chain-name.js +34 -0
- package/lib/core/analytics/constants.d.ts +5 -0
- package/lib/core/analytics/constants.js +9 -0
- package/lib/core/analytics/env.d.ts +29 -0
- package/lib/core/analytics/env.js +59 -0
- package/lib/core/analytics/index.d.ts +36 -0
- package/lib/core/analytics/index.js +79 -0
- package/lib/core/analytics/instrumentation.d.ts +29 -0
- package/lib/core/analytics/instrumentation.js +277 -0
- package/lib/core/analytics/method-taxonomy.d.ts +19 -0
- package/lib/core/analytics/method-taxonomy.js +128 -0
- package/lib/core/analytics/metrics.d.ts +33 -0
- package/lib/core/analytics/metrics.js +116 -0
- package/lib/core/analytics/sanitize.d.ts +44 -0
- package/lib/core/analytics/sanitize.js +260 -0
- package/lib/core/analytics/sentry-runtime.d.ts +15 -0
- package/lib/core/analytics/sentry-runtime.js +97 -0
- package/lib/core/analytics/sentry.d.ts +67 -0
- package/lib/core/analytics/sentry.js +613 -0
- package/lib/core/analytics/types.d.ts +48 -0
- package/lib/core/analytics/types.js +3 -0
- package/lib/core/analytics/user-identity.d.ts +41 -0
- package/lib/core/analytics/user-identity.js +141 -0
- package/lib/core/analytics/version.d.ts +6 -0
- package/lib/core/analytics/version.js +10 -0
- package/lib/core/attribution.d.ts +111 -0
- package/lib/core/attribution.js +142 -0
- package/lib/core/auth/index.d.ts +1 -0
- package/lib/core/auth/index.js +18 -0
- package/lib/core/auth/verify.d.ts +2 -0
- package/lib/core/auth/verify.js +31 -0
- package/lib/core/base.class.d.ts +152 -0
- package/lib/core/base.class.js +172 -0
- package/lib/core/cache.d.ts +9 -0
- package/lib/core/cache.js +31 -0
- package/lib/core/constants/adapters.d.ts +103 -0
- package/lib/core/constants/adapters.js +180 -0
- package/lib/core/constants/core.d.ts +133 -0
- package/lib/core/constants/core.js +209 -0
- package/lib/core/constants/swap-router.d.ts +150 -0
- package/lib/core/constants/swap-router.js +169 -0
- package/lib/core/constants/vaults.d.ts +93 -0
- package/lib/core/constants/vaults.js +273 -0
- package/lib/core/constants/web3.d.ts +91 -0
- package/lib/core/constants/web3.js +229 -0
- package/lib/core/errors/index.d.ts +114 -0
- package/lib/core/errors/index.js +183 -0
- package/lib/core/fetcher.d.ts +198 -0
- package/lib/core/fetcher.js +903 -0
- package/lib/core/helpers/adapters.d.ts +13 -0
- package/lib/core/helpers/adapters.js +39 -0
- package/lib/core/helpers/chain-address.d.ts +13 -0
- package/lib/core/helpers/chain-address.js +47 -0
- package/lib/core/helpers/chain-error.d.ts +207 -0
- package/lib/core/helpers/chain-error.js +682 -0
- package/lib/core/helpers/chain-support.d.ts +80 -0
- package/lib/core/helpers/chain-support.js +115 -0
- package/lib/core/helpers/core.d.ts +68 -0
- package/lib/core/helpers/core.js +285 -0
- package/lib/core/helpers/explorer-link.d.ts +16 -0
- package/lib/core/helpers/explorer-link.js +26 -0
- package/lib/core/helpers/multicall.d.ts +68 -0
- package/lib/core/helpers/multicall.js +103 -0
- package/lib/core/helpers/revert-decode.d.ts +248 -0
- package/lib/core/helpers/revert-decode.js +515 -0
- package/lib/core/helpers/signer.d.ts +52 -0
- package/lib/core/helpers/signer.js +145 -0
- package/lib/core/helpers/swap-router.d.ts +211 -0
- package/lib/core/helpers/swap-router.js +480 -0
- package/lib/core/helpers/vault-version.d.ts +23 -0
- package/lib/core/helpers/vault-version.js +75 -0
- package/lib/core/helpers/vaults.d.ts +89 -0
- package/lib/core/helpers/vaults.js +235 -0
- package/lib/core/helpers/web3.d.ts +353 -0
- package/lib/core/helpers/web3.js +992 -0
- package/lib/core/index.d.ts +23 -0
- package/lib/core/index.js +40 -0
- package/lib/core/logger/index.d.ts +98 -0
- package/lib/core/logger/index.js +144 -0
- package/lib/core/logger/slack.d.ts +16 -0
- package/lib/core/logger/slack.js +57 -0
- package/lib/core/vault-metadata.d.ts +12 -0
- package/lib/core/vault-metadata.js +42 -0
- package/lib/core/version-check.d.ts +58 -0
- package/lib/core/version-check.js +182 -0
- package/lib/evm/index.d.ts +2 -0
- package/lib/evm/index.js +19 -0
- package/lib/evm/methods/crossChainVault.d.ts +128 -0
- package/lib/evm/methods/crossChainVault.js +853 -0
- package/lib/evm/methods/crossChainVaultRegistry.d.ts +93 -0
- package/lib/evm/methods/crossChainVaultRegistry.js +240 -0
- package/lib/evm/methods/index.d.ts +2 -0
- package/lib/evm/methods/index.js +19 -0
- package/lib/evm/types/crossChain.d.ts +363 -0
- package/lib/evm/types/crossChain.js +20 -0
- package/lib/evm/types/index.d.ts +1 -0
- package/lib/evm/types/index.js +18 -0
- package/lib/index.d.ts +30 -0
- package/lib/index.js +52 -0
- package/lib/main.d.ts +527 -0
- package/lib/main.js +601 -0
- package/lib/modules/api/fetcher.d.ts +82 -0
- package/lib/modules/api/fetcher.js +150 -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 +313 -0
- package/lib/modules/api/main.js +479 -0
- package/lib/modules/sub-accounts/fetcher.d.ts +53 -0
- package/lib/modules/sub-accounts/fetcher.js +120 -0
- package/lib/modules/sub-accounts/index.d.ts +2 -0
- package/lib/modules/sub-accounts/index.js +19 -0
- package/lib/modules/sub-accounts/main.d.ts +243 -0
- package/lib/modules/sub-accounts/main.js +205 -0
- package/lib/modules/sub-accounts/utils.d.ts +106 -0
- package/lib/modules/sub-accounts/utils.js +112 -0
- package/lib/modules/vaults/adapter.helpers.d.ts +64 -0
- package/lib/modules/vaults/adapter.helpers.js +184 -0
- package/lib/modules/vaults/fetcher.d.ts +147 -0
- package/lib/modules/vaults/fetcher.js +368 -0
- package/lib/modules/vaults/getters.d.ts +570 -0
- package/lib/modules/vaults/getters.js +3051 -0
- package/lib/modules/vaults/index.d.ts +20 -0
- package/lib/modules/vaults/index.js +44 -0
- package/lib/modules/vaults/main.d.ts +601 -0
- package/lib/modules/vaults/main.js +1623 -0
- package/lib/modules/vaults/prefetch.d.ts +65 -0
- package/lib/modules/vaults/prefetch.js +120 -0
- package/lib/modules/vaults/read.actions.d.ts +225 -0
- package/lib/modules/vaults/read.actions.js +596 -0
- package/lib/modules/vaults/types.d.ts +71 -0
- package/lib/modules/vaults/types.js +3 -0
- package/lib/modules/vaults/utils/call-data-decoder.d.ts +61 -0
- package/lib/modules/vaults/utils/call-data-decoder.js +194 -0
- package/lib/modules/vaults/utils/date-utils.d.ts +50 -0
- package/lib/modules/vaults/utils/date-utils.js +84 -0
- package/lib/modules/vaults/utils.d.ts +140 -0
- package/lib/modules/vaults/utils.js +799 -0
- package/lib/modules/vaults/write.actions.d.ts +529 -0
- package/lib/modules/vaults/write.actions.js +1749 -0
- package/lib/polyfills.d.ts +1 -0
- package/lib/polyfills.js +12 -0
- package/lib/sdk.d.ts +26721 -0
- package/lib/services/coingecko/fetcher.d.ts +15 -0
- package/lib/services/coingecko/fetcher.js +67 -0
- package/lib/services/coingecko/index.d.ts +2 -0
- package/lib/services/coingecko/index.js +19 -0
- package/lib/services/coingecko/utils.d.ts +1 -0
- package/lib/services/coingecko/utils.js +24 -0
- package/lib/services/debank/fetcher.d.ts +126 -0
- package/lib/services/debank/fetcher.js +47 -0
- package/lib/services/debank/index.d.ts +2 -0
- package/lib/services/debank/index.js +19 -0
- package/lib/services/debank/utils.d.ts +38 -0
- package/lib/services/debank/utils.js +297 -0
- package/lib/services/layerzero/deposits.d.ts +49 -0
- package/lib/services/layerzero/deposits.js +166 -0
- package/lib/services/layerzero/redeems.d.ts +20 -0
- package/lib/services/layerzero/redeems.js +92 -0
- package/lib/services/layerzero/utils.d.ts +9 -0
- package/lib/services/layerzero/utils.js +22 -0
- package/lib/services/octavfi/fetcher.d.ts +9 -0
- package/lib/services/octavfi/fetcher.js +103 -0
- package/lib/services/octavfi/index.d.ts +3 -0
- package/lib/services/octavfi/index.js +20 -0
- package/lib/services/octavfi/types.d.ts +34 -0
- package/lib/services/octavfi/types.js +3 -0
- package/lib/services/octavfi/utils.d.ts +16 -0
- package/lib/services/octavfi/utils.js +212 -0
- package/lib/services/subgraph/fetcher.d.ts +2 -0
- package/lib/services/subgraph/fetcher.js +61 -0
- package/lib/services/subgraph/index.d.ts +2 -0
- package/lib/services/subgraph/index.js +19 -0
- package/lib/services/subgraph/schema.d.ts +45 -0
- package/lib/services/subgraph/schema.js +75 -0
- package/lib/services/subgraph/vaults.d.ts +25 -0
- package/lib/services/subgraph/vaults.js +1106 -0
- package/lib/services/swap-quotes/index.d.ts +105 -0
- package/lib/services/swap-quotes/index.js +77 -0
- package/lib/services/swap-quotes/paraswap.d.ts +51 -0
- package/lib/services/swap-quotes/paraswap.js +138 -0
- package/lib/types/api.d.ts +280 -0
- package/lib/types/api.js +3 -0
- package/lib/types/index.d.ts +12 -0
- package/lib/types/index.js +28 -0
- package/lib/types/points.d.ts +28 -0
- package/lib/types/points.js +3 -0
- package/lib/types/pools.d.ts +144 -0
- package/lib/types/pools.js +3 -0
- package/lib/types/staking.d.ts +28 -0
- package/lib/types/staking.js +3 -0
- package/lib/types/sub-accounts.d.ts +140 -0
- package/lib/types/sub-accounts.js +3 -0
- package/lib/types/subgraph.d.ts +74 -0
- package/lib/types/subgraph.js +3 -0
- package/lib/types/typed-contract.d.ts +102 -0
- package/lib/types/typed-contract.js +3 -0
- package/lib/types/user.d.ts +1 -0
- package/lib/types/user.js +3 -0
- package/lib/types/vaults.d.ts +714 -0
- package/lib/types/vaults.js +24 -0
- package/lib/types/web3.d.ts +51 -0
- package/lib/types/web3.js +14 -0
- package/lib/types/webserver.d.ts +698 -0
- package/lib/types/webserver.js +3 -0
- package/package.json +78 -0
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import type { IEnv } from '../../types';
|
|
2
|
+
import type { IUserIdentity } from './types';
|
|
3
|
+
/**
|
|
4
|
+
* Mask an API key, keeping only the last 5 characters visible.
|
|
5
|
+
* Example: "abcdefghij12345" -> "**********12345"
|
|
6
|
+
*
|
|
7
|
+
* @param apiKey - The raw API key to mask
|
|
8
|
+
* @returns Masked API key with last 5 characters visible
|
|
9
|
+
*/
|
|
10
|
+
export declare function hashApiKey(apiKey: string): string;
|
|
11
|
+
/**
|
|
12
|
+
* Generate a session ID that persists for the SDK instance lifetime.
|
|
13
|
+
* Provides user continuity even when wallet is not connected.
|
|
14
|
+
*
|
|
15
|
+
* @returns UUID v4 session identifier
|
|
16
|
+
*/
|
|
17
|
+
export declare function getSessionId(): string;
|
|
18
|
+
/**
|
|
19
|
+
* Generate a browser/environment fingerprint for cross-session tracking.
|
|
20
|
+
* Falls back gracefully in different environments.
|
|
21
|
+
*
|
|
22
|
+
* @returns Base64 encoded fingerprint string or undefined if unavailable
|
|
23
|
+
*/
|
|
24
|
+
export declare function generateFingerprint(): string | undefined;
|
|
25
|
+
/**
|
|
26
|
+
* Create a composite user identity for analytics.
|
|
27
|
+
*
|
|
28
|
+
* @param apiKey - Optional API key (will be hashed, never stored raw)
|
|
29
|
+
* @param walletAddress - Optional wallet address
|
|
30
|
+
* @param environment - Current environment (DEV or PROD)
|
|
31
|
+
* @returns User identity object
|
|
32
|
+
*/
|
|
33
|
+
export declare function createUserIdentity(apiKey?: string, walletAddress?: string, environment?: IEnv): IUserIdentity;
|
|
34
|
+
/**
|
|
35
|
+
* Generate a unique user ID for Sentry from identity components.
|
|
36
|
+
* Priority: apiKeyHash > wallet > fingerprint > session
|
|
37
|
+
*
|
|
38
|
+
* @param identity - User identity object
|
|
39
|
+
* @returns Prefixed user ID string
|
|
40
|
+
*/
|
|
41
|
+
export declare function getUserId(identity: IUserIdentity): string;
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.hashApiKey = hashApiKey;
|
|
4
|
+
exports.getSessionId = getSessionId;
|
|
5
|
+
exports.generateFingerprint = generateFingerprint;
|
|
6
|
+
exports.createUserIdentity = createUserIdentity;
|
|
7
|
+
exports.getUserId = getUserId;
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
9
|
+
const uuid_1 = require("uuid");
|
|
10
|
+
/** Session ID persists for SDK instance lifetime */
|
|
11
|
+
let sessionId = null;
|
|
12
|
+
/** Cached masked API key */
|
|
13
|
+
let cachedMaskedApiKey = null;
|
|
14
|
+
/**
|
|
15
|
+
* Mask an API key, keeping only the last 5 characters visible.
|
|
16
|
+
* Example: "abcdefghij12345" -> "**********12345"
|
|
17
|
+
*
|
|
18
|
+
* @param apiKey - The raw API key to mask
|
|
19
|
+
* @returns Masked API key with last 5 characters visible
|
|
20
|
+
*/
|
|
21
|
+
function hashApiKey(apiKey) {
|
|
22
|
+
if (!apiKey)
|
|
23
|
+
return '';
|
|
24
|
+
// Use cached masked key if available
|
|
25
|
+
if (cachedMaskedApiKey)
|
|
26
|
+
return cachedMaskedApiKey;
|
|
27
|
+
const visibleChars = 5;
|
|
28
|
+
if (apiKey.length <= visibleChars) {
|
|
29
|
+
cachedMaskedApiKey = apiKey;
|
|
30
|
+
}
|
|
31
|
+
else {
|
|
32
|
+
const masked = '*'.repeat(apiKey.length - visibleChars);
|
|
33
|
+
const visible = apiKey.slice(-visibleChars);
|
|
34
|
+
cachedMaskedApiKey = masked + visible;
|
|
35
|
+
}
|
|
36
|
+
return cachedMaskedApiKey;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Generate a session ID that persists for the SDK instance lifetime.
|
|
40
|
+
* Provides user continuity even when wallet is not connected.
|
|
41
|
+
*
|
|
42
|
+
* @returns UUID v4 session identifier
|
|
43
|
+
*/
|
|
44
|
+
function getSessionId() {
|
|
45
|
+
if (!sessionId) {
|
|
46
|
+
sessionId = (0, uuid_1.v4)();
|
|
47
|
+
}
|
|
48
|
+
return sessionId;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Generate a browser/environment fingerprint for cross-session tracking.
|
|
52
|
+
* Falls back gracefully in different environments.
|
|
53
|
+
*
|
|
54
|
+
* @returns Base64 encoded fingerprint string or undefined if unavailable
|
|
55
|
+
*/
|
|
56
|
+
function generateFingerprint() {
|
|
57
|
+
try {
|
|
58
|
+
// Browser environment
|
|
59
|
+
if (typeof window !== 'undefined' && typeof navigator !== 'undefined') {
|
|
60
|
+
const components = [
|
|
61
|
+
navigator.userAgent,
|
|
62
|
+
navigator.language,
|
|
63
|
+
new Date().getTimezoneOffset().toString(),
|
|
64
|
+
typeof screen !== 'undefined' ? screen.width?.toString() : '',
|
|
65
|
+
typeof screen !== 'undefined' ? screen.height?.toString() : '',
|
|
66
|
+
typeof screen !== 'undefined' ? screen.colorDepth?.toString() : '',
|
|
67
|
+
].filter(Boolean);
|
|
68
|
+
// Create a simple hash from components
|
|
69
|
+
const hash = (0, crypto_1.createHash)('sha256')
|
|
70
|
+
.update(components.join('|'))
|
|
71
|
+
.digest('hex');
|
|
72
|
+
return hash.substring(0, 32);
|
|
73
|
+
}
|
|
74
|
+
// Node.js environment
|
|
75
|
+
if (typeof process !== 'undefined' && process.platform) {
|
|
76
|
+
const components = [process.platform, process.arch, process.version];
|
|
77
|
+
const hash = (0, crypto_1.createHash)('sha256')
|
|
78
|
+
.update(components.join('|'))
|
|
79
|
+
.digest('hex');
|
|
80
|
+
return hash.substring(0, 32);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
catch {
|
|
84
|
+
// Silently fail if fingerprinting is not possible
|
|
85
|
+
return undefined;
|
|
86
|
+
}
|
|
87
|
+
return undefined;
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Create a composite user identity for analytics.
|
|
91
|
+
*
|
|
92
|
+
* @param apiKey - Optional API key (will be hashed, never stored raw)
|
|
93
|
+
* @param walletAddress - Optional wallet address
|
|
94
|
+
* @param environment - Current environment (DEV or PROD)
|
|
95
|
+
* @returns User identity object
|
|
96
|
+
*/
|
|
97
|
+
function createUserIdentity(apiKey, walletAddress, environment = 'PROD') {
|
|
98
|
+
let domain;
|
|
99
|
+
try {
|
|
100
|
+
if (typeof window !== 'undefined' && window.location) {
|
|
101
|
+
domain = window.location.hostname;
|
|
102
|
+
}
|
|
103
|
+
else if (typeof process !== 'undefined' && process.env) {
|
|
104
|
+
domain = process.env.VERCEL_PROJECT_PRODUCTION_URL || undefined;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Silently fail - domain is optional
|
|
109
|
+
}
|
|
110
|
+
return {
|
|
111
|
+
apiKeyHash: apiKey ? hashApiKey(apiKey) : undefined,
|
|
112
|
+
walletAddress: walletAddress?.toLowerCase(),
|
|
113
|
+
sessionId: getSessionId(),
|
|
114
|
+
fingerprint: generateFingerprint(),
|
|
115
|
+
environment,
|
|
116
|
+
domain,
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Generate a unique user ID for Sentry from identity components.
|
|
121
|
+
* Priority: apiKeyHash > wallet > fingerprint > session
|
|
122
|
+
*
|
|
123
|
+
* @param identity - User identity object
|
|
124
|
+
* @returns Prefixed user ID string
|
|
125
|
+
*/
|
|
126
|
+
function getUserId(identity) {
|
|
127
|
+
if (identity.domain) {
|
|
128
|
+
return `domain:${identity.domain}`;
|
|
129
|
+
}
|
|
130
|
+
if (identity.apiKeyHash) {
|
|
131
|
+
return `apikey:${identity.apiKeyHash}`;
|
|
132
|
+
}
|
|
133
|
+
if (identity.walletAddress) {
|
|
134
|
+
return `wallet:${identity.walletAddress}`;
|
|
135
|
+
}
|
|
136
|
+
if (identity.fingerprint) {
|
|
137
|
+
return `fp:${identity.fingerprint}`;
|
|
138
|
+
}
|
|
139
|
+
return `session:${identity.sessionId}`;
|
|
140
|
+
}
|
|
141
|
+
//# sourceMappingURL=user-identity.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SDK_VERSION = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* AUTO-GENERATED FILE - DO NOT EDIT
|
|
6
|
+
* Generated during publish from package.json version
|
|
7
|
+
* This file is gitignored and created at publish time
|
|
8
|
+
*/
|
|
9
|
+
exports.SDK_VERSION = '8.20.1';
|
|
10
|
+
//# sourceMappingURL=version.js.map
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* ERC-8021 transaction attribution (Base Builder Codes).
|
|
3
|
+
*
|
|
4
|
+
* ERC-8021 appends an attribution suffix to transaction calldata. Contracts
|
|
5
|
+
* decode their ABI-encoded arguments normally and ignore the trailing bytes,
|
|
6
|
+
* while offchain indexers (e.g. base.dev analytics for Base Builder Codes)
|
|
7
|
+
* read the suffix to attribute the transaction to the originating app.
|
|
8
|
+
*
|
|
9
|
+
* This is a leaf module: process-global state configured once via
|
|
10
|
+
* {@link IAugustBase.attribution} in the SDK constructor and read by the
|
|
11
|
+
* EVM write paths (the normalized-signer wrap in the EVM adapter and the
|
|
12
|
+
* cross-chain vault `writeContract` calls).
|
|
13
|
+
*
|
|
14
|
+
* @module attribution
|
|
15
|
+
*/
|
|
16
|
+
/**
|
|
17
|
+
* The 16-byte ERC-8021 suffix terminator. The last 16 bytes of an attributed
|
|
18
|
+
* transaction's calldata are always this marker; parsers read backwards from
|
|
19
|
+
* it to recover the schema ID and builder codes.
|
|
20
|
+
*/
|
|
21
|
+
export declare const ERC8021_MARKER = "80218021802180218021802180218021";
|
|
22
|
+
/**
|
|
23
|
+
* Configuration for ERC-8021 calldata-suffix attribution (Base Builder Codes).
|
|
24
|
+
*
|
|
25
|
+
* @example
|
|
26
|
+
* ```typescript
|
|
27
|
+
* const sdk = new AugustSDK({
|
|
28
|
+
* appName: 'my-app',
|
|
29
|
+
* providers: { 8453: 'https://...' },
|
|
30
|
+
* keys: { august: '...' },
|
|
31
|
+
* attribution: { builderCodes: ['bc_abc123'] },
|
|
32
|
+
* });
|
|
33
|
+
* ```
|
|
34
|
+
*/
|
|
35
|
+
export interface IAttributionConfig {
|
|
36
|
+
/**
|
|
37
|
+
* Builder codes to embed in the suffix, e.g. from base.dev registration
|
|
38
|
+
* (`bc_…`). ASCII strings of 1–64 characters each; the comma-joined list
|
|
39
|
+
* must fit in 255 bytes (schema 0 length prefix is a single byte).
|
|
40
|
+
*/
|
|
41
|
+
builderCodes: string[];
|
|
42
|
+
/**
|
|
43
|
+
* EVM chain IDs to attribute. Omit to attribute writes on every EVM chain
|
|
44
|
+
* (the suffix is inert on chains without an ERC-8021 indexer and costs
|
|
45
|
+
* ~16 gas per non-zero byte). When set, writes on other chains are sent
|
|
46
|
+
* without the suffix; call sites that cannot determine their chain ID
|
|
47
|
+
* append the suffix regardless, since over-attribution is harmless and
|
|
48
|
+
* under-attribution loses data.
|
|
49
|
+
*/
|
|
50
|
+
chains?: number[];
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build an ERC-8021 schema-0 attribution suffix from builder codes.
|
|
54
|
+
*
|
|
55
|
+
* Layout (appended to calldata, read back-to-front by parsers):
|
|
56
|
+
* `ascii(codes.join(','))` ∥ codesLength (1 byte) ∥ schemaId `0x00` ∥
|
|
57
|
+
* 16-byte marker `0x80218021802180218021802180218021`.
|
|
58
|
+
*
|
|
59
|
+
* @param codes Builder codes as printable-ASCII strings (e.g. `bc_abc123`),
|
|
60
|
+
* each 1–64 chars, no commas; the comma-joined list must be ≤ 255 bytes.
|
|
61
|
+
* @returns `0x`-prefixed hex suffix ready to concatenate onto calldata.
|
|
62
|
+
* @throws Error when `codes` is empty, a code contains a comma or
|
|
63
|
+
* non-printable/non-ASCII characters, or the joined list exceeds 255 bytes.
|
|
64
|
+
* @example
|
|
65
|
+
* ```typescript
|
|
66
|
+
* buildAttributionSuffix(['baseapp', 'morpho']);
|
|
67
|
+
* // '0x626173656170702c6d6f7270686f0e0080218021802180218021802180218021'
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare function buildAttributionSuffix(codes: string[]): string;
|
|
71
|
+
/**
|
|
72
|
+
* Set (or clear) the process-global attribution config.
|
|
73
|
+
*
|
|
74
|
+
* Called unconditionally on every `AugustSDK` construction — an instance
|
|
75
|
+
* that omits `attribution` passes `null` and RESETS the state, so a prior
|
|
76
|
+
* instance's builder codes never leak into a later instance in the same
|
|
77
|
+
* process (same semantics as `setPublicApiBaseUrl`).
|
|
78
|
+
*
|
|
79
|
+
* @param config Attribution config from the SDK constructor, or `null` to
|
|
80
|
+
* disable attribution.
|
|
81
|
+
* @throws Error when the config's builder codes fail validation — thrown
|
|
82
|
+
* synchronously from the constructor so misconfiguration is caught at
|
|
83
|
+
* init, not on the first write.
|
|
84
|
+
*/
|
|
85
|
+
export declare function setAttribution(config: IAttributionConfig | null): void;
|
|
86
|
+
/**
|
|
87
|
+
* Return the active ERC-8021 suffix for a write on the given chain, or
|
|
88
|
+
* `undefined` when attribution is off or the chain is excluded.
|
|
89
|
+
*
|
|
90
|
+
* @param chainId EVM chain ID of the transaction, when the call site knows
|
|
91
|
+
* it. When omitted and a `chains` restriction is configured, the suffix is
|
|
92
|
+
* returned anyway (over-attribution is harmless; see
|
|
93
|
+
* {@link IAttributionConfig.chains}).
|
|
94
|
+
* @returns `0x`-prefixed hex suffix, or `undefined` when nothing should be
|
|
95
|
+
* appended.
|
|
96
|
+
*/
|
|
97
|
+
export declare function getAttributionSuffix(chainId?: number): string | undefined;
|
|
98
|
+
/**
|
|
99
|
+
* Append the active attribution suffix to calldata.
|
|
100
|
+
*
|
|
101
|
+
* No-ops (returns `data` unchanged) when attribution is off, the chain is
|
|
102
|
+
* excluded, `data` is empty/absent (plain value transfers are never
|
|
103
|
+
* attributed), or `data` already ends with the ERC-8021 marker (guards
|
|
104
|
+
* against double-appending when an upstream layer — e.g. a wagmi config
|
|
105
|
+
* `dataSuffix` — already attributed the transaction).
|
|
106
|
+
*
|
|
107
|
+
* @param data `0x`-prefixed calldata of the outgoing transaction.
|
|
108
|
+
* @param chainId EVM chain ID of the transaction, when known.
|
|
109
|
+
* @returns Calldata with the suffix appended, or the input unchanged.
|
|
110
|
+
*/
|
|
111
|
+
export declare function appendAttributionSuffix(data: string | undefined | null, chainId?: number): string | undefined | null;
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* ERC-8021 transaction attribution (Base Builder Codes).
|
|
4
|
+
*
|
|
5
|
+
* ERC-8021 appends an attribution suffix to transaction calldata. Contracts
|
|
6
|
+
* decode their ABI-encoded arguments normally and ignore the trailing bytes,
|
|
7
|
+
* while offchain indexers (e.g. base.dev analytics for Base Builder Codes)
|
|
8
|
+
* read the suffix to attribute the transaction to the originating app.
|
|
9
|
+
*
|
|
10
|
+
* This is a leaf module: process-global state configured once via
|
|
11
|
+
* {@link IAugustBase.attribution} in the SDK constructor and read by the
|
|
12
|
+
* EVM write paths (the normalized-signer wrap in the EVM adapter and the
|
|
13
|
+
* cross-chain vault `writeContract` calls).
|
|
14
|
+
*
|
|
15
|
+
* @module attribution
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.ERC8021_MARKER = void 0;
|
|
19
|
+
exports.buildAttributionSuffix = buildAttributionSuffix;
|
|
20
|
+
exports.setAttribution = setAttribution;
|
|
21
|
+
exports.getAttributionSuffix = getAttributionSuffix;
|
|
22
|
+
exports.appendAttributionSuffix = appendAttributionSuffix;
|
|
23
|
+
/**
|
|
24
|
+
* The 16-byte ERC-8021 suffix terminator. The last 16 bytes of an attributed
|
|
25
|
+
* transaction's calldata are always this marker; parsers read backwards from
|
|
26
|
+
* it to recover the schema ID and builder codes.
|
|
27
|
+
*/
|
|
28
|
+
exports.ERC8021_MARKER = '80218021802180218021802180218021';
|
|
29
|
+
/**
|
|
30
|
+
* Build an ERC-8021 schema-0 attribution suffix from builder codes.
|
|
31
|
+
*
|
|
32
|
+
* Layout (appended to calldata, read back-to-front by parsers):
|
|
33
|
+
* `ascii(codes.join(','))` ∥ codesLength (1 byte) ∥ schemaId `0x00` ∥
|
|
34
|
+
* 16-byte marker `0x80218021802180218021802180218021`.
|
|
35
|
+
*
|
|
36
|
+
* @param codes Builder codes as printable-ASCII strings (e.g. `bc_abc123`),
|
|
37
|
+
* each 1–64 chars, no commas; the comma-joined list must be ≤ 255 bytes.
|
|
38
|
+
* @returns `0x`-prefixed hex suffix ready to concatenate onto calldata.
|
|
39
|
+
* @throws Error when `codes` is empty, a code contains a comma or
|
|
40
|
+
* non-printable/non-ASCII characters, or the joined list exceeds 255 bytes.
|
|
41
|
+
* @example
|
|
42
|
+
* ```typescript
|
|
43
|
+
* buildAttributionSuffix(['baseapp', 'morpho']);
|
|
44
|
+
* // '0x626173656170702c6d6f7270686f0e0080218021802180218021802180218021'
|
|
45
|
+
* ```
|
|
46
|
+
*/
|
|
47
|
+
function buildAttributionSuffix(codes) {
|
|
48
|
+
if (!Array.isArray(codes) || codes.length === 0) {
|
|
49
|
+
throw new Error('August SDK: attribution.builderCodes must be a non-empty array of builder-code strings (e.g. ["bc_abc123"]). Register at https://base.dev to obtain one.');
|
|
50
|
+
}
|
|
51
|
+
for (const code of codes) {
|
|
52
|
+
if (typeof code !== 'string' ||
|
|
53
|
+
code.length === 0 ||
|
|
54
|
+
code.length > 64 ||
|
|
55
|
+
!/^[\x21-\x7e]+$/.test(code) ||
|
|
56
|
+
code.includes(',')) {
|
|
57
|
+
throw new Error(`August SDK: invalid builder code "${code}". Codes must be 1-64 printable ASCII characters with no commas or whitespace.`);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
const joined = codes.join(',');
|
|
61
|
+
if (joined.length > 255) {
|
|
62
|
+
throw new Error(`August SDK: attribution builder codes exceed 255 bytes when comma-joined (got ${joined.length}). Use fewer or shorter codes.`);
|
|
63
|
+
}
|
|
64
|
+
let hex = '';
|
|
65
|
+
for (let i = 0; i < joined.length; i++) {
|
|
66
|
+
hex += joined.charCodeAt(i).toString(16).padStart(2, '0');
|
|
67
|
+
}
|
|
68
|
+
const length = joined.length.toString(16).padStart(2, '0');
|
|
69
|
+
return `0x${hex}${length}00${exports.ERC8021_MARKER}`;
|
|
70
|
+
}
|
|
71
|
+
let activeSuffix = null;
|
|
72
|
+
let activeChains = null;
|
|
73
|
+
/**
|
|
74
|
+
* Set (or clear) the process-global attribution config.
|
|
75
|
+
*
|
|
76
|
+
* Called unconditionally on every `AugustSDK` construction — an instance
|
|
77
|
+
* that omits `attribution` passes `null` and RESETS the state, so a prior
|
|
78
|
+
* instance's builder codes never leak into a later instance in the same
|
|
79
|
+
* process (same semantics as `setPublicApiBaseUrl`).
|
|
80
|
+
*
|
|
81
|
+
* @param config Attribution config from the SDK constructor, or `null` to
|
|
82
|
+
* disable attribution.
|
|
83
|
+
* @throws Error when the config's builder codes fail validation — thrown
|
|
84
|
+
* synchronously from the constructor so misconfiguration is caught at
|
|
85
|
+
* init, not on the first write.
|
|
86
|
+
*/
|
|
87
|
+
function setAttribution(config) {
|
|
88
|
+
if (!config) {
|
|
89
|
+
activeSuffix = null;
|
|
90
|
+
activeChains = null;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
activeSuffix = buildAttributionSuffix(config.builderCodes);
|
|
94
|
+
activeChains =
|
|
95
|
+
Array.isArray(config.chains) && config.chains.length > 0
|
|
96
|
+
? config.chains
|
|
97
|
+
: null;
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Return the active ERC-8021 suffix for a write on the given chain, or
|
|
101
|
+
* `undefined` when attribution is off or the chain is excluded.
|
|
102
|
+
*
|
|
103
|
+
* @param chainId EVM chain ID of the transaction, when the call site knows
|
|
104
|
+
* it. When omitted and a `chains` restriction is configured, the suffix is
|
|
105
|
+
* returned anyway (over-attribution is harmless; see
|
|
106
|
+
* {@link IAttributionConfig.chains}).
|
|
107
|
+
* @returns `0x`-prefixed hex suffix, or `undefined` when nothing should be
|
|
108
|
+
* appended.
|
|
109
|
+
*/
|
|
110
|
+
function getAttributionSuffix(chainId) {
|
|
111
|
+
if (!activeSuffix)
|
|
112
|
+
return undefined;
|
|
113
|
+
if (activeChains && typeof chainId === 'number') {
|
|
114
|
+
if (!activeChains.includes(chainId))
|
|
115
|
+
return undefined;
|
|
116
|
+
}
|
|
117
|
+
return activeSuffix;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Append the active attribution suffix to calldata.
|
|
121
|
+
*
|
|
122
|
+
* No-ops (returns `data` unchanged) when attribution is off, the chain is
|
|
123
|
+
* excluded, `data` is empty/absent (plain value transfers are never
|
|
124
|
+
* attributed), or `data` already ends with the ERC-8021 marker (guards
|
|
125
|
+
* against double-appending when an upstream layer — e.g. a wagmi config
|
|
126
|
+
* `dataSuffix` — already attributed the transaction).
|
|
127
|
+
*
|
|
128
|
+
* @param data `0x`-prefixed calldata of the outgoing transaction.
|
|
129
|
+
* @param chainId EVM chain ID of the transaction, when known.
|
|
130
|
+
* @returns Calldata with the suffix appended, or the input unchanged.
|
|
131
|
+
*/
|
|
132
|
+
function appendAttributionSuffix(data, chainId) {
|
|
133
|
+
const suffix = getAttributionSuffix(chainId);
|
|
134
|
+
if (!suffix)
|
|
135
|
+
return data;
|
|
136
|
+
if (typeof data !== 'string' || data === '' || data === '0x')
|
|
137
|
+
return data;
|
|
138
|
+
if (data.toLowerCase().endsWith(exports.ERC8021_MARKER))
|
|
139
|
+
return data;
|
|
140
|
+
return data + suffix.slice(2);
|
|
141
|
+
}
|
|
142
|
+
//# sourceMappingURL=attribution.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './verify';
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./verify"), exports);
|
|
18
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyInfuraKey = verifyInfuraKey;
|
|
4
|
+
exports.verifyAugustKey = verifyAugustKey;
|
|
5
|
+
const core_1 = require("../constants/core");
|
|
6
|
+
const fetcher_1 = require("../fetcher");
|
|
7
|
+
async function verifyInfuraKey(key) {
|
|
8
|
+
if (key.length !== 32)
|
|
9
|
+
return false;
|
|
10
|
+
const regex = /[a-z0-9]+/i;
|
|
11
|
+
if (!regex.test(key))
|
|
12
|
+
return false;
|
|
13
|
+
return true;
|
|
14
|
+
}
|
|
15
|
+
async function verifyAugustKey(key) {
|
|
16
|
+
// Fast path: no key means no verification possible. Returning false here
|
|
17
|
+
// preserves the historical contract (`init()` throws a generic "API key is invalid")
|
|
18
|
+
// and avoids letting an AUTH_MISSING_KEY error bubble up from the fetcher.
|
|
19
|
+
if (!key)
|
|
20
|
+
return false;
|
|
21
|
+
try {
|
|
22
|
+
const verify = await (0, fetcher_1.fetchAugustWithKey)(key, core_1.WEBSERVER_ENDPOINTS.auth.verify);
|
|
23
|
+
return verify.status === 200;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Network errors, timeouts, and any future thrown auth errors all
|
|
27
|
+
// resolve to "key not verified" here. Callers handle this as a boolean.
|
|
28
|
+
return false;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
//# sourceMappingURL=verify.js.map
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
import type { ISolanaConfig, IStellarConfig, IAddress, IChainId, IEnv, IProvidersConfig, IWSMonitorHeaders } from '../types';
|
|
2
|
+
import { type IAnalyticsConfig } from './analytics';
|
|
3
|
+
import { type IVersionCheckConfig } from './version-check';
|
|
4
|
+
import { type IAttributionConfig } from './attribution';
|
|
5
|
+
interface IKeys {
|
|
6
|
+
august?: string;
|
|
7
|
+
graph?: string;
|
|
8
|
+
coingecko?: string;
|
|
9
|
+
}
|
|
10
|
+
interface IMonitoring extends IWSMonitorHeaders {
|
|
11
|
+
slackWebhookUrl?: string;
|
|
12
|
+
env?: IEnv;
|
|
13
|
+
}
|
|
14
|
+
export interface IAugustBase {
|
|
15
|
+
/**
|
|
16
|
+
* Identifier-shaped name for the integrating application. Required.
|
|
17
|
+
*
|
|
18
|
+
* Pick a stable, kebab-case slug that identifies your product (e.g.
|
|
19
|
+
* `"acme-trader"`, `"my-defi-app"`). The SDK includes it on outbound
|
|
20
|
+
* analytics events so August Digital can see who's hitting which methods
|
|
21
|
+
* and reach out about breaking changes or critical bugs.
|
|
22
|
+
*
|
|
23
|
+
* Despite the friendly `appName` label, the value is used as a Sentry
|
|
24
|
+
* tag and HTTP header, so it must be identifier-shaped:
|
|
25
|
+
* 3–64 characters, `[a-zA-Z0-9._-]` only. Use a slug ("acme-trader"),
|
|
26
|
+
* not a display name ("Acme Trader").
|
|
27
|
+
*
|
|
28
|
+
* @throws Throws synchronously from the constructor if missing or empty.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* ```typescript
|
|
32
|
+
* const sdk = new AugustSDK({
|
|
33
|
+
* appName: 'acme-trader',
|
|
34
|
+
* providers: { 1: 'https://...' },
|
|
35
|
+
* keys: { august: '...' },
|
|
36
|
+
* });
|
|
37
|
+
* ```
|
|
38
|
+
*/
|
|
39
|
+
appName: string;
|
|
40
|
+
providers?: IProvidersConfig;
|
|
41
|
+
solana?: ISolanaConfig;
|
|
42
|
+
stellar?: IStellarConfig;
|
|
43
|
+
keys: IKeys;
|
|
44
|
+
monitoring?: IMonitoring;
|
|
45
|
+
/** Analytics configuration. Enabled by default (opt-out model). */
|
|
46
|
+
analytics?: IAnalyticsConfig;
|
|
47
|
+
/**
|
|
48
|
+
* Best-effort npm-registry version check. Enabled by default in
|
|
49
|
+
* non-production environments; never runs in `NODE_ENV=production`.
|
|
50
|
+
* Set `enabled: false` to disable entirely (or set the
|
|
51
|
+
* `AUGUST_SDK_DISABLE_VERSION_CHECK` env var).
|
|
52
|
+
*/
|
|
53
|
+
versionCheck?: IVersionCheckConfig;
|
|
54
|
+
/**
|
|
55
|
+
* Default request timeout (in milliseconds) for backend API calls made by
|
|
56
|
+
* this SDK instance. Falls back to the SDK's compiled-in
|
|
57
|
+
* `REQUEST_TIMEOUT_MS` (90 s) when omitted.
|
|
58
|
+
*
|
|
59
|
+
* Per-call `timeoutMs` (when threaded through to the fetcher) still wins
|
|
60
|
+
* over this value. Setting this only changes the default that's used when
|
|
61
|
+
* no per-call value is supplied.
|
|
62
|
+
*
|
|
63
|
+
* Note: this is a process-global override on the underlying fetcher
|
|
64
|
+
* helpers, so the last `AugustSDK` instantiated wins if you create several
|
|
65
|
+
* with different timeouts in the same process.
|
|
66
|
+
*/
|
|
67
|
+
timeoutMs?: number;
|
|
68
|
+
/**
|
|
69
|
+
* Override the base URL for the SDK's unauthenticated `public` vault-catalog
|
|
70
|
+
* API (what `getVault` / `getVaults` / `fetchTokenizedVault` read from).
|
|
71
|
+
* Defaults to the compiled-in prod base
|
|
72
|
+
* (`https://api.augustdigital.io/api/v1`) when omitted — so production apps
|
|
73
|
+
* pass nothing and behaviour is unchanged.
|
|
74
|
+
*
|
|
75
|
+
* Set this ONLY for a non-prod deployment that runs against an isolated
|
|
76
|
+
* backend (e.g. a staging API serving staging-only vaults). Must be an
|
|
77
|
+
* absolute http(s) URL including any base path, e.g.
|
|
78
|
+
* `https://api.staging.augustdigital.io/api/v1`. Invalid values are ignored.
|
|
79
|
+
*
|
|
80
|
+
* Note: this is a process-global override on the underlying fetcher helpers,
|
|
81
|
+
* applied on EVERY construction — so the last `AugustSDK` instantiated is
|
|
82
|
+
* authoritative, and one that omits `publicApiBaseUrl` RESETS to the prod
|
|
83
|
+
* default. (Stricter than `timeoutMs`, which stays sticky when omitted, since
|
|
84
|
+
* a stale cross-environment base is higher blast-radius than a stale timeout.)
|
|
85
|
+
*/
|
|
86
|
+
publicApiBaseUrl?: string;
|
|
87
|
+
/**
|
|
88
|
+
* ERC-8021 calldata-suffix attribution (Base Builder Codes). When set,
|
|
89
|
+
* every EVM write sent through the SDK — ethers vault writes and the
|
|
90
|
+
* cross-chain (OVault) viem writes — carries the attribution suffix so
|
|
91
|
+
* offchain indexers (base.dev) can credit the transaction to your app.
|
|
92
|
+
* Omit to send unattributed transactions (the default).
|
|
93
|
+
*
|
|
94
|
+
* Note: this is a process-global override applied on EVERY construction —
|
|
95
|
+
* the last `AugustSDK` instantiated is authoritative, and one that omits
|
|
96
|
+
* `attribution` RESETS it (same semantics as `publicApiBaseUrl`).
|
|
97
|
+
*
|
|
98
|
+
* @throws Throws synchronously from the constructor when the builder codes
|
|
99
|
+
* are malformed — see {@link IAttributionConfig}.
|
|
100
|
+
*/
|
|
101
|
+
attribution?: IAttributionConfig;
|
|
102
|
+
}
|
|
103
|
+
interface IActiveNetwork {
|
|
104
|
+
chainId: IChainId;
|
|
105
|
+
rpcUrl: string;
|
|
106
|
+
}
|
|
107
|
+
/**
|
|
108
|
+
* Base class providing core SDK functionality including provider management,
|
|
109
|
+
* network switching, and authentication state.
|
|
110
|
+
*/
|
|
111
|
+
export declare class AugustBase {
|
|
112
|
+
keys: IKeys;
|
|
113
|
+
monitoring: IMonitoring;
|
|
114
|
+
authorized: boolean;
|
|
115
|
+
activeNetwork?: IActiveNetwork;
|
|
116
|
+
providers: IProvidersConfig;
|
|
117
|
+
/** Validated app-name slug from the constructor. */
|
|
118
|
+
appName: string;
|
|
119
|
+
/**
|
|
120
|
+
* Initialize base SDK with provider configuration and API keys.
|
|
121
|
+
* Sets up the first provider as the active network by default.
|
|
122
|
+
*
|
|
123
|
+
* @throws If `appName` is missing, malformed, or out of the allowed
|
|
124
|
+
* length range — see {@link IAugustBase.appName}.
|
|
125
|
+
*/
|
|
126
|
+
constructor({ appName, providers, keys, monitoring, analytics, versionCheck, timeoutMs, publicApiBaseUrl, attribution, }: IAugustBase);
|
|
127
|
+
/**
|
|
128
|
+
* Verify API keys and authorize SDK usage.
|
|
129
|
+
* TODO: initialize class with appropriate keys and verify august key
|
|
130
|
+
*/
|
|
131
|
+
init(): Promise<void>;
|
|
132
|
+
/**
|
|
133
|
+
* Return the active network or throw a clear error.
|
|
134
|
+
* Use this in methods that require an EVM provider.
|
|
135
|
+
*/
|
|
136
|
+
protected requireActiveNetwork(): IActiveNetwork;
|
|
137
|
+
/**
|
|
138
|
+
* Switch the active blockchain network.
|
|
139
|
+
* Updates both chain ID and RPC URL for subsequent operations.
|
|
140
|
+
*/
|
|
141
|
+
switchNetwork(chainId: IChainId): void;
|
|
142
|
+
/**
|
|
143
|
+
* Set active wallet address and update monitoring headers.
|
|
144
|
+
* Preserves existing environment setting.
|
|
145
|
+
*/
|
|
146
|
+
updateWallet(address: IAddress): void;
|
|
147
|
+
/**
|
|
148
|
+
* Remove wallet address from SDK state and monitoring headers.
|
|
149
|
+
*/
|
|
150
|
+
clearWallet(): void;
|
|
151
|
+
}
|
|
152
|
+
export {};
|