diff --git a/wraps/core/polywrap.deploy.yaml b/wraps/core/polywrap.deploy.yaml index 7855dd3..b5b63b8 100644 --- a/wraps/core/polywrap.deploy.yaml +++ b/wraps/core/polywrap.deploy.yaml @@ -12,7 +12,7 @@ jobs: package: http uri: $$ipfs_deploy config: - postUrl: https://wraps.wrapscan.io/r/polywrap/ethers@1.1.0 + postUrl: https://wraps.wrapscan.io/r/polywrap/ethers@1.1.1 headers: - name: Authorization value: $POLYWRAP_WRAPSCAN_AUTH_HEADER_PROD diff --git a/wraps/core/polywrap.graphql b/wraps/core/polywrap.graphql index 68eb6a0..cfe53e7 100644 --- a/wraps/core/polywrap.graphql +++ b/wraps/core/polywrap.graphql @@ -214,6 +214,12 @@ type Module implements Utils_Module { connection: Connection ): BigInt! + # Get a transaction data based in given hash + getTransaction( + hash: String! + connection: Connection + ): TxResponse! + # Send an arbitrary JSON-RPC request to the Ethereum node sendRpc( # JSON-RPC method to call diff --git a/wraps/core/src/lib.rs b/wraps/core/src/lib.rs index 183b32a..5d58485 100644 --- a/wraps/core/src/lib.rs +++ b/wraps/core/src/lib.rs @@ -44,6 +44,20 @@ impl ModuleTrait for Module { )) } + fn get_transaction(args: wrap::ArgsGetTransaction) -> Result { + let provider = WrapProvider::new(&args.connection); + let transaction = provider.get_transaction(H256::from_str(&args.hash).unwrap()); + if let Ok(tx) = transaction { + if let Some(tx) = tx { + Ok(mapping::to_wrap_response(&provider, tx)) + } else { + return Err(format!("Transaction with hash {} not found", args.hash)); + } + } else { + return Err("Error fetching transaction".to_string()); + } + } + fn check_address(args: wrap::ArgsCheckAddress) -> Result { Ok(match Address::from_str(&args.address) { Ok(_) => true, diff --git a/wraps/core/tests/e2e.spec.ts b/wraps/core/tests/e2e.spec.ts index 015148d..3d56f28 100644 --- a/wraps/core/tests/e2e.spec.ts +++ b/wraps/core/tests/e2e.spec.ts @@ -445,9 +445,9 @@ describe("Ethereum Wrapper", () => { expect(response.value.hash).toBeDefined(); }) it("using provider signer", async () => { - const response = await clientWithWeb3Provider.invoke({ + const response = await clientWithWeb3Provider.invoke({ uri, - method: "sendTransaction", + method: "sendTransactionAndWait", args: { tx: { data: contracts.SimpleStorage.bytecode } } @@ -455,7 +455,18 @@ describe("Ethereum Wrapper", () => { if (!response.ok) throw response.error; expect(response.value).toBeDefined(); - expect(response.value.hash).toBeDefined(); + expect(response.value).toBeDefined(); + + const getTransactionResponse = await clientWithWeb3Provider.invoke({ + uri, + method: "getTransaction", + args: { + hash: response.value.transactionHash, + }, + }); + + if (!getTransactionResponse.ok) throw getTransactionResponse.error; + expect(getTransactionResponse.value).toBeDefined(); }) })