Skip to content

Commit

Permalink
validate link in arthera network (#426)
Browse files Browse the repository at this point in the history
  • Loading branch information
hichri-louay committed Feb 22, 2024
2 parents dd0ea21 + 4a64fd0 commit c88a317
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 13 deletions.
19 changes: 14 additions & 5 deletions controllers/campaign.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -1366,7 +1366,10 @@ exports.validateCampaign = async (req, res) => {
tronWeb.setAddress(walletAddr)
} else {
req.body.network = campaign.token.type
cred = await unlockV2(req, res)
cred =
req.body.network === 'ARTHERA'
? await unlockArthera(req, res)
: await unlockV2(req, res)
if (
typeof campaignLink.userExternal !== 'undefined' &&
campaignLink.userExternal === true
Expand All @@ -1385,9 +1388,13 @@ exports.validateCampaign = async (req, res) => {
}
} else {
const recoveredSigner =
await cred.WEB3.eth.accounts.recover(
campaignLink.applyerSignature
)
req.body.network === 'ARTHERA'
? await cred.Web3ARTHERA.eth.accounts.recover(
campaignLink.applyerSignature
)
: await cred.WEB3.eth.accounts.recover(
campaignLink.applyerSignature
)
if (
recoveredSigner.toLowerCase() !== campaignLink.id_wallet
) {
Expand Down Expand Up @@ -1423,7 +1430,8 @@ exports.validateCampaign = async (req, res) => {
signature.r,
signature.s,
cred,
tronWeb
tronWeb,
req.body.network
)
}

Expand Down Expand Up @@ -1553,6 +1561,7 @@ exports.validateCampaign = async (req, res) => {
return responseHandler.makeResponseError(res, 401, 'unothorized')
}
} catch (err) {
console.log({ err })
return responseHandler.makeResponseError(
res,
500,
Expand Down
21 changes: 13 additions & 8 deletions web3/campaigns.js
Original file line number Diff line number Diff line change
Expand Up @@ -1433,7 +1433,8 @@ exports.validateProm = async (
r,
s,
credentials,
tronWeb
tronWeb,
network
) => {
if (!!tronWeb) {
let ctr = await tronWeb.contract(
Expand All @@ -1455,13 +1456,17 @@ exports.validateProm = async (
} else return result
}
var gas = 1000000
// let ctr = await getPromContract(idProm, credentials)

let ctr = await getContractByNetwork(credentials)

// let ctr = await getPromContract(idProm, credentials)

var gasPrice = await ctr.getGasPrice()
let ctr
if (network === 'ARTHERA') {
ctr = new credentials.Web3ARTHERA.eth.Contract(
CampaignConstants[ArtheraNetworkConstant].abi,
CampaignConstants[ArtheraNetworkConstant].address
)
} else ctr = await getContractByNetwork(credentials)
var gasPrice =
network === 'ARTHERA'
? await credentials.Web3ARTHERA.eth.getGasPrice()
: await contract.getGasPrice()

var receipt = await ctr.methods
.validateProm(
Expand Down

0 comments on commit c88a317

Please sign in to comment.