-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathFreelancersNft.ts
More file actions
45 lines (39 loc) · 1.5 KB
/
FreelancersNft.ts
File metadata and controls
45 lines (39 loc) · 1.5 KB
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
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from 'ton-core';
export type FreelancersNftConfig = {
index: number;
collectionAddress: Address;
ownerAddress: Address;
content: Cell;
authorityAddress: Address;
editorAddress: Address;
revokedAt: number;
};
export function freelancersNftConfigToCell(config: FreelancersNftConfig): Cell {
return beginCell()
.storeUint(config.index, 64)
.storeAddress(config.collectionAddress)
.storeAddress(config.ownerAddress)
.storeRef(config.content)
.storeAddress(config.authorityAddress)
.storeAddress(config.editorAddress)
.storeUint(config.revokedAt, 64)
.endCell();
}
export class FreelancersNft implements Contract {
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
static createFromAddress(address: Address) {
return new FreelancersNft(address);
}
static createFromConfig(config: FreelancersNftConfig, code: Cell, workchain = 0) {
const data = freelancersNftConfigToCell(config);
const init = { code, data };
return new FreelancersNft(contractAddress(workchain, init), init);
}
async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
await provider.internal(via, {
value,
sendMode: SendMode.PAY_GAS_SEPARATLY,
body: beginCell().endCell(),
});
}
}