-
Notifications
You must be signed in to change notification settings - Fork 302
/
Copy pathdeployLibrary.ts
54 lines (43 loc) · 1.78 KB
/
deployLibrary.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
import { toNano } from 'ton-core';
import { compile, NetworkProvider } from '@ton-community/blueprint';
import 'dotenv/config';
import { LibraryDeployer } from '../wrappers/library-deployer';
export async function run(provider: NetworkProvider) {
/* const library: SimpleLibrary = {
public: true,
root: await compile('wallet_v5')
};
let secretKey = process.env.LIBRARY_KEEPER_SECRET_KEY;
if (!secretKey) {
const keypair = keyPairFromSeed(await getSecureRandomBytes(32));
console.log('GENERATED PRIVATE_KEY', keypair.secretKey.toString('hex'));
secretKey = keypair.secretKey.toString('hex');
fs.appendFileSync('.env', `LIBRARY_KEEPER_SECRET_KEY=${secretKey}`);
}
const keypair = keyPairFromSecretKey(Buffer.from(secretKey, 'hex'));
const libraryKeeper = provider.open(
LibraryKeeper.createFromConfig(
{ publicKey: keypair.publicKey, seqno: 0 },
await compile('library-keeper')
)
);
const isActive = await libraryKeeper.getIsActive();
if (!isActive) {
await libraryKeeper.sendDeploy(provider.sender(), toNano('0.1'));
await provider.waitForDeploy(libraryKeeper.address);
}
await libraryKeeper.sendAddLibrary({
libraryCode: library.root,
secretKey: keypair.secretKey
});
console.log('LIBRARY KEEPER ADDRESS', libraryKeeper.address);*/
const libraryDeployer = provider.open(
LibraryDeployer.createFromConfig(
{ libraryCode: await compile('wallet_v5') },
await compile('library-deployer')
)
);
await libraryDeployer.sendDeploy(provider.sender(), toNano('0.1'));
await provider.waitForDeploy(libraryDeployer.address);
console.log('LIBRARY ADDRESS', libraryDeployer.address);
}