• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

safe-global / safe-core-sdk / 12008523214

25 Nov 2024 10:55AM CUT coverage: 75.515%. Remained the same
12008523214

push

github

web-flow
feat(protocol-kit): Add react native compatibility (#1033)

241 of 390 branches covered (61.79%)

Branch coverage included in aggregate %.

786 of 970 relevant lines covered (81.03%)

3.76 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

20.0
/packages/sdk-starter-kit/src/utils/sendTransaction.ts
1
import { WalletClient, Transport, Chain, Hex, Account } from 'viem'
2
import { waitForTransactionReceipt } from 'viem/actions'
7✔
3
import Safe from '@safe-global/protocol-kit'
4
import { Transaction } from '@safe-global/types-kit'
5

6
/**
7
 * Sends a transaction using the signer (owner)
8
 * It's useful to deploy Safe accounts
9
 *
10
 * @param {Transaction} transaction  The transaction.
11
 * @param {Safe} protocolKit The protocolKit instance
12
 * @returns {Promise<string | undefined>} A promise that resolves with the transaction hash
13
 */
14
export const sendTransaction = async ({
7✔
15
  transaction,
16
  protocolKit
17
}: {
18
  transaction: Transaction
19
  protocolKit: Safe
20
}): Promise<string | undefined> => {
21
  const signer = (await protocolKit.getSafeProvider().getExternalSigner()) as WalletClient<
×
22
    Transport,
23
    Chain,
24
    Account
25
  >
26
  const client = protocolKit.getSafeProvider().getExternalProvider()
×
27

28
  if (!signer)
×
29
    throw new Error('SafeProvider must be initialized with a signer to use this function')
×
30

31
  const hash = await signer.sendTransaction({
×
32
    to: transaction.to,
33
    data: transaction.data as Hex,
34
    value: BigInt(transaction.value),
35
    account: signer.account
36
  })
37

38
  const receipt = await waitForTransactionReceipt(client, { hash })
×
39

40
  return receipt.transactionHash
×
41
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc