-
getAccountStatus
- このメソッドは、トークン・アカウントの現在のステータスを取得します。このメソッドは、チェーンコードの
Token Admin
、指定された組織のOrg Admin
、またはトークン・アカウント所有者によってコールできます。この方法では、新しいバージョンにアップグレードされる既存のチェーンコードのデータ移行もサポートされます。
-
@Validator(yup.string(), yup.string(), yup.string())
public async getAccountStatus(token_id: string, org_id: string, user_id: string) {
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
await this.Ctx.Auth.checkAuthorization("ACCOUNT_STATUS.get", "TOKEN", { account_id });
try {
return await this.Ctx.AccountStatus.getAccountStatus(account_id);
} catch (err) {
return await this.Ctx.AccountStatus.getDefaultAccountStatus(account_id);
}
}
- パラメータ:
token_id: string
- トークンのID。
org_id: string
- 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
user_id: string
- ユーザーのユーザー名または電子メールID。
- 戻り値:
- 成功時に、トークン・アカウント・ステータスの詳細を含むメッセージ。
- 戻り値の例:
{
"assetType": "oaccountStatus",
"status_id": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"account_id": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "active"
}
-
getAccountStatusHistory
- このメソッドは、アカウント・ステータスの履歴を取得します。このメソッドは、チェーンコードの
Token Admin
、指定された組織のOrg Admin
、またはトークン・アカウント所有者によってコールできます。
-
@Validator(yup.string(), yup.string(), yup.string())
public async getAccountStatusHistory(token_id: string, org_id: string, user_id: string) {
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
await this.Ctx.Account.getAccount(account_id);
await this.Ctx.Auth.checkAuthorization("ACCOUNT_STATUS.history", "TOKEN", { account_id });
const status_id = await this.Ctx.AccountStatus.generateAccountStatusId(account_id);
let account_status_history: any;
try {
account_status_history = await this.Ctx.AccountStatus.history(status_id);
} catch (err) {
return [];
}
return account_status_history;
}
- パラメータ:
token_id: string
- トークンのID。
org_id: string
- 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
user_id: string
- ユーザーのユーザー名または電子メールID。
- 戻り値:
- 成功時に、アカウント・ステータス履歴の詳細を含むメッセージ。
- 戻り値の例:
[
{
"trxId": "d5c6d6f601257ba9b6edaf5b7660f00adc13c37d5321b8f7d3a35afab2e93e63",
"timeStamp": "2022-12-02T10:39:14.000Z",
"value": {
"assetType": "oaccountStatus",
"status_id": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"account_id": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "suspended"
}
},
{
"trxId": "e6c850cfa084dc20ad95fb2bb8165eef3a3bd62a0ac867cccee57c2003125183",
"timeStamp": "2022-12-02T10:37:50.000Z",
"value": {
"assetType": "oaccountStatus",
"status_id": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"account_id": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "active"
}
}
]
-
activateAccount
- このメソッドは、トークン・アカウントをアクティブ化します。このメソッドは、チェーンコードの
Token Admin
または指定された組織のOrg Admin
によってのみコールできます。削除されたアカウントはアクティブ化できません。
-
@Validator(yup.string(), yup.string(), yup.string())
public async activateAccount(token_id: string, org_id: string, user_id: string) {
await this.Ctx.Auth.checkAuthorization("ACCOUNT_STATUS.activateAccount", "TOKEN", { org_id });
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
return await this.Ctx.Account.activateAccount(account_id);
}
- パラメータ:
token_id: string
- トークンのID。
org_id: string
- 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
user_id: string
- ユーザーのユーザー名または電子メールID。
- 戻り値:
- 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
- 戻り値の例:
{
"assetType": "oaccountStatus",
"status_id": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"account_id": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "active"
}
-
suspendAccount
- このメソッドは、トークン・アカウントを一時停止します。このメソッドは、チェーンコードの
Token Admin
または指定された組織のOrg Admin
によってのみコールできます。アカウントが一時停止された後は、アカウントを更新する操作を完了できません。削除されたアカウントは一時停止できません。
-
@Validator(yup.string(), yup.string(), yup.string())
public async suspendAccount(token_id: string, org_id: string, user_id: string) {
await this.Ctx.Auth.checkAuthorization("ACCOUNT_STATUS.suspendAccount", "TOKEN", { org_id });
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
return await this.Ctx.Account.suspendAccount(account_id);
}
- パラメータ:
token_id: string
- トークンのID。
org_id: string
- 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
user_id: string
- ユーザーのユーザー名または電子メールID。
- 戻り値:
- 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
- 戻り値の例:
{
"assetType": "oaccountStatus",
"status_id": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"account_id": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "suspended"
}
-
deleteAccount
- このメソッドはトークン・アカウントを削除します。このメソッドは、チェーンコードの
Token Admin
または指定された組織のOrg Admin
によってのみコールできます。アカウントの削除後は、アカウントを更新する操作を完了できません。削除されたアカウントは最終状態であり、他の状態に変更できません。勘定科目を削除するには、勘定科目残高と保留残高がゼロである必要があります。
-
@Validator(yup.string(), yup.string(), yup.string())
public async deleteAccount(token_id: string, org_id: string, user_id: string) {
await this.Ctx.Auth.checkAuthorization("ACCOUNT_STATUS.deleteAccount", "TOKEN", { org_id });
const account_id = await this.Ctx.Account.generateAccountId(token_id, org_id, user_id);
return await this.Ctx.Account.deleteAccount(account_id);
}
- パラメータ:
token_id: string
- トークンのID。
org_id: string
- 現在の組織内のユーザーのメンバーシップ・サービス・プロバイダ(MSP) ID。
user_id: string
- ユーザーのユーザー名または電子メールID。
- 戻り値:
- 成功すると、指定したトークン・アカウントのアカウント・ステータス・オブジェクトのJSON表現。
- 戻り値の例:
{
"assetType": "oaccountStatus",
"status_id": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"account_id": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "deleted"
}