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

feat(binance): integrate BUSD for bounties and hackathons 2 #8213

Merged
merged 22 commits into from
Jan 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 5 additions & 3 deletions app/assets/v2/js/lib/binance/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ binance_utils.getAddressTokenBalance = async (address, tokenContractAddress) =>
['balanceOf(address)']
);
const method_id = methodSignature.substr(0, 10);
const address = address.substr(2).padStart(64, '0'); // remove 0x and pad with zeroes
address = address.substr(2).padStart(64, '0'); // remove 0x and pad with zeroes

const params = [
{
Expand Down Expand Up @@ -166,7 +166,9 @@ binance_utils.transferViaExtension = async (amount, to_address, from_address, to

} else if (token_name === 'BUSD') {

const account_balance = await binance_utils.getAddressTokenBalance(from_address);
const busd_contract_address = '0xe9e7cea3dedca5984780bafc599bd69add087d56'

const account_balance = await binance_utils.getAddressTokenBalance(from_address, busd_contract_address);

if (Number(account_balance) < amount ) {
reject(`transferViaExtension: insufficent balance in address ${from_address}`);
Expand All @@ -185,7 +187,7 @@ binance_utils.transferViaExtension = async (amount, to_address, from_address, to
const params = [
{
from: from_address,
to: '0xe9e7cea3dedca5984780bafc599bd69add087d56', // BUSD token contract address
to: busd_contract_address,
data: method_id + to_address + amount
},
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const payWithBinanceExtension = (fulfillment_id, to_address, vm, modal) => {
const amount = vm.fulfillment_context.amount;
const token_name = vm.bounty.token_name;
const from_address = vm.bounty.bounty_owner_address;

binance_utils.transferViaExtension(
amount * 10 ** vm.decimals,
to_address,
Expand Down
5 changes: 5 additions & 0 deletions app/assets/v2/js/pages/hackathon_new_bounty.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,11 @@ Vue.mixin({
});

},
getBinanceSelectedAccount: async function() {
let vm = this;

vm.form.funderAddress = await binance_utils.getSelectedAccount();
},
getAmount: function(token) {
let vm = this;

Expand Down
6 changes: 3 additions & 3 deletions app/dashboard/sync/binance.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def get_binance_txn_status(fulfillment):
'Host': 'gitcoin.co'
}

binance_response = requests.post(binance_url, json=data, headers=headers).json()
binance_response = requests.post(binance_url, json=data).json()

result = binance_response['result']

Expand All @@ -43,9 +43,9 @@ def get_binance_txn_status(fulfillment):
if result:
tx_status = int(result.get('status'), 16) # convert hex to decimal

if tx_status == '1':
if tx_status == 1:
response = { 'status': 'done' }
elif tx_status == '0':
elif tx_status == 0:
response = { 'status': 'expired' }

except Exception as e:
Expand Down
1 change: 0 additions & 1 deletion app/dashboard/templates/bounty/new_bounty.html
Original file line number Diff line number Diff line change
Expand Up @@ -743,7 +743,6 @@ <h5 class="text-uppercase h3 font-weight-bold mb-0">Total</h5>
<script src="{% static "v2/js/lib/polkadot/extension.min.js" %}"></script>
<script src="{% static "v2/js/lib/polkadot/utils.js" %}"></script>

<script src="https://cdn.jsdelivr.net/npm/@binance-chain/[email protected]/lib/index.min.js"></script>
<script src="{% static "v2/js/lib/binance/utils.js" %}"></script>

<script>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -444,7 +444,7 @@ <h1 class="text-center">Fund Prize</h1>
</div>
</div>

<div class="funder-address-container" v-show="chainId !== '1'">
<div class="funder-address-container" v-show="chainId !== '1' && chainId !== '56'">
<label class="font-caption letter-spacing text-black-60" for="funderAddress">Funder Address</label>
<input name="funderAddress" id="funderAddress" class="form__input" type="text" placeholder="Address with which the bounty will be paid out" v-model="form.funderAddress">
<div class="text-danger" v-if="errors.funderAddress && !form.funderAddress">
Expand Down Expand Up @@ -521,6 +521,8 @@ <h5 class="text-uppercase h3 font-weight-bold mb-0">Total</h5>
<script src="{% static "v2/js/lib/polkadot/extension.min.js" %}"></script>
<script src="{% static "v2/js/lib/polkadot/utils.js" %}"></script>

<script src="{% static "v2/js/lib/binance/utils.js" %}"></script>

<script>
$('body').bootstrapTooltip({
selector: '[data-toggle="tooltip"]'
Expand Down