-
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。
- 傳回值:
- 傳回值範例:
[
{
"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"
}