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: rsk integration for bounties + hackathons #8259

Merged
merged 19 commits into from
Feb 16, 2021

Conversation

thelostone-mc
Copy link
Member

@thelostone-mc thelostone-mc commented Jan 18, 2021

Description

Chain ID: 30

Tokens:

Mainnet

  • R-BTC- 18
  • DOC - 18 - 0xe700691da7b9851f2f35f8b8182c69c53ccad9db
  • RDOC - 18 - 0x2d919f19d4892381d58edebeca66d5642cef1a1f

Testnet

  • DOC - 0x54c598fa101b6DFAB4EE130E11fd0A05C646802D
  • RDOC - 0x7fb303d9806a72563c46aad8d874b301419c374b

Fixes: #8348
Fixes: #8318

closes #8349
closes #8350
closes #8351
closes #8352

Tests

@thelostone-mc
Copy link
Member Author

thelostone-mc commented Feb 3, 2021

image

code snippet :
https://github.com/thelostone-mc/web/blob/rsk/app/assets/v2/js/pages/bounty_detail/rsk_extension.js#L9-L30

to reproduce, head over to gitcoin site and paste this in browser

 const rskHost = "https://public-node.testnet.rsk.co"
  const rskClient = new Web3();
  rskClient.setProvider(
    new rskClient.providers.HttpProvider(rskHost)
  );

to_address="0xbF80163459fd26227970DF1b0b16cB8C846566af"
from_address="0xD6332F76e3911EF876B330F4c5b2367045544B3d"
amount = 0.001 

 const tx_args = {
    to: to_address.toLowerCase(),
    from: from_address.toLowerCase(),
    value: rskClient.utils.toWei(String(amount)),
    gasPrice: '0x3938700',
    gas: rskClient.utils.toHex(318730),
    gasLimit: rskClient.utils.toHex(318730),
    nonce: await rskClient.eth.getTransactionCount(from_address.toLowerCase())
  };
  
  rskClient.eth.sendTransaction(
    tx_args,
    (error, result) => conso.log(error, result)
  );

@alepc253
Copy link

alepc253 commented Feb 3, 2021

@thelostone-mc it fails because sendTransaction is a method from personal module and it is not enabled in RSK public nodes (you need to use sendRawTransaction or sendSignedTransaction)

@thelostone-mc
Copy link
Member Author

thelostone-mc commented Feb 10, 2021

code to test ERC-20 transfer (tRif)

init connection

  const rskHost = "https://public-node.testnet.rsk.co";
  const rskClient = new Web3();
  rskClient.setProvider(
    new rskClient.providers.HttpProvider(rskHost)
  );

Do transfer

amount = 3.0;
amountInWei  = amount * 1.0 * Math.pow(10, 18);
amountAsString = new rskClient.utils.BN(BigInt(amountInWei)).toString();

to_address = '0xbF80163459fd26227970DF1b0b16cB8C846566af';

// rRif
token_address = ('0x19f64674d8a5b4e652319f5e239efd3bc969a1fe').toLowerCase();

token_contract =new  rskClient.eth.Contract(token_abi, token_address);
     

  data = token_contract.methods.transfer(to_address.toLowerCase(), amountAsString).encodeABI();

  tx_args = {
      to: token_address,
      from: ethereum.selectedAddress,
      value: '0x0',
      gasPrice: rskClient.utils.toHex(await rskClient.eth.getGasPrice()),
      gas: rskClient.utils.toHex(318730),
      gasLimit: rskClient.utils.toHex(318730),
      data: data
    };

await ethereum.request(
      {
        method: 'eth_sendTransaction',
        params: [tx_args],
      }
    );

@chibie
Copy link
Contributor

chibie commented Feb 11, 2021

when user clicks "payout bounty" but doesn't have nifty wallet extension installed or it's disabled

image

@chibie chibie marked this pull request as ready for review February 11, 2021 14:45
@chibie chibie changed the title WIP bounties: rsk integration feat: rsk integration for bounties + hackathons Feb 11, 2021
@thelostone-mc
Copy link
Member Author

LGTM

@thelostone-mc thelostone-mc added this to Engineering-Review in PR Review Board Feb 15, 2021
@@ -26,7 +26,7 @@ def record_payout_activity(fulfillment):
kwargs['profile'] = fulfillment.funder_profile
kwargs['metadata']['from'] = fulfillment.funder_profile.handle
kwargs['metadata']['to'] = fulfillment.profile.handle
kwargs['metadata']['payout_amount'] = fulfillment.payout_amount
kwargs['metadata']['payout_amount'] = str(fulfillment.payout_amount)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why does this change ? does this affect the round function that is used in frontend

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there's always been an error like object of type Decimal is not JSON serializable while running sync_pending_fulfillments

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did we check to make sure that does this not have any side affects ? @chibie

@thelostone-mc thelostone-mc merged commit c256f21 into gitcoinco:master Feb 16, 2021
PR Review Board automation moved this from Engineering-Review to Done Feb 16, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
4 participants