Skip to content

Commit

Permalink
Automate tweaks to generated TypeScript contract bindings
Browse files Browse the repository at this point in the history
  • Loading branch information
enlight committed Jan 7, 2020
1 parent 133cfa9 commit 4348836
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
8 changes: 8 additions & 0 deletions scripts/export-mainnet-contracts-abi.js
Original file line number Diff line number Diff line change
@@ -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;');
2 changes: 2 additions & 0 deletions src/mainnet-contracts/ERC20Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,3 +187,5 @@ const _abi = [
type: "function"
}
];

export const abi = _abi;
2 changes: 1 addition & 1 deletion src/mainnet-contracts/EthereumGatewayV1Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -817,4 +817,4 @@ const _abi = [
}
];

export const abi = _abi;
export const abi = _abi;
2 changes: 1 addition & 1 deletion src/mainnet-contracts/EthereumGatewayV2Factory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -749,4 +749,4 @@ const _abi = [
}
];

export const abi = _abi;
export const abi = _abi;

0 comments on commit 4348836

Please sign in to comment.