Skip to content

Commit 9b29082

Browse files
committed
refactor(SDK): move deterministic addresses to caravan.settings
1 parent 333694b commit 9b29082

File tree

2 files changed

+15
-6
lines changed

2 files changed

+15
-6
lines changed

sdk/py/caravan/factory.py

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
from .main import Caravan
99
from .packages import STABLE_VERSION, PackageType
10+
from .settings import FACTORY_DETERMINISTIC_ADDRESS, SINGLETON_DETERMINISTIC_ADDRESSES
1011

1112
if TYPE_CHECKING:
1213
from ape.contracts import ContractInstance
@@ -18,8 +19,7 @@ def __init__(self, address: AddressType | None = None):
1819
self.address = address
1920

2021
elif len((factory_type := PackageType.FACTORY()).deployments) == 0:
21-
# NOTE: This is the deterministic deployment address via CreateX
22-
self.address = "0x04579FFC45fE10A7901B88EaEc8F4850b847D37c"
22+
self.address = FACTORY_DETERMINISTIC_ADDRESS
2323

2424
if not len(self.provider.get_code(self.address)) > 0:
2525
raise RuntimeError("No CaravanFactory deployment on this chain")
@@ -31,10 +31,8 @@ def __init__(self, address: AddressType | None = None):
3131

3232
# NOTE: also lets us override for testing
3333
self._cached_releases: dict[Version, "ContractInstance"] = {
34-
# NOTE: This is the deterministic deployment address for v1 via CreateX
35-
Version("1"): PackageType.SINGLETON("1").at(
36-
"0xB810c65972596d213DCdf0A73b27fa7be59Ef3E2"
37-
),
34+
Version(version): PackageType.SINGLETON(version).at(address)
35+
for version, address in SINGLETON_DETERMINISTIC_ADDRESSES.items()
3836
}
3937

4038
@cached_property

sdk/py/caravan/settings.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,17 @@
11
import os
22
from pathlib import Path
3+
from typing import TYPE_CHECKING
34

5+
if TYPE_CHECKING:
6+
from ape.types import AddressType
7+
8+
# NOTE: This is the deterministic deployment address via CreateX
9+
FACTORY_DETERMINISTIC_ADDRESS: "AddressType" = "0x04579FFC45fE10A7901B88EaEc8F4850b847D37c"
10+
11+
# NOTE: This is the deterministic deployment addresses for each version via CreateX
12+
SINGLETON_DETERMINISTIC_ADDRESSES: dict[str, "AddressType"] = {
13+
"1": "0xB810c65972596d213DCdf0A73b27fa7be59Ef3E2",
14+
}
415

516
USER_CACHE_DIR: Path = (
617
path

0 commit comments

Comments
 (0)