Skip to content

Commit

Permalink
add arthera network in campaign file manager (#440)
Browse files Browse the repository at this point in the history
  • Loading branch information
hichri-louay committed Apr 22, 2024
2 parents 7fc4fca + 3aebe7d commit d22edd5
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 16 deletions.
21 changes: 7 additions & 14 deletions controllers/external.controller.js
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 },
{
$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
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
1 change: 1 addition & 0 deletions web3/campaigns.js
Expand Up @@ -38,6 +38,7 @@ const networks = [
{ name: 'BEP20', providerUrl: process.env.WEB3_URL_BEP20 },
{ name: 'POLYGON', providerUrl: process.env.WEB3_URL_POLYGON },
{ name: 'BTTC', providerUrl: process.env.WEB3_URL_BTT },
{ name: 'ARTHERA', providerUrl: process.env.WEB3_URL_ARTHERA },
]

const { getHttpProvider, networkProviders } = require('../web3/web3-connection')
Expand Down

0 comments on commit d22edd5

Please sign in to comment.