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

Unified eth address to 0x0000000000000000000000000000000000000000 #450

Merged
merged 3 commits into from
Nov 8, 2024
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
2 changes: 1 addition & 1 deletion libs/dx-fun/src/dx-fun.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class DxFunService extends ActionDto<FieldTypes> {
label: 'Coin description',
desc: 'The description of the coin',
type: 'input',
regex: '',
regex: '.{5,}',
regexDesc: 'Coin description',
},
],
Expand Down
24 changes: 7 additions & 17 deletions libs/news/src/news.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -145,10 +145,10 @@ export class NewsService extends ActionDto<FieldTypes> {
const provider = this.chainService.getProvider(chainId);

let tokenFromDecimal;
if (
formData.tokenFrom.toLocaleLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
let tokenInAddress = formData.tokenFrom.toLowerCase() as Address;

if (tokenInAddress === ethers.ZeroAddress) {
tokenInAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
tokenFromDecimal = 18;
} else {
const tokenFromContract = await new Contract(
Expand All @@ -172,7 +172,6 @@ export class NewsService extends ActionDto<FieldTypes> {
direction?: 'from' | 'to';
}>;
};
const tokenInAddress = formData.tokenFrom.toLowerCase() as Address;

const tokens: TransactionInfo['requiredTokenAmount'] = [
{
Expand All @@ -181,10 +180,7 @@ export class NewsService extends ActionDto<FieldTypes> {
},
];

if (
tokenInAddress.toLocaleLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
if (tokenInAddress === '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee') {
swapTx = await this.okxService.getSwapData(
account,
chainId,
Expand Down Expand Up @@ -279,10 +275,7 @@ export class NewsService extends ActionDto<FieldTypes> {
let tokenFromDecimal: bigint;
let tokenSymbol: string;
const provider = this.chainService.getProvider(chainId);
if (
formData.tokenFrom.toLocaleLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
if (formData.tokenFrom.toLowerCase() === ethers.ZeroAddress) {
tokenFromDecimal = 18n;
tokenSymbol = 'ETH';
} else {
Expand Down Expand Up @@ -310,10 +303,7 @@ export class NewsService extends ActionDto<FieldTypes> {
const { chainId } = additionalData;
let tokenSymbol: string;
const provider = this.chainService.getProvider(chainId);
if (
formData.tokenFrom.toLocaleLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
if (formData.tokenFrom.toLowerCase() === ethers.ZeroAddress) {
tokenSymbol = 'ETH';
} else {
const { symbol } = await getERC20SymbolAndDecimals(
Expand Down
21 changes: 7 additions & 14 deletions libs/okx-bridge/src/okxBridge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -155,10 +155,10 @@ export class OkxBridgeService extends ActionDto<FieldTypes> {
const provider = this.chainService.getProvider(fromChainId);

let tokenFromDecimal;
if (
formData.tokenFrom.toLocaleLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
let tokenInAddress = formData.tokenFrom.toLowerCase() as Address;

if (tokenInAddress === ethers.ZeroAddress) {
tokenInAddress = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee';
tokenFromDecimal = 18;
} else {
const tokenFromContract = await new Contract(
Expand All @@ -182,7 +182,6 @@ export class OkxBridgeService extends ActionDto<FieldTypes> {
direction?: 'from' | 'to';
}>;
};
const tokenInAddress = formData.tokenFrom.toLowerCase() as Address;

const tokens: TransactionInfo['requiredTokenAmount'] = [
{
Expand All @@ -192,7 +191,7 @@ export class OkxBridgeService extends ActionDto<FieldTypes> {
];

if (
tokenInAddress.toLocaleLowerCase() ===
tokenInAddress.toLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
bridgeTx = await this.okxService.getBridgeData(
Expand Down Expand Up @@ -295,10 +294,7 @@ export class OkxBridgeService extends ActionDto<FieldTypes> {
let tokenFromDecimal: bigint;
let tokenSymbol: string;
const provider = this.chainService.getProvider(chainId);
if (
formData.tokenFrom.toLocaleLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
if (formData.tokenFrom.toLowerCase() === ethers.ZeroAddress) {
tokenFromDecimal = 18n;
tokenSymbol = 'ETH';
} else {
Expand Down Expand Up @@ -326,10 +322,7 @@ export class OkxBridgeService extends ActionDto<FieldTypes> {
const { chainId } = additionalData;
let tokenSymbol: string;
const provider = this.chainService.getProvider(chainId);
if (
formData.tokenFrom.toLocaleLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
) {
if (formData.tokenFrom.toLowerCase() === ethers.ZeroAddress) {
tokenSymbol = 'ETH';
} else {
const { symbol } = await getERC20SymbolAndDecimals(
Expand Down
7 changes: 6 additions & 1 deletion src/modules/actionUrl/actionUrl.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
ApiTags,
getSchemaPath,
} from '@nestjs/swagger';
import { ethers } from 'ethers';
import { Response } from 'express';

import { OKXService } from '@core/shared';
Expand Down Expand Up @@ -717,7 +718,11 @@ export class ActionUrlController extends BaseController {
const supportTokens = await this.okxService.getAllTokens(Number(chainId));
return supportTokens.map((token) => ({
lable: token.tokenSymbol,
address: token.tokenContractAddress,
address:
token.tokenContractAddress.toLowerCase() ===
'0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee'
? ethers.ZeroAddress
: token.tokenContractAddress,
decimals: token.decimals,
}));
}
Expand Down
Loading