How to use the @0xcert/utils.fetchJson function in @0xcert/utils

To help you get started, we’ve selected a few @0xcert/utils 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 0xcert / framework / packages / 0xcert-wanchain-http-provider / src / core / provider.ts View on Github external
public send(data: any, callback: (err, data) => any) {

    const { url, ...options } = {
      url: 'http://localhost:8545',
      ...this._options,
    };

    return fetchJson(url, {
      ...options,
      method: 'POST',
      body: JSON.stringify(data),
      headers: {'Content-Type': 'application/json' },
    }).then((res) => {
      return res;
    }).then((res) => {
      return callback(null, res);
    }).catch((err) => {
      return callback(err, null);
    });
  }
github 0xcert / framework / packages / 0xcert-ethereum-asset-ledger / src / mutations / deploy.ts View on Github external
export default async function(provider: GenericProvider, { name, symbol, uriPrefix, uriPostfix, schemaId, capabilities }: AssetLedgerDeployRecipe) {
  const contract = await fetchJson(provider.assetLedgerSource);
  const source = contract.XcertMock.evm.bytecode.object;
  const codes = (capabilities || []).map((c) => getInterfaceCode(c));
  const attrs = {
    from: provider.accountId,
    data: `0x${source}${provider.encoder.encodeParameters(inputTypes, [name, symbol, uriPrefix, uriPostfix, schemaId, codes]).substr(2)}`,
  };
  const res = await provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(provider, res.result);
}
github 0xcert / framework / packages / 0xcert-ethereum-http-provider / src / core / provider.ts View on Github external
public send(data: any, callback: (err, data) => any) {

    const { url, ...options } = {
      url: 'http://localhost:8545',
      ...this._options,
    };

    return fetchJson(url, {
      ...options,
      method: 'POST',
      body: JSON.stringify(data),
      headers: {'Content-Type': 'application/json' },
    }).then((res) => {
      return res;
    }).then((res) => {
      return callback(null, res);
    }).catch((err) => {
      return callback(err, null);
    });
  }
github 0xcert / framework / packages / 0xcert-ethereum-value-ledger / src / mutations / deploy.ts View on Github external
export default async function(provider: GenericProvider, { name, symbol, decimals, supply }: ValueLedgerDeployRecipe) {
  const contract = await fetchJson(provider.valueLedgerSource);
  const source = contract.TokenMock.evm.bytecode.object;
  const attrs = {
    from: provider.accountId,
    data: `0x${source}${provider.encoder.encodeParameters(inputTypes, [ name, symbol, decimals, supply]).substr(2)}`,
  };
  const res = await provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(provider, res.result);
}

@0xcert/utils

General utility module with common helper functions.

MIT
Latest version published 3 years ago

Package Health Score

48 / 100
Full package analysis