-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added a bunch of secretswap files among other things
- Loading branch information
Showing
53 changed files
with
18,526 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import BigNumber from "bignumber.js"; | ||
// import { UserStoreEx } from 'stores/UserStore'; | ||
// import React from 'react'; | ||
// import Style from 'style-it'; | ||
import { humanizeBalance } from "@/utils/secretjs/SecretSwapSite/utils"; | ||
import { ExecuteResult } from "secretjs"; | ||
|
||
// export const ERROR_WRONG_VIEWING_KEY = 'Viewing Key Error'; | ||
|
||
// export async function getNativeBalance(walletAddress: string, secretjs: CosmWasmClient) { | ||
// return secretjs.getAccount(walletAddress).then(account => { | ||
// try { | ||
// const scrt_account = account.balance.find((acc) => acc.denom === 'uscrt'); | ||
// return new BigNumber(scrt_account.amount); | ||
// } catch (error) { | ||
// return new BigNumber(0); | ||
// } | ||
// }); | ||
// } | ||
|
||
// export const unlockJsx = (props: { onClick: any }) => | ||
// Style.it( | ||
// `.view-token-button { | ||
// cursor: pointer; | ||
// border-radius: 30px; | ||
// padding: 0 0.25rem; | ||
// margin: 0; | ||
// border: none; | ||
// } | ||
|
||
// .view-token-button:hover { | ||
// background: #cb9b5150; | ||
// }`, | ||
// <span role="img" aria-label={'view'} className="view-token-button" onClick={props.onClick}> | ||
// 🔍 View Balance | ||
// </span>, | ||
// ); | ||
|
||
// export const wrongViewingKey = <strong style={{ color: 'red' }}>Wrong Viewing Key</strong>; | ||
|
||
// export async function getTokenBalance( | ||
// walletAddress: string, | ||
// tokenAddress: string, | ||
// viewingKey: string, | ||
// userStore: UserStoreEx, | ||
// ): Promise<BigNumber | JSX.Element> { | ||
// if (!viewingKey) { | ||
// return unlockJsx({ | ||
// onClick: async e => { | ||
// await userStore.keplrWallet.suggestToken(userStore.chainId, tokenAddress); | ||
// // TODO trigger balance refresh if this was an "advanced set" that didn't | ||
// // result in an on-chain transaction | ||
// await userStore.updateScrtBalance(); | ||
// }, | ||
// }); | ||
// } | ||
|
||
// // todo: replace this with the function from blockchain-bridge/scrt/snip20 | ||
// const result = await userStore.secretjs.queryContractSmart(tokenAddress, { | ||
// balance: { | ||
// address: walletAddress, | ||
// key: viewingKey, | ||
// }, | ||
// }); | ||
|
||
// if (viewingKey && 'viewing_key_error' in result) { | ||
// // TODO handle this | ||
// return ( | ||
// <strong | ||
// style={{ | ||
// marginLeft: '0.2em', | ||
// color: 'red', | ||
// }} | ||
// > | ||
// {ERROR_WRONG_VIEWING_KEY} | ||
// </strong> | ||
// ); | ||
// } | ||
|
||
// try { | ||
// return new BigNumber(result.balance.amount); | ||
// } catch (error) { | ||
// console.log( | ||
// `Got an error while trying to query token ${tokenAddress} balance for address ${walletAddress}:`, | ||
// result, | ||
// error, | ||
// ); | ||
// return unlockJsx({ | ||
// onClick: async e => { | ||
// await userStore.keplrWallet.suggestToken(userStore.chainId, tokenAddress); | ||
// // TODO trigger balance refresh if this was an "advanced set" that didn't | ||
// // result in an on-chain transaction | ||
// }, | ||
// }); | ||
// } | ||
// } | ||
|
||
export function compareNormalize( | ||
number1: BigNumber.Value, | ||
number2: { amount: BigNumber.Value; decimals: number } | ||
): boolean { | ||
return humanizeBalance( | ||
new BigNumber(number2.amount as any), | ||
number2.decimals | ||
).isLessThan(new BigNumber(number1)); | ||
} | ||
|
||
export function storeTxResultLocally(txResult: ExecuteResult) { | ||
if (!localStorage || !localStorage.setItem || !txResult.transactionHash) { | ||
return; | ||
} | ||
const result = { | ||
data: new TextDecoder().decode(txResult.data), | ||
logs: txResult.logs, | ||
}; | ||
localStorage.setItem(txResult.transactionHash, JSON.stringify(result)); | ||
} | ||
|
||
export const shareOfPoolNumberFormat = new Intl.NumberFormat("en", { | ||
maximumFractionDigits: 10, | ||
}); |
Oops, something went wrong.