Skip to content

Commit d59765c

Browse files
authored
fix(smart-wallet-sdk): add historical smart wallet versions (#361)
1 parent f15cc01 commit d59765c

File tree

2 files changed

+54
-3
lines changed

2 files changed

+54
-3
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import { getAllSmartWalletVersions, SMART_WALLET_ADDRESSES, SupportedChainIds, SMART_WALLET_VERSIONS, SmartWalletVersion } from "./constants"
2+
3+
describe('constants', () => {
4+
it('SMART_WALLET_ADDRESSES should be latest versions', () => {
5+
// Since we only have one chain ID right now, test it directly
6+
const chainId = SupportedChainIds.SEPOLIA
7+
expect(SMART_WALLET_ADDRESSES[chainId]).toEqual(SMART_WALLET_VERSIONS[chainId][SmartWalletVersion.LATEST])
8+
})
9+
10+
it('getAllSmartWalletVersions should return all versions for a given chain id', () => {
11+
const chainId = SupportedChainIds.SEPOLIA
12+
expect(getAllSmartWalletVersions(chainId)).toEqual(Object.values(SMART_WALLET_VERSIONS[chainId]))
13+
})
14+
})

sdks/smart-wallet-sdk/src/constants.ts

Lines changed: 40 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,47 @@ export enum ModeType {
1717
BATCHED_CALL_CAN_REVERT = '0x0101000000000000000000000000000000000000000000000000000000000000'
1818
}
1919

20+
/**
21+
* Supported chain ids
22+
*/
23+
export enum SupportedChainIds {
24+
SEPOLIA = ChainId.SEPOLIA,
25+
}
26+
27+
/**
28+
* Supported smart wallet versions
29+
* @dev keyed by github release tag
30+
*/
31+
export enum SmartWalletVersion {
32+
LATEST = 'latest',
33+
v0_2_1_audit_2 = 'v0.2.1-audit.2',
34+
}
35+
36+
/**
37+
* Smart wallet versions for supported chains
38+
*/
39+
export const SMART_WALLET_VERSIONS : { [chainId in SupportedChainIds]: { [version in SmartWalletVersion]: `0x${string}` } } = {
40+
[SupportedChainIds.SEPOLIA]: {
41+
[SmartWalletVersion.LATEST]: '0x964914430aAe3e6805675EcF648cEfaED9e546a7',
42+
[SmartWalletVersion.v0_2_1_audit_2]: '0x964914430aAe3e6805675EcF648cEfaED9e546a7',
43+
}
44+
}
45+
2046
/**
2147
* Mapping of chainId to Smart Wallet contract addresses
22-
* @dev See README for detailed deployment addresses along with the commit hash
48+
* @dev Used to get the latest version of the smart wallet
49+
* See README for detailed deployment addresses along with the commit hash
50+
*/
51+
export const SMART_WALLET_ADDRESSES = Object.fromEntries(
52+
Object.entries(SMART_WALLET_VERSIONS).map(([chainId, versions]) => [
53+
chainId,
54+
versions[SmartWalletVersion.LATEST]
55+
])
56+
)
57+
58+
/**
59+
* Get all historical smart wallet versions for a given chain id
2360
*/
24-
export const SMART_WALLET_ADDRESSES: { [chainId in ChainId]?: `0x${string}` } = {
25-
[ChainId.SEPOLIA]: '0x964914430aAe3e6805675EcF648cEfaED9e546a7'
61+
export const getAllSmartWalletVersions = (chainId: SupportedChainIds) => {
62+
return Object.values(SMART_WALLET_VERSIONS[chainId])
2663
}

0 commit comments

Comments
 (0)