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

Fix for incorrect assetCode property #280

Merged
merged 4 commits into from
Nov 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
4 changes: 2 additions & 2 deletions signer-service/src/api/controllers/subsidize.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ exports.subsidizePostSwap = async (req, res) => {
const { address, amountRaw, token } = req.body;
console.log('Subsidize post swap', address, amountRaw, token);

const { assetCode, assetIssuer, maximumSubsidyAmountRaw } = TOKEN_CONFIG[token];
const { assetCodeRaw, assetIssuer, maximumSubsidyAmountRaw } = TOKEN_CONFIG[token];

if (Big(amountRaw).gt(Big(maximumSubsidyAmountRaw))) {
throw new Error('Amount exceeds maximum subsidy amount');
Expand All @@ -49,7 +49,7 @@ exports.subsidizePostSwap = async (req, res) => {
const assetIssuerHex = `0x${Keypair.fromPublicKey(assetIssuer).rawPublicKey().toString('hex')}`;
const pendulumCurrencyId = {
Stellar: {
AlphaNum4: { code: assetCode.padEnd(4, '\0'), issuer: assetIssuerHex },
AlphaNum4: { code: assetCodeRaw.padEnd(4, '\0'), issuer: assetIssuerHex },
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Isn't the idea that we don't need .padEnd(4, '\0') for assetCodeRaw?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes you're right here, should remove the pad (which should have never been needed, we were already padding on the config).

},
};

Expand Down
2 changes: 1 addition & 1 deletion signer-service/src/api/middlewares/validators.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ const validatePostSwapSubsidizationInput = (req, res, next) => {
}

const tokenConfig = TOKEN_CONFIG[token];
if (tokenConfig === undefined || tokenConfig.assetCode === undefined || tokenConfig.assetIssuer === undefined) {
if (tokenConfig === undefined || tokenConfig.assetCodeRaw === undefined || tokenConfig.assetIssuer === undefined) {
return res.status(400).json({ error: 'Invalid "token" parameter' });
}

Expand Down
2 changes: 1 addition & 1 deletion signer-service/src/constants/tokenConfig.js
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ const TOKEN_CONFIG = {

function getTokenConfigByAssetCode(cofig, assetCode) {
for (const key in cofig) {
ebma marked this conversation as resolved.
Show resolved Hide resolved
if (cofig[key].assetCode === assetCode) {
if (cofig[key].assetCodeRaw === assetCode) {
return cofig[key];
}
}
Expand Down
Loading