-
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.
-
@Validator(yup.string(), yup.string(), yup.string())
public async getAccountStatus(orgId: string, userId: string, tokenId ?: string) {
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.get", "TOKEN", { accountId: tokenAccount.accountId });
try {
return await this.Ctx.ERC1155AccountStatus.getAccountStatus(tokenAccount.accountId);
} catch (err) {
return await this.Ctx.ERC1155AccountStatus.getDefaultAccountStatus(tokenAccount.accountId);
}
}
- 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.
-
public async getAccountStatusHistory(orgId: string, userId: string, tokenId ?: string) {
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.history", "TOKEN", { accountId: tokenAccount.accountId });
const status_id = await this.Ctx.ERC1155AccountStatus.generateAccountStatusId(tokenAccount.accountId);
let accountStatusHistory: any;
try {
accountStatusHistory = await this.Ctx.ERC1155AccountStatus.history(status_id);
} catch (err) {
return [];
}
return accountStatusHistory;
}
- 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 :
[
{
"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
- 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
.
-
@Validator(yup.string(), yup.string(), yup.string())
public async activateAccount(orgId: string, userId: string, tokenId ?: string) {
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.activateAccount", "TOKEN");
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
return await this.Ctx.ERC1155Account.activateAccount(tokenAccount.accountId);
}
- 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.
-
@Validator(yup.string(), yup.string(), yup.string())
public async suspendAccount(orgId: string, userId: string, tokenId ?: string) {
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.suspendAccount", "TOKEN");
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
return await this.Ctx.ERC1155Account.suspendAccount(tokenAccount.accountId);
}
- 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.
-
@Validator(yup.string(), yup.string(), yup.string())
public async deleteAccount(orgId: string, userId: string, tokenId ?: string) {
await this.Ctx.ERC1155Auth.checkAuthorization("ERC1155ACCOUNT_STATUS.deleteAccount", "TOKEN");
const userAccountId = this.Ctx.ERC1155Account.generateAccountId(orgId, userId, ACCOUNT_TYPE.USER_ACCOUNT);
let tokenAccount = await this.Ctx.ERC1155Account.getAccount(userAccountId, tokenId);
return await this.Ctx.ERC1155Account.deleteAccount(tokenAccount.accountId);
}
- 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"
}