diff --git a/__tests__/defaultProvider.test.ts b/__tests__/defaultProvider.test.ts index 2b12f2d11..6a287084c 100644 --- a/__tests__/defaultProvider.test.ts +++ b/__tests__/defaultProvider.test.ts @@ -61,11 +61,6 @@ describe('defaultProvider', () => { return expect(block).toHaveProperty('block_number'); }); - test('getCode() -> { bytecode }', async () => { - const code = await testProvider.getCode(exampleContractAddress); - return expect(Array.isArray(code.bytecode)).toBe(true); - }); - describe('getStorageAt', () => { test('with "key" type of number', () => { return expect(testProvider.getStorageAt(exampleContractAddress, 0)).resolves.not.toThrow(); diff --git a/__tests__/sequencerProvider.test.ts b/__tests__/sequencerProvider.test.ts index 207d85fb8..10533853f 100644 --- a/__tests__/sequencerProvider.test.ts +++ b/__tests__/sequencerProvider.test.ts @@ -11,6 +11,7 @@ import { describeIfSequencer('SequencerProvider', () => { let provider: SequencerProvider; let customSequencerProvider: Provider; + let exampleContractAddress: string; beforeAll(async () => { provider = getTestProvider() as SequencerProvider; @@ -27,11 +28,12 @@ describeIfSequencer('SequencerProvider', () => { let exampleTransactionHash: string; beforeAll(async () => { - const { transaction_hash } = await provider.deployContract({ + const { transaction_hash, contract_address } = await provider.deployContract({ contract: compiledErc20, }); await provider.waitForTransaction(transaction_hash); exampleTransactionHash = transaction_hash; + exampleContractAddress = contract_address; }); test('getTransactionStatus()', async () => { @@ -44,6 +46,11 @@ describeIfSequencer('SequencerProvider', () => { expect(transactionTrace).toHaveProperty('signature'); }); + test('getCode() -> { bytecode }', async () => { + const code = await provider.getCode(exampleContractAddress); + return expect(Array.isArray(code.bytecode)).toBe(true); + }); + describeIfNotDevnet('which are not available on devnet', () => { test('getContractAddresses()', async () => { const { GpsStatementVerifier, Starknet } = await provider.getContractAddresses(); diff --git a/src/provider/default.ts b/src/provider/default.ts index 78284a3b3..30ffb19c3 100644 --- a/src/provider/default.ts +++ b/src/provider/default.ts @@ -10,7 +10,6 @@ import { DeployContractResponse, EstimateFeeResponse, GetBlockResponse, - GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, @@ -104,13 +103,6 @@ export class Provider implements ProviderInterface { return this.provider.declareContract(payload); } - public async getCode( - contractAddress: string, - blockIdentifier?: BlockIdentifier - ): Promise { - return this.provider.getCode(contractAddress, blockIdentifier); - } - public async waitForTransaction(txHash: BigNumberish, retryInterval?: number): Promise { return this.provider.waitForTransaction(txHash, retryInterval); } diff --git a/src/provider/interface.ts b/src/provider/interface.ts index b87b501d1..d6fafb19f 100644 --- a/src/provider/interface.ts +++ b/src/provider/interface.ts @@ -10,7 +10,6 @@ import type { DeployContractResponse, EstimateFeeResponse, GetBlockResponse, - GetCodeResponse, GetTransactionReceiptResponse, GetTransactionResponse, Invocation, @@ -43,11 +42,6 @@ export abstract class ProviderInterface { */ public abstract getBlock(blockIdentifier: BlockIdentifier): Promise; - public abstract getCode( - contractAddress: string, - blockIdentifier?: BlockIdentifier - ): Promise; - /** * Gets the contract class of the deployed contract. * diff --git a/src/provider/rpc.ts b/src/provider/rpc.ts index a440217b5..7c9f20d6f 100644 --- a/src/provider/rpc.ts +++ b/src/provider/rpc.ts @@ -223,17 +223,6 @@ export class RpcProvider implements ProviderInterface { return this.responseParser.parseCallContractResponse(result); } - public async getCode( - contractAddress: string, - _blockIdentifier?: BlockIdentifier - ): Promise { - // deprecated method, please wait for an update of starknet.js - - const result = await this.fetchEndpoint('starknet_getCode', [contractAddress]); - - return this.responseParser.parseGetCodeResponse(result); - } - public async waitForTransaction(txHash: BigNumberish, retryInterval: number = 8000) { let onchain = false; let retries = 100; diff --git a/src/provider/sequencer.ts b/src/provider/sequencer.ts index 77318e069..2ea14800b 100644 --- a/src/provider/sequencer.ts +++ b/src/provider/sequencer.ts @@ -332,9 +332,7 @@ export class SequencerProvider implements ProviderInterface { contractAddress: string, blockIdentifier: BlockIdentifier = 'pending' ): Promise { - return this.fetchEndpoint('get_code', { contractAddress, blockIdentifier }).then( - this.responseParser.parseGetCodeResponse - ); + return this.fetchEndpoint('get_code', { contractAddress, blockIdentifier }); } public async waitForTransaction(txHash: BigNumberish, retryInterval: number = 8000) { diff --git a/src/types/api/rpc.ts b/src/types/api/rpc.ts index ad244744f..e70093ff4 100644 --- a/src/types/api/rpc.ts +++ b/src/types/api/rpc.ts @@ -49,11 +49,6 @@ export namespace RPC { transactions: string[]; }; */ - export type GetCodeResponse = { - bytecode: string[]; - abi: string; - }; - export type GetStorageAtResponse = string; export type GetTransactionReceiptResponse = { @@ -192,11 +187,6 @@ export namespace RPC { REQUEST: any[]; RESPONSE: GetTransactionCountResponse; }; - starknet_getCode: { - QUERY: never; - REQUEST: any[]; - RESPONSE: GetCodeResponse; - }; starknet_call: { QUERY: never; REQUEST: any[]; diff --git a/src/types/provider.ts b/src/types/provider.ts index 8504c8c62..9bd018f97 100644 --- a/src/types/provider.ts +++ b/src/types/provider.ts @@ -16,11 +16,6 @@ export interface GetBlockResponse { transactions: Array; } -export interface GetCodeResponse { - bytecode: string[]; - // abi: string; // is not consistent between rpc and sequencer (is it?), therefore not included in the provider interface -} - export type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse; export interface CommonTransactionResponse { diff --git a/src/utils/responseParser/rpc.ts b/src/utils/responseParser/rpc.ts index 0a6df8767..41dc85e8a 100644 --- a/src/utils/responseParser/rpc.ts +++ b/src/utils/responseParser/rpc.ts @@ -62,10 +62,6 @@ export class RPCResponseParser extends ResponseParser { }; } - public parseGetCodeResponse(res: RPC.GetCodeResponse): RPC.GetCodeResponse { - return res; - } - public parseFeeEstimateResponse(res: RPC.EstimateFeeResponse): EstimateFeeResponse { return { overall_fee: toBN(res.overall_fee), diff --git a/src/utils/responseParser/sequencer.ts b/src/utils/responseParser/sequencer.ts index 8d7e7ad49..23b89b862 100644 --- a/src/utils/responseParser/sequencer.ts +++ b/src/utils/responseParser/sequencer.ts @@ -71,10 +71,6 @@ export class SequencerAPIResponseParser extends ResponseParser { }; } - public parseGetCodeResponse(res: Sequencer.GetCodeResponse): Sequencer.GetCodeResponse { - return res; - } - public parseFeeEstimateResponse(res: Sequencer.EstimateFeeResponse): EstimateFeeResponse { if ('overall_fee' in res) { let gasInfo = {};