-
getAccountStatus
- 此方法获取令牌帐户的当前状态。此方法可由链代码的
Token Admin
或令牌帐户所有者调用。
-
@Validator(yup.string(), yup.string(), yup.string())
public async getAccountStatus(orgId: string, userId: string, tokenId ?: string) {
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.get", "TOKEN", { accountId: tokenAccount.accountId });
try {
return await this.Ctx.ERC1155AccountStatus.getAccountStatus(tokenAccount.accountId);
} catch (err) {
return await this.Ctx.ERC1155AccountStatus.getDefaultAccountStatus(tokenAccount.accountId);
}
}
- 参数:
orgId: string
- 当前组织中用户的成员服务提供者 (MSP) ID。
userId: string
- 用户的用户名或电子邮件 ID。
tokenId ?: string
- 对于不可替代的令牌帐户,为空字符串。对于可替换标记帐户,标记 ID。
- 返回:
- 成功后,将以 JSON 表示标记账户状态。如果在分类账中找不到账户的状态,因为该账户是在账户状态功能可用之前创建的,则该状态在响应中将列为
active
。
- 返回值示例:
{
"assetType": "oaccountStatus",
"statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "active"
}
-
getAccountStatusHistory
- 此方法获取帐户状态的历史记录。此方法可由链代码的
Token Admin
或令牌帐户所有者调用。
-
public async getAccountStatusHistory(orgId: string, userId: string, tokenId ?: string) {
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.history", "TOKEN", { accountId: tokenAccount.accountId });
const status_id = await this.Ctx.ERC1155AccountStatus.generateAccountStatusId(tokenAccount.accountId);
let accountStatusHistory: any;
try {
accountStatusHistory = await this.Ctx.ERC1155AccountStatus.history(status_id);
} catch (err) {
return [];
}
return accountStatusHistory;
}
- 参数:
orgId: string
- 当前组织中用户的成员服务提供者 (MSP) ID。
userId: string
- 用户的用户名或电子邮件 ID。
tokenId ?: 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(), yup.string())
public async activateAccount(orgId: string, userId: string, tokenId ?: string) {
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.activateAccount", "TOKEN");
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
return await this.Ctx.ERC1155Account.activateAccount(tokenAccount.accountId);
}
- 参数:
orgId: string
- 当前组织中用户的成员服务提供者 (MSP) ID。
userId: string
- 用户的用户名或电子邮件 ID。
tokenId ?: string
- 对于不可替代的令牌帐户,为空字符串。对于可替换标记帐户,标记 ID。
- 返回:
- 返回值示例:
{
"assetType": "oaccountStatus",
"statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "active"
}
-
suspendAccount
- 此方法暂停令牌帐户。此方法只能由链代码的
Token Admin
调用。账户暂停后,您将无法完成任何更新账户的操作。已删除的账户无法挂起。
-
@Validator(yup.string(), yup.string(), yup.string())
public async suspendAccount(orgId: string, userId: string, tokenId ?: string) {
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.suspendAccount", "TOKEN");
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
return await this.Ctx.ERC1155Account.suspendAccount(tokenAccount.accountId);
}
- 参数:
orgId: string
- 当前组织中用户的成员服务提供者 (MSP) ID。
userId: string
- 用户的用户名或电子邮件 ID。
tokenId ?: string
- 对于不可替代的令牌帐户,为空字符串。对于可替换标记帐户,标记 ID。
- 返回:
- 返回值示例:
{
"assetType": "oaccountStatus",
"statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "suspended"
}
-
deleteAccount
- 此方法删除令牌帐户。此方法只能由链代码的
Token Admin
调用。在删除帐户后,您无法完成任何更新帐户的操作。已删除的账户处于最终状态,无法更改为任何其他状态。要删除帐户,帐户余额必须为零。
-
@Validator(yup.string(), yup.string(), yup.string())
public async deleteAccount(orgId: string, userId: string, tokenId ?: string) {
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.deleteAccount", "TOKEN");
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
return await this.Ctx.ERC1155Account.deleteAccount(tokenAccount.accountId);
}
- 参数:
orgId: string
- 当前组织中用户的成员服务提供者 (MSP) ID。
userId: string
- 用户的用户名或电子邮件 ID。
tokenId ?: string
- 对于不可替代的令牌帐户,为空字符串。对于可替换标记帐户,标记 ID。
- 返回:
- 返回值示例:
{
"assetType": "oaccountStatus",
"statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"status": "deleted"
}