Skip to content

Commit

Permalink
feature[setler-cli]: 0.0.25
Browse files Browse the repository at this point in the history
  • Loading branch information
mankins committed Sep 26, 2023
1 parent 0bbaa30 commit 8d7f64c
Show file tree
Hide file tree
Showing 10 changed files with 269 additions and 66 deletions.
13 changes: 13 additions & 0 deletions identity-wallet/setler-cli/changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,19 @@ Subsections: (Added, Changed, Deprecated, Removed, Fixed, Security)

## [Unreleased]

## [0.0.25] - 2023-09-26

### Added

- Scope now works through more functions allowing for multiple mnemonic wallets to be used.
- noPassword option for `setler wallet init` to allow for automated wallet creation with password of "password". This is not recommended for production use, but helps standardize seeds.
- SourceTag now included to identify transactions as coming from the Kudos Setler.
- X-addresses now supported for sending

### Changed

- Minimums for `setler kudos send` are now 2 \* the current send fee.

## [0.0.24] - 2023-09-25

### Removed
Expand Down
5 changes: 3 additions & 2 deletions identity-wallet/setler-cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@loremlabs/setler",
"version": "0.0.24",
"version": "0.0.25",
"description": "setler command-line tool, a non-custodial identity wallet with kudos support",
"license": "MIT",
"type": "module",
Expand Down Expand Up @@ -84,7 +84,8 @@
"eslint": "8.2.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
"prettier": "2.4.1"
"prettier": "2.4.1",
"xrpl-tagged-address-codec": "^0.2.1"
},
"main": "src/cli.js",
"directories": {
Expand Down
42 changes: 40 additions & 2 deletions identity-wallet/setler-cli/pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 37 additions & 7 deletions identity-wallet/setler-cli/src/actions/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,11 +81,23 @@ const exec = async (context) => {
// SETLER_KEYS_0="e..."
config.auth = config.auth || {};

let scope = context.flags.scope || process.env.SETLER_SCOPE || 0; // changing the scope will generate a new mnemonic and hd wallet
scope = parseInt(scope, 10);
context.scope = `${scope}`;

if (context.input[2] === "get") {
const profile = context.profile || 0;
const keys =
config.auth?.[`SETLER_KEYS_${profile}`] ||
process.env[`SETLER_KEYS_${profile}`];
config.auth?.[
`SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${profile}`
] ||
process.env[
`SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${profile}`
];

log(`SETLER_KEYS_${profile}="${keys}"`);

Expand All @@ -106,18 +118,36 @@ const exec = async (context) => {
{
type: "text",
name: "token",
message: `Enter SETLER_KEYS_${profile}: `,
message: `Enter SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${profile}: `,
initial:
process.env[`SETLER_KEYS_${profile}`] ||
config.auth?.[`SETLER_KEYS_${profile}`],
process.env[
`SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${profile}`
] ||
config.auth?.[
`SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${profile}`
],
},
]);
if (!response.token) {
process.exit(1);
}
config.auth[`SETLER_KEYS_${profile}`] = response.token;
config.auth[
`SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${profile}`
] = response.token;
} else {
config.auth[`SETLER_KEYS_${profile}`] = token;
config.auth[
`SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${profile}`
] = token;
}

// write
Expand Down
33 changes: 23 additions & 10 deletions identity-wallet/setler-cli/src/actions/kudos.js
Original file line number Diff line number Diff line change
Expand Up @@ -941,7 +941,11 @@ const exec = async (context) => {
JSON.stringify({ kudos: context.keys.kudos })
).toString("base64url");

log(`SETLER_KEYS_${context.profile}="${kudosKeysExportBase64}"`);
log(
`SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${context.profile}="${kudosKeysExportBase64}"`
);
}
break;
}
Expand Down Expand Up @@ -1070,8 +1074,9 @@ const exec = async (context) => {
case "send": {
await gatekeep(context);

const network =
let network =
context.flags.network || context.config.network || "xrpl:testnet";
network = network.replace("-", ":"); // nonsense
const kudosNetwork = context.flags.kudosNetwork || "kudos";
const keys = await context.vault.keys();

Expand Down Expand Up @@ -1632,7 +1637,10 @@ const exec = async (context) => {
text: "Fetching current exchange rate",
});

const amountUsd = parseFloat(amountXrp * exchangeRate).toFixed(2);
let amountUsd = parseFloat(amountXrp * exchangeRate).toFixed(2);
if (amountUsd === "0.00") {
amountUsd = parseFloat(amountXrp * exchangeRate).toFixed(5);
}
log(chalk.gray(`\tAmount in usd : \t$${amountUsd}\n`));

// confirm
Expand Down Expand Up @@ -1707,9 +1715,9 @@ const exec = async (context) => {
(totalDropsBeforeFees * address.weight) / totalWeight
); // TODO: validate the drops usage is correct
// see if we're below minimus threshold
if (amountDrops < 750) {
// don't try to send less than 0.0000075 XRP
// if the amount is less than 0.0000075 XRP, then we need to adjust the weight of this address
if (amountDrops < totalFeeEstimateDrops * 2) {
// don't try to send less than 2x the fee estimate
// if the amount is less than requirement, then we need to adjust the weight of this address
// and recalculate the weights
address.weight = 0;
changedWeights = true;
Expand All @@ -1719,7 +1727,9 @@ const exec = async (context) => {
165,
0
)(
`send: amount for ${address.address} is less than 0.0000075 XRP. Will skip this address.`
`send: amount for ${address.address} is less than ${
(totalFeeEstimateDrops * 2) / 1000000
} XRP. Will skip this address.`
)
);
}
Expand Down Expand Up @@ -1761,6 +1771,11 @@ const exec = async (context) => {
(creator) => creator.id === address.address
);

let amountUsd = parseFloat(address.amount * exchangeRate).toFixed(2);
if (amountUsd === "0.00") {
amountUsd = parseFloat(address.amount * exchangeRate).toFixed(5);
}

let output =
chalk.blueBright(
`${address.address} ${" ".repeat(
Expand All @@ -1782,9 +1797,7 @@ const exec = async (context) => {
)} ` +
chalk.greenBright(`${address.amount} XRP`) +
" ~ " +
chalk.cyanBright(
`$${parseFloat(address.amount * exchangeRate).toFixed(2)}`
) +
chalk.cyanBright(`$${amountUsd}`) +
(isSetlerCreator ? chalk.yellow(" (setler fee)") : "");

if (isSetlerCreator) {
Expand Down
3 changes: 2 additions & 1 deletion identity-wallet/setler-cli/src/actions/ns.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,8 @@ const exec = async (context) => {
case "lookup":
case "get": {
await gatekeep(context);
const network = context.flags.network || "xrpl:testnet";
const network =
context.flags.network || context.config.network || "xrpl:testnet";

const domain = context.flags.domain || "ident.cash";

Expand Down
4 changes: 3 additions & 1 deletion identity-wallet/setler-cli/src/actions/wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,9 @@ const exec = async (context) => {

if (context.input[2] === "env") {
// display env var version of key
const envKey = `SETLER_KEYS_${parseInt(context.profile, 10)}`;
const envKey = `SETLER_KEYS_${
parseInt(context.scope, 10) ? context.scope + "_" : ""
}${parseInt(context.profile, 10)}`;
// encodedKeys should be Base64Url encoded JSON of filteredKeys
const encodedKeys = JSON.stringify(filteredKeys);
const encodedKeysBase64 =
Expand Down
Loading

2 comments on commit 8d7f64c

@vercel
Copy link

@vercel vercel bot commented on 8d7f64c Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@vercel
Copy link

@vercel vercel bot commented on 8d7f64c Sep 26, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

ident-agency-net-enola – ./ident-agency/packages/enola

ident-agency-net-enola-loremlabs.vercel.app
ident-agency-net-enola.vercel.app
ident-agency-net-enola-git-main-loremlabs.vercel.app

Please sign in to comment.