-
GetAccountStatus
- 此方法會取得權杖帳戶的目前狀態。鏈碼的
Token Admin
或記號帳戶擁有者可以呼叫此方法。
-
func (t *Controller) GetAccountStatus(orgId string, userId string, tokenId ...string) (interface{}, error) {
userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.Get", "TOKEN", map[string]string{"accountId": userAccountId})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
if err != nil {
return nil, fmt.Errorf("error in GetAccountStatus. Error: %s", err)
}
tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
accountStatus, err := t.Ctx.ERC1155AccountStatus.GetAccountStatus(tokenAccountId)
if err != nil {
return t.Ctx.ERC1155AccountStatus.GetDefaultAccountStatus(tokenAccountId)
}
return accountStatus, nil
}
- 參數:
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
或記號帳戶擁有者可以呼叫此方法。
-
func (t *Controller) GetAccountStatusHistory(orgId string, userId string, tokenId ...string) (interface{}, error) {
userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.Get", "TOKEN", map[string]string{"accountId": userAccountId})
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
if err != nil {
return nil, fmt.Errorf("error in GetAccountStatusHistory. Error: %s", err)
}
tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
statusId, err := t.Ctx.ERC1155AccountStatus.GenerateAccountStatusId(tokenAccountId)
if err != nil {
return nil, err
}
accountStatusHistory, err := t.Ctx.ERC1155AccountStatus.History(statusId)
if err != nil {
return []map[string]interface{}{}, nil
}
return accountStatusHistory, nil
}
- 參數:
orgId: string
- 目前組織中使用者的成員服務提供者 (MSP) ID。
userId: string
- 使用者的使用者名稱或電子郵件 ID。
tokenId ...string
- 若為非工具權杖帳戶,則為空白字串。如果是有趣的權杖帳戶,則是權杖 ID。
- 傳回值:
- 傳回值範例:
[
{
"IsDelete": "false",
"Timestamp": "2022-12-02T16:20:34+05:30",
"TxId": "af1601c7a14b4becf4bb3b285d85553b39bf234caaf1cd488a284a31a2d9df78",
"Value": {
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"AssetType": "oaccountStatus",
"Status": "suspended",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
}
},
{
"IsDelete": "false",
"Timestamp": "2022-12-02T16:19:15+05:30",
"TxId": "4b307b989063e43add5357ab110e19174d586b9746cc8a30c9aa3a2b0b48a34e",
"Value": {
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"AssetType": "oaccountStatus",
"Status": "active",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7"
}
}
]
-
ActivateAccount
- 此方法會啟用權杖帳戶。鏈碼的
Token Admin
只能呼叫此方法。無法啟用已刪除的帳戶。對於在帳戶狀態功能可用之前所建立的任何帳戶,您必須呼叫此方法,將帳戶狀態設為 active
。
-
func (t *Controller) ActivateAccount(orgId string, userId string, tokenId ...string) (interface{}, error) {
userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.ActivateAccount", "TOKEN")
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
if err != nil {
return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
}
tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
return t.Ctx.ERC1155Account.ActivateAccount(tokenAccountId)
}
- 參數:
orgId: string
- 目前組織中使用者的成員服務提供者 (MSP) ID。
userId: string
- 使用者的使用者名稱或電子郵件 ID。
tokenId ...string
- 若為非工具權杖帳戶,則為空白字串。如果是有趣的權杖帳戶,則是權杖 ID。
- 傳回值:
- 傳回值範例:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
SuspendAccount
- 此方法會暫停權杖帳戶。鏈碼的
Token Admin
只能呼叫此方法。帳戶暫停後,您便無法完成任何更新帳戶的作業。無法暫停已刪除的帳戶。
-
func (t *Controller) SuspendAccount(orgId string, userId string, tokenId ...string) (interface{}, error) {
userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.SuspendAccount", "TOKEN")
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
if err != nil {
return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
}
tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
return t.Ctx.ERC1155Account.SuspendAccount(tokenAccountId)
}
- 參數:
orgId: string
- 目前組織中使用者的成員服務提供者 (MSP) ID。
userId: string
- 使用者的使用者名稱或電子郵件 ID。
tokenId ...string
- 若為非工具權杖帳戶,則為空白字串。如果是有趣的權杖帳戶,則是權杖 ID。
- 傳回值:
- 傳回值範例:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "suspended"
}
-
DeleteAccount
- 此方法會刪除記號帳戶。鏈碼的
Token Admin
只能呼叫此方法。刪除帳戶後,您便無法完成任何更新帳戶的作業。刪除的帳戶處於最終狀態,無法變更為任何其他狀態。若要刪除帳戶,帳戶餘額必須為零。
-
func (t *Controller) DeleteAccount(orgId string, userId string, tokenId ...string) (interface{}, error) {
userAccountId, err := t.Ctx.ERC1155Account.GenerateAccountId(orgId, userId, constants.UserAccount)
if err != nil {
return nil, fmt.Errorf("error in getting the generating accountId of (Org-Id: %s, User-Id: %s)", orgId, userId)
}
auth, err := t.Ctx.ERC1155Auth.CheckAuthorization("ERC1155AccountStatus.DeleteAccount", "TOKEN")
if err != nil && !auth {
return nil, fmt.Errorf("error in authorizing the caller %s", err.Error())
}
tokenAccount, err := t.Ctx.ERC1155Account.Get(userAccountId, tokenId...)
if err != nil {
return nil, fmt.Errorf("error in GetAccountTransactionHistory. Error: %s", err)
}
tokenAccountId, err := util.GetAccountProperty(tokenAccount, constants.AccountId)
return t.Ctx.ERC1155Account.DeleteAccount(tokenAccountId)
}
- 參數:
orgId: string
- 目前組織中使用者的成員服務提供者 (MSP) ID。
userId: string
- 使用者的使用者名稱或電子郵件 ID。
tokenId ...string
- 若為非工具權杖帳戶,則為空白字串。如果是有趣的權杖帳戶,則是權杖 ID。
- 傳回值:
- 傳回值範例:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "deleted"
}