Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: deploy on mantle and mantle testnet #1127

Merged
merged 21 commits into from
Jul 25, 2023
Merged
Show file tree
Hide file tree
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
92cb211
Add mantle-wadsley file to currency/chains/evm/data
MantisClone Jul 19, 2023
1f9e01a
Add Mantle Wadsley
MantisClone Jul 19, 2023
b2d4d6a
Fix file name
MantisClone Jul 19, 2023
afc8f92
Fix token name
MantisClone Jul 21, 2023
ea2e712
Don't deploy EthereumProxy
MantisClone Jul 21, 2023
42f1a9d
add Mantle
MantisClone Jul 24, 2023
9f4c5c6
Merge branch 'master' into deploy-mantle-testnet
MantisClone Jul 24, 2023
ab54355
fix: rename mantle-wadsley to mantle-testnet
MantisClone Jul 24, 2023
8252176
Merge branch 'deploy-mantle-testnet' of github.com:RequestNetwork/req…
MantisClone Jul 24, 2023
bb7c8ee
feat: deploy RequestDeployer on Mantle Testnet
MantisClone Jul 24, 2023
1e6b3ba
chore: add EthereumProxy and ERC20Proxy to Mantle Deployment list
MantisClone Jul 24, 2023
4cbd96c
Add mantle verification info
MantisClone Jul 24, 2023
90b8b1a
Deploy ERC20Proxy, ERC20FeeProxy, EthereumProxy, EthereumFeeProxy on …
MantisClone Jul 24, 2023
cae7664
Deploy RequestDeployer on Mantle mainnet
MantisClone Jul 24, 2023
3a8615e
Add ERC20Proxy to the list of smart contracts
MantisClone Jul 24, 2023
52d99c4
Add 'api-key' for mantle explorers (because APIs don't require API_KEYs)
MantisClone Jul 24, 2023
4e90124
Update hardhat-etherscan to latest version
MantisClone Jul 24, 2023
c5273ab
Deploy EthereumProxy, EthereumFeeProxy, ERC20Proxy, ERC20FeeProxy on …
MantisClone Jul 24, 2023
fe34d24
Add function to verify RequestDeployer
MantisClone Jul 24, 2023
b636159
Merge branch 'master' into deploy-mantle-testnet
MantisClone Jul 25, 2023
454b13c
Make MNT symbols unique, MNT-testnet on Mantle Testnet.
MantisClone Jul 25, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions packages/currency/src/chains/evm/data/mantle-testnet.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const chainId = 5001;
export const testnet = true;
1 change: 1 addition & 0 deletions packages/currency/src/chains/evm/data/mantle.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const chainId = 5000;
4 changes: 4 additions & 0 deletions packages/currency/src/chains/evm/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import * as FantomDefinition from './data/fantom';
import * as FuseDefinition from './data/fuse';
import * as GoerliDefinition from './data/goerli';
import * as MainnetDefinition from './data/mainnet';
import * as MantleDefinition from './data/mantle';
import * as MantleTestnetDefinition from './data/mantle-testnet';
import * as MaticDefinition from './data/matic';
import * as MoonbeamDefinition from './data/moonbeam';
import * as MumbaiDefinition from './data/mumbai';
Expand Down Expand Up @@ -39,6 +41,8 @@ export const chains: Record<CurrencyTypes.EvmChainName, EvmChain> = {
fuse: FuseDefinition,
goerli: GoerliDefinition,
mainnet: MainnetDefinition,
mantle: MantleDefinition,
'mantle-testnet': MantleTestnetDefinition,
matic: MaticDefinition,
moonbeam: MoonbeamDefinition,
mumbai: MumbaiDefinition,
Expand Down
12 changes: 12 additions & 0 deletions packages/currency/src/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ export const nativeCurrencies: Record<RequestLogicTypes.CURRENCY.ETH, NativeEthC
name: 'Tomb',
network: 'tombchain',
},
{
symbol: 'MNT',
decimals: 18,
name: 'Mantle',
network: 'mantle',
},
{
symbol: 'MNT',
benjlevesque marked this conversation as resolved.
Show resolved Hide resolved
decimals: 18,
name: 'Mantle Testnet',
network: 'mantle-testnet',
},
],
[RequestLogicTypes.CURRENCY.BTC]: [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ const networks: Record<string, ethers.providers.Network> = {
optimism: { chainId: 10, name: 'optimism' },
moonbeam: { chainId: 1284, name: 'moonbeam' },
tombchain: { chainId: 6969, name: 'tombchain' },
mantle: { chainId: 5000, name: 'mantle' },
'mantle-testnet': { chainId: 5001, name: 'mantle-testnet' },
};

/**
Expand Down Expand Up @@ -57,6 +59,10 @@ export class MultichainExplorerApiProvider extends ethers.providers.EtherscanPro
return 'https://api.arbiscan.io';
case 'avalanche':
return 'https://api.snowtrace.io';
case 'mantle':
return 'https://explorer.mantle.xyz/';
case 'mantle-testnet':
return 'https://explorer.testnet.mantle.xyz/';
default:
return super.getBaseUrl();
}
Expand Down
8 changes: 8 additions & 0 deletions packages/smart-contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,14 @@ Environment variables needed: `TENDERLY_...` (see `hardhat.config.ts`).
yarn hardhat tenderly-monitor-contracts
```

### Verify the RequestDeployer contract

If the RequestDeployer contract verification failed initially, it can be verified with:

```bash
yarn hardhat verify-deployer-contract --network <NETWORK>
```

#### Verify the contracts manually With Hardhat (legacy)

A more generic way to verify any contract by setting constructor argments manually:
Expand Down
37 changes: 36 additions & 1 deletion packages/smart-contracts/hardhat.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { config } from 'dotenv';
import deployAllContracts from './scripts/test-deploy-all';
import { deployAllPaymentContracts } from './scripts/deploy-payments';
import { checkCreate2Deployer } from './scripts-create2/check-deployer';
import { deployDeployer } from './scripts-create2/deploy-request-deployer';
import { deployDeployer, verifyDeployer } from './scripts-create2/deploy-request-deployer';
import { HardhatRuntimeEnvironmentExtended } from './scripts-create2/types';
import { computeCreate2DeploymentAddressesFromList } from './scripts-create2/compute-one-address';
import { VerifyCreate2FromList } from './scripts-create2/verify';
Expand Down Expand Up @@ -146,6 +146,16 @@ export default {
chainId: 6969,
accounts,
},
mantle: {
url: url('mantle'),
chainId: 5000,
accounts,
},
'mantle-testnet': {
url: url('mantle-testnet'),
chainId: 5001,
accounts,
},
},
etherscan: {
apiKey: {
Expand Down Expand Up @@ -175,6 +185,8 @@ export default {
sokol: 'api-key',
aurora: 'api-key',
auroraTestnet: 'api-key',
mantle: 'api-key',
'mantle-testnet': 'api-key',
},
customChains: [
{
Expand All @@ -185,6 +197,22 @@ export default {
browserURL: 'https://optimistic.etherscan.io/',
},
},
{
network: 'mantle',
chainId: 5000,
urls: {
apiURL: 'https://explorer.mantle.xyz/api',
browserURL: 'https://explorer.mantle.xyz/',
},
},
{
network: 'mantle-testnet',
chainId: 5001,
urls: {
apiURL: 'https://explorer.testnet.mantle.xyz/api',
browserURL: 'https://explorer.testnet.mantle.xyz/',
},
},
],
},
tenderly: {
Expand Down Expand Up @@ -256,6 +284,13 @@ task(
await deployDeployer(hre);
});

task(
'verify-deployer-contract',
'Verify request deployer contract on the specified network',
).setAction(async (_args, hre) => {
await verifyDeployer(hre);
});

task(
'compute-contract-addresses',
'Compute the contract addresses from the Create2DeploymentList using the create2 scheme',
Expand Down
2 changes: 1 addition & 1 deletion packages/smart-contracts/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@
},
"devDependencies": {
"@nomiclabs/hardhat-ethers": "2.0.2",
"@nomiclabs/hardhat-etherscan": "3.1.2",
"@nomiclabs/hardhat-etherscan": "3.1.7",
"@nomiclabs/hardhat-waffle": "2.0.1",
"@nomiclabs/hardhat-web3": "2.0.0",
"@openzeppelin/contracts": "4.4.2",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,20 @@ export async function deployDeployer(hre: HardhatRuntimeEnvironment): Promise<vo
console.error(e);
}
}

// Verifies the RequestDeployer (useful if the verification failed after deployment)
export async function verifyDeployer(hre: HardhatRuntimeEnvironment): Promise<void> {
try {
const RequestDeployer = await hre.ethers.getContractAt(
'RequestDeployer',
'0xE99Ab70a5FAE59551544FA326fA048f7B95A24B2',
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what is this address?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's the address of the RequestDeployer contract, same on all networks

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it should be a variable or should have a comment

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is one in the hardhat config file actually. Maybe we should put it elsewhere and export it

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Okay I'll fix this.

);
await verifyOne(
RequestDeployer.address,
{ contract: 'RequestDeployer' },
hre as HardhatRuntimeEnvironmentExtended,
);
} catch (e) {
console.error(e);
}
}
9 changes: 5 additions & 4 deletions packages/smart-contracts/scripts-create2/utils.ts
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

did you mean to version this?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, I don't think this file needs to be versioned. We edit the create2ContractDeploymentList based on which contracts we're trying to deploy.

If you're asking about "create2" in the filename, that's referring to the CREATE2 opcode which is one of the key ingredients to the xdeployer which makes our smart contract addresses the same across multiple chains.

Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,16 @@ import { EvmChains } from '@requestnetwork/currency';
*/
export const create2ContractDeploymentList = [
// 'ChainlinkConversionPath',
// 'EthereumProxy',
// 'EthereumFeeProxy',
'EthereumProxy',
'EthereumFeeProxy',
// 'EthConversionProxy',
// 'ERC20FeeProxy',
'ERC20Proxy',
'ERC20FeeProxy',
// 'ERC20SwapToPay',
// 'ERC20SwapToConversion',
// 'BatchConversionPayments',
// 'ERC20EscrowToPay',
'ERC20TransferableReceivable',
// 'ERC20TransferableReceivable',
];

/**
Expand Down
1 change: 1 addition & 0 deletions packages/smart-contracts/scripts-create2/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ export async function VerifyCreate2FromList(hre: HardhatRuntimeEnvironmentExtend
case 'EthereumProxy':
case 'EthereumFeeProxy':
case 'EthConversionProxy':
case 'ERC20Proxy':
case 'ERC20FeeProxy':
case 'ERC20SwapToPay':
case 'ERC20SwapToConversion':
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,14 @@ export const erc20FeeProxyArtifact = new ContractArtifact<ERC20FeeProxy>(
address: '0x399F5EE127ce7432E4921a61b8CF52b0af52cbfE',
creationBlockNumber: 2951048,
},
mantle: {
address: '0x399F5EE127ce7432E4921a61b8CF52b0af52cbfE',
creationBlockNumber: 127951,
},
'mantle-testnet': {
address: '0x399F5EE127ce7432E4921a61b8CF52b0af52cbfE',
creationBlockNumber: 16210087,
},
},
},
near: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,14 @@ export const erc20ProxyArtifact = new ContractArtifact<ERC20Proxy>(
address: '0x162edb802fae75b9ee4288345735008ba51a4ec9',
creationBlockNumber: 5628198,
},
mantle: {
address: '0x88Ecc15fDC2985A7926171B938BB2Cd808A5ba40',
creationBlockNumber: 127947,
},
'mantle-testnet': {
address: '0x88Ecc15fDC2985A7926171B938BB2Cd808A5ba40',
creationBlockNumber: 16210085,
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,14 @@ export const ethereumFeeProxyArtifact = new ContractArtifact<EthereumFeeProxy>(
address: '0xe11BF2fDA23bF0A98365e1A4c04A87C9339e8687',
creationBlockNumber: 2951047,
},
mantle: {
address: '0xe11BF2fDA23bF0A98365e1A4c04A87C9339e8687',
creationBlockNumber: 127944,
},
'mantle-testnet': {
address: '0xe11BF2fDA23bF0A98365e1A4c04A87C9339e8687',
creationBlockNumber: 16210081,
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -184,6 +184,14 @@ export const ethereumProxyArtifact = new ContractArtifact<EthereumProxy>(
address: '0x171Ee0881407d4c0C11eA1a2FB7D5b4cdED71e6e',
creationBlockNumber: 2415488,
},
mantle: {
address: '0x171Ee0881407d4c0C11eA1a2FB7D5b4cdED71e6e',
creationBlockNumber: 127942,
},
'mantle-testnet': {
address: '0x171Ee0881407d4c0C11eA1a2FB7D5b4cdED71e6e',
creationBlockNumber: 16210080,
},
},
},
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,14 @@ export const requestDeployer = new ContractArtifact<RequestDeployer>(
address: '0xE99Ab70a5FAE59551544FA326fA048f7B95A24B2',
creationBlockNumber: 2950756,
},
mantle: {
address: '0xE99Ab70a5FAE59551544FA326fA048f7B95A24B2',
creationBlockNumber: 119284,
},
'mantle-testnet': {
address: '0xE99Ab70a5FAE59551544FA326fA048f7B95A24B2',
creationBlockNumber: 16208647,
},
},
},
},
Expand Down
2 changes: 2 additions & 0 deletions packages/types/src/currency-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@ export type EvmChainName =
| 'fuse'
| 'goerli'
| 'mainnet'
| 'mantle'
| 'mantle-testnet'
| 'matic'
| 'moonbeam'
| 'mumbai'
Expand Down
4 changes: 3 additions & 1 deletion packages/utils/src/providers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,8 @@ const networkRpcs: Record<string, string> = {
optimism: 'https://mainnet.optimism.io',
moonbeam: 'https://moonbeam.public.blastapi.io',
tombchain: 'https://rpc.tombchain.com/',
mantle: 'https://rpc.mantle.xyz/',
'mantle-testnet': 'https://rpc.testnet.mantle.xyz/',
};

/**
Expand Down Expand Up @@ -91,7 +93,7 @@ const defaultProviderFactory: ProviderFactory = (network: string | undefined) =>

if (!warned) {
console.warn(
`No provider is specified for network ${network}, using ethers default provider.
`No provider is specified for network ${network}, using ethers default provider.
This is not recommended for Production environments.
Use setProviderFactory to override the default provider`,
);
Expand Down
Loading
Loading