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: expose the peerId that created the operations #551

Merged
merged 23 commits into from
Mar 18, 2025
Merged

Conversation

trungnotchung
Copy link
Member

@trungnotchung trungnotchung commented Mar 10, 2025

What type of PR is this?

  • Feature

Description

  • Created new interface DRPRuntimeContext and added to the IDRP.
  • Updated the DRPObject to update drp.context before applying an opeartion to the drp.
  • Updated all examples and blueprints.
  • Updated relevant tests and added new tests for that.

Steps to access the peerId of the operation creator in a function:

  • You need to add context: DrpRuntimeContext as an attribute of your DRP.
  • If you want to get the peerId that created the operations in a function, you can access it using this.context.caller.

For example, we can use this to verify the creator of the grant operation has admin permission:

grant(peerId: string, group: ACLGroup): void {
    if (!this.query_isAdmin(this.context.caller)) {
			throw new Error("Only admin peers can grant permissions.");
    }
    // remaining code
}

Related Issues and PRs

Added/updated tests?

  • Yes

Additional Info

add instructions or screenshots on what you might think is relevant or instructions on how to manually test it

[optional] Do we need to perform any post-deployment tasks?

Copy link

github-actions bot commented Mar 10, 2025

Flamegraph.com report

flamegraph.pprof
See in flamegraph.com

Created by Flamegraph.com Github Action

Copy link

github-actions bot commented Mar 10, 2025

Coverage Report

Status Category Percentage Covered / Total
🔵 Lines 85.99% 3156 / 3670
🔵 Statements 85.99% 3156 / 3670
🔵 Functions 83.85% 270 / 322
🔵 Branches 85.18% 828 / 972
File Coverage
File Stmts Branches Functions Lines Uncovered Lines
Changed Files
packages/object/src/index.ts 90% 80.95% 100% 90% 171-172, 176, 208-209, 224-225, 232-234, 255-256, 269-272, 301-302, 313-314, 354-355, 436-440, 448-449, 454-455, 466-467, 475-476, 491-492, 510-511, 519-520, 537-538, 551-552, 609-614, 629, 647-648, 658-659
packages/object/src/acl/index.ts 91.47% 82.75% 100% 91.47% 57-58, 79, 85-86, 94, 102, 158-161
packages/types/src/drp.ts 0% 100% 100% 0% 7-15
Generated in workflow #2436 for commit 8c5a924 by the Vitest Coverage Report Action

@trungnotchung trungnotchung marked this pull request as ready for review March 13, 2025 14:36
sfroment and others added 6 commits March 13, 2025 17:36
* origin:
  feat!: handle async DRP function  (#555)
  feat: interval-drp-discovery (#528)
* origin:
  fix: tsconfig for interval discovery (#564)
Signed-off-by: Sacha Froment <[email protected]>
Copy link
Member

@JanLewDev JanLewDev left a comment

Choose a reason for hiding this comment

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

otherwise lgtm

@sfroment sfroment requested a review from winprn March 17, 2025 07:02
Copy link
Contributor

@anhnd350309 anhnd350309 left a comment

Choose a reason for hiding this comment

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

lgtm

@sfroment sfroment merged commit a674c88 into main Mar 18, 2025
15 checks passed
sfroment added a commit that referenced this pull request Mar 18, 2025
* main:
  chore(deps): bump @opentelemetry/sdk-trace-web from 1.30.1 to 2.0.0 (#585)
  fix!: testcase handle sync message correctly (#588)
  feat: expose the peerId that created the operations (#551)
  Fix: testcase incorrect (#557)
  chore(deps-dev): bump eslint-import-resolver-typescript from 3.8.7 to 4.2.0 (#583)
  fix: add log config to createObject option to be passed down to finality store (#574)
  feat: add logger template (#576)
sfroment added a commit that referenced this pull request Mar 18, 2025
* origin:
  chore(deps): bump @opentelemetry/sdk-trace-web from 1.30.1 to 2.0.0 (#585)
  fix!: testcase handle sync message correctly (#588)
  feat: expose the peerId that created the operations (#551)
  Fix: testcase incorrect (#557)
  chore(deps-dev): bump eslint-import-resolver-typescript from 3.8.7 to 4.2.0 (#583)
  fix: add log config to createObject option to be passed down to finality store (#574)
  feat: add logger template (#576)
  chore: add @trung to keychain code owners (#562)
  refactor!: remove public credential (#563)
@sfroment sfroment deleted the feat/expose-peerid branch March 18, 2025 14:14
sfroment added a commit that referenced this pull request Mar 19, 2025
* origin:
  fix: log_config pass down to disco interval (#590)
  feat(object): drpobject become generic (#565)
  chore(deps): bump @opentelemetry/sdk-trace-web from 1.30.1 to 2.0.0 (#585)
  fix!: testcase handle sync message correctly (#588)
  feat: expose the peerId that created the operations (#551)
  Fix: testcase incorrect (#557)
  chore(deps-dev): bump eslint-import-resolver-typescript from 3.8.7 to 4.2.0 (#583)
  fix: add log config to createObject option to be passed down to finality store (#574)
  feat: add logger template (#576)
  chore: add @trung to keychain code owners (#562)
  refactor!: remove public credential (#563)
  fix(network): 🐛 isDialable shall ret true event when no callback is passed (#559)
  feat: add hashgraph visualizer (#512)
sfroment added a commit that referenced this pull request Mar 19, 2025
…t-bootstrap

* origin:
  fix(interval-discovery)!: now use a != topic in order not to have many invalid operation logs (#589)
  feat!: restrict set key access (#582)
  fix: log_config pass down to disco interval (#590)
  feat(object): drpobject become generic (#565)
  chore(deps): bump @opentelemetry/sdk-trace-web from 1.30.1 to 2.0.0 (#585)
  fix!: testcase handle sync message correctly (#588)
  feat: expose the peerId that created the operations (#551)
  Fix: testcase incorrect (#557)
  chore(deps-dev): bump eslint-import-resolver-typescript from 3.8.7 to 4.2.0 (#583)
  fix: add log config to createObject option to be passed down to finality store (#574)
  feat: add logger template (#576)
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.

[FEATURE] - Expose the peerId that created the operations
5 participants