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(tokenBurnTransaction): Implement TokenBurnTransaction E2E tests: TCK #311

Merged
merged 10 commits into from
Jan 10, 2025
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"
}

22 changes: 11 additions & 11 deletions docs/test-specifications/token-service/TokenBurnTransaction.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ https://docs.hedera.com/hedera/sdks-and-apis/rest-api

### Additional Notes

The tests contained in this specification will assume that a valid fungible token and a valid non-fungible token have already successfully created. The fungible token will have an initial supply of 9,223,372,036,854,775,807 (int64 max) and the non-fungible token will have three minted. <CREATED_FUNGIBLE_TOKEN_ID> will denote the ID of the created fungible token, <CREATED_FUNGIBLE_TOKEN_SUPPLY_KEY> will denote the supply key of the created fungible token as a DER-encoded hex string, and <CREATED_FUNGIBLE_TOKEN_ADMIN_KEY> will denote the admin key of the created fungible token as a DER-encoded hex string. <CREATED_NON_FUNGIBLE_TOKEN_ID> will denote the ID of the created non-fungible token, <CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY> will denote the supply key of the created non-fungible token as a DER-encoded hex string, and <CREATED_NON_FUNGIBLE_TOKEN_ADMIN_KEY> will denote the admin key of the created non-fungible token as a DER-encoded hex string. <NFT_SERIAL_1>, <NFT_SERIAL_2>, and <NFT_SERIAL_3> will denote the serial numbers of the three minted NFTs.
The tests contained in this specification will assume that a valid fungible token and a valid non-fungible token have already successfully created. The fungible token will have an initial supply of 1,000,000 and the non-fungible token will have three minted. <CREATED_FUNGIBLE_TOKEN_ID> will denote the ID of the created fungible token, <CREATED_FUNGIBLE_TOKEN_SUPPLY_KEY> will denote the supply key of the created fungible token as a DER-encoded hex string, and <CREATED_FUNGIBLE_TOKEN_ADMIN_KEY> will denote the admin key of the created fungible token as a DER-encoded hex string. <CREATED_NON_FUNGIBLE_TOKEN_ID> will denote the ID of the created non-fungible token, <CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY> will denote the supply key of the created non-fungible token as a DER-encoded hex string, and <CREATED_NON_FUNGIBLE_TOKEN_ADMIN_KEY> will denote the admin key of the created non-fungible token as a DER-encoded hex string. <NFT_SERIAL_1>, <NFT_SERIAL_2>, and <NFT_SERIAL_3> will denote the serial numbers of the three minted NFTs.

## Property Tests

Expand Down Expand Up @@ -150,16 +150,16 @@ The tests contained in this specification will assume that a valid fungible toke

- The list of NFT serial numbers to burn.

| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------|-------------------|
| 1 | Burns an NFT | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn succeeds and the token's treasury account no longer contains the first NFT. | N |
| 2 | Burns 3 NFTs | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>, <NFT_SERIAL_2>, <NFT_SERIAL_3>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn succeeds and the token's treasury account no longer contains any NFTs. | N |
| 3 | Burns 3 NFTs but one is already burned | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>, <NFT_SERIAL_2>, <BURNED_NFT_SERIAL_3>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an INVALID_NFT_ID response code from the network. | N |
| 4 | Burns no NFTs | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn succeeds and the token's treasury account contains all three NFTs. | N |
| 5 | Burns an NFT that doesn't exist | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=["12345678"], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an INVALID_TOKEN_NFT_SERIAL_NUMBER response code from the network. | N |
| 6 | Burns NFTs with the treasury account frozen | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an ACCOUNT_FROZEN_FOR_TOKEN response code from the network. | N |
| 7 | Burns paused NFTs | tokenId=<PAUSED_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<PAUSED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an TOKEN_IS_PAUSED response code from the network. | N |
| 8 | Burns fungible tokens with serial numbers | tokenId=<CREATED_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<CREATED_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn succeeds and the token's treasury account contains the same NFTs. | N |
| Test no | Name | Input | Expected response | Implemented (Y/N) |
|---------|---------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|--------------------------------------------------------------------------------------------|-------------------|
| 1 | Burns an NFT | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn succeeds and the token's treasury account no longer contains the first NFT. | N |
| 2 | Burns 3 NFTs | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>, <NFT_SERIAL_2>, <NFT_SERIAL_3>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn succeeds and the token's treasury account no longer contains any NFTs. | N |
| 3 | Burns 3 NFTs but one is already burned | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>, <NFT_SERIAL_2>, <BURNED_NFT_SERIAL_3>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an INVALID_NFT_ID response code from the network. | N |
| 4 | Burns no NFTs | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an INVALID_TOKEN_BURN_METADATA response code from the network. | N |
| 5 | Burns an NFT that doesn't exist | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=["12345678"], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an INVALID_NFT_ID response code from the network. | N |
| 6 | Burns NFTs with the treasury account frozen | tokenId=<CREATED_NON_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<CREATED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an ACCOUNT_FROZEN_FOR_TOKEN response code from the network. | N |
| 7 | Burns paused NFTs | tokenId=<PAUSED_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<PAUSED_NON_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn fails with an TOKEN_IS_PAUSED response code from the network. | N |
| 8 | Burns fungible tokens with serial numbers | tokenId=<CREATED_FUNGIBLE_TOKEN_ID>, serialNumbers=[<NFT_SERIAL_1>], commonTransactionParams.signers=[<CREATED_FUNGIBLE_TOKEN_SUPPLY_KEY>] | The token burn succeeds and the token's treasury account contains the same NFTs. | N |

#### JSON Request Example

Expand Down
12 changes: 12 additions & 0 deletions src/services/ConsensusInfoClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import {
AccountInfo,
AccountInfoQuery,
Client,
NftId,
TokenInfo,
TokenInfoQuery,
TokenNftInfo,
TokenNftInfoQuery,
} from "@hashgraph/sdk";

class ConsensusInfoClient {
Expand Down Expand Up @@ -51,6 +54,15 @@ class ConsensusInfoClient {
return this.executeTokenMethod(tokenId, new TokenInfoQuery());
}

async getTokenNftInfo(
tokenId: string,
serialNumber: string,
): Promise<TokenNftInfo[]> {
let query = new TokenNftInfoQuery();
query.setNftId(NftId.fromString(tokenId + "/" + serialNumber));
return query.execute(this.sdkClient);
}

async executeAccountMethod(
accountId: string,
method: AccountInfoQuery | AccountBalanceQuery,
Expand Down
12 changes: 12 additions & 0 deletions src/services/MirrorNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,18 @@ 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, tokenId: string) {
const url = `${this.mirrorNodeRestUrl}/api/v1/accounts/${accountId}/tokens?token.id=${tokenId}`;
return retryOnError(async () => fetchData(url));
}

// TODO: Get mirror node interface with OpenAPI
async getAccountNfts(accountId: string, tokenId: string) {
const url = `${this.mirrorNodeRestUrl}/api/v1/accounts/${accountId}/nfts?token.id=${tokenId}`;
return retryOnError(async () => fetchData(url));
}
}

export default new MirrorNodeClient();
Loading