Skip to content

Commit 1cf46c2

Browse files
authored
Merge branch 'main' into issueEnforcer
2 parents 046b8e0 + aae89fa commit 1cf46c2

11 files changed

Lines changed: 93 additions & 11 deletions

.github/workflows/pr-check-primary-codecov.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ jobs:
3737
python-version: "3.11"
3838

3939
- name: Install uv
40-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
40+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
4141

4242
- name: Install dependencies
4343
run: |

.github/workflows/pr-check-primary-codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
egress-policy: audit
4343

4444
- name: Initialize CodeQL
45-
uses: github/codeql-action/init@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
45+
uses: github/codeql-action/init@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
4646
with:
4747
languages: ${{ matrix.language }}
4848
build-mode: ${{ matrix.build-mode }}
@@ -57,7 +57,7 @@ jobs:
5757

5858
- name: Install uv
5959
if: matrix.language == 'python'
60-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
60+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
6161
with:
6262
enable-cache: true
6363

@@ -66,6 +66,6 @@ jobs:
6666
run: uv sync --frozen --all-groups --all-packages --all-extras
6767

6868
- name: Perform CodeQL Analysis
69-
uses: github/codeql-action/analyze@8aad20d150bbac5944a9f9d289da16a4b0d87c1e # v4.36.2
69+
uses: github/codeql-action/analyze@54f647b7e1bb85c95cddabcd46b0c578ec92bc1a # v4.36.3
7070
with:
7171
category: "/language:${{matrix.language}}"

.github/workflows/pr-check-secondary-deps-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
cache: "pip"
3939

4040
- name: Install uv
41-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
41+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
4242

4343
- name: Create virtual environment
4444
run: uv venv

.github/workflows/pr-check-secondary-examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ jobs:
5858
working-directory: .github/scripts
5959

6060
- name: Install uv
61-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
61+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
6262

6363
- name: Install dependencies
6464
run: uv sync --frozen --all-groups --all-packages --all-extras

.github/workflows/pr-check-secondary-tck-test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ jobs:
4242
python-version: "3.14"
4343

4444
- name: Install uv
45-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
45+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
4646
with:
4747
enable-cache: true
4848

.github/workflows/pr-check-secondary-unit-integration-test.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ jobs:
5454
python-version: ${{ matrix.python-version }}
5555

5656
- name: Install uv
57-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
57+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
5858
with:
5959
enable-cache: true
6060

@@ -117,7 +117,7 @@ jobs:
117117
python-version: ${{ matrix.python-version }}
118118

119119
- name: Install uv
120-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
120+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
121121
with:
122122
enable-cache: true
123123

.github/workflows/test-scripts.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ jobs:
3232
persist-credentials: false
3333

3434
- name: Install uv
35-
uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
35+
uses: astral-sh/setup-uv@d31148d669074a8d0a63714ba94f3201e7020bc3 # v8.3.0
3636

3737
- name: Install dependencies
3838
run: uv sync --frozen --all-groups --all-packages --all-extras

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ default-groups = ["dev", "lint"]
6565
[build-system]
6666
requires = [
6767
"pdm-backend>=2.4.8,<3",
68-
"setuptools>=82,<83",
68+
"setuptools>=82,<84",
6969
"setuptools_scm>=7,<11",
7070
"grpcio-tools>=1.76.0,<2"
7171
]

