@uniswap/smart-wallet-sdk
Version:
⚒️ An SDK for building applications with smart wallets on Uniswap
129 lines • 6.44 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.getAllSmartWalletVersions = exports.SMART_WALLET_ADDRESSES = exports.SMART_WALLET_VERSIONS = exports.SmartWalletVersion = exports.SupportedChainIds = exports.ModeType = exports.SELF_CALL_TARGET = exports.DELEGATION_MAGIC_PREFIX = void 0;
exports.getSmartWalletAddress = getSmartWalletAddress;
const sdk_core_1 = require("@uniswap/sdk-core");
// https://eips.ethereum.org/EIPS/eip-7702
exports.DELEGATION_MAGIC_PREFIX = '0xef0100';
/**
* The target address for self-calls is address(0)
*/
exports.SELF_CALL_TARGET = '0x0000000000000000000000000000000000000000';
/**
* Call types for smart wallet calls
* Follows ERC-7579
*/
var ModeType;
(function (ModeType) {
ModeType["BATCHED_CALL"] = "0x0100000000000000000000000000000000000000000000000000000000000000";
ModeType["BATCHED_CALL_CAN_REVERT"] = "0x0101000000000000000000000000000000000000000000000000000000000000";
})(ModeType || (exports.ModeType = ModeType = {}));
/**
* Supported chain ids
*/
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 || (exports.SupportedChainIds = SupportedChainIds = {}));
/**
* Supported smart wallet versions
* @dev keyed by github release tag
*/
var SmartWalletVersion;
(function (SmartWalletVersion) {
SmartWalletVersion["LATEST"] = "latest";
SmartWalletVersion["v1_0_0"] = "v1.0.0";
SmartWalletVersion["v1_0_0_staging"] = "v1.0.0-staging";
})(SmartWalletVersion || (exports.SmartWalletVersion = SmartWalletVersion = {}));
/**
* Smart wallet versions for supported chains
*/
exports.SMART_WALLET_VERSIONS = {
[SupportedChainIds.MAINNET]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0_staging]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[SupportedChainIds.UNICHAIN]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0_staging]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[SupportedChainIds.BASE]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0_staging]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[SupportedChainIds.OPTIMISM]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0_staging]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[SupportedChainIds.BNB]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0_staging]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[SupportedChainIds.ARBITRUM_ONE]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
},
[SupportedChainIds.UNICHAIN_SEPOLIA]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0_staging]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[SupportedChainIds.SEPOLIA]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0_staging]: '0x3cbad1e3b9049ecdb9588fb48dd61d80faf41bd5',
},
[SupportedChainIds.XLAYER]: {
[SmartWalletVersion.LATEST]: '0x000000009B1D0aF20D8C6d0A44e162d11F9b8f00',
[SmartWalletVersion.v1_0_0]: '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.
*/
exports.SMART_WALLET_ADDRESSES = (() => {
const entries = Object.entries(exports.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
*/
const getAllSmartWalletVersions = (chainId) => {
return Object.values(exports.SMART_WALLET_VERSIONS[chainId]);
};
exports.getAllSmartWalletVersions = getAllSmartWalletVersions;
/**
* Get the latest Smart Wallet address for a given chain id.
* Normalizes string ids to numbers and guards against prototype pollution.
*/
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(exports.SMART_WALLET_ADDRESSES, normalized)) {
throw new Error(`Smart wallet not found for chainId: ${chainIdLike}`);
}
return exports.SMART_WALLET_ADDRESSES[normalized];
}
//# sourceMappingURL=constants.js.map