Skip to content

Commit

Permalink
feat: account deployContract ts overide base class
Browse files Browse the repository at this point in the history
  • Loading branch information
tabaktoni committed Nov 25, 2022
1 parent f695629 commit dd4502d
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 9 deletions.
2 changes: 1 addition & 1 deletion __tests__/account.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ describe('deploy and test Wallet', () => {
});

test('UDC DeployContract', async () => {
const deployResponse = await account.deployContract2({
const deployResponse = await account.deployContract({
classHash: erc20ClassHash,
constructorCalldata: [
encodeShortString('Token'),
Expand Down
8 changes: 4 additions & 4 deletions src/account/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import {
Abi,
Call,
DeclareContractResponse,
DeployContract2Response,
DeployContractResponse,
DeployContractUDCResponse,
EstimateFeeAction,
InvocationsDetails,
InvocationsSignerDetails,
Expand Down Expand Up @@ -327,10 +327,10 @@ export class Account extends Provider implements AccountInterface {
* @param detials InvocationsDetails
* @returns Promise<AccountDeployContractResponse>
*/
public async deployContract2(
public async deployContract(
payload: UniversalDeployerContractPayload,
details: InvocationsDetails = {}
): Promise<DeployContract2Response> {
): Promise<DeployContractUDCResponse> {
const deployTx = await this.deploy(payload, details);
const txReceipt = await this.waitForTransaction(deployTx.transaction_hash);
return parseUDCEvent(txReceipt);
Expand All @@ -342,7 +342,7 @@ export class Account extends Provider implements AccountInterface {
) {
const { transaction_hash } = await this.declare({ contract, classHash }, details);
const declare = await this.waitForTransaction(transaction_hash);
const deploy = await this.deployContract2({ classHash, constructorCalldata }, details);
const deploy = await this.deployContract({ classHash, constructorCalldata }, details);
return { declare: { ...declare, class_hash: classHash }, deploy };
}

Expand Down
13 changes: 13 additions & 0 deletions src/account/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
DeclareContractResponse,
DeclareDeployContractResponse,
DeployContractResponse,
DeployContractUDCResponse,
EstimateFeeAction,
EstimateFeeDetails,
EstimateFeeResponse,
Expand Down Expand Up @@ -164,6 +165,18 @@ export abstract class AccountInterface extends ProviderInterface {
transactionsDetail?: InvocationsDetails
): Promise<InvokeFunctionResponse>;

/**
* Simplify deploy simulating old DeployContract with same response + UDC specific response
*
* @param payload UniversalDeployerContractPayload
* @param detials InvocationsDetails
* @returns Promise<AccountDeployContractResponse>
*/
public abstract deployContract(
payload: UniversalDeployerContractPayload,
details: InvocationsDetails
): Promise<DeployContractUDCResponse>;

/**
* Declares and Deploy a given compiled contract (json) to starknet using UDC
*
Expand Down
2 changes: 1 addition & 1 deletion src/provider/default.ts
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ export class Provider implements ProviderInterface {
* @deprecated This method won't be supported, use Account.deploy instead
*/
public async deployContract(
payload: DeployContractPayload,
payload: DeployContractPayload | any,
details: InvocationsDetails
): Promise<DeployContractResponse> {
return this.provider.deployContract(payload, details);
Expand Down
2 changes: 1 addition & 1 deletion src/provider/interface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ export abstract class ProviderInterface {
* @returns a confirmation of sending a transaction on the starknet contract
*/
public abstract deployContract(
payload: DeployContractPayload,
payload: DeployContractPayload | any,
details?: InvocationsDetails
): Promise<DeployContractResponse>;

Expand Down
4 changes: 2 additions & 2 deletions src/types/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ export interface DeployContractResponse {
transaction_hash: string;
}

export interface DeployContract2Response extends DeployContractResponse {
export interface DeployContractUDCResponse extends DeployContractResponse {
address: string;
deployer: string;
unique: string;
Expand All @@ -30,5 +30,5 @@ export interface DeployContract2Response extends DeployContractResponse {

export type DeclareDeployContractResponse = {
declare: DeclareTransactionReceiptResponse;
deploy: DeployContract2Response;
deploy: DeployContractUDCResponse;
};

0 comments on commit dd4502d

Please sign in to comment.