Skip to content

Commit

Permalink
Merge branch '2.0' into nova-wasm-explorer-optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
Thoralf-M committed May 8, 2024
2 parents ab3be64 + a62a55d commit 8034edd
Show file tree
Hide file tree
Showing 65 changed files with 871 additions and 372 deletions.
11 changes: 6 additions & 5 deletions .github/actions/private-tangle/setup/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,9 @@ runs:
repository: iotaledger/iota-core
path: iota-core

- name: Prepare files for start and stop
- name: Prepare file for start
shell: bash
run: |
echo "docker compose down -v" >> cleanup.sh
echo "rm *.snapshot" >> cleanup.sh
chmod +x cleanup.sh
# remove the last 5 lines and add docker compose with `-d` to run it in the background
sed -i -n -e :a -e '1,5!{P;N;D;};N;ba' run.sh
echo "docker compose -f docker-compose.yml up -d" >> run.sh
Expand All @@ -27,6 +23,11 @@ runs:
go-version-file: "iota-core/go.mod"
cache: false

- name: Replace port 8084 by 8087 as it's already used by Mono
shell: bash
run: sed -i 's#8084#8087#g' docker-compose.yml
working-directory: iota-core/tools/docker-network

- name: Setup private tangle
shell: bash
# setup-go sets the PATH for the correct version, but sudo uses a different PATH by default
Expand Down
6 changes: 3 additions & 3 deletions .github/actions/private-tangle/tear-down/action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: 'private-tangle-tear-down'
description: 'tear-down a private tangle'
name: "private-tangle-tear-down"
description: "tear-down a private tangle"
runs:
using: "composite"
steps:
- name: Tear down private tangle
shell: bash
run: |
sudo ./cleanup.sh
sudo docker compose down -v
working-directory: iota-core/tools/docker-network
12 changes: 6 additions & 6 deletions Cargo.lock

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

8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

