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

ALL CHANGES #1

Closed
wants to merge 555 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
555 commits
Select commit Hold shift + click to select a range
8590f28
external claim
gaetbout Jun 19, 2024
ff9b8dc
fix re-entrant
gaetbout Jun 20, 2024
241f4a4
claim internal done
gaetbout Jun 20, 2024
666714d
working pausable
gaetbout Jun 20, 2024
8dc113d
poc using library calls
sgc-code Jun 20, 2024
f042e67
fix escrow account validation
sgc-code Jun 20, 2024
3558e03
factory tests
gaetbout Jun 20, 2024
f32091d
upgrade and gift_status
Leonard-Pat Jun 20, 2024
5250246
clean
gaetbout Jun 20, 2024
739617f
remove upgrade fn
Leonard-Pat Jun 20, 2024
d05f50f
fixing upgrade periods
gaetbout Jun 20, 2024
560ffa1
Merge pull request #35 from argentlabs/fix-escrow-account-validation
sgc-code Jun 20, 2024
f5761a1
Merge branch 'develop' into test/events
sgc-code Jun 20, 2024
3c5974b
Merge branch 'develop' into upgrade/fix-period-csts
sgc-code Jun 20, 2024
84a10d5
Merge pull request #37 from argentlabs/upgrade/fix-period-csts
sgc-code Jun 20, 2024
b2bcec2
Merge branch 'develop' into test/events
Leonard-Pat Jun 20, 2024
e64515d
remove comment and name last arg of event
Leonard-Pat Jun 20, 2024
55ef2bf
Merge pull request #33 from argentlabs/test/events
Leonard-Pat Jun 20, 2024
e59c9a7
genericAccount => devnetAccount
gaetbout Jun 21, 2024
8bad2bb
gas price devnet testnet
gaetbout Jun 21, 2024
4b070f2
format
gaetbout Jun 21, 2024
78c40a9
Merge branch 'develop' into testnet-test
gaetbout Jun 21, 2024
c7ee4c7
Merge branch 'develop' into poc-library-calls
sgc-code Jun 21, 2024
8530439
fix succeeded instead of accepted on l2
gaetbout Jun 21, 2024
b319b0a
fixing 'Not possible to claim more via reentrancy' test
gaetbout Jun 21, 2024
9ae3a32
returning receipt instead of response
gaetbout Jun 21, 2024
1928abd
using executtion_status from receipt
gaetbout Jun 21, 2024
2f5ffd5
more features moved to account impl
sgc-code Jun 21, 2024
a854012
example for outside execution
sgc-code Jun 21, 2024
7d66afa
Merge branch 'develop' into test/missing-tests
Leonard-Pat Jun 21, 2024
33eec92
fix time
Leonard-Pat Jun 20, 2024
934c810
new upgrade changes
Leonard-Pat Jun 21, 2024
cf2b021
more upgrade tests - remove status
Leonard-Pat Jun 21, 2024
d6d2900
upgrade tessts
Leonard-Pat Jun 21, 2024
99b7352
update fixtures
Leonard-Pat Jun 21, 2024
2717336
update comment
Leonard-Pat Jun 21, 2024
ea80833
getMaxGift => getGiftAmount
gaetbout Jun 21, 2024
9bba7f4
batman
gaetbout Jun 22, 2024
960cbed
revert expecteation file
gaetbout Jun 22, 2024
8b8ee60
format
gaetbout Jun 22, 2024
a1e399c
Merge pull request #38 from argentlabs/small-fixes
Leonard-Pat Jun 23, 2024
eaaec76
fix all tests
Leonard-Pat Jun 23, 2024
3db615b
remove top comments
gaetbout Jun 24, 2024
f1edb6c
add class hash to deposit function
Leonard-Pat Jun 24, 2024
ba24148
updated deposit function to use claimAccountClassHash
Leonard-Pat Jun 24, 2024
d532e29
deposit tests
Leonard-Pat Jun 24, 2024
3d1623e
remove ds store
Leonard-Pat Jun 24, 2024
b5a1ce8
gitignore
Leonard-Pat Jun 24, 2024
72e9acd
Update src/contracts/timelock_upgrade.cairo
Leonard-Pat Jun 24, 2024
e47ae9e
basic scripts
Leonard-Pat Jun 24, 2024
1c892ea
scripts
Leonard-Pat Jun 24, 2024
a27dbc4
pr comments
Leonard-Pat Jun 24, 2024
87944cf
Update scripts/claim-dust.ts
Leonard-Pat Jun 24, 2024
e8559d1
fix linting errors
Leonard-Pat Jun 24, 2024
8ab92bc
update tests
Leonard-Pat Jun 24, 2024
c7dd4a4
comment
Leonard-Pat Jun 24, 2024
14b1258
update gas report for baseline
gaetbout Jun 24, 2024
d98ec5a
format + useTxV3
gaetbout Jun 24, 2024
2ff0011
get dust + claim external using txv3
gaetbout Jun 24, 2024
a07d41e
format
gaetbout Jun 24, 2024
abae971
remove useless arg
gaetbout Jun 24, 2024
8ba369b
use setDefaultTransactionVersionV3
gaetbout Jun 24, 2024
c8c09f0
update get dust to use tx version
gaetbout Jun 24, 2024
ab28b5a
format
gaetbout Jun 24, 2024
1139cae
remove never used details
gaetbout Jun 24, 2024
78440f4
account ternary operator
gaetbout Jun 24, 2024
5e7bbf8
Merge pull request #30 from argentlabs/testnet-test
sgc-code Jun 25, 2024
8de4399
Merge branch 'develop' into test/missing-tests
sgc-code Jun 25, 2024
29528fe
merge
Leonard-Pat Jun 25, 2024
bb70299
review comments
sgc-code Jun 25, 2024
f0856f1
simplify
sgc-code Jun 25, 2024
6aaa274
Merge branch 'develop' into poc-library-calls
sgc-code Jun 25, 2024
9152ed5
rename
sgc-code Jun 25, 2024
29513c8
format
sgc-code Jun 25, 2024
681a2b1
simplify events
sgc-code Jun 25, 2024
b80c2c2
first draft
gaetbout Jun 25, 2024
8ce144e
fix upgrade tests
Leonard-Pat Jun 25, 2024
aaf4b33
remove class hash
Leonard-Pat Jun 25, 2024
72005f5
remove only
Leonard-Pat Jun 25, 2024
13962d6
2 type deser
gaetbout Jun 25, 2024
89e2ef8
full_deser + selector from calldata
gaetbout Jun 25, 2024
1ebd55c
ILama => IExecutableAction
gaetbout Jun 25, 2024
2b55c34
Merge pull request #39 from argentlabs/feat/class-hash-deposit
sgc-code Jun 25, 2024
93712f0
Merge branch 'develop' into test/missing-tests
Leonard-Pat Jun 25, 2024
ddc6d93
fix most tests
sgc-code Jun 25, 2024
30e9943
Merge branch 'develop' into poc-library-calls
sgc-code Jun 25, 2024
c98e97a
udpate gas report
sgc-code Jun 25, 2024
7045f07
Merge branch 'poc-library-calls' into feat/action-safeguards
sgc-code Jun 25, 2024
d866177
execute_action update signature
gaetbout Jun 25, 2024
3acaa3a
emtpy line
Leonard-Pat Jun 25, 2024
56fb502
Update tests-integration/upgrade.test.ts
Leonard-Pat Jun 25, 2024
ea5ae6c
calc days
Leonard-Pat Jun 25, 2024
fcd8750
ignore
Leonard-Pat Jun 25, 2024
14b457a
Update src/contracts/timelock_upgrade.cairo
Leonard-Pat Jun 25, 2024
ca1b08d
describe blocks
Leonard-Pat Jun 25, 2024
3282203
Merge pull request #36 from argentlabs/test/missing-tests
Leonard-Pat Jun 25, 2024
d30e883
Merge branch 'develop' into poc-library-calls
sgc-code Jun 25, 2024
e3977f3
Update src/contracts/claim_account_impl.cairo
sgc-code Jun 25, 2024
3dbce5a
style
sgc-code Jun 25, 2024
f3d33cd
Merge branch 'poc-library-calls' of https://github.com/argentlabs/arg…
sgc-code Jun 25, 2024
1b81ebd
style
sgc-code Jun 25, 2024
a434e35
fixing tests
gaetbout Jun 25, 2024
c632e9f
Using Sergio's impl
gaetbout Jun 25, 2024
90996fa
Update src/contracts/claim_account_impl.cairo
sgc-code Jun 25, 2024
c33481a
remove interface.cairo
sgc-code Jun 25, 2024
2af66b8
Merge pull request #34 from argentlabs/poc-library-calls
sgc-code Jun 25, 2024
e9a3676
Merge branch 'develop' into package-by-feature
sgc-code Jun 25, 2024
0d50cfa
formatter
sgc-code Jun 25, 2024
7c128fa
merge w develop
gaetbout Jun 25, 2024
688a23e
failing entrypoint not found
gaetbout Jun 25, 2024
6a47463
exposing fns
gaetbout Jun 25, 2024
11ce476
reverting some code'
gaetbout Jun 25, 2024
9bdd790
merge w develop
gaetbout Jun 26, 2024
aaed507
Merge pull request #42 from argentlabs/feat/action-safeguards
sgc-code Jun 26, 2024
520dbc8
no message
sgc-code Jun 26, 2024
5f53272
Merge pull request #45 from argentlabs/package-by-feature
sgc-code Jun 26, 2024
3ad8b6d
first pass
Leonard-Pat Jun 26, 2024
527f7a6
second pass
Leonard-Pat Jun 26, 2024
efdabea
thrid pass
Leonard-Pat Jun 26, 2024
2e12df0
forth pass
Leonard-Pat Jun 26, 2024
112921b
fifth pass
Leonard-Pat Jun 26, 2024
658a8aa
final test
Leonard-Pat Jun 26, 2024
12f1026
rename library
Leonard-Pat Jun 26, 2024
67f553e
Fix outside execution version
sgc-code Jun 26, 2024
869f76c
rename all account --> escrow
Leonard-Pat Jun 26, 2024
c9a92a3
improve lib call syntax
sgc-code Jun 26, 2024
611223d
Merge branch 'feat/grand-rename' into fix-outside-execution-version
sgc-code Jun 26, 2024
fbfba40
Merge branch 'feat/grand-rename' into improve-lib-call-syntax
sgc-code Jun 26, 2024
38083bb
Update src/mocks/reentrant_erc20.cairo
Leonard-Pat Jun 26, 2024
5826460
improve balance_of syntax
sgc-code Jun 26, 2024
dce2e8a
fix profiler
Leonard-Pat Jun 26, 2024
7713a24
pr comments
Leonard-Pat Jun 26, 2024
29fc3a4
library dispatcher
Leonard-Pat Jun 26, 2024
75ceaca
Merge branch 'feat/grand-rename' into improve-balance_of-syntax
sgc-code Jun 26, 2024
3e79807
Merge branch 'feat/grand-rename' into improve-lib-call-syntax
sgc-code Jun 26, 2024
08b1de8
Merge branch 'feat/grand-rename' into fix-outside-execution-version
sgc-code Jun 26, 2024
d70200b
comments
Leonard-Pat Jun 26, 2024
07d04ed
tweaks to upgrade
sgc-code Jun 26, 2024
63ec58a
Merge pull request #46 from argentlabs/feat/grand-rename
sgc-code Jun 26, 2024
c3d380a
Merge branch 'feat/grand-rename' into improve-lib-call-syntax
sgc-code Jun 26, 2024
aeab5ca
Merge branch 'develop' into improve-lib-call-syntax
sgc-code Jun 26, 2024
b63ba14
Merge pull request #47 from argentlabs/fix-outside-execution-version
sgc-code Jun 26, 2024
54e67f1
Merge branch 'develop' into improve-balance_of-syntax
sgc-code Jun 26, 2024
0b67de7
Merge branch 'develop' into improve-lib-call-syntax
sgc-code Jun 26, 2024
ba09219
Merge branch 'develop' into tweaks-to-upgrade
sgc-code Jun 26, 2024
0184c19
Merge pull request #48 from argentlabs/improve-lib-call-syntax
sgc-code Jun 26, 2024
5111c0c
Merge pull request #49 from argentlabs/improve-balance_of-syntax
sgc-code Jun 26, 2024
6be55b8
Merge branch 'develop' into tweaks-to-upgrade
sgc-code Jun 26, 2024
a5cec1d
update tests
sgc-code Jun 26, 2024
31d2427
better is_zero
sgc-code Jun 27, 2024
a325e9c
first draft
gaetbout Jun 27, 2024
3b52d8e
Default instead of Zero
sgc-code Jun 27, 2024
2f3bab5
remove TODOs
sgc-code Jun 27, 2024
1899509
save
gaetbout Jun 27, 2024
3027145
remove not tested
gaetbout Jun 27, 2024
f25ed3d
remvoe extra comment
gaetbout Jun 27, 2024
835e9b9
Test invalid selector on lib calls
sgc-code Jun 27, 2024
37b55d5
fixing tests
gaetbout Jun 27, 2024
8317ffd
revert
gaetbout Jun 27, 2024
237b64b
Merge pull request #53 from argentlabs/test-invalid-selector-on-lib-c…
sgc-code Jun 27, 2024
5f2a576
fixing tests
gaetbout Jun 27, 2024
6d8b7c8
revert comment
gaetbout Jun 27, 2024
664afc4
Merge branch 'develop' into remove-todos
Leonard-Pat Jun 27, 2024
40b4f79
Merge pull request #51 from argentlabs/remove-todos
Leonard-Pat Jun 27, 2024
6f12450
Merge branch 'develop' into align-error-message
Leonard-Pat Jun 27, 2024
cc94637
fixing tests
gaetbout Jun 27, 2024
cf1aea4
Merge pull request #52 from argentlabs/align-error-message
Leonard-Pat Jun 27, 2024
78b769a
Merge branch 'develop' into tweaks-to-upgrade
sgc-code Jun 27, 2024
8002326
address PR issues
sgc-code Jun 27, 2024
b5c67f5
use chai should
sgc-code Jun 27, 2024
b37d239
fix linter
sgc-code Jun 27, 2024
50c52e7
Merge pull request #50 from argentlabs/tweaks-to-upgrade
sgc-code Jun 27, 2024
897b124
update readme
sgc-code Jun 27, 2024
3fccd11
Update README.md
sgc-code Jun 27, 2024
ff14bb7
Update README.md
sgc-code Jun 27, 2024
6992b48
Update README.md
sgc-code Jun 27, 2024
3875bf3
Update README.md
sgc-code Jun 27, 2024
5d28fc5
update readme
sgc-code Jun 27, 2024
b9bcf07
Merge branch 'update-readme' of https://github.com/argentlabs/argent-…
sgc-code Jun 27, 2024
ff63b10
Merge branch 'develop' into update-readme
sgc-code Jun 27, 2024
cb47e93
Update README.md
sgc-code Jun 27, 2024
b2ceb81
Update README.md
sgc-code Jun 27, 2024
545d964
more dots
sgc-code Jun 27, 2024
87b66c3
Update README.md
sgc-code Jun 27, 2024
b16fede
Update README.md
sgc-code Jun 27, 2024
d63be19
Merge pull request #55 from argentlabs/update-readme
sgc-code Jun 27, 2024
7a74bfe
fix tests
gaetbout Jun 28, 2024
fe6fdff
merge develop
gaetbout Jun 28, 2024
277b3d2
adding all non tested mesgs
gaetbout Jun 28, 2024
7d52520
merge w develop
gaetbout Jun 28, 2024
eec0a6c
format + update gas report
gaetbout Jun 28, 2024
b66de94
get dust for multiple claims
gaetbout Jun 28, 2024
ec2e32f
adding some tests lib acc
gaetbout Jun 28, 2024
bea8081
adding factory test
gaetbout Jun 28, 2024
121b8ae
wrong address
gaetbout Jun 28, 2024
9034a3e
invalid calldata
gaetbout Jun 28, 2024
f3e5f41
invalid calldata
gaetbout Jun 28, 2024
4d5b22f
the long dong
gaetbout Jun 28, 2024
b44de8d
wrong signature
gaetbout Jun 28, 2024
7c3384c
remove comments
gaetbout Jun 28, 2024
cc41f23
first draft
gaetbout Jun 28, 2024
6ba61f0
update gas report
gaetbout Jun 28, 2024
a1c0f34
Merge branch 'develop' into feat/admin-scripts
Leonard-Pat Jun 28, 2024
e42c408
update scripts
Leonard-Pat Jun 28, 2024
624857c
deployment
Leonard-Pat Jun 28, 2024
dd519e8
deployed with shared account
Leonard-Pat Jun 28, 2024
a07a009
fixing SGC remarks
gaetbout Jul 1, 2024
1594ca4
remove owner
Leonard-Pat Jul 1, 2024
10eeca5
update claim dust
Leonard-Pat Jul 1, 2024
13c82b0
Merge pull request #57 from argentlabs/feat/deploy-sepolia
Leonard-Pat Jul 1, 2024
84887c0
Merge branch 'develop' into feat/admin-scripts
Leonard-Pat Jul 1, 2024
936ef28
rename file to snake
Leonard-Pat Jul 1, 2024
570b9b9
import
Leonard-Pat Jul 1, 2024
d25f799
Merge pull request #41 from argentlabs/profile/dust
sgc-code Jul 1, 2024
eca7529
Merge pull request #40 from argentlabs/feat/admin-scripts
sgc-code Jul 1, 2024
e0c5196
Merge branch 'develop' into align-error-message-tests
sgc-code Jul 1, 2024
e422a9d
add diagrams
sgc-code Jul 1, 2024
f4d21a8
Merge pull request #54 from argentlabs/align-error-message-tests
sgc-code Jul 1, 2024
bcdc0b8
Merge branch 'develop' into add-diagrams
sgc-code Jul 1, 2024
33e2656
first draft
gaetbout Jul 1, 2024
d214e1f
middle of fixing
Leonard-Pat Jul 1, 2024
6322a58
Fixed reentrancy tests
Leonard-Pat Jul 1, 2024
3292286
gift --> claim
Leonard-Pat Jul 1, 2024
ecbc964
adding factory deposit tests
gaetbout Jul 1, 2024
c57036d
use serialize
Leonard-Pat Jul 1, 2024
7fe1446
format
Leonard-Pat Jul 1, 2024
b0f1afa
Merge pull request #59 from argentlabs/fix/reentrancy
sgc-code Jul 2, 2024
012cd67
Merge pull request #60 from argentlabs/tests/failing-trasnfers
sgc-code Jul 2, 2024
e4ab499
Merge branch 'develop' into gas-report
sgc-code Jul 3, 2024
a61e5b4
Merge pull request #56 from argentlabs/gas-report
sgc-code Jul 3, 2024
0f51eb8
Merge branch 'develop' into add-diagrams
sgc-code Jul 3, 2024
4f75243
update diagrams
sgc-code Jul 3, 2024
2d671cc
remove empty deployments file
sgc-code Jul 3, 2024
da52dcf
Merge pull request #58 from argentlabs/add-diagrams
sgc-code Jul 3, 2024
436958c
more restrictions on validation
sgc-code Jul 4, 2024
66efc04
fix error message
sgc-code Jul 4, 2024
95850fb
Update src/contracts/escrow_account.cairo
sgc-code Jul 4, 2024
20e0348
Merge pull request #61 from argentlabs/more-restrictions-on-validation
sgc-code Jul 5, 2024
0cb7be8
consistent check for claimed or cancelled
sgc-code Jul 8, 2024
86142ed
fix tests
sgc-code Jul 8, 2024
b2d62fb
Merge pull request #62 from argentlabs/consistent-check-for-claimed-o…
sgc-code Jul 9, 2024
9a92001
no message
sgc-code Jul 9, 2024
52b346f
improve upgrade mechanism
sgc-code Jul 9, 2024
7a8466d
assert lock was reset
sgc-code Jul 12, 2024
fc1f40d
Merge pull request #63 from argentlabs/better-upgrade
sgc-code Jul 12, 2024
83b9e35
add audit report
sgc-code Jul 16, 2024
4170549
update deployments.txt
gaetbout Jul 17, 2024
aac358f
deploy on sepolia
gaetbout Jul 19, 2024
d14d871
deploy mainnet with argent.stark as owner
gaetbout Jul 22, 2024
4ab474c
Merge pull request #64 from argentlabs/deploy
sgc-code Jul 22, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
RPC_URL=http://127.0.0.1:5050
ADDRESS=0x000000000000000000000000000000000000000000000000000000000000000
PRIVATE_KEY=0x000000000000000000000000000000000000000000000000000000000000000
12 changes: 12 additions & 0 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"parser": "@typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": "latest",
"sourceType": "module"
},
"extends": ["plugin:@typescript-eslint/recommended"],
"env": {
"node": true
},
"ignorePatterns": ["dist", "cairo"]
}
26 changes: 26 additions & 0 deletions .github/workflows/cairo-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Cairo CI

