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 soldTicket = async ({params, stateStore}) => { | |
const { eventId, typeId } = params; | |
const registeredEventsBuffer = await stateStore.chain.get( | |
CHAIN_STATE_EVENTS | |
); | |
if (!registeredEventsBuffer) { | |
throw new Error('No events found'); | |
} |
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
await reducerHandler.invoke("event:soldTicket", { | |
eventId: asset.eventId, | |
typeId: asset.typeId, | |
}); |
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
await reducerHandler.invoke("token:credit", { | |
address: organization.ownerAddress, | |
amount: asset.value, | |
}); |
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
await reducerHandler.invoke("token:debit", { | |
address: senderAddress, | |
amount: asset.value, | |
}); |
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
import WebSocket from 'isomorphic-ws'; | |
import { EventEmitter } from 'events'; | |
const CONNECTION_TIMEOUT = 2000; | |
const ACKNOWLEDGMENT_TIMEOUT = 2000; | |
const RESPONSE_TIMEOUT = 3000; | |
const timeout = async (ms, message) => new Promise((_, reject) => { | |
const id = setTimeout(() => { | |
clearTimeout(id); |
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 | |
} |
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 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 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 tx = new FundContractTransaction({ | |
nonce: nonce.toString(), | |
senderPublicKey: publicKey, | |
asset: { | |
...data | |
} | |
}); | |
tx.fee = (tx.minFee + BigInt(65000)).toString(); | |
tx.sign(config.networkIdentifier, passphrase); |
NewerOlder