This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
BaseTransaction, | |
TransactionError, | |
utils | |
} = require('@liskhq/lisk-transactions'); | |
class MultiRecipient extends BaseTransaction { | |
static get TYPE() { | |
return 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { | |
BaseTransaction, | |
TransactionError, | |
utils | |
} = require('@liskhq/lisk-transactions'); | |
class MultiRecipient extends BaseTransaction { | |
static get TYPE() { | |
return 20; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const {proposal, errors} = await this.applyProposalAsset(store); | |
errors.map(err => { | |
errs.push(err); | |
}); | |
proposal.publicKey = this.getProposalPublicKey(); | |
proposal.asset = { | |
...proposal.asset, | |
options: proposal.asset.options || {}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public async applyProposalAsset(store: StateStore): Promise<ApplyProposal> { | |
const errors: TransactionError[] = []; | |
const proposal = await store.account.getOrDefault(this.getProposalAddress()) as ProposalAccount; | |
const addressBook = await store.account.getOrDefault(getAddressFromPublicKey(this.asset.addressBook)) as AddressBookAccount; | |
const proposedMember = await store.account.getOrDefault(getAddressFromPublicKey(this.asset.options.member)) as Account; | |
if (!this.asset.options.member) { | |
errors.push( | |
new TransactionError( | |
'`.asset.options.member` should contain the proposal.', |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// slotTypes = [minutes, hours, days, months] in seconds | |
export const getPastSlots = ( | |
start, | |
now, | |
type, | |
length, | |
unit | |
) => { | |
const slot = slotTypes[type] * length; | |
return Math.floor((now - start) / slot) - unit; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tx = new FundContractTransaction({ | |
nonce: nonce.toString(), | |
senderPublicKey: publicKey, | |
asset: { | |
...data | |
} | |
}); | |
tx.fee = (tx.minFee + BigInt(65000)).toString(); | |
tx.sign(config.networkIdentifier, passphrase); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public calculateVoteStake(investments: Array<Investment>): bigint { | |
let voteStake = BigInt(0); | |
investments.map(investment => { | |
if (investment.address === this.senderId) { | |
voteStake += BigInt(investment.amount); | |
} | |
}); | |
return voteStake; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const voteWeightNo = votes | |
.filter(v => v.vote === 0) | |
.map(v => v.stake) | |
.reduce((accumulator, currentValue) => accumulator + currentValue); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public allowedToClaim(currentTime: number, startTime: number, payments: Array<Payment>): boolean { | |
const currentPeriod = this.calculateCurrentPeriod(currentTime, startTime); | |
if (payments.find(p => | |
p.type === 0 && | |
p.period === this.asset.period)) { | |
return false; | |
} | |
return currentPeriod >= this.asset.period && (this.asset.period * PERIOD) + startTime < currentTime; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const tx = { | |
senderPublicKey: wallet.account.publicKey, | |
networkIdentifier, | |
nonce: wallet.account.nonce.toString(), | |
passphrase: passphrase, | |
asset: { | |
fundraiser: fundraiser, | |
amount: convertLSKToBeddows(amount.toString()), | |
message | |
} |
OlderNewer