-
Notifications
You must be signed in to change notification settings - Fork 1
feat: Return Jettons, that were sent by accident #59
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
base: main
Are you sure you want to change the base?
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR adds automatic return logic for accidental Jetton/TON transfers to vault contracts, updates environment helpers to expose an initialization check, and expands test coverage around these scenarios.
- Added
isInited
helpers increateJettonVault
andcreateTonVault
environments - Implemented
UnexpectedJettonNotification
handler inTonVault
and proof‐check return logic inJettonVault
- Expanded tests to verify accidental returns for both TON and Jetton vaults, and updated formatting in pre-commit hook
Reviewed Changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 3 comments.
Show a summary per file
File | Description |
---|---|
sources/utils/environment.ts | Added isInited method to vault interface and factories |
sources/tests/ton-vault.spec.ts | New test for returning Jettons sent to TON Vault |
sources/tests/proofs.spec.ts | New tests for invalid proofs and wrong‐Jetton scenarios |
sources/contracts/vaults/ton-vault.tact | Defined UnexpectedJettonNotification & return message |
sources/contracts/vaults/proofs/check-proof.tact | Refactored checkProof to return Bool |
sources/contracts/vaults/jetton-vault.tact | Added return‐on‐invalid‐proof and wrong‐sender logic |
sources/contracts/utils/utils.tact | Introduced sliceWithOneZeroBit helper |
.husky/pre-commit | Updated tact-fmt invocation |
Comments suppressed due to low confidence (1)
.husky/pre-commit:2
- [nitpick] The
tact-fmt
invocation was modified to--write ./
, but the diff context shows an extra space and missing dash alignment. Ensure the pre-commit script matches other hooks and linting conventions.
yarn tact-fmt --write ./
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Jettons can still get stuck in the vault because of this:
|
I will solve that as part of #61 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great job, small nitpicks
@@ -134,4 +134,125 @@ describe("Proofs", () => { | |||
) | |||
expect(await jettonVaultInstance.getInited()).toBe(false) | |||
}) | |||
test("Jettons are returned if proof type is incorrect", async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's add classic const balanceBefore = jetton.balance()
and then expect(balanceAfter).toBe(balanceBefore)
@@ -44,6 +62,27 @@ contract TonVault( | |||
}); | |||
} | |||
|
|||
// Someone possibly transferred us jettons by accident | |||
receive(msg: UnexpectedJettonNotification) { | |||
message(MessageParameters { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe let's separate this refund to standalone function? It is used three times with the same exact code
Closes #58