Skip to content

Commit

Permalink
Deprecate Mumbai on tapir (#508)
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec authored Apr 10, 2024
2 parents 846b2b6 + 0c968ae commit efd3c60
Show file tree
Hide file tree
Showing 23 changed files with 69 additions and 69 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/tapir.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ on:

# TODO: Use variables when GH supports it for forks. See https://github.com/orgs/community/discussions/44322
env:
RPC_PROVIDER_URL: "https://polygon-mumbai-bor.publicnode.com"
RPC_PROVIDER_URL: "https://rpc-amoy.polygon.technology"
ENCRYPTOR_PRIVATE_KEY: "0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86"
CONSUMER_PRIVATE_KEY: "0xf307e165339cb5deb2b8ec59c31a5c0a957b8e8453ce7fe8a19d9a4c8acf36d4"
RITUAL_ID: "0"
Expand Down
2 changes: 1 addition & 1 deletion demos/taco-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ production _just yet_.
### Lynx Testnet

The current release of `@nucypher/taco` supports Ursulas working on Lynx (bleeding-edge) test
network and contracts deployed on Mumbai testnet.
network and contracts deployed on Polygon Amoy testnet.

## References

Expand Down
6 changes: 3 additions & 3 deletions demos/taco-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
initialize,
ThresholdMessageKit,
} from '@nucypher/taco';
import { Mumbai, useEthers } from '@usedapp/core';
import { useEthers } from '@usedapp/core';
import { ethers } from 'ethers';
import React, { useEffect, useState } from 'react';

