Skip to content

Commit

Permalink
Merge branch 'master' of github.com:BuildOnViction/tomoissuer
Browse files Browse the repository at this point in the history
  • Loading branch information
bobcoin98 committed Jan 11, 2024
2 parents 3808f3a + a92c6d2 commit 59e4a8d
Show file tree
Hide file tree
Showing 25 changed files with 3,707 additions and 196 deletions.
521 changes: 521 additions & 0 deletions abis/MyVRC25.json

Large diffs are not rendered by default.

545 changes: 545 additions & 0 deletions abis/MyVRC25Mintable.json

Large diffs are not rendered by default.

15 changes: 8 additions & 7 deletions apis/account.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const config = require('config')
const router = express.Router()
const { check, validationResult, query } = require('express-validator/check')
const axios = require('axios')
// const web3 = require('../models/blockchain/web3')
const web3 = require('../models/blockchain/web3')
const urljoin = require('url-join')

function serializeQuery (params, prefix) {
Expand Down Expand Up @@ -35,7 +35,7 @@ router.get('/:account', [
try {
const account = req.params.account.toLowerCase()
const { data } = await axios.get(
urljoin(config.get('tomoscanAPI'), `/api/accounts/${account}`)
urljoin(config.get('tomoscanAPI'), `/api/account/${account}`)
)
return res.json(data)
} catch (error) {
Expand All @@ -47,21 +47,22 @@ router.get('/:account/listTokens', [
query('limit')
.isInt({ min: 0, max: 200 }).optional().withMessage('limit should greater than 0 and less than 200'),
query('page').isNumeric({ no_symbols: true }).optional().withMessage('page must be number'),
check('account').exists().isLength({ min: 42, max: 42 }).withMessage('Account address is incorrect.')
check('account').exists().custom((account) => web3.utils.isAddress(account))
.withMessage('Account address is incorrect.')
], async (req, res, next) => {
const errors = validationResult(req)
if (!errors.isEmpty()) {
return next(errors.array())
}
try {
const account = (req.params.account || '').toLowerCase()
const account = web3.utils.toChecksumAddress(req.params.account)
const params = {
limit: req.query.limit || 1,
page: req.query.page || 1
limit: req.query.limit || 1
}
params.offset = ((req.query.page || 1) - 1) * params.limit
const query = serializeQuery(params)
const { data } = await axios.get(
urljoin(config.get('tomoscanAPI'), `/api/accounts/${account}/listTokens?${query}`)
urljoin(config.get('tomoscanAPI'), `/api/token/listByOwner?owner=${account}&${query}`)
)
return res.json(data)
} catch (error) {
Expand Down
59 changes: 44 additions & 15 deletions apis/token.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ router.post('/createToken', [
check('decimals').exists().withMessage("'decimal' is required"),
check('totalSupply').exists().withMessage("'totalSupply' is required"),
check('type').exists().withMessage("'type' is required")
.isIn(['trc20', 'trc21']).withMessage("'type' should be 'trc20' or 'trc21'"),
.isIn(['trc20', 'trc21', 'vrc25']).withMessage("'type' should be 'trc20' or 'trc21'"),
check('minFee').isFloat({ min: 0 }).exists().withMessage("'minFee' is required"),
check('mintable').exists().isBoolean().withMessage("'mintable' must be true or false")
], async function (req, res, next) {
Expand All @@ -100,15 +100,21 @@ router.post('/createToken', [
let contractCode
let p
if (mintable) {
if (type === 'trc21') {
if (type === 'vrc25') {
p = path.resolve(__dirname, '../contracts', 'MyVRC25Mintable.sol')
contractCode = fs.readFileSync(p, 'UTF-8')
} else if (type === 'trc21') {
p = path.resolve(__dirname, '../contracts', 'TRC21Mintable.sol')
contractCode = fs.readFileSync(p, 'UTF-8')
} else {
p = path.resolve(__dirname, '../contracts', 'TRC20Mintable.sol')
contractCode = fs.readFileSync(p, 'UTF-8')
}
} else {
if (type === 'trc21') {
if (type === 'vrc25') {
p = path.resolve(__dirname, '../contracts', 'MyVRC25.sol')
contractCode = fs.readFileSync(p, 'UTF-8')
} else if (type === 'trc21') {
p = path.resolve(__dirname, '../contracts', 'TRC21.sol')
contractCode = fs.readFileSync(p, 'UTF-8')
} else {
Expand Down Expand Up @@ -381,11 +387,15 @@ router.get('/getToken', async function (req, res, next) {
}
})

router.get('/:token', [], async (req, res, next) => {
router.get('/:token', [
check('token').exists().custom(
(token) => web3.utils.isAddress(token)
).withMessage('token address is incorrect.')
], async (req, res, next) => {
try {
const token = req.params.token || ''
const token = web3.utils.toChecksumAddress(req.params.token)
const { data } = await axios.get(
urljoin(config.get('tomoscanAPI'), `/api/tokens/${token}`)
urljoin(config.get('tomoscanAPI'), `/api/token/${token}`)
)
return res.json(data)
} catch (error) {
Expand All @@ -406,40 +416,59 @@ router.get('/holders/trc21/:token', [], async (req, res, next) => {
return next(error)
}
})
router.get('/holders/:token', [], async (req, res, next) => {
router.get('/holders/:token', [
check('token').exists().custom(
(token) => web3.utils.isAddress(token)
).withMessage('token address is incorrect.')
], async (req, res, next) => {
try {
const token = req.params.token || ''
const token = web3.utils.toChecksumAddress(req.params.token)
const page = req.query.page || 1
const limit = req.query.limit || 20
const { data } = await axios.get(
urljoin(config.get('tomoscanAPI'), `/api/token-holders/?address=${token}&page=${page}&limit=${limit}`)
urljoin(config.get('tomoscanAPI'), `/api/tokenHolder/${token}?offset=${(page - 1) * limit}&limit=${limit}`)
)
return res.json(data)
} catch (error) {
return next(error)
}
})
router.get('/txes/trc20/:token', [], async (req, res, next) => {

router.get('/nft/txs/:token', [
check('token').exists().custom(
(token) => web3.utils.isAddress(token)
).withMessage('token address is incorrect.')
], async (req, res, next) => {
try {
const token = req.params.token || ''
const token = web3.utils.toChecksumAddress(req.params.token)
const page = req.query.page || 1
const limit = req.query.limit || 20
const { data } = await axios.get(
urljoin(config.get('tomoscanAPI'), `/api/token-txs/trc20?token=${token}&page=${page}&limit=${limit}`)
urljoin(
config.get('tomoscanAPI'),
`/api/tokenTx/nft/list?tokenAddress=${token}&offset=${(page - 1) * limit}&limit=${limit}`
)
)
return res.json(data)
} catch (error) {
return next(error)
}
})

router.get('/txes/trc21/:token', [], async (req, res, next) => {
router.get('/txs/:token', [
check('token').exists().custom(
(token) => web3.utils.isAddress(token)
).withMessage('token address is incorrect.')
], async (req, res, next) => {
try {
const token = req.params.token || ''
const token = web3.utils.toChecksumAddress(req.params.token)
const page = req.query.page || 1
const limit = req.query.limit || 20
const { data } = await axios.get(
urljoin(config.get('tomoscanAPI'), `/api/token-txs/trc21?token=${token}&page=${page}&limit=${limit}`)
urljoin(
config.get('tomoscanAPI'),
`/api/tokenTx/list?tokenAddress=${token}&offset=${(page - 1) * limit}&limit=${limit}`
)
)
return res.json(data)
} catch (error) {
Expand Down
4 changes: 4 additions & 0 deletions app/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ import MyTRC21Abi from '../build/contracts/MyTRC21'
import MyTRC21MintableAbi from '../build/contracts/MyTRC21Mintable'
import MyTRC20Abi from '../build/contracts/MyTRC20'
import MyTRC20MintableAbi from '../build/contracts/MyTRC20Mintable'
import MyVRC25Abi from '../build/contracts/MyVRC25'
import MyVRC25MintableAbi from '../build/contracts/MyVRC25Mintable'

import Web3 from 'web3'
import { BootstrapVue, BootstrapVueIcons } from 'bootstrap-vue'
Expand Down Expand Up @@ -90,6 +92,8 @@ Vue.prototype.setupProvider = async function (provider, wjs) {
Vue.prototype.MyTRC21Mintable = MyTRC21MintableAbi
Vue.prototype.MyTRC20 = MyTRC20Abi
Vue.prototype.MyTRC20Mintable = MyTRC20MintableAbi
Vue.prototype.MyVRC25 = MyVRC25Abi
Vue.prototype.MyVRC25Mintable = MyVRC25MintableAbi
if (chainConfig.issuerAddress) {
Vue.prototype.TRC21Issuer = new wjs.eth.Contract(
TRC21IssuerAritfacts.abi,
Expand Down
2 changes: 1 addition & 1 deletion app/assets/scss/components/_token.scss
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@
margin-left: 5px;
}
.apply-tomoz {
background: $background-violet;
background: $background-blue;
@include fsz(14);
// border-radius: 30px;
padding: 2px 10px;
Expand Down
4 changes: 2 additions & 2 deletions app/assets/scss/settings/_colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ $background-white: #ffffff;
$background-oranges: #141414;
$background-blue: #766B60;
$background-blue-active: #766B60;
$background-violet: #5565c7;
$background-violet-active: #3D4DAC;
$background-violet: #766B60;
$background-violet-active: #766B60;

$background-primary: #EBE9E5;

Expand Down
Loading

0 comments on commit 59e4a8d

Please sign in to comment.