Skip to content

Commit

Permalink
wip arthera integration for external users
Browse files Browse the repository at this point in the history
  • Loading branch information
hichri-louay committed Apr 22, 2024
1 parent ac1c028 commit 3aebe7d
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
21 changes: 7 additions & 14 deletions controllers/external.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ const {
getLinkedinLinkInfo,
influencersLinks,
getTransactionAmountExternal,
updateBounty,
} = require('../web3/campaigns')

const { create } = require('ipfs-http-client')
Expand Down Expand Up @@ -1150,12 +1151,12 @@ module.exports.externalAnswer = async (req, res) => {
}

let bountie = campaignData.bounties.find(
(b) => b.oracle == findBountyOracle(prom.typeSN)
(b) => b.oracle == findBountyOracle(link.typeSN)
)
let maxBountieFollowers =
bountie.categories[bountie.categories.length - 1].maxFollowers
var evts = await updateBounty(
idProm,
req.body.idProm,
credentials,
tronWeb,
campaignData.token.type
Expand All @@ -1166,15 +1167,15 @@ module.exports.externalAnswer = async (req, res) => {
}

await Request.updateOne(
{ id: idProm },
{ id: req.body.idProm },

Check failure

Code scanning / CodeQL

Database query built from user-controlled sources High

This query object depends on a
user-provided value
.
{
$set: {
nbAbos: stats,
isBounty: true,
new: false,
date: Date.now(),
typeSN: prom.typeSN,
idPost: prom.idPost,
typeSN: link.typeSN,
idPost: link.idPost,
idUser: externalWallet.idUser,
},
},
Expand All @@ -1189,7 +1190,7 @@ module.exports.externalAnswer = async (req, res) => {
campaignContract:
(!!tronWeb && TronConstant.campaign.address) ||
ctr.options.address,
idProm: idProm,
idProm: req.body.idProm,
nbAbos: stats,
})
} finally {
Expand Down Expand Up @@ -1254,14 +1255,6 @@ module.exports.externalAnswer = async (req, res) => {
stats?.shares != prevstat[0]?.shares ||
stats?.views != prevstat[0]?.views
) {
requests = await Request.find({
new: true,
isBounty: false,
typeSN: link.typeSN,
idPost: link.idPost,
idUser: externalWallet.UserId,
})
var tronWeb
var idRequest = req.body.tx[0].topics[1]

// var idRequest = (!!tronWeb && evt.result.idRequest) || evt.raw.topics[1]
Expand Down
10 changes: 8 additions & 2 deletions manager/oracles.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
web3PolygonUrl,
CampaignConstants,
OracleConstants,
web3UrlArthera,
} = require('../conf/const')
const child_process = require('child_process')
const {
Expand Down Expand Up @@ -1514,7 +1515,12 @@ exports.answerCallExternal = async (opts) => {
campaignWallet = JSON.parse(campaignKeystore)

const web3 = new Web3(
new Web3.providers.HttpProvider(web3UrlBep20, options)
new Web3.providers.HttpProvider(
opts.credentials.network.toUpperCase() === 'ARTHERA'
? web3UrlArthera
: web3UrlBep20,
options
)
)

// Decrypt the campaign wallet using the owner's password
Expand Down Expand Up @@ -1549,7 +1555,7 @@ exports.answerCallExternal = async (opts) => {
)
.send({
from: process.env.CAMPAIGN_OWNER,
gas: 500000,
gas: 800000,
gasPrice: gasPrice,
})
.once('transactionHash', function (hash) {})
Expand Down

0 comments on commit 3aebe7d

Please sign in to comment.