-
Notifications
You must be signed in to change notification settings - Fork 23
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Build: Completed Bank Card Payment Validator #31
base: master
Are you sure you want to change the base?
Changes from all commits
0d0c126
e64158d
a481f08
bbfa37c
9ea7c55
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
DWOLLA_APP_KEY='yTS7SjznX9BndQi0wgqS72Dx0T1oNhg5KLofB3Hb9hifrahzBg' | ||
DWOLLA_APP_SECRET='zr5fbPQaTnEJ6LIzNMPk6nMFrTxPQqRrkwQ8xF7AwezHEhn2oI' |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM node:11-alpine | ||
COPY dwolla-card-validator.js /src/dwolla-card-validator.js | ||
COPY entrypoint.sh /entrypoint.sh | ||
RUN npm i https ethers fs dwolla-v2 | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
const https = require('https'); | ||
const ethers = require('ethers'); | ||
const fs = require('fs'); | ||
require('dotenv').config(); | ||
|
||
const root = 'iexec_out'; | ||
const determinismFilePath = `${root}/determinism.iexec`; | ||
const callbackFilePath = `${root}/callback.iexec`; | ||
const errorFilePath = `${root}/error.iexec`; | ||
|
||
|
||
/***************************************************************************** | ||
* TOOLS * | ||
*****************************************************************************/ | ||
|
||
const Client = require("dwolla-v2").Client; | ||
|
||
/***************************************************************************** | ||
* CONFIG * | ||
*****************************************************************************/ | ||
|
||
// dwolla api key | ||
const APIKEY = process.env.DWOLLA_APP_KEY; | ||
const SECRET = process.env.DWOLLA_APP_SECRET | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are these envvar coming from? I don't see them set anywhere. Should they come from a dataset? You cannot expect the worker to have them "by default" |
||
|
||
/***************************************************************************** | ||
* ARGUMENTS * | ||
*****************************************************************************/ | ||
|
||
var dwolla = new Client({ | ||
environment: "sandbox" // defaults to 'production' | ||
}); | ||
|
||
/***************************************************************************** | ||
* HTTP QUERY * | ||
*****************************************************************************/ | ||
let URL='/api-sandbox.dwolla.com/transfers/${id}'; //In production use api.dwolla.com | ||
|
||
const query = { | ||
method: 'GET', | ||
port: 443, | ||
host: 'api-sandbox.dwolla.com', //In production use api.dwolla.com | ||
path: URL | ||
}; | ||
|
||
/***************************************************************************** | ||
* EXECUTE * | ||
*****************************************************************************/ | ||
new Promise(async (resolve, reject) => { | ||
|
||
console.log(`- Calling API ${query.host}${query.path}`); | ||
let chunks = []; | ||
let request = https.request(query, res => { | ||
res.on('data', (chunk) => { | ||
chunks.push(chunk); | ||
}); | ||
res.on('end', () => { | ||
if (chunks.length) | ||
{ | ||
resolve(chunks.join('')); | ||
} | ||
else | ||
{ | ||
reject(`[HTTP ERROR]\nstatusCode: ${res.statusCode}`); | ||
} | ||
}); | ||
}); | ||
request.on('error', reject); | ||
request.end(); | ||
}) | ||
.then(data => { | ||
let results = JSON.parse(data.toString()); | ||
|
||
if (results.error !== undefined) | ||
{ | ||
throw new Error(results.error); | ||
} | ||
|
||
.then(res => const response = { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this then isn't attached to anything. |
||
return { | ||
amount: { currency: res.currency, | ||
value: res.value } | ||
correlationId: res.correlationId, | ||
request: { | ||
type: 'GET', | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Where are these values ( |
||
} ); | ||
|
||
var iexeccallback = ethers.utils.defaultAbiCoder.encode(['uint256', 'string', 'uint256'], [id, amount, value]); | ||
var iexecconsensus = ethers.utils.keccak256(iexeccallback); | ||
fs.writeFile(callbackFilePath, iexeccallback , (err) => {}); | ||
fs.writeFile(determinismFilePath, iexecconsensus, (err) => {}); | ||
|
||
console.log(`- Success: ${results}`); | ||
}) | ||
.catch(error => { | ||
fs.writeFile( | ||
errorFilePath, | ||
error.toString(), | ||
(err) => {} | ||
); | ||
fs.writeFile( | ||
determinismFilePath, | ||
ethers.utils.solidityKeccak256(['string'],[error.toString()]), | ||
(err) => {} | ||
); | ||
console.log(error.toString()); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node src/price-feed.js $@ |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{ | ||
"app": { | ||
"42": "0x71bA4A5aDE91b7e05577bFC17C71cad1c71ecbe3" | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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": "0x3591CCE5B7318dCAA4597ABe846EF7Df7C5BCDcC", | ||
"name": "DwollaCardValidator", | ||
"type": "DOCKER", | ||
"multiaddr": "registry.hub.docker.com/emmaodia/dwolla-card-validator:1.0.0", | ||
"checksum": "0x131600405f0e8c32340a359b493d170d582c6bf911a38694947e65bd92efa559", | ||
"mrenclave": "" | ||
}, | ||
"order": { | ||
"apporder": { | ||
"app": "0x71bA4A5aDE91b7e05577bFC17C71cad1c71ecbe3", | ||
"appprice": "0", | ||
"volume": "1000000", | ||
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"datasetrestrict": "0x0000000000000000000000000000000000000000", | ||
"workerpoolrestrict": "0x0000000000000000000000000000000000000000", | ||
"requesterrestrict": "0x0000000000000000000000000000000000000000" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
{ | ||
"42": { | ||
"apporder": { | ||
"app": "0x71bA4A5aDE91b7e05577bFC17C71cad1c71ecbe3", | ||
"appprice": "0", | ||
"volume": "1000000", | ||
"tag": "0x0000000000000000000000000000000000000000000000000000000000000000", | ||
"datasetrestrict": "0x0000000000000000000000000000000000000000", | ||
"workerpoolrestrict": "0x0000000000000000000000000000000000000000", | ||
"requesterrestrict": "0x0000000000000000000000000000000000000000", | ||
"salt": "0xd564967de9260bbd045ae63ddd262d5390c937956a85d7304ae646079a361caa", | ||
"sign": "0xca66d542c704d9faec383877ca3f71e6d260c22ec8a58f01e3a2aaea59c478205efb41b7f12c79787593b039373ca0db2d0b6f199fa05f4f782f7aff0cd0606b1c" | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
.env |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FROM node:11-alpine | ||
COPY tls-notary.js /src/tls-notary.js | ||
COPY entrypoint.sh /entrypoint.sh | ||
RUN npm i https ethers fs node-forge | ||
RUN chmod +x /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node src/tls-notary.js $@ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is dwolla-v2 available? I don't see it being installed in the dockerfile.