From 4348836e47486676715ee0f66f2112e741c89d36 Mon Sep 17 00:00:00 2001 From: Vadim Macagon Date: Tue, 7 Jan 2020 19:34:17 +0700 Subject: [PATCH] Automate tweaks to generated TypeScript contract bindings --- package.json | 2 +- scripts/export-mainnet-contracts-abi.js | 8 ++++++++ src/mainnet-contracts/ERC20Factory.ts | 2 ++ src/mainnet-contracts/EthereumGatewayV1Factory.ts | 2 +- src/mainnet-contracts/EthereumGatewayV2Factory.ts | 2 +- 5 files changed, 13 insertions(+), 3 deletions(-) create mode 100644 scripts/export-mainnet-contracts-abi.js diff --git a/package.json b/package.json index 378765bf..a9a8fd75 100644 --- a/package.json +++ b/package.json @@ -26,7 +26,7 @@ "proto": "node ./scripts/gen-proto.js", "copy-contracts": "node ./scripts/copy-contracts.js", "prepublish": "yarn proto && yarn gen-contract-types && yarn build && webpack", - "gen-contract-types": "typechain \"src/mainnet-contracts/*.json\" --target=ethers --outDir src/mainnet-contracts" + "gen-contract-types": "typechain \"src/mainnet-contracts/*.json\" --target=ethers --outDir src/mainnet-contracts && node scripts/export-mainnet-contracts-abi.js" }, "dependencies": { "@binance-chain/javascript-sdk": "^2.14.5", diff --git a/scripts/export-mainnet-contracts-abi.js b/scripts/export-mainnet-contracts-abi.js new file mode 100644 index 00000000..3c1e4633 --- /dev/null +++ b/scripts/export-mainnet-contracts-abi.js @@ -0,0 +1,8 @@ +// This script exports the ABI from the TypeChain generated bindings in src/mainnet-contracts/*.ts + +const fs = require('fs'); +const path = require('path'); + +fs.appendFileSync(path.join(__dirname, '../src/mainnet-contracts/ERC20Factory.ts'), '\nexport const abi = _abi;'); +fs.appendFileSync(path.join(__dirname, '../src/mainnet-contracts/EthereumGatewayV1Factory.ts'), '\nexport const abi = _abi;'); +fs.appendFileSync(path.join(__dirname, '../src/mainnet-contracts/EthereumGatewayV2Factory.ts'), '\nexport const abi = _abi;'); diff --git a/src/mainnet-contracts/ERC20Factory.ts b/src/mainnet-contracts/ERC20Factory.ts index 2570a66e..9fa0d6f4 100644 --- a/src/mainnet-contracts/ERC20Factory.ts +++ b/src/mainnet-contracts/ERC20Factory.ts @@ -187,3 +187,5 @@ const _abi = [ type: "function" } ]; + +export const abi = _abi; \ No newline at end of file diff --git a/src/mainnet-contracts/EthereumGatewayV1Factory.ts b/src/mainnet-contracts/EthereumGatewayV1Factory.ts index 50ac42f7..30097443 100644 --- a/src/mainnet-contracts/EthereumGatewayV1Factory.ts +++ b/src/mainnet-contracts/EthereumGatewayV1Factory.ts @@ -817,4 +817,4 @@ const _abi = [ } ]; -export const abi = _abi; +export const abi = _abi; \ No newline at end of file diff --git a/src/mainnet-contracts/EthereumGatewayV2Factory.ts b/src/mainnet-contracts/EthereumGatewayV2Factory.ts index 13ccd44f..c0466201 100644 --- a/src/mainnet-contracts/EthereumGatewayV2Factory.ts +++ b/src/mainnet-contracts/EthereumGatewayV2Factory.ts @@ -749,4 +749,4 @@ const _abi = [ } ]; -export const abi = _abi; +export const abi = _abi; \ No newline at end of file