@uniswap/smart-wallet-sdk
Version:
⚒️ An SDK for building applications with smart wallets on Uniswap
124 lines • 5.94 kB
JavaScript
import { ChainId } from '@uniswap/sdk-core';
// https://eips.ethereum.org/EIPS/eip-7702
export const DELEGATION_MAGIC_PREFIX = '0xef0100';
/**
* The target address for self-calls is address(0)
*/
export const SELF_CALL_TARGET = '0x0000000000000000000000000000000000000000';
/**
* Call types for smart wallet calls
* Follows ERC-7579
*/
export var ModeType;
(function (ModeType) {
ModeType["BATCHED_CALL"] = "0x0100000000000000000000000000000000000000000000000000000000000000";
ModeType["BATCHED_CALL_CAN_REVERT"] = "0x0101000000000000000000000000000000000000000000000000000000000000";
})(ModeType || (ModeType = {}));
/**
* Supported chain ids
*/
export var SupportedChainIds;
(function (SupportedChainIds) {
SupportedChainIds[SupportedChainIds["MAINNET"] = 1] = "MAINNET";
SupportedChainIds[SupportedChainIds["UNICHAIN"] = 130] = "UNICHAIN";
SupportedChainIds[SupportedChainIds["UNICHAIN_SEPOLIA"] = 1301] = "UNICHAIN_SEPOLIA";
SupportedChainIds[SupportedChainIds["SEPOLIA"] = 11155111] = "SEPOLIA";
SupportedChainIds[SupportedChainIds["BASE"] = 8453] = "BASE";
SupportedChainIds[SupportedChainIds["OPTIMISM"] = 10] = "OPTIMISM";
SupportedChainIds[SupportedChainIds["BNB"] = 56] = "BNB";
SupportedChainIds[SupportedChainIds["ARBITRUM_ONE"] = 42161] = "ARBITRUM_ONE";
SupportedChainIds[SupportedChainIds["XLAYER"] = 196] = "XLAYER";
})(SupportedChainIds || (SupportedChainIds = {}));
/**
* Supported smart wallet versions
* @dev keyed by github release tag
*/
export var SmartWalletVersion;
(function (SmartWalletVersion) {
SmartWalletVersion["LATEST"] = "latest";
SmartWalletVersion["v1_0_0"] = "v1.0.0";
SmartWalletVersion["v1_0_0_staging"] = "v1.0.0-staging";
})(SmartWalletVersion || (SmartWalletVersion = {}));
/**
* Smart wallet versions for supported chains
*/
export const SMART_WALLET_VERSIONS = {
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[]: {
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
},
};
/**
* Mapping of chainId to Smart Wallet contract addresses
* @dev Used to get the latest version of the smart wallet
* See README for detailed deployment addresses along with the commit hash
* @deprecated Use getSmartWalletAddress() instead of indexing this map directly.
*/
export const SMART_WALLET_ADDRESSES = (() => {
const entries = Object.entries(SMART_WALLET_VERSIONS).map(([chainId, versions]) => [
chainId,
versions[SmartWalletVersion.LATEST],
]);
const map = Object.fromEntries(entries);
// Explicitly remove prototype to prevent access via __proto__/constructor, etc.
Object.setPrototypeOf(map, null);
return map;
})();
/**
* Get all historical smart wallet versions for a given chain id
*/
export const getAllSmartWalletVersions = (chainId) => {
return Object.values(SMART_WALLET_VERSIONS[chainId]);
};
/**
* Get the latest Smart Wallet address for a given chain id.
* Normalizes string ids to numbers and guards against prototype pollution.
*/
export function getSmartWalletAddress(chainIdLike) {
const normalized = typeof chainIdLike === 'string' ? Number(chainIdLike) : chainIdLike;
const isValid = typeof normalized === 'number' && Number.isFinite(normalized) && Number.isInteger(normalized);
if (!isValid || !Object.prototype.hasOwnProperty.call(SMART_WALLET_ADDRESSES, normalized)) {
throw new Error(`Smart wallet not found for chainId: ${chainIdLike}`);
}
return SMART_WALLET_ADDRESSES[normalized];
}
//# sourceMappingURL=constants.js.map