-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path15-AddToWhitelist.ts
74 lines (51 loc) · 1.79 KB
/
15-AddToWhitelist.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
import {fromB64} from '@mysten/sui.js/utils';
import {TransactionBlock} from '@mysten/sui.js/transactions';
import {Ed25519Keypair} from '@mysten/sui.js/keypairs/ed25519';
import {
PACKAGE_ADDRESS, SUI_NETWORK,
} from "./config";
import {getFullnodeUrl, SuiClient} from "@mysten/sui.js/client";
//Admin-partner signer setup
let adminPrivateKeyArray = Uint8Array.from(Array.from(fromB64(process.env.ADMIN_SECRET_KEY!)));
const adminKeypair = Ed25519Keypair.fromSecretKey(adminPrivateKeyArray.slice(1));
const adminAddress = adminKeypair.getPublicKey().toSuiAddress();
console.log("Admin address: ", adminAddress);
const client = new SuiClient({
url: SUI_NETWORK
});
const doactions = async () => {
const txb = new TransactionBlock();
const now: number = Date.now();
console.log("Package = ",PACKAGE_ADDRESS);
txb.moveCall({
target: `${PACKAGE_ADDRESS}::allow_list_test::add_to_whitelist`,
arguments: [
txb.pure(adminAddress!),
],
});
txb.setGasBudget(1000000000);
client.signAndExecuteTransactionBlock({
signer: adminKeypair,
transactionBlock: txb,
requestType: "WaitForLocalExecution",
options: {
showEffects: true, showObjectChanges: true,
},
}).then((txRes) => {
let status1 = txRes.effects?.status;
if (status1?.status !== "success") {
console.log("process failed. Status: ", status1);
process.exit(1);
}
console.log("process Finished. Status: ", status1);
}).catch((err) => {
console.log("process failed. Error: ", err);
process.exit(1);
});
}
const doactions2 = async () => {
client.getAllCoins({owner: adminAddress}).then((coins) => {
console.log("Coins: ", coins);
});
}
doactions();