Skip to content

Commit

Permalink
Replace _providerAddress with _provider
Browse files Browse the repository at this point in the history
  • Loading branch information
gjgd committed Jul 11, 2018
1 parent de6cb0f commit 7578465
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
16 changes: 8 additions & 8 deletions contracts/TransmuteDPOS.sol
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,23 @@ import "./ProviderPool.sol";
contract TransmuteDPOS is TransmuteToken, RoundManager, ProviderPool {

event ProviderAdded (
address indexed _providerAddress,
address indexed _provider,
uint _pricePerStorageMineral,
uint _pricePerComputeMineral,
uint _blockRewardCut,
uint _feeShare
);

event ProviderUpdated (
address indexed _providerAddress,
address indexed _provider,
uint _pricePerStorageMineral,
uint _pricePerComputeMineral,
uint _blockRewardCut,
uint _feeShare
);

event ProviderResigned (
address indexed _providerAddress
address indexed _provider
);

struct Delegator {
Expand Down Expand Up @@ -79,15 +79,15 @@ contract TransmuteDPOS is TransmuteToken, RoundManager, ProviderPool {
emit ProviderResigned(msg.sender);
}

function bond(address _providerAddress, uint _amount) external {
Provider storage p = providers[_providerAddress];
function bond(address _provider, uint _amount) external {
Provider storage p = providers[_provider];
// A delegator is only allowed to bond to an Unregistered provider if the provider is himself
// otherwise _providerAddress has to be associated with a Registered provider
require(_providerAddress == msg.sender || p.status != ProviderStatus.Unregistered);
// otherwise _provider has to be associated with a Registered provider
require(_provider == msg.sender || p.status != ProviderStatus.Unregistered);
// Check if delegator has not already bonded to some address
require(delegators[msg.sender].delegateAddress == address(0));
this.transferFrom(msg.sender, this, _amount);
delegators[msg.sender] = Delegator(_providerAddress, _amount);
delegators[msg.sender] = Delegator(_provider, _amount);
p.totalAmountBonded = p.totalAmountBonded.add(_amount);
}
}
14 changes: 7 additions & 7 deletions test/TestTransmuteDPOS.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@ contract('TransmuteDPOS', accounts => {
// Step 1: Approve the transfer of amountBonded tokens (ERC20 spec)
// Step 2: Bond the amount to the provider
// Step 3: Registering parameters with provider()
async function approveBondProvider(pricePerStorageMineral, pricePerComputeMineral, blockRewardCut, feeShare, amountBonded, providerAddress) {
async function approveBondProvider(pricePerStorageMineral, pricePerComputeMineral, blockRewardCut, feeShare, amountBonded, provider) {
// This approve function comes from the ERC20 Transmute Token contract
await tdpos.approve(contractAddress, amountBonded, {from: providerAddress});
await tdpos.bond(providerAddress, amountBonded, {from: providerAddress});
await tdpos.provider(pricePerStorageMineral, pricePerComputeMineral, blockRewardCut, feeShare, {from: providerAddress});
await tdpos.approve(contractAddress, amountBonded, {from: provider});
await tdpos.bond(provider, amountBonded, {from: provider});
await tdpos.provider(pricePerStorageMineral, pricePerComputeMineral, blockRewardCut, feeShare, {from: provider});
}

describe('provider', () => {
Expand Down Expand Up @@ -92,7 +92,7 @@ contract('TransmuteDPOS', accounts => {
assert.web3Event(result, {
event: 'ProviderAdded',
args: {
_providerAddress: accounts[2],
_provider: accounts[2],
_pricePerStorageMineral: 22,
_pricePerComputeMineral: 10,
_blockRewardCut: 1,
Expand All @@ -106,7 +106,7 @@ contract('TransmuteDPOS', accounts => {
assert.web3Event(result, {
event: 'ProviderUpdated',
args: {
_providerAddress: accounts[2],
_provider: accounts[2],
_pricePerStorageMineral: 21,
_pricePerComputeMineral: 11,
_blockRewardCut: 2,
Expand Down Expand Up @@ -196,7 +196,7 @@ contract('TransmuteDPOS', accounts => {
assert.web3Event(result, {
event: 'ProviderResigned',
args: {
_providerAddress: accounts[2],
_provider: accounts[2],
}
});
});
Expand Down

0 comments on commit 7578465

Please sign in to comment.