forked from oxheadalpha/composed-fa2-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontract_interface.ts
44 lines (39 loc) · 1.29 KB
/
contract_interface.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
import { nat, mutez, address } from '@oxheadalpha/fa2-interfaces';
import {
ContractAbstraction,
ContractMethod,
ContractProvider,
TezosToolkit
} from '@taquito/taquito';
import { createContractInterface } from './base_ft_contract';
export interface ExchangeAdminContract {
withdrawFees: () => ContractMethod<ContractProvider>;
changeFee: (
old_fee: mutez,
new_fee: mutez
) => ContractMethod<ContractProvider>;
}
export interface MinterContract {
mint: (expected_fee: mutez) => ContractMethod<ContractProvider>;
burn: (ntokens: nat) => ContractMethod<ContractProvider>;
}
export const ExchangeAdmin = (
contract: ContractAbstraction<ContractProvider>
): ExchangeAdminContract => ({
withdrawFees: () => contract.methods.withdraw_fees(),
changeFee: (old_fee: mutez, new_fee: mutez) =>
contract.methods.change_fee(old_fee, new_fee)
});
export const Minter = (
contract: ContractAbstraction<ContractProvider>
): MinterContract => ({
mint: (expected_fee: mutez) => contract.methods.mint(expected_fee),
burn: (ntokens: nat) => contract.methods.burn(ntokens)
});
export const createCustomContractInterface = async (
toolkit: TezosToolkit,
contractAddress: address
) =>
(await createContractInterface(toolkit, contractAddress))
.with(Minter)
.with(ExchangeAdmin);