Skip to content

Commit dad1eea

Browse files
committed
feat: add gateway provider class
1 parent b217b3b commit dad1eea

File tree

9 files changed

+885
-147
lines changed

9 files changed

+885
-147
lines changed

src/provider/abstractProvider.ts

Lines changed: 16 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { CompiledContract } from '../types';
12
import { BigNumberish } from '../utils/number';
23
import { BlockIdentifier } from './utils';
34

@@ -21,42 +22,16 @@ type Status =
2122
*/
2223

2324
export interface GetBlockResponse {
24-
acceptedTime: number; // "timestamp"
25+
acceptedTime: number;
2526
blockHash: string;
2627
blockNumber: number;
2728
gasPrice: string;
28-
newRoot: string; // "state_root"
29-
oldRoot?: string; // missing
30-
parentHash: string; // "parent_block_hash"
31-
sequencer: string; // "sequencer_address"
32-
status: Status;
33-
transactions: Array<unknown>;
34-
}
35-
36-
/**
37-
* getStateUpdate response object
38-
*/
39-
40-
export interface GetStateUpdateResponse {
41-
blockHash: string;
4229
newRoot: string;
43-
oldRoot: string;
44-
acceptedTime?: number; // missing on the default provider
45-
stateDiff: {
46-
storageDiffs: Array<{
47-
address: string;
48-
key: string;
49-
value: string;
50-
}>;
51-
deployedContracts: Array<{
52-
address: string;
53-
contractHash: string;
54-
}>;
55-
nonces?: Array<{
56-
contractAddress: string;
57-
nonce: BigNumberish;
58-
}>; // missing on the default provider
59-
};
30+
oldRoot?: string;
31+
parentHash: string;
32+
sequencer: string;
33+
status: Status;
34+
transactions: Array<string>;
6035
}
6136

6237
/**
@@ -67,10 +42,10 @@ export interface GetStateUpdateResponse {
6742
export type GetTransactionResponse = InvokeTransactionResponse & DeclareTransactionResponse;
6843

6944
export interface CommonTransactionResponse {
70-
transactionHash: string;
71-
maxFee: string;
72-
version: string;
73-
signature: Array<string>;
45+
transactionHash?: string;
46+
version?: string;
47+
signature?: Array<string>;
48+
maxFee?: string;
7449
nonce?: string;
7550
}
7651

@@ -99,7 +74,7 @@ export interface ContractClass {
9974
}
10075

10176
export interface DeclareTransactionResponse extends CommonTransactionResponse {
102-
contractClass?: ContractClass;
77+
contractClass?: any;
10378
senderAddress?: string;
10479
}
10580

@@ -109,9 +84,9 @@ export type GetTransactionReceiptResponse =
10984

11085
export interface CommonTransactionReceiptResponse {
11186
transactionHash: string;
112-
actualFee: string;
11387
status: Status;
114-
statusData: string;
88+
actualFee?: string;
89+
statusData?: string;
11590
}
11691

11792
export interface MessageToL1 {
@@ -178,9 +153,6 @@ export abstract class Provider {
178153
// Get block information given the block hash or number
179154
abstract getBlock(blockIdentifier: BlockIdentifier): Promise<GetBlockResponse>;
180155

181-
// Get the information about the result of executing the requested block
182-
abstract getStateUpdate(blockHash: BigNumberish): Promise<GetStateUpdateResponse>;
183-
184156
// Get the value of the storage at the given address and key
185157
abstract getStorageAt(
186158
contractAddress: string,
@@ -194,15 +166,6 @@ export abstract class Provider {
194166
// Get the transaction receipt by the transaction hash
195167
abstract getTransactionReceipt(txHash: BigNumberish): Promise<GetTransactionReceiptResponse>;
196168

197-
// Get the contract class deployed under the given class hash.
198-
abstract getClass(classHash: BigNumberish): Promise<ContractClass>;
199-
200-
// Get the contract class deployed under the given address.
201-
abstract getClassAt(contractAddress: BigNumberish): Promise<ContractClass>;
202-
203-
// Get the class hash deployed under the given address.
204-
abstract getClassHash(contractAddress: BigNumberish): Promise<string>;
205-
206169
// Estimates the resources required by a transaction relative to a given state
207170
abstract estimateFee(
208171
request: FunctionCall,
@@ -222,13 +185,13 @@ export abstract class Provider {
222185
): Promise<InvokeContractResponse>;
223186

224187
abstract deployContract(
225-
contractClass: ContractClass,
188+
compiledContract: CompiledContract | string,
226189
constructorCalldata: Array<BigNumberish>,
227190
salt?: BigNumberish
228191
): Promise<DeployContractResponse>;
229192

230193
abstract declareContract(
231-
contractClass: ContractClass,
194+
compiledContract: CompiledContract | string,
232195
version?: BigNumberish
233196
): Promise<DeclareContractResponse>;
234197

0 commit comments

Comments
 (0)