Skip to content

Commit

Permalink
feat: deploy on mantle and mantle testnet (#1127)
Browse files Browse the repository at this point in the history
  • Loading branch information
MantisClone authored Jul 25, 2023
1 parent d606fc7 commit d539717
Show file tree
Hide file tree
Showing 19 changed files with 21,236 additions and 22,342 deletions.
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-testnet',
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',
);
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
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

0 comments on commit d539717

Please sign in to comment.