How to use the eosjs/dist/eosjs-jssig.JsSignatureProvider 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 EOSIO / demux-js-eos / src / v1.7 / readers / state-history / StateHistoryPostgresBlock.ts View on Github external
import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig'
import fetch from 'node-fetch'
import { TextDecoder, TextEncoder } from 'util'
import { EosAction, TransactionActions } from '../../interfaces'
import { StateHistoryPostgresAbiProvider } from './StateHistoryPostgresAbiProvider'

// Wrapper to deal with differences between the definitions of fetch for the browser built-in
// and the node-fetch polyfill for node
// Is there a better way to do this?
const fetchWrapper = (input?: string | Request, init?: RequestInit): Promise => {
  const anyInput = input as any
  const anyInit = init as any
  return fetch(anyInput, anyInit) as any
}

const signatureProvider = new JsSignatureProvider([])
const rpc = new JsonRpc('', { fetch: fetchWrapper } )
const abiProvider = new StateHistoryPostgresAbiProvider()
const api = new Api({
  rpc,
  abiProvider,
  signatureProvider,
  textDecoder: new TextDecoder(),
  textEncoder: new TextEncoder()
})

const getApi = (blockNumber: number, massiveInstance: any, dbSchema: string, log: Logger) => {
  const instanceAbiProvider = api.abiProvider as StateHistoryPostgresAbiProvider
  instanceAbiProvider.setState(blockNumber, massiveInstance, dbSchema, log)
  return api
}
github eosrio / simpleos / src / app / dashboard / vote / vote.component.ts View on Github external
const [auth, publicKey] = this.trxFactory.getAuth();
		// check current votes
		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
			},
		});
github EOSIO / demux-js-eos / src / v1.8 / readers / state-history / StateHistoryPostgresBlock.ts View on Github external
import { JsSignatureProvider } from 'eosjs/dist/eosjs-jssig'
import fetch from 'node-fetch'
import { TextDecoder, TextEncoder } from 'util'
import { EosAction, TransactionActions } from '../../'
import { StateHistoryPostgresAbiProvider } from './StateHistoryPostgresAbiProvider'

// Wrapper to deal with differences between the definitions of fetch for the browser built-in
// and the node-fetch polyfill for node
// Is there a better way to do this?
const fetchWrapper = (input?: string | Request, init?: RequestInit): Promise => {
  const anyInput = input as any
  const anyInit = init as any
  return fetch(anyInput, anyInit) as any
}

const signatureProvider = new JsSignatureProvider([])
const rpc = new JsonRpc('', { fetch: fetchWrapper } )
const abiProvider = new StateHistoryPostgresAbiProvider()
const api = new Api({
  rpc,
  abiProvider,
  signatureProvider,
  textDecoder: new TextDecoder(),
  textEncoder: new TextEncoder()
})

const getApi = (blockNumber: number, massiveInstance: any, dbSchema: string, log: Logger) => {
  const instanceAbiProvider = api.abiProvider as StateHistoryPostgresAbiProvider
  instanceAbiProvider.setState(blockNumber, massiveInstance, dbSchema, log)
  return api
}
github eosrio / simpleos / index.js View on Github external
async function claimGBM(account_name, private_key, permission, rpc) {
	const signatureProvider = new JsSignatureProvider([private_key]);
	const api = new Api({rpc, signatureProvider, textDecoder: TextDec, textEncoder: TextEnc});
	// check current votes
	const accountData = await rpc.get_account(account_name);
	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'];
		}
	}
github eosrio / simpleos / src / app / services / eosjs2.service.ts View on Github external
initAPI(key) {
		this.JsSigProvider = new JsSignatureProvider ( [ key ] );
		this.api = new Api ( {
			rpc: this.rpc ,
			signatureProvider: this.JsSigProvider ,
			textDecoder: new TextDecoder () ,
			textEncoder: new TextEncoder ()
		} );
		setTimeout ( () => {
			this.JsSigProvider = null;
			this.api = null;
		} , 5000 );
	}
github infiniteXLabs / infeos / utils / eosio_utils / EOSJS_Instance.js View on Github external
function createInstance(args) {
        let endpoint = args[0];
        let privateKeys = args[1];

        let signatureProvider = new JsSignatureProvider(privateKeys);

        let rpc = new JsonRpc(endpoint, { fetch });
        let EOSApi = new Api({ rpc, signatureProvider, textDecoder: new TextDecoder(), textEncoder: new TextEncoder() });
        
        return {
            EOSApi: EOSApi,
            EOSRpc: rpc,
            RpcError: RpcError,
            Serialize: Serialize,
            JsSignatureProvider: JsSignatureProvider
        };
    }
github EOSIO / eosio-reference-chrome-extension-authenticator-app / src / utils / Api.ts View on Github external
public decodeAbis(abis: HexAbi[]): AbiInfo[] {
    const signatureProvider = new JsSignatureProvider([])
    const api = new EosApi({
      rpc: this.rpc,
      signatureProvider,
      chainId: null,
      abiProvider: this.abiProvider,
    })
    return abis.map(({ abi, ...rest }) => {
      const uInt8Abi = Serialize.hexToUint8Array(abi)
      return { abi: api.rawAbiToJson(uInt8Abi), ...rest }
    })
  }
}
github EOSIO / eosio-reference-chrome-extension-authenticator-app / src / utils / manifest / AssertActionCreator.ts View on Github external
constructor() {
    const rpc = new JsonRpc(null)
    const signatureProvider = new JsSignatureProvider([])
    this.api = new EosApi({
      rpc,
      signatureProvider,
      chainId: null,
    })

    this.api.transactionTypes = Serialize.getTypesFromAbi(Serialize.createInitialTypes(), assertAbi)
  }