Skip to content

Commit

Permalink
Merge main into sweep/add-sweep-config
Browse files Browse the repository at this point in the history
  • Loading branch information
sweep-ai[bot] authored Nov 22, 2023
2 parents 12ba720 + 901d31c commit ce1b343
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 23 deletions.
15 changes: 9 additions & 6 deletions plugin/src/components/DevnetAccountSelector/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,16 +43,17 @@ const DevnetAccountSelector: React.FC = () => {
if (jsonStatus.health) {
setIsDevnetAlive(true)
} else {
setAvailableDevnetAccounts([])
setIsDevnetAlive(false)
}
return
}
if (status !== 'Alive!!!' || response.status !== 200) {
} else if (status !== 'Alive!!!' || response.status !== 200) {
setAvailableDevnetAccounts([])
setIsDevnetAlive(false)
} else {
setIsDevnetAlive(true)
}
} catch (error) {
setAvailableDevnetAccounts([])
setIsDevnetAlive(false)
}
}
Expand Down Expand Up @@ -96,7 +97,8 @@ const DevnetAccountSelector: React.FC = () => {
if (
JSON.stringify(accounts) !== JSON.stringify(availableDevnetAccounts)
) {
setAvailableDevnetAccounts(accounts)
if (accounts !== undefined) setAvailableDevnetAccounts(accounts)
else setAvailableDevnetAccounts([])
}
} catch (e) {
setAvailableDevnetAccounts([])
Expand Down Expand Up @@ -124,9 +126,10 @@ const DevnetAccountSelector: React.FC = () => {
if (
!(
selectedDevnetAccount !== null &&
availableDevnetAccounts !== undefined &&
availableDevnetAccounts.includes(selectedDevnetAccount)
) &&
availableDevnetAccounts.length > 0
(availableDevnetAccounts !== undefined && availableDevnetAccounts.length > 0)
) {
setSelectedDevnetAccount(availableDevnetAccounts[0])
}
Expand Down Expand Up @@ -195,7 +198,7 @@ const DevnetAccountSelector: React.FC = () => {
</D.Trigger>
<D.Portal>
<D.Content>
{isDevnetAlive && availableDevnetAccounts.length > 0
{isDevnetAlive && (availableDevnetAccounts !== undefined && availableDevnetAccounts.length > 0)
? availableDevnetAccounts.map((account, index) => {
return (
<D.Item onClick={() => { handleAccountChange(index) }} key={index}>
Expand Down
39 changes: 22 additions & 17 deletions plugin/src/utils/network.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,26 +28,31 @@ const getAccounts = async (
customDevnetUrl: string = devnetUrl,
isKatana: boolean = false
): Promise<DevnetAccount[]> => {
if (isKatana) {
const response = await fetch(`${customDevnetUrl}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'katana_predeployedAccounts',
params: [],
id: 1
try {
if (isKatana) {
const response = await fetch(`${customDevnetUrl}`, {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
jsonrpc: '2.0',
method: 'katana_predeployedAccounts',
params: [],
id: 1
})
})
})
const jsonResp = await response.json()
const accounts: DevnetAccount[] = jsonResp.result
const jsonResp = await response.json()
const accounts: DevnetAccount[] = jsonResp.result
return accounts
}
const response = await fetch(`${customDevnetUrl}/predeployed_accounts`)
const accounts: DevnetAccount[] = await response.json()
return accounts
} catch (error) {
console.error(error)
return []
}
const response = await fetch(`${customDevnetUrl}/predeployed_accounts`)
const accounts: DevnetAccount[] = await response.json()
return accounts
}

const getAccountBalance = async (
Expand Down

0 comments on commit ce1b343

Please sign in to comment.