Skip to content

Commit

Permalink
Fixing "Invalid" error (#405)
Browse files Browse the repository at this point in the history
The source of the error was, that I treated the observables the wrong way.
I expected `submitAndWatch()` to return a chain of events, to which I could subscribe from a bunch of sources, while it actually led to side effects being multiplied in the sources.
`shareReplay()` returns a multicast observable that actually behaves the way I expected it to.
  • Loading branch information
mutantcornholio authored May 14, 2024
1 parent b502a3b commit a22b714
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 9 deletions.
4 changes: 2 additions & 2 deletions src/dripper/polkadot/PolkadotActions.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ss58Address } from "@polkadot-labs/hdkd-helpers";
import { AccountId, Binary } from "polkadot-api";
import { filter, firstValueFrom } from "rxjs";
import { filter, firstValueFrom, shareReplay } from "rxjs";

import { config } from "src/config";
import { logger } from "src/logger";
Expand Down Expand Up @@ -101,7 +101,7 @@ export class PolkadotActions {

// client.submit(tx) waits for the finalized value, which might be important for real money,
// but for the faucet drips, early respond is better UX
const submit$ = client.submitAndWatch(tx);
const submit$ = client.submitAndWatch(tx).pipe(shareReplay(1));

const hash = (await firstValueFrom(submit$.pipe(filter((value) => value.type === "broadcasted")))).txHash;

Expand Down
7 changes: 0 additions & 7 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2342,13 +2342,6 @@ bl@^4.0.3:
inherits "^2.0.4"
readable-stream "^3.4.0"

blake2@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/blake2/-/blake2-5.0.0.tgz#6306e49d974fb051b6fb2aad669307b9838bfbaa"
integrity sha512-MLpq1DwBB9rC0IHuRc2gXLEAeNNTTYHEtvYCA5lK4RmoUPRmQLSLQrwgJvou62BvH9KP7whe8n+xxw45++fnYg==
dependencies:
nan "^2.17.0"

[email protected], body-parser@^1.20.0:
version "1.20.2"
resolved "https://registry.yarnpkg.com/body-parser/-/body-parser-1.20.2.tgz#6feb0e21c4724d06de7ff38da36dad4f57a747fd"
Expand Down

0 comments on commit a22b714

Please sign in to comment.