Skip to content

Commit

Permalink
chore: npm package and compilation overhaul
Browse files Browse the repository at this point in the history
  • Loading branch information
aesedepece committed Oct 5, 2022
1 parent f0aff2e commit bc6917d
Show file tree
Hide file tree
Showing 21 changed files with 14,174 additions and 300 deletions.
23 changes: 11 additions & 12 deletions .github/workflows/node.js.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,12 @@ name: Node.js CI

on:
push:
branches: [ "main" ]
branches: ['main']
pull_request:
branches: [ "main" ]
branches: ['main']

jobs:
build:

runs-on: ubuntu-latest

strategy:
Expand All @@ -20,12 +19,12 @@ jobs:
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm install --global yarn
- run: yarn install
- run: yarn ci
16 changes: 4 additions & 12 deletions .github/workflows/npm-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,6 @@ on:
types: [created]

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
- run: npm ci
- run: npm test

publish-npm:
needs: build
runs-on: ubuntu-latest
Expand All @@ -27,7 +17,9 @@ jobs:
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish
- run: npm install --global yarn
- run: yarn install
- run: yarn ci
- run: yarn publish
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,5 +102,4 @@ dist
# TernJS port file
.tern-port

yarn.lock
package-lock.json
19 changes: 14 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ yarn build
### Infura as destination provider:

```console
node dist/src/bin/ethers/infura
node dist/bin/ethers/infura
```

Required environment variables:
Expand All @@ -35,7 +35,7 @@ Optional environment variables:
### Celo-compatible destination providers:

```console
node dist/src/bin/celo
node dist/bin/celo
```

Required environment variables:
Expand All @@ -56,7 +56,7 @@ Optional environment variables:
### Conflux-compatible destination providers:

```console
node ./dist/src/bin/conflux
node ./dist/bin/conflux
```

Required environment variables:
Expand All @@ -78,7 +78,7 @@ Optional environment variables:
### Reef-compatible destination providers:

```console
node ./dist/src/bin/reef
node ./dist/bin/reef
```

Required environment variables:
Expand All @@ -96,7 +96,7 @@ Optional environment variables:
### Generic destination providers:

```console
node ./dist/src/bin/ethers
node ./dist/bin/ethers
```

Generic destination providers need to comply with the `JsonRpcProvider` type from the `Ethers.js` library:
Expand Down Expand Up @@ -137,37 +137,46 @@ There are several package scripts at your disposal for you to launch specific ga
- `SEED_PHRASE`: seed phrase to be used with either `Infura` or `Ethers.js` providers.

### Running gateways to Ethereum networks:

- Rinkeby: `npm run ethereum:rinkeby`
- Goerli: `npm run ethereum:goerli`
- Kovan: `npm run ethereum:kovan`
- Ropsten: `npm run ethereum:ropsten`
- Mainnet: `npm run ethereum:mainnet`

### Running gateways to BOBA Layer-2 networks:

- Rinkeby: `npm run boba:rinkeby`
- Mainnet: `npm run boba:mainnet`

### Running gateways to CELO networks:

- Alfajores: `npm run celo:alfajores`
- Mainnet: `npm run celo:mainnet`

### Running gateways to Conflux networks:

- Testnet: `npm run conflux:testnet`
- Mainnet: `npm run conflux:mainnet`

### Running gateways to HARMONY networks:

