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

refactor(cli): deprecate --provider-url for --rpc-url #1242

Merged
merged 20 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
6 changes: 3 additions & 3 deletions examples/sample-hardhat-project/package-lock.json

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

8 changes: 4 additions & 4 deletions packages/builder/src/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@ export const DEFAULT_REGISTRY_CONFIG = [
{
name: 'OP Mainnet',
chainId: 10,
providerUrl: ['frame', 'direct', 'https://optimism.llamarpc.com'],
rpcUrl: ['frame', 'direct', 'https://optimism.llamarpc.com'],
address: DEFAULT_REGISTRY_ADDRESS,
},
{
name: 'Ethereum Mainnet',
chainId: 1,
providerUrl: ['frame', 'direct', 'https://eth.llamarpc.com'],
rpcUrl: ['frame', 'direct', 'https://eth.llamarpc.com'],
address: DEFAULT_REGISTRY_ADDRESS,
},
];
Expand All @@ -30,13 +30,13 @@ export const DEFAULT_REGISTRY_CONFIG = [
{
name: 'OP Sepolia',
chainId: 11155420,
providerUrl: ['frame', 'direct', 'https://optimism-sepolia-rpc.publicnode.com'],
rpcUrl: ['frame', 'direct', 'https://optimism-sepolia-rpc.publicnode.com'],
address: DEFAULT_REGISTRY_ADDRESS,
},
{
name: 'Ethereum Sepolia',
chainId: 11155111,
providerUrl: ['frame', 'direct', 'https://ethereum-sepolia-rpc.publicnode.com'],
rpcUrl: ['frame', 'direct', 'https://ethereum-sepolia-rpc.publicnode.com'],
address: DEFAULT_REGISTRY_ADDRESS,
},
];
Expand Down
4 changes: 2 additions & 2 deletions packages/cli/src/commands/alter.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { alter } from './alter';
// Jest Mocking
jest.mock('../settings', () => ({
resolveCliSettings: jest.fn().mockReturnValue({
registryProviderUrl: 'http://localhost:3000',
registryRpcUrl: 'http://localhost:3000',
registryChainId: '123', // or whatever value is appropriate in your case
privateKey: generatePrivateKey(), // or whatever value is appropriate in your case
cannonDirectory: dirSync().name,
providerUrl: 'http://localhost:8545',
rpcUrl: 'http://localhost:8545',
// Add other properties as needed
}),
}));
Expand Down
11 changes: 4 additions & 7 deletions packages/cli/src/commands/build.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,16 +100,15 @@ describe('build', () => {
});

