Skip to content

Commit

Permalink
Fix naming conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
josediegorobles committed Dec 11, 2023
1 parent 86fc832 commit 5616a2e
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 26 deletions.
8 changes: 4 additions & 4 deletions lib/web/rgb.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,11 @@

import * as BMC from "./bitmask_core";

export const issueContract = async (
export const fullIssueContract = async (
nostrHexSk: string,
request: IssuePreRequest
request: FullIssueRequest
): Promise<IssueResponse> =>
JSON.parse(await BMC.issue_contract(nostrHexSk, request));
JSON.parse(await BMC.full_issue_contract(nostrHexSk, request));

export const createInvoice = async (
nostrHexSk: string,
Expand Down Expand Up @@ -250,7 +250,7 @@ export interface IssueMetadata {
collectible?: NewCollectible[];
}

export interface IssuePreRequest {
export interface FullIssueRequest {
/// The ticker of the asset
ticker: string;
/// Name of the asset
Expand Down
22 changes: 19 additions & 3 deletions src/web.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ use wasm_bindgen_futures::{future_to_promise, JsFuture};

use crate::rgb::structs::ContractAmount;
use crate::structs::{
AcceptRequest, FullRgbTransferRequest, ImportRequest, InvoiceRequest, IssueMediaRequest,
IssuePreRequest, IssueRequest, MediaRequest, PsbtRequest, PublishPsbtRequest, ReIssueRequest,
AcceptRequest, FullIssueRequest, FullRgbTransferRequest, ImportRequest, InvoiceRequest,
IssueMediaRequest, IssueRequest, MediaRequest, PsbtRequest, PublishPsbtRequest, ReIssueRequest,
RgbBidRequest, RgbOfferRequest, RgbRemoveTransferRequest, RgbSaveTransferRequest,
RgbSwapRequest, RgbTransferRequest, SecretString, SignPsbtRequest, WatcherRequest,
};
Expand Down Expand Up @@ -381,7 +381,23 @@ pub mod rgb {
set_panic_hook();

future_to_promise(async move {
let pre_req: IssuePreRequest = serde_wasm_bindgen::from_value(request).unwrap();
let req: IssueRequest = serde_wasm_bindgen::from_value(request).unwrap();
match crate::rgb::issue_contract(&nostr_hex_sk, req).await {
Ok(result) => Ok(JsValue::from_string(
serde_json::to_string(&result).unwrap(),
)),
Err(err) => Err(JsValue::from_string(err.to_string())),
}
})
}

#[allow(clippy::too_many_arguments)]
#[wasm_bindgen]
pub fn full_issue_contract(nostr_hex_sk: String, request: JsValue) -> Promise {
set_panic_hook();

future_to_promise(async move {
let pre_req: FullIssueRequest = serde_wasm_bindgen::from_value(request).unwrap();
let media = match pre_req.meta {
Some(media) => {
let media = crate::rgb::import_uda_data(media).await;
Expand Down
6 changes: 3 additions & 3 deletions tests/rgb/web/contracts.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
use bitmask_core::{
info,
structs::{
ContractsResponse, DecryptedWalletData, IssuePreRequest, NextAddressResponse,
ContractsResponse, DecryptedWalletData, FullIssueRequest, NextAddressResponse,
NextUtxoResponse, SecretString, WatcherRequest, WatcherResponse,
},
web::{
Expand Down Expand Up @@ -93,7 +93,7 @@ async fn allow_issue_and_list_contracts() {
let supply = 5;
let issue_utxo = next_utxo;
let issue_seal = format!("tapret1st:{issue_utxo}");
let issue_req = IssuePreRequest {
let issue_req = FullIssueRequest {
ticker: "DIBA".to_string(),
name: "DIBA".to_string(),
description: "DIBA".to_string(),
Expand All @@ -105,7 +105,7 @@ async fn allow_issue_and_list_contracts() {
};

let issue_req = serde_wasm_bindgen::to_value(&issue_req).expect("");
let issue_resp: JsValue = resolve(issue_contract(sk.to_string(), issue_req)).await;
let issue_resp: JsValue = resolve(full_issue_contract(sk.to_string(), issue_req)).await;

Check failure on line 108 in tests/rgb/web/contracts.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0425]: cannot find function `full_issue_contract` in this scope --> tests/rgb/web/contracts.rs:108:39 | 108 | let issue_resp: JsValue = resolve(full_issue_contract(sk.to_string(), issue_req)).await; | ^^^^^^^^^^^^^^^^^^^ | ::: /home/runner/work/bitmask-core/bitmask-core/src/web.rs:380:5 | 380 | pub fn issue_contract(nostr_hex_sk: String, request: JsValue) -> Promise { | ------------------------------------------------------------------------ similarly named function `issue_contract` defined here | help: a function with a similar name exists | 108 | let issue_resp: JsValue = resolve(issue_contract(sk.to_string(), issue_req)).await; | ~~~~~~~~~~~~~~ help: consider importing this function | 5 + use bitmask_core::web::rgb::full_issue_contract; |

info!("List Contracts");
let list_contracts_resp: JsValue = resolve(list_contracts(sk.to_string())).await;
Expand Down
12 changes: 6 additions & 6 deletions tests/rgb/web/proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use bitmask_core::{
rgb::{prefetch::prefetch_resolver_txs, resolvers::ExplorerResolver},
structs::{
AssetType, BatchRgbTransferResponse, ContractResponse, ContractsResponse,
DecryptedWalletData, FullRgbTransferRequest, FundVaultDetails, ImportRequest,
InvoiceRequest, InvoiceResponse, IssueMediaRequest, IssuePreRequest, IssueResponse,
DecryptedWalletData, FullIssueRequest, FullRgbTransferRequest, FundVaultDetails,
ImportRequest, InvoiceRequest, InvoiceResponse, IssueMediaRequest, IssueResponse,
MediaItemRequest, MediaRequest, MediaResponse, NextAddressResponse, NextUtxoResponse,
PsbtFeeRequest, PublishedPsbtResponse, RgbSaveTransferRequest, RgbTransferRequest,
RgbTransferResponse, RgbTransferStatusResponse, SecretString, SignPsbtRequest, WalletData,
Expand Down Expand Up @@ -158,7 +158,7 @@ async fn import_and_get_consig_from_proxy() {
let precision = 2;
let issue_utxo = issuer_next_utxo.utxo.unwrap().outpoint.to_string();
let issue_seal = format!("tapret1st:{issue_utxo}");
let issue_req = IssuePreRequest {
let issue_req = FullIssueRequest {
ticker: "DIBA".to_string(),
name: "DIBA".to_string(),
description: "DIBA".to_string(),
Expand All @@ -170,7 +170,7 @@ async fn import_and_get_consig_from_proxy() {
};

let issue_req = serde_wasm_bindgen::to_value(&issue_req).expect("");
let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await;
let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await;

Check failure on line 173 in tests/rgb/web/proxy.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0425]: cannot find function `full_issue_contract` in this scope --> tests/rgb/web/proxy.rs:173:39 | 173 | let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await; | ^^^^^^^^^^^^^^^^^^^ | ::: /home/runner/work/bitmask-core/bitmask-core/src/web.rs:380:5 | 380 | pub fn issue_contract(nostr_hex_sk: String, request: JsValue) -> Promise { | ------------------------------------------------------------------------ similarly named function `issue_contract` defined here | help: a function with a similar name exists | 173 | let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await; | ~~~~~~~~~~~~~~ help: consider importing this function | 5 + use bitmask_core::web::rgb::full_issue_contract; |
let issuer_resp: IssueResponse = json_parse(&issue_resp);

info!("Import Contract (Owner)");
Expand Down Expand Up @@ -368,7 +368,7 @@ async fn create_uda_with_medias() {
let precision = 0;
let issue_utxo = issuer_next_utxo.utxo.unwrap().outpoint.to_string();
let issue_seal = format!("tapret1st:{issue_utxo}");
let issue_req = IssuePreRequest {
let issue_req = FullIssueRequest {
ticker: "DIBA".to_string(),
name: "DIBA".to_string(),
description: "DIBA".to_string(),
Expand All @@ -380,6 +380,6 @@ async fn create_uda_with_medias() {
};

let issue_req = serde_wasm_bindgen::to_value(&issue_req).expect("");
let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await;
let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await;

Check failure on line 383 in tests/rgb/web/proxy.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0425]: cannot find function `full_issue_contract` in this scope --> tests/rgb/web/proxy.rs:383:39 | 383 | let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await; | ^^^^^^^^^^^^^^^^^^^ | ::: /home/runner/work/bitmask-core/bitmask-core/src/web.rs:380:5 | 380 | pub fn issue_contract(nostr_hex_sk: String, request: JsValue) -> Promise { | ------------------------------------------------------------------------ similarly named function `issue_contract` defined here | help: a function with a similar name exists | 383 | let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await; | ~~~~~~~~~~~~~~ help: consider importing this function | 5 + use bitmask_core::web::rgb::full_issue_contract; |
let issuer_resp: IssueResponse = json_parse(&issue_resp);
}
8 changes: 4 additions & 4 deletions tests/rgb/web/swaps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ use bitmask_core::{
rgb::{prefetch::prefetch_resolver_txs, resolvers::ExplorerResolver},
structs::{
AssetType, BatchRgbTransferResponse, ContractResponse, ContractsResponse,
DecryptedWalletData, FullRgbTransferRequest, FundVaultDetails, ImportRequest,
InvoiceRequest, InvoiceResponse, IssuePreRequest, IssueResponse, NextAddressResponse,
DecryptedWalletData, FullIssueRequest, FullRgbTransferRequest, FundVaultDetails,
ImportRequest, InvoiceRequest, InvoiceResponse, IssueResponse, NextAddressResponse,
NextUtxoResponse, PsbtFeeRequest, PublishedPsbtResponse, RgbBidRequest, RgbBidResponse,
RgbOfferRequest, RgbOfferResponse, RgbSaveTransferRequest, RgbSwapRequest, RgbSwapResponse,
RgbTransferRequest, RgbTransferResponse, RgbTransferStatusResponse, SecretString,
Expand Down Expand Up @@ -180,7 +180,7 @@ async fn create_transfer_swap_flow() {
let precision = 2;
let issue_utxo = issuer_next_utxo.utxo.unwrap().outpoint.to_string();
let issue_seal = format!("tapret1st:{issue_utxo}");
let issue_req = IssuePreRequest {
let issue_req = FullIssueRequest {
ticker: "DIBA".to_string(),
name: "DIBA".to_string(),
description: "DIBA".to_string(),
Expand All @@ -192,7 +192,7 @@ async fn create_transfer_swap_flow() {
};

let issue_req = serde_wasm_bindgen::to_value(&issue_req).expect("");
let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await;
let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await;

Check failure on line 195 in tests/rgb/web/swaps.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0425]: cannot find function `full_issue_contract` in this scope --> tests/rgb/web/swaps.rs:195:39 | 195 | let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await; | ^^^^^^^^^^^^^^^^^^^ | ::: /home/runner/work/bitmask-core/bitmask-core/src/web.rs:380:5 | 380 | pub fn issue_contract(nostr_hex_sk: String, request: JsValue) -> Promise { | ------------------------------------------------------------------------ similarly named function `issue_contract` defined here | help: a function with a similar name exists | 195 | let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await; | ~~~~~~~~~~~~~~ help: consider importing this function | 5 + use bitmask_core::web::rgb::full_issue_contract; |
let issuer_resp: IssueResponse = json_parse(&issue_resp);

info!("Import Contract (Owner)");
Expand Down
12 changes: 6 additions & 6 deletions tests/rgb/web/transfers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ use bitmask_core::{
rgb::{prefetch::prefetch_resolver_txs, resolvers::ExplorerResolver},
structs::{
AssetType, BatchRgbTransferResponse, ContractResponse, ContractsResponse,
DecryptedWalletData, FullRgbTransferRequest, FundVaultDetails, ImportRequest,
InvoiceRequest, InvoiceResponse, IssuePreRequest, IssueResponse, NextAddressResponse,
DecryptedWalletData, FullIssueRequest, FullRgbTransferRequest, FundVaultDetails,
ImportRequest, InvoiceRequest, InvoiceResponse, IssueResponse, NextAddressResponse,
NextUtxoResponse, PsbtFeeRequest, PublishedPsbtResponse, RgbSaveTransferRequest,
RgbTransferRequest, RgbTransferResponse, RgbTransferStatusResponse, SecretString,
SignPsbtRequest, WalletData, WatcherRequest, WatcherResponse,
Expand Down Expand Up @@ -155,7 +155,7 @@ async fn create_transfer_with_fee_value() {
let precision = 2;
let issue_utxo = issuer_next_utxo.utxo.unwrap().outpoint.to_string();
let issue_seal = format!("tapret1st:{issue_utxo}");
let issue_req = IssuePreRequest {
let issue_req = FullIssueRequest {
ticker: "DIBA".to_string(),
name: "DIBA".to_string(),
description: "DIBA".to_string(),
Expand All @@ -167,7 +167,7 @@ async fn create_transfer_with_fee_value() {
};

let issue_req = serde_wasm_bindgen::to_value(&issue_req).expect("");
let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await;
let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await;

Check failure on line 170 in tests/rgb/web/transfers.rs

View workflow job for this annotation

GitHub Actions / lint-wasm

error[E0425]: cannot find function `full_issue_contract` in this scope --> tests/rgb/web/transfers.rs:170:39 | 170 | let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await; | ^^^^^^^^^^^^^^^^^^^ | ::: /home/runner/work/bitmask-core/bitmask-core/src/web.rs:380:5 | 380 | pub fn issue_contract(nostr_hex_sk: String, request: JsValue) -> Promise { | ------------------------------------------------------------------------ similarly named function `issue_contract` defined here | help: a function with a similar name exists | 170 | let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await; | ~~~~~~~~~~~~~~ help: consider importing this function | 5 + use bitmask_core::web::rgb::full_issue_contract; |
let issuer_resp: IssueResponse = json_parse(&issue_resp);

info!("Import Contract (Owner)");
Expand Down Expand Up @@ -460,7 +460,7 @@ async fn create_transfer_with_fee_rate() {
let precision = 2;
let issue_utxo = issuer_next_utxo.utxo.unwrap().outpoint.to_string();
let issue_seal = format!("tapret1st:{issue_utxo}");
let issue_req = IssuePreRequest {
let issue_req = FullIssueRequest {
ticker: "DIBA".to_string(),
name: "DIBA".to_string(),
description: "DIBA".to_string(),
Expand All @@ -472,7 +472,7 @@ async fn create_transfer_with_fee_rate() {
};

let issue_req = serde_wasm_bindgen::to_value(&issue_req).expect("");
let issue_resp: JsValue = resolve(issue_contract(issuer_sk.to_string(), issue_req)).await;
let issue_resp: JsValue = resolve(full_issue_contract(issuer_sk.to_string(), issue_req)).await;
let issuer_resp: IssueResponse = json_parse(&issue_resp);

info!("Import Contract (Owner)");
Expand Down

0 comments on commit 5616a2e

Please sign in to comment.