Skip to content

Commit

Permalink
Revert "[Feature] Multi Offer (#135)"
Browse files Browse the repository at this point in the history
This reverts commit 4ec8c2f.
  • Loading branch information
nkysg committed Mar 3, 2023
1 parent 2b733fc commit e928ee3
Show file tree
Hide file tree
Showing 10 changed files with 61 additions and 1,218 deletions.
2 changes: 1 addition & 1 deletion build/StarcoinFramework/BuildInfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ compiled_package_info:
? address: "0x00000000000000000000000000000001"
name: YieldFarmingV2
: StarcoinFramework
source_digest: 9171A59A0F735B5531F80C357F850D2E91F7C8887F6DDE36390713DBDCD4C41E
source_digest: E0BF7F59CE58E05A3CCC9A8C8E6EF9CA68F0E8E78030805F0A9B949BF534566A
build_flags:
dev_mode: false
test_mode: false
Expand Down
Binary file modified build/StarcoinFramework/abis/Offer/take_offer.abi
Binary file not shown.
Binary file modified build/StarcoinFramework/bytecode_modules/Offer.mv
Binary file not shown.
791 changes: 22 additions & 769 deletions build/StarcoinFramework/docs/Offer.md

Large diffs are not rendered by default.

Binary file modified build/StarcoinFramework/source_maps/Offer.mvsm
Binary file not shown.
58 changes: 9 additions & 49 deletions integration-tests/offer/offer.exp
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
processed 17 tasks
processed 10 tasks

task 4 'run'. lines 9-31:
task 4 'run'. lines 9-32:
{
"gas_used": 140695,
"gas_used": 87526,
"status": "Executed"
}

