diff --git a/bank_card_payment/app/Dockerfile b/bank_card_payment/app/Dockerfile new file mode 100644 index 00000000..973f1ed9 --- /dev/null +++ b/bank_card_payment/app/Dockerfile @@ -0,0 +1,6 @@ +FROM jfloff/alpine-python +COPY test_dwolla.py /test_dwolla.py +COPY requirements.txt /requirements.txt +RUN pip install -r /requirements.txt +RUN chmod +x /test_dwolla.py +ENTRYPOINT ["/test_dwolla.py"] \ No newline at end of file diff --git a/bank_card_payment/app/requirements.txt b/bank_card_payment/app/requirements.txt new file mode 100644 index 00000000..1781170a --- /dev/null +++ b/bank_card_payment/app/requirements.txt @@ -0,0 +1 @@ +dwollav2>=1.3.0 \ No newline at end of file diff --git a/bank_card_payment/app/test_dwolla.py b/bank_card_payment/app/test_dwolla.py new file mode 100644 index 00000000..ed2aea0f --- /dev/null +++ b/bank_card_payment/app/test_dwolla.py @@ -0,0 +1,20 @@ +#!/usr/bin/env python +import dwollav2 +import sys +payment_id = sys.argv[1] + + +client = dwollav2.Client( + key = 'XfEX77omgP2XNRjI04wQOA3nusm6xrJy7xRoiulVLdh4hxhwDS', + secret = 'HhpRzVXYX3t4NMpcwS7pC4XgJsqXi5E2DQIBNWevGGwvQOxpda', + environment = 'sandbox' +) + +app_token = client.Auth.client() + +payment_info = app_token.get('https://api-sandbox.dwolla.com/transfers/%s' % payment_id) +amount = '%(value)s %(currency)s' % (payment_info.body['amount']) +payer_ID = payment_info.body['id'] +print(amount,payer_ID) + + diff --git a/bank_card_payment/chain.json b/bank_card_payment/chain.json new file mode 100644 index 00000000..700ab0e4 --- /dev/null +++ b/bank_card_payment/chain.json @@ -0,0 +1,29 @@ +{ + "default": "kovan", + "chains": { + "dev": { + "host": "http://localhost:8545", + "sms": "http://localhost:5000", + "id": "17", + "hub": "0x60E25C038D70A15364DAc11A042DB1dD7A2cccBC" + }, + "ropsten": { + "host": "https://ropsten.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "3" + }, + "rinkeby": { + "host": "https://rinkeby.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "4" + }, + "kovan": { + "host": "https://kovan.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "42", + "sms": "https://sms-kovan.iex.ec" + }, + "mainnet": { + "host": "https://mainnet.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "1", + "sms": "https://sms-mainnet.iex.ec" + } + } +} \ No newline at end of file diff --git a/bank_card_payment/deployed.json b/bank_card_payment/deployed.json new file mode 100644 index 00000000..77a0897b --- /dev/null +++ b/bank_card_payment/deployed.json @@ -0,0 +1,5 @@ +{ + "app": { + "42": "0x4f29393e0e9842DdEaf49a0AC2e7fc66CFA00a33" + } +} \ No newline at end of file diff --git a/bank_card_payment/iexec.json b/bank_card_payment/iexec.json new file mode 100644 index 00000000..a5ca7555 --- /dev/null +++ b/bank_card_payment/iexec.json @@ -0,0 +1,35 @@ +{ + "description": "My iExec ressource description, must be at least 150 chars long in order to pass the validation checks. Describe your application, dataset or workerpool to your users", + "license": "MIT", + "author": "?", + "social": { + "website": "?", + "github": "?" + }, + "logo": "logo.png", + "buyConf": { + "params": "", + "tag": "0x0000000000000000000000000000000000000000000000000000000000000000", + "trust": "0", + "callback": "0x0000000000000000000000000000000000000000" + }, + "app": { + "owner": "0xe597d6fD63A56e645DbD680C56599038e5E02Be3", + "name": "BankCardPayment", + "type": "DOCKER", + "multiaddr": "registry.hub.docker.com/thomasvangurp/price-feed:1.0.0", + "checksum": "0x78495ddcb012dd32091cfa80a757c240d3dcc0366db64869c902e6802b043daa", + "mrenclave": "" + }, + "order": { + "apporder": { + "app": "0x4f29393e0e9842DdEaf49a0AC2e7fc66CFA00a33", + "appprice": "0", + "volume": "1000000", + "tag": "0x0000000000000000000000000000000000000000000000000000000000000000", + "datasetrestrict": "0x0000000000000000000000000000000000000000", + "workerpoolrestrict": "0x0000000000000000000000000000000000000000", + "requesterrestrict": "0x0000000000000000000000000000000000000000" + } + } +} \ No newline at end of file diff --git a/bank_card_payment/orders.json b/bank_card_payment/orders.json new file mode 100644 index 00000000..eee96b4c --- /dev/null +++ b/bank_card_payment/orders.json @@ -0,0 +1,15 @@ +{ + "42": { + "apporder": { + "app": "0x4f29393e0e9842DdEaf49a0AC2e7fc66CFA00a33", + "appprice": "0", + "volume": "1000000", + "tag": "0x0000000000000000000000000000000000000000000000000000000000000000", + "datasetrestrict": "0x0000000000000000000000000000000000000000", + "workerpoolrestrict": "0x0000000000000000000000000000000000000000", + "requesterrestrict": "0x0000000000000000000000000000000000000000", + "salt": "0x911dc3bcbd5991abd8e56cfb0d51889b51045425b8e7771e78d179cdb5de7fa4", + "sign": "0xf26c19dfc30a01701d95be4acf87198222d9081f33ce99589a445358c325ad814a0467f3ae0702f101418ac05208e33139a6f2243ea2e77951fc60512978342f1c" + } + } +} \ No newline at end of file diff --git a/bank_card_payment/smart-contract b/bank_card_payment/smart-contract new file mode 160000 index 00000000..b7cd4ef5 --- /dev/null +++ b/bank_card_payment/smart-contract @@ -0,0 +1 @@ +Subproject commit b7cd4ef5e286189f47a6959eceef17ecd0928934 diff --git a/weather_api/app/Dockerfile b/weather_api/app/Dockerfile new file mode 100644 index 00000000..304e2db4 --- /dev/null +++ b/weather_api/app/Dockerfile @@ -0,0 +1,7 @@ +FROM jfloff/alpine-python +COPY config.ini /config.ini +COPY darkskyp_api_call.py /darkskyp_api_call.py +COPY requirements.txt /requirements.txt +RUN pip install -r /requirements.txt +RUN chmod +x /darkskyp_api_call.py +ENTRYPOINT ["/darkskyp_api_call.py"] \ No newline at end of file diff --git a/weather_api/app/config.ini b/weather_api/app/config.ini new file mode 100644 index 00000000..598693db --- /dev/null +++ b/weather_api/app/config.ini @@ -0,0 +1,6 @@ +[openweathermap] +api=c1b5213b85fc28611f3a462ac85000f4 +[darksky] +api=28ea66e419c8820705d5496cce3ac0ae +[opencagedata] +api=812c8fc8222b49a0b650fea303db6f5c \ No newline at end of file diff --git a/weather_api/app/darkskyp_api_call.py b/weather_api/app/darkskyp_api_call.py new file mode 100644 index 00000000..814120b9 --- /dev/null +++ b/weather_api/app/darkskyp_api_call.py @@ -0,0 +1,54 @@ +#!/usr/bin/env python3 +import configparser +import requests +import sys +import ciso8601 +import time +from opencage.geocoder import OpenCageGeocode + +def get_api_key(api_name): + config = configparser.ConfigParser() + config.read('config.ini') + return config[api_name]['api'] + +def get_unixtime(date): + """return unixtime for date""" + ts = ciso8601.parse_datetime(date) + # to get time in seconds: + return int(time.mktime(ts.timetuple())) + + +def get_coordinates(api_key, location): + geocoder = OpenCageGeocode(api_key) + result = geocoder.geocode(location, no_annotations='1') + if result and len(result): + longitude = result[0]['geometry']['lng'] + latitude = result[0]['geometry']['lat'] + else: + sys.stderr.write("not found: %s\n" % location) + return latitude,longitude + +def get_weather(api_key, lat, long, date): + weatherdict = {'api_key':api_key,'start':date,'lat':lat,'long':long} + url = "https://api.darksky.net/forecast/{api_key}/{lat},{long},{start}?exclude=currently,flags,hourly".format(**weatherdict) + r = requests.get(url) + return r.json() + + +def main(): + if len(sys.argv) != 3: + exit("Usage: {} DATE LOCATION".format(sys.argv[0])) + date = sys.argv[1] + epoch_time = str(get_unixtime(date)) + location = sys.argv[2] + + api_key_ds = get_api_key('darksky') + api_key_oc = get_api_key('opencagedata') + lat,long = get_coordinates(api_key_oc, location) + weather = get_weather(api_key_ds, lat,long, epoch_time) + + print(weather['daily']['data'][0]['summary']) + + +if __name__ == '__main__': + main() diff --git a/weather_api/app/openweathermap_api_call.py b/weather_api/app/openweathermap_api_call.py new file mode 100644 index 00000000..dffda3cb --- /dev/null +++ b/weather_api/app/openweathermap_api_call.py @@ -0,0 +1,41 @@ +#!/usr/bin/env python3 +import configparser +import requests +import sys +import ciso8601 +import time + +def get_api_key(): + config = configparser.ConfigParser() + config.read('config.ini') + return config['openweathermap']['api'] + +def get_unixtime(date): + """return unixtime for date""" + ts = ciso8601.parse_datetime(date) + # to get time in seconds: + return int(time.mktime(ts.timetuple())) + +def get_weather(api_key, location, date): + weatherdict = {'api_key':api_key,'start':date,'city ID':location} + url = "http://history.openweathermap.org/data/2.5/history/city?q={city ID}&type=hour&start={start}&cnt=1".format(**weatherdict) + # url = "https://api.openweathermap.org/data/2.5/weather?q={}&units=metric&appid={}".format(location, api_key) + r = requests.get(url) + return r.json() + + +def main(): + if len(sys.argv) != 3: + exit("Usage: {} LOCATION".format(sys.argv[0])) + date = sys.argv[1] + epoch_time = str(get_unixtime(date)) + location = sys.argv[2] + + api_key = get_api_key() + weather = get_weather(api_key, location, epoch_time) + + print(weather['weather'][0]['description']) + + +if __name__ == '__main__': + main() diff --git a/weather_api/app/requirements.txt b/weather_api/app/requirements.txt new file mode 100644 index 00000000..b528b260 --- /dev/null +++ b/weather_api/app/requirements.txt @@ -0,0 +1,3 @@ +requests +ciso8601==1.0.1 +opencage \ No newline at end of file diff --git a/weather_api/chain.json b/weather_api/chain.json new file mode 100644 index 00000000..700ab0e4 --- /dev/null +++ b/weather_api/chain.json @@ -0,0 +1,29 @@ +{ + "default": "kovan", + "chains": { + "dev": { + "host": "http://localhost:8545", + "sms": "http://localhost:5000", + "id": "17", + "hub": "0x60E25C038D70A15364DAc11A042DB1dD7A2cccBC" + }, + "ropsten": { + "host": "https://ropsten.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "3" + }, + "rinkeby": { + "host": "https://rinkeby.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "4" + }, + "kovan": { + "host": "https://kovan.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "42", + "sms": "https://sms-kovan.iex.ec" + }, + "mainnet": { + "host": "https://mainnet.infura.io/v3/f3e0664e01504f5ab2b4360853ce0dc7", + "id": "1", + "sms": "https://sms-mainnet.iex.ec" + } + } +} \ No newline at end of file diff --git a/weather_api/deployed.json b/weather_api/deployed.json new file mode 100644 index 00000000..35025abd --- /dev/null +++ b/weather_api/deployed.json @@ -0,0 +1,5 @@ +{ + "app": { + "42": "0x5f9049B4461Be705eCf75688042e3593f3E2eD42" + } +} \ No newline at end of file diff --git a/weather_api/iexec.json b/weather_api/iexec.json new file mode 100644 index 00000000..f853c007 --- /dev/null +++ b/weather_api/iexec.json @@ -0,0 +1,35 @@ +{ + "description": "My iExec ressource description, must be at least 150 chars long in order to pass the validation checks. Describe your application, dataset or workerpool to your users", + "license": "MIT", + "author": "?", + "social": { + "website": "?", + "github": "?" + }, + "logo": "logo.png", + "buyConf": { + "params": "", + "tag": "0x0000000000000000000000000000000000000000000000000000000000000000", + "trust": "0", + "callback": "0x0000000000000000000000000000000000000000" + }, + "app": { + "owner": "0xe597d6fD63A56e645DbD680C56599038e5E02Be3", + "name": "WeatherOracle", + "type": "DOCKER", + "multiaddr": "registry.hub.docker.com/thomasvangurp/weather_oracle:1.0.0", + "checksum": "0xcbeeaa8491196182d0160b8b60e96175ba50c19476201074dc93bd0b980d4ad0", + "mrenclave": "" + }, + "order": { + "apporder": { + "app": "0x5f9049B4461Be705eCf75688042e3593f3E2eD42", + "appprice": "0", + "volume": "1000000", + "tag": "0x0000000000000000000000000000000000000000000000000000000000000000", + "datasetrestrict": "0x0000000000000000000000000000000000000000", + "workerpoolrestrict": "0x0000000000000000000000000000000000000000", + "requesterrestrict": "0x0000000000000000000000000000000000000000" + } + } +} \ No newline at end of file diff --git a/weather_api/orders.json b/weather_api/orders.json new file mode 100644 index 00000000..a0fad15f --- /dev/null +++ b/weather_api/orders.json @@ -0,0 +1,15 @@ +{ + "42": { + "apporder": { + "app": "0x5f9049B4461Be705eCf75688042e3593f3E2eD42", + "appprice": "0", + "volume": "1000000", + "tag": "0x0000000000000000000000000000000000000000000000000000000000000000", + "datasetrestrict": "0x0000000000000000000000000000000000000000", + "workerpoolrestrict": "0x0000000000000000000000000000000000000000", + "requesterrestrict": "0x0000000000000000000000000000000000000000", + "salt": "0xd8f63c3065e0fcca5374c2e85ec222cfa3ad92dcb465b3b8b19dd2f0982e7bdb", + "sign": "0xeb86d1560702069a210c1caf682f1a336096b5b3c316da2eecff42107a622cad2bf72fbf6e54f28dff42f07e3d56083d5d7e183aed26464c00e8ede95f1546291b" + } + } +} \ No newline at end of file diff --git a/weather_api/smart-contract b/weather_api/smart-contract new file mode 160000 index 00000000..b7cd4ef5 --- /dev/null +++ b/weather_api/smart-contract @@ -0,0 +1 @@ +Subproject commit b7cd4ef5e286189f47a6959eceef17ecd0928934