Skip to content
This repository has been archived by the owner on Dec 15, 2023. It is now read-only.

Fix udc address #336

Merged
merged 4 commits into from
Nov 9, 2022
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
2 changes: 1 addition & 1 deletion page/docs/guide/udc.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ sidebar_position: 15

# UDC

Devnet comes with a [Universal Deployer Contract (UDC)](https://community.starknet.io/t/universal-deployer-contract-proposal/1864) predeployed at `0x25fcb74260022bd8ed7e8d542408941826b53345e478b8303d6f31744838a36`. The implementation used is [OpenZeppelin v0.5.0](https://github.com/OpenZeppelin/cairo-contracts/blob/v0.5.0/src/openzeppelin/utils/presets/UniversalDeployer.cairo)
Devnet comes with a [Universal Deployer Contract (UDC)](https://community.starknet.io/t/universal-deployer-contract-proposal/1864) predeployed at `0x41a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf`. The implementation used is [OpenZeppelin v0.5.0](https://github.com/OpenZeppelin/cairo-contracts/blob/v0.5.0/src/openzeppelin/utils/presets/UniversalDeployer.cairo)
6 changes: 5 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,11 @@ markers = [
"timestamps",
"transaction_trace",
"tx_version",
"web3_messaging"
"web3_messaging",
]
junit_family="xunit1"
asyncio_mode="strict"
filterwarnings=[
"ignore::DeprecationWarning:lark.*:",
"ignore::DeprecationWarning:frozendict.*:",
]
4 changes: 1 addition & 3 deletions starknet_devnet/fee_token.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,7 @@ class FeeToken:
# Precalculated to fixed address
# ADDRESS = calculate_contract_address_from_hash(salt=10, class_hash=HASH,
# constructor_calldata=[], deployer_address=0)
ADDRESS = (
2774287484619332564597403632816768868845110259953541691709975889937073775752
)
ADDRESS = 0x62230EA046A9A5FBC261AC77D03C8D41E5D442DB2284587570AB46455FD2488
SYMBOL = "ETH"
NAME = "ether"

Expand Down
12 changes: 4 additions & 8 deletions starknet_devnet/udc.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,9 @@ class UDC:
HASH_BYTES = to_bytes(HASH)

# Precalculated to fixed address
# ADDRESS = calculate_contract_address_from_hash(salt=10, class_hash=HASH,
# ADDRESS = calculate_contract_address_from_hash(salt=0, class_hash=HASH,
# constructor_calldata=[], deployer_address=0)
ADDRESS = (
1073880354184614071153542798898672284640862493126523554954769603345737026102
)

contract: StarknetContract = None
ADDRESS = 0x41A78E741E5AF2FEC34B695679BC6891742439F7AFB8484ECD7766661AD02BF

def __init__(self, starknet_wrapper):
self.starknet_wrapper = starknet_wrapper
Expand All @@ -46,13 +42,13 @@ async def deploy(self):
await starknet.state.state.set_contract_class(UDC.HASH_BYTES, contract_class)
await starknet.state.state.deploy_contract(UDC.ADDRESS, UDC.HASH_BYTES)

self.contract = StarknetContract(
contract = StarknetContract(
state=starknet.state,
abi=contract_class.abi,
contract_address=UDC.ADDRESS,
deploy_call_info=None,
)

await self.starknet_wrapper.store_contract(
UDC.ADDRESS, self.contract, contract_class
UDC.ADDRESS, contract, contract_class
)
2 changes: 1 addition & 1 deletion test/shared.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,5 +63,5 @@
"0x62230ea046a9a5fbc261ac77d03c8d41e5d442db2284587570ab46455fd2488"
)
EXPECTED_UDC_ADDRESS = (
"0x25fcb74260022bd8ed7e8d542408941826b53345e478b8303d6f31744838a36"
"0x41a78e741e5af2fec34b695679bc6891742439f7afb8484ecd7766661ad02bf"
)
9 changes: 9 additions & 0 deletions test/test_deploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
get_class_by_hash,
get_class_hash_at,
get_transaction_receipt,
load_contract_class,
mint,
send_tx,
)
Expand Down Expand Up @@ -269,6 +270,14 @@ def test_deploy_through_deployer_constructor():

def test_precomputed_udc_address():
"""Test if the precomputed address of UDC is correct."""
udc_contract_class = load_contract_class("starknet_devnet/UDC_OZ_0.5.0.json")
calculated_address = calculate_contract_address(
salt=0,
contract_class=udc_contract_class,
constructor_calldata=[],
deployer_address=0,
)
assert_equal(UDC.ADDRESS, calculated_address)
assert_equal(UDC.ADDRESS, int(EXPECTED_UDC_ADDRESS, 16))


Expand Down