task 5 'run'. lines 35-47:
task 5 'run'. lines 36-49:
{
"gas_used": 80018,
"gas_used": 25951,
"status": {
"MoveAbort": {
"location": {
Expand All @@ -22,9 +22,9 @@ task 5 'run'. lines 35-47:
}
}

task 7 'run'. lines 51-63:
task 7 'run'. lines 53-65:
{
"gas_used": 38916,
"gas_used": 26009,
"status": {
"MoveAbort": {
"location": {
Expand All @@ -38,48 +38,8 @@ task 7 'run'. lines 51-63:
}
}

task 9 'run'. lines 67-79:
task 9 'run'. lines 69-82:
{
"gas_used": 146388,
"status": "Executed"
}

task 10 'run'. lines 82-103:
{
"gas_used": 258865,
"status": "Executed"
}

task 11 'run'. lines 105-117:
{
"gas_used": 40121,
"status": {
"MoveAbort": {
"location": {
"Module": {
"address": "0x00000000000000000000000000000001",
"name": "Offer"
}
},
"abort_code": "26117"
}
}
}

task 13 'run'. lines 121-145:
{
"gas_used": 155351,
"status": "Executed"
}

task 14 'run'. lines 147-159:
{
"gas_used": 106491,
"status": "Executed"
}

task 16 'run'. lines 163-177:
{
"gas_used": 187043,
"gas_used": 92321,
"status": "Executed"
}
103 changes: 4 additions & 99 deletions integration-tests/offer/offer.move
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ script {
assert!(Offer::address_of<Token<STC>>(Signer::address_of(&account)) == @bob, 1002);
}
}

// check: EXECUTED

//! block-prologue
Expand All @@ -44,9 +45,10 @@ script {
Account::deposit_to_self(&account, token);
}
}

// check: "Keep(ABORTED { code: 26117"

//# block --author alice --timestamp 86400000
//# block --author alice

//# run --signers carol
script {
Expand All @@ -62,7 +64,7 @@ script {
}
// check: "Keep(ABORTED { code: 25863"

//# block --author alice --timestamp 86405000
//# block --author alice

//# run --signers bob
script {
Expand All @@ -76,102 +78,5 @@ script {
Account::deposit_to_self(&account, token);
}
}
// check: EXECUTED


//# run --signers alice
script {
use StarcoinFramework::Account;
use StarcoinFramework::Offer;
use StarcoinFramework::STC::STC;
use StarcoinFramework::Signer;
use StarcoinFramework::Token::Token;

fun create_offer_v2(account: signer) {
let token = Account::withdraw<STC>(&account, 10000);
Offer::create_v2(&account, token, @bob, 5);
let token = Account::withdraw<STC>(&account, 10000);
Offer::create_v2(&account, token, @bob, 10);
let token = Account::withdraw<STC>(&account, 10000);
Offer::create(&account, token, @bob, 10);
// test Offer::exists_at_v2
assert!(Offer::exists_at_v2<Token<STC>>(Signer::address_of(&account)), 1001);
// test Offer::address_of_v2
assert!(Offer::address_of_v2<Token<STC>>(Signer::address_of(&account), 0) == @bob, 1002);
}
}
// check: EXECUTED

//# run --signers bob
script {
use StarcoinFramework::Account;
use StarcoinFramework::Offer;
use StarcoinFramework::Token::Token;
use StarcoinFramework::STC::STC;

fun redeem_offer_v2(account: signer) {
let token = Offer::redeem_v2<Token<STC>>(&account, @alice, 0);
Account::deposit_to_self(&account, token);
}
}
// check: "Keep(ABORTED { code: 26117"

//# block --author alice --timestamp 86410000

//# run --signers carol
script {
use StarcoinFramework::Offer;
use StarcoinFramework::Token::Token;
use StarcoinFramework::Vector;
use StarcoinFramework::Option;
use StarcoinFramework::STC::STC;

fun redeem_offer_v2(_account: signer) {
let op_offer_infos = Offer::get_offers_infos<Token<STC>>(@alice);
assert!(Option::is_some(&op_offer_infos), 101);
let offer_infos = Option::destroy_some(op_offer_infos);
let offers_length = Offer::get_offers_length<Token<STC>>(@alice);
assert!(Vector::length(&offer_infos) == 3, 102);
assert!(offers_length == 3,103);
let ( for, time_lock) = Offer::unpack_offer_info(Vector::remove(&mut offer_infos, 0));
assert!(for == @bob, 104);
assert!(time_lock == 86410, 105);

let op_idx = Offer::find_offer<Token<STC>>(@alice, @bob);
assert!(Option::is_some(&op_idx), 106);
assert!(Option::destroy_some(op_idx) == 0, 107);
}
}
// check: EXECUTED

//# run --signers bob
script {
use StarcoinFramework::Account;
use StarcoinFramework::Offer;
use StarcoinFramework::Token::Token;
use StarcoinFramework::STC::STC;

fun redeem_offer_v2(account: signer) {
let token = Offer::redeem_v2<Token<STC>>(&account, @alice, 0);
Account::deposit_to_self(&account, token);
}
}
// check: EXECUTED

//# block --author alice --timestamp 7862415000

//# run --signers alice
script {
use StarcoinFramework::Account;
use StarcoinFramework::Offer;
use StarcoinFramework::Token::Token;
use StarcoinFramework::STC::STC;

fun retake_offer(account: signer) {
let token = Offer::retake<Token<STC>>(&account, 1);
Account::deposit_to_self(&account, token);
let token = Offer::retake<Token<STC>>(&account, 0);
Account::deposit_to_self(&account, token);
}
}
// check: EXECUTED
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ task 2 'run'. lines 5-16:

task 4 'run'. lines 21-29:
{
"gas_used": 198724,
"gas_used": 175833,
"status": "Executed"
}

task 6 'run'. lines 35-45:
{
"gas_used": 94617,
"gas_used": 40838,
"status": "Executed"
}

Expand Down
4 changes: 2 additions & 2 deletions integration-tests/treasury/split_linear_cap.exp
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ task 2 'run'. lines 7-23:

task 4 'run'. lines 26-45:
{
"gas_used": 191897,
"gas_used": 169006,
"status": "Executed"
}

task 6 'run'. lines 48-59:
{
"gas_used": 97125,
"gas_used": 43346,
"status": "Executed"
}
Loading

0 comments on commit e928ee3

Please sign in to comment.