Skip to content

Commit

Permalink
Add Same-T Fund functionality
Browse files Browse the repository at this point in the history
Add same-t fund functionality
Fixed some small bugs
  • Loading branch information
grctest committed Sep 11, 2024
1 parent f755e21 commit 8f9284a
Show file tree
Hide file tree
Showing 48 changed files with 1,447 additions and 85 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ Integrates with both the [Beet](https://github.com/bitshares/beet) and [BeetEOS]
* Create prediction market assets
* Buy Life Time Membership for your account
* User configurable blockchain node connections

* Create/update/delete Same-T Funds

## Dev Commands

Expand Down
122 changes: 61 additions & 61 deletions src/components/CreatePrediction.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -317,96 +317,96 @@ export default function Prediction(properties) {
setCommissionFunction(0);
return;
}

const split = parsedInput.toString().split(".");
if (split.length > 1) {
const decimals = split[1].length;
if (decimals > 2) {
parsedInput = parseFloat(parsedInput.toFixed(2));
}
}

if (parsedInput > 100) {
setCommissionFunction(100);
} else if (parsedInput < 0.01) {
setCommissionFunction(0.01);
} else {
setCommissionFunction(parsedInput);
}

e.currentTarget.value = input;

}, 500),
[]
);
);

const [whitelistMarketFeeSharingDialogOpen, setWhitelistMarketFeeSharingDialogOpen] = useState(false);
const [whitelistAuthorityDialogOpen, setWhitelistAuthorityDialogOpen] = useState(false);
const [blacklistAuthorityDialogOpen, setBlacklistAuthorityDialogOpen] = useState(false);
const [whitelistMarketFeeSharingDialogOpen, setWhitelistMarketFeeSharingDialogOpen] = useState(false);
const [whitelistAuthorityDialogOpen, setWhitelistAuthorityDialogOpen] = useState(false);
const [blacklistAuthorityDialogOpen, setBlacklistAuthorityDialogOpen] = useState(false);

const feeSharingWhitelistRow = ({ index, style }) => {
const feeSharingWhitelistRow = ({ index, style }) => {
let res = feeSharingWhitelist[index];
if (!res) {
return null;
}

return (
<div style={{ ...style }} key={`acard-${res.id}`}>
<Card className="ml-2 mr-2 mt-1">
<Card className="ml-2 mr-2 mt-1">
<CardHeader className="pb-3 pt-3">
<span className="grid grid-cols-12">
<span className="grid grid-cols-12">
<span className="col-span-1">
<Avatar
<Avatar
size={40} name={res.name} extra="Borrower"
expression={{ eye: "normal", mouth: "open" }}
colors={["#92A1C6", "#146A7C", "#F0AB3D", "#C271B4", "#C20D90"]}
/>
/>
</span>
<span className="col-span-10 ml-3">
#{index + 1}: {res.name} ({res.id})
</span>
<span className="col-span-1">
<Button
variant="outline"
className="mr-2"
onClick={(e) => {
e.preventDefault();
const _update = feeSharingWhitelist.filter((x) => x.id !== res.id);
setFeeSharingWhitelist(_update);
}}
>
</Button>
<Button
variant="outline"
className="mr-2"
onClick={(e) => {
e.preventDefault();
const _update = feeSharingWhitelist.filter((x) => x.id !== res.id);
setFeeSharingWhitelist(_update);
}}
>
</Button>
</span>
</span>
</span>
</CardHeader>
</Card>
</Card>
</div>
);
};
};

