How to use the @0xcert/scaffold.AssetLedgerCapability.DESTROY_ASSET function in @0xcert/scaffold

To help you get started, we’ve selected a few @0xcert/scaffold 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-asset-ledger / src / queries / get-capabilities.ts View on Github external
export default async function(ledger: AssetLedger) {
  return Promise.all(
    [ AssetLedgerCapability.DESTROY_ASSET,
      AssetLedgerCapability.REVOKE_ASSET,
      AssetLedgerCapability.TOGGLE_TRANSFERS,
      AssetLedgerCapability.UPDATE_ASSET,
    ].map(async (capability) => {
      const code = getInterfaceCode(capability);
      const attrs = {
        to: ledger.id,
        data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [code]).substr(2),
      };
      const res = await ledger.provider.post({
        method: 'eth_call',
        params: [attrs, 'latest'],
      });
      return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0] ? capability : -1;
    }),
  ).then((abilities) => {
github 0xcert / framework / packages / 0xcert-ethereum-asset-ledger / src / lib / capabilities.ts View on Github external
export function getInterfaceCode(capability: AssetLedgerCapability): string {
    if (capability == AssetLedgerCapability.DESTROY_ASSET) {
        return '0x9d118770';
    } else if (capability == AssetLedgerCapability.REVOKE_ASSET) {
        return '0x20c5429b';
    } else if (capability == AssetLedgerCapability.UPDATE_ASSET) {
      return '0xbda0e852';
    }  else if (capability == AssetLedgerCapability.TOGGLE_TRANSFERS) {
        return '0xbedb86fb';
    } else {
        return null;
    }
}