/
create_transaction.ts
33 lines (31 loc) · 1.13 KB
/
create_transaction.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
import { PublicKey } from '@near-js/crypto';
import { Action } from './actions';
import { Transaction } from './schema';
/**
* Creates a new transaction object with the provided parameters.
* @param signerId The NEAR account ID of the transaction signer.
* @param publicKey The public key associated with the signer.
* @param receiverId The NEAR account ID of the transaction receiver.
* @param nonce The nonce value for the transaction, represented as a BN, string, or number.
* @param actions An array of transaction actions to be performed.
* @param blockHash The hash of the block where the transaction will be included.
* @returns A new transaction object initialized with the provided parameters.
*/
export function createTransaction(
signerId: string,
publicKey: PublicKey,
receiverId: string,
nonce: bigint | string | number,
actions: Action[],
blockHash: Uint8Array
): Transaction {
const txNonce = typeof nonce === 'bigint' ? nonce : BigInt(nonce);
return new Transaction({
signerId,
publicKey,
nonce: txNonce,
receiverId,
actions,
blockHash,
});
}