Skip to content

feat(examples): add TRX DelegateResource example scripts#8253

Merged
bhavidhingra merged 1 commit intomasterfrom
copilot/add-trx-delegate-resource-example
Apr 14, 2026
Merged

feat(examples): add TRX DelegateResource example scripts#8253
bhavidhingra merged 1 commit intomasterfrom
copilot/add-trx-delegate-resource-example

Conversation

@bhavidhingra
Copy link
Copy Markdown
Contributor

@bhavidhingra bhavidhingra commented Mar 5, 2026

Summary

  • Adds example scripts (examples/ts/trx/delegate-resource.ts, examples/ts/trx/get-resource-delegations.ts) demonstrating how to build/sign a TRX DelegateResource transaction and query resource delegations via the BitGo SDK
  • Adds getResourceDelegations(params?) method to the Wallet class in sdk-core, following the same pattern as getAccountResources():
    • New types in iWallet.ts: GetResourceDelegationsOptions, DelegationRecord, GetResourceDelegationsResponse
    • resource filter accepts any string (case-insensitive) — backend handles validation
    • Uses this.url('/resourcedelegations') + .query() for the GET request
  • Refactors handleV2ResourceDelegations in express to use wallet.getResourceDelegations() instead of calling bitgo.get(bitgo.url(...)) directly, consistent with how handleV2AccountResources uses wallet.getAccountResources()
  • Updates express handler tests to stub wallet.getResourceDelegations() instead of the raw bitgo HTTP methods
  • Adds unit tests for wallet.getResourceDelegations() covering all query param combinations

Test plan

  • Verify all scripts compile without errors
  • Run get-resource-delegations.ts against a testnet wallet to confirm delegations are returned
  • Run delegate-resource.ts against a testnet wallet with frozen TRX balance to confirm the delegation flow works end-to-end
  • Verify both ENERGY and BANDWIDTH resource types work (case-insensitive)
  • Run sdk-core unit tests: yarn run unit-test --scope @bitgo/sdk-core -- -- --grep "getResourceDelegations"
  • Run express unit tests: yarn run unit-test --scope @bitgo/express -- -- --grep "TRX Resource Delegation"

🤖 Generated with Claude Code

@bhavidhingra bhavidhingra requested a review from a team as a code owner March 5, 2026 18:11
@bhavidhingra bhavidhingra marked this pull request as draft March 5, 2026 18:12
@bhavidhingra bhavidhingra force-pushed the copilot/add-get-account-resources-method branch from 7038a4f to d286299 Compare March 6, 2026 10:19
@sachushaji
Copy link
Copy Markdown
Contributor

@claude

@bhavidhingra bhavidhingra changed the base branch from copilot/add-get-account-resources-method to master March 25, 2026 16:26
@bhavidhingra bhavidhingra force-pushed the copilot/add-trx-delegate-resource-example branch 4 times, most recently from 449452c to 41b0d66 Compare March 25, 2026 16:44
@bhavidhingra bhavidhingra changed the title feat(examples): add TRX DelegateResource example script feat(examples): add TRX DelegateResource example scripts Mar 25, 2026
@bhavidhingra bhavidhingra force-pushed the copilot/add-trx-delegate-resource-example branch from 41b0d66 to 8c426ae Compare March 25, 2026 16:47
@bhavidhingra bhavidhingra marked this pull request as ready for review March 25, 2026 16:47
@sachushaji
Copy link
Copy Markdown
Contributor

@claude

5 similar comments
@sachushaji
Copy link
Copy Markdown
Contributor

@claude

@sachushaji
Copy link
Copy Markdown
Contributor

@claude

@sachushaji
Copy link
Copy Markdown
Contributor

@claude

@sachushaji
Copy link
Copy Markdown
Contributor

@claude

@sachushaji
Copy link
Copy Markdown
Contributor

@claude

@bhavidhingra bhavidhingra force-pushed the copilot/add-trx-delegate-resource-example branch 3 times, most recently from 3d17681 to 7592b0f Compare April 9, 2026 12:23
@bhavidhingra bhavidhingra requested review from a team as code owners April 9, 2026 12:23
@bhavidhingra bhavidhingra force-pushed the copilot/add-trx-delegate-resource-example branch from 7592b0f to 8e80838 Compare April 9, 2026 12:27
Add an example script demonstrating how to build and sign a TRX
DelegateResource transaction via the BitGo platform API. This allows
delegating frozen ENERGY or BANDWIDTH resources to another address.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>

TICKET: CHALO-350
@bhavidhingra bhavidhingra force-pushed the copilot/add-trx-delegate-resource-example branch from 8e80838 to 7074a0e Compare April 9, 2026 12:50
Copy link
Copy Markdown
Contributor

@MohammedRyaan786 MohammedRyaan786 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@bhavidhingra bhavidhingra merged commit 681c554 into master Apr 14, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants