Skip to content

Commit

Permalink
TEST
Browse files Browse the repository at this point in the history
Signed-off-by: jagpreetsinghsasan <[email protected]>
  • Loading branch information
jagpreetsinghsasan committed Dec 15, 2023
1 parent b5677d4 commit fc86661
Show file tree
Hide file tree
Showing 5 changed files with 328 additions and 41 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -447,18 +447,41 @@
"nullable": false
},
"contract": {
"oneOf": [
{
"$ref": "#/components/schemas/ContractJsonDefinition",
"description": "Send contract ABI directly in the request."
},
{
"$ref": "#/components/schemas/ContractKeychainDefinition",
"description": "Read contract definition from the keychain plugin."
}
],
"$ref": "#/components/schemas/ContractKeychainDefinition",
"description": "Send contract ABI directly in the request.",
"nullable": false
},
"constructorArgs": {
"description": "The list of arguments to pass in to the constructor of the contract being deployed.",
"type": "array",
"default": [],
"items": {}
},
"gasConfig": {
"$ref": "#/components/schemas/GasTransactionConfig",
"nullable": false
},
"value": {
"type": "string",
"description": "Ether balance to send on deployment.",
"nullable": false
}
}
},
"DeployContractNoKeychainV1Request": {
"type": "object",
"required": ["web3SigningCredential", "contract"],
"additionalProperties": false,
"properties": {
"web3SigningCredential": {
"$ref": "#/components/schemas/Web3SigningCredential",
"nullable": false
},
"contract": {
"$ref": "#/components/schemas/ContractJsonDefinition",
"description": "Send contract ABI directly in the request.",
"nullable": false
},
"constructorArgs": {
"description": "The list of arguments to pass in to the constructor of the contract being deployed.",
"type": "array",
Expand Down Expand Up @@ -959,6 +982,50 @@
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain": {
"post": {
"x-hyperledger-cacti": {
"http": {
"verbLowerCase": "post",
"path": "/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain"
}
},
"operationId": "deployContractNoKeychain",
"summary": "Deploys the contract to ethereum ledger without keychain.",
"parameters": [],
"requestBody": {
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/DeployContractNoKeychainV1Request"
}
}
}
},
"responses": {
"200": {
"description": "OK",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/RunTransactionResponse"
}
}
}
},
"500": {
"description": "Internal Server Error",
"content": {
"application/json": {
"schema": {
"$ref": "#/components/schemas/ErrorExceptionResponseV1"
}
}
}
}
}
}
},
"/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/run-transaction": {
"post": {
"x-hyperledger-cacti": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,43 @@ export interface ContractKeychainDefinition {
*/
'keychainId': string;
}
/**
*
* @export
* @interface DeployContractNoKeychainV1Request
*/
export interface DeployContractNoKeychainV1Request {
/**
*
* @type {Web3SigningCredential}
* @memberof DeployContractNoKeychainV1Request
*/
'web3SigningCredential': Web3SigningCredential;
/**
*
* @type {ContractJsonDefinition}
* @memberof DeployContractNoKeychainV1Request
*/
'contract': ContractJsonDefinition;
/**
* The list of arguments to pass in to the constructor of the contract being deployed.
* @type {Array<any>}
* @memberof DeployContractNoKeychainV1Request
*/
'constructorArgs'?: Array<any>;
/**
*
* @type {GasTransactionConfig}
* @memberof DeployContractNoKeychainV1Request
*/
'gasConfig'?: GasTransactionConfig;
/**
* Ether balance to send on deployment.
* @type {string}
* @memberof DeployContractNoKeychainV1Request
*/
'value'?: string;
}
/**
*
* @export
Expand All @@ -156,10 +193,10 @@ export interface DeployContractV1Request {
'web3SigningCredential': Web3SigningCredential;
/**
*
* @type {DeployContractV1RequestContract}
* @type {ContractKeychainDefinition}
* @memberof DeployContractV1Request
*/
'contract': DeployContractV1RequestContract;
'contract': ContractKeychainDefinition;
/**
* The list of arguments to pass in to the constructor of the contract being deployed.
* @type {Array<any>}
Expand All @@ -179,12 +216,6 @@ export interface DeployContractV1Request {
*/
'value'?: string;
}
/**
* @type DeployContractV1RequestContract
* @export
*/
export type DeployContractV1RequestContract = ContractJsonDefinition | ContractKeychainDefinition;

/**
*
* @export
Expand Down Expand Up @@ -1257,6 +1288,40 @@ export const DefaultApiAxiosParamCreator = function (configuration?: Configurati
options: localVarRequestOptions,
};
},
/**
*
* @summary Deploys the contract to ethereum ledger without keychain.
* @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deployContractNoKeychain: async (deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options: AxiosRequestConfig = {}): Promise<RequestArgs> => {
const localVarPath = `/api/v1/plugins/@hyperledger/cactus-plugin-ledger-connector-ethereum/deploy-contract-no-keychain`;
// use dummy base URL string because the URL constructor only accepts absolute URLs.
const localVarUrlObj = new URL(localVarPath, DUMMY_BASE_URL);
let baseOptions;
if (configuration) {
baseOptions = configuration.baseOptions;
}

const localVarRequestOptions = { method: 'POST', ...baseOptions, ...options};
const localVarHeaderParameter = {} as any;
const localVarQueryParameter = {} as any;



localVarHeaderParameter['Content-Type'] = 'application/json';

setSearchParams(localVarUrlObj, localVarQueryParameter);
let headersFromBaseOptions = baseOptions && baseOptions.headers ? baseOptions.headers : {};
localVarRequestOptions.headers = {...localVarHeaderParameter, ...headersFromBaseOptions, ...options.headers};
localVarRequestOptions.data = serializeDataIfNeeded(deployContractNoKeychainV1Request, localVarRequestOptions, configuration)

return {
url: toPathString(localVarUrlObj),
options: localVarRequestOptions,
};
},
/**
*
* @summary Get the Prometheus Metrics
Expand Down Expand Up @@ -1444,6 +1509,17 @@ export const DefaultApiFp = function(configuration?: Configuration) {
const localVarAxiosArgs = await localVarAxiosParamCreator.deployContract(deployContractV1Request, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Deploys the contract to ethereum ledger without keychain.
* @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
async deployContractNoKeychain(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: AxiosRequestConfig): Promise<(axios?: AxiosInstance, basePath?: string) => AxiosPromise<RunTransactionResponse>> {
const localVarAxiosArgs = await localVarAxiosParamCreator.deployContractNoKeychain(deployContractNoKeychainV1Request, options);
return createRequestFunction(localVarAxiosArgs, globalAxios, BASE_PATH, configuration);
},
/**
*
* @summary Get the Prometheus Metrics
Expand Down Expand Up @@ -1518,6 +1594,16 @@ export const DefaultApiFactory = function (configuration?: Configuration, basePa
deployContract(deployContractV1Request?: DeployContractV1Request, options?: any): AxiosPromise<RunTransactionResponse> {
return localVarFp.deployContract(deployContractV1Request, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Deploys the contract to ethereum ledger without keychain.
* @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
*/
deployContractNoKeychain(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: any): AxiosPromise<RunTransactionResponse> {
return localVarFp.deployContractNoKeychain(deployContractNoKeychainV1Request, options).then((request) => request(axios, basePath));
},
/**
*
* @summary Get the Prometheus Metrics
Expand Down Expand Up @@ -1589,6 +1675,18 @@ export class DefaultApi extends BaseAPI {
return DefaultApiFp(this.configuration).deployContract(deployContractV1Request, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Deploys the contract to ethereum ledger without keychain.
* @param {DeployContractNoKeychainV1Request} [deployContractNoKeychainV1Request]
* @param {*} [options] Override http request option.
* @throws {RequiredError}
* @memberof DefaultApi
*/
public deployContractNoKeychain(deployContractNoKeychainV1Request?: DeployContractNoKeychainV1Request, options?: AxiosRequestConfig) {
return DefaultApiFp(this.configuration).deployContractNoKeychain(deployContractNoKeychainV1Request, options).then((request) => request(this.axios, this.basePath));
}

/**
*
* @summary Get the Prometheus Metrics
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ import {
} from "@hyperledger/cactus-common";

import { DeployContractEndpoint } from "./web-services/deploy-contract-v1-endpoint";
import { DeployContractNoKeychainEndpoint } from "./web-services/deploy-contract-no-keychain-v1-endpoint";

import {
DeployContractV1Request,
Expand All @@ -59,6 +60,7 @@ import {
ContractKeychainDefinition,
GasTransactionConfig,
ContractJSON,
DeployContractNoKeychainV1Request,
} from "./generated/openapi/typescript-axios";

import { RunTransactionEndpoint } from "./web-services/run-transaction-v1-endpoint";
Expand All @@ -69,7 +71,6 @@ import { InvokeRawWeb3EthMethodEndpoint } from "./web-services/invoke-raw-web3et
import { InvokeRawWeb3EthContractEndpoint } from "./web-services/invoke-raw-web3eth-contract-v1-endpoint";

import {
isContractJsonDefinition,
isContractKeychainDefinition,
isDeployedContractJsonDefinition,
isGasTransactionConfigEIP1559,
Expand Down Expand Up @@ -376,6 +377,13 @@ export class PluginLedgerConnectorEthereum
});
endpoints.push(endpoint);
}
{
const endpoint = new DeployContractNoKeychainEndpoint({
connector: this,
logLevel: this.options.logLevel,
});
endpoints.push(endpoint);
}
{
const endpoint = new RunTransactionEndpoint({
connector: this,
Expand Down Expand Up @@ -953,24 +961,25 @@ export class PluginLedgerConnectorEthereum
if (isWeb3SigningCredentialNone(req.web3SigningCredential)) {
throw new Error(`Cannot deploy contract with pre-signed TX`);
}
return this.deployContractFromKeychain(req, req.contract);
}

if (isContractJsonDefinition(req.contract)) {
return this.runContractDeployment({
web3SigningCredential: req.web3SigningCredential,
gasConfig: req.gasConfig,
constructorArgs: req.constructorArgs,
value: req.value,
contractJSON: req.contract.contractJSON,
});
} else if (isContractKeychainDefinition(req.contract)) {
return this.deployContractFromKeychain(req, req.contract);
} else {
// Exhaustive check
const unknownContract: never = req.contract;
throw new Error(
`Unknown contract definition provided: ${unknownContract}`,
);
public async deployContractNoKeychain(
req: DeployContractNoKeychainV1Request,
): Promise<RunTransactionResponse> {
Checks.truthy(req, "deployContractNoKeychain() request arg");

if (isWeb3SigningCredentialNone(req.web3SigningCredential)) {
throw new Error(`Cannot deploy contract with pre-signed TX`);
}

return this.runContractDeployment({
web3SigningCredential: req.web3SigningCredential,
gasConfig: req.gasConfig,
constructorArgs: req.constructorArgs,
value: req.value,
contractJSON: req.contract.contractJSON,
});
}

/**
Expand Down
Loading

0 comments on commit fc86661

Please sign in to comment.