Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const sanitizeValues = json => json
export default class VaultEvent extends Model {
static table = 'vault_events'
@field('address') address
@field('event_id') eventId
@field('event') event
@field('block_number') blockNumber
@field('ref') ref
@json('return_values', sanitizeValues) returnValues
@action async addEvent(data) {
return this.create(lpEvent => {
const { event, address, id, blockNumber } = data
lpEvent.eventId = id
lpEvent.address = address
lpEvent.event = event
lpEvent.blockNumber = blockNumber
})
}
}
subscriptions: { type: 'belongs_to', key: 'rid' }
}
@field('msg') msg;
@field('t') t;
@date('ts') ts;
@json('u', sanitizer) u;
@relation('subscriptions', 'rid') subscription;
@field('alias') alias;
@json('parse_urls', sanitizer) parseUrls;
@field('groupable') groupable;
@field('avatar') avatar;
@json('attachments', sanitizer) attachments;
@json('urls', sanitizer) urls;
@date('_updated_at') _updatedAt;
@field('status') status;
@field('pinned') pinned;
@field('starred') starred;
@date('ts') ts;
@json('u', sanitizer) u;
@relation('subscriptions', 'rid') subscription;
@field('alias') alias;
@json('parse_urls', sanitizer) parseUrls;
@field('groupable') groupable;
@field('avatar') avatar;
@json('attachments', sanitizer) attachments;
@json('urls', sanitizer) urls;
@date('_updated_at') _updatedAt;
@field('status') status;
@field('pinned') pinned;
@field('starred') starred;
@json('edited_by', sanitizer) editedBy;
@json('reactions', sanitizer) reactions;
@field('role') role;
static table = 'pledges'
static associations = {
profiles: { type: 'belongs_to', key: 'profile_id' },
}
@field('id_pledge') idPledge
@field('owner_id') owner
@field('amount') amount
@field('token') token
@field('commit_time') commitTime
@field('n_delegates') nDelegates
@field('intended_project') intendedProject
@field('pledge_state') pledgeState
@field('block_number') blockNumber
@relation('profiles', 'profile_id') profile
@json('delegates', sanitizeValues) delegates
@action async transferTo(to, amount, projectId) {
const toPledgeQuery = await this.collections.get('pledges').query(
Q.where('pledge_id', to)
).fetch()
const pledgesCollection = await this.collections.get('pledges')
const toPledge = toPledgeQuery[0]
const args = [
this.prepareUpdate(pledge => {
pledge.amount = (BigInt(pledge.amount) - BigInt(amount)).toString()
})
]
if (toPledge) {
args.push(
toPledge.prepareUpdate(pledge => {
pledge.amount = (BigInt(pledge.amount) + BigInt(amount)).toString()
import { sanitizer } from '../utils';
export default class Message extends Model {
static table = 'messages';
static associations = {
subscriptions: { type: 'belongs_to', key: 'rid' }
}
@field('msg') msg;
@field('t') t;
@date('ts') ts;
@json('u', sanitizer) u;
@relation('subscriptions', 'rid') subscription;
@field('alias') alias;
@json('parse_urls', sanitizer) parseUrls;
@field('groupable') groupable;
@field('avatar') avatar;
@json('attachments', sanitizer) attachments;
@json('urls', sanitizer) urls;
@date('_updated_at') _updatedAt;
@field('topic') topic;
@field('blocked') blocked;
@field('blocker') blocker;
@field('react_when_read_only') reactWhenReadOnly;
@field('archived') archived;
@field('join_code_required') joinCodeRequired;
@field('notifications') notifications;
@json('muted', sanitizer) muted;
@field('broadcast') broadcast;
@field('prid') prid;
@field('draft_message') draftMessage;
@date('last_thread_sync') lastThreadSync;
@date('jitsi_timeout') jitsiTimeout;
@field('auto_translate') autoTranslate;
@field('auto_translate_language') autoTranslateLanguage;
@json('last_message', sanitizer) lastMessage;
@field('tcount') tcount;
@date('tlm') tlm;
@json('replies', sanitizer) replies;
@json('mentions', sanitizer) mentions;
@json('channels', sanitizer) channels;
@field('unread') unread;
@field('auto_translate') autoTranslate;
@json('translations', sanitizer) translations;
@field('tmsg') tmsg;
@json('blocks', sanitizer) blocks;
}
@field('role') role;
@field('drid') drid;
@field('dcount') dcount;
@date('dlm') dlm;
@field('tmid') tmid;
@field('tcount') tcount;
@date('tlm') tlm;
@json('replies', sanitizer) replies;
@json('mentions', sanitizer) mentions;
@json('channels', sanitizer) channels;
@field('unread') unread;
@field('auto_translate') autoTranslate;
@json('translations', sanitizer) translations;
@field('tmsg') tmsg;
@json('blocks', sanitizer) blocks;
}
import { action, field, json } from '@nozbe/watermelondb/decorators'
const sanitizeValues = json => json
export default class LpEvent extends Model {
static table = 'lp_events'
@field('address') address
@field('event_id') eventId
@field('event') event
@field('block_number') blockNumber
@json('return_values', sanitizeValues) returnValues
@action async addEvent(data) {
return this.create(lpEvent => {
const { event, address, id, blockNumber } = data
lpEvent.eventId = id
lpEvent.address = address
lpEvent.event = event
lpEvent.blockNumber = blockNumber
})
}
}
@field('broadcast') broadcast;
@field('prid') prid;
@field('draft_message') draftMessage;
@date('last_thread_sync') lastThreadSync;
@date('jitsi_timeout') jitsiTimeout;
@field('auto_translate') autoTranslate;
@field('auto_translate_language') autoTranslateLanguage;
@json('last_message', sanitizer) lastMessage;
@children('messages') messages;
@children('threads') threads;
@children('thread_messages') threadMessages;
@field('hide_unread_status') hideUnreadStatus;
}