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

[WIP] Add TypeScript to this library #27

Open
wants to merge 24 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
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ site
site/
lib/assets/tester.json
lib/assets/development.json
lib/build/contracts
lib/build/contracts
build
1 change: 1 addition & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ install: npm install
script:
- npm i -g truffle
- sh deploy.sh
- npm run build
- npm test
git:
submodules: true
4 changes: 2 additions & 2 deletions deploy.js → archive/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const web3 = new Web3(provider)
const TruffleContract = require('truffle-contract')

const getArtifact = name => {
const contract = TruffleContract(require(`./lib/build/contracts/${name}.json`))
const contract = TruffleContract(require(`./static/build/contracts/${name}.json`))
contract.setProvider(provider)
contract.detectNetwork()
return contract
Expand Down Expand Up @@ -150,7 +150,7 @@ async function main() {
timestampScheduler: timestampScheduler.address
}
const fs = require('fs')
fs.writeFileSync('./lib/assets/tester.json', JSON.stringify(contracts))
fs.writeFileSync('./static/assets/tester.json', JSON.stringify(contracts))
resolve({
// Ganache attached web3
web3: web3,
Expand Down
18 changes: 18 additions & 0 deletions archive/deploy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#!/bin/bash
echo "Deploying contracts..."
cd ethereum-alarm-clock
truffle network --clean
truffle migrate --reset
cd ..

echo "Moving the generated contract files..."
rm -Rfv static/build/*
mkdir static/build
cp -Rfv ethereum-alarm-clock/build/* static/build/contracts
cp -fv ethereum-alarm-clock/package.json static/build/ethereum-alarm-clock.json
ls static/build

node ./extractContractsInfo.js development
mv -fv contracts.json static/assets/development.json || true

echo "Done."
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 2 additions & 2 deletions extractContractsInfo.js → archive/extractContractsInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
* Available networks:
* mainnet, ropsten, rinkeby, kovan, development
*/
const artifactsDir = './lib/build/contracts';
const dest = './lib/build/abi'
const artifactsDir = './static/build/contracts';
const dest = './static/build/abi'
const fs = require('fs');
const path = require('path');

Expand Down
File renamed without changes.
File renamed without changes.
26 changes: 26 additions & 0 deletions archive/test/RequestFactory.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// const Bignumber = require("bignumber.js");
// const { expect } = require("chai");

// const initEacjs = require("../index");

// const mockWeb3 = {
// version: {
// getNetwork: (cb) => {
// return ()
// }
// }
// };

// describe("RequestFactory", () => {
// let eacjs;

// before(() => {
// eacjs = initEacjs(mockWeb3);
// })


// it("Creates a new instance of RequestFactory", async () => {
// const rFactory = await eacjs.requestFactory();
// expect(rFactory.addess).to.exist;
// })
// })
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/requestFactory.js → archive/test/requestFactory.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ describe("Request Factory", () => {
let web3

before(async () => {
const deployed = await Deployer()
const deployed = await Deployer();
web3 = deployed.web3
eac = require('../index')(web3)
})
Expand Down
File renamed without changes.
2 changes: 1 addition & 1 deletion test/txRequest.js → archive/test/txRequest.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { timetravel } = require('./helper/mine2')

describe("TxRequest", () => {
let eac
let delpoyed
let deployed
let web3

before(async () => {
Expand Down
File renamed without changes.
16 changes: 0 additions & 16 deletions deploy.sh

This file was deleted.

1 change: 0 additions & 1 deletion ethereum-alarm-clock
Submodule ethereum-alarm-clock deleted from 50b116
50 changes: 1 addition & 49 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,49 +1 @@
/* eslint global-require: "off", import/no-dynamic-require: "off" */

const Constants = require("./lib/constants")
const RequestFactory = require("./lib/requestFactory")
const Scheduler = require("./lib/scheduling")
const TxRequest = require("./lib/txRequest")
const Util = require("./lib/util")
const RequestData = require("./lib/txRequest/requestData")
const version = require('./package.json').version;
const contracts = require("./lib/build/ethereum-alarm-clock.json").version;

module.exports = (web3) => {
if (!web3) {
return {
Constants,
RequestFactory,
Scheduler,
TxRequest,
Util: Util(),
RequestData,
version,
contracts
}
}

const util = Util(web3)
return {
Constants,
requestFactory: async () => {
const chainName = await util.getChainName()
const contracts = require(`./lib/assets/${chainName}.json`)
return new RequestFactory(contracts.requestFactory, web3)
},
scheduler: async () => {
const chainName = await util.getChainName()
const contracts = require(`./lib/assets/${chainName}.json`)
return new Scheduler(
contracts.blockScheduler,
contracts.timestampScheduler,
web3
)
},
transactionRequest: address => new TxRequest(address, web3),
Util: util,
RequestData,
version,
contracts
}
}
module.exports = require("./build/index.js").default;
1 change: 0 additions & 1 deletion lib/build/abi/BaseScheduler.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/BlockScheduler.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/ClaimLib.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/CloneFactory.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/DelayedPayment.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/ExecutionLib.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/IterTools.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/MathLib.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/Migrations.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/PaymentLib.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/Proxy.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/RecurringPayment.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/RequestFactory.json

This file was deleted.

1 change: 0 additions & 1 deletion lib/build/abi/RequestFactoryInterface.json

This file was deleted.

Loading