-
-
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.
GITC-112: tezos crosschain | bounties/hackathons (#9182)
* tezos backend init * finish sync * svg + add to chain list * add tenant * + browser script * start tezos extension * + taquito, beacon wallet * - finish extension - switch to mainnet - count confirmations * minify taquito beacon wallet * add validation for tezos addresses * fix address validation * show web3 modal only for eth in issue/fulfill * make migrations * address comments * compress tezos.svg * review fix Co-authored-by: Octavio Amuchástegui <[email protected]> Co-authored-by: Aditya Anand M C <[email protected]>
- Loading branch information
1 parent
3bb4d64
commit 8a534c4
Showing
19 changed files
with
297 additions
and
22 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
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,80 @@ | ||
const payWithTezosExtension = async(fulfillment_id, to_address, vm, modal) => { | ||
|
||
const amount = vm.fulfillment_context.amount; | ||
const token_name = vm.bounty.token_name; | ||
|
||
let selectedAddress; | ||
|
||
const Tezos = new taquito.TezosToolkit('https://mainnet-tezos.giganode.io'); | ||
const wallet = new taquitoBeaconWallet.BeaconWallet({ name: 'Gitcoin' }); | ||
|
||
Tezos.setWalletProvider(wallet); | ||
|
||
const activeAccount = await wallet.client.getActiveAccount(); | ||
|
||
if (activeAccount) { | ||
console.log('Already connected:', activeAccount.address); | ||
selectedAddress = activeAccount.address; | ||
} else { | ||
try { | ||
await wallet.requestPermissions(); | ||
selectedAddress = await wallet.getPKH(); | ||
console.log('New connection:', selectedAddress); | ||
} catch (e) { | ||
console.log(e); | ||
} | ||
} | ||
|
||
if (token_name == 'XTZ') { | ||
try { | ||
const txHash = await wallet.sendOperations([ | ||
{ | ||
kind: beacon.TezosOperationType.TRANSACTION, | ||
destination: to_address, | ||
amount: amount * 10 ** vm.decimals | ||
} | ||
]); | ||
|
||
callback(null, selectedAddress, txHash); | ||
} catch (e) { | ||
modal.closeModal(); | ||
_alert({ message: `${e.title} - ${e.description}` }, 'danger'); | ||
console.log(e); | ||
} | ||
} | ||
|
||
function callback(error, from_address, txn) { | ||
if (error) { | ||
_alert({ message: gettext('Unable to payout bounty due to: ' + error) }, 'danger'); | ||
console.log(error); | ||
} else { | ||
|
||
const payload = { | ||
payout_type: 'tezos_ext', | ||
tenant: 'TEZOS', | ||
amount: amount, | ||
token_name: token_name, | ||
funder_address: from_address, | ||
payout_tx_id: txn | ||
}; | ||
|
||
modal.closeModal(); | ||
const apiUrlBounty = `/api/v1/bounty/payout/${fulfillment_id}`; | ||
|
||
fetchData(apiUrlBounty, 'POST', payload).then(response => { | ||
if (200 <= response.status && response.status <= 204) { | ||
vm.fetchBounty(); | ||
_alert('Payment Successful', 'success'); | ||
|
||
} else { | ||
_alert('Unable to make payout bounty. Please try again later', 'danger'); | ||
console.error(`error: bounty payment failed with status: ${response.status} and message: ${response.message}`); | ||
} | ||
}).catch(function(error) { | ||
_alert('Unable to make payout bounty. Please try again later', 'danger'); | ||
console.log(error); | ||
}); | ||
} | ||
} | ||
}; | ||
|
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
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,28 @@ | ||
# Generated by Django 2.2.20 on 2021-06-23 15:36 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
|
||
dependencies = [ | ||
('dashboard', '0180_auto_20210503_0431'), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name='bounty', | ||
name='web3_type', | ||
field=models.CharField(choices=[('legacy_gitcoin', 'Legacy Bounty'), ('bounties_network', 'Bounties Network'), ('qr', 'QR Code'), ('web3_modal', 'Web3 Modal'), ('polkadot_ext', 'Polkadot Ext'), ('binance_ext', 'Binance Ext'), ('harmony_ext', 'Harmony Ext'), ('rsk_ext', 'RSK Ext'), ('xinfin_ext', 'Xinfin Ext'), ('nervos_ext', 'Nervos Ext'), ('algorand_ext', 'Algorand Ext'), ('sia_ext', 'Sia Ext'), ('tezos_ext', 'Tezos Ext'), ('fiat', 'Fiat'), ('manual', 'Manual')], default='bounties_network', max_length=50), | ||
), | ||
migrations.AlterField( | ||
model_name='bountyfulfillment', | ||
name='payout_type', | ||
field=models.CharField(blank=True, choices=[('bounties_network', 'bounties_network'), ('qr', 'qr'), ('fiat', 'fiat'), ('web3_modal', 'web3_modal'), ('polkadot_ext', 'polkadot_ext'), ('binance_ext', 'binance_ext'), ('harmony_ext', 'harmony_ext'), ('rsk_ext', 'rsk_ext'), ('xinfin_ext', 'xinfin_ext'), ('nervos_ext', 'nervos_ext'), ('algorand_ext', 'algorand_ext'), ('sia_ext', 'sia_ext'), ('tezos_ext', 'tezos_ext'), ('manual', 'manual')], help_text='payment type used to make the payment', max_length=20, null=True), | ||
), | ||
migrations.AlterField( | ||
model_name='bountyfulfillment', | ||
name='tenant', | ||
field=models.CharField(blank=True, choices=[('BTC', 'BTC'), ('ETH', 'ETH'), ('ETC', 'ETC'), ('ZIL', 'ZIL'), ('CELO', 'CELO'), ('PYPL', 'PYPL'), ('POLKADOT', 'POLKADOT'), ('BINANCE', 'BINANCE'), ('HARMONY', 'HARMONY'), ('FILECOIN', 'FILECOIN'), ('RSK', 'RSK'), ('XINFIN', 'XINFIN'), ('NERVOS', 'NERVOS'), ('ALGORAND', 'ALGORAND'), ('SIA', 'SIA'), ('TEZOS', 'TEZOS'), ('OTHERS', 'OTHERS')], help_text='specific tenant type under the payout_type', max_length=10, null=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
Oops, something went wrong.