- Testnet (Shard #0): `npm run harmony:testnet#0`

### Running gateways to KCC networks:

- Testnet: `npm run kcc:testnet`

### Running gateways to METIS networks:

- Stardust (Rinkeby): `npm run metis:rinkeby`

### Running gateways to POLYGON networks:

- Mumbai (Goerli): `npm run polygon:goerli`

### Running gateways to REEF CHAIN networks:

- Testnet: `npm run reef:testnet`

## How to create a server for any other provider
Expand Down
4 changes: 2 additions & 2 deletions docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,10 @@ WORKDIR /data
RUN npm install yarn
RUN yarn
RUN yarn build
RUN chmod +x dist/src/bin/*
RUN chmod +x dist/bin/*
RUN yarn link

# Set the entrypoint and main command
# Runs the bot by default, but CMD can be overriden when running a container so it runs the reactions monitor server
ENTRYPOINT ["npx"]
CMD ["w3gw-infura"]
CMD ["w3gw-infura"]
103 changes: 54 additions & 49 deletions package.json

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/bin/celo/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (process.argv.length >= 5) {
}

// Mandatory: the private key to use for generation the server's own wrapped wallet.
const privateKeys = JSON.parse(process.env.PRIVATE_KEYS || "")
const privateKeys = JSON.parse(process.env.PRIVATE_KEYS || '')
if (!privateKeys || privateKeys.length == 0) {
throw Error(
'No private keys were provided. Please set the `PRIVATE_KEYS` environment variable.'
Expand Down
4 changes: 2 additions & 2 deletions src/bin/conflux/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ if (process.argv.length >= 5) {
}

// Mandatory: the private key to use for generation the server's own wrapped wallet.
const privateKeys = JSON.parse(process.env.PRIVATE_KEYS || "")
const privateKeys = JSON.parse(process.env.PRIVATE_KEYS || '')
if (!privateKeys || privateKeys.length === 0) {
throw Error(
'No private keys were provided. Please set the `PRIVATE_KEYS` environment variable.'
Expand Down Expand Up @@ -73,7 +73,7 @@ const estimateGasPrice: boolean = JSON.parse(
)

// Optional: Epoch number tag to be used as default value on those RPC methods that may require it.
const epochLabel = process.env.CONFLUX_DEFAULT_EPOCH_LABEL || "latest_finalized"
const epochLabel = process.env.CONFLUX_DEFAULT_EPOCH_LABEL || 'latest_finalized'

console.log('='.repeat(120))
console.log(
Expand Down
2 changes: 1 addition & 1 deletion src/bin/ethers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ const destinationProvider = new ethers.providers.JsonRpcProvider(
new WalletMiddlewareServer(
destinationProvider,
seed_phrase,
interleave_blocks,
interleave_blocks,
gas_price,
gas_limit,
num_addresses,
Expand Down
2 changes: 1 addition & 1 deletion src/bin/ethers/infura.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ new WalletMiddlewareServer(
false, // mock filters
gas_price_factor,
gas_limit_factor,
false, // force EIP-1559 txs
false // force EIP-1559 txs
)
.initialize()
.listen(port)
7 changes: 1 addition & 6 deletions src/bin/reef/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,6 @@ console.log(
)
console.log()

new WalletMiddlewareServer(
rpcUrl,
graphUrl,
seedPhrase,
numAddresses
)
new WalletMiddlewareServer(rpcUrl, graphUrl, seedPhrase, numAddresses)
.initialize()
.listen(port)
14 changes: 7 additions & 7 deletions src/celo/server.ts
Original file line number Diff line number Diff line change
Expand Up @@ -212,22 +212,22 @@ export class WalletMiddlewareServer {
'StableTokenEUR',
await this.wrapper.kit.registry.addressFor(CeloContract.StableTokenEUR)
]
]);
])

const decimals: number = await (
await this.wrapper.kit.contracts.getGoldToken()
).decimals()
await this.wrapper.kit.contracts.getGoldToken()
).decimals()

this.wrapper.wallets.forEach(async (wallet, index) => {
const balance: any = await wallet.getBalance()
const balance: any = await wallet.getBalance()
await traceKeyValue(`Celo wallet #${index}`, [
['Address', await wallet.getAddress()],
['Balance', `${balance / 10 ** decimals} CELO`],
['Chainid', await wallet.getChainId()],
['Nonce ', await wallet.getTransactionCount()]
])
})

console.log(
`Listening on ${hostname ||
'0.0.0.0'}:${port} [${logger.level.toUpperCase()}]\n`
Expand Down
Loading

0 comments on commit bc6917d

Please sign in to comment.