-
GetAccountStatus
- Cette méthode obtient le statut courant du compte de jeton. Cette méthode peut être appelée par la chaîne
Token Admin
du code de chaîne ou par le responsable du compte de jeton.
-
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
}
- Paramètres :
orgId: string
- ID fournisseur de services d'adhésion (MSP) de l'utilisateur dans l'organisation courante.
userId: string
- Nom d'utilisateur ou ID courriel de l'utilisateur.
tokenId ...string
- Pour un compte de jeton non fongible, une chaîne vide. Pour un compte de jeton fongible, l'ID jeton.
- Retourne :
- En cas de succès, une représentation JSON du statut du compte de jeton. Si aucun statut n'est trouvé dans le livre pour le compte, car le compte a été créé avant que la fonctionnalité de statut de compte ne soit disponible, le statut est
active
dans la réponse.
- Exemple de valeur renvoyée :
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
GetAccountStatusHistory
- Cette méthode permet d'obtenir l'historique du statut du compte. Cette méthode peut être appelée par la chaîne
Token Admin
du code de chaîne ou par le responsable du compte de jeton.
-
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
}
- Paramètres :
orgId: string
- ID fournisseur de services d'adhésion (MSP) de l'utilisateur dans l'organisation courante.
userId: string
- Nom d'utilisateur ou ID courriel de l'utilisateur.
tokenId ...string
- Pour un compte de jeton non fongible, une chaîne vide. Pour un compte de jeton fongible, l'ID jeton.
- Retourne :
- En cas de succès, l'historique des statuts de compte au format JSON.
- Exemple de valeur renvoyée :
[
{
"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
- Cette méthode active un compte de jeton. Cette méthode ne peut être appelée que par un élément
Token Admin
du code de chaîne. Les comptes supprimés ne peuvent pas être activés. Pour tous les comptes créés avant que la fonctionnalité de statut de compte ne soit disponible, vous devez appeler cette méthode pour régler le statut du compte à 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)
}
- Paramètres :
orgId: string
- ID fournisseur de services d'adhésion (MSP) de l'utilisateur dans l'organisation courante.
userId: string
- Nom d'utilisateur ou ID courriel de l'utilisateur.
tokenId ...string
- Pour un compte de jeton non fongible, une chaîne vide. Pour un compte de jeton fongible, l'ID jeton.
- Retourne :
- En cas de succès, une représentation JSON du statut du compte de jeton.
- Exemple de valeur renvoyée :
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
SuspendAccount
- Cette méthode suspend un compte de jeton. Cette méthode ne peut être appelée que par un élément
Token Admin
du code de chaîne. Une fois qu'un compte est suspendu, vous ne pouvez pas effectuer d'opérations qui mettent à jour le compte. Un compte supprimé ne peut pas être suspendu.
-
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)
}
- Paramètres :
orgId: string
- ID fournisseur de services d'adhésion (MSP) de l'utilisateur dans l'organisation courante.
userId: string
- Nom d'utilisateur ou ID courriel de l'utilisateur.
tokenId ...string
- Pour un compte de jeton non fongible, une chaîne vide. Pour un compte de jeton fongible, l'ID jeton.
- Retourne :
- En cas de succès, une représentation JSON du statut du compte de jeton.
- Exemple de valeur renvoyée :
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "suspended"
}
-
DeleteAccount
- Cette méthode supprime un compte de jeton. Cette méthode ne peut être appelée que par un élément
Token Admin
du code de chaîne. Une fois qu'un compte est supprimé, vous ne pouvez pas effectuer d'opérations qui mettent à jour le compte. Le compte supprimé est à l'état final et ne peut pas être remplacé par un autre état. Pour supprimer un compte, le solde doit être égal à zéro.
-
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)
}
- Paramètres :
orgId: string
- ID fournisseur de services d'adhésion (MSP) de l'utilisateur dans l'organisation courante.
userId: string
- Nom d'utilisateur ou ID courriel de l'utilisateur.
tokenId ...string
- Pour un compte de jeton non fongible, une chaîne vide. Pour un compte de jeton fongible, l'ID jeton.
- Retourne :
- En cas de succès, une représentation JSON du statut du compte de jeton.
- Exemple de valeur renvoyée :
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "deleted"
}