Skip to content
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: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Changelog

## 0.0.1-alpha.10 (2025-01-13)

- Update Defender SDK to v2.1.0, enable internal `origin` option for Defender deployments.
- **Breaking changes:**
- Requires Node 18 or higher.

## 0.0.1-alpha.9 (2024-09-16)

- Fix packaging. ([#15](https://github.com/OpenZeppelin/defender-deploy-client-cli/pull/15))
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
The MIT License (MIT)

Copyright (c) 2023 zOS Global Limited
Copyright (c) 2023-2025 Zeppelin Group Ltd

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ Run 'npx @openzeppelin/defender-deploy-client-cli <COMMAND> --help' for more inf

### Deploying a contract
```
npx @openzeppelin/defender-deploy-client-cli deploy --contractName <CONTRACT_NAME> --contractPath <CONTRACT_PATH> --chainId <CHAIN_ID> --buildInfoFile <BUILD_INFO_FILE_PATH> [--constructorBytecode <CONSTRUCTOR_ARGS>] [--licenseType '<LICENSE>'] [--verifySourceCode <true|false>] [--relayerId <RELAYER_ID>] [--salt <SALT>] [--createFactoryAddress <CREATE_FACTORY_ADDRESS>] [--gasLimit <GAS_LIMIT>] [--gasPrice <GAS_PRICE>] [--maxFeePerGas <MAX_FEE_PER_GAS>] [--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS>] [--metadata '<METADATA>']
npx @openzeppelin/defender-deploy-client-cli deploy --contractName <CONTRACT_NAME> --contractPath <CONTRACT_PATH> --chainId <CHAIN_ID> --buildInfoFile <BUILD_INFO_FILE_PATH> [--constructorBytecode <CONSTRUCTOR_ARGS>] [--licenseType '<LICENSE>'] [--verifySourceCode <true|false>] [--relayerId <RELAYER_ID>] [--salt <SALT>] [--createFactoryAddress <CREATE_FACTORY_ADDRESS>] [--gasLimit <GAS_LIMIT>] [--gasPrice <GAS_PRICE>] [--maxFeePerGas <MAX_FEE_PER_GAS>] [--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS>] [--metadata '<METADATA>'] [--origin '<ORIGIN>']

Deploys a contract using OpenZeppelin Defender.

Expand All @@ -69,7 +69,7 @@ Additional options:
--maxFeePerGas <MAX_FEE_PER_GAS> Maximum total fee per gas, in wei.
--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS> Maximum priority fee per gas, in wei.
--metadata '<METADATA>' Use this to identify, tag, or classify deployments. See https://docs.openzeppelin.com/defender/module/deploy#metadata. Must be a JSON string, for example: --metadata '{ "commitHash": "4ae3e0d", "tag": "v1.0.0", "anyOtherField": "anyValue" }'

--origin <ORIGIN> The client that made the deployment. For internal use only. Only 'Foundry' or 'SDK' are supported. Defaults to 'SDK'.
```

### Proposing an upgrade
Expand Down
10 changes: 5 additions & 5 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@openzeppelin/defender-deploy-client-cli",
"version": "0.0.1-alpha.9",
"version": "0.0.1-alpha.10",
"description": "CLI for deployments using OpenZeppelin Defender SDK",
"repository": "https://github.com/OpenZeppelin/defender-deploy-client-cli",
"license": "MIT",
Expand All @@ -19,7 +19,7 @@
"defender-deploy-client-cli": "./dist/cli.js"
},
"devDependencies": {
"@types/node": "^16.11.7",
"@types/node": "^18.0.0",
"@types/minimist": "^1.2.5",
"ava": "^6.0.0",
"rimraf": "^5.0.0",
Expand All @@ -28,9 +28,9 @@
},
"dependencies": {
"minimist": "^1.2.8",
"@openzeppelin/defender-sdk-deploy-client": "^1.14.4",
"@openzeppelin/defender-sdk-base-client": "^1.14.4",
"@openzeppelin/defender-sdk-network-client": "^1.14.4",
"@openzeppelin/defender-sdk-deploy-client": "^2.1.0",
"@openzeppelin/defender-sdk-base-client": "^2.1.0",
"@openzeppelin/defender-sdk-network-client": "^2.1.0",
"dotenv": "^16.3.1"
}
}
24 changes: 20 additions & 4 deletions src/commands/deploy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@ import minimist from 'minimist';
import { FunctionArgs, deployContract } from '../internal/deploy-contract';
import { getDeployClient } from '../internal/client';
import { USAGE_COMMAND_PREFIX, getAndValidateString, getNetwork } from '../internal/utils';
import { DeployClient, DeployMetadata, TxOverrides } from '@openzeppelin/defender-sdk-deploy-client';
import { DeployClient, DeploymentResponse, DeployMetadata, TxOverrides } from '@openzeppelin/defender-sdk-deploy-client';
import { NetworkClient } from '@openzeppelin/defender-sdk-network-client';

