Merge pull request #69 from Superalgos/develop
Adding access code for alpha testers
This commit is contained in:
12 files changed
+3101
-237
No files matched your search
Generated
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@superalgos/operations-client",
|
||||
"version": "0.0.29",
|
||||
"version": "0.0.32",
|
||||
"lockfileVersion": 1,
|
||||
"requires": true,
|
||||
"dependencies": {
|
||||
|
||||
+1
-1
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "@superalgos/operations-client",
|
||||
"version": "0.0.31",
|
||||
"version": "0.0.34",
|
||||
"description": "Superalgos Operations client-side web app",
|
||||
"main": "src/index.js",
|
||||
"dependencies": {
|
||||
|
||||
@@ -32,5 +32,8 @@ export const clone = gql`
|
||||
processName
|
||||
keyId
|
||||
botSlug
|
||||
exchangeName
|
||||
timePeriod
|
||||
balanceAssetB
|
||||
}
|
||||
`
|
||||
@@ -53,7 +53,7 @@ const botTypes = {
|
||||
}
|
||||
|
||||
const exchanges = {
|
||||
Coss: "Coss",
|
||||
// COSS: "COSS",
|
||||
Poloniex: "Poloniex"
|
||||
}
|
||||
|
||||
|
||||
@@ -40,8 +40,11 @@ class AddClone extends Component {
|
||||
teams: [],
|
||||
teamId: '',
|
||||
keyId: '',
|
||||
exchangeName: exchanges.Coss,
|
||||
exchangeName: exchanges.Poloniex,
|
||||
processName: indicatorProcessNames.Daily,
|
||||
accessCodeOption: false,
|
||||
accessCode: '',
|
||||
balanceAssetB: 0.001,
|
||||
|
||||
// Indicator Bot
|
||||
startYear: 2019,
|
||||
@@ -52,8 +55,6 @@ class AddClone extends Component {
|
||||
timePeriod: '01-hs',
|
||||
|
||||
//Error handlers
|
||||
nameError: false,
|
||||
teamError: false,
|
||||
botError: false,
|
||||
modeError: false,
|
||||
isNewCloneConfirmationOpen: false,
|
||||
@@ -61,6 +62,8 @@ class AddClone extends Component {
|
||||
serverError: false,
|
||||
processNameError: false,
|
||||
keyIdError: false,
|
||||
accessCodeError: false,
|
||||
balanceAssetBError: false
|
||||
}
|
||||
}
|
||||
|
||||
@@ -293,8 +296,47 @@ class AddClone extends Component {
|
||||
Live Trading Clones are limited to an initial investment
|
||||
of 0.001 BTC. If you choose to run this bot or any modified
|
||||
version of the code, you are doing it at your own risk.
|
||||
</Typography>
|
||||
</Typography>
|
||||
|
||||
<FormControlLabel
|
||||
control={
|
||||
<Checkbox
|
||||
checked={this.state.accessCodeOption}
|
||||
onChange={(e) => this.setState({ accessCodeOption: e.target.checked })}
|
||||
color="primary"
|
||||
/>
|
||||
}
|
||||
label="I have an Access Code"
|
||||
className={classNames(classes.form, classes.textField)}
|
||||
/>
|
||||
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
{this.state.accessCodeOption &&
|
||||
<React.Fragment>
|
||||
<Typography className={classes.typography} variant='subtitle1' align='justify'>
|
||||
The Access Code is only used by alpha testers. Please contact the team for more details.
|
||||
</Typography>
|
||||
<TextField
|
||||
label="Access Code"
|
||||
className={classNames(classes.margin, classes.textField, classes.form)}
|
||||
value={this.state.accessCode}
|
||||
onChange={(e) => this.setState({ accessCode: e.target.value })}
|
||||
onBlur={(e) => this.setState({ accessCodeError: false })}
|
||||
error={this.state.accessCodeError}
|
||||
fullWidth
|
||||
/>
|
||||
|
||||
<TextField
|
||||
label="BTC Initial Balance"
|
||||
className={classNames(classes.margin, classes.textField, classes.form)}
|
||||
value={this.state.balanceAssetB}
|
||||
onChange={(e) => this.setState({ balanceAssetB: e.target.value })}
|
||||
onBlur={(e) => this.setState({ balanceAssetBError: false })}
|
||||
error={this.state.balanceAssetBError}
|
||||
fullWidth
|
||||
/>
|
||||
</React.Fragment>
|
||||
}
|
||||
|
||||
@@ -491,6 +533,8 @@ class AddClone extends Component {
|
||||
variables.clone.waitTime = this.state.waitTime
|
||||
} else {
|
||||
variables.clone.keyId = this.state.keyId
|
||||
variables.clone.accessCode = this.state.accessCode
|
||||
variables.clone.balanceAssetB = Number(this.state.balanceAssetB)
|
||||
}
|
||||
} else {
|
||||
variables.clone.processName = this.state.processName
|
||||
@@ -527,11 +571,14 @@ class AddClone extends Component {
|
||||
stateDatetime: 0,
|
||||
createDatetime: 0,
|
||||
runAsTeam: false,
|
||||
exchangeName: exchanges.Coss,
|
||||
exchangeName: exchanges.Poloniex,
|
||||
processName: indicatorProcessNames.Daily,
|
||||
teams: [],
|
||||
teamId: '',
|
||||
keyId: '',
|
||||
accessCodeOption: false,
|
||||
accessCode: '',
|
||||
balanceAssetB: 0.001,
|
||||
|
||||
// Indicator Bot
|
||||
startYear: 2019,
|
||||
@@ -542,24 +589,24 @@ class AddClone extends Component {
|
||||
timePeriod: '01-hs',
|
||||
|
||||
//Error handlers
|
||||
nameError: false,
|
||||
teamError: false,
|
||||
botError: false,
|
||||
modeError: false,
|
||||
isNewCloneConfirmationOpen: false,
|
||||
serverResponse: '',
|
||||
serverError: false,
|
||||
processNameError: false,
|
||||
keyIdError: false
|
||||
keyIdError: false,
|
||||
accessCodeError: false,
|
||||
balanceAssetBError: false
|
||||
})
|
||||
};
|
||||
|
||||
validate() {
|
||||
let isError = false
|
||||
|
||||
if (this.state.selectedBot.length < 1) {
|
||||
if (this.state.selectedBot.id.length < 1) {
|
||||
isError = true
|
||||
this.setState(state => ({ selectedBotError: true }));
|
||||
this.setState(state => ({ botError: true }));
|
||||
}
|
||||
|
||||
if (this.state.mode.length < 1) {
|
||||
@@ -567,12 +614,34 @@ class AddClone extends Component {
|
||||
this.setState(state => ({ modeError: true }));
|
||||
}
|
||||
|
||||
if (this.state.selectedBot.kind === "Trading"
|
||||
&& this.state.mode === 'noTime') {
|
||||
isError = true
|
||||
this.setState(state => ({ modeError: true }));
|
||||
}
|
||||
|
||||
if (this.state.selectedBot.kind !== "Trading"
|
||||
&& this.state.processName.length < 1) {
|
||||
isError = true
|
||||
this.setState(state => ({ processNameError: true }));
|
||||
}
|
||||
|
||||
if (this.state.mode === 'live' && this.state.keyId.length < 1) {
|
||||
isError = true
|
||||
this.setState(state => ({ keyIdError: true }));
|
||||
}
|
||||
|
||||
if (this.state.accessCodeOption) {
|
||||
if (this.state.accessCode.length < 1) {
|
||||
isError = true
|
||||
this.setState(state => ({ accessCodeError: true }));
|
||||
}
|
||||
if (this.state.balanceAssetB.length < 1 || isNaN(this.state.balanceAssetB)) {
|
||||
isError = true
|
||||
this.setState(state => ({ balanceAssetBError: true }));
|
||||
}
|
||||
}
|
||||
|
||||
return isError;
|
||||
|
||||
}
|
||||
|
||||
@@ -55,6 +55,7 @@ class ListClones extends Component {
|
||||
<div className={classes.details}>
|
||||
<div className={classes.column4}>
|
||||
<Typography className={classes.cloneInfoBold}>Created:</Typography>
|
||||
<Typography className={classes.cloneInfoBold}>Resume Execution:</Typography>
|
||||
{ isDefined(clone.beginDatetime) &&
|
||||
<Typography className={classes.cloneInfoBold}>Begin:</Typography>
|
||||
}
|
||||
@@ -64,11 +65,17 @@ class ListClones extends Component {
|
||||
{ isDefined(clone.waitTime) &&
|
||||
<Typography className={classes.cloneInfoBold}>Wait Time:</Typography>
|
||||
}
|
||||
<Typography className={classes.cloneInfoBold}>Resume Execution:</Typography>
|
||||
<Typography className={classes.cloneInfoBold}>Run As Team:</Typography>
|
||||
{ clone.botType === 'Trading' &&
|
||||
<React.Fragment>
|
||||
<Typography className={classes.cloneInfoBold}>Exchange:</Typography>
|
||||
<Typography className={classes.cloneInfoBold}>Time Period:</Typography>
|
||||
<Typography className={classes.cloneInfoBold}>Initial Balance (BTC):</Typography>
|
||||
</React.Fragment>
|
||||
}
|
||||
</div>
|
||||
<div className={classes.column4}>
|
||||
<Typography className={classes.cloneInfoNormal}>{toLocalTime(clone.createDatetime)}</Typography>
|
||||
<Typography className={classes.cloneInfoNormal}>{clone.resumeExecution ? 'Yes':'No'}</Typography>
|
||||
{ isDefined(clone.beginDatetime) &&
|
||||
<Typography className={classes.cloneInfoNormal}>{toLocalTime(clone.beginDatetime)}</Typography>
|
||||
}
|
||||
@@ -78,8 +85,13 @@ class ListClones extends Component {
|
||||
{ isDefined(clone.waitTime) &&
|
||||
<Typography className={classes.cloneInfoNormal}>{clone.waitTime}</Typography>
|
||||
}
|
||||
<Typography className={classes.cloneInfoNormal}>{clone.resumeExecution ? 'Yes':'No'}</Typography>
|
||||
<Typography className={classes.cloneInfoNormal}>{clone.runAsTeam ? 'Yes':'No'}</Typography>
|
||||
{ clone.botType === 'Trading' &&
|
||||
<React.Fragment>
|
||||
<Typography className={classes.cloneInfoNormal}>{clone.exchangeName}</Typography>
|
||||
<Typography className={classes.cloneInfoNormal}>{clone.timePeriod}</Typography>
|
||||
<Typography className={classes.cloneInfoNormal}>{clone.balanceAssetB}</Typography>
|
||||
</React.Fragment>
|
||||
}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
Generated
+2939
-193
File diff suppressed because it is too large.
Load diff
@@ -47,32 +47,33 @@ const createClone = async (clone) => {
|
||||
'value': process.env.AUTH_AUDIENCE
|
||||
})
|
||||
|
||||
// MINIO
|
||||
env.push({
|
||||
'name': 'STORAGE_PROVIDER',
|
||||
'value': process.env.STORAGE_PROVIDER
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_END_POINT',
|
||||
'value': process.env.MINIO_END_POINT
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_PORT',
|
||||
'value': process.env.MINIO_PORT
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_USE_SSL',
|
||||
'value': process.env.MINIO_USE_SSL
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_ACCESS_KEY',
|
||||
'value': process.env.MINIO_ACCESS_KEY
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_SECRET_KEY',
|
||||
'value': process.env.MINIO_SECRET_KEY
|
||||
})
|
||||
|
||||
if (process.env.STORAGE_PROVIDER === 'Minio') {
|
||||
env.push({
|
||||
'name': 'MINIO_END_POINT',
|
||||
'value': process.env.MINIO_END_POINT
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_PORT',
|
||||
'value': process.env.MINIO_PORT
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_USE_SSL',
|
||||
'value': process.env.MINIO_USE_SSL
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_ACCESS_KEY',
|
||||
'value': process.env.MINIO_ACCESS_KEY
|
||||
})
|
||||
env.push({
|
||||
'name': 'MINIO_SECRET_KEY',
|
||||
'value': process.env.MINIO_SECRET_KEY
|
||||
})
|
||||
}
|
||||
|
||||
logger.debug('createClone General Financial Being Configuration.')
|
||||
env.push({
|
||||
@@ -112,6 +113,15 @@ const createClone = async (clone) => {
|
||||
'value': clone.exchangeName
|
||||
})
|
||||
|
||||
env.push({
|
||||
'name': 'INITIAL_BALANCE_ASSET_A',
|
||||
'value': clone.balanceAssetA.toString()
|
||||
})
|
||||
env.push({
|
||||
'name': 'INITIAL_BALANCE_ASSET_B',
|
||||
'value': clone.balanceAssetB.toString()
|
||||
})
|
||||
|
||||
logger.debug('createClone Trading Configuration.')
|
||||
if (clone.botType === Trading) {
|
||||
env.push({
|
||||
|
||||
@@ -53,7 +53,12 @@ const cloneSchema = new Schema({
|
||||
processName: {
|
||||
type: String,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
exchangeName: String,
|
||||
timePeriod: String,
|
||||
balanceAssetA: Number,
|
||||
balanceAssetB: Number
|
||||
|
||||
})
|
||||
|
||||
const Clone = mongoose.model('Clone', cloneSchema)
|
||||
|
||||
@@ -46,7 +46,18 @@ const resolve = async (parent, { clone }, context) => {
|
||||
clone.createDatetime = new Date().valueOf() / 1000 | 0
|
||||
clone.active = true
|
||||
|
||||
// TODO Temporary Limitation on bot creation
|
||||
// TODO Temporary Limitations on bot creation
|
||||
if (clone.accessCode !== undefined && clone.accessCode.length > 0) {
|
||||
if (clone.accessCode === process.env.ACCESS_CODE) {
|
||||
clone.balanceAssetA = Number(process.env.DEFAULT_BALANCE_ASSET_A)
|
||||
} else {
|
||||
throw new Error('Invalid access code.')
|
||||
}
|
||||
} else {
|
||||
clone.balanceAssetA = Number(process.env.DEFAULT_BALANCE_ASSET_A)
|
||||
clone.balanceAssetB = Number(process.env.DEFAULT_BALANCE_ASSET_B)
|
||||
}
|
||||
|
||||
if (!(clone.teamSlug === "AAMasters" || clone.teamSlug === "AAVikings")) {
|
||||
let clones = await Clone.find({
|
||||
authId: context.userId,
|
||||
@@ -57,7 +68,7 @@ const resolve = async (parent, { clone }, context) => {
|
||||
throw new Error('Currently maximum number of clones per user is 5. You can delete an existing clone and try again.')
|
||||
}
|
||||
}
|
||||
|
||||
// END temporary limitations
|
||||
try {
|
||||
let newClone = new Clone(clone)
|
||||
newClone.authId = context.userId
|
||||
|
||||
@@ -39,7 +39,11 @@ const CloneType = new GraphQLObjectType({
|
||||
botAvatar: {type: GraphQLString},
|
||||
teamAvatar: {type: GraphQLString},
|
||||
keyId: {type: GraphQLString},
|
||||
botSlug: {type: GraphQLString}
|
||||
botSlug: {type: GraphQLString},
|
||||
exchangeName:{type: GraphQLString},
|
||||
timePeriod:{type: GraphQLString},
|
||||
balanceAssetA:{type: GraphQLFloat},
|
||||
balanceAssetB:{type: GraphQLFloat},
|
||||
})
|
||||
})
|
||||
export default CloneType
|
||||
@@ -3,7 +3,8 @@ import {
|
||||
GraphQLInt,
|
||||
GraphQLInputObjectType,
|
||||
GraphQLBoolean,
|
||||
GraphQLNonNull
|
||||
GraphQLNonNull,
|
||||
GraphQLFloat
|
||||
} from 'graphql'
|
||||
|
||||
const Type = new GraphQLInputObjectType({
|
||||
@@ -26,7 +27,10 @@ const Type = new GraphQLInputObjectType({
|
||||
botType: { type: new GraphQLNonNull(GraphQLString) },
|
||||
keyId: { type: GraphQLString },
|
||||
timePeriod: { type: GraphQLString },
|
||||
exchangeName: { type: GraphQLString }
|
||||
exchangeName: { type: GraphQLString },
|
||||
balanceAssetA: { type: GraphQLFloat },
|
||||
balanceAssetB: { type: GraphQLFloat },
|
||||
accessCode: { type: GraphQLString }
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
Reference in new issue
Block a user