Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(tokenGrantKycTransaction): Implement TokenGrantKycTransaction E2E tests: TCK #300

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .prettierrc
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,3 @@
"arrowParens": "always",
"endOfLine": "lf"
}

38 changes: 19 additions & 19 deletions docs/test-specifications/token-service/TokenGrantKycTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,19 @@ The tests contained in this specification will assume that a valid account and a

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------|-------------------|
| 1 | Grants KYC of a token to an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token grants KYC to the account. | N |
| 2 | Grants KYC of a token that doesn't exist to an account | tokenId="123.456.789", accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an INVALID_TOKEN_ID response code from the network. | N |
| 3 | Grants KYC of a token with an empty token ID to an account | tokenId="", accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an SDK internal error. | N |
| 4 | Grants KYC of a token with no token ID to an account | accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an INVALID_TOKEN_ID response code from the network. | N |
| 5 | Grants KYC of a deleted token to an account | tokenId=<DELETED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<DELETED_TOKEN_KYC_KEY>] | The token KYC grant fails with an TOKEN_WAS_DELETED response code from the network. | N |
| 6 | Grants KYC of a token to an account without signing with the token's KYC key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an INVALID_SIGNATURE response code from the network. | N |
| 7 | Grants KYC of a token to an account but signs with the the token's admin key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_ADMIN_KEY>] | The token KYC grant fails with an INVALID_SIGNATURE response code from the network. | N |
| 8 | Grants KYC of a token to an account but signs with an incorrect private key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<INCORRECT_VALID_PRIVATE_KEY>] | The token KYC grant fails with an INVALID_SIGNATURE response code from the network. | N |
| 9 | Grants KYC of a token with no KYC key to an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an TOKEN_HAS_NO_KYC_KEY response code from the network. | N |
| 10 | Grants KYC of a token to an account that already has KYC | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token grants KYC to the account. | N |
| 11 | Grants KYC of a token to an account that is not associated with the token | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an TOKEN_NOT_ASSOCIATED_TO_ACCOUNT response code from the network. | N |
| 12 | Grants KYC of a paused token to an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an TOKEN_IS_PAUSED response code from the network. | N |
| 13 | Grants KYC of a token to a frozen account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an ACCOUNT_FROZEN_FOR_TOKEN response code from the network. | N |
| 1 | Grants KYC of a token to an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token grants KYC to the account. | Y |
| 2 | Grants KYC of a token that doesn't exist to an account | tokenId="123.456.789", accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an INVALID_TOKEN_ID response code from the network. | Y |
| 3 | Grants KYC of a token with an empty token ID to an account | tokenId="", accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an SDK internal error. | Y |
| 4 | Grants KYC of a token with no token ID to an account | accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an INVALID_TOKEN_ID response code from the network. | Y |
| 5 | Grants KYC of a deleted token to an account | tokenId=<DELETED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<DELETED_TOKEN_KYC_KEY>] | The token KYC grant fails with an TOKEN_WAS_DELETED response code from the network. | Y |
| 6 | Grants KYC of a token to an account without signing with the token's KYC key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an INVALID_SIGNATURE response code from the network. | Y |
| 7 | Grants KYC of a token to an account but signs with the the token's admin key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_ADMIN_KEY>] | The token KYC grant fails with an INVALID_SIGNATURE response code from the network. | Y |
| 8 | Grants KYC of a token to an account but signs with an incorrect private key | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<INCORRECT_VALID_PRIVATE_KEY>] | The token KYC grant fails with an INVALID_SIGNATURE response code from the network. | Y |
| 9 | Grants KYC of a token with no KYC key to an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID> | The token KYC grant fails with an TOKEN_HAS_NO_KYC_KEY response code from the network. | Y |
| 10 | Grants KYC of a token to an account that already has KYC | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token grants KYC to the account. | Y |
| 11 | Grants KYC of a token to an account that is not associated with the token | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an TOKEN_NOT_ASSOCIATED_TO_ACCOUNT response code from the network. | Y |
| 12 | Grants KYC of a paused token to an account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an TOKEN_IS_PAUSED response code from the network. | Y |
| 13 | Grants KYC of a token to a frozen account | tokenId=<CREATED_TOKEN_ID>, accountId=<CREATED_ACCOUNT_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an ACCOUNT_FROZEN_FOR_TOKEN response code from the network. | Y |

#### JSON Request Example

Expand Down Expand Up @@ -103,12 +103,12 @@ The tests contained in this specification will assume that a valid account and a

- The ID of the account to which to grant KYC.

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|---------------------------------------------------------------------------------------|-------------------|
| 1 | Grants KYC of a token to an account that doesn't exist | tokenId=<CREATED_TOKEN_ID>, accountId="123.456.789", commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an INVALID_ACCOUNT_ID response code from the network. | N |
| 2 | Grants KYC of a token to an empty account ID | tokenId=<CREATED_TOKEN_ID>, accountId="", commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an SDK internal error. | N |
| 3 | Grants KYC of a token to an account with no account ID | tokenId=<CREATED_TOKEN_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an INVALID_ACCOUNT_ID response code from the network. | N |
| 4 | Grants KYC of a token to a deleted account | tokenId=<CREATED_TOKEN_ID>, accountId=<DELETED_ACCOUNT_ID>, commonTransactionParams.signers=[<DELETED_TOKEN_KYC_KEY>] | The token KYC grant fails with an ACCOUNT_WAS_DELETED response code from the network. | N |
| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|--------------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------|-------------------|
| 1 | Grants KYC of a token to an account that doesn't exist | tokenId=<CREATED_TOKEN_ID>, accountId="123.456.789", commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an INVALID_ACCOUNT_ID response code from the network. | Y |
| 2 | Grants KYC of a token to an empty account ID | tokenId=<CREATED_TOKEN_ID>, accountId="", commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an SDK internal error. | Y |
| 3 | Grants KYC of a token to an account with no account ID | tokenId=<CREATED_TOKEN_ID>, commonTransactionParams.signers=[<CREATED_TOKEN_KYC_KEY>] | The token KYC grant fails with an INVALID_ACCOUNT_ID response code from the network. | Y |
| 4 | Grants KYC of a token to a deleted account | tokenId=<CREATED_TOKEN_ID>, accountId=<DELETED_ACCOUNT_ID>, commonTransactionParams.signers=[<DELETED_TOKEN_KYC_KEY>] | The token KYC grant fails with an ACCOUNT_DELETED response code from the network. | Y |

#### JSON Request Example

Expand Down
6 changes: 6 additions & 0 deletions src/services/MirrorNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,12 @@ class MirrorNodeClient {
const url = `${this.mirrorNodeRestUrl}/api/v1/tokens/${tokenId}`;
return retryOnError(async () => fetchData(url));
}

// TODO: Get mirror node interface with OpenAPI
async getTokenRelationships(accountId: string): Promise<any> {
const url = `${this.mirrorNodeRestUrl}/api/v1/accounts/${accountId}/tokens`;
return retryOnError(async () => fetchData(url));
}
}

export default new MirrorNodeClient();
Loading