-
GetAccountStatus
- 이 메소드는 토큰 계정의 현재 상태를 가져옵니다. 이 메소드는 체인 코드의
Token Admin
또는 토큰 계정 소유자가 호출할 수 있습니다.
-
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
}
- 매개변수:
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
또는 토큰 계정 소유자가 호출할 수 있습니다.
-
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
}
- 매개변수:
orgId: string
- 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
userId: string
- 사용자의 사용자 이름 또는 전자메일 ID입니다.
tokenId ...string
- 사용할 수 없는 토큰 계정의 경우 빈 문자열입니다. 대체 가능 토큰 계정의 경우 토큰 ID입니다.
- 반환값:
- 성공 시 JSON 형식의 계정 상태 기록입니다.
- 반환 값 예제:
[
{
"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
- 이 메소드는 토큰 계정을 활성화합니다. 이 메소드는 체인 코드의
Token Admin
로만 호출할 수 있습니다. 삭제된 계정은 활성화할 수 없습니다. 계정 상태 기능을 사용할 수 있기 전에 생성된 계정의 경우 이 메소드를 호출하여 계정 상태를 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)
}
- 매개변수:
orgId: string
- 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
userId: string
- 사용자의 사용자 이름 또는 전자메일 ID입니다.
tokenId ...string
- 사용할 수 없는 토큰 계정의 경우 빈 문자열입니다. 대체 가능 토큰 계정의 경우 토큰 ID입니다.
- 반환값:
- 성공 시 토큰 계정 상태의 JSON 표현입니다.
- 반환 값 예제:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "active"
}
-
SuspendAccount
- 이 메소드는 토큰 계정을 일시 중지합니다. 이 메소드는 체인 코드의
Token Admin
로만 호출할 수 있습니다. 계정이 일시 중지된 후에는 계정 업데이트 작업을 완료할 수 없습니다. 삭제된 계정은 일시 중지할 수 없습니다.
-
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)
}
- 매개변수:
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이어야 합니다.
-
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)
}
- 매개변수:
orgId: string
- 현재 조직에 있는 사용자의 멤버쉽 서비스 제공자(MSP) ID입니다.
userId: string
- 사용자의 사용자 이름 또는 전자메일 ID입니다.
tokenId ...string
- 사용할 수 없는 토큰 계정의 경우 빈 문자열입니다. 대체 가능 토큰 계정의 경우 토큰 ID입니다.
- 반환값:
- 성공 시 토큰 계정 상태의 JSON 표현입니다.
- 반환 값 예제:
{
"AssetType": "oaccountStatus",
"StatusId": "oaccountStatus~5a0b0d8b1c6433af9fedfe0d9e6580e7cf6b6bb62a0de6267aaf79f79d5e96d7",
"AccountId": "oaccount~1c568151c4acbcd1bd265c766c677145760a61c47fc8a3ba681a4cfbe287f9c1",
"Status": "deleted"
}