forked from 0LNetworkCommunity/libra-legacy-v5
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Easy account creation (0LNetworkCommunity#781)
* acount creation workflow now uses authkey prefix and coin sending. * script api for balance transfer * scaffold transfer cmd in txs * who am i, functionon keygen, to find your authkey. * patch genesis env issue
- Loading branch information
1 parent
68ef326
commit d0e8573
Showing
41 changed files
with
898 additions
and
155 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
language/diem-framework/modules/0L_transaction_scripts/ol_transfer.move
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
// For transferring balance between accounts. | ||
address 0x1 { | ||
module TransferScripts { | ||
use 0x1::DiemAccount; | ||
use 0x1::GAS::GAS; | ||
use 0x1::Globals; | ||
use 0x1::Signer; | ||
|
||
public(script) fun balance_transfer( | ||
sender: signer, | ||
destination: address, | ||
unscaled_value: u64, | ||
) { | ||
// IMPORTANT: the human representation of a value is unscaled. The user which expects to send 10 coins, will input that as an unscaled_value. This script converts it to the Move internal scale by multiplying by COIN_SCALING_FACTOR. | ||
let value = unscaled_value * Globals::get_coin_scaling_factor(); | ||
let sender_addr = Signer::address_of(&sender); | ||
let sender_balance_pre = DiemAccount::balance<GAS>(sender_addr); | ||
let destination_balance_pre = DiemAccount::balance<GAS>(destination); | ||
|
||
let with_cap = DiemAccount::extract_withdraw_capability(&sender); | ||
DiemAccount::pay_from<GAS>(&with_cap, destination, value, b"balance_transfer", b""); | ||
DiemAccount::restore_withdraw_capability(with_cap); | ||
|
||
assert(DiemAccount::balance<GAS>(destination) > destination_balance_pre, 01); | ||
assert(DiemAccount::balance<GAS>(sender_addr) < sender_balance_pre, 02); | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.