TypeScript ERC-721 토큰 계정 상태에 대한 메소드

Blockchain App Builder는 확장된 ERC-721 표준을 사용하는 토큰의 계정 상태를 관리하는 데 사용할 수 있는 방법을 자동으로 생성합니다.

다음 방법을 사용하여 토큰 사용자 계정을 활성, 일시 중지됨 또는 삭제됨 상태로 설정할 수 있습니다.

계정이 일시 중지되면 계정 사용자는 조폐, 연소, 토큰 전송 등의 쓰기 작업을 완료할 수 없습니다. 또한 다른 사용자는 토큰을 일시 중지된 계정으로 전송할 수 없습니다. 일시 중지된 계정은 여전히 읽기 작업을 완료할 수 있습니다.

토큰 잔액이 0이 아닌 계정은 삭제할 수 없습니다. 계정을 삭제하려면 계정의 모든 토큰을 이전하거나 레코딩해야 합니다. 계정이 삭제된 상태이면 계정 상태를 다시 활성 또는 일시 중지됨으로 변경할 수 없습니다.

자동으로 생성된 계정 상태 방법

getAccountStatus
이 메소드는 토큰 계정의 현재 상태를 가져옵니다. 이 메소드는 체인 코드의 Token Admin 또는 토큰 계정 소유자가 호출할 수 있습니다.
@Validator(yup.string(), yup.string())
     public async getAccountStatus(orgId: string, userId: string) {
       const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
       await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.get", "TOKEN", { accountId });
       try {
         return await this.Ctx.ERC721AccountStatus.getAccountStatus(accountId);
       } catch (err) {
        return await this.Ctx.ERC721AccountStatus.getDefaultAccountStatus(accountId);
       }
     }
매개변수:
  • orgId: string – 현재 조직에 있는 사용자의 멤버쉽 서비스 공급자(MSP) ID입니다.
  • userId: string – 사용자의 사용자 이름 또는 전자 메일 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다. 계정 상태 기능을 사용할 수 있기 전에 계정이 생성되었으므로 계정에 대한 원장에서 상태를 찾을 수 없는 경우 상태는 응답에 active로 나열됩니다.
반환 값 예:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "active"
}
getAccountStatusHistory
이 방법은 계정 상태의 기록을 가져옵니다. 이 메소드는 체인 코드의 Token Admin 또는 토큰 계정 소유자가 호출할 수 있습니다.
public async getAccountStatusHistory(orgId: string, userId: string) {
       const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
       await this.Ctx.ERC721Account.getAccount(accountId);
       await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.history", "TOKEN", { accountId });
       const status_id = await this.Ctx.ERC721AccountStatus.generateAccountStatusId(accountId);
       let accountStatusHistory: any;
       try {
         accountStatusHistory = await this.Ctx.ERC721AccountStatus.history(status_id);
       } catch (err) {
         return [];
       }
       return accountStatusHistory;
     }
매개변수:
  • orgId: string – 현재 조직에 있는 사용자의 멤버쉽 서비스 공급자(MSP) ID입니다.
  • userId: string – 사용자의 사용자 이름 또는 전자 메일 ID입니다.
반환값:
  • 성공 시 계정 상태 기록은 JSON 형식입니다.
