-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add support for collection of oracles to chains endpoint (#210)
- Breaking Change /api/v1/chains: each chain is now allowed to have multiple gas price configurations (resulting in a collection instead of a single object of fixed and oracle gas prices). - The new GasPrice for each chain is now ranked – a lower value means that it'd show up higher on the list (eg.: rank 1 > rank 100) - The new GasPrice collection is allowed to be empty – this is not only to reduce complexity but also because the current relationship between GasPrice <> Chain means that a Chain needs to exist first before assigning a GasPrice to it.
- Loading branch information
Showing
8 changed files
with
334 additions
and
115 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
# Generated by Django 3.2.6 on 2021-09-01 12:38 | ||
|
||
import django.db.models.deletion | ||
import gnosis.eth.django.models | ||
from django.db import migrations, models | ||
|
||
|
||
def copy_gas_prices(apps, schema_editor): | ||
GasPrice = apps.get_model("chains", "GasPrice") | ||
Chain = apps.get_model("chains", "Chain") | ||
|
||
GasPrice.objects.bulk_create( | ||
GasPrice( | ||
chain=chain, | ||
oracle_uri=chain.gas_price_oracle_uri, | ||
oracle_parameter=chain.gas_price_oracle_parameter, | ||
gwei_factor=chain.gas_price_oracle_gwei_factor, | ||
fixed_wei_value=chain.gas_price_fixed_wei, | ||
) | ||
for chain in Chain.objects.all() | ||
) | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("chains", "0022_remove_chain_block_explorer_uri"), | ||
] | ||
|
||
operations = [ | ||
migrations.CreateModel( | ||
name="GasPrice", | ||
fields=[ | ||
( | ||
"id", | ||
models.BigAutoField( | ||
auto_created=True, | ||
primary_key=True, | ||
serialize=False, | ||
verbose_name="ID", | ||
), | ||
), | ||
("oracle_uri", models.URLField(blank=True, null=True)), | ||
( | ||
"oracle_parameter", | ||
models.CharField(blank=True, max_length=255, null=True), | ||
), | ||
( | ||
"gwei_factor", | ||
models.DecimalField( | ||
decimal_places=9, | ||
default=1, | ||
help_text="Factor required to reach the Gwei unit", | ||
max_digits=19, | ||
verbose_name="Gwei multiplier factor", | ||
), | ||
), | ||
( | ||
"fixed_wei_value", | ||
gnosis.eth.django.models.Uint256Field( | ||
blank=True, null=True, verbose_name="Fixed gas price (wei)" | ||
), | ||
), | ||
("rank", models.SmallIntegerField(default=100)), | ||
( | ||
"chain", | ||
models.ForeignKey( | ||
on_delete=django.db.models.deletion.CASCADE, to="chains.chain" | ||
), | ||
), | ||
], | ||
), | ||
# noop for backwards because it will be handled by the backwards of CreateModel (ie.: destroying the model) | ||
migrations.RunPython(copy_gas_prices, migrations.RunPython.noop), | ||
] |
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,28 @@ | ||
# Generated by Django 3.2.6 on 2021-09-01 12:38 | ||
|
||
from django.db import migrations | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("chains", "0023_create_gas_price_model"), | ||
] | ||
|
||
operations = [ | ||
migrations.RemoveField( | ||
model_name="chain", | ||
name="gas_price_fixed_wei", | ||
), | ||
migrations.RemoveField( | ||
model_name="chain", | ||
name="gas_price_oracle_gwei_factor", | ||
), | ||
migrations.RemoveField( | ||
model_name="chain", | ||
name="gas_price_oracle_parameter", | ||
), | ||
migrations.RemoveField( | ||
model_name="chain", | ||
name="gas_price_oracle_uri", | ||
), | ||
] |
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
Oops, something went wrong.