mobilestacks 0.1.8 → 0.1.9
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.
|
@@ -11,15 +11,15 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
|
11
11
|
.addParam('functionName', 'Function name', { type: 'string', required: true })
|
|
12
12
|
.addParam('args', 'Comma-separated function arguments', { type: 'string', required: false, defaultValue: '' })
|
|
13
13
|
.addParam('network', 'Network (mainnet|testnet)', { type: 'string', required: false, defaultValue: 'testnet' })
|
|
14
|
-
.setAction(async (args) => {
|
|
14
|
+
.setAction(async (args, env) => {
|
|
15
15
|
const contractAddress = args.contractAddress;
|
|
16
16
|
const contractName = args.contractName;
|
|
17
17
|
const functionName = args.functionName;
|
|
18
18
|
const fnArgs = args.args;
|
|
19
19
|
const network = args.network;
|
|
20
20
|
const apiUrl = network === 'mainnet'
|
|
21
|
-
?
|
|
22
|
-
:
|
|
21
|
+
? env.config.networks.mainnet.url
|
|
22
|
+
: env.config.networks.testnet.url;
|
|
23
23
|
const url = `${apiUrl}/v2/contracts/call-read/${contractAddress}/${contractName}/${functionName}`;
|
|
24
24
|
const body = fnArgs
|
|
25
25
|
? { arguments: fnArgs.split(',').map((a) => a.trim()) }
|
|
@@ -24,9 +24,8 @@ function containsSecret(obj) {
|
|
|
24
24
|
const file = args.file;
|
|
25
25
|
const network = args.network;
|
|
26
26
|
let codeBody = fs_1.default.readFileSync(file, 'utf8');
|
|
27
|
-
|
|
28
|
-
codeBody = codeBody.replace(/^\uFEFF/, '').replace(/[^\x20-\x7E\n\
|
|
29
|
-
// Switch network if needed
|
|
27
|
+
codeBody = codeBody.replace(/\r\n/g, '\n').replace(/\r/g, '\n');
|
|
28
|
+
codeBody = codeBody.replace(/^\uFEFF/, '').replace(/[^\x20-\x7E\n\t]/g, '');
|
|
30
29
|
if (network === 'mainnet') {
|
|
31
30
|
env.network = (0, network_1.createNetwork)({ network: 'mainnet', client: { baseUrl: env.config.networks.mainnet.url } });
|
|
32
31
|
}
|
|
@@ -9,7 +9,7 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
|
9
9
|
.addParam('address', 'STX address to fund', { type: 'string', required: true })
|
|
10
10
|
.setAction(async (args, env) => {
|
|
11
11
|
if (env.network.client.baseUrl && env.network.client.baseUrl.includes('testnet')) {
|
|
12
|
-
const url =
|
|
12
|
+
const url = `${env.config.networks.testnet.url}/extended/v1/faucet/stx`;
|
|
13
13
|
const res = await (0, node_fetch_1.default)(url, {
|
|
14
14
|
method: 'POST',
|
|
15
15
|
headers: { 'Content-Type': 'application/json' },
|
|
@@ -9,11 +9,11 @@ const node_fetch_1 = __importDefault(require("node-fetch"));
|
|
|
9
9
|
.addParam('contractAddress', 'Deployed contract address (STX...)', { type: 'string', required: true })
|
|
10
10
|
.addParam('contractName', 'Contract name', { type: 'string', required: true })
|
|
11
11
|
.addParam('network', 'Network (mainnet|testnet)', { type: 'string', required: false, defaultValue: 'testnet' })
|
|
12
|
-
.setAction(async (args) => {
|
|
12
|
+
.setAction(async (args, env) => {
|
|
13
13
|
const { contractAddress, contractName, network } = args;
|
|
14
14
|
const apiUrl = network === 'mainnet'
|
|
15
|
-
?
|
|
16
|
-
:
|
|
15
|
+
? env.config.networks.mainnet.url
|
|
16
|
+
: env.config.networks.testnet.url;
|
|
17
17
|
const url = `${apiUrl}/extended/v1/contract/${contractAddress}/${contractName}`;
|
|
18
18
|
const res = await (0, node_fetch_1.default)(url);
|
|
19
19
|
if (!res.ok)
|
package/dist/tasks/send-stx.js
CHANGED
|
@@ -12,16 +12,18 @@ function containsSecret(obj) {
|
|
|
12
12
|
// This task sends STX to an address using the loaded SRE (env)
|
|
13
13
|
(0, dsl_1.task)('send-stx', 'Sends STX to an address')
|
|
14
14
|
.addParam('to', 'Recipient STX address', { type: 'string', required: true })
|
|
15
|
-
.addParam('amount', 'Amount in
|
|
15
|
+
.addParam('amount', 'Amount in STX (e.g. 10.5)', { type: 'number', required: true })
|
|
16
16
|
.addParam('memo', 'Optional memo', { type: 'string', required: false, defaultValue: '' })
|
|
17
17
|
.setAction(async (args, env) => {
|
|
18
18
|
const to = args.to;
|
|
19
|
-
const
|
|
19
|
+
const amountSTX = args.amount;
|
|
20
20
|
const memo = args.memo;
|
|
21
21
|
const { wallet, network } = env;
|
|
22
|
+
// Convert STX to microSTX (1 STX = 1,000,000 microSTX)
|
|
23
|
+
const amountMicroStx = BigInt(Math.floor(amountSTX * 1_000_000));
|
|
22
24
|
const tx = await (0, transactions_1.makeSTXTokenTransfer)({
|
|
23
25
|
recipient: to,
|
|
24
|
-
amount:
|
|
26
|
+
amount: amountMicroStx,
|
|
25
27
|
senderKey: wallet.privateKey,
|
|
26
28
|
network,
|
|
27
29
|
memo: memo || undefined
|
|
@@ -11,15 +11,15 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
11
11
|
.addParam('contractName', 'Contract name', { type: 'string', required: true })
|
|
12
12
|
.addParam('source', 'Path to contract source file', { type: 'string', required: true })
|
|
13
13
|
.addParam('network', 'Network (mainnet|testnet)', { type: 'string', required: false, defaultValue: 'testnet' })
|
|
14
|
-
.setAction(async (args) => {
|
|
14
|
+
.setAction(async (args, env) => {
|
|
15
15
|
const contractAddress = args.contractAddress;
|
|
16
16
|
const contractName = args.contractName;
|
|
17
17
|
const source = args.source;
|
|
18
18
|
const network = args.network;
|
|
19
19
|
const codeBody = fs_1.default.readFileSync(source, 'utf8');
|
|
20
20
|
const apiUrl = network === 'mainnet'
|
|
21
|
-
?
|
|
22
|
-
:
|
|
21
|
+
? env.config.networks.mainnet.url
|
|
22
|
+
: env.config.networks.testnet.url;
|
|
23
23
|
// Fetch contract source from chain
|
|
24
24
|
const url = `${apiUrl}/extended/v1/contract/source/${contractAddress}/${contractName}`;
|
|
25
25
|
const res = await (0, node_fetch_1.default)(url);
|
|
@@ -28,8 +28,8 @@ const fs_1 = __importDefault(require("fs"));
|
|
|
28
28
|
const onChain = await res.json();
|
|
29
29
|
const verified = onChain.source_code && onChain.source_code.trim() === codeBody.trim();
|
|
30
30
|
const explorer = network === 'mainnet'
|
|
31
|
-
? `https://explorer.
|
|
32
|
-
: `https://explorer.
|
|
31
|
+
? `https://explorer.hiro.so/txid/${contractAddress}.${contractName}`
|
|
32
|
+
: `https://explorer.hiro.so/txid/${contractAddress}.${contractName}?chain=testnet`;
|
|
33
33
|
return {
|
|
34
34
|
verified,
|
|
35
35
|
message: verified ? 'Contract source matches on-chain code!' : 'Source does NOT match on-chain code!',
|