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

🧠 Logic: 🗂️ source_file/1 predicate #311

Merged
merged 8 commits into from
Mar 17, 2023
Merged

Conversation

amimart
Copy link
Member

@amimart amimart commented Mar 16, 2023

Implements #308

Refer to the issue concerning the predicate definition.

Regarding the implementation, to manage only files loaded as prolog sources a trick has been done using reflection on the prolog VM.

🎯 Example

> okp4d --home $CHAIN_HOME query logic ask --program ":- consult('cosmwasm:okp4-storage:okp41ffzp0xmjhwkltuxcvccl0z9tyfuu7txp5ke0tpkcjpzuq9fcj3pqrteqt3?query=%7B%22object_data%22%3A%7B%22id%22%3A%221cc6de7672c97db145a3940df2264140ea893c6688fa5ca55b73cb8b68e0574d%22%7D%7D')." "source_file(X)."
answer:
  has_more: false
  results:
  - substitutions:
    - term:
        arguments: []
        name: '''cosmwasm:okp4-storage:okp41ffzp0xmjhwkltuxcvccl0z9tyfuu7txp5ke0tpkcjpzuq9fcj3pqrteqt3?query=%7B%22object_data%22%3A%7B%22id%22%3A%221cc6de7672c97db145a3940df2264140ea893c6688fa5ca55b73cb8b68e0574d%22%7D%7D'''
      variable: X
  success: true
  variables:
  - X
gas_used: "70002"
height: "2397"

@amimart amimart self-assigned this Mar 16, 2023
@amimart amimart requested review from ccamel and bdeneux and removed request for ccamel March 16, 2023 10:24
@amimart amimart force-pushed the feat/source-file-predicate branch 2 times, most recently from 0869ab2 to e98ef24 Compare March 16, 2023 10:56
x/logic/predicate/file.go Outdated Show resolved Hide resolved
@amimart amimart requested a review from bdeneux March 16, 2023 15:10
Copy link
Contributor

@bdeneux bdeneux left a comment

Choose a reason for hiding this comment

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

Very nice 😁 That seems good to me 👍

x/logic/predicate/file_test.go Show resolved Hide resolved
x/logic/predicate/file.go Outdated Show resolved Hide resolved
x/logic/predicate/file_test.go Show resolved Hide resolved
x/logic/predicate/file.go Outdated Show resolved Hide resolved
@amimart amimart requested a review from ccamel March 17, 2023 12:57
Copy link
Member

@ccamel ccamel left a comment

Choose a reason for hiding this comment

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

All good. Great improvement.

@amimart amimart merged commit e89fcf2 into main Mar 17, 2023
@amimart amimart deleted the feat/source-file-predicate branch March 17, 2023 13:06
@bot-anik
Copy link
Member

🎉 This PR is included in version 4.1.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

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