Skip to content

Commit 2f3f46a

Browse files
authored
Name audit for 0.24 release (payjoin#803)
2 parents ab142b3 + ba6f515 commit 2f3f46a

File tree

11 files changed

+103
-103
lines changed

11 files changed

+103
-103
lines changed

payjoin-cli/src/app/v2/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ use payjoin::bitcoin::consensus::encode::serialize_hex;
55
use payjoin::bitcoin::{Amount, FeeRate};
66
use payjoin::persist::OptionalTransitionOutcome;
77
use payjoin::receive::v2::{
8-
process_err_res, replay_event_log as replay_receiver_event_log, MaybeInputsOwned,
8+
process_err_res, replay_event_log as replay_receiver_event_log, Initialized, MaybeInputsOwned,
99
MaybeInputsSeen, OutputsUnknown, PayjoinProposal, ProvisionalProposal, Receiver,
10-
ReceiverTypeState, SessionHistory, UncheckedProposal, WantsInputs, WantsOutputs, WithContext,
10+
ReceiverTypeState, SessionHistory, UncheckedProposal, WantsInputs, WantsOutputs,
1111
};
1212
use payjoin::send::v2::{
1313
replay_event_log as replay_sender_event_log, Sender, SenderBuilder, SenderTypeState,
@@ -114,7 +114,7 @@ impl AppTrait for App {
114114
println!("Request Payjoin by sharing this Payjoin Uri:");
115115
println!("{}", pj_uri);
116116

117-
self.process_receiver_session(ReceiverTypeState::WithContext(session.clone()), &persister)
117+
self.process_receiver_session(ReceiverTypeState::Initialized(session.clone()), &persister)
118118
.await?;
119119
Ok(())
120120
}
@@ -251,7 +251,7 @@ impl App {
251251

252252
async fn long_poll_fallback(
253253
&self,
254-
session: Receiver<WithContext>,
254+
session: Receiver<Initialized>,
255255
persister: &ReceiverPersister,
256256
) -> Result<Receiver<UncheckedProposal>> {
257257
let ohttp_relay = self
@@ -287,7 +287,7 @@ impl App {
287287
) -> Result<()> {
288288
let res = {
289289
match session {
290-
ReceiverTypeState::WithContext(proposal) =>
290+
ReceiverTypeState::Initialized(proposal) =>
291291
self.read_from_directory(proposal, persister).await,
292292
ReceiverTypeState::UncheckedProposal(proposal) =>
293293
self.check_proposal(proposal, persister).await,
@@ -307,7 +307,7 @@ impl App {
307307
self.send_payjoin_proposal(proposal, persister).await,
308308
ReceiverTypeState::Uninitialized(_) =>
309309
return Err(anyhow!("Uninitialized receiver session")),
310-
ReceiverTypeState::TerminalState =>
310+
ReceiverTypeState::TerminalFailure =>
311311
return Err(anyhow!("Terminal receiver session")),
312312
}
313313
};
@@ -331,7 +331,7 @@ impl App {
331331
#[allow(clippy::incompatible_msrv)]
332332
async fn read_from_directory(
333333
&self,
334-
session: Receiver<WithContext>,
334+
session: Receiver<Initialized>,
335335
persister: &ReceiverPersister,
336336
) -> Result<()> {
337337
let mut interrupt = self.interrupt.clone();

payjoin-ffi/python/test/test_payjoin_integration_test.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ def setUpClass(cls):
6161
cls.sender = cls.env.get_sender()
6262

6363
async def process_receiver_proposal(self, receiver: ReceiverTypeState, recv_persister: InMemoryReceiverSessionEventLog, ohttp_relay: Url) -> Optional[ReceiverTypeState]:
64-
if receiver.is_WITH_CONTEXT():
64+
if receiver.is_INITIALIZED():
6565
res = await self.retrieve_receiver_proposal(receiver.inner, recv_persister, ohttp_relay)
6666
if res is None:
6767
return None
@@ -87,11 +87,11 @@ async def process_receiver_proposal(self, receiver: ReceiverTypeState, recv_pers
8787
raise Exception(f"Unknown receiver state: {receiver}")
8888

8989

90-
def create_receiver_context(self, receiver_address: bitcoinffi.Address, directory: Url, ohttp_keys: OhttpKeys, recv_persister: InMemoryReceiverSessionEventLog) -> WithContext:
90+
def create_receiver_context(self, receiver_address: bitcoinffi.Address, directory: Url, ohttp_keys: OhttpKeys, recv_persister: InMemoryReceiverSessionEventLog) -> Initialized:
9191
receiver = UninitializedReceiver().create_session(address=receiver_address, directory=directory.as_string(), ohttp_keys=ohttp_keys, expire_after=None).save(recv_persister)
9292
return receiver
9393

94-
async def retrieve_receiver_proposal(self, receiver: WithContext, recv_persister: InMemoryReceiverSessionEventLog, ohttp_relay: Url):
94+
async def retrieve_receiver_proposal(self, receiver: Initialized, recv_persister: InMemoryReceiverSessionEventLog, ohttp_relay: Url):
9595
agent = httpx.AsyncClient()
9696
request: RequestResponse = receiver.extract_req(ohttp_relay.as_string())
9797
response = await agent.post(
@@ -150,7 +150,7 @@ async def test_integration_v2_to_v2(self):
150150
recv_persister = InMemoryReceiverSessionEventLog(1)
151151
sender_persister = InMemorySenderPersister(1)
152152
session = self.create_receiver_context(receiver_address, directory, ohttp_keys, recv_persister)
153-
process_response = await self.process_receiver_proposal(ReceiverTypeState.WITH_CONTEXT(session), recv_persister, ohttp_relay)
153+
process_response = await self.process_receiver_proposal(ReceiverTypeState.INITIALIZED(session), recv_persister, ohttp_relay)
154154
print(f"session: {session.to_json()}")
155155
self.assertIsNone(process_response)
156156

@@ -173,7 +173,7 @@ async def test_integration_v2_to_v2(self):
173173
# Inside the Receiver:
174174

175175
# GET fallback psbt
176-
payjoin_proposal = await self.process_receiver_proposal(ReceiverTypeState.WITH_CONTEXT(session), recv_persister, ohttp_relay)
176+
payjoin_proposal = await self.process_receiver_proposal(ReceiverTypeState.INITIALIZED(session), recv_persister, ohttp_relay)
177177
self.assertIsNotNone(payjoin_proposal)
178178
self.assertEqual(payjoin_proposal.is_PAYJOIN_PROPOSAL(), True)
179179

payjoin-ffi/python/test/test_payjoin_unit_test.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def test_receiver_persistence(self):
5757
None
5858
).save(persister)
5959
result = payjoin.payjoin_ffi.replay_receiver_event_log(persister)
60-
self.assertTrue(result.state().is_WITH_CONTEXT())
60+
self.assertTrue(result.state().is_INITIALIZED())
6161

6262
class InMemorySenderPersister(payjoin.payjoin_ffi.JsonSenderSessionPersister):
6363
def __init__(self, id):

payjoin-ffi/src/receive/mod.rs

Lines changed: 24 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ pub struct InitInputsTransition(
6262
Option<
6363
payjoin::persist::MaybeBadInitInputsTransition<
6464
payjoin::receive::v2::SessionEvent,
65-
payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>,
65+
payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>,
6666
payjoin::IntoUrlError,
6767
>,
6868
>,
@@ -71,7 +71,7 @@ pub struct InitInputsTransition(
7171
);
7272

7373
impl InitInputsTransition {
74-
pub fn save<P>(&self, persister: &P) -> Result<WithContext, ReceiverPersistedError>
74+
pub fn save<P>(&self, persister: &P) -> Result<Initialized, ReceiverPersistedError>
7575
where
7676
P: SessionPersister<SessionEvent = payjoin::receive::v2::SessionEvent>,
7777
{
@@ -98,7 +98,7 @@ impl From<UninitializedReceiver>
9898
}
9999

100100
impl UninitializedReceiver {
101-
/// Creates a new [`WithContext`] with the provided parameters.
101+
/// Creates a new [`Initialized`] with the provided parameters.
102102
///
103103
/// # Parameters
104104
/// - `address`: The Bitcoin address for the payjoin session.
@@ -107,7 +107,7 @@ impl UninitializedReceiver {
107107
/// - `expire_after`: The duration after which the session expires.
108108
///
109109
/// # Returns
110-
/// A new instance of [`WithContext`].
110+
/// A new instance of [`Initialized`].
111111
///
112112
/// # References
113113
/// - [BIP 77: Payjoin Version 2: Serverless Payjoin](https://github.com/bitcoin/bips/blob/master/bip-0077.md)
@@ -129,35 +129,35 @@ impl UninitializedReceiver {
129129
}
130130

131131
#[derive(Clone, Debug, serde::Serialize, serde::Deserialize)]
132-
pub struct WithContext(payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>);
132+
pub struct Initialized(payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>);
133133

134-
impl From<WithContext> for payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext> {
135-
fn from(value: WithContext) -> Self { value.0 }
134+
impl From<Initialized> for payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized> {
135+
fn from(value: Initialized) -> Self { value.0 }
136136
}
137137

138-
impl From<payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>> for WithContext {
139-
fn from(value: payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>) -> Self {
138+
impl From<payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>> for Initialized {
139+
fn from(value: payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>) -> Self {
140140
Self(value)
141141
}
142142
}
143143

144-
pub struct WithContextTransition(
144+
pub struct InitializedTransition(
145145
Arc<
146146
RwLock<
147147
Option<
148148
payjoin::persist::MaybeFatalTransitionWithNoResults<
149149
payjoin::receive::v2::SessionEvent,
150150
payjoin::receive::v2::Receiver<payjoin::receive::v2::UncheckedProposal>,
151-
payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>,
151+
payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>,
152152
payjoin::receive::Error,
153153
>,
154154
>,
155155
>,
156156
>,
157157
);
158158

159-
impl WithContextTransition {
160-
pub fn save<P>(&self, persister: &P) -> Result<WithContextTransitionOutcome, ReceiverPersistedError>
159+
impl InitializedTransition {
160+
pub fn save<P>(&self, persister: &P) -> Result<InitializedTransitionOutcome, ReceiverPersistedError>
161161
where
162162
P: SessionPersister<SessionEvent = payjoin::receive::v2::SessionEvent>,
163163
{
@@ -173,14 +173,14 @@ impl WithContextTransition {
173173
}
174174
}
175175

176-
pub struct WithContextTransitionOutcome(
176+
pub struct InitializedTransitionOutcome(
177177
payjoin::persist::OptionalTransitionOutcome<
178178
payjoin::receive::v2::Receiver<payjoin::receive::v2::UncheckedProposal>,
179-
payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>,
179+
payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>,
180180
>,
181181
);
182182

183-
impl WithContextTransitionOutcome {
183+
impl InitializedTransitionOutcome {
184184
pub fn is_none(&self) -> bool { self.0.is_none() }
185185

186186
pub fn is_success(&self) -> bool { self.0.is_success() }
@@ -194,21 +194,21 @@ impl
194194
From<
195195
payjoin::persist::OptionalTransitionOutcome<
196196
payjoin::receive::v2::Receiver<payjoin::receive::v2::UncheckedProposal>,
197-
payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>,
197+
payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>,
198198
>,
199-
> for WithContextTransitionOutcome
199+
> for InitializedTransitionOutcome
200200
{
201201
fn from(
202202
value: payjoin::persist::OptionalTransitionOutcome<
203203
payjoin::receive::v2::Receiver<payjoin::receive::v2::UncheckedProposal>,
204-
payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>,
204+
payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>,
205205
>,
206206
) -> Self {
207207
Self(value)
208208
}
209209
}
210210

211-
impl WithContext {
211+
impl Initialized {
212212
pub fn extract_req(&self, ohttp_relay: String) -> Result<(Request, ClientResponse), Error> {
213213
self.0
214214
.clone()
@@ -218,15 +218,15 @@ impl WithContext {
218218
}
219219

220220
///The response can either be an UncheckedProposal or an ACCEPTED message indicating no UncheckedProposal is available yet.
221-
pub fn process_res(&self, body: &[u8], ctx: &ClientResponse) -> WithContextTransition {
222-
WithContextTransition(Arc::new(RwLock::new(Some(
221+
pub fn process_res(&self, body: &[u8], ctx: &ClientResponse) -> InitializedTransition {
222+
InitializedTransition(Arc::new(RwLock::new(Some(
223223
self.0.clone().process_res(body, ctx.into()),
224224
))))
225225
}
226226

227227
/// Build a V2 Payjoin URI from the receiver's context
228228
pub fn pj_uri(&self) -> crate::PjUri {
229-
<Self as Into<payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>>>::into(
229+
<Self as Into<payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>>>::into(
230230
self.clone(),
231231
)
232232
.pj_uri()
@@ -238,7 +238,7 @@ impl WithContext {
238238
}
239239

240240
pub fn from_json(json: &str) -> Result<Self, SerdeJsonError> {
241-
serde_json::from_str::<payjoin::receive::v2::Receiver<payjoin::receive::v2::WithContext>>(
241+
serde_json::from_str::<payjoin::receive::v2::Receiver<payjoin::receive::v2::Initialized>>(
242242
json,
243243
)
244244
.map_err(Into::into)

0 commit comments

Comments
 (0)