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(accountAllowanceApproveTransaction): Implement AccountAllowanceApproveTransaction E2E tests: TCK #314

Open
wants to merge 4 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"
}

Large diffs are not rendered by default.

This file was deleted.

22 changes: 11 additions & 11 deletions docs/test-specifications/crypto-service/allowances.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ Allowances can be granted to accounts to allow that account to spend on behalf o

| Parameter Name | Type | Required/Optional | Description/Notes |
|------------------|-------------|-------------------|--------------------------------------------------------------------------------------------------------------------------------------|
| ownerAccountId | string | optional | The ID of the account granting the allowance. |
| spenderAccountId | string | optional | The ID of the account being granted the allowance. |
| ownerAccountId | string | required | The ID of the account granting the allowance. |
| spenderAccountId | string | required | The ID of the account being granted the allowance. |
| hbar | json object | optional | REQUIRED if `token` and `nft` are not provided. The parameters of the [HBAR Allowance](#hbar-allowance-object-definition) to grant. |
| token | json object | optional | REQUIRED if `hbar` and `nft` are not provided. The parameters of the [Token Allowance](#token-allowance-object-definition) to grant. |
| nft | json object | optional | REQUIRED if `hbar` and `token` are not provided. The parameters of the [NFT Allowance](#nft-allowance-object-definition) to grant. |
Expand All @@ -16,23 +16,23 @@ Allowances can be granted to accounts to allow that account to spend on behalf o

| Parameter Name | Type | Required/Optional | Description/Notes |
|---------------------|--------|-------------------|--------------------------------------|
| amount | string | optional | The amount of HBAR to be allowanced. |
| amount | string | required | The amount of HBAR to be allowanced. |

### Token Allowance Object Definition

| Parameter Name | Type | Required/Optional | Description/Notes |
|----------------|--------|-------------------|-------------------------------------------|
| tokenId | string | optional | The ID of the token to be allowanced. |
| amount | string | optional | The amount of the token to be allowanced. |
| tokenId | string | required | The ID of the token to be allowanced. |
| amount | string | required | The amount of the token to be allowanced. |

### NFT Allowance Object Definition

| Parameter Name | Type | Required/Optional | Description/Notes |
|--------------------------|--------------|-------------------|------------------------------------------------------------------------------------------------------------------------|
| tokenId | string | optional | The ID of the token to be allowanced. |
| serialNumbers | list<string> | optional | The serial numbers of the NFTs to be allowanced. |
| approvedForAll | bool | optional | Should the spender be granted access to all the owner's NFTs of the tokenId class (currently owned and in the future)? |
| delegateSpenderAccountId | string | optional | The ID of the account of a spender is granted approvedForAll access and can grant NFT allowances to another spender. |
| Parameter Name | Type | Required/Optional | Description/Notes |
|--------------------------|--------------|-------------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| tokenId | string | required | The ID of the token to be allowanced. |
| serialNumbers | list<string> | optional | REQUIRED if `approvedForAll` is not provided. The serial numbers of the NFTs to be allowanced. |
| approvedForAll | bool | optional | REQUIRED if `serialNumbers` is not provided. Should the spender be granted access to all the owner's NFTs of the tokenId class (currently owned and in the future)? |
| delegateSpenderAccountId | string | optional | The ID of the account of a spender who is already granted approvedForAll privileges and can grant NFT allowances to another spender. |

## Example Usage

Expand Down
26 changes: 26 additions & 0 deletions src/services/MirrorNodeClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@ import { retryOnError } from "../utils/helpers/retry-on-error";

class MirrorNodeClient {
private mirrorNodeRestUrl: string | undefined;
private mirrorNodeRestJavaUrl: string | undefined;

constructor() {
this.mirrorNodeRestUrl = process.env.MIRROR_NODE_REST_URL;
this.mirrorNodeRestJavaUrl = process.env.MIRROR_NODE_REST_JAVA_URL;
}

// TODO: Get mirror node interface with OpenAPI
Expand All @@ -25,6 +27,30 @@ class MirrorNodeClient {
const url = `${this.mirrorNodeRestUrl}/api/v1/tokens/${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));
}

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

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

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

export default new MirrorNodeClient();
Loading