-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathCustomersNft.ts
More file actions
41 lines (35 loc) · 1.33 KB
/
CustomersNft.ts
File metadata and controls
41 lines (35 loc) · 1.33 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
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from 'ton-core';
export type CustomersNftConfig = {
index: number;
collectionAddress: Address;
ownerAddress: Address;
content: Cell;
editorAddress: Address;
};
export function customersNftConfigToCell(config: CustomersNftConfig): Cell {
return beginCell()
.storeUint(config.index, 64)
.storeAddress(config.collectionAddress)
.storeAddress(config.ownerAddress)
.storeRef(config.content)
.storeAddress(config.editorAddress)
.endCell();
}
export class CustomersNft implements Contract {
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
static createFromAddress(address: Address) {
return new CustomersNft(address);
}
static createFromConfig(config: CustomersNftConfig, code: Cell, workchain = 0) {
const data = customersNftConfigToCell(config);
const init = { code, data };
return new CustomersNft(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(),
});
}
}