forked from oxheadalpha/composed-fa2-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathorigination.ts
59 lines (55 loc) · 1.46 KB
/
origination.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
import { TezosToolkit } from '@taquito/taquito';
import {
address,
mutez,
createOnChainTokenMetadata,
TokenMetadataInternal
} from '@oxheadalpha/fa2-interfaces';
import { originateContract } from '@oxheadalpha/tezos-tools';
import { createStorage } from './base_ft_contract';
export const createCustomStorage = (
metadata: string,
owner: address,
token: TokenMetadataInternal,
fee: mutez //fee is a part of the custom storage extension
) => {
const baseStorage = createStorage({
metadata,
owner,
token
});
return { asset: baseStorage, fee, collected_fees: 0 };
};
const tzip16Meta = {
name: 'TZFA2',
description: 'Tezos/FA2 Exchange',
homepage: 'https://github.com/oxheadalpha/composed-fa2-example',
version: '1.0.0',
license: { name: 'MIT' },
interfaces: ['TZIP-016', 'TZIP-012', 'TZIP-021'],
source: {
tools: ['LIGO'],
location: 'https://github.com/oxheadalpha/composed-fa2-example'
}
};
const tokenMeta = {
token_id: 0,
decimals: 1000000,
symbol: 'TZFA2',
shouldPreferSymbol: true
};
export const originateCustomContract = async (
toolkit: TezosToolkit,
code: string,
fee: mutez
): Promise<address> => {
const owner = await toolkit.signer.publicKeyHash();
const storage = createCustomStorage(
JSON.stringify(tzip16Meta, null, 2),
owner,
createOnChainTokenMetadata(tokenMeta),
fee
);
const contract = await originateContract(toolkit, code, storage, 'TZFA2');
return contract.address;
};