Skip to content

Commit 42ecd2b

Browse files
committed
base support
1 parent d6a95e8 commit 42ecd2b

12 files changed

+2398
-2748
lines changed

package-lock.json

Lines changed: 2327 additions & 2724 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33
"version": "0.1.0",
44
"private": true,
55
"dependencies": {
6-
"@certusone/wormhole-sdk": "^0.9.4",
7-
"@injectivelabs/sdk-ts": "^1.0.211",
8-
"@injectivelabs/ts-types": "^1.0.14",
9-
"@injectivelabs/tx-ts": "^1.0.43",
10-
"@injectivelabs/wallet-ts": "^1.0.185",
6+
"@certusone/wormhole-sdk": "^0.9.11",
7+
"@injectivelabs/sdk-ts": "^1.0.368",
8+
"@injectivelabs/ts-types": "^1.0.27",
9+
"@injectivelabs/wallet-ts": "^1.0.346",
1110
"@manahippo/aptos-wallet-adapter": "^1.0.2",
1211
"@material-ui/core": "^4.12.2",
1312
"@material-ui/icons": "^4.11.2",

src/components/ShowTx.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import {
2121
CHAIN_ID_APTOS,
2222
CHAIN_ID_ARBITRUM,
2323
CHAIN_ID_INJECTIVE,
24+
CHAIN_ID_BASE,
2425
} from "@certusone/wormhole-sdk";
2526
import { Button, makeStyles, Typography } from "@material-ui/core";
2627
import { Transaction } from "../store/transferSlice";
@@ -121,6 +122,10 @@ export default function ShowTx({
121122
? `https://${CLUSTER === "testnet" ? "moonbase." : ""}moonscan.io/tx/${
122123
tx?.id
123124
}`
125+
: chainId === CHAIN_ID_BASE
126+
? `https://${CLUSTER === "testnet" ? "goerli." : ""}basescan.org/tx/${
127+
tx?.id
128+
}`
124129
: chainId === CHAIN_ID_XPLA
125130
? `https://explorer.xpla.io/${
126131
CLUSTER === "testnet" ? "testnet/" : ""

src/components/SmartAddress.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import {
2424
CHAIN_ID_INJECTIVE,
2525
terra,
2626
CHAIN_ID_NEAR,
27+
CHAIN_ID_BASE,
2728
} from "@certusone/wormhole-sdk";
2829
import { Button, makeStyles, Tooltip, Typography } from "@material-ui/core";
2930
import { FileCopy, OpenInNew } from "@material-ui/icons";
@@ -155,6 +156,10 @@ export default function SmartAddress({
155156
? `https://${CLUSTER === "testnet" ? "moonbase." : ""}moonscan.io/${
156157
isAsset ? "token" : "address"
157158
}/${useableAddress}`
159+
: chainId === CHAIN_ID_BASE
160+
? `https://${CLUSTER === "testnet" ? "goerli." : ""}basescan.org/${
161+
isAsset ? "token" : "address"
162+
}/${useableAddress}`
158163
: chainId === CHAIN_ID_KARURA
159164
? `https://${
160165
CLUSTER === "testnet"

src/components/TransactionProgress.tsx

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
CHAIN_ID_ACALA,
44
CHAIN_ID_ARBITRUM,
55
CHAIN_ID_AURORA,
6+
CHAIN_ID_BASE,
67
CHAIN_ID_CELO,
78
CHAIN_ID_FANTOM,
89
CHAIN_ID_KARURA,
@@ -97,6 +98,8 @@ export default function TransactionProgress({
9798
? 32
9899
: chainId === CHAIN_ID_ARBITRUM
99100
? 64 // something to show progress
101+
: chainId === CHAIN_ID_BASE
102+
? 124 // something to show progress
100103
: isEVMChain(chainId)
101104
? 15
102105
: 1;
@@ -116,6 +119,8 @@ export default function TransactionProgress({
116119
<Typography variant="body2" className={classes.message}>
117120
{chainId === CHAIN_ID_ARBITRUM
118121
? `Waiting for Ethereum finality on Arbitrum block ${tx?.block}` //TODO: more advanced finality checking for Arbitrum
122+
: chainId === CHAIN_ID_BASE
123+
? `Waiting for Ethereum finality on Base block ${tx?.block}` //TODO: more advanced finality checking for Base
119124
: blockDiff < expectedBlocks
120125
? `Waiting for ${blockDiff} / ${expectedBlocks} confirmations on ${CHAINS_BY_ID[chainId].name}...`
121126
: `Waiting for Wormhole Network consensus...`}

src/hooks/useHandleCreateWrapped.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,7 @@ async function injective(
418418
msg,
419419
"Wormhole - Create Wrapped"
420420
);
421-
dispatch(setCreateTx({ id: tx.txhash, block: tx.height }));
421+
dispatch(setCreateTx({ id: tx.txHash, block: tx.height }));
422422
enqueueSnackbar(null, {
423423
content: <Alert severity="success">Transaction confirmed</Alert>,
424424
});

src/hooks/useHandleRedeem.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ async function injective(
374374
msg,
375375
"Wormhole - Complete Transfer"
376376
);
377-
dispatch(setRedeemTx({ id: tx.txhash, block: tx.height }));
377+
dispatch(setRedeemTx({ id: tx.txHash, block: tx.height }));
378378
enqueueSnackbar(null, {
379379
content: <Alert severity="success">Transaction confirmed</Alert>,
380380
});

src/hooks/useHandleTransfer.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ async function injective(
637637
msgs,
638638
"Wormhole - Initiate Transfer"
639639
);
640-
dispatch(setTransferTx({ id: tx.txhash, block: tx.height }));
640+
dispatch(setTransferTx({ id: tx.txHash, block: tx.height }));
641641
enqueueSnackbar(null, {
642642
content: <Alert severity="success">Transaction confirmed</Alert>,
643643
});

src/icons/base.svg

Lines changed: 11 additions & 0 deletions
Loading

src/utils/consts.ts

Lines changed: 22 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import {
66
CHAIN_ID_ARBITRUM,
77
CHAIN_ID_AURORA,
88
CHAIN_ID_AVAX,
9+
CHAIN_ID_BASE,
910
CHAIN_ID_BSC,
1011
CHAIN_ID_CELO,
1112
CHAIN_ID_ETH,
@@ -37,6 +38,7 @@ import aptosIcon from "../icons/aptos.svg";
3738
import arbitrumIcon from "../icons/arbitrum.svg";
3839
import auroraIcon from "../icons/aurora.svg";
3940
import avaxIcon from "../icons/avax.svg";
41+
import baseIcon from "../icons/base.svg";
4042
import bscIcon from "../icons/bsc.svg";
4143
import celoIcon from "../icons/celo.svg";
4244
import ethIcon from "../icons/eth.svg";
@@ -54,7 +56,6 @@ import xplaIcon from "../icons/xpla.svg";
5456
import injectiveIcon from "../icons/injective.svg";
5557
import { AptosNetwork } from "./aptos";
5658
import { getNetworkInfo, Network } from "@injectivelabs/networks";
57-
import { ChainId as InjectiveChainId } from "@injectivelabs/ts-types";
5859
import nearIcon from "../icons/near.svg";
5960
import { ConnectConfig, keyStores } from "near-api-js";
6061

@@ -101,6 +102,11 @@ export const CHAINS: ChainInfo[] =
101102
name: "Avalanche",
102103
logo: avaxIcon,
103104
},
105+
{
106+
id: CHAIN_ID_BASE,
107+
name: "Base Goerli",
108+
logo: baseIcon,
109+
},
104110
{
105111
id: CHAIN_ID_BSC,
106112
name: "Binance Smart Chain",
@@ -240,7 +246,8 @@ export const CHAINS_WITH_NFT_SUPPORT = CHAINS.filter(
240246
id === CHAIN_ID_CELO ||
241247
id === CHAIN_ID_NEON ||
242248
id === CHAIN_ID_ARBITRUM ||
243-
id === CHAIN_ID_MOONBEAM
249+
id === CHAIN_ID_MOONBEAM ||
250+
id === CHAIN_ID_BASE
244251
);
245252
export type ChainsById = { [key in ChainId]: ChainInfo };
246253
export const CHAINS_BY_ID: ChainsById = CHAINS.reduce((obj, chain) => {
@@ -290,6 +297,8 @@ export const getDefaultNativeCurrencySymbol = (chainId: ChainId) =>
290297
? "ETH"
291298
: chainId === CHAIN_ID_MOONBEAM
292299
? "GLMR"
300+
: chainId === CHAIN_ID_BASE
301+
? "ETH"
293302
: "";
294303

295304
export const getDefaultNativeCurrencyAddressEvm = (chainId: ChainId) => {
@@ -347,6 +356,8 @@ export const getExplorerName = (chainId: ChainId) =>
347356
? "Arbiscan"
348357
: chainId === CHAIN_ID_MOONBEAM
349358
? "Moonscan"
359+
: chainId === CHAIN_ID_BASE
360+
? "BaseScan"
350361
: "Explorer";
351362
export const WORMHOLE_RPC_HOSTS =
352363
CLUSTER === "testnet"
@@ -367,6 +378,7 @@ export const CELO_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 44787 : 1381;
367378
export const NEON_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 245022926 : 1381;
368379
export const ARBITRUM_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 421613 : 1381;
369380
export const MOONBEAM_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 1287 : 1381;
381+
export const BASE_NETWORK_CHAIN_ID = CLUSTER === "testnet" ? 84531 : 1381;
370382
export const getEvmChainId = (chainId: ChainId) =>
371383
chainId === CHAIN_ID_ETH
372384
? ETH_NETWORK_CHAIN_ID
@@ -396,6 +408,8 @@ export const getEvmChainId = (chainId: ChainId) =>
396408
? ARBITRUM_NETWORK_CHAIN_ID
397409
: chainId === CHAIN_ID_MOONBEAM
398410
? MOONBEAM_NETWORK_CHAIN_ID
411+
: chainId === CHAIN_ID_BASE
412+
? BASE_NETWORK_CHAIN_ID
399413
: undefined;
400414
export const SOLANA_HOST = process.env.REACT_APP_SOLANA_API_URL
401415
? process.env.REACT_APP_SOLANA_API_URL
@@ -445,8 +459,8 @@ export const APTOS_NETWORK =
445459
export const APTOS_NATIVE_DECIMALS = 8;
446460
export const APTOS_NATIVE_TOKEN_KEY = "0x1::aptos_coin::AptosCoin";
447461

448-
export const INJECTIVE_NETWORK = getNetworkInfo(Network.TestnetK8s);
449-
export const INJECTIVE_NETWORK_CHAIN_ID = InjectiveChainId.Testnet;
462+
export const INJECTIVE_NETWORK = Network.TestnetK8s;
463+
export const INJECTIVE_NETWORK_INFO = getNetworkInfo(Network.TestnetK8s);
450464

451465
export const ALGORAND_HOST =
452466
CLUSTER === "testnet"
@@ -528,6 +542,8 @@ export const COVALENT_ARBITRUM =
528542

529543
export const COVALENT_MOONBEAM =
530544
CLUSTER === "devnet" ? null : MOONBEAM_NETWORK_CHAIN_ID; // Covalent only supports mainnet
545+
export const COVALENT_BASE =
546+
CLUSTER === "devnet" ? null : BASE_NETWORK_CHAIN_ID;
531547

532548
export const COVALENT_GET_TOKENS_URL = (
533549
chainId: ChainId,
@@ -556,6 +572,8 @@ export const COVALENT_GET_TOKENS_URL = (
556572
? COVALENT_ARBITRUM
557573
: chainId === CHAIN_ID_MOONBEAM
558574
? COVALENT_MOONBEAM
575+
: chainId === CHAIN_ID_BASE
576+
? COVALENT_BASE
559577
: "";
560578
// https://www.covalenthq.com/docs/api/#get-/v1/{chain_id}/address/{address}/balances_v2/
561579
return chainNum

src/utils/injective.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@ import {
66
TxGrpcClient,
77
} from "@injectivelabs/sdk-ts";
88
import { MsgBroadcaster, WalletStrategy } from "@injectivelabs/wallet-ts";
9-
import { INJECTIVE_NETWORK, INJECTIVE_NETWORK_CHAIN_ID } from "./consts";
9+
import { INJECTIVE_NETWORK, INJECTIVE_NETWORK_INFO } from "./consts";
1010

1111
export const NATIVE_INJECTIVE_DECIMALS = 18;
1212

1313
export const INJECTIVE_NATIVE_DENOM = "inj";
1414

1515
export const getInjectiveWasmClient = () =>
16-
new ChainGrpcWasmApi(INJECTIVE_NETWORK.sentryGrpcApi);
16+
new ChainGrpcWasmApi(INJECTIVE_NETWORK_INFO.grpc);
1717

1818
export const getInjectiveBankClient = () =>
19-
new ChainGrpcBankApi(INJECTIVE_NETWORK.sentryGrpcApi);
19+
new ChainGrpcBankApi(INJECTIVE_NETWORK_INFO.grpc);
2020

2121
export const getInjectiveTxClient = () =>
22-
new TxGrpcClient(INJECTIVE_NETWORK.sentryGrpcApi);
22+
new TxGrpcClient(INJECTIVE_NETWORK_INFO.grpc);
2323

2424
export const isValidInjectiveAddress = (address: string) => {
2525
if (isNativeDenomInjective(address)) {
@@ -45,22 +45,19 @@ export const broadcastInjectiveTx = async (
4545
memo: string = ""
4646
) => {
4747
const client = getInjectiveTxClient();
48+
const network = INJECTIVE_NETWORK;
4849
const broadcaster = new MsgBroadcaster({
49-
endpoints: {
50-
indexerApi: INJECTIVE_NETWORK.indexerApi,
51-
sentryGrpcApi: INJECTIVE_NETWORK.sentryGrpcApi,
52-
sentryHttpApi: INJECTIVE_NETWORK.sentryHttpApi,
53-
},
54-
chainId: INJECTIVE_NETWORK_CHAIN_ID,
50+
network,
5551
walletStrategy,
5652
simulateTx: true,
5753
});
58-
const txHash = await broadcaster.broadcast({
54+
const txResponse = await broadcaster.broadcast({
55+
//@ts-ignore
5956
msgs,
6057
address: walletAddress,
6158
memo,
6259
});
63-
const tx = await client.fetchTx(txHash);
60+
const tx = await client.fetchTxPoll(txResponse.txHash);
6461
if (!tx) {
6562
throw new Error("Unable to fetch transaction");
6663
}

src/utils/metaMaskChainParameters.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,13 @@ export const METAMASK_CHAIN_PARAMETERS: {
125125
rpcUrls: ["https://rpc.api.moonbase.moonbeam.network"],
126126
blockExplorerUrls: ["https://moonbase.moonscan.io"],
127127
},
128+
84531: {
129+
chainId: "0x14A33",
130+
chainName: "Base Goerli",
131+
nativeCurrency: { name: "Ether", symbol: "ETH", decimals: 18 },
132+
rpcUrls: ["https://goerli.base.org"],
133+
blockExplorerUrls: ["https://goerli.basescan.org"],
134+
},
128135
};
129136

130137
export interface EvmRpcMap {

0 commit comments

Comments
 (0)