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: escrowable capabilities #121

Merged
merged 9 commits into from
Sep 13, 2023
Merged

feat: escrowable capabilities #121

merged 9 commits into from
Sep 13, 2023

Conversation

dndll
Copy link
Member

@dndll dndll commented Jul 21, 2023

Description

This introduces an escrow macro which allows you to lock some thing in the store until some unlock predicate has passed.

This feature is something akin to a lightweight approval system and it a fairly common use case, we actually needed it elsewhere so I figured I'd contribute to this repo.

Doesn't expose external functionality as it's more an internal operation for contract developers.

Edit: I had to make a fork and contribute this way, I have access to settings in this repo but for some reason I can't contribute directly.

TODO:

  • workspace tests

@dndll dndll requested a review from encody July 21, 2023 11:01
@dndll dndll marked this pull request as ready for review July 24, 2023 10:31
encody
encody previously requested changes Jul 24, 2023
src/escrow.rs Show resolved Hide resolved
src/escrow.rs Outdated Show resolved Hide resolved

#[derive(BorshSerialize, BorshDeserialize, Serialize, Deserialize, Clone)]
#[serde(crate = "near_sdk::serde")]
pub enum PrimaryColour {
Copy link
Contributor

Choose a reason for hiding this comment

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

🇬🇧

src/escrow.rs Show resolved Hide resolved
encody and others added 2 commits July 24, 2023 22:57
@dndll dndll requested a review from encody July 24, 2023 16:04
@dndll dndll self-assigned this Jul 25, 2023
@dndll dndll dismissed encody’s stale review July 26, 2023 08:24

Re requested review

@dndll
Copy link
Member Author

dndll commented Aug 7, 2023

hey @encody - Whats the nexts steps for this PR; are there other reviewers you want to add?

@encody encody merged commit d4b8777 into near:develop Sep 13, 2023
3 of 4 checks passed
@dndll dndll deleted the feat/escrow branch September 14, 2023 07:41
encody added a commit that referenced this pull request Sep 14, 2023
* basic generic upgrade function

* adding Upgrade and UpgradeHook traits

* update to stable near-sdk-rs

* broken upgrade workspaces-tests

* fix: remove migrate argument

* Added basic failure tests for upgrade

* added owner check for upgrade tests

* not owner failure test

* removing JS scripts

* feat: adds more derives to events

* cleaned up workspaces tests for upgrade

* removed unnecessary near_bindgen

* fixed macro version issue

* fix: some comments

* chore: conciseness

* fix: repo url in Cargo.toml

* fixing naming conventions

* chore: adds build task to workspaces tests

* feat: #[derive(Nep297)] allows enums

* feat: #[event] supports enums

* fix: Owner uses borsh storage keys

* fix: upgrade workspaces version to 0.6

* fix: removes generic requirement from Event trait

* chore: convert events back to enum shape with owned values

* fix: pin Rust version to 1.64; fixes #83

* Use dtolnay/rust-toolchain (#87)

* fix: use dtolnay/rust-toolchain for GH Action

* fix: rust doc warning from README.md

* Add safety invariants to owner module docs (#75)

* Add safety invariants to owner module docs

* Add usage and safety guide for owner component

* Add module docs for pause and rbac

* Add module docs for migrate and resolve comments

* Update links

* Resolve comments

* Fix cargo docs warning

* Resolve comments

* chore: minor corrections & formatting

Co-authored-by: Jacob <[email protected]>

* chore: adds .DS_Store to .gitignore

* fix: better doc links in Slot

* Default storage keys enum (#90)

* feat: default storage keys enum

* fix: doc links

* Link items in docs and other improvements (#91)

* Link items and doc improvements

* Add rbac macro attr doc and resolve comments

* Upgrade macro (#84)

* adding upgrade macro

* fix linting issues

* removing generic parameters

* fixing lint issues

* feat: new upgrade macro

* fix: tests for new upgrade macro

* fix: use Box to decrease enum size

* chore: better documentation for new upgrade modules

* fix: macro documentation

* wip: transfer to mac

* chore: workspace tests for upgrade

* upgrade multisig testing

* feat: better naming for raw functions + args structs

* chore: rename "none" hook body flag to "empty"

* chore: serialized upgrade uses PostUpgrade struct

* Upgrade macros safety docs (#96)

* chore: simplify api

Co-authored-by: Jacob <[email protected]>
Co-authored-by: Ishan Bhanuka <[email protected]>

* feat: unstable feature flag and upgrade near_sdk -> 4.1.0

* fix: Eq derive now that Base64VecU8: Eq

* fix: remove near-sdk default features usage (#98)

* fix: remove near-sdk default features usage

* commit to re-trigger CI

* explicitly increase sdk version on test to ensure it gets used internally

* chore: Cow -> String (#100)

* Makes `Rbac` iterable (#99)

* wip: how to implement iterator

* fix: unused imports

* feat: possible rbac iter implementation

* feat: iterable rbac works

* chore: finish docs & tests

* chore: upgrade Rust to 1.65

* chore: upgrade GH Actions Rust to 1.65

* feat: update version to 0.7.0

* chore: optimize has_role (#102)

* chore: update version to 0.7.1

* Fuller Iterator implementation for Rbac iterator (#105)

* feat: fuller Iterator implementation for Rbac iterator

* feat: mut and non-mut versions of with_members_of, more Iter guarantees

* Disallows Event name collisions (#108)

* feat: disallow event name collisions, tests

* chore: clippy fix

* chore: add name change notification

* chore: versions to 0.7.2

* Change package name to `near-sdk-contract-tools` (#109)

* chore: change name

* chore: change repository details

* fix: inaccurate documentation

* chore: upgrade rust, workspaces, adds approval keys test

* fix: clippy: needless borrow

* feat: easier network specification in tests

* feat: create account test

* chore: create account test, base64 for Vec<u8> in native tx actions

* feat: delete account native transaction action test

* feat: stake action test

* feat: utils tests

* chore: unused imports

* fix: check additional fees sum

* chore: add rename warning to docs

* feat: finally, a decent prefix_key signature

* BREAKING: Internal Traits (#111)

* feat: internal trait for Rbac

* feat: Pause internal trait and separate default implementation

* fix: remove duplicate empty impl in Pause macro

* feat: Owner internal trait

* feat: Nep141 internal trait

* feat: ApprovalManager internal trait

* fix: grammar

* better test naming

* fix: double underscore warning (#113)

* feat: adds kudelski audit final doc (#114)

* chore: mention audit in README.md

* chore: version bump to v1.0.0

* fix: exclude documents folder from publishing

* chore: version bump to v1.0.1

* fix: skip upgrade_jsonbase64 test on ghactions (#119)

* fix: warnings

* Non-Fungible Token Standards (#69)

* feat: nep171 wip

* feat: nep171 events are owned; some experiments for allowing approval extension

* feat: some ideas for implementing approval extension (wip)

* fix: crate name change

* feat: nep171 macro progress

* full nep171 implementation

* chore: simplify nft_resolve_transfer

* chore: finished nep171 macro

* chore: cleanup, tests, renaming

* chore: documentation comments

* chore: workspaces tests & multiple token ids

* feat: nep171 multiple token id transfer

* chore: more tests + small fixes

* fix: warnings

* feat: predicate api improvements

* feat: remove predicate, introduce check function

* feat: nft events version 1.2.0 update

* Nep177: NFT Metadata (#124)

* feat: nep177

* chore: more function implementation

* feat: nep177 macro

* feat: non_fungible_token macro

* feat: documentation comments

* feat: switch to using #[serde(flatten)] for token metadata

* feat: nep178

* chore: upgrade tests & organize libs

* feat: nep178 macro integration

* feat: nep178 testing

* chore: docs

* chore: more tests and examples in docs

* chore: lots of docs

* feat: switch hook state to associated type

* feat: nep181 internals done, improved hooks

* feat: nep181 macro, sanity test

* chore: qol nft module

* feat: docs

* feat: further enumeration tests

* feat: final (?) tests for enumeration

* chore: update readme to mention nep-171 and related

* Fast Account IDs (#123)

* feat: fast account ID

* fix: cleanup, extract to fn, switch to Rc

* Escrow (#121)

* feat: escrowable capabilities

* feat: add getter for locked state

* docs(escrow): add some documentation

* test(escrow): add integration test for macro

* test(escrow): add workspace test for macro

* test(escrow): add integration test for escrow macro

* fix: some clippy lints, also optional macro props

* feat(escrow): optionally implement events
allows types that implement `serde::Serialize` to emit events

---------

Co-authored-by: Jacob Lindahl <[email protected]>

* chore: more tests, more const in fast account id

* chore: cleanup md

* feat: nep-178 hooks improved

* v1.1.0

---------

Co-authored-by: nearken <[email protected]>
Co-authored-by: nearken <[email protected]>
Co-authored-by: Ishan Bhanuka <[email protected]>
Co-authored-by: Austin Abell <[email protected]>
Co-authored-by: Don <[email protected]>
encody added a commit that referenced this pull request Oct 30, 2023
* basic generic upgrade function

* adding Upgrade and UpgradeHook traits

* update to stable near-sdk-rs

* broken upgrade workspaces-tests

* fix: remove migrate argument

* Added basic failure tests for upgrade

* added owner check for upgrade tests

* not owner failure test

* removing JS scripts

* feat: adds more derives to events

* cleaned up workspaces tests for upgrade

* removed unnecessary near_bindgen

* fixed macro version issue

* fix: some comments

* chore: conciseness

* fix: repo url in Cargo.toml

* fixing naming conventions

* chore: adds build task to workspaces tests

* feat: #[derive(Nep297)] allows enums

* feat: #[event] supports enums

* fix: Owner uses borsh storage keys

* fix: upgrade workspaces version to 0.6

* fix: removes generic requirement from Event trait

* chore: convert events back to enum shape with owned values

* fix: pin Rust version to 1.64; fixes #83

* Use dtolnay/rust-toolchain (#87)

* fix: use dtolnay/rust-toolchain for GH Action

* fix: rust doc warning from README.md

* Add safety invariants to owner module docs (#75)

* Add safety invariants to owner module docs

* Add usage and safety guide for owner component

* Add module docs for pause and rbac

* Add module docs for migrate and resolve comments

* Update links

* Resolve comments

* Fix cargo docs warning

* Resolve comments

* chore: minor corrections & formatting

Co-authored-by: Jacob <[email protected]>

* chore: adds .DS_Store to .gitignore

* fix: better doc links in Slot

* Default storage keys enum (#90)

* feat: default storage keys enum

* fix: doc links

* Link items in docs and other improvements (#91)

* Link items and doc improvements

* Add rbac macro attr doc and resolve comments

* Upgrade macro (#84)

* adding upgrade macro

* fix linting issues

* removing generic parameters

* fixing lint issues

* feat: new upgrade macro

* fix: tests for new upgrade macro

* fix: use Box to decrease enum size

* chore: better documentation for new upgrade modules

* fix: macro documentation

* wip: transfer to mac

* chore: workspace tests for upgrade

* upgrade multisig testing

* feat: better naming for raw functions + args structs

* chore: rename "none" hook body flag to "empty"

* chore: serialized upgrade uses PostUpgrade struct

* Upgrade macros safety docs (#96)

* chore: simplify api

Co-authored-by: Jacob <[email protected]>
Co-authored-by: Ishan Bhanuka <[email protected]>

* feat: unstable feature flag and upgrade near_sdk -> 4.1.0

* fix: Eq derive now that Base64VecU8: Eq

* fix: remove near-sdk default features usage (#98)

* fix: remove near-sdk default features usage

* commit to re-trigger CI

* explicitly increase sdk version on test to ensure it gets used internally

* chore: Cow -> String (#100)

* Makes `Rbac` iterable (#99)

* wip: how to implement iterator

* fix: unused imports

* feat: possible rbac iter implementation

* feat: iterable rbac works

* chore: finish docs & tests

* chore: upgrade Rust to 1.65

* chore: upgrade GH Actions Rust to 1.65

* feat: update version to 0.7.0

* chore: optimize has_role (#102)

* chore: update version to 0.7.1

* Fuller Iterator implementation for Rbac iterator (#105)

* feat: fuller Iterator implementation for Rbac iterator

* feat: mut and non-mut versions of with_members_of, more Iter guarantees

* Disallows Event name collisions (#108)

* feat: disallow event name collisions, tests

* chore: clippy fix

* chore: add name change notification

* chore: versions to 0.7.2

* Change package name to `near-sdk-contract-tools` (#109)

* chore: change name

* chore: change repository details

* fix: inaccurate documentation

* chore: upgrade rust, workspaces, adds approval keys test

* fix: clippy: needless borrow

* feat: easier network specification in tests

* feat: create account test

* chore: create account test, base64 for Vec<u8> in native tx actions

* feat: delete account native transaction action test

* feat: stake action test

* feat: utils tests

* chore: unused imports

* fix: check additional fees sum

* chore: add rename warning to docs

* feat: finally, a decent prefix_key signature

* BREAKING: Internal Traits (#111)

* feat: internal trait for Rbac

* feat: Pause internal trait and separate default implementation

* fix: remove duplicate empty impl in Pause macro

* feat: Owner internal trait

* feat: Nep141 internal trait

* feat: ApprovalManager internal trait

* fix: grammar

* better test naming

* fix: double underscore warning (#113)

* feat: adds kudelski audit final doc (#114)

* chore: mention audit in README.md

* chore: version bump to v1.0.0

* fix: exclude documents folder from publishing

* chore: version bump to v1.0.1

* fix: skip upgrade_jsonbase64 test on ghactions (#119)

* fix: warnings

* Non-Fungible Token Standards (#69)

* feat: nep171 wip

* feat: nep171 events are owned; some experiments for allowing approval extension

* feat: some ideas for implementing approval extension (wip)

* fix: crate name change

* feat: nep171 macro progress

* full nep171 implementation

* chore: simplify nft_resolve_transfer

* chore: finished nep171 macro

* chore: cleanup, tests, renaming

* chore: documentation comments

* chore: workspaces tests & multiple token ids

* feat: nep171 multiple token id transfer

* chore: more tests + small fixes

* fix: warnings

* feat: predicate api improvements

* feat: remove predicate, introduce check function

* feat: nft events version 1.2.0 update

* Nep177: NFT Metadata (#124)

* feat: nep177

* chore: more function implementation

* feat: nep177 macro

* feat: non_fungible_token macro

* feat: documentation comments

* feat: switch to using #[serde(flatten)] for token metadata

* feat: nep178

* chore: upgrade tests & organize libs

* feat: nep178 macro integration

* feat: nep178 testing

* chore: docs

* chore: more tests and examples in docs

* chore: lots of docs

* feat: switch hook state to associated type

* feat: nep181 internals done, improved hooks

* feat: nep181 macro, sanity test

* chore: qol nft module

* feat: docs

* feat: further enumeration tests

* feat: final (?) tests for enumeration

* chore: update readme to mention nep-171 and related

* Fast Account IDs (#123)

* feat: fast account ID

* fix: cleanup, extract to fn, switch to Rc

* Escrow (#121)

* feat: escrowable capabilities

* feat: add getter for locked state

* docs(escrow): add some documentation

* test(escrow): add integration test for macro

* test(escrow): add workspace test for macro

* test(escrow): add integration test for escrow macro

* fix: some clippy lints, also optional macro props

* feat(escrow): optionally implement events
allows types that implement `serde::Serialize` to emit events

---------

Co-authored-by: Jacob Lindahl <[email protected]>

* chore: more tests, more const in fast account id

* chore: cleanup md

* feat: nep-178 hooks improved

* v1.1.0

* fix: gh actions tests should work again

* BREAKING: Fungible Token Improvements (better hooks + dynamic metadata) (#127)

* feat: better hooks for nep141

* chore: move resolve code to macro

* chore: use Result instead of panicking in nep141 functions

* chore: update nep148 to use dynamic metadata

* feat: extension hooks

* chore: upgrade to [email protected]

* chore: use pretty_assertions and fix gas issue

* chore: clean tests

* fix: update ghactions rust version to 1.72

---------

Co-authored-by: Jacob Lindahl <[email protected]>

* NEP-145: Storage Management (#126)

* storage management wip

* more internal methods

* wip: macro impl

* feat: finish + basic impl nep145

* chore: sanity test and docs

* fix: change method names + initial test skeleton

* fix: only resolved half the merge lmao

* chore: storage management tests

* chore: run out of storage test

* BREAKING: Refactor Fungible Token (#128)

* feat: better hooks for nep141

* chore: move resolve code to macro

* chore: use Result instead of panicking in nep141 functions

* chore: update nep148 to use dynamic metadata

* feat: extension hooks

* chore: upgrade to [email protected]

* chore: use pretty_assertions and fix gas issue

* chore: clean tests

* fix: update ghactions rust version to 1.72

* feat: nep145 convenience method for storage accounting

* fix: error message typo

* feat: new hooks

* feat: removes State associated type variable

* fix: readme sample

* feat: adds all_hooks + PausableHook

* feat: storage force unregister hook

* feat: FungibleToken derive macro includes NEP-145

* chore: fmt + docs

* chore: split out hooks to separate modules

---------

Co-authored-by: Jacob Lindahl <[email protected]>

* chore: NEARFoundation -> near repo update (#130)

* BREAKING: Upgrade all components to new hooks API (#129)

* feat: upgrade nep-171 to new hooks

* feat: "our most powerful hooks api yet"

* chore: 178 hooks and some reorg

* chore: move 178 actions to own module

* chore: nep178 extract error to separate module

* chore: nep141 transfers don't require owned values

* Normalize & update dependencies (#131)

* fix: remove external serde* deps; use near_sdk-provided serde* instead

* chore: use workspace dependencies for everything

* chore: upgrade strum deps

* chore: loosen version requirements

* chore: remove unused dependencies

* feat: nextest

* chore: use nextest in GH actions

* fix: gh actions syntax

* feat: use caching in ghaction

* Integrate NEP-145 with token standards (#132)

* feat: nep145 full integration with nep141

* feat: some renames; full nep145<>nep171 integration

* fmt

* fix: failing test & conciseness

* chore: better readme

* v2.0.0

---------

Co-authored-by: nearken <[email protected]>
Co-authored-by: nearken <[email protected]>
Co-authored-by: Ishan Bhanuka <[email protected]>
Co-authored-by: Austin Abell <[email protected]>
Co-authored-by: Don <[email protected]>
Co-authored-by: Jacob <[email protected]>
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.

2 participants