mirror of
https://github.com/alexgo-io/stacks-puppet-node.git
synced 2026-05-24 08:09:52 +08:00
refactor: Rename "address" to "recipient" in peg-in operation + SQL comment in sortdb
This commit is contained in:
@@ -414,7 +414,7 @@ impl FromRow<PegInOp> for PegInOp {
|
||||
let block_height = u64::from_column(row, "block_height")?;
|
||||
let burn_header_hash = BurnchainHeaderHash::from_column(row, "burn_header_hash")?;
|
||||
|
||||
let address = StacksAddress::from_column(row, "address")?;
|
||||
let recipient = StacksAddress::from_column(row, "recipient")?;
|
||||
let peg_wallet_address = PoxAddress::from_column(row, "peg_wallet_address")?;
|
||||
let amount = row
|
||||
.get::<_, String>("amount")?
|
||||
@@ -426,7 +426,7 @@ impl FromRow<PegInOp> for PegInOp {
|
||||
vtxindex,
|
||||
block_height,
|
||||
burn_header_hash,
|
||||
address,
|
||||
recipient,
|
||||
peg_wallet_address,
|
||||
amount,
|
||||
})
|
||||
@@ -732,7 +732,7 @@ const SORTITION_DB_SCHEMA_5: &'static [&'static str] = &[r#"
|
||||
block_height INTEGER NOT NULL,
|
||||
burn_header_hash TEXT NOT NULL,
|
||||
|
||||
address TEXT NOT NULL,
|
||||
recipient TEXT NOT NULL, -- Stacks address to receive the sBTC, can also be a smart contract address
|
||||
peg_wallet_address TEXT NOT NULL,
|
||||
amount TEXT NOT NULL,
|
||||
|
||||
@@ -4800,12 +4800,12 @@ impl<'a> SortitionHandleTx<'a> {
|
||||
&op.vtxindex,
|
||||
&u64_to_sql(op.block_height)?,
|
||||
&op.burn_header_hash,
|
||||
&op.address.to_string(),
|
||||
&op.recipient.to_string(),
|
||||
&op.peg_wallet_address.to_string(),
|
||||
&op.amount.to_string(),
|
||||
];
|
||||
|
||||
self.execute("REPLACE INTO peg_in (txid, vtxindex, block_height, burn_header_hash, address, peg_wallet_address, amount) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)", args)?;
|
||||
self.execute("REPLACE INTO peg_in (txid, vtxindex, block_height, burn_header_hash, recipient, peg_wallet_address, amount) VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7)", args)?;
|
||||
|
||||
Ok(())
|
||||
}
|
||||
@@ -6235,7 +6235,7 @@ pub mod tests {
|
||||
let burn_header_hash = BurnchainHeaderHash([0x03; 32]);
|
||||
|
||||
let peg_in = PegInOp {
|
||||
address,
|
||||
recipient: address,
|
||||
peg_wallet_address,
|
||||
amount,
|
||||
|
||||
|
||||
@@ -315,7 +315,7 @@ pub struct DelegateStxOp {
|
||||
|
||||
#[derive(Debug, PartialEq, Clone, Eq, Serialize, Deserialize)]
|
||||
pub struct PegInOp {
|
||||
pub address: StacksAddress,
|
||||
pub recipient: StacksAddress,
|
||||
pub peg_wallet_address: PoxAddress,
|
||||
pub amount: u64, // BTC amount to peg in, in satoshis
|
||||
|
||||
|
||||
@@ -27,7 +27,7 @@ impl PegInOp {
|
||||
return Err(OpError::InvalidInput);
|
||||
};
|
||||
|
||||
let address = Self::parse_data(&tx.data())?;
|
||||
let recipient = Self::parse_data(&tx.data())?;
|
||||
|
||||
let txid = tx.txid();
|
||||
let vtxindex = tx.vtxindex();
|
||||
@@ -35,7 +35,7 @@ impl PegInOp {
|
||||
let burn_header_hash = block_header.block_hash;
|
||||
|
||||
Ok(Self {
|
||||
address,
|
||||
recipient,
|
||||
peg_wallet_address,
|
||||
amount,
|
||||
txid,
|
||||
@@ -122,7 +122,7 @@ mod tests {
|
||||
|
||||
let op = PegInOp::from_tx(&header, &tx).expect("Failed to construct peg-in operation");
|
||||
|
||||
assert_eq!(op.address, stx_address);
|
||||
assert_eq!(op.recipient, stx_address);
|
||||
assert_eq!(op.amount, amount);
|
||||
assert_eq!(op.peg_wallet_address.bytes(), peg_wallet_address);
|
||||
}
|
||||
|
||||
@@ -1041,8 +1041,8 @@ impl BitcoinRegtestController {
|
||||
let op_bytes = {
|
||||
let mut bytes = self.config.burnchain.magic_bytes.as_bytes().to_vec();
|
||||
bytes.push(Opcodes::PegIn as u8);
|
||||
bytes.push(payload.address.version);
|
||||
bytes.extend_from_slice(payload.address.bytes.as_bytes());
|
||||
bytes.push(payload.recipient.version);
|
||||
bytes.extend_from_slice(payload.recipient.bytes.as_bytes());
|
||||
bytes
|
||||
};
|
||||
|
||||
|
||||
@@ -10468,7 +10468,7 @@ fn test_submit_and_observe_peg_in_request() {
|
||||
|
||||
// Let's send a Peg-in op.
|
||||
let peg_in_op = PegInOp {
|
||||
address: receiver_stx_addr,
|
||||
recipient: receiver_stx_addr,
|
||||
peg_wallet_address,
|
||||
amount: 1337,
|
||||
txid: Txid([0u8; 32]),
|
||||
@@ -10501,7 +10501,7 @@ fn test_submit_and_observe_peg_in_request() {
|
||||
|
||||
let parsed_peg_in_op = ops.first().unwrap();
|
||||
|
||||
assert_eq!(parsed_peg_in_op.address, peg_in_op.address);
|
||||
assert_eq!(parsed_peg_in_op.recipient, peg_in_op.recipient);
|
||||
assert_eq!(parsed_peg_in_op.amount, peg_in_op.amount);
|
||||
assert_eq!(
|
||||
parsed_peg_in_op.peg_wallet_address,
|
||||
|
||||
Reference in New Issue
Block a user