Skip to content

Commit 0579eb8

Browse files
committed
fixes
1 parent c89c107 commit 0579eb8

4 files changed

Lines changed: 77 additions & 20 deletions

File tree

‎docs/sdk-and-tools/sdk-js/cookbook/fetching-data-from-network/reference.mdx‎

Lines changed: 58 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -16,23 +16,27 @@ tags:
1616
### Fetching the network config
1717

1818
```js
19+
import { DevnetEntrypoint } from "@multiversx/sdk-core";
20+
1921
{
2022
const entrypoint = new DevnetEntrypoint();
2123
const networkProvider = entrypoint.createNetworkProvider();
2224

23-
const networkConfig = networkProvider.getNetworkConfig();
25+
const networkConfig = await networkProvider.getNetworkConfig();
2426
}
2527
```
2628

2729
### Fetching the network status
2830

2931
```js
32+
import { DevnetEntrypoint } from "@multiversx/sdk-core";
33+
3034
{
3135
const entrypoint = new DevnetEntrypoint();
3236
const networkProvider = entrypoint.createNetworkProvider();
3337

34-
const metaNetworkStatus = networkProvider.getNetworkStatus(); // fetches status from metachain
35-
const networkStatus = networkProvider.getNetworkStatus(); // fetches status from shard one
38+
const metaNetworkStatus = await networkProvider.getNetworkStatus(); // fetches status from metachain
39+
const shardOneNetworkStatus = await networkProvider.getNetworkStatus(1); // fetches status from shard one
3640
}
3741
```
3842

@@ -43,6 +47,8 @@ When using the **PROXY**, keep in mind that the shard must also be specified in
4347

