Skip to content

Commit

Permalink
[stdlib] Fix some todo and do clean up (#1543)
Browse files Browse the repository at this point in the history
1. Move SortedLinkedList.move and TokenLockPool.move to incubator.
2. Finish PackageTxnManager and DummyToken's TODO.
  • Loading branch information
jolestar authored Oct 26, 2020
1 parent 0995907 commit eb0d760
Show file tree
Hide file tree
Showing 30 changed files with 860 additions and 2,448 deletions.
Binary file modified core/genesis/generated/halley/genesis
Binary file not shown.
Binary file modified core/genesis/generated/main/genesis
Binary file not shown.
623 changes: 623 additions & 0 deletions vm/functional-tests/tests/testsuite/incubator/SortedLinkedList.move

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
address 0x1 {
// Test the token lock
//! account: alice, 100000 0x1::STC::STC
//! account: bob, 0 0x1::STC::STC

module TokenLockPool {
use 0x1::Token::{Self, Token};
use 0x1::Timestamp;
Expand Down Expand Up @@ -33,15 +36,13 @@ module TokenLockPool {
const EAMOUNT_TOO_BIG: u64 = 103;

public fun initialize(account: &signer) {
Timestamp::assert_genesis();
CoreAddresses::assert_genesis_address(account);
let token_pool = TokenPool<STC> { token: Token::zero() };
move_to(account, token_pool);
//TODO how to init other token's pool.
}

spec fun initialize {
include Timestamp::AbortsIfNotGenesis;
include CoreAddresses::AbortsIfNotGenesisAddress;
aborts_if exists<TokenPool<STC>>(Signer::address_of(account));
}
Expand Down Expand Up @@ -174,4 +175,115 @@ module TokenLockPool {
}

}

//! new-transaction
//!sender: genesis
script {
use {{default}}::TokenLockPool;
fun init(account: &signer){
TokenLockPool::initialize(account);
}
}

//! new-transaction

//! sender: alice
script {
use 0x1::Account;
use {{default}}::TokenLockPool;
use 0x1::STC::STC;
use 0x1::Offer;

fun create_lock(account: &signer) {
let token = Account::withdraw<STC>(account, 10000);
let key = TokenLockPool::create_linear_lock<STC>(token, 5);
Offer::create(account, key, {{bob}}, 0);
}
}

//! new-transaction
//! sender: bob
script {
use 0x1::Offer;
use 0x1::STC::STC;
use 0x1::Box;
use {{default}}::TokenLockPool::{LinearTimeLockKey};

fun redeem_offer(account: &signer) {
let key = Offer::redeem<LinearTimeLockKey<STC>>(account, {{alice}});
Box::put(account, key);
}
}


//! block-prologue
//! author: alice
//! block-time: 1000
//! block-number: 1

//! new-transaction
//! sender: bob
script {
use 0x1::Account;
use 0x1::STC::STC;
use 0x1::Token;
use 0x1::Box;
use {{default}}::TokenLockPool::{Self, LinearTimeLockKey};

fun unlock(account: &signer) {
let key = Box::take<LinearTimeLockKey<STC>>(account);
let token = TokenLockPool::unlock_with_linear_key(&mut key);
// withdraw 10000/5
assert(Token::value(&token) == 2000, 1001);
Box::put(account, key);
Account::deposit_to_self(account, token);
}
}

//! block-prologue
//! author: alice
//! block-time: 2000
//! block-number: 2

//! new-transaction
//! sender: bob
script {
use 0x1::Account;
use 0x1::STC::STC;
use 0x1::Token;
use 0x1::Box;
use {{default}}::TokenLockPool::{Self, LinearTimeLockKey};

fun unlock(account: &signer) {
let key = Box::take<LinearTimeLockKey<STC>>(account);
let token = TokenLockPool::unlock_with_linear_key(&mut key);
// withdraw 10000/5 again
assert(Token::value(&token) == 2000, 1002);
Box::put(account, key);
Account::deposit_to_self(account, token);
}
}

//! block-prologue
//! author: alice
//! block-time: 5000
//! block-number: 3

//! new-transaction
//! sender: bob
script {
use 0x1::Account;
use 0x1::STC::STC;
use 0x1::Token;
use 0x1::Box;
use {{default}}::TokenLockPool::{Self, LinearTimeLockKey};

fun unlock(account: &signer) {
let key = Box::take<LinearTimeLockKey<STC>>(account);
//unlock all remain
let token = TokenLockPool::unlock_with_linear_key(&mut key);
assert(Token::value(&token) == 6000, 1003);
TokenLockPool::destroy_empty(key);
Account::deposit_to_self(account, token);
}
}
234 changes: 0 additions & 234 deletions vm/functional-tests/tests/testsuite/list/NameService.move

This file was deleted.

Loading

0 comments on commit eb0d760

Please sign in to comment.