-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathtaquito-run.ts
66 lines (64 loc) · 1.91 KB
/
taquito-run.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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import {
BatchOperation,
ContractMethod,
ContractProvider,
OperationBatch,
SendParams,
TransactionOperation,
TransactionWalletOperation,
Wallet,
WalletOperationBatch
} from '@taquito/taquito';
import { BatchWalletOperation } from '@taquito/taquito/dist/types/wallet/batch-operation';
export async function runMethod<TProvider extends ContractProvider>(
cm: ContractMethod<TProvider>,
sendParams?: SendParams
): Promise<TransactionOperation>;
export async function runMethod<TProvider extends Wallet>(
cm: ContractMethod<TProvider>,
sendParams?: SendParams
): Promise<TransactionWalletOperation>;
/**
* Run and confirms a Taquito ContractMethod
* @param cm - a Taquito ContractMethod
* @returns Taquito TransactionOperation
*
* Usage example:
* ```typescript
* const op: TransactionOperation = await fa2.runMethod(fa2Contract.transferTokens(txs));
* ```
*/
export async function runMethod<TProvider extends ContractProvider | Wallet>(
cm: ContractMethod<TProvider>,
sendParams?: SendParams
): Promise<TransactionWalletOperation | TransactionOperation> {
const op = await cm.send(sendParams);
await op.confirmation();
return op;
}
export async function runBatch(batch: OperationBatch): Promise<BatchOperation>;
export async function runBatch(
batch: WalletOperationBatch
): Promise<BatchWalletOperation>;
/**
* Run and confirms a Taquito batch
* @param batch - a Taquito OperationBatch
* @returns Taquito BatchOperation
*
* Usage example:
* ```typescript
* const batch = toolkit.contract.batch();
*
* batch.withContractCall(fa2Contract.transferTokens(txs1));
* batch.withContractCall(fa2Contract.transferTokens(txs2));
*
* const op: BatchOperation = await fa2.runBatch(batch);
* ```
*/
export async function runBatch(
batch: OperationBatch | WalletOperationBatch
): Promise<BatchOperation | BatchWalletOperation> {
const op = await batch.send();
await op.confirmation();
return op;
}