Skip to content

Commit

Permalink
feat: update pkg @fluencelabs/deal-aurora (#143)
Browse files Browse the repository at this point in the history
* feat: update pkg @fluencelabs/deal-aurora

* update README

* fix README

---------

Co-authored-by: Artsiom Shamsutdzinau <[email protected]>
  • Loading branch information
elshan-eth and shamsartem authored Feb 15, 2023
1 parent 2659d9d commit 2a49316
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 210 deletions.
9 changes: 3 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ Fluence CLI is designed to be the only tool that you need to manage the life cyc

Prerequisites:

- Linux or MacOS (there are currently some bugs on Windows)
- [Node.js = 16.x.x](https://nodejs.org/)
- Linux or MacOS (there are currently some bugs on Windows)
- [Node.js = 16.x.x](https://nodejs.org/)

To install and try fluence, run:

Expand All @@ -31,15 +31,12 @@ A complete list of commands together with usage examples is available [here](./d

## Support

Please, file an [issue](https://github.com/fluencelabs/fluence-cli/issues) if you find a bug. You can also contact us at [Discord](https://discord.com/invite/5qSnPZKh7u) or [Telegram](https://t.me/fluence_project). We will do our best to resolve the issue ASAP.

Please, file an [issue](https://github.com/fluencelabs/fluence-cli/issues) if you find a bug. You can also contact us at [Discord](https://discord.com/invite/5qSnPZKh7u) or [Telegram](https://t.me/fluence_project). We will do our best to resolve the issue ASAP.

## Contributing

Any interested person is welcome to contribute to the project. Please, make sure you read and follow some basic [rules](./CONTRIBUTING.md).


## License

All software code is copyright (c) Fluence Labs, Inc. under the [Apache-2.0](./LICENSE) license.

57 changes: 27 additions & 30 deletions docs/commands/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* [`fluence aqua`](#fluence-aqua)
* [`fluence autocomplete [SHELL]`](#fluence-autocomplete-shell)
* [`fluence build`](#fluence-build)
* [`fluence deal change-app [DEAL-ADDRESS] [DEAL-NEW-APP-CID]`](#fluence-deal-change-app-deal-address-deal-new-app-cid)
* [`fluence deal create`](#fluence-deal-create)
* [`fluence deal faucet [AMOUNT] [TOKEN]`](#fluence-deal-faucet-amount-token)
* [`fluence dependency cargo install [PACKAGE-NAME | PACKAGE-NAME@VERSION]`](#fluence-dependency-cargo-install-package-name--package-nameversion)
* [`fluence dependency install`](#fluence-dependency-install)
* [`fluence dependency npm install [PACKAGE-NAME | PACKAGE-NAME@VERSION]`](#fluence-dependency-npm-install-package-name--package-nameversion)
Expand Down Expand Up @@ -112,51 +112,48 @@ EXAMPLES

_See code: [dist/commands/build.ts](https://github.com/fluencelabs/fluence-cli/blob/v0.2.37/dist/commands/build.ts)_

## `fluence deal create`
## `fluence deal change-app [DEAL-ADDRESS] [DEAL-NEW-APP-CID]`

Create your deal with the specified parameters
Change app id in the deal

```
USAGE
$ fluence deal create --appCID <value> --requiredStake <value> [--no-input] [-k <value>] [--pricePerEpoch
<value>] [--minWorkers <value>] [--maxWorkers <value>] [--targetWorkers <value>] [--network <value>]
$ fluence deal change-app [DEAL-ADDRESS] [DEAL-NEW-APP-CID] [--no-input] [-k <value>] [--network <value>]
ARGUMENTS
DEAL-ADDRESS Deal address
DEAL-NEW-APP-CID New app CID for the deal
FLAGS
-k, --privKey=<value> Private key with which transactions will be signed through cli
--appCID=<value> (required) CID of the application that will be deployed
--maxWorkers=<value> [default: 5]
--minWorkers=<value> [default: 1]
--network=<network> [default: testnet] $The network in which the transactions used by the command will be carried
out (local, testnet)
--no-input Don't interactively ask for any input from the user
--pricePerEpoch=<value> [default: 1] The price that you will pay to resource owners per epoch
--requiredStake=<value> (required) Required collateral in FLT tokens to join a deal for resource owners.
--targetWorkers=<value> [default: 3]
-k, --privKey=<value> Private key with which transactions will be signed through cli
--network=<network> [default: testnet] $The network in which the transactions used by the command will be carried
out (local, testnet)
--no-input Don't interactively ask for any input from the user
DESCRIPTION
Create your deal with the specified parameters
Change app id in the deal
```

## `fluence deal faucet [AMOUNT] [TOKEN]`
## `fluence deal create`

Dev faucet for receiving FLT and FakeUSD tokens
Create your deal with the specified parameters

```
USAGE
$ fluence deal faucet [AMOUNT] [TOKEN] [--no-input] [-k <value>] [--network <value>]
ARGUMENTS
AMOUNT Amount of tokens to receive
TOKEN Name of the token: FakeUSD, FLT
$ fluence deal create --appCID <value> [--no-input] [-k <value>] [--minWorkers <value>] [--targetWorkers
<value>] [--network <value>]
FLAGS
-k, --privKey=<value> Private key with which transactions will be signed through cli
--network=<network> [default: testnet] $The network in which the transactions used by the command will be carried
out (local, testnet)
--no-input Don't interactively ask for any input from the user
-k, --privKey=<value> Private key with which transactions will be signed through cli
--appCID=<value> (required) CID of the application that will be deployed
--minWorkers=<value> [default: 1] Required workers to activate the deal
--network=<network> [default: testnet] $The network in which the transactions used by the command will be carried
out (local, testnet)
--no-input Don't interactively ask for any input from the user
--targetWorkers=<value> [default: 3] Max workers in the deal
DESCRIPTION
Dev faucet for receiving FLT and FakeUSD tokens
Create your deal with the specified parameters
```

## `fluence dependency cargo install [PACKAGE-NAME | PACKAGE-NAME@VERSION]`
Expand Down Expand Up @@ -490,7 +487,7 @@ _See code: [dist/commands/remove.ts](https://github.com/fluencelabs/fluence-cli/

## `fluence resource-owner pat create [DEAL-ADDRESS]`

Create PAT (Peer auth token) in a deal for auth
Create provider access token for the deal

```
USAGE
Expand All @@ -506,7 +503,7 @@ FLAGS
--no-input Don't interactively ask for any input from the user
DESCRIPTION
Create PAT (Peer auth token) in a deal for auth
Create provider access token for the deal
```

## `fluence run`
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

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

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
},
"dependencies": {
"@fluencelabs/aqua-api": "=0.9.3",
"@fluencelabs/deal-aurora": "^0.1.4",
"@fluencelabs/deal-aurora": "^0.1.8",
"@fluencelabs/fluence": "0.28.0",
"@fluencelabs/fluence-network-environment": "^1.0.13",
"@iarna/toml": "^2.2.5",
Expand Down
78 changes: 78 additions & 0 deletions src/commands/deal/change-app.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
* Copyright 2022 Fluence Labs Limited
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { Args, Flags } from "@oclif/core";

import { BaseCommand, baseFlags } from "../../baseCommand.js";
import { NETWORK_FLAG } from "../../lib/const.js";
import { initCli } from "../../lib/lifecyle.js";
import { input } from "../../lib/prompt.js";
import {
getSigner,
ensureChainNetwork,
getDealContract,
} from "../../lib/provider.js";

const DEAL_NEW_APP_CID_ARG = "DEAL-NEW-APP-CID";
const DEAL_ADDRESS_ARG = "DEAL-ADDRESS";

export default class ChangeApp extends BaseCommand<typeof ChangeApp> {
static override description = "Change app id in the deal";
static override flags = {
...baseFlags,
privKey: Flags.string({
char: "k",
description:
"Private key with which transactions will be signed through cli",
required: false,
}),

...NETWORK_FLAG,
};

static override args = {
[DEAL_ADDRESS_ARG]: Args.string({
description: "Deal address",
}),
[DEAL_NEW_APP_CID_ARG]: Args.string({
description: "New app CID for the deal",
}),
};

async run(): Promise<void> {
const { args, flags } = await initCli(this, await this.parse(ChangeApp));

const network = await ensureChainNetwork({
maybeChainNetwork: flags.network,
});

const dealAddress: string =
args[DEAL_ADDRESS_ARG] ??
(await input({ message: "Enter deal address" }));

const newAppCID =
args[DEAL_NEW_APP_CID_ARG] ??
(await input({ message: "Enter new app CID" }));

const signer = await getSigner(network, flags.privKey);
const deal = getDealContract(dealAddress, signer);

const tx = await deal.setAppCID(newAppCID);
await tx.wait();

this.log(`Tx hash: ${tx.hash}`);
}
}
31 changes: 4 additions & 27 deletions src/commands/deal/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,13 @@
import assert from "node:assert";

import { Flags } from "@oclif/core";
import { BigNumber, utils } from "ethers";
import { BigNumber } from "ethers";

import { BaseCommand, baseFlags } from "../../baseCommand.js";
import { NETWORK_FLAG } from "../../lib/const.js";
import { initCli } from "../../lib/lifecyle.js";
import {
getFactoryContract,
getUSDContract,
getSigner,
ensureChainNetwork,
} from "../../lib/provider.js";
Expand All @@ -47,28 +46,13 @@ export default class Create extends BaseCommand<typeof Create> {
description: "CID of the application that will be deployed",
required: true,
}),
requiredStake: Flags.string({
description:
"Required collateral in FLT tokens to join a deal for resource owners.",
required: true,
}),
pricePerEpoch: Flags.string({
description: "The price that you will pay to resource owners per epoch",
required: false,
default: "1",
}),
minWorkers: Flags.string({
description: "",
description: "Required workers to activate the deal",
required: false,
default: "1",
}),
maxWorkers: Flags.string({
description: "",
required: false,
default: "5",
}),
targetWorkers: Flags.string({
description: "",
description: "Max workers in the deal",
required: false,
default: "3",
}),
Expand All @@ -87,16 +71,9 @@ export default class Create extends BaseCommand<typeof Create> {
const factory = getFactoryContract(signer, network);

const tx = await factory.createDeal(
(
await getUSDContract(signer, network)
).address,
BigNumber.from(flags.pricePerEpoch).mul(BigNumber.from(10).pow(18)),
BigNumber.from(flags.requiredStake).mul(BigNumber.from(10).pow(18)),
BigNumber.from(flags.minWorkers),
BigNumber.from(flags.maxWorkers),
BigNumber.from(flags.targetWorkers),
utils.formatBytes32String(flags.appCID),
[]
flags.appCID
);

const res = await tx.wait();
Expand Down
Loading

0 comments on commit 2a49316

Please sign in to comment.