How to use the eosjs/dist.Api function in eosjs

To help you get started, we’ve selected a few eosjs examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github eosrio / simpleos / src / app / dashboard / vote / vote.component.ts View on Github external
const accountData = await this.eosjs.rpc.get_account(auth.actor);
		let _producers = [];
		let _proxy = '';
		if (accountData['voter_info']) {
			if (accountData['voter_info']['proxy'] !== '') {
				// voting on proxy
				_proxy = accountData['voter_info']['proxy'];
			} else {
				// voting on producers
				_producers = accountData['voter_info']['producers'];
			}
		}
		const claim_private_key = await this.keytar.getPassword('simpleos', this.claimPublicKey);
		const signatureProvider = new JsSignatureProvider([claim_private_key]);
		const rpc = this.eosjs.rpc;
		const api = new Api({rpc, signatureProvider, textDecoder: new TextDecoder, textEncoder: new TextEncoder});
		const _actions = [];
		_actions.push({
			account: 'eosio',
			name: 'voteproducer',
			authorization: [{
				actor: auth.actor,
				permission: 'claim',
			}],
			data: {
				voter: auth.actor,
				proxy: _proxy,
				producers: _producers
			},
		});

		if (!voteOnly) {