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

Digital Cash - allow configure fee token accepted #1221

Merged
merged 27 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
e5501b6
allow esdt as fee & config in init
alyn509 Sep 19, 2023
4b30eb5
update test & fix token fee
alyn509 Sep 19, 2023
cb5a873
separate fee and fund endpoints
alyn509 Sep 19, 2023
05faf58
change static to const
alyn509 Sep 19, 2023
d4ceb15
split contract to modules
alyn509 Sep 19, 2023
708298f
pay fee and fund
alyn509 Sep 19, 2023
8df5ef6
make forward payable and allow it to cover fees
alyn509 Sep 19, 2023
aa6cfa5
update forward test
alyn509 Sep 19, 2023
30bb573
fix broken require
alyn509 Sep 19, 2023
cdc1cfe
mandos error message typo
alyn509 Sep 19, 2023
fa52f7f
update scenario tests
alyn509 Sep 19, 2023
8a320aa
pay fee and fund egld 1 transfer
alyn509 Sep 19, 2023
02a910c
Merge branch 'master' into digital-cash-multi-fee
alyn509 Sep 25, 2023
fc4aaaf
Merge branch 'master' into digital-cash-multi-fee
alyn509 Sep 25, 2023
7f981e9
fix after review + tests
alyn509 Sep 26, 2023
2a23fc3
wasm lib
alyn509 Sep 26, 2023
088c82c
Merge branch 'master' into digital-cash-multi-fee
alyn509 Sep 26, 2023
c2da120
don't send if payment is empty
alyn509 Sep 26, 2023
0b6cea1
tests whitelist / blacklist fee token
alyn509 Sep 27, 2023
b4421b2
pay fee and fund egld test
alyn509 Sep 27, 2023
95c39d2
pay fee and fund esdt test
alyn509 Sep 27, 2023
08056f9
fix test
alyn509 Sep 27, 2023
be98e11
Merge branch 'master' into digital-cash-multi-fee
alyn509 Sep 27, 2023
7c7d3c9
fix test balance esdt
alyn509 Sep 27, 2023
a051029
Merge branch 'master' into digital-cash-multi-fee
alyn509 Sep 27, 2023
7d55783
Merge branch 'master' into digital-cash-multi-fee
alyn509 Sep 27, 2023
a64f669
Merge branch 'master' into digital-cash-multi-fee
alyn509 Sep 28, 2023
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
22 changes: 18 additions & 4 deletions contracts/examples/digital-cash/scenarios/claim-egld.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,11 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x885532043a061e0c779e4064b85193f72cffd22c5bcc208c209128e60f21bf0d": {
Expand All @@ -149,11 +153,21 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:3",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10",
"str:collectedFees": "10"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1",
"str:collectedFees|nested:str:EGLD": "10"
},
"code": "file:../output/digital-cash.wasm"
},
Expand Down
22 changes: 18 additions & 4 deletions contracts/examples/digital-cash/scenarios/claim-esdt.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,11 @@
"4-expiration_round": "u64:10",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x885532043a061e0c779e4064b85193f72cffd22c5bcc208c209128e60f21bf0d": {
Expand All @@ -148,11 +152,21 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:3",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10",
"str:collectedFees": "10"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1",
"str:collectedFees|nested:str:EGLD": "10"
},
"code": "file:../output/digital-cash.wasm"
},
Expand Down
20 changes: 17 additions & 3 deletions contracts/examples/digital-cash/scenarios/claim-fees.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,11 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x885532043a061e0c779e4064b85193f72cffd22c5bcc208c209128e60f21bf0d": {
Expand All @@ -84,10 +88,20 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:3",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1"
},
"code": "file:../output/digital-cash.wasm"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,11 @@
"4-expiration_round": "u64:10",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x487bd4010b50c24a02018345fe5171edf4182e6294325382c75ef4c4409f01bd": {
Expand All @@ -146,11 +150,21 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10",
"str:collectedFees": "30"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1",
"str:collectedFees|nested:str:EGLD": "30"
},
"code": "file:../output/digital-cash.wasm"
},
Expand Down
64 changes: 55 additions & 9 deletions contracts/examples/digital-cash/scenarios/forward.scen.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"tx": {
"from": "address:acc2",
"to": "sc:the_digital_cash_contract",
"egldValue": "0",
"function": "forward",
"arguments": [
"0xdb474a3a065d3f0c0a62ae680ef6435e48eb482899d2ae30ff7a3a4b0ef19c60",
Expand Down Expand Up @@ -54,10 +55,11 @@
},
{
"step": "scCall",
"id": "forward-ok",
"id": "forward-without-fees-ok",
"tx": {
"from": "address:acc2",
"to": "sc:the_digital_cash_contract",
"egldValue": "0",
"function": "forward",
"arguments": [
"0xdb474a3a065d3f0c0a62ae680ef6435e48eb482899d2ae30ff7a3a4b0ef19c60",
Expand All @@ -81,7 +83,7 @@
"tx": {
"from": "address:acc2",
"to": "sc:the_digital_cash_contract",
"egldValue": "1,000",
"egldValue": "500",
"function": "depositFees",
"arguments": [
"0x8dc17613990e9b7476401a36d112d1a4d31190dec21e7e9a3c933872a27613ee"
Expand All @@ -100,11 +102,37 @@
},
{
"step": "scCall",
"id": "forward-ok",
"id": "forward-with-fees-fail",
"tx": {
"from": "address:acc2",
"to": "sc:the_digital_cash_contract",
"function": "forward",
"egldValue": "500",
"arguments": [
"0x885532043a061e0c779e4064b85193f72cffd22c5bcc208c209128e60f21bf0d",
"0x885532043a061e0c779e4064b85193f72cffd22c5bcc208c209128e60f21bf0d",
"0x1ac4f6d4d45836d97ffeda83a66aaea7631a3bb3d4063421ccb2b9de9485bdb4c9bd6e44e003f6a9c9eb74379467238204ff579471d203b1878c3f1530592a02"
],
"gasLimit": "500,000,000",
"gasPrice": "0"
},
"expect": {
"out": [],
"status": "4",
"message": "str:invalid depositor address",
"logs": "*",
"gas": "*",
"refund": "*"
}
},
{
"step": "scCall",
"id": "forward-with-fees-ok",
"tx": {
"from": "address:acc2",
"to": "sc:the_digital_cash_contract",
"function": "forward",
"egldValue": "500",
"arguments": [
"0x885532043a061e0c779e4064b85193f72cffd22c5bcc208c209128e60f21bf0d",
"0x8dc17613990e9b7476401a36d112d1a4d31190dec21e7e9a3c933872a27613ee",
Expand Down Expand Up @@ -142,7 +170,11 @@
"4-expiration_round": "u64:10",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x487bd4010b50c24a02018345fe5171edf4182e6294325382c75ef4c4409f01bd": {
Expand All @@ -153,7 +185,11 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x8dc17613990e9b7476401a36d112d1a4d31190dec21e7e9a3c933872a27613ee": {
Expand All @@ -164,11 +200,21 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:3",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10",
"str:collectedFees": "40"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1",
"str:collectedFees|nested:str:EGLD": "40"
},
"code": "file:../output/digital-cash.wasm"
},
Expand All @@ -178,7 +224,7 @@
"storage": {}
},
"address:acc2": {
"nonce": "8",
"nonce": "9",
"balance": "997,000",
"esdt": {
"str:CASHTOKEN-123456": "50"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,20 @@
"4-expiration_round": "u64:10",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1"
},
"code": "file:../output/digital-cash.wasm"
},
Expand Down Expand Up @@ -197,7 +207,11 @@
"4-expiration_round": "u64:10",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x487bd4010b50c24a02018345fe5171edf4182e6294325382c75ef4c4409f01bd": {
Expand All @@ -208,10 +222,20 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1"
},
"code": "file:../output/digital-cash.wasm"
},
Expand Down Expand Up @@ -389,7 +413,11 @@
"4-expiration_round": "u64:10",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x487bd4010b50c24a02018345fe5171edf4182e6294325382c75ef4c4409f01bd": {
Expand All @@ -400,7 +428,11 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:1",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:deposit|0x885532043a061e0c779e4064b85193f72cffd22c5bcc208c209128e60f21bf0d": {
Expand All @@ -411,10 +443,20 @@
"4-expiration_round": "u64:16",
"5-fees": {
"0-num_token_to_transfer": "u32:3",
"1-value": "biguint:1,000"
"1-value": {
"0-tokenIdentifier": "nested:str:EGLD",
"1-nonce": "u64:0",
"2-amount": "biguint:1,000"
}
}
},
"str:fee": "10"
"str:fee|nested:str:EGLD": "10",
"str:whitelistedFeeTokens|str:.len": "1",
"str:whitelistedFeeTokens|str:.item|u32:1": "str:EGLD",
"str:whitelistedFeeTokens|str:.index|nested:str:EGLD": "1",
"str:allTimeFeeTokens|str:.len": "1",
"str:allTimeFeeTokens|str:.item|u32:1": "str:EGLD",
"str:allTimeFeeTokens|str:.index|nested:str:EGLD": "1"
},
"code": "file:../output/digital-cash.wasm"
},
Expand Down
Loading
Loading