Skip to content
Closed
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
111 changes: 100 additions & 11 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@
"test": "npm run build && node ./dist/test/test",
"testunit": "npm run build && mocha --timeout 15000 dist/test/unit/*.js ",
"testdeploy": "npm run build && node ./dist/test/deploy",
"testrpc": "testrpc -l 90000000 -p 8545 -m \"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat\""
"testrpc": "testrpc -l 90000000 -p 8545 -m \"candy maple cake sugar pudding cream honey rich smooth crumble sweet treat\"",
"lint": "tslint -p tsconfig.json -t verbose"
},
"devDependencies": {
"@types/chai": "^4.0.5",
Expand All @@ -24,6 +25,7 @@
"dirty-chai": "^2.0.1",
"mocha": "^4.0.1",
"ts-node": "^3.3.0",
"tslint": "^5.8.0",
"typings": "^2.1.1"
},
"dependencies": {
Expand Down
2 changes: 1 addition & 1 deletion src/artifacts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ export default {
RequestCoreArtifact: RequestCoreArtifact as any as Artifact,
RequestEthereumArtifact: RequestEthereumArtifact as any as Artifact,
RequestSynchroneExtensionEscrowArtifact: RequestSynchroneExtensionEscrowArtifact as any as Artifact,
};
};
2 changes: 1 addition & 1 deletion src/config.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
// import * as Config from './config.json';
const Config = require('./config.json');
export default Config;
export default Config;
6 changes: 3 additions & 3 deletions src/requestNetwork.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ export default class RequestNetwork {
public requestEthereumService: RequestEthereumService;
public requestSynchroneExtensionEscrowService: RequestSynchroneExtensionEscrowService;
public requestCoreService: RequestCoreService;
constructor(provider? : any, networkId ? : number, useIpfsPublic : boolean = true) {

constructor(provider?: any, networkId ?: number, useIpfsPublic: boolean = true) {
if(provider && !networkId)
{
throw Error('if you give provider you have to give the networkId too');
Expand All @@ -26,4 +26,4 @@ export default class RequestNetwork {
this.requestEthereumService = new RequestEthereumService();
this.requestSynchroneExtensionEscrowService = new RequestSynchroneExtensionEscrowService();
}
}
}
8 changes: 4 additions & 4 deletions src/servicesContracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Artifacts from './artifacts';

import RequestEthereumService from './servicesContracts/requestEthereum-service';

export const getServiceFromAddress = function(address:string) : any{
export const getServiceFromAddress = function(address: string): any{
if(!address) return undefined;

if(isThisArtifact(Artifacts.RequestEthereumArtifact, address)) {
Expand All @@ -12,11 +12,11 @@ export const getServiceFromAddress = function(address:string) : any{
}
}

const isThisArtifact = function(artifact:any,address:string) : boolean {
const isThisArtifact = function(artifact: any,address: string): boolean {
if(!address) return false;
let found:boolean = false;
let found: boolean = false;
Object.keys(artifact.networks).forEach(function(k) {
found = found || (artifact.networks[k].address && artifact.networks[k].address.toLowerCase() == address.toLowerCase());
})
return found;
}
}
48 changes: 24 additions & 24 deletions src/servicesContracts/requestEthereum-service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default class RequestEthereumService {

// RequestEthereum on blockchain
protected abiRequestCore: any;
protected requestCoreServices:any;
protected requestCoreServices: any;

protected abiRequestEthereum: any;
protected addressRequestEthereum: string;
Expand All @@ -47,10 +47,10 @@ export default class RequestEthereumService {
public createRequestAsPayee (
_payer: string,
_amountInitial: any,
_data ? : string,
_extension ? : string,
_extensionParams ? : Array < any > ,
_options ? : any,
_data ?: string,
_extension ?: string,
_extensionParams ?: Array < any > ,
_options ?: any,
): Web3PromiEvent {
let promiEvent = Web3PromiEvent();
_amountInitial = new BN(_amountInitial);
Expand Down Expand Up @@ -100,7 +100,7 @@ export default class RequestEthereumService {
// we do nothing here!
},
(confirmationNumber: number, receipt: any) => {
if (confirmationNumber == _options.numberOfConfirmation)
if (confirmationNumber == _options.numberOfConfirmation)
{
let event = this.web3Single.decodeEvent(this.abiRequestCore, 'Created', receipt.events[0]);
this.getRequest(event.requestId).then((request) => {
Expand All @@ -121,7 +121,7 @@ export default class RequestEthereumService {

public accept(
_requestId: string,
_options ? : any): Web3PromiEvent {
_options ?: any): Web3PromiEvent {
let promiEvent = Web3PromiEvent();
_options = this.web3Single.setUpOptions(_options);

Expand Down Expand Up @@ -167,7 +167,7 @@ export default class RequestEthereumService {

public cancel(
_requestId: string,
_options ? : any): Web3PromiEvent {
_options ?: any): Web3PromiEvent {
let promiEvent = Web3PromiEvent();
_options = this.web3Single.setUpOptions(_options);

Expand Down Expand Up @@ -222,7 +222,7 @@ export default class RequestEthereumService {
_requestId: string,
_amount: any,
_additionals: any,
_options ? : any): Web3PromiEvent {
_options ?: any): Web3PromiEvent {
let promiEvent = Web3PromiEvent();

_additionals = new BN(_additionals);
Expand Down Expand Up @@ -272,7 +272,7 @@ export default class RequestEthereumService {
public refundAction(
_requestId: string,
_amount: any,
_options ? : any): Web3PromiEvent {
_options ?: any): Web3PromiEvent {
let promiEvent = Web3PromiEvent();
_options = this.web3Single.setUpOptions(_options);
_options.value = new BN(_amount);
Expand All @@ -283,7 +283,7 @@ export default class RequestEthereumService {

this.getRequest(_requestId).then((request) => {
if (_options.value.isNeg()) return promiEvent.reject(Error('_amount must a positive integer'));

if ( request.state != Types.State.Accepted ) {
return promiEvent.reject(Error('request must be accepted'));
}
Expand Down Expand Up @@ -322,7 +322,7 @@ export default class RequestEthereumService {
public subtractAction(
_requestId: string,
_amount: any,
_options ? : any): Web3PromiEvent {
_options ?: any): Web3PromiEvent {
let promiEvent = Web3PromiEvent();
_options = this.web3Single.setUpOptions(_options);
_amount = new BN(_amount);
Expand Down Expand Up @@ -375,7 +375,7 @@ export default class RequestEthereumService {
public additionalAction(
_requestId: string,
_amount: any,
_options ? : any): Web3PromiEvent {
_options ?: any): Web3PromiEvent {
let promiEvent = Web3PromiEvent();
_options = this.web3Single.setUpOptions(_options);
_amount = new BN(_amount);
Expand Down Expand Up @@ -426,7 +426,7 @@ export default class RequestEthereumService {



public withdraw(_options ? : any): Web3PromiEvent {
public withdraw(_options ?: any): Web3PromiEvent {
let promiEvent = Web3PromiEvent();
_options = this.web3Single.setUpOptions(_options);

Expand All @@ -435,7 +435,7 @@ export default class RequestEthereumService {
let account = _options.from || defaultAccount;

var method = this.instanceRequestEthereum.methods.withdraw();

this.web3Single.broadcastMethod(
method,
(transactionHash: string) => {
Expand Down Expand Up @@ -468,30 +468,30 @@ export default class RequestEthereumService {

public getRequest(_requestId: string): Promise < any > {
return this.requestCoreServices.getRequest(_requestId);
}
}

public getRequestHistory(
_requestId: string,
_fromBlock ?: number,
_toBlock ?: number): Promise < any > {
return this.requestCoreServices.getRequestHistory(_requestId,_fromBlock,_toBlock);
}
}

public getRequestHistoryCurrencyContractInfo(
_requestId: string,
_fromBlock ?: number,
_toBlock ?: number): Promise < any > {
return new Promise(async (resolve, reject) => {
// let events = await this.instanceSynchroneExtensionEscrow.getPastEvents('allEvents', {
// // allEvents and filter don't work together so far. issues created on web3 github
// // filter: {requestId: _requestId},
// // filter: {requestId: _requestId},
// fromBlock: requestEthereum_Artifact.networks[this.web3Single.networkName].blockNumber,
// toBlock: 'latest'
// });

// events by event waiting for a patch of web3
let optionFilters = {
filter: { requestId: _requestId },
filter: { requestId: _requestId },
fromBlock: requestEthereum_Artifact.networks[this.web3Single.networkName].blockNumber,
toBlock: 'latest'
};
Expand All @@ -500,7 +500,7 @@ export default class RequestEthereumService {
let events = [];
events = events.concat(await this.instanceRequestEthereum.getPastEvents('EtherAvailableToWithdraw', optionFilters));

return resolve(await Promise.all(events.map(async e => {
return resolve(await Promise.all(events.map(async e => {
return new Promise(async (resolve, reject) => {
resolve({
_meta: {
Expand All @@ -513,6 +513,6 @@ export default class RequestEthereumService {
});
});
})));
});
}
}
});
}
}
Loading