How to use the @0xcert/ethereum-generic-provider.Mutation function in @0xcert/ethereum-generic-provider

To help you get started, we’ve selected a few @0xcert/ethereum-generic-provider 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-ethereum-order-gateway / src / mutations / perform.ts View on Github external
let functionSignature = '0x8b1d8335'; // perform
  if (order.takerId === zeroAddress) {
    functionSignature = '0x04aa2cb7'; // performAnyTaker
  }
  const recipeTuple = createRecipeTuple(gateway, order);
  const signatureTuple = createSignatureTuple(claim);
  const attrs = {
    from: gateway.provider.accountId,
    to: gateway.id,
    data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple, signatureTuple]).substr(2),
  };
  const res = await gateway.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(gateway.provider, res.result);
}
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);
}
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-asset-ledger / src / mutations / approve-account.ts View on Github external
export default async function(ledger: AssetLedger, accountId: string, assetId: string) {
  const attrs = {
    from: ledger.provider.accountId,
    to: ledger.id,
    data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, assetId]).substr(2),
  };
  const res = await ledger.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(ledger.provider, res.result, ledger);
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / mutations / asset-ledger-deploy-order / cancel.ts View on Github external
export default async function(gateway: Gateway, order: AssetLedgerDeployOrder) {
  const recipeTuple = createRecipeTuple(order);
  const attrs = {
    from: gateway.provider.accountId,
    to: gateway.config.assetLedgerDeployOrderId,
    data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
  };
  const res = await gateway.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(gateway.provider, res.result, gateway);
}
github 0xcert / framework / packages / 0xcert-ethereum-value-ledger / src / mutations / approve-account.ts View on Github external
export default async function(ledger: ValueLedger, accountId: string, value: string) {
  const attrs = {
    from: ledger.provider.accountId,
    to: ledger.id,
    data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, value]).substr(2),
  };
  const res = await ledger.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(ledger.provider, res.result, ledger);
}
github 0xcert / framework / packages / 0xcert-ethereum-asset-ledger / src / mutations / revoke-asset.ts View on Github external
export default async function(ledger: AssetLedger, assetId: string) {
  const attrs = {
    from: ledger.provider.accountId,
    to: ledger.id,
    data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [assetId]).substr(2),
  };
  const res = await ledger.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(ledger.provider, res.result, ledger);
}
github 0xcert / framework / packages / 0xcert-ethereum-asset-ledger / src / mutations / grant-abilities.ts View on Github external
export default async function(ledger: AssetLedger, accountId: string, abilities: string) {
  const attrs = {
    from: ledger.provider.accountId,
    to: ledger.id,
    data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, abilities]).substr(2),
  };
  const res = await ledger.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(ledger.provider, res.result, ledger);
}
github 0xcert / framework / packages / 0xcert-ethereum-asset-ledger / src / mutations / safe-transfer.ts View on Github external
const inputTypes = ['address', 'address', 'uint256'];
  if (typeof receiverData !== 'undefined') {
    inputTypes.push('bytes');
  }
  const data = [senderId, receiverId, id, receiverData]
    .filter((a) => typeof a !== 'undefined');
  const attrs = {
    from: ledger.provider.accountId,
    to: ledger.id,
    data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, data).substr(2),
  };
  const res = await ledger.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(ledger.provider, res.result, ledger);
}
github 0xcert / framework / packages / 0xcert-ethereum-gateway / src / mutations / value-ledger-deploy-order / cancel.ts View on Github external
export default async function(gateway: Gateway, order: ValueLedgerDeployOrder) {
  const recipeTuple = createRecipeTuple(order);
  const attrs = {
    from: gateway.provider.accountId,
    to: gateway.config.valueLedgerDeployOrderId,
    data: functionSignature + gateway.provider.encoder.encodeParameters(inputTypes, [recipeTuple]).substr(2),
  };
  const res = await gateway.provider.post({
    method: 'eth_sendTransaction',
    params: [attrs],
  });
  return new Mutation(gateway.provider, res.result, gateway);
}