Skip to content

Commit

Permalink
Merge pull request #169 from open-format/feature/sepolia-network
Browse files Browse the repository at this point in the history
Feature: Sepolia network
  • Loading branch information
tinypell3ts authored Apr 12, 2024
2 parents c80a32a + 80e26f8 commit 5c78ba0
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 200 deletions.
6 changes: 6 additions & 0 deletions .changeset/smooth-suits-hug.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@openformat/react": patch
"@openformat/sdk": patch
---

- Remove support for old chains
5 changes: 5 additions & 0 deletions .changeset/stale-cougars-march.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@openformat/sdk": minor
---

Adds support for Arbitrum Sepolia
5 changes: 1 addition & 4 deletions packages/react/src/helpers/chain.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@
import { ChainId, Chains } from '@openformat/sdk';

export const chainIdToNetwork = {
[Chains.polygonMumbai.id]: Chains.polygonMumbai,
[Chains.polygon.id]: Chains.polygon,
[Chains.aurora.id]: Chains.aurora,
[Chains.auroraTestnet.id]: Chains.auroraTestnet,
[Chains.foundry.id]: Chains.foundry,
[Chains.arbitrumSepolia.id]: Chains.arbitrumSepolia,
};

export const getNetworkByChainId = (chainId: ChainId) => {
Expand Down
12 changes: 6 additions & 6 deletions packages/react/src/provider.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Chains, OpenFormatSDK } from '@openformat/sdk';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { Aurora, AuroraTestnet, Mumbai, Polygon } from '@thirdweb-dev/chains';
import { ArbitrumSepolia } from '@thirdweb-dev/chains';
import {
Chain,
localWallet,
Expand Down Expand Up @@ -31,9 +31,9 @@ export function OpenFormatProvider({
children,
config = {
// @ts-ignore
networks: [Chains.polygonMumbai],
networks: [Chains.arbitrumSepolia],
appId: '',
activeChain: 'mumbai',
activeChain: 'arbitrum-sepolia',
},
}: {
children: React.ReactNode;
Expand All @@ -42,14 +42,14 @@ export function OpenFormatProvider({
appId: string;
clientId: string;
signer?: Signer | string;
activeChain?: 'mumbai' | 'polygon' | 'aurora' | 'aurora-testnet';
activeChain?: 'arbitrum-sepolia';
};
}) {
return (
<ThirdwebProvider
activeChain={config.activeChain}
clientId={config.clientId}
supportedChains={[Polygon, Aurora, Mumbai, AuroraTestnet]}
supportedChains={[ArbitrumSepolia]}
autoConnect={true}
supportedWallets={[metamaskWallet({ recommended: true }), localWallet()]}
>
Expand All @@ -62,7 +62,7 @@ function InnerProvider({
children,
config = {
// @ts-ignore
networks: [Chains.polygonMumbai],
networks: [Chains.arbitrumSepolia],
appId: '',
},
}: {
Expand Down
6 changes: 3 additions & 3 deletions packages/sdk/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Fungible token creation and minting

```ts
const sdk = new OpenFormatSDK({
network: Chains.polygonMumbai,
network: Chains.arbitrumSepolia,
appId: 'INSERT_APP_ID',
signer: 'INSERT_PRIVATE_KEY',
});
Expand All @@ -33,7 +33,7 @@ NFT creation and minting

```ts
const sdk = new OpenFormatSDK({
network: Chains.polygonMumbai,
network: Chains.arbitrumSepolia,
appId: 'INSERT_APP_ID',
signer: 'INSERT_PRIVATE_KEY',
});
Expand Down Expand Up @@ -77,7 +77,7 @@ import { OpenFormatSDK, Chains } from '@openformat/sdk';

const sdk = new OpenFormatSDK({
// Choose which blockchain you would like to use
network: Chains.polygonMumbai,
network: Chains.arbitrumSepolia,
// Go to https://apps.openformat.tech/ to generate App
appId: 'INSERT_APP_ID',
// Private key for sign transactions
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -91,13 +91,13 @@
"dependencies": {
"@microsoft/api-documenter": "^7.23.12",
"@microsoft/api-extractor": "^7.38.3",
"@wagmi/chains": "^0.2.17",
"axios": "^1.4.0",
"graphql": "^16.6.0",
"graphql-request": "^5.1.0",
"lodash.forown": "^4.4.0",
"lodash.isobject": "^3.0.2",
"lodash.merge": "^4.6.2",
"lodash.unionby": "^4.8.0"
"lodash.unionby": "^4.8.0",
"viem": "^2.9.16"
}
}
10 changes: 2 additions & 8 deletions packages/sdk/src/constants/addresses.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,11 @@ export const appFactoryContracts: ContractData = {
[Chains.polygon.id]: {
address: '0x1e823247D26efd56f5172b8C19F6c44CA700F2c5',
},
[Chains.polygonMumbai.id]: {
address: '0x429cB2c2A030952D3F5e10B534584aB49c303763',
},
[Chains.polygonAmoy.id]: {
address: '0x542D145f2c66CB9ac58447Fe141BFB12fea7C8bE',
},
[Chains.aurora.id]: {
address: '0xc0553B98d93114FB241196272603DF4543359820',
},
[Chains.auroraTestnet.id]: {
address: '0x4d9D07E924F9bC486d496CacFaf2Bd9C7bC4E22F',
[Chains.arbitrumSepolia.id]: {
address: '0x19781Af95cA4E113D5D1412452225D11A84ce992',
},
[Chains.foundry.id]: {
//@dev this change depending on local blockchain.
Expand Down
101 changes: 2 additions & 99 deletions packages/sdk/src/constants/chains.ts
Original file line number Diff line number Diff line change
@@ -1,105 +1,8 @@
import { aurora, auroraTestnet, Chain, foundry, polygon } from '@wagmi/chains';

//@dev custom polygonMumbai chain due to failing rpc urls
export const polygonMumbai = {
id: 80_001,
name: 'Polygon Mumbai',
network: 'maticmum',
nativeCurrency: { name: 'MATIC', symbol: 'MATIC', decimals: 18 },
rpcUrls: {
alchemy: {
http: ['https://polygon-mumbai.g.alchemy.com/v2'],
webSocket: ['wss://polygon-mumbai.g.alchemy.com/v2'],
},
infura: {
http: ['https://polygon-mumbai.infura.io/v3'],
webSocket: ['wss://polygon-mumbai.infura.io/ws/v3'],
},
default: {
http: ['https://polygon-testnet.public.blastapi.io'],
},
public: {
http: ['https://polygon-testnet.public.blastapi.io'],
},
},
blockExplorers: {
etherscan: {
name: 'PolygonScan',
url: 'https://mumbai.polygonscan.com',
},
default: {
name: 'PolygonScan',
url: 'https://mumbai.polygonscan.com',
},
},
testnet: true,
} as const satisfies Chain;

export const arbitrumSepolia = {
id: 421_614,
name: 'Arbitrum Sepolia',
nativeCurrency: {
name: 'Arbitrum Sepolia Ether',
symbol: 'ETH',
decimals: 18,
},
rpcUrls: {
default: {
http: ['https://sepolia-rollup.arbitrum.io/rpc'],
},
},
blockExplorers: {
default: {
name: 'Arbiscan',
url: 'https://sepolia.arbiscan.io',
apiUrl: 'https://api-sepolia.arbiscan.io/api',
},
},
contracts: {
multicall3: {
address: '0xca11bde05977b3631167028862be2a173976ca11',
blockCreated: 81930,
},
},
testnet: true,
};

export const polygonAmoy = {
id: 80002,
name: 'Polygon Amoy',
network: 'amoy',
nativeCurrency: { name: 'MATIC', symbol: 'MATIC', decimals: 18 },
rpcUrls: {
alchemy: {
http: ['https://polygon-amoy.g.alchemy.com/v2'],
webSocket: ['wss://polygon-amoy.g.alchemy.com/v2'],
},
infura: {
http: ['https://polygon-amoy.infura.io/v3'],
webSocket: ['wss://polygon-amoy.infura.io/ws/v3'],
},
default: {
http: ['https://rpc-amoy.polygon.technology'],
},
public: {
http: ['https://rpc-amoy.polygon.technology'],
},
},
blockExplorers: {
default: {
name: 'OkLink',
url: 'https://www.oklink.com/amoy',
},
},
testnet: true,
} as const satisfies Chain;
import { arbitrumSepolia, foundry, polygon, polygonAmoy } from 'viem/chains';

export const Chains = {
aurora,
auroraTestnet,
foundry,
polygon,
polygonMumbai,
foundry,
arbitrumSepolia,
polygonAmoy,
};
11 changes: 4 additions & 7 deletions packages/sdk/src/constants/subgraph.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,11 @@ export const Subgraphs: SubgraphData = {
[Chains.polygon.id]: {
url: 'https://api.thegraph.com/subgraphs/name/open-format/polygon-v2',
},
[Chains.polygonMumbai.id]: {
url: 'https://subgraphs.openformat.tech/subgraphs/name/open-format/mumbai',
[Chains.arbitrumSepolia.id]: {
url: 'https://subgraph.satsuma-prod.com/7238a0e24f3c/openformat--330570/open-format-arbitrum-sepolia/api',
},
[Chains.aurora.id]: {
url: 'https://api.thegraph.com/subgraphs/name/open-format/aurora-v2',
},
[Chains.auroraTestnet.id]: {
url: 'https://api.thegraph.com/subgraphs/name/open-format/aurora-testnet-v2',
[Chains.polygonAmoy.id]: {
url: 'https://subgraph.satsuma-prod.com/7238a0e24f3c/openformat--330570/open-format-amoy/api',
},
[Chains.foundry.id]: {
url: 'http://0.0.0.0:8000/subgraphs/name/open-format/mumbai',
Expand Down
5 changes: 1 addition & 4 deletions packages/sdk/src/core/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ export class BaseContract {
const chainId = (await this.provider.getNetwork()).chainId;
let maxPriorityFeePerGas: BigNumber;

if (
chainId === Chains.polygon.id ||
chainId === Chains.polygonMumbai.id
) {
if (chainId === Chains.polygon.id) {
maxPriorityFeePerGas = await getPolygonGasFee(chainId);
} else {
maxPriorityFeePerGas = BigNumber.from(feeData.maxPriorityFeePerGas);
Expand Down
4 changes: 2 additions & 2 deletions packages/sdk/src/core/sdk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { ERC721LazyMint } from './token/ERC721/ERC721LazyMint';
* const sdk = new OpenFormatSDK({
* signer: "0x....",
* appId: "0x1ade2613adb6bafbc65d40eb9c1effbe3bfd8b81",
* network: Chains.polygonMumbai
* network: Chains.arbitrumSepolia
* });
* ```
*/
Expand All @@ -38,7 +38,7 @@ export class OpenFormatSDK extends BaseContract {
App: App;

static defaultOptions: SDKOptions = {
network: Chains.polygonMumbai,
network: Chains.arbitrumSepolia,
appId: '',
};

Expand Down
10 changes: 4 additions & 6 deletions packages/sdk/src/helpers/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@ export function getSubgraphUrlFromChainID(chainId: ChainId) {
switch (chainId) {
case Chains.polygon.id:
return Subgraphs[Chains.polygon.id].url;
case Chains.polygonMumbai.id:
return Subgraphs[Chains.polygonMumbai.id].url;
case Chains.aurora.id:
return Subgraphs[Chains.aurora.id].url;
case Chains.auroraTestnet.id:
return Subgraphs[Chains.auroraTestnet.id].url;
case Chains.polygonAmoy.id:
return Subgraphs[Chains.polygonAmoy.id].url;
case Chains.arbitrumSepolia.id:
return Subgraphs[Chains.arbitrumSepolia.id].url;
case Chains.foundry.id:
return Subgraphs[Chains.foundry.id].url;
default:
Expand Down
8 changes: 2 additions & 6 deletions packages/sdk/src/helpers/transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,12 @@ export function fromWei(amount: BigNumberish): string {
* ```
*/
export async function getPolygonGasFee(
chainId: typeof Chains.polygon.id | typeof Chains.polygonMumbai.id
chainId: typeof Chains.polygon.id
): Promise<BigNumber> {
function getURL(
chainId: typeof Chains.polygon.id | typeof Chains.polygonMumbai.id
) {
function getURL(chainId: typeof Chains.polygon.id) {
switch (chainId) {
case Chains.polygon.id:
return 'https://gasstation.polygon.technology/v2';
case Chains.polygonMumbai.id:
return 'https://gasstation-testnet.polygon.technology/v2';
}
}

Expand Down
2 changes: 1 addition & 1 deletion packages/sdk/src/types/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Chain } from '@wagmi/chains';
import { BigNumberish, Signer } from 'ethers';
import { Chain } from 'viem/chains';
import {
ERC20Base as ERC20BaseContract,
ERC20FactoryFacet,
Expand Down
28 changes: 5 additions & 23 deletions packages/sdk/test/sdk.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { Chains, ContractType, OpenFormatSDK } from '../src';
import { APP_ID } from './utilities';

const APP_ID = '';

describe('sdk', () => {
it('should initialize the SDK on the polygon network', async () => {
Expand All @@ -12,34 +13,15 @@ describe('sdk', () => {

expect(network.chainId).toBe(137);
});
it('should initialize the SDK on the mumbai network', async () => {
const sdk = new OpenFormatSDK({
network: Chains.polygonMumbai,
appId: APP_ID,
});

const network = await sdk.provider.getNetwork();

expect(network.chainId).toBe(80001);
});
it('should initialize the SDK on the aurora network', async () => {
it('should initialize the SDK on the arbitrum sepolia network', async () => {
const sdk = new OpenFormatSDK({
network: Chains.aurora,
network: Chains.arbitrumSepolia,
appId: APP_ID,
});
const network = await sdk.provider.getNetwork();

expect(network.chainId).toBe(1313161554);
});

it('should initialize the SDK on the aurora testnet network', async () => {
const sdk = new OpenFormatSDK({
network: Chains.auroraTestnet,
appId: APP_ID,
});
const network = await sdk.provider.getNetwork();

expect(network.chainId).toBe(1313161555);
expect(network.chainId).toBe(421614);
});

it('should initialize the SDK on a local network', async () => {
Expand Down
Loading

0 comments on commit 5c78ba0

Please sign in to comment.