Skip to content

fix(smart-wallet-sdk): add historical smart wallet versions #361

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions sdks/smart-wallet-sdk/src/constants.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { getAllSmartWalletVersions, SMART_WALLET_ADDRESSES, SupportedChainIds, SMART_WALLET_VERSIONS, SmartWalletVersion } from "./constants"

describe('constants', () => {
it('SMART_WALLET_ADDRESSES should be latest versions', () => {
// Since we only have one chain ID right now, test it directly
const chainId = SupportedChainIds.SEPOLIA
expect(SMART_WALLET_ADDRESSES[chainId]).toEqual(SMART_WALLET_VERSIONS[chainId][SmartWalletVersion.LATEST])
})

it('getAllSmartWalletVersions should return all versions for a given chain id', () => {
const chainId = SupportedChainIds.SEPOLIA
expect(getAllSmartWalletVersions(chainId)).toEqual(Object.values(SMART_WALLET_VERSIONS[chainId]))
})
})
43 changes: 40 additions & 3 deletions sdks/smart-wallet-sdk/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,47 @@ export enum ModeType {
BATCHED_CALL_CAN_REVERT = '0x0101000000000000000000000000000000000000000000000000000000000000'
}

/**
* Supported chain ids
*/
export enum SupportedChainIds {
SEPOLIA = ChainId.SEPOLIA,
}

/**
* Supported smart wallet versions
* @dev keyed by github release tag
*/
export enum SmartWalletVersion {
LATEST = 'latest',
v0_2_1_audit_2 = 'v0.2.1-audit.2',
}

/**
* Smart wallet versions for supported chains
*/
export const SMART_WALLET_VERSIONS : { [chainId in SupportedChainIds]: { [version in SmartWalletVersion]: `0x${string}` } } = {
[SupportedChainIds.SEPOLIA]: {
[SmartWalletVersion.LATEST]: '0x964914430aAe3e6805675EcF648cEfaED9e546a7',
[SmartWalletVersion.v0_2_1_audit_2]: '0x964914430aAe3e6805675EcF648cEfaED9e546a7',
}
}

/**
* Mapping of chainId to Smart Wallet contract addresses
* @dev See README for detailed deployment addresses along with the commit hash
* @dev Used to get the latest version of the smart wallet
* See README for detailed deployment addresses along with the commit hash
*/
export const SMART_WALLET_ADDRESSES = Object.fromEntries(
Object.entries(SMART_WALLET_VERSIONS).map(([chainId, versions]) => [
chainId,
versions[SmartWalletVersion.LATEST]
])
)

/**
* Get all historical smart wallet versions for a given chain id
*/
export const SMART_WALLET_ADDRESSES: { [chainId in ChainId]?: `0x${string}` } = {
[ChainId.SEPOLIA]: '0x964914430aAe3e6805675EcF648cEfaED9e546a7'
export const getAllSmartWalletVersions = (chainId: SupportedChainIds) => {
return Object.values(SMART_WALLET_VERSIONS[chainId])
}
Loading