Skip to content

Commit

Permalink
fix isAddressValid
Browse files Browse the repository at this point in the history
  • Loading branch information
mihaieremia committed Sep 30, 2024
1 parent fad9692 commit 726df63
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 24 deletions.
42 changes: 21 additions & 21 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -69,51 +69,51 @@
},
"homepage": "https://github.com/XOXNO/sdk-js#readme",
"devDependencies": {
"@aws-sdk/client-ses": "^3.637.0",
"@commitlint/cli": "^19.4.0",
"@commitlint/config-conventional": "^19.2.2",
"@aws-sdk/client-ses": "^3.658.1",
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@ianvs/prettier-plugin-sort-imports": "^4.3.1",
"@semantic-release/changelog": "^6.0.3",
"@semantic-release/git": "^10.0.1",
"@swc/cli": "^0.4.0",
"@swc/core": "^1.7.14",
"@swc/core": "^1.7.26",
"@types/he": "^1.2.3",
"@types/jest": "^29.5.12",
"@types/node": "^22.5.0",
"@types/react": "^18.3.4",
"@typescript-eslint/eslint-plugin": "^8.2.0",
"@typescript-eslint/parser": "^8.2.0",
"commitizen": "^4.3.0",
"@types/jest": "^29.5.13",
"@types/node": "^22.7.4",
"@types/react": "^18.3.10",
"@typescript-eslint/eslint-plugin": "^8.8.0",
"@typescript-eslint/parser": "^8.8.0",
"commitizen": "^4.3.1",
"cz-conventional-changelog": "^3.3.0",
"eslint": "^8",
"eslint": "^9",
"eslint-config-prettier": "^9.1.0",
"eslint-plugin-prettier": "^5.2.1",
"fork-ts-checker-webpack-plugin": "^9.0.2",
"husky": "^9.1.5",
"husky": "^9.1.6",
"jest": "^29.7.0",
"prettier": "^3.3.3",
"react": "^19.0.0-rc-187dd6a7-20240806",
"react-dom": "^19.0.0-rc-187dd6a7-20240806",
"semantic-release": "^24.1.0",
"semantic-release": "^24.1.2",
"swc-loader": "^0.2.6",
"terser-webpack-plugin": "^5.3.10",
"ts-jest": "^29.2.5",
"ts-loader": "^9.5.1",
"typedoc": "^0.26.6",
"typescript": "^5.5.4",
"webpack": "^5.94.0",
"typedoc": "^0.26.7",
"typescript": "^5.6.2",
"webpack": "^5.95.0",
"webpack-cli": "^5.1.4",
"webpack-merge": "^6.0.1"
},
"dependencies": {
"axios": "^1.7.5",
"@multiversx/sdk-core": "^13.4.1",
"@multiversx/sdk-network-providers": "^2.6.0",
"@react-email/components": "^0.0.22",
"axios": "^1.7.7",
"@multiversx/sdk-core": "^13.6.3",
"@multiversx/sdk-network-providers": "^2.7.1",
"@react-email/components": "^0.0.25",
"he": "^1.2.0",
"protobufjs": "^7.4.0",
"react-markdown": "^9.0.1",
"use-intl": "^3.17.6",
"use-intl": "^3.20.0",
"webpack-bundle-analyzer": "^4.10.2"
},
"peerDependencies": {
Expand Down
2 changes: 2 additions & 0 deletions src/interactions/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ import type {
WithSenderAndNonce,
} from '../types/interactions'
import { AuctionType } from '../types/interactions'
import { isAddressValid } from '../utils/helpers'
import { ContractQueryRunner } from '../utils/scCalls'
import { SmartContractAbis } from '../utils/SmartContractAbis'
import { getSmartContract } from '../utils/SmartContractService'
Expand Down Expand Up @@ -134,6 +135,7 @@ export class SCInteraction {
token: string,
nonce: number
): Promise<number> {
if (!isAddressValid(address)) throw new Error('Invalid address')
const result = await this.getResult(
this.xo.methods.userDeposit([address, token, nonce])
)
Expand Down
3 changes: 1 addition & 2 deletions src/users/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import type {
CreatorInfo,
EventCreatorInfo,
GetNFTsArgs,
IMintInfo,
IMintInfoExtended,
SearchNFTsResponse,
StakingStatus,
StakingSummaryPools,
Expand Down Expand Up @@ -481,6 +479,7 @@ export class UserModule {
public getStakingCreatorInfo = async (
address: string
): Promise<StakingCreatorInfo> => {
if (!isAddressValid(address)) throw new Error('Invalid address')
return await this.api.fetchWithTimeout<StakingCreatorInfo>(
`/user/${address}/staking/creator`,
{
Expand Down
2 changes: 1 addition & 1 deletion src/utils/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@ export const getIdentifierFromColAndNonce = (
}

export const isAddressValid = (address: string | Buffer): boolean => {
return address.includes('erd1')
return address.includes('erd1') && address?.length === 62
}

0 comments on commit 726df63

Please sign in to comment.