本文整理汇总了TypeScript中bignumber.js.default.max方法的典型用法代码示例。如果您正苦于以下问题:TypeScript js.default.max方法的具体用法?TypeScript js.default.max怎么用?TypeScript js.default.max使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类bignumber.js.default
的用法示例。
在下文中一共展示了js.default.max方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: BigNumber
groupSize: 3,
groupSeparator: ' ',
decimalSeparator: ','
}
});
// Alternatively but equivalently (excluding FORMAT):
BigNumber.config(40, 7, [-10, 20], 500, 1, 1, 3, 80)
const obj = BigNumber.config();
obj.ERRORS // true
obj.RANGE // [-500, 500]
{
const x = new BigNumber('3257869345.0378653')
BigNumber.max(4e9, x, '123456789.9') // '4000000000'
const arr = [12, '13', new BigNumber(14)]
BigNumber.max(arr) // '14'
}
{
const x = new BigNumber('3257869345.0378653')
BigNumber.min(4e9, x, '123456789.9') // '123456789.9'
const arr = [2, new BigNumber(-14), '-15.9999', -12]
BigNumber.min(arr) // '-15.9999'
}
BigNumber.config({ DECIMAL_PLACES: 10 })
BigNumber.random() // '0.4117936847'
示例2: co
return co(function *() {
const { userKeychain, backupKeychain, bitgoKeychain } = keychains;
const userKey = HDNode.fromBase58(userKeychain.pub).getKey();
const userAddress = rippleKeypairs.deriveAddress(userKey.getPublicKeyBuffer().toString('hex'));
const backupKey = HDNode.fromBase58(backupKeychain.pub).getKey();
const backupAddress = rippleKeypairs.deriveAddress(backupKey.getPublicKeyBuffer().toString('hex'));
const bitgoKey = HDNode.fromBase58(bitgoKeychain.pub).getKey();
const bitgoAddress = rippleKeypairs.deriveAddress(bitgoKey.getPublicKeyBuffer().toString('hex'));
// initially, we need to generate a random root address which has to be distinct from all three keychains
let keyPair = ECPair.makeRandom();
if (walletParams.rootPrivateKey) {
const rootPrivateKey = walletParams.rootPrivateKey;
if (typeof rootPrivateKey !== 'string' || rootPrivateKey.length !== 64) {
throw new Error('rootPrivateKey needs to be a hexadecimal private key string');
}
keyPair = prova.ECPair.fromPrivateKeyBuffer(Buffer.from(walletParams.rootPrivateKey, 'hex'));
}
const privateKey: Buffer = keyPair.getPrivateKeyBuffer();
const publicKey: Buffer = keyPair.getPublicKeyBuffer();
const rootAddress = rippleKeypairs.deriveAddress(publicKey.toString('hex'));
const self = this;
const rippleLib = ripple();
const feeInfo = yield self.getFeeInfo();
const openLedgerFee = new BigNumber(feeInfo.xrpOpenLedgerFee);
const medianFee = new BigNumber(feeInfo.xrpMedianFee);
const fee = BigNumber.max(openLedgerFee, medianFee).times(1.5).toFixed(0);
// configure multisigners
const multisigAssignmentTx = {
TransactionType: 'SignerListSet',
Account: rootAddress,
SignerQuorum: 2,
SignerEntries: [
{
SignerEntry: {
Account: userAddress,
SignerWeight: 1
}
},
{
SignerEntry: {
Account: backupAddress,
SignerWeight: 1
}
},
{
SignerEntry: {
Account: bitgoAddress,
SignerWeight: 1
}
}
],
Flags: 2147483648,
// LastLedgerSequence: ledgerVersion + 10,
Fee: fee,
Sequence: 1
};
const signedMultisigAssignmentTx = rippleLib.signWithPrivateKey(JSON.stringify(multisigAssignmentTx), privateKey.toString('hex'));
// enforce destination tags
const destinationTagTx = {
TransactionType: 'AccountSet',
Account: rootAddress,
SetFlag: 1,
Flags: 2147483648,
// LastLedgerSequence: ledgerVersion + 10,
Fee: fee,
Sequence: 2
};
const signedDestinationTagTx = rippleLib.signWithPrivateKey(JSON.stringify(destinationTagTx), privateKey.toString('hex'));
// disable master key
const masterDeactivationTx = {
TransactionType: 'AccountSet',
Account: rootAddress,
SetFlag: 4,
Flags: 2147483648,
// LastLedgerSequence: ledgerVersion + 10,
Fee: fee,
Sequence: 3
};
const signedMasterDeactivationTx = rippleLib.signWithPrivateKey(JSON.stringify(masterDeactivationTx), privateKey.toString('hex'));
// extend the wallet initialization params
walletParams.rootPub = publicKey.toString('hex');
walletParams.initializationTxs = {
setMultisig: signedMultisigAssignmentTx.signedTransaction,
disableMasterKey: signedMasterDeactivationTx.signedTransaction,
forceDestinationTag: signedDestinationTagTx.signedTransaction
};
return walletParams;
}).call(this);