This repository has been archived by the owner on Apr 8, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[PI-387] add example for estimatedNextBatchTime
- Loading branch information
1 parent
060b915
commit 65b5e36
Showing
2 changed files
with
52 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
#!/usr/bin/env -S yarn node | ||
/* eslint-disable no-unused-vars */ | ||
|
||
/* | ||
DO NOT EDIT THIS FILE BY HAND! | ||
Examples are generated using helpers/buildExamples.js script. | ||
Check README.md for more details. | ||
*/ | ||
|
||
const sw = require('@rhino.fi/starkware-crypto') | ||
const getWeb3 = require('./helpers/getWeb3') | ||
|
||
const RhinofiClientFactory = require('../src') | ||
const envVars = require('./helpers/loadFromEnvOrConfig')( | ||
process.env.CONFIG_FILE_NAME | ||
) | ||
const logExampleResult = require('./helpers/logExampleResult')(__filename) | ||
|
||
const ethPrivKey = envVars.ETH_PRIVATE_KEY | ||
// NOTE: you can also generate a new key using:` | ||
// const starkPrivKey = rhinofi.stark.createPrivateKey() | ||
const starkPrivKey = envVars.STARK_PRIVATE_KEY | ||
const rpcUrl = envVars.RPC_URL | ||
|
||
const { web3, provider } = getWeb3(ethPrivKey, rpcUrl) | ||
|
||
const rhinofiConfig = { | ||
api: envVars.API_URL, | ||
dataApi: envVars.DATA_API_URL, | ||
useAuthHeader: true, | ||
wallet: { | ||
type: 'tradingKey', | ||
meta: { | ||
starkPrivateKey: starkPrivKey | ||
} | ||
} | ||
// Add more variables to override default values | ||
} | ||
|
||
;(async () => { | ||
const rhinofi = await RhinofiClientFactory(web3, rhinofiConfig) | ||
|
||
const estimatedNextBatchTimeResponse = await rhinofi.estimatedNextBatchTime() | ||
|
||
logExampleResult(estimatedNextBatchTimeResponse) | ||
|
||
})() | ||
.catch(error => { | ||
console.error(error) | ||
process.exit(1) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters