How to use the @0xcert/scaffold.GeneralAssetLedgerAbility.ALLOW_CREATE_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-abilities.ts View on Github external
export default async function(ledger: AssetLedger, accountId: string) {
  return Promise.all(
    [ SuperAssetLedgerAbility.MANAGE_ABILITIES,
      GeneralAssetLedgerAbility.CREATE_ASSET,
      GeneralAssetLedgerAbility.REVOKE_ASSET,
      GeneralAssetLedgerAbility.TOGGLE_TRANSFERS,
      GeneralAssetLedgerAbility.UPDATE_ASSET,
      GeneralAssetLedgerAbility.ALLOW_CREATE_ASSET,
      GeneralAssetLedgerAbility.UPDATE_URI_BASE,
      GeneralAssetLedgerAbility.ALLOW_UPDATE_ASSET_IMPRINT,
    ].map(async (ability) => {
      const attrs = {
        to: ledger.id,
        data: functionSignature + ledger.provider.encoder.encodeParameters(inputTypes, [accountId, ability]).substr(2),
      };
      const res = await ledger.provider.post({
        method: 'eth_call',
        params: [attrs, 'latest'],
      });
      return ledger.provider.encoder.decodeParameters(outputTypes, res.result)[0] ? ability : -1;
    }),
  ).then((abilities) => {
    return abilities.filter((a) => a !== -1).sort((a, b) => a - b);
  }).catch(() => {