Skip to content
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

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
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
2 changes: 2 additions & 0 deletions bankCardPaymentValidator/app/.example.env.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
DWOLLA_APP_KEY='yTS7SjznX9BndQi0wgqS72Dx0T1oNhg5KLofB3Hb9hifrahzBg'
DWOLLA_APP_SECRET='zr5fbPQaTnEJ6LIzNMPk6nMFrTxPQqRrkwQ8xF7AwezHEhn2oI'
6 changes: 6 additions & 0 deletions bankCardPaymentValidator/app/Dockerfile
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"]
109 changes: 109 additions & 0 deletions bankCardPaymentValidator/app/dwolla-card-validator.js
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;
Copy link
Member

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.


/*****************************************************************************
* CONFIG *
*****************************************************************************/

// dwolla api key
const APIKEY = process.env.DWOLLA_APP_KEY;
const SECRET = process.env.DWOLLA_APP_SECRET
Copy link
Member

@Amxx Amxx Oct 18, 2019

Choose a reason for hiding this comment

The 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 = {
Copy link
Member

Choose a reason for hiding this comment

The 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',
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where are these values (amount, correlationId, request) used? This is confusing

} );

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());
});
1 change: 1 addition & 0 deletions bankCardPaymentValidator/app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node src/price-feed.js $@
29 changes: 29 additions & 0 deletions bankCardPaymentValidator/chain.json
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"
}
}
}
5 changes: 5 additions & 0 deletions bankCardPaymentValidator/deployed.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"app": {
"42": "0x71bA4A5aDE91b7e05577bFC17C71cad1c71ecbe3"
}
}
35 changes: 35 additions & 0 deletions bankCardPaymentValidator/iexec.json
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"
}
}
}
15 changes: 15 additions & 0 deletions bankCardPaymentValidator/orders.json
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"
}
}
}
1 change: 1 addition & 0 deletions bankCardPaymentValidator/smart-contract
Submodule smart-contract added at b7cd4e
2 changes: 2 additions & 0 deletions tlsNotaryDOracle/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
.env
6 changes: 6 additions & 0 deletions tlsNotaryDOracle/app/Dockerfile
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"]
1 change: 1 addition & 0 deletions tlsNotaryDOracle/app/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
node src/tls-notary.js $@
Loading