sentioxyz / sentio-sdk

https://sdk.sentio.xyz/
Apache License 2.0
8 stars 5 forks source link

[feature request] Add a helper function to check if an address is a null address #460

Closed chongzhe closed 1 year ago

chongzhe commented 1 year ago

reference implementation according to chatgpt:

` const { utils } = require('ethers');

function isNullAddress(address) { try { // Normalize the input address const normalizedAddress = utils.getAddress(address); // Check if the normalized address is equal to the null address (all zeros) return normalizedAddress === '0x0000000000000000000000000000000000000000'; } catch (error) { // If the getAddress function throws an error, the input is not a valid address return false; } }

const testAddress = '0x0000000000000000000000000000000000000000'; console.log(isNullAddress(testAddress)); // Output: true `

zfy0701 commented 1 year ago

bultin now

https://github.com/sentioxyz/sentio-sdk/pull/483/files#diff-d8c16c02a67e533b29afa2271006b041708b07a1fb3e1d4b3d4aeb9f59781733R245

just import from "@sentio/sdk/eth"