Skip to content

Commit

Permalink
Merge pull request #107 from jrmncos/feat/add-token-braavos-wallet
Browse files Browse the repository at this point in the history
feat: using wallet_watchAsset to interact with Braavos
  • Loading branch information
Darlington02 authored Jul 16, 2024
2 parents d987707 + f2ce180 commit c37ce08
Showing 1 changed file with 8 additions and 9 deletions.
17 changes: 8 additions & 9 deletions frontend/src/app/components/ui_components/AddTokenModal.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
"use client";
import { useEffect, useState } from "react";
import GenericModal from "./GenericModal";
import { WalletAccount } from "starknet";
import { useConnect } from "@starknet-react/core";
const providerUrl = "https://starknet-sepolia.public.blastapi.io";

const AddTokenModal = ({
openAddTokenModal,
Expand All @@ -22,20 +20,21 @@ const AddTokenModal = ({
function handleAddToken() {
const fetchAddToken = async () => {
try {
const myWalletAccount = new WalletAccount(
{ nodeUrl: providerUrl },
// @ts-ignore
connector?._wallet,
);

const resp = await myWalletAccount.watchAsset({
// @ts-ignore
const walletProvider = connector?._wallet
const asset = {
type: "ERC20",
options: {
address: tokenAddress,
symbol,
decimals,
name,
},
};

const resp = await walletProvider.request({
type: 'wallet_watchAsset',
params: asset,
});
console.log(resp);
} catch (err) {
Expand Down

0 comments on commit c37ce08

Please sign in to comment.