Skip to content

Commit

Permalink
remove src path
Browse files Browse the repository at this point in the history
  • Loading branch information
Nicholas Rodrigues Lordello committed May 13, 2020
1 parent ba1f8a0 commit 4751213
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 41 deletions.
7 changes: 4 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
"name": "@gnosis.pm/dex-contracts",
"version": "0.2.15",
"description": "Contracts for dFusion multi-token batch auction exchange",
"main": "build/commonjs/index.ts",
"module": "build/esm/index.js",
"jsnext:main": "build/esm/index.js",
"main": "build/common/src/index.ts",
"types": "build/common/src/index.d.ts",
"ts:main": "src/index.ts",
"module": "build/esm/src/index.js",
"jsnext:main": "build/esm/src/index.js",
"directories": {
"test": "test"
},
Expand Down
25 changes: 0 additions & 25 deletions src/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
* @packageDocumentation
*/

import { TransactionReceipt } from "web3-core";
import { Contract } from "web3-eth-contract";
import { AbiItem } from "web3-utils";

export { BatchExchange } from "../build/types/BatchExchange";
Expand All @@ -28,26 +26,3 @@ export interface ContractArtifact {
};
};
}

/**
* Get a contract deployment, returning both the web3 contract object as well as
* the transaction receipt for the contract deployment.
*
* @throws If the contract is not deployed on the network the web3 provider is
* connected to.
*/
export async function deployment<C extends Contract>(
web3: Web3,
{ abi, networks }: ContractArtifact,
): Promise<[C, TransactionReceipt]> {
const chainId = await web3.eth.getChainId();
const network = networks[chainId];
if (!networks) {
throw new Error(`not deployed on network with chain ID ${chainId}`);
}

const tx = await web3.eth.getTransactionReceipt(network.transactionHash);
const contract = new web3.eth.Contract(abi, network.address);

return [contract as C, tx];
}
4 changes: 2 additions & 2 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export * from "./fraction";
export * from "./orderbook";
export * from "./streamed";

export * from "./encoding";
export * from "./onchain_reading";
export * from "./encoding.js";
export * from "./onchain_reading.js";
27 changes: 25 additions & 2 deletions src/streamed/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/

import Web3 from "web3";
import { BlockNumber } from "web3-core";
import { BlockNumber, TransactionReceipt } from "web3-core";
import { Contract } from "web3-eth-contract";
import {
BatchExchange,
BatchExchangeArtifact,
ContractArtifact,
deployment,
} from "../contracts";
import { IndexedOrder } from "../encoding";
import { AnyEvent } from "./events";
Expand Down Expand Up @@ -306,3 +306,26 @@ export class InvalidAuctionStateError extends Error {
super(`invalid auction state at block ${block}: ${inner.message}`);
}
}

/**
* Get a contract deployment, returning both the web3 contract object as well as
* the transaction receipt for the contract deployment.
*
* @throws If the contract is not deployed on the network the web3 provider is
* connected to.
*/
export async function deployment<C extends Contract>(
web3: Web3,
{ abi, networks }: ContractArtifact,
): Promise<[C, TransactionReceipt]> {
const chainId = await web3.eth.getChainId();
const network = networks[chainId];
if (!networks) {
throw new Error(`not deployed on network with chain ID ${chainId}`);
}

const tx = await web3.eth.getTransactionReceipt(network.transactionHash);
const contract = new web3.eth.Contract(abi, network.address);

return [contract as C, tx];
}
2 changes: 1 addition & 1 deletion test/models/streamed/index.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
StreamedOrderbook,
deployment,
getOpenOrders,
} from "@src/index";
} from "../../../src";

describe("Streamed Orderbook", () => {
describe("init", () => {
Expand Down
6 changes: 3 additions & 3 deletions test/models/streamed/state.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { expect } from "chai";
import { BatchExchange, DEFAULT_ORDERBOOK_OPTIONS } from "@src/index";
import { AuctionState } from "@src/streamed/state";
import { AnyEvent, EventName, EventValues } from "@src/streamed/events";
import { BatchExchange, DEFAULT_ORDERBOOK_OPTIONS } from "../../../src";
import { AuctionState } from "../../../src/streamed/state";
import { AnyEvent, EventName, EventValues } from "../../../src/streamed/events";

function auctionState(): AuctionState {
return new AuctionState({ ...DEFAULT_ORDERBOOK_OPTIONS, strict: true });
Expand Down
8 changes: 3 additions & 5 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
// "allowJs": true, /* Allow javascript files to be compiled. */
// "checkJs": true, /* Report errors in .js files. */
// "jsx": "preserve", /* Specify JSX code generation: 'preserve', 'react-native', or 'react'. */
// "declaration": true, /* Generates corresponding '.d.ts' file. */
"declaration": true, /* Generates corresponding '.d.ts' file. */
// "declarationMap": true, /* Generates a sourcemap for each corresponding '.d.ts' file. */
// "sourceMap": true, /* Generates corresponding '.map' file. */
// "outFile": "./", /* Concatenate and emit output to single file. */
Expand Down Expand Up @@ -40,10 +40,8 @@

/* Module Resolution Options */
"moduleResolution": "node" /* Specify module resolution strategy: 'node' (Node.js) or 'classic' (TypeScript pre-1.6). */,
"baseUrl": "./",
"paths": {
"@src/*": ["./src/*"],
},
// "baseUrl": "./", /* Base directory to resolve non-absolute module names. */
// "paths": {}, /* A series of entries which re-map imports to lookup locations relative to the 'baseUrl'. */
// "rootDirs": [], /* List of root folders whose combined content represents the structure of the project at runtime. */
// "typeRoots": [],
//"allowSyntheticDefaultImports": true /* Allow default imports from modules with no default export. This does not affect code emit, just typechecking. */,
Expand Down

0 comments on commit 4751213

Please sign in to comment.