ERC-721トークン・アカウント・ステータスのTypeScriptメソッド

ブロックチェーン・アプリケーション・ビルダーは、拡張ERC-721標準を使用するトークンのアカウント・ステータスを管理するために使用できるメソッドを自動的に生成します。

次の方法を使用して、トークン・ユーザー・アカウントをアクティブ、一時停止または削除された状態に設定できます。

アカウントが一時停止されると、アカウント・ユーザーは書込み操作を完了できません。これには、トークンのマイニング、書込みおよび転送が含まれます。また、他のユーザーはトークンを中断されたアカウントに転送できません。中断されたアカウントは、引き続き読取り操作を完了できます。

トークン残高がゼロ以外のアカウントは削除できません。アカウントを削除する前に、アカウント内のすべてのトークンを転送または書き込む必要があります。アカウントが削除済状態になると、アカウントの状態をアクティブまたは一時停止に戻すことはできません。

自動生成された勘定科目ステータス方法

getAccountStatus
このメソッドは、トークン・アカウントの現在のステータスを取得します。このメソッドは、チェーンコードのToken Adminまたはトークン・アカウント所有者によってコールできます。
@Validator(yup.string(), yup.string())
     public async getAccountStatus(orgId: string, userId: string) {
       const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
       await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.get", "TOKEN", { accountId });
       try {
         return await this.Ctx.ERC721AccountStatus.getAccountStatus(accountId);
       } catch (err) {
        return await this.Ctx.ERC721AccountStatus.getDefaultAccountStatus(accountId);
       }
     }
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。アカウント・ステータス機能が使用可能になる前にアカウントが作成されたためにアカウントの元帳にステータスが見つからない場合、ステータスはレスポンスでactiveとしてリストされます。
戻り値の例:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "active"
}
getAccountStatusHistory
このメソッドは、アカウント・ステータスの履歴を取得します。このメソッドは、チェーンコードのToken Adminまたはトークン・アカウント所有者によってコールできます。
public async getAccountStatusHistory(orgId: string, userId: string) {
       const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
       await this.Ctx.ERC721Account.getAccount(accountId);
       await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.history", "TOKEN", { accountId });
       const status_id = await this.Ctx.ERC721AccountStatus.generateAccountStatusId(accountId);
       let accountStatusHistory: any;
       try {
         accountStatusHistory = await this.Ctx.ERC721AccountStatus.history(status_id);
       } catch (err) {
         return [];
       }
       return accountStatusHistory;
     }
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功すると、JSON形式のアカウント・ステータス履歴が表示されます。
戻り値の例:
[
  {
    "trxId": "d5c6d6f601257ba9b6edaf5b7660f00adc13c37d5321b8f7d3a35afab2e93e63",
    "timeStamp": "2022-12-02T10:39:14.000Z",
    "value": {
      "assetType": "oaccountStatus",
      "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
      "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "status": "suspended"
    }
  },
  {
    "trxId": "e6c850cfa084dc20ad95fb2bb8165eef3a3bd62a0ac867cccee57c2003125183",
    "timeStamp": "2022-12-02T10:37:50.000Z",
    "value": {
      "assetType": "oaccountStatus",
      "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
      "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "status": "active"
    }
  }
]
activateAccount
このメソッドは、トークン・アカウントをアクティブ化します。このメソッドは、チェーンコードのToken Adminによってのみコールできます。削除されたアカウントはアクティブ化できません。アカウント・ステータス機能が使用可能になる前に作成されたアカウントの場合は、このメソッドをコールして、アカウント・ステータスをactiveに設定する必要があります。
@Validator(yup.string(), yup.string())
 public async activateAccount(orgId: string, userId: string) {
   await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.activateAccount", "TOKEN");
   const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
   return await this.Ctx.ERC721Account.activateAccount(accountId);
 }
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。
戻り値の例:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "active"
}
suspendAccount
このメソッドは、トークン・アカウントを一時停止します。このメソッドは、チェーンコードのToken Adminによってのみコールできます。アカウントが一時停止された後は、アカウントを更新する操作を完了できません。削除されたアカウントは一時停止できません。
@Validator(yup.string(), yup.string())
 public async suspendAccount(orgId: string, userId: string) {
   await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.suspendAccount", "TOKEN");
   const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
   return await this.Ctx.ERC721Account.suspendAccount(accountId);
 }
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。
戻り値の例:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "suspended"
}
deleteAccount
このメソッドはトークン・アカウントを削除します。このメソッドは、チェーンコードのToken Adminによってのみコールできます。アカウントの削除後は、アカウントを更新する操作を完了できません。削除されたアカウントは最終状態であり、他の状態に変更できません。勘定科目を削除するには、勘定科目残高がゼロである必要があります。
@Validator(yup.string(), yup.string())
 public async deleteAccount(orgId: string, userId: string) {
   await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.deleteAccount", "TOKEN");
   const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
   return await this.Ctx.ERC721Account.deleteAccount(accountId);
 }
パラメータ:
  • orgId: string - 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
  • userId: string - ユーザーのユーザー名または電子メールID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。
戻り値の例:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "deleted"
}

アカウント・ステータスSDKメソッド

getAccountStatus
このメソッドは、トークン・アカウントの現在のステータスを取得します。
Ctx.ERC721AccountStatus.getAccountStatus(accountId: string)
パラメータ:
  • accountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、トークン・アカウント・ステータスのJSON表現。アカウント・ステータス機能が使用可能になる前にアカウントが作成されたためにアカウントの元帳にステータスが見つからない場合、ステータスはレスポンスでactiveとしてリストされます。
戻り値の例:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "active"
}
getAccountStatusHistory
このメソッドは、アカウント・ステータスの履歴を取得します。
Ctx.ERC721AccountStatus.history(statusId: string)
パラメータ:
  • statusId: string - アカウント・ステータス・オブジェクトのID。
戻り値:
  • 成功した場合、アカウント・ステータス履歴のJSON表現。
戻り値の例:
[
  {
    "trxId": "d5c6d6f601257ba9b6edaf5b7660f00adc13c37d5321b8f7d3a35afab2e93e63",
    "timeStamp": "2022-12-02T10:39:14.000Z",
    "value": {
      "assetType": "oaccountStatus",
      "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
      "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "status": "suspended"
    }
  },
  {
    "trxId": "e6c850cfa084dc20ad95fb2bb8165eef3a3bd62a0ac867cccee57c2003125183",
    "timeStamp": "2022-12-02T10:37:50.000Z",
    "value": {
      "assetType": "oaccountStatus",
      "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
      "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
      "status": "active"
    }
  }
]
activateAccount
このメソッドは、トークン・アカウントをアクティブ化します。アカウント・ステータス機能が使用可能になる前に作成されたアカウントの場合は、このメソッドをコールして、アカウント・ステータスをactiveに設定する必要があります。
Ctx.ERC721Account.activateAccount(accountId: string)
パラメータ:
  • accountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
戻り値の例:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "active"
}
suspendAccount
このメソッドは、トークン・アカウントを一時停止します。
Ctx.ERC721AccountStatus.suspendAccount(accountId: string)
パラメータ:
  • accountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
戻り値の例:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "suspended"
}
deleteAccount
このメソッドはトークン・アカウントを削除します。
Ctx.ERC721Account.deleteAccount(accountId: string)
パラメータ:
  • accountId: string - トークン・アカウントのID。
戻り値:
  • 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
戻り値の例:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "deleted"
}