Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
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
428 changes: 428 additions & 0 deletions contracts/DecentralisedPaymentProcessor.sol

Large diffs are not rendered by default.

12 changes: 9 additions & 3 deletions contracts/MonethaSupportedTokens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ contract MonethaSupportedTokens is Restricted {
}

mapping (uint => Token) public tokens;
mapping (address => bool) public validToken;

uint public tokenId;

Expand All @@ -34,12 +35,15 @@ contract MonethaSupportedTokens is Restricted {
});
allAddresses.push(_tokenAddress);
allAccronym.push(bytes32(_tokenAcronym));
validToken[_tokenAddress] = true;
}

function deleteToken(uint _tokenId)
external onlyMonetha
{

address _tokenAddress = tokens[_tokenId].token_address;
validToken[_tokenAddress] = false;

tokens[_tokenId].token_address = tokens[tokenId].token_address;
tokens[_tokenId].token_acronym = tokens[tokenId].token_acronym;

Expand All @@ -52,9 +56,11 @@ contract MonethaSupportedTokens is Restricted {
tokenId--;
}

function getAll() external view returns (address[], bytes32[])
{
function getAll() external view returns (address[], bytes32[]) {
return (allAddresses, allAccronym);
}

function isTokenValid(address _tokenAddr) external view returns (bool) {
return validToken[_tokenAddr];
}
}
11 changes: 10 additions & 1 deletion contracts/PaymentProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "./MonethaGateway.sol";
import "./MerchantDealsHistory.sol";
import "./MerchantWallet.sol";
import "./GenericERC20.sol";
import "./MonethaSupportedTokens.sol";


/**
Expand Down Expand Up @@ -46,6 +47,9 @@ contract PaymentProcessor is Pausable, Destructible, Contactable, Restricted {

uint public constant PERMILLE_COEFFICIENT = 1000;

/// MonethaSupportedTokens contract for validating tokens
MonethaSupportedTokens public supportedTokens;

/// MonethaGateway contract for payment processing
MonethaGateway public monethaGateway;

Expand Down Expand Up @@ -101,6 +105,7 @@ contract PaymentProcessor is Pausable, Destructible, Contactable, Restricted {
* @param _merchantWallet Address of MerchantWallet, where merchant reputation and funds are stored
*/
constructor(
address _tokenAddr,
string _merchantId,
MerchantDealsHistory _merchantHistory,
MonethaGateway _monethaGateway,
Expand All @@ -110,6 +115,7 @@ contract PaymentProcessor is Pausable, Destructible, Contactable, Restricted {
{
require(bytes(_merchantId).length > 0);

supportedTokens = MonethaSupportedTokens(_tokenAddr);
merchantIdHash = keccak256(abi.encodePacked(_merchantId));

setMonethaGateway(_monethaGateway);
Expand Down Expand Up @@ -142,7 +148,10 @@ contract PaymentProcessor is Pausable, Destructible, Contactable, Restricted {
require(_paymentAcceptor != address(0));
require(_originAddress != address(0));
require(orders[_orderId].price == 0 && orders[_orderId].fee == 0);

if (_tokenAddress != address(0)) {
require(supportedTokens.isTokenValid(_tokenAddress) == true, "token not supported");
}

orders[_orderId] = Order({
state : State.Created,
price : _price,
Expand Down
9 changes: 8 additions & 1 deletion contracts/PrivatePaymentProcessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import "monetha-utility-contracts/contracts/Restricted.sol";
import "./MonethaGateway.sol";
import "./MerchantWallet.sol";
import "./GenericERC20.sol";
import "./MonethaSupportedTokens.sol";

contract PrivatePaymentProcessor is Pausable, Destructible, Contactable, Restricted {

Expand Down Expand Up @@ -60,6 +61,9 @@ contract PrivatePaymentProcessor is Pausable, Destructible, Contactable, Restric
uint amount
);

/// MonethaSupportedTokens contract for validating tokens
MonethaSupportedTokens public supportedTokens;

/// MonethaGateway contract for payment processing
MonethaGateway public monethaGateway;

Expand Down Expand Up @@ -87,6 +91,7 @@ contract PrivatePaymentProcessor is Pausable, Destructible, Contactable, Restric
* @param _merchantWallet Address of MerchantWallet, where merchant reputation and funds are stored
*/
constructor(
address _tokenAddr,
string _merchantId,
MonethaGateway _monethaGateway,
MerchantWallet _merchantWallet
Expand All @@ -97,6 +102,7 @@ contract PrivatePaymentProcessor is Pausable, Destructible, Contactable, Restric

merchantIdHash = keccak256(abi.encodePacked(_merchantId));

supportedTokens = MonethaSupportedTokens(_tokenAddr);
setMonethaGateway(_monethaGateway);
setMerchantWallet(_merchantWallet);
}
Expand Down Expand Up @@ -165,7 +171,8 @@ contract PrivatePaymentProcessor is Pausable, Destructible, Contactable, Restric
require(_originAddress != 0x0);
require(_orderValue > 0);
require(_tokenAddress != address(0));

require(supportedTokens.isTokenValid(_tokenAddress) == true, "token not supported");

address fundAddress;
fundAddress = merchantWallet.merchantFundAddress();

Expand Down
Loading