Skip to content

Commit

Permalink
Feature/typescript interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexis Masseron authored and Kriys94 committed Jul 11, 2019
1 parent 4853edd commit d9cfe68
Show file tree
Hide file tree
Showing 32 changed files with 4,895 additions and 63 deletions.
14 changes: 13 additions & 1 deletion .gitlab-ci.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
stages:
- test
- publish

test-lint:
stage: test
Expand All @@ -9,4 +10,15 @@ test-lint:
- npm install
script:
- npm run lint
- npm run test:cover
- npm run test:cover
except:
- tags

npm-publish:
stage: publish
image: node:10
script:
- echo '//registry.npmjs.org/:_authToken=${NPM_TOKEN}'>.npmrc
- npm publish
only:
- tags
11 changes: 6 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -2,18 +2,19 @@

# gitlab options
PROTO_REPO=pkg
PROTO_DIR=types
PROTO_DIST_DIR=proto
PROTO_SRC_DIR=types
GITLAB_PATH=ConsenSys/client/fr/core-stack
PROTO_TAG=v0.6.1

protobuf: ## Generate protobuf stubs
@docker-compose -f scripts/docker-compose.yml up

import-proto:
rm -rf $(PROTO_REPO) $(PROTO_DIR);
rm -rf $(PROTO_REPO) $(PROTO_DIST_DIR)
git clone -b $(PROTO_TAG) --single-branch git@gitlab.com:$(GITLAB_PATH)/$(PROTO_REPO).git;
mkdir -p $(PROTO_DIR);
mv $(PROTO_REPO)/$(PROTO_DIR)/* $(PROTO_DIR);
mkdir -p $(PROTO_DIST_DIR);
mv $(PROTO_REPO)/$(PROTO_SRC_DIR)/* $(PROTO_DIST_DIR);
rm -rf $(PROTO_REPO)/;
rm $(PROTO_DIR)/*/*.go;
rm $(PROTO_DIST_DIR)/*/*.go;

16 changes: 8 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -181,17 +181,17 @@ try {
const broker = CoreStack.broker('localhost:9092')

// Init class to generate wallets in CoreStack
const wallet = await broker.wallet()
const walletGenerator = await broker.walletGenerator()

// Generate multiple wallets asynchronously and get addresses
const wallets = await Promise.all([
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate()
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate()
])
console.log('Wallets generated: ' wallets)
// Wallets generated: [
Expand Down
18 changes: 9 additions & 9 deletions example/all/app.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import CoreStackSDK from '../../src'
import CoreStackSDK from '../../lib'

// Test for generating many wallets
(async () => {
Expand All @@ -12,7 +12,7 @@ import CoreStackSDK from '../../src'
// Init class to generate wallets, produce, consume in CoreStack
const producer = await broker.producer()
const consumer = await broker.consumer()
const wallet = await broker.wallet()
const walletGenerator = await broker.walletGenerator()

const consume = consumer.consume()

Expand All @@ -35,13 +35,13 @@ import CoreStackSDK from '../../src'

// Generate wallets and get addresses
const wallets = await Promise.all([
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate()
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate()
])
console.log(wallets)
} catch (e) {
Expand Down
16 changes: 8 additions & 8 deletions example/generateWallet/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import CoreStackSDK from '../../src'
const broker = CoreStack.broker('localhost:9092')

// Init class to generate wallets in CoreStack
const wallet = await broker.wallet()
const walletGenerator = await broker.walletGenerator()

// Generate wallets and get addresses
const wallets = await Promise.all([
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate(),
wallet.generate()
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate()
])
console.log(wallets)
} catch (e) {
Expand Down
54 changes: 54 additions & 0 deletions example/typescript/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import CoreStack, { CoreStackRequest } from "core-stack-sdk";

(async() => {
const CS = new CoreStack();
const broker = CS.broker("localhost:9092");

// Init producer, consumer, wallet generator
const producer = await broker.producer();
const consumer = await broker.consumer();
const walletGenerator = await broker.walletGenerator()

// Start consuming
const consume = consumer.consume();
consume.on("message", message => {
console.log("Message consumed: ", message);
});

// Produce a transaction
const payload: CoreStackRequest = {
chainId: '888',
to: "0x71b7d704598945e72e7581bac3b070d300dc6eb3",
call: {
contract: "SimpleToken",
method: "constructor()"
// method: 'transfer(address,uint256)',
// args: ["dbb881a51cd4023e4400cef3ef73046743f08da3", "100000"]
},
gas: 2000000,
from: "0x7e654d251da770a068413677967f6d3ea2fea9e4"
// protocol: {
// name: 'test'
// },
// gasPrice: '100000000',
// data: '0x0000000000000000000000000000000',
// raw: '0x0000000000000000000000000000000',
// hash: '0x0000000000000000000000000000000',
// privateFrom: '0x0000000000000000000000000000000',
// privateFor: ['0x0000000000000000000000000000000'],
}
const tx = await producer.send(payload);
console.log("Message sent: ", tx)

// Generate a wallet
const wallets = await Promise.all([
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate(),
walletGenerator.generate()
])
console.log("Wallets created", wallets)
})()
Loading

0 comments on commit d9cfe68

Please sign in to comment.