Skip to content

Commit

Permalink
Merge pull request #89 from MeshJS/fetchAssetAddresses
Browse files Browse the repository at this point in the history
Fetch asset addresses
  • Loading branch information
abdelkrimdev authored Feb 4, 2023
2 parents 0269936 + ed7ab75 commit e759d68
Show file tree
Hide file tree
Showing 30 changed files with 314 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Generate Wallet
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Generate new mnemonic phrases for your wallet
</p>
</div>
<RunDemoButton
runDemoFn={runDemoGetMnemonic}
loading={loading}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,16 @@ function Left() {

function Right() {
const { name } = useWallet();
const wallets = useWalletList();
const hasAvailableWallets = wallets.length > 0;

return (
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Connect Wallet
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Connect to a CIP30 compatible wallet
</p>
</div>

<Codeblock
data={`const wallet = await BrowserWallet.enable('${
name ? name : 'eternl'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Assets
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get assets in the connected wallet
</p>
</div>
<Codeblock
data={`const assets = await wallet.getAssets();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Balance
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get all assets in the connected wallet
</p>
</div>
<Codeblock
data={`const balance = await wallet.getBalance();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Change Address
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get address that should be used for transaction's change
</p>
</div>
<Codeblock
data={`const changeAddress = await wallet.getChangeAddress();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ export default function GetInstalledWallets() {
return (
<SectionTwoCol
sidebarTo="getInstallWallets"
header="Get installed wallets"
header="Get Installed Wallets"
leftFn={Left()}
rightFn={Right()}
/>
Expand Down Expand Up @@ -41,6 +41,12 @@ function Right() {
}
return (
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Installed Wallets
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get a list of wallets on user's device
</p>
</div>
<Codeblock data={`BrowserWallet.getInstalledWallets();`} isJson={false} />
<RunDemoButton
runDemoFn={runDemo}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Lovelace
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get amount of ADA in connected wallet
</p>
</div>
<Codeblock
data={`const lovelace = await wallet.getLovelace();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Network ID
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get currently connected network
</p>
</div>
<Codeblock
data={`const networkId = await wallet.getNetworkId();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,12 @@ function Right({ policyId, setPolicyId }) {
}
return (
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get a Collection of Assets
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get a list of assets belonging to the policy ID
</p>
</div>
<Input
value={policyId}
onChange={(e) => setPolicyId(e.target.value)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Policy IDs
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get a list of policy IDs from all assets in wallet
</p>
</div>
<Codeblock
data={`const policyIds = await wallet.getPolicyIds();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Reward Addresses
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get stake addresses
</p>
</div>
<Codeblock
data={`const rewardAddresses = await wallet.getRewardAddresses();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Unused Addresses
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get addresses that are unused
</p>
</div>
<Codeblock
data={`const unusedAddresses = await wallet.getUnusedAddresses();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get Used Addresses
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get addresses that are used
</p>
</div>
<Codeblock
data={`const usedAddresses = await wallet.getUsedAddresses();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ function Right() {
return (
<>
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Get UTXOs
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Get UTXOs of the connected wallet
</p>
</div>
<Codeblock
data={`const utxos = await wallet.getUtxos();`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,12 @@ function Right(payload, setPayload) {

return (
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Sign Data
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Use connected wallet to sign a payload
</p>
</div>
<Input
value={payload}
onChange={(e) => setPayload(e.target.value)}
Expand Down
6 changes: 6 additions & 0 deletions packages/demo/components/pages/apis/browserwallet/signTx.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ function Left() {
function Right() {
return (
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Sign Transaction
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Use connected wallet to sign a transaction
</p>
</div>
<Codeblock
data={`const signedTx = await wallet.signTx(tx, partialSign?);`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,12 @@ function Left() {
function Right() {
return (
<Card>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Submit Transaction
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Use connected wallet to submit a transaction
</p>
</div>
<Codeblock
data={`const txHash = await wallet.submitTx(signedTx);`}
isJson={false}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,10 +119,14 @@ export function evaluateTxRight({ evaluator }) {
return (
<>
<Card>
<p>
Unlock an asset from the always succeed to check how much it takes to
execute this transaction.
</p>
<div className="p-5 text-lg font-semibold text-left text-gray-900 bg-white dark:text-white dark:bg-gray-800">
Evaluate Transaction
<p className="mt-1 text-sm font-normal text-gray-500 dark:text-gray-400">
Unlock an asset from the always succeed to check how much it takes
to execute this transaction.
</p>
</div>

{connected ? (
<>
<RunDemoButton
Expand Down
27 changes: 27 additions & 0 deletions packages/demo/components/pages/providers/fetcher.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ import {
fetchBlockInfoLeft,
fetchBlockInfoRight,
} from './fetchers/fetchBlockInfo';
import {
fetchCollectionAssetsLeft,
fetchCollectionAssetsRight,
} from './fetchers/fetchCollectionAssets';

export default function Fetcher({ fetcher, fetcherName }) {
const { wallet, connected } = useWallet();
Expand Down Expand Up @@ -65,6 +69,10 @@ export default function Fetcher({ fetcher, fetcherName }) {
const [block, setBlock] = useState<string>(
'79f60880b097ec7dabb81f75f0b52fedf5e922d4f779a11c0c432dcf22c56089'
);
const [policyId, setPolicyId] = useState<string>(
'd9312da562da182b02322fd8acb536f37eb9d29fba7c49dc17255527'
);
const [cursor, setCursor] = useState<string>('1');

// useEffect(() => {
// async function init() {
Expand Down Expand Up @@ -164,6 +172,25 @@ export default function Fetcher({ fetcher, fetcherName }) {
badge={<BadgeFetcher />}
/>

<SectionTwoCol
sidebarTo="fetchCollectionAssets"
header="fetchCollectionAssets"
leftFn={fetchCollectionAssetsLeft({
fetcherName,
policyId,
cursor,
})}
rightFn={fetchCollectionAssetsRight({
fetcher,
policyId,
setPolicyId,
cursor,
setCursor,
})}
isH3={true}
badge={<BadgeFetcher />}
/>

<SectionTwoCol
sidebarTo="fetchHandleAddress"
header="fetchHandleAddress"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Codeblock from '../../../ui/codeblock';
import Input from '../../../ui/input';

export function fetchAccountInfoLeft({ fetcherName, fetchAccountInfoAddress }) {
let code1 = `await ${fetcherName}.fetchAddressUTxOs(\n`;
let code1 = `await ${fetcherName}.fetchAccountInfo(\n`;
code1 += ` '${fetchAccountInfoAddress}',\n`;
code1 += `)`;
return (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export function fetchAssetAddressesLeft({
fetcherName,
fetchAssetAddressesAsset,
}) {
let code1 = `await ${fetcherName}.fetchAssetAddress(\n`;
let code1 = `await ${fetcherName}.fetchAssetAddresses(\n`;
code1 += ` '${fetchAssetAddressesAsset}',\n`;
code1 += `)`;
return (
Expand Down
Loading

1 comment on commit e759d68

@vercel
Copy link

@vercel vercel bot commented on e759d68 Feb 4, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.