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