diff --git a/Account.html b/Account.html index 8de94d3b..72451dc0 100644 --- a/Account.html +++ b/Account.html @@ -24,7 +24,7 @@
@@ -573,7 +573,7 @@
Returns:

diff --git a/Address.html b/Address.html index 4d9bc13c..e05e87da 100644 --- a/Address.html +++ b/Address.html @@ -24,7 +24,7 @@
@@ -1428,7 +1428,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Asset.html b/Asset.html index 5dde3ed5..09f21b7c 100644 --- a/Asset.html +++ b/Asset.html @@ -24,7 +24,7 @@
@@ -2053,7 +2053,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Claimant.html b/Claimant.html index 61f7ad60..68122c5c 100644 --- a/Claimant.html +++ b/Claimant.html @@ -24,7 +24,7 @@
@@ -1625,7 +1625,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Contract.html b/Contract.html index 127de48b..c2770a72 100644 --- a/Contract.html +++ b/Contract.html @@ -24,7 +24,7 @@
@@ -103,7 +103,7 @@

new Contract<
Source:
@@ -260,7 +260,7 @@

addressSource:
@@ -516,8 +516,8 @@
Returns:
-

Build a InvokeHostFunctionOp operation to call the -contract.

+

an InvokeHostFunctionOp operation to call the +contract with the given method and parameters

@@ -576,7 +576,7 @@

contractId<
Source:
@@ -682,7 +682,7 @@

getFootpr
Source:
@@ -787,7 +787,7 @@

toStringSource:
@@ -864,7 +864,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/ContractSpec.html b/ContractSpec.html index 030b633f..33145672 100644 --- a/ContractSpec.html +++ b/ContractSpec.html @@ -24,7 +24,7 @@
@@ -45,6 +45,9 @@

ContractSpec

+

Provides a ContractSpec class which can contains the XDR types defined by the contract. +This allows the class to be used to convert between native and raw xdr.ScVals.

+ @@ -55,6 +58,8 @@

+

Constructor

+

new ContractSpec(entries)

@@ -99,7 +104,7 @@

new Contr
Source:
@@ -219,6 +224,29 @@

Throws:
+
+
Example
+ +
const specEntries = [...]; // XDR spec entries of a smart contract
+const contractSpec = new ContractSpec(specEntries);
+
+// Convert native value to ScVal
+const args = {
+  arg1: 'value1',
+  arg2: 1234
+};
+const scArgs = contractSpec.funcArgsToScVals('funcName', args);
+
+// Call contract
+const resultScv = await callContract(contractId, 'funcName', scArgs);
+
+// Convert result ScVal back to native value
+const result = contractSpec.funcResToNative('funcName', resultScv);
+
+console.log(result); // {success: true}
+ +
+

@@ -287,7 +315,7 @@

findEntrySource:
@@ -479,7 +507,7 @@

funcA
Source:
@@ -710,7 +738,7 @@

funcRe
Source:
@@ -941,7 +969,7 @@

getFuncSource:
@@ -1133,7 +1161,7 @@

nativeTo
Source:
@@ -1371,7 +1399,7 @@

scVal
Source:
@@ -1589,7 +1617,7 @@

scValToN
Source:
@@ -1776,7 +1804,7 @@

Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/FeeBumpTransaction.html b/FeeBumpTransaction.html index 2cae4c77..6d58137c 100644 --- a/FeeBumpTransaction.html +++ b/FeeBumpTransaction.html @@ -24,7 +24,7 @@
@@ -2040,7 +2040,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Int128_Int128.html b/Int128_Int128.html index 179da2a2..7306e011 100644 --- a/Int128_Int128.html +++ b/Int128_Int128.html @@ -24,7 +24,7 @@
@@ -230,7 +230,7 @@
Parameters:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Int256_Int256.html b/Int256_Int256.html index 23182653..0bfcffbc 100644 --- a/Int256_Int256.html +++ b/Int256_Int256.html @@ -24,7 +24,7 @@
@@ -230,7 +230,7 @@
Parameters:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Keypair.html b/Keypair.html index 3786c4f4..8b68f960 100644 --- a/Keypair.html +++ b/Keypair.html @@ -24,7 +24,7 @@
@@ -2462,7 +2462,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/LiquidityPoolAsset.html b/LiquidityPoolAsset.html index 73e7b8f4..0f7602ab 100644 --- a/LiquidityPoolAsset.html +++ b/LiquidityPoolAsset.html @@ -24,7 +24,7 @@
@@ -919,7 +919,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/LiquidityPoolId.html b/LiquidityPoolId.html index 24d249d0..8977d653 100644 --- a/LiquidityPoolId.html +++ b/LiquidityPoolId.html @@ -24,7 +24,7 @@
@@ -867,7 +867,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Memo.html b/Memo.html index 223af916..c164d1f4 100644 --- a/Memo.html +++ b/Memo.html @@ -24,7 +24,7 @@
@@ -1386,7 +1386,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/MuxedAccount.html b/MuxedAccount.html index 0c1bfb84..c69b68dd 100644 --- a/MuxedAccount.html +++ b/MuxedAccount.html @@ -24,7 +24,7 @@
@@ -985,7 +985,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Operation.html b/Operation.html index f29435a8..00413ecb 100644 --- a/Operation.html +++ b/Operation.html @@ -24,7 +24,7 @@
@@ -12124,7 +12124,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/ScInt.html b/ScInt.html index 5ca31389..45555a22 100644 --- a/ScInt.html +++ b/ScInt.html @@ -24,7 +24,7 @@
@@ -486,7 +486,7 @@

Classes


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Server.html b/Server.html index c3c63825..52bbbf1b 100644 --- a/Server.html +++ b/Server.html @@ -24,7 +24,7 @@
@@ -45,6 +45,9 @@

Server

+

Handles the network connection to a Soroban RPC instance, exposing an +interface for requests to that instance.

+ @@ -55,15 +58,17 @@

+

Constructor

+ -

new Server()

+

new Server(serverURL, optsopt)

-

