This file contains hidden or 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
function propose( | |
address[] memory targets, | |
uint256[] memory values, | |
bytes[] memory calldatas, | |
string memory description | |
) public virtual override returns (uint256) { | |
require( | |
getVotes(_msgSender(), block.number - 1) >= proposalThreshold(), | |
"Governor: proposer votes below proposal threshold" | |
); |
This file contains hidden or 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
function payoutSubscription(uint256 subscriptionId) public { | |
Subscription memory sub = subscriptions[subscriptionId]; | |
require(sub.active, 'subscription inactive'); | |
require((block.timestamp - sub.lastPayout) >= sub.payoutPeriod, 'Too soon'); | |
subscriptions[subscriptionId].lastPayout = block.timestamp; | |
require(IERC20(sub.token).transferFrom(sub.payer, sub.receiver, sub.amount), 'transfer from failed'); | |
emit Payout(subscriptionId, sub.amount, sub.token); | |
} |
This file contains hidden or 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
modifier onlyCreator(uint256 subscriptionId) { | |
require(msg.sender == subscriptions[subscriptionId].payer, 'not allowed'); | |
_; | |
} | |
function cancelSubscription(uint256 subscriptionId) onlyCreator(subscriptionId) public { | |
//delete subscriptions[subscriptionCounter]; | |
subscriptions[subscriptionCounter].active = false; | |
emit SubscriptionCanceled(subscriptionId); | |
} |
This file contains hidden or 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
event SubscriptionCreated(address indexed from, address indexed to, uint256 subscriptionId, Subscription subscription); | |
event SubscriptionCanceled(uint256 indexed subscriptionId); | |
event Payout(uint256 indexed subscriptionId, uint256 amount, address token); | |
function createSubscription(address receiver, uint256 amount, uint256 payoutPeriod, address token) external { | |
Subscription memory newSub = Subscription( | |
msg.sender, | |
receiver, | |
amount, | |
token, |
This file contains hidden or 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
contract SubscriptionManager { | |
struct Subscription { | |
address payer; | |
address receiver; | |
uint256 amount; | |
address token; | |
uint256 payoutPeriod; | |
uint256 lastPayout; | |
bool active; |
This file contains hidden or 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
contract Storage { | |
uint256 number; | |
/** | |
* @dev Store value in variable | |
* @param num value to store | |
*/ | |
function store(uint256 num) public { | |
number = num; |
This file contains hidden or 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
class GeneratorController: | |
def __init__(self, base_dir, img_dir, meta_dir, weights_map, traits_order, | |
percent_appearance=None, matching_traits=None): | |
self.base_dir = base_dir | |
self.img_dir = img_dir | |
self.meta_dir = meta_dir | |
self.weights_map = weights_map | |
self.traits_order = traits_order | |
self.percent_appearance = percent_appearance or {} |
This file contains hidden or 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
def combine_all(): | |
prin("darko") |
This file contains hidden or 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
// npm i bitcoinaverage | |
const ba = require('bitcoinaverage'); | |
var publicKey = 'ZGUyZTQ3NTJiNDQ5NDkzM2I4YTRjNjE2YTY1Y2Y0ZjE'; | |
var restClient = ba.restfulClient(publicKey); | |
restClient.getTickerDataPerSymbol('crypto', 'DOGEUSD', function(response) { | |
console.log(response); | |
}, function(error){ | |
console.log(error); |
This file contains hidden or 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
import requests | |
BA_API_KEY = 'your api key here' | |
def get_dogecoin_price(): | |
price_url = 'https://apiv2.bitcoinaverage.com/indices/crypto/ticker/DOGEUSD' | |
response = requests.get(price_url, headers={'x-ba-key': BA_API_KEY}) | |
return response.json() | |
result = get_dogecoin_price() |