Skip to content
This repository has been archived by the owner on May 16, 2024. It is now read-only.

Commit

Permalink
Change testnet and replace AlchemyProvider for EtherscanProvider
Browse files Browse the repository at this point in the history
As of 24 Oct 2023, AlchemyProvider still doesn't support sepolia,
making any integration using it to fail.

Resolves: [CORE-1838]
  • Loading branch information
brayansdt committed Oct 24, 2023
1 parent 7c09481 commit 15c56ed
Show file tree
Hide file tree
Showing 31 changed files with 42 additions and 42 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ yarn add @imtbl/core-sdk
Initialize the Core SDK client with the network on which you want your application to run (see [all networks available](./src/config/config.ts)):
| Param | Description |
| -- | -- |
| `Config.SANDBOX` | The default test network (currently, it is Goërli) |
| `Config.SANDBOX` | The default test network (currently, it is Sepolia) |
| `Config.PRODUCTION` | Ethereum network |

```ts
Expand Down Expand Up @@ -99,13 +99,13 @@ ImmutableX provides two Stark key generation methods:

If your user has a Stark key that was generated using the deterministic method, the Core SDK provides a way for you to retrieve this key using the [generateLegacyStarkPrivateKey()](https://github.com/immutable/imx-core-sdk/blob/83f800956f541f338b3267ec7cb16e039182dfa6/src/utils/stark/starkCurve.ts#L152) method:
```ts
import { AlchemyProvider } from '@ethersproject/providers';
import { EtherscanProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { generateLegacyStarkPrivateKey } from '@imtbl/core-sdk';

// Create Ethereum signer
const ethNetwork = 'goerli'; // Or 'mainnet'
const provider = new AlchemyProvider(ethNetwork, YOUR_ALCHEMY_API_KEY);
const ethNetwork = 'sepolia'; // Or 'mainnet'
const provider = new EtherscanProvider(ethNetwork, ETHERSCAN_API_KEY);
const ethSigner = new Wallet(YOUR_PRIVATE_ETH_KEY).connect(provider);

// Get the legacy Stark private key
Expand Down Expand Up @@ -161,13 +161,13 @@ The second option provides an application with an interface to the user's accoun
The Core SDK provides functionality for applications to generate Stark (L2) [signers](/src/utils/stark/starkSigner.ts#L60).

```ts
import { AlchemyProvider } from '@ethersproject/providers';
import { EtherscanProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { createStarkSigner } from '@imtbl/core-sdk';

// Create Ethereum signer
const ethNetwork = 'goerli'; // Or 'mainnet'
const provider = new AlchemyProvider(ethNetwork, YOUR_ALCHEMY_API_KEY);
const ethNetwork = 'sepolia'; // Or 'mainnet'
const provider = new EtherscanProvider(ethNetwork, ETHERSCAN_API_KEY);
const ethSigner = new Wallet(YOUR_PRIVATE_ETH_KEY).connect(provider);

// Create Stark signer
Expand Down
2 changes: 1 addition & 1 deletion examples/.env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PRIVATE_KEY=
STARK_PRIVATE_KEY=
ALCHEMY_API_KEY=
ETHERSCAN_API_KEY=
2 changes: 1 addition & 1 deletion examples/addMetadataSchemaToCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/cancelOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/completeErc20Withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const client = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/completeEthWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const client = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/completeNftWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const client = new ImmutableX(Config.SANDBOX);

Expand Down
6 changes: 3 additions & 3 deletions examples/createCollection.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { AlchemyProvider } from '@ethersproject/providers';
import { EtherscanProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { ImmutableX, Config, CreateCollectionRequest } from '@imtbl/core-sdk';
import { requireEnvironmentVariable } from './libs/utils';

(async () => {
const privateKey = requireEnvironmentVariable('PRIVATE_KEY');
const alchemyKey = requireEnvironmentVariable('ALCHEMY_API_KEY');
const etherscanKey = requireEnvironmentVariable('ETHERSCAN_API_KEY');
const wallet = new Wallet(privateKey);
const provider = new AlchemyProvider('goerli', alchemyKey);
const provider = new EtherscanProvider('sepolia', etherscanKey);
const signer = wallet.connect(provider);

const imxClient = new ImmutableX(Config.SANDBOX);
Expand Down
2 changes: 1 addition & 1 deletion examples/createErc20Withdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const client = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/createEthWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const client = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/createExchangeTransfer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/createMetadataRefresh.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/createNftWithdrawal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const client = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/createOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { Config, ImmutableX, UnsignedOrderRequest } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/createProject.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config, CreateProjectRequest } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/createTrade.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config, GetSignableTradeRequest } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/depositEth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

// IMX class client
const client = new ImmutableX(Config.SANDBOX);
Expand Down
2 changes: 1 addition & 1 deletion examples/depositNft.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { generateWalletConnection } from './libs/walletConnection';

(async () => {
try {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

// IMX class client
const client = new ImmutableX(Config.SANDBOX);
Expand Down
2 changes: 1 addition & 1 deletion examples/getMetadataRefreshErrors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/getMetadataRefreshResults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/getProjects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { generateWalletConnection } from './libs/walletConnection';
(async () => {
try {
const client = new ImmutableX(Config.SANDBOX);
const wallet = await generateWalletConnection('goerli');
const wallet = await generateWalletConnection('sepolia');
const pageSize = 200;
const projects = await client.getProjects(wallet.ethSigner, pageSize);

Expand Down
6 changes: 3 additions & 3 deletions examples/libs/walletConnection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { AlchemyProvider } from '@ethersproject/providers';
import { EtherscanProvider } from '@ethersproject/providers';
import { Wallet } from '@ethersproject/wallet';
import { createStarkSigner, WalletConnection } from '@imtbl/core-sdk';
import { requireEnvironmentVariable } from './utils';
Expand All @@ -11,10 +11,10 @@ export const generateWalletConnection = async (
): Promise<WalletConnection> => {
const userPrivateKey = requireEnvironmentVariable('PRIVATE_KEY');
const userStarkKey = requireEnvironmentVariable('STARK_PRIVATE_KEY');
const alchemyKey = requireEnvironmentVariable('ALCHEMY_API_KEY');
const etherscanKey = requireEnvironmentVariable('ETHERSCAN_API_KEY');

// connect provider
const provider = new AlchemyProvider(ethNetwork, alchemyKey);
const provider = new EtherscanProvider(ethNetwork, etherscanKey);

// L1 credentials
const ethSigner = new Wallet(userPrivateKey).connect(provider);
Expand Down
2 changes: 1 addition & 1 deletion examples/listMetadataRefreshes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/mint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config, UnsignedMintRequest } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/registerUser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/transferErc20.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/transferEth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/transferNfts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
2 changes: 1 addition & 1 deletion examples/updateCollection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { generateWalletConnection } from './libs/walletConnection';
// IMX class client
const client = new ImmutableX(Config.SANDBOX);

const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const collectionAddress = ''; // collection address

Expand Down
2 changes: 1 addition & 1 deletion examples/updateMetadataSchemaByName.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { ImmutableX, Config, MetadataSchemaRequest } from '@imtbl/core-sdk';
import { generateWalletConnection } from './libs/walletConnection';

(async () => {
const walletConnection = await generateWalletConnection('goerli');
const walletConnection = await generateWalletConnection('sepolia');

const imxClient = new ImmutableX(Config.SANDBOX);

Expand Down
4 changes: 2 additions & 2 deletions src/utils/crypto/crypto.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { Wallet } from '@ethersproject/wallet';

describe('signRaw()', () => {
test('Correctly signs string', async () => {
const provider = getDefaultProvider('goerli', {});
const provider = getDefaultProvider('sepolia', {});
const signer = new Wallet(
'5c7b4b5cad9a3fc7b1ba235a49cd74e615488a18b0d6a531739fd1062935104d',
).connect(provider);
Expand All @@ -19,7 +19,7 @@ describe('signRaw()', () => {

describe('signMessage()', () => {
test('Correctly signs message', async () => {
const provider = getDefaultProvider('goerli', {});
const provider = getDefaultProvider('sepolia', {});
const signer = new Wallet(
'5c7b4b5cad9a3fc7b1ba235a49cd74e615488a18b0d6a531739fd1062935104d',
).connect(provider);
Expand Down

0 comments on commit 15c56ed

Please sign in to comment.