Skip to content

Commit ae163fa

Browse files
committed
Finding bountyId and storing in dB is working
1 parent b124974 commit ae163fa

File tree

5 files changed

+29
-19
lines changed

5 files changed

+29
-19
lines changed

app/assets/v2/js/abi.js

Lines changed: 4 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

app/assets/v2/js/pages/bounty_details.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -210,20 +210,15 @@ var pendingChangesWarning = function(issueURL, last_modified_time_remote, now){
210210
// Only run this after the transaction is confirmed to be on the blockchain
211211
var getBountyId = function (callback) {
212212
// Get total number of bounties on the contract
213-
if (localStorage['bountyId'] != null) {
213+
if (localStorage['bountyId']) {
214214
callback(null, localStorage['bountyId']);
215215
}
216216
var transactionInfo;
217217
var bountiesLength;
218218
var bountyId;
219219
// var bounty = web3.eth.contract(bounty_abi).at(bounty_address());
220-
var bounty = web3.eth.contract(bounty_abi).at('0xf209d2b723b6417cbf04c07e733bee776105a073'); //hardcode to test
221-
setTimeout(function() {
222-
if (bounty['transactionHash'] == null) {
223-
console.log('Bounty not ready yet...');
224-
getBountyId(callback);
225-
}
226-
},1000)
220+
var bounty = web3.eth.contract(bounty_abi).at(bounty_address()); //hardcode to test
221+
227222
bounty.getNumBounties(function(error, result){
228223
console.log("Callback is now running...");
229224
if (error){
@@ -242,10 +237,11 @@ var pendingChangesWarning = function(issueURL, last_modified_time_remote, now){
242237
return;
243238
}
244239
issuer = result2[0];
240+
var bountyDetails = JSON.parse(localStorage['bountyDetails']);
245241
console.log('issuer from stdb: ' + issuer);
246242
console.log('account from bountyDetails:' + localStorage['bountyDetails'].split(",")[2])
247243
// compare issuer to the submitting address
248-
if (issuer == localStorage['bountyDetails'].split(",")[2]) {
244+
if (issuer == bountyDetails[2]) {
249245
bounty.getBountyData(i, function(error, result3) {
250246
if (error) {
251247
console.error(error);
@@ -264,18 +260,22 @@ var pendingChangesWarning = function(issueURL, last_modified_time_remote, now){
264260
i -= 1;
265261
if (i == 0) {
266262
console.log('bountyId not found.')
263+
localStorage['bountyId'] = 0;
267264
callback('bountyId not found', 0)
268-
}
265+
} else {
269266
getBountyLoop(i);
267+
}
270268
}
271269
})
272270
} else {
273271
i -= 1;
274272
if (i == 0) {
275273
console.log('bountyId not found.')
274+
localStorage['bountyId'] = 0;
276275
callback('bountyId not found', 0)
277-
}
276+
} else {
278277
getBountyLoop(i);
278+
}
279279
}
280280
})
281281
}
@@ -291,10 +291,11 @@ var pendingChangesWarning = function(issueURL, last_modified_time_remote, now){
291291
// Add bountyId to localStorage['bountyDetails'][11]
292292
getBountyId(function(error, result) {
293293
if(result != 0){
294-
var bountyDetails = localStorage['bountyDetails'].split(",");
295-
// bountyDetails = bountyDetails + "," + result.toString();
296-
bountyDetails = bountyDetails.push(result);
294+
var bountyDetails = JSON.parse(localStorage['bountyDetails']);
295+
// bountyDetails[8] = JSON.stringify(bountyDetails[8])
297296
debugger;
297+
// bountyDetails = bountyDetails + "," + result.toString();
298+
bountyDetails[11] = result;
298299
sync_web3(issueURL, bountyDetails, changes_synced_callback);
299300
console.log('success syncing with web3');
300301
} else {

app/assets/v2/js/pages/new_bounty.js

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,9 @@ $(document).ready(function(){
2626
if(localStorage['bountyType']){
2727
$('select[name=bountyType] option:contains('+localStorage['bountyType']+')').prop('selected', true);
2828
}
29-
if(localStorage['issueURL']){
30-
$('input[name=issueURL]').val(localStorage['issueURL']);
31-
}
29+
// if(localStorage['issueURL']){
30+
// $('input[name=issueURL]').val(localStorage['issueURL']);
31+
// }
3232
//fetch issue URL related info
3333
$("input[name=amount]").keyup(setUsdAmount);
3434
$("input[name=amount]").blur(setUsdAmount);
@@ -125,6 +125,7 @@ $(document).ready(function(){
125125
localStorage['experienceLevel'] = $('select[name=experienceLevel').val();
126126
localStorage['projectLength'] = $('select[name=projectLength').val();
127127
localStorage['bountyType'] = $('select[name=bountyType').val();
128+
localStorage.removeItem('bountyId');
128129

129130

130131
//setup web3
@@ -204,7 +205,7 @@ $(document).ready(function(){
204205
}
205206

206207
localStorage['txid'] = result;
207-
localStorage['bountyDetails'] = bountyDetails;
208+
localStorage['bountyDetails'] = JSON.stringify(bountyDetails);
208209
syncDb();
209210

210211
}
@@ -294,6 +295,7 @@ $(document).ready(function(){
294295
}
295296

296297
// Add data to IPFS and kick off all the callbacks.
298+
297299
ipfs.addJson(submit, newIpfsCallback);
298300
// getBountyId()
299301
});

app/dashboard/helpers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,6 +227,7 @@ def process_bounty_details(bountydetails, url, contract_address, network):
227227
#extract json
228228
metadata = None
229229
claimee_metadata = None
230+
# import pdb; pdb.set_trace()
230231
try:
231232
metadata = json.loads(bountydetails[8])
232233
except Exception as e:
@@ -253,6 +254,7 @@ def process_bounty_details(bountydetails, url, contract_address, network):
253254
except Exception as e:
254255
print(e)
255256
didChange = True
257+
# import pdb; pdb.set_trace();
256258

257259
with transaction.atomic():
258260
for old_bounty in old_bounties:

app/dashboard/views.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,6 @@ def profile_keywords_helper(handle):
284284

285285
def profile_keywords(request, handle):
286286
keywords = profile_keywords_helper(handle)
287-
288287
response = {
289288
'status': 200,
290289
'keywords': keywords,
@@ -369,8 +368,10 @@ def sync_web3(request):
369368
bountydetails[8] = str(bountydetails[8]) # multiple fields (metaData)
370369
bountydetails[9] = int(bountydetails[9]) # expires_date (expirationTime)
371370
bountydetails[10] = str(bountydetails[10]) # claimee_metadata (claimee_metaData)
371+
bountydetails[11] = int(bountydetails[11]) # standard_bounties_id (_bountyId)
372372
print(bountydetails)
373373
contract_address = request.POST.get('contract_address')
374+
# import pdb; pdb.set_trace();
374375
network = request.POST.get('network')
375376
didChange, old_bounty, new_bounty = process_bounty_details(bountydetails, issueURL, contract_address, network)
376377

0 commit comments

Comments
 (0)