Skip to content

Commit

Permalink
fix: support flat event type in ABI
Browse files Browse the repository at this point in the history
  • Loading branch information
xJonathanLEI committed Nov 8, 2023
1 parent 3fd85cf commit 4ed026b
Show file tree
Hide file tree
Showing 6 changed files with 48 additions and 62 deletions.
40 changes: 20 additions & 20 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ serde = { version = "1.0.164", features = ["derive"] }
serde_json = { version = "1.0.99", features = ["preserve_order"] }
serde_with = "2.3.3"
shellexpand = "3.1.0"
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "33e200d3d53a685586ee178b4bd0be4b48250c08" }
starknet = { git = "https://github.com/xJonathanLEI/starknet-rs", rev = "cfa3c43e4c12ca3a45c471b233fe3eb5a2f31e0c" }
tempfile = "3.8.0"
thiserror = "1.0.40"
tokio = { version = "1.28.2", default-features = false, features = ["macros", "rt-multi-thread"] }
Expand Down
1 change: 0 additions & 1 deletion src/account.rs
Original file line number Diff line number Diff line change
Expand Up @@ -265,7 +265,6 @@ impl AccountArgs {
pub async fn into_account<P>(self, provider: P) -> Result<SingleOwnerAccount<P, AnySigner>>
where
P: Provider + Send + Sync,
P::Error: 'static,
{
let signer = self.signer.into_task()?;

Expand Down
65 changes: 27 additions & 38 deletions src/provider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,12 +121,10 @@ impl ExtendedProvider {
#[cfg_attr(not(target_arch = "wasm32"), async_trait)]
#[cfg_attr(target_arch = "wasm32", async_trait(?Send))]
impl Provider for ExtendedProvider {
type Error = <AnyProvider as Provider>::Error;

async fn get_block_with_tx_hashes<B>(
&self,
block_id: B,
) -> Result<MaybePendingBlockWithTxHashes, ProviderError<Self::Error>>
) -> Result<MaybePendingBlockWithTxHashes, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
{
Expand All @@ -136,7 +134,7 @@ impl Provider for ExtendedProvider {
async fn get_block_with_txs<B>(
&self,
block_id: B,
) -> Result<MaybePendingBlockWithTxs, ProviderError<Self::Error>>
) -> Result<MaybePendingBlockWithTxs, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
{
Expand All @@ -146,7 +144,7 @@ impl Provider for ExtendedProvider {
async fn get_state_update<B>(
&self,
block_id: B,
) -> Result<MaybePendingStateUpdate, ProviderError<Self::Error>>
) -> Result<MaybePendingStateUpdate, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
{
Expand All @@ -158,7 +156,7 @@ impl Provider for ExtendedProvider {
contract_address: A,
key: K,
block_id: B,
) -> Result<FieldElement, ProviderError<Self::Error>>
) -> Result<FieldElement, ProviderError>
where
A: AsRef<FieldElement> + Send + Sync,
K: AsRef<FieldElement> + Send + Sync,
Expand All @@ -171,7 +169,7 @@ impl Provider for ExtendedProvider {
async fn get_transaction_by_hash<H>(
&self,
transaction_hash: H,
) -> Result<Transaction, ProviderError<Self::Error>>
) -> Result<Transaction, ProviderError>
where
H: AsRef<FieldElement> + Send + Sync,
{
Expand All @@ -182,7 +180,7 @@ impl Provider for ExtendedProvider {
&self,
block_id: B,
index: u64,
) -> Result<Transaction, ProviderError<Self::Error>>
) -> Result<Transaction, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
{
Expand All @@ -197,7 +195,7 @@ impl Provider for ExtendedProvider {
async fn get_transaction_receipt<H>(
&self,
transaction_hash: H,
) -> Result<MaybePendingTransactionReceipt, ProviderError<Self::Error>>
) -> Result<MaybePendingTransactionReceipt, ProviderError>
where
H: AsRef<FieldElement> + Send + Sync,
{
Expand All @@ -208,7 +206,7 @@ impl Provider for ExtendedProvider {
&self,
block_id: B,
class_hash: H,
) -> Result<ContractClass, ProviderError<Self::Error>>
) -> Result<ContractClass, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
H: AsRef<FieldElement> + Send + Sync,
Expand All @@ -220,7 +218,7 @@ impl Provider for ExtendedProvider {
&self,
block_id: B,
contract_address: A,
) -> Result<FieldElement, ProviderError<Self::Error>>
) -> Result<FieldElement, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
A: AsRef<FieldElement> + Send + Sync,
Expand All @@ -233,29 +231,22 @@ impl Provider for ExtendedProvider {
&self,
block_id: B,
contract_address: A,
) -> Result<ContractClass, ProviderError<Self::Error>>
) -> Result<ContractClass, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
A: AsRef<FieldElement> + Send + Sync,
{
<AnyProvider as Provider>::get_class_at(&self.provider, block_id, contract_address).await
}

async fn get_block_transaction_count<B>(
&self,
block_id: B,
) -> Result<u64, ProviderError<Self::Error>>
async fn get_block_transaction_count<B>(&self, block_id: B) -> Result<u64, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
{
<AnyProvider as Provider>::get_block_transaction_count(&self.provider, block_id).await
}

async fn call<R, B>(
&self,
request: R,
block_id: B,
) -> Result<Vec<FieldElement>, ProviderError<Self::Error>>
async fn call<R, B>(&self, request: R, block_id: B) -> Result<Vec<FieldElement>, ProviderError>
where
R: AsRef<FunctionCall> + Send + Sync,
B: AsRef<BlockId> + Send + Sync,
Expand All @@ -267,7 +258,7 @@ impl Provider for ExtendedProvider {
&self,
request: R,
block_id: B,
) -> Result<Vec<FeeEstimate>, ProviderError<Self::Error>>
) -> Result<Vec<FeeEstimate>, ProviderError>
where
R: AsRef<[BroadcastedTransaction]> + Send + Sync,
B: AsRef<BlockId> + Send + Sync,
Expand All @@ -279,33 +270,31 @@ impl Provider for ExtendedProvider {
&self,
message: M,
block_id: B,
) -> Result<FeeEstimate, ProviderError<Self::Error>>
) -> Result<FeeEstimate, ProviderError>
where
M: AsRef<MsgFromL1> + Send + Sync,
B: AsRef<BlockId> + Send + Sync,
{
<AnyProvider as Provider>::estimate_message_fee(&self.provider, message, block_id).await
}

async fn block_number(&self) -> Result<u64, ProviderError<Self::Error>> {
async fn block_number(&self) -> Result<u64, ProviderError> {
<AnyProvider as Provider>::block_number(&self.provider).await
}

async fn block_hash_and_number(
&self,
) -> Result<BlockHashAndNumber, ProviderError<Self::Error>> {
async fn block_hash_and_number(&self) -> Result<BlockHashAndNumber, ProviderError> {
<AnyProvider as Provider>::block_hash_and_number(&self.provider).await
}

async fn chain_id(&self) -> Result<FieldElement, ProviderError<Self::Error>> {
async fn chain_id(&self) -> Result<FieldElement, ProviderError> {
<AnyProvider as Provider>::chain_id(&self.provider).await
}

async fn pending_transactions(&self) -> Result<Vec<Transaction>, ProviderError<Self::Error>> {
async fn pending_transactions(&self) -> Result<Vec<Transaction>, ProviderError> {
<AnyProvider as Provider>::pending_transactions(&self.provider).await
}

async fn syncing(&self) -> Result<SyncStatusType, ProviderError<Self::Error>> {
async fn syncing(&self) -> Result<SyncStatusType, ProviderError> {
<AnyProvider as Provider>::syncing(&self.provider).await
}

Expand All @@ -314,7 +303,7 @@ impl Provider for ExtendedProvider {
filter: EventFilter,
continuation_token: Option<String>,
chunk_size: u64,
) -> Result<EventsPage, ProviderError<Self::Error>> {
) -> Result<EventsPage, ProviderError> {
<AnyProvider as Provider>::get_events(
&self.provider,
filter,
Expand All @@ -328,7 +317,7 @@ impl Provider for ExtendedProvider {
&self,
block_id: B,
contract_address: A,
) -> Result<FieldElement, ProviderError<Self::Error>>
) -> Result<FieldElement, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
A: AsRef<FieldElement> + Send + Sync,
Expand All @@ -339,7 +328,7 @@ impl Provider for ExtendedProvider {
async fn add_invoke_transaction<I>(
&self,
invoke_transaction: I,
) -> Result<InvokeTransactionResult, ProviderError<Self::Error>>
) -> Result<InvokeTransactionResult, ProviderError>
where
I: AsRef<BroadcastedInvokeTransaction> + Send + Sync,
{
Expand All @@ -349,7 +338,7 @@ impl Provider for ExtendedProvider {
async fn add_declare_transaction<D>(
&self,
declare_transaction: D,
) -> Result<DeclareTransactionResult, ProviderError<Self::Error>>
) -> Result<DeclareTransactionResult, ProviderError>
where
D: AsRef<BroadcastedDeclareTransaction> + Send + Sync,
{
Expand All @@ -360,7 +349,7 @@ impl Provider for ExtendedProvider {
async fn add_deploy_account_transaction<D>(
&self,
deploy_account_transaction: D,
) -> Result<DeployAccountTransactionResult, ProviderError<Self::Error>>
) -> Result<DeployAccountTransactionResult, ProviderError>
where
D: AsRef<BroadcastedDeployAccountTransaction> + Send + Sync,
{
Expand All @@ -374,7 +363,7 @@ impl Provider for ExtendedProvider {
async fn trace_transaction<H>(
&self,
transaction_hash: H,
) -> Result<TransactionTrace, ProviderError<Self::Error>>
) -> Result<TransactionTrace, ProviderError>
where
H: AsRef<FieldElement> + Send + Sync,
{
Expand All @@ -386,7 +375,7 @@ impl Provider for ExtendedProvider {
block_id: B,
transactions: T,
simulation_flags: S,
) -> Result<Vec<SimulatedTransaction>, ProviderError<Self::Error>>
) -> Result<Vec<SimulatedTransaction>, ProviderError>
where
B: AsRef<BlockId> + Send + Sync,
T: AsRef<[BroadcastedTransaction]> + Send + Sync,
Expand All @@ -404,7 +393,7 @@ impl Provider for ExtendedProvider {
async fn trace_block_transactions<H>(
&self,
block_hash: H,
) -> Result<Vec<TransactionTraceWithHash>, ProviderError<Self::Error>>
) -> Result<Vec<TransactionTraceWithHash>, ProviderError>
where
H: AsRef<FieldElement> + Send + Sync,
{
Expand Down
1 change: 0 additions & 1 deletion src/subcommands/declare.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ impl Declare {
async fn check_already_declared<P>(provider: P, class_hash: FieldElement) -> Result<bool>
where
P: Provider,
P::Error: 'static,
{
match provider
.get_class(BlockId::Tag(BlockTag::Pending), class_hash)
Expand Down
1 change: 0 additions & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@ pub async fn watch_tx<P>(
) -> Result<()>
where
P: Provider,
P::Error: 'static,
{
loop {
match provider.get_transaction_receipt(transaction_hash).await {
Expand Down

0 comments on commit 4ed026b

Please sign in to comment.