You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
38 lines
1.6 KiB
38 lines
1.6 KiB
const main = require('../contracts/main'); |
|
const subcommand = require('subcommand'); |
|
const {Address} = require("ton"); |
|
const {keyPairFromSeed, getSecureRandomBytes, keyPairFromSecretKey} = require("ton-crypto"); |
|
const {Base64} = require('@tonconnect/protocol'); |
|
const BN = require("bn.js"); |
|
|
|
const express = require('express') |
|
const app = express() |
|
const port = 5171 |
|
|
|
app.get('/', (req, res) => { |
|
res.send('Agorata microservice for dealing with TON') |
|
}) |
|
|
|
app.get('/buy-message/:collection/:domain' /* the rest as get parameters: buyer, key */, (req, res) => { |
|
let collection = Address.parse(req.params.collection); |
|
if (req.query.buyer !== '') { |
|
let buyer = Address.parse(req.query.buyer); |
|
let key = Buffer.from(req.query.key, 'hex'); |
|
let signature = main.signBuy(req.params.domain, collection, buyer, key); |
|
let msg = main.createItem({domain: req.params.domain, signature}) |
|
res.send(JSON.stringify([Base64.encode(msg.toBoc()), collection.toString()])); |
|
} else { |
|
let msg = main.createItem({domain: req.params.domain, signature: '0'}) |
|
res.send(JSON.stringify([Base64.encode(msg.toBoc()), collection.toString()])); |
|
} |
|
}); |
|
|
|
app.get('/content-message/:address/:zone/:domain', (req, res) => { |
|
let msg = main.setContent({domain: req.params.domain, zone: req.params.zone}); |
|
let addr = main.getItemAddr(Address.parse(req.params.address), req.params.domain, 0); |
|
res.send(JSON.stringify([Base64.encode(msg.toBoc()), addr.toString()])); |
|
}); |
|
|
|
app.listen(port, () => { |
|
console.log(`Example app listening on port ${port}`) |
|
})
|
|
|