daostack / daostack/arc.js

implement "approveAndStake"

Open
#95 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
14
Forks
13
PR merge metrics
No merged PRs in 30d

Description

This is from the infra `test/genesisprotocol.js`:

```const stake = async function(_testSetup,_proposalId,_vote,_amount,_staker) {
var nonce = (await _testSetup.genesisProtocol.stakesNonce(_staker)).toString();
var textMsg = "0x"+ethereumjs.soliditySHA3(
["address","bytes32","uint", "uint","uint"],
[_testSetup.genesisProtocol.address, _proposalId,_vote,_amount, nonce]
).toString("hex");
const signature = await web3.eth.sign(textMsg, _staker);
const encodeABI = await new web3.eth.Contract(_testSetup.genesisProtocol.abi).methods.stakeWithSignature(_proposalId,_vote,_amount,nonce,signatureType,signature).encodeABI();

const transaction = await _testSetup.stakingToken.approveAndCall(
_testSetup.genesisProtocol.address, _amount, encodeABI ,{from : _staker}
);
var stakeLog;
await _testSetup.genesisProtocol.getPastEvents('Stake',
{_proposalId: _proposalId},
{fromBlock: transaction.blockNumber}
)
.then(function(events){
stakeLog = events;
});

return stakeLog;
};```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.