モザイクにアタッチされたグローバルモザイク制限を取得する

モザイクのグローバル制限リストの取得

前提条件

方法 #01: 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.testnet.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.testnet.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.testnet.symboldev.network:3000")) {
            final RestrictionMosaicRepository restrictionRepository = repositoryFactory
                    .createRestrictionMosaicRepository();

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

            MosaicRestrictionSearchCriteria criteria = new MosaicRestrictionSearchCriteria()
                .mosaicId(mosaicId);

            List<MosaicGlobalRestriction> restrictions = MosaicRestrictionPaginationStreamer
                .global(restrictionRepository, criteria).toList().toFuture().get();

            final JsonHelper helper = new JsonHelperJackson2();
            System.out.println(helper.prettyPrint(restrictions));
        }

方法 #02: CLI を使用する

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