Skip to content

Commit 75f5363

Browse files
authored
Update aliases, add Identifier constructor (WASM) (#1732)
* Add/update aliases * Add Identifier constructor * Prepare release
1 parent 070b27a commit 75f5363

File tree

7 files changed

+40
-14
lines changed

7 files changed

+40
-14
lines changed

bindings_wasm/CHANGELOG.md

+6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# @xmtp/wasm-bindings
22

3+
## 1.0.0-rc2
4+
5+
- Updated some WASM aliases to remove references to addresses
6+
- Added new camelCase aliases
7+
- Added `Identifier` class constructor
8+
39
## 1.0.0-rc1
410

511
- Added `pausedForVersion` to groups for client enforcement

bindings_wasm/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@xmtp/wasm-bindings",
3-
"version": "1.0.0-rc1",
3+
"version": "1.0.0-rc2",
44
"type": "module",
55
"license": "MIT",
66
"description": "WASM bindings for the libXMTP rust library",

bindings_wasm/src/client.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ pub async fn create_client(
184184

185185
#[wasm_bindgen]
186186
impl Client {
187-
#[wasm_bindgen(getter, js_name = accountAddress)]
187+
#[wasm_bindgen(getter, js_name = accountIdentifier)]
188188
pub fn account_identifier(&self) -> Identifier {
189189
self.account_identifier.clone()
190190
}
@@ -286,7 +286,7 @@ impl Client {
286286
Ok(())
287287
}
288288

289-
#[wasm_bindgen(js_name = findInboxIdByAddress)]
289+
#[wasm_bindgen(js_name = findInboxIdByIdentifier)]
290290
pub async fn find_inbox_id_by_identifier(
291291
&self,
292292
identifier: Identifier,

bindings_wasm/src/conversation.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ pub struct GroupMember {
5757
#[wasm_bindgen(js_name = inboxId)]
5858
#[serde(rename = "inboxId")]
5959
pub inbox_id: String,
60-
#[wasm_bindgen(js_name = accountAddresses)]
60+
#[wasm_bindgen(js_name = accountIdentifiers)]
6161
#[serde(rename = "accountIdentifiers")]
6262
pub account_identifiers: Vec<Identifier>,
6363
#[wasm_bindgen(js_name = installationIds)]
@@ -75,11 +75,11 @@ pub struct GroupMember {
7575
impl GroupMember {
7676
#[wasm_bindgen(constructor)]
7777
pub fn new(
78-
inbox_id: String,
79-
account_identifiers: Vec<Identifier>,
80-
installation_ids: Vec<String>,
81-
permission_level: PermissionLevel,
82-
consent_state: ConsentState,
78+
#[wasm_bindgen(js_name = inboxId)] inbox_id: String,
79+
#[wasm_bindgen(js_name = accountIdentifiers)] account_identifiers: Vec<Identifier>,
80+
#[wasm_bindgen(js_name = installationIds)] installation_ids: Vec<String>,
81+
#[wasm_bindgen(js_name = permissionLevel)] permission_level: PermissionLevel,
82+
#[wasm_bindgen(js_name = consentState)] consent_state: ConsentState,
8383
) -> Self {
8484
Self {
8585
inbox_id,

bindings_wasm/src/identity.rs

+18
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,28 @@ use xmtp_id::associations::{ident, Identifier as XmtpIdentifier};
66
#[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize)]
77
pub struct Identifier {
88
pub identifier: String,
9+
#[wasm_bindgen(js_name = identifierKind)]
910
pub identifier_kind: IdentifierKind,
11+
#[wasm_bindgen(js_name = relyingParty)]
1012
pub relying_party: Option<String>,
1113
}
1214

15+
#[wasm_bindgen]
16+
impl Identifier {
17+
#[wasm_bindgen(constructor)]
18+
pub fn new(
19+
identifier: String,
20+
#[wasm_bindgen(js_name = identifierKind)] identifier_kind: IdentifierKind,
21+
#[wasm_bindgen(js_name = relyingParty)] relying_party: Option<String>,
22+
) -> Self {
23+
Self {
24+
identifier,
25+
identifier_kind,
26+
relying_party,
27+
}
28+
}
29+
}
30+
1331
#[wasm_bindgen]
1432
#[derive(Clone, Debug, Hash, PartialEq, Eq, Serialize)]
1533
pub enum IdentifierKind {

bindings_wasm/src/inbox_id.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@ use xmtp_api::{strategies, ApiClientWrapper, ApiIdentifier};
44
use xmtp_api_http::XmtpHttpApiClient;
55
use xmtp_id::associations::Identifier as XmtpIdentifier;
66

7-
#[wasm_bindgen(js_name = getInboxIdForAddress)]
8-
pub async fn get_inbox_id_for_address(
7+
#[wasm_bindgen(js_name = getInboxIdForIdentifier)]
8+
pub async fn get_inbox_id_for_identifier(
99
host: String,
10-
account_identifier: Identifier,
10+
#[wasm_bindgen(js_name = accountIdentifier)] account_identifier: Identifier,
1111
) -> Result<Option<String>, JsError> {
1212
let api_client = ApiClientWrapper::new(
1313
XmtpHttpApiClient::new(host.clone(), "0.0.0".into())?.into(),
@@ -25,7 +25,9 @@ pub async fn get_inbox_id_for_address(
2525
}
2626

2727
#[wasm_bindgen(js_name = generateInboxId)]
28-
pub fn generate_inbox_id(account_identifier: Identifier) -> Result<String, JsError> {
28+
pub fn generate_inbox_id(
29+
#[wasm_bindgen(js_name = accountIdentifier)] account_identifier: Identifier,
30+
) -> Result<String, JsError> {
2931
// ensure that the nonce is always 1 for now since this will only be used for the
3032
// create_client function above, which also has a hard-coded nonce of 1
3133
let ident: XmtpIdentifier = account_identifier.try_into()?;

bindings_wasm/src/inbox_state.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct InboxState {
3131
#[wasm_bindgen(js_name = recoveryIdentifier)]
3232
pub recovery_identifier: Identifier,
3333
pub installations: Vec<Installation>,
34-
#[wasm_bindgen(js_name = accountAddresses)]
34+
#[wasm_bindgen(js_name = accountIdentifiers)]
3535
pub account_identifiers: Vec<Identifier>,
3636
}
3737

0 commit comments

Comments
 (0)