-
GetAccountStatus
- Diese Methode ruft den aktuellen Status des Token-Accounts ab. Diese Methode kann von der
Token Admin
des Chaincodes oder vom Tokenkontoinhaber aufgerufen werden.
-
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
}
- Parameter:
orgId: string
: Die Mitgliedsdienstanbieter-(MSP-)ID des Benutzers in der aktuellen Organisation.
userId: string
: Der Benutzername oder die E-Mail-ID des Benutzers.
tokenId ...string
: Für ein nicht fungierbares Tokenkonto eine leere Zeichenfolge. Für ein fungibles Tokenkonto die Token-ID.
- Rückgabewert:
- Bei Erfolg eine JSON-Darstellung des Tokenaccountstatus. Wenn im Buch für das Konto kein Status gefunden wird, weil das Konto erstellt wurde, bevor die Funktion für den Kontostatus verfügbar war, wird der Status in der Antwort als
active
aufgeführt.
- Beispiel für Rückgabewert:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
GetAccountStatusHistory
- Diese Methode ruft die Historie des Kontostatus ab. Diese Methode kann von der
Token Admin
des Chaincodes oder vom Tokenkontoinhaber aufgerufen werden.
-
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
}
- Parameter:
orgId: string
: Die Mitgliedsdienstanbieter-(MSP-)ID des Benutzers in der aktuellen Organisation.
userId: string
: Der Benutzername oder die E-Mail-ID des Benutzers.
tokenId ...string
: Für ein nicht fungierbares Tokenkonto eine leere Zeichenfolge. Für ein fungibles Tokenkonto die Token-ID.
- Rückgabewert:
- Bei Erfolg die Accountstatushistorie im JSON-Format.
- Beispiel für Rückgabewert:
[
{
"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
- Mit dieser Methode wird ein Token-Account aktiviert. Diese Methode kann nur von einem
Token Admin
des Chaincodes aufgerufen werden. Gelöschte Accounts können nicht aktiviert werden. Wenn Accounts, die vor der Accountstatusfunktion erstellt wurden, verfügbar sind, müssen Sie diese Methode aufrufen, um den Accountstatus auf active
zu setzen.
-
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)
}
- Parameter:
orgId: string
: Die Mitgliedsdienstanbieter-(MSP-)ID des Benutzers in der aktuellen Organisation.
userId: string
: Der Benutzername oder die E-Mail-ID des Benutzers.
tokenId ...string
: Für ein nicht fungierbares Tokenkonto eine leere Zeichenfolge. Für ein fungibles Tokenkonto die Token-ID.
- Rückgabewert:
- Bei Erfolg eine JSON-Darstellung des Tokenaccountstatus.
- Beispiel für Rückgabewert:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
SuspendAccount
- Mit dieser Methode wird ein Token-Account unterbrochen. Diese Methode kann nur von einem
Token Admin
des Chaincodes aufgerufen werden. Nachdem ein Konto ausgesetzt wurde, können Sie keine Vorgänge ausführen, die das Konto aktualisieren. Ein gelöschter Account kann nicht ausgesetzt werden.
-
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)
}
- Parameter:
orgId: string
: Die Mitgliedsdienstanbieter-(MSP-)ID des Benutzers in der aktuellen Organisation.
userId: string
: Der Benutzername oder die E-Mail-ID des Benutzers.
tokenId ...string
: Für ein nicht fungierbares Tokenkonto eine leere Zeichenfolge. Für ein fungibles Tokenkonto die Token-ID.
- Rückgabewert:
- Bei Erfolg eine JSON-Darstellung des Tokenaccountstatus.
- Beispiel für Rückgabewert:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "suspended"
}
-
DeleteAccount
- Mit dieser Methode wird ein Token-Account gelöscht. Diese Methode kann nur von einem
Token Admin
des Chaincodes aufgerufen werden. Nachdem ein Konto gelöscht wurde, können Sie keine Vorgänge abschließen, die das Konto aktualisieren. Das gelöschte Konto befindet sich in einem endgültigen Status und kann nicht in einen anderen Status geändert werden. Um ein Konto zu löschen, muss der Kontensaldo Null sein.
-
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)
}
- Parameter:
orgId: string
: Die Mitgliedsdienstanbieter-(MSP-)ID des Benutzers in der aktuellen Organisation.
userId: string
: Der Benutzername oder die E-Mail-ID des Benutzers.
tokenId ...string
: Für ein nicht fungierbares Tokenkonto eine leere Zeichenfolge. Für ein fungibles Tokenkonto die Token-ID.
- Rückgabewert:
- Bei Erfolg eine JSON-Darstellung des Tokenaccountstatus.
- Beispiel für Rückgabewert:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "deleted"
}