tck/handlers/token.py

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@
1313
from hiero_sdk_python.tokens.fee_assessment_method import FeeAssessmentMethod
1414
from hiero_sdk_python.tokens.nft_id import NftId
1515
from hiero_sdk_python.tokens.supply_type import SupplyType
16+
from hiero_sdk_python.tokens.token_airdrop_claim import TokenClaimAirdropTransaction
17+
from hiero_sdk_python.tokens.token_airdrop_pending_id import PendingAirdropId
1618
from hiero_sdk_python.tokens.token_airdrop_transaction import TokenAirdropTransaction
1719
from hiero_sdk_python.tokens.token_associate_transaction import TokenAssociateTransaction
1820
from hiero_sdk_python.tokens.token_create_transaction import TokenCreateTransaction
@@ -28,6 +30,7 @@
2830
from tck.param.token import (
2931
AirdropTokenParams,
3032
AssociateTokenParams,
33+
ClaimTokenParams,
3134
CreateTokenParams,
3235
DeleteTokenParams,
3336
FreezeTokenParams,
@@ -37,6 +40,7 @@
3740
from tck.response.token import (
3841
AirdropTokenResponse,
3942
AssociateTokenResponse,
43+
ClaimTokenResponse,
4044
CreateTokenResponse,
4145
DeleteTokenResponse,
4246
FreezeTokenResponse,
@@ -429,3 +433,48 @@ def airdrop_token(params: AirdropTokenParams) -> AirdropTokenResponse:
429433
)
430434

431435
return AirdropTokenResponse(status=ResponseCode(receipt.status).name)
436+
437+
438+
def _build_claim_token_transaction(params: ClaimTokenParams) -> TokenClaimAirdropTransaction:
439+
"""Build a TokenClaimAirdropTransaction from TCK params."""
440+
transaction = TokenClaimAirdropTransaction().set_grpc_deadline(DEFAULT_GRPC_TIMEOUT)
441+
442+
sender_id = AccountId.from_string(params.senderAccountId)
443+
receiver_id = AccountId.from_string(params.receiverAccountId)
444+
token_id = TokenId.from_string(params.tokenId)
445+
446+
if params.serialNumbers:
447+
for serial_number in params.serialNumbers:
448+
transaction.add_pending_airdrop_id(
449+
PendingAirdropId(
450+
sender_id=sender_id,
451+
receiver_id=receiver_id,
452+
nft_id=NftId(token_id=token_id, serial_number=int(serial_number)),
453+
)
454+
)
455+
else:
456+
transaction.add_pending_airdrop_id(
457+
PendingAirdropId(
458+
sender_id=sender_id,
459+
receiver_id=receiver_id,
460+
token_id=token_id,
461+
)
462+
)
463+
464+
return transaction
465+
466+
467+
@rpc_method("claimToken")
468+
def claim_token(params: ClaimTokenParams) -> ClaimTokenResponse:
469+
"""Claim pending token airdrops using TCK claimToken parameters."""
470+
client = get_client(params.sessionId)
471+
472+
transaction = _build_claim_token_transaction(params)
473+
474+
if params.commonTransactionParams is not None:
475+
params.commonTransactionParams.apply_common_params(transaction, client)
476+
477+
response = transaction.execute(client, wait_for_receipt=False)
478+
receipt: TransactionReceipt = response.get_receipt(client, validate_status=True)
479+
480+
return ClaimTokenResponse(status=ResponseCode(receipt.status).name)

tck/param/token.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,3 +204,31 @@ def parse_json_params(cls, params: dict) -> AirdropTokenParams:
204204
sessionId=parse_session_id(params),
205205
commonTransactionParams=parse_common_transaction_params(params),
206206
)
207+
208+
209+
@dataclass
210+
class ClaimTokenParams(BaseTransactionParams):
211+
"""Request parameters for the claimToken endpoint."""
212+
213+
senderAccountId: str | None = None
214+
receiverAccountId: str | None = None
215+
tokenId: str | None = None
216+
serialNumbers: list[str] | None = None
217+
218+
@classmethod
219+
def parse_json_params(cls, params: dict) -> ClaimTokenParams:
220+
"""Parse JSON-RPC params into a ClaimTokenParams instance."""
221+
serial_numbers = params.get("serialNumbers")
222+
if serial_numbers is not None and not isinstance(serial_numbers, list):
223+
raise ValueError("serialNumbers must be a list")
224+
if serial_numbers is not None and any(not isinstance(serial_number, str) for serial_number in serial_numbers):
225+
raise ValueError("each serialNumbers item must be a string")
226+
227+
return cls(
228+
senderAccountId=params.get("senderAccountId"),
229+
receiverAccountId=params.get("receiverAccountId"),
230+
tokenId=params.get("tokenId"),
231+
serialNumbers=serial_numbers,
232+
sessionId=parse_session_id(params),
233+
commonTransactionParams=parse_common_transaction_params(params),
234+
)

0 commit comments

Comments
 (0)