-
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"
}