Skip to content
This repository was archived by the owner on Sep 8, 2022. It is now read-only.

Commit

Permalink
added fix for claim app
Browse files Browse the repository at this point in the history
  • Loading branch information
spacehaz committed Jan 31, 2020
2 parents 47f88fe + 286dc39 commit 0443d9d
Show file tree
Hide file tree
Showing 13 changed files with 331 additions and 189 deletions.
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: npx pm2-runtime start --name relayer npm -- run server
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,24 +15,22 @@
## Getting started

Clone repo

```bash
git clone https://github.com/LinkdropHQ/linkdrop-binance-x.git
```

Install dependencies

```bash
yarn install
```


## Contributors

* **Amir Jumaniyazov:** [@amiromayer](https://github.com/amiromayer)

* **Mikhail Dobrokhvalov:** [@dobrokhvalov](https://github.com/dobrokhvalov)

* **Haz Baikulov:** [@spacehaz](https://github.com/spacehaz)

- **Amir Jumaniyazov:** [@amiromayer](https://github.com/amiromayer)
- **Haz Baikulov:** [@spacehaz](https://github.com/spacehaz)
- **Mikhail Dobrokhvalov:** [@dobrokhvalov](https://github.com/dobrokhvalov)

## Contributing

Expand Down
20 changes: 20 additions & 0 deletions app.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"name": "Linkdrop x Binance Chain Server",
"description": "Relay service to distribute BEP2 tokens",
"repository": "https://github.com/LinkdropHQ/linkdrop-binance-x/tree/dev",
"env": {
"VERIFIER_ADDRESS": {
"description": "Public Ethereum address corresponding to private key the links have been signed with",
"value": "0xbF0e4036BF968dD007F9B4A1BFdA4e54C042F612"
},
"SENDER_PRIVATE_KEY": {
"description": "Binance chain private key that holds BEP2 tokens to be distributed",
"value": ""
}
},
"keywords": ["node", "express"],
"addons": ["mongolab"],
"scripts": {
"postdeploy": "yarn global add pm2"
}
}
8 changes: 6 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
"test": "cd packages/sdk && yarn test",
"generate-links": "npx babel-node packages/scripts/src/generate-links",
"claim-link": "npx babel-node packages/scripts/src/claim-link",
"server": "npx babel-node packages/server/index"
"server": "npx babel-node packages/server/index",
"start": "npx pm2-runtime start --name relayer npm -- run server"
},
"devDependencies": {
"@babel/cli": "^7.4.4",
Expand All @@ -22,5 +23,8 @@
"@babel/preset-env": "^7.4.5",
"@babel/register": "^7.4.4",
"lerna": "^3.16.4"
},
"engines": {
"node": "10.16.0"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,16 @@ class Step3 extends React.Component {
</div>
<div className={styles.serviceFee}>
<div className={styles.title}>{this.t('titles.instruction')}</div>
<div className={styles.instruction} dangerouslySetInnerHTML={{__html: this.t('texts.sendInstruction', { amount: amount * linksAmount, symbol, senderAddress})}} />
<div
className={styles.instruction}
dangerouslySetInnerHTML={{
__html: this.t('texts.sendInstruction', {
amount: amount * linksAmount,
symbol,
senderAddress
}
)}}
/>
</div>
<ApproveSummary />
<CheckButton />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export default {
scriptInstruction: 'To generate more than {{linksLimit}} links at a time',
scriptDescription: 'This script will deploy the linkdrop proxy contract for your campaign and top it up with the required ETH amount for covering fee costs as well as approve your ERC20 tokens.',
sendViaIntercom: 'Have a question — send us a message via <span>Intercom</span>',
sendInstruction: 'Send <span>{{amount}}</span> of <span>{{symbol}}</span> to <span>{{senderAddress}}</span> and press "Check" button. Do not close the page after you pressed the button.',
sendInstruction: 'Send <span>{{amount}} {{symbol}}</span> and <span>37500 BNB to <span>{{senderAddress}}</span> and press "Check" button. Do not close the page after you pressed the button.',
codeBlockScript: `{
"LINKDROP_MASTER_ADDRESS": "{{masterAddress}}",
"SIGNING_KEY": "{{signingKey}}",
Expand Down
6 changes: 5 additions & 1 deletion packages/sdk/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,7 @@ const claim = async ({
}

try {
alert('sdk 1')
const claimParams = {
asset,
linkId,
Expand All @@ -405,15 +406,18 @@ const claim = async ({
receiverSignature
}

const response = await axios.post(`${apiHost}/api/v1/claim`, claimParams)
alert('sdk 2')

const response = await axios.post(`${apiHost}/api/v1/claim`, claimParams)
alert('sdk 3')
if (response.status !== 200) {
throw new Error(`Invalid response status ${response.status}`)
} else {
const { success, txHash, error } = response.data
return { success, txHash, error }
}
} catch (err) {
alert(err)
throw new Error(err)
}
}
Expand Down
5 changes: 5 additions & 0 deletions packages/server/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Linkdrop x Binance Chain Server

## Deployment

[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://heroku.com/deploy?template=https://github.com/LinkdropHQ/linkdrop-binance-x)
12 changes: 6 additions & 6 deletions packages/server/api/controllers/claim.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import ClaimTx from '../models/ClaimTx'
import { wrapAsync } from '../utils'
import sdk from '@linkdrop/binance-sdk'
import Table from 'cli-table'
import config from '../../config/config.json'
import config from '../../config'

/**
* Function to check whether a `linkId` has already been claimed
Expand Down Expand Up @@ -138,11 +138,11 @@ const claim = wrapAsync(async (req, res) => {
console.log(table.toString(), '\n')

asset,
amount,
linkId,
verifierSignature,
receiverAddress,
receiverSignature
amount,
linkId,
verifierSignature,
receiverAddress,
receiverSignature
}

res.json({
Expand Down
4 changes: 2 additions & 2 deletions packages/server/config/config.json.sample
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"SENDER_PRIVATE_KEY": "", // Private key of the account holding tokens to be distributed
"VERIFIER_ADDRESS": "" // Address corresponding to `VERIFIER_PRIVATE_KEY` that signed links
"SENDER_PRIVATE_KEY": "",
"VERIFIER_ADDRESS": ""
}
14 changes: 14 additions & 0 deletions packages/server/config/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import path from 'path'
import fs from 'fs'
const configPath = path.resolve(__dirname, './config.json')

// If config file does not exist, create it and fill with sample config content
if (!fs.existsSync(configPath)) {
fs.copyFileSync(`${configPath}.sample`, configPath, err => {
if (err) throw new Error(err)
})
}

const config = require(configPath)

export default config
8 changes: 3 additions & 5 deletions packages/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,8 @@
"fast-csv": "^3.0.1",
"mongoose": "^5.6.0",
"morgan": "^1.9.1",
"pm2": "^3.5.1",
"query-string": "^6.8.1"
},
"devDependencies": {
"pm2": "^4.2.2",
"query-string": "^6.8.1",
"@babel/cli": "^7.4.4",
"@babel/core": "^7.4.5",
"@babel/node": "^7.4.5",
Expand All @@ -37,4 +35,4 @@
"babel": {
"extends": "../../babel.config.js"
}
}
}
Loading

0 comments on commit 0443d9d

Please sign in to comment.