Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Chore/bindings: cleanup is alive 2.0 #1541

Merged
merged 73 commits into from
Dec 13, 2023
Merged
Show file tree
Hide file tree
Changes from 68 commits
Commits
Show all changes
73 commits
Select commit Hold shift + click to select a range
2d1a2e3
simplify nodejs client and wallet
Aug 21, 2023
bd97ea3
got -> was
Aug 23, 2023
027b86c
fixed client on node side
Aug 30, 2023
acb57a2
wasm
Aug 31, 2023
f55739f
removed await for client
Aug 31, 2023
18d8c5a
lint n format
Aug 31, 2023
a6f2cea
fixed test and client error return
Aug 31, 2023
e975a52
fixed error and comment
Aug 31, 2023
b7f7941
Simplify nodejs and wasm bindings p. 2 (#1146)
Sep 7, 2023
ec86449
final changes
Sep 7, 2023
aa268a3
removed unused PromiseString
Sep 7, 2023
efadf01
lint
Sep 7, 2023
1f41eb9
wasm update
Oct 30, 2023
019ae71
nodejs
Oct 30, 2023
c9545a2
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Nov 2, 2023
a225a03
removed async closure
Nov 2, 2023
72a5c32
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Nov 10, 2023
3839c32
nodejs fixed with tests
Nov 12, 2023
e4e310c
fmt
Nov 12, 2023
39e4e2f
Merge branch '2.0' into chore/bindings-cleanup-is-alive
thibault-martinez Nov 13, 2023
71f9a05
some fixes
Nov 13, 2023
ccdc3e9
mqtt
Nov 13, 2023
ed24604
Merge branch 'chore/bindings-cleanup-is-alive' of https://github.com/…
Nov 20, 2023
6ce7f94
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Nov 20, 2023
97db51e
rewrite again eh :D
Nov 22, 2023
6291e00
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Nov 22, 2023
45fad99
client.create()
Nov 22, 2023
003dab6
format and fmt
Nov 22, 2023
5cea26c
review and 8050
Nov 23, 2023
0e18ccf
typo
Nov 24, 2023
24a53a2
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Nov 27, 2023
3f91978
updated error handling in nodejs once again
Nov 27, 2023
17ab66b
wasm destroy rename
Nov 27, 2023
1923bc0
Update bindings/nodejs/lib/index.ts
kwek20 Nov 27, 2023
80cd0e0
secret manager create
Nov 27, 2023
fe74d39
Merge branch 'chore/bindings-cleanup-is-alive' of https://github.com/…
Nov 27, 2023
734d1a2
typo grrr
Nov 27, 2023
8cb263f
forgot to rename create methods
Nov 28, 2023
b2d4f53
Done more comment explaining :D
Nov 29, 2023
5c870db
removed mqtt custom serde
Nov 29, 2023
a3a48bc
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Nov 30, 2023
48a4985
wasm fixes
Nov 30, 2023
4e9bb4d
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Nov 30, 2023
682aa3a
fix tests
Nov 30, 2023
bcc0e10
fmt
Nov 30, 2023
4368192
fixed secret
Nov 30, 2023
761dd26
promise await
Nov 30, 2023
3f78b05
fixed errors, separate eslint
Dec 1, 2023
2925828
wasm side
Dec 1, 2023
34dfd32
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 1, 2023
56c6cc1
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 1, 2023
a5998ca
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 1, 2023
6f45ce8
typo
Dec 4, 2023
ab6fb3d
Merge branch 'chore/bindings-cleanup-is-alive' of https://github.com/…
Dec 4, 2023
5b7da91
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 4, 2023
e02cb59
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 4, 2023
7cc4395
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Alex6323 Dec 5, 2023
12f3918
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Thoralf-M Dec 5, 2023
bef024b
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 5, 2023
17a293a
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Alex6323 Dec 6, 2023
e74505a
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Thoralf-M Dec 6, 2023
78c9a24
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 6, 2023
77004df
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Alex6323 Dec 8, 2023
ce63428
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Alex6323 Dec 11, 2023
d518f00
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Alex6323 Dec 11, 2023
bee73a4
Merge branch '2.0' into chore/bindings-cleanup-is-alive
Dec 12, 2023
f08147f
Merge branch '2.0' into chore/bindings-cleanup-is-alive
thibault-martinez Dec 12, 2023
a0776af
Nit
thibault-martinez Dec 12, 2023
b155e04
Merge branch '2.0' into chore/bindings-cleanup-is-alive
thibault-martinez Dec 12, 2023
5e2be63
removed inner
Dec 12, 2023
0143e3d
Merge branch 'chore/bindings-cleanup-is-alive' of https://github.com/…
Dec 12, 2023
36f92e6
Merge branch '2.0' into chore/bindings-cleanup-is-alive
thibault-martinez Dec 12, 2023
ba5142a
Merge branch '2.0' into chore/bindings-cleanup-is-alive
thibault-martinez Dec 12, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions bindings/core/tests/combined.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async fn create_wallet() -> Result<()> {
let client_options = r#"{
"nodes":[
{
"url":"http://localhost:14265",
"url":"http://localhost:8050",
"auth":null,
"disabled":false
}
Expand Down Expand Up @@ -70,7 +70,7 @@ async fn client_from_wallet() -> Result<()> {
let client_options = r#"{
"nodes":[
{
"url":"http://localhost:14265",
"url":"http://localhost:8050",
"auth":null,
"disabled":false
}
Expand Down Expand Up @@ -112,7 +112,7 @@ async fn client_from_wallet() -> Result<()> {
// "about solution utility exist rail budget vacuum major survey clerk pave ankle wealth gym gossip still medal
// expect strong rely amazing inspire lazy lunar", ).unwrap();
// let client = ClientBuilder::default()
// .with_nodes(&["http://localhost:14265"])
// .with_nodes(&["http://localhost:8050"])
// .unwrap()
// .finish()
// .await
Expand Down
4 changes: 3 additions & 1 deletion bindings/nodejs/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ target
**/node_modules/
**/out/
**/tests/
**/dist
**/dist
jest.config.js
.eslintrc.js
2 changes: 2 additions & 0 deletions bindings/nodejs/.eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const typescriptEslintRules = {
'@typescript-eslint/no-empty-interface': 'off',
'@typescript-eslint/no-var-requires': 'off', // cleanest way to set dotenv path
'@typescript-eslint/no-explicit-any': 'off',
"@typescript-eslint/no-floating-promises": ["error"],
};

module.exports = {
Expand All @@ -24,6 +25,7 @@ module.exports = {
parserOptions: {
ecmaVersion: 12,
sourceType: 'module',
project: ["./tsconfig.eslint.json"],
},
rules: typescriptEslintRules,
};
4 changes: 2 additions & 2 deletions bindings/nodejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ const { Client, initLogger } = require('@iota/sdk');
async function run() {
initLogger();

const client = new Client({
const client = await Client.create({
nodes: ['https://api.testnet.shimmer.network'],
});

Expand All @@ -102,7 +102,7 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
```

## Wallet Usage
Expand Down
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/04-get-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand All @@ -30,4 +30,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
6 changes: 3 additions & 3 deletions bindings/nodejs/examples/client/05-get-address-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});

try {
const secretManager = new SecretManager({
const secretManager = SecretManager.create({
mnemonic: process.env.MNEMONIC as string,
});

Expand Down Expand Up @@ -75,4 +75,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
6 changes: 3 additions & 3 deletions bindings/nodejs/examples/client/06-simple-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,9 @@ async function run() {
mnemonic: process.env.MNEMONIC,
};

const secretManager = new SecretManager(mnemonicSecretManager);
const secretManager = SecretManager.create(mnemonicSecretManager);

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand Down Expand Up @@ -67,4 +67,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/07-get-block-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand All @@ -38,4 +38,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
6 changes: 3 additions & 3 deletions bindings/nodejs/examples/client/08-data-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ async function run() {
mnemonic: process.env.MNEMONIC,
};

const secretManager = new SecretManager(mnemonicSecretManager);
const secretManager = SecretManager.create(mnemonicSecretManager);

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand Down Expand Up @@ -75,4 +75,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/10-mqtt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async function run() {
}

// Connecting to a MQTT broker using raw ip doesn't work with TCP. This is a limitation of rustls.
const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand Down Expand Up @@ -55,4 +55,4 @@ async function run() {
}, 10000);
}

run();
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/11-build-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand Down Expand Up @@ -121,4 +121,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/12-get-raw-block.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand All @@ -32,4 +32,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/13-build-account-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand Down Expand Up @@ -59,4 +59,4 @@ async function run() {
}
}

run();
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/14-build-foundry-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand Down Expand Up @@ -53,4 +53,4 @@ async function run() {
}
}

run();
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/15-build-nft-output.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand Down Expand Up @@ -68,4 +68,4 @@ async function run() {
}
}

run();
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/16-custom-plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async function run() {
}
}

const client = new Client({
const client = await Client.create({
// Insert your node URL in the .env.
nodes: [process.env.NODE_URL as string],
});
Expand All @@ -41,4 +41,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/client/getting-started.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { Client } from '@iota/sdk';

// In this example we will get information about the node
async function run() {
const client = new Client({
const client = await Client.create({
nodes: ['https://api.testnet.shimmer.network'],
});

Expand All @@ -20,4 +20,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
4 changes: 2 additions & 2 deletions bindings/nodejs/examples/evm/send-evm-transaction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ async function run(): Promise<void> {
mnemonic: process.env.MNEMONIC as string,
};

const secretManager = new SecretManager(mnemonicSecretManager);
const secretManager = SecretManager.create(mnemonicSecretManager);

const addresses = await secretManager.generateEvmAddresses({
coinType: ETHEREUM_COIN_TYPE,
Expand Down Expand Up @@ -170,4 +170,4 @@ function padHexString(str: string): string {
return str.length % 2 !== 0 ? '0' + str : str;
}

run();
void run().then(() => process.exit());
2 changes: 1 addition & 1 deletion bindings/nodejs/examples/exchange/0-generate-mnemonic.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
6 changes: 3 additions & 3 deletions bindings/nodejs/examples/exchange/1-create-wallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ async function run() {
},
};

const secretManager = new SecretManager(strongholdSecretManager);
const secretManager = SecretManager.create(strongholdSecretManager);

// A mnemonic can be generated with `Utils.generateMnemonic()`.
// Store the mnemonic in the Stronghold snapshot, this needs to be done only the first time.
Expand Down Expand Up @@ -65,10 +65,10 @@ async function run() {

// Set syncOnlyMostBasicOutputs to true if not interested in outputs that are timelocked,
// have a storage deposit return, expiration or are nft/account/foundry outputs.
wallet.setDefaultSyncOptions({ syncOnlyMostBasicOutputs: true });
await wallet.setDefaultSyncOptions({ syncOnlyMostBasicOutputs: true });
} catch (error) {
console.error(error);
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
2 changes: 1 addition & 1 deletion bindings/nodejs/examples/exchange/3-check-balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
2 changes: 1 addition & 1 deletion bindings/nodejs/examples/exchange/4-listen-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,4 +57,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
2 changes: 1 addition & 1 deletion bindings/nodejs/examples/exchange/5-send-amount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,4 +51,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
2 changes: 1 addition & 1 deletion bindings/nodejs/examples/how_tos/account_output/create.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,4 +65,4 @@ async function run() {
process.exit(0);
}

run();
void run().then(() => process.exit());
2 changes: 1 addition & 1 deletion bindings/nodejs/examples/how_tos/account_output/destroy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -77,4 +77,4 @@ async function run() {
process.exit(0);
}

run();
void run().then(() => process.exit());
15 changes: 9 additions & 6 deletions bindings/nodejs/examples/how_tos/account_wallet/request-funds.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ async function run() {
const wallet = await Wallet.create({
storagePath: process.env.WALLET_DB_PATH,
});

const balance = await wallet.sync();

const totalBaseTokenBalance = balance.baseCoin.total;
Expand All @@ -39,14 +38,18 @@ async function run() {
const accountId = balance.accounts[0];
console.log(`Account Id: ${accountId}`);

const client = await wallet.getClient();

// Get Account address
const accountAddress = Utils.accountIdToBech32(
accountId,
await (await wallet.getClient()).getBech32Hrp(),
await client.getBech32Hrp(),
);

const faucetResponse = await client.requestFundsFromFaucet(
faucetUrl,
accountAddress,
);
const faucetResponse = await (
await wallet.getClient()
).requestFundsFromFaucet(faucetUrl, accountAddress);
console.log(faucetResponse);

await new Promise((resolve) => setTimeout(resolve, 10000));
Expand All @@ -66,4 +69,4 @@ async function run() {
}
}

run().then(() => process.exit());
void run().then(() => process.exit());
Loading
Loading