Skip to content

Commit

Permalink
Merge pull request #910 from lens-protocol/T-19965/amoy-testnet
Browse files Browse the repository at this point in the history
feat: amoy testnet support
  • Loading branch information
cesarenaldi authored Apr 12, 2024
2 parents e24dbe1 + 7bf86f4 commit 9c763d0
Show file tree
Hide file tree
Showing 39 changed files with 773 additions and 399 deletions.
7 changes: 7 additions & 0 deletions .changeset/lemon-knives-peel.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
"@lens-protocol/react": patch
"@lens-protocol/react-native": patch
"@lens-protocol/react-web": patch
---

**feat:** aligns testnet handle namespace to mainnet (i.e., `lens/`)
12 changes: 12 additions & 0 deletions .changeset/small-socks-lie.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
---
"@lens-protocol/gated-content": minor
"@lens-protocol/shared-kernel": minor
"@lens-protocol/api-bindings": minor
"@lens-protocol/client": minor
"@lens-protocol/react": minor
"@lens-protocol/wagmi": minor
"@lens-protocol/react-native": minor
"@lens-protocol/react-web": minor
---

**chore:** updated development environment to Amoy testnet
4 changes: 2 additions & 2 deletions examples/lens-next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
"next": "^14.1.1",
"react": "^18",
"react-dom": "^18",
"viem": "^2.7.6",
"wagmi": "^2.5.6"
"viem": "^2.9.16",
"wagmi": "^2.5.19"
},
"devDependencies": {
"@playwright/test": "^1.42.1",
Expand Down
6 changes: 3 additions & 3 deletions examples/lens-next-app/src/components/Web3Provider.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import React from "react";
import { WagmiProvider, createConfig, http } from "wagmi";
import { polygon, polygonMumbai } from "wagmi/chains";
import { polygon, polygonAmoy } from "wagmi/chains";
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { ConnectKitProvider, getDefaultConfig } from "connectkit";
import { LensConfig, LensProvider, development, production } from "@lens-protocol/react-web";
Expand All @@ -15,9 +15,9 @@ type ConnectKitConfig = Parameters<typeof getDefaultConfig>[0];
const appConfigs = {
development: {
connectkit: {
chains: [polygonMumbai],
chains: [polygonAmoy],
transports: {
[polygonMumbai.id]: http(),
[polygonAmoy.id]: http(),
},
} as Partial<ConnectKitConfig>,
lens: {
Expand Down
2 changes: 1 addition & 1 deletion examples/node/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ This package is a collection of simple node.js scripts showcasing the `@lens-pro
## Getting Started

Some scripts require a wallet to authenticate the LensClient. Copy `.env.example` file to `.env` and define the private key for the wallet you want to use with the scripts. Best practice is to create a new test wallet. You don't need any funds in the wallet to experiment with the LensClient SDK.
But you will need a bit of MUMBAI MATIC to upload data or files to devnet Irys. You can get it from [the faucet](https://faucet.polygon.technology/).
But you will need a bit of AMOY MATIC to upload data or files to devnet Irys. You can get it from [the faucet](https://faucet.polygon.technology/).

### Run a script

Expand Down
2 changes: 1 addition & 1 deletion examples/node/scripts/handle/resolveAddress.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ async function main() {
environment: development,
});

const address = await client.handle.resolveAddress({ handle: 'test/wagmi' });
const address = await client.handle.resolveAddress({ handle: 'lens/wagmi' });

console.log(`Address: `, address);
}
Expand Down
10 changes: 4 additions & 6 deletions examples/node/scripts/misc/onboarding.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dotenv.config();
const typedAbi = abi as ethers.ContractInterface;

const permissonlessCreatorAddress = {
development: '0xCb4FB63c3f13CB83cCD6F10E9e5F29eC250329Cc',
development: '0x36440da1D98FF46637f0b98AAA082bc77977B49B',
production: '0x0b5e6100243f793e480DE6088dE6bA70aA9f3872',
};

Expand All @@ -27,12 +27,10 @@ if (!process.env.INFURA_API_KEY) {
}

const rpcUrl = {
development: `https://polygon-mumbai.infura.io/v3/${process.env.INFURA_API_KEY}`,
development: `https://polygon-amoy.infura.io/v3/${process.env.INFURA_API_KEY}`,
production: `https://polygon.infura.io/v3/${process.env.INFURA_API_KEY}`,
};

const HANDLE_NAMESPACE = 'test'; // use 'lens' namespace for production

async function main() {
// prepare new handle
const requestedHandle = 'jane_doe'; // input from the user
Expand All @@ -50,7 +48,7 @@ async function main() {

// check if the requested handle is available
const handleOwnerAddress = await client.handle.resolveAddress({
handle: `${HANDLE_NAMESPACE}/${requestedHandle}`,
handle: `lens/${requestedHandle}`,
});

if (handleOwnerAddress) {
Expand Down Expand Up @@ -112,7 +110,7 @@ async function main() {
console.log('A new profile has been successfully minted.');

// now fetch the newly created profile to get the id
const fullHandle = `${HANDLE_NAMESPACE}/${requestedHandle}`;
const fullHandle = `lens/${requestedHandle}`;

const profile = await client.profile.fetch({
forHandle: fullHandle,
Expand Down
2 changes: 1 addition & 1 deletion examples/node/scripts/profile/fetch.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async function main() {

// by handle
const profileByHandle = await client.profile.fetch({
forHandle: 'test/@firstprofile',
forHandle: 'lens/firstprofile',
});

console.log(`Profile fetched by handle: `, {
Expand Down
2 changes: 1 addition & 1 deletion examples/node/scripts/profile/fetchAll.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function main() {

// by a list of Lens handles
const profilesByHandle = await client.profile.fetchAll({
where: { handles: ['test/@firstprofile'] },
where: { handles: ['lens/firstprofile'] },
});

console.log(
Expand Down
4 changes: 2 additions & 2 deletions examples/node/scripts/profile/recipes/profileMetadata.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ dotenv.config();
const typedAbi = abi as ethers.ContractInterface;

const lensHubAddress = {
development: '0x4fbffF20302F3326B20052ab9C217C44F6480900',
development: '0xA2574D9DdB6A325Ad2Be838Bd854228B80215148',
production: '0xDb46d1Dc155634FbC732f92E853b10B288AD5a1d',
};

Expand All @@ -21,7 +21,7 @@ if (!process.env.INFURA_API_KEY) {
}

const rpcUrl = {
development: `https://polygon-mumbai.infura.io/v3/${process.env.INFURA_API_KEY}`,
development: `https://polygon-amoy.infura.io/v3/${process.env.INFURA_API_KEY}`,
production: `https://polygon.infura.io/v3/${process.env.INFURA_API_KEY}`,
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ dotenv.config();
const typedAbi = abi as ethers.ContractInterface;

const publicActionProxyAddress = {
development: '0xab5607f5447d538fc79bb32364ddecd8f76d7ee8',
development: '0x88c8fa7C470d9d94aDfA40187157917B26A548d3',
production: '0x53582b1b7BE71622E7386D736b6baf87749B7a2B',
};

Expand All @@ -19,7 +19,7 @@ if (!process.env.INFURA_API_KEY) {
}

const rpcUrl = {
development: `https://polygon-mumbai.infura.io/v3/${process.env.INFURA_API_KEY}`,
development: `https://polygon-amoy.infura.io/v3/${process.env.INFURA_API_KEY}`,
production: `https://polygon.infura.io/v3/${process.env.INFURA_API_KEY}`,
};

Expand Down
8 changes: 4 additions & 4 deletions examples/node/scripts/shared/uploadWithIrys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,21 @@ export async function uploadWithIrys(data: { [key: string]: unknown }): Promise<
url: 'https://devnet.irys.xyz',
token: 'matic',
key: walletPrivateKey,
config: { providerUrl: 'https://rpc-mumbai.maticvigil.com/' },
config: { providerUrl: 'https://rpc-amoy.polygon.technology/' },
});

const atomicBalance = await irys.getLoadedBalance();
const balance = irys.utils.fromAtomic(atomicBalance);

console.log(
`Irys balance for wallet ${String(irys.address)} is ${balance.toString()} MUMBAI MATIC`,
`Irys balance for wallet ${String(irys.address)} is ${balance.toString()} AMOY MATIC`,
);

// fund Irys balance if empty
if (balance.eq(0)) {
console.log('Trying to fund your irys balance with 0.1 MUMBAI MATIC');
console.log('Trying to fund your irys balance with 0.1 AMOY MATIC');

await irys.fund(0.1e18); // 0.1 MUMBAI MATIC
await irys.fund(0.1e18); // 0.1 AMOY MATIC
}

const serialized = JSON.stringify(data);
Expand Down
4 changes: 2 additions & 2 deletions examples/web/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@
"react-hot-toast": "^2.4.1",
"react-router-dom": "^6.20.0",
"readable-web-to-node-stream": "^3.0.2",
"viem": "^2.7.6",
"wagmi": "^2.5.6"
"viem": "^2.9.16",
"wagmi": "^2.5.19"
},
"devDependencies": {
"@babel/core": "^7.23.3",
Expand Down
6 changes: 3 additions & 3 deletions examples/web/src/Providers.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@ import { LensConfig, LensProvider, development } from '@lens-protocol/react-web'
import { bindings } from '@lens-protocol/wagmi';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { WagmiProvider, createConfig, http } from 'wagmi';
import { polygon, polygonMumbai } from 'wagmi/chains';
import { polygon, polygonAmoy } from 'wagmi/chains';

const queryClient = new QueryClient();

const wagmiConfig = createConfig({
chains: [polygonMumbai, polygon],
chains: [polygonAmoy, polygon],
transports: {
[polygonMumbai.id]: http(),
[polygonAmoy.id]: http(),
[polygon.id]: http(),
},
});
Expand Down
6 changes: 3 additions & 3 deletions examples/web/src/hooks/useIrysUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ async function getWebIrys(client: Client<Transport, Chain, Account>) {
url: 'https://devnet.irys.xyz',
token: 'matic',
wallet: {
rpcUrl: 'https://rpc-mumbai.maticvigil.com/',
rpcUrl: 'https://rpc-amoy.polygon.technology/',
name: 'ethersv5',
provider: new Web3Provider(client.transport),
},
Expand All @@ -39,9 +39,9 @@ export function useIrysUploadHandler() {
const confirm = window.confirm(
`In this example we will now upload metadata file via the Irys.
Please make sure your wallet is connected to the Polygon Mumbai testnet.
Please make sure your wallet is connected to the Polygon Amoy testnet.
You can get some Mumbai MATIC from the Mumbai Faucet: https://mumbaifaucet.com/`,
You can get some Amoy MATIC from the Amoy Faucet: https://faucet.polygon.technology/`,
);

if (!confirm) {
Expand Down
1 change: 0 additions & 1 deletion examples/web/src/inbox/components/ProfileSelector.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ export function ProfileSelector({ onProfileSelected }: ProfileSelectorProps) {
where: {
ownedBy: [
'0x8d960334c2EF30f425b395C1506Ef7c5783789F3',
'0x248ba21F6ff51cf0CD4765C3Bc9fAD2030a591d5',
'0x3fC47cdDcFd59dce20694b575AFc1D94186775b0',
'0x01d79BcEaEaaDfb8fD2F2f53005289CFcF483464',
'0x52EAF3F04cbac0a4B9878A75AB2523722325D4D4',
Expand Down
4 changes: 2 additions & 2 deletions examples/web/src/misc/UseResolveAddress.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export function UseResolveAddress() {
const { execute, loading } = useResolveAddress();

const resolve = async () => {
const result = await execute({ handle: 'test/wagmi' });
const result = await execute({ handle: 'lens/wagmi' });

if (result.isFailure()) {
toast.error(result.error.message);
Expand All @@ -22,7 +22,7 @@ export function UseResolveAddress() {
</h1>

<button onClick={resolve} disabled={loading}>
Resolve test/wagmi
Resolve lens/wagmi
</button>
</div>
);
Expand Down
2 changes: 1 addition & 1 deletion examples/web/src/profiles/UseCreateProfile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ export function CreateProfileForm({ address }: { address: string }) {
<legend>Choose an handle for your profile</legend>
<label>
<div>
test/&nbsp;
lens/&nbsp;
<input type="text" name="localName" placeholder="wagmi" disabled={loading} />
</div>
</label>
Expand Down
4 changes: 2 additions & 2 deletions packages/api-bindings/codegen-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ generates:
UUID: string
Void: void
schema:
# - https://api-mumbai.lens-v2.crtlkey.com/ # staging
- https://api-v2-mumbai-live.lens.dev/graphql # testnet
# - https://api-amoy.lens-v2.crtlkey.com/ # staging
- https://api-v2-amoy.lens.dev/ # testnet
# - http://localhost:4000/
documents:
- src/lens/graphql/*.graphql
Expand Down
2 changes: 1 addition & 1 deletion packages/api-bindings/src/lens/__helpers__/queries/misc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export function mockCurrenciesResponse({
contract: {
__typename: 'NetworkAddress',
address: currency.address,
chainId: 80001,
chainId: 80002,
},
}),
),
Expand Down
1 change: 1 addition & 0 deletions packages/api-bindings/src/lens/utils/amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function chainType(chainId: number): ChainType {
return ChainType.ETHEREUM;
case 137:
case 80001:
case 80002:
return ChainType.POLYGON;
default:
throw new Error(`Not supported chainId: ${chainId}`);
Expand Down
4 changes: 2 additions & 2 deletions packages/client/codegen-api.yml
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ config:
field: true

schema:
# - https://api-mumbai.lens-v2.crtlkey.com/ # staging
- https://api-v2-mumbai-live.lens.dev/graphql # testnet
# - https://api-amoy.lens-v2.crtlkey.com/ # staging
- https://api-v2-amoy.lens.dev/ # testnet
# - http://localhost:4000/
documents:
- src/**/*.graphql
Expand Down
6 changes: 3 additions & 3 deletions packages/client/src/__helpers__/BundlrUploader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class BundlrUploader {
'matic',
this.signer.privateKey,
{
providerUrl: 'https://rpc-mumbai.maticvigil.com/',
providerUrl: 'https://rpc-amoy.polygon.technology/',
},
);
const atomicBalance = await bundlr.getLoadedBalance();
Expand All @@ -20,13 +20,13 @@ export class BundlrUploader {
// fund bundlr balance if empty
if (balance.lte(0.001)) {
try {
await bundlr.fund(0.1e18); // 0.1 MUMBAI MATIC
await bundlr.fund(0.1e18); // 0.1 AMOY MATIC
} catch (error) {
// eslint-disable-next-line no-console
console.warn(
`Cannot fund ${String(
bundlr.address,
)} Bundlr balance. Mumbai ${balance.toString()} MATIC available.`,
)} Bundlr balance. Amoy ${balance.toString()} MATIC available.`,
);
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/client/src/__helpers__/setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { isRelaySuccess } from '../submodules';
import { BundlrUploader } from './BundlrUploader';

export async function createOrGetProfile(signer: Wallet, client: LensClient, handle: string) {
const fullHandle = `test/${handle}`;
const fullHandle = `lens/${handle}`;
const profile = await client.profile.fetch({ forHandle: fullHandle });

if (profile) {
Expand Down
4 changes: 2 additions & 2 deletions packages/client/src/environments.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export const production = new Environment(

export const development = new Environment(
'development',
'https://api-v2-mumbai-live.lens.dev',
'https://api-v2-amoy.lens.dev',
GatedEnvironments.development,
);

Expand All @@ -32,6 +32,6 @@ export const development = new Environment(
*/
export const staging = new Environment(
'staging',
'https://api-mumbai.lens-v2.crtlkey.com/',
'https://api-amoy.lens-v2.crtlkey.com',
GatedEnvironments.development,
);
5 changes: 4 additions & 1 deletion packages/client/src/gated/__tests__/LensClient.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ const signerWithNoProfile = new Wallet(
'dc377a505ab51735b73656ddfd5abc01fb9d26544b71d9188ecd74c70a22cb6d',
);

describe(`Given an instance of "gated.${LensClient.name}"`, () => {
/**
* Disabled until Lit team comes back with a solution for Amoy testnet
*/
xdescribe(`Given an instance of "gated.${LensClient.name}"`, () => {
const initialPostMetadata = metadata.image({
image: {
item: faker.internet.url(),
Expand Down
Loading

0 comments on commit 9c763d0

Please sign in to comment.