Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/master' into 0.18
Browse files Browse the repository at this point in the history
  • Loading branch information
ynohtna92 committed Apr 27, 2024
2 parents caa46fe + 08bbf56 commit c45472b
Show file tree
Hide file tree
Showing 26 changed files with 475 additions and 174 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,28 @@
Changelog
=========

[0.18.3](https://github.com/ordinals/ord/releases/tag/0.18.3) - 2023-04-19
--------------------------------------------------------------------------

### Added
- Add `dry-run` flag to `resume` command ([#3592](https://github.com/ordinals/ord/pull/3592) by [felipelincoln](https://github.com/felipelincoln))
- Add back runes balances API ([#3571](https://github.com/ordinals/ord/pull/3571) by [lugondev](https://github.com/lugondev))
- Show premine percentage ([#3567](https://github.com/ordinals/ord/pull/3567) by [raphjaph](https://github.com/raphjaph))
- Add default content proxy and decompress to env command ([#3509](https://github.com/ordinals/ord/pull/3509) by [jahvi](https://github.com/jahvi))

### Changed
- Resume cycles through all pending etchings ([#3566](https://github.com/ordinals/ord/pull/3566) by [raphjaph](https://github.com/raphjaph))

### Misc
- Check rune minimum at height before sending ([#3626](https://github.com/ordinals/ord/pull/3626) by [raphjaph](https://github.com/raphjaph))
- Update recursion.md with consistant syntax ([#3585](https://github.com/ordinals/ord/pull/3585) by [zmeyer44](https://github.com/zmeyer44))
- Add test Rune cannot be minted less than limit amount ([#3556](https://github.com/ordinals/ord/pull/3556) by [lugondev](https://github.com/lugondev))
- Clear etching when rune commitment is spent ([#3618](https://github.com/ordinals/ord/pull/3618) by [felipelincoln](https://github.com/felipelincoln))
- Remove timeout for wallet client ([#3621](https://github.com/ordinals/ord/pull/3621) by [raphjaph](https://github.com/raphjaph))
- Remove duplicated word ([#3598](https://github.com/ordinals/ord/pull/3598) by [oxSaturn](https://github.com/oxSaturn))
- Address runes review comments ([#3605](https://github.com/ordinals/ord/pull/3605) by [casey](https://github.com/casey))
- Generate sample batch.yaml in env command ([#3530](https://github.com/ordinals/ord/pull/3530) by [twosatsmaxi](https://github.com/twosatsmaxi))

[0.18.2](https://github.com/ordinals/ord/releases/tag/0.18.2) - 2023-04-17
--------------------------------------------------------------------------

Expand Down
24 changes: 12 additions & 12 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "ord-litecoin"
description = "◉ Ordinal wallet and block explorer for litecoin"
version = "0.18.2"
version = "0.18.3"
license = "CC0-1.0"
edition = "2021"
autotests = false
Expand Down
17 changes: 8 additions & 9 deletions crates/ordinals/src/rune.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,13 @@ impl Rune {
}

pub fn first_rune_height(network: Network) -> u32 {
SUBSIDY_HALVING_INTERVAL
* match network {
Network::Bitcoin => 3,
Network::Regtest => 0,
Network::Signet => 0,
Network::Testnet => 3,
_ => 0,
}
match network {
Network::Bitcoin => 2675600,
Network::Regtest => 0,
Network::Signet => 0,
Network::Testnet => SUBSIDY_HALVING_INTERVAL * 12,
_ => 0,
}
}

pub fn minimum_at_height(chain: Network, height: Height) -> Self {
Expand Down Expand Up @@ -246,7 +245,7 @@ mod tests {
);
}

const START: u32 = SUBSIDY_HALVING_INTERVAL * 4;
const START: u32 = 2675600;
const END: u32 = START + SUBSIDY_HALVING_INTERVAL;
const INTERVAL: u32 = SUBSIDY_HALVING_INTERVAL / 12;

Expand Down
2 changes: 1 addition & 1 deletion docs/src/guides/batch-inscribing.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
Batch Inscribing
================

Multiple inscriptions can be created inscriptions at the same time using the
Multiple inscriptions can be created at the same time using the
[pointer field](./../inscriptions/pointer.md). This is especially helpful for
collections, or other cases when multiple inscriptions should share the same
parent, since the parent can passed into a reveal transaction that creates
Expand Down
2 changes: 1 addition & 1 deletion docs/src/inscriptions/recursion.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ The recursive endpoints are:
- `/r/blocktime`: UNIX time stamp of latest block.
- `/r/children/<INSCRIPTION_ID>`: the first 100 child inscription ids.
- `/r/children/<INSCRIPTION_ID>/<PAGE>`: the set of 100 child inscription ids on `<PAGE>`.
- `/r/inscription/:inscription_id`: information about an inscription
- `/r/inscription/<INSCRIPTION_ID>`: information about an inscription
- `/r/metadata/<INSCRIPTION_ID>`: JSON string containing the hex-encoded CBOR metadata.
- `/r/sat/<SAT_NUMBER>`: the first 100 inscription ids on a sat.
- `/r/sat/<SAT_NUMBER>/<PAGE>`: the set of 100 inscription ids on `<PAGE>`.
Expand Down
7 changes: 5 additions & 2 deletions src/decimal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ impl Decimal {

impl Display for Decimal {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
let magnitude = 10u128.pow(self.scale.into());
let magnitude = 10u128.checked_pow(self.scale.into()).ok_or(fmt::Error)?;

let integer = self.value / magnitude;
let mut fraction = self.value % magnitude;
Expand Down Expand Up @@ -68,7 +68,10 @@ impl FromStr for Decimal {
} else {
let trailing_zeros = decimal.chars().rev().take_while(|c| *c == '0').count();
let significant_digits = decimal.chars().count() - trailing_zeros;
let decimal = decimal.parse::<u128>()? / 10u128.pow(u32::try_from(trailing_zeros).unwrap());
let decimal = decimal.parse::<u128>()?
/ 10u128
.checked_pow(u32::try_from(trailing_zeros).unwrap())
.context("excessive trailing zeros")?;
(decimal, u8::try_from(significant_digits).unwrap())
};

Expand Down
10 changes: 5 additions & 5 deletions src/index.rs
Original file line number Diff line number Diff line change
Expand Up @@ -375,8 +375,8 @@ impl Index {
amount: Some(1),
cap: Some(u128::MAX),
height: (
Some((SUBSIDY_HALVING_INTERVAL * 3).into()),
Some((SUBSIDY_HALVING_INTERVAL * 4).into()),
Some(2675600),
Some((2675600 + SUBSIDY_HALVING_INTERVAL).into()),
),
offset: (None, None),
}),
Expand Down Expand Up @@ -1782,12 +1782,12 @@ impl Index {
};

let max_id = RuneId {
block: block_height + 1,
tx: 0,
block: block_height,
tx: u32::MAX,
};

let runes = rune_id_to_rune_entry
.range(min_id.store()..max_id.store())?
.range(min_id.store()..=max_id.store())?
.map(|result| result.map(|(_, entry)| RuneEntry::load(entry.value()).spaced_rune))
.collect::<Result<Vec<SpacedRune>, StorageError>>()?;

Expand Down
3 changes: 1 addition & 2 deletions src/index/updater/rune_updater.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,7 @@ impl<'a, 'tx, 'client> RuneUpdater<'a, 'tx, 'client> {
.unwrap_or_default();

// assign all un-allocated runes to the default output, or the first non
// OP_RETURN output if there is no default, or if the default output is
// too large
// OP_RETURN output if there is no default
if let Some(vout) = pointer
.map(|pointer| pointer.into_usize())
.inspect(|&pointer| assert!(pointer < allocated.len()))
Expand Down
103 changes: 97 additions & 6 deletions src/runes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3909,6 +3909,100 @@ mod tests {
);
}

#[test]
fn rune_cannot_be_minted_less_than_limit_amount() {
let context = Context::builder().arg("--index-runes").build();

let (txid0, id) = context.etch(
Runestone {
etching: Some(Etching {
rune: Some(Rune(RUNE)),
terms: Some(Terms {
amount: Some(1000),
cap: Some(100),
..default()
}),
..default()
}),
..default()
},
1,
);

context.assert_runes(
[(
id,
RuneEntry {
block: id.block,
etching: txid0,
spaced_rune: SpacedRune {
rune: Rune(RUNE),
spacers: 0,
},
timestamp: id.block,
mints: 0,
terms: Some(Terms {
amount: Some(1000),
cap: Some(100),
..default()
}),
..default()
},
)],
[],
);

let txid1 = context.core.broadcast_tx(TransactionTemplate {
inputs: &[(2, 0, 0, Witness::new())],
outputs: 2,
op_return: Some(
Runestone {
mint: Some(id),
edicts: vec![Edict {
id,
amount: 111,
output: 0,
}],
..default()
}
.encipher(),
),
..default()
});

context.mine_blocks(1);

context.assert_runes(
[(
id,
RuneEntry {
block: id.block,
etching: txid0,
terms: Some(Terms {
amount: Some(1000),
cap: Some(100),
..default()
}),
mints: 1,
spaced_rune: SpacedRune {
rune: Rune(RUNE),
spacers: 0,
},
premine: 0,
timestamp: id.block,
..default()
},
)],
[(
OutPoint {
txid: txid1,
vout: 0,
},
vec![(id, 1000)],
)],
);
}

#[test]
fn etching_with_amount_can_be_minted() {
let context = Context::builder().arg("--index-runes").build();
Expand Down Expand Up @@ -5973,10 +6067,7 @@ mod tests {

#[test]
fn genesis_rune() {
assert_eq!(
Chain::Mainnet.first_rune_height(),
SUBSIDY_HALVING_INTERVAL * 3,
);
assert_eq!(Chain::Mainnet.first_rune_height(), 2675600);

Context::builder()
.chain(Chain::Mainnet)
Expand All @@ -6002,8 +6093,8 @@ mod tests {
amount: Some(1),
cap: Some(u128::MAX),
height: (
Some((SUBSIDY_HALVING_INTERVAL * 3).into()),
Some((SUBSIDY_HALVING_INTERVAL * 4).into()),
Some(2675600),
Some((2675600 + SUBSIDY_HALVING_INTERVAL).into()),
),
offset: (None, None),
}),
Expand Down
8 changes: 4 additions & 4 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@ mod tests {
assert_eq!(
Settings::merge(
Options {
litecoin_rpc_username: Some("foo".into()),
litecoin_rpc_username: Some("foo".into()),
..default()
},
Default::default(),
Expand All @@ -604,7 +604,7 @@ mod tests {
assert_eq!(
Settings::merge(
Options {
litecoin_rpc_password: Some("foo".into()),
litecoin_rpc_password: Some("foo".into()),
..default()
},
Default::default(),
Expand Down Expand Up @@ -897,8 +897,8 @@ mod tests {
#[test]
fn bitcoin_rpc_and_pass_setting() {
let config = Settings {
litecoin_rpc_username: Some("config_user".into()),
litecoin_rpc_password: Some("config_pass".into()),
litecoin_rpc_username: Some("config_user".into()),
litecoin_rpc_password: Some("config_pass".into()),
..default()
};

Expand Down
Loading

0 comments on commit c45472b

Please sign in to comment.