@ton/blueprint 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +146 -0
- package/README.md +114 -0
- package/dist/cli/build.d.ts +4 -0
- package/dist/cli/build.js +68 -0
- package/dist/cli/cli.d.ts +7 -0
- package/dist/cli/cli.js +106 -0
- package/dist/cli/create.d.ts +6 -0
- package/dist/cli/create.js +96 -0
- package/dist/cli/help.d.ts +2 -0
- package/dist/cli/help.js +55 -0
- package/dist/cli/run.d.ts +2 -0
- package/dist/cli/run.js +18 -0
- package/dist/cli/test.d.ts +2 -0
- package/dist/cli/test.js +9 -0
- package/dist/compile/CompilerConfig.d.ts +21 -0
- package/dist/compile/CompilerConfig.js +2 -0
- package/dist/compile/OverwritableVirtualFileSystem.d.ts +10 -0
- package/dist/compile/OverwritableVirtualFileSystem.js +24 -0
- package/dist/compile/compile.d.ts +14 -0
- package/dist/compile/compile.js +115 -0
- package/dist/index.d.ts +6 -0
- package/dist/index.js +10 -0
- package/dist/network/NetworkProvider.d.ts +22 -0
- package/dist/network/NetworkProvider.js +2 -0
- package/dist/network/createNetworkProvider.d.ts +3 -0
- package/dist/network/createNetworkProvider.js +282 -0
- package/dist/network/send/DeeplinkProvider.d.ts +10 -0
- package/dist/network/send/DeeplinkProvider.js +44 -0
- package/dist/network/send/MnemonicProvider.d.ts +19 -0
- package/dist/network/send/MnemonicProvider.js +80 -0
- package/dist/network/send/SendProvider.d.ts +6 -0
- package/dist/network/send/SendProvider.js +2 -0
- package/dist/network/send/TonConnectProvider.d.ts +12 -0
- package/dist/network/send/TonConnectProvider.js +108 -0
- package/dist/network/send/TonHubProvider.d.ts +16 -0
- package/dist/network/send/TonHubProvider.js +110 -0
- package/dist/network/storage/FSStorage.d.ts +8 -0
- package/dist/network/storage/FSStorage.js +53 -0
- package/dist/network/storage/Storage.d.ts +18 -0
- package/dist/network/storage/Storage.js +2 -0
- package/dist/paths.d.ts +12 -0
- package/dist/paths.js +19 -0
- package/dist/template.d.ts +4 -0
- package/dist/template.js +15 -0
- package/dist/templates/func/common/wrappers/compile.ts.template +7 -0
- package/dist/templates/func/counter/contracts/contract.fc.template +72 -0
- package/dist/templates/func/counter/scripts/deploy.ts.template +22 -0
- package/dist/templates/func/counter/scripts/increment.ts.template +38 -0
- package/dist/templates/func/counter/tests/spec.ts.template +81 -0
- package/dist/templates/func/counter/wrappers/wrapper.ts.template +67 -0
- package/dist/templates/func/empty/contracts/contract.fc.template +6 -0
- package/dist/templates/func/empty/scripts/deploy.ts.template +14 -0
- package/dist/templates/func/empty/tests/spec.ts.template +39 -0
- package/dist/templates/func/empty/wrappers/wrapper.ts.template +30 -0
- package/dist/templates/tact/common/wrappers/compile.ts.template +7 -0
- package/dist/templates/tact/common/wrappers/wrapper.ts.template +2 -0
- package/dist/templates/tact/counter/contracts/contract.tact.template +29 -0
- package/dist/templates/tact/counter/scripts/deploy.ts.template +23 -0
- package/dist/templates/tact/counter/scripts/increment.ts.template +45 -0
- package/dist/templates/tact/counter/tests/spec.ts.template +82 -0
- package/dist/templates/tact/empty/contracts/contract.tact.template +8 -0
- package/dist/templates/tact/empty/scripts/deploy.ts.template +23 -0
- package/dist/templates/tact/empty/tests/spec.ts.template +41 -0
- package/dist/ui/InquirerUIProvider.d.ts +12 -0
- package/dist/ui/InquirerUIProvider.js +70 -0
- package/dist/ui/UIProvider.d.ts +8 -0
- package/dist/ui/UIProvider.js +2 -0
- package/dist/utils.d.ts +39 -0
- package/dist/utils.js +122 -0
- package/package.json +51 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
{{name}}.ts
|
|
2
|
+
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from 'ton-core';
|
|
3
|
+
|
|
4
|
+
export type {{name}}Config = {
|
|
5
|
+
id: number;
|
|
6
|
+
counter: number;
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
export function {{loweredName}}ConfigToCell(config: {{name}}Config): Cell {
|
|
10
|
+
return beginCell().storeUint(config.id, 32).storeUint(config.counter, 32).endCell();
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
export const Opcodes = {
|
|
14
|
+
increase: 0x7e8764ef,
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export class {{name}} implements Contract {
|
|
18
|
+
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
|
|
19
|
+
|
|
20
|
+
static createFromAddress(address: Address) {
|
|
21
|
+
return new {{name}}(address);
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
static createFromConfig(config: {{name}}Config, code: Cell, workchain = 0) {
|
|
25
|
+
const data = {{loweredName}}ConfigToCell(config);
|
|
26
|
+
const init = { code, data };
|
|
27
|
+
return new {{name}}(contractAddress(workchain, init), init);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
|
|
31
|
+
await provider.internal(via, {
|
|
32
|
+
value,
|
|
33
|
+
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
34
|
+
body: beginCell().endCell(),
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
async sendIncrease(
|
|
39
|
+
provider: ContractProvider,
|
|
40
|
+
via: Sender,
|
|
41
|
+
opts: {
|
|
42
|
+
increaseBy: number;
|
|
43
|
+
value: bigint;
|
|
44
|
+
queryID?: number;
|
|
45
|
+
}
|
|
46
|
+
) {
|
|
47
|
+
await provider.internal(via, {
|
|
48
|
+
value: opts.value,
|
|
49
|
+
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
50
|
+
body: beginCell()
|
|
51
|
+
.storeUint(Opcodes.increase, 32)
|
|
52
|
+
.storeUint(opts.queryID ?? 0, 64)
|
|
53
|
+
.storeUint(opts.increaseBy, 32)
|
|
54
|
+
.endCell(),
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
async getCounter(provider: ContractProvider) {
|
|
59
|
+
const result = await provider.get('get_counter', []);
|
|
60
|
+
return result.stack.readNumber();
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async getID(provider: ContractProvider) {
|
|
64
|
+
const result = await provider.get('get_id', []);
|
|
65
|
+
return result.stack.readNumber();
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
deploy{{name}}.ts
|
|
2
|
+
import { toNano } from 'ton-core';
|
|
3
|
+
import { {{name}} } from '../wrappers/{{name}}';
|
|
4
|
+
import { compile, NetworkProvider } from '@ton-community/blueprint';
|
|
5
|
+
|
|
6
|
+
export async function run(provider: NetworkProvider) {
|
|
7
|
+
const {{loweredName}} = provider.open({{name}}.createFromConfig({}, await compile('{{name}}')));
|
|
8
|
+
|
|
9
|
+
await {{loweredName}}.sendDeploy(provider.sender(), toNano('0.05'));
|
|
10
|
+
|
|
11
|
+
await provider.waitForDeploy({{loweredName}}.address);
|
|
12
|
+
|
|
13
|
+
// run methods on `{{loweredName}}`
|
|
14
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
{{name}}.spec.ts
|
|
2
|
+
import { Blockchain, SandboxContract } from '@ton-community/sandbox';
|
|
3
|
+
import { Cell, toNano } from 'ton-core';
|
|
4
|
+
import { {{name}} } from '../wrappers/{{name}}';
|
|
5
|
+
import '@ton-community/test-utils';
|
|
6
|
+
import { compile } from '@ton-community/blueprint';
|
|
7
|
+
|
|
8
|
+
describe('{{name}}', () => {
|
|
9
|
+
let code: Cell;
|
|
10
|
+
|
|
11
|
+
beforeAll(async () => {
|
|
12
|
+
code = await compile('{{name}}');
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
let blockchain: Blockchain;
|
|
16
|
+
let {{loweredName}}: SandboxContract<{{name}}>;
|
|
17
|
+
|
|
18
|
+
beforeEach(async () => {
|
|
19
|
+
blockchain = await Blockchain.create();
|
|
20
|
+
|
|
21
|
+
{{loweredName}} = blockchain.openContract({{name}}.createFromConfig({}, code));
|
|
22
|
+
|
|
23
|
+
const deployer = await blockchain.treasury('deployer');
|
|
24
|
+
|
|
25
|
+
const deployResult = await {{loweredName}}.sendDeploy(deployer.getSender(), toNano('0.05'));
|
|
26
|
+
|
|
27
|
+
expect(deployResult.transactions).toHaveTransaction({
|
|
28
|
+
from: deployer.address,
|
|
29
|
+
to: {{loweredName}}.address,
|
|
30
|
+
deploy: true,
|
|
31
|
+
success: true,
|
|
32
|
+
});
|
|
33
|
+
});
|
|
34
|
+
|
|
35
|
+
it('should deploy', async () => {
|
|
36
|
+
// the check is done inside beforeEach
|
|
37
|
+
// blockchain and {{loweredName}} are ready to use
|
|
38
|
+
});
|
|
39
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
{{name}}.ts
|
|
2
|
+
import { Address, beginCell, Cell, Contract, contractAddress, ContractProvider, Sender, SendMode } from 'ton-core';
|
|
3
|
+
|
|
4
|
+
export type {{name}}Config = {};
|
|
5
|
+
|
|
6
|
+
export function {{loweredName}}ConfigToCell(config: {{name}}Config): Cell {
|
|
7
|
+
return beginCell().endCell();
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class {{name}} implements Contract {
|
|
11
|
+
constructor(readonly address: Address, readonly init?: { code: Cell; data: Cell }) {}
|
|
12
|
+
|
|
13
|
+
static createFromAddress(address: Address) {
|
|
14
|
+
return new {{name}}(address);
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
static createFromConfig(config: {{name}}Config, code: Cell, workchain = 0) {
|
|
18
|
+
const data = {{loweredName}}ConfigToCell(config);
|
|
19
|
+
const init = { code, data };
|
|
20
|
+
return new {{name}}(contractAddress(workchain, init), init);
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
async sendDeploy(provider: ContractProvider, via: Sender, value: bigint) {
|
|
24
|
+
await provider.internal(via, {
|
|
25
|
+
value,
|
|
26
|
+
sendMode: SendMode.PAY_GAS_SEPARATELY,
|
|
27
|
+
body: beginCell().endCell(),
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
{{snakeName}}.tact
|
|
2
|
+
import "@stdlib/deploy";
|
|
3
|
+
|
|
4
|
+
message Add {
|
|
5
|
+
queryId: Int as uint64;
|
|
6
|
+
amount: Int as uint32;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
contract {{name}} with Deployable {
|
|
10
|
+
id: Int as uint32;
|
|
11
|
+
counter: Int as uint32;
|
|
12
|
+
|
|
13
|
+
init(id: Int) {
|
|
14
|
+
self.id = id;
|
|
15
|
+
self.counter = 0;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
receive(msg: Add) {
|
|
19
|
+
self.counter = (self.counter + msg.amount);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
get fun counter(): Int {
|
|
23
|
+
return self.counter;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
get fun id(): Int {
|
|
27
|
+
return self.id;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
deploy{{name}}.ts
|
|
2
|
+
import { toNano } from 'ton-core';
|
|
3
|
+
import { {{name}} } from '../wrappers/{{name}}';
|
|
4
|
+
import { NetworkProvider } from '@ton-community/blueprint';
|
|
5
|
+
|
|
6
|
+
export async function run(provider: NetworkProvider) {
|
|
7
|
+
const {{loweredName}} = provider.open(await {{name}}.fromInit(BigInt(Math.floor(Math.random() * 10000))));
|
|
8
|
+
|
|
9
|
+
await {{loweredName}}.send(
|
|
10
|
+
provider.sender(),
|
|
11
|
+
{
|
|
12
|
+
value: toNano('0.05'),
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
$$type: 'Deploy',
|
|
16
|
+
queryId: 0n,
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
await provider.waitForDeploy({{loweredName}}.address);
|
|
21
|
+
|
|
22
|
+
console.log('ID', await {{loweredName}}.getId());
|
|
23
|
+
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
increment{{name}}.ts
|
|
2
|
+
import { Address, toNano } from 'ton-core';
|
|
3
|
+
import { {{name}} } from '../wrappers/{{name}}';
|
|
4
|
+
import { NetworkProvider, sleep } from '@ton-community/blueprint';
|
|
5
|
+
|
|
6
|
+
export async function run(provider: NetworkProvider, args: string[]) {
|
|
7
|
+
const ui = provider.ui();
|
|
8
|
+
|
|
9
|
+
const address = Address.parse(args.length > 0 ? args[0] : await ui.input('{{name}} address'));
|
|
10
|
+
|
|
11
|
+
if (!(await provider.isContractDeployed(address))) {
|
|
12
|
+
ui.write(`Error: Contract at address ${address} is not deployed!`);
|
|
13
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
const {{loweredName}} = provider.open({{name}}.fromAddress(address));
|
|
17
|
+
|
|
18
|
+
const counterBefore = await {{loweredName}}.getCounter();
|
|
19
|
+
|
|
20
|
+
await {{loweredName}}.send(
|
|
21
|
+
provider.sender(),
|
|
22
|
+
{
|
|
23
|
+
value: toNano('0.05'),
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
$$type: 'Add',
|
|
27
|
+
queryId: 0n,
|
|
28
|
+
amount: 1n,
|
|
29
|
+
}
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
ui.write('Waiting for counter to increase...');
|
|
33
|
+
|
|
34
|
+
let counterAfter = await {{loweredName}}.getCounter();
|
|
35
|
+
let attempt = 1;
|
|
36
|
+
while (counterAfter === counterBefore) {
|
|
37
|
+
ui.setActionPrompt(`Attempt ${attempt}`);
|
|
38
|
+
await sleep(2000);
|
|
39
|
+
counterAfter = await {{loweredName}}.getCounter();
|
|
40
|
+
attempt++;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
ui.clearActionPrompt();
|
|
44
|
+
ui.write('Counter increased successfully!');
|
|
45
|
+
}
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
{{name}}.spec.ts
|
|
2
|
+
import { Blockchain, SandboxContract } from '@ton-community/sandbox';
|
|
3
|
+
import { toNano } from 'ton-core';
|
|
4
|
+
import { {{name}} } from '../wrappers/{{name}}';
|
|
5
|
+
import '@ton-community/test-utils';
|
|
6
|
+
|
|
7
|
+
describe('{{name}}', () => {
|
|
8
|
+
let blockchain: Blockchain;
|
|
9
|
+
let {{loweredName}}: SandboxContract<{{name}}>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
blockchain = await Blockchain.create();
|
|
13
|
+
|
|
14
|
+
{{loweredName}} = blockchain.openContract(await {{name}}.fromInit(0n));
|
|
15
|
+
|
|
16
|
+
const deployer = await blockchain.treasury('deployer');
|
|
17
|
+
|
|
18
|
+
const deployResult = await {{loweredName}}.send(
|
|
19
|
+
deployer.getSender(),
|
|
20
|
+
{
|
|
21
|
+
value: toNano('0.05'),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
$$type: 'Deploy',
|
|
25
|
+
queryId: 0n,
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(deployResult.transactions).toHaveTransaction({
|
|
30
|
+
from: deployer.address,
|
|
31
|
+
to: {{loweredName}}.address,
|
|
32
|
+
deploy: true,
|
|
33
|
+
success: true,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should deploy', async () => {
|
|
38
|
+
// the check is done inside beforeEach
|
|
39
|
+
// blockchain and {{loweredName}} are ready to use
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
it('should increase counter', async () => {
|
|
43
|
+
const increaseTimes = 3;
|
|
44
|
+
for (let i = 0; i < increaseTimes; i++) {
|
|
45
|
+
console.log(`increase ${i + 1}/${increaseTimes}`);
|
|
46
|
+
|
|
47
|
+
const increaser = await blockchain.treasury('increaser' + i);
|
|
48
|
+
|
|
49
|
+
const counterBefore = await {{loweredName}}.getCounter();
|
|
50
|
+
|
|
51
|
+
console.log('counter before increasing', counterBefore);
|
|
52
|
+
|
|
53
|
+
const increaseBy = BigInt(Math.floor(Math.random() * 100));
|
|
54
|
+
|
|
55
|
+
console.log('increasing by', increaseBy);
|
|
56
|
+
|
|
57
|
+
const increaseResult = await {{loweredName}}.send(
|
|
58
|
+
increaser.getSender(),
|
|
59
|
+
{
|
|
60
|
+
value: toNano('0.05'),
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
$$type: 'Add',
|
|
64
|
+
queryId: 0n,
|
|
65
|
+
amount: increaseBy,
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
|
|
69
|
+
expect(increaseResult.transactions).toHaveTransaction({
|
|
70
|
+
from: increaser.address,
|
|
71
|
+
to: {{loweredName}}.address,
|
|
72
|
+
success: true,
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
const counterAfter = await {{loweredName}}.getCounter();
|
|
76
|
+
|
|
77
|
+
console.log('counter after increasing', counterAfter);
|
|
78
|
+
|
|
79
|
+
expect(counterAfter).toBe(counterBefore + increaseBy);
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
});
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
deploy{{name}}.ts
|
|
2
|
+
import { toNano } from 'ton-core';
|
|
3
|
+
import { {{name}} } from '../wrappers/{{name}}';
|
|
4
|
+
import { NetworkProvider } from '@ton-community/blueprint';
|
|
5
|
+
|
|
6
|
+
export async function run(provider: NetworkProvider) {
|
|
7
|
+
const {{loweredName}} = provider.open(await {{name}}.fromInit());
|
|
8
|
+
|
|
9
|
+
await {{loweredName}}.send(
|
|
10
|
+
provider.sender(),
|
|
11
|
+
{
|
|
12
|
+
value: toNano('0.05'),
|
|
13
|
+
},
|
|
14
|
+
{
|
|
15
|
+
$$type: 'Deploy',
|
|
16
|
+
queryId: 0n,
|
|
17
|
+
}
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
await provider.waitForDeploy({{loweredName}}.address);
|
|
21
|
+
|
|
22
|
+
// run methods on `{{loweredName}}`
|
|
23
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
{{name}}.spec.ts
|
|
2
|
+
import { Blockchain, SandboxContract } from '@ton-community/sandbox';
|
|
3
|
+
import { toNano } from 'ton-core';
|
|
4
|
+
import { {{name}} } from '../wrappers/{{name}}';
|
|
5
|
+
import '@ton-community/test-utils';
|
|
6
|
+
|
|
7
|
+
describe('{{name}}', () => {
|
|
8
|
+
let blockchain: Blockchain;
|
|
9
|
+
let {{loweredName}}: SandboxContract<{{name}}>;
|
|
10
|
+
|
|
11
|
+
beforeEach(async () => {
|
|
12
|
+
blockchain = await Blockchain.create();
|
|
13
|
+
|
|
14
|
+
{{loweredName}} = blockchain.openContract(await {{name}}.fromInit());
|
|
15
|
+
|
|
16
|
+
const deployer = await blockchain.treasury('deployer');
|
|
17
|
+
|
|
18
|
+
const deployResult = await {{loweredName}}.send(
|
|
19
|
+
deployer.getSender(),
|
|
20
|
+
{
|
|
21
|
+
value: toNano('0.05'),
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
$$type: 'Deploy',
|
|
25
|
+
queryId: 0n,
|
|
26
|
+
}
|
|
27
|
+
);
|
|
28
|
+
|
|
29
|
+
expect(deployResult.transactions).toHaveTransaction({
|
|
30
|
+
from: deployer.address,
|
|
31
|
+
to: {{loweredName}}.address,
|
|
32
|
+
deploy: true,
|
|
33
|
+
success: true,
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
it('should deploy', async () => {
|
|
38
|
+
// the check is done inside beforeEach
|
|
39
|
+
// blockchain and {{loweredName}} are ready to use
|
|
40
|
+
});
|
|
41
|
+
});
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { UIProvider } from '../ui/UIProvider';
|
|
2
|
+
export declare class InquirerUIProvider implements UIProvider {
|
|
3
|
+
#private;
|
|
4
|
+
constructor();
|
|
5
|
+
write(message: string): void;
|
|
6
|
+
prompt(message: string): Promise<boolean>;
|
|
7
|
+
input(message: string): Promise<string>;
|
|
8
|
+
choose<T>(message: string, choices: T[], display: (v: T) => string): Promise<T>;
|
|
9
|
+
setActionPrompt(message: string): void;
|
|
10
|
+
clearActionPrompt(): void;
|
|
11
|
+
close(): void;
|
|
12
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
14
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
15
|
+
};
|
|
16
|
+
var _InquirerUIProvider_bottomBar;
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.InquirerUIProvider = void 0;
|
|
19
|
+
const inquirer_1 = __importDefault(require("inquirer"));
|
|
20
|
+
class DestroyableBottomBar extends inquirer_1.default.ui.BottomBar {
|
|
21
|
+
destroy() {
|
|
22
|
+
this.close();
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
class InquirerUIProvider {
|
|
26
|
+
constructor() {
|
|
27
|
+
_InquirerUIProvider_bottomBar.set(this, void 0);
|
|
28
|
+
__classPrivateFieldSet(this, _InquirerUIProvider_bottomBar, new DestroyableBottomBar(), "f");
|
|
29
|
+
}
|
|
30
|
+
write(message) {
|
|
31
|
+
__classPrivateFieldGet(this, _InquirerUIProvider_bottomBar, "f").log.write(message);
|
|
32
|
+
}
|
|
33
|
+
async prompt(message) {
|
|
34
|
+
const { prompt } = await inquirer_1.default.prompt({
|
|
35
|
+
type: 'confirm',
|
|
36
|
+
name: 'prompt',
|
|
37
|
+
message,
|
|
38
|
+
});
|
|
39
|
+
return prompt;
|
|
40
|
+
}
|
|
41
|
+
async input(message) {
|
|
42
|
+
const { val } = await inquirer_1.default.prompt({
|
|
43
|
+
name: 'val',
|
|
44
|
+
message: message,
|
|
45
|
+
});
|
|
46
|
+
return val;
|
|
47
|
+
}
|
|
48
|
+
async choose(message, choices, display) {
|
|
49
|
+
const { choice } = await inquirer_1.default.prompt([
|
|
50
|
+
{
|
|
51
|
+
type: 'list',
|
|
52
|
+
name: 'choice',
|
|
53
|
+
message: message,
|
|
54
|
+
choices: choices.map((c) => ({ name: display(c), value: c })),
|
|
55
|
+
},
|
|
56
|
+
]);
|
|
57
|
+
return choice;
|
|
58
|
+
}
|
|
59
|
+
setActionPrompt(message) {
|
|
60
|
+
__classPrivateFieldGet(this, _InquirerUIProvider_bottomBar, "f").updateBottomBar(message);
|
|
61
|
+
}
|
|
62
|
+
clearActionPrompt() {
|
|
63
|
+
__classPrivateFieldGet(this, _InquirerUIProvider_bottomBar, "f").updateBottomBar('');
|
|
64
|
+
}
|
|
65
|
+
close() {
|
|
66
|
+
__classPrivateFieldGet(this, _InquirerUIProvider_bottomBar, "f").destroy();
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
exports.InquirerUIProvider = InquirerUIProvider;
|
|
70
|
+
_InquirerUIProvider_bottomBar = new WeakMap();
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export interface UIProvider {
|
|
2
|
+
write(message: string): void;
|
|
3
|
+
prompt(message: string): Promise<boolean>;
|
|
4
|
+
input(message: string): Promise<string>;
|
|
5
|
+
choose<T>(message: string, choices: T[], display: (v: T) => string): Promise<T>;
|
|
6
|
+
setActionPrompt(message: string): void;
|
|
7
|
+
clearActionPrompt(): void;
|
|
8
|
+
}
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { Address, Cell } from 'ton-core';
|
|
2
|
+
import { UIProvider } from './ui/UIProvider';
|
|
3
|
+
export declare const tonDeepLink: (address: Address, amount: bigint, body?: Cell, stateInit?: Cell) => string;
|
|
4
|
+
export declare function sleep(ms: number): Promise<unknown>;
|
|
5
|
+
export declare function oneOrZeroOf<T extends {
|
|
6
|
+
[k: string]: boolean | undefined;
|
|
7
|
+
}>(options: T): keyof T | undefined;
|
|
8
|
+
export declare const findCompiles: () => Promise<{
|
|
9
|
+
path: string;
|
|
10
|
+
name: string;
|
|
11
|
+
}[]>;
|
|
12
|
+
export declare const findScripts: () => Promise<{
|
|
13
|
+
path: string;
|
|
14
|
+
name: string;
|
|
15
|
+
}[]>;
|
|
16
|
+
export declare function selectOption(options: {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}[], opts: {
|
|
20
|
+
ui: UIProvider;
|
|
21
|
+
msg: string;
|
|
22
|
+
hint?: string;
|
|
23
|
+
}): Promise<{
|
|
24
|
+
name: string;
|
|
25
|
+
value: string;
|
|
26
|
+
}>;
|
|
27
|
+
export declare function selectFile(files: {
|
|
28
|
+
name: string;
|
|
29
|
+
path: string;
|
|
30
|
+
}[], opts: {
|
|
31
|
+
ui: UIProvider;
|
|
32
|
+
hint?: string;
|
|
33
|
+
import?: boolean;
|
|
34
|
+
}): Promise<{
|
|
35
|
+
module: any;
|
|
36
|
+
name: string;
|
|
37
|
+
path: string;
|
|
38
|
+
}>;
|
|
39
|
+
export declare function getExplorerLink(address: string, network: string, explorer: string): string;
|