Expand All @@ -32,7 +32,7 @@ export default function App() {

useEffect(() => {
initialize();
switchNetwork(Mumbai.chainId);
switchNetwork(80002);
}, []);

const encryptMessage = async (message: string) => {
Expand All @@ -41,7 +41,7 @@ export default function App() {
}
setLoading(true);

await switchNetwork(Mumbai.chainId);
await switchNetwork(80002);

const provider = new ethers.providers.Web3Provider(window.ethereum);
const encryptedMessage = await encrypt(
Expand Down
4 changes: 2 additions & 2 deletions demos/taco-demo/src/ConditionBuilder.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { conditions } from '@nucypher/taco';
import { Mumbai, useEthers } from '@usedapp/core';
import { useEthers } from '@usedapp/core';
import React, { useState } from 'react';

interface Props {
Expand All @@ -9,7 +9,7 @@ interface Props {
}

const rpcCondition = new conditions.base.rpc.RpcCondition({
chain: Mumbai.chainId,
chain: 80002,
method: 'eth_getBalance',
parameters: [':userAddress'],
returnValueTest: {
Expand Down
4 changes: 2 additions & 2 deletions demos/taco-demo/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Config, DAppProvider, Mumbai } from '@usedapp/core';
import { Config, DAppProvider } from '@usedapp/core';
import React, { StrictMode } from 'react';
import * as ReactDOMClient from 'react-dom/client';

import App from './App';

const config: Config = {
networks: [Mumbai],
readOnlyChainId: 80002,
};
const rootElement = document.getElementById('root');

Expand Down
2 changes: 1 addition & 1 deletion demos/taco-nft-demo/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ production _just yet_.
### Lynx Testnet

The current release of `@nucypher/taco` supports Ursulas working on Lynx (bleeding-edge) test
network and contracts deployed on Mumbai testnet.
network and contracts deployed on Polygon Amoy testnet.

## References

Expand Down
4 changes: 2 additions & 2 deletions demos/taco-nft-demo/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
initialize,
ThresholdMessageKit,
} from '@nucypher/taco';
import { Mumbai, useEthers } from '@usedapp/core';
import { useEthers } from '@usedapp/core';
import { ethers } from 'ethers';
import React, { useEffect, useState } from 'react';

Expand Down Expand Up @@ -40,7 +40,7 @@ export default function App() {
}
setLoading(true);

await switchNetwork(Mumbai.chainId);
await switchNetwork(80002);

const provider = new ethers.providers.Web3Provider(window.ethereum);
const encryptedMessage = await encrypt(
Expand Down
4 changes: 2 additions & 2 deletions demos/taco-nft-demo/src/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { Config, DAppProvider, Mumbai } from '@usedapp/core';
import { Config, DAppProvider } from '@usedapp/core';
import React, { StrictMode } from 'react';
import * as ReactDOMClient from 'react-dom/client';

import App from './App';

const config: Config = {
networks: [Mumbai],
readOnlyChainId: 80002,
};
const rootElement = document.getElementById('root');

Expand Down
8 changes: 4 additions & 4 deletions examples/pre/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ function App() {
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');

const { chainId } = await provider.getNetwork();
const mumbaiChainId = 80001;
if (chainId !== mumbaiChainId) {
// Switch to Polygon Mumbai testnet
const amoyChainId = 80002;
if (chainId !== amoyChainId) {
// Switch to Polygon Amoy testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: hexlify(mumbaiChainId) }],
params: [{ chainId: hexlify(amoyChainId) }],
});
}

Expand Down
6 changes: 3 additions & 3 deletions examples/pre/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ const runExample = async () => {

const provider = new ethers.providers.JsonRpcProvider(rpcProviderUrl);

// Make sure the provider is connected to Mumbai testnet
// Make sure the provider is connected to Polygon Amoy testnet
const network = await provider.getNetwork();
if (network.chainId !== 80001) {
console.error('Please connect to Mumbai testnet');
if (network.chainId !== 80002) {
console.error('Please connect to Polygon Amoy testnet');
}

const signer = new ethers.Wallet(privateKey);
Expand Down
8 changes: 4 additions & 4 deletions examples/pre/react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function App() {
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');

const { chainId } = await provider.getNetwork();
const mumbaiChainId = 80001;
if (chainId !== mumbaiChainId) {
// Switch to Polygon Mumbai testnet
const amoyChainId = 80002;
if (chainId !== amoyChainId) {
// Switch to Polygon Amoy testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: hexlify(mumbaiChainId) }],
params: [{ chainId: hexlify(amoyChainId) }],
});
}

Expand Down
8 changes: 4 additions & 4 deletions examples/pre/webpack-5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,12 +54,12 @@ const runExample = async () => {
await provider.send('eth_requestAccounts', []);

const { chainId } = await provider.getNetwork();
const mumbaiChainId = 80001;
if (chainId !== mumbaiChainId) {
// Switch to Polygon Mumbai testnet
const amoyChainId = 80002;
if (chainId !== amoyChainId) {
// Switch to Polygon Amoy testnet
await window.ethereum!.request!({
method: 'wallet_switchEthereumChain',
params: [{ chainId: hexlify(mumbaiChainId) }],
params: [{ chainId: hexlify(amoyChainId) }],
});
}

Expand Down
16 changes: 9 additions & 7 deletions examples/taco/nextjs/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ function App() {
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');

const { chainId } = await provider.getNetwork();
const mumbaiChainId = 80001;
if (chainId !== mumbaiChainId) {
// Switch to Polygon Mumbai testnet
const amoyChainId = 80002;
if (chainId !== amoyChainId) {
// Switch to Polygon Amoy testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: hexlify(mumbaiChainId) }],
params: [{ chainId: hexlify(amoyChainId) }],
});
}

Expand All @@ -64,12 +64,14 @@ function App() {
}

const encryptMessage = async () => {
if(!provider) return;
setEncrypting(true)
if (!provider) {
return;
}
setEncrypting(true);
try {
const signer = provider.getSigner();
const hasPositiveBalance = new conditions.base.rpc.RpcCondition({
chain: 80001,
chain: 80002,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
Expand Down
6 changes: 3 additions & 3 deletions examples/taco/nodejs/.env.example
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# URL for RPC blockchain provider. For TACo testnet you should use a Polygon Mumbai endpoint.
# Current default extracted from https://chainlist.org/chain/80001, but ideally, you'll use your own endpoint.
RPC_PROVIDER_URL=https://polygon-mumbai-bor.publicnode.com
# URL for RPC blockchain provider. For TACo testnet you should use a Polygon Amoy endpoint.
# Current default extracted from https://chainlist.org/chain/80002, but ideally, you'll use your own endpoint.
RPC_PROVIDER_URL=https://rpc-amoy.polygon.technology
# Hex-encoded private keys for the Encryptor and the Consumer.
# We provide here some defaults, but we encourage you to choose your own.
ENCRYPTOR_PRIVATE_KEY=0x900edb9e8214b2353f82aa195e915128f419a92cfb8bbc0f4784f10ef4112b86
Expand Down
2 changes: 1 addition & 1 deletion examples/taco/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ This example shows how to use `@nucypher/taco` in Node.js.

This script needs 3 environment variables, that you can set in the `.env` file:

* `RPC_PROVIDER_URL`: For TACo testnet you should use a Polygon Mumbai endpoint.
* `RPC_PROVIDER_URL`: For TACo testnet you should use a Polygon Amoy endpoint.
* `ENCRYPTOR_PRIVATE_KEY` and `CONSUMER_PRIVATE_KEY`: Hex-encoded private keys for the Encryptor and the Consumer,
respectively.

Expand Down
11 changes: 4 additions & 7 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ const encryptToBytes = async (messageString: string) => {
const message = toBytes(messageString);
console.log(format('Encrypting message ("%s") ...', messageString));

// TODO: Remove after fixing #506
const chain = domain === 'lynx' ? 80002 : 80001;

const hasPositiveBalance = new conditions.base.rpc.RpcCondition({
chain,
chain: 80002,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
Expand Down Expand Up @@ -97,10 +94,10 @@ const decryptFromBytes = async (encryptedBytes: Uint8Array) => {
};

const runExample = async () => {
// Make sure the provider is connected to Mumbai testnet
// Make sure the provider is connected to Polygon Amoy testnet
const network = await provider.getNetwork();
if (network.chainId !== 80001) {
console.error('Please connect to Mumbai testnet');
if (network.chainId !== 80002) {
console.error('Please connect to Polygon Amoy testnet');
}
await initialize();

Expand Down
22 changes: 13 additions & 9 deletions examples/taco/react/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,12 +33,12 @@ function App() {
const provider = new ethers.providers.Web3Provider(window.ethereum, 'any');

const { chainId } = await provider.getNetwork();
const mumbaiChainId = 80001;
if (chainId !== mumbaiChainId) {
// Switch to Polygon Mumbai testnet
const amoyChainId = 80002;
if (chainId !== amoyChainId) {
// Switch to Polygon Amoy testnet
await window.ethereum.request({
method: 'wallet_switchEthereumChain',
params: [{ chainId: hexlify(mumbaiChainId) }],
params: [{ chainId: hexlify(amoyChainId) }],
});
}

Expand All @@ -61,12 +61,14 @@ function App() {
}

const encryptMessage = async () => {
if(!provider) return;
setEncrypting(true)
if (!provider) {
return;
}
setEncrypting(true);
try {
const signer = provider.getSigner();
const hasPositiveBalance = new conditions.base.rpc.RpcCondition({
chain: 80001,
chain: 80002,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
Expand All @@ -91,9 +93,11 @@ function App() {
}

const decryptMessage = async () => {
if(!encryptedText || !provider) return
if (!encryptedText || !provider) {
return;
}
try {
setDecrypting(true)
setDecrypting(true);
const signer = provider.getSigner();

console.log('Decrypting message...');
Expand Down
10 changes: 5 additions & 5 deletions examples/taco/webpack-5/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,20 +25,20 @@ const runExample = async () => {
const signer = provider.getSigner();

const { chainId } = await provider.getNetwork();
const mumbaiChainId = 80001;
if (chainId !== mumbaiChainId) {
// Switch to Polygon Mumbai testnet
const amoyChainId = 80002;
if (chainId !== amoyChainId) {
// Switch to Polygon Amoy testnet
await window.ethereum!.request!({
method: 'wallet_switchEthereumChain',
params: [{ chainId: hexlify(mumbaiChainId) }],
params: [{ chainId: hexlify(amoyChainId) }],
});
}
console.log("Signer's address:", await signer.getAddress());

console.log('Encrypting message...');
const message = toBytes('this is a secret');
const hasPositiveBalance = new conditions.base.rpc.RpcCondition({
chain: 80001,
chain: 80002,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
Expand Down
2 changes: 1 addition & 1 deletion packages/shared/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
"dependencies": {
"@ethersproject/abi": "^5.7.0",
"@ethersproject/providers": "^5.7.2",
"@nucypher/nucypher-contracts": "^0.21.0",
"@nucypher/nucypher-contracts": "^0.22.0",
"@nucypher/nucypher-core": "*",
"axios": "^1.6.8",
"deep-equal": "^2.2.3",
Expand Down
1 change: 0 additions & 1 deletion packages/shared/src/web3.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { fromHexString } from './utils';

export enum ChainId {
POLYGON = 137,
MUMBAI = 80001, // TODO(#506): Deprecate MUMBAI
AMOY = 80002,
SEPOLIA = 11155111,
ETHEREUM_MAINNET = 1,
Expand Down
1 change: 0 additions & 1 deletion packages/taco/src/conditions/const.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export const CONTEXT_PARAM_PREFIX = ':';

export const SUPPORTED_CHAIN_IDS = [
ChainId.POLYGON,
ChainId.MUMBAI, // TODO(#506): Deprecate MUMBAI
ChainId.AMOY,
ChainId.SEPOLIA,
ChainId.ETHEREUM_MAINNET,
Expand Down
1 change: 0 additions & 1 deletion packages/taco/test/conditions/base/condition.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ describe('validation', () => {
chain: {
_errors: [
'Invalid literal value, expected 137',
'Invalid literal value, expected 80001', // TODO(#506): Deprecate MUMBAI
'Invalid literal value, expected 80002',
'Invalid literal value, expected 11155111',
'Invalid literal value, expected 1',
Expand Down
8 changes: 4 additions & 4 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit efd3c60

Please sign in to comment.