Skip to content

Commit

Permalink
chore(wallet-template): use new tx-helper
Browse files Browse the repository at this point in the history
  • Loading branch information
ryanleecode committed Jul 12, 2024
1 parent b1b547b commit 16a3b49
Show file tree
Hide file tree
Showing 25 changed files with 12 additions and 1,184 deletions.
14 changes: 4 additions & 10 deletions pnpm-lock.yaml

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

18 changes: 8 additions & 10 deletions projects/wallet-template/src/background/createBackgroundRpc.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import {
createRpc,
RpcError,
} from "@substrate/light-client-extension-helpers/utils"
import { createTx } from "@substrate/light-client-extension-helpers/tx-helper"
import { ss58Address, ss58Decode } from "@polkadot-labs/hdkd-helpers"
import { toHex, fromHex } from "@polkadot-api/utils"
import { getPolkadotSigner } from "@polkadot-api/signer"
Expand All @@ -15,7 +16,6 @@ import { UserSignedExtensionName } from "../types/UserSignedExtension"
import { createClient } from "@polkadot-api/substrate-client"
import { getObservableClient } from "@polkadot-api/observable-client"
import { filter, firstValueFrom, map, mergeMap, take } from "rxjs"
import { createTx } from "./tx-helper/create-tx"
import * as pjs from "./pjs"
import { Bytes, Variant } from "@polkadot-api/substrate-bindings"
import { InPageRpcSpec } from "../inpage/types"
Expand Down Expand Up @@ -86,7 +86,7 @@ export const createBackgroundRpc = (
const client = getObservableClient(createClient(chain.provider))
const chainHead$ = client.chainHead$()

const { best: atBlock, userSignedExtensionNames } = await firstValueFrom(
const userSignedExtensionNames = await firstValueFrom(
chainHead$.best$.pipe(
mergeMap((blockInfo) =>
chainHead$.getRuntimeContext$(blockInfo.hash).pipe(
Expand All @@ -96,10 +96,6 @@ export const createBackgroundRpc = (
.map(({ identifier }) => identifier)
.filter(isUserSignedExtensionName),
),
map((userSignedExtensionNames) => ({
best: blockInfo,
userSignedExtensionNames,
})),
),
),
filter(Boolean),
Expand Down Expand Up @@ -166,13 +162,15 @@ export const createBackgroundRpc = (
? userSignedExtensions.ChargeAssetTxPayment?.tip
: userSignedExtensions.ChargeTransactionPayment) ?? 0n

const tx = await firstValueFrom(
createTx(chainHead$, signer, fromHex(callData), atBlock, {
const tx = await createTx(chain.provider)({
signer,
callData: fromHex(callData),
hinted: {
mortality,
asset,
tip,
}).pipe(filter(Boolean)),
)
},
})

return toHex(tx)
} finally {
Expand Down
7 changes: 0 additions & 7 deletions projects/wallet-template/src/background/tx-helper/README.md

This file was deleted.

99 changes: 0 additions & 99 deletions projects/wallet-template/src/background/tx-helper/create-tx.ts

This file was deleted.

101 changes: 0 additions & 101 deletions projects/wallet-template/src/background/tx-helper/descriptors.ts

This file was deleted.

2 changes: 0 additions & 2 deletions projects/wallet-template/src/background/tx-helper/index.ts

This file was deleted.

Loading

0 comments on commit 16a3b49

Please sign in to comment.