-
Notifications
You must be signed in to change notification settings - Fork 106
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add contract address configuration (#1175)
This adds the fields from the`ContractNetworksConfig` of the `protocol-kit`](https://docs.safe.global/sdk/protocol-kit/reference/safe#init) in order to dynamically initialise it: - Add new fields to `Chain` model (and `ChainFactory`) for: - Safe singleton - Safe ProxyFactory - MultiSend - MultiSendCallOnly - FallbackHandler - SignMessageLib - CreateCall - SimulateTxAccessor - SafeWebAuthnSignerFactoryAddress - Serialise fields with a new `ContractAddressesSerializer` on the `ChainSerializer` - Add test for view - Generate and test respective migration
- Loading branch information
Showing
6 changed files
with
205 additions
and
0 deletions.
There are no files selected for viewing
77 changes: 77 additions & 0 deletions
77
src/chains/migrations/0043_chain_create_call_address_and_more.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
# Generated by Django 5.0.6 on 2024-07-10 14:14 | ||
|
||
import gnosis.eth.django.models | ||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
("chains", "0042_chain_balances_provider_chain_name_and_more"), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name="chain", | ||
name="create_call_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="fallback_handler_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="multi_send_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="multi_send_call_only_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="safe_proxy_factory_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="safe_singleton_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="sign_message_lib_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="simulate_tx_accessor_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
migrations.AddField( | ||
model_name="chain", | ||
name="safe_web_authn_signer_factory_address", | ||
field=gnosis.eth.django.models.EthereumAddressField( | ||
blank=True, null=True | ||
), # type: ignore[no-untyped-call] | ||
), | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
from django.db.migrations.state import StateApps | ||
|
||
from chains.migrations.tests.utils import TestMigrations | ||
|
||
|
||
class Migration0043TestCase(TestMigrations): | ||
migrate_from = "0042_chain_balances_provider_chain_name_and_more" | ||
migrate_to = "0043_chain_create_call_address_and_more" | ||
|
||
def setUpBeforeMigration(self, apps: StateApps) -> None: | ||
Chain = apps.get_model("chains", "Chain") | ||
Chain.objects.create( | ||
id=1, | ||
name="Mainnet", | ||
short_name="eth", | ||
description="", | ||
l2=False, | ||
rpc_authentication="API_KEY_PATH", | ||
rpc_uri="https://mainnet.infura.io/v3/", | ||
safe_apps_rpc_authentication="API_KEY_PATH", | ||
safe_apps_rpc_uri="https://mainnet.infura.io/v3/", | ||
block_explorer_uri_address_template="https://etherscan.io/address/{{address}}", | ||
block_explorer_uri_tx_hash_template="https://etherscan.io/tx/{{txHash}}", | ||
currency_name="Ether", | ||
currency_symbol="ETH", | ||
currency_decimals=18, | ||
currency_logo_uri="https://gnosis-safe-token-logos.s3.amazonaws.com/ethereum-eth-logo.png", | ||
transaction_service_uri="http://mainnet-safe-transaction-web.safe.svc.cluster.local", | ||
vpc_transaction_service_uri="", | ||
theme_text_color="#001428", | ||
theme_background_color="#E8E7E6", | ||
ens_registry_address="0x00000000000C2E074eC69A0dFb2997BA6C7d2e1e", | ||
recommended_master_copy_version="1.3.0", | ||
prices_provider_native_coin="ethereum", | ||
prices_provider_chain_name="ethereum", | ||
hidden=False, | ||
balances_provider_chain_name="ethereum", | ||
balances_provider_enabled=True, | ||
) | ||
|
||
def test_new_fields(self) -> None: | ||
Chain = self.apps_registry.get_model("chains", "Chain") | ||
|
||
chain = Chain.objects.get(id=1) | ||
|
||
self.assertEqual(chain.safe_singleton_address, None) | ||
self.assertEqual(chain.safe_proxy_factory_address, None) | ||
self.assertEqual(chain.multi_send_address, None) | ||
self.assertEqual(chain.multi_send_call_only_address, None) | ||
self.assertEqual(chain.fallback_handler_address, None) | ||
self.assertEqual(chain.sign_message_lib_address, None) | ||
self.assertEqual(chain.create_call_address, None) | ||
self.assertEqual(chain.simulate_tx_accessor_address, None) | ||
self.assertEqual(chain.safe_web_authn_signer_factory_address, None) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters