-
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。
- 返回:
- 返回值示例:
[
{
"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。
- 返回:
- 返回值示例:
{
"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。
- 返回:
- 返回值示例:
{
"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。
- 返回:
- 返回值示例:
{
"assetType": "oaccountStatus",
"statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "deleted"
}