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

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

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

계정이 일시 중지되면 계정 사용자는 알림, 레코딩 및 전송 토큰을 포함하는 쓰기 작업을 완료할 수 없습니다. 또한 다른 사용자는 일시 중지된 계정으로 토큰을 전송할 수 없습니다. 일시 중지된 계정은 여전히 읽기 작업을 완료할 수 있습니다.

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

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

getAccountStatus
이 메소드는 토큰 계정의 현재 상태를 가져옵니다. 이 메소드는 체인 코드의 Token Admin 또는 토큰 계정 소유자가 호출할 수 있습니다.
@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);
    }
  }
매개변수:
  • orgId: string - 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
  • userId: string - 사용자의 사용자 이름 또는 전자메일 ID입니다.
  • tokenId ?: string - 사용할 수 없는 토큰 계정의 경우 빈 문자열입니다. 대체 가능 토큰 계정의 경우 토큰 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다. 계정 상태 기능을 사용할 수 있기 전에 계정이 생성되었으므로 계정에 대한 원장에서 상태를 찾을 수 없는 경우 응답에 상태가 active로 나열됩니다.
반환 값 예제:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "active"
}
getAccountStatusHistory
이 방법은 계정 상태 기록을 가져옵니다. 이 메소드는 체인 코드의 Token Admin 또는 토큰 계정 소유자가 호출할 수 있습니다.
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;
  }
매개변수:
  • orgId: string - 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
  • userId: string - 사용자의 사용자 이름 또는 전자메일 ID입니다.
  • tokenId ?: 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(), 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);
}
매개변수:
  • orgId: string - 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
  • userId: string - 사용자의 사용자 이름 또는 전자메일 ID입니다.
  • tokenId ?: string - 사용할 수 없는 토큰 계정의 경우 빈 문자열입니다. 대체 가능 토큰 계정의 경우 토큰 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다.
반환 값 예제:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "active"
}
suspendAccount
이 메소드는 토큰 계정을 일시 중지합니다. 이 메소드는 체인 코드의 Token Admin로만 호출할 수 있습니다. 계정이 일시 중지된 후에는 계정 업데이트 작업을 완료할 수 없습니다. 삭제된 계정은 일시 중지할 수 없습니다.
@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);
}
매개변수:
  • orgId: string - 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
  • userId: string - 사용자의 사용자 이름 또는 전자메일 ID입니다.
  • tokenId ?: string - 사용할 수 없는 토큰 계정의 경우 빈 문자열입니다. 대체 가능 토큰 계정의 경우 토큰 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다.
반환 값 예제:
{
    "assetType": "oaccountStatus",
    "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
    "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
    "status": "suspended"
}
deleteAccount
이 메소드는 토큰 계정을 삭제합니다. 이 메소드는 체인 코드의 Token Admin로만 호출할 수 있습니다. 계정이 삭제된 후에는 계정 업데이트 작업을 완료할 수 없습니다. 삭제된 계정은 최종 상태이므로 다른 상태로 변경할 수 없습니다. 계정을 삭제하려면 계정 잔액이 0이어야 합니다.
@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);
}
매개변수:
  • orgId: string - 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
  • userId: string - 사용자의 사용자 이름 또는 전자메일 ID입니다.
  • tokenId ?: string - 사용할 수 없는 토큰 계정의 경우 빈 문자열입니다. 대체 가능 토큰 계정의 경우 토큰 ID입니다.
반환값:
  • 성공 시 토큰 계정 상태의 JSON 표현입니다.
반환 값 예제:
{
  "assetType": "oaccountStatus",
  "statusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
  "accountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
  "status": "deleted"
}

계정 상태 SDK 방법

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