Skip to content

Commit bb21c03

Browse files
authored
Merge branch 'master' into abdul/fix/make-active-clrs-collapsible
2 parents fccddda + b413bde commit bb21c03

58 files changed

Lines changed: 836 additions & 235 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

app/app/settings.py

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,6 @@
150150
'wiki.plugins.macros.apps.MacrosConfig',
151151
'adminsortable2',
152152
'debug_toolbar',
153-
'haystack',
154153
]
155154

156155
MIDDLEWARE = [
@@ -868,18 +867,6 @@ def callback(request):
868867
with open(str(root.path(PTOKEN_FACTORY_ABI_PATH))) as f:
869868
PTOKEN_FACTORY_ABI = json.load(f)
870869

871-
HAYSTACK_ELASTIC_SEARCH_URL = env('HAYSTACK_ELASTIC_SEARCH_URL', default='')
872-
873-
HAYSTACK_CONNECTIONS = {
874-
'default': {
875-
'ENGINE': 'haystack.backends.elasticsearch2_backend.Elasticsearch2SearchEngine',
876-
'URL': HAYSTACK_ELASTIC_SEARCH_URL,
877-
'INDEX_NAME': 'haystack',
878-
},
879-
}
880-
# Update Search index in realtime (using models.db.signals)
881-
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
882-
883870
account_sid = env('TWILIO_ACCOUNT_SID', default='')
884871
auth_token = env('TWILIO_AUTH_TOKEN', default='')
885872
verify_service = env('TWILIO_VERIFY_SERVICE', default='')

app/assets/v2/css/gitcoin.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ h4,
2121
.sticky-top {
2222
position: sticky!important;
2323
top: 0;
24-
z-index: 3;
24+
z-index: 1;
2525
}
2626

2727
.lighter {
Lines changed: 1 addition & 0 deletions
Loading

app/assets/v2/js/cart-ethereum-zksync.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ Vue.component('grantsCartEthereumZksync', {
5252
});
5353

5454
// Update zkSync checkout connection, state, and data frontend needs when wallet connection changes
55-
window.addEventListener('dataWalletReady', async (e) => {
55+
window.addEventListener('dataWalletReady', async(e) => {
5656
await this.setupZkSync();
5757
await this.onChangeHandler(this.donationInputs);
5858
});

app/assets/v2/js/cart.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -271,12 +271,12 @@ Vue.component('grants-cart', {
271271
if (isAllDai) {
272272
if (donationCurrencies.length === 1) {
273273
// Special case since we overestimate here otherwise
274-
return 80000;
274+
return 100000;
275275
}
276276
// Below curve found by running script at the repo below around 9AM PT on 2020-Jun-19
277277
// then generating a conservative best-fit line
278278
// https://github.com/mds1/Gitcoin-Checkout-Gas-Analysis
279-
return 25000 * donationCurrencies.length + 125000;
279+
return 27500 * donationCurrencies.length + 125000;
280280
}
281281

282282
// Otherwise, based on contract tests, we use the more conservative heuristic below to get
@@ -287,7 +287,7 @@ Vue.component('grants-cart', {
287287
const tokenAddr = currentValue.token.toLowerCase();
288288

289289
if (currentValue.token === ETH_ADDRESS) {
290-
return accumulator + 50000; // ETH donation gas estimate
290+
return accumulator + 70000; // ETH donation gas estimate
291291

292292
} else if (tokenAddr === '0x960b236A07cf122663c4303350609A66A7B288C0'.toLowerCase()) {
293293
return accumulator + 170000; // ANT donation gas estimate
@@ -951,6 +951,9 @@ Vue.component('grants-cart', {
951951
saveSubscriptionPayload.token_symbol.push(tokenName);
952952
} // end for each donation
953953

954+
// to allow , within comments
955+
saveSubscriptionPayload.comment = saveSubscriptionPayload.comment.join('_,_');
956+
954957
// Configure request parameters
955958
const url = '/grants/bulk-fund';
956959
const headers = {
@@ -1093,6 +1096,7 @@ Vue.component('grants-cart', {
10931096

10941097
// Configure data to save
10951098
let cartData;
1099+
10961100
if (!txHashes) {
10971101
// No transaction hashes were provided, so just save off the cart data directly
10981102
cartData = this.donationInputs;
@@ -1105,8 +1109,8 @@ Vue.component('grants-cart', {
11051109
return {
11061110
...donation,
11071111
txHash: txHashes[index]
1108-
}
1109-
})
1112+
};
1113+
});
11101114
}
11111115

11121116

app/assets/v2/js/grants/_detail-component.js

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,10 @@ Vue.mixin({
7777
data.logo = vm.logo;
7878
}
7979

80+
if (vm.logoBackground) {
81+
data.image_css = `background-color: ${vm.logoBackground};`;
82+
}
83+
8084
$.ajax({
8185
type: 'post',
8286
url: apiUrlGrant,
@@ -90,6 +94,7 @@ Vue.mixin({
9094
vm.grant.last_update = new Date();
9195
vm.grant.description_rich = JSON.stringify(vm.$refs.myQuillEditor.quill.getContents());
9296
vm.grant.description = vm.$refs.myQuillEditor.quill.getText();
97+
vm.grant.image_css = `background-color: ${vm.logoBackground};`;
9398
vm.$root.$emit('bv::toggle::collapse', 'sidebar-grant-edit');
9499
_alert('Updated grant.', 'success');
95100

@@ -218,6 +223,10 @@ Vue.mixin({
218223
});
219224
});
220225
},
226+
changeColor() {
227+
let vm = this;
228+
vm.grant.image_css = `background-color: ${vm.logoBackground};`
229+
},
221230
onFileChange(e) {
222231
let vm = this;
223232

@@ -300,7 +309,7 @@ Vue.mixin({
300309
},
301310
tweetVerification() {
302311
let vm = this;
303-
const tweetContent = `https://twitter.com/intent/tweet?text=${encodeURI(vm.verification_tweet)}%20${encodeURI(vm.user_code)}`;
312+
const tweetContent = `https://twitter.com/intent/tweet?text=${encodeURIComponent(vm.verification_tweet)}%20${encodeURIComponent(vm.user_code)}`;
304313

305314
window.open(tweetContent, '_blank');
306315
},
@@ -324,7 +333,7 @@ Vue.mixin({
324333
if (vm.grant.twitter_handle_2 && !(/^@?[a-zA-Z0-9_]{1,15}$/).test(vm.grant.twitter_handle_2)) {
325334
vm.$set(vm.errors, 'twitter_handle_2', 'Please enter your twitter handle e.g georgecostanza');
326335
}
327-
if (vm.grant.description_rich.length < 10) {
336+
if (vm.grant.description_rich_edited.length < 10) {
328337
vm.$set(vm.errors, 'description', 'Please enter description for the grant');
329338
}
330339

@@ -427,6 +436,7 @@ Vue.component('grant-details', {
427436
isStaff: isStaff,
428437
logo: null,
429438
logoPreview: null,
439+
logoBackground: null,
430440
relatedGrants: [],
431441
rows: 0,
432442
perPage: 4,
@@ -483,7 +493,9 @@ Vue.component('grant-details', {
483493
let vm = this;
484494

485495
vm.grant.description_rich_edited = vm.grant.description_rich;
486-
vm.editor.updateContents(JSON.parse(vm.grant.description_rich));
496+
if (vm.grant.description_rich_edited) {
497+
vm.editor.updateContents(JSON.parse(vm.grant.description_rich));
498+
}
487499
vm.grantInCart();
488500
},
489501
watch: {

app/assets/v2/js/grants/_detail.js

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Vue.mixin({
3838
fetchRelated: function() {
3939
let vm = this;
4040
let ids;
41-
let size = 6
41+
let size = 6;
4242

4343
if (!Object.keys(vm.grant.metadata).length || !vm.grant.metadata?.related?.length) {
4444
return;
@@ -49,7 +49,7 @@ Vue.mixin({
4949
});
5050
vm.relatedGrantsIds = vm.paginate(ids, size, vm.relatedGrantsPage);
5151

52-
vm.relatedGrantsPage+= 1;
52+
vm.relatedGrantsPage += 1;
5353

5454
if (!vm.relatedGrantsIds.length) {
5555
return;
@@ -73,8 +73,8 @@ Vue.mixin({
7373
let vm = this;
7474

7575
page = vm.transactions.next_page_number;
76-
if (!page){
77-
return
76+
if (!page) {
77+
return;
7878
}
7979
vm.loadingTx = true;
8080

@@ -99,8 +99,8 @@ Vue.mixin({
9999
let vm = this;
100100

101101
page = vm.contributors.next_page_number;
102-
if (!page){
103-
return
102+
if (!page) {
103+
return;
104104
}
105105
vm.loadingContributors = true;
106106

@@ -133,31 +133,31 @@ Vue.mixin({
133133
},
134134
tabChange: function(input) {
135135

136-
console.log(input)
136+
console.log(input);
137137
window.location = `${this.grant.details_url}?tab=${input}`;
138138
},
139139
enableTab: function() {
140140
let vm = this;
141-
let urlParams = new URLSearchParams(window.location.search)
141+
let urlParams = new URLSearchParams(window.location.search);
142142

143143
vm.tab = urlParams.get('tab');
144144

145145
switch (vm.tab) {
146146
case 'sybil_profile':
147-
vm.tabSelected = 4;
147+
vm.tabSelected = 4;
148148
break;
149149
case 'stats':
150-
vm.tabSelected = 5;
150+
vm.tabSelected = 5;
151151
break;
152152
default:
153-
vm.tabSelected = 0;
153+
vm.tabSelected = 0;
154154
}
155155
window.history.replaceState({}, document.title, `${window.location.pathname}`);
156156
},
157157
scrollToElement(element) {
158158
let container = this.$refs[element];
159159

160-
container.scrollIntoViewIfNeeded({behavior: "smooth", block: "start"});
160+
container.scrollIntoViewIfNeeded({behavior: 'smooth', block: 'start'});
161161
}
162162
},
163163
computed: {
@@ -195,7 +195,7 @@ if (document.getElementById('gc-grant-detail')) {
195195
loadingRelated: false,
196196
loading: false,
197197
isStaff: isStaff,
198-
transactions:{
198+
transactions: {
199199
grantTransactions: [],
200200
next_page_number: 1
201201
},
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
var binance_utils = {};
2+
3+
binance_utils.getChainVerbose = chainId => {
4+
switch (chainId) {
5+
case 'Binance-Chain-Tigris':
6+
return { name: 'Binance Chain Network', addressType: 'bbc-mainnet' };
7+
case 'Binance-Chain-Ganges':
8+
return { name: 'Binance Chain Test Network', addressType: 'bbc-testnet' };
9+
case '0x38':
10+
return { name: 'Binance Smart Chain Network', addressType: 'eth' };
11+
case '0x61':
12+
return { name: 'Binance Smart Chain Test Network', addressType: 'eth' };
13+
}
14+
}
15+
16+
17+
/**
18+
* Returns wallet's balance on the connected binance network
19+
* @param {String} address
20+
*/
21+
binance_utils.getAddressBalance = async address => {
22+
const isConnected = await BinanceChain.isConnected();
23+
24+
if (!isConnected || !address)
25+
return;
26+
27+
data = {
28+
method: 'eth_getBalance',
29+
params: [address, 'latest']
30+
};
31+
32+
const result = await BinanceChain.request(data);
33+
34+
// convert hex balance to integer and account for decimal points
35+
const bnbBalance = BigInt(result).toString(10) * 10 ** -18;
36+
37+
return Promise.resolve(bnbBalance.toFixed(4));
38+
};
39+
40+
41+
/**
42+
* Get accounts connected in extension
43+
*/
44+
binance_utils.getExtensionConnectedAccounts = async () => {
45+
const isConnected = await BinanceChain.isConnected();
46+
47+
if (!isConnected)
48+
return;
49+
50+
const accounts = await BinanceChain.requestAccounts();
51+
52+
return Promise.resolve(accounts);
53+
};
54+
55+
56+
/**
57+
* Sign and transfer token to another address via extension and returns txn hash
58+
* @param {Number} amount
59+
* @param {String} to_address
60+
* @param {String} from_address : optional, if not passed takes account first account from getExtensionConnectedAccounts
61+
*/
62+
binance_utils.transferViaExtension = async (amount, to_address, from_address) => {
63+
64+
return new Promise(async(resolve, reject) => {
65+
66+
const isConnected = await BinanceChain.isConnected();
67+
68+
if (!isConnected) {
69+
reject(`transferViaExtension: binance hasn't connected to the network ${binance_utils.getChainVerbose(BinanceChain.chainId).name}`);
70+
} else if (!amount) {
71+
reject('transferViaExtension: missing param amount');
72+
} else if (!to_address) {
73+
reject('transferViaExtension: missing param to_address');
74+
}
75+
76+
const chainVerbose = binance_utils.getChainVerbose(BinanceChain.chainId);
77+
78+
if (!from_address) {
79+
const accounts = await binance_utils.getExtensionConnectedAccounts();
80+
from_address = accounts && accounts[0]['addresses'].find(address => address.type === chainVerbose.addressType).address;
81+
}
82+
83+
if (!from_address) {
84+
reject('transferViaExtension: missing param from_address');
85+
}
86+
87+
const account_balance = await binance_utils.getAddressBalance(from_address);
88+
89+
if (Number(account_balance) < amount) {
90+
reject(`transferViaExtension: insufficent balance in address ${from_address}`);
91+
}
92+
93+
if (chainVerbose.addressType === 'eth') {
94+
const params = [
95+
{
96+
from: from_address,
97+
to: to_address,
98+
value: '0x' + amount.toString(16) // convert amount to hex
99+
},
100+
];
101+
102+
BinanceChain
103+
.request({
104+
method: 'eth_sendTransaction',
105+
params
106+
})
107+
.then(txHash => {
108+
resolve(txHash);
109+
})
110+
.catch(error => {
111+
reject('transferViaExtension: something went wrong' + error);
112+
});
113+
}
114+
});
115+
};
116+
117+
118+
/* EVENTS */
119+
BinanceChain.on('connect', info => {
120+
console.log(`connected to ${binance_utils.getChainVerbose(info.chainId).name}!`);
121+
});
122+
123+
BinanceChain.on('chainChanged', chainId => {
124+
console.log(`connected to ${binance_utils.getChainVerbose(chainId).name}!`);
125+
window.location.reload(); // reload page when chain changes
126+
});

0 commit comments

Comments
 (0)