const USAGE = `${USAGE_COMMAND_PREFIX} deploy --contractName <CONTRACT_NAME> --contractPath <CONTRACT_PATH> --chainId <CHAIN_ID> --buildInfoFile <BUILD_INFO_FILE_PATH> [--constructorBytecode <CONSTRUCTOR_ARGS>] [--licenseType <LICENSE>] [--verifySourceCode <true|false>] [--relayerId <RELAYER_ID>] [--salt <SALT>] [--createFactoryAddress <CREATE_FACTORY_ADDRESS>] [--gasLimit <GAS_LIMIT>] [--gasPrice <GAS_PRICE>] [--maxFeePerGas <MAX_FEE_PER_GAS>] [--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS>] [--metadata <METADATA>]`;
const USAGE = `${USAGE_COMMAND_PREFIX} deploy --contractName <CONTRACT_NAME> --contractPath <CONTRACT_PATH> --chainId <CHAIN_ID> --buildInfoFile <BUILD_INFO_FILE_PATH> [--constructorBytecode <CONSTRUCTOR_ARGS>] [--licenseType <LICENSE>] [--verifySourceCode <true|false>] [--relayerId <RELAYER_ID>] [--salt <SALT>] [--createFactoryAddress <CREATE_FACTORY_ADDRESS>] [--gasLimit <GAS_LIMIT>] [--gasPrice <GAS_PRICE>] [--maxFeePerGas <MAX_FEE_PER_GAS>] [--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS>] [--metadata <METADATA>] [--origin <ORIGIN>]`;
const DETAILS = `
Deploys a contract using OpenZeppelin Defender.

Expand All @@ -27,6 +27,7 @@ Additional options:
--maxFeePerGas <MAX_FEE_PER_GAS> Maximum total fee per gas, in wei.
--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS> Maximum priority fee per gas, in wei.
--metadata '<METADATA>' Use this to identify, tag, or classify deployments. See https://docs.openzeppelin.com/defender/module/deploy#metadata. Must be a JSON string, for example: --metadata '{ "commitHash": "4ae3e0d", "tag": "v1.0.0", "anyOtherField": "anyValue" }'
--origin <ORIGIN> The client that made the deployment. For internal use only. Only 'Foundry' or 'SDK' are supported. Defaults to 'SDK'.
`;

export async function deploy(args: string[], deployClient?: DeployClient, networkClient?: NetworkClient): Promise<void> {
Expand All @@ -47,7 +48,7 @@ function parseArgs(args: string[]) {
'help',
'verifySourceCode',
],
string: ['contractName', 'contractPath', 'chainId', 'buildInfoFile', 'licenseType', 'constructorBytecode', 'relayerId', 'salt', 'createFactoryAddress', 'gasLimit', 'gasPrice', 'maxFeePerGas', 'maxPriorityFeePerGas', 'metadata'],
string: ['contractName', 'contractPath', 'chainId', 'buildInfoFile', 'licenseType', 'constructorBytecode', 'relayerId', 'salt', 'createFactoryAddress', 'gasLimit', 'gasPrice', 'maxFeePerGas', 'maxPriorityFeePerGas', 'metadata', 'origin'],

alias: { h: 'help' },
default: { verifySourceCode: true },
Expand Down Expand Up @@ -100,10 +101,11 @@ async function getFunctionArgs(parsedArgs: minimist.ParsedArgs, extraArgs: strin
};

const metadata = getAndValidateJsonString(parsedArgs, 'metadata');
const origin = getAndValidateOrigin(parsedArgs, 'origin');

checkInvalidArgs(parsedArgs);

return { contractName, contractPath, network, buildInfoFile, licenseType, constructorBytecode, verifySourceCode, relayerId, salt, createFactoryAddress, txOverrides, metadata };
return { contractName, contractPath, network, buildInfoFile, licenseType, constructorBytecode, verifySourceCode, relayerId, salt, createFactoryAddress, txOverrides, metadata, origin };
}
}

Expand All @@ -129,6 +131,7 @@ function checkInvalidArgs(parsedArgs: minimist.ParsedArgs) {
'maxFeePerGas',
'maxPriorityFeePerGas',
'metadata',
'origin',
].includes(key),
);
if (invalidArgs.length > 0) {
Expand Down Expand Up @@ -168,4 +171,17 @@ function getAndValidateJsonString(parsedArgs: minimist.ParsedArgs, option: strin
} else {
return undefined;
}
}

