Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bug resolved for non-evm flow in v2 #261

Merged
merged 1 commit into from
May 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions app/controllers/api/v1/transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,19 @@ module.exports = function (router: any) {
signedData: any
) {
try {
swapAndWithdrawTransaction.sourceAmount = signedData.amount;
swapAndWithdrawTransaction.sourceWalletAddress = signedData.from;
swapAndWithdrawTransaction.destinationWalletAddress =
signedData.targetAddress;
if (swapAndWithdrawTransaction.sourceAmount) {
swapAndWithdrawTransaction.sourceAmount =
await swapUtilsHelper.amountToHuman_(
swapAndWithdrawTransaction.sourceNetwork,
swapAndWithdrawTransaction.sourceCabn,
swapAndWithdrawTransaction.sourceAmount
);
if (swapAndWithdrawTransaction.sourceNetwork.isNonEVM == false) {
swapAndWithdrawTransaction.sourceAmount = signedData.amount;
if (swapAndWithdrawTransaction.sourceAmount) {
swapAndWithdrawTransaction.sourceAmount =
await swapUtilsHelper.amountToHuman_(
swapAndWithdrawTransaction.sourceNetwork,
swapAndWithdrawTransaction.sourceCabn,
swapAndWithdrawTransaction.sourceAmount
);
}
}
} catch (e) {
console.log(e);
Expand Down
58 changes: 36 additions & 22 deletions app/lib/httpCalls/fiberAxiosHelper.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,32 @@
var axios = require("axios").default;

module.exports = {

async doWithdrawSigned(req: any, swapAndWithdrawTransactionObject: any, token: any) {
async doWithdrawSigned(
req: any,
swapAndWithdrawTransactionObject: any,
token: any
) {
try {
const config = {
headers:{
Authorization: await withdrawTransactionHelper.fiberAuthorizationToken()
}
headers: {
Authorization:
await withdrawTransactionHelper.fiberAuthorizationToken(),
},
};
let baseUrl = ((global as any) as any).environment.baseUrlFIBEREngineBackend;
let baseUrl = (global as any as any).environment
.baseUrlFIBEREngineBackend;
let url = `${baseUrl}/v2/multiswap/withdraw/signed/${swapAndWithdrawTransactionObject.receiveTransactionId}`;
console.log('doSwapAndWithdraw doWithdrawSigned url',url);
let res = await axios.post(url, this.getWithdrawBody(swapAndWithdrawTransactionObject, ), config);
if(res.data.body && res.data.body.data){
console.log('doSwapAndWithdraw doWithdrawSigned hash',res.data.body.data);
console.log("doSwapAndWithdraw doWithdrawSigned url", url);
let res = await axios.post(
url,
this.getWithdrawBody(swapAndWithdrawTransactionObject),
config
);
if (res.data.body && res.data.body.data) {
console.log(
"doSwapAndWithdraw doWithdrawSigned hash",
res.data.body.data
);
return res.data.body;
}
} catch (error: any) {
Expand All @@ -26,16 +38,18 @@ module.exports = {
async getTokenQuoteInformation(req: any) {
try {
const config = {
headers:{
Authorization: await withdrawTransactionHelper.fiberAuthorizationToken()
}
headers: {
Authorization:
await withdrawTransactionHelper.fiberAuthorizationToken(),
},
};
let baseUrl = ((global as any) as any).environment.baseUrlFIBEREngineBackend;
let baseUrl = (global as any as any).environment
.baseUrlFIBEREngineBackend;
let url = `${baseUrl}/v1/multiswap/token/categorized/quote/info?sourceAmount=${req.query.sourceAmount}&sourceNetworkChainId=${req.query.sourceNetwork}&destinationNetworkChainId=${req.query.destinationNetwork}&sourceTokenContractAddress=${req.query.sourceCabn}&destinationTokenContractAddress=${req.query.destinationCabn}`;
console.log('getTokenQuoteInformation url',url);
console.log("getTokenQuoteInformation url", url);
let res = await axios.get(url, config);
if(res.data.body){
console.log('getTokenQuoteInformation response',res.data.body);
if (res.data.body) {
console.log("getTokenQuoteInformation response", res.data.body);
return res.data.body;
}
} catch (error: any) {
Expand All @@ -44,22 +58,22 @@ module.exports = {
return null;
},

getWithdrawBody(model: any){
getWithdrawBody(model: any) {
let body: any = {};
body.sourceAmount = model.sourceAmount;
body.sourceNetworkChainId = model.sourceNetwork.chainId;
body.sourceTokenContractAddress = model.sourceCabn.tokenContractAddress;
body.sourceWalletAddress = model.sourceWalletAddress;
body.destinationNetworkChainId = model.destinationNetwork.chainId;
body.destinationTokenContractAddress = model.destinationCabn.tokenContractAddress;
body.destinationTokenContractAddress =
model.destinationCabn.tokenContractAddress;
body.destinationWalletAddress = model.destinationWalletAddress;
body.salt = model.payBySig.salt;
body.hash = model.payBySig.hash;
body.signatures = model.payBySig.signatures;
body.bridgeAmount = model.bridgeAmount;

console.log('getWithdrawBody body',body);
console.log("getWithdrawBody body", body);
return body;
}

},
};
4 changes: 2 additions & 2 deletions app/lib/httpCalls/multiswapNodeAxiosHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module.exports = {
token: any
) {
try {
// let baseUrl = ((global as any) as any).environment.baseUrlMultiswapNodeBackend;
let baseUrl = "http://localhost:3000";
let baseUrl = (global as any as any).environment
.baseUrlMultiswapNodeBackend;
let url = `${baseUrl}/api/jobs`;
console.log("doSwapAndWithdraw createJobBySwapHash url", url);
let body: any = {};
Expand Down