@ar.io/sdk 3.0.0-alpha.1 → 3.0.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/README.md +43 -43
- package/bundles/web.bundle.min.js +1 -1
- package/lib/cjs/cli/commands/gatewayWriteCommands.js +4 -4
- package/lib/cjs/cli/options.js +1 -1
- package/lib/cjs/cli/utils.js +5 -5
- package/lib/cjs/version.js +1 -1
- package/lib/esm/cli/commands/gatewayWriteCommands.js +4 -4
- package/lib/esm/cli/options.js +1 -1
- package/lib/esm/cli/utils.js +5 -5
- package/lib/esm/version.js +1 -1
- package/lib/types/cli/utils.d.ts +1 -1
- package/lib/types/version.d.ts +1 -1
- package/package.json +1 -1
|
@@ -38,10 +38,10 @@ async function joinNetwork(options) {
|
|
|
38
38
|
if (!options.skipConfirmation) {
|
|
39
39
|
const settings = await ario.getGatewayRegistrySettings();
|
|
40
40
|
if (settings.operators.minStake > mARIOQuantity.valueOf()) {
|
|
41
|
-
throw new Error(`The minimum operator stake is ${(0, utils_js_1.formatARIOWithCommas)(new index_js_1.mARIOToken(settings.operators.minStake).toARIO())}
|
|
41
|
+
throw new Error(`The minimum operator stake is ${(0, utils_js_1.formatARIOWithCommas)(new index_js_1.mARIOToken(settings.operators.minStake).toARIO())} ARIO. Please provide a higher stake.`);
|
|
42
42
|
}
|
|
43
43
|
await (0, utils_js_1.assertEnoughBalance)(ario, signerAddress, mARIOQuantity.toARIO());
|
|
44
|
-
await (0, utils_js_1.assertConfirmationPrompt)(`Gateway Settings:\n\n${JSON.stringify(settings, null, 2)}\n\nYou are about to stake ${(0, utils_js_1.formatARIOWithCommas)(mARIOQuantity.toARIO())}
|
|
44
|
+
await (0, utils_js_1.assertConfirmationPrompt)(`Gateway Settings:\n\n${JSON.stringify(settings, null, 2)}\n\nYou are about to stake ${(0, utils_js_1.formatARIOWithCommas)(mARIOQuantity.toARIO())} ARIO to join the AR.IO network\nAre you sure?\n`, options);
|
|
45
45
|
}
|
|
46
46
|
const result = await ario.joinNetwork(settings, (0, utils_js_1.writeActionTagsFromOptions)(options));
|
|
47
47
|
const output = {
|
|
@@ -96,7 +96,7 @@ async function saveObservations(o) {
|
|
|
96
96
|
exports.saveObservations = saveObservations;
|
|
97
97
|
async function increaseOperatorStake(o) {
|
|
98
98
|
const increaseQty = (0, utils_js_1.requiredMIOFromOptions)(o, 'operatorStake');
|
|
99
|
-
await (0, utils_js_1.assertConfirmationPrompt)(`You are about to increase your operator stake by ${(0, utils_js_1.formatARIOWithCommas)(increaseQty.toARIO())}
|
|
99
|
+
await (0, utils_js_1.assertConfirmationPrompt)(`You are about to increase your operator stake by ${(0, utils_js_1.formatARIOWithCommas)(increaseQty.toARIO())} ARIO\nAre you sure?`, o);
|
|
100
100
|
return ((0, utils_js_1.writeARIOFromOptions)(o).ario.increaseOperatorStake({
|
|
101
101
|
increaseQty,
|
|
102
102
|
}),
|
|
@@ -106,7 +106,7 @@ exports.increaseOperatorStake = increaseOperatorStake;
|
|
|
106
106
|
async function decreaseOperatorStake(o) {
|
|
107
107
|
const decreaseQty = (0, utils_js_1.requiredMIOFromOptions)(o, 'operatorStake');
|
|
108
108
|
// TODO: Can assert stake is sufficient for action, and new target stake meets contract minimum
|
|
109
|
-
await (0, utils_js_1.assertConfirmationPrompt)(`You are about to decrease your operator stake by ${(0, utils_js_1.formatARIOWithCommas)(decreaseQty.toARIO())}
|
|
109
|
+
await (0, utils_js_1.assertConfirmationPrompt)(`You are about to decrease your operator stake by ${(0, utils_js_1.formatARIOWithCommas)(decreaseQty.toARIO())} ARIO\nAre you sure?`, o);
|
|
110
110
|
return (0, utils_js_1.writeARIOFromOptions)(o).ario.decreaseOperatorStake({
|
|
111
111
|
decreaseQty,
|
|
112
112
|
}, (0, utils_js_1.writeActionTagsFromOptions)(o));
|
package/lib/cjs/cli/options.js
CHANGED
package/lib/cjs/cli/utils.js
CHANGED
|
@@ -296,15 +296,15 @@ function recordTypeFromOptions(options) {
|
|
|
296
296
|
exports.recordTypeFromOptions = recordTypeFromOptions;
|
|
297
297
|
function requiredMIOFromOptions(options, key) {
|
|
298
298
|
if (options[key] === undefined) {
|
|
299
|
-
throw new Error(`No ${key} provided. Use --${key} denominated in
|
|
299
|
+
throw new Error(`No ${key} provided. Use --${key} denominated in ARIO`);
|
|
300
300
|
}
|
|
301
301
|
return new index_js_1.ARIOToken(+options[key]).toMARIO();
|
|
302
302
|
}
|
|
303
303
|
exports.requiredMIOFromOptions = requiredMIOFromOptions;
|
|
304
|
-
async function assertEnoughBalance(
|
|
305
|
-
const balance = await
|
|
306
|
-
if (balance <
|
|
307
|
-
throw new Error(`Insufficient
|
|
304
|
+
async function assertEnoughBalance(ario, address, arioQuantity) {
|
|
305
|
+
const balance = await ario.getBalance({ address });
|
|
306
|
+
if (balance < arioQuantity.toMARIO().valueOf()) {
|
|
307
|
+
throw new Error(`Insufficient ARIO balance for action. Balance available: ${new index_js_1.mARIOToken(balance).toARIO()} ARIO`);
|
|
308
308
|
}
|
|
309
309
|
}
|
|
310
310
|
exports.assertEnoughBalance = assertEnoughBalance;
|
package/lib/cjs/version.js
CHANGED
|
@@ -32,10 +32,10 @@ export async function joinNetwork(options) {
|
|
|
32
32
|
if (!options.skipConfirmation) {
|
|
33
33
|
const settings = await ario.getGatewayRegistrySettings();
|
|
34
34
|
if (settings.operators.minStake > mARIOQuantity.valueOf()) {
|
|
35
|
-
throw new Error(`The minimum operator stake is ${formatARIOWithCommas(new mARIOToken(settings.operators.minStake).toARIO())}
|
|
35
|
+
throw new Error(`The minimum operator stake is ${formatARIOWithCommas(new mARIOToken(settings.operators.minStake).toARIO())} ARIO. Please provide a higher stake.`);
|
|
36
36
|
}
|
|
37
37
|
await assertEnoughBalance(ario, signerAddress, mARIOQuantity.toARIO());
|
|
38
|
-
await assertConfirmationPrompt(`Gateway Settings:\n\n${JSON.stringify(settings, null, 2)}\n\nYou are about to stake ${formatARIOWithCommas(mARIOQuantity.toARIO())}
|
|
38
|
+
await assertConfirmationPrompt(`Gateway Settings:\n\n${JSON.stringify(settings, null, 2)}\n\nYou are about to stake ${formatARIOWithCommas(mARIOQuantity.toARIO())} ARIO to join the AR.IO network\nAre you sure?\n`, options);
|
|
39
39
|
}
|
|
40
40
|
const result = await ario.joinNetwork(settings, writeActionTagsFromOptions(options));
|
|
41
41
|
const output = {
|
|
@@ -86,7 +86,7 @@ export async function saveObservations(o) {
|
|
|
86
86
|
}
|
|
87
87
|
export async function increaseOperatorStake(o) {
|
|
88
88
|
const increaseQty = requiredMARIOFromOptions(o, 'operatorStake');
|
|
89
|
-
await assertConfirmationPrompt(`You are about to increase your operator stake by ${formatARIOWithCommas(increaseQty.toARIO())}
|
|
89
|
+
await assertConfirmationPrompt(`You are about to increase your operator stake by ${formatARIOWithCommas(increaseQty.toARIO())} ARIO\nAre you sure?`, o);
|
|
90
90
|
return (writeARIOFromOptions(o).ario.increaseOperatorStake({
|
|
91
91
|
increaseQty,
|
|
92
92
|
}),
|
|
@@ -95,7 +95,7 @@ export async function increaseOperatorStake(o) {
|
|
|
95
95
|
export async function decreaseOperatorStake(o) {
|
|
96
96
|
const decreaseQty = requiredMARIOFromOptions(o, 'operatorStake');
|
|
97
97
|
// TODO: Can assert stake is sufficient for action, and new target stake meets contract minimum
|
|
98
|
-
await assertConfirmationPrompt(`You are about to decrease your operator stake by ${formatARIOWithCommas(decreaseQty.toARIO())}
|
|
98
|
+
await assertConfirmationPrompt(`You are about to decrease your operator stake by ${formatARIOWithCommas(decreaseQty.toARIO())} ARIO\nAre you sure?`, o);
|
|
99
99
|
return writeARIOFromOptions(o).ario.decreaseOperatorStake({
|
|
100
100
|
decreaseQty,
|
|
101
101
|
}, writeActionTagsFromOptions(o));
|
package/lib/esm/cli/options.js
CHANGED
package/lib/esm/cli/utils.js
CHANGED
|
@@ -267,14 +267,14 @@ export function recordTypeFromOptions(options) {
|
|
|
267
267
|
}
|
|
268
268
|
export function requiredMIOFromOptions(options, key) {
|
|
269
269
|
if (options[key] === undefined) {
|
|
270
|
-
throw new Error(`No ${key} provided. Use --${key} denominated in
|
|
270
|
+
throw new Error(`No ${key} provided. Use --${key} denominated in ARIO`);
|
|
271
271
|
}
|
|
272
272
|
return new ARIOToken(+options[key]).toMARIO();
|
|
273
273
|
}
|
|
274
|
-
export async function assertEnoughBalance(
|
|
275
|
-
const balance = await
|
|
276
|
-
if (balance <
|
|
277
|
-
throw new Error(`Insufficient
|
|
274
|
+
export async function assertEnoughBalance(ario, address, arioQuantity) {
|
|
275
|
+
const balance = await ario.getBalance({ address });
|
|
276
|
+
if (balance < arioQuantity.toMARIO().valueOf()) {
|
|
277
|
+
throw new Error(`Insufficient ARIO balance for action. Balance available: ${new mARIOToken(balance).toARIO()} ARIO`);
|
|
278
278
|
}
|
|
279
279
|
}
|
|
280
280
|
export async function confirmationPrompt(message) {
|
package/lib/esm/version.js
CHANGED
package/lib/types/cli/utils.d.ts
CHANGED
|
@@ -52,7 +52,7 @@ export declare function recordTypeFromOptions<O extends {
|
|
|
52
52
|
type?: string;
|
|
53
53
|
}>(options: O): 'lease' | 'permabuy';
|
|
54
54
|
export declare function requiredMIOFromOptions<O extends GlobalCLIOptions>(options: O, key: string): mARIOToken;
|
|
55
|
-
export declare function assertEnoughBalance(
|
|
55
|
+
export declare function assertEnoughBalance(ario: AoARIORead, address: string, arioQuantity: ARIOToken): Promise<void>;
|
|
56
56
|
export declare function confirmationPrompt(message: string): Promise<boolean>;
|
|
57
57
|
export declare function assertConfirmationPrompt<O extends {
|
|
58
58
|
skipConfirmation?: boolean;
|
package/lib/types/version.d.ts
CHANGED