Skip to content

Commit

Permalink
docs: fix merkle tree contracts typo issues (#4169)
Browse files Browse the repository at this point in the history
  • Loading branch information
momodaka authored Aug 5, 2024
1 parent 661c793 commit 3ba2211
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions contrib-contracts/modules/MerkleDistributor.move
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@ address StarcoinAssociation {
module MerkleDistributorScripts {
use StarcoinAssociation::MerkleDistributor;
use StarcoinFramework::Account;
public(script) fun create<T: store>(signer: signer, merkle_root: vector<u8>, token_amounts: u128, leafs: u64) {
public(script) fun create<T: store>(signer: signer, merkle_root: vector<u8>, token_amounts: u128, leaves: u64) {
let tokens = Account::withdraw<T>(&signer, token_amounts);
MerkleDistributor::create<T>(&signer, merkle_root, tokens, leafs);
MerkleDistributor::create<T>(&signer, merkle_root, tokens, leaves);
}

public(script) fun claim_for_address<T: store>(distribution_address: address, index: u64, account: address, amount: u128, merkle_proof: vector<vector<u8>>) {
Expand Down Expand Up @@ -72,9 +72,9 @@ module MerkleDistributor {
const ALREADY_CLAIMED: u64 = 2;

/// Initialization.
public fun create<T: store>(signer: &signer, merkle_root: vector<u8>, tokens: Token<T>, leafs: u64) {
let bitmap_count = leafs / 128;
if (bitmap_count * 128 < leafs) {
public fun create<T: store>(signer: &signer, merkle_root: vector<u8>, tokens: Token<T>, leaves: u64) {
let bitmap_count = leaves / 128;
if (bitmap_count * 128 < leaves) {
bitmap_count = bitmap_count + 1;
};
let claimed_bitmap = Vector::empty();
Expand Down
4 changes: 2 additions & 2 deletions contrib-contracts/src/merkle_distributor_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ fn test_merkle_distributor() -> Result<()> {
let merkle_root = MoveValue::vector_u8(raw_root);

let rewards_total = MoveValue::U128(proofs.iter().map(|p| p.amount).sum());
let leafs = MoveValue::U64(proofs.len() as u64);
let leaves = MoveValue::U64(proofs.len() as u64);

let script_function = ScriptFunction::new(
ModuleId::new(
Expand All @@ -64,7 +64,7 @@ fn test_merkle_distributor() -> Result<()> {
vec![
merkle_root.simple_serialize().unwrap(),
rewards_total.simple_serialize().unwrap(),
leafs.simple_serialize().unwrap(),
leaves.simple_serialize().unwrap(),
],
);

Expand Down

0 comments on commit 3ba2211

Please sign in to comment.