4448
#### Fetching a block using the **API**
4549
```js
50+
import { ApiNetworkProvider } from "@multiversx/sdk-core";
51+
4652
{
4753
const api = new ApiNetworkProvider("https://devnet-api.multiversx.com");
4854
const blockHash = "1147e111ce8dd860ae43a0f0d403da193a940bfd30b7d7f600701dd5e02f347a";
@@ -53,6 +59,8 @@ When using the **PROXY**, keep in mind that the shard must also be specified in
5359
Additionally, we can fetch the latest block from the network:
5460

5561
```js
62+
import { ApiNetworkProvider } from "@multiversx/sdk-core";
63+
5664
{
5765
const api = new ApiNetworkProvider("https://devnet-api.multiversx.com");
5866
const latestBlock = await api.getLatestBlock();
@@ -63,27 +71,33 @@ Additionally, we can fetch the latest block from the network:
6371

6472
When using the proxy, we have to provide the shard, as well.
6573
```js
74+
import { ProxyNetworkProvider } from "@multiversx/sdk-core";
75+
6676
{
67-
const proxy = new ProxyNetworkProvider("https://devnet-api.multiversx.com");
77+
const proxy = new ProxyNetworkProvider("https://devnet-gateway.multiversx.com");
6878
const blockHash = "1147e111ce8dd860ae43a0f0d403da193a940bfd30b7d7f600701dd5e02f347a";
69-
const block = proxy.getBlock({ blockHash, shard: 1 });
79+
const block = await proxy.getBlock({ blockHash, shard: 1 });
7080
}
7181
```
7282

7383
We can also fetch the latest block from the network.
7484
By default, the shard will be the metachain, but we can specify a different shard if needed.
7585

7686
```js
87+
import { ProxyNetworkProvider } from "@multiversx/sdk-core";
88+
7789
{
78-
const proxy = new ProxyNetworkProvider("https://devnet-api.multiversx.com");
79-
const latestBlock = proxy.getLatestBlock();
90+
const proxy = new ProxyNetworkProvider("https://devnet-gateway.multiversx.com");
91+
const latestBlock = await proxy.getLatestBlock();
8092
}
8193
```
8294

8395
### Fetching an Account
8496
To fetch an account, we need its address. Once we have the address, we create an `Address` object and pass it as an argument to the method.
8597

8698
```js
99+
import { Address, DevnetEntrypoint } from "@multiversx/sdk-core";
100+
87101
{
88102
const entrypoint = new DevnetEntrypoint();
89103
const api = entrypoint.createNetworkProvider();
@@ -96,6 +110,8 @@ To fetch an account, we need its address. Once we have the address, we create an
96110
We can also fetch an account's storage, allowing us to retrieve all key-value pairs saved for that account.
97111

98112
```js
113+
import { Address, DevnetEntrypoint } from "@multiversx/sdk-core";
114+
99115
{
100116
const entrypoint = new DevnetEntrypoint();
101117
const api = entrypoint.createNetworkProvider();
@@ -107,6 +123,8 @@ We can also fetch an account's storage, allowing us to retrieve all key-value pa
107123
If we only want to fetch a specific key, we can do so as follows:
108124

109125
```js
126+
import { Address, DevnetEntrypoint } from "@multiversx/sdk-core";
127+
110128
{
111129
const entrypoint = new DevnetEntrypoint();
112130
const api = entrypoint.createNetworkProvider();
@@ -124,11 +142,13 @@ To implement this, we need to define the condition to check each time the accoun
124142
Keep in mind that this method has a default timeout, which can be adjusted using the `AwaitingOptions` class.
125143

126144
```js
145+
import { Address, DevnetEntrypoint } from "@multiversx/sdk-core";
146+
127147
{
128148
const entrypoint = new DevnetEntrypoint();
129149
const api = entrypoint.createNetworkProvider();
130150

131-
const condition = (account: any) => {
151+
const condition = (account) => {
132152
return account.balance >= 7000000000000000000n; // 7 EGLD
133153
};
134154
const alice = Address.newFromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th");
@@ -142,6 +162,8 @@ To execute transactions, we use the network providers to broadcast them to the n
142162
#### Sending a Transaction
143163

144164
```js
165+
import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core";
166+
145167
{
146168
const entrypoint = new DevnetEntrypoint();
147169
const api = entrypoint.createNetworkProvider();
@@ -164,6 +186,8 @@ To execute transactions, we use the network providers to broadcast them to the n
164186

165187
#### Sending multiple transactions
166188
```js
189+
import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core";
190+
167191
{
168192
const entrypoint = new DevnetEntrypoint();
169193
const api = entrypoint.createNetworkProvider();
@@ -210,6 +234,8 @@ To execute transactions, we use the network providers to broadcast them to the n
210234
A transaction can be simulated before being sent for processing by the network. This is primarily used for smart contract calls, allowing you to preview the results produced by the smart contract.
211235

212236
```js
237+
import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core";
238+
213239
{
214240
const entrypoint = new DevnetEntrypoint();
215241
const api = entrypoint.createNetworkProvider();
@@ -233,6 +259,8 @@ A transaction can be simulated before being sent for processing by the network.
233259
Before sending a transaction to the network for processing, you can retrieve the estimated gas limit required for the transaction to be executed.
234260

235261
```js
262+
import { Address, DevnetEntrypoint, Transaction } from "@multiversx/sdk-core";
263+
236264
{
237265
const entrypoint = new DevnetEntrypoint();
238266
const api = entrypoint.createNetworkProvider();
@@ -259,6 +287,8 @@ Before sending a transaction to the network for processing, you can retrieve the
259287
After sending a transaction, you may want to wait until it is processed before proceeding with another action. Keep in mind that this method has a default timeout, which can be adjusted using the `AwaitingOptions` class.
260288

261289
```js
290+
import { DevnetEntrypoint } from "@multiversx/sdk-core";
291+
262292
{
263293
const entrypoint = new DevnetEntrypoint();
264294
const api = entrypoint.createNetworkProvider();
@@ -272,11 +302,13 @@ After sending a transaction, you may want to wait until it is processed before p
272302
Similar to accounts, we can wait until a transaction meets a specific condition.
273303

274304
```js
305+
import { DevnetEntrypoint } from "@multiversx/sdk-core";
306+
275307
{
276308
const entrypoint = new DevnetEntrypoint();
277309
const api = entrypoint.createNetworkProvider();
278310

279-
const condition = (txOnNetwork: any) => !txOnNetwork.status.isSuccessful();
311+
const condition = (txOnNetwork) => txOnNetwork.status.isSuccessful();
280312

281313
const txHash = "exampletransactionhash";
282314
const transactionOnNetwork = await api.awaitTransactionOnCondition(txHash, condition);
@@ -287,6 +319,8 @@ Similar to accounts, we can wait until a transaction meets a specific condition.
287319
After sending a transaction, you may want to wait until it is processed before proceeding with another action. Keep in mind that this method has a default timeout, which can be adjusted using the `AwaitingOptions` class.
288320

289321
```js
322+
import { DevnetEntrypoint } from "@multiversx/sdk-core";
323+
290324
{
291325
const entrypoint = new DevnetEntrypoint();
292326
const api = entrypoint.createNetworkProvider();
@@ -300,6 +334,8 @@ After sending a transaction, you may want to wait until it is processed before p
300334
After sending a transaction, we can fetch it from the network using the transaction hash, which we receive after broadcasting the transaction.
301335

302336
```js
337+
import { DevnetEntrypoint } from "@multiversx/sdk-core";
338+
303339
{
304340
const entrypoint = new DevnetEntrypoint();
305341
const api = entrypoint.createNetworkProvider();
@@ -313,6 +349,8 @@ After sending a transaction, we can fetch it from the network using the transact
313349
We can fetch a specific token (ESDT, MetaESDT, SFT, NFT) from an account by providing the account's address and the token identifier.
314350

315351
```js
352+
import { Address, DevnetEntrypoint, Token } from "@multiversx/sdk-core";
353+
316354
{
317355
const entrypoint = new DevnetEntrypoint();
318356
const api = entrypoint.createNetworkProvider();
@@ -330,6 +368,8 @@ We can fetch a specific token (ESDT, MetaESDT, SFT, NFT) from an account by prov
330368
Fetches all fungible tokens held by an account. Note that this method does not handle pagination, but it can be achieved using `doGetGeneric`.
331369

332370
```js
371+
import { Address, DevnetEntrypoint } from "@multiversx/sdk-core";
372+
333373
{
334374
const entrypoint = new DevnetEntrypoint();
335375
const api = entrypoint.createNetworkProvider();
@@ -343,6 +383,8 @@ Fetches all fungible tokens held by an account. Note that this method does not h
343383
Fetches all non-fungible tokens held by an account. Note that this method does not handle pagination, but it can be achieved using `doGetGeneric`.
344384

345385
```js
386+
import { Address, DevnetEntrypoint } from "@multiversx/sdk-core";
387+
346388
{
347389
const entrypoint = new DevnetEntrypoint();
348390
const api = entrypoint.createNetworkProvider();
@@ -356,6 +398,8 @@ Fetches all non-fungible tokens held by an account. Note that this method does n
356398
If we want to fetch the metadata of a token (e.g., owner, decimals, etc.), we can use the following methods:
357399

358400
```js
401+
import { DevnetEntrypoint } from "@multiversx/sdk-core";
402+
359403
{
360404
const entrypoint = new DevnetEntrypoint();
361405
const api = entrypoint.createNetworkProvider();
@@ -372,6 +416,8 @@ If we want to fetch the metadata of a token (e.g., owner, decimals, etc.), we ca
372416
Smart contract queries, or view functions, are endpoints that only read data from the contract. To send a query to the observer nodes, we can proceed as follows:
373417

374418
```js
419+
import { Address, DevnetEntrypoint, SmartContractQuery } from "@multiversx/sdk-core";
420+
375421
{
376422
const entrypoint = new DevnetEntrypoint();
377423
const api = entrypoint.createNetworkProvider();
@@ -390,14 +436,15 @@ The methods exposed by the `ApiNetworkProvider` or `ProxyNetworkProvider` are th
390436
Let’s assume we want to retrieve all the transactions sent by Alice in which the `delegate` function was called.
391437

392438
```js
439+
import { Address, DevnetEntrypoint } from "@multiversx/sdk-core";
440+
393441
{
394442
const entrypoint = new DevnetEntrypoint();
395443
const api = entrypoint.createNetworkProvider();
396444

397445
const alice = Address.newFromBech32("erd1qyu5wthldzr8wx5c9ucg8kjagg0jfs53s8nr3zpz3hypefsdd8ssycr6th");
398-
const url = `transactions/${alice.toBech32()}?function=delegate`;
446+
const url = `accounts/${alice.toBech32()}/transactions?function=delegate`;
399447

400448
const response = await api.doGetGeneric(url);
401449
}
402450
```
403-

‎docs/sdk-and-tools/sdk-js/cookbook/multisig/deploy-multisig-contract.mdx‎

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,14 @@ These operations can be performed using both the **controller** and the **factor
2424

2525
#### Deploying a Multisig Smart Contract using the controller
2626
```js
27+
import * as fs from 'fs';
28+
import * as path from 'path';
29+
import { Abi, Account, Address, DevnetEntrypoint } from '@multiversx/sdk-core';
30+
2731
{
28-
const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json");
29-
const bytecode = await loadContractCode("src/testdata/multisig-full.wasm");
32+
const abiJson = fs.readFileSync('src/testdata/multisig-full.abi.json', { encoding: 'utf8' });
33+
const abi = Abi.create(JSON.parse(abiJson));
34+
const bytecode = new Uint8Array(fs.readFileSync('src/testdata/multisig-full.wasm'));
3035

3136
// create the entrypoint and the multisig controller
3237
const entrypoint = new DevnetEntrypoint();
@@ -44,7 +49,7 @@ These operations can be performed using both the **controller** and the **factor
4449
alice.address,
4550
Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"),
4651
],
47-
bytecode: bytecode.valueOf(),
52+
bytecode,
4853
gasLimit: 100000000n,
4954
});
5055

@@ -54,15 +59,20 @@ These operations can be performed using both the **controller** and the **factor
5459
// wait for transaction completion, extract multisig contract's address
5560
const outcome = await controller.awaitCompletedDeploy(txHash);
5661

57-
const contractAddress = outcome[0].contractAddress;
62+
const contractAddress = outcome.contracts[0].address;
5863
}
5964
```
6065

6166
#### Deploying a Multisig Smart Contract using the factory
6267
```js
68+
import * as fs from 'fs';
69+
import * as path from 'path';
70+
import { Abi, Account, Address, DevnetEntrypoint } from '@multiversx/sdk-core';
71+
6372
{
64-
const abi = await loadAbiRegistry("src/testdata/multisig-full.abi.json");
65-
const bytecode = await loadContractCode("src/testdata/multisig-full.wasm");
73+
const abiJson = fs.readFileSync('src/testdata/multisig-full.abi.json', { encoding: 'utf8' });
74+
const abi = Abi.create(JSON.parse(abiJson));
75+
const bytecode = new Uint8Array(fs.readFileSync('src/testdata/multisig-full.wasm'));
6676

6777
// create the entrypoint and the multisig factory
6878
const entrypoint = new DevnetEntrypoint();
@@ -80,7 +90,7 @@ These operations can be performed using both the **controller** and the **factor
8090
alice.address,
8191
Address.newFromBech32("erd1spyavw0956vq68xj8y4tenjpq2wd5a9p2c6j8gsz7ztyrnpxrruqzu66jx"),
8292
],
83-
bytecode: bytecode.valueOf(),
93+
bytecode,
8494
gasLimit: 100000000n,
8595
});
8696

‎docs/sdk-and-tools/sdk-js/cookbook/multisig/propose-action.mdx‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -592,5 +592,5 @@ transfer with no function call adds nothing after it. Pass `optGasLimit` /
592592
is what happens to the action id this recipe creates.
593593
- [Read a multisig's state](/sdk-and-tools/sdk-js/cookbook/multisig/read-multisig-state)
594594
checks roles, quorum, and pending actions before proposing.
595-
- [Deploy a smart contract](/sdk-and-tools/sdk-js/cookbook/smart-contracts-deploy/deploy-contract)
595+
- [Deploy a smart contract](/sdk-and-tools/sdk-js/cookbook/multisig/deploy-multisig-contract)
596596
is how the multisig itself, being a contract, gets deployed.

‎package.json‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"write-translations": "docusaurus write-translations",
2424
"write-heading-ids": "docusaurus write-heading-ids",
2525
"generate:llms": "node scripts/generate-llms-txt.js",
26-
"generate:md-urls": "node scripts/generate-md-urls.js",
26+
"generate:md-urls": "node scripts/generate-md-urls.js && node scripts/generate-md-urls.js",
2727
"generate:cookbook": "node scripts/generate-cookbook-manifest.js"
2828
},
2929
"dependencies": {

0 commit comments

Comments
 (0)