Skip to content

Commit

Permalink
getTez updates
Browse files Browse the repository at this point in the history
  • Loading branch information
harryttd committed Oct 11, 2023
1 parent 7affb55 commit d172c83
Show file tree
Hide file tree
Showing 6 changed files with 14 additions and 11 deletions.
6 changes: 4 additions & 2 deletions getTez/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# get-tez

This zero dependency package provides a programmatic interface to interact with the [Tezos faucet](https://github.com/oxheadalpha/tezos-faucet-backend). It is a script that can be run from a JavaScript/Typescript program or directly from a shell.
This zero dependency package provides a programmatic interface to interact with the [Tezos faucet](https://github.com/oxheadalpha/tezos-faucet-backend). It is a script that can be run from a JavaScript/Typescript program or directly from a shell. Your NodeJS version should support the [`fetch`](https://nodejs.org/dist/latest-v18.x/docs/api/globals.html#fetch) api.

## Installation

Expand Down Expand Up @@ -38,6 +38,7 @@ const txHash = await getTez({
amount: 10,
network: "ghostnet",
})
// txHash: ooaEskbj...
```

Example using the `faucetUrl` parameter:
Expand All @@ -47,14 +48,15 @@ const txHash = await getTez({
amount: 10,
faucetUrl: "https://my-custom-faucet-url.com",
})
// txHash: ooaEskbj...
```

### CLI

You can also run the script directly from the command line with Node.js. When you install the package via npm, the JavaScript file will be located at `node_modules/@oxheadalpha/get-tez/dist/getTez.js`. You can run it with the following command:

```bash
node node_modules/@oxheadalpha/get-tez/dist/getTez.js tz1... --amount 10 --network ghostnet
node node_modules/@oxheadalpha/get-tez tz1... --amount 10 --network ghostnet
```

Run the script with the `--help` flag for more information.
8 changes: 4 additions & 4 deletions getTez/getTez.ts
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ const validateArgs = async (args: GetTezArgs): Promise<ValidatedArgs> => {
if (!args.faucetUrl) {
const teztnetsUrl = "https://teztnets.xyz/teztnets.json"
const response = await fetch(teztnetsUrl, {
signal: AbortSignal.timeout(2000),
signal: AbortSignal.timeout(5000),
})

if (!response.ok) {
Expand Down Expand Up @@ -178,7 +178,7 @@ const getInfo = async (faucetUrl: string) => {

const response = await fetch(`${faucetUrl}/info`, {
headers: requestHeaders,
signal: AbortSignal.timeout(2000),
signal: AbortSignal.timeout(5000),
})

const body = await response.json()
Expand All @@ -198,7 +198,7 @@ const getChallenge = async ({ address, amount, faucetUrl }: ValidatedArgs) => {
const response = await fetch(`${faucetUrl}/challenge`, {
method: "POST",
headers: requestHeaders,
signal: AbortSignal.timeout(2000),
signal: AbortSignal.timeout(5000),
body: `address=${address}&amount=${amount}`,
})

Expand Down Expand Up @@ -283,7 +283,7 @@ const verifySolution = async ({
const response = await fetch(`${faucetUrl}/verify`, {
method: "POST",
headers: requestHeaders,
signal: AbortSignal.timeout(2000),
signal: AbortSignal.timeout(5000),
body: `address=${address}&amount=${amount}&nonce=${nonce}&solution=${solution}`,
})

Expand Down
6 changes: 3 additions & 3 deletions getTez/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion getTez/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
},
"repository": {
"type": "git",
"url": "https://github.com/oxheadalpha/tezos-faucet/tree/main/getTez"
"url": "git+https://github.com/oxheadalpha/tezos-faucet.git#main"
},
"keywords": [
"tezos",
Expand Down
2 changes: 1 addition & 1 deletion getTez/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
// "disableReferencedProjectLoad": true, /* Reduce the number of projects loaded automatically by TypeScript. */

/* Language and Environment */
"target": "ES2020", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
"target": "ES6", /* Set the JavaScript language version for emitted JavaScript and include compatible library declarations. */
// "lib": [], /* Specify a set of bundled library declaration files that describe the target runtime environment. */
// "jsx": "preserve", /* Specify what JSX code is generated. */
// "experimentalDecorators": true, /* Enable experimental support for legacy experimental decorators. */
Expand Down
1 change: 1 addition & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d172c83

Please sign in to comment.