-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
103 lines (82 loc) · 2.48 KB
/
index.js
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
import { getFullnodeUrl, SuiClient } from "@mysten/sui/client";
import { Transaction } from "@mysten/sui/transactions";
import { Ed25519Keypair } from "@mysten/sui/keypairs/ed25519";
import "dotenv/config";
import { KioskClient, Network, KioskTransaction } from "@mysten/kiosk";
async function createKiosk() {
const tx = new Transaction();
const kioskTx = new KioskTransaction({ transaction: tx, kioskClient });
// Calls the creation function.
kioskTx.create();
// Shares the kiosk and transfers the `KioskOwnerCap` to the owner.
kioskTx.shareAndTransferCap(myAddress);
// Always called as our last kioskTx interaction.
kioskTx.finalize();
const result = await suiClient.signAndExecuteTransaction({
signer: keypair,
transaction: tx,
requestType: "WaitForLocalExecution",
options: {
showEffects: true,
},
});
console.log("result", result);
}
async function getOwnedKiosks() {
const { kioskOwnerCaps, kioskIds } = await kioskClient.getOwnedKiosks({
address: myAddress,
});
// console.log(kioskOwnerCaps);
console.log(kioskIds);
}
async function getKioskDetails(id) {
const kioskData = await kioskClient.getKiosk({
id,
options: {
withObjects: true, // This will include NFT details
},
});
console.log(kioskData);
}
async function getNftDetails(id) {
const nftDetails = await suiClient.getObject({
id,
options: {
showContent: true,
showType: true,
},
});
console.log(nftDetails);
}
async function getTransferPolicies(type) {
const policyForType = await kioskClient.getTransferPolicies({
type,
});
console.log(policyForType);
}
async function getOwnedTransferPolicies(address) {
const policies = await kioskClient.getOwnedTransferPolicies({
address,
});
console.log(policies);
}
const pk = process.env.PK;
const keypair = Ed25519Keypair.fromSecretKey(pk);
const myAddress = keypair.getPublicKey().toSuiAddress();
const suiClient = new SuiClient({ url: getFullnodeUrl("mainnet") });
const kioskClient = new KioskClient({
client: suiClient,
network: Network.MAINNET,
});
// createKiosk();
// getOwnedKiosks();
// getKioskDetails(
// "0xa4233513bbc445854e38a7b21cd1e1bd38dbc6a2faef72a90e4fe408fe65023e"
// );
// getNftDetails(
// "0x6a64a177e78a6ec137e94a305feafecbd3fdb39ca78059bcd487a3bd4c0c7822"
// );
// getTransferPolicies(
// "0x6529f24fa077aa43d2dd7ee34fdd3ad8d0292bc3528d7a3c95dad55e29174ebe::sui_collection_w::SUI_COLLECTION"
// );
// getOwnedTransferPolicies(myAddress);