Getting mosaic global restrictions attached to a mosaic

Get the list of mosaic global restrictions.

Prerequisites

Method #01: Using the SDK

// replace with mosaic id
const mosaicIdHex = '634a8ac3fc2b65b3';
const mosaicId = new MosaicId(mosaicIdHex);
// replace with node endpoint
const nodeUrl = 'http://api-01.us-east-1.096x.symboldev.network:3000';
const repositoryFactory = new RepositoryFactoryHttp(nodeUrl);
const restrictionHttp = repositoryFactory.createRestrictionMosaicRepository();

restrictionHttp.getMosaicGlobalRestriction(mosaicId)
    .subscribe((mosaicGlobalRestrictions) => {
        if (mosaicGlobalRestrictions.restrictions.size > 0) {
            console.log('Key\t', 'Reference MosaicId\t', 'Restriction Type\t', 'Restriction Value');
            mosaicGlobalRestrictions.restrictions.forEach((value: MosaicGlobalRestrictionItem, key: string) => {
                console.log('\n' + key + '\t', value.referenceMosaicId.toHex() +
                    '\t', MosaicRestrictionType[value.restrictionType] +
                    '\t', value.restrictionValue);
            });
        } else {
            console.log('\n The mosaic does not have mosaic global restrictions assigned.');
        }
    }, (err) => console.log(err));
// replace with mosaic id
const mosaicIdHex = '634a8ac3fc2b65b3';
const mosaicId = new symbol_sdk_1.MosaicId(mosaicIdHex);
// replace with node endpoint
const nodeUrl = 'http://api-01.us-east-1.096x.symboldev.network:3000';
const repositoryFactory = new symbol_sdk_1.RepositoryFactoryHttp(nodeUrl);
const restrictionHttp = repositoryFactory.createRestrictionMosaicRepository();
restrictionHttp.getMosaicGlobalRestriction(mosaicId)
    .subscribe((mosaicGlobalRestrictions) => {
    if (mosaicGlobalRestrictions.restrictions.size > 0) {
        console.log('Key\t', 'Reference MosaicId\t', 'Restriction Type\t', 'Restriction Value');
        mosaicGlobalRestrictions.restrictions.forEach((value, key) => {
            console.log('\n' + key + '\t', value.referenceMosaicId.toHex() +
                '\t', symbol_sdk_1.MosaicRestrictionType[value.restrictionType] +
                '\t', value.restrictionValue);
        });
    }
    else {
        console.log('\n The mosaic does not have mosaic global restrictions assigned.');
    }
}, (err) => console.log(err));
        // replace with node endpoint
        try (final RepositoryFactory repositoryFactory = new RepositoryFactoryVertxImpl(
                "http://api-01.us-east-1.096x.symboldev.network:3000")) {
            final RestrictionMosaicRepository restrictionRepository = repositoryFactory
                    .createRestrictionMosaicRepository();

            // replace with mosaicId
            final String mosaicIdHex = "634a8ac3fc2b65b3";
            final MosaicId mosaicId = new MosaicId(mosaicIdHex);

            final List<MosaicGlobalRestriction> restrictions = restrictionRepository
                    .getMosaicGlobalRestrictions(Collections.singletonList(mosaicId))
                    .toFuture().get();
            final JsonHelper helper = new JsonHelperJackson2();
            System.out.println(helper.prettyPrint(restrictions));
        }

Method #02: Using the CLI

symbol-cli restriction mosaicglobal --mosaic-id 634a8ac3fc2b65b3