From caf22d40f68ef462428621bc849acdeaa7289e5e Mon Sep 17 00:00:00 2001 From: Ryan Pate Date: Wed, 10 Apr 2024 17:51:16 -0700 Subject: [PATCH] feat(pg): Add support for Polygon Amoy --- .changeset/twenty-radios-tie.md | 6 ++ README.md | 1 + .../contracts/foundry/SphinxConstants.sol | 85 ++++++++++--------- packages/contracts/src/networks.ts | 17 ++++ packages/core/test/convert.spec.ts | 1 + 5 files changed, 72 insertions(+), 38 deletions(-) create mode 100644 .changeset/twenty-radios-tie.md diff --git a/.changeset/twenty-radios-tie.md b/.changeset/twenty-radios-tie.md new file mode 100644 index 000000000..ffb5b7cd9 --- /dev/null +++ b/.changeset/twenty-radios-tie.md @@ -0,0 +1,6 @@ +--- +'@sphinx-labs/contracts': patch +'@sphinx-labs/plugins': patch +--- + +Support Polygon Amoy diff --git a/README.md b/README.md index 186977001..0c07528e0 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ Test networks: - Optimism Sepolia - Arbitrum Sepolia - Polygon Mumbai +- Polygon Amoy - Polygon zkEVM Cardona - BNB Smart Chain Testnet - Gnosis Chiado diff --git a/packages/contracts/contracts/foundry/SphinxConstants.sol b/packages/contracts/contracts/foundry/SphinxConstants.sol index 851247335..fd887dd33 100644 --- a/packages/contracts/contracts/foundry/SphinxConstants.sol +++ b/packages/contracts/contracts/foundry/SphinxConstants.sol @@ -14,7 +14,7 @@ contract SphinxConstants { address public constant safeSingletonAddress = 0xd9Db270c1B5E3Bd161E8c8503c55cEABeE709552; address public constant sphinxModuleImplAddress = 0x8f4E4d51B8050B0ff713eff1F88f3dD8b5e8a530; - uint8 internal constant numSupportedNetworks = 47; + uint8 internal constant numSupportedNetworks = 48; function getNetworkInfoArray() public pure returns (NetworkInfo[] memory) { NetworkInfo[] memory all = new NetworkInfo[](numSupportedNetworks); @@ -91,6 +91,14 @@ contract SphinxConstants { dripSizeString: '1 MATIC' }); all[9] = NetworkInfo({ + network: Network.polygon_amoy, + name: "polygon_amoy", + chainId: 80002, + networkType: NetworkType.Testnet, + dripSize: 1000000000000000000, + dripSizeString: '1 MATIC' + }); + all[10] = NetworkInfo({ network: Network.bnb, name: "bnb", chainId: 56, @@ -98,7 +106,7 @@ contract SphinxConstants { dripSize: 50000000000000000, dripSizeString: '0.05 BNB' }); - all[10] = NetworkInfo({ + all[11] = NetworkInfo({ network: Network.bnb_testnet, name: "bnb_testnet", chainId: 97, @@ -106,7 +114,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 BNB' }); - all[11] = NetworkInfo({ + all[12] = NetworkInfo({ network: Network.gnosis, name: "gnosis", chainId: 100, @@ -114,7 +122,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 xDAI' }); - all[12] = NetworkInfo({ + all[13] = NetworkInfo({ network: Network.gnosis_chiado, name: "gnosis_chiado", chainId: 10200, @@ -122,7 +130,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 xDAI' }); - all[13] = NetworkInfo({ + all[14] = NetworkInfo({ network: Network.linea, name: "linea", chainId: 59144, @@ -130,7 +138,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[14] = NetworkInfo({ + all[15] = NetworkInfo({ network: Network.linea_sepolia, name: "linea_sepolia", chainId: 59141, @@ -138,7 +146,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[15] = NetworkInfo({ + all[16] = NetworkInfo({ network: Network.polygon_zkevm, name: "polygon_zkevm", chainId: 1101, @@ -146,7 +154,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[16] = NetworkInfo({ + all[17] = NetworkInfo({ network: Network.polygon_zkevm_cardona, name: "polygon_zkevm_cardona", chainId: 2442, @@ -154,7 +162,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[17] = NetworkInfo({ + all[18] = NetworkInfo({ network: Network.avalanche, name: "avalanche", chainId: 43114, @@ -162,7 +170,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 AVAX' }); - all[18] = NetworkInfo({ + all[19] = NetworkInfo({ network: Network.avalanche_fuji, name: "avalanche_fuji", chainId: 43113, @@ -170,7 +178,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 AVAX' }); - all[19] = NetworkInfo({ + all[20] = NetworkInfo({ network: Network.fantom, name: "fantom", chainId: 250, @@ -178,7 +186,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 FTM' }); - all[20] = NetworkInfo({ + all[21] = NetworkInfo({ network: Network.fantom_testnet, name: "fantom_testnet", chainId: 4002, @@ -186,7 +194,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 FTM' }); - all[21] = NetworkInfo({ + all[22] = NetworkInfo({ network: Network.base, name: "base", chainId: 8453, @@ -194,7 +202,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[22] = NetworkInfo({ + all[23] = NetworkInfo({ network: Network.base_sepolia, name: "base_sepolia", chainId: 84532, @@ -202,7 +210,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[23] = NetworkInfo({ + all[24] = NetworkInfo({ network: Network.celo, name: "celo", chainId: 42220, @@ -210,7 +218,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 CELO' }); - all[24] = NetworkInfo({ + all[25] = NetworkInfo({ network: Network.celo_alfajores, name: "celo_alfajores", chainId: 44787, @@ -218,7 +226,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 CELO' }); - all[25] = NetworkInfo({ + all[26] = NetworkInfo({ network: Network.moonriver, name: "moonriver", chainId: 1285, @@ -226,7 +234,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 MOVR' }); - all[26] = NetworkInfo({ + all[27] = NetworkInfo({ network: Network.moonbeam, name: "moonbeam", chainId: 1284, @@ -234,7 +242,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 GLMR' }); - all[27] = NetworkInfo({ + all[28] = NetworkInfo({ network: Network.moonbase_alpha, name: "moonbase_alpha", chainId: 1287, @@ -242,7 +250,7 @@ contract SphinxConstants { dripSize: 50000000000000000, dripSizeString: '0.05 GLMR' }); - all[28] = NetworkInfo({ + all[29] = NetworkInfo({ network: Network.fuse, name: "fuse", chainId: 122, @@ -250,7 +258,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 FUSE' }); - all[29] = NetworkInfo({ + all[30] = NetworkInfo({ network: Network.evmos, name: "evmos", chainId: 9001, @@ -258,7 +266,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 EVMOS' }); - all[30] = NetworkInfo({ + all[31] = NetworkInfo({ network: Network.evmos_testnet, name: "evmos_testnet", chainId: 9000, @@ -266,7 +274,7 @@ contract SphinxConstants { dripSize: 15000000000000000, dripSizeString: '0.015 EVMOS' }); - all[31] = NetworkInfo({ + all[32] = NetworkInfo({ network: Network.kava, name: "kava", chainId: 2222, @@ -274,7 +282,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 KAVA' }); - all[32] = NetworkInfo({ + all[33] = NetworkInfo({ network: Network.kava_testnet, name: "kava_testnet", chainId: 2221, @@ -282,7 +290,7 @@ contract SphinxConstants { dripSize: 1000000000000000000, dripSizeString: '1 KAVA' }); - all[33] = NetworkInfo({ + all[34] = NetworkInfo({ network: Network.scroll, name: "scroll", chainId: 534352, @@ -290,7 +298,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[34] = NetworkInfo({ + all[35] = NetworkInfo({ network: Network.scroll_sepolia, name: "scroll_sepolia", chainId: 534351, @@ -298,7 +306,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[35] = NetworkInfo({ + all[36] = NetworkInfo({ network: Network.rootstock, name: "rootstock", chainId: 30, @@ -306,7 +314,7 @@ contract SphinxConstants { dripSize: 1000000000000000, dripSizeString: '0.001 RBTC' }); - all[36] = NetworkInfo({ + all[37] = NetworkInfo({ network: Network.rootstock_testnet, name: "rootstock_testnet", chainId: 31, @@ -314,7 +322,7 @@ contract SphinxConstants { dripSize: 1000000000000000, dripSizeString: '0.001 RBTC' }); - all[37] = NetworkInfo({ + all[38] = NetworkInfo({ network: Network.zora, name: "zora", chainId: 7777777, @@ -322,7 +330,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[38] = NetworkInfo({ + all[39] = NetworkInfo({ network: Network.zora_sepolia, name: "zora_sepolia", chainId: 999999999, @@ -330,7 +338,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[39] = NetworkInfo({ + all[40] = NetworkInfo({ network: Network.rari, name: "rari", chainId: 1380012617, @@ -338,7 +346,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[40] = NetworkInfo({ + all[41] = NetworkInfo({ network: Network.rari_sepolia, name: "rari_sepolia", chainId: 1918988905, @@ -346,7 +354,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[41] = NetworkInfo({ + all[42] = NetworkInfo({ network: Network.blast_sepolia, name: "blast_sepolia", chainId: 168587773, @@ -354,7 +362,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[42] = NetworkInfo({ + all[43] = NetworkInfo({ network: Network.blast, name: "blast", chainId: 81457, @@ -362,7 +370,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[43] = NetworkInfo({ + all[44] = NetworkInfo({ network: Network.taiko_katla, name: "taiko_katla", chainId: 167008, @@ -370,7 +378,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[44] = NetworkInfo({ + all[45] = NetworkInfo({ network: Network.mode_sepolia, name: "mode_sepolia", chainId: 919, @@ -378,7 +386,7 @@ contract SphinxConstants { dripSize: 150000000000000000, dripSizeString: '0.15 ETH' }); - all[45] = NetworkInfo({ + all[46] = NetworkInfo({ network: Network.mode, name: "mode", chainId: 34443, @@ -386,7 +394,7 @@ contract SphinxConstants { dripSize: 25000000000000000, dripSizeString: '0.025 ETH' }); - all[46] = NetworkInfo({ + all[47] = NetworkInfo({ network: Network.darwinia_pangolin, name: "darwinia_pangolin", chainId: 43, @@ -408,6 +416,7 @@ enum Network { arbitrum_sepolia, polygon, polygon_mumbai, + polygon_amoy, bnb, bnb_testnet, gnosis, diff --git a/packages/contracts/src/networks.ts b/packages/contracts/src/networks.ts index f51a983a5..c69a2a2ed 100644 --- a/packages/contracts/src/networks.ts +++ b/packages/contracts/src/networks.ts @@ -274,6 +274,23 @@ export const SPHINX_NETWORKS: Array = [ actionGasLimitBuffer: false, eip2028: true, }, + { + name: 'polygon_amoy', + displayName: 'Polygon Amoy', + chainId: BigInt(80002), + rpcUrl: () => `${process.env.POLYGON_AMOY_URL}`, + rpcUrlId: 'POLYGON_AMOY_URL', + blockexplorers: {}, + currency: 'MATIC', + dripSize: '1', + networkType: 'Testnet', + dripVersion: 2, + decimals: 18, + queryFilterBlockLimit: 2000, + legacyTx: false, + actionGasLimitBuffer: false, + eip2028: true, + }, { name: 'bnb', displayName: 'Binance Smart Chain', diff --git a/packages/core/test/convert.spec.ts b/packages/core/test/convert.spec.ts index 90d9fac70..b9122748a 100644 --- a/packages/core/test/convert.spec.ts +++ b/packages/core/test/convert.spec.ts @@ -51,6 +51,7 @@ describe('Convert EthersJS Objects', () => { 421614: '0x012e2232816e5dcea285a6a357bb3f9f49e117b0966344ea0eff4a0875246efe', 80001: '0x0a8af66052dac81560e05391bb06a4f1064dcc51d2e6e903a0055f348dfaed7a', + 80002: '0xd1be6d96df5a3e2a661bb1aabb1ee65fc1eeef01e10fdec471da012d1f65c603', 97: '0x3bc5c7f3d0d7ebf44f0ef679c9637f5a0cf25d24c9e4385569784ea3b46bc1da', 10200: '0x1d37b9dba8689bc21e336075bccee374ea63f7dfa049c0bef63db652ff987558', 43113: '0xb33c1cf0f2be7d8bd20fe2e84048bad007297906702ad6d03a80951998031d00',