The IOTA SDK is a Rust-based project that provides a convenient and efficient way to interact with nodes in the
Shimmer and IOTA networks running
the [Stardust protocol](https://wiki.iota.org/shimmer/develop/explanations/what-is-stardust). It consists of two main
the [IOTA 2.0 protocol](https://wiki.iota.org/learn/protocols/iota2.0/introduction-to-digital-autonomy/). It consists of two main
modules: `client` and `wallet`.

## Table of Contents

- [Requirements](#requirements)
- [Dependencies](#dependencies)
- [Dependencies](#dependencies)
- [Getting Started](#getting-started)
- [Install the IOTA SDK](#install-the-iota-sdk)
- [Install the IOTA SDK](#install-the-iota-sdk)
- [Client](#client-usage)
- [Wallet](#wallet-usage)
- [Examples](#examples)
Expand Down Expand Up @@ -41,7 +41,7 @@ modules: `client` and `wallet`.
This library follows the following branching strategy:

| Branch | Description |
|--------------|--------------------------------------------------------------------------------------------------------------------------------|
| ------------ | ------------------------------------------------------------------------------------------------------------------------------ |
| `develop` | Ongoing development for future releases of the staging networks. This branch gets merged into `staging` on release. |
| `production` | The latest releases for the IOTA network. |
| `staging` | The latest releases for the Shimmer network. |
Expand Down
2 changes: 1 addition & 1 deletion bindings/core/src/method/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ pub enum ClientMethod {
/// epoch - 1 is also used as the last epoch for which rewards are fetched. Callers that do not build
/// transactions with the returned values may omit this value in which case it defaults to the latest committed
/// slot, which is good enough to, e.g. display estimated rewards to users.
slot_index: Option<SlotIndex>,
slot: Option<SlotIndex>,
},
/// Returns information of all registered validators and if they are active, ordered by their holding stake.
#[serde(rename_all = "camelCase")]
Expand Down
10 changes: 7 additions & 3 deletions bindings/core/src/method/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ pub enum WalletMethod {
/// Expected response: [`Transaction`](crate::Response::Transaction)
#[serde(rename_all = "camelCase")]
GetIncomingTransaction { transaction_id: TransactionId },
/// Get the [`OutputData`](iota_sdk::wallet::types::OutputData) of an output stored in the wallet.
/// Expected response: [`OutputData`](crate::Response::OutputData)
/// Get the [`OutputData`](iota_sdk::wallet::types::OutputData) of an output stored
/// in the wallet. Expected response: [`OutputData`](crate::Response::OutputData)
#[serde(rename_all = "camelCase")]
GetOutput { output_id: OutputId },
// /// Expected response: [`ParticipationEvent`](crate::Response::ParticipationEvent)
Expand Down Expand Up @@ -229,7 +229,11 @@ pub enum WalletMethod {
/// Claim outputs.
/// Expected response: [`PreparedTransaction`](crate::Response::PreparedTransaction)
#[serde(rename_all = "camelCase")]
PrepareClaimOutputs { output_ids_to_claim: Vec<OutputId> },
PrepareClaimOutputs {
output_ids_to_claim: Vec<OutputId>,
#[serde(default)]
options: Option<TransactionOptions>,
},
/// Consolidate outputs.
/// Expected response: [`PreparedTransaction`](crate::Response::PreparedTransaction)
PrepareConsolidateOutputs { params: ConsolidationParams },
Expand Down
4 changes: 2 additions & 2 deletions bindings/core/src/method_handler/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,8 @@ pub(crate) async fn call_client_method_internal(
ClientMethod::GetAccountCongestion { account_id, work_score } => {
Response::Congestion(client.get_account_congestion(&account_id, work_score).await?)
}
ClientMethod::GetOutputManaRewards { output_id, slot_index } => {
Response::ManaRewards(client.get_output_mana_rewards(&output_id, slot_index).await?)
ClientMethod::GetOutputManaRewards { output_id, slot } => {
Response::ManaRewards(client.get_output_mana_rewards(&output_id, slot).await?)
}
ClientMethod::GetValidators { page_size, cursor } => {
Response::Validators(client.get_validators(page_size, cursor).await?)
Expand Down
7 changes: 5 additions & 2 deletions bindings/core/src/method_handler/wallet.rs
Original file line number Diff line number Diff line change
Expand Up @@ -234,8 +234,11 @@ pub(crate) async fn call_wallet_method_internal(
let data = wallet.prepare_burn(burn, options).await?;
Response::PreparedTransaction(data)
}
WalletMethod::PrepareClaimOutputs { output_ids_to_claim } => {
let data = wallet.prepare_claim_outputs(output_ids_to_claim).await?;
WalletMethod::PrepareClaimOutputs {
output_ids_to_claim,
options,
} => {
let data = wallet.prepare_claim_outputs(output_ids_to_claim, options).await?;
Response::PreparedTransaction(data)
}
WalletMethod::PrepareConsolidateOutputs { params } => {
Expand Down
19 changes: 19 additions & 0 deletions bindings/nodejs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Security -->

## 2.0.0-beta.1 - 2024-05-08

### Fixed

- `Client::getOutputManaRewards()` slot query parameter;
- Allow custom allotment of account bound mana;

## 2.0.0-alpha.9 - 2024-05-02

### Added

- `Wallet::prepareClaimOutputs()` optional transactionOptions parameter;

## 2.0.0-alpha.8 - 2024-04-22

### Fixed

- `Wallet::restoreFromStrongholdSnapshot()` with same source and target path;

## 2.0.0-alpha.7 - 2024-04-19

### Fixed
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -75,10 +75,10 @@ calling [`Client.getNodeInfo()`](https://wiki.iota.org/shimmer/iota-sdk/referenc
and then print the node's information.

```javascript
const { Client, initLogger } = require('@iota/sdk');
import { Client } from '@iota/sdk';

// In this example we will get information about the node
async function run() {
initLogger();

const client = await Client.create({
nodes: ['https://api.testnet.shimmer.network'],
Expand Down
12 changes: 5 additions & 7 deletions bindings/nodejs/examples/how_tos/wallet/consolidate-outputs.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// Copyright 2023 IOTA Stiftung
// SPDX-License-Identifier: Apache-2.0

import { CommonOutput, Utils, Wallet, initLogger } from '@iota/sdk';
import { CommonOutput, Wallet, initLogger } from '@iota/sdk';

// This example uses secrets in environment variables for simplicity which should not be done in production.
require('dotenv').config({ path: '.env' });
Expand Down Expand Up @@ -46,11 +46,10 @@ async function run() {
const outputs = await wallet.unspentOutputs();
console.log('Outputs BEFORE consolidation:');

outputs.forEach(({ output, address }, i) => {
outputs.forEach(({ output }, i) => {
console.log(`OUTPUT #${i}`);
console.log(
'- address: %s\n- amount: %d\n- native token: %s',
Utils.addressToBech32(address, 'rms'),
'- amount: %d\n- native token: %s',
output.getAmount(),
output instanceof CommonOutput
? (output as CommonOutput).getNativeToken() ?? []
Expand Down Expand Up @@ -80,11 +79,10 @@ async function run() {

// Outputs after consolidation
console.log('Outputs AFTER consolidation:');
outputs.forEach(({ output, address }, i) => {
outputs.forEach(({ output }, i) => {
console.log(`OUTPUT #${i}`);
console.log(
'- address: %s\n- amount: %d\n- native tokens: %s',
Utils.addressToBech32(address, 'rms'),
'- amount: %d\n- native tokens: %s',
output.getAmount(),
output instanceof CommonOutput
? (output as CommonOutput).getNativeToken()
Expand Down
6 changes: 3 additions & 3 deletions bindings/nodejs/examples/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1329,9 +1329,9 @@ [email protected], hash.js@^1.0.0, hash.js@^1.0.3, hash.js@^1.1.7:
minimalistic-assert "^1.0.1"

hasown@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.0.tgz#f4c513d454a57b7c7e1650778de226b11700546c"
integrity sha512-vUptKVTpIJhcczKBbgnS+RtcuYMB8+oNzPK2/Hp3hanz8JmpATdmmgLgSaadVREkDm+e2giHwY3ZRkyjSIDDFA==
version "2.0.1"
resolved "https://registry.yarnpkg.com/hasown/-/hasown-2.0.1.tgz#26f48f039de2c0f8d3356c223fb8d50253519faa"
integrity sha512-1/th4MHjnwncwXsIW6QMzlvYL9kG5e/CpVvLRZe4XPa8TOUNbCELqmvhDmnkNsAjwaG4+I8gJJL0JBvTTLO9qA==
dependencies:
function-bind "^1.1.2"

Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/lib/client/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -198,13 +198,13 @@ export class Client {
*/
async getOutputManaRewards(
outputId: OutputId,
slotIndex?: SlotIndex,
slot?: SlotIndex,
): Promise<ManaRewardsResponse> {
const response = await this.methodHandler.callMethod({
name: 'getOutputManaRewards',
data: {
outputId,
slotIndex,
slot,
},
});

Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/lib/types/client/bridge/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export interface __GetOutputManaRewardsMethod__ {
name: 'getOutputManaRewards';
data: {
outputId: OutputId;
slotIndex?: SlotIndex;
slot?: SlotIndex;
};
}

Expand Down
1 change: 1 addition & 0 deletions bindings/nodejs/lib/types/wallet/bridge/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,6 +153,7 @@ export type __PrepareClaimOutputsMethod__ = {
name: 'prepareClaimOutputs';
data: {
outputIdsToClaim: OutputId[];
options?: TransactionOptions;
};
};

Expand Down
28 changes: 11 additions & 17 deletions bindings/nodejs/lib/types/wallet/output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
// SPDX-License-Identifier: Apache-2.0

import { Type } from 'class-transformer';
import { Address, AddressDiscriminator } from '../block/address';
import { Output, OutputDiscriminator, OutputId } from '../block/output';
import { OutputMetadataResponse } from '../models/api';
import { OutputIdProof, OutputMetadataResponse } from '../models/api';

/** Output to claim */
export enum OutputsToClaim {
Expand All @@ -15,28 +14,23 @@ export enum OutputsToClaim {
All = 'All',
}

/** An output with metadata */
/** An output with additional data */
export class OutputData {
/** The identifier of an Output */
outputId!: OutputId;
/** The metadata of the output */
metadata!: OutputMetadataResponse;
/** The actual Output */
/** The output itself */
@Type(() => Output, {
discriminator: OutputDiscriminator,
})
output!: Output;
/** Associated account address */
@Type(() => Address, {
discriminator: AddressDiscriminator,
})
address!: Address;
/** Network ID */
/** The metadata of the output */
metadata!: OutputMetadataResponse;
/** The output ID proof */
OutputIdProof!: OutputIdProof;
/** The corresponding output ID */
outputId!: OutputId;
/** The network ID the output belongs to */
networkId!: string;
/** Remainder */
/** Whether the output represents a remainder amount */
remainder!: boolean;
/** BIP32 path */
chain?: Segment[];
}

/** A Segment of the BIP32 path*/
Expand Down
7 changes: 6 additions & 1 deletion bindings/nodejs/lib/wallet/wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -419,8 +419,11 @@ export class Wallet {
*/
async claimOutputs(
outputIds: OutputId[],
transactionOptions?: TransactionOptions,
): Promise<TransactionWithMetadata> {
return (await this.prepareClaimOutputs(outputIds)).send();
return (
await this.prepareClaimOutputs(outputIds, transactionOptions)
).send();
}

/**
Expand All @@ -431,11 +434,13 @@ export class Wallet {
*/
async prepareClaimOutputs(
outputIds: OutputId[],
transactionOptions?: TransactionOptions,
): Promise<PreparedTransaction> {
const response = await this.methodHandler.callMethod({
name: 'prepareClaimOutputs',
data: {
outputIdsToClaim: outputIds,
options: transactionOptions,
},
});
const parsed = JSON.parse(
Expand Down
2 changes: 1 addition & 1 deletion bindings/nodejs/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@iota/sdk",
"version": "2.0.0-alpha.7",
"version": "2.0.0-beta.1",
"description": "Node.js binding to the IOTA SDK library",
"main": "out/index.js",
"types": "out/index.d.ts",
Expand Down
Loading

0 comments on commit 8034edd

Please sign in to comment.