Soroban-RPC Server URL (ex. http://localhost:8000/soroban/rpc).

+

Soroban RPC Server URL (ex. http://localhost:8000/soroban/rpc).

@@ -99,13 +104,20 @@

new ServerSource:
+
See:
+
+ +
+ @@ -118,6 +130,206 @@

new ServerParameters:

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
serverURL + + +string + + + + + + + + + + +

Soroban-RPC Server URL (ex. +http://localhost:8000/soroban/rpc).

+ +
opts + + +object + + + + + + <optional>
+ + + + + +
+

Options object

+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeAttributesDescription
allowHttp + + +boolean + + + + + + <optional>
+ + + + + +
+

allows connecting to insecure http servers +(default: false). This must be set to false in production deployments! +You can also use Config class to set this globally.

+ +
headers + + +Record.<string, string> + + + + + + <optional>
+ + + + + +
+

allows setting custom headers

+ +
+ + +
+ + @@ -202,13 +414,20 @@

(async) get
Source:
+
See:
+
+ +
+ @@ -304,7 +523,8 @@

Returns:
-

Returns a promise to the Account object with populated sequence number.

+

a promise to the Account object with +a populated sequence number

@@ -315,7 +535,8 @@
Returns:
Example
-
server.getAccount("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4").then(account => {
+    
const accountId = "GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4";
+server.getAccount(accountId).then((account) => {
   console.log("sequence:", account.sequence);
 });
@@ -336,6 +557,9 @@

(async)

Reads the current value of contract data ledger entries directly.

+

Allows you to directly inspect the current state of a contract. This is a +backup way to access your contract data which may not be available via +events or Server.simulateTransaction.

@@ -371,13 +595,20 @@

(async) Source:
+
See:
+
+ +
+ @@ -407,6 +638,8 @@
Parameters:
+ Default + Description @@ -446,12 +679,15 @@
Parameters:
+ + + + -

The contract ID containing the -data to load. Encoded as Stellar Contract Address string (e.g. -CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5), a -Contract, or an Address instance.

+

the contract ID containing the +data to load as a strkey (C... form), a Contract, or an +Address instance

@@ -483,9 +719,13 @@
Parameters:
+ + + + -

The key of the contract data to load.

+

the key of the contract data to load

@@ -500,7 +740,7 @@
Parameters:
-Durability +Durability @@ -519,11 +759,17 @@
Parameters:
+ + + Durability.Persistent + + + -

The "durability keyspace" that this -ledger key belongs to, which is either 'temporary' or 'persistent' (the -default), see Durability.

+

the "durability +keyspace" that this ledger key belongs to, which is either 'temporary' +or 'persistent' (the default), see Durability.

@@ -564,8 +810,7 @@
Returns:
-

Returns a promise to the -SorobanRpc.LedgerEntryResult object with the current value.

+

the current data value

@@ -582,11 +827,7 @@
Example
console.log("value:", data.xdr); console.log("lastModified:", data.lastModifiedLedgerSeq); console.log("latestLedger:", data.latestLedger); -}); - -Allows you to directly inspect the current state of a contract. This is a -backup way to access your contract data which may not be available via -events or simulateTransaction.
+});

@@ -597,14 +838,14 @@

Example
-

(async) getEvents() → {Promise.<SorobanRpc.GetEventsResponse>}

+

(async) getEvents(request) → {Promise.<SorobanRpc.GetEventsResponse>}

-

Fetches all events that match a given set of filters.

+

Fetch all events that match a given set of filters.

The given filters (see SorobanRpc.EventFilter for detailed fields) are combined only in a logical OR fashion, and all of the fields in each filter are optional.

@@ -645,13 +886,20 @@

(async) getE
Source:
+
See:
+
+ +
+ @@ -664,6 +912,58 @@

(async) getE +

Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
request + + +Server.GetEventsRequest + + + + +

event filters

+ +
+ + @@ -695,9 +995,8 @@
Returns:
-

a promise to the -SorobanRpc.GetEventsResponse object containing a paginatable set -of the events matching the given event filters.

+

a paginatable set of the +events matching the given event filters

@@ -782,13 +1081,20 @@

(async) getH
Source:
+
See:
+
+ +
+ @@ -832,7 +1138,9 @@

Returns:
-

Returns a promise to the SorobanRpc.GetHealthResponse object with the status of the server ("healthy").

+

a promise to the +SorobanRpc.GetHealthResponse object with the status of the +server (e.g. "healthy").

@@ -843,7 +1151,7 @@
Returns:
Example
-
server.getHealth().then(health => {
+    
server.getHealth().then((health) => {
   console.log("status:", health.status);
 });
@@ -863,7 +1171,8 @@

(async) -

Fetches the latest ledger meta info from network which Soroban-RPC is connected to.

+

Fetch the latest ledger meta info from network which this Soroban RPC +server is connected to.

@@ -899,13 +1208,20 @@

(async) Source:
+
See:
+
+ +
+ @@ -949,9 +1265,8 @@
Returns:
-

a promise to the -SorobanRpc.GetLatestLedgerResponse object containing metadata -about the latest ledger from network soroban-rpc server is connected to.

+

metadata about the +latest ledger on the network that this RPC server is connected to

@@ -962,7 +1277,7 @@
Returns:
Example
-
server.getLatestLedger().then(response => {
+    
server.getLatestLedger().then((response) => {
   console.log("hash:", response.id);
   console.log("sequence:", response.sequence);
   console.log("protocolVersion:", response.protocolVersion);
@@ -977,18 +1292,19 @@ 
Example
-

(async) getLedgerEntries(keys) → {Promise.<SorobanRpc.GetLedgerEntriesResponse>}

+

(async) getLedgerEntries(…keys) → {Promise.<SorobanRpc.GetLedgerEntriesResponse>}

-

Reads the current value of ledger entries directly.

+

Reads the current value of arbitrary ledger entries directly.

Allows you to directly inspect the current state of contracts, contract's -code, or any other ledger entries. This is a backup way to access your -contract data which may not be available via events or simulateTransaction.

-

To fetch contract wasm byte-code, use the ContractCode ledger entry key.

+code, accounts, or any other ledger entries.

+

To fetch a contract's WASM byte-code, built the appropriate +xdr.LedgerKeyContractCode ledger entry key (or see +Contract.getFootprint).

@@ -1024,13 +1340,20 @@

(async) Source:
+
See:
+
+ +
+ @@ -1056,6 +1379,8 @@
Parameters:
Type + Attributes + @@ -1081,11 +1406,21 @@
Parameters:
+ + + + + + + <repeatable>
+ + + -

The ledger entry keys to load.

+

one or more ledger entry keys to load

@@ -1126,9 +1461,8 @@
Returns:
-

Returns a promise -to the SorobanRpc.GetLedgerEntriesResponse object with the -current value.

+

the current +on-chain values for the given ledger keys

@@ -1144,6 +1478,7 @@
Example
contractId: StrKey.decodeContract(contractId), key: xdr.ScVal.scvSymbol("counter"), })); + server.getLedgerEntries([key]).then(response => { const ledgerData = response.entries[0]; console.log("key:", ledgerData.key); @@ -1168,7 +1503,7 @@

(async) get
-

Fetches metadata about the network which Soroban-RPC is connected to.

+

Fetch metadata about the network this Soroban RPC server is connected to.

@@ -1204,13 +1539,20 @@

(async) get
Source:
+
See:
+
+ +
+ @@ -1254,9 +1596,8 @@

Returns:
-

a promise to the -SorobanRpc.GetNetworkResponse object containing metadata -about the current network this soroban-rpc server is connected to.

+

metadata about the +current network this RPC server is connected to

@@ -1267,7 +1608,7 @@
Returns:
Example
-
server.getNetwork().then(network => {
+    
server.getNetwork().then((network) => {
   console.log("friendbotUrl:", network.friendbotUrl);
   console.log("passphrase:", network.passphrase);
   console.log("protocolVersion:", network.protocolVersion);
@@ -1290,7 +1631,7 @@ 

(async)

Fetch the details of a submitted transaction.

-

When submitting a transaction, clients should poll this to tell when the +

After submitting a transaction, clients should poll this to tell when the transaction has completed.

@@ -1327,13 +1668,20 @@

(async) Source:
+
See:
+
+ +
+ @@ -1388,7 +1736,7 @@

Parameters:
-

The hex-encoded hash of the transaction to check.

+

hex-encoded hash of the transaction to check

@@ -1429,10 +1777,8 @@
Returns:
-

Returns a promise to -the SorobanRpc.GetTransactionResponse object with the status, -result, and other details about the transaction. Raw XDR fields are -parsed into their appropriate structures wherever possible.

+

the status, +result, and other details about the transaction

@@ -1444,11 +1790,11 @@
Returns:
Example
const transactionHash = "c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a";
-server.getTransaction(transactionHash).then(transaction => {
-  console.log("status:", transaction.status);
-  console.log("envelopeXdr:", transaction.envelopeXdr);
-  console.log("resultMetaXdr:", transaction.resultMetaXdr);
-  console.log("resultXdr:", transaction.resultXdr);
+server.getTransaction(transactionHash).then((tx) => {
+  console.log("status:", tx.status);
+  console.log("envelopeXdr:", tx.envelopeXdr);
+  console.log("resultMetaXdr:", tx.resultMetaXdr);
+  console.log("resultXdr:", tx.resultXdr);
 });

@@ -1479,7 +1825,7 @@

(async)

You can call the Server.simulateTransaction method directly first if you want to inspect estimated fees for a given transaction in detail -first, if that is of importance.

+first, then re-assemble it manually or via assembleTransaction.

@@ -1515,13 +1861,22 @@

(async) Source:
+
See:
+
+ +
+ @@ -1589,7 +1944,7 @@
Parameters:
-

The transaction to +

the transaction to prepare. It should include exactly one operation, which must be one of xdr.InvokeHostFunctionOp, xdr.BumpFootprintExpirationOp, or xdr.RestoreFootprintOp.

@@ -1633,9 +1988,9 @@
Parameters:
-

Explicitly provide a network -passphrase. If not passed, the current network passphrase will be -requested from the server via Server.getNetwork.

+

explicitly provide a network +passphrase (default: requested from the server via +Server.getNetwork).

@@ -1711,11 +2066,11 @@
Returns:
-

Returns a copy of the -transaction, with the expected authorizations (in the case of -invocation) and ledger footprint added. The transaction fee will also -automatically be padded with the contract's minimum resource fees -discovered from the simulation.

+

a copy of the +transaction with the expected authorizations (in the case of +invocation), resources, and ledger footprints added. The transaction fee +will also automatically be padded with the contract's minimum resource +fees discovered from the simulation.

@@ -1730,24 +2085,18 @@
Example
const contract = new SorobanClient.Contract(contractId); // Right now, this is just the default fee for this example. -const fee = 100; - -const transaction = new SorobanClient.TransactionBuilder(account, { - fee, - // Uncomment the following line to build transactions for the live network. Be - // sure to also change the horizon hostname. - // networkPassphrase: SorobanClient.Networks.PUBLIC, - networkPassphrase: SorobanClient.Networks.TESTNET - }) - // Add a contract.increment soroban contract invocation operation +const fee = SorobanClient.BASE_FEE; +const transaction = new SorobanClient.TransactionBuilder(account, { fee }) + // Uncomment the following line to build transactions for the live network. Be + // sure to also change the horizon hostname. + //.setNetworkPassphrase(SorobanClient.Networks.PUBLIC) + .setNetworkPassphrase(SorobanClient.Networks.FUTURENET) + .setTimeout(30) // valid for the next 30s + // Add an operation to call increment() on the contract .addOperation(contract.call("increment")) - // Make this transaction valid for the next 30 seconds only - .setTimeout(30) - // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) - // .addMemo(SorobanClient.Memo.text('Hello world!')) .build(); -preparedTransaction = await server.prepareTransaction(transaction); +const preparedTransaction = await server.prepareTransaction(transaction); // Sign this transaction with the secret key // NOTE: signing is transaction is network specific. Test network transactions @@ -1778,10 +2127,7 @@

(async) -

Use the friendbot faucet to create and fund a new account. The method will -return an Account object for the created account, or if the account already -existed. If friendbot is not configured on this network, this method will -throw an error. If the request fails, this method will throw an error.

+

Fund a new account using the network's friendbot faucet, if any.

@@ -1817,13 +2163,22 @@

(async) Source:
+
See:
+
+ +
+ @@ -1891,8 +2246,8 @@

Parameters:
-

The address or account we want to -create and fund.

+

the address or account instance that we +want to create and fund with friendbot

@@ -1928,9 +2283,10 @@
Parameters:
-

The optional explicit address for -friendbot. If not provided, the client will call the Soroban-RPC -getNetwork method to attempt to find this network's friendbot url.

+

optionally, an explicit address for +friendbot (by default: this calls the Soroban RPC +Server.getNetwork method to try to discover this network's +Friendbot url).

@@ -1950,6 +2306,21 @@
Parameters:
+
+
Throws:
+ + + +
+ +

if Friendbot is not configured on this network or request failure

+ +
+ + + +
+
@@ -1971,8 +2342,10 @@
Returns:
-

Returns a promise to the Account object -with populated sequence number.

+

an Account object for the created +account, or the existing account if it's already funded with the +populated sequence number (note that the account will not be "topped +off" if it already exists)

@@ -1985,9 +2358,9 @@
Example
server
    .requestAirdrop("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4")
-   .then(accountCreated => {
+   .then((accountCreated) => {
      console.log("accountCreated:", accountCreated);
-   }).catch(error => {
+   }).catch((error) => {
      console.error("error:", error);
    });
@@ -2007,11 +2380,11 @@

(async) -

Submit a real transaction to the Stellar network. This is the only way to -make changes "on-chain". Unlike Horizon, Soroban-RPC does not wait for -transaction completion. It simply validates the transaction and enqueues -it. Clients should call Server#getTransactionStatus to learn about -transaction success/failure.

+

Submit a real transaction to the Stellar network.

+

Unlike Horizon, Soroban RPC does not wait for transaction completion. It +simply validates the transaction and enqueues it. Clients should call +Server.getTransactionStatus to learn about transaction +success/failure.

@@ -2047,13 +2420,22 @@

(async) Source:
+
See:
+
+ +
+ @@ -2111,8 +2493,7 @@
Parameters:
-

The transaction to -submit.

+

to submit

@@ -2153,9 +2534,8 @@
Returns:
-

Returns a promise to -the SorobanRpc.SendTransactionResponse object with the -transaction id, status, and any error if available.

+

the +transaction id, status, and any error if available

@@ -2170,23 +2550,15 @@
Example
const contract = new SorobanClient.Contract(contractId); // Right now, this is just the default fee for this example. -const fee = 100; - -const transaction = new SorobanClient.TransactionBuilder(account, { - fee, - // Uncomment the following line to build transactions for the live network. Be - // sure to also change the horizon hostname. - // networkPassphrase: SorobanClient.Networks.PUBLIC, - networkPassphrase: SorobanClient.Networks.STANDALONE - }) - // Add a contract.increment soroban contract invocation operation - // Note: For real transactions you will need to include the footprint - // and auth in the operation, as returned from simulateTransaction. +const fee = SorobanClient.BASE_FEE; +const transaction = new SorobanClient.TransactionBuilder(account, { fee }) + // Uncomment the following line to build transactions for the live network. Be + // sure to also change the horizon hostname. + //.setNetworkPassphrase(SorobanClient.Networks.PUBLIC) + .setNetworkPassphrase(SorobanClient.Networks.FUTURENET) + .setTimeout(30) // valid for the next 30s + // Add an operation to call increment() on the contract .addOperation(contract.call("increment")) - // Make this transaction valid for the next 30 seconds only - .setTimeout(30) - // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) - // .addMemo(SorobanClient.Memo.text('Hello world!')) .build(); // Sign this transaction with the secret key @@ -2196,7 +2568,7 @@
Example
const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey); transaction.sign(sourceKeypair); -server.sendTransaction(transaction).then(result => { +server.sendTransaction(transaction).then((result) => { console.log("hash:", result.hash); console.log("status:", result.status); console.log("errorResultXdr:", result.errorResultXdr); @@ -2255,13 +2627,26 @@

(async) <
Source:
+
See:
+
+ +
+ @@ -2319,11 +2704,11 @@
Parameters:
-

The transaction to -simulate. It should include exactly one operation, which must be one of +

the transaction to +simulate, which should include exactly one operation (one of xdr.InvokeHostFunctionOp, xdr.BumpFootprintExpirationOp, -or xdr.RestoreFootprintOp. Any provided footprint will be -ignored.

+or xdr.RestoreFootprintOp). Any provided footprint or auth +information will be ignored.

@@ -2364,10 +2749,9 @@
Returns:
-

Returns a -promise to the SorobanRpc.SimulateTransactionResponse object -with the cost, footprint, result/auth requirements (if applicable), and -error of the transaction.

+

an object with +the cost, footprint, result/auth requirements (if applicable), and error +of the transaction

@@ -2382,31 +2766,18 @@
Example
const contract = new SorobanClient.Contract(contractId); // Right now, this is just the default fee for this example. -const fee = 100; - -const transaction = new SorobanClient.TransactionBuilder(account, { - fee, - // Uncomment the following line to build transactions for the live network. Be - // sure to also change the horizon hostname. - // networkPassphrase: SorobanClient.Networks.PUBLIC, - networkPassphrase: SorobanClient.Networks.FUTURENET - }) - // Add a contract.increment soroban contract invocation operation +const fee = SorobanClient.BASE_FEE; +const transaction = new SorobanClient.TransactionBuilder(account, { fee }) + // Uncomment the following line to build transactions for the live network. Be + // sure to also change the horizon hostname. + //.setNetworkPassphrase(SorobanClient.Networks.PUBLIC) + .setNetworkPassphrase(SorobanClient.Networks.FUTURENET) + .setTimeout(30) // valid for the next 30s + // Add an operation to call increment() on the contract .addOperation(contract.call("increment")) - // Make this transaction valid for the next 30 seconds only - .setTimeout(30) - // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) - // .addMemo(SorobanClient.Memo.text('Hello world!')) .build(); -// Sign this transaction with the secret key -// NOTE: signing is transaction is network specific. Test network transactions -// won't work in the public network. To switch networks, use the Network object -// as explained above (look for SorobanClient.Network). -const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey); -transaction.sign(sourceKeypair); - -server.simulateTransaction(transaction).then(sim => { +server.simulateTransaction(transaction).then((sim) => { console.log("cost:", sim.cost); console.log("result:", sim.result); console.log("error:", sim.error); @@ -2434,7 +2805,7 @@
Example

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/SignerKey.html b/SignerKey.html index e4874cda..d08fea71 100644 --- a/SignerKey.html +++ b/SignerKey.html @@ -24,7 +24,7 @@
@@ -497,7 +497,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Soroban.html b/Soroban.html new file mode 100644 index 00000000..a19332c5 --- /dev/null +++ b/Soroban.html @@ -0,0 +1,568 @@ + + + + + + Soroban - Documentation + + + + + + + + + + + + + + + + + +
+ +

Soroban

+ + + + + + + +
+ +
+ +

+ Soroban +

+ + +
+ +
+
+ + +
+ + + +

new Soroban()

+ + + + + +
+

Soroban helper class +formatting, parsing, and etc

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + + + + + + + + + + + + + +

Methods

+ + + +
+ + + +

(static) formatTokenAmount(amount, decimals) → {string}

+ + + + + +
+

All arithmetic inside the contract is performed on integers to +avoid potential precision and consistency issues of floating-point

+

This function takes the smart contract value and its decimals (if the token has any) and returns a display value

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
amount + + +string + + + + +

the token amount you want to display

+ +
decimals + + +number + + + + +

specify how many decimal places a token has

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +string + + +
+
+ + +
+
    +
  • display value
  • +
+
+ + +
+ + + +
+ + +
+ + + +

(static) parseTokenAmount(value, decimals) → {string}

+ + + + + +
+

parse token amount to use it on smart contract

+

This function takes the display value and its decimals (if the token has +any) and returns a string that'll be used within the smart contract.

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
value + + +string + + + + +

the token amount you want to use it on smart contract

+ +
decimals + + +number + + + + +

specify how many decimal places a token has

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +string + + +
+
+ + +
+
    +
  • smart contract value
  • +
+
+ + +
+ + + +
+
Example
+ +
const displayValueAmount = "123.4560"
+const parsedAmountForSmartContract = parseTokenAmount("123.4560", 5);
+parsedAmountForSmartContract === "12345600"
+ +
+ +
+ + + + + + +
+ +
+ + + + +
+ +
+ +
+ Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme. +
+ + + + + \ No newline at end of file diff --git a/SorobanDataBuilder.html b/SorobanDataBuilder.html index ce8a447e..e1b006de 100644 --- a/SorobanDataBuilder.html +++ b/SorobanDataBuilder.html @@ -24,7 +24,7 @@
@@ -301,7 +301,7 @@

append
Source:
@@ -483,7 +483,7 @@

buildSource:
@@ -587,7 +587,7 @@

getFootpr
Source:
@@ -691,7 +691,7 @@

getReadOnl
Source:
@@ -795,7 +795,7 @@

getReadWr
Source:
@@ -909,7 +909,7 @@

setFootpr
Source:
@@ -1121,7 +1121,7 @@

setReadOnl
Source:
@@ -1273,7 +1273,7 @@

setReadWr
Source:
@@ -1429,7 +1429,7 @@

setRe
Source:
@@ -1548,7 +1548,7 @@

Returns:
-

setResources(cpuInstrs, readBytes, writeBytes, metadataBytes) → {SorobanDataBuilder}

+

setResources(cpuInstrs, readBytes, writeBytes) → {SorobanDataBuilder}

@@ -1593,7 +1593,7 @@

setResour
Source:
@@ -1712,32 +1712,6 @@

Parameters:
- - - - metadataBytes - - - - - -number - - - - - - - - - - -

number of extended metadata bytes

- - - - - @@ -1827,7 +1801,7 @@

(static) from
Source:
@@ -1958,7 +1932,7 @@

Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/SorobanRpc.html b/SorobanRpc.html index 61651c63..2aea7979 100644 --- a/SorobanRpc.html +++ b/SorobanRpc.html @@ -24,7 +24,7 @@
@@ -130,7 +130,7 @@


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/StrKey.html b/StrKey.html index 55304ddc..730b7db1 100644 --- a/StrKey.html +++ b/StrKey.html @@ -24,7 +24,7 @@
@@ -3145,7 +3145,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Transaction.html b/Transaction.html index bc4ab5d2..daa3841d 100644 --- a/Transaction.html +++ b/Transaction.html @@ -24,7 +24,7 @@
@@ -2960,7 +2960,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/TransactionBuilder.html b/TransactionBuilder.html index 38de119b..7a0df0b9 100644 --- a/TransactionBuilder.html +++ b/TransactionBuilder.html @@ -24,7 +24,7 @@
@@ -3658,7 +3658,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Uint128_Uint128.html b/Uint128_Uint128.html index e573991a..0f074fd3 100644 --- a/Uint128_Uint128.html +++ b/Uint128_Uint128.html @@ -24,7 +24,7 @@
@@ -230,7 +230,7 @@
Parameters:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/Uint256_Uint256.html b/Uint256_Uint256.html index 8db53488..74d84fb5 100644 --- a/Uint256_Uint256.html +++ b/Uint256_Uint256.html @@ -24,7 +24,7 @@
@@ -230,7 +230,7 @@
Parameters:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/XdrLargeInt.html b/XdrLargeInt.html index ce1d92c5..d6fcc1c0 100644 --- a/XdrLargeInt.html +++ b/XdrLargeInt.html @@ -24,7 +24,7 @@
@@ -163,9 +163,9 @@
Parameters:
-

force a specific data type. the type choices -are: 'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (default: the -smallest one that fits the value)

+

force a specific data type. the type choices are: +'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (default: the smallest +one that fits the value) (see XdrLargeInt.isType)

@@ -189,13 +189,7 @@
Parameters:
string | -XdrLargeInt -| - -ScInt -| - -Array.<(number|bigint|string|XdrLargeInt|ScInt)> +Array.<(number|bigint|string)> @@ -206,9 +200,8 @@
Parameters:
-
    -
  • a list of integer-like values interpreted in big-endian order
  • -
+

a list of +integer-like values interpreted in big-endian order

@@ -453,7 +446,7 @@

toBigIntSource:
@@ -553,7 +546,7 @@

toI128Source:
@@ -689,7 +682,7 @@

toI256Source:
@@ -793,7 +786,7 @@

toI64Source:
@@ -1029,7 +1022,7 @@

toScValSource:
@@ -1079,7 +1072,7 @@
Returns:
-

the smallest ScVal interpretation of the stored value

+

the smallest interpretation of the stored value

@@ -1133,7 +1126,7 @@

toU128Source:
@@ -1269,7 +1262,7 @@

toU256Source:
@@ -1373,7 +1366,7 @@

toU64Source:
@@ -1433,6 +1426,167 @@
Returns:

+ +
+ + + +

(static) getType(scvType) → {string}

+ + + + + +
+

Convert the raw ScValType string (e.g. 'scvI128', generated by the XDR) +to a type description for XdrLargeInt construction (e.g. 'i128')

+
+ + + + + +
+ + + + + + + + + + + + + + + + + + + + + + + + + + +
Source:
+
+ + + + + + + +
+ + + + + + + + + +
Parameters:
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
NameTypeDescription
scvType + + +string + + + + +

the xdr.ScValType as a string

+ +
+ + + + + + + + + + + + + + +
+
Returns:
+ + + +
+
+ Type: +
+
+ +string + + +
+
+ + +
+

a suitable equivalent type to construct this object

+
+ + +
+ + + +
+ @@ -1450,7 +1604,7 @@
Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:45 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/global.html b/global.html index 3d52f144..1e434e04 100644 --- a/global.html +++ b/global.html @@ -24,7 +24,7 @@
@@ -471,70 +471,6 @@

(constant) BA -

- - - -
-

Durability

- - - - -
-

Specifies the durability namespace of contract-related ledger entries.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - -
@@ -1006,21 +942,13 @@
Type:
-

(constant) SERVER_TIME_MAP

+

SUBMIT_TRANSACTION_TIMEOUT

-

keep a local map of server times -(export this purely for testing purposes)

-

each entry will map the server domain to the last-known time and the local -time it was recorded, ex:

-
"localhost:8000": {
-  serverTime: 1552513039,
-  localTimeRecorded: 1552513052
-}
-
+

Specifies the durability namespace of contract-related ledger entries.

@@ -1056,7 +984,7 @@

(constant) Source:
@@ -1142,72 +1070,6 @@

(constant) - - - -
-

default

- - - - -
-

Given a hostname, get the current time of that server (i.e., use the last- -recorded server time and offset it by the time since then.) If there IS no -recorded server time, or it's been 5 minutes since the last, return null.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - -
@@ -1452,7 +1314,7 @@

as
Source:
@@ -3807,163 +3669,6 @@

Returns:
-

- - -
- - - -

getType(scvType) → {ScIntType}

- - - - - -
-

Convert the raw ScValType string (e.g. 'scvI128', generated by the XDR) to -an ScIntType (e.g. 'i128', used by this abstraction layer).

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - -
Parameters:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
NameTypeDescription
scvType - - -string - - - - -

the xdr.ScValType as a string

- -
- - - - - - - - - - - - - - -
-
Returns:
- - - -
-
- Type: -
-
- -ScIntType - - -
-
- - - -
- - -
@@ -4571,7 +4276,7 @@

nativeTo
Source:
@@ -4969,7 +4674,7 @@

par
Source:
@@ -5113,7 +4818,7 @@

(async) postSource:
@@ -5196,7 +4901,7 @@

(async) pos
Source:
@@ -5228,115 +4933,6 @@

(async) pos - -

- - -
- - - -

readObj()

- - - - - -
-

Provides a ContractSpec class which can contains the XDR types defined by the contract. -This allows the class to be used to convert between native and raw xdr.ScVals.

-
- - - - - -
- - - - - - - - - - - - - - - - - - - - - - - - - - -
Source:
-
- - - - - - - -
- - - - - - - - - - - - - - - - - - - - - - - -
-
Example
- -
```js
-const specEntries = [...]; // XDR spec entries of a smart contract
-const contractSpec = new ContractSpec(specEntries);
-
-// Convert native value to ScVal
-const args = {
-  arg1: 'value1',
-  arg2: 1234
-};
-const scArgs = contractSpec.funcArgsToScVals('funcName', args);
-
-// Call contract
-const resultScv = await callContract(contractId, 'funcName', scArgs);
-
-// Convert result ScVal back to native value
-const result = contractSpec.funcResToNative('funcName', resultScv);
-
-console.log(result); // {success: true}
-```
- -
@@ -5608,7 +5204,7 @@

scValToN
Source:
@@ -6802,7 +6398,7 @@

Returns:

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/index.html b/index.html index e13293c8..ddbb2d4d 100644 --- a/index.html +++ b/index.html @@ -24,7 +24,7 @@
@@ -222,7 +222,7 @@

License


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_account.js.html b/js-stellar-base_src_account.js.html index 9271c9ba..5e9fb998 100644 --- a/js-stellar-base_src_account.js.html +++ b/js-stellar-base_src_account.js.html @@ -24,7 +24,7 @@
@@ -113,7 +113,7 @@

js-stellar-base/src/account.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_address.js.html b/js-stellar-base_src_address.js.html index 9b4e0dd5..fa23cf6d 100644 --- a/js-stellar-base_src_address.js.html +++ b/js-stellar-base_src_address.js.html @@ -24,7 +24,7 @@
@@ -189,7 +189,7 @@

js-stellar-base/src/address.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_asset.js.html b/js-stellar-base_src_asset.js.html index 7bd328ae..cb8c3086 100644 --- a/js-stellar-base_src_asset.js.html +++ b/js-stellar-base_src_asset.js.html @@ -24,7 +24,7 @@
@@ -345,7 +345,7 @@

js-stellar-base/src/asset.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_auth.js.html b/js-stellar-base_src_auth.js.html index 9771a6d6..72d24361 100644 --- a/js-stellar-base_src_auth.js.html +++ b/js-stellar-base_src_auth.js.html @@ -24,7 +24,7 @@
@@ -211,22 +211,25 @@

js-stellar-base/src/auth.js

address: new Address(publicKey).toScAddress(), nonce: auth.nonce(), signatureExpirationLedger: auth.signatureExpirationLedger(), - signatureArgs: [ + // This structure is defined here: + // https://soroban.stellar.org/docs/fundamentals-and-concepts/invoking-contracts-with-transactions#stellar-account-signatures + // + // Encoding a contract structure as an ScVal means the keys are supposed + // to be symbols, hence the forced typing here. + signature: xdr.ScVal.scvVec([ nativeToScVal( { public_key: StrKey.decodeEd25519PublicKey(publicKey), signature }, { - // force the keys to be interpreted as symbols (expected for - // Soroban [contracttype]s) type: { public_key: ['symbol', null], signature: ['symbol', null] } } ) - ] + ]) }) ) }); @@ -248,7 +251,7 @@

js-stellar-base/src/auth.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_claimant.js.html b/js-stellar-base_src_claimant.js.html index 77063a16..50f1e8d4 100644 --- a/js-stellar-base_src_claimant.js.html +++ b/js-stellar-base_src_claimant.js.html @@ -24,7 +24,7 @@
@@ -223,7 +223,7 @@

js-stellar-base/src/claimant.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_contract.js.html b/js-stellar-base_src_contract.js.html index e65743eb..3d6fdb02 100644 --- a/js-stellar-base_src_contract.js.html +++ b/js-stellar-base_src_contract.js.html @@ -24,7 +24,7 @@
@@ -57,7 +57,6 @@

js-stellar-base/src/contract.js

* @param {string} contractId - ID of the contract (ex. * `CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE`). */ -// TODO: Support contract deployment, maybe? export class Contract { constructor(contractId) { try { @@ -90,18 +89,21 @@

js-stellar-base/src/contract.js

/** * Returns an operation that will invoke this contract call. * - * @param {string} method - name of the method to call - * @param {...xdr.ScVal} params - arguments to pass to the function call - * @returns {xdr.Operation} Build a InvokeHostFunctionOp operation to call the - * contract. + * @param {string} method name of the method to call + * @param {...xdr.ScVal} params arguments to pass to the function call + * + * @returns {xdr.Operation} an InvokeHostFunctionOp operation to call the + * contract with the given method and parameters */ call(method, ...params) { return Operation.invokeHostFunction({ - func: xdr.HostFunction.hostFunctionTypeInvokeContract([ - this.address().toScVal(), - xdr.ScVal.scvSymbol(method), - ...params - ]), + func: xdr.HostFunction.hostFunctionTypeInvokeContract( + new xdr.InvokeContractArgs({ + contractAddress: this.address().toScAddress(), + functionName: method, + args: params + }) + ), auth: [] }); } @@ -117,17 +119,13 @@

js-stellar-base/src/contract.js

getFootprint() { return [ xdr.LedgerKey.contractCode( - new xdr.LedgerKeyContractCode({ - hash: this._id, - bodyType: xdr.ContractEntryBodyType.dataEntry() - }) + new xdr.LedgerKeyContractCode({ hash: this._id }) ), xdr.LedgerKey.contractData( new xdr.LedgerKeyContractData({ contract: this.address().toScAddress(), key: xdr.ScVal.scvLedgerKeyContractInstance(), - durability: xdr.ContractDataDurability.persistent(), - bodyType: xdr.ContractEntryBodyType.dataEntry() + durability: xdr.ContractDataDurability.persistent() }) ) ]; @@ -145,7 +143,7 @@

js-stellar-base/src/contract.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_events.js.html b/js-stellar-base_src_events.js.html index b6dc7cfe..2b27f25d 100644 --- a/js-stellar-base_src_events.js.html +++ b/js-stellar-base_src_events.js.html @@ -24,7 +24,7 @@
@@ -95,7 +95,7 @@

js-stellar-base/src/events.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_fee_bump_transaction.js.html b/js-stellar-base_src_fee_bump_transaction.js.html index bfa9f837..72e49574 100644 --- a/js-stellar-base_src_fee_bump_transaction.js.html +++ b/js-stellar-base_src_fee_bump_transaction.js.html @@ -24,7 +24,7 @@
@@ -166,7 +166,7 @@

js-stellar-base/src/fee_bump_transaction.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_get_liquidity_pool_id.js.html b/js-stellar-base_src_get_liquidity_pool_id.js.html index cb627b07..9e35b55e 100644 --- a/js-stellar-base_src_get_liquidity_pool_id.js.html +++ b/js-stellar-base_src_get_liquidity_pool_id.js.html @@ -24,7 +24,7 @@
@@ -105,7 +105,7 @@

js-stellar-base/src/get_liquidity_pool_id.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_invocation.js.html b/js-stellar-base_src_invocation.js.html index 645f02ca..cdb99c03 100644 --- a/js-stellar-base_src_invocation.js.html +++ b/js-stellar-base_src_invocation.js.html @@ -24,7 +24,7 @@
@@ -249,7 +249,7 @@

js-stellar-base/src/invocation.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_keypair.js.html b/js-stellar-base_src_keypair.js.html index 467feafa..b4b9b978 100644 --- a/js-stellar-base_src_keypair.js.html +++ b/js-stellar-base_src_keypair.js.html @@ -24,7 +24,7 @@
@@ -327,7 +327,7 @@

js-stellar-base/src/keypair.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_liquidity_pool_asset.js.html b/js-stellar-base_src_liquidity_pool_asset.js.html index 29804ab9..2605d4b4 100644 --- a/js-stellar-base_src_liquidity_pool_asset.js.html +++ b/js-stellar-base_src_liquidity_pool_asset.js.html @@ -24,7 +24,7 @@
@@ -171,7 +171,7 @@

js-stellar-base/src/liquidity_pool_asset.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_liquidity_pool_id.js.html b/js-stellar-base_src_liquidity_pool_id.js.html index e2d2df20..32a0fd1c 100644 --- a/js-stellar-base_src_liquidity_pool_id.js.html +++ b/js-stellar-base_src_liquidity_pool_id.js.html @@ -24,7 +24,7 @@
@@ -128,7 +128,7 @@

js-stellar-base/src/liquidity_pool_id.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_memo.js.html b/js-stellar-base_src_memo.js.html index 2d15044e..6da2652c 100644 --- a/js-stellar-base_src_memo.js.html +++ b/js-stellar-base_src_memo.js.html @@ -24,7 +24,7 @@
@@ -296,7 +296,7 @@

js-stellar-base/src/memo.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_muxed_account.js.html b/js-stellar-base_src_muxed_account.js.html index d0861ccc..ee0781ef 100644 --- a/js-stellar-base_src_muxed_account.js.html +++ b/js-stellar-base_src_muxed_account.js.html @@ -24,7 +24,7 @@
@@ -188,7 +188,7 @@

js-stellar-base/src/muxed_account.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_network.js.html b/js-stellar-base_src_network.js.html index 76fea20f..513a745b 100644 --- a/js-stellar-base_src_network.js.html +++ b/js-stellar-base_src_network.js.html @@ -24,7 +24,7 @@
@@ -67,7 +67,7 @@

js-stellar-base/src/network.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_numbers_index.js.html b/js-stellar-base_src_numbers_index.js.html index e75964b7..77c3799d 100644 --- a/js-stellar-base_src_numbers_index.js.html +++ b/js-stellar-base_src_numbers_index.js.html @@ -24,7 +24,7 @@
@@ -39,7 +39,7 @@

js-stellar-base/src/numbers/index.js

-
import { XdrLargeInt, getType } from './xdr_large_int';
+            
import { XdrLargeInt } from './xdr_large_int';
 
 export { Uint128 } from './uint128';
 export { Uint256 } from './uint256';
@@ -67,7 +67,7 @@ 

js-stellar-base/src/numbers/index.js

* @throws {TypeError} if the `scv` input value doesn't represent an integer */ export function scValToBigInt(scv) { - const scIntType = getType(scv.switch().name); + const scIntType = XdrLargeInt.getType(scv.switch().name); switch (scv.switch().name) { case 'scvU32': @@ -110,7 +110,7 @@

js-stellar-base/src/numbers/index.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_numbers_int128.js.html b/js-stellar-base_src_numbers_int128.js.html index 86688345..2dd8c6dc 100644 --- a/js-stellar-base_src_numbers_int128.js.html +++ b/js-stellar-base_src_numbers_int128.js.html @@ -24,7 +24,7 @@
@@ -74,7 +74,7 @@

js-stellar-base/src/numbers/int128.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_numbers_int256.js.html b/js-stellar-base_src_numbers_int256.js.html index 9c4677ce..41e7b823 100644 --- a/js-stellar-base_src_numbers_int256.js.html +++ b/js-stellar-base_src_numbers_int256.js.html @@ -24,7 +24,7 @@
@@ -74,7 +74,7 @@

js-stellar-base/src/numbers/int256.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_numbers_sc_int.js.html b/js-stellar-base_src_numbers_sc_int.js.html index 74529ed2..05197b46 100644 --- a/js-stellar-base_src_numbers_sc_int.js.html +++ b/js-stellar-base_src_numbers_sc_int.js.html @@ -24,7 +24,7 @@
@@ -165,7 +165,7 @@

js-stellar-base/src/numbers/sc_int.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_numbers_uint128.js.html b/js-stellar-base_src_numbers_uint128.js.html index f62a53f8..506762ee 100644 --- a/js-stellar-base_src_numbers_uint128.js.html +++ b/js-stellar-base_src_numbers_uint128.js.html @@ -24,7 +24,7 @@
@@ -74,7 +74,7 @@

js-stellar-base/src/numbers/uint128.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_numbers_uint256.js.html b/js-stellar-base_src_numbers_uint256.js.html index 9b3606d6..3b6aab08 100644 --- a/js-stellar-base_src_numbers_uint256.js.html +++ b/js-stellar-base_src_numbers_uint256.js.html @@ -24,7 +24,7 @@
@@ -74,7 +74,7 @@

js-stellar-base/src/numbers/uint256.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_numbers_xdr_large_int.js.html b/js-stellar-base_src_numbers_xdr_large_int.js.html index 57256cfb..f778478b 100644 --- a/js-stellar-base_src_numbers_xdr_large_int.js.html +++ b/js-stellar-base_src_numbers_xdr_large_int.js.html @@ -24,7 +24,7 @@
@@ -56,11 +56,11 @@

js-stellar-base/src/numbers/xdr_large_int.js

* the type / width / size in bits of the integer you're targeting, regardless * of the input value(s) you provide. * - * @param {string} type - force a specific data type. the type choices - * are: 'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (default: the - * smallest one that fits the `value`) - * @param {number|bigint|string|XdrLargeInt|ScInt|Array<number|bigint|string|XdrLargeInt|ScInt>} values - * - a list of integer-like values interpreted in big-endian order + * @param {string} type - force a specific data type. the type choices are: + * 'i64', 'u64', 'i128', 'u128', 'i256', and 'u256' (default: the smallest + * one that fits the `value`) (see {@link XdrLargeInt.isType}) + * @param {number|bigint|string|Array<number|bigint|string>} values a list of + * integer-like values interpreted in big-endian order */ export class XdrLargeInt { /** @@ -132,16 +132,12 @@

js-stellar-base/src/numbers/xdr_large_int.js

return Number(bi); } - /** - * @returns {bigint} - */ + /** @returns {bigint} */ toBigInt() { return this.int.toBigInt(); } - /** - * @returns {xdr.ScVal} the integer encoded with `ScValType = I64` - */ + /** @returns {xdr.ScVal} the integer encoded with `ScValType = I64` */ toI64() { this._sizeCheck(64); const v = this.toBigInt(); @@ -152,9 +148,7 @@

js-stellar-base/src/numbers/xdr_large_int.js

return xdr.ScVal.scvI64(new xdr.Int64(v)); } - /** - * @returns {xdr.ScVal} the integer encoded with `ScValType = U64` - */ + /** @returns {xdr.ScVal} the integer encoded with `ScValType = U64` */ toU64() { this._sizeCheck(64); return xdr.ScVal.scvU64( @@ -197,9 +191,7 @@

js-stellar-base/src/numbers/xdr_large_int.js

); } - /** - * @returns {xdr.ScVal} the integer encoded with `ScValType = I256` - */ + /** @returns {xdr.ScVal} the integer encoded with `ScValType = I256` */ toI256() { const v = this.int.toBigInt(); const hiHi64 = BigInt.asIntN(64, v >> 192n); // keep sign bit @@ -217,9 +209,7 @@

js-stellar-base/src/numbers/xdr_large_int.js

); } - /** - * @returns {xdr.ScVal} the integer encoded with `ScValType = U256` - */ + /** @returns {xdr.ScVal} the integer encoded with `ScValType = U256` */ toU256() { const v = this.int.toBigInt(); const hiHi64 = BigInt.asUintN(64, v >> 192n); // encode sign bit @@ -237,9 +227,7 @@

js-stellar-base/src/numbers/xdr_large_int.js

); } - /** - * @returns {xdr.ScVal} the smallest ScVal interpretation of the stored value - */ + /** @returns {xdr.ScVal} the smallest interpretation of the stored value */ toScVal() { switch (this.type) { case 'i64': @@ -279,18 +267,31 @@

js-stellar-base/src/numbers/xdr_large_int.js

throw RangeError(`value too large for ${bits} bits (${this.type})`); } } -} -/** - * Convert the raw `ScValType` string (e.g. 'scvI128', generated by the XDR) to - * an `ScIntType` (e.g. 'i128', used by this abstraction layer). - * - * @param {string} scvType - the `xdr.ScValType` as a string - * - * @returns {ScIntType} - */ -export function getType(scvType) { - return scvType.slice(3).toLowerCase(); + static isType(type) { + switch (type) { + case 'i64': + case 'i128': + case 'i256': + case 'u64': + case 'u128': + case 'u256': + return true; + default: + return false; + } + } + + /** + * Convert the raw `ScValType` string (e.g. 'scvI128', generated by the XDR) + * to a type description for {@link XdrLargeInt} construction (e.g. 'i128') + * + * @param {string} scvType the `xdr.ScValType` as a string + * @returns {string} a suitable equivalent type to construct this object + */ + static getType(scvType) { + return scvType.slice(3).toLowerCase(); + } }
@@ -304,7 +305,7 @@

js-stellar-base/src/numbers/xdr_large_int.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operation.js.html b/js-stellar-base_src_operation.js.html index 1794bec8..acd283f1 100644 --- a/js-stellar-base_src_operation.js.html +++ b/js-stellar-base_src_operation.js.html @@ -24,7 +24,7 @@
@@ -727,7 +727,7 @@

js-stellar-base/src/operation.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_account_merge.js.html b/js-stellar-base_src_operations_account_merge.js.html index b5e27f22..2c1d4e07 100644 --- a/js-stellar-base_src_operations_account_merge.js.html +++ b/js-stellar-base_src_operations_account_merge.js.html @@ -24,7 +24,7 @@
@@ -80,7 +80,7 @@

js-stellar-base/src/operations/account_merge.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_allow_trust.js.html b/js-stellar-base_src_operations_allow_trust.js.html index 2ee468ff..7019a488 100644 --- a/js-stellar-base_src_operations_allow_trust.js.html +++ b/js-stellar-base_src_operations_allow_trust.js.html @@ -24,7 +24,7 @@
@@ -106,7 +106,7 @@

js-stellar-base/src/operations/allow_trust.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_begin_sponsoring_future_reserves.js.html b/js-stellar-base_src_operations_begin_sponsoring_future_reserves.js.html index 3e6a0839..caf969d2 100644 --- a/js-stellar-base_src_operations_begin_sponsoring_future_reserves.js.html +++ b/js-stellar-base_src_operations_begin_sponsoring_future_reserves.js.html @@ -24,7 +24,7 @@
@@ -84,7 +84,7 @@

js-stellar-base/src/operations/begin_sponsoring_future_re
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_bump_footprint_expiration.js.html b/js-stellar-base_src_operations_bump_footprint_expiration.js.html index a2d85403..5bdbbc1b 100644 --- a/js-stellar-base_src_operations_bump_footprint_expiration.js.html +++ b/js-stellar-base_src_operations_bump_footprint_expiration.js.html @@ -24,7 +24,7 @@
@@ -92,7 +92,7 @@

js-stellar-base/src/operations/bump_footprint_expiration.
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_bump_sequence.js.html b/js-stellar-base_src_operations_bump_sequence.js.html index 4c383485..0ec37fbc 100644 --- a/js-stellar-base_src_operations_bump_sequence.js.html +++ b/js-stellar-base_src_operations_bump_sequence.js.html @@ -24,7 +24,7 @@
@@ -88,7 +88,7 @@

js-stellar-base/src/operations/bump_sequence.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_change_trust.js.html b/js-stellar-base_src_operations_change_trust.js.html index e93f8f81..36878ca6 100644 --- a/js-stellar-base_src_operations_change_trust.js.html +++ b/js-stellar-base_src_operations_change_trust.js.html @@ -24,7 +24,7 @@
@@ -103,7 +103,7 @@

js-stellar-base/src/operations/change_trust.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_claim_claimable_balance.js.html b/js-stellar-base_src_operations_claim_claimable_balance.js.html index 4599a30c..b2a6b3d3 100644 --- a/js-stellar-base_src_operations_claim_claimable_balance.js.html +++ b/js-stellar-base_src_operations_claim_claimable_balance.js.html @@ -24,7 +24,7 @@
@@ -92,7 +92,7 @@

js-stellar-base/src/operations/claim_claimable_balance.js
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_clawback.js.html b/js-stellar-base_src_operations_clawback.js.html index a8b70f61..da15472d 100644 --- a/js-stellar-base_src_operations_clawback.js.html +++ b/js-stellar-base_src_operations_clawback.js.html @@ -24,7 +24,7 @@
@@ -93,7 +93,7 @@

js-stellar-base/src/operations/clawback.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_clawback_claimable_balance.js.html b/js-stellar-base_src_operations_clawback_claimable_balance.js.html index eff44a75..05f8fe75 100644 --- a/js-stellar-base_src_operations_clawback_claimable_balance.js.html +++ b/js-stellar-base_src_operations_clawback_claimable_balance.js.html @@ -24,7 +24,7 @@
@@ -88,7 +88,7 @@

js-stellar-base/src/operations/clawback_claimable_balance
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_create_account.js.html b/js-stellar-base_src_operations_create_account.js.html index d8d2547a..874ec115 100644 --- a/js-stellar-base_src_operations_create_account.js.html +++ b/js-stellar-base_src_operations_create_account.js.html @@ -24,7 +24,7 @@
@@ -88,7 +88,7 @@

js-stellar-base/src/operations/create_account.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_create_claimable_balance.js.html b/js-stellar-base_src_operations_create_claimable_balance.js.html index 6ce06228..5020ee19 100644 --- a/js-stellar-base_src_operations_create_claimable_balance.js.html +++ b/js-stellar-base_src_operations_create_claimable_balance.js.html @@ -24,7 +24,7 @@
@@ -120,7 +120,7 @@

js-stellar-base/src/operations/create_claimable_balance.j
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_create_passive_sell_offer.js.html b/js-stellar-base_src_operations_create_passive_sell_offer.js.html index d16825b1..953898b1 100644 --- a/js-stellar-base_src_operations_create_passive_sell_offer.js.html +++ b/js-stellar-base_src_operations_create_passive_sell_offer.js.html @@ -24,7 +24,7 @@
@@ -93,7 +93,7 @@

js-stellar-base/src/operations/create_passive_sell_offer.
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_end_sponsoring_future_reserves.js.html b/js-stellar-base_src_operations_end_sponsoring_future_reserves.js.html index d73508b0..190880ee 100644 --- a/js-stellar-base_src_operations_end_sponsoring_future_reserves.js.html +++ b/js-stellar-base_src_operations_end_sponsoring_future_reserves.js.html @@ -24,7 +24,7 @@
@@ -72,7 +72,7 @@

js-stellar-base/src/operations/end_sponsoring_future_rese
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_inflation.js.html b/js-stellar-base_src_operations_inflation.js.html index dc228e39..b085c8d8 100644 --- a/js-stellar-base_src_operations_inflation.js.html +++ b/js-stellar-base_src_operations_inflation.js.html @@ -24,7 +24,7 @@
@@ -67,7 +67,7 @@

js-stellar-base/src/operations/inflation.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_invoke_host_function.js.html b/js-stellar-base_src_operations_invoke_host_function.js.html index c696bcdd..06dbe335 100644 --- a/js-stellar-base_src_operations_invoke_host_function.js.html +++ b/js-stellar-base_src_operations_invoke_host_function.js.html @@ -24,7 +24,7 @@
@@ -88,7 +88,7 @@

js-stellar-base/src/operations/invoke_host_function.js
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_liquidity_pool_deposit.js.html b/js-stellar-base_src_operations_liquidity_pool_deposit.js.html index 051037ff..57c48517 100644 --- a/js-stellar-base_src_operations_liquidity_pool_deposit.js.html +++ b/js-stellar-base_src_operations_liquidity_pool_deposit.js.html @@ -24,7 +24,7 @@
@@ -111,7 +111,7 @@

js-stellar-base/src/operations/liquidity_pool_deposit.js<
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_liquidity_pool_withdraw.js.html b/js-stellar-base_src_operations_liquidity_pool_withdraw.js.html index b5742fa3..f06fff95 100644 --- a/js-stellar-base_src_operations_liquidity_pool_withdraw.js.html +++ b/js-stellar-base_src_operations_liquidity_pool_withdraw.js.html @@ -24,7 +24,7 @@
@@ -99,7 +99,7 @@

js-stellar-base/src/operations/liquidity_pool_withdraw.js
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_manage_buy_offer.js.html b/js-stellar-base_src_operations_manage_buy_offer.js.html index f7d56427..f53c95fb 100644 --- a/js-stellar-base_src_operations_manage_buy_offer.js.html +++ b/js-stellar-base_src_operations_manage_buy_offer.js.html @@ -24,7 +24,7 @@
@@ -98,7 +98,7 @@

js-stellar-base/src/operations/manage_buy_offer.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_manage_data.js.html b/js-stellar-base_src_operations_manage_data.js.html index f65c9ff9..0c8c0a10 100644 --- a/js-stellar-base_src_operations_manage_data.js.html +++ b/js-stellar-base_src_operations_manage_data.js.html @@ -24,7 +24,7 @@
@@ -97,7 +97,7 @@

js-stellar-base/src/operations/manage_data.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_manage_sell_offer.js.html b/js-stellar-base_src_operations_manage_sell_offer.js.html index 6b99f08e..a9537000 100644 --- a/js-stellar-base_src_operations_manage_sell_offer.js.html +++ b/js-stellar-base_src_operations_manage_sell_offer.js.html @@ -24,7 +24,7 @@
@@ -98,7 +98,7 @@

js-stellar-base/src/operations/manage_sell_offer.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_path_payment_strict_receive.js.html b/js-stellar-base_src_operations_path_payment_strict_receive.js.html index 749d94d7..475de1ce 100644 --- a/js-stellar-base_src_operations_path_payment_strict_receive.js.html +++ b/js-stellar-base_src_operations_path_payment_strict_receive.js.html @@ -24,7 +24,7 @@
@@ -117,7 +117,7 @@

js-stellar-base/src/operations/path_payment_strict_receiv
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_path_payment_strict_send.js.html b/js-stellar-base_src_operations_path_payment_strict_send.js.html index af553875..ac21dad1 100644 --- a/js-stellar-base_src_operations_path_payment_strict_send.js.html +++ b/js-stellar-base_src_operations_path_payment_strict_send.js.html @@ -24,7 +24,7 @@
@@ -116,7 +116,7 @@

js-stellar-base/src/operations/path_payment_strict_send.j
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_payment.js.html b/js-stellar-base_src_operations_payment.js.html index fc4d771a..46d5c5ce 100644 --- a/js-stellar-base_src_operations_payment.js.html +++ b/js-stellar-base_src_operations_payment.js.html @@ -24,7 +24,7 @@
@@ -96,7 +96,7 @@

js-stellar-base/src/operations/payment.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_restore_footprint.js.html b/js-stellar-base_src_operations_restore_footprint.js.html index 91fe90bf..5a870880 100644 --- a/js-stellar-base_src_operations_restore_footprint.js.html +++ b/js-stellar-base_src_operations_restore_footprint.js.html @@ -24,7 +24,7 @@
@@ -80,7 +80,7 @@

js-stellar-base/src/operations/restore_footprint.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_revoke_sponsorship.js.html b/js-stellar-base_src_operations_revoke_sponsorship.js.html index 74fd48e4..c330ce33 100644 --- a/js-stellar-base_src_operations_revoke_sponsorship.js.html +++ b/js-stellar-base_src_operations_revoke_sponsorship.js.html @@ -24,7 +24,7 @@
@@ -367,7 +367,7 @@

js-stellar-base/src/operations/revoke_sponsorship.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_set_options.js.html b/js-stellar-base_src_operations_set_options.js.html index 72fd5d1a..eabbdd35 100644 --- a/js-stellar-base_src_operations_set_options.js.html +++ b/js-stellar-base_src_operations_set_options.js.html @@ -24,7 +24,7 @@
@@ -235,7 +235,7 @@

js-stellar-base/src/operations/set_options.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_operations_set_trustline_flags.js.html b/js-stellar-base_src_operations_set_trustline_flags.js.html index e5dfc663..92ade09f 100644 --- a/js-stellar-base_src_operations_set_trustline_flags.js.html +++ b/js-stellar-base_src_operations_set_trustline_flags.js.html @@ -24,7 +24,7 @@
@@ -137,7 +137,7 @@

js-stellar-base/src/operations/set_trustline_flags.js

- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_scval.js.html b/js-stellar-base_src_scval.js.html index cbaafed1..5e8e336a 100644 --- a/js-stellar-base_src_scval.js.html +++ b/js-stellar-base_src_scval.js.html @@ -24,7 +24,7 @@
@@ -43,7 +43,7 @@

js-stellar-base/src/scval.js

import { Address } from './address'; import { Contract } from './contract'; -import { ScInt, scValToBigInt } from './numbers/index'; +import { ScInt, XdrLargeInt, scValToBigInt } from './numbers/index'; /** * Attempts to convert native types into smart contract values @@ -106,7 +106,6 @@

js-stellar-base/src/scval.js

* `scvString`. * * @returns {xdr.ScVal} a wrapped, smart, XDR version of the input value - * * @throws {TypeError} if... * - there are arrays with more than one type in them * - there are values that do not have a sensible conversion (e.g. random XDR @@ -116,6 +115,7 @@

js-stellar-base/src/scval.js

* - the type you specified (via `opts.type`) is incompatible with the value * you passed in (`val`), e.g. `nativeToScVal("a string", { type: 'i128' })`, * though this does not apply for types that ignore `opts` (e.g. addresses). + * @see scValToNative * * @example * nativeToScVal(1000); // gives ScValType === scvU64 @@ -171,8 +171,6 @@

js-stellar-base/src/scval.js

* * // Similarly, the inverse should work: * scValToNative(scv) == gigaMap; // true - * - * @see scValToNative */ export function nativeToScVal(val, opts = {}) { switch (typeof val) { @@ -259,19 +257,28 @@

js-stellar-base/src/scval.js

return new ScInt(val, { type: opts?.type }).toScVal(); - case 'string': - switch (opts?.type ?? 'string') { + case 'string': { + const optType = opts?.type ?? 'string'; + switch (optType) { case 'string': return xdr.ScVal.scvString(val); case 'symbol': return xdr.ScVal.scvSymbol(val); + case 'address': + return new Address(val).toScVal(); + default: + if (XdrLargeInt.isType(optType)) { + return new XdrLargeInt(optType, val).toScVal(); + } + throw new TypeError( `invalid type (${opts.type}) specified for string value` ); } + } case 'boolean': return xdr.ScVal.scvBool(val); @@ -414,7 +421,7 @@

js-stellar-base/src/scval.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_signerkey.js.html b/js-stellar-base_src_signerkey.js.html index 1c4b6700..74f4fb51 100644 --- a/js-stellar-base_src_signerkey.js.html +++ b/js-stellar-base_src_signerkey.js.html @@ -24,7 +24,7 @@
@@ -143,7 +143,7 @@

js-stellar-base/src/signerkey.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_signing.js.html b/js-stellar-base_src_signing.js.html index 29897e6f..96bae0df 100644 --- a/js-stellar-base_src_signing.js.html +++ b/js-stellar-base_src_signing.js.html @@ -24,7 +24,7 @@
@@ -158,7 +158,7 @@

js-stellar-base/src/signing.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_soroban.js.html b/js-stellar-base_src_soroban.js.html new file mode 100644 index 00000000..78eac165 --- /dev/null +++ b/js-stellar-base_src_soroban.js.html @@ -0,0 +1,128 @@ + + + + + + js-stellar-base/src/soroban.js - Documentation + + + + + + + + + + + + + + + + + +
+ +

js-stellar-base/src/soroban.js

+ + + + + + + +
+
+
/**
+ * Soroban helper class
+ * formatting, parsing, and etc
+ * @class Soroban
+ */
+export class Soroban {
+  /**
+   * All arithmetic inside the contract is performed on integers to
+   * avoid potential precision and consistency issues of floating-point
+   *
+   * This function takes the smart contract value and its decimals (if the token has any) and returns a display value
+   * @param {string} amount - the token amount you want to display
+   * @param {number} decimals - specify how many decimal places a token has
+   * @returns {string} - display value
+   */
+  static formatTokenAmount(amount, decimals) {
+    let formatted = amount;
+
+    if (amount.includes('.')) {
+      throw new Error('No decimal is allowed');
+    }
+
+    if (decimals > 0) {
+      if (decimals > formatted.length) {
+        formatted = ['0', formatted.toString().padStart(decimals, '0')].join(
+          '.'
+        );
+      } else {
+        formatted = [
+          formatted.slice(0, -decimals),
+          formatted.slice(-decimals)
+        ].join('.');
+      }
+    }
+
+    // remove trailing zero if any
+    return formatted.replace(/(\.\d*?)0+$/, '$1');
+  }
+
+  /**
+   * parse token amount to use it on smart contract
+   *
+   * This function takes the display value and its decimals (if the token has
+   * any) and returns a string that'll be used within the smart contract.
+   * @param {string} value - the token amount you want to use it on smart contract
+   * @param {number} decimals - specify how many decimal places a token has
+   * @returns {string} - smart contract value
+   *
+   *
+   * @example
+   * const displayValueAmount = "123.4560"
+   * const parsedAmountForSmartContract = parseTokenAmount("123.4560", 5);
+   * parsedAmountForSmartContract === "12345600"
+   */
+  static parseTokenAmount(value, decimals) {
+    const [whole, fraction, ...rest] = value.split('.').slice();
+
+    if (rest.length) {
+      throw new Error(`Invalid decimal value: ${value}`);
+    }
+
+    const shifted = BigInt(
+      whole + (fraction?.padEnd(decimals, '0') ?? '0'.repeat(decimals))
+    );
+
+    return shifted.toString();
+  }
+}
+
+
+
+ + + + +
+ +
+ +
+ Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme. +
+ + + + + diff --git a/js-stellar-base_src_sorobandata_builder.js.html b/js-stellar-base_src_sorobandata_builder.js.html index dc8daa7d..f2d550e0 100644 --- a/js-stellar-base_src_sorobandata_builder.js.html +++ b/js-stellar-base_src_sorobandata_builder.js.html @@ -24,7 +24,7 @@
@@ -84,8 +84,7 @@

js-stellar-base/src/sorobandata_builder.js

footprint: new xdr.LedgerFootprint({ readOnly: [], readWrite: [] }), instructions: 0, readBytes: 0, - writeBytes: 0, - extendedMetaDataSizeBytes: 0 + writeBytes: 0 }), ext: new xdr.ExtensionPoint(0), refundableFee: new xdr.Int64(0) @@ -133,15 +132,13 @@

js-stellar-base/src/sorobandata_builder.js

* @param {number} cpuInstrs number of CPU instructions * @param {number} readBytes number of bytes being read * @param {number} writeBytes number of bytes being written - * @param {number} metadataBytes number of extended metadata bytes * * @returns {SorobanDataBuilder} */ - setResources(cpuInstrs, readBytes, writeBytes, metadataBytes) { + setResources(cpuInstrs, readBytes, writeBytes) { this._data.resources().instructions(cpuInstrs); this._data.resources().readBytes(readBytes); this._data.resources().writeBytes(writeBytes); - this._data.resources().extendedMetaDataSizeBytes(metadataBytes); return this; } @@ -251,7 +248,7 @@

js-stellar-base/src/sorobandata_builder.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_strkey.js.html b/js-stellar-base_src_strkey.js.html index 4b258fb2..847db80d 100644 --- a/js-stellar-base_src_strkey.js.html +++ b/js-stellar-base_src_strkey.js.html @@ -24,7 +24,7 @@
@@ -449,7 +449,7 @@

js-stellar-base/src/strkey.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_transaction.js.html b/js-stellar-base_src_transaction.js.html index 0c017c25..bb84b261 100644 --- a/js-stellar-base_src_transaction.js.html +++ b/js-stellar-base_src_transaction.js.html @@ -24,7 +24,7 @@
@@ -419,7 +419,7 @@

js-stellar-base/src/transaction.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_transaction_base.js.html b/js-stellar-base_src_transaction_base.js.html index 1d04fa2d..cdb86158 100644 --- a/js-stellar-base_src_transaction_base.js.html +++ b/js-stellar-base_src_transaction_base.js.html @@ -24,7 +24,7 @@
@@ -268,7 +268,7 @@

js-stellar-base/src/transaction_base.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_transaction_builder.js.html b/js-stellar-base_src_transaction_builder.js.html index aae5e6bd..5683dd2f 100644 --- a/js-stellar-base_src_transaction_builder.js.html +++ b/js-stellar-base_src_transaction_builder.js.html @@ -24,7 +24,7 @@
@@ -851,7 +851,7 @@

js-stellar-base/src/transaction_builder.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/js-stellar-base_src_util_decode_encode_muxed_account.js.html b/js-stellar-base_src_util_decode_encode_muxed_account.js.html index 2619e3f7..c2270c3e 100644 --- a/js-stellar-base_src_util_decode_encode_muxed_account.js.html +++ b/js-stellar-base_src_util_decode_encode_muxed_account.js.html @@ -24,7 +24,7 @@
@@ -175,7 +175,7 @@

js-stellar-base/src/util/decode_encode_muxed_account.js
- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/lib_contract_spec.js.html b/lib_contract_spec.js.html index 790de289..32974831 100644 --- a/lib_contract_spec.js.html +++ b/lib_contract_spec.js.html @@ -24,7 +24,7 @@
@@ -51,7 +51,6 @@

lib/contract_spec.js

* This allows the class to be used to convert between native and raw `xdr.ScVal`s. * * @example - * ```js * const specEntries = [...]; // XDR spec entries of a smart contract * const contractSpec = new ContractSpec(specEntries); * @@ -69,17 +68,7 @@

lib/contract_spec.js

* const result = contractSpec.funcResToNative('funcName', resultScv); * * console.log(result); // {success: true} - * ``` */ - -function readObj(args, input) { - let inputName = input.name().toString(); - let entry = Object.entries(args).find(([name, _]) => name === inputName); - if (!entry) { - throw new Error(`Missing field ${inputName}`); - } - return entry[1]; -} class ContractSpec { entries = []; @@ -170,6 +159,9 @@

lib/contract_spec.js

throw new Error(`Multiple outputs not supported`); } let output = outputs[0]; + if (output.switch().value === _stellarBase.xdr.ScSpecType.scSpecTypeResult().value) { + return this.scValToNative(val, output.result().okType()); + } return this.scValToNative(val, output); } @@ -641,6 +633,14 @@

lib/contract_spec.js

return false; } }; +} +function readObj(args, input) { + let inputName = input.name().toString(); + let entry = Object.entries(args).find(([name, _]) => name === inputName); + if (!entry) { + throw new Error(`Missing field ${inputName}`); + } + return entry[1]; }

@@ -653,7 +653,7 @@

lib/contract_spec.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/lib_jsonrpc.js.html b/lib_jsonrpc.js.html index bd03ee40..4716ad79 100644 --- a/lib_jsonrpc.js.html +++ b/lib_jsonrpc.js.html @@ -24,7 +24,7 @@
@@ -47,7 +47,6 @@

lib/jsonrpc.js

exports.post = post; exports.postObject = postObject; var _axios = _interopRequireDefault(require("./axios")); -var _utils = require("./utils"); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } /** * Sends the jsonrpc 'params' as an array. @@ -63,7 +62,7 @@

lib/jsonrpc.js

method, params }); - if ((0, _utils.hasOwnProperty)(response.data, "error")) { + if (hasOwnProperty(response.data, "error")) { throw response.data.error; } else { var _response$data; @@ -82,12 +81,18 @@

lib/jsonrpc.js

method, params: param }); - if ((0, _utils.hasOwnProperty)(response.data, "error")) { + if (hasOwnProperty(response.data, "error")) { throw response.data.error; } else { var _response$data2; return (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.result; } +} + +// Check if the given object X has a field Y, and make that available to +// typescript typing. +function hasOwnProperty(obj, prop) { + return obj.hasOwnProperty(prop); }
@@ -100,7 +105,7 @@

lib/jsonrpc.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/lib_server.js.html b/lib_server.js.html index d7d8ec35..9cc27faa 100644 --- a/lib_server.js.html +++ b/lib_server.js.html @@ -24,7 +24,7 @@
@@ -45,8 +45,8 @@

lib/server.js

value: true }); exports.Server = exports.SUBMIT_TRANSACTION_TIMEOUT = exports.Durability = void 0; -var _stellarBase = require("stellar-base"); var _urijs = _interopRequireDefault(require("urijs")); +var _stellarBase = require("stellar-base"); var _axios = _interopRequireDefault(require("./axios")); var jsonrpc = _interopRequireWildcard(require("./jsonrpc")); var _soroban_rpc = require("./soroban_rpc"); @@ -57,18 +57,19 @@

lib/server.js

/* tslint:disable:variable-name no-namespace */ const SUBMIT_TRANSACTION_TIMEOUT = 60 * 1000; -exports.SUBMIT_TRANSACTION_TIMEOUT = SUBMIT_TRANSACTION_TIMEOUT; + /** * Specifies the durability namespace of contract-related ledger entries. */ +exports.SUBMIT_TRANSACTION_TIMEOUT = SUBMIT_TRANSACTION_TIMEOUT; let Durability = /*#__PURE__*/function (Durability) { Durability["Temporary"] = "temporary"; Durability["Persistent"] = "persistent"; return Durability; }({}); +exports.Durability = Durability; /** - * Server handles the network connection to a - * [Soroban-RPC](https://soroban.stellar.org/docs) instance and exposes an + * Handles the network connection to a Soroban RPC instance, exposing an * interface for requests to that instance. * * @constructor @@ -76,36 +77,27 @@

lib/server.js

* @param {string} serverURL Soroban-RPC Server URL (ex. * `http://localhost:8000/soroban/rpc`). * @param {object} [opts] Options object - * @param {boolean} [opts.allowHttp] - Allow connecting to http servers, - * default: `false`. This must be set to false in production deployments! You - * can also use {@link Config} class to set this globally. - * @param {string} [opts.appName] - Allow set custom header `X-App-Name` - * @param {string} [opts.appVersion] - Allow set custom header `X-App-Version` + * @param {boolean} [opts.allowHttp] allows connecting to insecure http servers + * (default: `false`). This must be set to false in production deployments! + * You can also use {@link Config} class to set this globally. + * @param {Record<string, string>} [opts.headers] allows setting custom headers + * + * @see https://soroban.stellar.org/api/methods */ -exports.Durability = Durability; class Server { - /** - * Soroban-RPC Server URL (ex. `http://localhost:8000/soroban/rpc`). - */ + /** Soroban RPC Server URL (ex. `http://localhost:8000/soroban/rpc`). */ constructor(serverURL, opts = {}) { this.serverURL = (0, _urijs.default)(serverURL); - const customHeaders = {}; - if (opts.appName) { - customHeaders["X-App-Name"] = opts.appName; - } - if (opts.appVersion) { - customHeaders["X-App-Version"] = opts.appVersion; - } - if (Object.keys(customHeaders).length === 0) { + if (opts.headers && Object.keys(opts.headers).length === 0) { _axios.default.interceptors.request.use(config => { // merge the custom headers into any existing headers - config.headers = Object.assign(config.headers, customHeaders); + config.headers = Object.assign(config.headers, opts.headers); return config; }); } if (this.serverURL.protocol() !== "https" && !opts.allowHttp) { - throw new Error("Cannot connect to insecure soroban-rpc server"); + throw new Error("Cannot connect to insecure Soroban RPC server if `allowHttp` isn't set"); } } @@ -115,27 +107,31 @@

lib/server.js

* Needed to get the current sequence number for the account so you can build * a successful transaction with {@link TransactionBuilder}. * + * @param {string} address - The public address of the account to load. + * + * @returns {Promise<Account>} a promise to the {@link Account} object with + * a populated sequence number + * + * @see https://soroban.stellar.org/api/methods/getLedgerEntries * @example - * server.getAccount("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4").then(account => { + * const accountId = "GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4"; + * server.getAccount(accountId).then((account) => { * console.log("sequence:", account.sequence); * }); - * - * @param {string} address - The public address of the account to load. - * @returns {Promise<Account>} Returns a promise to the {@link Account} object with populated sequence number. */ async getAccount(address) { const ledgerKey = _stellarBase.xdr.LedgerKey.account(new _stellarBase.xdr.LedgerKeyAccount({ accountId: _stellarBase.xdr.PublicKey.publicKeyTypeEd25519(_stellarBase.StrKey.decodeEd25519PublicKey(address)) - })).toXDR("base64"); - const data = await jsonrpc.post(this.serverURL.toString(), "getLedgerEntries", [ledgerKey]); - const ledgerEntries = data.entries ?? []; - if (ledgerEntries.length === 0) { + })); + const resp = await this.getLedgerEntries(ledgerKey); + const entries = resp.entries ?? []; + if (entries.length === 0) { return Promise.reject({ code: 404, message: `Account not found: ${address}` }); } - const ledgerEntryData = ledgerEntries[0].xdr; + const ledgerEntryData = entries[0].xdr; const accountEntry = _stellarBase.xdr.LedgerEntryData.fromXDR(ledgerEntryData, "base64").account(); return new _stellarBase.Account(address, accountEntry.seqNum().toString()); } @@ -143,20 +139,41 @@

lib/server.js

/** * General node health check. * + * @returns {Promise<SorobanRpc.GetHealthResponse>} a promise to the + * {@link SorobanRpc.GetHealthResponse} object with the status of the + * server (e.g. "healthy"). + * + * @see https://soroban.stellar.org/api/methods/getHealth * @example - * server.getHealth().then(health => { + * server.getHealth().then((health) => { * console.log("status:", health.status); * }); - * - * @returns {Promise<SorobanRpc.GetHealthResponse>} Returns a promise to the {@link SorobanRpc.GetHealthResponse} object with the status of the server ("healthy"). */ async getHealth() { - return await jsonrpc.post(this.serverURL.toString(), "getHealth"); + return jsonrpc.post(this.serverURL.toString(), "getHealth"); } /** * Reads the current value of contract data ledger entries directly. * + * Allows you to directly inspect the current state of a contract. This is a + * backup way to access your contract data which may not be available via + * events or {@link Server.simulateTransaction}. + * + * @param {string|Address|Contract} contract the contract ID containing the + * data to load as a strkey (`C...` form), a {@link Contract}, or an + * {@link Address} instance + * @param {xdr.ScVal} key the key of the contract data to load + * @param {Durability} [durability=Durability.Persistent] the "durability + * keyspace" that this ledger key belongs to, which is either 'temporary' + * or 'persistent' (the default), see {@link Durability}. + * + * @returns {Promise<SorobanRpc.LedgerEntryResult>} the current data value + * + * @warning If the data entry in question is a 'temporary' entry, it's + * entirely possible that it has expired out of existence. + * + * @see https://soroban.stellar.org/api/methods/getLedgerEntries * @example * const contractId = "CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5"; * const key = xdr.ScVal.scvSymbol("counter"); @@ -165,26 +182,6 @@

lib/server.js

* console.log("lastModified:", data.lastModifiedLedgerSeq); * console.log("latestLedger:", data.latestLedger); * }); - * - * Allows you to directly inspect the current state of a contract. This is a - * backup way to access your contract data which may not be available via - * events or simulateTransaction. - * - * @param {string|Address|Contract} contract - The contract ID containing the - * data to load. Encoded as Stellar Contract Address string (e.g. - * `CCJZ5DGASBWQXR5MPFCJXMBI333XE5U3FSJTNQU7RIKE3P5GN2K2WYD5`), a - * {@link Contract}, or an {@link Address} instance. - * @param {xdr.ScVal} key - The key of the contract data to load. - * @param {Durability} [durability] - The "durability keyspace" that this - * ledger key belongs to, which is either 'temporary' or 'persistent' (the - * default), see {@link Durability}. - * - * @returns {Promise<SorobanRpc.LedgerEntryResult>} Returns a promise to the - * {@link SorobanRpc.LedgerEntryResult} object with the current value. - * - * @warning If the data entry in question is a 'temporary' entry, it's - * entirely possible that it has expired out of existence. Future versions - * of this client may provide abstractions to handle that. */ async getContractData(contract, key, durability = Durability.Persistent) { // coalesce `contract` param variants to an ScAddress @@ -210,38 +207,45 @@

lib/server.js

throw new TypeError(`invalid durability: ${durability}`); } let contractKey = _stellarBase.xdr.LedgerKey.contractData(new _stellarBase.xdr.LedgerKeyContractData({ - contract: scAddress, key, - durability: xdrDurability, - bodyType: _stellarBase.xdr.ContractEntryBodyType.dataEntry() // expirationExtension is internal - })).toXDR("base64"); - return jsonrpc.post(this.serverURL.toString(), "getLedgerEntries", [contractKey]).then(response => { - const ledgerEntries = response.entries ?? []; - if (ledgerEntries.length !== 1) { + contract: scAddress, + durability: xdrDurability + })); + return this.getLedgerEntries(contractKey).then(response => { + const entries = response.entries ?? []; + if (entries.length === 0) { return Promise.reject({ code: 404, message: `Contract data not found. Contract: ${_stellarBase.Address.fromScAddress(scAddress).toString()}, Key: ${key.toXDR("base64")}, Durability: ${durability}` }); } - return ledgerEntries[0]; + return entries[0]; }); } /** - * Reads the current value of ledger entries directly. + * Reads the current value of arbitrary ledger entries directly. * * Allows you to directly inspect the current state of contracts, contract's - * code, or any other ledger entries. This is a backup way to access your - * contract data which may not be available via events or simulateTransaction. + * code, accounts, or any other ledger entries. + * + * To fetch a contract's WASM byte-code, built the appropriate + * {@link xdr.LedgerKeyContractCode} ledger entry key (or see + * {@link Contract.getFootprint}). * - * To fetch contract wasm byte-code, use the ContractCode ledger entry key. + * @param {xdr.ScVal[]} keys one or more ledger entry keys to load * + * @returns {Promise<SorobanRpc.GetLedgerEntriesResponse>} the current + * on-chain values for the given ledger keys + * + * @see https://soroban.stellar.org/api/methods/getLedgerEntries * @example * const contractId = "CAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAD2KM"; * const key = xdr.LedgerKey.contractData(new xdr.LedgerKeyContractData({ * contractId: StrKey.decodeContract(contractId), * key: xdr.ScVal.scvSymbol("counter"), * })); + * * server.getLedgerEntries([key]).then(response => { * const ledgerData = response.entries[0]; * console.log("key:", ledgerData.key); @@ -249,38 +253,31 @@

lib/server.js

* console.log("lastModified:", ledgerData.lastModifiedLedgerSeq); * console.log("latestLedger:", response.latestLedger); * }); - * - * @param {xdr.ScVal[]} keys - The ledger entry keys to load. - * - * @returns {Promise<SorobanRpc.GetLedgerEntriesResponse>} Returns a promise - * to the {@link SorobanRpc.GetLedgerEntriesResponse} object with the - * current value. */ - async getLedgerEntries(keys) { + async getLedgerEntries(...keys) { return await jsonrpc.post(this.serverURL.toString(), "getLedgerEntries", keys.map(k => k.toXDR("base64"))); } /** * Fetch the details of a submitted transaction. * - * When submitting a transaction, clients should poll this to tell when the + * After submitting a transaction, clients should poll this to tell when the * transaction has completed. * + * @param {string} hash hex-encoded hash of the transaction to check + * + * @returns {Promise<SorobanRpc.GetTransactionResponse>} the status, + * result, and other details about the transaction + * + * @see https://soroban.stellar.org/api/methods/getTransaction * @example * const transactionHash = "c4515e3bdc0897f21cc5dbec8c82cf0a936d4741cb74a8e158eb51b9fb00411a"; - * server.getTransaction(transactionHash).then(transaction => { - * console.log("status:", transaction.status); - * console.log("envelopeXdr:", transaction.envelopeXdr); - * console.log("resultMetaXdr:", transaction.resultMetaXdr); - * console.log("resultXdr:", transaction.resultXdr); + * server.getTransaction(transactionHash).then((tx) => { + * console.log("status:", tx.status); + * console.log("envelopeXdr:", tx.envelopeXdr); + * console.log("resultMetaXdr:", tx.resultMetaXdr); + * console.log("resultXdr:", tx.resultXdr); * }); - * - * @param {string} hash - The hex-encoded hash of the transaction to check. - * - * @returns {Promise<SorobanRpc.GetTransactionResponse>} Returns a promise to - * the {@link SorobanRpc.GetTransactionResponse} object with the status, - * result, and other details about the transaction. Raw XDR fields are - * parsed into their appropriate structures wherever possible. */ async getTransaction(hash) { const raw = await jsonrpc.post(this.serverURL.toString(), "getTransaction", hash); @@ -313,7 +310,7 @@

lib/server.js

} /** - * Fetches all events that match a given set of filters. + * Fetch all events that match a given set of filters. * * The given filters (see {@link SorobanRpc.EventFilter} for detailed fields) * are combined only in a logical OR fashion, and all of the fields in each @@ -322,6 +319,11 @@

lib/server.js

* To page through events, use the `pagingToken` field on the relevant * {@link SorobanRpc.EventResponse} object to set the `cursor` parameter. * + * @param {Server.GetEventsRequest} request event filters + * @returns {Promise<SorobanRpc.GetEventsResponse>} a paginatable set of the + * events matching the given event filters + * + * @see https://soroban.stellar.org/api/methods/getEvents * @example * server.getEvents({ * startLedger: "1000", @@ -344,10 +346,6 @@

lib/server.js

* ], * limit: 10, * }); - * - * @returns {Promise<SorobanRpc.GetEventsResponse>} a promise to the - * {@link SorobanRpc.GetEventsResponse} object containing a paginatable set - * of the events matching the given event filters. */ async getEvents(request) { // TODO: It'd be nice if we could do something to infer the types of filter @@ -356,112 +354,104 @@

lib/server.js

// is an ScSymbol and the last is a U32. // // The difficulty comes in matching up the correct integer primitives. - return await jsonrpc.postObject(this.serverURL.toString(), "getEvents", { + return jsonrpc.postObject(this.serverURL.toString(), "getEvents", { filters: request.filters ?? [], pagination: { ...(request.cursor && { cursor: request.cursor }), - // add fields only if defined + // add if defined ...(request.limit && { limit: request.limit }) }, ...(request.startLedger && { - startLedger: String(request.startLedger) + startLedger: request.startLedger.toString() }) }); } /** - * Fetches metadata about the network which Soroban-RPC is connected to. + * Fetch metadata about the network this Soroban RPC server is connected to. + * + * @returns {Promise<SorobanRpc.GetNetworkResponse>} metadata about the + * current network this RPC server is connected to * + * @see https://soroban.stellar.org/api/methods/getNetwork * @example - * server.getNetwork().then(network => { + * server.getNetwork().then((network) => { * console.log("friendbotUrl:", network.friendbotUrl); * console.log("passphrase:", network.passphrase); * console.log("protocolVersion:", network.protocolVersion); * }); - * - * @returns {Promise<SorobanRpc.GetNetworkResponse>} a promise to the - * {@link SorobanRpc.GetNetworkResponse} object containing metadata - * about the current network this soroban-rpc server is connected to. */ async getNetwork() { return await jsonrpc.post(this.serverURL.toString(), "getNetwork"); } /** - * Fetches the latest ledger meta info from network which Soroban-RPC is connected to. + * Fetch the latest ledger meta info from network which this Soroban RPC + * server is connected to. * + * @returns {Promise<SorobanRpc.GetLatestLedgerResponse>} metadata about the + * latest ledger on the network that this RPC server is connected to + * + * @see https://soroban.stellar.org/api/methods/getLatestLedger * @example - * server.getLatestLedger().then(response => { + * server.getLatestLedger().then((response) => { * console.log("hash:", response.id); * console.log("sequence:", response.sequence); * console.log("protocolVersion:", response.protocolVersion); * }); - * - * @returns {Promise<SorobanRpc.GetLatestLedgerResponse>} a promise to the - * {@link SorobanRpc.GetLatestLedgerResponse} object containing metadata - * about the latest ledger from network soroban-rpc server is connected to. */ async getLatestLedger() { - return await jsonrpc.post(this.serverURL.toString(), "getLatestLedger"); + return jsonrpc.post(this.serverURL.toString(), "getLatestLedger"); } /** * Submit a trial contract invocation to get back return values, expected * ledger footprint, expected authorizations, and expected costs. * + * @param {Transaction | FeeBumpTransaction} transaction the transaction to + * simulate, which should include exactly one operation (one of + * {@link xdr.InvokeHostFunctionOp}, {@link xdr.BumpFootprintExpirationOp}, + * or {@link xdr.RestoreFootprintOp}). Any provided footprint or auth + * information will be ignored. + * + * @returns {Promise<SorobanRpc.SimulateTransactionResponse>} an object with + * the cost, footprint, result/auth requirements (if applicable), and error + * of the transaction + * + * @see https://developers.stellar.org/docs/glossary/transactions/ + * @see https://soroban.stellar.org/api/methods/simulateTransaction + * @see Server.prepareTransaction + * @see assembleTransaction + * * @example * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE'; * const contract = new SorobanClient.Contract(contractId); * * // Right now, this is just the default fee for this example. - * const fee = 100; - * - * const transaction = new SorobanClient.TransactionBuilder(account, { - * fee, - * // Uncomment the following line to build transactions for the live network. Be - * // sure to also change the horizon hostname. - * // networkPassphrase: SorobanClient.Networks.PUBLIC, - * networkPassphrase: SorobanClient.Networks.FUTURENET - * }) - * // Add a contract.increment soroban contract invocation operation + * const fee = SorobanClient.BASE_FEE; + * const transaction = new SorobanClient.TransactionBuilder(account, { fee }) + * // Uncomment the following line to build transactions for the live network. Be + * // sure to also change the horizon hostname. + * //.setNetworkPassphrase(SorobanClient.Networks.PUBLIC) + * .setNetworkPassphrase(SorobanClient.Networks.FUTURENET) + * .setTimeout(30) // valid for the next 30s + * // Add an operation to call increment() on the contract * .addOperation(contract.call("increment")) - * // Make this transaction valid for the next 30 seconds only - * .setTimeout(30) - * // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) - * // .addMemo(SorobanClient.Memo.text('Hello world!')) * .build(); * - * // Sign this transaction with the secret key - * // NOTE: signing is transaction is network specific. Test network transactions - * // won't work in the public network. To switch networks, use the Network object - * // as explained above (look for SorobanClient.Network). - * const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey); - * transaction.sign(sourceKeypair); - * - * server.simulateTransaction(transaction).then(sim => { + * server.simulateTransaction(transaction).then((sim) => { * console.log("cost:", sim.cost); * console.log("result:", sim.result); * console.log("error:", sim.error); * console.log("latestLedger:", sim.latestLedger); * }); - * - * @param {Transaction | FeeBumpTransaction} transaction - The transaction to - * simulate. It should include exactly one operation, which must be one of - * {@link xdr.InvokeHostFunctionOp}, {@link xdr.BumpFootprintExpirationOp}, - * or {@link xdr.RestoreFootprintOp}. Any provided footprint will be - * ignored. - * - * @returns {Promise<SorobanRpc.SimulateTransactionResponse>} Returns a - * promise to the {@link SorobanRpc.SimulateTransactionResponse} object - * with the cost, footprint, result/auth requirements (if applicable), and - * error of the transaction. */ async simulateTransaction(transaction) { - return await jsonrpc.post(this.serverURL.toString(), "simulateTransaction", transaction.toXDR()).then(raw => (0, _transaction.parseRawSimulation)(raw)); + return jsonrpc.post(this.serverURL.toString(), "simulateTransaction", transaction.toXDR()).then(_transaction.parseRawSimulation); } /** @@ -479,31 +469,48 @@

lib/server.js

* * You can call the {@link Server.simulateTransaction} method directly first * if you want to inspect estimated fees for a given transaction in detail - * first, if that is of importance. + * first, then re-assemble it manually or via {@link assembleTransaction}. + * + * @param {Transaction | FeeBumpTransaction} transaction the transaction to + * prepare. It should include exactly one operation, which must be one of + * {@link xdr.InvokeHostFunctionOp}, {@link xdr.BumpFootprintExpirationOp}, + * or {@link xdr.RestoreFootprintOp}. * + * Any provided footprint will be overwritten. However, if your operation + * has existing auth entries, they will be preferred over ALL auth entries + * from the simulation. In other words, if you include auth entries, you + * don't care about the auth returned from the simulation. Other fields + * (footprint, etc.) will be filled as normal. + * @param {string} [networkPassphrase] explicitly provide a network + * passphrase (default: requested from the server via + * {@link Server.getNetwork}). + * + * @returns {Promise<Transaction | FeeBumpTransaction>} a copy of the + * transaction with the expected authorizations (in the case of + * invocation), resources, and ledger footprints added. The transaction fee + * will also automatically be padded with the contract's minimum resource + * fees discovered from the simulation. + * + * @see assembleTransaction + * @see https://soroban.stellar.org/api/methods/simulateTransaction + * @throws {jsonrpc.Error<any> | Error} if simulation fails * @example * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE'; * const contract = new SorobanClient.Contract(contractId); * * // Right now, this is just the default fee for this example. - * const fee = 100; - * - * const transaction = new SorobanClient.TransactionBuilder(account, { - * fee, - * // Uncomment the following line to build transactions for the live network. Be - * // sure to also change the horizon hostname. - * // networkPassphrase: SorobanClient.Networks.PUBLIC, - * networkPassphrase: SorobanClient.Networks.TESTNET - * }) - * // Add a contract.increment soroban contract invocation operation + * const fee = SorobanClient.BASE_FEE; + * const transaction = new SorobanClient.TransactionBuilder(account, { fee }) + * // Uncomment the following line to build transactions for the live network. Be + * // sure to also change the horizon hostname. + * //.setNetworkPassphrase(SorobanClient.Networks.PUBLIC) + * .setNetworkPassphrase(SorobanClient.Networks.FUTURENET) + * .setTimeout(30) // valid for the next 30s + * // Add an operation to call increment() on the contract * .addOperation(contract.call("increment")) - * // Make this transaction valid for the next 30 seconds only - * .setTimeout(30) - * // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) - * // .addMemo(SorobanClient.Memo.text('Hello world!')) * .build(); * - * preparedTransaction = await server.prepareTransaction(transaction); + * const preparedTransaction = await server.prepareTransaction(transaction); * * // Sign this transaction with the secret key * // NOTE: signing is transaction is network specific. Test network transactions @@ -517,28 +524,6 @@

lib/server.js

* console.log("status:", result.status); * console.log("errorResultXdr:", result.errorResultXdr); * }); - * - * @param {Transaction | FeeBumpTransaction} transaction - The transaction to - * prepare. It should include exactly one operation, which must be one of - * {@link xdr.InvokeHostFunctionOp}, {@link xdr.BumpFootprintExpirationOp}, - * or {@link xdr.RestoreFootprintOp}. - * - * Any provided footprint will be overwritten. However, if your operation - * has existing auth entries, they will be preferred over ALL auth entries - * from the simulation. In other words, if you include auth entries, you - * don't care about the auth returned from the simulation. Other fields - * (footprint, etc.) will be filled as normal. - * @param {string} [networkPassphrase] - Explicitly provide a network - * passphrase. If not passed, the current network passphrase will be - * requested from the server via {@link Server.getNetwork}. - * - * @returns {Promise<Transaction | FeeBumpTransaction>} Returns a copy of the - * transaction, with the expected authorizations (in the case of - * invocation) and ledger footprint added. The transaction fee will also - * automatically be padded with the contract's minimum resource fees - * discovered from the simulation. - * - * @throws {jsonrpc.Error<any> | Error} if simulation fails */ async prepareTransaction(transaction, networkPassphrase) { const [{ @@ -546,7 +531,7 @@

lib/server.js

}, simResponse] = await Promise.all([networkPassphrase ? Promise.resolve({ passphrase: networkPassphrase }) : this.getNetwork(), this.simulateTransaction(transaction)]); - if (simResponse.error) { + if (_soroban_rpc.SorobanRpc.isSimulationError(simResponse)) { throw simResponse.error; } if (!simResponse.result) { @@ -556,34 +541,33 @@

lib/server.js

} /** - * Submit a real transaction to the Stellar network. This is the only way to - * make changes "on-chain". Unlike Horizon, Soroban-RPC does not wait for - * transaction completion. It simply validates the transaction and enqueues - * it. Clients should call {@link Server#getTransactionStatus} to learn about - * transaction success/failure. + * Submit a real transaction to the Stellar network. + * + * Unlike Horizon, Soroban RPC does not wait for transaction completion. It + * simply validates the transaction and enqueues it. Clients should call + * {@link Server.getTransactionStatus} to learn about transaction + * success/failure. + * + * @param {Transaction | FeeBumpTransaction} transaction to submit + * @returns {Promise<SorobanRpc.SendTransactionResponse>} the + * transaction id, status, and any error if available * + * @see https://developers.stellar.org/docs/glossary/transactions/ + * @see https://soroban.stellar.org/api/methods/sendTransaction * @example * const contractId = 'CA3D5KRYM6CB7OWQ6TWYRR3Z4T7GNZLKERYNZGGA5SOAOPIFY6YQGAXE'; * const contract = new SorobanClient.Contract(contractId); * * // Right now, this is just the default fee for this example. - * const fee = 100; - * - * const transaction = new SorobanClient.TransactionBuilder(account, { - * fee, - * // Uncomment the following line to build transactions for the live network. Be - * // sure to also change the horizon hostname. - * // networkPassphrase: SorobanClient.Networks.PUBLIC, - * networkPassphrase: SorobanClient.Networks.STANDALONE - * }) - * // Add a contract.increment soroban contract invocation operation - * // Note: For real transactions you will need to include the footprint - * // and auth in the operation, as returned from simulateTransaction. + * const fee = SorobanClient.BASE_FEE; + * const transaction = new SorobanClient.TransactionBuilder(account, { fee }) + * // Uncomment the following line to build transactions for the live network. Be + * // sure to also change the horizon hostname. + * //.setNetworkPassphrase(SorobanClient.Networks.PUBLIC) + * .setNetworkPassphrase(SorobanClient.Networks.FUTURENET) + * .setTimeout(30) // valid for the next 30s + * // Add an operation to call increment() on the contract * .addOperation(contract.call("increment")) - * // Make this transaction valid for the next 30 seconds only - * .setTimeout(30) - * // Uncomment to add a memo (https://developers.stellar.org/docs/glossary/transactions/) - * // .addMemo(SorobanClient.Memo.text('Hello world!')) * .build(); * * // Sign this transaction with the secret key @@ -593,45 +577,44 @@

lib/server.js

* const sourceKeypair = SorobanClient.Keypair.fromSecret(sourceSecretKey); * transaction.sign(sourceKeypair); * - * server.sendTransaction(transaction).then(result => { + * server.sendTransaction(transaction).then((result) => { * console.log("hash:", result.hash); * console.log("status:", result.status); * console.log("errorResultXdr:", result.errorResultXdr); * }); - * - * @param {Transaction | FeeBumpTransaction} transaction - The transaction to - * submit. - * @returns {Promise<SorobanRpc.SendTransactionResponse>} Returns a promise to - * the {@link SorobanRpc.SendTransactionResponse} object with the - * transaction id, status, and any error if available. */ async sendTransaction(transaction) { return await jsonrpc.post(this.serverURL.toString(), "sendTransaction", transaction.toXDR()); } /** - * Use the friendbot faucet to create and fund a new account. The method will - * return an Account object for the created account, or if the account already - * existed. If friendbot is not configured on this network, this method will - * throw an error. If the request fails, this method will throw an error. + * Fund a new account using the network's friendbot faucet, if any. + * + * @param {string | Account} address the address or account instance that we + * want to create and fund with friendbot + * @param {string} [friendbotUrl] optionally, an explicit address for + * friendbot (by default: this calls the Soroban RPC + * {@link Server.getNetwork} method to try to discover this network's + * Friendbot url). * + * @returns {Promise<Account>} an {@link Account} object for the created + * account, or the existing account if it's already funded with the + * populated sequence number (note that the account will not be "topped + * off" if it already exists) + * + * @throws if Friendbot is not configured on this network or request failure + * + * @see + * https://developers.stellar.org/docs/fundamentals-and-concepts/testnet-and-pubnet#friendbot + * @see Friendbot.Response * @example * server * .requestAirdrop("GBZC6Y2Y7Q3ZQ2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4QZJ2XZ3Z5YXZ6Z7Z2Y4") - * .then(accountCreated => { + * .then((accountCreated) => { * console.log("accountCreated:", accountCreated); - * }).catch(error => { + * }).catch((error) => { * console.error("error:", error); * }); - * - * @param {string | Account} address - The address or account we want to - * create and fund. - * @param {string} [friendbotUrl] - The optional explicit address for - * friendbot. If not provided, the client will call the Soroban-RPC - * `getNetwork` method to attempt to find this network's friendbot url. - * - * @returns {Promise<Account>} Returns a promise to the {@link Account} object - * with populated sequence number. */ async requestAirdrop(address, friendbotUrl) { const account = typeof address === "string" ? address : address.accountId(); @@ -665,13 +648,10 @@

lib/server.js

operations = meta.operations(); break; case 1: - operations = meta.v1().operations(); - break; case 2: - operations = meta.v2().operations(); - break; case 3: - operations = meta.v3().operations(); + // all three have the same interface + operations = meta.value().operations(); break; default: throw new Error("Unexpected transaction meta switch value"); @@ -701,7 +681,7 @@

lib/server.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/lib_soroban_rpc.js.html b/lib_soroban_rpc.js.html index 2303620e..48acc662 100644 --- a/lib_soroban_rpc.js.html +++ b/lib_soroban_rpc.js.html @@ -24,7 +24,7 @@
@@ -66,6 +66,33 @@

lib/soroban_rpc.js

return GetTransactionStatus; }({}); _SorobanRpc.GetTransactionStatus = GetTransactionStatus; + /** + * Simplifies {@link RawSimulateTransactionResponse} into separate interfaces + * based on status: + * - on success, this includes all fields, though `result` is only present + * if an invocation was simulated (since otherwise there's nothing to + * "resultify") + * - if there was an expiration error, this includes error and restoration + * fields + * - for all other errors, this only includes error fields + * + * @see https://soroban.stellar.org/api/methods/simulateTransaction#returns + */ + /** Includes simplified fields only present on success. */ + /** Includes details about why the simulation failed */ + function isSimulationError(sim) { + return 'error' in sim; + } + _SorobanRpc.isSimulationError = isSimulationError; + function isSimulationSuccess(sim) { + return 'transactionData' in sim; + } + _SorobanRpc.isSimulationSuccess = isSimulationSuccess; + function isSimulationRestore(sim) { + return isSimulationSuccess(sim) && 'restorePreamble' in sim; + } + _SorobanRpc.isSimulationRestore = isSimulationRestore; + /** @see https://soroban.stellar.org/api/methods/simulateTransaction#returns */ })(SorobanRpc || (exports.SorobanRpc = SorobanRpc = {})); @@ -78,7 +105,7 @@

lib/soroban_rpc.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.
diff --git a/lib_transaction.js.html b/lib_transaction.js.html index a8fedba9..93b88c62 100644 --- a/lib_transaction.js.html +++ b/lib_transaction.js.html @@ -24,7 +24,7 @@
@@ -47,6 +47,7 @@

lib/transaction.js

exports.assembleTransaction = assembleTransaction; exports.parseRawSimulation = parseRawSimulation; var _stellarBase = require("stellar-base"); +var _soroban_rpc = require("./soroban_rpc"); /** * Combines the given raw transaction alongside the simulation results. * @@ -74,12 +75,12 @@

lib/transaction.js

if (!isSorobanTransaction(raw)) { throw new TypeError("unsupported transaction: must contain exactly one " + "invokeHostFunction, bumpFootprintExpiration, or restoreFootprint " + "operation"); } - const coalesced = parseRawSimulation(simulation); - if (!coalesced.result) { - throw new Error(`simulation incorrect: ${JSON.stringify(coalesced)}`); + let success = parseRawSimulation(simulation); + if (!_soroban_rpc.SorobanRpc.isSimulationSuccess(success)) { + throw new Error(`simulation incorrect: ${JSON.stringify(success)}`); } const classicFeeNum = parseInt(raw.fee) || 0; - const minResourceFeeNum = parseInt(coalesced.minResourceFee) || 0; + const minResourceFeeNum = parseInt(success.minResourceFee) || 0; const txnBuilder = _stellarBase.TransactionBuilder.cloneFrom(raw, { // automatically update the tx fee that will be set on the resulting tx to // the sum of 'classic' fee provided from incoming tx.fee and minResourceFee @@ -91,7 +92,7 @@

lib/transaction.js

// soroban transaction will be equal to incoming tx.fee + minResourceFee. fee: (classicFeeNum + minResourceFeeNum).toString(), // apply the pre-built Soroban Tx Data from simulation onto the Tx - sorobanData: coalesced.transactionData.build(), + sorobanData: success.transactionData.build(), networkPassphrase }); switch (raw.operations[0].type) { @@ -108,25 +109,12 @@

lib/transaction.js

// // the intuition is "if auth exists, this tx has probably been // simulated before" - auth: existingAuth.length > 0 ? existingAuth : coalesced.result.auth + auth: existingAuth.length > 0 ? existingAuth : success.result.auth })); break; } return txnBuilder; } -function isSorobanTransaction(tx) { - if (tx.operations.length !== 1) { - return false; - } - switch (tx.operations[0].type) { - case "invokeHostFunction": - case "bumpFootprintExpiration": - case "restoreFootprint": - return true; - default: - return false; - } -} /** * Converts a raw response schema into one with parsed XDR fields and a @@ -138,38 +126,83 @@

lib/transaction.js

* @returns the original parameter (if already parsed), parsed otherwise */ function parseRawSimulation(sim) { - var _sim$results; + var _sim$events; const looksRaw = isSimulationRaw(sim); if (!looksRaw) { // Gordon Ramsey in shambles return sim; } - return { + + // shared across all responses + let base = { id: sim.id, - minResourceFee: sim.minResourceFee, latestLedger: sim.latestLedger, - cost: sim.cost, - transactionData: new _stellarBase.SorobanDataBuilder(sim.transactionData), - events: (sim.events ?? []).map(event => _stellarBase.xdr.DiagnosticEvent.fromXDR(event, "base64")), - ...(sim.error !== undefined && { + events: ((_sim$events = sim.events) === null || _sim$events === void 0 ? void 0 : _sim$events.map(evt => _stellarBase.xdr.DiagnosticEvent.fromXDR(evt, 'base64'))) ?? [] + }; + + // error type: just has error string + if (typeof sim.error === 'string') { + return { + ...base, error: sim.error - }), - // only if present - // ^ XOR v - ...((sim.results ?? []).length > 0 && { - result: (_sim$results = sim.results) === null || _sim$results === void 0 ? void 0 : _sim$results.map(result => { + }; + } + return parseSuccessful(sim, base); +} +function parseSuccessful(sim, partial) { + var _sim$results; + // success type: might have a result (if invoking) and... + const success = { + ...partial, + transactionData: new _stellarBase.SorobanDataBuilder(sim.transactionData), + minResourceFee: sim.minResourceFee, + cost: sim.cost, + ...( + // coalesce 0-or-1-element results[] list into a single result struct + // with decoded fields if present + (((_sim$results = sim.results) === null || _sim$results === void 0 ? void 0 : _sim$results.length) ?? 0 > 0) && { + result: sim.results.map(row => { return { - auth: (result.auth ?? []).map(entry => _stellarBase.xdr.SorobanAuthorizationEntry.fromXDR(entry, "base64")), - retval: _stellarBase.xdr.ScVal.fromXDR(result.xdr, "base64") + auth: (row.auth ?? []).map(entry => _stellarBase.xdr.SorobanAuthorizationEntry.fromXDR(entry, 'base64')), + // if return value is missing ("falsy") we coalesce to void + retval: !!row.xdr ? _stellarBase.xdr.ScVal.fromXDR(row.xdr, 'base64') : _stellarBase.xdr.ScVal.scvVoid() }; - })[0] // only if present + })[0] }) }; -} + if (!sim.restorePreamble) { + return success; + } + // ...might have a restoration hint (if some state is expired) + return { + ...success, + restorePreamble: { + minResourceFee: sim.restorePreamble.minResourceFee, + transactionData: new _stellarBase.SorobanDataBuilder(sim.restorePreamble.transactionData) + } + }; +} function isSimulationRaw(sim) { - // lazy check to determine parameter type - return sim.result === undefined || typeof sim.transactionData === "string" || (sim.results ?? []).length > 0; + var _asRaw$events; + const asGud = sim; + const asRaw = sim; + + // lazy checks to determine type: check existence of parsed-only fields note + return asRaw.restorePreamble !== undefined || !(asGud.restorePreamble !== undefined || asGud.result !== undefined || typeof asGud.transactionData !== 'string') || asRaw.error !== undefined && (!((_asRaw$events = asRaw.events) !== null && _asRaw$events !== void 0 && _asRaw$events.length) || typeof asRaw.events[0] === 'string') || (asRaw.results ?? []).length > 0; +} +function isSorobanTransaction(tx) { + if (tx.operations.length !== 1) { + return false; + } + switch (tx.operations[0].type) { + case "invokeHostFunction": + case "bumpFootprintExpiration": + case "restoreFootprint": + return true; + default: + return false; + } } @@ -182,7 +215,7 @@

lib/transaction.js


- Generated by JSDoc 4.0.2 on Fri Sep 01 2023 22:20:20 GMT+0000 (Coordinated Universal Time) using the Minami theme. + Generated by JSDoc 4.0.2 on Wed Sep 13 2023 23:46:44 GMT+0000 (Coordinated Universal Time) using the Minami theme.