Skip to content

Commit

Permalink
Rename localhost network to devnet
Browse files Browse the repository at this point in the history
  • Loading branch information
h0ngcha0 committed Feb 3, 2023
1 parent 81d4eae commit 4eaf829
Show file tree
Hide file tree
Showing 20 changed files with 43 additions and 39 deletions.
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"packages": ["packages/*"],
"version": "0.5.0-rc0",
"version": "0.5.0-rc.1",
"npmClient": "yarn",
"useWorkspaces": true
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": "0.5.0-rc0",
"version": "0.5.0-rc.1",
"private": true,
"name": "alephium-browser-extension-wallet",
"repository": "github:alephium/extension-wallet",
Expand Down
4 changes: 2 additions & 2 deletions packages/dapp/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alephium/dapp",
"version": "0.5.0-rc0",
"version": "0.5.0-rc.1",
"private": true,
"scripts": {
"dev": "next dev",
Expand All @@ -11,7 +11,7 @@
},
"dependencies": {
"@alephium/web3": "v0.3.0-rc.7",
"@alephium/get-extension-wallet": "^0.5.0-rc0",
"@alephium/get-extension-wallet": "^0.5.0-rc.1",
"@argent/get-starknet": "^5.2.0",
"@argent/x-sessions": "^5.2.0",
"ethers": "^5.5.1",
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/pages/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const Home: NextPage = () => {
{isConnected ? (
<>
<h3 style={{ margin: 0 }}>
Wallet address: <code>{address && address}</code>
Wallet address: <code>{address}</code>
</h3>
<h3 style={{ margin: 0 }}>
Network: <code>{network}</code>
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp/src/services/token.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export const erc20TokenAddressByNetwork = {
}

export type PublicNetwork = keyof typeof erc20TokenAddressByNetwork
export type Network = PublicNetwork | "localhost"
export type Network = PublicNetwork | "devnet"

export type TokenBalance = {
id: string
Expand Down
4 changes: 2 additions & 2 deletions packages/dapp/src/services/wallet.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const silentConnectWallet = async (
onDisconnected: () => Promise<void>
) => {
const windowAlephium = await connect({ showList: false })
await windowAlephium?.enable({ onDisconnected, networkId: 'localhost', chainGroup: 0 })
await windowAlephium?.enable({ onDisconnected, networkId: 'devnet', chainGroup: 0 })
return windowAlephium
}

Expand All @@ -22,7 +22,7 @@ export const connectWallet = async (

await windowAlephium?.enable({
onDisconnected,
networkId: 'localhost',
networkId: 'devnet',
chainGroup: 0
})

Expand Down
2 changes: 1 addition & 1 deletion packages/extension/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alephium/extension",
"version": "0.5.0-rc0",
"version": "0.5.0-rc.1",
"main": "index.js",
"license": "MIT",
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/assets/default-alephium-tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"name": "ALPH",
"symbol": "ALPH",
"decimals": "18",
"network": "localhost",
"network": "devnet",
"image": "https://raw.githubusercontent.com/alephium/alephium-brand-guide/a4680dc86d6061a8d08468ebb42d659ab74db64a/logos/light/Logo-Icon.svg",
"showAlways": true
},
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/assets/default-tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
"name": "Ether",
"symbol": "ETH",
"decimals": "18",
"network": "localhost",
"network": "devnet",
"image": "https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png",
"showAlways": true
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@ export const calculateEstimateFeeFromL1Gas = async (
): Promise<EstimateFee> => {
const fallbackPrice = number.toBN(10e14)
try {
if (account.networkId === "localhost") {
console.log("Using fallback gas price for localhost")
if (account.networkId === "devnet") {
console.log("Using fallback gas price for devnet")
return {
overall_fee: fallbackPrice,
suggestedMaxFee: stark.estimatedFeeToMaxFee(fallbackPrice),
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/src/background/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ export class Wallet {

const networks = defaultNetworks
.map((network) => network.id)
.filter((networkId) => networkId !== "localhost")
.filter((networkId) => networkId !== "devnet")
const accountsResults = await Promise.all(
networks.map(async (networkId) => {
const network = await this.getNetwork(networkId)
Expand Down
10 changes: 5 additions & 5 deletions packages/extension/src/shared/network/defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import { Network } from "./type"

const DEV_ONLY_NETWORKS: Network[] = [
{
id: 'localhost',
id: 'devnet',
nodeUrl: 'http://127.0.0.1:22973',
explorerApiUrl: 'http://localhost:9090',
explorerUrl: 'http://localhost:3000',
name: 'Localhost',
name: 'Devnet',
chainId: 2
}
]
Expand All @@ -30,13 +30,13 @@ export const defaultNetworks: Network[] = [
chainId: 1
},
{
id: 'localhost',
id: 'devnet',
nodeUrl: 'http://127.0.0.1:22973',
explorerApiUrl: 'http://localhost:9090',
explorerUrl: 'http://localhost:3000',
name: 'Localhost',
name: 'Devnet',
chainId: 2
}
]

export const defaultNetwork = defaultNetworks[1]
export const defaultNetwork = defaultNetworks[2]
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export const AccountEditScreen: FC = () => {
)

const showDelete =
account && (account.networkId === "localhost")
account && (account.networkId === "devnet")

const handleHideOrDeleteAccount = async (account: Account) => {
if (showDelete) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -264,7 +264,7 @@ export const SendTokenScreen: FC = () => {

const maxAmount =
account?.networkId ===
"localhost" /** FIXME: workaround for localhost fee estimate with devnet 0.3.4 */
"devnet" /** FIXME: workaround for localhost fee estimate with devnet 0.3.4 */
? balanceBn.sub(maxFee).sub(100000000000000)
: balanceBn.sub(maxFee)

Expand Down
24 changes: 14 additions & 10 deletions packages/extension/src/ui/features/actions/ActionScreen.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -79,18 +79,22 @@ export const ActionScreen: FC = () => {
host={action.payload.host}
networkId={action.payload.networkId}
group={action.payload.group}
onConnect={async (selectedAccount: Account) => {
useAppState.setState({ isLoading: true })
selectAccount(selectedAccount)
// continue with approval with selected account
await approveAction(action)
await waitForMessage("CONNECT_DAPP_RES")
useAppState.setState({ isLoading: false })
onConnect={async (selectedAccount?: Account) => {
if (selectedAccount) {
useAppState.setState({ isLoading: true })
selectAccount(selectedAccount)
// continue with approval with selected account
await approveAction(action)
await waitForMessage("CONNECT_DAPP_RES")
useAppState.setState({ isLoading: false })
}
closePopupIfLastAction()
}}
onDisconnect={async (selectedAccount: Account) => {
await removePreAuthorization(action.payload.host, selectedAccount)
await rejectAction(action.meta.hash)
onDisconnect={async (selectedAccount?: Account) => {
if (selectedAccount) {
await removePreAuthorization(action.payload.host, selectedAccount)
await rejectAction(action.meta.hash)
}
closePopupIfLastAction()
}}
onReject={onReject}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ import { DappIcon } from "./DappIcon"
import { useDappDisplayAttributes } from "./useDappDisplayAttributes"

interface ConnectDappProps extends Omit<ConfirmPageProps, "onSubmit"> {
onConnect: (selectedAccount: Account) => void
onDisconnect: (selectedAccount: Account) => void
onConnect: (selectedAccount?: Account) => void
onDisconnect: (selectedAccount?: Account) => void
host: string
networkId?: string,
group?: number
Expand Down Expand Up @@ -220,11 +220,11 @@ export const ConnectDappScreen: FC<ConnectDappProps> = ({
}, [])

const onConnect = useCallback(() => {
selectedAccount && onConnectProp(selectedAccount)
onConnectProp(selectedAccount)
}, [onConnectProp, selectedAccount])

const onDisconnect = useCallback(() => {
selectedAccount && onDisconnectProp(selectedAccount)
onDisconnectProp(selectedAccount)
}, [onDisconnectProp, selectedAccount])

const dappDisplayAttributes = useDappDisplayAttributes(host)
Expand Down
2 changes: 1 addition & 1 deletion packages/extension/test/networkSchema.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
} from "../src/shared/network"

const defaultLocalhostNetwork = defaultNetworks.find(
({ id }) => id === "localhost",
({ id }) => id === "devnet",
)

describe("networkSchema", () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/get-extension-wallet/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@alephium/get-extension-wallet",
"version": "0.5.0-rc0",
"version": "0.5.0-rc.1",
"main": "dist/",
"browser": {
"crypto": false
Expand Down
2 changes: 1 addition & 1 deletion packages/storybook/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "5.2.0",
"private": true,
"devDependencies": {
"@alephium/extension": "^0.5.0-rc0",
"@alephium/extension": "^0.5.0-rc.1",
"@argent/ui": "^5.2.0",
"@babel/core": "^7.18.5",
"@chakra-ui/storybook-addon": "^4.0.12",
Expand Down
2 changes: 1 addition & 1 deletion packages/swap/src/assets/tokens.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
"name": "Ether",
"symbol": "ETH",
"decimals": "18",
"networkId": "localhost",
"networkId": "devnet",
"image": "https://dv3jj1unlp2jl.cloudfront.net/128/color/eth.png"
},
{
Expand Down

0 comments on commit 4eaf829

Please sign in to comment.