Skip to content

Commit 0fe5319

Browse files
committed
Reform
1 parent 5241335 commit 0fe5319

File tree

7 files changed

+121
-34
lines changed

7 files changed

+121
-34
lines changed

batch.yaml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,13 @@ etching:
4545
offset:
4646
start: 1000
4747
end: 9000
48-
turbo: true,
48+
# future runes protocol changes may be opt-in. this may be for a variety of
49+
# reasons, including that they make light client validation harder, or simply
50+
# because they are too degenerate.
51+
#
52+
# setting `turbo` to `true` opts in to these future protocol changes,
53+
# whatever they may be.
54+
turbo: true
4955

5056
# inscriptions to inscribe
5157
inscriptions:

src/subcommand/server.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2785,7 +2785,7 @@ mod tests {
27852785
<dt>symbol</dt>
27862786
<dd>%</dd>
27872787
<dt>turbo</dt>
2788-
<dd>yes</dd>
2788+
<dd>true</dd>
27892789
<dt>etching</dt>
27902790
<dd><a class=monospace href=/tx/{txid}>{txid}</a></dd>
27912791
<dt>parent</dt>

src/templates/rune.rs

Lines changed: 2 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,5 @@
11
use super::*;
22

3-
enum Foo {
4-
No,
5-
Yes,
6-
}
7-
8-
impl From<bool> for Foo {
9-
fn from(b: bool) -> Self {
10-
match b {
11-
false => Self::No,
12-
true => Self::Yes,
13-
}
14-
}
15-
}
16-
17-
impl Display for Foo {
18-
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
19-
match self {
20-
Self::No => write!(f, "no"),
21-
Self::Yes => write!(f, "yes"),
22-
}
23-
}
24-
}
25-
263
#[derive(Boilerplate, Debug, PartialEq, Serialize, Deserialize)]
274
pub struct RuneHtml {
285
pub entry: RuneEntry,
@@ -117,7 +94,7 @@ mod tests {
11794
<dt>symbol</dt>
11895
<dd>%</dd>
11996
<dt>turbo</dt>
120-
<dd>yes</dd>
97+
<dd>true</dd>
12198
<dt>etching</dt>
12299
<dd><a class=monospace href=/tx/0{64}>0{64}</a></dd>
123100
<dt>parent</dt>
@@ -189,7 +166,7 @@ mod tests {
189166
"<h1>B•CGDENLQRQWDSLRUGSNLBTMFIJAV</h1>
190167
<dl>.*
191168
<dt>turbo</dt>
192-
<dd>no</dd>
169+
<dd>false</dd>
193170
.*</dl>
194171
"
195172
);

src/wallet/batch/plan.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -446,6 +446,10 @@ impl Plan {
446446
edicts: Vec::new(),
447447
etching: Some(ordinals::Etching {
448448
divisibility: (etching.divisibility > 0).then_some(etching.divisibility),
449+
premine: (premine > 0).then_some(premine),
450+
rune: Some(etching.rune.rune),
451+
spacers: (etching.rune.spacers > 0).then_some(etching.rune.spacers),
452+
symbol: Some(etching.symbol),
449453
terms: etching
450454
.terms
451455
.map(|terms| -> Result<ordinals::Terms> {
@@ -463,11 +467,7 @@ impl Plan {
463467
})
464468
})
465469
.transpose()?,
466-
turbo: false,
467-
premine: (premine > 0).then_some(premine),
468-
rune: Some(etching.rune.rune),
469-
spacers: (etching.rune.spacers > 0).then_some(etching.rune.spacers),
470-
symbol: Some(etching.symbol),
470+
turbo: etching.turbo,
471471
}),
472472
mint: None,
473473
pointer: (premine > 0).then_some((reveal_outputs.len() - 1).try_into().unwrap()),

templates/rune.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ <h1>{{ self.entry.spaced_rune }}</h1>
6363
<dd>{{ symbol }}</dd>
6464
%% }
6565
<dt>turbo</dt>
66-
<dd>{{ Foo::from(self.entry.turbo) }}</dd>
66+
<dd>{{ self.entry.turbo }}</dd>
6767
<dt>etching</dt>
6868
<dd><a class=monospace href=/tx/{{ self.entry.etching }}>{{ self.entry.etching }}</a></dd>
6969
%% if let Some(parent) = self.parent {

tests/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -342,6 +342,8 @@ fn batch(core: &mockcore::Handle, ord: &TestServer, batchfile: batch::File) -> E
342342
<dd>{divisibility}</dd>
343343
<dt>symbol</dt>
344344
<dd>{symbol}</dd>
345+
<dt>turbo</dt>
346+
<dd>{turbo}</dd>
345347
<dt>etching</dt>
346348
<dd><a class=monospace href=/tx/{reveal}>{reveal}</a></dd>
347349
<dt>parent</dt>

tests/wallet/batch_command.rs

Lines changed: 103 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1462,7 +1462,109 @@ fn batch_can_etch_rune() {
14621462
ord.assert_response_regex(
14631463
"/rune/AAAAAAAAAAAAA",
14641464
format!(
1465-
r".*<dt>parent</dt>\s*<dd><a class=monospace href=/inscription/{parent}>{parent}</a></dd>.*"
1465+
r".*\s*<dt>turbo</dt>\s*<dd>false</dd>.*<dt>parent</dt>\s*<dd><a class=monospace href=/inscription/{parent}>{parent}</a></dd>.*"
1466+
),
1467+
);
1468+
1469+
let destination = batch
1470+
.output
1471+
.rune
1472+
.unwrap()
1473+
.destination
1474+
.unwrap()
1475+
.require_network(Network::Regtest)
1476+
.unwrap();
1477+
1478+
assert!(core.state().is_wallet_address(&destination));
1479+
1480+
let reveal = core.tx_by_id(batch.output.reveal);
1481+
1482+
assert_eq!(
1483+
reveal.input[0].sequence,
1484+
Sequence::from_height(Runestone::COMMIT_CONFIRMATIONS - 1)
1485+
);
1486+
1487+
let Artifact::Runestone(runestone) = Runestone::decipher(&reveal).unwrap() else {
1488+
panic!();
1489+
};
1490+
1491+
let pointer = reveal.output.len() - 2;
1492+
1493+
assert_eq!(runestone.pointer, Some(pointer.try_into().unwrap()));
1494+
1495+
assert_eq!(
1496+
reveal.output[pointer].script_pubkey,
1497+
destination.script_pubkey(),
1498+
);
1499+
1500+
assert_eq!(
1501+
CommandBuilder::new("--regtest wallet balance")
1502+
.core(&core)
1503+
.ord(&ord)
1504+
.run_and_deserialize_output::<Balance>(),
1505+
Balance {
1506+
cardinal: 44999980000,
1507+
ordinal: 10000,
1508+
runic: Some(10000),
1509+
runes: Some(vec![(rune, 1000)].into_iter().collect()),
1510+
total: 450 * COIN_VALUE,
1511+
}
1512+
);
1513+
}
1514+
1515+
#[test]
1516+
fn batch_can_etch_turbo_rune() {
1517+
let core = mockcore::builder().network(Network::Regtest).build();
1518+
1519+
let ord = TestServer::spawn_with_server_args(&core, &["--regtest", "--index-runes"], &[]);
1520+
1521+
create_wallet(&core, &ord);
1522+
1523+
core.mine_blocks(1);
1524+
1525+
let rune = SpacedRune {
1526+
rune: Rune(RUNE),
1527+
spacers: 0,
1528+
};
1529+
1530+
let batch = batch(
1531+
&core,
1532+
&ord,
1533+
batch::File {
1534+
etching: Some(batch::Etching {
1535+
divisibility: 0,
1536+
rune,
1537+
supply: "1000".parse().unwrap(),
1538+
premine: "1000".parse().unwrap(),
1539+
symbol: '¢',
1540+
terms: None,
1541+
turbo: true,
1542+
}),
1543+
inscriptions: vec![batch::Entry {
1544+
file: "inscription.jpeg".into(),
1545+
..default()
1546+
}],
1547+
..default()
1548+
},
1549+
);
1550+
1551+
let parent = batch.output.inscriptions[0].id;
1552+
1553+
let request = ord.request(format!("/content/{parent}"));
1554+
1555+
assert_eq!(request.status(), 200);
1556+
assert_eq!(request.headers().get("content-type").unwrap(), "image/jpeg");
1557+
assert_eq!(request.text().unwrap(), "inscription");
1558+
1559+
ord.assert_response_regex(
1560+
format!("/inscription/{parent}"),
1561+
r".*<dt>rune</dt>\s*<dd><a href=/rune/AAAAAAAAAAAAA>AAAAAAAAAAAAA</a></dd>.*",
1562+
);
1563+
1564+
ord.assert_response_regex(
1565+
"/rune/AAAAAAAAAAAAA",
1566+
format!(
1567+
r".*\s*<dt>turbo</dt>\s*<dd>true</dd>.*<dt>parent</dt>\s*<dd><a class=monospace href=/inscription/{parent}>{parent}</a></dd>.*"
14661568
),
14671569
);
14681570

0 commit comments

Comments
 (0)