Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions src/common/api/breakaway.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import axios, { AxiosResponse } from "axios"
import * as ls from "../util/local-storage";

// const baUrl = "http://localhost:4000"
const baUrl = "http://localhost:4000"
// const baUrl = "https://breakaway-points-system-api.onrender.com"
const baUrl = "https://api.breakaway.community"
// const baUrl = "https://api.breakaway.community"
const accessToken = ls.get("ba_access_token")

export const createBreakawayUser = async (username: string, community: string, referral: string, email: string)=> {
Expand Down Expand Up @@ -119,7 +119,6 @@ export const getBtcWalletBalance = async (address: string) => {
Authorization: `Bearer ${accessToken}`,
},
});
// console.log(response)

return response.data;
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/common/components/editor-toolbar/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -511,14 +511,14 @@ export class EditorToolbar extends Component<Props> {
</div>
</div>
</Tooltip>
<Tooltip content={_t("editor-toolbar.emoji")}>
{/* <Tooltip content={_t("editor-toolbar.emoji")}>
<div className="editor-tool" role="none">
{emoticonHappyOutlineSvg}
{showEmoji && <EmojiPicker fallback={(e) => {
this.insertText(e, '');
}}/>}
</div>
</Tooltip>
</Tooltip> */}
<Tooltip content="Markdown tutorial">
<a href="https://commonmark.org/help/">
<div className="editor-tool" role="none">
Expand Down
13 changes: 7 additions & 6 deletions src/common/components/profile-card/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ interface Props {
global: Global;
history: History;
activeUser: ActiveUser | any;
account: Account;
account: Account | any;
section?: string;
addAccount: (data: Account) => void;
updateActiveUser: (data?: Account) => void;
Expand Down Expand Up @@ -95,6 +95,7 @@ export const ProfileCard = (props: Props) => {
},[])

useEffect(() => {
console.log(account)
setFollowersList(false);
setFollowingList(false);
setFollowsActiveUserLoading(activeUser && activeUser.username ? true : false);
Expand All @@ -105,7 +106,7 @@ export const ProfileCard = (props: Props) => {
console.log(global)
const getMetaData = () => {
try {
const metaData = JSON.parse(activeUser?.data?.posting_json_metadata);
const metaData = JSON.parse(account?.posting_json_metadata);
setJsonMetaData(metaData)
} catch (error) {
console.log(error)
Expand Down Expand Up @@ -179,20 +180,20 @@ export const ProfileCard = (props: Props) => {
<ResourceCreditsInfo {...props} rcPercent={rcPercent} account={account} />
</div>

{ (global?.communityTitle === "Bitcoin Machines" && global?.hive_id === "hive-159314") &&
{ (global?.hive_id === "hive-125568" || global?.hive_id === "hive-159314") && jsonMetaData?.bitcoin &&
<div className="btc-profile">
<h5>BTC ordinal info</h5>
<div className="btc-info">
<span>Address:</span>
<span className="b-info">{formatString(jsonMetaData?.bitcoin.address)}</span>
<span className="b-info">{formatString(jsonMetaData?.bitcoin?.address)}</span>
</div>
<div className="btc-info">
<span>Message:</span>
<span className="b-info">{jsonMetaData?.bitcoin.message}</span>
<span className="b-info">{jsonMetaData?.bitcoin?.message}</span>
</div>
<div className="btc-info">
<span>Signature:</span>
<span className="b-info">{formatString(jsonMetaData?.bitcoin.signature)}</span>
<span className="b-info">{formatString(jsonMetaData?.bitcoin?.signature)}</span>
</div>
</div> }

Expand Down
21 changes: 11 additions & 10 deletions src/common/components/wallet-bitcoin-machines/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,7 @@ interface Props {
dynamicProps: DynamicProps;
history: History;
activeUser: ActiveUser | any;
account: Account;
account: Account | any;
points: Points;
signingKey: string;
transactions: Transactions;
Expand Down Expand Up @@ -142,7 +142,7 @@ export const WalletBtc = (props: Props) => {
useEffect(() => {
const getMetaData = () => {
try {
const metaData = JSON.parse(activeUser?.data?.posting_json_metadata);
const metaData = JSON.parse(account?.posting_json_metadata);
setJsonMetaData(metaData)
} catch (error) {
console.log(error)
Expand Down Expand Up @@ -215,7 +215,8 @@ export const WalletBtc = (props: Props) => {
<div className="wallet-ecency">
<div className="wallet-main">
<div className="wallet-info">
<div className="balance-row alternative">
{!jsonMetaData?.bitcoin && <div>{account.name} does not have a bitcoin profile</div>}
{jsonMetaData?.bitcoin && <div className="balance-row alternative">
<div className="balance-info">
<div className="title">Btc Address</div>
<div className="description">Your bitcoin wallet address</div>
Expand All @@ -231,9 +232,9 @@ export const WalletBtc = (props: Props) => {
</span>
</div>
</div>
</div>
</div>}

<div className="balance-row alternative">
{jsonMetaData?.bitcoin && <div className="balance-row alternative">
<div className="balance-info">
<div className="title">{communityInfo?.title}</div>
<div className="description">Your bitcoin wallet balance</div>
Expand All @@ -243,9 +244,9 @@ export const WalletBtc = (props: Props) => {
{bitcoinBalance.toFixed(5)} (BTC)
</div>
</div>
</div>
</div>}

<div className="balance-row alternative">
{/* <div className="balance-row alternative">
<div className="balance-info">
<div className="title">Staked Token</div>
<div className="description">Staked tokens are simila to hive power. The more tokens you stake, the more influnce you can have in rewarding other people's content</div>
Expand All @@ -255,9 +256,9 @@ export const WalletBtc = (props: Props) => {
0.000 OrdsToken
</div>
</div>
</div>
</div> */}

<div className="p-transaction-list">
{jsonMetaData?.bitcoin && <div className="p-transaction-list">
<div className="transaction-list-header">
<h2>Bitcoin Wallet Transactions</h2>
</div>
Expand All @@ -277,7 +278,7 @@ export const WalletBtc = (props: Props) => {
</div>
);
})()}
</div>
</div>}
</div>
<WalletMenu global={global} username={account.name} active="ecency" communityInfo={communityInfo} />
</div>
Expand Down
2 changes: 1 addition & 1 deletion src/common/components/wallet-menu/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ export default class WalletMenu extends Component<Props> {
<span className="sub-title">Tokens</span>
<span className="platform-logo">{hiveEngineSvg}</span>
</Link>
{(global?.communityTitle === "Bitcoin Machines" && global?.hive_id === "hive-159314") &&
{(global?.hive_id === "hive-125568" || global?.hive_id === "hive-159314") &&
<Link className={_c(`menu-item bitcoin ${active === "bitcoin" ? "active" : ""}`)} to={`/@${username}/bitcoin-machines`}>
<span className="title">Btc</span>
<span className="sub-title">Ordinals</span>
Expand Down
2 changes: 1 addition & 1 deletion src/common/pages/common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export interface PageProps {
addUser: (user: User) => void;
deleteUser: (username: string) => void;

activeUser: ActiveUser | null;
activeUser: ActiveUser | any;
setActiveUser: (username: string | null) => void;
updateActiveUser: (data?: Account) => void;

Expand Down
25 changes: 24 additions & 1 deletion src/common/pages/submit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ import ModalConfirm from "../components/modal-confirm";
import ResizableTextarea from "../components/resizable-text-area";
import TextareaAutocomplete from "../components/textarea-autocomplete";
import { ThreeSpeakManager } from "../util/ThreeSpeakProvider";
import { updateUserPoints } from "../api/breakaway";
import { updateUserPoints, getBtcWalletBalance } from "../api/breakaway";
import { useThreeSpeakManager } from "../util/ThreeSpeakProvider";
import { getCommunity } from "../api/bridge";

Expand Down Expand Up @@ -532,7 +532,16 @@ class SubmitPage extends BaseComponent<Props, State> {
if (!activeUser || !activeUser.data.__loaded) {
return;
}

const bitcoinBalance = await this.getBitcoinAddressbalance()

if(bitcoinBalance < 1) {
console.log("Insufficient bitcoin balance")
error("Insufficient Btc Balance")
return;
}

// return;
this.stateSet({posting: true});

let author = activeUser.username;
Expand Down Expand Up @@ -797,6 +806,19 @@ class SubmitPage extends BaseComponent<Props, State> {
this.setState({communityData})
}

getBitcoinAddressbalance = async () => {
const {activeUser} = this.props
try {
const metaData = JSON.parse(activeUser?.data?.posting_json_metadata);

const bitcoinBalance = await getBtcWalletBalance(metaData?.bitcoin?.address)
console.log(bitcoinBalance)
return bitcoinBalance.balance
} catch (error) {
console.log(error)
}
}

render() {
const {title, tags, body, reward, preview, posting, editingEntry, saving, editingDraft, advanced, beneficiaries, schedule, reblogSwitch, clearModal, selectedThumbnail, thumbnails, disabled} = this.state;

Expand All @@ -807,6 +829,7 @@ class SubmitPage extends BaseComponent<Props, State> {
};

const {global, activeUser} = this.props;
console.log(activeUser)

const spinner = <Spinner animation="grow" variant="light" size="sm" style={{marginRight: "6px"}}/>;
// const isMobile = typeof window !== 'undefined' && window.innerWidth < 570;
Expand Down