function getAndValidateOrigin(parsedArgs: minimist.ParsedArgs, option: string): DeploymentResponse['origin'] | undefined {
const value = getAndValidateString(parsedArgs, option);
const supportedOrigins: DeploymentResponse['origin'][] = ['Foundry', 'SDK'];
if (value !== undefined) {
if (!supportedOrigins.includes(value as DeploymentResponse['origin'])) {
throw new Error(`Option --${option} only supports 'Foundry' or 'SDK'`);
}
return value as DeploymentResponse['origin'];
} else {
return undefined;
}
}
2 changes: 2 additions & 0 deletions src/internal/deploy-contract.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export interface FunctionArgs {
createFactoryAddress?: string;
txOverrides?: TxOverrides;
metadata?: DeployMetadata;
origin?: DeployContractRequest['origin'];
}

export async function deployContract(args: FunctionArgs, client: DeployClient) {
Expand All @@ -34,6 +35,7 @@ export async function deployContract(args: FunctionArgs, client: DeployClient) {
createFactoryAddress: args.createFactoryAddress,
txOverrides: args.txOverrides,
metadata: args.metadata,
origin: args.origin,
};

let deployment: DeploymentResponse;
Expand Down
Binary file modified test/cli.js.snap
Binary file not shown.
5 changes: 4 additions & 1 deletion test/deploy.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ test('deploy required args', async t => {
maxPriorityFeePerGas: undefined
},
metadata: undefined,
origin: undefined,
});
});

Expand All @@ -102,6 +103,7 @@ test('deploy all args', async t => {
'--maxFeePerGas', '2000000000', // 2 gwei
'--maxPriorityFeePerGas', '500000000', // 0.5 gwei
'--metadata', '{ "commitHash": "4ae3e0d", "tag": "v1.0.0", "anyOtherField": "anyValue" }',
'--origin', 'Foundry',
];

await deploy(args, t.context.fakeDeployClient, t.context.fakeNetworkClient);
Expand Down Expand Up @@ -129,7 +131,8 @@ test('deploy all args', async t => {
commitHash: '4ae3e0d',
tag: 'v1.0.0',
anyOtherField: 'anyValue',
}
},
origin: 'Foundry',
});
});

Expand Down
3 changes: 2 additions & 1 deletion test/deploy.js.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Generated by [AVA](https://avajs.dev).

> Snapshot 1

`Usage: npx @openzeppelin/defender-deploy-client-cli deploy --contractName <CONTRACT_NAME> --contractPath <CONTRACT_PATH> --chainId <CHAIN_ID> --buildInfoFile <BUILD_INFO_FILE_PATH> [--constructorBytecode <CONSTRUCTOR_ARGS>] [--licenseType <LICENSE>] [--verifySourceCode <true|false>] [--relayerId <RELAYER_ID>] [--salt <SALT>] [--createFactoryAddress <CREATE_FACTORY_ADDRESS>] [--gasLimit <GAS_LIMIT>] [--gasPrice <GAS_PRICE>] [--maxFeePerGas <MAX_FEE_PER_GAS>] [--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS>] [--metadata <METADATA>]␊
`Usage: npx @openzeppelin/defender-deploy-client-cli deploy --contractName <CONTRACT_NAME> --contractPath <CONTRACT_PATH> --chainId <CHAIN_ID> --buildInfoFile <BUILD_INFO_FILE_PATH> [--constructorBytecode <CONSTRUCTOR_ARGS>] [--licenseType <LICENSE>] [--verifySourceCode <true|false>] [--relayerId <RELAYER_ID>] [--salt <SALT>] [--createFactoryAddress <CREATE_FACTORY_ADDRESS>] [--gasLimit <GAS_LIMIT>] [--gasPrice <GAS_PRICE>] [--maxFeePerGas <MAX_FEE_PER_GAS>] [--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS>] [--metadata <METADATA>] [--origin <ORIGIN>]
Deploys a contract using OpenZeppelin Defender.␊
Expand All @@ -30,5 +30,6 @@ Generated by [AVA](https://avajs.dev).
--maxFeePerGas <MAX_FEE_PER_GAS> Maximum total fee per gas, in wei.␊
--maxPriorityFeePerGas <MAX_PRIORITY_FEE_PER_GAS> Maximum priority fee per gas, in wei.␊
--metadata '<METADATA>' Use this to identify, tag, or classify deployments. See https://docs.openzeppelin.com/defender/module/deploy#metadata. Must be a JSON string, for example: --metadata '{ "commitHash": "4ae3e0d", "tag": "v1.0.0", "anyOtherField": "anyValue" }'␊
--origin <ORIGIN> The client that made the deployment. For internal use only. Only 'Foundry' or 'SDK' are supported. Defaults to 'SDK'.␊
`
Binary file modified test/deploy.js.snap
Binary file not shown.
Binary file modified test/get-approval-process.js.snap
Binary file not shown.
Binary file modified test/propose-upgrade.js.snap
Binary file not shown.
Loading
Loading