-
GetAccountStatus
- Questo metodo recupera lo stato corrente dell'account token. Questo metodo può essere chiamato dal
Token Admin
del codice concatenato o dal proprietario dell'account token.
-
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
}
- Parametri:
orgId: string
: l'ID del provider di servizi di appartenenza (MSP) dell'utente nell'organizzazione corrente.
userId: string
: il nome utente o l'ID e-mail dell'utente.
tokenId ...string
: per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
- Restituisce:
- In caso di operazione riuscita, una rappresentazione JSON dello stato dell'account token. Se non viene trovato alcuno stato nel libro contabile per il conto perché il conto è stato creato prima che la funzionalità di stato del conto fosse disponibile, lo stato viene elencato come
active
nella risposta.
- Esempio di valore restituito:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
GetAccountStatusHistory
- Questo metodo recupera la cronologia dello stato dell'account. Questo metodo può essere chiamato dal
Token Admin
del codice concatenato o dal proprietario dell'account token.
-
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
}
- Parametri:
orgId: string
: l'ID del provider di servizi di appartenenza (MSP) dell'utente nell'organizzazione corrente.
userId: string
: il nome utente o l'ID e-mail dell'utente.
tokenId ...string
: per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
- Restituisce:
- In caso di operazione riuscita, la cronologia dello stato dell'account in formato JSON.
- Esempio di valore restituito:
[
{
"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
- Questo metodo attiva un account token. Questo metodo può essere richiamato solo da un
Token Admin
del codice concatenato. Impossibile attivare gli account eliminati. Per tutti i conti creati prima della disponibilità della funzionalità di stato del conto, è necessario chiamare questo metodo per impostare lo stato del conto su 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)
}
- Parametri:
orgId: string
: l'ID del provider di servizi di appartenenza (MSP) dell'utente nell'organizzazione corrente.
userId: string
: il nome utente o l'ID e-mail dell'utente.
tokenId ...string
: per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
- Restituisce:
- In caso di operazione riuscita, una rappresentazione JSON dello stato dell'account token.
- Esempio di valore restituito:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
SuspendAccount
- Questo metodo sospende un account token. Questo metodo può essere richiamato solo da un
Token Admin
del codice concatenato. Dopo la sospensione di un conto, non è possibile completare le operazioni che lo aggiornano. Impossibile sospendere un account eliminato.
-
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)
}
- Parametri:
orgId: string
: l'ID del provider di servizi di appartenenza (MSP) dell'utente nell'organizzazione corrente.
userId: string
: il nome utente o l'ID e-mail dell'utente.
tokenId ...string
: per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
- Restituisce:
- In caso di operazione riuscita, una rappresentazione JSON dello stato dell'account token.
- Esempio di valore restituito:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "suspended"
}
-
DeleteAccount
- Questo metodo elimina un account token. Questo metodo può essere richiamato solo da un
Token Admin
del codice concatenato. Dopo l'eliminazione di un account, non è possibile completare le operazioni che lo aggiornano. L'account eliminato è in uno stato finale e non può essere modificato in nessun altro stato. Per eliminare un conto, il saldo del conto deve essere zero.
-
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)
}
- Parametri:
orgId: string
: l'ID del provider di servizi di appartenenza (MSP) dell'utente nell'organizzazione corrente.
userId: string
: il nome utente o l'ID e-mail dell'utente.
tokenId ...string
: per un account token non fungibile, una stringa vuota. Per un account token fungibile, l'ID token.
- Restituisce:
- In caso di operazione riuscita, una rappresentazione JSON dello stato dell'account token.
- Esempio di valore restituito:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "deleted"
}