Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
[WIP] Continue working on getAcceptedPaymentDetails function
Browse files Browse the repository at this point in the history
  • Loading branch information
MantisClone committed Nov 9, 2022
1 parent c3d223b commit 13aa2c1
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 18 deletions.
82 changes: 65 additions & 17 deletions app/controllers/tokens.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,23 +69,58 @@ acceptToken = (chainId, tokenAddress) => {
];
=======
const tokens2 = {
ethereum: {chainId: 1, tokenAddress: "0x0000000000000000000000000000000000000000"},
matic: {chainId: 137, tokenAddress: "0x0000000000000000000000000000000000000000"},
bnb: {chainId: 56, tokenAddress: "0x0000000000000000000000000000000000000000"},
arbitrum: {chainId: 42161, tokenAddress: "0x0000000000000000000000000000000000000000"},
avalanche: {chainId: 43114, tokenAddress: "0x0000000000000000000000000000000000000000"},
boba: {chainId: 288, tokenAddress: "0xa18bF3994C0Cc6E3b63ac420308E5383f53120D7"},
"boba-eth": {chainId: 288, tokenAddress: "0x0000000000000000000000000000000000000000"}
ethereum: {
chainId: 1,
acceptedTokens: [
{ETH: "0x0000000000000000000000000000000000000000"}
]
},
matic: {
chainId: 137,
acceptedTokens: [
{MATIC: "0x0000000000000000000000000000000000000000"}
]
},
bnb: {
chainId: 56,
acceptedTokens: [
{BNB: "0x0000000000000000000000000000000000000000"},
]
},
arbitrum: {
chainId: 42161,
acceptedTokens: [
{ETH: "0x0000000000000000000000000000000000000000"},
]
},
avalanche: {
chainId: 43114,
acceptedTokens: [
{AVAX: "0x0000000000000000000000000000000000000000"},
]
},
boba: {
chainId: 288,
acceptedTokens: [
{BOBA: "0xa18bF3994C0Cc6E3b63ac420308E5383f53120D7"},
]
},
"boba-eth": {
chainId: 288,
acceptedTokens: [
{ETH: "0x0000000000000000000000000000000000000000"},
]
}
};

const tokens =[
{name: "ethereum", chainId: 1, tokenAddress: "0x0000000000000000000000000000000000000000"},
{name: "matic", chainId: 137, tokenAddress: "0x0000000000000000000000000000000000000000"},
{name: "bnb", chainId: 56, tokenAddress: "0x0000000000000000000000000000000000000000"},
{name: "arbitrum", chainId: 42161, tokenAddress: "0x0000000000000000000000000000000000000000"},
{name: "avalanche", chainId: 43114, tokenAddress: "0x0000000000000000000000000000000000000000"},
{name: "boba", chainId: 288, tokenAddress: "0xa18bF3994C0Cc6E3b63ac420308E5383f53120D7"},
{name: "boba-eth", chainId: 288, tokenAddress: "0x0000000000000000000000000000000000000000"}
{name: "ethereum", chainId: 1, tokenAddress: "0x0000000000000000000000000000000000000000", symbol: "ETH"},
{name: "matic", chainId: 137, tokenAddress: "0x0000000000000000000000000000000000000000", symbol: "MATIC"},
{name: "bnb", chainId: 56, tokenAddress: "0x0000000000000000000000000000000000000000", symbol: "BNB"},
{name: "arbitrum", chainId: 42161, tokenAddress: "0x0000000000000000000000000000000000000000", symbol: "ETH"},
{name: "avalanche", chainId: 43114, tokenAddress: "0x0000000000000000000000000000000000000000", symbol: "AVAX"},
{name: "boba", chainId: 288, tokenAddress: "0xa18bF3994C0Cc6E3b63ac420308E5383f53120D7", symbol: "ETH"},
{name: "boba-eth", chainId: 288, tokenAddress: "0x0000000000000000000000000000000000000000", symbol: "BOBA"}
];
>>>>>>> ad3aaab ([WIP] Add registration POST call, debugging getAcceptedPaymentDetails)

Expand All @@ -107,10 +142,23 @@ module.exports = acceptToken;
=======
getAcceptedPaymentDetails = () => {
const accepted = process.env.ACCEPTED_PAYMENTS.split(",");

return accepted.map((payment) => {
tokens2[payment]
const acceptedDetails = accepted.map((payment) => tokens2[payment]);
const compressedDetails = [];
acceptedDetails.forEach((detail) => {
const added = false;
compressedDetails.forEach((compressedDetail) => {
if(detail.chainId == compressedDetail.chainId) {
compressedDetail.acceptedTokens.push({[detail.symbol]: detail.tokenAddress});
}
})
if(!added) {
compressedDetails.push({
"chainId": detail.chainId,
"acceptedTokens": [{[detail.symbol]: detail.tokenAddress}]
})
}
})
return compressedDetails;
}

module.exports = acceptToken, getAcceptedPaymentDetails;
Expand Down
2 changes: 1 addition & 1 deletion server.js
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ const register = () => {
else {
console.log('Skipping registration because DBS_URI == "DEBUG"');
// Inject debug code here
console.log(getAcceptedPaymentDetails().toString());
console.log(JSON.stringify(getAcceptedPaymentDetails()));
}
>>>>>>> ad3aaab ([WIP] Add registration POST call, debugging getAcceptedPaymentDetails)
}
Expand Down

0 comments on commit 13aa2c1

Please sign in to comment.