const whitelistAuthorityRow = ({ index, style }) => {
const whitelistAuthorityRow = ({ index, style }) => {
let res = whitelistAuthorities[index];
if (!res) {
return null;
return null;
}

return (
<div style={{ ...style }} key={`acard-${res.id}`}>
<div style={{ ...style }} key={`acard-${res.id}`}>
<Card className="ml-2 mr-2 mt-1">
<CardHeader className="pb-3 pt-3">
<CardHeader className="pb-3 pt-3">
<span className="grid grid-cols-12">
<span className="col-span-1">
<span className="col-span-1">
<Avatar
size={40} name={res.name} extra="Borrower"
expression={{ eye: "normal", mouth: "open" }}
colors={["#92A1C6", "#146A7C", "#F0AB3D", "#C271B4", "#C20D90"]}
size={40} name={res.name} extra="Borrower"
expression={{ eye: "normal", mouth: "open" }}
colors={["#92A1C6", "#146A7C", "#F0AB3D", "#C271B4", "#C20D90"]}
/>
</span>
<span className="col-span-10 ml-3">
#{index + 1}: {res.name} ({res.id})
</span>
<span className="col-span-1">
</span>
<span className="col-span-10 ml-3">
#{index + 1}: {res.name} ({res.id})
</span>
<span className="col-span-1">
<Button
variant="outline"
className="mr-2"
Expand All @@ -418,36 +418,36 @@ export default function Prediction(properties) {
>
</Button>
</span>
</span>
</span>
</CardHeader>
</CardHeader>
</Card>
</div>
</div>
);
};
};

const blacklistAuthorityRow = ({ index, style }) => {
const blacklistAuthorityRow = ({ index, style }) => {
let res = blacklistAuthorities[index];
if (!res) {
return null;
return null;
}

return (
<div style={{ ...style }} key={`acard-${res.id}`}>
<div style={{ ...style }} key={`acard-${res.id}`}>
<Card className="ml-2 mr-2 mt-1">
<CardHeader className="pb-3 pt-3">
<CardHeader className="pb-3 pt-3">
<span className="grid grid-cols-12">
<span className="col-span-1">
<span className="col-span-1">
<Avatar
size={40} name={res.name} extra="Borrower"
expression={{ eye: "normal", mouth: "open" }}
colors={["#92A1C6", "#146A7C", "#F0AB3D", "#C271B4", "#C20D90"]}
size={40} name={res.name} extra="Borrower"
expression={{ eye: "normal", mouth: "open" }}
colors={["#92A1C6", "#146A7C", "#F0AB3D", "#C271B4", "#C20D90"]}
/>
</span>
<span className="col-span-9 ml-3">
#{index + 1}: {res.name} ({res.id})
</span>
<span className="col-span-1">
</span>
<span className="col-span-9 ml-3">
#{index + 1}: {res.name} ({res.id})
</span>
<span className="col-span-1">
<Button
variant="outline"
className="mr-2"
Expand All @@ -459,13 +459,13 @@ export default function Prediction(properties) {
>
</Button>
</span>
</span>
</span>
</CardHeader>
</CardHeader>
</Card>
</div>
</div>
);
}
}

return (
<>
Expand Down
2 changes: 1 addition & 1 deletion src/components/CreditDeals.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ export default function CreditDeals(properties) {
let unsubscribeLenderDeals;

if (usr && usr.id) {
const lenderDealsStore = createLenderDealsStore([usr.chain, usr.id]);
const lenderDealsStore = createLenderDealsStore([usr.chain, usr.id, currentNode ? currentNode.url : null]);

unsubscribeLenderDeals = lenderDealsStore.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
Expand Down
6 changes: 3 additions & 3 deletions src/components/CreditOffer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ function hoursTillExpiration(expirationTime) {
return hours;
}

export default function CreditBorrow(properties) {
export default function CreditOffer(properties) {
const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance });
const form = useForm({
defaultValues: {
Expand Down Expand Up @@ -225,7 +225,7 @@ export default function CreditBorrow(properties) {
return;
}

const offerStore = createObjectStore([_chain, JSON.stringify([id])]);
const offerStore = createObjectStore([_chain, JSON.stringify([id]), currentNode ? currentNode.url : null]);
offerStore.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
const foundOffer = data[0];
Expand Down Expand Up @@ -437,7 +437,7 @@ export default function CreditBorrow(properties) {
if (foundOwner) {
setOwner(foundOwner);
} else {
const userStore = createObjectStore([_chain, JSON.stringify([relevantOffer.owner_account])]);
const userStore = createObjectStore([_chain, JSON.stringify([relevantOffer.owner_account]), currentNode ? currentNode.url : null]);
userStore.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
const foundUser = data[0];
Expand Down
4 changes: 2 additions & 2 deletions src/components/CreditOfferEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -277,7 +277,7 @@ export default function CreditOfferEditor(properties) {
let unsub;

if (offerID && usr && usr.chain) {
const offerDataStore = createObjectStore([usr.chain, JSON.stringify([offerID])]);
const offerDataStore = createObjectStore([usr.chain, JSON.stringify([offerID]), currentNode ? currentNode.url : null]);
unsub = offerDataStore.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
const _data = data[0];
Expand Down Expand Up @@ -348,7 +348,7 @@ export default function CreditOfferEditor(properties) {
const _batchIDs = _identityBatch.flatMap(Object.keys);
console.log({ _batchIDs });

const usernameDataStore = createUsernameStore([usr.chain, _batchIDs]);
const usernameDataStore = createUsernameStore([usr.chain, _batchIDs, currentNode ? currentNode.url : null]);
unsub = usernameDataStore.subscribe(({ data }) => {
if (data && !data.error && !data.loading) {
/*
Expand Down
2 changes: 1 addition & 1 deletion src/components/CreditOffers.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ function hoursTillExpiration(expirationTime) {
return hours;
}

export default function CreditBorrow(properties) {
export default function CreditOffers(properties) {
const { t, i18n } = useTranslation(locale.get(), { i18n: i18nInstance });
const usr = useSyncExternalStore($currentUser.subscribe, $currentUser.get, () => true);

Expand Down
21 changes: 21 additions & 0 deletions src/components/Home.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,27 @@ export default function Home(properties) {
</ul>
</HoverCardContent>
</HoverCard>

<HoverCard key="tfunds">
<HoverCardTrigger asChild>
<a href="/tfunds/index.html" style={{ textDecoration: "none" }}>
<Card className="h-full hover:shadow-md hover:shadow-black">
<CardHeader>
<CardTitle>{t("Home:tfunds.title")}</CardTitle>
<CardDescription>{t("Home:tfunds.subtitle")}</CardDescription>
</CardHeader>
</Card>
</a>
</HoverCardTrigger>
<HoverCardContent className="w-80 text-sm pt-1">
<ul className="ml-2 list-disc [&>li]:mt-2">
<li>{t("Home:tfunds.hover1")}</li>
<li>{t("Home:tfunds.hover2")}</li>
<li>{t("Home:tfunds.hover3")}</li>
<li>{t("Home:tfunds.hover4")}</li>
</ul>
</HoverCardContent>
</HoverCard>
</div>

<h4 className="mt-3 mb-2">
Expand Down
4 changes: 2 additions & 2 deletions src/components/Predictions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ export default function Predictions(properties) {
const [pmaProcessedData, setPmaProcessedData] = useState([]);
useEffect(() => {
async function fetching() {
const _store = createObjectStore([_chain, JSON.stringify(predictionMarketAssets.map(x => x.id)), currentNode.url]);
const _store = createObjectStore([_chain, JSON.stringify(predictionMarketAssets.map(x => x.id)), currentNode ? currentNode.url : null]);

_store.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
Expand Down Expand Up @@ -250,7 +250,7 @@ export default function Predictions(properties) {
const [completedPMAs, setCompletedPMAs] = useState([]);
useEffect(() => {
async function fetching() {
const _store = createObjectStore([_chain, JSON.stringify(pmaProcessedData.map(x => x.bitasset_data_id)), currentNode.url]);
const _store = createObjectStore([_chain, JSON.stringify(pmaProcessedData.map(x => x.bitasset_data_id)), currentNode ? currentNode.url : null]);

_store.subscribe(({ data, error, loading }) => {
if (data && !error && !loading) {
Expand Down
Loading

0 comments on commit 8f9284a

Please sign in to comment.