Browse Source

Update rewardshare fee

resolve-20231003
AlphaX-Projects 1 year ago
parent
commit
a650ff8ab0
  1. 6
      crypto/api/constants.js
  2. 6
      crypto/api/transactions/reward-share/RemoveRewardShareTransaction.js
  3. 7
      crypto/api/transactions/reward-share/RewardShareTransaction.js

6
crypto/api/constants.js

@ -161,6 +161,10 @@ const PROXY_URL = "/proxy/"
// Chat reference timestamp // Chat reference timestamp
const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 1674316800000 const CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP = 1674316800000
// Dynamic fee timestamp
const DYNAMIC_FEE_TIMESTAMP = 1692118800000
// Used as a salt for all Qora addresses. Salts used for storing your private keys in local storage will be randomly generated // Used as a salt for all Qora addresses. Salts used for storing your private keys in local storage will be randomly generated
const STATIC_SALT = new Uint8Array([54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78, 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6]) const STATIC_SALT = new Uint8Array([54, 190, 201, 206, 65, 29, 123, 129, 147, 231, 180, 166, 171, 45, 95, 165, 78, 200, 208, 194, 44, 207, 221, 146, 45, 238, 68, 68, 69, 102, 62, 6])
const BCRYPT_ROUNDS = 10 // Remember that the total work spent on key derivation is BCRYPT_ROUNDS * KDF_THREADS const BCRYPT_ROUNDS = 10 // Remember that the total work spent on key derivation is BCRYPT_ROUNDS * KDF_THREADS
@ -168,4 +172,4 @@ const BCRYPT_VERSION = "2a"
const STATIC_BCRYPT_SALT = `$${BCRYPT_VERSION}$${BCRYPT_ROUNDS}$IxVE941tXVUD4cW0TNVm.O` const STATIC_BCRYPT_SALT = `$${BCRYPT_VERSION}$${BCRYPT_ROUNDS}$IxVE941tXVUD4cW0TNVm.O`
const KDF_THREADS = 16 const KDF_THREADS = 16
export { TX_TYPES, ERROR_CODES, QORT_DECIMALS, PROXY_URL, STATIC_SALT, ADDRESS_VERSION, KDF_THREADS, STATIC_BCRYPT_SALT, CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP } export { TX_TYPES, ERROR_CODES, QORT_DECIMALS, PROXY_URL, STATIC_SALT, ADDRESS_VERSION, KDF_THREADS, STATIC_BCRYPT_SALT, CHAT_REFERENCE_FEATURE_TRIGGER_TIMESTAMP, DYNAMIC_FEE_TIMESTAMP }

6
crypto/api/transactions/reward-share/RemoveRewardShareTransaction.js

@ -2,6 +2,7 @@
import TransactionBase from '../TransactionBase.js' import TransactionBase from '../TransactionBase.js'
import publicKeyToAddress from '../../wallet/publicKeyToAddress.js' import publicKeyToAddress from '../../wallet/publicKeyToAddress.js'
import { Base58 } from '../../deps/deps.js' import { Base58 } from '../../deps/deps.js'
import { DYNAMIC_FEE_TIMESTAMP } from '../../constants.js'
export default class RemoveRewardShareTransaction extends TransactionBase { export default class RemoveRewardShareTransaction extends TransactionBase {
constructor() { constructor() {
@ -34,8 +35,13 @@ export default class RemoveRewardShareTransaction extends TransactionBase {
set recipient(recipient) { set recipient(recipient) {
const _address = publicKeyToAddress(this._keyPair.publicKey) const _address = publicKeyToAddress(this._keyPair.publicKey)
this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient) this._recipient = recipient instanceof Uint8Array ? recipient : this.constructor.Base58.decode(recipient)
if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
this.fee = _address === recipient ? 0 : 0.01
} else {
this.fee = _address === recipient ? 0 : 0.001 this.fee = _address === recipient ? 0 : 0.001
} }
}
set percentageShare(share) { set percentageShare(share) {
this._percentageShare = share * 100 this._percentageShare = share * 100

7
crypto/api/transactions/reward-share/RewardShareTransaction.js

@ -4,6 +4,7 @@ import TransactionBase from "../TransactionBase.js"
import nacl from '../../deps/nacl-fast.js' import nacl from '../../deps/nacl-fast.js'
import ed2curve from '../../deps/ed2curve.js' import ed2curve from '../../deps/ed2curve.js'
import { Sha256 } from 'asmcrypto.js' import { Sha256 } from 'asmcrypto.js'
import { DYNAMIC_FEE_TIMESTAMP } from '../../constants.js'
export default class RewardShareTransaction extends TransactionBase { export default class RewardShareTransaction extends TransactionBase {
constructor() { constructor() {
@ -54,6 +55,12 @@ export default class RewardShareTransaction extends TransactionBase {
this._base58RewardShareSeed = this.constructor.Base58.encode(this._rewardShareSeed) this._base58RewardShareSeed = this.constructor.Base58.encode(this._rewardShareSeed)
this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(this._rewardShareSeed) this._rewardShareKeyPair = nacl.sign.keyPair.fromSeed(this._rewardShareSeed)
if (new Date(this._timestamp).getTime() >= DYNAMIC_FEE_TIMESTAMP) {
this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.01)
} else {
this.fee = (recipientPublicKey === this.constructor.Base58.encode(this._keyPair.publicKey) ? 0 : 0.001)
}
} }
set recipient(recipient) { set recipient(recipient) {

Loading…
Cancel
Save