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: add attribute to detect the deployment origin #634

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
20 changes: 20 additions & 0 deletions packages/deploy/src/api/deployment.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,26 @@ describe('Deploy Client', () => {
expect(deployClient.api.post).toBeCalledWith('/deployments', deployCreatePayload);
expect(createAuthenticatedApi).toBeCalled();
});
it('adds origin to the payload if not provided', async () => {
await deployClient.deployContract(deployCreatePayload);
expect(deployClient.api.post).toHaveBeenCalledWith(
'/deployments',
expect.objectContaining({
origin: 'SDK',
}),
);
expect(createAuthenticatedApi).toHaveBeenCalled();
});
it('allows custom origin', async () => {
await deployClient.deployContract({ ...deployCreatePayload, origin: 'Foundry' });
expect(deployClient.api.post).toHaveBeenCalledWith(
'/deployments',
expect.objectContaining({
origin: 'Foundry',
}),
);
expect(createAuthenticatedApi).toHaveBeenCalled();
});
});
describe('get', () => {
it('calls API correctly', async () => {
Expand Down
4 changes: 4 additions & 0 deletions packages/deploy/src/api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ export class DeployClient extends BaseApiClient {
params.artifactPayload = JSON.stringify(extractArtifact(params));
}

// If the origin is not provided,
// we assume the deployment was made using the SDK
if (!params.origin) params.origin = 'SDK';

return this.apiCall(async (api) => {
return api.post(`${DEPLOYMENTS_PATH}`, params);
});
Expand Down
15 changes: 12 additions & 3 deletions packages/deploy/src/models/deployment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,14 +46,20 @@ export interface DeployContractRequest {
approvalProcessId?: string;
createFactoryAddress?: string;
/**
* Only applies to Relayers approval processes, for other default approval processes it has no effect
* @description Only applies to Relayers approval processes, for other default approval processes it has no effect
* @default undefined
*/
txOverrides?: TxOverrides;
/*
* A note to be included in the deployment.
/**
* @description Key-value pairs to be included in the deployment.
*/
metadata?: DeployMetadata;
/**
* @description The client that made the deployment. For internal use only.
* @warning this variable does not represent the `tx.origin` of the deployment.
* @default 'SDK'
*/
origin?: DeploymentOrigin;
}
export interface DeployRequestLibraries {
[k: `${string}:${string}`]: string;
Expand All @@ -70,6 +76,8 @@ export interface DeploymentUpdateRequest {
address?: Address;
}

export type DeploymentOrigin = 'SDK' | 'Foundry' | 'Hardhat' | 'Remix' | 'Wizard';

export interface DeploymentResponse {
deploymentId: string;
createdAt: string;
Expand Down Expand Up @@ -98,6 +106,7 @@ export interface DeploymentResponse {
[k: string]: string;
};
constructorInputs?: (string | boolean | number)[];
origin?: DeploymentOrigin;
}
export interface BlockExplorerVerification {
status: string;
Expand Down
Loading