-
-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3945 from rafalkowalski/issue/3913
[Issue #3913] Add functionality to become a matching partner
- Loading branch information
Showing
7 changed files
with
175 additions
and
16 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
const GITCOIN_ADDRESS = '0x00De4B13153673BCAE2616b67bf822500d325Fc3'; | ||
|
||
function createMatchingPartner(transactionID, transactionAmount) { | ||
let newMatchPledgeUrl = '/grants/matching-partners/new'; | ||
|
||
$.post(newMatchPledgeUrl, {hash: transactionID, amount: transactionAmount}).then(function(result) { | ||
_alert( | ||
result.message, | ||
'success' | ||
); | ||
}).fail(function(data) { | ||
_alert( | ||
data.responseJSON['message'], | ||
'error' | ||
); | ||
}); | ||
} | ||
|
||
function saveTransactionDetails(transactionID) { | ||
|
||
web3.eth.getTransaction(transactionID).then(function(transactionDetails) { | ||
let network = document.web3network || 'mainnet'; | ||
let data = { | ||
'txid': transactionID, | ||
'amount': transactionDetails.value, | ||
'network': network, | ||
'from_address': transactionDetails.from, | ||
'to_address': transactionDetails.to, | ||
'type': 'matchpledge' | ||
}; | ||
|
||
let newAttestationsUrl = '/revenue/attestations/new'; | ||
|
||
$.post(newAttestationsUrl, data).then(function(result) { | ||
createMatchingPartner(transactionID, transactionDetails.value); | ||
}); | ||
|
||
}); | ||
|
||
} | ||
|
||
function processPayment() { | ||
var ethAmount = prompt('How many ETH would you like to transfer?', '1ETH'); | ||
|
||
if (ethAmount && ethAmount.length > 0) { | ||
ethAmount = ethAmount.replace('ETH', ''); | ||
var transactionParams = { | ||
to: GITCOIN_ADDRESS, | ||
from: web3.currentProvider.selectedAddress, | ||
value: web3.utils.toWei(ethAmount) | ||
}; | ||
|
||
web3.eth.sendTransaction( | ||
transactionParams, | ||
function(error, hash) { | ||
if (error) { | ||
_alert(error.message, 'error'); | ||
} else { | ||
saveTransactionDetails(hash); | ||
} | ||
} | ||
); | ||
} | ||
} |
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,18 @@ | ||
# Generated by Django 2.1.7 on 2019-03-14 22:34 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('grants', '0018_grant_hidden'), | ||
] | ||
|
||
operations = [ | ||
migrations.AddField( | ||
model_name='matchpledge', | ||
name='data', | ||
field=models.TextField(blank=True), | ||
), | ||
] |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
from django.urls import reverse | ||
|
||
from test_plus.test import TestCase | ||
|
||
|
||
class GrantsViewResponsesTests(TestCase): | ||
def test_not_authorized(self): | ||
response = self.client.post(reverse('grants:new_matching_partner')) | ||
|
||
expected_response = {'message': 'Not Authorized', 'status': 403} | ||
self.assertEqual(response.status_code, expected_response['status']) | ||
self.assertEqual(response.json(), expected_response) |
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