Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ks contract versioning #2951

Merged
merged 12 commits into from
Nov 27, 2018
6 changes: 6 additions & 0 deletions app/assets/v2/js/grants/cancel_subscription.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,12 @@ window.onload = function() {
});

// need to delete subscription from miner so it isn't checked every 15 seconds.
//
// let compiledSubscription;
//
// if (data.contract_version == 0) {
// compiledSubscription = compiledSubscription0;
// }

let deployedSubscription = new web3.eth.Contract(compiledSubscription.abi, data.contract_address);

Expand Down
6,344 changes: 3,279 additions & 3,065 deletions app/assets/v2/js/grants/compiledSubscriptionContract.js

Large diffs are not rendered by default.

6 changes: 6 additions & 0 deletions app/assets/v2/js/grants/detail.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,12 @@ $(document).ready(function() {
data[this.name] = this.value;
});

// let compiledSubscription;
//
// if (data.contract_version == 0) {
// compiledSubscription = compiledSubscription0;
// }

let deployedSubscription = new web3.eth.Contract(compiledSubscription.abi, data.contract_address);

web3.eth.getAccounts(function(err, accounts) {
Expand Down
4 changes: 4 additions & 0 deletions app/assets/v2/js/grants/new.js
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ $(document).ready(function() {

$('#token_symbol').val($('#js-token option:selected').text());

console.log('compiledSubscription', compiledSubscription);

// Begin New Deploy Subscription Contract
let SubscriptionContract = new web3.eth.Contract(compiledSubscription.abi);

Expand All @@ -61,6 +63,8 @@ $(document).ready(function() {
// data.frequency
web3.utils.toTwosComplement(0),
// data.gas_price
web3.utils.toTwosComplement(0),
// contract version
web3.utils.toTwosComplement(0)
];

Expand Down
12 changes: 12 additions & 0 deletions app/assets/v2/js/grants/shared.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,16 @@
// outside of document.ready to be in global scope
var compiledSubscription;

$(document).ready(function() {

let contractVersion = $('#contract_version').val();

if (contractVersion) {
if (contractVersion == 0) {
compiledSubscription = compiledSubscription0;
}
}

var params = {
page: document.location.pathname
};
Expand Down
14 changes: 14 additions & 0 deletions app/dashboard/migrations/0117_merge_20181126_1652.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Generated by Django 2.1.2 on 2018-11-26 16:52

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('dashboard', '0112_auto_20181107_1809'),
('dashboard', '0116_merge_20181115_2252'),
]

operations = [
]
17 changes: 17 additions & 0 deletions app/grants/migrations/0007_auto_20181126_1652.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 2.1.2 on 2018-11-26 16:52

from django.db import migrations


class Migration(migrations.Migration):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@SaptakS @thelostone-mc do these migrations look ok to you?


dependencies = [
('grants', '0006_auto_20181121_1646'),
]

operations = [
migrations.AlterModelOptions(
name='grant',
options={'ordering': ['-created_on']},
),
]
18 changes: 18 additions & 0 deletions app/grants/migrations/0008_grant_contract_version.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 2.1.2 on 2018-11-26 20:34

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('grants', '0007_auto_20181126_1652'),
]

operations = [
migrations.AddField(
model_name='grant',
name='contract_version',
field=models.DecimalField(decimal_places=0, default=0, help_text='The contract version the Grant.', max_digits=3),
),
]
6 changes: 6 additions & 0 deletions app/grants/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,12 @@ class Meta:
default='0x0',
help_text=_('The contract address of the Grant.'),
)
contract_version = models.DecimalField(
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@captnseagraves
cc @owocki

Should we include a process for handling the ABI based on contract version, so it outputs the appropriate static URL or a given contract version..?

Also, we are we using a decimalfield if decimal_places=0 with max_digits=3?

Can we switch this to a charfield? If we're going by semantic versioning, decimalfield won't make sense: 0.1.0 for example. If we're using integers like: 0 or 1, we should use positiveintegerfield here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we switch this to a charfield? If we're going by semantic versioning, decimalfield won't make sense: 0.1.0 for example. If we're using integers like: 0 or 1, we should use positiveintegerfield here.

this makes sense to me

Should we include a process for handling the ABI based on contract version, so it outputs the appropriate static URL or a given contract version..?

as does this

default=0,
decimal_places=0,
max_digits=3,
help_text=_('The contract version the Grant.'),
)
transaction_hash = models.CharField(
max_length=255,
default='0x0',
Expand Down
4 changes: 2 additions & 2 deletions app/grants/templates/grants/cancel.html
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ <h2 class="font-title-lg my-4">{% trans "Cancel Contribution" %}</h2>
<button class="button button--primary button--warning button--full">{% trans "Cancel Contribution" %}
</button>
<input type="hidden" id="contract_address" name="contract_address" value="{{ grant.contract_address }}">
<input type="hidden" id="contract_version" name="contract_version" value="{{ grant.contract_version }}">
<input type="hidden" id="admin_address" name="admin_address" value="{{ grant.admin_address }}">
<input type="hidden" id="token_address" name="token_address" value="{{ subscription.token_address }}">
<input type="hidden" id="amount_per_period" name="amount_per_period" value="{{ subscription.amount_per_period }}">
Expand All @@ -105,11 +106,10 @@ <h2 class="font-title-lg my-4">{% trans "Cancel Contribution" %}</h2>
<!-- jQuery -->
<script src="{% static "v2/js/grants/compiledSubscriptionContract.js" %}"></script>
<script src="{% static "v2/js/grants/compiledTokenContract.js" %}"></script>
<script src="{% static "v2/js/grants/cancel_subscription.js" %}"></script>
<script src="{% static "v2/js/grants/shared.js" %}"></script>
<script src="{% static "v2/js/grants/cancel_subscription.js" %}"></script>
<script src="{% static "v2/js/abi.js" %}"></script>
<script src="{% static "v2/js/pages/shared_bounty_mutation_estimate_gas.js" %}"></script>
<script src="{% static "v2/js/shared.js" %}"></script>
<script src="{% static "v2/js/ipfs-api.js" %}"></script>
<script src="{% static "v2/js/ipfs.js" %}"></script>
</html>
4 changes: 3 additions & 1 deletion app/grants/templates/grants/detail.html
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ <h4 class="my-4" >{% trans "This grant has ended. You can find all active grants
<button class="button button--primary button--warning" id="cancel_grant">{% trans "Cancel this Grant" %}
</button>
<input type="hidden" id="contract_address" name="contract_address" value="{{ grant.contract_address }}">
<input type="hidden" id="contract_version" name="contract_version" value="{{ grant.contract_version }}">
</form>
{% elif user_subscription %}
<a href="{% url 'grants:subscription_cancel' grant.id grant.slug user_subscription.id %}">
Expand Down Expand Up @@ -302,9 +303,10 @@ <h5 class="font-body mt-2 font-weight-semibold">

<script src="{% static "v2/js/grants/compiledSubscriptionContract.js" %}"></script>
<script src="{% static "v2/js/abi.js" %}"></script>
<script src="{% static "v2/js/shared.js" %}"></script>
<script src="{% static "v2/js/ipfs-api.js" %}"></script>
<script src="{% static "v2/js/ipfs.js" %}"></script>
<script src="{% static "v2/js/user-search.js" %}"></script>
<script src="{% static "v2/js/grants/shared.js" %}"></script>
<script src="{% static "v2/js/grants/detail.js" %}"></script>

</html>
3 changes: 2 additions & 1 deletion app/grants/templates/grants/fund.html
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ <h2 class="font-title-lg my-4">{% trans "Fund Grant" %}</h2>
<input type="hidden" id="admin_address" name="admin_address" value="{{ grant.admin_address }}">
<input type="hidden" id="token_address" name="token_address" value="{{ grant.token_address }}">
<input type="hidden" id="contract_address" name="contract_address" value="{{ grant.contract_address }}">
<input type="hidden" id="contract_version" name="contract_version" value="{{ grant.contract_version }}">
<input type="hidden" id="network" name="network" value="{{ grant.network }}">
<input type="hidden" id="subscription_hash" name="subscription_hash" value="">
<input type="hidden" id="signature" name="signature" value="">
Expand All @@ -193,8 +194,8 @@ <h2 class="font-title-lg my-4">{% trans "Fund Grant" %}</h2>
<script src="{% static "v2/js/tokens.js" %}"></script>
<script src="{% static "v2/js/abi.js" %}"></script>
<script src="{% static "v2/js/pages/shared_bounty_mutation_estimate_gas.js" %}"></script>
<script src="{% static "v2/js/grants/fund.js" %}"></script>
<script src="{% static "v2/js/grants/shared.js" %}"></script>
<script src="{% static "v2/js/grants/fund.js" %}"></script>
<script src="{% static "v2/js/ipfs-api.js" %}"></script>
<script src="{% static "v2/js/ipfs.js" %}"></script>
</html>
6 changes: 3 additions & 3 deletions app/grants/templates/grants/new.html
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ <h1>{% trans "Create a Grant" %}</h1>
<div>
<input type="hidden" class="form__input form__input-lg " id="transaction_hash" name="transaction_hash" />
<input type="hidden" class="form__input form__input-lg " id="contract_address" name="contract_address" />
<input type="hidden" id="contract_version" name="contract_version" value="0">
<input type="hidden" class="form__input form__input-lg " id="network" name="network" />
<input type="hidden" id="receipt" name="receipt" value="{}">
<input type="hidden" id="token_symbol" name="token_symbol" value="">
Expand All @@ -159,12 +160,11 @@ <h1>{% trans "Create a Grant" %}</h1>
<script src="{% static "v2/js/abi.js" %}"></script>
<script src="/dynamic/js/tokens_dynamic.js"></script>
<script src="{% static "v2/js/tokens.js" %}"></script>
<script src="{% static "v2/js/shared.js" %}"></script>
<script src="{% static "v2/js/ipfs-api.js" %}"></script>
<script src="{% static "v2/js/ipfs.js" %}"></script>
<script src="{% static "v2/js/grants/compiledSubscriptionContract.js" %}"></script>
<script src="{% static "v2/js/user-search.js" %}"></script>
<script src="{% static "v2/js/grants/new.js" %}"></script>
<script src="{% static "v2/js/grants/compiledSubscriptionContract.js" %}"></script>
<script src="{% static "v2/js/grants/shared.js" %}"></script>
<script src="{% static "v2/js/grants/new.js" %}"></script>
<script src="{% static "v2/js/waiting_room_entertainment.js" %}"></script>
</html>
1 change: 1 addition & 0 deletions app/grants/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ def grant_new(request):
'token_address': request.POST.get('denomination', ''),
'token_symbol': request.POST.get('token_symbol', ''),
'amount_goal': request.POST.get('amount_goal', 1),
'contract_version': request.POST.get('contract_version', ''),
'transaction_hash': request.POST.get('transaction_hash', ''),
'contract_address': request.POST.get('contract_address', ''),
'network': request.POST.get('network', 'mainnet'),
Expand Down