mirror of
https://github.com/Qortal/Qortal-Hub.git
synced 2025-05-20 08:36:58 +00:00
Unify constants in a unique file
This commit is contained in:
parent
ac6e46bce0
commit
e8db9887be
@ -63,7 +63,7 @@ import {
|
||||
publishGroupEncryptedResource,
|
||||
publishOnQDN,
|
||||
} from './backgroundFunctions/encryption';
|
||||
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from './constants/codes';
|
||||
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from './constants/constants';
|
||||
import Base58 from './deps/Base58';
|
||||
import { encryptSingle } from './qdn/encryption/group-encryption';
|
||||
import { _createPoll, _voteOnPoll } from './qortalRequests/get';
|
||||
|
@ -8,7 +8,7 @@ import {
|
||||
publishOnQDN,
|
||||
uint8ArrayToObject,
|
||||
} from './backgroundFunctions/encryption';
|
||||
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from './constants/codes';
|
||||
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from './constants/constants';
|
||||
import Base58 from './deps/Base58';
|
||||
import axios from 'axios';
|
||||
import {
|
||||
@ -29,7 +29,7 @@ import { RequestQueueWithPromise } from './utils/queue/queue';
|
||||
import { validateAddress } from './utils/validateAddress';
|
||||
import { Sha256 } from 'asmcrypto.js';
|
||||
import { TradeBotRespondMultipleRequest } from './transactions/TradeBotRespondMultipleRequest';
|
||||
import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from './constants/resourceTypes';
|
||||
import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from './constants/constants';
|
||||
import {
|
||||
addDataPublishesCase,
|
||||
addEnteredQmailTimestampCase,
|
||||
|
@ -24,7 +24,7 @@ import {
|
||||
resumeAllQueues,
|
||||
} from '../../App';
|
||||
import { CustomizedSnackbars } from '../Snackbar/Snackbar';
|
||||
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from '../../constants/codes';
|
||||
import { PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY } from '../../constants/constants';
|
||||
import { useMessageQueue } from '../../MessageQueueContext';
|
||||
import {
|
||||
executeEvent,
|
||||
@ -43,7 +43,7 @@ import {
|
||||
import ShortUniqueId from 'short-unique-id';
|
||||
import { ReplyPreview } from './MessageItem';
|
||||
import { ExitIcon } from '../../assets/Icons/ExitIcon';
|
||||
import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from '../../constants/resourceTypes';
|
||||
import { RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS } from '../../constants/constants';
|
||||
import { getFee, isExtMsg } from '../../background';
|
||||
import AppViewerContainer from '../Apps/AppViewerContainer';
|
||||
import CloseIcon from '@mui/icons-material/Close';
|
||||
|
@ -1 +0,0 @@
|
||||
export const PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY = "4001"
|
@ -184,3 +184,7 @@ export {
|
||||
CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP,
|
||||
DYNAMIC_FEE_TIMESTAMP,
|
||||
};
|
||||
|
||||
export const RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS = 102;
|
||||
|
||||
export const PUBLIC_NOTIFICATION_CODE_FIRST_SECRET_KEY = '4001'; // Q for Qortal
|
||||
|
@ -1,5 +0,0 @@
|
||||
// Qortal 8 decimals
|
||||
export const QORT_DECIMALS = 1e8
|
||||
|
||||
// Q for Qortal
|
||||
export const ADDRESS_VERSION = 58
|
@ -1 +0,0 @@
|
||||
export const RESOURCE_TYPE_NUMBER_GROUP_CHAT_REACTIONS = 102
|
@ -1,36 +1,38 @@
|
||||
// @ts-nocheck
|
||||
import Base58 from '../../deps/Base58'
|
||||
import BROKEN_RIPEMD160 from '../../deps/broken-ripemd160'
|
||||
import RIPEMD160 from '../../deps/ripemd160'
|
||||
import utils from '../../utils/utils'
|
||||
import {Buffer} from 'buffer'
|
||||
import {Sha256} from 'asmcrypto.js'
|
||||
import { ADDRESS_VERSION } from '../../constants/general.js'
|
||||
import Base58 from '../../deps/Base58';
|
||||
import BROKEN_RIPEMD160 from '../../deps/broken-ripemd160';
|
||||
import RIPEMD160 from '../../deps/ripemd160';
|
||||
import utils from '../../utils/utils';
|
||||
import { Buffer } from 'buffer';
|
||||
import { Sha256 } from 'asmcrypto.js';
|
||||
import { ADDRESS_VERSION } from '../../constants/constants.js';
|
||||
|
||||
const repeatSHA256 = (passphrase, hashes) => {
|
||||
let hash = passphrase
|
||||
for (let i = 0; i < hashes; i++) {
|
||||
hash = new Sha256().process(hash).finish().result
|
||||
}
|
||||
return hash
|
||||
}
|
||||
let hash = passphrase;
|
||||
for (let i = 0; i < hashes; i++) {
|
||||
hash = new Sha256().process(hash).finish().result;
|
||||
}
|
||||
return hash;
|
||||
};
|
||||
|
||||
const publicKeyToAddress = (publicKey, qora = false) => {
|
||||
const publicKeySha256 = new Sha256().process(publicKey).finish().result
|
||||
const _publicKeyHash = qora ? new BROKEN_RIPEMD160().digest(publicKeySha256) : new RIPEMD160().update(Buffer.from(publicKeySha256)).digest('hex')
|
||||
const publicKeyHash = qora ? _publicKeyHash : _publicKeyHash
|
||||
const publicKeySha256 = new Sha256().process(publicKey).finish().result;
|
||||
const _publicKeyHash = qora
|
||||
? new BROKEN_RIPEMD160().digest(publicKeySha256)
|
||||
: new RIPEMD160().update(Buffer.from(publicKeySha256)).digest('hex');
|
||||
const publicKeyHash = qora ? _publicKeyHash : _publicKeyHash;
|
||||
|
||||
let address = new Uint8Array()
|
||||
let address = new Uint8Array();
|
||||
|
||||
address = utils.appendBuffer(address, [ADDRESS_VERSION])
|
||||
address = utils.appendBuffer(address, publicKeyHash)
|
||||
address = utils.appendBuffer(address, [ADDRESS_VERSION]);
|
||||
address = utils.appendBuffer(address, publicKeyHash);
|
||||
|
||||
const checkSum = repeatSHA256(address, 2)
|
||||
address = utils.appendBuffer(address, checkSum.subarray(0, 4))
|
||||
const checkSum = repeatSHA256(address, 2);
|
||||
address = utils.appendBuffer(address, checkSum.subarray(0, 4));
|
||||
|
||||
address = Base58.encode(address)
|
||||
address = Base58.encode(address);
|
||||
|
||||
return address
|
||||
}
|
||||
return address;
|
||||
};
|
||||
|
||||
export default publicKeyToAddress
|
||||
export default publicKeyToAddress;
|
||||
|
Loading…
x
Reference in New Issue
Block a user