it('should resolve chainId from provider url', async () => {
const providerUrl = `http://127.0.0.1:${port}`;
const rpcUrl = `http://127.0.0.1:${port}`;

jest.mocked(provider.getChainId).mockResolvedValue(chainId);

await cli.parseAsync([...fixedArgs, '--provider-url', providerUrl]);
await cli.parseAsync([...fixedArgs, '--rpc-url', rpcUrl]);

expect((utilProvider.resolveProvider as jest.Mock).mock.calls[0][0].cliSettings.providerUrl).toEqual(providerUrl);
expect((utilProvider.resolveProvider as jest.Mock).mock.calls[0][0].cliSettings.rpcUrl).toEqual(rpcUrl);
expect((utilProvider.resolveProvider as jest.Mock).mock.calls[0][0].chainId).toEqual(chainId);
expect(utilProvider.resolveProvider).toHaveBeenCalledTimes(1);

expect((buildCommand.build as jest.Mock).mock.calls[0][0].provider).toEqual(provider);
});
});
Expand All @@ -121,9 +120,7 @@ describe('build', () => {

await cli.parseAsync(args);

expect((utilProvider.resolveProvider as jest.Mock).mock.calls[0][0].cliSettings.providerUrl.split(',')[0]).toEqual(
'frame'
);
expect((utilProvider.resolveProvider as jest.Mock).mock.calls[0][0].cliSettings.rpcUrl.split(',')[0]).toEqual('frame');
expect((utilProvider.resolveProvider as jest.Mock).mock.calls[0][0].chainId).toEqual(chainId);
expect(utilProvider.resolveProvider).toHaveBeenCalledTimes(1);

Expand Down
16 changes: 6 additions & 10 deletions packages/cli/src/commands/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ interface Params {
persist?: boolean;
plugins?: boolean;
publicSourceCode?: boolean;
providerUrl?: string;
rpcUrl?: string;
registryPriority?: 'local' | 'onchain' | 'offline';
gasPrice?: bigint;
gasFee?: bigint;
Expand All @@ -74,7 +74,7 @@ export async function build({
persist = true,
plugins = true,
publicSourceCode = false,
providerUrl,
rpcUrl,
registryPriority,
gasPrice,
gasFee,
Expand All @@ -86,7 +86,7 @@ export async function build({
throw new Error('wipe and upgradeFrom are mutually exclusive. Please specify one or the other');
}

if (!persist && providerUrl) {
if (!persist && rpcUrl) {
log(
yellowBright(bold('⚠️ This is a simulation. No changes will be made to the chain. No package data will be saved.\n'))
);
Expand Down Expand Up @@ -228,14 +228,10 @@ export async function build({
}
log('');

const providerUrlMsg =
provider.transport.type === 'http'
? provider.transport.url
: typeof providerUrl === 'string'
? providerUrl.split(',')[0]
: providerUrl;
const rpcUrlMsg =
provider.transport.type === 'http' ? provider.transport.url : typeof rpcUrl === 'string' ? rpcUrl.split(',')[0] : rpcUrl;

log(bold(`Building the chain (ID ${chainId})${providerUrlMsg ? ' via ' + hideApiKey(providerUrlMsg) : ''}...`));
log(bold(`Building the chain (ID ${chainId})${rpcUrlMsg ? ' via ' + hideApiKey(rpcUrlMsg) : ''}...`));

let defaultSignerAddress: string;
if (getDefaultSigner) {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/fetch.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ describe('fetch', () => {
jest.fn().mockReturnValue({
ipfsUrl: 'http://127.0.0.1:5001',
publishIpfsUrl: 'http://127.0.0.1:5001',
registryProviderUrl: 'http://localhost:3000',
registryRpcUrl: 'http://localhost:3000',
registryAddress: viem.zeroAddress,
registryChainId: '123',
cannonDirectory: '/cannon/directory/',
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/src/commands/publish.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ describe('publish command', () => {
jest.fn().mockReturnValue({
ipfsUrl: 'http://127.0.0.1:5001',
publishIpfsUrl: 'http://127.0.0.1:5001',
registryProviderUrl: 'http://localhost:3000',
registryRpcUrl: 'http://localhost:3000',
registryAddress: viem.zeroAddress,
registryChainId: '123', // or whatever value is appropriate in your case
cannonDirectory: dirSync().name,
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/commands/publishers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ export async function publishers({ cliSettings, options, packageRef }: Params) {

if (cliSettings.isE2E) {
// anvil optimism fork
cliSettings.registries[0].providerUrl = ['http://127.0.0.1:9546'];
cliSettings.registries[0].rpcUrl = ['http://127.0.0.1:9546'];
// anvil mainnet fork
cliSettings.registries[1].providerUrl = ['http://127.0.0.1:9545'];
cliSettings.registries[1].rpcUrl = ['http://127.0.0.1:9545'];
}

debug('Registries list: ', cliSettings.registries);
Expand Down Expand Up @@ -98,13 +98,13 @@ export async function publishers({ cliSettings, options, packageRef }: Params) {
const registryProviders = await Promise.all([
resolveProviderAndSigners({
chainId: readRegistry.chainId!,
checkProviders: readRegistry.providerUrl,
checkProviders: readRegistry.rpcUrl,
action: ProviderAction.ReadProvider,
}),
resolveProviderAndSigners({
chainId: writeRegistry.chainId!,
privateKey: cliSettings.privateKey!,
checkProviders: writeRegistry.providerUrl,
checkProviders: writeRegistry.rpcUrl,
action: options.list ? ProviderAction.ReadProvider : ProviderAction.WriteProvider,
}),
]);
Expand Down Expand Up @@ -242,7 +242,7 @@ export async function publishers({ cliSettings, options, packageRef }: Params) {
waitForEvent({
eventName: 'PackagePublishersChanged',
abi: mainnetRegistry.contract.abi,
providerUrl: _.last(mainnetRegistryConfig.providerUrl)!,
rpcUrl: _.last(mainnetRegistryConfig.rpcUrl)!,
expectedArgs: {
name: packageNameHex,
publisher: mainnetPublishers,
Expand All @@ -251,7 +251,7 @@ export async function publishers({ cliSettings, options, packageRef }: Params) {
waitForEvent({
eventName: 'PackagePublishersChanged',
abi: optimismRegistry.contract.abi,
providerUrl: _.last(optimismRegistryConfig.providerUrl)!,
rpcUrl: _.last(optimismRegistryConfig.rpcUrl)!,
expectedArgs: {
name: packageNameHex,
publisher: optimismPublishers,
Expand Down
12 changes: 6 additions & 6 deletions packages/cli/src/commands/register.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ export async function register({ cliSettings, options, packageRefs, fromPublish
// mock provider urls when the execution comes from e2e tests
if (cliSettings.isE2E) {
// anvil optimism fork
cliSettings.registries[0].providerUrl = ['http://127.0.0.1:9546'];
cliSettings.registries[0].rpcUrl = ['http://127.0.0.1:9546'];
// anvil mainnet fork
cliSettings.registries[1].providerUrl = ['http://127.0.0.1:9545'];
cliSettings.registries[1].rpcUrl = ['http://127.0.0.1:9545'];
}

debug('Registries list: ', cliSettings.registries);
Expand All @@ -42,13 +42,13 @@ export async function register({ cliSettings, options, packageRefs, fromPublish
const registryProviders = await Promise.all([
resolveProviderAndSigners({
chainId: readRegistry.chainId!,
checkProviders: readRegistry.providerUrl,
checkProviders: readRegistry.rpcUrl,
action: ProviderAction.ReadProvider,
}),
resolveProviderAndSigners({
chainId: writeRegistry.chainId!,
privateKey: cliSettings.privateKey!,
checkProviders: writeRegistry.providerUrl,
checkProviders: writeRegistry.rpcUrl,
action: ProviderAction.WriteProvider,
}),
]);
Expand Down Expand Up @@ -194,7 +194,7 @@ export async function register({ cliSettings, options, packageRefs, fromPublish
waitForEvent({
eventName: 'PackageOwnerChanged',
abi: mainnetRegistry.contract.abi,
providerUrl: _.last(optimismRegistryConfig.providerUrl)!,
rpcUrl: _.last(optimismRegistryConfig.rpcUrl)!,
expectedArgs: {
name: packageNameHex,
owner: userAddress,
Expand All @@ -203,7 +203,7 @@ export async function register({ cliSettings, options, packageRefs, fromPublish
waitForEvent({
eventName: 'PackagePublishersChanged',
abi: mainnetRegistry.contract.abi,
providerUrl: _.last(optimismRegistryConfig.providerUrl)!,
rpcUrl: _.last(optimismRegistryConfig.rpcUrl)!,
expectedArgs: {
name: packageNameHex,
publisher: [userAddress],
Expand Down
8 changes: 4 additions & 4 deletions packages/cli/src/commands/unpublish.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,9 @@ export async function unpublish({ cliSettings, options, packageRef }: Params) {

if (cliSettings.isE2E) {
// anvil optimism fork
cliSettings.registries[0].providerUrl = ['http://127.0.0.1:9546'];
cliSettings.registries[0].rpcUrl = ['http://127.0.0.1:9546'];
// anvil mainnet fork
cliSettings.registries[1].providerUrl = ['http://127.0.0.1:9545'];
cliSettings.registries[1].rpcUrl = ['http://127.0.0.1:9545'];
}

// initialized optimism as the default registry
Expand Down Expand Up @@ -92,13 +92,13 @@ export async function unpublish({ cliSettings, options, packageRef }: Params) {
resolveProviderAndSigners({
chainId: writeRegistry.chainId!,
privateKey: cliSettings.privateKey!,
checkProviders: writeRegistry.providerUrl,
checkProviders: writeRegistry.rpcUrl,
action: ProviderAction.WriteProvider,
}),
// read from the other one
resolveProviderAndSigners({
chainId: readRegistry.chainId!,
checkProviders: readRegistry.providerUrl,
checkProviders: readRegistry.rpcUrl,
action: ProviderAction.ReadProvider,
}),
]);
Expand Down
42 changes: 33 additions & 9 deletions packages/cli/src/commandsConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,13 @@ const commandsConfig = {
anvilOptions: anvilOptions,
options: [
{
flags: '-n --provider-url [url]',
flags: '-n --rpc-url [url]',
description: 'RPC endpoint to fork off of',
},
{
flags: '-n --provider-url [url]',
description: '(DEPRECATED) RPC endpoint to fork off of',
},
{
flags: '--build',
description: 'Specify to rebuild generated artifacts with latest, even if no changed settings have been defined.',
Expand Down Expand Up @@ -246,9 +250,13 @@ const commandsConfig = {
anvilOptions: anvilOptions,
options: [
{
flags: '-n --provider-url [url]',
flags: '-n --rpc-url [url]',
description: 'RPC endpoint to execute the deployment on',
},
{
flags: '-n --provider-url [url]',
description: '(DEPRECATED) RPC endpoint to fork off of',
},
{
flags: '-c --chain-id <number>',
description: 'The chain id to run against',
Expand Down Expand Up @@ -372,9 +380,13 @@ const commandsConfig = {
'When the change needs to be made in a subpackage, specify the step names leading to the subpackage, comma separated.',
},
{
flags: '-n --provider-url [url]',
flags: '-n --rpc-url [url]',
description: 'RPC endpoint to alter to',
},
{
flags: '-n --provider-url [url]',
description: '(DEPRECATED) RPC endpoint to fork off of',
},
{
flags: '-p --preset <preset>',
description: '(DEPRECATED) Preset of the deployment to alter',
Expand Down Expand Up @@ -427,7 +439,7 @@ const commandsConfig = {
],
options: [
{
flags: '-n --registry-provider-url [url]',
flags: '-n --registry-rpc-url [url]',
description: 'RPC endpoint to publish to',
},
{
Expand Down Expand Up @@ -499,7 +511,7 @@ const commandsConfig = {
],
options: [
{
flags: '-n --registry-provider-url [url]',
flags: '-n --registry-rpc-url [url]',
description: 'RPC endpoint to unpublish to',
},
{
Expand Down Expand Up @@ -551,7 +563,7 @@ const commandsConfig = {
],
options: [
{
flags: '-n --registry-provider-url [url]',
flags: '-n --registry-rpc-url [url]',
description: 'RPC endpoint to register your package to',
},
{
Expand Down Expand Up @@ -611,7 +623,7 @@ const commandsConfig = {
description: 'List package publishers',
},
{
flags: '-n --registry-provider-url [url]',
flags: '-n --registry-rpc-url [url]',
description: 'RPC endpoint to add a publisher to your package',
},
{
Expand Down Expand Up @@ -756,6 +768,10 @@ const commandsConfig = {
},
{
flags: '-n --provider-url [url]',
description: '(DEPRECATED) RPC endpoint to fork off of',
},
{
flags: '-n --rpc-url [url]',
description: 'RPC endpoint to fork off of',
},
{
Expand Down Expand Up @@ -810,9 +826,13 @@ const commandsConfig = {
],
options: [
{
flags: '-n --provider-url [url]',
flags: '-n --rpc-url [url]',
description: 'RPC endpoint to fork off of',
},
{
flags: '-n --provider-url [url]',
description: '(DEPRECATED) RPC endpoint to fork off of',
},
{
flags: '-c --chain-id',
description: 'Chain ID to connect to and run fork tests with',
Expand Down Expand Up @@ -855,9 +875,13 @@ const commandsConfig = {
description: 'Chain ID of deployment to interact with ',
},
{
flags: '-n --provider-url [url]',
flags: '-n --rpc-url [url]',
description: 'RPC endpoint to execute the deployment on',
},
{
flags: '-n --provider-url [url]',
description: '(DEPRECATED) RPC endpoint to fork off of',
},
{
flags: '-p --preset <preset>',
description: '(DEPRECATED) Load an alternate setting preset',
Expand Down
Loading
Loading