반환 값 예:
[
  {
    "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
이 메소드는 토큰 계정을 활성화합니다. 이 메소드는 체인 코드의 Token Admin만 호출할 수 있습니다. 삭제된 계정은 활성화할 수 없습니다. 계정 상태 기능을 사용할 수 있기 전에 생성된 계정의 경우 이 메소드를 호출하여 계정 상태를 active로 설정해야 합니다.
@Validator(yup.string(), yup.string())
 public async activateAccount(orgId: string, userId: string) {
   await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.activateAccount", "TOKEN");
   const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
   return await this.Ctx.ERC721Account.activateAccount(accountId);
 }
매개변수:
  • orgId: string – 현재 조직에 있는 사용자의 멤버쉽 서비스 공급자(MSP) ID입니다.
  • userId: string – 사용자의 사용자 이름 또는 전자 메일 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다.
반환 값 예:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "active"
}
suspendAccount
이 메소드는 토큰 계정을 일시 중지합니다. 이 메소드는 체인 코드의 Token Admin만 호출할 수 있습니다. 계정이 일시 중지된 후에는 계정 업데이트 작업을 완료할 수 없습니다. 삭제된 계정은 일시 중지할 수 없습니다.
@Validator(yup.string(), yup.string())
 public async suspendAccount(orgId: string, userId: string) {
   await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.suspendAccount", "TOKEN");
   const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
   return await this.Ctx.ERC721Account.suspendAccount(accountId);
 }
매개변수:
  • orgId: string – 현재 조직에 있는 사용자의 멤버쉽 서비스 공급자(MSP) ID입니다.
  • userId: string – 사용자의 사용자 이름 또는 전자 메일 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다.
반환 값 예:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "suspended"
}
deleteAccount
이 메소드는 토큰 계정을 삭제합니다. 이 메소드는 체인 코드의 Token Admin만 호출할 수 있습니다. 계정이 삭제된 후에는 계정을 업데이트하는 작업을 완료할 수 없습니다. 삭제된 계정은 최종 상태이며 다른 상태로 변경할 수 없습니다. 계정을 삭제하려면 계정 잔액이 0이어야 합니다.
@Validator(yup.string(), yup.string())
 public async deleteAccount(orgId: string, userId: string) {
   await this.Ctx.ERC721Auth.checkAuthorization("ERC721ACCOUNT_STATUS.deleteAccount", "TOKEN");
   const accountId = await this.Ctx.ERC721Account.generateAccountId(orgId, userId);
   return await this.Ctx.ERC721Account.deleteAccount(accountId);
 }
매개변수:
  • orgId: string – 현재 조직에 있는 사용자의 멤버쉽 서비스 공급자(MSP) ID입니다.
  • userId: string – 사용자의 사용자 이름 또는 전자 메일 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다.
반환 값 예:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "deleted"
}

계정 상태 SDK 방법

getAccountStatus
이 메소드는 토큰 계정의 현재 상태를 가져옵니다.
Ctx.ERC721AccountStatus.getAccountStatus(accountId: string)
매개변수:
  • accountId: string – 토큰 계정의 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다. 계정 상태 기능을 사용할 수 있기 전에 계정이 생성되었으므로 계정에 대한 원장에서 상태를 찾을 수 없는 경우 상태는 응답에 active로 나열됩니다.
반환 값 예:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "active"
}
getAccountStatusHistory
이 방법은 계정 상태의 기록을 가져옵니다.
Ctx.ERC721AccountStatus.history(statusId: string)
매개변수:
  • statusId: string – 계정 상태 객체의 ID입니다.
반환값:
  • 성공 시 계정 상태 기록의 JSON 표현입니다.
반환 값 예제:
[
  {
    "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
이 메소드는 토큰 계정을 활성화합니다. 계정 상태 기능을 사용할 수 있기 전에 생성된 계정의 경우 이 메소드를 호출하여 계정 상태를 active로 설정해야 합니다.
Ctx.ERC721Account.activateAccount(accountId: string)
매개변수:
  • accountId: string – 토큰 계정의 ID입니다.
반환값:
  • 성공 시 지정된 토큰 계정에 대한 계정 상태 객체의 JSON 표현입니다.
반환 값 예제:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "active"
}
suspendAccount
이 메소드는 토큰 계정을 일시 중지합니다.
Ctx.ERC721AccountStatus.suspendAccount(accountId: string)
매개변수:
  • accountId: string – 토큰 계정의 ID입니다.
반환값:
  • 성공 시 지정된 토큰 계정에 대한 계정 상태 객체의 JSON 표현입니다.
반환 값 예제:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "suspended"
}
deleteAccount
이 메소드는 토큰 계정을 삭제합니다.
Ctx.ERC721Account.deleteAccount(accountId: string)
매개변수:
  • accountId: string – 토큰 계정의 ID입니다.
반환값:
  • 성공 시 지정된 토큰 계정에 대한 계정 상태 객체의 JSON 표현입니다.
반환 값 예제:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "deleted"
}