on: push

jobs:
tests:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3
- name: Step 2 - Getting scarb
uses: software-mansion/[email protected]
- name: Step 3 - Setting up snfoundry
uses: foundry-rs/setup-snfoundry@v3
- name: Step 4 - Running tests
run: scarb test

format:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3
- name: Step 2 - Getting scarb
uses: software-mansion/[email protected]
- name: Step 3 - Checking format
run: scarb fmt --check
64 changes: 64 additions & 0 deletions .github/workflows/integration-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Integration CI

on: push

jobs:
integration-tests:
runs-on: ubuntu-latest
steps:
- name: Check out main branch
uses: actions/checkout@v3

- name: Setup Scarb
uses: software-mansion/[email protected]

- name: Install project
run: yarn install --frozen-lockfile

- name: Start devnet in background
run: scarb run start-devnet

- name: Run integration tests
run: scarb --release build && tsc && yarn mocha tests-integration/*.test.ts --forbid-only --forbid-pending

format:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Install project
run: yarn install --frozen-lockfile

- name: Step 3 - Check correct formatting
run: yarn prettier --check .

lint:
runs-on: ubuntu-latest
steps:
- name: Step 1 - Check out main branch
uses: actions/checkout@v3

- name: Step 2 - Install project
run: yarn install --frozen-lockfile

- name: Step 3 - Check correct linting
run: yarn eslint .

gas-report:
runs-on: ubuntu-latest
steps:
- name: Check out main branch
uses: actions/checkout@v3

- name: Setup Scarb
uses: software-mansion/[email protected]

- name: Install project
run: yarn install --frozen-lockfile

- name: Start devnet in background
run: scarb run start-devnet

- name: Gas report
run: scarb run profile --check
46 changes: 46 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# Logs
logs
*.log
npm-debug.log*

# Runtime data
pids
*.pid
*.seed

# Directory for instrumented libs generated by jscoverage/JSCover
lib-cov

# Coverage directory used by tools like istanbul
coverage

# nyc test coverage
.nyc_output

# Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files)
.grunt

# node-waf configuration
.lock-wscript

# Compiled binary addons (http://nodejs.org/api/addons.html)
build/Release

# Dependency directories
node_modules
jspm_packages

# Optional npm cache directory
.npm

# Optional REPL history
.node_repl_history
.next

# Cairo
target
.snfoundry_cache/

.env
dist
.DS_STORE
7 changes: 7 additions & 0 deletions .mocharc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"extensions": ["ts"],
"test": ["tests/**.ts"],
"node-option": ["loader=ts-node/esm"],
"slow": 5000,
"timeout": 300000
}
1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
18
8 changes: 8 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
cairo
venv
target
deployments/artifacts
dist
.github
tests-integration/fixtures
starknet-devnet-rs
9 changes: 9 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"arrowParens": "always",
"useTabs": false,
"trailingComma": "all",
"singleQuote": false,
"semi": true,
"printWidth": 120,
"plugins": ["prettier-plugin-organize-imports"]
}
2 changes: 2 additions & 0 deletions .tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
scarb 2.6.3
starknet-foundry 0.24.0
8 changes: 8 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Use the base image
FROM shardlabs/starknet-devnet-rs:bab781a018318df51adb20fc60716c8429ee89b0

# Expose port 5050
EXPOSE 5050

# Set default command to run the container
CMD ["--gas-price", "36000000000", "--data-gas-price", "1", "--timeout", "320", "--seed", "0", "--lite-mode", "--gas-price-strk", "36000000000", "--data-gas-price-strk", "1"]
118 changes: 118 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
# Starknet Gifting

The goal of this protocol is to allow sending tokens to a recipient without knowing their address. This is done using a non-custodial escrow contract. Since the escrow contract functions as an account, it can pay for its own transactions, meaning the recipient doesn't need funds to initiate the claim. This is ideal for onboarding new users who can claim a gift to a newly created and even undeployed account.

## High level Flow

1. The sender creates a key pair locally called **gift_key**.
2. The sender deposits the tokens to be transferred, along with a small amount of fee token (ETH or STK) to cover the claim transaction, to the factory. The sender also specifies the **public key** as an identifier.
3. The factory deploys an escrow account to which the gift amount is transferred along with the fee amount.
4. The sender shares the **private key** with the recipient over an external channel such as text or email.
5. The recipient can claim the tokens by transferring them from the escrow account to their account using the private key to sign the transaction.

As the fee should be larger than the claiming transaction cost, there might be a small amount of fee token left. We will refer to this leftover amount as "dust".

## Deposits

Deposits follow the flow described in the first 3 steps above.

![Sessions diagram](/docs/deposit_diagram.png)

For more details please see the `deposit` function at [Deposit example](./lib/deposit.ts).

## Claiming

Claiming can be done in two ways:

### Internal claim

The recipient uses the private key to craft a transaction to claim the gift. The `fee_amount` will be used to cover the transaction fees, so the recipient only gets the `gift_amount`. The recipient doesn’t need to have any funds in their wallet or even a deployed wallet to claim the gift using this method.

![Sessions diagram](/docs/internal_claim.png)

Edge cases:

- Insufficient `fee_amount`: Alternative options are "external claiming", waiting for transaction price to go down, or canceling the gift (see below).
- Dust: `fee_amount` will usually be higher than the actual fee and there will be some amount left in the contract. The protocol owner can collect the dust later.
- If the internal claim transaction fails for any reason, the account won't allow to submit another transaction. But the gift can be cancelled or claimed using the external method.

For more details about how to trigger it please see the `claimInternal` function at [Claim Internal Example](./lib/claim.ts).

### External claim

It is also possible for someone else to pay for the claim fees. This can be useful if the funds deposited to pay for the claim transaction are not enough, or if someone wants to subsidize the claim.

The receiver can use the private key sign a message containing the address receiving the address (and optionally some address that will receive the dust). Using this signature, anybody can execute a transaction to perform the claim. To do so, they should call `claim_external` on the escrow account (through the `execute_action` entrypoint).

![Sessions diagram](/docs/external_claim.png)

For more details please see the `claimExternal` function at [Claim External Example](./lib/claim.ts).

## Cancelling Gifts

Gifts can be cancelled by the sender provided that they have not been claimed yet. The sender will retrieve both the `gift_amount` and the `fee_amount` they deposited for that gift.

For more details please see the `cancelGift` function at [Cancel example](./lib/claim.ts).

## Operator

This section outlines all the operations that the factory owner is allowed to perform.

### Claim Dust

The operator can claim the dust left in an escrow account. This action can only be done after a claim has been performed.

### Pause deposits

The owner has the capability to pause all deposits. However, it cannot prevent any claims from happening, nor can it prevent any cancellations.

### Upgrade

The protocol can be upgraded to add new functionality or fix issues however, it can only be upgraded after a 7 day timelock. This prevents the owner from upgrading to a malicious implementation, as users will have enough time to leave the protocol by either claiming or cancelling their gifts.

Through an upgrade, the owner can make the protocol non upgradeable in the future.

## Escrow account address calculation

To compute the address of the escrow account, you can either call `get_escrow_address()` with the relevant arguments. Or you can do it off-chain using, for example, starknetJS.
The parameters are as follow:

- Salt: 0
- Class hash: the class hash of the escrow account
- Constructor calldata: The constructor argument used to deploy the escrow account
- Deployer address: The address of the factory

# Development

## Local development

We recommend you to install scarb through ASDF. Please refer to [these instructions](https://docs.swmansion.com/scarb/download.html#install-via-asdf).
Thanks to the [.tool-versions file](./.tool-versions), you don't need to install a specific scarb or starknet foundry version. The correct one will be automatically downloaded and installed.

##@ Test the contracts (Cairo)

```
scarb test
```

### Install the devnet (run in project root folder)

You should have docker installed in your machine then you can start the devnet by running the following command:

```shell
scarb run start-devnet
```

### Install JS dependencies

Install all packages:

```shell
yarn
```

Run all integration tests:

```shell
scarb run test-ts
```
54 changes: 54 additions & 0 deletions Scarb.lock
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# Code generated by scarb DO NOT EDIT.
version = 1

[[package]]
name = "alexandria_data_structures"
version = "0.2.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=cairo-v2.6.0#946e6e2f9d390ad9f345882a352c0dd6f02ef3ad"
dependencies = [
"alexandria_encoding",
]

[[package]]
name = "alexandria_encoding"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=cairo-v2.6.0#946e6e2f9d390ad9f345882a352c0dd6f02ef3ad"
dependencies = [
"alexandria_math",
"alexandria_numeric",
]

[[package]]
name = "alexandria_math"
version = "0.2.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=cairo-v2.6.0#946e6e2f9d390ad9f345882a352c0dd6f02ef3ad"
dependencies = [
"alexandria_data_structures",
]

[[package]]
name = "alexandria_numeric"
version = "0.1.0"
source = "git+https://github.com/keep-starknet-strange/alexandria.git?rev=cairo-v2.6.0#946e6e2f9d390ad9f345882a352c0dd6f02ef3ad"
dependencies = [
"alexandria_math",
]

[[package]]
name = "argent_gifting"
version = "0.1.0"
dependencies = [
"alexandria_math",
"openzeppelin",
"snforge_std",
]

[[package]]
name = "openzeppelin"
version = "0.13.0"
source = "git+https://github.com/OpenZeppelin/cairo-contracts.git?tag=v0.13.0#978b4e75209da355667d8954d2450e32bd71fe49"

[[package]]
name = "snforge_std"
version = "0.24.0"
source = "git+https://github.com/foundry-rs/starknet-foundry?tag=v0.24.0#95e9fb09cb91b3c05295915179ee1b55bf923653"
Loading
Loading