From b0ffc4b7ea6268fedc307df9b7ad080e59a42e38 Mon Sep 17 00:00:00 2001 From: Mike Turner Date: Tue, 14 Jan 2025 11:29:45 -0600 Subject: [PATCH] Update some types to interfaces, export all types, update docs --- package.json | 15 +- sdk/docs/Account.html | 70 +- sdk/docs/AleoKeyProvider.html | 71 + sdk/docs/AleoKeyProviderParams.html | 3 + ...yProviderParams_AleoKeyProviderParams.html | 3 + sdk/docs/AleoNetworkClient.html | 162 +- sdk/docs/BlockHeightSearch.html | 13 + sdk/docs/ExecuteOptions.html | 3 + sdk/docs/FunctionKeyProvider.html | 69 + sdk/docs/KeySearchParams.html | 3 + sdk/docs/NetworkRecordProvider.html | 63 + sdk/docs/OfflineKeyProvider.html | 100 ++ sdk/docs/OfflineSearchParams.html | 7 + ...flineSearchParams_OfflineSearchParams.html | 3 + sdk/docs/ProgramManager.html | 401 +++++ sdk/docs/ProgramManager_ProgramManager.html | 3 + sdk/docs/RecordProvider.html | 46 + sdk/docs/RecordSearchParams.html | 3 + sdk/docs/account.ts.html | 59 +- sdk/docs/data/search.json | 2 +- sdk/docs/function-key-provider.ts.html | 617 ++++++++ sdk/docs/index.html | 4 +- sdk/docs/network-client.ts.html | 827 +++++++++++ sdk/docs/offline-key-provider.ts.html | 609 ++++++++ sdk/docs/program-manager.ts.html | 1302 +++++++++++++++++ sdk/docs/record-provider.ts.html | 306 ++++ sdk/docs/scripts/core.js | 135 +- sdk/docs/scripts/core.min.js | 4 +- sdk/docs/scripts/search.min.js | 10 +- sdk/docs/sdk/docs/public/aleo.svg | 5 + sdk/docs/styles/clean-jsdoc-theme-base.css | 1098 ++++++++------ sdk/docs/styles/clean-jsdoc-theme-dark.css | 25 +- sdk/docs/styles/clean-jsdoc-theme-light.css | 298 ++-- .../styles/clean-jsdoc-theme-scrollbar.css | 30 + ...lean-jsdoc-theme-without-scrollbar.min.css | 1 + sdk/docs/styles/clean-jsdoc-theme.min.css | 2 +- sdk/jsdoc.json | 8 +- sdk/package.json | 8 +- sdk/src/browser.ts | 14 +- sdk/src/models/confirmed_transaction.ts | 2 +- sdk/src/models/deploy.ts | 2 +- sdk/src/models/executionJSON.ts | 2 +- sdk/src/models/functionObject.ts | 4 +- sdk/src/models/input/inputJSON.ts | 2 +- sdk/src/models/input/inputObject.ts | 5 +- sdk/src/models/output/outputJSON.ts | 2 +- sdk/src/models/output/outputObject.ts | 4 +- sdk/src/models/plaintext/plaintext.ts | 2 +- sdk/src/models/transaction/transactionJSON.ts | 2 +- ...sactionSummary.ts => transactionObject.ts} | 2 +- sdk/src/models/transition/transitionJSON.ts | 2 +- sdk/src/models/transition/transitionObject.ts | 4 +- sdk/src/network-client.ts | 15 +- sdk/tests/key-provider.test.ts | 257 ++-- sdk/tests/network-client.test.ts | 10 +- yarn.lock | 8 +- 56 files changed, 5852 insertions(+), 875 deletions(-) create mode 100644 sdk/docs/AleoKeyProvider.html create mode 100644 sdk/docs/AleoKeyProviderParams.html create mode 100644 sdk/docs/AleoKeyProviderParams_AleoKeyProviderParams.html create mode 100644 sdk/docs/BlockHeightSearch.html create mode 100644 sdk/docs/ExecuteOptions.html create mode 100644 sdk/docs/FunctionKeyProvider.html create mode 100644 sdk/docs/KeySearchParams.html create mode 100644 sdk/docs/NetworkRecordProvider.html create mode 100644 sdk/docs/OfflineKeyProvider.html create mode 100644 sdk/docs/OfflineSearchParams.html create mode 100644 sdk/docs/OfflineSearchParams_OfflineSearchParams.html create mode 100644 sdk/docs/ProgramManager.html create mode 100644 sdk/docs/ProgramManager_ProgramManager.html create mode 100644 sdk/docs/RecordProvider.html create mode 100644 sdk/docs/RecordSearchParams.html create mode 100644 sdk/docs/function-key-provider.ts.html create mode 100644 sdk/docs/network-client.ts.html create mode 100644 sdk/docs/offline-key-provider.ts.html create mode 100644 sdk/docs/program-manager.ts.html create mode 100644 sdk/docs/record-provider.ts.html create mode 100644 sdk/docs/sdk/docs/public/aleo.svg create mode 100644 sdk/docs/styles/clean-jsdoc-theme-scrollbar.css create mode 100644 sdk/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css rename sdk/src/models/transaction/{transactionSummary.ts => transactionObject.ts} (88%) diff --git a/package.json b/package.json index 4d144e863..5ea91538e 100644 --- a/package.json +++ b/package.json @@ -15,24 +15,23 @@ "scripts": { "build:wasm": "cd wasm && yarn build", "build:sdk": "cd sdk && yarn build", + "build:sdk-docs": "jsdoc -c sdk/jsdoc.json", "build:create-leo-app": "cd create-leo-app && yarn build", "build:all": "yarn build:wasm && yarn build:sdk && yarn build:create-leo-app", - "start:website": "cd website && yarn dev", + "deploy:wasm": "cd wasm && npm publish --access=public", + "deploy:sdk": "cd sdk && npm publish --access=public", + "deploy:create-leo-app": "cd create-leo-app && npm publish --access=public", + "deploy": "yarn build:all && yarn deploy:wasm && yarn deploy:sdk && yarn deploy:create-leo-app", "test:wasm": "cd wasm && yarn test", "test:sdk": "cd sdk && yarn test", "test": "yarn test:wasm && yarn test:sdk", "change-version": "node scripts/change-version.js", - - "deploy:wasm": "cd wasm && npm publish --access=public", - "deploy:sdk": "cd sdk && npm publish --access=public", - "deploy:create-leo-app": "cd create-leo-app && npm publish --access=public", - "deploy": "yarn build:all && yarn deploy:wasm && yarn deploy:sdk && yarn deploy:create-leo-app", - "lint": "prettier . --check", - "pretty": "prettier . --write" + "pretty": "prettier . --write", + "start:website": "cd website && yarn dev" }, "optionalDependencies": { "glob": "^11.0.0" diff --git a/sdk/docs/Account.html b/sdk/docs/Account.html index 8e9cd146a..67384c912 100644 --- a/sdk/docs/Account.html +++ b/sdk/docs/Account.html @@ -1,35 +1,35 @@ Class: Account
On this page

Account

Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from an existing private key or seed, and message signing and verification functionality. An Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key, and a public account address are derived. The private key lies at the root of an Aleo account. It is a highly sensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value transfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public address to which other users of Aleo can send Aleo credits and other records to. This class should only be used environments where the safety of the underlying key material can be assured.

Constructor

new Account()

Example
// Create a new account
-let myRandomAccount = new Account();
+    
On this page

Account

Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from an existing private key or seed, and message signing and verification functionality. An Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key, and a public account address are derived. The private key lies at the root of an Aleo account. It is a highly sensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value transfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public address to which other users of Aleo can send Aleo credits and other records to. This class should only be used environments where the safety of the underlying key material can be assured.

Constructor

new Account()

Example
// Create a new account
+const myRandomAccount = new Account();
 
 // Create an account from a randomly generated seed
-let seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);
-let mySeededAccount = new Account({seed: seed});
+const seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);
+const mySeededAccount = new Account({seed: seed});
 
 // Create an account from an existing private key
-let myExistingAccount = new Account({privateKey: 'myExistingPrivateKey'})
+const myExistingAccount = new Account({privateKey: 'myExistingPrivateKey'})
 
 // Sign a message
-let hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
-let signature = myRandomAccount.sign(hello_world)
+const hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+const signature = myRandomAccount.sign(hello_world)
 
 // Verify a signature
-myRandomAccount.verify(hello_world, signature)

Classes

Account

Methods

(static) fromCiphertext(ciphertext, password) → {PrivateKey|Error}

Attempts to create an account from a private key ciphertext
Parameters:
NameTypeDescription
ciphertextPrivateKeyCiphertext | string
passwordstring
Returns:
Type: 
PrivateKey | Error
Example
let ciphertext = PrivateKey.newEncrypted("password");
-let account = Account.fromCiphertext(ciphertext, "password");

(static) fromCiphertext(ciphertext, password) → {PrivateKey|Error}

Attempts to create an account from a private key ciphertext
Parameters:
NameTypeDescription
ciphertextPrivateKeyCiphertext | string
passwordstring
Returns:
Type: 
PrivateKey | Error
Example
let ciphertext = PrivateKey.newEncrypted("password");
-let account = Account.fromCiphertext(ciphertext, "password");

decryptRecord(ciphertext) → {Record}

Decrypts a Record in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
Record
Example
let account = new Account();
-let record = account.decryptRecord("record1ciphertext");

decryptRecord(ciphertext) → {Record}

Decrypts a Record in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
Record
Example
let account = new Account();
-let record = account.decryptRecord("record1ciphertext");

decryptRecords(ciphertexts) → {Array.<Record>}

Decrypts an array of Records in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextsArray.<string>
Returns:
Type: 
Array.<Record>
Example
let account = new Account();
-let record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);

decryptRecords(ciphertexts) → {Array.<Record>}

Decrypts an array of Records in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextsArray.<string>
Returns:
Type: 
Array.<Record>
Example
let account = new Account();
-let record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);

encryptAccount(ciphertext) → {PrivateKeyCiphertext}

Encrypt the account's private key with a password
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
PrivateKeyCiphertext
Example
let account = new Account();
-let ciphertext = account.encryptAccount("password");

encryptAccount(ciphertext) → {PrivateKeyCiphertext}

Encrypt the account's private key with a password
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
PrivateKeyCiphertext
Example
let account = new Account();
-let ciphertext = account.encryptAccount("password");

ownsRecordCiphertext(ciphertext) → {boolean}

Determines whether the account owns a ciphertext record
Parameters:
NameTypeDescription
ciphertextRecordCipherText | string
Returns:
Type: 
boolean
Example
// Create a connection to the Aleo network and an account
-let connection = new NodeConnection("vm.aleo.org/api");
-let account = Account.fromCiphertext("ciphertext", "password");
+myRandomAccount.verify(hello_world, signature)

Classes

Account

Methods

(static) fromCiphertext(ciphertext, password) → {PrivateKey}

Attempts to create an account from a private key ciphertext
Parameters:
NameTypeDescription
ciphertextPrivateKeyCiphertext | string
passwordstring
Returns:
Type: 
PrivateKey
Example
const ciphertext = PrivateKey.newEncrypted("password");
+const account = Account.fromCiphertext(ciphertext, "password");

(static) fromCiphertext(ciphertext, password) → {PrivateKey}

Attempts to create an account from a private key ciphertext
Parameters:
NameTypeDescription
ciphertextPrivateKeyCiphertext | string
passwordstring
Returns:
Type: 
PrivateKey
Example
const ciphertext = PrivateKey.newEncrypted("password");
+const account = Account.fromCiphertext(ciphertext, "password");

decryptRecord(ciphertext) → {Record}

Decrypts a Record in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
Record
Example
const account = new Account();
+const record = account.decryptRecord("record1ciphertext");

decryptRecord(ciphertext) → {Record}

Decrypts a Record in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
Record
Example
const account = new Account();
+const record = account.decryptRecord("record1ciphertext");

decryptRecords(ciphertexts) → {Array.<Record>}

Decrypts an array of Records in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextsArray.<string>
Returns:
Type: 
Array.<Record>
Example
const account = new Account();
+const record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);

decryptRecords(ciphertexts) → {Array.<Record>}

Decrypts an array of Records in ciphertext form into plaintext
Parameters:
NameTypeDescription
ciphertextsArray.<string>
Returns:
Type: 
Array.<Record>
Example
const account = new Account();
+const record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);

encryptAccount(ciphertext) → {PrivateKeyCiphertext}

Encrypt the account's private key with a password
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
PrivateKeyCiphertext
Example
const account = new Account();
+const ciphertext = account.encryptAccount("password");

encryptAccount(ciphertext) → {PrivateKeyCiphertext}

Encrypt the account's private key with a password
Parameters:
NameTypeDescription
ciphertextstring
Returns:
Type: 
PrivateKeyCiphertext
Example
const account = new Account();
+const ciphertext = account.encryptAccount("password");

ownsRecordCiphertext(ciphertext) → {boolean}

Determines whether the account owns a ciphertext record
Parameters:
NameTypeDescription
ciphertextRecordCipherText | string
Returns:
Type: 
boolean
Example
// Create a connection to the Aleo network and an account
+const connection = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const account = Account.fromCiphertext("ciphertext", "password");
 
 // Get a record from the network
-let record = connection.getBlock(1234);
-let recordCipherText = record.transactions[0].execution.transitions[0].id;
+const record = connection.getBlock(1234);
+const recordCipherText = record.transactions[0].execution.transitions[0].id;
 
 // Check if the account owns the record
 if account.ownsRecord(recordCipherText) {
@@ -38,12 +38,12 @@
     // Store the record in a local database
     // Etc.
 }

ownsRecordCiphertext(ciphertext) → {boolean}

Determines whether the account owns a ciphertext record
Parameters:
NameTypeDescription
ciphertextRecordCipherText | string
Returns:
Type: 
boolean
Example
// Create a connection to the Aleo network and an account
-let connection = new NodeConnection("vm.aleo.org/api");
-let account = Account.fromCiphertext("ciphertext", "password");
+const connection = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const account = Account.fromCiphertext("ciphertext", "password");
 
 // Get a record from the network
-let record = connection.getBlock(1234);
-let recordCipherText = record.transactions[0].execution.transitions[0].id;
+const record = connection.getBlock(1234);
+const recordCipherText = record.transactions[0].execution.transitions[0].id;
 
 // Check if the account owns the record
 if account.ownsRecord(recordCipherText) {
@@ -51,14 +51,14 @@
     // Decrypt the record and check if it's spent
     // Store the record in a local database
     // Etc.
-}

sign(message) → {Signature}

Signs a message with the account's private key. Returns a Signature.
Parameters:
NameTypeDescription
messageUint8Array
Returns:
Type: 
Signature
Example
let account = new Account();
-let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
-account.sign(message);

sign(message) → {Signature}

Signs a message with the account's private key. Returns a Signature.
Parameters:
NameTypeDescription
messageUint8Array
Returns:
Type: 
Signature
Example
let account = new Account();
-let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
-account.sign(message);

verify(message, signature) → {boolean}

Verifies the Signature on a message.
Parameters:
NameTypeDescription
messageUint8Array
signatureSignature
Returns:
Type: 
boolean
Example
let account = new Account();
-let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
-let signature = account.sign(message);
-account.verify(message, signature);

verify(message, signature) → {boolean}

Verifies the Signature on a message.
Parameters:
NameTypeDescription
messageUint8Array
signatureSignature
Returns:
Type: 
boolean
Example
let account = new Account();
-let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
-let signature = account.sign(message);
-account.verify(message, signature);
\ No newline at end of file +}

sign(message) → {Signature}

Signs a message with the account's private key. Returns a Signature.
Parameters:
NameTypeDescription
messageUint8Array
Returns:
Type: 
Signature
Example
const account = new Account();
+const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+account.sign(message);

sign(message) → {Signature}

Signs a message with the account's private key. Returns a Signature.
Parameters:
NameTypeDescription
messageUint8Array
Returns:
Type: 
Signature
Example
const account = new Account();
+const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+account.sign(message);

verify(message, signature) → {boolean}

Verifies the Signature on a message.
Parameters:
NameTypeDescription
messageUint8Array
signatureSignature
Returns:
Type: 
boolean
Example
const account = new Account();
+const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+const signature = account.sign(message);
+account.verify(message, signature);

verify(message, signature) → {boolean}

Verifies the Signature on a message.
Parameters:
NameTypeDescription
messageUint8Array
signatureSignature
Returns:
Type: 
boolean
Example
const account = new Account();
+const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+const signature = account.sign(message);
+account.verify(message, signature);
\ No newline at end of file diff --git a/sdk/docs/AleoKeyProvider.html b/sdk/docs/AleoKeyProvider.html new file mode 100644 index 000000000..77fb09d6a --- /dev/null +++ b/sdk/docs/AleoKeyProvider.html @@ -0,0 +1,71 @@ +Class: AleoKeyProvider
On this page

AleoKeyProvider

AleoKeyProvider class. Implements the KeyProvider interface. Enables the retrieval of Aleo program proving and verifying keys for the credits.aleo program over http from official Aleo sources and storing and retrieving function keys from a local memory cache.

Constructor

new AleoKeyProvider()

Methods

cacheKeys(keyId, keys)

Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
Parameters:
NameTypeDescription
keyIdstringaccess key for the cache
keysFunctionKeyPairkeys to cache

cacheKeys(keyId, keys)

Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
Parameters:
NameTypeDescription
keyIdstringaccess key for the cache
keysFunctionKeyPairkeys to cache

clearCache()

Clear the key cache

clearCache()

Clear the key cache

containsKeys(keyId) → {boolean}

Determine if a keyId exists in the cache
Parameters:
NameTypeDescription
keyIdstringkeyId of a proving and verifying key pair
Returns:
true if the keyId exists in the cache, false otherwise
Type: 
boolean

containsKeys(keyId) → {boolean}

Determine if a keyId exists in the cache
Parameters:
NameTypeDescription
keyIdstringkeyId of a proving and verifying key pair
Returns:
true if the keyId exists in the cache, false otherwise
Type: 
boolean

deleteKeys(keyId) → {boolean}

Delete a set of keys from the cache
Parameters:
NameTypeDescription
keyIdstringkeyId of a proving and verifying key pair to delete from memory
Returns:
true if the keyId exists in the cache and was deleted, false if the key did not exist
Type: 
boolean

deleteKeys(keyId) → {boolean}

Delete a set of keys from the cache
Parameters:
NameTypeDescription
keyIdstringkeyId of a proving and verifying key pair to delete from memory
Returns:
true if the keyId exists in the cache and was deleted, false if the key did not exist
Type: 
boolean

(async) feePrivateKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the fee_private function in the credits.aleo program
Returns:
Proving and verifying keys for the fee function
Type: 
Promise.<FunctionKeyPair>

(async) feePrivateKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the fee_private function in the credits.aleo program
Returns:
Proving and verifying keys for the fee function
Type: 
Promise.<FunctionKeyPair>

(async) feePublicKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the fee_public function in the credits.aleo program
Returns:
Proving and verifying keys for the fee function
Type: 
Promise.<FunctionKeyPair>

(async) feePublicKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the fee_public function in the credits.aleo program
Returns:
Proving and verifying keys for the fee function
Type: 
Promise.<FunctionKeyPair>

(async) fetchRemoteKeys(verifierUrl, proverUrl, cacheKey) → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for a specified program from a specified url.
Parameters:
NameTypeDescription
verifierUrlstringUrl of the proving key
proverUrlstringUrl the verifying key
cacheKeystringKey to store the keys in the cache
Returns:
Proving and verifying keys for the specified program
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new AleoKeyProvider object
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually
+const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.fetchKeys(
+    CREDITS_PROGRAM_KEYS.transfer_private.prover,
+    CREDITS_PROGRAM_KEYS.transfer_private.verifier,
+);

(async) fetchRemoteKeys(verifierUrl, proverUrl, cacheKey) → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for a specified program from a specified url.
Parameters:
NameTypeDescription
verifierUrlstringUrl of the proving key
proverUrlstringUrl the verifying key
cacheKeystringKey to store the keys in the cache
Returns:
Proving and verifying keys for the specified program
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new AleoKeyProvider object
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually
+const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.fetchKeys(
+    CREDITS_PROGRAM_KEYS.transfer_private.prover,
+    CREDITS_PROGRAM_KEYS.transfer_private.verifier,
+);

(async) functionKeys(params) → {Promise.<FunctionKeyPair>}

Get arbitrary function keys from a provider
Parameters:
NameTypeDescription
paramsKeySearchParamsparameters for the key search in form of: {proverUri: string, verifierUri: string, cacheKey: string}
Returns:
Proving and verifying keys for the specified program
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new object which implements the KeyProvider interface
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually using the key provider
+const keySearchParams = { "cacheKey": "myProgram:myFunction" };
+const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(keySearchParams);

(async) functionKeys(params) → {Promise.<FunctionKeyPair>}

Get arbitrary function keys from a provider
Parameters:
NameTypeDescription
paramsKeySearchParamsparameters for the key search in form of: {proverUri: string, verifierUri: string, cacheKey: string}
Returns:
Proving and verifying keys for the specified program
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new object which implements the KeyProvider interface
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually using the key provider
+const keySearchParams = { "cacheKey": "myProgram:myFunction" };
+const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(keySearchParams);

getKeys(keyId) → {FunctionKeyPair}

Get a set of keys from the cache
Parameters:
NameTypeDescription
keyIdkeyId of a proving and verifying key pair
Returns:
Proving and verifying keys for the specified program
Type: 
FunctionKeyPair

getKeys(keyId) → {FunctionKeyPair}

Get a set of keys from the cache
Parameters:
NameTypeDescription
keyIdkeyId of a proving and verifying key pair
Returns:
Proving and verifying keys for the specified program
Type: 
FunctionKeyPair

(async) getVerifyingKey() → {Promise.<VerifyingKey>}

Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise
Returns:
Verifying key for the function
Type: 
Promise.<VerifyingKey>

(async) getVerifyingKey(verifierUri) → {Promise.<VerifyingKey>}

Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise
Parameters:
NameTypeDescription
verifierUristring
Returns:
Verifying key for the function
Type: 
Promise.<VerifyingKey>

(async) joinKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the join function in the credits.aleo program
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

(async) joinKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the join function in the credits.aleo program
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

(async) splitKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the split function in the credits.aleo program
Returns:
Proving and verifying keys for the split function
Type: 
Promise.<FunctionKeyPair>

(async) splitKeys() → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the split function in the credits.aleo program
Returns:
Proving and verifying keys for the split function
Type: 
Promise.<FunctionKeyPair>

(async) transferKeys(visibility) → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the transfer functions in the credits.aleo program
Parameters:
NameTypeDescription
visibilitystringVisibility of the transfer function
Returns:
Proving and verifying keys for the transfer functions
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new AleoKeyProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually
+const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");

(async) transferKeys(visibility) → {Promise.<FunctionKeyPair>}

Returns the proving and verifying keys for the transfer functions in the credits.aleo program
Parameters:
NameTypeDescription
visibilitystringVisibility of the transfer function
Returns:
Proving and verifying keys for the transfer functions
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new AleoKeyProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually
+const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");

useCache(useCache)

Use local memory to store keys
Parameters:
NameTypeDescription
useCachebooleanwhether to store keys in local memory

useCache(useCache)

Use local memory to store keys
Parameters:
NameTypeDescription
useCachebooleanwhether to store keys in local memory
\ No newline at end of file diff --git a/sdk/docs/AleoKeyProviderParams.html b/sdk/docs/AleoKeyProviderParams.html new file mode 100644 index 000000000..c4b2d5342 --- /dev/null +++ b/sdk/docs/AleoKeyProviderParams.html @@ -0,0 +1,3 @@ +Class: AleoKeyProviderParams
On this page

AleoKeyProviderParams

AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.

Constructor

new AleoKeyProviderParams(params)

Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally specify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must be provided.
Parameters:
NameTypeDescription
paramsAleoKeyProviderInitParamsOptional search parameters

Classes

AleoKeyProviderParams
\ No newline at end of file diff --git a/sdk/docs/AleoKeyProviderParams_AleoKeyProviderParams.html b/sdk/docs/AleoKeyProviderParams_AleoKeyProviderParams.html new file mode 100644 index 000000000..01c07083e --- /dev/null +++ b/sdk/docs/AleoKeyProviderParams_AleoKeyProviderParams.html @@ -0,0 +1,3 @@ +Class: AleoKeyProviderParams
On this page

AleoKeyProviderParams# AleoKeyProviderParams

new AleoKeyProviderParams(params)

Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally specify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must be provided.
Parameters:
NameTypeDescription
paramsAleoKeyProviderInitParamsOptional search parameters
\ No newline at end of file diff --git a/sdk/docs/AleoNetworkClient.html b/sdk/docs/AleoNetworkClient.html index d98259076..0e8b47e7a 100644 --- a/sdk/docs/AleoNetworkClient.html +++ b/sdk/docs/AleoNetworkClient.html @@ -1,31 +1,167 @@ -Class: AleoNetworkClient
On this page

AleoNetworkClient

Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this class provide information on the Aleo Blockchain

Constructor

new AleoNetworkClient(host)

Parameters:
NameTypeDescription
hoststring
Example
// Connection to a local node
-let local_connection = new AleoNetworkClient("http://localhost:3030");
+Class: AleoNetworkClient
On this page

AleoNetworkClient

Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this allow users to query public information from the Aleo blockchain and submit transactions to the network.

Constructor

new AleoNetworkClient(host)

Parameters:
NameTypeDescription
hoststring
Example
// Connection to a local node
+const localNetworkClient = new AleoNetworkClient("http://localhost:3030");
 
 // Connection to a public beacon node
-let public_connection = new AleoNetworkClient("https://api.explorer.aleo.org/v1");

Classes

AleoNetworkClient

Methods

(async) findUnspentRecords()

Attempts to find unspent records in the Aleo blockchain for a specified private key
Example
// Find all unspent records
+const publicnetworkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");

Methods

(async) findUnspentRecords(startHeight, endHeight, privateKey, amounts, maxMicrocredits, nonces)

Attempts to find unspent records in the Aleo blockchain for a specified private key.
Parameters:
NameTypeDescription
startHeightnumberThe height at which to start searching for unspent records
endHeightnumberThe height at which to stop searching for unspent records
privateKeystring | PrivateKeyThe private key to use to find unspent records
amountsArray.<number>The amounts (in microcredits) to search for (eg. [100, 200, 3000])
maxMicrocreditsnumberThe maximum number of microcredits to search for
noncesArray.<string>The nonces of already found records to exclude from the search
Example
// Find all unspent records
 const privateKey = "[PRIVATE_KEY]";
-let records = connection.findUnspentRecords(0, undefined, privateKey);
+const records = networkClient.findUnspentRecords(0, undefined, privateKey);
 
 // Find specific amounts
 const startHeight = 500000;
 const amounts = [600000, 1000000];
-let records = connection.findUnspentRecords(startHeight, undefined, privateKey, amounts);
+const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, amounts);
 
 // Find specific amounts with a maximum number of cumulative microcredits
 const maxMicrocredits = 100000;
-let records = connection.findUnspentRecords(startHeight, undefined, privateKey, undefined, maxMicrocredits);

(async) findUnspentRecords(startHeight, endHeight, privateKey, amounts, maxMicrocredits) → {Promise.<(Array.<RecordPlaintext>|Error)>}

Attempts to find unspent records in the Aleo blockchain for a specified private key
Parameters:
NameTypeDescription
startHeightnumber
endHeightnumber | undefined
privateKeystring | undefined
amountsArray | undefined
maxMicrocreditsnumber | undefined
Returns:
Type: 
Promise.<(Array.<RecordPlaintext>|Error)>
Example
// Find all unspent records
+const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, undefined, maxMicrocredits);

(async) findUnspentRecords(startHeight, endHeight, privateKey, amounts, maxMicrocredits, nonces) → {Promise.<Array.<RecordPlaintext>>}

Attempts to find unspent records in the Aleo blockchain for a specified private key.
Parameters:
NameTypeDescription
startHeightnumberThe height at which to start searching for unspent records
endHeightnumberThe height at which to stop searching for unspent records
privateKeystring | PrivateKeyThe private key to use to find unspent records
amountsArray.<number>The amounts (in microcredits) to search for (eg. [100, 200, 3000])
maxMicrocreditsnumberThe maximum number of microcredits to search for
noncesArray.<string>The nonces of already found records to exclude from the search
Returns:
Type: 
Promise.<Array.<RecordPlaintext>>
Example
// Find all unspent records
 const privateKey = "[PRIVATE_KEY]";
-let records = connection.findUnspentRecords(0, undefined, privateKey);
+const records = networkClient.findUnspentRecords(0, undefined, privateKey);
 
 // Find specific amounts
 const startHeight = 500000;
 const amounts = [600000, 1000000];
-let records = connection.findUnspentRecords(startHeight, undefined, privateKey, amounts);
+const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, amounts);
 
 // Find specific amounts with a maximum number of cumulative microcredits
 const maxMicrocredits = 100000;
-let records = connection.findUnspentRecords(startHeight, undefined, privateKey, undefined, maxMicrocredits);

getAccount()

Return the Aleo account used in the node connection
Example
let account = connection.getAccount();

getAccount() → {Account|undefined}

Return the Aleo account used in the node connection
Returns:
Type: 
Account | undefined
Example
let account = connection.getAccount();

(async) getBlock(height)

Returns the block contents of the block at the specified block height
Parameters:
NameTypeDescription
heightnumber
Example
let block = connection.getBlock(1234);

(async) getBlock(height) → {Promise.<(Block|Error)>}

Returns the block contents of the block at the specified block height
Parameters:
NameTypeDescription
heightnumber
Returns:
Type: 
Promise.<(Block|Error)>
Example
let block = connection.getBlock(1234);

(async) getBlockRange(start, end)

Returns a range of blocks between the specified block heights
Parameters:
NameTypeDescription
startnumber
endnumber
Example
let blockRange = connection.getBlockRange(2050, 2100);

(async) getBlockRange(start, end) → {Promise.<(Array.<Block>|Error)>}

Returns a range of blocks between the specified block heights
Parameters:
NameTypeDescription
startnumber
endnumber
Returns:
Type: 
Promise.<(Array.<Block>|Error)>
Example
let blockRange = connection.getBlockRange(2050, 2100);

(async) getLatestBlock()

Returns the block contents of the latest block
Example
let latestHeight = connection.getLatestBlock();

(async) getLatestBlock() → {Promise.<(Block|Error)>}

Returns the block contents of the latest block
Returns:
Type: 
Promise.<(Block|Error)>
Example
let latestHeight = connection.getLatestBlock();

(async) getLatestHash()

Returns the hash of the last published block
Example
let latestHash = connection.getLatestHash();

(async) getLatestHash() → {Promise.<(string|Error)>}

Returns the hash of the last published block
Returns:
Type: 
Promise.<(string|Error)>
Example
let latestHash = connection.getLatestHash();

(async) getLatestHeight()

Returns the latest block height
Example
let latestHeight = connection.getLatestHeight();

(async) getLatestHeight() → {Promise.<(number|Error)>}

Returns the latest block height
Returns:
Type: 
Promise.<(number|Error)>
Example
let latestHeight = connection.getLatestHeight();

(async) getProgram(programId)

Returns the source code of a program
Parameters:
NameTypeDescription
programIdstring
Example
let program = connection.getProgram("foo.aleo");

(async) getProgram(programId) → {Promise.<(string|Error)>}

Returns the source code of a program
Parameters:
NameTypeDescription
programIdstring
Returns:
Type: 
Promise.<(string|Error)>
Example
let program = connection.getProgram("foo.aleo");

(async) getStateRoot()

Returns the latest state/merkle root of the Aleo blockchain
Example
let stateRoot = connection.getStateRoot();

(async) getStateRoot() → {Promise.<(string|Error)>}

Returns the latest state/merkle root of the Aleo blockchain
Returns:
Type: 
Promise.<(string|Error)>
Example
let stateRoot = connection.getStateRoot();

(async) getTransaction(id)

Returns a transaction by its unique identifier
Parameters:
NameTypeDescription
idstring
Example
let transaction = connection.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");

(async) getTransaction(id) → {Promise.<(Transaction|Error)>}

Returns a transaction by its unique identifier
Parameters:
NameTypeDescription
idstring
Returns:
Type: 
Promise.<(Transaction|Error)>
Example
let transaction = connection.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");

(async) getTransactions(height)

Returns the transactions present at the specified block height
Parameters:
NameTypeDescription
heightnumber
Example
let transactions = connection.getTransactions(654);

(async) getTransactions(height) → {Promise.<(Array.<Transaction>|Error)>}

Returns the transactions present at the specified block height
Parameters:
NameTypeDescription
heightnumber
Returns:
Type: 
Promise.<(Array.<Transaction>|Error)>
Example
let transactions = connection.getTransactions(654);

(async) getTransactionsInMempool()

Returns the transactions in the memory pool.
Example
let transactions = connection.getTransactionsInMempool();

(async) getTransactionsInMempool() → {Promise.<(Array.<Transaction>|Error)>}

Returns the transactions in the memory pool.
Returns:
Type: 
Promise.<(Array.<Transaction>|Error)>
Example
let transactions = connection.getTransactionsInMempool();

(async) getTransitionId()

Returns the transition id by its unique identifier
Example
let transition = connection.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");

(async) getTransitionId(transition_id) → {Promise.<(Transition|Error)>}

Returns the transition id by its unique identifier
Parameters:
NameTypeDescription
transition_idstring
Returns:
Type: 
Promise.<(Transition|Error)>
Example
let transition = connection.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");

setAccount(account)

Set an account
Parameters:
NameTypeDescription
accountAccount
Example
let account = new Account();
-connection.setAccount(account);

setAccount(account)

Set an account
Parameters:
NameTypeDescription
accountAccount
Example
let account = new Account();
-connection.setAccount(account);
\ No newline at end of file +const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, undefined, maxMicrocredits);

getAccount()

Return the Aleo account used in the networkClient
Example
const account = networkClient.getAccount();

getAccount() → {Account|undefined}

Return the Aleo account used in the networkClient
Returns:
Type: 
Account | undefined
Example
const account = networkClient.getAccount();

(async) getBlock(height)

Returns the contents of the block at the specified block height.
Parameters:
NameTypeDescription
heightnumber
Example
const block = networkClient.getBlock(1234);

(async) getBlock(height) → {Promise.<BlockJSON>}

Returns the contents of the block at the specified block height.
Parameters:
NameTypeDescription
heightnumber
Returns:
Type: 
Promise.<BlockJSON>
Example
const block = networkClient.getBlock(1234);

(async) getBlockRange(start, end)

Returns a range of blocks between the specified block heights.
Parameters:
NameTypeDescription
startnumber
endnumber
Example
const blockRange = networkClient.getBlockRange(2050, 2100);

(async) getBlockRange(start, end) → {Promise.<Array.<BlockJSON>>}

Returns a range of blocks between the specified block heights.
Parameters:
NameTypeDescription
startnumber
endnumber
Returns:
Type: 
Promise.<Array.<BlockJSON>>
Example
const blockRange = networkClient.getBlockRange(2050, 2100);

(async) getDeploymentTransactionForProgram(program) → {TransactionJSON}

Returns the deployment transaction associated with a specified program.
Parameters:
NameTypeDescription
programProgram | string
Returns:
Type: 
TransactionJSON

(async) getDeploymentTransactionForProgram(program) → {TransactionJSON}

Returns the deployment transaction associated with a specified program.
Parameters:
NameTypeDescription
programProgram | string
Returns:
Type: 
TransactionJSON

(async) getDeploymentTransactionIDForProgram(program) → {TransactionJSON}

Returns the deployment transaction id associated with the specified program.
Parameters:
NameTypeDescription
programProgram | string
Returns:
Type: 
TransactionJSON

(async) getDeploymentTransactionIDForProgram(program) → {TransactionJSON}

Returns the deployment transaction id associated with the specified program.
Parameters:
NameTypeDescription
programProgram | string
Returns:
Type: 
TransactionJSON

(async) getDeploymentTransactioObjectnForProgram(program) → {TransactionJSON}

Returns the deployment transaction associated with a specified program as a wasm object.
Parameters:
NameTypeDescription
programProgram | string
Returns:
Type: 
TransactionJSON

(async) getDeploymentTransactioObjectnForProgram(program) → {TransactionJSON}

Returns the deployment transaction associated with a specified program as a wasm object.
Parameters:
NameTypeDescription
programProgram | string
Returns:
Type: 
TransactionJSON

(async) getLatestBlock()

Returns the contents of the latest block.
Example
const latestHeight = networkClient.getLatestBlock();

(async) getLatestBlock() → {Promise.<BlockJSON>}

Returns the contents of the latest block.
Returns:
Type: 
Promise.<BlockJSON>
Example
const latestHeight = networkClient.getLatestBlock();

(async) getLatestCommittee() → {Promise.<object>}

Returns the latest committee.
Returns:
A javascript object containing the latest committee
Type: 
Promise.<object>

(async) getLatestCommittee() → {Promise.<object>}

Returns the latest committee.
Returns:
A javascript object containing the latest committee
Type: 
Promise.<object>

(async) getLatestHeight()

Returns the latest block height.
Example
const latestHeight = networkClient.getLatestHeight();

(async) getLatestHeight() → {Promise.<number>}

Returns the latest block height.
Returns:
Type: 
Promise.<number>
Example
const latestHeight = networkClient.getLatestHeight();

(async) getProgram(programId) → {Promise.<string>}

Returns the source code of a program given a program ID.
Parameters:
NameTypeDescription
programIdstringThe program ID of a program deployed to the Aleo Network
Returns:
Source code of the program
Type: 
Promise.<string>
Example
const program = networkClient.getProgram("hello_hello.aleo");
+const expectedSource = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n"
+assert.equal(program, expectedSource);

(async) getProgram(programId) → {Promise.<string>}

Returns the source code of a program given a program ID.
Parameters:
NameTypeDescription
programIdstringThe program ID of a program deployed to the Aleo Network
Returns:
Source code of the program
Type: 
Promise.<string>
Example
const program = networkClient.getProgram("hello_hello.aleo");
+const expectedSource = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n"
+assert.equal(program, expectedSource);

(async) getProgramImportNames(inputProgram) → {Array.<string>}

Get a list of the program names that a program imports.
Parameters:
NameTypeDescription
inputProgramProgram | stringThe program id or program source code to get the imports of
Returns:
- The list of program names that the program imports
Type: 
Array.<string>
Example
const programImportsNames = networkClient.getProgramImports("double_test.aleo");
+const expectedImportsNames = ["multiply_test.aleo"];
+assert.deepStrictEqual(programImportsNames, expectedImportsNames);

(async) getProgramImportNames(inputProgram) → {Array.<string>}

Get a list of the program names that a program imports.
Parameters:
NameTypeDescription
inputProgramProgram | stringThe program id or program source code to get the imports of
Returns:
- The list of program names that the program imports
Type: 
Array.<string>
Example
const programImportsNames = networkClient.getProgramImports("double_test.aleo");
+const expectedImportsNames = ["multiply_test.aleo"];
+assert.deepStrictEqual(programImportsNames, expectedImportsNames);

(async) getProgramImports(inputProgram) → {Promise.<ProgramImports>}

Returns an object containing the source code of a program and the source code of all programs it imports
Parameters:
NameTypeDescription
inputProgramProgram | stringThe program ID or program source code of a program deployed to the Aleo Network
Returns:
Object of the form { "program_id": "program_source", .. } containing program id & source code for all program imports
Type: 
Promise.<ProgramImports>
Example
const double_test_source = "import multiply_test.aleo;\n\nprogram double_test.aleo;\n\nfunction double_it:\n    input r0 as u32.private;\n    call multiply_test.aleo/multiply 2u32 r0 into r1;\n    output r1 as u32.private;\n"
+const double_test = Program.fromString(double_test_source);
+const expectedImports = {
+    "multiply_test.aleo": "program multiply_test.aleo;\n\nfunction multiply:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    mul r0 r1 into r2;\n    output r2 as u32.private;\n"
+}
+
+// Imports can be fetched using the program ID, source code, or program object
+let programImports = await networkClient.getProgramImports("double_test.aleo");
+assert.deepStrictEqual(programImports, expectedImports);
+
+// Using the program source code
+programImports = await networkClient.getProgramImports(double_test_source);
+assert.deepStrictEqual(programImports, expectedImports);
+
+// Using the program object
+programImports = await networkClient.getProgramImports(double_test);
+assert.deepStrictEqual(programImports, expectedImports);

(async) getProgramImports(inputProgram) → {Promise.<ProgramImports>}

Returns an object containing the source code of a program and the source code of all programs it imports
Parameters:
NameTypeDescription
inputProgramProgram | stringThe program ID or program source code of a program deployed to the Aleo Network
Returns:
Object of the form { "program_id": "program_source", .. } containing program id & source code for all program imports
Type: 
Promise.<ProgramImports>
Example
const double_test_source = "import multiply_test.aleo;\n\nprogram double_test.aleo;\n\nfunction double_it:\n    input r0 as u32.private;\n    call multiply_test.aleo/multiply 2u32 r0 into r1;\n    output r1 as u32.private;\n"
+const double_test = Program.fromString(double_test_source);
+const expectedImports = {
+    "multiply_test.aleo": "program multiply_test.aleo;\n\nfunction multiply:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    mul r0 r1 into r2;\n    output r2 as u32.private;\n"
+}
+
+// Imports can be fetched using the program ID, source code, or program object
+let programImports = await networkClient.getProgramImports("double_test.aleo");
+assert.deepStrictEqual(programImports, expectedImports);
+
+// Using the program source code
+programImports = await networkClient.getProgramImports(double_test_source);
+assert.deepStrictEqual(programImports, expectedImports);
+
+// Using the program object
+programImports = await networkClient.getProgramImports(double_test);
+assert.deepStrictEqual(programImports, expectedImports);

(async) getProgramMappingNames(programId)

Returns the names of the mappings of a program.
Parameters:
NameTypeDescription
programIdstringThe program ID to get the mappings of (e.g. "credits.aleo")
Example
const mappings = networkClient.getProgramMappingNames("credits.aleo");
+const expectedMappings = ["account"];
+assert.deepStrictEqual(mappings, expectedMappings);

(async) getProgramMappingNames(programId) → {Promise.<Array.<string>>}

Returns the names of the mappings of a program.
Parameters:
NameTypeDescription
programIdstringThe program ID to get the mappings of (e.g. "credits.aleo")
Returns:
Type: 
Promise.<Array.<string>>
Example
const mappings = networkClient.getProgramMappingNames("credits.aleo");
+const expectedMappings = ["account"];
+assert.deepStrictEqual(mappings, expectedMappings);

(async) getProgramMappingPlaintext(programId, mappingName, key) → {Promise.<string>}

Returns the value of a mapping as a wasm Plaintext object. Returning an object in this format allows it to be converted to a Js type and for its internal members to be inspected if it's a struct or array.
Parameters:
NameTypeDescription
programIdstringThe program ID to get the mapping value of (e.g. "credits.aleo")
mappingNamestringThe name of the mapping to get the value of (e.g. "account")
keystring | PlaintextThe key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
Returns:
String representation of the value of the mapping
Type: 
Promise.<string>
Example
// Get the bond state as an account.
+const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
+
+// Get the two members of the object individually.
+const validator = unbondedState.getMember("validator");
+const microcredits = unbondedState.getMember("microcredits");
+
+// Ensure the expected values are correct.
+assert.equal(validator, "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd");
+assert.equal(microcredits, BigInt("9007199254740991"));
+
+// Get a JS object representation of the unbonded state.
+const unbondedStateObject = unbondedState.toObject();
+
+const expectedState = {
+    validator: "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd",
+    microcredits: BigInt("9007199254740991")
+};
+assert.equal(unbondedState, expectedState);

(async) getProgramMappingPlaintext(programId, mappingName, key) → {Promise.<string>}

Returns the value of a mapping as a wasm Plaintext object. Returning an object in this format allows it to be converted to a Js type and for its internal members to be inspected if it's a struct or array.
Parameters:
NameTypeDescription
programIdstringThe program ID to get the mapping value of (e.g. "credits.aleo")
mappingNamestringThe name of the mapping to get the value of (e.g. "account")
keystring | PlaintextThe key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
Returns:
String representation of the value of the mapping
Type: 
Promise.<string>
Example
// Get the bond state as an account.
+const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
+
+// Get the two members of the object individually.
+const validator = unbondedState.getMember("validator");
+const microcredits = unbondedState.getMember("microcredits");
+
+// Ensure the expected values are correct.
+assert.equal(validator, "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd");
+assert.equal(microcredits, BigInt("9007199254740991"));
+
+// Get a JS object representation of the unbonded state.
+const unbondedStateObject = unbondedState.toObject();
+
+const expectedState = {
+    validator: "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd",
+    microcredits: BigInt("9007199254740991")
+};
+assert.equal(unbondedState, expectedState);

(async) getProgramMappingValue(programId, mappingName, key) → {Promise.<string>}

Returns the value of a program's mapping for a specific key.
Parameters:
NameTypeDescription
programIdstringThe program ID to get the mapping value of (e.g. "credits.aleo")
mappingNamestringThe name of the mapping to get the value of (e.g. "account")
keystring | PlaintextThe key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
Returns:
String representation of the value of the mapping
Type: 
Promise.<string>
Example
// Get public balance of an account
+const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
+const expectedValue = "0u64";
+assert.equal(mappingValue, expectedValue);

(async) getProgramMappingValue(programId, mappingName, key) → {Promise.<string>}

Returns the value of a program's mapping for a specific key.
Parameters:
NameTypeDescription
programIdstringThe program ID to get the mapping value of (e.g. "credits.aleo")
mappingNamestringThe name of the mapping to get the value of (e.g. "account")
keystring | PlaintextThe key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
Returns:
String representation of the value of the mapping
Type: 
Promise.<string>
Example
// Get public balance of an account
+const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
+const expectedValue = "0u64";
+assert.equal(mappingValue, expectedValue);

(async) getProgramObject(inputProgram) → {Promise.<Program>}

Returns a program object from a program ID or program source code.
Parameters:
NameTypeDescription
inputProgramstringThe program ID or program source code of a program deployed to the Aleo Network
Returns:
Source code of the program
Type: 
Promise.<Program>
Example
const programID = "hello_hello.aleo";
+const programSource = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n"
+
+// Get program object from program ID or program source code
+const programObjectFromID = await networkClient.getProgramObject(programID);
+const programObjectFromSource = await networkClient.getProgramObject(programSource);
+
+// Both program objects should be equal
+assert.equal(programObjectFromID.to_string(), programObjectFromSource.to_string());

(async) getProgramObject(inputProgram) → {Promise.<Program>}

Returns a program object from a program ID or program source code.
Parameters:
NameTypeDescription
inputProgramstringThe program ID or program source code of a program deployed to the Aleo Network
Returns:
Source code of the program
Type: 
Promise.<Program>
Example
const programID = "hello_hello.aleo";
+const programSource = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n"
+
+// Get program object from program ID or program source code
+const programObjectFromID = await networkClient.getProgramObject(programID);
+const programObjectFromSource = await networkClient.getProgramObject(programSource);
+
+// Both program objects should be equal
+assert.equal(programObjectFromID.to_string(), programObjectFromSource.to_string());

(async) getStateRoot()

Returns the latest state/merkle root of the Aleo blockchain.
Example
const stateRoot = networkClient.getStateRoot();

(async) getStateRoot() → {Promise.<string>}

Returns the latest state/merkle root of the Aleo blockchain.
Returns:
Type: 
Promise.<string>
Example
const stateRoot = networkClient.getStateRoot();

(async) getTransaction(id)

Returns a transaction by its unique identifier.
Parameters:
NameTypeDescription
idstring
Example
const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");

(async) getTransaction(id) → {Promise.<TransactionJSON>}

Returns a transaction by its unique identifier.
Parameters:
NameTypeDescription
idstring
Returns:
Type: 
Promise.<TransactionJSON>
Example
const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");

(async) getTransactionObject(transactionId)

Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs, outputs, and records to be searched for and displayed.
Parameters:
NameTypeDescription
transactionIdstring
Examples
const transactionObject = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
+// Get the transaction inputs as a JS array.
+const transactionOutputs = transactionObject.inputs(true);
+
+// Get the transaction outputs as a JS object.
+const transactionInputs = transactionObject.outputs(true);
+
+// Get any records generated in transitions in the transaction as a JS object.
+const records = transactionObject.records();
+
+// Get the transaction type.
+const transactionType = transactionObject.transactionType();
+assert.equal(transactionType, "Execute");
+
+// Get a JS representation of all inputs, outputs, and transaction metadata.
+const transactionSummary = transactionObject.summary();
const transaction = networkClient.getTransactionObject("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");

(async) getTransactionObject(transactionId) → {Promise.<Transaction>}

Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs, outputs, and records to be searched for and displayed.
Parameters:
NameTypeDescription
transactionIdstring
Returns:
Type: 
Promise.<Transaction>
Examples
const transactionObject = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
+// Get the transaction inputs as a JS array.
+const transactionOutputs = transactionObject.inputs(true);
+
+// Get the transaction outputs as a JS object.
+const transactionInputs = transactionObject.outputs(true);
+
+// Get any records generated in transitions in the transaction as a JS object.
+const records = transactionObject.records();
+
+// Get the transaction type.
+const transactionType = transactionObject.transactionType();
+assert.equal(transactionType, "Execute");
+
+// Get a JS representation of all inputs, outputs, and transaction metadata.
+const transactionSummary = transactionObject.summary();
const transaction = networkClient.getTransactionObject("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");

(async) getTransactionObjects(height)

Returns an array of transactions as wasm objects present at the specified block height.
Parameters:
NameTypeDescription
heightnumber
Example
const transactions = networkClient.getTransactionObjects(654);
+
+let transaction_summaries = transactions.map(transaction => transaction.summary());

(async) getTransactionObjects(height) → {Promise.<Array.<Transaction>>}

Returns an array of transactions as wasm objects present at the specified block height.
Parameters:
NameTypeDescription
heightnumber
Returns:
Type: 
Promise.<Array.<Transaction>>
Example
const transactions = networkClient.getTransactionObjects(654);
+
+let transaction_summaries = transactions.map(transaction => transaction.summary());

(async) getTransactionObjectsInMempool()

Returns the transactions in the memory pool as wasm objects.
Example
const transactions = networkClient.getTransactionsInMempool();

(async) getTransactionObjectsInMempool() → {Promise.<Array.<Transaction>>}

Returns the transactions in the memory pool as wasm objects.
Returns:
Type: 
Promise.<Array.<Transaction>>
Example
const transactions = networkClient.getTransactionsInMempool();

(async) getTransactions(height)

Returns the transactions present at the specified block height.
Parameters:
NameTypeDescription
heightnumber
Example
const transactions = networkClient.getTransactions(654);

(async) getTransactions(height) → {Promise.<Array.<TransactionJSON>>}

Returns the transactions present at the specified block height.
Parameters:
NameTypeDescription
heightnumber
Returns:
Type: 
Promise.<Array.<TransactionJSON>>
Example
const transactions = networkClient.getTransactions(654);

(async) getTransactionsInMempool()

Returns the transactions in the memory pool.
Example
const transactions = networkClient.getTransactionsInMempool();

(async) getTransactionsInMempool() → {Promise.<Array.<TransactionJSON>>}

Returns the transactions in the memory pool.
Returns:
Type: 
Promise.<Array.<TransactionJSON>>
Example
const transactions = networkClient.getTransactionsInMempool();

(async) getTransitionId(inputOrOutputID)

Returns the transition ID of the transition corresponding to the ID of the input or output.
Parameters:
NameTypeDescription
inputOrOutputIDstringID of the input or output.
Example
const transitionId = networkClient.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");

(async) getTransitionId(inputOrOutputID) → {Promise.<string>}

Returns the transition ID of the transition corresponding to the ID of the input or output.
Parameters:
NameTypeDescription
inputOrOutputIDstringID of the input or output.
Returns:
Type: 
Promise.<string>
Example
const transitionId = networkClient.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");

setAccount(account)

Set an account to use in networkClient calls
Parameters:
NameTypeDescription
accountAccount
Example
const account = new Account();
+networkClient.setAccount(account);

setAccount(account)

Set an account to use in networkClient calls
Parameters:
NameTypeDescription
accountAccount
Example
const account = new Account();
+networkClient.setAccount(account);

setHost(host, host)

Set a new host for the networkClient
Parameters:
NameTypeDescription
hoststringThe address of a node hosting the Aleo API
host

setHost(host, host)

Set a new host for the networkClient
Parameters:
NameTypeDescription
hoststringThe address of a node hosting the Aleo API
host

(async) submitSolution(solution)

Submit a solution to the Aleo network.
Parameters:
NameTypeDescription
solutionstringThe string representation of the solution desired to be submitted to the network.

(async) submitSolution(solution) → {Promise.<string>}

Submit a solution to the Aleo network.
Parameters:
NameTypeDescription
solutionstringThe string representation of the solution desired to be submitted to the network.
Returns:
Type: 
Promise.<string>

(async) submitTransaction(transaction) → {string}

Submit an execute or deployment transaction to the Aleo network.
Parameters:
NameTypeDescription
transactionTransaction | stringThe transaction to submit to the network
Returns:
- The transaction id of the submitted transaction or the resulting error
Type: 
string

(async) submitTransaction(transaction) → {string}

Submit an execute or deployment transaction to the Aleo network.
Parameters:
NameTypeDescription
transactionTransaction | stringThe transaction to submit to the network
Returns:
- The transaction id of the submitted transaction or the resulting error
Type: 
string
\ No newline at end of file diff --git a/sdk/docs/BlockHeightSearch.html b/sdk/docs/BlockHeightSearch.html new file mode 100644 index 000000000..d11d45bea --- /dev/null +++ b/sdk/docs/BlockHeightSearch.html @@ -0,0 +1,13 @@ +Class: BlockHeightSearch
On this page

BlockHeightSearch

BlockHeightSearch is a RecordSearchParams implementation that allows for searching for records within a given block height range.

Constructor

new BlockHeightSearch()

Example
// Create a new BlockHeightSearch
+const params = new BlockHeightSearch(89995, 99995);
+
+// Create a new NetworkRecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// The record provider can be used to find records with a given number of microcredits and the block height search
+// can be used to find records within a given block height range
+const record = await recordProvider.findCreditsRecord(5000, true, [], params);
\ No newline at end of file diff --git a/sdk/docs/ExecuteOptions.html b/sdk/docs/ExecuteOptions.html new file mode 100644 index 000000000..560fae6e1 --- /dev/null +++ b/sdk/docs/ExecuteOptions.html @@ -0,0 +1,3 @@ +Interface: ExecuteOptions
On this page

ExecuteOptions

Represents the options for executing a transaction in the Aleo network. This interface is used to specify the parameters required for building and submitting an execution transaction.
Properties
NameTypeAttributesDescription
programNamestringThe name of the program containing the function to be executed.
functionNamestringThe name of the function to execute within the program.
feenumberThe fee to be paid for the transaction.
privateFeebooleanIf true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
inputsArray.<string>The inputs to the function being executed.
recordSearchParamsRecordSearchParams<optional>
Optional parameters for searching for a record to pay the execution transaction fee.
keySearchParamsKeySearchParams<optional>
Optional parameters for finding the matching proving & verifying keys for the function.
feeRecordstring | RecordPlaintext<optional>
Optional fee record to use for the transaction.
provingKeyProvingKey<optional>
Optional proving key to use for the transaction.
verifyingKeyVerifyingKey<optional>
Optional verifying key to use for the transaction.
privateKeyPrivateKey<optional>
Optional private key to use for the transaction.
offlineQueryOfflineQuery<optional>
Optional offline query if creating transactions in an offline environment.
programstring | Program<optional>
Optional program source code to use for the transaction.
importsProgramImports<optional>
Optional programs that the program being executed imports.
\ No newline at end of file diff --git a/sdk/docs/FunctionKeyProvider.html b/sdk/docs/FunctionKeyProvider.html new file mode 100644 index 000000000..8c9ee36ec --- /dev/null +++ b/sdk/docs/FunctionKeyProvider.html @@ -0,0 +1,69 @@ +Interface: FunctionKeyProvider
On this page

FunctionKeyProvider

KeyProvider interface. Enables the retrieval of public proving and verifying keys for Aleo Programs.

Members

bondPublicKeys :Promise.<FunctionKeyPair>

Get bond_public function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>

bondValidatorKeys :Promise.<FunctionKeyPair>

Get bond_validator function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>

cacheKeys :void

Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
Type:
  • void

claimUnbondPublicKeys :Promise.<FunctionKeyPair>

Get unbond_public function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>

feePrivateKeys :Promise.<FunctionKeyPair>

Get fee_private function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>

feePublicKeys :Promise.<FunctionKeyPair>

Get fee_public function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>

functionKeys :Promise.<FunctionKeyPair>

Get arbitrary function keys from a provider
Type:
  • Promise.<FunctionKeyPair>
Example
// Create a search object which implements the KeySearchParams interface
+class IndexDbSearch implements KeySearchParams {
+    db: string
+    keyId: string
+    constructor(params: {db: string, keyId: string}) {
+        this.db = params.db;
+        this.keyId = params.keyId;
+    }
+}
+
+// Create a new object which implements the KeyProvider interface
+class IndexDbKeyProvider implements FunctionKeyProvider {
+    async functionKeys(params: KeySearchParams): Promise<FunctionKeyPair> {
+        return new Promise((resolve, reject) => {
+            const request = indexedDB.open(params.db, 1);
+
+            request.onupgradeneeded = function(e) {
+                const db = e.target.result;
+                if (!db.objectStoreNames.contains('keys')) {
+                    db.createObjectStore('keys', { keyPath: 'id' });
+                }
+            };
+
+            request.onsuccess = function(e) {
+                const db = e.target.result;
+                const transaction = db.transaction(["keys"], "readonly");
+                const store = transaction.objectStore("keys");
+                const request = store.get(params.keyId);
+                request.onsuccess = function(e) {
+                    if (request.result) {
+                        resolve(request.result as FunctionKeyPair);
+                    } else {
+                        reject(new Error("Key not found"));
+                    }
+                };
+                request.onerror = function(e) { reject(new Error("Error fetching key")); };
+            };
+
+            request.onerror = function(e) { reject(new Error("Error opening database")); };
+        });
+    }
+
+    // implement the other methods...
+}
+
+
+const keyProvider = new AleoKeyProvider();
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually
+const searchParams = new IndexDbSearch({db: "keys", keyId: "credits.aleo:transferPrivate"});
+const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(searchParams);

joinKeys :Promise.<FunctionKeyPair>

Get join function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>

splitKeys :Promise.<FunctionKeyPair>

Get split function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>

transferKeys :Promise.<FunctionKeyPair>

Get keys for a variant of the transfer function from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>
Example
// Create a new object which implements the KeyProvider interface
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for value transfers
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+
+// Keys can also be fetched manually
+const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");

unBondPublicKeys :Promise.<FunctionKeyPair>

Get unbond_public function keys from the credits.aleo program
Type:
  • Promise.<FunctionKeyPair>
\ No newline at end of file diff --git a/sdk/docs/KeySearchParams.html b/sdk/docs/KeySearchParams.html new file mode 100644 index 000000000..e3d40774c --- /dev/null +++ b/sdk/docs/KeySearchParams.html @@ -0,0 +1,3 @@ +Interface: KeySearchParams
On this page

KeySearchParams

Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider implementations.
\ No newline at end of file diff --git a/sdk/docs/NetworkRecordProvider.html b/sdk/docs/NetworkRecordProvider.html new file mode 100644 index 000000000..f17cd9ce3 --- /dev/null +++ b/sdk/docs/NetworkRecordProvider.html @@ -0,0 +1,63 @@ +Class: NetworkRecordProvider
On this page

NetworkRecordProvider

A record provider implementation that uses the official Aleo API to find records for usage in program execution and deployment, wallet functionality, and other use cases.

Constructor

new NetworkRecordProvider()

Methods

(async) findCreditsRecord(microcredits, unspent, nonces, searchParameters) → {Promise.<RecordPlaintext>}

Find a credit record with a given number of microcredits by via the official Aleo API
Parameters:
NameTypeDescription
microcreditsnumberThe number of microcredits to search for
unspentbooleanWhether or not the record is unspent
noncesArray.<string>Nonces of records already found so that they are not found again
searchParametersRecordSearchParamsAdditional parameters to search for
Returns:
The record if found, otherwise an error
Type: 
Promise.<RecordPlaintext>
Example
// Create a new NetworkRecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// The record provider can be used to find records with a given number of microcredits
+const record = await recordProvider.findCreditsRecord(5000, true, []);
+
+// When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
+// found again if a subsequent search is performed
+const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
+
+// When the program manager is initialized with the record provider it will be used to find automatically find
+// fee records and amount records for value transfers so that they do not need to be specified manually
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);

(async) findCreditsRecord(microcredits, unspent, nonces, searchParameters) → {Promise.<RecordPlaintext>}

Find a credit record with a given number of microcredits by via the official Aleo API
Parameters:
NameTypeDescription
microcreditsnumberThe number of microcredits to search for
unspentbooleanWhether or not the record is unspent
noncesArray.<string>Nonces of records already found so that they are not found again
searchParametersRecordSearchParamsAdditional parameters to search for
Returns:
The record if found, otherwise an error
Type: 
Promise.<RecordPlaintext>
Example
// Create a new NetworkRecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// The record provider can be used to find records with a given number of microcredits
+const record = await recordProvider.findCreditsRecord(5000, true, []);
+
+// When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
+// found again if a subsequent search is performed
+const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
+
+// When the program manager is initialized with the record provider it will be used to find automatically find
+// fee records and amount records for value transfers so that they do not need to be specified manually
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);

(async) findCreditsRecords(microcredits, unspent, nonces, searchParameters) → {Promise.<RecordPlaintext>}

Find a list of credit records with a given number of microcredits by via the official Aleo API
Parameters:
NameTypeDescription
microcreditsArray.<number>The number of microcredits to search for
unspentbooleanWhether or not the record is unspent
noncesArray.<string>Nonces of records already found so that they are not found again
searchParametersRecordSearchParamsAdditional parameters to search for
Returns:
The record if found, otherwise an error
Type: 
Promise.<RecordPlaintext>
Example
// Create a new NetworkRecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// The record provider can be used to find records with a given number of microcredits
+const record = await recordProvider.findCreditsRecord(5000, true, []);
+
+// When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
+// found again if a subsequent search is performed
+const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
+
+// When the program manager is initialized with the record provider it will be used to find automatically find
+// fee records and amount records for value transfers so that they do not need to be specified manually
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);

(async) findCreditsRecords(microcredits, unspent, nonces, searchParameters) → {Promise.<RecordPlaintext>}

Find a list of credit records with a given number of microcredits by via the official Aleo API
Parameters:
NameTypeDescription
microcreditsArray.<number>The number of microcredits to search for
unspentbooleanWhether or not the record is unspent
noncesArray.<string>Nonces of records already found so that they are not found again
searchParametersRecordSearchParamsAdditional parameters to search for
Returns:
The record if found, otherwise an error
Type: 
Promise.<RecordPlaintext>
Example
// Create a new NetworkRecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// The record provider can be used to find records with a given number of microcredits
+const record = await recordProvider.findCreditsRecord(5000, true, []);
+
+// When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
+// found again if a subsequent search is performed
+const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
+
+// When the program manager is initialized with the record provider it will be used to find automatically find
+// fee records and amount records for value transfers so that they do not need to be specified manually
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);

(async) findRecord()

Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error.

(async) findRecord(unspent, noncesopt, searchParametersopt) → {Promise.<RecordPlaintext>}

Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error.
Parameters:
NameTypeAttributesDescription
unspentboolean
noncesArray<optional>
searchParametersRecordSearchParams<optional>
Returns:
Type: 
Promise.<RecordPlaintext>

(async) findRecords()

Find multiple arbitrary records. WARNING: This function is not implemented yet and will throw an error.

(async) findRecords(unspent, noncesopt, searchParametersopt) → {Promise.<Array>}

Find multiple arbitrary records. WARNING: This function is not implemented yet and will throw an error.
Parameters:
NameTypeAttributesDescription
unspentboolean
noncesArray<optional>
searchParametersRecordSearchParams<optional>
Returns:
Type: 
Promise.<Array>

setAccount(account)

Set the account used to search for records
Parameters:
NameTypeDescription
accountAccountThe account to use for searching for records

setAccount(account)

Set the account used to search for records
Parameters:
NameTypeDescription
accountAccountThe account to use for searching for records
\ No newline at end of file diff --git a/sdk/docs/OfflineKeyProvider.html b/sdk/docs/OfflineKeyProvider.html new file mode 100644 index 000000000..64f6c9704 --- /dev/null +++ b/sdk/docs/OfflineKeyProvider.html @@ -0,0 +1,100 @@ +Class: OfflineKeyProvider
On this page

OfflineKeyProvider

A key provider meant for building transactions offline on devices such as hardware wallets. This key provider is not able to contact the internet for key material and instead relies on the user to insert Aleo function proving & verifying keys from local storage prior to usage.

Constructor

new OfflineKeyProvider()

Example
// Create an offline program manager
+const programManager = new ProgramManager();
+
+// Create a temporary account for the execution of the program
+const account = new Account();
+programManager.setAccount(account);
+
+// Create the proving keys from the key bytes on the offline machine
+console.log("Creating proving keys from local key files");
+const program = "program hello_hello.aleo; function hello: input r0 as u32.public; input r1 as u32.private; add r0 r1 into r2; output r2 as u32.private;";
+const myFunctionProver = await getLocalKey("/path/to/my/function/hello_hello.prover");
+const myFunctionVerifier = await getLocalKey("/path/to/my/function/hello_hello.verifier");
+const feePublicProvingKeyBytes = await getLocalKey("/path/to/credits.aleo/feePublic.prover");
+
+myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProver);
+myFunctionVerifyingKey = VerifyingKey.fromBytes(myFunctionVerifier);
+const feePublicProvingKey = ProvingKey.fromBytes(feePublicKeyBytes);
+
+// Create an offline key provider
+console.log("Creating offline key provider");
+const offlineKeyProvider = new OfflineKeyProvider();
+
+// Cache the keys
+// Cache the proving and verifying keys for the custom hello function
+OfflineKeyProvider.cacheKeys("hello_hello.aleo/hello", myFunctionProvingKey, myFunctionVerifyingKey);
+
+// Cache the proving key for the fee_public function (the verifying key is automatically cached)
+OfflineKeyProvider.insertFeePublicKey(feePublicProvingKey);
+
+// Create an offline query using the latest state root in order to create the inclusion proof
+const offlineQuery = new OfflineQuery("latestStateRoot");
+
+// Insert the key provider into the program manager
+programManager.setKeyProvider(offlineKeyProvider);
+
+// Create the offline search params
+const offlineSearchParams = new OfflineSearchParams("hello_hello.aleo/hello");
+
+// Create the offline transaction
+const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction("hello_hello.aleo", "hello", 1, false, ["5u32", "5u32"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);
+
+// Broadcast the transaction later on a machine with internet access
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const txId = await networkClient.broadcastTransaction(offlineExecuteTx);

Methods

bondPublicKeys() → {Promise.<FunctionKeyPair>}

Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the bond_public function
Type: 
Promise.<FunctionKeyPair>

bondPublicKeys() → {Promise.<FunctionKeyPair>}

Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the bond_public function
Type: 
Promise.<FunctionKeyPair>

bondValidatorKeys() → {Promise.<FunctionKeyPair>}

Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the bond_public function
Type: 
Promise.<FunctionKeyPair>

bondValidatorKeys() → {Promise.<FunctionKeyPair>}

Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the bond_public function
Type: 
Promise.<FunctionKeyPair>

cacheKeys(keyId, keys)

Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
Parameters:
NameTypeDescription
keyIdstringaccess key for the cache
keysFunctionKeyPairkeys to cache

cacheKeys(keyId, keys) → {void}

Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
Parameters:
NameTypeDescription
keyIdstringaccess key for the cache
keysFunctionKeyPairkeys to cache
Returns:
Type: 
void

claimUnbondPublicKeys() → {Promise.<FunctionKeyPair>}

Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the unbond_public function
Type: 
Promise.<FunctionKeyPair>

claimUnbondPublicKeys() → {Promise.<FunctionKeyPair>}

Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the unbond_public function
Type: 
Promise.<FunctionKeyPair>

feePrivateKeys() → {Promise.<FunctionKeyPair>}

Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

feePrivateKeys() → {Promise.<FunctionKeyPair>}

Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

feePublicKeys() → {Promise.<FunctionKeyPair>}

Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

feePublicKeys() → {Promise.<FunctionKeyPair>}

Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

functionKeys(params) → {Promise.<FunctionKeyPair>}

Get arbitrary function key from the offline key provider cache.
Parameters:
NameTypeDescription
paramsKeySearchParams | undefinedOptional search parameters for the key provider
Returns:
Proving and verifying keys for the specified program
Type: 
Promise.<FunctionKeyPair>
Example
/// First cache the keys from local offline resources
+const offlineKeyProvider = new OfflineKeyProvider();
+const myFunctionVerifyingKey = VerifyingKey.fromString("verifier...");
+const myFunctionProvingKeyBytes = await readBinaryFile('./resources/myfunction.prover');
+const myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProvingKeyBytes);
+
+/// Cache the keys for future use with a memorable locator
+offlineKeyProvider.cacheKeys("myprogram.aleo/myfunction", [myFunctionProvingKey, myFunctionVerifyingKey]);
+
+/// When they're needed, retrieve the keys from the cache
+
+/// First create a search parameter object with the same locator used to cache the keys
+const keyParams = new OfflineSearchParams("myprogram.aleo/myfunction");
+
+/// Then retrieve the keys
+const [myFunctionProver, myFunctionVerifier] = await offlineKeyProvider.functionKeys(keyParams);

functionKeys(params) → {Promise.<FunctionKeyPair>}

Get arbitrary function key from the offline key provider cache.
Parameters:
NameTypeDescription
paramsKeySearchParams | undefinedOptional search parameters for the key provider
Returns:
Proving and verifying keys for the specified program
Type: 
Promise.<FunctionKeyPair>
Example
/// First cache the keys from local offline resources
+const offlineKeyProvider = new OfflineKeyProvider();
+const myFunctionVerifyingKey = VerifyingKey.fromString("verifier...");
+const myFunctionProvingKeyBytes = await readBinaryFile('./resources/myfunction.prover');
+const myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProvingKeyBytes);
+
+/// Cache the keys for future use with a memorable locator
+offlineKeyProvider.cacheKeys("myprogram.aleo/myfunction", [myFunctionProvingKey, myFunctionVerifyingKey]);
+
+/// When they're needed, retrieve the keys from the cache
+
+/// First create a search parameter object with the same locator used to cache the keys
+const keyParams = new OfflineSearchParams("myprogram.aleo/myfunction");
+
+/// Then retrieve the keys
+const [myFunctionProver, myFunctionVerifier] = await offlineKeyProvider.functionKeys(keyParams);

insertBondPublicKeys(provingKey)

Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for bond_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertBondPublicKeys(provingKey)

Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for bond_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertClaimUnbondPublicKeys(provingKey)

Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for claim_unbond_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertClaimUnbondPublicKeys(provingKey)

Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for claim_unbond_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertFeePrivateKeys(provingKey)

Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for fee_private before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertFeePrivateKeys(provingKey)

Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for fee_private before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertFeePublicKeys(provingKey)

Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for fee_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertFeePublicKeys(provingKey)

Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for fee_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertJoinKeys(provingKey)

Insert the proving and verifying keys for the join function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for join before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertJoinKeys(provingKey)

Insert the proving and verifying keys for the join function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for join before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertSetValidatorStateKeys(provingKey)

Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for set_validator_state before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertSetValidatorStateKeys(provingKey)

Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for set_validator_state before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertSplitKeys(provingKey)

Insert the proving and verifying keys for the split function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for split before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertSplitKeys(provingKey)

Insert the proving and verifying keys for the split function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for split before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPrivateKeys(provingKey)

Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_private before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPrivateKeys(provingKey)

Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_private before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPrivateToPublicKeys(provingKey)

Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_private_to_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPrivateToPublicKeys(provingKey)

Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_private_to_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPublicKeys(provingKey)

Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPublicKeys(provingKey)

Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_public before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPublicToPrivateKeys(provingKey)

Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_public_to_private before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

insertTransferPublicToPrivateKeys(provingKey)

Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check that the keys match the expected checksum for transfer_public_to_private before inserting them into the cache.
Parameters:
NameTypeDescription
provingKey

joinKeys() → {Promise.<FunctionKeyPair>}

Get join function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

joinKeys() → {Promise.<FunctionKeyPair>}

Get join function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

splitKeys() → {Promise.<FunctionKeyPair>}

Get split function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

splitKeys() → {Promise.<FunctionKeyPair>}

Get split function keys from the credits.aleo program. The keys must be cached prior to calling this method for it to work.
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

transferKeys(visibility) → {Promise.<FunctionKeyPair>}

Get keys for a variant of the transfer function from the credits.aleo program.
Parameters:
NameTypeDescription
visibilitystringVisibility of the transfer function (private, public, privateToPublic, publicToPrivate)
Returns:
Proving and verifying keys for the specified transfer function
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new OfflineKeyProvider
+const offlineKeyProvider = new OfflineKeyProvider();
+
+// Cache the keys for future use with the official locator
+const transferPublicProvingKeyBytes = await readBinaryFile('./resources/transfer_public.prover.a74565e');
+const transferPublicProvingKey = ProvingKey.fromBytes(transferPublicProvingKeyBytes);
+
+// Cache the transfer_public keys for future use with the OfflinKeyProvider's convenience method for
+// transfer_public (the verifying key will be cached automatically)
+offlineKeyProvider.insertTransferPublicKeys(transferPublicProvingKey);
+
+/// When they're needed, retrieve the keys from the cache
+const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");

transferKeys(visibility) → {Promise.<FunctionKeyPair>}

Get keys for a variant of the transfer function from the credits.aleo program.
Parameters:
NameTypeDescription
visibilitystringVisibility of the transfer function (private, public, privateToPublic, publicToPrivate)
Returns:
Proving and verifying keys for the specified transfer function
Type: 
Promise.<FunctionKeyPair>
Example
// Create a new OfflineKeyProvider
+const offlineKeyProvider = new OfflineKeyProvider();
+
+// Cache the keys for future use with the official locator
+const transferPublicProvingKeyBytes = await readBinaryFile('./resources/transfer_public.prover.a74565e');
+const transferPublicProvingKey = ProvingKey.fromBytes(transferPublicProvingKeyBytes);
+
+// Cache the transfer_public keys for future use with the OfflinKeyProvider's convenience method for
+// transfer_public (the verifying key will be cached automatically)
+offlineKeyProvider.insertTransferPublicKeys(transferPublicProvingKey);
+
+/// When they're needed, retrieve the keys from the cache
+const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");

(async) unBondPublicKeys() → {Promise.<FunctionKeyPair>}

Get unbond_public function keys from the credits.aleo program
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

(async) unBondPublicKeys() → {Promise.<FunctionKeyPair>}

Get unbond_public function keys from the credits.aleo program
Returns:
Proving and verifying keys for the join function
Type: 
Promise.<FunctionKeyPair>

verifyCreditsKeys() → {boolean}

Determines if the keys for a given credits function match the expected keys.
Returns:
Whether the keys match the expected keys
Type: 
boolean

verifyCreditsKeys(locator, provingKey, verifyingKey) → {boolean}

Determines if the keys for a given credits function match the expected keys.
Parameters:
NameTypeDescription
locatorstring
provingKeyProvingKey
verifyingKeyVerifyingKey
Returns:
Whether the keys match the expected keys
Type: 
boolean
\ No newline at end of file diff --git a/sdk/docs/OfflineSearchParams.html b/sdk/docs/OfflineSearchParams.html new file mode 100644 index 000000000..152aa66c4 --- /dev/null +++ b/sdk/docs/OfflineSearchParams.html @@ -0,0 +1,7 @@ +Class: OfflineSearchParams
On this page

OfflineSearchParams

Search parameters for the offline key provider. This class implements the KeySearchParams interface and includes a convenience method for creating a new instance of this class for each function of the credits.aleo program.

Constructor

new OfflineSearchParams(cacheKey, verifyCreditsKeys)

Create a new OfflineSearchParams instance.
Parameters:
NameTypeDefaultDescription
cacheKeystringKey used to store the local function proving & verifying keys. This should be stored under the naming convention "programName/functionName" (i.e. "myprogram.aleo/myfunction")
verifyCreditsKeysbooleanfalseWhether to verify the keys against the credits.aleo program, defaults to false, but should be set to true if using keys from the credits.aleo program
Example
// If storing a key for a custom program function
+offlineSearchParams = new OfflineSearchParams("myprogram.aleo/myfunction");
+
+// If storing a key for a credits.aleo program function
+bondPublicKeyParams = OfflineSearchParams.bondPublicKeyParams();

Classes

OfflineSearchParams

Methods

(static) bondPublicKeyParams()

Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program.

(static) bondPublicKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) bondValidatorKeyParams()

Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program.

(static) bondValidatorKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) claimUnbondPublicKeyParams()

Create a new OfflineSearchParams instance for the claim_unbond_public function of the

(static) claimUnbondPublicKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the claim_unbond_public function of the
Returns:
Type: 
OfflineSearchParams

(static) feePrivateKeyParams()

Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program.

(static) feePrivateKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) feePublicKeyParams()

Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program.

(static) feePublicKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) inclusionKeyParams()

Create a new OfflineSearchParams instance for the inclusion prover function.

(static) inclusionKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the inclusion prover function.
Returns:
Type: 
OfflineSearchParams

(static) joinKeyParams()

Create a new OfflineSearchParams instance for the join function of the credits.aleo program.

(static) joinKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the join function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) setValidatorStateKeyParams()

Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program.

(static) setValidatorStateKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) splitKeyParams()

Create a new OfflineSearchParams instance for the split function of the credits.aleo program.

(static) splitKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the split function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) transferPrivateKeyParams()

Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program.

(static) transferPrivateKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) transferPrivateToPublicKeyParams()

Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program.

(static) transferPrivateToPublicKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) transferPublicAsSignerKeyParams()

Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program.

(static) transferPublicAsSignerKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) transferPublicKeyParams()

Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program.

(static) transferPublicKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) transferPublicToPrivateKeyParams()

Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program.

(static) transferPublicToPrivateKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams

(static) unbondPublicKeyParams()

Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program.

(static) unbondPublicKeyParams() → {OfflineSearchParams}

Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program.
Returns:
Type: 
OfflineSearchParams
\ No newline at end of file diff --git a/sdk/docs/OfflineSearchParams_OfflineSearchParams.html b/sdk/docs/OfflineSearchParams_OfflineSearchParams.html new file mode 100644 index 000000000..6bc503006 --- /dev/null +++ b/sdk/docs/OfflineSearchParams_OfflineSearchParams.html @@ -0,0 +1,3 @@ +Class: OfflineSearchParams
On this page

OfflineSearchParams# OfflineSearchParams

new OfflineSearchParams(cacheKey, verifyCreditsKeys)

Create a new OfflineSearchParams instance.
Parameters:
NameTypeDescription
cacheKeystringKey used to store the local function proving & verifying keys. This should be stored under the naming convention "programName/functionName" (i.e. "myprogram.aleo/myfunction")
verifyCreditsKeysbooleanWhether to verify the keys against the credits.aleo program, defaults to false, but should be set to true if using keys from the credits.aleo program
\ No newline at end of file diff --git a/sdk/docs/ProgramManager.html b/sdk/docs/ProgramManager.html new file mode 100644 index 000000000..eecad1e58 --- /dev/null +++ b/sdk/docs/ProgramManager.html @@ -0,0 +1,401 @@ +Class: ProgramManager
On this page

ProgramManager

The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.

Constructor

new ProgramManager(host, keyProvider, recordProvider)

Create a new instance of the ProgramManager
Parameters:
NameTypeDescription
hoststring | undefinedA host uri running the official Aleo API
keyProviderFunctionKeyProvider | undefinedA key provider that implements FunctionKeyProvider interface
recordProviderRecordProvider | undefinedA record provider that implements RecordProvider interface

Classes

ProgramManager

Methods

(async) bondPublic(staker_address, validator_address, withdrawal_address, amount, options)

Bond credits to validator.
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is bonding the credits
validator_addressstringAddress of the validator to bond to, if this address is the same as the signer (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 1,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
optionsOptionsOptions for the execution
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);

(async) bondPublic(staker_address, validator_address, withdrawal_address, amount, options)

Bond credits to validator.
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is bonding the credits
validator_addressstringAddress of the validator to bond to, if this address is the same as the signer (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 1,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
optionsOptionsOptions for the execution
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);

(async) bondValidator(validator_address, withdrawal_address, amount, commission, options)

Build transaction to bond a validator.
Parameters:
NameTypeDescription
validator_addressstringAddress of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
commissionnumberThe commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.bondValidator("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);

(async) bondValidator(validator_address, withdrawal_address, amount, commission, options)

Build transaction to bond a validator.
Parameters:
NameTypeDescription
validator_addressstringAddress of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
commissionnumberThe commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.bondValidator("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);

(async) buildBondPublicTransaction(staker_address, validator_address, withdrawal_address, amount, options)

Build transaction to bond credits to a validator for later submission to the Aleo Network
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is bonding the credits
validator_addressstringAddress of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction object for later submission
+const tx = await programManager.buildBondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+console.log(tx);
+
+// The transaction can be later submitted to the network using the network client.
+const result = await programManager.networkClient.submitTransaction(tx);

(async) buildBondPublicTransaction(staker_address, validator_address, withdrawal_address, amount, options)

Build transaction to bond credits to a validator for later submission to the Aleo Network
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is bonding the credits
validator_addressstringAddress of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction object for later submission
+const tx = await programManager.buildBondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+console.log(tx);
+
+// The transaction can be later submitted to the network using the network client.
+const result = await programManager.networkClient.submitTransaction(tx);

(async) buildBondValidatorTransaction(validator_address, withdrawal_address, amount, commission, options)

Build a bond_validator transaction for later submission to the Aleo Network.
Parameters:
NameTypeDescription
validator_addressstringAddress of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
commissionnumberThe commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bond validator transaction object for later use.
+const tx = await programManager.buildBondValidatorTransaction("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+console.log(tx);
+
+// The transaction can later be submitted to the network using the network client.
+const tx_id = await programManager.networkClient.submitTransaction(tx);

(async) buildBondValidatorTransaction(validator_address, withdrawal_address, amount, commission, options)

Build a bond_validator transaction for later submission to the Aleo Network.
Parameters:
NameTypeDescription
validator_addressstringAddress of the validator to bond to, if this address is the same as the staker (i.e. the executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing validator and is different from the address of the executor of this function, it will bond the credits to that validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
withdrawal_addressstringAddress to withdraw the staked credits to when unbond_public is called.
amountnumberThe amount of credits to bond
commissionnumberThe commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bond validator transaction object for later use.
+const tx = await programManager.buildBondValidatorTransaction("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+console.log(tx);
+
+// The transaction can later be submitted to the network using the network client.
+const tx_id = await programManager.networkClient.submitTransaction(tx);

(async) buildClaimUnbondPublicTransaction(staker_address, options) → {Promise.<Transaction>}

Build a transaction to claim unbonded public credits in the Aleo network.
Parameters:
NameTypeDescription
staker_addressstringThe address of the staker who is claiming the credits.
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
- A promise that resolves to the transaction or an error message.
Type: 
Promise.<Transaction>
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to claim unbonded credits.
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+
+// Create the claim unbonded transaction object for later use.
+const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
+console.log(tx);
+
+// The transaction can be submitted later to the network using the network client.
+programManager.networkClient.submitTransaction(tx);

(async) buildClaimUnbondPublicTransaction(staker_address, options) → {Promise.<Transaction>}

Build a transaction to claim unbonded public credits in the Aleo network.
Parameters:
NameTypeDescription
staker_addressstringThe address of the staker who is claiming the credits.
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
- A promise that resolves to the transaction or an error message.
Type: 
Promise.<Transaction>
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to claim unbonded credits.
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+
+// Create the claim unbonded transaction object for later use.
+const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
+console.log(tx);
+
+// The transaction can be submitted later to the network using the network client.
+programManager.networkClient.submitTransaction(tx);

(async) buildExecutionTransaction(options) → {Promise.<Transaction>}

Builds an execution transaction for submission to the Aleo network.
Parameters:
NameTypeDescription
optionsExecuteOptionsThe options for the execution transaction.
Returns:
- A promise that resolves to the transaction or an error.
Type: 
Promise.<Transaction>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+
+// Build and execute the transaction
+const transaction = await programManager.buildExecutionTransaction({
+  programName: "hello_hello.aleo",
+  functionName: "hello_hello",
+  fee: 0.020,
+  privateFee: false,
+  inputs: ["5u32", "5u32"],
+  keySearchParams: { "cacheKey": "hello_hello:hello" }
+});
+const result = await programManager.networkClient.submitTransaction(transaction);

(async) buildExecutionTransaction(options) → {Promise.<Transaction>}

Builds an execution transaction for submission to the Aleo network.
Parameters:
NameTypeDescription
optionsExecuteOptionsThe options for the execution transaction.
Returns:
- A promise that resolves to the transaction or an error.
Type: 
Promise.<Transaction>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+
+// Build and execute the transaction
+const transaction = await programManager.buildExecutionTransaction({
+  programName: "hello_hello.aleo",
+  functionName: "hello_hello",
+  fee: 0.020,
+  privateFee: false,
+  inputs: ["5u32", "5u32"],
+  keySearchParams: { "cacheKey": "hello_hello:hello" }
+});
+const result = await programManager.networkClient.submitTransaction(transaction);

(async) buildSetValidatorStateTransaction(validator_state, options)

Build a set_validator_state transaction for later usage. This function allows a validator to set their state to be either opened or closed to new stakers. When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator. When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond. This function serves two primary purposes: 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers. 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
Parameters:
NameTypeDescription
validator_stateboolean
optionsPartial.<ExecuteOptions>Override default execution options
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("ValidatorPrivateKey"));
+
+// Create the bonding transaction
+const tx = await programManager.buildSetValidatorStateTransaction(true);
+
+// The transaction can be submitted later to the network using the network client.
+programManager.networkClient.submitTransaction(tx);

(async) buildSetValidatorStateTransaction(validator_state, options)

Build a set_validator_state transaction for later usage. This function allows a validator to set their state to be either opened or closed to new stakers. When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator. When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond. This function serves two primary purposes: 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers. 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
Parameters:
NameTypeDescription
validator_stateboolean
optionsPartial.<ExecuteOptions>Override default execution options
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("ValidatorPrivateKey"));
+
+// Create the bonding transaction
+const tx = await programManager.buildSetValidatorStateTransaction(true);
+
+// The transaction can be submitted later to the network using the network client.
+programManager.networkClient.submitTransaction(tx);

(async) buildTransferPublicAsSignerTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>

(async) buildTransferPublicAsSignerTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>

(async) buildTransferPublicTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>

(async) buildTransferPublicTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>

(async) buildTransferTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Build a transaction to transfer credits to another account for later submission to the Aleo network
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programName = "hello_hello.aleo";
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+await programManager.initialize();
+const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) buildTransferTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Build a transaction to transfer credits to another account for later submission to the Aleo network
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programName = "hello_hello.aleo";
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+await programManager.initialize();
+const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) buildUnbondPublicTransaction(staker_address, amount, options) → {Promise.<Transaction>}

Build a transaction to unbond public credits from a validator in the Aleo network.
Parameters:
NameTypeDescription
staker_addressstringThe address of the staker who is unbonding the credits.
amountnumberThe amount of credits to unbond (scaled by 1,000,000).
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
- A promise that resolves to the transaction or an error message.
Type: 
Promise.<Transaction>
Example
// Create a keyProvider to handle key management.
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to unbond credits.
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
+console.log(tx);
+
+// The transaction can be submitted later to the network using the network client.
+programManager.networkClient.submitTransaction(tx);

(async) buildUnbondPublicTransaction(staker_address, amount, options) → {Promise.<Transaction>}

Build a transaction to unbond public credits from a validator in the Aleo network.
Parameters:
NameTypeDescription
staker_addressstringThe address of the staker who is unbonding the credits.
amountnumberThe amount of credits to unbond (scaled by 1,000,000).
optionsPartial.<ExecuteOptions>Override default execution options.
Returns:
- A promise that resolves to the transaction or an error message.
Type: 
Promise.<Transaction>
Example
// Create a keyProvider to handle key management.
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to unbond credits.
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
+console.log(tx);
+
+// The transaction can be submitted later to the network using the network client.
+programManager.networkClient.submitTransaction(tx);

(async) claimUnbondPublic(staker_address, options)

Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will claim them and add them to the public balance of the account.
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is claiming the credits
optionsExecuteOptions
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.claimUnbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");

(async) claimUnbondPublic(staker_address, options)

Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will claim them and add them to the public balance of the account.
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is claiming the credits
optionsExecuteOptions
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.claimUnbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");

createProgramFromSource(program) → {Program}

Create a program object from a program's source code
Parameters:
NameTypeDescription
programstringProgram source code
Returns:
The program object
Type: 
Program

createProgramFromSource(program) → {Program}

Create a program object from a program's source code
Parameters:
NameTypeDescription
programstringProgram source code
Returns:
The program object
Type: 
Program

creditsProgram() → {Program}

Get the credits program object
Returns:
The credits program object
Type: 
Program

creditsProgram() → {Program}

Get the credits program object
Returns:
The credits program object
Type: 
Program

(async) deploy(program, fee, privateFee, recordSearchParams, feeRecord, privateKey) → {string}

Deploy an Aleo program to the Aleo network
Parameters:
NameTypeDescription
programstringProgram source code
feenumberFee to pay for the transaction
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for searching for a record to use pay the deployment fee
feeRecordstring | RecordPlaintext | undefinedOptional Fee record to use for the transaction
privateKeyPrivateKey | undefinedOptional private key to use for the transaction
Returns:
The transaction id of the deployed program or a failure message from the network
Type: 
string
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for deployments
+const program = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n";
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+
+// Define a fee in credits
+const fee = 1.2;
+
+// Deploy the program
+const tx_id = await programManager.deploy(program, fee);
+
+// Verify the transaction was successful
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) deploy(program, fee, privateFee, recordSearchParams, feeRecord, privateKey) → {string}

Deploy an Aleo program to the Aleo network
Parameters:
NameTypeDescription
programstringProgram source code
feenumberFee to pay for the transaction
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for searching for a record to use pay the deployment fee
feeRecordstring | RecordPlaintext | undefinedOptional Fee record to use for the transaction
privateKeyPrivateKey | undefinedOptional private key to use for the transaction
Returns:
The transaction id of the deployed program or a failure message from the network
Type: 
string
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for deployments
+const program = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n";
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+
+// Define a fee in credits
+const fee = 1.2;
+
+// Deploy the program
+const tx_id = await programManager.deploy(program, fee);
+
+// Verify the transaction was successful
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) execute(options) → {Promise.<Transaction>}

Builds an execution transaction for submission to the Aleo network.
Parameters:
NameTypeDescription
optionsExecuteOptionsThe options for the execution transaction.
Returns:
- A promise that resolves to the transaction or an error.
Type: 
Promise.<Transaction>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+
+// Build and execute the transaction
+const transaction = await programManager.execute({
+  programName: "hello_hello.aleo",
+  functionName: "hello_hello",
+  fee: 0.020,
+  privateFee: false,
+  inputs: ["5u32", "5u32"],
+  keySearchParams: { "cacheKey": "hello_hello:hello" }
+});
+const result = await programManager.networkClient.submitTransaction(transaction);

(async) execute(options) → {Promise.<Transaction>}

Builds an execution transaction for submission to the Aleo network.
Parameters:
NameTypeDescription
optionsExecuteOptionsThe options for the execution transaction.
Returns:
- A promise that resolves to the transaction or an error.
Type: 
Promise.<Transaction>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+
+// Build and execute the transaction
+const transaction = await programManager.execute({
+  programName: "hello_hello.aleo",
+  functionName: "hello_hello",
+  fee: 0.020,
+  privateFee: false,
+  inputs: ["5u32", "5u32"],
+  keySearchParams: { "cacheKey": "hello_hello:hello" }
+});
+const result = await programManager.networkClient.submitTransaction(transaction);

(async) join(recordOne, recordTwo, fee, privateFee, recordSearchParams, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Join two credits records into a single credits record
Parameters:
NameTypeDescription
recordOneRecordPlaintext | stringFirst credits record to join
recordTwoRecordPlaintext | stringSecond credits record to join
feenumberFee in credits pay for the join transaction
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the fee record to use to pay the fee for the join transaction
feeRecordRecordPlaintext | string | undefinedFee record to use for the join transaction
privateKeyPrivateKey | undefinedPrivate key to use for the join transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
Type: 
Promise.<string>

(async) join(recordOne, recordTwo, fee, privateFee, recordSearchParams, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Join two credits records into a single credits record
Parameters:
NameTypeDescription
recordOneRecordPlaintext | stringFirst credits record to join
recordTwoRecordPlaintext | stringSecond credits record to join
feenumberFee in credits pay for the join transaction
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the fee record to use to pay the fee for the join transaction
feeRecordRecordPlaintext | string | undefinedFee record to use for the join transaction
privateKeyPrivateKey | undefinedPrivate key to use for the join transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
Type: 
Promise.<string>

(async) run(program, function_name, inputs, proveExecution, imports, keySearchParams, provingKey, verifyingKey, privateKey, offlineQuery) → {Promise.<string>}

Run an Aleo program in offline mode
Parameters:
NameTypeDescription
programstringProgram source code containing the function to be executed
function_namestringFunction name to execute
inputsArray.<string>Inputs to the function
proveExecutionnumberWhether to prove the execution of the function and return an execution transcript that contains the proof.
importsArray.<string> | undefinedOptional imports to the program
keySearchParamsKeySearchParams | undefinedOptional parameters for finding the matching proving & verifying keys for the function
provingKeyProvingKey | undefinedOptional proving key to use for the transaction
verifyingKeyVerifyingKey | undefinedOptional verifying key to use for the transaction
privateKeyPrivateKey | undefinedOptional private key to use for the transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
Type: 
Promise.<string>
Example
import { Account, Program } from '@provablehq/sdk';
+
+/// Create the source for the "helloworld" program
+const program = "program helloworld.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n";
+const programManager = new ProgramManager();
+
+/// Create a temporary account for the execution of the program
+const account = new Account();
+programManager.setAccount(account);
+
+/// Get the response and ensure that the program executed correctly
+const executionResponse = await programManager.run(program, "hello", ["5u32", "5u32"]);
+const result = executionResponse.getOutputs();
+assert(result === ["10u32"]);

(async) run(program, function_name, inputs, proveExecution, imports, keySearchParams, provingKey, verifyingKey, privateKey, offlineQuery) → {Promise.<string>}

Run an Aleo program in offline mode
Parameters:
NameTypeDescription
programstringProgram source code containing the function to be executed
function_namestringFunction name to execute
inputsArray.<string>Inputs to the function
proveExecutionnumberWhether to prove the execution of the function and return an execution transcript that contains the proof.
importsArray.<string> | undefinedOptional imports to the program
keySearchParamsKeySearchParams | undefinedOptional parameters for finding the matching proving & verifying keys for the function
provingKeyProvingKey | undefinedOptional proving key to use for the transaction
verifyingKeyVerifyingKey | undefinedOptional verifying key to use for the transaction
privateKeyPrivateKey | undefinedOptional private key to use for the transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
Type: 
Promise.<string>
Example
import { Account, Program } from '@provablehq/sdk';
+
+/// Create the source for the "helloworld" program
+const program = "program helloworld.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n";
+const programManager = new ProgramManager();
+
+/// Create a temporary account for the execution of the program
+const account = new Account();
+programManager.setAccount(account);
+
+/// Get the response and ensure that the program executed correctly
+const executionResponse = await programManager.run(program, "hello", ["5u32", "5u32"]);
+const result = executionResponse.getOutputs();
+assert(result === ["10u32"]);

setAccount(account)

Set the account to use for transaction submission to the Aleo network
Parameters:
NameTypeDescription
accountAccountAccount to use for transaction submission

setAccount(account)

Set the account to use for transaction submission to the Aleo network
Parameters:
NameTypeDescription
accountAccountAccount to use for transaction submission

setHost(host)

Set the host peer to use for transaction submission to the Aleo network
Parameters:
NameTypeDescription
hoststringPeer url to use for transaction submission

setHost(host)

Set the host peer to use for transaction submission to the Aleo network
Parameters:
NameTypeDescription
hoststringPeer url to use for transaction submission

setKeyProvider(keyProvider)

Set the key provider that provides the proving and verifying keys for programs
Parameters:
NameTypeDescription
keyProviderFunctionKeyProvider

setKeyProvider(keyProvider)

Set the key provider that provides the proving and verifying keys for programs
Parameters:
NameTypeDescription
keyProviderFunctionKeyProvider

setRecordProvider(recordProvider)

Set the record provider that provides records for transactions
Parameters:
NameTypeDescription
recordProviderRecordProvider

setRecordProvider(recordProvider)

Set the record provider that provides records for transactions
Parameters:
NameTypeDescription
recordProviderRecordProvider

(async) setValidatorState(validator_state, options)

Submit a set_validator_state transaction to the Aleo Network. This function allows a validator to set their state to be either opened or closed to new stakers. When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator. When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond. This function serves two primary purposes: 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers. 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
Parameters:
NameTypeDescription
validator_stateboolean
optionsPartial.<ExecuteOptions>Override default execution options
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("ValidatorPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.setValidatorState(true);

(async) setValidatorState(validator_state, options)

Submit a set_validator_state transaction to the Aleo Network. This function allows a validator to set their state to be either opened or closed to new stakers. When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator. When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond. This function serves two primary purposes: 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers. 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
Parameters:
NameTypeDescription
validator_stateboolean
optionsPartial.<ExecuteOptions>Override default execution options
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("ValidatorPrivateKey"));
+
+// Create the bonding transaction
+const tx_id = await programManager.setValidatorState(true);

(async) split(splitAmount, amountRecord, privateKey, offlineQuery) → {Promise.<string>}

Split credits into two new credits records
Parameters:
NameTypeDescription
splitAmountnumberAmount in microcredits to split from the original credits record
amountRecordRecordPlaintext | stringAmount record to use for the split transaction
privateKeyPrivateKey | undefinedOptional private key to use for the split transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
Type: 
Promise.<string>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programName = "hello_hello.aleo";
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+const record = "{  owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private,  microcredits: 45000000u64.private,  _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
+const tx_id = await programManager.split(25000000, record);
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) split(splitAmount, amountRecord, privateKey, offlineQuery) → {Promise.<string>}

Split credits into two new credits records
Parameters:
NameTypeDescription
splitAmountnumberAmount in microcredits to split from the original credits record
amountRecordRecordPlaintext | stringAmount record to use for the split transaction
privateKeyPrivateKey | undefinedOptional private key to use for the split transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
Type: 
Promise.<string>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programName = "hello_hello.aleo";
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+const record = "{  owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private,  microcredits: 45000000u64.private,  _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
+const tx_id = await programManager.split(25000000, record);
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) synthesizeKeys(program, function_id, inputs, privateKey) → {Promise.<FunctionKeyPair>}

Pre-synthesize proving and verifying keys for a program
Parameters:
NameTypeDescription
programstringThe program source code to synthesize keys for
function_idstringThe function id to synthesize keys for
inputsArray.<string>Sample inputs to the function
privateKeyPrivateKey | undefinedOptional private key to use for the key synthesis
Returns:
Type: 
Promise.<FunctionKeyPair>

(async) synthesizeKeys(program, function_id, inputs, privateKey) → {Promise.<FunctionKeyPair>}

Pre-synthesize proving and verifying keys for a program
Parameters:
NameTypeDescription
programstringThe program source code to synthesize keys for
function_idstringThe function id to synthesize keys for
inputsArray.<string>Sample inputs to the function
privateKeyPrivateKey | undefinedOptional private key to use for the key synthesis
Returns:
Type: 
Promise.<FunctionKeyPair>

(async) transfer(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Transfer credits to another account
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+await programManager.initialize();
+const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) transfer(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery) → {Promise.<string>}

Transfer credits to another account
Parameters:
NameTypeDescription
amountnumberThe amount of credits to transfer
recipientstringThe recipient of the transfer
transferTypestringThe type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
feenumberThe fee to pay for the transfer
privateFeebooleanUse a private record to pay the fee. If false this will use the account's public credit balance
recordSearchParamsRecordSearchParams | undefinedOptional parameters for finding the amount and fee records for the transfer transaction
amountRecordRecordPlaintext | stringOptional amount record to use for the transfer
feeRecordRecordPlaintext | stringOptional fee record to use for the transfer
privateKeyPrivateKey | undefinedOptional private key to use for the transfer transaction
offlineQueryOfflineQuery | undefinedOptional offline query if creating transactions in an offline environment
Returns:
The transaction id of the transfer transaction
Type: 
Promise.<string>
Example
// Create a new NetworkClient, KeyProvider, and RecordProvider
+const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+const keyProvider = new AleoKeyProvider();
+const recordProvider = new NetworkRecordProvider(account, networkClient);
+
+// Initialize a program manager with the key provider to automatically fetch keys for executions
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+await programManager.initialize();
+const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
+const transaction = await programManager.networkClient.getTransaction(tx_id);

(async) unbondPublic(staker_address, amount, options)

Unbond a specified amount of staked credits.
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is unbonding the credits
amountnumberAmount of credits to unbond. If the address of the executor of this function is an existing validator, it will subtract this amount of credits from the validator's staked credits. If there are less than 1,000,000 credits staked pool after the unbond, the validator will be removed from the validator set. If the address of the executor of this function is not a validator and has credits bonded as a delegator, it will subtract this amount of credits from the delegator's staked credits. If there are less than 10 credits bonded after the unbond operation, the delegator will be removed from the validator's staking pool.
optionsExecuteOptionsOptions for the execution
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction and send it to the network
+const tx_id = await programManager.unbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 10);

(async) unbondPublic(staker_address, amount, options)

Unbond a specified amount of staked credits.
Parameters:
NameTypeDescription
staker_addressstringAddress of the staker who is unbonding the credits
amountnumberAmount of credits to unbond. If the address of the executor of this function is an existing validator, it will subtract this amount of credits from the validator's staked credits. If there are less than 1,000,000 credits staked pool after the unbond, the validator will be removed from the validator set. If the address of the executor of this function is not a validator and has credits bonded as a delegator, it will subtract this amount of credits from the delegator's staked credits. If there are less than 10 credits bonded after the unbond operation, the delegator will be removed from the validator's staking pool.
optionsExecuteOptionsOptions for the execution
Returns:
string
Example
// Create a keyProvider to handle key management
+const keyProvider = new AleoKeyProvider();
+keyProvider.useCache = true;
+
+// Create a new ProgramManager with the key that will be used to bond credits
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+programManager.setAccount(new Account("YourPrivateKey"));
+
+// Create the bonding transaction and send it to the network
+const tx_id = await programManager.unbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 10);

verifyExecution(executionResponse) → {boolean}

Verify a proof of execution from an offline execution
Parameters:
NameTypeDescription
executionResponseexecutionResponse
Returns:
True if the proof is valid, false otherwise
Type: 
boolean

verifyExecution(executionResponse) → {boolean}

Verify a proof of execution from an offline execution
Parameters:
NameTypeDescription
executionResponseexecutionResponse
Returns:
True if the proof is valid, false otherwise
Type: 
boolean

verifyProgram(program)

Verify a program is valid
Parameters:
NameTypeDescription
programstringThe program source code

verifyProgram(program) → {boolean}

Verify a program is valid
Parameters:
NameTypeDescription
programstringThe program source code
Returns:
Type: 
boolean
\ No newline at end of file diff --git a/sdk/docs/ProgramManager_ProgramManager.html b/sdk/docs/ProgramManager_ProgramManager.html new file mode 100644 index 000000000..55f32e459 --- /dev/null +++ b/sdk/docs/ProgramManager_ProgramManager.html @@ -0,0 +1,3 @@ +Class: ProgramManager
On this page

ProgramManager# ProgramManager

\ No newline at end of file diff --git a/sdk/docs/RecordProvider.html b/sdk/docs/RecordProvider.html new file mode 100644 index 000000000..261cf72c1 --- /dev/null +++ b/sdk/docs/RecordProvider.html @@ -0,0 +1,46 @@ +Interface: RecordProvider
On this page

RecordProvider

Interface for a record provider. A record provider is used to find records for use in deployment and execution transactions on the Aleo Network. A default implementation is provided by the NetworkRecordProvider class. However, a custom implementation can be provided (say if records are synced locally to a database from the network) by implementing this interface.

Members

findCreditsRecord :Promise.<RecordPlaintext>

Find a credits.aleo record with a given number of microcredits from the chosen provider
Type:
  • Promise.<RecordPlaintext>
Example
// A class implementing record provider can be used to find a record with a given number of microcredits
+const record = await recordProvider.findCreditsRecord(5000, true, []);
+
+// When a record is found but not yet used, its nonce should be added to the nonces array so that it is not
+// found again if a subsequent search is performed
+const record2 = await recordProvider.findCreditsRecord(5000, true, [record.nonce()]);
+
+// When the program manager is initialized with the record provider it will be used to find automatically find
+// fee records and amount records for value transfers so that they do not need to be specified manually
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);

findCreditsRecords :Promise.<Array>

Find a list of credit.aleo records with a given number of microcredits from the chosen provider
Type:
  • Promise.<Array>
Example
// A class implementing record provider can be used to find a record with a given number of microcredits
+const records = await recordProvider.findCreditsRecords([5000, 5000], true, []);
+
+// When a record is found but not yet used, it's nonce should be added to the nonces array so that it is not
+// found again if a subsequent search is performed
+const nonces = [];
+records.forEach(record => { nonces.push(record.nonce()) });
+const records2 = await recordProvider.findCreditsRecord(5000, true, nonces);
+
+// When the program manager is initialized with the record provider it will be used to find automatically find
+// fee records and amount records for value transfers so that they do not need to be specified manually
+const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);

findRecord :Promise.<RecordPlaintext>

Find an arbitrary record
Type:
  • Promise.<RecordPlaintext>
Example
// The RecordSearchParams interface can be used to create parameters for custom record searches which can then
+// be passed to the record provider. An example of how this would be done for the credits.aleo program is shown
+// below.
+
+class CustomRecordSearch implements RecordSearchParams {
+    startHeight: number;
+    endHeight: number;
+    amount: number;
+    program: string;
+    recordName: string;
+    constructor(startHeight: number, endHeight: number, credits: number, maxRecords: number, programName: string, recordName: string) {
+        this.startHeight = startHeight;
+        this.endHeight = endHeight;
+        this.amount = amount;
+        this.program = programName;
+        this.recordName = recordName;
+    }
+}
+
+const params = new CustomRecordSearch(0, 100, 5000, "credits.aleo", "credits");
+
+const record = await recordProvider.findRecord(true, [], params);

findRecords :Promise.<Array>

Find multiple records from arbitrary programs
Type:
  • Promise.<Array>
\ No newline at end of file diff --git a/sdk/docs/RecordSearchParams.html b/sdk/docs/RecordSearchParams.html new file mode 100644 index 000000000..bf7cb71bb --- /dev/null +++ b/sdk/docs/RecordSearchParams.html @@ -0,0 +1,3 @@ +Interface: RecordSearchParams
On this page

RecordSearchParams

Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider implementations.
\ No newline at end of file diff --git a/sdk/docs/account.ts.html b/sdk/docs/account.ts.html index 9a2401d9b..4eb500b55 100644 --- a/sdk/docs/account.ts.html +++ b/sdk/docs/account.ts.html @@ -1,13 +1,13 @@ -Source: account.ts
On this page

account.ts

import {
+Source: account.ts
On this page

account.ts

import {
   Address,
   PrivateKey,
   Signature,
   ViewKey,
   PrivateKeyCiphertext,
   RecordCiphertext,
-} from "@provablehq/wasm";
+} from "./wasm";
 
 interface AccountParam {
   privateKey?: string;
@@ -27,18 +27,18 @@
  *
  * @example
  * // Create a new account
- * let myRandomAccount = new Account();
+ * const myRandomAccount = new Account();
  *
  * // Create an account from a randomly generated seed
- * let seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);
- * let mySeededAccount = new Account({seed: seed});
+ * const seed = new Uint8Array([94, 91, 52, 251, 240, 230, 226, 35, 117, 253, 224, 210, 175, 13, 205, 120, 155, 214, 7, 169, 66, 62, 206, 50, 188, 40, 29, 122, 40, 250, 54, 18]);
+ * const mySeededAccount = new Account({seed: seed});
  *
  * // Create an account from an existing private key
- * let myExistingAccount = new Account({privateKey: 'myExistingPrivateKey'})
+ * const myExistingAccount = new Account({privateKey: 'myExistingPrivateKey'})
  *
  * // Sign a message
- * let hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
- * let signature = myRandomAccount.sign(hello_world)
+ * const hello_world = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+ * const signature = myRandomAccount.sign(hello_world)
  *
  * // Verify a signature
  * myRandomAccount.verify(hello_world, signature)
@@ -63,11 +63,11 @@
    * Attempts to create an account from a private key ciphertext
    * @param {PrivateKeyCiphertext | string} ciphertext
    * @param {string} password
-   * @returns {PrivateKey | Error}
+   * @returns {PrivateKey}
    *
    * @example
-   * let ciphertext = PrivateKey.newEncrypted("password");
-   * let account = Account.fromCiphertext(ciphertext, "password");
+   * const ciphertext = PrivateKey.newEncrypted("password");
+   * const account = Account.fromCiphertext(ciphertext, "password");
    */
   public static fromCiphertext(ciphertext: PrivateKeyCiphertext | string, password: string) {
     try {
@@ -111,8 +111,8 @@
    * @returns {PrivateKeyCiphertext}
    *
    * @example
-   * let account = new Account();
-   * let ciphertext = account.encryptAccount("password");
+   * const account = new Account();
+   * const ciphertext = account.encryptAccount("password");
    */
   encryptAccount(password: string) {
     return this._privateKey.toCiphertext(password);
@@ -124,8 +124,8 @@
    * @returns {Record}
    *
    * @example
-   * let account = new Account();
-   * let record = account.decryptRecord("record1ciphertext");
+   * const account = new Account();
+   * const record = account.decryptRecord("record1ciphertext");
    */
   decryptRecord(ciphertext: string) {
     return this._viewKey.decrypt(ciphertext);
@@ -137,8 +137,8 @@
    * @returns {Record[]}
    *
    * @example
-   * let account = new Account();
-   * let record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);
+   * const account = new Account();
+   * const record = account.decryptRecords(["record1ciphertext", "record2ciphertext"]);
    */
   decryptRecords(ciphertexts: string[]) {
     return ciphertexts.map((ciphertext) => this._viewKey.decrypt(ciphertext));
@@ -151,12 +151,12 @@
    *
    * @example
    * // Create a connection to the Aleo network and an account
-   * let connection = new NodeConnection("vm.aleo.org/api");
-   * let account = Account.fromCiphertext("ciphertext", "password");
+   * const connection = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+   * const account = Account.fromCiphertext("ciphertext", "password");
    *
    * // Get a record from the network
-   * let record = connection.getBlock(1234);
-   * let recordCipherText = record.transactions[0].execution.transitions[0].id;
+   * const record = connection.getBlock(1234);
+   * const recordCipherText = record.transactions[0].execution.transitions[0].id;
    *
    * // Check if the account owns the record
    * if account.ownsRecord(recordCipherText) {
@@ -189,8 +189,8 @@
    * @returns {Signature}
    *
    * @example
-   * let account = new Account();
-   * let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+   * const account = new Account();
+   * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
    * account.sign(message);
    */
   sign(message: Uint8Array) {
@@ -205,13 +205,14 @@
    * @returns {boolean}
    *
    * @example
-   * let account = new Account();
-   * let message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
-   * let signature = account.sign(message);
+   * const account = new Account();
+   * const message = Uint8Array.from([104, 101, 108, 108, 111 119, 111, 114, 108, 100])
+   * const signature = account.sign(message);
    * account.verify(message, signature);
    */
   verify(message: Uint8Array, signature: Signature) {
     return this._address.verify(message, signature);
   }
+
 }
-
+
\ No newline at end of file diff --git a/sdk/docs/data/search.json b/sdk/docs/data/search.json index 1e166d79c..dce00df90 100644 --- a/sdk/docs/data/search.json +++ b/sdk/docs/data/search.json @@ -1 +1 @@ -{"list":[{"title":"Account","link":"Account"},{"title":"Account.fromCiphertext","link":"Account ▸ fromCiphertext","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account.fromCiphertext","link":"Account ▸ fromCiphertext","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#decryptRecord","link":"Account ▸ decryptRecord","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#decryptRecord","link":"Account ▸ decryptRecord","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#decryptRecords","link":"Account ▸ decryptRecords","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#decryptRecords","link":"Account ▸ decryptRecords","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#encryptAccount","link":"Account ▸ encryptAccount","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#encryptAccount","link":"Account ▸ encryptAccount","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#ownsRecordCiphertext","link":"Account ▸ ownsRecordCiphertext","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#ownsRecordCiphertext","link":"Account ▸ ownsRecordCiphertext","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#sign","link":"Account ▸ sign","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#sign","link":"Account ▸ sign","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#verify","link":"Account ▸ verify","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"Account#verify","link":"Account ▸ verify","description":"Key Management class. Enables the creation of a new Aleo Account, importation of an existing account from\nan existing private key or seed, and message signing and verification functionality.\n\nAn Aleo Account is generated from a randomly generated seed (number) from which an account private key, view key,\nand a public account address are derived. The private key lies at the root of an Aleo account. It is a highly\nsensitive secret and should be protected as it allows for creation of Aleo Program executions and arbitrary value\ntransfers. The View Key allows for decryption of a user's activity on the blockchain. The Address is the public\naddress to which other users of Aleo can send Aleo credits and other records to. This class should only be used\nenvironments where the safety of the underlying key material can be assured."},{"title":"AleoNetworkClient","link":"AleoNetworkClient"},{"title":"AleoNetworkClient#findUnspentRecords","link":"AleoNetworkClient ▸ findUnspentRecords","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#findUnspentRecords","link":"AleoNetworkClient ▸ findUnspentRecords","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getAccount","link":"AleoNetworkClient ▸ getAccount","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getAccount","link":"AleoNetworkClient ▸ getAccount","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getBlock","link":"AleoNetworkClient ▸ getBlock","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getBlock","link":"AleoNetworkClient ▸ getBlock","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getBlockRange","link":"AleoNetworkClient ▸ getBlockRange","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getBlockRange","link":"AleoNetworkClient ▸ getBlockRange","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getLatestBlock","link":"AleoNetworkClient ▸ getLatestBlock","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getLatestBlock","link":"AleoNetworkClient ▸ getLatestBlock","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getLatestHash","link":"AleoNetworkClient ▸ getLatestHash","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getLatestHash","link":"AleoNetworkClient ▸ getLatestHash","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getLatestHeight","link":"AleoNetworkClient ▸ getLatestHeight","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getLatestHeight","link":"AleoNetworkClient ▸ getLatestHeight","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getProgram","link":"AleoNetworkClient ▸ getProgram","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getProgram","link":"AleoNetworkClient ▸ getProgram","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getStateRoot","link":"AleoNetworkClient ▸ getStateRoot","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getStateRoot","link":"AleoNetworkClient ▸ getStateRoot","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransaction","link":"AleoNetworkClient ▸ getTransaction","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransaction","link":"AleoNetworkClient ▸ getTransaction","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransactions","link":"AleoNetworkClient ▸ getTransactions","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransactions","link":"AleoNetworkClient ▸ getTransactions","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransactionsInMempool","link":"AleoNetworkClient ▸ getTransactionsInMempool","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransactionsInMempool","link":"AleoNetworkClient ▸ getTransactionsInMempool","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransitionId","link":"AleoNetworkClient ▸ getTransitionId","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#getTransitionId","link":"AleoNetworkClient ▸ getTransitionId","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#setAccount","link":"AleoNetworkClient ▸ setAccount","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"AleoNetworkClient#setAccount","link":"AleoNetworkClient ▸ setAccount","description":"Connection management class that encapsulates REST calls to publicly exposed endpoints of Aleo nodes.\nThe methods provided in this class provide information on the Aleo Blockchain"},{"title":"DevelopmentClient","link":"DevelopmentClient","description":"Creates a new DevelopmentClient to interact with an Aleo Development Server."}]} \ No newline at end of file +{"list":[{"title":"Account","link":"Account"},{"title":"Account.fromCiphertext","link":"fromCiphertext","description":"Attempts to create an account from a private key ciphertext"},{"title":"Account.fromCiphertext","link":"fromCiphertext","description":"Attempts to create an account from a private key ciphertext"},{"title":"Account#decryptRecord","link":"decryptRecord","description":"Decrypts a Record in ciphertext form into plaintext"},{"title":"Account#decryptRecord","link":"decryptRecord","description":"Decrypts a Record in ciphertext form into plaintext"},{"title":"Account#decryptRecords","link":"decryptRecords","description":"Decrypts an array of Records in ciphertext form into plaintext"},{"title":"Account#decryptRecords","link":"decryptRecords","description":"Decrypts an array of Records in ciphertext form into plaintext"},{"title":"Account#encryptAccount","link":"encryptAccount","description":"Encrypt the account's private key with a password"},{"title":"Account#encryptAccount","link":"encryptAccount","description":"Encrypt the account's private key with a password"},{"title":"Account#ownsRecordCiphertext","link":"ownsRecordCiphertext","description":"Determines whether the account owns a ciphertext record"},{"title":"Account#ownsRecordCiphertext","link":"ownsRecordCiphertext","description":"Determines whether the account owns a ciphertext record"},{"title":"Account#sign","link":"sign","description":"Signs a message with the account's private key.\nReturns a Signature."},{"title":"Account#sign","link":"sign","description":"Signs a message with the account's private key.\nReturns a Signature."},{"title":"Account#verify","link":"verify","description":"Verifies the Signature on a message."},{"title":"Account#verify","link":"verify","description":"Verifies the Signature on a message."},{"title":"AleoKeyProvider","link":"AleoKeyProvider"},{"title":"AleoKeyProvider#cacheKeys","link":"cacheKeys","description":"Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\nexists in the cache using the containsKeys method prior to calling this method if overwriting is not desired."},{"title":"AleoKeyProvider#cacheKeys","link":"cacheKeys","description":"Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\nexists in the cache using the containsKeys method prior to calling this method if overwriting is not desired."},{"title":"AleoKeyProvider#clearCache","link":"clearCache","description":"Clear the key cache"},{"title":"AleoKeyProvider#clearCache","link":"clearCache","description":"Clear the key cache"},{"title":"AleoKeyProvider#containsKeys","link":"containsKeys","description":"Determine if a keyId exists in the cache"},{"title":"AleoKeyProvider#containsKeys","link":"containsKeys","description":"Determine if a keyId exists in the cache"},{"title":"AleoKeyProvider#deleteKeys","link":"deleteKeys","description":"Delete a set of keys from the cache"},{"title":"AleoKeyProvider#deleteKeys","link":"deleteKeys","description":"Delete a set of keys from the cache"},{"title":"AleoKeyProvider#feePrivateKeys","link":"feePrivateKeys","description":"Returns the proving and verifying keys for the fee_private function in the credits.aleo program"},{"title":"AleoKeyProvider#feePrivateKeys","link":"feePrivateKeys","description":"Returns the proving and verifying keys for the fee_private function in the credits.aleo program"},{"title":"AleoKeyProvider#feePublicKeys","link":"feePublicKeys","description":"Returns the proving and verifying keys for the fee_public function in the credits.aleo program"},{"title":"AleoKeyProvider#feePublicKeys","link":"feePublicKeys","description":"Returns the proving and verifying keys for the fee_public function in the credits.aleo program"},{"title":"AleoKeyProvider#fetchRemoteKeys","link":"fetchRemoteKeys","description":"Returns the proving and verifying keys for a specified program from a specified url."},{"title":"AleoKeyProvider#fetchRemoteKeys","link":"fetchRemoteKeys","description":"Returns the proving and verifying keys for a specified program from a specified url."},{"title":"AleoKeyProvider#functionKeys","link":"functionKeys","description":"Get arbitrary function keys from a provider"},{"title":"AleoKeyProvider#functionKeys","link":"functionKeys","description":"Get arbitrary function keys from a provider"},{"title":"AleoKeyProvider#getKeys","link":"getKeys","description":"Get a set of keys from the cache"},{"title":"AleoKeyProvider#getKeys","link":"getKeys","description":"Get a set of keys from the cache"},{"title":"AleoKeyProvider#getVerifyingKey","link":"getVerifyingKey","description":"Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise"},{"title":"AleoKeyProvider#getVerifyingKey","link":"getVerifyingKey","description":"Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise"},{"title":"AleoKeyProvider#joinKeys","link":"joinKeys","description":"Returns the proving and verifying keys for the join function in the credits.aleo program"},{"title":"AleoKeyProvider#joinKeys","link":"joinKeys","description":"Returns the proving and verifying keys for the join function in the credits.aleo program"},{"title":"AleoKeyProvider#splitKeys","link":"splitKeys","description":"Returns the proving and verifying keys for the split function in the credits.aleo program"},{"title":"AleoKeyProvider#splitKeys","link":"splitKeys","description":"Returns the proving and verifying keys for the split function in the credits.aleo program"},{"title":"AleoKeyProvider#transferKeys","link":"transferKeys","description":"Returns the proving and verifying keys for the transfer functions in the credits.aleo program"},{"title":"AleoKeyProvider#transferKeys","link":"transferKeys","description":"Returns the proving and verifying keys for the transfer functions in the credits.aleo program"},{"title":"AleoKeyProvider#useCache","link":"useCache","description":"Use local memory to store keys"},{"title":"AleoKeyProvider#useCache","link":"useCache","description":"Use local memory to store keys"},{"title":"AleoKeyProviderParams","link":"AleoKeyProviderParams","description":"Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally\nspecify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique\ncacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must\nbe provided."},{"title":"AleoKeyProviderParams#AleoKeyProviderParams","link":"AleoKeyProviderParams","description":"Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally\nspecify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique\ncacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must\nbe provided."},{"title":"AleoNetworkClient","link":"AleoNetworkClient"},{"title":"AleoNetworkClient#findUnspentRecords","link":"findUnspentRecords","description":"Attempts to find unspent records in the Aleo blockchain for a specified private key."},{"title":"AleoNetworkClient#findUnspentRecords","link":"findUnspentRecords","description":"Attempts to find unspent records in the Aleo blockchain for a specified private key."},{"title":"AleoNetworkClient#getAccount","link":"getAccount","description":"Return the Aleo account used in the networkClient"},{"title":"AleoNetworkClient#getAccount","link":"getAccount","description":"Return the Aleo account used in the networkClient"},{"title":"AleoNetworkClient#getBlock","link":"getBlock","description":"Returns the contents of the block at the specified block height."},{"title":"AleoNetworkClient#getBlock","link":"getBlock","description":"Returns the contents of the block at the specified block height."},{"title":"AleoNetworkClient#getBlockRange","link":"getBlockRange","description":"Returns a range of blocks between the specified block heights."},{"title":"AleoNetworkClient#getBlockRange","link":"getBlockRange","description":"Returns a range of blocks between the specified block heights."},{"title":"AleoNetworkClient#getDeploymentTransactionForProgram","link":"getDeploymentTransactionForProgram","description":"Returns the deployment transaction associated with a specified program."},{"title":"AleoNetworkClient#getDeploymentTransactionForProgram","link":"getDeploymentTransactionForProgram","description":"Returns the deployment transaction associated with a specified program."},{"title":"AleoNetworkClient#getDeploymentTransactionIDForProgram","link":"getDeploymentTransactionIDForProgram","description":"Returns the deployment transaction id associated with the specified program."},{"title":"AleoNetworkClient#getDeploymentTransactionIDForProgram","link":"getDeploymentTransactionIDForProgram","description":"Returns the deployment transaction id associated with the specified program."},{"title":"AleoNetworkClient#getDeploymentTransactioObjectnForProgram","link":"getDeploymentTransactioObjectnForProgram","description":"Returns the deployment transaction associated with a specified program as a wasm object."},{"title":"AleoNetworkClient#getDeploymentTransactioObjectnForProgram","link":"getDeploymentTransactioObjectnForProgram","description":"Returns the deployment transaction associated with a specified program as a wasm object."},{"title":"AleoNetworkClient#getLatestBlock","link":"getLatestBlock","description":"Returns the contents of the latest block."},{"title":"AleoNetworkClient#getLatestBlock","link":"getLatestBlock","description":"Returns the contents of the latest block."},{"title":"AleoNetworkClient#getLatestCommittee","link":"getLatestCommittee","description":"Returns the latest committee."},{"title":"AleoNetworkClient#getLatestCommittee","link":"getLatestCommittee","description":"Returns the latest committee."},{"title":"AleoNetworkClient#getLatestHeight","link":"getLatestHeight","description":"Returns the latest block height."},{"title":"AleoNetworkClient#getLatestHeight","link":"getLatestHeight","description":"Returns the latest block height."},{"title":"AleoNetworkClient#getProgram","link":"getProgram","description":"Returns the source code of a program given a program ID."},{"title":"AleoNetworkClient#getProgram","link":"getProgram","description":"Returns the source code of a program given a program ID."},{"title":"AleoNetworkClient#getProgramImportNames","link":"getProgramImportNames","description":"Get a list of the program names that a program imports."},{"title":"AleoNetworkClient#getProgramImportNames","link":"getProgramImportNames","description":"Get a list of the program names that a program imports."},{"title":"AleoNetworkClient#getProgramImports","link":"getProgramImports","description":"Returns an object containing the source code of a program and the source code of all programs it imports"},{"title":"AleoNetworkClient#getProgramImports","link":"getProgramImports","description":"Returns an object containing the source code of a program and the source code of all programs it imports"},{"title":"AleoNetworkClient#getProgramMappingNames","link":"getProgramMappingNames","description":"Returns the names of the mappings of a program."},{"title":"AleoNetworkClient#getProgramMappingNames","link":"getProgramMappingNames","description":"Returns the names of the mappings of a program."},{"title":"AleoNetworkClient#getProgramMappingPlaintext","link":"getProgramMappingPlaintext","description":"Returns the value of a mapping as a wasm Plaintext object. Returning an\nobject in this format allows it to be converted to a Js type and for its\ninternal members to be inspected if it's a struct or array."},{"title":"AleoNetworkClient#getProgramMappingPlaintext","link":"getProgramMappingPlaintext","description":"Returns the value of a mapping as a wasm Plaintext object. Returning an\nobject in this format allows it to be converted to a Js type and for its\ninternal members to be inspected if it's a struct or array."},{"title":"AleoNetworkClient#getProgramMappingValue","link":"getProgramMappingValue","description":"Returns the value of a program's mapping for a specific key."},{"title":"AleoNetworkClient#getProgramMappingValue","link":"getProgramMappingValue","description":"Returns the value of a program's mapping for a specific key."},{"title":"AleoNetworkClient#getProgramObject","link":"getProgramObject","description":"Returns a program object from a program ID or program source code."},{"title":"AleoNetworkClient#getProgramObject","link":"getProgramObject","description":"Returns a program object from a program ID or program source code."},{"title":"AleoNetworkClient#getStateRoot","link":"getStateRoot","description":"Returns the latest state/merkle root of the Aleo blockchain."},{"title":"AleoNetworkClient#getStateRoot","link":"getStateRoot","description":"Returns the latest state/merkle root of the Aleo blockchain."},{"title":"AleoNetworkClient#getTransaction","link":"getTransaction","description":"Returns a transaction by its unique identifier."},{"title":"AleoNetworkClient#getTransaction","link":"getTransaction","description":"Returns a transaction by its unique identifier."},{"title":"AleoNetworkClient#getTransactionObject","link":"getTransactionObject","description":"Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,\noutputs, and records to be searched for and displayed."},{"title":"AleoNetworkClient#getTransactionObject","link":"getTransactionObject","description":"Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,\noutputs, and records to be searched for and displayed."},{"title":"AleoNetworkClient#getTransactionObjects","link":"getTransactionObjects","description":"Returns an array of transactions as wasm objects present at the specified block height."},{"title":"AleoNetworkClient#getTransactionObjects","link":"getTransactionObjects","description":"Returns an array of transactions as wasm objects present at the specified block height."},{"title":"AleoNetworkClient#getTransactionObjectsInMempool","link":"getTransactionObjectsInMempool","description":"Returns the transactions in the memory pool as wasm objects."},{"title":"AleoNetworkClient#getTransactionObjectsInMempool","link":"getTransactionObjectsInMempool","description":"Returns the transactions in the memory pool as wasm objects."},{"title":"AleoNetworkClient#getTransactions","link":"getTransactions","description":"Returns the transactions present at the specified block height."},{"title":"AleoNetworkClient#getTransactions","link":"getTransactions","description":"Returns the transactions present at the specified block height."},{"title":"AleoNetworkClient#getTransactionsInMempool","link":"getTransactionsInMempool","description":"Returns the transactions in the memory pool."},{"title":"AleoNetworkClient#getTransactionsInMempool","link":"getTransactionsInMempool","description":"Returns the transactions in the memory pool."},{"title":"AleoNetworkClient#getTransitionId","link":"getTransitionId","description":"Returns the transition ID of the transition corresponding to the ID of the input or output."},{"title":"AleoNetworkClient#getTransitionId","link":"getTransitionId","description":"Returns the transition ID of the transition corresponding to the ID of the input or output."},{"title":"AleoNetworkClient#setAccount","link":"setAccount","description":"Set an account to use in networkClient calls"},{"title":"AleoNetworkClient#setAccount","link":"setAccount","description":"Set an account to use in networkClient calls"},{"title":"AleoNetworkClient#setHost","link":"setHost","description":"Set a new host for the networkClient"},{"title":"AleoNetworkClient#setHost","link":"setHost","description":"Set a new host for the networkClient"},{"title":"AleoNetworkClient#submitSolution","link":"submitSolution","description":"Submit a solution to the Aleo network."},{"title":"AleoNetworkClient#submitSolution","link":"submitSolution","description":"Submit a solution to the Aleo network."},{"title":"AleoNetworkClient#submitTransaction","link":"submitTransaction","description":"Submit an execute or deployment transaction to the Aleo network."},{"title":"AleoNetworkClient#submitTransaction","link":"submitTransaction","description":"Submit an execute or deployment transaction to the Aleo network."},{"title":"BlockHeightSearch","link":"BlockHeightSearch"},{"title":"ExecuteOptions","link":"ExecuteOptions","description":"Represents the options for executing a transaction in the Aleo network.\nThis interface is used to specify the parameters required for building and submitting an execution transaction."},{"title":"FunctionKeyProvider","link":"FunctionKeyProvider","description":"KeyProvider interface. Enables the retrieval of public proving and verifying keys for Aleo Programs."},{"title":"FunctionKeyProvider#bondPublicKeys","link":"bondPublicKeys","description":"Get bond_public function keys from the credits.aleo program"},{"title":"FunctionKeyProvider#bondValidatorKeys","link":"bondValidatorKeys","description":"Get bond_validator function keys from the credits.aleo program"},{"title":"FunctionKeyProvider#cacheKeys","link":"cacheKeys","description":"Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\nexists in the cache using the containsKeys method prior to calling this method if overwriting is not desired."},{"title":"FunctionKeyProvider#claimUnbondPublicKeys","link":"claimUnbondPublicKeys","description":"Get unbond_public function keys from the credits.aleo program"},{"title":"FunctionKeyProvider#feePrivateKeys","link":"feePrivateKeys","description":"Get fee_private function keys from the credits.aleo program"},{"title":"FunctionKeyProvider#feePublicKeys","link":"feePublicKeys","description":"Get fee_public function keys from the credits.aleo program"},{"title":"FunctionKeyProvider#functionKeys","link":"functionKeys","description":"Get arbitrary function keys from a provider"},{"title":"FunctionKeyProvider#joinKeys","link":"joinKeys","description":"Get join function keys from the credits.aleo program"},{"title":"FunctionKeyProvider#splitKeys","link":"splitKeys","description":"Get split function keys from the credits.aleo program"},{"title":"FunctionKeyProvider#transferKeys","link":"transferKeys","description":"Get keys for a variant of the transfer function from the credits.aleo program"},{"title":"FunctionKeyProvider#unBondPublicKeys","link":"unBondPublicKeys","description":"Get unbond_public function keys from the credits.aleo program"},{"title":"KeySearchParams","link":"KeySearchParams","description":"Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider\nimplementations."},{"title":"NetworkRecordProvider","link":"NetworkRecordProvider"},{"title":"NetworkRecordProvider#findCreditsRecord","link":"findCreditsRecord","description":"Find a credit record with a given number of microcredits by via the official Aleo API"},{"title":"NetworkRecordProvider#findCreditsRecord","link":"findCreditsRecord","description":"Find a credit record with a given number of microcredits by via the official Aleo API"},{"title":"NetworkRecordProvider#findCreditsRecords","link":"findCreditsRecords","description":"Find a list of credit records with a given number of microcredits by via the official Aleo API"},{"title":"NetworkRecordProvider#findCreditsRecords","link":"findCreditsRecords","description":"Find a list of credit records with a given number of microcredits by via the official Aleo API"},{"title":"NetworkRecordProvider#findRecord","link":"findRecord","description":"Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error."},{"title":"NetworkRecordProvider#findRecord","link":"findRecord","description":"Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error."},{"title":"NetworkRecordProvider#findRecords","link":"findRecords","description":"Find multiple arbitrary records. WARNING: This function is not implemented yet and will throw an error."},{"title":"NetworkRecordProvider#findRecords","link":"findRecords","description":"Find multiple arbitrary records. WARNING: This function is not implemented yet and will throw an error."},{"title":"NetworkRecordProvider#setAccount","link":"setAccount","description":"Set the account used to search for records"},{"title":"NetworkRecordProvider#setAccount","link":"setAccount","description":"Set the account used to search for records"},{"title":"OfflineKeyProvider","link":"OfflineKeyProvider"},{"title":"OfflineKeyProvider#bondPublicKeys","link":"bondPublicKeys","description":"Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#bondPublicKeys","link":"bondPublicKeys","description":"Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#bondValidatorKeys","link":"bondValidatorKeys","description":"Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#bondValidatorKeys","link":"bondValidatorKeys","description":"Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#cacheKeys","link":"cacheKeys","description":"Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\nexists in the cache using the containsKeys method prior to calling this method if overwriting is not desired."},{"title":"OfflineKeyProvider#cacheKeys","link":"cacheKeys","description":"Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId\nexists in the cache using the containsKeys method prior to calling this method if overwriting is not desired."},{"title":"OfflineKeyProvider#claimUnbondPublicKeys","link":"claimUnbondPublicKeys","description":"Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#claimUnbondPublicKeys","link":"claimUnbondPublicKeys","description":"Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#feePrivateKeys","link":"feePrivateKeys","description":"Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#feePrivateKeys","link":"feePrivateKeys","description":"Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#feePublicKeys","link":"feePublicKeys","description":"Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#feePublicKeys","link":"feePublicKeys","description":"Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#functionKeys","link":"functionKeys","description":"Get arbitrary function key from the offline key provider cache."},{"title":"OfflineKeyProvider#functionKeys","link":"functionKeys","description":"Get arbitrary function key from the offline key provider cache."},{"title":"OfflineKeyProvider#insertBondPublicKeys","link":"insertBondPublicKeys","description":"Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for bond_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertBondPublicKeys","link":"insertBondPublicKeys","description":"Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for bond_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertClaimUnbondPublicKeys","link":"insertClaimUnbondPublicKeys","description":"Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for claim_unbond_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertClaimUnbondPublicKeys","link":"insertClaimUnbondPublicKeys","description":"Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for claim_unbond_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertFeePrivateKeys","link":"insertFeePrivateKeys","description":"Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for fee_private before inserting them into the cache."},{"title":"OfflineKeyProvider#insertFeePrivateKeys","link":"insertFeePrivateKeys","description":"Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for fee_private before inserting them into the cache."},{"title":"OfflineKeyProvider#insertFeePublicKeys","link":"insertFeePublicKeys","description":"Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for fee_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertFeePublicKeys","link":"insertFeePublicKeys","description":"Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for fee_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertJoinKeys","link":"insertJoinKeys","description":"Insert the proving and verifying keys for the join function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for join before inserting them into the cache."},{"title":"OfflineKeyProvider#insertJoinKeys","link":"insertJoinKeys","description":"Insert the proving and verifying keys for the join function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for join before inserting them into the cache."},{"title":"OfflineKeyProvider#insertSetValidatorStateKeys","link":"insertSetValidatorStateKeys","description":"Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for set_validator_state before inserting them into the cache."},{"title":"OfflineKeyProvider#insertSetValidatorStateKeys","link":"insertSetValidatorStateKeys","description":"Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for set_validator_state before inserting them into the cache."},{"title":"OfflineKeyProvider#insertSplitKeys","link":"insertSplitKeys","description":"Insert the proving and verifying keys for the split function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for split before inserting them into the cache."},{"title":"OfflineKeyProvider#insertSplitKeys","link":"insertSplitKeys","description":"Insert the proving and verifying keys for the split function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for split before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPrivateKeys","link":"insertTransferPrivateKeys","description":"Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_private before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPrivateKeys","link":"insertTransferPrivateKeys","description":"Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_private before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPrivateToPublicKeys","link":"insertTransferPrivateToPublicKeys","description":"Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_private_to_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPrivateToPublicKeys","link":"insertTransferPrivateToPublicKeys","description":"Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_private_to_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPublicKeys","link":"insertTransferPublicKeys","description":"Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPublicKeys","link":"insertTransferPublicKeys","description":"Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_public before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPublicToPrivateKeys","link":"insertTransferPublicToPrivateKeys","description":"Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_public_to_private before inserting them into the cache."},{"title":"OfflineKeyProvider#insertTransferPublicToPrivateKeys","link":"insertTransferPublicToPrivateKeys","description":"Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs\nto be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check\nthat the keys match the expected checksum for transfer_public_to_private before inserting them into the cache."},{"title":"OfflineKeyProvider#joinKeys","link":"joinKeys","description":"Get join function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#joinKeys","link":"joinKeys","description":"Get join function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#splitKeys","link":"splitKeys","description":"Get split function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#splitKeys","link":"splitKeys","description":"Get split function keys from the credits.aleo program. The keys must be cached prior to calling this\nmethod for it to work."},{"title":"OfflineKeyProvider#transferKeys","link":"transferKeys","description":"Get keys for a variant of the transfer function from the credits.aleo program."},{"title":"OfflineKeyProvider#transferKeys","link":"transferKeys","description":"Get keys for a variant of the transfer function from the credits.aleo program."},{"title":"OfflineKeyProvider#unBondPublicKeys","link":"unBondPublicKeys","description":"Get unbond_public function keys from the credits.aleo program"},{"title":"OfflineKeyProvider#unBondPublicKeys","link":"unBondPublicKeys","description":"Get unbond_public function keys from the credits.aleo program"},{"title":"OfflineKeyProvider#verifyCreditsKeys","link":"verifyCreditsKeys","description":"Determines if the keys for a given credits function match the expected keys."},{"title":"OfflineKeyProvider#verifyCreditsKeys","link":"verifyCreditsKeys","description":"Determines if the keys for a given credits function match the expected keys."},{"title":"OfflineSearchParams","link":"OfflineSearchParams","description":"Create a new OfflineSearchParams instance."},{"title":"OfflineSearchParams.bondPublicKeyParams","link":"bondPublicKeyParams","description":"Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program."},{"title":"OfflineSearchParams.bondPublicKeyParams","link":"bondPublicKeyParams","description":"Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program."},{"title":"OfflineSearchParams.bondValidatorKeyParams","link":"bondValidatorKeyParams","description":"Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program."},{"title":"OfflineSearchParams.bondValidatorKeyParams","link":"bondValidatorKeyParams","description":"Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program."},{"title":"OfflineSearchParams.claimUnbondPublicKeyParams","link":"claimUnbondPublicKeyParams","description":"Create a new OfflineSearchParams instance for the claim_unbond_public function of the"},{"title":"OfflineSearchParams.claimUnbondPublicKeyParams","link":"claimUnbondPublicKeyParams","description":"Create a new OfflineSearchParams instance for the claim_unbond_public function of the"},{"title":"OfflineSearchParams.feePrivateKeyParams","link":"feePrivateKeyParams","description":"Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program."},{"title":"OfflineSearchParams.feePrivateKeyParams","link":"feePrivateKeyParams","description":"Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program."},{"title":"OfflineSearchParams.feePublicKeyParams","link":"feePublicKeyParams","description":"Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program."},{"title":"OfflineSearchParams.feePublicKeyParams","link":"feePublicKeyParams","description":"Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program."},{"title":"OfflineSearchParams.inclusionKeyParams","link":"inclusionKeyParams","description":"Create a new OfflineSearchParams instance for the inclusion prover function."},{"title":"OfflineSearchParams.inclusionKeyParams","link":"inclusionKeyParams","description":"Create a new OfflineSearchParams instance for the inclusion prover function."},{"title":"OfflineSearchParams.joinKeyParams","link":"joinKeyParams","description":"Create a new OfflineSearchParams instance for the join function of the credits.aleo program."},{"title":"OfflineSearchParams.joinKeyParams","link":"joinKeyParams","description":"Create a new OfflineSearchParams instance for the join function of the credits.aleo program."},{"title":"OfflineSearchParams.setValidatorStateKeyParams","link":"setValidatorStateKeyParams","description":"Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program."},{"title":"OfflineSearchParams.setValidatorStateKeyParams","link":"setValidatorStateKeyParams","description":"Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program."},{"title":"OfflineSearchParams.splitKeyParams","link":"splitKeyParams","description":"Create a new OfflineSearchParams instance for the split function of the credits.aleo program."},{"title":"OfflineSearchParams.splitKeyParams","link":"splitKeyParams","description":"Create a new OfflineSearchParams instance for the split function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPrivateKeyParams","link":"transferPrivateKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPrivateKeyParams","link":"transferPrivateKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPrivateToPublicKeyParams","link":"transferPrivateToPublicKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPrivateToPublicKeyParams","link":"transferPrivateToPublicKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPublicAsSignerKeyParams","link":"transferPublicAsSignerKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPublicAsSignerKeyParams","link":"transferPublicAsSignerKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPublicKeyParams","link":"transferPublicKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPublicKeyParams","link":"transferPublicKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPublicToPrivateKeyParams","link":"transferPublicToPrivateKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program."},{"title":"OfflineSearchParams.transferPublicToPrivateKeyParams","link":"transferPublicToPrivateKeyParams","description":"Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program."},{"title":"OfflineSearchParams.unbondPublicKeyParams","link":"unbondPublicKeyParams","description":"Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program."},{"title":"OfflineSearchParams.unbondPublicKeyParams","link":"unbondPublicKeyParams","description":"Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program."},{"title":"OfflineSearchParams#OfflineSearchParams","link":"OfflineSearchParams","description":"Create a new OfflineSearchParams instance."},{"title":"ProgramManager","link":"ProgramManager","description":"Create a new instance of the ProgramManager"},{"title":"ProgramManager#bondPublic","link":"bondPublic","description":"Bond credits to validator."},{"title":"ProgramManager#bondPublic","link":"bondPublic","description":"Bond credits to validator."},{"title":"ProgramManager#bondValidator","link":"bondValidator","description":"Build transaction to bond a validator."},{"title":"ProgramManager#bondValidator","link":"bondValidator","description":"Build transaction to bond a validator."},{"title":"ProgramManager#buildBondPublicTransaction","link":"buildBondPublicTransaction","description":"Build transaction to bond credits to a validator for later submission to the Aleo Network"},{"title":"ProgramManager#buildBondPublicTransaction","link":"buildBondPublicTransaction","description":"Build transaction to bond credits to a validator for later submission to the Aleo Network"},{"title":"ProgramManager#buildBondValidatorTransaction","link":"buildBondValidatorTransaction","description":"Build a bond_validator transaction for later submission to the Aleo Network."},{"title":"ProgramManager#buildBondValidatorTransaction","link":"buildBondValidatorTransaction","description":"Build a bond_validator transaction for later submission to the Aleo Network."},{"title":"ProgramManager#buildClaimUnbondPublicTransaction","link":"buildClaimUnbondPublicTransaction","description":"Build a transaction to claim unbonded public credits in the Aleo network."},{"title":"ProgramManager#buildClaimUnbondPublicTransaction","link":"buildClaimUnbondPublicTransaction","description":"Build a transaction to claim unbonded public credits in the Aleo network."},{"title":"ProgramManager#buildExecutionTransaction","link":"buildExecutionTransaction","description":"Builds an execution transaction for submission to the Aleo network."},{"title":"ProgramManager#buildExecutionTransaction","link":"buildExecutionTransaction","description":"Builds an execution transaction for submission to the Aleo network."},{"title":"ProgramManager#buildSetValidatorStateTransaction","link":"buildSetValidatorStateTransaction","description":"Build a set_validator_state transaction for later usage.\n\nThis function allows a validator to set their state to be either opened or closed to new stakers.\nWhen the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\nWhen the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n\nThis function serves two primary purposes:\n1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them."},{"title":"ProgramManager#buildSetValidatorStateTransaction","link":"buildSetValidatorStateTransaction","description":"Build a set_validator_state transaction for later usage.\n\nThis function allows a validator to set their state to be either opened or closed to new stakers.\nWhen the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\nWhen the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n\nThis function serves two primary purposes:\n1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them."},{"title":"ProgramManager#buildTransferPublicAsSignerTransaction","link":"buildTransferPublicAsSignerTransaction","description":"Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network"},{"title":"ProgramManager#buildTransferPublicAsSignerTransaction","link":"buildTransferPublicAsSignerTransaction","description":"Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network"},{"title":"ProgramManager#buildTransferPublicTransaction","link":"buildTransferPublicTransaction","description":"Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network"},{"title":"ProgramManager#buildTransferPublicTransaction","link":"buildTransferPublicTransaction","description":"Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network"},{"title":"ProgramManager#buildTransferTransaction","link":"buildTransferTransaction","description":"Build a transaction to transfer credits to another account for later submission to the Aleo network"},{"title":"ProgramManager#buildTransferTransaction","link":"buildTransferTransaction","description":"Build a transaction to transfer credits to another account for later submission to the Aleo network"},{"title":"ProgramManager#buildUnbondPublicTransaction","link":"buildUnbondPublicTransaction","description":"Build a transaction to unbond public credits from a validator in the Aleo network."},{"title":"ProgramManager#buildUnbondPublicTransaction","link":"buildUnbondPublicTransaction","description":"Build a transaction to unbond public credits from a validator in the Aleo network."},{"title":"ProgramManager#claimUnbondPublic","link":"claimUnbondPublic","description":"Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will\nclaim them and add them to the public balance of the account."},{"title":"ProgramManager#claimUnbondPublic","link":"claimUnbondPublic","description":"Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will\nclaim them and add them to the public balance of the account."},{"title":"ProgramManager#createProgramFromSource","link":"createProgramFromSource","description":"Create a program object from a program's source code"},{"title":"ProgramManager#createProgramFromSource","link":"createProgramFromSource","description":"Create a program object from a program's source code"},{"title":"ProgramManager#creditsProgram","link":"creditsProgram","description":"Get the credits program object"},{"title":"ProgramManager#creditsProgram","link":"creditsProgram","description":"Get the credits program object"},{"title":"ProgramManager#deploy","link":"deploy","description":"Deploy an Aleo program to the Aleo network"},{"title":"ProgramManager#deploy","link":"deploy","description":"Deploy an Aleo program to the Aleo network"},{"title":"ProgramManager#execute","link":"execute","description":"Builds an execution transaction for submission to the Aleo network."},{"title":"ProgramManager#execute","link":"execute","description":"Builds an execution transaction for submission to the Aleo network."},{"title":"ProgramManager#join","link":"join","description":"Join two credits records into a single credits record"},{"title":"ProgramManager#join","link":"join","description":"Join two credits records into a single credits record"},{"title":"ProgramManager#ProgramManager","link":"ProgramManager","description":"Create a new instance of the ProgramManager"},{"title":"ProgramManager#run","link":"run","description":"Run an Aleo program in offline mode"},{"title":"ProgramManager#run","link":"run","description":"Run an Aleo program in offline mode"},{"title":"ProgramManager#setAccount","link":"setAccount","description":"Set the account to use for transaction submission to the Aleo network"},{"title":"ProgramManager#setAccount","link":"setAccount","description":"Set the account to use for transaction submission to the Aleo network"},{"title":"ProgramManager#setHost","link":"setHost","description":"Set the host peer to use for transaction submission to the Aleo network"},{"title":"ProgramManager#setHost","link":"setHost","description":"Set the host peer to use for transaction submission to the Aleo network"},{"title":"ProgramManager#setKeyProvider","link":"setKeyProvider","description":"Set the key provider that provides the proving and verifying keys for programs"},{"title":"ProgramManager#setKeyProvider","link":"setKeyProvider","description":"Set the key provider that provides the proving and verifying keys for programs"},{"title":"ProgramManager#setRecordProvider","link":"setRecordProvider","description":"Set the record provider that provides records for transactions"},{"title":"ProgramManager#setRecordProvider","link":"setRecordProvider","description":"Set the record provider that provides records for transactions"},{"title":"ProgramManager#setValidatorState","link":"setValidatorState","description":"Submit a set_validator_state transaction to the Aleo Network.\n\nThis function allows a validator to set their state to be either opened or closed to new stakers.\nWhen the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\nWhen the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n\nThis function serves two primary purposes:\n1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them."},{"title":"ProgramManager#setValidatorState","link":"setValidatorState","description":"Submit a set_validator_state transaction to the Aleo Network.\n\nThis function allows a validator to set their state to be either opened or closed to new stakers.\nWhen the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.\nWhen the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.\n\nThis function serves two primary purposes:\n1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.\n2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them."},{"title":"ProgramManager#split","link":"split","description":"Split credits into two new credits records"},{"title":"ProgramManager#split","link":"split","description":"Split credits into two new credits records"},{"title":"ProgramManager#synthesizeKeys","link":"synthesizeKeys","description":"Pre-synthesize proving and verifying keys for a program"},{"title":"ProgramManager#synthesizeKeys","link":"synthesizeKeys","description":"Pre-synthesize proving and verifying keys for a program"},{"title":"ProgramManager#transfer","link":"transfer","description":"Transfer credits to another account"},{"title":"ProgramManager#transfer","link":"transfer","description":"Transfer credits to another account"},{"title":"ProgramManager#unbondPublic","link":"unbondPublic","description":"Unbond a specified amount of staked credits."},{"title":"ProgramManager#unbondPublic","link":"unbondPublic","description":"Unbond a specified amount of staked credits."},{"title":"ProgramManager#verifyExecution","link":"verifyExecution","description":"Verify a proof of execution from an offline execution"},{"title":"ProgramManager#verifyExecution","link":"verifyExecution","description":"Verify a proof of execution from an offline execution"},{"title":"ProgramManager#verifyProgram","link":"verifyProgram","description":"Verify a program is valid"},{"title":"ProgramManager#verifyProgram","link":"verifyProgram","description":"Verify a program is valid"},{"title":"RecordProvider","link":"RecordProvider","description":"Interface for a record provider. A record provider is used to find records for use in deployment and execution\ntransactions on the Aleo Network. A default implementation is provided by the NetworkRecordProvider class. However,\na custom implementation can be provided (say if records are synced locally to a database from the network) by\nimplementing this interface."},{"title":"RecordProvider#findCreditsRecord","link":"findCreditsRecord","description":"Find a credits.aleo record with a given number of microcredits from the chosen provider"},{"title":"RecordProvider#findCreditsRecords","link":"findCreditsRecords","description":"Find a list of credit.aleo records with a given number of microcredits from the chosen provider"},{"title":"RecordProvider#findRecord","link":"findRecord","description":"Find an arbitrary record"},{"title":"RecordProvider#findRecords","link":"findRecords","description":"Find multiple records from arbitrary programs"},{"title":"RecordSearchParams","link":"RecordSearchParams","description":"Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider\nimplementations."}]} \ No newline at end of file diff --git a/sdk/docs/function-key-provider.ts.html b/sdk/docs/function-key-provider.ts.html new file mode 100644 index 000000000..8236f7bfe --- /dev/null +++ b/sdk/docs/function-key-provider.ts.html @@ -0,0 +1,617 @@ +Source: function-key-provider.ts
On this page

function-key-provider.ts

import {
+    CREDITS_PROGRAM_KEYS,
+    KEY_STORE,
+    Key,
+    PRIVATE_TRANSFER,
+    PRIVATE_TO_PUBLIC_TRANSFER,
+    PUBLIC_TRANSFER,
+    PUBLIC_TO_PRIVATE_TRANSFER,
+    PUBLIC_TRANSFER_AS_SIGNER,
+} from "./constants";
+
+import {
+    ProvingKey,
+    VerifyingKey,
+} from "./wasm";
+
+import { get } from "./utils";
+
+type FunctionKeyPair = [ProvingKey, VerifyingKey];
+type CachedKeyPair = [Uint8Array, Uint8Array];
+type AleoKeyProviderInitParams = {
+    proverUri?: string;
+    verifierUri?: string;
+    cacheKey?: string;
+};
+
+/**
+ * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider
+ * implementations.
+ */
+interface KeySearchParams {
+    [key: string]: any; // This allows for arbitrary keys with any type values
+}
+
+/**
+ * AleoKeyProviderParams search parameter for the AleoKeyProvider. It allows for the specification of a proverUri and
+ * verifierUri to fetch keys via HTTP from a remote resource as well as a unique cacheKey to store the keys in memory.
+ */
+class AleoKeyProviderParams implements KeySearchParams {
+    name: string | undefined;
+    proverUri: string | undefined;
+    verifierUri: string | undefined;
+    cacheKey: string | undefined;
+
+    /**
+     * Create a new AleoKeyProviderParams object which implements the KeySearchParams interface. Users can optionally
+     * specify a url for the proverUri & verifierUri to fetch keys via HTTP from a remote resource as well as a unique
+     * cacheKey to store the keys in memory for future use. If no proverUri or verifierUri is specified, a cachekey must
+     * be provided.
+     *
+     * @param { AleoKeyProviderInitParams } params - Optional search parameters
+     */
+    constructor(params: {proverUri?: string, verifierUri?: string, cacheKey?: string, name?: string}) {
+        this.proverUri = params.proverUri;
+        this.verifierUri = params.verifierUri;
+        this.cacheKey = params.cacheKey;
+        this.name = params.name;
+    }
+}
+
+/**
+ * KeyProvider interface. Enables the retrieval of public proving and verifying keys for Aleo Programs.
+ */
+interface FunctionKeyProvider {
+    /**
+     * Get bond_public function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function
+     */
+    bondPublicKeys(): Promise<FunctionKeyPair>;
+
+    /**
+     * Get bond_validator function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_validator function
+     */
+    bondValidatorKeys(): Promise<FunctionKeyPair>;
+
+    /**
+     * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId
+     * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
+     *
+     * @param {string} keyId access key for the cache
+     * @param {FunctionKeyPair} keys keys to cache
+     */
+    cacheKeys(keyId: string, keys: FunctionKeyPair): void;
+
+    /**
+     * Get unbond_public function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function
+     */
+    claimUnbondPublicKeys(): Promise<FunctionKeyPair>;
+
+    /**
+     * Get arbitrary function keys from a provider
+     *
+     * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
+     *
+     * @example
+     * // Create a search object which implements the KeySearchParams interface
+     * class IndexDbSearch implements KeySearchParams {
+     *     db: string
+     *     keyId: string
+     *     constructor(params: {db: string, keyId: string}) {
+     *         this.db = params.db;
+     *         this.keyId = params.keyId;
+     *     }
+     * }
+     *
+     * // Create a new object which implements the KeyProvider interface
+     * class IndexDbKeyProvider implements FunctionKeyProvider {
+     *     async functionKeys(params: KeySearchParams): Promise<FunctionKeyPair> {
+     *         return new Promise((resolve, reject) => {
+     *             const request = indexedDB.open(params.db, 1);
+     *
+     *             request.onupgradeneeded = function(e) {
+     *                 const db = e.target.result;
+     *                 if (!db.objectStoreNames.contains('keys')) {
+     *                     db.createObjectStore('keys', { keyPath: 'id' });
+     *                 }
+     *             };
+     *
+     *             request.onsuccess = function(e) {
+     *                 const db = e.target.result;
+     *                 const transaction = db.transaction(["keys"], "readonly");
+     *                 const store = transaction.objectStore("keys");
+     *                 const request = store.get(params.keyId);
+     *                 request.onsuccess = function(e) {
+     *                     if (request.result) {
+     *                         resolve(request.result as FunctionKeyPair);
+     *                     } else {
+     *                         reject(new Error("Key not found"));
+     *                     }
+     *                 };
+     *                 request.onerror = function(e) { reject(new Error("Error fetching key")); };
+     *             };
+     *
+     *             request.onerror = function(e) { reject(new Error("Error opening database")); };
+     *         });
+     *     }
+     *
+     *     // implement the other methods...
+     * }
+     *
+     *
+     * const keyProvider = new AleoKeyProvider();
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     *
+     * // Keys can also be fetched manually
+     * const searchParams = new IndexDbSearch({db: "keys", keyId: "credits.aleo:transferPrivate"});
+     * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(searchParams);
+     */
+    functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair>;
+
+    /**
+     * Get fee_private function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    feePrivateKeys(): Promise<FunctionKeyPair>;
+
+    /**
+     * Get fee_public function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    feePublicKeys(): Promise<FunctionKeyPair>;
+
+    /**
+     * Get join function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    joinKeys(): Promise<FunctionKeyPair>;
+
+    /**
+     * Get split function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    splitKeys(): Promise<FunctionKeyPair>;
+
+    /**
+     * Get keys for a variant of the transfer function from the credits.aleo program
+     *
+     * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function
+     *
+     * @example
+     * // Create a new object which implements the KeyProvider interface
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     *
+     * // Keys can also be fetched manually
+     * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
+     */
+    transferKeys(visibility: string): Promise<FunctionKeyPair>;
+
+    /**
+     * Get unbond_public function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    unBondPublicKeys(): Promise<FunctionKeyPair>;
+
+}
+
+
+/**
+ * AleoKeyProvider class. Implements the KeyProvider interface. Enables the retrieval of Aleo program proving and
+ * verifying keys for the credits.aleo program over http from official Aleo sources and storing and retrieving function
+ * keys from a local memory cache.
+ */
+class AleoKeyProvider implements FunctionKeyProvider {
+    cache: Map<string, CachedKeyPair>;
+    cacheOption: boolean;
+    keyUris: string;
+
+    async fetchBytes(
+        url = "/",
+    ): Promise<Uint8Array> {
+        try {
+        const response = await get(url);
+        const data = await response.arrayBuffer();
+        return new Uint8Array(data);
+        } catch (error: any) {
+            throw new Error("Error fetching data." + error.message);
+        }
+    }
+
+    constructor() {
+        this.keyUris = KEY_STORE;
+        this.cache = new Map<string, CachedKeyPair>();
+        this.cacheOption = false;
+    }
+
+    /**
+     * Use local memory to store keys
+     *
+     * @param {boolean} useCache whether to store keys in local memory
+     */
+    useCache(useCache: boolean) {
+        this.cacheOption = useCache;
+    }
+
+    /**
+     * Clear the key cache
+     */
+    clearCache() {
+        this.cache.clear();
+    }
+
+    /**
+     * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId
+     * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
+     *
+     * @param {string} keyId access key for the cache
+     * @param {FunctionKeyPair} keys keys to cache
+     */
+    cacheKeys(keyId: string, keys: FunctionKeyPair) {
+        const [provingKey, verifyingKey] = keys;
+        this.cache.set(keyId, [provingKey.toBytes(), verifyingKey.toBytes()]);
+    }
+
+    /**
+     * Determine if a keyId exists in the cache
+     *
+     * @param {string} keyId keyId of a proving and verifying key pair
+     * @returns {boolean} true if the keyId exists in the cache, false otherwise
+     */
+    containsKeys(keyId: string): boolean {
+        return this.cache.has(keyId)
+    }
+
+    /**
+     * Delete a set of keys from the cache
+     *
+     * @param {string} keyId keyId of a proving and verifying key pair to delete from memory
+     * @returns {boolean} true if the keyId exists in the cache and was deleted, false if the key did not exist
+     */
+    deleteKeys(keyId: string): boolean {
+        return this.cache.delete(keyId)
+    }
+
+    /**
+     * Get a set of keys from the cache
+     * @param keyId keyId of a proving and verifying key pair
+     *
+     * @returns {FunctionKeyPair} Proving and verifying keys for the specified program
+     */
+    getKeys(keyId: string): FunctionKeyPair {
+        console.debug(`Checking if key exists in cache. KeyId: ${keyId}`)
+        if (this.cache.has(keyId)) {
+            const [provingKeyBytes, verifyingKeyBytes] = <CachedKeyPair>this.cache.get(keyId);
+            return [ProvingKey.fromBytes(provingKeyBytes), VerifyingKey.fromBytes(verifyingKeyBytes)];
+        } else {
+            throw new Error("Key not found in cache.");
+        }
+    }
+
+    /**
+     * Get arbitrary function keys from a provider
+     *
+     * @param {KeySearchParams} params parameters for the key search in form of: {proverUri: string, verifierUri: string, cacheKey: string}
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
+     *
+     * @example
+     * // Create a new object which implements the KeyProvider interface
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     *
+     * // Keys can also be fetched manually using the key provider
+     * const keySearchParams = { "cacheKey": "myProgram:myFunction" };
+     * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.functionKeys(keySearchParams);
+     */
+    async functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair> {
+        if (params) {
+            let proverUrl;
+            let verifierUrl;
+            let cacheKey;
+            if ("name" in params && typeof params["name"] == "string") {
+                let key = CREDITS_PROGRAM_KEYS.getKey(params["name"]);
+                return this.fetchCreditsKeys(key);
+            }
+
+            if ("proverUri" in params && typeof params["proverUri"] == "string") {
+                proverUrl = params["proverUri"];
+            }
+
+            if ("verifierUri" in params && typeof params["verifierUri"] == "string") {
+                verifierUrl = params["verifierUri"];
+            }
+
+            if ("cacheKey" in params && typeof params["cacheKey"] == "string") {
+                cacheKey = params["cacheKey"];
+            }
+
+            if (proverUrl && verifierUrl) {
+                return await this.fetchRemoteKeys(proverUrl, verifierUrl, cacheKey);
+            }
+
+            if (cacheKey) {
+                return this.getKeys(cacheKey);
+            }
+        }
+        throw new Error("Invalid parameters provided, must provide either a cacheKey and/or a proverUrl and a verifierUrl");
+    }
+
+    /**
+     * Returns the proving and verifying keys for a specified program from a specified url.
+     *
+     * @param {string} verifierUrl Url of the proving key
+     * @param {string} proverUrl Url the verifying key
+     * @param {string} cacheKey Key to store the keys in the cache
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
+     *
+     * @example
+     * // Create a new AleoKeyProvider object
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     *
+     * // Keys can also be fetched manually
+     * const [transferPrivateProvingKey, transferPrivateVerifyingKey] = await keyProvider.fetchKeys(
+     *     CREDITS_PROGRAM_KEYS.transfer_private.prover,
+     *     CREDITS_PROGRAM_KEYS.transfer_private.verifier,
+     * );
+     */
+    async fetchRemoteKeys(proverUrl: string, verifierUrl: string, cacheKey?: string): Promise<FunctionKeyPair> {
+        try {
+            // If cache is enabled, check if the keys have already been fetched and return them if they have
+            if (this.cacheOption) {
+                if (!cacheKey) {
+                    cacheKey = proverUrl;
+                }
+                const value = this.cache.get(cacheKey);
+                if (typeof value !== "undefined") {
+                    return [ProvingKey.fromBytes(value[0]), VerifyingKey.fromBytes(value[1])];
+                } else {
+                    console.debug("Fetching proving keys from url " + proverUrl);
+                    const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl))
+                    console.debug("Fetching verifying keys " + verifierUrl);
+                    const verifyingKey = <VerifyingKey>(await this.getVerifyingKey(verifierUrl));
+                    this.cache.set(cacheKey, [provingKey.toBytes(), verifyingKey.toBytes()]);
+                    return [provingKey, verifyingKey];
+                }
+            }
+            else {
+                // If cache is disabled, fetch the keys and return them
+                const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl))
+                const verifyingKey = <VerifyingKey>(await this.getVerifyingKey(verifierUrl));
+                return [provingKey, verifyingKey];
+            }
+        } catch (error: any) {
+            throw new Error(`Error: ${error.message} fetching fee proving and verifying keys from ${proverUrl} and ${verifierUrl}.`);
+        }
+    }
+
+    /***
+     * Fetches the proving key from a remote source.
+     *
+     * @param proverUrl
+     * @param cacheKey
+     *
+     * @returns {Promise<ProvingKey>} Proving key for the specified program
+     */
+    async fetchProvingKey(proverUrl: string, cacheKey?: string): Promise<ProvingKey> {
+        try {
+            // If cache is enabled, check if the keys have already been fetched and return them if they have
+            if (this.cacheOption) {
+                if (!cacheKey) {
+                    cacheKey = proverUrl;
+                }
+                const value = this.cache.get(cacheKey);
+                if (typeof value !== "undefined") {
+                    return ProvingKey.fromBytes(value[0]);
+                } else {
+                    console.debug("Fetching proving keys from url " + proverUrl);
+                    const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
+                    return provingKey;
+                }
+            }
+            else {
+                const provingKey = <ProvingKey>ProvingKey.fromBytes(await this.fetchBytes(proverUrl));
+                return provingKey;
+            }
+        } catch (error: any) {
+            throw new Error(`Error: ${error.message} fetching fee proving keys from ${proverUrl}`);
+        }
+    }
+
+    async fetchCreditsKeys(key: Key): Promise<FunctionKeyPair> {
+        try {
+            if (!this.cache.has(key.locator) || !this.cacheOption) {
+                const verifying_key = key.verifyingKey()
+                const proving_key = <ProvingKey>await this.fetchProvingKey(key.prover, key.locator);
+                if (this.cacheOption) {
+                    this.cache.set(CREDITS_PROGRAM_KEYS.bond_public.locator, [proving_key.toBytes(), verifying_key.toBytes()]);
+                }
+                return [proving_key, verifying_key];
+            } else {
+                const keyPair = <CachedKeyPair>this.cache.get(key.locator);
+                return [ProvingKey.fromBytes(keyPair[0]), VerifyingKey.fromBytes(keyPair[1])];
+            }
+        } catch (error: any) {
+            throw new Error(`Error: fetching credits.aleo keys: ${error.message}`);
+        }
+    }
+
+    async bondPublicKeys(): Promise<FunctionKeyPair> {
+        return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_public);
+    }
+
+    bondValidatorKeys(): Promise<FunctionKeyPair> {
+        return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_validator);
+    }
+
+    claimUnbondPublicKeys(): Promise<FunctionKeyPair> {
+        return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.claim_unbond_public)
+    }
+
+    /**
+     * Returns the proving and verifying keys for the transfer functions in the credits.aleo program
+     * @param {string} visibility Visibility of the transfer function
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the transfer functions
+     *
+     * @example
+     * // Create a new AleoKeyProvider
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for value transfers
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     *
+     * // Keys can also be fetched manually
+     * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
+     */
+    async transferKeys(visibility: string): Promise<FunctionKeyPair> {
+        if (PRIVATE_TRANSFER.has(visibility)) {
+            return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private);
+        } else if (PRIVATE_TO_PUBLIC_TRANSFER.has(visibility)) {
+            return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private_to_public);
+        } else if (PUBLIC_TRANSFER.has(visibility)) {
+            return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public);
+        } else if (PUBLIC_TRANSFER_AS_SIGNER.has(visibility)) {
+            return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_as_signer);
+        } else if (PUBLIC_TO_PRIVATE_TRANSFER.has(visibility)) {
+            return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_to_private);
+        } else {
+            throw new Error("Invalid visibility type");
+        }
+    }
+
+    /**
+     * Returns the proving and verifying keys for the join function in the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    async joinKeys(): Promise<FunctionKeyPair> {
+        return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.join);
+    }
+
+    /**
+     * Returns the proving and verifying keys for the split function in the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the split function
+     * */
+    async splitKeys(): Promise<FunctionKeyPair> {
+        return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.split);
+    }
+
+    /**
+     * Returns the proving and verifying keys for the fee_private function in the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function
+     */
+    async feePrivateKeys(): Promise<FunctionKeyPair> {
+        return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_private);
+    }
+
+    /**
+     * Returns the proving and verifying keys for the fee_public function in the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the fee function
+     */
+    async feePublicKeys(): Promise<FunctionKeyPair> {
+        return await this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public);
+    }
+
+    /**
+     * Gets a verifying key. If the verifying key is for a credits.aleo function, get it from the wasm cache otherwise
+     *
+     * @returns {Promise<VerifyingKey>} Verifying key for the function
+     */
+    // attempt to fetch it from the network
+    async getVerifyingKey(verifierUri: string): Promise<VerifyingKey> {
+        switch (verifierUri) {
+            case CREDITS_PROGRAM_KEYS.bond_public.verifier:
+                return CREDITS_PROGRAM_KEYS.bond_public.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.bond_validator.verifier:
+                return CREDITS_PROGRAM_KEYS.bond_validator.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.claim_unbond_public.verifier:
+                return CREDITS_PROGRAM_KEYS.claim_unbond_public.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.fee_private.verifier:
+                return CREDITS_PROGRAM_KEYS.fee_private.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.fee_public.verifier:
+                return CREDITS_PROGRAM_KEYS.fee_public.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.inclusion.verifier:
+                return CREDITS_PROGRAM_KEYS.inclusion.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.join.verifier:
+                return CREDITS_PROGRAM_KEYS.join.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.set_validator_state.verifier:
+                return CREDITS_PROGRAM_KEYS.set_validator_state.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.split.verifier:
+                return CREDITS_PROGRAM_KEYS.split.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.transfer_private.verifier:
+                return CREDITS_PROGRAM_KEYS.transfer_private.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.transfer_private_to_public.verifier:
+                return CREDITS_PROGRAM_KEYS.transfer_private_to_public.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.transfer_public.verifier:
+                return CREDITS_PROGRAM_KEYS.transfer_public.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.transfer_public_as_signer.verifier:
+                return CREDITS_PROGRAM_KEYS.transfer_public_as_signer.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.transfer_public_to_private.verifier:
+                return CREDITS_PROGRAM_KEYS.transfer_public_to_private.verifyingKey();
+            case CREDITS_PROGRAM_KEYS.unbond_public.verifier:
+                return CREDITS_PROGRAM_KEYS.unbond_public.verifyingKey();
+            default:
+                try {
+                    /// Try to fetch the verifying key from the network as a string
+                    const response = await get(verifierUri);
+                    const text = await response.text();
+                    return <VerifyingKey>VerifyingKey.fromString(text);
+                } catch (e) {
+                    /// If that fails, try to fetch the verifying key from the network as bytes
+                    try {
+                    return <VerifyingKey>VerifyingKey.fromBytes(await this.fetchBytes(verifierUri));
+                    } catch (inner: any) {
+                        throw new Error("Invalid verifying key. Error: " + inner.message);
+                    }
+                }
+        }
+    }
+
+    unBondPublicKeys(): Promise<FunctionKeyPair> {
+        return this.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.unbond_public);
+    }
+}
+
+export {AleoKeyProvider, AleoKeyProviderParams, AleoKeyProviderInitParams, CachedKeyPair, FunctionKeyPair, FunctionKeyProvider, KeySearchParams}
+
\ No newline at end of file diff --git a/sdk/docs/index.html b/sdk/docs/index.html index 75a9d4a61..62249c473 100644 --- a/sdk/docs/index.html +++ b/sdk/docs/index.html @@ -1,3 +1,3 @@ -Aleo SDK
On this page

Aleo SDK

@provablehq/sdk

Aleo high-level utilities in javascript to handle Accounts, Records, and Node connections in the browser.

Makes use of @provablehq/wasm under the hood.

Happy hacking!

Build Guide

  1. To build the project, go to the project's root and execute npm install && npm run build.

Documentation

  1. To view the documentation, open docs/index.html.
  2. To regenerate the documentation, run npx jsdoc --configure jsdoc.json --verbose

Aleo Tools

Aleo SDK account generator

Aleo Home

You can visit the SnarkVM repo and SnarkOS repo to go deep into the code of aleo infrastructure

\ No newline at end of file +
On this page

Website

Zero-Knowledge Web App SDK

The Aleo SDK provides tools for building zero-knowledge applications. It consists of several TypeScript & JavaScript libraries which provide the following functionality:

  1. Aleo account management
  2. Web-based program execution and deployment
  3. Aleo credit transfers
  4. Management of program state and data
  5. Communication with the Aleo network

All of this functionality is demonstrated on Provable.tools.

The Aleo SDK is divided into three TypeScript/JavaScript packages:

1. Aleo SDK - Build Zero-Knowledge Web Apps

Aleo SDK

The official Aleo SDK providing JavaScript/TypeScript tools for creating zero-knowledge applications.

⚡ Build your own app

Start here with the Aleo SDK Readme to get started building your first zero-knowledge web app.

Source: Aleo SDK

2. Create-Leo-App - Zero-Knowledge Web App Examples

Create Leo App

Create-leo-app provides zero-knowledge web app examples in common web frameworks such as React. Developers looking to start with working examples should start here.

Source: sdk/create-leo-app

3. Aleo Wasm - Zero-Knowledge Algorithms in JavaScript + WebAssembly

Create Leo AppCreate Leo AppAleo-Wasm

Aleo Wasm is a Rust crate which compiles the Aleo source code responsible for creating and executing zero-knowledge programs into WebAssembly.

When compiled with wasm-pack, JavaScript bindings are generated for the WebAssembly allowing Aleo zero-knowledge programs to be used in the browser and Node.js. This package is available on NPM (linked above). The Aleo Wasm readme provides instructions for compiling this crate and using it in web projects for those interested in building from source.

❗ Currently, program execution is only available in web browsers. However, account, program, and data management within NodeJS is functional.

Source: Aleo Wasm

📚 Documentation

API Documentation

API Documentation, tutorials for the Aleo SDK, and documentation on how to build Leo and Aleo Instructions programs can be found on the Leo Developer Docs page.

SDK Readme

The SDK readme provides concepts core to executing zero-knowledge programs in the web and several detailed examples of how to use the SDK to build web apps using Aleo.

Aleo Wasm Readme

The Aleo Wasm readme provides instructions for compiling the Aleo Wasm crate and using it in web projects. Those who want to build from source or create their own WebAssembly bindings should start here.

❤️ Contributors

Thanks goes to these wonderful people (emoji key):

Mike Turner
Mike Turner

💻 🚧 💬 👀
Brent C
Brent C

💻 🚧 💬 👀
Collin Chin
Collin Chin

💻 🚧 💬 👀
Howard Wu
Howard Wu

💻 🤔 🔬 👀
Raymond Chu
Raymond Chu

💻 🤔 🔬 👀
d0cd
d0cd

💻 🤔 🔬 👀
Alessandro Coglio
Alessandro Coglio

📖 🔬 👀
a h
a h

💻 📖
Anthony DiPrinzio
Anthony DiPrinzio

💻
Ali Mousa
Ali Mousa

💻
Ivan Litteri
Ivan Litteri

💻
Nacho Avecilla
Nacho Avecilla

💻
ljedrz
ljedrz

💻
Facundo Olano
Facundo Olano

💻
Nicolas Continanza
Nicolas Continanza

💻
Mike
Mike

💻
Javier Rodríguez Chatruc
Javier Rodríguez Chatruc

💻
Pablo Deymonnaz
Pablo Deymonnaz

💻
Bob Niu
Bob Niu

💻
sptg
sptg

💻
Hamza Khchichine
Hamza Khchichine

💻
Kendrick
Kendrick

💻
Dependabot
Dependabot

💻
All Contributors
All Contributors

📖
Add your contributions

This project follows the all-contributors specification. Contributions of any kind welcome!

\ No newline at end of file diff --git a/sdk/docs/network-client.ts.html b/sdk/docs/network-client.ts.html new file mode 100644 index 000000000..fa23316d4 --- /dev/null +++ b/sdk/docs/network-client.ts.html @@ -0,0 +1,827 @@ +Source: network-client.ts
On this page

network-client.ts

import { get, post, parseJSON, logAndThrow } from "./utils";
+import { Account } from "./account";
+import { BlockJSON } from "./models/blockJSON";
+import { TransactionJSON } from "./models/transaction/transactionJSON";
+import {
+  Plaintext,
+  RecordCiphertext,
+  Program,
+  RecordPlaintext,
+  PrivateKey,
+  Transaction,
+} from "./wasm";
+
+type ProgramImports = { [key: string]: string | Program };
+
+interface AleoNetworkClientOptions {
+  headers?: { [key: string]: string };
+}
+
+/**
+ * Client library that encapsulates REST calls to publicly exposed endpoints of Aleo nodes. The methods provided in this
+ * allow users to query public information from the Aleo blockchain and submit transactions to the network.
+ *
+ * @param {string} host
+ * @example
+ * // Connection to a local node
+ * const localNetworkClient = new AleoNetworkClient("http://localhost:3030");
+ *
+ * // Connection to a public beacon node
+ * const publicnetworkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+ */
+class AleoNetworkClient {
+  host: string;
+  headers: { [key: string]: string };
+  account: Account | undefined;
+
+  constructor(host: string, options?: AleoNetworkClientOptions) {
+    this.host = host + "/%%NETWORK%%";
+
+    if (options && options.headers) {
+      this.headers = options.headers;
+
+    } else {
+      this.headers = {
+        // This is replaced by the actual version by a Rollup plugin
+        "X-Aleo-SDK-Version": "%%VERSION%%",
+      };
+    }
+  }
+
+  /**
+   * Set an account to use in networkClient calls
+   *
+   * @param {Account} account
+   * @example
+   * const account = new Account();
+   * networkClient.setAccount(account);
+   */
+  setAccount(account: Account) {
+    this.account = account;
+  }
+
+  /**
+   * Return the Aleo account used in the networkClient
+   *
+   * @example
+   * const account = networkClient.getAccount();
+   */
+  getAccount(): Account | undefined {
+    return this.account;
+  }
+
+  /**
+   * Set a new host for the networkClient
+   *
+   * @param {string} host The address of a node hosting the Aleo API
+   * @param host
+   */
+  setHost(host: string) {
+    this.host = host + "/%%NETWORK%%";
+  }
+
+  async fetchData<Type>(
+      url = "/",
+  ): Promise<Type> {
+    try {
+      const response = await get(this.host + url, {
+        headers: this.headers
+      });
+
+      const text = await response.text();
+      return parseJSON(text);
+
+    } catch (error) {
+      throw new Error("Error fetching data.");
+    }
+  }
+
+  /**
+   * Attempts to find unspent records in the Aleo blockchain for a specified private key.
+   * @param {number} startHeight - The height at which to start searching for unspent records
+   * @param {number} endHeight - The height at which to stop searching for unspent records
+   * @param {string | PrivateKey} privateKey - The private key to use to find unspent records
+   * @param {number[]} amounts - The amounts (in microcredits) to search for (eg. [100, 200, 3000])
+   * @param {number} maxMicrocredits - The maximum number of microcredits to search for
+   * @param {string[]} nonces - The nonces of already found records to exclude from the search
+   *
+   * @example
+   * // Find all unspent records
+   * const privateKey = "[PRIVATE_KEY]";
+   * const records = networkClient.findUnspentRecords(0, undefined, privateKey);
+   *
+   * // Find specific amounts
+   * const startHeight = 500000;
+   * const amounts = [600000, 1000000];
+   * const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, amounts);
+   *
+   * // Find specific amounts with a maximum number of cumulative microcredits
+   * const maxMicrocredits = 100000;
+   * const records = networkClient.findUnspentRecords(startHeight, undefined, privateKey, undefined, maxMicrocredits);
+   */
+  async findUnspentRecords(
+      startHeight: number,
+      endHeight: number | undefined,
+      privateKey: string | PrivateKey | undefined,
+      amounts: number[] | undefined,
+      maxMicrocredits?: number | undefined,
+      nonces?: string[] | undefined,
+  ): Promise<Array<RecordPlaintext>> {
+    nonces = nonces || [];
+    // Ensure start height is not negative
+    if (startHeight < 0) {
+      throw new Error("Start height must be greater than or equal to 0");
+    }
+
+    // Initialize search parameters
+    const records = new Array<RecordPlaintext>();
+    let start;
+    let end;
+    let resolvedPrivateKey: PrivateKey;
+    let failures = 0;
+    let totalRecordValue = BigInt(0);
+    let latestHeight: number;
+
+    // Ensure a private key is present to find owned records
+    if (typeof privateKey === "undefined") {
+      if (typeof this.account === "undefined") {
+        throw new Error("Private key must be specified in an argument to findOwnedRecords or set in the AleoNetworkClient");
+      } else {
+        resolvedPrivateKey = this.account._privateKey;
+      }
+    } else {
+      try {
+        resolvedPrivateKey = privateKey instanceof PrivateKey ? privateKey : PrivateKey.from_string(privateKey);
+      } catch (error) {
+        throw new Error("Error parsing private key provided.");
+      }
+    }
+    const viewKey = resolvedPrivateKey.to_view_key();
+
+    // Get the latest height to ensure the range being searched is valid
+    try {
+      const blockHeight = await this.getLatestHeight();
+      if (typeof blockHeight === "number") {
+        latestHeight = blockHeight;
+      } else {
+        throw new Error("Error fetching latest block height.");
+      }
+    } catch (error) {
+      throw new Error("Error fetching latest block height.");
+    }
+
+    // If no end height is specified or is greater than the latest height, set the end height to the latest height
+    if (typeof endHeight === "number" && endHeight <= latestHeight) {
+      end = endHeight
+    } else {
+      end = latestHeight;
+    }
+
+    // If the starting is greater than the ending height, return an error
+    if (startHeight > end) {
+      throw new Error("Start height must be less than or equal to end height.");
+    }
+
+    // Iterate through blocks in reverse order in chunks of 50
+    while (end > startHeight) {
+      start = end - 50;
+      if (start < startHeight) {
+        start = startHeight;
+      }
+      try {
+        // Get 50 blocks (or the difference between the start and end if less than 50)
+        const blocks = await this.getBlockRange(start, end);
+        end = start;
+        // Iterate through blocks to find unspent records
+        for (let i = 0; i < blocks.length; i++) {
+          const block = blocks[i];
+          const transactions = block.transactions;
+          if (!(typeof transactions === "undefined")) {
+            for (let j = 0; j < transactions.length; j++) {
+              const confirmedTransaction = transactions[j];
+              // Search for unspent records in execute transactions of credits.aleo
+              if (confirmedTransaction.type == "execute") {
+                const transaction = confirmedTransaction.transaction;
+                if (transaction.execution && !(typeof transaction.execution.transitions == "undefined")) {
+                  for (let k = 0; k < transaction.execution.transitions.length; k++) {
+                    const transition = transaction.execution.transitions[k];
+                    // Only search for unspent records in credits.aleo (for now)
+                    if (transition.program !== "credits.aleo") {
+                      continue;
+                    }
+                    if (!(typeof transition.outputs == "undefined")) {
+                      for (let l = 0; l < transition.outputs.length; l++) {
+                        const output = transition.outputs[l];
+                        if (output.type === "record") {
+                          try {
+                            // Create a wasm record ciphertext object from the found output
+                            const record = RecordCiphertext.fromString(output.value);
+                            // Determine if the record is owned by the specified view key
+                            if (record.isOwner(viewKey)) {
+                              // Decrypt the record and get the serial number
+                              const recordPlaintext = record.decrypt(viewKey);
+
+                              // If the record has already been found, skip it
+                              const nonce = recordPlaintext.nonce();
+                              if (nonces.includes(nonce)) {
+                                continue;
+                              }
+
+                              // Otherwise record the nonce that has been found
+                              const serialNumber = recordPlaintext.serialNumberString(resolvedPrivateKey, "credits.aleo", "credits");
+                              // Attempt to see if the serial number is spent
+                              try {
+                                await this.getTransitionId(serialNumber);
+                              } catch (error) {
+                                // If it's not found, add it to the list of unspent records
+                                if (!amounts) {
+                                  records.push(recordPlaintext);
+                                  // If the user specified a maximum number of microcredits, check if the search has found enough
+                                  if (typeof maxMicrocredits === "number") {
+                                    totalRecordValue += recordPlaintext.microcredits();
+                                    // Exit if the search has found the amount specified
+                                    if (totalRecordValue >= BigInt(maxMicrocredits)) {
+                                      return records;
+                                    }
+                                  }
+                                }
+                                // If the user specified a list of amounts, check if the search has found them
+                                if (!(typeof amounts === "undefined") && amounts.length > 0) {
+                                  let amounts_found = 0;
+                                  if (recordPlaintext.microcredits() > amounts[amounts_found]) {
+                                      amounts_found += 1;
+                                      records.push(recordPlaintext);
+                                      // If the user specified a maximum number of microcredits, check if the search has found enough
+                                      if (typeof maxMicrocredits === "number") {
+                                        totalRecordValue += recordPlaintext.microcredits();
+                                        // Exit if the search has found the amount specified
+                                        if (totalRecordValue >= BigInt(maxMicrocredits)) {
+                                          return records;
+                                        }
+                                      }
+                                      if (records.length >= amounts.length) {
+                                        return records;
+                                      }
+                                  }
+                                }
+                              }
+                            }
+                          } catch (error) {
+                          }
+                        }
+                      }
+                    }
+                  }
+                }
+              }
+            }
+          }
+        }
+      } catch (error) {
+        // If there is an error fetching blocks, log it and keep searching
+        console.warn("Error fetching blocks in range: " + start.toString() + "-" + end.toString());
+        console.warn("Error: ", error);
+        failures += 1;
+        if (failures > 10) {
+          console.warn("10 failures fetching records reached. Returning records fetched so far");
+          return records;
+        }
+      }
+    }
+    return records;
+  }
+
+  /**
+   * Returns the contents of the block at the specified block height.
+   *
+   * @param {number} height
+   * @example
+   * const block = networkClient.getBlock(1234);
+   */
+  async getBlock(height: number): Promise<BlockJSON> {
+    try {
+      const block = await this.fetchData<BlockJSON>("/block/" + height);
+      return block;
+    } catch (error) {
+      throw new Error("Error fetching block.");
+    }
+  }
+
+  /**
+   * Returns a range of blocks between the specified block heights.
+   *
+   * @param {number} start
+   * @param {number} end
+   * @example
+   * const blockRange = networkClient.getBlockRange(2050, 2100);
+   */
+  async getBlockRange(start: number, end: number): Promise<Array<BlockJSON>> {
+    try {
+      return await this.fetchData<Array<BlockJSON>>("/blocks?start=" + start + "&end=" + end);
+    } catch (error) {
+      const errorMessage = `Error fetching blocks between ${start} and ${end}.`;
+      throw new Error(errorMessage);
+    }
+  }
+
+  /**
+   * Returns the deployment transaction id associated with the specified program.
+   *
+   * @param {Program | string} program
+   * @returns {TransactionJSON}
+   */
+  async getDeploymentTransactionIDForProgram(program: Program | string): Promise<string> {
+    if (program instanceof Program) {
+      program = program.toString();
+    }
+    try {
+      const id = await this.fetchData<string>("/find/transactionID/deployment/" + program);
+      return id.replace("\"", "")
+    } catch (error) {
+      throw new Error("Error fetching deployment transaction for program.");
+    }
+  }
+
+  /**
+   * Returns the deployment transaction associated with a specified program.
+   *
+   * @param {Program | string} program
+   * @returns {TransactionJSON}
+   */
+  async getDeploymentTransactionForProgram(program: Program | string): Promise<TransactionJSON> {
+    try {
+      const transaction_id = <string>await this.getDeploymentTransactionIDForProgram(program);
+      return <TransactionJSON>await this.getTransaction(transaction_id);
+    } catch (error) {
+      throw new Error("Error fetching deployment transaction for program.");
+    }
+  }
+
+  /**
+   * Returns the deployment transaction associated with a specified program as a wasm object.
+   *
+   * @param {Program | string} program
+   * @returns {TransactionJSON}
+   */
+  async getDeploymentTransactioObjectnForProgram(program: Program | string): Promise<Transaction> {
+    try {
+      const transaction_id = <string>await this.getDeploymentTransactionIDForProgram(program);
+      return await this.getTransactionObject(transaction_id);
+    } catch (error) {
+      throw new Error("Error fetching deployment transaction for program.");
+    }
+  }
+
+  /**
+   * Returns the contents of the latest block.
+   *
+   * @example
+   * const latestHeight = networkClient.getLatestBlock();
+   */
+  async getLatestBlock(): Promise<BlockJSON> {
+    try {
+      return await this.fetchData<BlockJSON>("/block/latest") as BlockJSON;
+    } catch (error) {
+      throw new Error("Error fetching latest block.");
+    }
+  }
+
+  /**
+   * Returns the latest committee.
+   *
+   * @returns {Promise<object>} A javascript object containing the latest committee
+   */
+  async getLatestCommittee(): Promise<object> {
+    try {
+      return await this.fetchData<object>("/committee/latest");
+    } catch (error) {
+      throw new Error("Error fetching latest block.");
+    }
+  }
+
+  /**
+   * Returns the latest block height.
+   *
+   * @example
+   * const latestHeight = networkClient.getLatestHeight();
+   */
+  async getLatestHeight(): Promise<number> {
+    try {
+      return Number(await this.fetchData<bigint>("/block/height/latest"));
+    } catch (error) {
+      throw new Error("Error fetching latest height.");
+    }
+  }
+
+  /**
+   * Returns the source code of a program given a program ID.
+   *
+   * @param {string} programId The program ID of a program deployed to the Aleo Network
+   * @return {Promise<string>} Source code of the program
+   *
+   * @example
+   * const program = networkClient.getProgram("hello_hello.aleo");
+   * const expectedSource = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n"
+   * assert.equal(program, expectedSource);
+   */
+  async getProgram(programId: string): Promise<string> {
+    try {
+      return await this.fetchData<string>("/program/" + programId)
+    } catch (error) {
+      throw new Error("Error fetching program");
+    }
+  }
+
+  /**
+   * Returns a program object from a program ID or program source code.
+   *
+   * @param {string} inputProgram The program ID or program source code of a program deployed to the Aleo Network
+   * @return {Promise<Program>} Source code of the program
+   *
+   * @example
+   * const programID = "hello_hello.aleo";
+   * const programSource = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n"
+   *
+   * // Get program object from program ID or program source code
+   * const programObjectFromID = await networkClient.getProgramObject(programID);
+   * const programObjectFromSource = await networkClient.getProgramObject(programSource);
+   *
+   * // Both program objects should be equal
+   * assert.equal(programObjectFromID.to_string(), programObjectFromSource.to_string());
+   */
+  async getProgramObject(inputProgram: string): Promise<Program> {
+    try {
+      return Program.fromString(inputProgram);
+    } catch (error) {
+      try {
+        return Program.fromString(<string>(await this.getProgram(inputProgram)));
+      } catch (error) {
+        throw new Error(`${inputProgram} is neither a program name or a valid program`);
+      }
+    }
+  }
+
+  /**
+   *  Returns an object containing the source code of a program and the source code of all programs it imports
+   *
+   * @param {Program | string} inputProgram The program ID or program source code of a program deployed to the Aleo Network
+   * @returns {Promise<ProgramImports>} Object of the form { "program_id": "program_source", .. } containing program id & source code for all program imports
+   *
+   * @example
+   * const double_test_source = "import multiply_test.aleo;\n\nprogram double_test.aleo;\n\nfunction double_it:\n    input r0 as u32.private;\n    call multiply_test.aleo/multiply 2u32 r0 into r1;\n    output r1 as u32.private;\n"
+   * const double_test = Program.fromString(double_test_source);
+   * const expectedImports = {
+   *     "multiply_test.aleo": "program multiply_test.aleo;\n\nfunction multiply:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    mul r0 r1 into r2;\n    output r2 as u32.private;\n"
+   * }
+   *
+   * // Imports can be fetched using the program ID, source code, or program object
+   * let programImports = await networkClient.getProgramImports("double_test.aleo");
+   * assert.deepStrictEqual(programImports, expectedImports);
+   *
+   * // Using the program source code
+   * programImports = await networkClient.getProgramImports(double_test_source);
+   * assert.deepStrictEqual(programImports, expectedImports);
+   *
+   * // Using the program object
+   * programImports = await networkClient.getProgramImports(double_test);
+   * assert.deepStrictEqual(programImports, expectedImports);
+   */
+  async getProgramImports(inputProgram: Program | string): Promise<ProgramImports> {
+    try {
+      const imports: ProgramImports = {};
+
+      // Get the program object or fail if the program is not valid or does not exist
+      const program = inputProgram instanceof Program ? inputProgram : <Program>(await this.getProgramObject(inputProgram));
+
+      // Get the list of programs that the program imports
+      const importList = program.getImports();
+
+      // Recursively get any imports that the imported programs have in a depth first search order
+      for (let i = 0; i < importList.length; i++) {
+        const import_id = importList[i];
+        if (!imports.hasOwnProperty(import_id)) {
+          const programSource = <string>await this.getProgram(import_id);
+          const nestedImports = <ProgramImports>await this.getProgramImports(import_id);
+          for (const key in nestedImports) {
+            if (!imports.hasOwnProperty(key)) {
+              imports[key] = nestedImports[key];
+            }
+          }
+          imports[import_id] = programSource;
+        }
+      }
+      return imports;
+    } catch (error: any) {
+      logAndThrow("Error fetching program imports: " + error.message);
+    }
+  }
+
+  /**
+   * Get a list of the program names that a program imports.
+   *
+   * @param {Program | string} inputProgram - The program id or program source code to get the imports of
+   * @returns {string[]} - The list of program names that the program imports
+   *
+   * @example
+   * const programImportsNames = networkClient.getProgramImports("double_test.aleo");
+   * const expectedImportsNames = ["multiply_test.aleo"];
+   * assert.deepStrictEqual(programImportsNames, expectedImportsNames);
+   */
+  async getProgramImportNames(inputProgram: Program | string): Promise<string[]> {
+    try {
+      const program = inputProgram instanceof Program ? inputProgram : <Program>(await this.getProgramObject(inputProgram));
+      return program.getImports();
+    } catch (error: any) {
+      throw new Error("Error fetching program imports with error: " + error.message);
+    }
+  }
+
+  /**
+   * Returns the names of the mappings of a program.
+   *
+   * @param {string} programId - The program ID to get the mappings of (e.g. "credits.aleo")
+   * @example
+   * const mappings = networkClient.getProgramMappingNames("credits.aleo");
+   * const expectedMappings = ["account"];
+   * assert.deepStrictEqual(mappings, expectedMappings);
+   */
+  async getProgramMappingNames(programId: string): Promise<Array<string>> {
+    try {
+      return await this.fetchData<Array<string>>("/program/" + programId + "/mappings")
+    } catch (error) {
+      throw new Error("Error fetching program mappings - ensure the program exists on chain before trying again");
+    }
+  }
+
+  /**
+   * Returns the value of a program's mapping for a specific key.
+   *
+   * @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
+   * @param {string} mappingName - The name of the mapping to get the value of (e.g. "account")
+   * @param {string | Plaintext} key - The key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
+   * @return {Promise<string>} String representation of the value of the mapping
+   *
+   * @example
+   * // Get public balance of an account
+   * const mappingValue = networkClient.getMappingValue("credits.aleo", "account", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
+   * const expectedValue = "0u64";
+   * assert.equal(mappingValue, expectedValue);
+   */
+  async getProgramMappingValue(programId: string, mappingName: string, key: string | Plaintext): Promise<string> {
+    try {
+      const keyString = key instanceof Plaintext ? key.toString() : key;
+      return await this.fetchData<string>("/program/" + programId + "/mapping/" + mappingName + "/" + keyString)
+    } catch (error) {
+      throw new Error("Error fetching mapping value - ensure the mapping exists and the key is correct");
+    }
+  }
+
+
+  /**
+   * Returns the value of a mapping as a wasm Plaintext object. Returning an
+   * object in this format allows it to be converted to a Js type and for its
+   * internal members to be inspected if it's a struct or array.
+   *
+   * @example
+   * // Get the bond state as an account.
+   * const unbondedState = networkClient.getMappingPlaintext("credits.aleo", "bonded", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px");
+   *
+   * // Get the two members of the object individually.
+   * const validator = unbondedState.getMember("validator");
+   * const microcredits = unbondedState.getMember("microcredits");
+   *
+   * // Ensure the expected values are correct.
+   * assert.equal(validator, "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd");
+   * assert.equal(microcredits, BigInt("9007199254740991"));
+   *
+   * // Get a JS object representation of the unbonded state.
+   * const unbondedStateObject = unbondedState.toObject();
+   *
+   * const expectedState = {
+   *     validator: "aleo1u6940v5m0fzud859xx2c9tj2gjg6m5qrd28n636e6fdd2akvfcgqs34mfd",
+   *     microcredits: BigInt("9007199254740991")
+   * };
+   * assert.equal(unbondedState, expectedState);
+   *
+   * @param {string} programId - The program ID to get the mapping value of (e.g. "credits.aleo")
+   * @param {string} mappingName - The name of the mapping to get the value of (e.g. "account")
+   * @param {string | Plaintext} key - The key of the mapping to get the value of (e.g. "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px")
+   *
+   * @return {Promise<string>} String representation of the value of the mapping
+   */
+  async getProgramMappingPlaintext(programId: string, mappingName: string, key: string | Plaintext): Promise<Plaintext> {
+    try {
+      const keyString = key instanceof Plaintext ? key.toString() : key;
+      const value = await this.fetchData<string>("/program/" + programId + "/mapping/" + mappingName + "/" + keyString);
+      return Plaintext.fromString(value);
+    } catch (error) {
+      throw new Error("Failed to fetch mapping value");
+    }
+  }
+
+  /**
+   * Returns the latest state/merkle root of the Aleo blockchain.
+   *
+   * @example
+   * const stateRoot = networkClient.getStateRoot();
+   */
+  async getStateRoot(): Promise<string> {
+    try {
+      return await this.fetchData<string>("/stateRoot/latest");
+    } catch (error) {
+      throw new Error("Error fetching Aleo state root");
+    }
+  }
+
+  /**
+   * Returns a transaction by its unique identifier.
+   *
+   * @param {string} id
+   * @example
+   * const transaction = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
+   */
+  async getTransaction(transactionId: string): Promise<TransactionJSON> {
+    try {
+    return await this.fetchData<TransactionJSON>("/transaction/" + transactionId);
+    } catch (error) {
+      throw new Error("Error fetching transaction.");
+    }
+  }
+
+  /**
+   * Returns a transaction as a wasm object. Getting a transaction of this type will allow the ability for the inputs,
+   * outputs, and records to be searched for and displayed.
+   *
+   * @example
+   * const transactionObject = networkClient.getTransaction("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
+   * // Get the transaction inputs as a JS array.
+   * const transactionOutputs = transactionObject.inputs(true);
+   *
+   * // Get the transaction outputs as a JS object.
+   * const transactionInputs = transactionObject.outputs(true);
+   *
+   * // Get any records generated in transitions in the transaction as a JS object.
+   * const records = transactionObject.records();
+   *
+   * // Get the transaction type.
+   * const transactionType = transactionObject.transactionType();
+   * assert.equal(transactionType, "Execute");
+   *
+   * // Get a JS representation of all inputs, outputs, and transaction metadata.
+   * const transactionSummary = transactionObject.summary();
+   *
+   * @param {string} transactionId
+   * @example
+   * const transaction = networkClient.getTransactionObject("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj");
+   */
+  async getTransactionObject(transactionId: string): Promise<Transaction> {
+    try {
+      const transaction = await this.fetchData<string>("/transaction/" + transactionId);
+      return Transaction.fromString(transaction);
+    } catch (error) {
+      throw new Error("Error fetching transaction.");
+    }
+  }
+
+  /**
+   * Returns the transactions present at the specified block height.
+   *
+   * @param {number} height
+   * @example
+   * const transactions = networkClient.getTransactions(654);
+   */
+  async getTransactions(height: number): Promise<Array<TransactionJSON>> {
+    try {
+    return await this.fetchData<Array<TransactionJSON>>("/block/" + height.toString() + "/transactions");
+    } catch (error) {
+      throw new Error("Error fetching transactions.");
+    }
+  }
+
+  /**
+   * Returns an array of transactions as wasm objects present at the specified block height.
+   *
+   * @param {number} height
+   * @example
+   * const transactions = networkClient.getTransactionObjects(654);
+   *
+   * let transaction_summaries = transactions.map(transaction => transaction.summary());
+   */
+  async getTransactionObjects(height: number): Promise<Array<Transaction>> {
+    try {
+      return (await this.fetchData<Array<string>>("/block/" + height.toString() + "/transactions"))
+          .reduce<Array<Transaction>>((acc, transaction) => {
+              acc.push(Transaction.fromString(transaction));
+              return acc;
+            }, []);
+    } catch (error) {
+      throw new Error("Error fetching transactions.");
+    }
+  }
+
+  /**
+   * Returns the transactions in the memory pool.
+   *
+   * @example
+   * const transactions = networkClient.getTransactionsInMempool();
+   */
+  async getTransactionsInMempool(): Promise<Array<TransactionJSON>> {
+    try {
+      return await this.fetchData<Array<TransactionJSON>>("/memoryPool/transactions");
+    } catch (error) {
+      throw new Error("Error fetching transactions from mempool.");
+    }
+  }
+
+  /**
+   * Returns the transactions in the memory pool as wasm objects.
+   *
+   * @example
+   * const transactions = networkClient.getTransactionsInMempool();
+   */
+  async getTransactionObjectsInMempool(): Promise<Array<Transaction>> {
+    try {
+      return (await this.fetchData<Array<string>>("/memoryPool/transactions"))
+          .reduce<Array<Transaction>>((acc, transaction) => {
+        acc.push(Transaction.fromString(transaction));
+        return acc;
+      }, []);
+    } catch (error) {
+      throw new Error("Error fetching transactions from mempool.");
+    }
+  }
+
+  /**
+   * Returns the transition ID of the transition corresponding to the ID of the input or output.
+   * @param {string} inputOrOutputID - ID of the input or output.
+   *
+   * @example
+   * const transitionId = networkClient.getTransitionId("2429232855236830926144356377868449890830704336664550203176918782554219952323field");
+   */
+  async getTransitionId(inputOrOutputID: string): Promise<string> {
+    try {
+      return await this.fetchData<string>("/find/transitionID/" + inputOrOutputID);
+    } catch (error) {
+      throw new Error("Error fetching transition ID.");
+    }
+  }
+
+  /**
+   * Submit an execute or deployment transaction to the Aleo network.
+   *
+   * @param {Transaction | string} transaction  - The transaction to submit to the network
+   * @returns {string} - The transaction id of the submitted transaction or the resulting error
+   */
+  async submitTransaction(transaction: Transaction | string): Promise<string> {
+    const transaction_string = transaction instanceof Transaction ? transaction.toString() : transaction;
+    try {
+      const response = await post(this.host + "/transaction/broadcast", {
+        body: transaction_string,
+        headers: Object.assign({}, this.headers, {
+          "Content-Type": "application/json",
+        }),
+      });
+
+      try {
+        const text = await response.text();
+        return parseJSON(text);
+
+      } catch (error: any) {
+        throw new Error(`Error posting transaction. Aleo network response: ${error.message}`);
+      }
+    } catch (error: any) {
+      throw new Error(`Error posting transaction: No response received: ${error.message}`);
+    }
+  }
+
+  /**
+   * Submit a solution to the Aleo network.
+   *
+   * @param {string} solution The string representation of the solution desired to be submitted to the network.
+   */
+  async submitSolution(solution: string): Promise<string> {
+    try {
+      const response = await post(this.host + "/solution/broadcast", {
+        body: solution,
+        headers: Object.assign({}, this.headers, {
+          "Content-Type": "application/json",
+        }),
+      });
+
+      try {
+        const text = await response.text();
+        return parseJSON(text);
+
+      } catch (error: any) {
+        throw new Error(`Error posting transaction. Aleo network response: ${error.message}`);
+      }
+    } catch (error: any) {
+      throw new Error(`Error posting transaction: No response received: ${error.message}`);
+    }
+  }
+}
+
+export { AleoNetworkClient, AleoNetworkClientOptions, ProgramImports }
+
\ No newline at end of file diff --git a/sdk/docs/offline-key-provider.ts.html b/sdk/docs/offline-key-provider.ts.html new file mode 100644 index 000000000..2112cd3a6 --- /dev/null +++ b/sdk/docs/offline-key-provider.ts.html @@ -0,0 +1,609 @@ +Source: offline-key-provider.ts
On this page

offline-key-provider.ts

import {
+    CachedKeyPair,
+    FunctionKeyPair,
+    FunctionKeyProvider,
+    KeySearchParams,
+} from "./function-key-provider";
+
+import {
+    ProvingKey,
+    VerifyingKey,
+} from "./wasm";
+
+import {
+    CREDITS_PROGRAM_KEYS,
+    PRIVATE_TRANSFER,
+    PRIVATE_TO_PUBLIC_TRANSFER,
+    PUBLIC_TRANSFER,
+    PUBLIC_TO_PRIVATE_TRANSFER,
+    PUBLIC_TRANSFER_AS_SIGNER,
+} from "./constants";
+
+/**
+ * Search parameters for the offline key provider. This class implements the KeySearchParams interface and includes
+ * a convenience method for creating a new instance of this class for each function of the credits.aleo program.
+ *
+ * @example
+ * // If storing a key for a custom program function
+ * offlineSearchParams = new OfflineSearchParams("myprogram.aleo/myfunction");
+ *
+ * // If storing a key for a credits.aleo program function
+ * bondPublicKeyParams = OfflineSearchParams.bondPublicKeyParams();
+ */
+class OfflineSearchParams implements KeySearchParams {
+    cacheKey: string | undefined;
+    verifyCreditsKeys: boolean | undefined;
+
+    /**
+     * Create a new OfflineSearchParams instance.
+     *
+     * @param {string} cacheKey - Key used to store the local function proving & verifying keys. This should be stored
+     * under the naming convention "programName/functionName" (i.e. "myprogram.aleo/myfunction")
+     * @param {boolean} verifyCreditsKeys - Whether to verify the keys against the credits.aleo program,
+     * defaults to false, but should be set to true if using keys from the credits.aleo program
+     */
+    constructor(cacheKey: string, verifyCreditsKeys = false) {
+        this.cacheKey = cacheKey;
+        this.verifyCreditsKeys = verifyCreditsKeys;
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the bond_public function of the credits.aleo program.
+     */
+    static bondPublicKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.bond_public.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the bond_validator function of the credits.aleo program.
+     */
+    static bondValidatorKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.bond_validator.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the claim_unbond_public function of the
+     */
+    static claimUnbondPublicKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.claim_unbond_public.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the fee_private function of the credits.aleo program.
+     */
+    static feePrivateKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.fee_private.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the fee_public function of the credits.aleo program.
+     */
+    static feePublicKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.fee_public.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the inclusion prover function.
+     */
+    static inclusionKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.inclusion.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the join function of the credits.aleo program.
+     */
+    static joinKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.join.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the set_validator_state function of the credits.aleo program.
+     */
+    static setValidatorStateKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.set_validator_state.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the split function of the credits.aleo program.
+     */
+    static splitKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.split.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the transfer_private function of the credits.aleo program.
+     */
+    static transferPrivateKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_private.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the transfer_private_to_public function of the credits.aleo program.
+     */
+    static transferPrivateToPublicKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the transfer_public function of the credits.aleo program.
+     */
+    static transferPublicKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the transfer_public_as_signer function of the credits.aleo program.
+     */
+    static transferPublicAsSignerKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public_as_signer.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the transfer_public_to_private function of the credits.aleo program.
+     */
+    static transferPublicToPrivateKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator, true);
+    }
+
+    /**
+     * Create a new OfflineSearchParams instance for the unbond_public function of the credits.aleo program.
+     */
+    static unbondPublicKeyParams(): OfflineSearchParams {
+        return new OfflineSearchParams(CREDITS_PROGRAM_KEYS.unbond_public.locator, true);
+    }
+}
+
+/**
+ * A key provider meant for building transactions offline on devices such as hardware wallets. This key provider is not
+ * able to contact the internet for key material and instead relies on the user to insert Aleo function proving &
+ * verifying keys from local storage prior to usage.
+ *
+ * @example
+ * // Create an offline program manager
+ * const programManager = new ProgramManager();
+ *
+ * // Create a temporary account for the execution of the program
+ * const account = new Account();
+ * programManager.setAccount(account);
+ *
+ * // Create the proving keys from the key bytes on the offline machine
+ * console.log("Creating proving keys from local key files");
+ * const program = "program hello_hello.aleo; function hello: input r0 as u32.public; input r1 as u32.private; add r0 r1 into r2; output r2 as u32.private;";
+ * const myFunctionProver = await getLocalKey("/path/to/my/function/hello_hello.prover");
+ * const myFunctionVerifier = await getLocalKey("/path/to/my/function/hello_hello.verifier");
+ * const feePublicProvingKeyBytes = await getLocalKey("/path/to/credits.aleo/feePublic.prover");
+ *
+ * myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProver);
+ * myFunctionVerifyingKey = VerifyingKey.fromBytes(myFunctionVerifier);
+ * const feePublicProvingKey = ProvingKey.fromBytes(feePublicKeyBytes);
+ *
+ * // Create an offline key provider
+ * console.log("Creating offline key provider");
+ * const offlineKeyProvider = new OfflineKeyProvider();
+ *
+ * // Cache the keys
+ * // Cache the proving and verifying keys for the custom hello function
+ * OfflineKeyProvider.cacheKeys("hello_hello.aleo/hello", myFunctionProvingKey, myFunctionVerifyingKey);
+ *
+ * // Cache the proving key for the fee_public function (the verifying key is automatically cached)
+ * OfflineKeyProvider.insertFeePublicKey(feePublicProvingKey);
+ *
+ * // Create an offline query using the latest state root in order to create the inclusion proof
+ * const offlineQuery = new OfflineQuery("latestStateRoot");
+ *
+ * // Insert the key provider into the program manager
+ * programManager.setKeyProvider(offlineKeyProvider);
+ *
+ * // Create the offline search params
+ * const offlineSearchParams = new OfflineSearchParams("hello_hello.aleo/hello");
+ *
+ * // Create the offline transaction
+ * const offlineExecuteTx = <Transaction>await this.buildExecutionTransaction("hello_hello.aleo", "hello", 1, false, ["5u32", "5u32"], undefined, offlineSearchParams, undefined, undefined, undefined, undefined, offlineQuery, program);
+ *
+ * // Broadcast the transaction later on a machine with internet access
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+ * const txId = await networkClient.broadcastTransaction(offlineExecuteTx);
+ */
+class OfflineKeyProvider implements FunctionKeyProvider {
+    cache: Map<string, CachedKeyPair>;
+
+    constructor() {
+        this.cache = new Map<string, CachedKeyPair>();
+    }
+
+    /**
+     * Get bond_public function keys from the credits.aleo program. The keys must be cached prior to calling this
+     * method for it to work.
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function
+     */
+    bondPublicKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.bondPublicKeyParams());
+    };
+
+    /**
+     * Get bond_validator function keys from the credits.aleo program. The keys must be cached prior to calling this
+     * method for it to work.
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the bond_public function
+     */
+    bondValidatorKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.bondValidatorKeyParams());
+    };
+
+
+    /**
+     * Cache a set of keys. This will overwrite any existing keys with the same keyId. The user can check if a keyId
+     * exists in the cache using the containsKeys method prior to calling this method if overwriting is not desired.
+     *
+     * @param {string} keyId access key for the cache
+     * @param {FunctionKeyPair} keys keys to cache
+     */
+    cacheKeys(keyId: string, keys: FunctionKeyPair): void {
+        const [provingKey, verifyingKey] = keys;
+        this.cache.set(keyId, [provingKey.toBytes(), verifyingKey.toBytes()]);
+    };
+
+    /**
+     * Get unbond_public function keys from the credits.aleo program. The keys must be cached prior to calling this
+     * method for it to work.
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the unbond_public function
+     */
+    claimUnbondPublicKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.claimUnbondPublicKeyParams());
+    };
+
+    /**
+     * Get arbitrary function key from the offline key provider cache.
+     *
+     * @param {KeySearchParams | undefined} params - Optional search parameters for the key provider
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified program
+     *
+     * @example
+     * /// First cache the keys from local offline resources
+     * const offlineKeyProvider = new OfflineKeyProvider();
+     * const myFunctionVerifyingKey = VerifyingKey.fromString("verifier...");
+     * const myFunctionProvingKeyBytes = await readBinaryFile('./resources/myfunction.prover');
+     * const myFunctionProvingKey = ProvingKey.fromBytes(myFunctionProvingKeyBytes);
+     *
+     * /// Cache the keys for future use with a memorable locator
+     * offlineKeyProvider.cacheKeys("myprogram.aleo/myfunction", [myFunctionProvingKey, myFunctionVerifyingKey]);
+     *
+     * /// When they're needed, retrieve the keys from the cache
+     *
+     * /// First create a search parameter object with the same locator used to cache the keys
+     * const keyParams = new OfflineSearchParams("myprogram.aleo/myfunction");
+     *
+     * /// Then retrieve the keys
+     * const [myFunctionProver, myFunctionVerifier] = await offlineKeyProvider.functionKeys(keyParams);
+     */
+    functionKeys(params?: KeySearchParams): Promise<FunctionKeyPair> {
+        return new Promise((resolve, reject) => {
+            if (params === undefined) {
+                reject(new Error("No search parameters provided, cannot retrieve keys"));
+            } else {
+                const keyId = params.cacheKey;
+                const verifyCreditsKeys = params.verifyCreditsKeys;
+                if (this.cache.has(keyId)) {
+                    const [provingKeyBytes, verifyingKeyBytes] = this.cache.get(keyId) as CachedKeyPair;
+                    const provingKey = ProvingKey.fromBytes(provingKeyBytes);
+                    const verifyingKey = VerifyingKey.fromBytes(verifyingKeyBytes);
+                    if (verifyCreditsKeys) {
+                        const keysMatchExpected = this.verifyCreditsKeys(keyId, provingKey, verifyingKey)
+                        if (!keysMatchExpected) {
+                            reject (new Error(`Cached keys do not match expected keys for ${keyId}`));
+                        }
+                    }
+                    resolve([provingKey, verifyingKey]);
+                } else {
+                    reject(new Error("Keys not found in cache for " + keyId));
+                }
+            }
+        });
+    };
+
+    /**
+     * Determines if the keys for a given credits function match the expected keys.
+     *
+     * @returns {boolean} Whether the keys match the expected keys
+     */
+    verifyCreditsKeys(locator: string, provingKey: ProvingKey, verifyingKey: VerifyingKey): boolean {
+        switch (locator) {
+            case CREDITS_PROGRAM_KEYS.bond_public.locator:
+                return provingKey.isBondPublicProver() && verifyingKey.isBondPublicVerifier();
+            case CREDITS_PROGRAM_KEYS.claim_unbond_public.locator:
+                return provingKey.isClaimUnbondPublicProver() && verifyingKey.isClaimUnbondPublicVerifier();
+            case CREDITS_PROGRAM_KEYS.fee_private.locator:
+                return provingKey.isFeePrivateProver() && verifyingKey.isFeePrivateVerifier();
+            case CREDITS_PROGRAM_KEYS.fee_public.locator:
+                return provingKey.isFeePublicProver() && verifyingKey.isFeePublicVerifier();
+            case CREDITS_PROGRAM_KEYS.inclusion.locator:
+                return provingKey.isInclusionProver() && verifyingKey.isInclusionVerifier();
+            case CREDITS_PROGRAM_KEYS.join.locator:
+                return provingKey.isJoinProver() && verifyingKey.isJoinVerifier();
+            case CREDITS_PROGRAM_KEYS.set_validator_state.locator:
+                return provingKey.isSetValidatorStateProver() && verifyingKey.isSetValidatorStateVerifier();
+            case CREDITS_PROGRAM_KEYS.split.locator:
+                return provingKey.isSplitProver() && verifyingKey.isSplitVerifier();
+            case CREDITS_PROGRAM_KEYS.transfer_private.locator:
+                return provingKey.isTransferPrivateProver() && verifyingKey.isTransferPrivateVerifier();
+            case CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator:
+                return provingKey.isTransferPrivateToPublicProver() && verifyingKey.isTransferPrivateToPublicVerifier();
+            case CREDITS_PROGRAM_KEYS.transfer_public.locator:
+                return provingKey.isTransferPublicProver() && verifyingKey.isTransferPublicVerifier();
+            case CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator:
+                return provingKey.isTransferPublicToPrivateProver() && verifyingKey.isTransferPublicToPrivateVerifier();
+            case CREDITS_PROGRAM_KEYS.unbond_public.locator:
+                return provingKey.isUnbondPublicProver() && verifyingKey.isUnbondPublicVerifier();
+            default:
+                return false;
+        }
+    }
+
+    /**
+     * Get fee_private function keys from the credits.aleo program. The keys must be cached prior to calling this
+     * method for it to work.
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    feePrivateKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.feePrivateKeyParams());
+    };
+
+    /**
+     * Get fee_public function keys from the credits.aleo program. The keys must be cached prior to calling this
+     * method for it to work.
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    feePublicKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.feePublicKeyParams());
+    };
+
+    /**
+     * Get join function keys from the credits.aleo program. The keys must be cached prior to calling this
+     * method for it to work.
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    joinKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.joinKeyParams());
+    };
+
+    /**
+     * Get split function keys from the credits.aleo program. The keys must be cached prior to calling this
+     * method for it to work.
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    splitKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.splitKeyParams());
+    };
+
+    /**
+     * Get keys for a variant of the transfer function from the credits.aleo program.
+     *
+     *
+     * @param {string} visibility Visibility of the transfer function (private, public, privateToPublic, publicToPrivate)
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the specified transfer function
+     *
+     * @example
+     * // Create a new OfflineKeyProvider
+     * const offlineKeyProvider = new OfflineKeyProvider();
+     *
+     * // Cache the keys for future use with the official locator
+     * const transferPublicProvingKeyBytes = await readBinaryFile('./resources/transfer_public.prover.a74565e');
+     * const transferPublicProvingKey = ProvingKey.fromBytes(transferPublicProvingKeyBytes);
+     *
+     * // Cache the transfer_public keys for future use with the OfflinKeyProvider's convenience method for
+     * // transfer_public (the verifying key will be cached automatically)
+     * offlineKeyProvider.insertTransferPublicKeys(transferPublicProvingKey);
+     *
+     * /// When they're needed, retrieve the keys from the cache
+     * const [transferPublicProvingKey, transferPublicVerifyingKey] = await keyProvider.transferKeys("public");
+     */
+    transferKeys(visibility: string): Promise<FunctionKeyPair> {
+        if (PRIVATE_TRANSFER.has(visibility)) {
+            return this.functionKeys(OfflineSearchParams.transferPrivateKeyParams());
+        } else if (PRIVATE_TO_PUBLIC_TRANSFER.has(visibility)) {
+            return this.functionKeys(OfflineSearchParams.transferPrivateToPublicKeyParams());
+        } else if (PUBLIC_TRANSFER.has(visibility)) {
+            return this.functionKeys(OfflineSearchParams.transferPublicKeyParams());
+        } else if (PUBLIC_TRANSFER_AS_SIGNER.has(visibility)) {
+            return this.functionKeys(OfflineSearchParams.transferPublicAsSignerKeyParams());
+        } else if (PUBLIC_TO_PRIVATE_TRANSFER.has(visibility)) {
+            return this.functionKeys(OfflineSearchParams.transferPublicToPrivateKeyParams());
+        } else {
+            throw new Error("Invalid visibility type");
+        }
+    };
+
+    /**
+     * Get unbond_public function keys from the credits.aleo program
+     *
+     * @returns {Promise<FunctionKeyPair>} Proving and verifying keys for the join function
+     */
+    async unBondPublicKeys(): Promise<FunctionKeyPair> {
+        return this.functionKeys(OfflineSearchParams.unbondPublicKeyParams());
+    };
+
+    /**
+     * Insert the proving and verifying keys for the bond_public function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for bond_public before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertBondPublicKeys(provingKey: ProvingKey) {
+        if (provingKey.isBondPublicProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.bond_public.locator, [provingKey.toBytes(), VerifyingKey.bondPublicVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for bond_public");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the claim_unbond_public function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for claim_unbond_public before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertClaimUnbondPublicKeys(provingKey: ProvingKey) {
+        if (provingKey.isClaimUnbondPublicProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.claim_unbond_public.locator, [provingKey.toBytes(), VerifyingKey.claimUnbondPublicVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for claim_unbond_public");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the fee_private function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for fee_private before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertFeePrivateKeys(provingKey: ProvingKey) {
+        if (provingKey.isFeePrivateProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.fee_private.locator, [provingKey.toBytes(), VerifyingKey.feePrivateVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for fee_private");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the fee_public function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for fee_public before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertFeePublicKeys(provingKey: ProvingKey) {
+        if (provingKey.isFeePublicProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.fee_public.locator, [provingKey.toBytes(), VerifyingKey.feePublicVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for fee_public");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the join function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for join before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertJoinKeys(provingKey: ProvingKey) {
+        if (provingKey.isJoinProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.join.locator, [provingKey.toBytes(), VerifyingKey.joinVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for join");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the set_validator_state function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for set_validator_state before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertSetValidatorStateKeys(provingKey: ProvingKey) {
+        if (provingKey.isSetValidatorStateProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.set_validator_state.locator, [provingKey.toBytes(), VerifyingKey.setValidatorStateVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for set_validator_state");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the split function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for split before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertSplitKeys(provingKey: ProvingKey) {
+        if (provingKey.isSplitProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.split.locator, [provingKey.toBytes(), VerifyingKey.splitVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for split");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the transfer_private function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for transfer_private before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertTransferPrivateKeys(provingKey: ProvingKey) {
+        if (provingKey.isTransferPrivateProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.transfer_private.locator, [provingKey.toBytes(), VerifyingKey.transferPrivateVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for transfer_private");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the transfer_private_to_public function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for transfer_private_to_public before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertTransferPrivateToPublicKeys(provingKey: ProvingKey) {
+        if (provingKey.isTransferPrivateToPublicProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.transfer_private_to_public.locator, [provingKey.toBytes(), VerifyingKey.transferPrivateToPublicVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for transfer_private_to_public");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the transfer_public function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for transfer_public before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertTransferPublicKeys(provingKey: ProvingKey) {
+        if (provingKey.isTransferPublicProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.transfer_public.locator, [provingKey.toBytes(), VerifyingKey.transferPublicVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for transfer_public");
+        }
+    }
+
+    /**
+     * Insert the proving and verifying keys for the transfer_public_to_private function into the cache. Only the proving key needs
+     * to be inserted, the verifying key is automatically inserted by the SDK. This function will automatically check
+     * that the keys match the expected checksum for transfer_public_to_private before inserting them into the cache.
+     *
+     * @param provingKey
+     */
+    insertTransferPublicToPrivateKeys(provingKey: ProvingKey) {
+        if (provingKey.isTransferPublicToPrivateProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.transfer_public_to_private.locator, [provingKey.toBytes(), VerifyingKey.transferPublicToPrivateVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for transfer_public_to_private");
+        }
+    }
+
+    insertUnbondPublicKeys(provingKey: ProvingKey) {
+        if (provingKey.isUnbondPublicProver()) {
+            this.cache.set(CREDITS_PROGRAM_KEYS.unbond_public.locator, [provingKey.toBytes(), VerifyingKey.unbondPublicVerifier().toBytes()]);
+        } else {
+            throw new Error("Attempted to insert invalid proving keys for unbond_public");
+        }
+    }
+}
+
+
+export {OfflineKeyProvider, OfflineSearchParams}
+
\ No newline at end of file diff --git a/sdk/docs/program-manager.ts.html b/sdk/docs/program-manager.ts.html new file mode 100644 index 000000000..04095c6d3 --- /dev/null +++ b/sdk/docs/program-manager.ts.html @@ -0,0 +1,1302 @@ +Source: program-manager.ts
On this page

program-manager.ts

import { Account } from "./account";
+import { AleoNetworkClient, ProgramImports } from "./network-client";
+
+import {
+    RecordProvider,
+    RecordSearchParams,
+} from "./record-provider";
+
+import {
+    AleoKeyProvider,
+    AleoKeyProviderParams,
+    FunctionKeyPair,
+    FunctionKeyProvider,
+    KeySearchParams,
+} from "./function-key-provider";
+
+import {
+    ExecutionResponse,
+    Execution as FunctionExecution,
+    OfflineQuery,
+    RecordPlaintext,
+    PrivateKey,
+    Program,
+    ProvingKey,
+    VerifyingKey,
+    Transaction,
+    ProgramManager as WasmProgramManager,
+    verifyFunctionExecution,
+} from "./wasm";
+
+import {
+    CREDITS_PROGRAM_KEYS,
+    PRIVATE_TRANSFER_TYPES,
+    VALID_TRANSFER_TYPES,
+} from "./constants";
+
+import { logAndThrow } from "./utils";
+
+/**
+ * Represents the options for executing a transaction in the Aleo network.
+ * This interface is used to specify the parameters required for building and submitting an execution transaction.
+ *
+ * @property {string} programName - The name of the program containing the function to be executed.
+ * @property {string} functionName - The name of the function to execute within the program.
+ * @property {number} fee - The fee to be paid for the transaction.
+ * @property {boolean} privateFee - If true, uses a private record to pay the fee; otherwise, uses the account's public credit balance.
+ * @property {string[]} inputs - The inputs to the function being executed.
+ * @property {RecordSearchParams} [recordSearchParams] - Optional parameters for searching for a record to pay the execution transaction fee.
+ * @property {KeySearchParams} [keySearchParams] - Optional parameters for finding the matching proving & verifying keys for the function.
+ * @property {string | RecordPlaintext} [feeRecord] - Optional fee record to use for the transaction.
+ * @property {ProvingKey} [provingKey] - Optional proving key to use for the transaction.
+ * @property {VerifyingKey} [verifyingKey] - Optional verifying key to use for the transaction.
+ * @property {PrivateKey} [privateKey] - Optional private key to use for the transaction.
+ * @property {OfflineQuery} [offlineQuery] - Optional offline query if creating transactions in an offline environment.
+ * @property {string | Program} [program] - Optional program source code to use for the transaction.
+ * @property {ProgramImports} [imports] - Optional programs that the program being executed imports.
+ */
+interface ExecuteOptions {
+    programName: string;
+    functionName: string;
+    fee: number;
+    privateFee: boolean;
+    inputs: string[];
+    recordSearchParams?: RecordSearchParams;
+    keySearchParams?: KeySearchParams;
+    feeRecord?: string | RecordPlaintext;
+    provingKey?: ProvingKey;
+    verifyingKey?: VerifyingKey;
+    privateKey?: PrivateKey;
+    offlineQuery?: OfflineQuery;
+    program?: string | Program;
+    imports?: ProgramImports;
+}
+
+/**
+ * The ProgramManager class is used to execute and deploy programs on the Aleo network and create value transfers.
+ */
+class ProgramManager {
+    account: Account | undefined;
+    keyProvider: FunctionKeyProvider;
+    host: string;
+    networkClient: AleoNetworkClient;
+    recordProvider: RecordProvider | undefined;
+
+    /** Create a new instance of the ProgramManager
+     *
+     * @param { string | undefined } host A host uri running the official Aleo API
+     * @param { FunctionKeyProvider | undefined } keyProvider A key provider that implements {@link FunctionKeyProvider} interface
+     * @param { RecordProvider | undefined } recordProvider A record provider that implements {@link RecordProvider} interface
+     */
+    constructor(host?: string | undefined, keyProvider?: FunctionKeyProvider | undefined, recordProvider?: RecordProvider | undefined) {
+        this.host = host ? host : 'https://api.explorer.provable.com/v1';
+        this.networkClient = new AleoNetworkClient(this.host);
+
+        this.keyProvider = keyProvider ? keyProvider : new AleoKeyProvider();
+        this.recordProvider = recordProvider;
+    }
+
+    /**
+     * Set the account to use for transaction submission to the Aleo network
+     *
+     * @param {Account} account Account to use for transaction submission
+     */
+    setAccount(account: Account) {
+        this.account = account;
+    }
+
+    /**
+     * Set the key provider that provides the proving and verifying keys for programs
+     *
+     * @param {FunctionKeyProvider} keyProvider
+     */
+    setKeyProvider(keyProvider: FunctionKeyProvider) {
+        this.keyProvider = keyProvider;
+    }
+
+    /**
+     * Set the host peer to use for transaction submission to the Aleo network
+     *
+     * @param host {string} Peer url to use for transaction submission
+     */
+    setHost(host: string) {
+        this.host = host;
+        this.networkClient.setHost(host);
+    }
+
+    /**
+     * Set the record provider that provides records for transactions
+     *
+     * @param {RecordProvider} recordProvider
+     */
+    setRecordProvider(recordProvider: RecordProvider) {
+        this.recordProvider = recordProvider;
+    }
+
+    /**
+     * Deploy an Aleo program to the Aleo network
+     *
+     * @param {string} program Program source code
+     * @param {number} fee Fee to pay for the transaction
+     * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
+     * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for searching for a record to use
+     * pay the deployment fee
+     * @param {string | RecordPlaintext | undefined} feeRecord Optional Fee record to use for the transaction
+     * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction
+     * @returns {string} The transaction id of the deployed program or a failure message from the network
+     *
+     * @example
+     * // Create a new NetworkClient, KeyProvider, and RecordProvider
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for deployments
+     * const program = "program hello_hello.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n";
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     *
+     * // Define a fee in credits
+     * const fee = 1.2;
+     *
+     * // Deploy the program
+     * const tx_id = await programManager.deploy(program, fee);
+     *
+     * // Verify the transaction was successful
+     * const transaction = await programManager.networkClient.getTransaction(tx_id);
+     */
+    async deploy(
+        program: string,
+        fee: number,
+        privateFee: boolean,
+        recordSearchParams?: RecordSearchParams,
+        feeRecord?: string | RecordPlaintext,
+        privateKey?: PrivateKey,
+    ): Promise<string> {
+        // Ensure the program is valid and does not exist on the network
+        try {
+            const programObject = Program.fromString(program);
+            let programSource;
+            try {
+                programSource = await this.networkClient.getProgram(programObject.id());
+            } catch (e) {
+                // Program does not exist on the network, deployment can proceed
+                console.log(`Program ${programObject.id()} does not exist on the network, deploying...`);
+            }
+            if (typeof programSource == "string") {
+                throw (`Program ${programObject.id()} already exists on the network, please rename your program`);
+            }
+        } catch (e: any) {
+            logAndThrow(`Error validating program: ${e.message}`);
+        }
+
+        // Get the private key from the account if it is not provided in the parameters
+        let deploymentPrivateKey = privateKey;
+        if (typeof privateKey === "undefined" && typeof this.account !== "undefined") {
+            deploymentPrivateKey = this.account.privateKey();
+        }
+
+        if (typeof deploymentPrivateKey === "undefined") {
+            throw("No private key provided and no private key set in the ProgramManager");
+        }
+
+        // Get the fee record from the account if it is not provided in the parameters
+        try {
+            feeRecord = privateFee ? <RecordPlaintext>await this.getCreditsRecord(fee, [], feeRecord, recordSearchParams) : undefined;
+        } catch (e: any) {
+            logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
+        }
+
+        // Get the proving and verifying keys from the key provider
+        let feeKeys;
+        try {
+            feeKeys = privateFee ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys() : <FunctionKeyPair>await this.keyProvider.feePublicKeys();
+        } catch (e: any) {
+            logAndThrow(`Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`);
+        }
+        const [feeProvingKey, feeVerifyingKey] = feeKeys;
+
+        // Resolve the program imports if they exist
+        let imports;
+        try {
+            imports = await this.networkClient.getProgramImports(program);
+        } catch (e: any) {
+            logAndThrow(`Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`);
+        }
+
+        // Build a deployment transaction and submit it to the network
+        const tx = await WasmProgramManager.buildDeploymentTransaction(deploymentPrivateKey, program, fee, feeRecord, this.host, imports, feeProvingKey, feeVerifyingKey);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Builds an execution transaction for submission to the Aleo network.
+     *
+     * @param {ExecuteOptions} options - The options for the execution transaction.
+     * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
+     *
+     * @example
+     * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for executions
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     *
+     * // Build and execute the transaction
+     * const transaction = await programManager.buildExecutionTransaction({
+     *   programName: "hello_hello.aleo",
+     *   functionName: "hello_hello",
+     *   fee: 0.020,
+     *   privateFee: false,
+     *   inputs: ["5u32", "5u32"],
+     *   keySearchParams: { "cacheKey": "hello_hello:hello" }
+     * });
+     * const result = await programManager.networkClient.submitTransaction(transaction);
+     */
+    async buildExecutionTransaction(options: ExecuteOptions): Promise<Transaction> {
+        // Destructure the options object to access the parameters
+        const {
+            programName,
+            functionName,
+            fee,
+            privateFee,
+            inputs,
+            recordSearchParams,
+            keySearchParams,
+            privateKey,
+            offlineQuery
+        } = options;
+
+        let feeRecord = options.feeRecord;
+        let provingKey = options.provingKey;
+        let verifyingKey = options.verifyingKey;
+        let program = options.program;
+        let imports = options.imports;
+
+        // Ensure the function exists on the network
+        if (program === undefined) {
+            try {
+                program = <string>(await this.networkClient.getProgram(programName));
+            } catch (e: any) {
+                logAndThrow(`Error finding ${programName}. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network the program is deployed to the network.`);
+            }
+        } else if (program instanceof Program) {
+            program = program.toString();
+        }
+
+        // Get the private key from the account if it is not provided in the parameters
+        let executionPrivateKey = privateKey;
+        if (typeof privateKey === "undefined" && typeof this.account !== "undefined") {
+            executionPrivateKey = this.account.privateKey();
+        }
+
+        if (typeof executionPrivateKey === "undefined") {
+            throw("No private key provided and no private key set in the ProgramManager");
+        }
+
+        // Get the fee record from the account if it is not provided in the parameters
+        try {
+            feeRecord = privateFee ? <RecordPlaintext>await this.getCreditsRecord(fee, [], feeRecord, recordSearchParams) : undefined;
+        } catch (e: any) {
+            logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
+        }
+
+        // Get the fee proving and verifying keys from the key provider
+        let feeKeys;
+        try {
+            feeKeys = privateFee ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys() : <FunctionKeyPair>await this.keyProvider.feePublicKeys();
+        } catch (e: any) {
+            logAndThrow(`Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`);
+        }
+        const [feeProvingKey, feeVerifyingKey] = feeKeys;
+
+        // If the function proving and verifying keys are not provided, attempt to find them using the key provider
+        if (!provingKey || !verifyingKey) {
+            try {
+                [provingKey, verifyingKey] = <FunctionKeyPair>await this.keyProvider.functionKeys(keySearchParams);
+            } catch (e) {
+                console.log(`Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`)
+            }
+        }
+
+        // Resolve the program imports if they exist
+        const numberOfImports = Program.fromString(program).getImports().length;
+        if (numberOfImports > 0 && !imports) {
+            try {
+                imports = <ProgramImports>await this.networkClient.getProgramImports(programName);
+            } catch (e: any) {
+                logAndThrow(`Error finding program imports. Network response: '${e.message}'. Please ensure you're connected to a valid Aleo network and the program is deployed to the network.`);
+            }
+        }
+
+        // Build an execution transaction and submit it to the network
+        return await WasmProgramManager.buildExecutionTransaction(executionPrivateKey, program, functionName, inputs, fee, feeRecord, this.host, imports, provingKey, verifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
+    }
+
+    /**
+     * Builds an execution transaction for submission to the Aleo network.
+     *
+     * @param {ExecuteOptions} options - The options for the execution transaction.
+     * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error.
+     *
+     * @example
+     * // Create a new NetworkClient, KeyProvider, and RecordProvider using official Aleo record, key, and network providers
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for executions
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     *
+     * // Build and execute the transaction
+     * const transaction = await programManager.execute({
+     *   programName: "hello_hello.aleo",
+     *   functionName: "hello_hello",
+     *   fee: 0.020,
+     *   privateFee: false,
+     *   inputs: ["5u32", "5u32"],
+     *   keySearchParams: { "cacheKey": "hello_hello:hello" }
+     * });
+     * const result = await programManager.networkClient.submitTransaction(transaction);
+     */
+    async execute(options: ExecuteOptions): Promise<string> {
+        const tx = <Transaction>await this.buildExecutionTransaction(options);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Run an Aleo program in offline mode
+     *
+     * @param {string} program Program source code containing the function to be executed
+     * @param {string} function_name Function name to execute
+     * @param {string[]} inputs Inputs to the function
+     * @param {number} proveExecution Whether to prove the execution of the function and return an execution transcript
+     * that contains the proof.
+     * @param {string[] | undefined} imports Optional imports to the program
+     * @param {KeySearchParams | undefined} keySearchParams Optional parameters for finding the matching proving &
+     * verifying keys for the function
+     * @param {ProvingKey | undefined} provingKey Optional proving key to use for the transaction
+     * @param {VerifyingKey | undefined} verifyingKey Optional verifying key to use for the transaction
+     * @param {PrivateKey | undefined} privateKey Optional private key to use for the transaction
+     * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
+     * @returns {Promise<string>}
+     *
+     * @example
+     * import { Account, Program } from '@provablehq/sdk';
+     *
+     * /// Create the source for the "helloworld" program
+     * const program = "program helloworld.aleo;\n\nfunction hello:\n    input r0 as u32.public;\n    input r1 as u32.private;\n    add r0 r1 into r2;\n    output r2 as u32.private;\n";
+     * const programManager = new ProgramManager();
+     *
+     * /// Create a temporary account for the execution of the program
+     * const account = new Account();
+     * programManager.setAccount(account);
+     *
+     * /// Get the response and ensure that the program executed correctly
+     * const executionResponse = await programManager.run(program, "hello", ["5u32", "5u32"]);
+     * const result = executionResponse.getOutputs();
+     * assert(result === ["10u32"]);
+     */
+    async run(
+        program: string,
+        function_name: string,
+        inputs: string[],
+        proveExecution: boolean,
+        imports?: ProgramImports,
+        keySearchParams?: KeySearchParams,
+        provingKey?: ProvingKey,
+        verifyingKey?: VerifyingKey,
+        privateKey?: PrivateKey,
+        offlineQuery?: OfflineQuery,
+    ): Promise<ExecutionResponse> {
+        // Get the private key from the account if it is not provided in the parameters
+        let executionPrivateKey = privateKey;
+        if (typeof privateKey === "undefined" && typeof this.account !== "undefined") {
+            executionPrivateKey = this.account.privateKey();
+        }
+
+        if (typeof executionPrivateKey === "undefined") {
+            throw("No private key provided and no private key set in the ProgramManager");
+        }
+
+        // If the function proving and verifying keys are not provided, attempt to find them using the key provider
+        if (!provingKey || !verifyingKey) {
+            try {
+                [provingKey, verifyingKey] = <FunctionKeyPair>await this.keyProvider.functionKeys(keySearchParams);
+            } catch (e) {
+                console.log(`Function keys not found. Key finder response: '${e}'. The function keys will be synthesized`)
+            }
+        }
+
+        // Run the program offline and return the result
+        console.log("Running program offline")
+        console.log("Proving key: ", provingKey);
+        console.log("Verifying key: ", verifyingKey);
+        return WasmProgramManager.executeFunctionOffline(executionPrivateKey, program, function_name, inputs, proveExecution, false, imports, provingKey, verifyingKey, this.host, offlineQuery);
+    }
+
+    /**
+     * Join two credits records into a single credits record
+     *
+     * @param {RecordPlaintext | string} recordOne First credits record to join
+     * @param {RecordPlaintext | string} recordTwo Second credits record to join
+     * @param {number} fee Fee in credits pay for the join transaction
+     * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
+     * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the fee record to use
+     * to pay the fee for the join transaction
+     * @param {RecordPlaintext | string | undefined} feeRecord Fee record to use for the join transaction
+     * @param {PrivateKey | undefined} privateKey Private key to use for the join transaction
+     * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
+     * @returns {Promise<string>}
+     */
+    async join(
+        recordOne: RecordPlaintext | string,
+        recordTwo: RecordPlaintext | string,
+        fee: number,
+        privateFee: boolean,
+        recordSearchParams?: RecordSearchParams | undefined,
+        feeRecord?: RecordPlaintext | string | undefined,
+        privateKey?: PrivateKey,
+        offlineQuery?: OfflineQuery,
+    ): Promise<string> {
+        // Get the private key from the account if it is not provided in the parameters
+        let executionPrivateKey = privateKey;
+        if (typeof privateKey === "undefined" && typeof this.account !== "undefined") {
+            executionPrivateKey = this.account.privateKey();
+        }
+
+        if (typeof executionPrivateKey === "undefined") {
+            throw("No private key provided and no private key set in the ProgramManager");
+        }
+
+        // Get the proving and verifying keys from the key provider
+        let feeKeys;
+        let joinKeys
+        try {
+            feeKeys = privateFee ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys() : <FunctionKeyPair>await this.keyProvider.feePublicKeys();
+            joinKeys = <FunctionKeyPair>await this.keyProvider.joinKeys();
+        } catch (e: any) {
+            logAndThrow(`Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`);
+        }
+        const [feeProvingKey, feeVerifyingKey] = feeKeys;
+        const [joinProvingKey, joinVerifyingKey] = joinKeys;
+
+        // Get the fee record from the account if it is not provided in the parameters
+        try {
+            feeRecord = privateFee ? <RecordPlaintext>await this.getCreditsRecord(fee, [], feeRecord, recordSearchParams) : undefined;
+        } catch (e: any) {
+            logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
+        }
+
+        // Validate the records provided are valid plaintext records
+        try {
+            recordOne = recordOne instanceof RecordPlaintext ? recordOne : RecordPlaintext.fromString(recordOne);
+            recordTwo = recordTwo instanceof RecordPlaintext ? recordTwo : RecordPlaintext.fromString(recordTwo);
+        } catch (e: any) {
+            logAndThrow('Records provided are not valid. Please ensure they are valid plaintext records.')
+        }
+
+        // Build an execution transaction and submit it to the network
+        const tx = await WasmProgramManager.buildJoinTransaction(executionPrivateKey, recordOne, recordTwo, fee, feeRecord, this.host, joinProvingKey, joinVerifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Split credits into two new credits records
+     *
+     * @param {number} splitAmount Amount in microcredits to split from the original credits record
+     * @param {RecordPlaintext | string} amountRecord Amount record to use for the split transaction
+     * @param {PrivateKey | undefined} privateKey Optional private key to use for the split transaction
+     * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
+     * @returns {Promise<string>}
+     *
+     * @example
+     * // Create a new NetworkClient, KeyProvider, and RecordProvider
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for executions
+     * const programName = "hello_hello.aleo";
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * const record = "{  owner: aleo184vuwr5u7u0ha5f5k44067dd2uaqewxx6pe5ltha5pv99wvhfqxqv339h4.private,  microcredits: 45000000u64.private,  _nonce: 4106205762862305308495708971985748592380064201230396559307556388725936304984group.public}"
+     * const tx_id = await programManager.split(25000000, record);
+     * const transaction = await programManager.networkClient.getTransaction(tx_id);
+     */
+    async split(splitAmount: number, amountRecord: RecordPlaintext | string, privateKey?: PrivateKey, offlineQuery?: OfflineQuery): Promise<string> {
+        // Get the private key from the account if it is not provided in the parameters
+        let executionPrivateKey = privateKey;
+        if (typeof executionPrivateKey === "undefined" && typeof this.account !== "undefined") {
+            executionPrivateKey = this.account.privateKey();
+        }
+
+        if (typeof executionPrivateKey === "undefined") {
+            throw("No private key provided and no private key set in the ProgramManager");
+        }
+
+        // Get the split keys from the key provider
+        let splitKeys;
+        try {
+            splitKeys = <FunctionKeyPair>await this.keyProvider.splitKeys();
+        } catch (e: any) {
+            logAndThrow(`Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`);
+        }
+        const [splitProvingKey, splitVerifyingKey] = splitKeys;
+
+        // Validate the record to be split
+        try {
+            amountRecord = amountRecord instanceof RecordPlaintext ? amountRecord : RecordPlaintext.fromString(amountRecord);
+        } catch (e: any) {
+            logAndThrow("Record provided is not valid. Please ensure it is a valid plaintext record.");
+        }
+
+        // Build an execution transaction and submit it to the network
+        const tx = await WasmProgramManager.buildSplitTransaction(executionPrivateKey, splitAmount, amountRecord, this.host, splitProvingKey, splitVerifyingKey, offlineQuery);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Pre-synthesize proving and verifying keys for a program
+     *
+     * @param program {string} The program source code to synthesize keys for
+     * @param function_id {string} The function id to synthesize keys for
+     * @param inputs {Array<string>}  Sample inputs to the function
+     * @param privateKey {PrivateKey | undefined} Optional private key to use for the key synthesis
+     *
+     * @returns {Promise<FunctionKeyPair>}
+     */
+    async synthesizeKeys(
+        program: string,
+        function_id: string,
+        inputs: Array<string>,
+        privateKey?: PrivateKey,
+    ): Promise<FunctionKeyPair> {
+        // Resolve the program imports if they exist
+        let imports;
+
+        let executionPrivateKey = privateKey;
+        if (typeof executionPrivateKey === "undefined") {
+            if (typeof this.account !== "undefined") {
+                executionPrivateKey = this.account.privateKey();
+            } else {
+                executionPrivateKey = new PrivateKey();
+            }
+        }
+
+        // Attempt to run an offline execution of the program and extract the proving and verifying keys
+        try {
+            imports = await this.networkClient.getProgramImports(program);
+            const keyPair = await WasmProgramManager.synthesizeKeyPair(
+                executionPrivateKey,
+                program,
+                function_id,
+                inputs,
+                imports
+            );
+            return [<ProvingKey>keyPair.provingKey(), <VerifyingKey>keyPair.verifyingKey()];
+        } catch (e: any) {
+            logAndThrow(`Could not synthesize keys - error ${e.message}. Please ensure the program is valid and the inputs are correct.`);
+        }
+    }
+
+    /**
+     * Build a transaction to transfer credits to another account for later submission to the Aleo network
+     *
+     * @param {number} amount The amount of credits to transfer
+     * @param {string} recipient The recipient of the transfer
+     * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
+     * @param {number} fee The fee to pay for the transfer
+     * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
+     * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
+     * records for the transfer transaction
+     * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
+     * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
+     * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
+     * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
+     * @returns {Promise<string>} The transaction id of the transfer transaction
+     *
+     * @example
+     * // Create a new NetworkClient, KeyProvider, and RecordProvider
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for executions
+     * const programName = "hello_hello.aleo";
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * await programManager.initialize();
+     * const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
+     * const transaction = await programManager.networkClient.getTransaction(tx_id);
+     */
+    async buildTransferTransaction(
+        amount: number,
+        recipient: string,
+        transferType: string,
+        fee: number,
+        privateFee: boolean,
+        recordSearchParams?: RecordSearchParams,
+        amountRecord?: RecordPlaintext | string,
+        feeRecord?: RecordPlaintext | string,
+        privateKey?: PrivateKey,
+        offlineQuery?: OfflineQuery
+    ): Promise<Transaction> {
+        // Validate the transfer type
+        transferType = <string>validateTransferType(transferType);
+
+        // Get the private key from the account if it is not provided in the parameters
+        let executionPrivateKey = privateKey;
+        if (typeof executionPrivateKey === "undefined" && typeof this.account !== "undefined") {
+            executionPrivateKey = this.account.privateKey();
+        }
+
+        if (typeof executionPrivateKey === "undefined") {
+            throw("No private key provided and no private key set in the ProgramManager");
+        }
+
+        // Get the proving and verifying keys from the key provider
+        let feeKeys;
+        let transferKeys
+        try {
+            feeKeys = privateFee ? <FunctionKeyPair>await this.keyProvider.feePrivateKeys() : <FunctionKeyPair>await this.keyProvider.feePublicKeys();
+            transferKeys = <FunctionKeyPair>await this.keyProvider.transferKeys(transferType);
+        } catch (e: any) {
+            logAndThrow(`Error finding fee keys. Key finder response: '${e.message}'. Please ensure your key provider is configured correctly.`);
+        }
+        const [feeProvingKey, feeVerifyingKey] = feeKeys;
+        const [transferProvingKey, transferVerifyingKey] = transferKeys;
+
+        // Get the amount and fee record from the account if it is not provided in the parameters
+        try {
+            // Track the nonces of the records found so no duplicate records are used
+            const nonces: string[] = [];
+            if (requiresAmountRecord(transferType)) {
+                // If the transfer type is private and requires an amount record, get it from the record provider
+                amountRecord = <RecordPlaintext>await this.getCreditsRecord(fee, [], amountRecord, recordSearchParams);
+                nonces.push(amountRecord.nonce());
+            } else {
+                amountRecord = undefined;
+            }
+            feeRecord = privateFee ? <RecordPlaintext>await this.getCreditsRecord(fee, nonces, feeRecord, recordSearchParams) : undefined;
+        } catch (e: any) {
+            logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
+        }
+
+        // Build an execution transaction and submit it to the network
+        return await WasmProgramManager.buildTransferTransaction(executionPrivateKey, amount, recipient, transferType, amountRecord, fee, feeRecord, this.host, transferProvingKey, transferVerifyingKey, feeProvingKey, feeVerifyingKey, offlineQuery);
+    }
+
+    /**
+     * Build a transfer_public transaction to transfer credits to another account for later submission to the Aleo network
+     *
+     * @param {number} amount The amount of credits to transfer
+     * @param {string} recipient The recipient of the transfer
+     * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
+     * @param {number} fee The fee to pay for the transfer
+     * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
+     * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
+     * records for the transfer transaction
+     * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
+     * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
+     * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
+     * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
+     * @returns {Promise<string>} The transaction id of the transfer transaction
+     */
+    async buildTransferPublicTransaction(
+        amount: number,
+        recipient: string,
+        fee: number,
+        privateKey?: PrivateKey,
+        offlineQuery?: OfflineQuery
+    ): Promise<Transaction> {
+        return this.buildTransferTransaction(amount, recipient, "public", fee, false, undefined, undefined, undefined, privateKey, offlineQuery);
+    }
+
+    /**
+     * Build a transfer_public_as_signer transaction to transfer credits to another account for later submission to the Aleo network
+     *
+     * @param {number} amount The amount of credits to transfer
+     * @param {string} recipient The recipient of the transfer
+     * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
+     * @param {number} fee The fee to pay for the transfer
+     * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
+     * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
+     * records for the transfer transaction
+     * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
+     * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
+     * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
+     * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
+     * @returns {Promise<string>} The transaction id of the transfer transaction
+     */
+    async buildTransferPublicAsSignerTransaction(
+        amount: number,
+        recipient: string,
+        fee: number,
+        privateKey?: PrivateKey,
+        offlineQuery?: OfflineQuery
+    ): Promise<Transaction> {
+        return this.buildTransferTransaction(amount, recipient, "public", fee, false, undefined, undefined, undefined, privateKey, offlineQuery);
+    }
+
+    /**
+     * Transfer credits to another account
+     *
+     * @param {number} amount The amount of credits to transfer
+     * @param {string} recipient The recipient of the transfer
+     * @param {string} transferType The type of transfer to perform - options: 'private', 'privateToPublic', 'public', 'publicToPrivate'
+     * @param {number} fee The fee to pay for the transfer
+     * @param {boolean} privateFee Use a private record to pay the fee. If false this will use the account's public credit balance
+     * @param {RecordSearchParams | undefined} recordSearchParams Optional parameters for finding the amount and fee
+     * records for the transfer transaction
+     * @param {RecordPlaintext | string} amountRecord Optional amount record to use for the transfer
+     * @param {RecordPlaintext | string} feeRecord Optional fee record to use for the transfer
+     * @param {PrivateKey | undefined} privateKey Optional private key to use for the transfer transaction
+     * @param {OfflineQuery | undefined} offlineQuery Optional offline query if creating transactions in an offline environment
+     * @returns {Promise<string>} The transaction id of the transfer transaction
+     *
+     * @example
+     * // Create a new NetworkClient, KeyProvider, and RecordProvider
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // Initialize a program manager with the key provider to automatically fetch keys for executions
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * await programManager.initialize();
+     * const tx_id = await programManager.transfer(1, "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "private", 0.2)
+     * const transaction = await programManager.networkClient.getTransaction(tx_id);
+     */
+    async transfer(
+        amount: number,
+        recipient: string,
+        transferType: string,
+        fee: number,
+        privateFee: boolean,
+        recordSearchParams?: RecordSearchParams,
+        amountRecord?: RecordPlaintext | string,
+        feeRecord?: RecordPlaintext | string,
+        privateKey?: PrivateKey,
+        offlineQuery?: OfflineQuery
+    ): Promise<string> {
+        const tx = <Transaction>await this.buildTransferTransaction(amount, recipient, transferType, fee, privateFee, recordSearchParams, amountRecord, feeRecord, privateKey, offlineQuery);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Build transaction to bond credits to a validator for later submission to the Aleo Network
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("YourPrivateKey"));
+     *
+     * // Create the bonding transaction object for later submission
+     * const tx = await programManager.buildBondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+     * console.log(tx);
+     *
+     * // The transaction can be later submitted to the network using the network client.
+     * const result = await programManager.networkClient.submitTransaction(tx);
+     *
+     * @returns string
+     * @param {string} staker_address Address of the staker who is bonding the credits
+     * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the
+     * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
+     * requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing
+     * validator and is different from the address of the executor of this function, it will bond the credits to that
+     * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
+     * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
+     * @param {number} amount The amount of credits to bond
+     * @param {Partial<ExecuteOptions>} options - Override default execution options.
+     */
+    async buildBondPublicTransaction(staker_address: string, validator_address: string, withdrawal_address: string, amount: number, options: Partial<ExecuteOptions> = {}) {
+        const scaledAmount = Math.trunc(amount * 1000000);
+
+        const {
+            programName = "credits.aleo",
+            functionName = "bond_public",
+            fee = options.fee || 0.86,
+            privateFee = false,
+            inputs = [staker_address, validator_address, withdrawal_address, `${scaledAmount.toString()}u64`],
+            keySearchParams = new AleoKeyProviderParams({
+                proverUri: CREDITS_PROGRAM_KEYS.bond_public.prover,
+                verifierUri: CREDITS_PROGRAM_KEYS.bond_public.verifier,
+                cacheKey: "credits.aleo/bond_public"
+            }),
+            program = this.creditsProgram(),
+            ...additionalOptions
+        } = options;
+
+        const executeOptions: ExecuteOptions = {
+            programName,
+            functionName,
+            fee,
+            privateFee,
+            inputs,
+            keySearchParams,
+            ...additionalOptions
+        };
+
+        return await this.buildExecutionTransaction(executeOptions);
+    }
+
+    /**
+     * Bond credits to validator.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("YourPrivateKey"));
+     *
+     * // Create the bonding transaction
+     * const tx_id = await programManager.bondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", "aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+     *
+     * @returns string
+     * @param {string} staker_address Address of the staker who is bonding the credits
+     * @param {string} validator_address Address of the validator to bond to, if this address is the same as the signer (i.e. the
+     * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
+     * requires a minimum of 1,000,000 credits to bond (subject to change). If the address is specified is an existing
+     * validator and is different from the address of the executor of this function, it will bond the credits to that
+     * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
+     * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
+     * @param {number} amount The amount of credits to bond
+     * @param {Options} options Options for the execution
+     */
+    async bondPublic(staker_address: string, validator_address: string, withdrawal_address:string, amount: number, options: Partial<ExecuteOptions> = {}) {
+        const tx = <Transaction>await this.buildBondPublicTransaction(staker_address, validator_address, withdrawal_address, amount, options);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Build a bond_validator transaction for later submission to the Aleo Network.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("YourPrivateKey"));
+     *
+     * // Create the bond validator transaction object for later use.
+     * const tx = await programManager.buildBondValidatorTransaction("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+     * console.log(tx);
+     *
+     * // The transaction can later be submitted to the network using the network client.
+     * const tx_id = await programManager.networkClient.submitTransaction(tx);
+     *
+     * @returns string
+     * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the
+     * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
+     * requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing
+     * validator and is different from the address of the executor of this function, it will bond the credits to that
+     * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
+     * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
+     * @param {number} amount The amount of credits to bond
+     * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
+     * @param {Partial<ExecuteOptions>} options - Override default execution options.
+     */
+    async buildBondValidatorTransaction(validator_address: string, withdrawal_address: string, amount: number, commission: number, options: Partial<ExecuteOptions> = {}) {
+        const scaledAmount = Math.trunc(amount * 1000000);
+
+        const adjustedCommission = Math.trunc(commission)
+
+        const {
+            programName = "credits.aleo",
+            functionName = "bond_validator",
+            fee = options.fee || 0.86,
+            privateFee = false,
+            inputs = [validator_address, withdrawal_address, `${scaledAmount.toString()}u64`, `${adjustedCommission.toString()}u8`],
+            keySearchParams = new AleoKeyProviderParams({
+                proverUri: CREDITS_PROGRAM_KEYS.bond_validator.prover,
+                verifierUri: CREDITS_PROGRAM_KEYS.bond_validator.verifier,
+                cacheKey: "credits.aleo/bond_validator"
+            }),
+            program = this.creditsProgram(),
+            ...additionalOptions
+        } = options;
+
+        const executeOptions: ExecuteOptions = {
+            programName,
+            functionName,
+            fee,
+            privateFee,
+            inputs,
+            keySearchParams,
+            ...additionalOptions
+        };
+
+        return await this.buildExecutionTransaction(executeOptions);
+    }
+
+    /**
+     * Build transaction to bond a validator.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("YourPrivateKey"));
+     *
+     * // Create the bonding transaction
+     * const tx_id = await programManager.bondValidator("aleo1rhgdu77hgyqd3xjj8ucu3jj9r2krwz6mnzyd80gncr5fxcwlh5rsvzp9px", "aleo1feya8sjy9k2zflvl2dx39pdsq5tju28elnp2ektnn588uu9ghv8s84msv9", 2000000);
+     *
+     * @returns string
+     * @param {string} validator_address Address of the validator to bond to, if this address is the same as the staker (i.e. the
+     * executor of this function), it will attempt to bond the credits as a validator. Bonding as a validator currently
+     * requires a minimum of 10,000,000 credits to bond (subject to change). If the address is specified is an existing
+     * validator and is different from the address of the executor of this function, it will bond the credits to that
+     * validator's staking committee as a delegator. A minimum of 10 credits is required to bond as a delegator.
+     * @param {string} withdrawal_address Address to withdraw the staked credits to when unbond_public is called.
+     * @param {number} amount The amount of credits to bond
+     * @param {number} commission The commission rate for the validator (must be between 0 and 100 - an error will be thrown if it is not)
+     * @param {Partial<ExecuteOptions>} options - Override default execution options.
+     */
+    async bondValidator(validator_address: string, withdrawal_address: string, amount: number, commission: number, options: Partial<ExecuteOptions> = {}) {
+        const tx = <Transaction>await this.buildBondValidatorTransaction(validator_address, withdrawal_address, amount, commission, options);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Build a transaction to unbond public credits from a validator in the Aleo network.
+     *
+     * @param {string} staker_address - The address of the staker who is unbonding the credits.
+     * @param {number} amount - The amount of credits to unbond (scaled by 1,000,000).
+     * @param {Partial<ExecuteOptions>} options - Override default execution options.
+     * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.
+     *
+     * @example
+     * // Create a keyProvider to handle key management.
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to unbond credits.
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * const tx = await programManager.buildUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 2000000);
+     * console.log(tx);
+     *
+     * // The transaction can be submitted later to the network using the network client.
+     * programManager.networkClient.submitTransaction(tx);
+     */
+    async buildUnbondPublicTransaction(staker_address: string, amount: number, options: Partial<ExecuteOptions> = {}): Promise<Transaction> {
+        const scaledAmount = Math.trunc(amount * 1000000);
+
+        const {
+            programName = "credits.aleo",
+            functionName = "unbond_public",
+            fee = options.fee || 1.3,
+            privateFee = false,
+            inputs = [staker_address, `${scaledAmount.toString()}u64`],
+            keySearchParams = new AleoKeyProviderParams({
+                proverUri: CREDITS_PROGRAM_KEYS.unbond_public.prover,
+                verifierUri: CREDITS_PROGRAM_KEYS.unbond_public.verifier,
+                cacheKey: "credits.aleo/unbond_public"
+            }),
+            program = this.creditsProgram(),
+            ...additionalOptions
+        } = options;
+
+        const executeOptions: ExecuteOptions = {
+            programName,
+            functionName,
+            fee,
+            privateFee,
+            inputs,
+            keySearchParams,
+            ...additionalOptions
+        };
+
+        return this.buildExecutionTransaction(executeOptions);
+    }
+
+    /**
+     * Unbond a specified amount of staked credits.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("YourPrivateKey"));
+     *
+     * // Create the bonding transaction and send it to the network
+     * const tx_id = await programManager.unbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j", 10);
+     *
+     * @returns string
+     * @param {string} staker_address Address of the staker who is unbonding the credits
+     * @param {number} amount Amount of credits to unbond. If the address of the executor of this function is an
+     * existing validator, it will subtract this amount of credits from the validator's staked credits. If there are
+     * less than 1,000,000 credits staked pool after the unbond, the validator will be removed from the validator set.
+     * If the address of the executor of this function is not a validator and has credits bonded as a delegator, it will
+     * subtract this amount of credits from the delegator's staked credits. If there are less than 10 credits bonded
+     * after the unbond operation, the delegator will be removed from the validator's staking pool.
+     * @param {ExecuteOptions} options Options for the execution
+     */
+    async unbondPublic(staker_address: string, amount: number, options: Partial<ExecuteOptions> = {}): Promise<string> {
+        const tx = <Transaction>await this.buildUnbondPublicTransaction(staker_address, amount, options);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Build a transaction to claim unbonded public credits in the Aleo network.
+     *
+     * @param {string} staker_address - The address of the staker who is claiming the credits.
+     * @param {Partial<ExecuteOptions>} options - Override default execution options.
+     * @returns {Promise<Transaction>} - A promise that resolves to the transaction or an error message.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to claim unbonded credits.
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     *
+     * // Create the claim unbonded transaction object for later use.
+     * const tx = await programManager.buildClaimUnbondPublicTransaction("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
+     * console.log(tx);
+     *
+     * // The transaction can be submitted later to the network using the network client.
+     * programManager.networkClient.submitTransaction(tx);
+     */
+    async buildClaimUnbondPublicTransaction(staker_address: string, options: Partial<ExecuteOptions> = {}): Promise<Transaction> {
+        const {
+            programName = "credits.aleo",
+            functionName = "claim_unbond_public",
+            fee = options.fee || 2,
+            privateFee = false,
+            inputs = [staker_address],
+            keySearchParams = new AleoKeyProviderParams({
+                proverUri: CREDITS_PROGRAM_KEYS.claim_unbond_public.prover,
+                verifierUri: CREDITS_PROGRAM_KEYS.claim_unbond_public.verifier,
+                cacheKey: "credits.aleo/claim_unbond_public"
+            }),
+            program = this.creditsProgram(),
+            ...additionalOptions
+        } = options;
+
+        const executeOptions: ExecuteOptions = {
+            programName,
+            functionName,
+            fee,
+            privateFee,
+            inputs,
+            keySearchParams,
+            ...additionalOptions
+        };
+
+        return await this.buildExecutionTransaction(executeOptions);
+    }
+
+    /**
+     * Claim unbonded credits. If credits have been unbonded by the account executing this function, this method will
+     * claim them and add them to the public balance of the account.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("YourPrivateKey"));
+     *
+     * // Create the bonding transaction
+     * const tx_id = await programManager.claimUnbondPublic("aleo1jx8s4dvjepculny4wfrzwyhs3tlyv65r58ns3g6q2gm2esh7ps8sqy9s5j");
+     *
+     * @param {string} staker_address Address of the staker who is claiming the credits
+     * @param {ExecuteOptions} options
+     * @returns string
+     */
+    async claimUnbondPublic(staker_address: string, options: Partial<ExecuteOptions> = {}): Promise<string> {
+        const tx = <Transaction>await this.buildClaimUnbondPublicTransaction(staker_address, options);
+        return await this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Build a set_validator_state transaction for later usage.
+     *
+     * This function allows a validator to set their state to be either opened or closed to new stakers.
+     * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.
+     * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.
+     *
+     * This function serves two primary purposes:
+     * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.
+     * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("ValidatorPrivateKey"));
+     *
+     * // Create the bonding transaction
+     * const tx = await programManager.buildSetValidatorStateTransaction(true);
+     *
+     * // The transaction can be submitted later to the network using the network client.
+     * programManager.networkClient.submitTransaction(tx);
+     *
+     * @returns string
+     * @param {boolean} validator_state
+     * @param {Partial<ExecuteOptions>} options - Override default execution options
+     */
+    async buildSetValidatorStateTransaction(validator_state: boolean, options: Partial<ExecuteOptions> = {}) {
+        const {
+            programName = "credits.aleo",
+            functionName = "set_validator_state",
+            fee = 1,
+            privateFee = false,
+            inputs = [validator_state.toString()],
+            keySearchParams = new AleoKeyProviderParams({
+                proverUri: CREDITS_PROGRAM_KEYS.set_validator_state.prover,
+                verifierUri: CREDITS_PROGRAM_KEYS.set_validator_state.verifier,
+                cacheKey: "credits.aleo/set_validator_state"
+            }),
+            ...additionalOptions
+        } = options;
+
+        const executeOptions: ExecuteOptions = {
+            programName,
+            functionName,
+            fee,
+            privateFee,
+            inputs,
+            keySearchParams,
+            ...additionalOptions
+        };
+
+        return await this.execute(executeOptions);
+    }
+
+    /**
+     * Submit a set_validator_state transaction to the Aleo Network.
+     *
+     * This function allows a validator to set their state to be either opened or closed to new stakers.
+     * When the validator is open to new stakers, any staker (including the validator) can bond or unbond from the validator.
+     * When the validator is closed to new stakers, existing stakers can still bond or unbond from the validator, but new stakers cannot bond.
+     *
+     * This function serves two primary purposes:
+     * 1. Allow a validator to leave the committee, by closing themselves to stakers and then unbonding all of their stakers.
+     * 2. Allow a validator to maintain their % of stake, by closing themselves to allowing more stakers to bond to them.
+     *
+     * @example
+     * // Create a keyProvider to handle key management
+     * const keyProvider = new AleoKeyProvider();
+     * keyProvider.useCache = true;
+     *
+     * // Create a new ProgramManager with the key that will be used to bond credits
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, undefined);
+     * programManager.setAccount(new Account("ValidatorPrivateKey"));
+     *
+     * // Create the bonding transaction
+     * const tx_id = await programManager.setValidatorState(true);
+     *
+     * @returns string
+     * @param {boolean} validator_state
+     * @param {Partial<ExecuteOptions>} options - Override default execution options
+     */
+    async setValidatorState(validator_state: boolean, options: Partial<ExecuteOptions> = {}) {
+        const tx = <string>await this.buildSetValidatorStateTransaction(validator_state, options);
+        return this.networkClient.submitTransaction(tx);
+    }
+
+    /**
+     * Verify a proof of execution from an offline execution
+     *
+     * @param {executionResponse} executionResponse
+     * @returns {boolean} True if the proof is valid, false otherwise
+     */
+    verifyExecution(executionResponse: ExecutionResponse): boolean {
+        try {
+            const execution = <FunctionExecution>executionResponse.getExecution();
+            const function_id = executionResponse.getFunctionId();
+            const program = executionResponse.getProgram();
+            const verifyingKey = executionResponse.getVerifyingKey();
+            return verifyFunctionExecution(execution, verifyingKey, program, function_id);
+        } catch(e) {
+            console.warn("The execution was not found in the response, cannot verify the execution");
+            return false;
+        }
+    }
+
+    /**
+     * Create a program object from a program's source code
+     *
+     * @param {string} program Program source code
+     * @returns {Program} The program object
+     */
+    createProgramFromSource(program: string): Program {
+        return Program.fromString(program);
+    }
+
+    /**
+     * Get the credits program object
+     *
+     * @returns {Program} The credits program object
+     */
+    creditsProgram(): Program {
+        return Program.getCreditsProgram();
+    }
+
+    /**
+     * Verify a program is valid
+     *
+     * @param {string} program The program source code
+     */
+    verifyProgram(program: string): boolean {
+        try {
+            <Program>Program.fromString(program);
+            return true;
+        } catch (e) {
+            return false;
+        }
+    }
+
+    // Internal utility function for getting a credits.aleo record
+    async getCreditsRecord(amount: number, nonces: string[], record?: RecordPlaintext | string, params?: RecordSearchParams): Promise<RecordPlaintext> {
+        try {
+            return record instanceof RecordPlaintext ? record : RecordPlaintext.fromString(<string>record);
+        } catch (e) {
+            try {
+                const recordProvider = <RecordProvider>this.recordProvider;
+                return <RecordPlaintext>(await recordProvider.findCreditsRecord(amount, true, nonces, params))
+            } catch (e: any) {
+                logAndThrow(`Error finding fee record. Record finder response: '${e.message}'. Please ensure you're connected to a valid Aleo network and a record with enough balance exists.`);
+            }
+        }
+    }
+}
+
+// Ensure the transfer type requires an amount record
+function requiresAmountRecord(transferType: string): boolean {
+    return PRIVATE_TRANSFER_TYPES.has(transferType);
+}
+
+// Validate the transfer type
+function validateTransferType(transferType: string): string {
+    return VALID_TRANSFER_TYPES.has(transferType) ? transferType :
+        logAndThrow(`Invalid transfer type '${transferType}'. Valid transfer types are 'private', 'privateToPublic', 'public', and 'publicToPrivate'.`);
+}
+
+export { ProgramManager }
+
\ No newline at end of file diff --git a/sdk/docs/record-provider.ts.html b/sdk/docs/record-provider.ts.html new file mode 100644 index 000000000..d1baceb6f --- /dev/null +++ b/sdk/docs/record-provider.ts.html @@ -0,0 +1,306 @@ +Source: record-provider.ts
On this page

record-provider.ts

import { RecordPlaintext } from "./wasm";
+import { logAndThrow } from "./utils";
+import { Account } from "./account";
+import { AleoNetworkClient } from "./network-client";
+
+/**
+ * Interface for record search parameters. This allows for arbitrary search parameters to be passed to record provider
+ * implementations.
+ */
+interface RecordSearchParams {
+    [key: string]: any; // This allows for arbitrary keys with any type values
+}
+
+/**
+ * Interface for a record provider. A record provider is used to find records for use in deployment and execution
+ * transactions on the Aleo Network. A default implementation is provided by the NetworkRecordProvider class. However,
+ * a custom implementation can be provided (say if records are synced locally to a database from the network) by
+ * implementing this interface.
+ */
+interface RecordProvider {
+    account: Account
+
+    /**
+     * Find a credits.aleo record with a given number of microcredits from the chosen provider
+     *
+     * @param {number} microcredits The number of microcredits to search for
+     * @param {boolean} unspent Whether or not the record is unspent
+     * @param {string[]} nonces Nonces of records already found so they are not found again
+     * @param {RecordSearchParams} searchParameters Additional parameters to search for
+     * @returns {Promise<RecordPlaintext>} The record if found, otherwise an error
+     *
+     * @example
+     * // A class implementing record provider can be used to find a record with a given number of microcredits
+     * const record = await recordProvider.findCreditsRecord(5000, true, []);
+     *
+     * // When a record is found but not yet used, its nonce should be added to the nonces array so that it is not
+     * // found again if a subsequent search is performed
+     * const record2 = await recordProvider.findCreditsRecord(5000, true, [record.nonce()]);
+     *
+     * // When the program manager is initialized with the record provider it will be used to find automatically find
+     * // fee records and amount records for value transfers so that they do not need to be specified manually
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     */
+    findCreditsRecord(microcredits: number, unspent: boolean,  nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext>;
+
+    /**
+     * Find a list of credit.aleo records with a given number of microcredits from the chosen provider
+     *
+     * @param {number} microcreditAmounts A list of separate microcredit amounts to search for (e.g. [5000, 100000])
+     * @param {boolean} unspent Whether or not the record is unspent
+     * @param {string[]} nonces Nonces of records already found so that they are not found again
+     * @param {RecordSearchParams} searchParameters Additional parameters to search for
+     * @returns {Promise<RecordPlaintext[]>} A list of records with a value greater or equal to the amounts specified if such records exist, otherwise an error
+     *
+     * @example
+     * // A class implementing record provider can be used to find a record with a given number of microcredits
+     * const records = await recordProvider.findCreditsRecords([5000, 5000], true, []);
+     *
+     * // When a record is found but not yet used, it's nonce should be added to the nonces array so that it is not
+     * // found again if a subsequent search is performed
+     * const nonces = [];
+     * records.forEach(record => { nonces.push(record.nonce()) });
+     * const records2 = await recordProvider.findCreditsRecord(5000, true, nonces);
+     *
+     * // When the program manager is initialized with the record provider it will be used to find automatically find
+     * // fee records and amount records for value transfers so that they do not need to be specified manually
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     */
+    findCreditsRecords(microcreditAmounts: number[], unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]>;
+
+    /**
+     * Find an arbitrary record
+     * @param {boolean} unspent Whether or not the record is unspent
+     * @param {string[]} nonces Nonces of records already found so that they are not found again
+     * @param {RecordSearchParams} searchParameters Additional parameters to search for
+     * @returns {Promise<RecordPlaintext>} The record if found, otherwise an error
+     *
+     * @example
+     * // The RecordSearchParams interface can be used to create parameters for custom record searches which can then
+     * // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown
+     * // below.
+     *
+     * class CustomRecordSearch implements RecordSearchParams {
+     *     startHeight: number;
+     *     endHeight: number;
+     *     amount: number;
+     *     program: string;
+     *     recordName: string;
+     *     constructor(startHeight: number, endHeight: number, credits: number, maxRecords: number, programName: string, recordName: string) {
+     *         this.startHeight = startHeight;
+     *         this.endHeight = endHeight;
+     *         this.amount = amount;
+     *         this.program = programName;
+     *         this.recordName = recordName;
+     *     }
+     * }
+     *
+     * const params = new CustomRecordSearch(0, 100, 5000, "credits.aleo", "credits");
+     *
+     * const record = await recordProvider.findRecord(true, [], params);
+     */
+    findRecord(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext>;
+
+    /**
+     * Find multiple records from arbitrary programs
+     *
+     * @param {boolean} unspent Whether or not the record is unspent
+     * @param {string[]} nonces Nonces of records already found so that they are not found again
+     * @param {RecordSearchParams} searchParameters Additional parameters to search for
+     * @returns {Promise<RecordPlaintext>} The record if found, otherwise an error
+     *
+     * // The RecordSearchParams interface can be used to create parameters for custom record searches which can then
+     * // be passed to the record provider. An example of how this would be done for the credits.aleo program is shown
+     * // below.
+     *
+     * class CustomRecordSearch implements RecordSearchParams {
+     *     startHeight: number;
+     *     endHeight: number;
+     *     amount: number;
+     *     maxRecords: number;
+     *     programName: string;
+     *     recordName: string;
+     *     constructor(startHeight: number, endHeight: number, credits: number, maxRecords: number, programName: string, recordName: string) {
+     *         this.startHeight = startHeight;
+     *         this.endHeight = endHeight;
+     *         this.amount = amount;
+     *         this.maxRecords = maxRecords;
+     *         this.programName = programName;
+     *         this.recordName = recordName;
+     *     }
+     * }
+     *
+     * const params = new CustomRecordSearch(0, 100, 5000, 2, "credits.aleo", "credits");
+     * const records = await recordProvider.findRecord(true, [], params);
+     */
+    findRecords(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]>;
+}
+
+/**
+ * A record provider implementation that uses the official Aleo API to find records for usage in program execution and
+ * deployment, wallet functionality, and other use cases.
+ */
+class NetworkRecordProvider implements RecordProvider {
+    account: Account;
+    networkClient: AleoNetworkClient;
+    constructor(account: Account, networkClient: AleoNetworkClient) {
+        this.account = account;
+        this.networkClient = networkClient;
+    }
+
+    /**
+     * Set the account used to search for records
+     *
+     * @param {Account} account The account to use for searching for records
+     */
+    setAccount(account: Account) {
+        this.account = account;
+    }
+
+    /**
+     * Find a list of credit records with a given number of microcredits by via the official Aleo API
+     *
+     * @param {number[]} microcredits The number of microcredits to search for
+     * @param {boolean} unspent Whether or not the record is unspent
+     * @param {string[]} nonces Nonces of records already found so that they are not found again
+     * @param {RecordSearchParams} searchParameters Additional parameters to search for
+     * @returns {Promise<RecordPlaintext>} The record if found, otherwise an error
+     *
+     * @example
+     * // Create a new NetworkRecordProvider
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // The record provider can be used to find records with a given number of microcredits
+     * const record = await recordProvider.findCreditsRecord(5000, true, []);
+     *
+     * // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
+     * // found again if a subsequent search is performed
+     * const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
+     *
+     * // When the program manager is initialized with the record provider it will be used to find automatically find
+     * // fee records and amount records for value transfers so that they do not need to be specified manually
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     *
+     * */
+    async findCreditsRecords(microcredits: number[], unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]> {
+        let startHeight = 0;
+        let endHeight = 0;
+
+        if (searchParameters) {
+            if ("startHeight" in searchParameters && typeof searchParameters["endHeight"] == "number") {
+                startHeight = searchParameters["startHeight"];
+            }
+
+            if ("endHeight" in searchParameters && typeof searchParameters["endHeight"] == "number") {
+                endHeight = searchParameters["endHeight"];
+            }
+        }
+
+        // If the end height is not specified, use the current block height
+        if (endHeight == 0) {
+            const end = await this.networkClient.getLatestHeight();
+            endHeight = end;
+        }
+
+        // If the start height is greater than the end height, throw an error
+        if (startHeight >= endHeight) {
+            logAndThrow("Start height must be less than end height");
+        }
+
+        return await this.networkClient.findUnspentRecords(startHeight, endHeight, this.account.privateKey(), microcredits, undefined, nonces);
+    }
+
+    /**
+     * Find a credit record with a given number of microcredits by via the official Aleo API
+     *
+     * @param {number} microcredits The number of microcredits to search for
+     * @param {boolean} unspent Whether or not the record is unspent
+     * @param {string[]} nonces Nonces of records already found so that they are not found again
+     * @param {RecordSearchParams} searchParameters Additional parameters to search for
+     * @returns {Promise<RecordPlaintext>} The record if found, otherwise an error
+     *
+     * @example
+     * // Create a new NetworkRecordProvider
+     * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+     * const keyProvider = new AleoKeyProvider();
+     * const recordProvider = new NetworkRecordProvider(account, networkClient);
+     *
+     * // The record provider can be used to find records with a given number of microcredits
+     * const record = await recordProvider.findCreditsRecord(5000, true, []);
+     *
+     * // When a record is found but not yet used, it's nonce should be added to the nonces parameter so that it is not
+     * // found again if a subsequent search is performed
+     * const records = await recordProvider.findCreditsRecords(5000, true, [record.nonce()]);
+     *
+     * // When the program manager is initialized with the record provider it will be used to find automatically find
+     * // fee records and amount records for value transfers so that they do not need to be specified manually
+     * const programManager = new ProgramManager("https://api.explorer.provable.com/v1", keyProvider, recordProvider);
+     * programManager.transfer(1, "aleo166q6ww6688cug7qxwe7nhctjpymydwzy2h7rscfmatqmfwnjvggqcad0at", "public", 0.5);
+     */
+    async findCreditsRecord(microcredits: number, unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext> {
+        let records = null;
+
+        try {
+            records = await this.findCreditsRecords([microcredits], unspent, nonces, searchParameters);
+        } catch (e) {}
+
+        if (records && records.length > 0) {
+            return records[0];
+        }
+
+        console.error("Record not found with error:", records);
+        throw new Error("Record not found");
+    }
+
+    /**
+     * Find an arbitrary record. WARNING: This function is not implemented yet and will throw an error.
+     */
+    async findRecord(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext> {
+        throw new Error("Method not implemented.");
+    }
+
+    /**
+     * Find multiple arbitrary records. WARNING: This function is not implemented yet and will throw an error.
+     */
+    async findRecords(unspent: boolean, nonces?: string[], searchParameters?: RecordSearchParams): Promise<RecordPlaintext[]> {
+        throw new Error("Method not implemented.");
+    }
+
+}
+
+/**
+ * BlockHeightSearch is a RecordSearchParams implementation that allows for searching for records within a given
+ * block height range.
+ *
+ * @example
+ * // Create a new BlockHeightSearch
+ * const params = new BlockHeightSearch(89995, 99995);
+ *
+ * // Create a new NetworkRecordProvider
+ * const networkClient = new AleoNetworkClient("https://api.explorer.provable.com/v1");
+ * const keyProvider = new AleoKeyProvider();
+ * const recordProvider = new NetworkRecordProvider(account, networkClient);
+ *
+ * // The record provider can be used to find records with a given number of microcredits and the block height search
+ * // can be used to find records within a given block height range
+ * const record = await recordProvider.findCreditsRecord(5000, true, [], params);
+ *
+ */
+class BlockHeightSearch implements RecordSearchParams {
+    startHeight: number;
+    endHeight: number;
+    constructor(startHeight: number, endHeight: number) {
+        this.startHeight = startHeight;
+        this.endHeight = endHeight;
+    }
+}
+
+export { BlockHeightSearch, NetworkRecordProvider, RecordProvider, RecordSearchParams};
+
\ No newline at end of file diff --git a/sdk/docs/scripts/core.js b/sdk/docs/scripts/core.js index d5e5a4303..47ae5e7c8 100644 --- a/sdk/docs/scripts/core.js +++ b/sdk/docs/scripts/core.js @@ -11,12 +11,46 @@ var MIN_FONT_SIZE = 10; var localStorage = window.localStorage; function getTheme() { - var body = document.body; + var theme = localStorage.getItem(themeLocalStorageKey); + + if (theme) return theme; + + theme = document.body.getAttribute('data-theme'); + + switch (theme) { + case 'dark': + case 'light': + return theme; + case 'fallback-dark': + if ( + // eslint-disable-next-line no-undef + window.matchMedia('(prefers-color-scheme)').matches && + // eslint-disable-next-line no-undef + window.matchMedia('(prefers-color-scheme: light)').matches + ) { + return 'light'; + } + + return 'dark'; + + case 'fallback-light': + if ( + // eslint-disable-next-line no-undef + window.matchMedia('(prefers-color-scheme)').matches && + // eslint-disable-next-line no-undef + window.matchMedia('(prefers-color-scheme: dark)').matches + ) { + return 'dark'; + } - return body.getAttribute('data-theme'); + return 'light'; + + default: + return 'dark'; + } } -function updateTheme(theme) { +function localUpdateTheme(theme) { var body = document.body; var svgUse = document.querySelectorAll('.theme-svg-use'); var iconID = theme === 'dark' ? '#light-theme-icon' : '#dark-theme-icon'; @@ -28,7 +62,10 @@ function updateTheme(theme) { svgUse.forEach(function (svg) { svg.setAttribute('xlink:href', iconID); }); +} +function updateTheme(theme) { + localUpdateTheme(theme); localStorage.setItem(themeLocalStorageKey, theme); } @@ -44,17 +81,7 @@ function toggleTheme() { (function () { var theme = getTheme(); - var themeStoredInLocalStorage = localStorage.getItem(themeLocalStorageKey); - - if (themeStoredInLocalStorage) { - if (theme === themeStoredInLocalStorage) { - return; - } - - updateTheme(themeStoredInLocalStorage); - } else { - localStorage.setItem(themeLocalStorageKey, theme); - } + updateTheme(theme); })(); /** @@ -145,12 +172,15 @@ function bringElementIntoView(element, updateHistory = true) { /** * tocbotInstance is defined in layout.tmpl * It is defined when we are initializing tocbot. - * + * */ // eslint-disable-next-line no-undef if (tocbotInstance) { - // eslint-disable-next-line no-undef - setTimeout(() => tocbotInstance.updateTocListActiveElement(element), 60) + setTimeout( + // eslint-disable-next-line no-undef + () => tocbotInstance.updateTocListActiveElement(element), + 60 + ); } var navbar = document.querySelector('.navbar-container'); var body = document.querySelector('.main-content'); @@ -249,7 +279,6 @@ function addAnchor() { * @param {string} value */ function copy(value) { - console.log(value); const el = document.createElement('textarea'); el.value = value; @@ -401,9 +430,9 @@ function getFontSize() { return currentFontSize; } -function updateFontSize(fontSize) { +function localUpdateFontSize(fontSize) { html.style.fontSize = fontSize + 'px'; - localStorage.setItem(fontSizeLocalStorageKey, fontSize); + var fontSizeText = document.querySelector( '#b77a68a492f343baabea06fad81f651e' ); @@ -413,6 +442,11 @@ function updateFontSize(fontSize) { } } +function updateFontSize(fontSize) { + localUpdateFontSize(fontSize); + localStorage.setItem(fontSizeLocalStorageKey, fontSize); +} + (function () { var fontSize = getFontSize(); var fontSizeInLocalStorage = localStorage.getItem(fontSizeLocalStorageKey); @@ -452,8 +486,9 @@ function fontSizeTooltip() { return `
- ";return'
'+('
'+t.toLocaleUpperCase()+"
")+e+"
"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function updateFontSize(e){html.style.fontSize=e+"px",localStorage.setItem(fontSizeLocalStorageKey,e);var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function incrementFont(e){var t=getFontSize();ttocbotInstance.updateTocListActiveElement(e),60),o=document.querySelector(".navbar-container"),n=document.querySelector(".main-content"),i=e.getBoundingClientRect().top,c=16,o&&(c+=o.scrollHeight),n&&n.scrollBy(0,i-c),t&&history.pushState(null,null,"#"+e.id))}function bringLinkToView(e){e.preventDefault(),e.stopPropagation();var e=e.currentTarget.getAttribute("href");!e||(e=document.getElementById(e.slice(1)))&&bringElementIntoView(e)}function bringIdToViewOnMount(){var e,t;isSourcePage()||""!==(e=window.location.hash)&&((t=document.getElementById(e.slice(1)))||(e=decodeURI(e),t=document.getElementById(e.slice(1))),t&&bringElementIntoView(t,!1))}function createAnchorElement(e){var t=document.createElement("a");return t.textContent="#",t.href="#"+e,t.classList.add("link-anchor"),t.onclick=bringLinkToView,t}function addAnchor(){var e=document.querySelector(".main-content").querySelector("section");[e.querySelectorAll("h1"),e.querySelectorAll("h2"),e.querySelectorAll("h3"),e.querySelectorAll("h4")].forEach(function(e){e.forEach(function(e){var t=createAnchorElement(e.id);e.classList.add("has-anchor"),e.append(t)})})}function copy(e){const t=document.createElement("textarea");t.value=e,document.body.appendChild(t),t.select(),document.execCommand("copy"),document.body.removeChild(t)}function showTooltip(e){var t=document.getElementById(e);t.classList.add("show-tooltip"),setTimeout(function(){t.classList.remove("show-tooltip")},3e3)}function copyFunction(e){var t=document.getElementById(e);copy((t.querySelector(".linenums")||t.querySelector("code")).innerText.trim().replace(/(^\t)/gm,"")),showTooltip("tooltip-"+e)}function hideTocOnSourcePage(){isSourcePage()&&(document.querySelector(".toc-container").style.display="none")}function getPreTopBar(e,t=""){e='";return'
'+('
'+t.toLocaleUpperCase()+"
")+e+"
"}function getPreDiv(){var e=document.createElement("div");return e.classList.add("pre-div"),e}function processAllPre(){var e=document.querySelectorAll("pre"),t=document.querySelector("#PeOAagUepe"),o=document.querySelector("#VuAckcnZhf"),n=0,i=0,c=(t&&(i=t.getBoundingClientRect().height),o&&(n=o.getBoundingClientRect().height),window.innerHeight-n-i-250);e.forEach(function(e,t){var o,n=e.parentNode;n&&"true"===n.getAttribute("data-skip-pre-process")||(n=getPreDiv(),o=getPreTopBar(t="ScDloZOMdL"+t,e.getAttribute("data-lang")||"code"),n.innerHTML=o,e.style.maxHeight=c+"px",e.id=t,e.classList.add("prettyprint"),e.parentNode.insertBefore(n,e),n.appendChild(e))})}function highlightAndBringLineIntoView(){var e=window.location.hash.replace("#line","");try{var t='[data-line-number="'+e+'"',o=document.querySelector(t);o.scrollIntoView(),o.parentNode.classList.add("selected")}catch(e){console.error(e)}}function getFontSize(){var e=16;try{e=Number.parseInt(html.style.fontSize.split("px")[0],10)}catch(e){console.log(e)}return e}function localUpdateFontSize(e){html.style.fontSize=e+"px";var t=document.querySelector("#b77a68a492f343baabea06fad81f651e");t&&(t.innerHTML=e)}function updateFontSize(e){localUpdateFontSize(e),localStorage.setItem(fontSizeLocalStorageKey,e)}function incrementFont(e){var t=getFontSize();t
- `}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable(),addHrefToSidebarTitle()}!function(){var e=getTheme(),t=localStorage.getItem(themeLocalStorageKey);t?e!==t&&updateTheme(t):localStorage.setItem(themeLocalStorageKey,e)}(),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}); \ No newline at end of file + `}function initTooltip(){tippy(".theme-toggle",{content:"Toggle Theme",delay:500}),tippy(".search-button",{content:"Search",delay:500}),tippy(".font-size",{content:"Change font size",delay:500}),tippy(".codepen-button",{content:"Open code in CodePen",placement:"left"}),tippy(".copy-code",{content:"Copy this code",placement:"left"}),tippy(".font-size",{content:fontSizeTooltip(),trigger:"click",interactive:!0,allowHTML:!0,placement:"left"})}function fixTable(){for(const t of document.querySelectorAll("table")){if(t.classList.contains("hljs-ln"))return;var e=document.createElement("div");e.classList.add("table-div"),t.parentNode.insertBefore(e,t),e.appendChild(t)}}function hideMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.remove("show"),t&&t.setAttribute("data-isopen","false"),o&&o.setAttribute("xlink:href","#menu-icon")}function showMobileMenu(){var e=document.querySelector("#mobile-sidebar"),t=document.querySelector("#mobile-menu"),o=t.querySelector("use");e&&e.classList.add("show"),t&&t.setAttribute("data-isopen","true"),o&&o.setAttribute("xlink:href","#close-icon")}function onMobileMenuClick(){("true"===document.querySelector("#mobile-menu").getAttribute("data-isopen")?hideMobileMenu:showMobileMenu)()}function initMobileMenu(){var e=document.querySelector("#mobile-menu");e&&e.addEventListener("click",onMobileMenuClick)}function addHrefToSidebarTitle(){document.querySelectorAll(".sidebar-title-anchor").forEach(function(e){e.setAttribute("href",baseURL)})}function highlightActiveLinkInSidebar(){var e=document.location.href.split("/");const t=decodeURI(e[e.length-1]);let o=document.querySelector(`.sidebar a[href*='${t}']`);if(!o)try{o=document.querySelector(`.sidebar a[href*='${t.split("#")[0]}']`)}catch(e){return void console.error(e)}o&&(o.parentElement.classList.add("active"),o.scrollIntoView())}function onDomContentLoaded(){var e=document.querySelectorAll(".theme-toggle");initMobileMenu(),e&&e.forEach(function(e){e.addEventListener("click",toggleTheme)}),hljs.addPlugin({"after:highlightElement":function(e){e.el.parentNode.setAttribute("data-lang","code")}}),hljs.highlightAll(),hljs.initLineNumbersOnLoad({singleLine:!0}),initAccordion(),addAnchor(),processAllPre(),hideTocOnSourcePage(),setTimeout(function(){bringIdToViewOnMount(),isSourcePage()&&highlightAndBringLineIntoView()},1e3),initTooltip(),fixTable(),addHrefToSidebarTitle(),highlightActiveLinkInSidebar()}updateTheme(getTheme()),function(){var e=getFontSize(),t=localStorage.getItem(fontSizeLocalStorageKey);t?(t=Number.parseInt(t,10))!==e&&updateFontSize(t):updateFontSize(e)}(),window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",e=>{e=new URL(e.newURL);""!==e.hash&&bringIdToViewOnMount(e.hash)}),window.addEventListener("storage",e=>{"undefined"!==e.newValue&&(initTooltip(),e.key===themeLocalStorageKey&&localUpdateTheme(e.newValue),e.key===fontSizeLocalStorageKey&&localUpdateFontSize(e.newValue))}); \ No newline at end of file diff --git a/sdk/docs/scripts/search.min.js b/sdk/docs/scripts/search.min.js index c20e606b0..5358bced8 100644 --- a/sdk/docs/scripts/search.min.js +++ b/sdk/docs/scripts/search.min.js @@ -1,6 +1,6 @@ -const searchId="LiBfqbJVcV",searchHash="#"+searchId,searchContainer=document.querySelector("#PkfLWpAbet"),searchWrapper=document.querySelector("#iCxFxjkHbP"),searchCloseButton=document.querySelector("#VjLlGakifb"),searchInput=document.querySelector("#vpcKVYIppa"),resultBox=document.querySelector("#fWwVHRuDuN");function showResultText(e){resultBox.innerHTML=`${e}`}function hideSearch(){window.location.hash===searchHash&&history.go(-1),window.onhashchange=null,searchContainer&&(searchContainer.style.display="none")}function listenCloseKey(e){"Escape"===e.key&&(hideSearch(),window.removeEventListener("keyup",listenCloseKey))}function showSearch(){try{hideMobileMenu()}catch(e){console.error(e)}window.onhashchange=hideSearch,window.location.hash!==searchHash&&history.pushState(null,null,searchHash),searchContainer&&(searchContainer.style.display="flex",window.addEventListener("keyup",listenCloseKey)),searchInput&&searchInput.focus()}async function fetchAllData(){var{hostname:e,protocol:t,port:n}=location,t=t+"//"+e+(""!==n?":"+n:"")+baseURL,e=new URL("data/search.json",t);const a=await fetch(e);n=(await a.json()).list;return n}function onClickSearchItem(t){const n=t.currentTarget;if(n){const a=n.getAttribute("href")||"";t=a.split("#")[1]||"";let e=document.getElementById(t);e||(t=decodeURI(t),e=document.getElementById(t)),e&&setTimeout(function(){bringElementIntoView(e)},100)}}function buildSearchResult(e){let t="";var n=/(<([^>]+)>)/gi;for(const s of e){const{title:c="",description:i=""}=s.item;var a=s.item.link.replace('.*/,""),o=c.replace(n,""),r=i.replace(n,"");t+=` - -
${o}
-
${r||"No description available."}
-
+const searchId="LiBfqbJVcV",searchHash="#"+searchId,searchContainer=document.querySelector("#PkfLWpAbet"),searchWrapper=document.querySelector("#iCxFxjkHbP"),searchCloseButton=document.querySelector("#VjLlGakifb"),searchInput=document.querySelector("#vpcKVYIppa"),resultBox=document.querySelector("#fWwVHRuDuN");function showResultText(e){resultBox.innerHTML=`${e}`}function hideSearch(){window.location.hash===searchHash&&history.go(-1),window.onhashchange=null,searchContainer&&(searchContainer.style.display="none")}function listenCloseKey(e){"Escape"===e.key&&(hideSearch(),window.removeEventListener("keyup",listenCloseKey))}function showSearch(){try{hideMobileMenu()}catch(e){console.error(e)}window.onhashchange=hideSearch,window.location.hash!==searchHash&&history.pushState(null,null,searchHash),searchContainer&&(searchContainer.style.display="flex",window.addEventListener("keyup",listenCloseKey)),searchInput&&searchInput.focus()}async function fetchAllData(){var{hostname:e,protocol:t,port:n}=location,t=t+"//"+e+(""!==n?":"+n:"")+baseURL,e=new URL("data/search.json",t);const a=await fetch(e);n=(await a.json()).list;return n}function onClickSearchItem(t){const n=t.currentTarget;if(n){const a=n.getAttribute("href")||"";t=a.split("#")[1]||"";let e=document.getElementById(t);e||(t=decodeURI(t),e=document.getElementById(t)),e&&setTimeout(function(){bringElementIntoView(e)},100)}}function buildSearchResult(e){let t="";var n=/(<([^>]+)>)/gi;for(const s of e){const{title:c="",description:i=""}=s.item;var a=s.item.link.replace('.*/,""),o=c.replace(n,""),r=i.replace(n,"");t+=` + +
${o}
+
${r||"No description available."}
+
`}return t}function getSearchResult(e,t,n){var t={...{shouldSort:!0,threshold:.4,location:0,distance:100,maxPatternLength:32,minMatchCharLength:1,keys:t}},a=Fuse.createIndex(t.keys,e);const o=new Fuse(e,t,a),r=o.search(n);return 20{o=null,a||t.apply(this,e)},n),a&&!o&&t.apply(this,e)}}let searchData;async function search(e){e=e.target.value;if(resultBox)if(e){if(!searchData){showResultText("Loading...");try{searchData=await fetchAllData()}catch(e){return console.log(e),void showResultText("Failed to load result.")}}e=getSearchResult(searchData,["title","description"],e);e.length?resultBox.innerHTML=buildSearchResult(e):showResultText("No result found! Try some different combination.")}else showResultText("Type anything to view search result");else console.error("Search result container not found")}function onDomContentLoaded(){const e=document.querySelectorAll(".search-button");var t=debounce(search,300);searchCloseButton&&searchCloseButton.addEventListener("click",hideSearch),e&&e.forEach(function(e){e.addEventListener("click",showSearch)}),searchContainer&&searchContainer.addEventListener("click",hideSearch),searchWrapper&&searchWrapper.addEventListener("click",function(e){e.stopPropagation()}),searchInput&&searchInput.addEventListener("keyup",t),window.location.hash===searchHash&&showSearch()}window.addEventListener("DOMContentLoaded",onDomContentLoaded),window.addEventListener("hashchange",function(){window.location.hash===searchHash&&showSearch()}); \ No newline at end of file diff --git a/sdk/docs/sdk/docs/public/aleo.svg b/sdk/docs/sdk/docs/public/aleo.svg new file mode 100644 index 000000000..aba4ea2da --- /dev/null +++ b/sdk/docs/sdk/docs/public/aleo.svg @@ -0,0 +1,5 @@ + + + + + diff --git a/sdk/docs/styles/clean-jsdoc-theme-base.css b/sdk/docs/styles/clean-jsdoc-theme-base.css index 8a41c293a..070a022f2 100644 --- a/sdk/docs/styles/clean-jsdoc-theme-base.css +++ b/sdk/docs/styles/clean-jsdoc-theme-base.css @@ -1,46 +1,54 @@ @font-face { - font-family: 'heading'; - src: url('../fonts/WorkSans-Bold.ttf') format('truetype'); - font-display: swap; + font-display: swap; + font-family: 'heading'; + src: url('../fonts/WorkSans-Bold.ttf') format('truetype'); + } @font-face { - font-family: 'body'; - src: url('../fonts/OpenSans-Regular.ttf') format('truetype'); - font-display: swap; + font-display: swap; + font-family: 'body'; + src: url('../fonts/OpenSans-Regular.ttf') format('truetype'); + } @font-face { - font-family: 'code'; - src: url('../fonts/Inconsolata-Regular.ttf') format('truetype'); - font-display: swap; + font-display: swap; + font-family: 'code'; + src: url('../fonts/Inconsolata-Regular.ttf') format('truetype'); + } :root { - --outer-wrapper-max-width: 65rem; + --outer-wrapper-max-width: 65rem; + } * { - box-sizing: border-box; - margin: 0; - padding: 0; + box-sizing: border-box; + margin: 0; + padding: 0; + } html, body { - min-height: 100%; - width: 100%; - line-height: 1.75; + line-height: 1.75; + min-height: 100%; + width: 100%; + } body { - font-family: 'body'; - overflow-x: hidden; - position: relative; + font-family: 'body'; + overflow-x: hidden; + position: relative; + } b { - font-family: heading; + font-family: heading; + } h1, @@ -49,213 +57,258 @@ h3, h4, h5, h6 { - font-family: 'heading'; - font-weight: normal; - line-height: 1.75; + font-family: 'heading'; + font-weight: normal; + line-height: 1.75; + } h1 { - font-size: 3.5rem; - margin: 0; + font-size: 3.5rem; + margin: 0; + } h2 { - font-size: 2.25rem; - margin: 2rem 0 0; + font-size: 2.25rem; + margin: 2rem 0 0; + } h3 { - font-size: 1.5rem; + font-size: 1.5rem; + } h4 { - font-size: 1.25rem; + font-size: 1.25rem; + } h5 { - font-size: 1rem; + font-size: 1rem; + } h6 { - font-size: 1rem; + font-size: 1rem; + } img { - max-width: 100%; + max-width: 100%; + } a { - text-decoration: none; + text-decoration: none; + } a:hover { - text-decoration: underline; + text-decoration: underline; + } /* badges */ + a img { - margin-right: 0.5rem; + margin-right: 0.5rem; + } p { - margin: 1rem 0; + margin: 1rem 0; + } article ul { - list-style: none; + list-style: disc; } article ul li, article ol li { - padding: 0.5rem 0; + padding: 0.5rem 0; + } article ol, article ul { - padding-left: 3rem; + padding-left: 2rem; + } article ol p, article ul p { - margin: 0; + margin: 0; + } /* stylelint-disable-next-line */ .variation { - display: none; + display: none; + } .signature-attributes { - font-style: italic; - font-weight: lighter; + font-style: italic; + font-weight: lighter; + } .ancestors a { - text-decoration: none; + text-decoration: none; + } .important { - font-weight: bold; + font-weight: bold; + } .signature { - font-family: 'code'; + font-family: 'code'; + } .name { - font-family: 'code'; - font-weight: bold; + font-family: 'code'; + font-weight: bold; + } blockquote { - font-size: 0.875rem; - padding: 0.0625rem 1.25rem; - border-radius: 1rem; - margin: 0.5rem 0; + border-radius: 1rem; + font-size: 0.875rem; + margin: 0.5rem 0; + padding: 0.0625rem 1.25rem; + } .details { - border-radius: 1rem; - margin: 1rem 0; + border-radius: 1rem; + margin: 1rem 0; + } .details .details-item-container { - display: flex; - padding: 1rem 2rem; + display: flex; + padding: 1rem 2rem; + } dt { - font-family: heading; + font-family: heading; + } .details dt { - float: left; - min-width: 11rem; + float: left; + min-width: 11rem; + } .details ul { - margin: 0; - display: inline-flex; - list-style-type: none; + display: inline-flex; + list-style-type: none; + margin: 0; + } .details ul li { - display: inline-flex; - margin-right: 0.6125rem; - padding: 0; - word-break: break-word; + display: inline-flex; + margin-right: 0.6125rem; + padding: 0; + word-break: break-word; + } /* stylelint-disable-next-line */ .details ul li p { - margin: 0; + margin: 0; + } /* stylelint-disable */ .details pre.prettyprint { - margin: 0; + margin: 0; + } /* stylelint-enable */ .details .object-value { - padding-top: 0; + padding-top: 0; + } .description { - margin-bottom: 2rem; + margin-bottom: 2rem; + } .method-member-container table { - margin-top: 1rem; + margin-top: 1rem; + } .pre-div .hljs-ln { - margin: 0; + margin: 0; + } .code-caption { - font-size: 0.875rem; + font-size: 0.875rem; + } .prettyprint { - font-size: 0.875rem; - overflow: auto; + font-size: 0.875rem; + overflow: auto; + } +/* stylelint-disable-next-line selector-no-qualifying-type,rule-empty-line-before */ pre.prettyprint { - margin-top: 3rem; + margin-top: 3rem; + } .prettyprint.source { - width: inherit; + width: inherit; + } .prettyprint code { - display: block; - font-size: 1rem; - line-height: 1.75; - padding: 0 0 1rem; + display: block; + font-size: 1rem; + line-height: 1.75; + padding: 0 0 1rem; + } .prettyprint .compact { - padding: 0; + padding: 0; + } +/* stylelint-disable-next-line selector-no-qualifying-type,rule-empty-line-before */ h4.name { - margin-top: 0.5rem; + margin-top: 0.5rem; + } .params, .props, table { - border-collapse: separate; - border-spacing: 0 0.5rem; - border-radius: 0.5rem; - font-size: 0.875rem; - margin: 0; - width: 100%; + border-collapse: separate; + border-radius: 0.5rem; + border-spacing: 0 0.5rem; + font-size: 0.875rem; + margin: 0; + width: 100%; + } table td:first-child, @@ -263,8 +316,9 @@ table td:first-child, table thead th:first-child, .params thead th:first-child, .props thead th:first-child { - border-top-left-radius: 1rem; - border-bottom-left-radius: 1rem; + border-bottom-left-radius: 1rem; + border-top-left-radius: 1rem; + } table td:last-child, @@ -272,21 +326,24 @@ table td:last-child, table thead th:last-child, .params thead th:last-child, .props thead th:last-child { - border-top-right-radius: 1rem; - border-bottom-right-radius: 1rem; + border-bottom-right-radius: 1rem; + border-top-right-radius: 1rem; + } table th, .params th { - position: sticky; - top: 0; + position: sticky; + top: 0; + } .params .name, .props .name, .name code { - font-family: 'code'; - font-size: 1rem; + font-family: 'code'; + font-size: 1rem; + } .params td, @@ -295,681 +352,808 @@ table th, .props th, th, td { - display: table-cell; - margin: 0; - padding: 1rem 2rem; - text-align: left; - vertical-align: top; + display: table-cell; + margin: 0; + padding: 1rem 2rem; + text-align: left; + vertical-align: top; + } .params thead tr, .props thead tr { - font-weight: bold; + font-weight: bold; + } /* stylelint-disable */ .params .params thead tr, .props .props thead tr { - font-weight: bold; + font-weight: bold; + } .params td.description > p:first-child, .props td.description > p:first-child { - margin-top: 0; - padding-top: 0; + margin-top: 0; + padding-top: 0; + } .params td.description > p:last-child, .props td.description > p:last-child { - margin-bottom: 0; - padding-bottom: 0; + margin-bottom: 0; + padding-bottom: 0; + } dl.param-type { - margin-bottom: 1rem; - padding-bottom: 1rem; + margin-bottom: 1rem; + padding-bottom: 1rem; + } /* stylelint-enable */ .param-type dt, .param-type dd { - display: inline-block; + display: inline-block; + } .param-type dd { - font-family: 'code'; - font-size: 1rem; + font-family: 'code'; + font-size: 1rem; + } code { - border-radius: 0.3rem; - font-family: 'code'; - font-size: 1rem; - padding: 0.1rem 0.4rem; + border-radius: 0.3rem; + font-family: 'code'; + font-size: 1rem; + padding: 0.1rem 0.4rem; + } .mt-20 { - margin-top: 1.5rem; + margin-top: 1.5rem; + } .codepen-form { - bottom: 0; - position: absolute; - right: 0.6125rem; + bottom: 0; + position: absolute; + right: 0.6125rem; + } .body-wrapper { - display: flex; - flex-direction: column; - height: 100vh; - position: relative; + display: flex; + flex-direction: column; + height: 100vh; + position: relative; + } .sidebar-container { - position: fixed; - display: flex; - padding: 1rem; - top: 0; - bottom: 0; - left: 0; - width: 25rem; - z-index: 10; + bottom: 0; + display: flex; + left: 0; + padding: 1rem; + position: fixed; + top: 0; + width: 25rem; + z-index: 10; + } .sidebar { - border-radius: 1rem; - flex: 1; - padding: 1.5rem 0; - overflow: hidden; - display: flex; - flex-direction: column; + border-radius: 1rem; + display: flex; + flex: 1; + flex-direction: column; + overflow: hidden; + padding: 1.5rem 0; + } .sidebar-title { - margin: 0; - padding: 0 2rem; - text-decoration: none; - font-size: 1.5rem; - font-family: heading; + font-family: heading; + font-size: 1.5rem; + margin: 0 0 2rem; + padding: 0 2rem; + text-decoration: none; + } .sidebar-title:hover { - text-decoration: none; + text-decoration: none; + } .sidebar-items-container { - margin-top: 5rem; - overflow: auto; - flex: 1; - position: relative; + flex: 1; + overflow: auto; + position: relative; + } .sidebar-section-title { - padding: 0.5rem 2rem; - font-family: heading; - font-size: 1.25rem; - border-radius: 1rem; + border-radius: 1rem; + font-family: heading; + font-size: 1.25rem; + padding: 0.5rem 2rem; + } .with-arrow { - align-items: center; - cursor: pointer; - display: flex; + align-items: center; + cursor: pointer; + display: flex; + } .with-arrow div { - flex: 1; + flex: 1; + } .with-arrow svg { - height: 1rem; - width: 1rem; - transition: transform 0.3s; + height: 1rem; + transition: transform 0.3s; + width: 1rem; + } .with-arrow[data-isopen='true'] svg { - transform: rotate(180deg); + transform: rotate(180deg); + } .sidebar-section-children-container { - border-radius: 0.5rem; - overflow: hidden; + border-radius: 0.5rem; + overflow: hidden; + } .sidebar-section-children a { - display: block; - width: 100%; - padding: 0.25rem 2rem; + display: block; + padding: 0.25rem 2rem; + width: 100%; + } .sidebar-section-children a { - text-decoration: none; + text-decoration: none; + } .with-arrow[data-isopen='false'] + .sidebar-section-children-container { - height: 0; - overflow: hidden; + height: 0; + overflow: hidden; + } .with-arrow[data-isopen='true'] + .sidebar-section-children-container { - height: auto; + height: auto; + } .toc-container { - position: fixed; - top: 0; - right: 4rem; - bottom: 0; - width: 16rem; - z-index: 10; + bottom: 0; + position: fixed; + right: 4rem; + top: 0; + width: 16rem; + z-index: 10; + } .toc-content { - padding-top: 10rem; - display: flex; - flex-direction: column; - height: 100%; + display: flex; + flex-direction: column; + height: 100%; + padding-top: 10rem; + } +/* stylelint-disable-next-line selector-max-id,rule-empty-line-before */ #eed4d2a0bfd64539bb9df78095dec881 { - margin: 2rem 0; - flex: 1; - overflow: auto; + flex: 1; + margin: 2rem 0; + overflow: auto; + } .toc-list { - padding-left: 1rem; - list-style: none; + list-style: none; + padding-left: 1rem; + } .toc-link { - display: block; - white-space: nowrap; - overflow: hidden; - text-overflow: ellipsis; - width: 100%; + display: block; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; + width: 100%; + } .toc-link.is-active-link { - font-family: heading; + font-family: heading; + } .has-anchor { - position: relative; + position: relative; + } .link-anchor { - padding: 0 0.5rem; + padding: 0 0.5rem; + } .has-anchor .link-anchor { - position: absolute; - left: 0; - top: 0; - transform: translateX(-100%); - text-decoration: none; - visibility: hidden; + left: 0; + position: absolute; + text-decoration: none; + top: 0; + transform: translateX(-100%); + visibility: hidden; + } .has-anchor:hover .link-anchor { - visibility: visible; + visibility: visible; + } .navbar-container { - position: fixed; - z-index: 10; - top: 0; - left: 25rem; - right: 25rem; - height: 7rem; - padding-top: 1rem; - display: flex; - justify-content: center; + display: flex; + height: 7rem; + justify-content: center; + left: 25rem; + padding-top: 1rem; + position: fixed; + right: 25rem; + top: 0; + z-index: 10; + } .navbar { - display: flex; - padding: 1rem 4rem 1rem 2rem; - flex: 1; - max-width: var(--outer-wrapper-max-width); + display: flex; + flex: 1; + max-width: var(--outer-wrapper-max-width); + padding: 1rem 4rem 1rem 2rem; + } .navbar-left-items { - display: flex; - flex: 1; + display: flex; + flex: 1; + } .navbar-right-items { - display: flex; + display: flex; + } .icon-button svg { - height: 1rem; - width: 1rem; + height: 1rem; + width: 1rem; + } .icon-button { - background: transparent; - position: relative; - display: inline-flex; - border: 0; - padding: 0.5rem; - border-radius: 50%; - cursor: pointer; - transition: background 0.3s; + background: transparent; + border: 0; + border-radius: 50%; + cursor: pointer; + display: inline-flex; + padding: 0.5rem; + position: relative; + transition: background 0.3s; + } .navbar-right-item { - display: flex; - justify-content: center; - align-items: center; - margin: 0 0.25rem; + align-items: center; + display: flex; + justify-content: center; + margin: 0 0.25rem; + } .navbar-item { - border-radius: 0.5rem; - overflow: hidden; + border-radius: 0.5rem; + overflow: hidden; + } .navbar-item a { - display: inline-block; - padding: 1rem 2rem; - text-decoration: none; - transition: 0.3s; + display: inline-block; + padding: 1rem 2rem; + text-decoration: none; + transition: 0.3s; + } .font-size-tooltip { - display: flex; - align-items: center; - margin: 0 -0.5rem; + align-items: center; + display: flex; + margin: 0 -0.5rem; + } .font-size-tooltip .icon-button.disabled { - pointer-events: none; + pointer-events: none; + } .main-content { - position: relative; - flex: 1; - overflow: auto; - display: flex; - flex-direction: column; - align-items: center; - padding: 7rem 25rem 0; + align-items: center; + display: flex; + flex: 1; + flex-direction: column; + overflow: auto; + padding: 7rem 25rem 0; + position: relative; + } .main-wrapper { - width: 100%; - max-width: var(--outer-wrapper-max-width); - padding: 0 4rem 1rem; + max-width: var(--outer-wrapper-max-width); + padding: 0 4rem 1rem; + width: 100%; + } .p-h-n { - padding: 0.4rem 1rem; + padding: 0.4rem 1rem; + } .footer { - width: 100%; - margin: 5rem 0 0 0; - border-radius: 1rem; - font-size: 0.875rem; - display: flex; - justify-content: center; + border-radius: 1rem; + display: flex; + font-size: 0.875rem; + justify-content: center; + margin-top: 5rem; + width: 100%; + } .source-page + .footer { - margin-top: 3rem; + margin-top: 3rem; + } .footer .wrapper { - flex: 1; - padding: 1rem 2rem; - max-width: var(--outer-wrapper-max-width); + flex: 1; + max-width: var(--outer-wrapper-max-width); + padding: 1rem 2rem; + } pre { - position: relative; + position: relative; + } .hljs table td { - background: transparent; - padding: 0 0.6125rem; - line-height: 1.5; - border-radius: 0; + background: transparent; + border-radius: 0; + line-height: 1.5; + padding: 0 0.6125rem; + } .hljs .hljs-ln-numbers { - width: 2rem; - white-space: nowrap; - /* user-select: none; */ - padding-left: 1.5rem; + padding-left: 1.5rem; + user-select: none; + white-space: nowrap; + width: 2rem; + } .hljs-ln-line.hljs-ln-numbers::before { - content: attr(data-line-number); + content: attr(data-line-number); + } .pre-div { - position: relative; - border-radius: 1rem; - overflow: hidden; - margin: 2rem 0; + border-radius: 1rem; + margin: 2rem 0; + overflow: hidden; + position: relative; + } .pre-top-bar-container { - align-items: center; - display: flex; - justify-content: space-between; - left: 0; - padding: 0.3125rem 1.5rem; - position: absolute; - right: 0; - top: 0; + align-items: center; + display: flex; + justify-content: space-between; + left: 0; + padding: 0.3125rem 1.5rem; + position: absolute; + right: 0; + top: 0; + } .code-copy-icon-container { - align-items: center; - border-radius: 50%; - cursor: pointer; - display: flex; - height: 1.875rem; - justify-content: center; - transition: 0.3s; - width: 1.875rem; + align-items: center; + border-radius: 50%; + cursor: pointer; + display: flex; + height: 1.875rem; + justify-content: center; + transition: 0.3s; + width: 1.875rem; + } .code-copy-icon-container > div { - margin-top: 0.25rem; - position: relative; + margin-top: 0.25rem; + position: relative; + } .sm-icon { - height: 1rem; - width: 1rem; + height: 1rem; + width: 1rem; + } .code-lang-name { - font-family: 'body'; - font-size: 0.75rem; + font-family: 'body'; + font-size: 0.75rem; + } .tooltip { - border-radius: 0.3125rem; - opacity: 0; - padding: 0.1875rem 0.5rem; - position: absolute; - right: 2rem; - top: 0.3125rem; - transform: scale(0); - transition: 0.3s; + border-radius: 0.3125rem; + opacity: 0; + padding: 0.1875rem 0.5rem; + position: absolute; + right: 2rem; + top: 0.3125rem; + transform: scale(0); + transition: 0.3s; + } .show-tooltip { - opacity: 1; - transform: scale(1); + opacity: 1; + transform: scale(1); + } .allow-overflow { - overflow: auto; + overflow: auto; + } .bold { - font-family: heading; + font-family: heading; + } .search-container { - position: fixed; - top: 0; - bottom: 0; - right: 0; - left: 0; - justify-content: center; - z-index: 50; - align-items: flex-start; + align-items: flex-start; + bottom: 0; + justify-content: center; + left: 0; + position: fixed; + right: 0; + top: 0; + z-index: 50; + } .search-container .wrapper { - width: 100%; - max-width: 60rem; - padding: 4rem 2rem 2rem; - border-radius: 1rem; - margin: 3rem 25rem; - position: relative; + border-radius: 1rem; + margin: 3rem 25rem; + max-width: 60rem; + padding: 4rem 2rem 2rem; + position: relative; + width: 100%; + } .search-close-button { - position: absolute; - top: 1rem; - right: 1rem; + position: absolute; + right: 1rem; + top: 1rem; + } .search-result-c-text { - display: flex; - justify-content: center; - user-select: none; + display: flex; + justify-content: center; + user-select: none; + } .search-result-c { - min-height: 20rem; - max-height: 40rem; - overflow: auto; - padding: 2rem 0; + max-height: 40rem; + min-height: 20rem; + overflow: auto; + padding: 2rem 0; + } .search-box-c { - width: 100%; - position: relative; - display: flex; - align-items: center; + align-items: center; + display: flex; + position: relative; + width: 100%; + } .search-box-c svg { - height: 1.5rem; - width: 1.5rem; - position: absolute; - left: 1.5rem; + height: 1.5rem; + left: 1.5rem; + position: absolute; + width: 1.5rem; + } .search-input { - border: none; - border-radius: 1rem; - width: 100%; - flex: 1; - padding: 1rem 2rem 1rem 4rem; - font-family: body; - font-size: 1.25rem; + border: 0; + border-radius: 1rem; + flex: 1; + font-family: body; + font-size: 1.25rem; + padding: 1rem 2rem 1rem 4rem; + width: 100%; + } .search-result-item { - display: block; - text-decoration: none; - padding: 1rem; - border-radius: 1rem; - margin: 1rem 0; + border-radius: 1rem; + display: block; + margin: 1rem 0; + padding: 1rem; + text-decoration: none; + } .search-result-item:hover { - text-decoration: none; + text-decoration: none; + } .search-result-item:active { - text-decoration: none; + text-decoration: none; + } .search-result-item-title { - font-family: heading; - font-size: 1.5rem; - margin: 0; + font-family: heading; + font-size: 1.5rem; + margin: 0; + } .search-result-item-p { - font-size: 0.875rem; - margin: 0; + font-size: 0.875rem; + margin: 0; + } .mobile-menu-icon-container { - display: none; - position: fixed; - bottom: 1.5rem; - right: 2rem; - z-index: 30; + bottom: 1.5rem; + display: none; + position: fixed; + right: 2rem; + z-index: 30; + } .mobile-menu-icon-container .icon-button svg { - height: 2rem; - width: 2rem; + height: 2rem; + width: 2rem; + } .mobile-sidebar-container { - position: fixed; - top: 0; - right: 0; - left: 0; - bottom: 0; - padding: 1rem; - z-index: 25; + bottom: 0; + display: none; + left: 0; + padding: 1rem; + position: fixed; + right: 0; + top: 0; + z-index: 25; - display: none; } .mobile-sidebar-container.show { - display: block; + display: block; + } .mobile-sidebar-wrapper { - border-radius: 1rem; - height: 100%; - width: 100%; - display: flex; - flex-direction: column; - padding-top: 2rem; + border-radius: 1rem; + display: flex; + flex-direction: column; + height: 100%; + padding-top: 2rem; + width: 100%; + } .mobile-nav-links { - display: flex; - flex-wrap: wrap; - padding-top: 2rem; + display: flex; + flex-wrap: wrap; + padding-top: 2rem; + } .mobile-sidebar-items-c { - flex: 1; - overflow: auto; + flex: 1; + overflow: auto; + } .mobile-navbar-actions { - display: flex; - padding: 1rem; + display: flex; + padding: 1rem; + } .rel { - position: relative; + position: relative; + } .icon-button.codepen-button svg { - height: 1.5rem; - width: 1.5rem; + height: 1.5rem; + width: 1.5rem; + } .table-div { - width: 100%; - overflow: auto; -} + overflow: auto; + width: 100%; -.tag-default { - overflow: auto; } -/* scroll bar */ -::-webkit-scrollbar { - width: 0.3125rem; - height: 0.3125rem; -} +.tag-default { + overflow: auto; -::-webkit-scrollbar-thumb, -::-webkit-scrollbar-track { - border-radius: 1rem; } @media screen and (max-width: 100em) { - .toc-container { + + .toc-container { display: none; - } - .main-content { - padding: 7rem 0 0 25rem; - } +} + +.main-content { + padding: 7rem 0 0 25rem; - .search-container .wrapper { - margin-right: 1rem; - } +} - .navbar-container { - /* For scrollbar */ +.search-container .wrapper { + margin-right: 1rem; + +} + +.navbar-container { + /* For scrollbar */ right: 1rem; - } + +} + } @media screen and (min-width: 65em) { - .mobile-sidebar-container.show { + + .mobile-sidebar-container.show { display: none; - } + +} + } @media screen and (max-width: 65em) { - h1 { + + h1 { font-size: 3rem; - } - h2 { - font-size: 2rem; - } +} + +h2 { + font-size: 2rem; + +} - h3 { - font-size: 1.875; - } +h3 { + font-size: 1.875; - h4, +} + +h4, h5, h6 { - font-size: 1rem; - } + font-size: 1rem; - .main-wrapper { - padding: 0 1rem 1rem; - } +} - .search-result-c { - max-height: 25rem; - } +.main-wrapper { + padding: 0 1rem 1rem; - .mobile-menu-icon-container { - display: block; - } +} - .sidebar-container { - display: none; - } +.search-result-c { + max-height: 25rem; - .search-container .wrapper { - margin-left: 1rem; - } +} - .main-content { - padding-left: 0; - padding-top: 1rem; - } +.mobile-menu-icon-container { + display: block; - .navbar-container { - display: none; - } +} + +.sidebar-container { + display: none; + +} + +.search-container .wrapper { + margin-left: 1rem; + +} + +.main-content { + padding-left: 0; + padding-top: 1rem; + +} - .source-page + .footer, +.navbar-container { + display: none; + +} + +.source-page + .footer, .footer { - margin-top: 2rem; - } + margin-top: 2rem; - .has-anchor:hover .link-anchor { - visibility: hidden; - } } + +.has-anchor:hover .link-anchor { + visibility: hidden; + +} + +} + +.child-tutorial-container { + display: flex; + flex-direction: row; + flex-wrap: wrap; + +} + +.child-tutorial { + border: 1px solid; + border-radius: 10px; + display: block; + margin: 5px; + padding: 10px 16px; + +} + +.child-tutorial:hover { + text-decoration: none; + +} + diff --git a/sdk/docs/styles/clean-jsdoc-theme-dark.css b/sdk/docs/styles/clean-jsdoc-theme-dark.css index 63de899cc..78cc519b2 100644 --- a/sdk/docs/styles/clean-jsdoc-theme-dark.css +++ b/sdk/docs/styles/clean-jsdoc-theme-dark.css @@ -10,7 +10,7 @@ body { a, a:active { - color: #00bbff; + color: #0bf; } hr { @@ -43,6 +43,8 @@ h6 { background: #252525; } + + .with-arrow { fill: #999; } @@ -51,6 +53,10 @@ h6 { background: #292929; } +.sidebar-section-children.active { + background: #444; +} + .sidebar-section-children a:hover { background: #2c2c2c; } @@ -86,8 +92,8 @@ h6 { } .navbar-item a:active { - color: #aaa; background-color: #222; + color: #aaa; } .navbar-item:hover { @@ -105,8 +111,8 @@ h6 { .toc-link { color: #777; - transition: color 0.3s; font-size: 0.875rem; + transition: color 0.3s; } .toc-link.is-active-link { @@ -193,7 +199,6 @@ samp { color: #eee; } -/* stylelint-enable */ table .name, .params .name, @@ -396,12 +401,12 @@ blockquote { background: #222; } -/* scroll bar */ -::-webkit-scrollbar-track { - background: #333; + +.child-tutorial { + border-color: #555; + color: #f3f3f3; } -::-webkit-scrollbar-thumb { - background: #555; - outline: 0.06125rem solid #555; +.child-tutorial:hover { + background: #222; } diff --git a/sdk/docs/styles/clean-jsdoc-theme-light.css b/sdk/docs/styles/clean-jsdoc-theme-light.css index a900941ef..ee47d2a7d 100644 --- a/sdk/docs/styles/clean-jsdoc-theme-light.css +++ b/sdk/docs/styles/clean-jsdoc-theme-light.css @@ -1,20 +1,25 @@ .light ::selection { - background: #ffce76; - color: #1d1919; + background: #ffce76; + color: #1d1919; + } +/* stylelint-disable-next-line selector-no-qualifying-type,rule-empty-line-before */ body.light { - background-color: #fff; - color: #111; + background-color: #fff; + color: #111; + } .light a, .light a:active { - color: #007bff; + color: #007bff; + } .light hr { - color: #f7f7f7; + color: #f7f7f7; + } .light h1, @@ -23,231 +28,293 @@ body.light { .light h4, .light h5, .light h6 { - color: #111; + color: #111; + } .light .sidebar { - background-color: #f7f7f7; - color: #222; + background-color: #f7f7f7; + color: #222; + } .light .sidebar-title { - color: #222; + color: #222; + } .light .sidebar-section-title { - color: #222; + color: #222; + } -.light .sidebar-section-title:hover { - background: #eee; +.light .sidebar-section-title:hover, +.light .sidebar-section-title.active { + background: #eee; } + .light .with-arrow { - fill: #111; + fill: #111; + } .light .sidebar-section-children-container { - background: #eee; + background: #eee; +} + +.light .sidebar-section-children.active { + background: #ccc; } + + + .light .sidebar-section-children a:hover { - background: #e0e0e0; + background: #e0e0e0; + } .light .sidebar-section-children a { - color: #111; + color: #111; + } .light .navbar-container { - background: #fff; + background: #fff; + } .light .icon-button svg, .light .navbar-item a { - color: #222; - fill: #222; + color: #222; + fill: #222; + } .light .tippy-box { - background: #eee; - color: #111; + background: #eee; + color: #111; + } .light .tippy-arrow { - color: #f1f1f1; + color: #f1f1f1; + } +/* stylelint-disable-next-line selector-max-compound-selectors,rule-empty-line-before */ .light .font-size-tooltip .icon-button svg { - fill: #111; + fill: #111; + } +/* stylelint-disable-next-line selector-max-compound-selectors, rule-empty-line-before */ .light .font-size-tooltip .icon-button.disabled svg { - fill: #999; + fill: #999; + } .light .icon-button:hover { - background: #ddd; + background: #ddd; + } .light .icon-button:active { - background: #ccc; + background: #ccc; + } .light .navbar-item a:active { - color: #333; - background-color: #eee; + background-color: #eee; + color: #333; + } .light .navbar-item:hover { - background: #f7f7f7; + background: #f7f7f7; + } .light .footer { - background: #f7f7f7; - color: #111; + background: #f7f7f7; + color: #111; + } .light .footer a { - color: #111; + color: #111; + } .light .toc-link { - color: #999; - transition: color 0.3s; - font-size: 0.875rem; + color: #999; + font-size: 0.875rem; + transition: color 0.3s; + } .light .toc-link.is-active-link { - color: #111; + color: #111; + } .light .has-anchor .link-anchor { - color: #ddd; + color: #ddd; + } .light .has-anchor .link-anchor:hover { - color: #ccc; + color: #ccc; + } .light .signature-attributes { - color: #aaa; + color: #aaa; + } .light .ancestors { - color: #999; + color: #999; + } .light .ancestors a { - color: #999 !important; + color: #999 !important; + } .light .important { - color: #ee1313; + color: #ee1313; + } .light .type-signature { - color: #00918e; + color: #00918e; + } .light .name, .light .name a { - color: #293a80; + color: #293a80; + } .light .details { - background: #f9f9f9; - color: #101010; + background: #f9f9f9; + color: #101010; + } .light .member-item-container strong, .light .method-member-container strong { - color: #000; + color: #000; + } .light .prettyprint { - background: #f7f7f7; + background: #f7f7f7; + } .light .pre-div { - background: #f7f7f7; + background: #f7f7f7; + } .light .hljs .hljs-ln-numbers { - color: #aaa; + color: #aaa; + } .light .hljs .selected { - background: #ccc; + background: #ccc; + } +/* stylelint-disable-next-line selector-no-qualifying-type,rule-empty-line-before */ .light table.hljs-ln td { - background: none; + background: none; + } +/* stylelint-disable-next-line selector-max-compound-selectors,rule-empty-line-before */ .light .hljs .selected .hljs-ln-numbers { - color: #444; + color: #444; + } .light .pre-top-bar-container { - background-color: #eee; + background-color: #eee; + } .light .prettyprint code { - background-color: #f7f7f7; + background-color: #f7f7f7; + } .light table .name, .light .params .name, .light .props .name, .light .name code { - color: #4d4e53; + color: #4d4e53; + } .light table td, .light .params td { - background: #f7f7f7; + background: #f7f7f7; + } +/* stylelint-disable-next-line selector-max-compound-selectors,rule-empty-line-before */ .light table thead th, .light .params thead th, .light .props thead th { - background-color: #eee; - color: #111; + background-color: #eee; + color: #111; + } /* stylelint-disable */ .light table .params thead tr, .light .params .params thead tr, .light .props .props thead tr { - background-color: #eee; - color: #111; + background-color: #eee; + color: #111; + } .light .disabled { - color: #454545; + color: #454545; + } .light .code-lang-name { - color: #ff0000; + color: #ff0000; + } .light .tooltip { - background: #ffce76; - color: #000; + background: #ffce76; + color: #000; + } /* Code */ .light .hljs-comment, .light .hljs-quote { - color: #a0a1a7; + color: #a0a1a7; + } .light .hljs-doctag, .light .hljs-keyword, .light .hljs-formula { - color: #a626a4; + color: #a626a4; + } .light .hljs-section, @@ -255,11 +322,13 @@ body.light { .light .hljs-selector-tag, .light .hljs-deletion, .light .hljs-subst { - color: #e45649; + color: #e45649; + } .light .hljs-literal { - color: #0184bb; + color: #0184bb; + } .light .hljs-string, @@ -267,7 +336,8 @@ body.light { .light .hljs-addition, .light .hljs-attribute, .light .hljs-meta .hljs-string { - color: #50a14f; + color: #50a14f; + } .light .hljs-attr, @@ -278,7 +348,8 @@ body.light { .light .hljs-selector-attr, .light .hljs-selector-pseudo, .light .hljs-number { - color: #986801; + color: #986801; + } .light .hljs-symbol, @@ -287,102 +358,125 @@ body.light { .light .hljs-meta, .light .hljs-selector-id, .light .hljs-title { - color: #4078f2; + color: #4078f2; + } .light .hljs-built_in, .light .hljs-title.class_, .light .hljs-class .hljs-title { - color: #c18401; + color: #c18401; + } .light .hljs-emphasis { - font-style: italic; + font-style: italic; + } .light .hljs-strong { - font-weight: bold; + font-weight: bold; + } .light .hljs-link { - text-decoration: underline; + text-decoration: underline; + } /* Code Ends */ .light blockquote { - background: #eee; - color: #111; + background: #eee; + color: #111; + } .light code { - background: #ddd; - color: #000; + background: #ddd; + color: #000; + } .light .search-container { - background: rgba(0, 0, 0, 0.1); + background: rgba(0, 0, 0, 0.1); + } .light .search-close-button svg { - fill: #f00; + fill: #f00; + } .light .search-container .wrapper { - background: #eee; + background: #eee; + } .light .search-result-c { - color: #aaa; + color: #aaa; + } .light .search-box-c svg { - fill: #333; + fill: #333; + } .light .search-input { - background: #f7f7f7; - color: #111; + background: #f7f7f7; + color: #111; + } .light .search-result-item { - background: #f7f7f7; + background: #f7f7f7; + } .light .search-result-item:hover { - background: #e9e9e9; + background: #e9e9e9; + } .light .search-result-item:active { - background: #f7f7f7; + background: #f7f7f7; + } .light .search-result-item-title { - color: #111; + color: #111; + } .light .search-result-item-p { - color: #aaa; + color: #aaa; + } .light .mobile-menu-icon-container .icon-button { - background: #e5e5e5; + background: #e5e5e5; + } .light .mobile-sidebar-container { - background: #fff; + background: #fff; + } .light .mobile-sidebar-wrapper { - background: #f7f7f7; + background: #f7f7f7; + } -/* scroll bar */ -.light ::-webkit-scrollbar-track { - background: #ddd; +.light .child-tutorial { + border-color: #aaa; + color: #222; + } -.light ::-webkit-scrollbar-thumb { - background: #aaa; - outline: 0.06125rem solid #aaa; +.light .child-tutorial:hover { + background: #ccc; + } + diff --git a/sdk/docs/styles/clean-jsdoc-theme-scrollbar.css b/sdk/docs/styles/clean-jsdoc-theme-scrollbar.css new file mode 100644 index 000000000..4bcc3f1bc --- /dev/null +++ b/sdk/docs/styles/clean-jsdoc-theme-scrollbar.css @@ -0,0 +1,30 @@ +::-webkit-scrollbar { + height: 0.3125rem; + width: 0.3125rem; + +} + +::-webkit-scrollbar-thumb, +::-webkit-scrollbar-track { + border-radius: 1rem; +} + +::-webkit-scrollbar-track { + background: #333; +} + +::-webkit-scrollbar-thumb { + background: #555; + outline: 0.06125rem solid #555; +} + + +.light ::-webkit-scrollbar-track { + background: #ddd; + +} + +.light ::-webkit-scrollbar-thumb { + background: #aaa; + outline: 0.06125rem solid #aaa; +} \ No newline at end of file diff --git a/sdk/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css b/sdk/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css new file mode 100644 index 000000000..ced379500 --- /dev/null +++ b/sdk/docs/styles/clean-jsdoc-theme-without-scrollbar.min.css @@ -0,0 +1 @@ +@font-face{font-display:swap;font-family:"heading";src:url(../fonts/WorkSans-Bold.ttf)format("truetype")}@font-face{font-display:swap;font-family:"body";src:url(../fonts/OpenSans-Regular.ttf)format("truetype")}@font-face{font-display:swap;font-family:"code";src:url(../fonts/Inconsolata-Regular.ttf)format("truetype")}:root{--outer-wrapper-max-width:65rem}*{box-sizing:border-box;margin:0;padding:0}html,body{line-height:1.75;min-height:100%;width:100%}body{font-family:"body";overflow-x:hidden;position:relative}b{font-family:heading}h1,h2,h3,h4,h5,h6{font-family:"heading";font-weight:400;line-height:1.75}h1{font-size:3.5rem;margin:0}h2{font-size:2.25rem;margin:2rem 0 0}h3{font-size:1.5rem}h4{font-size:1.25rem}h5{font-size:1rem}h6{font-size:1rem}img{max-width:100%}a{text-decoration:none}a:hover{text-decoration:underline}a img{margin-right:.5rem}p{margin:1rem 0}article ul{list-style:disc}article ul li,article ol li{padding:.5rem 0}article ol,article ul{padding-left:2rem}article ol p,article ul p{margin:0}.variation{display:none}.signature-attributes{font-style:italic;font-weight:lighter}.ancestors a{text-decoration:none}.important{font-weight:700}.signature{font-family:"code"}.name{font-family:"code";font-weight:700}blockquote{border-radius:1rem;font-size:.875rem;margin:.5rem 0;padding:.0625rem 1.25rem}.details{border-radius:1rem;margin:1rem 0}.details .details-item-container{display:flex;padding:1rem 2rem}dt{font-family:heading}.details dt{float:left;min-width:11rem}.details ul{display:inline-flex;list-style-type:none;margin:0}.details ul li{display:inline-flex;margin-right:.6125rem;padding:0;word-break:break-word}.details ul li p{margin:0}.details pre.prettyprint{margin:0}.details .object-value{padding-top:0}.description{margin-bottom:2rem}.method-member-container table{margin-top:1rem}.pre-div .hljs-ln{margin:0}.code-caption{font-size:.875rem}.prettyprint{font-size:.875rem;overflow:auto}pre.prettyprint{margin-top:3rem}.prettyprint.source{width:inherit}.prettyprint code{display:block;font-size:1rem;line-height:1.75;padding:0 0 1rem}.prettyprint .compact{padding:0}h4.name{margin-top:.5rem}.params,.props,table{border-collapse:separate;border-radius:.5rem;border-spacing:0 .5rem;font-size:.875rem;margin:0;width:100%}table td:first-child,.params td:first-child,table thead th:first-child,.params thead th:first-child,.props thead th:first-child{border-bottom-left-radius:1rem;border-top-left-radius:1rem}table td:last-child,.params td:last-child,table thead th:last-child,.params thead th:last-child,.props thead th:last-child{border-bottom-right-radius:1rem;border-top-right-radius:1rem}table th,.params th{position:sticky;top:0}.params .name,.props .name,.name code{font-family:"code";font-size:1rem}.params td,.params th,.props td,.props th,th,td{display:table-cell;margin:0;padding:1rem 2rem;text-align:left;vertical-align:top}.params thead tr,.props thead tr{font-weight:700}.params .params thead tr,.props .props thead tr{font-weight:700}.params td.description>p:first-child,.props td.description>p:first-child{margin-top:0;padding-top:0}.params td.description>p:last-child,.props td.description>p:last-child{margin-bottom:0;padding-bottom:0}dl.param-type{margin-bottom:1rem;padding-bottom:1rem}.param-type dt,.param-type dd{display:inline-block}.param-type dd{font-family:"code";font-size:1rem}code{border-radius:.3rem;font-family:"code";font-size:1rem;padding:.1rem .4rem}.mt-20{margin-top:1.5rem}.codepen-form{bottom:0;position:absolute;right:.6125rem}.body-wrapper{display:flex;flex-direction:column;height:100vh;position:relative}.sidebar-container{bottom:0;display:flex;left:0;padding:1rem;position:fixed;top:0;width:25rem;z-index:10}.sidebar{border-radius:1rem;display:flex;flex:1;flex-direction:column;overflow:hidden;padding:1.5rem 0}.sidebar-title{font-family:heading;font-size:1.5rem;margin:0 0 2rem;padding:0 2rem;text-decoration:none}.sidebar-title:hover{text-decoration:none}.sidebar-items-container{flex:1;overflow:auto;position:relative}.sidebar-section-title{border-radius:1rem;font-family:heading;font-size:1.25rem;padding:.5rem 2rem}.with-arrow{align-items:center;cursor:pointer;display:flex}.with-arrow div{flex:1}.with-arrow svg{height:1rem;transition:transform .3s;width:1rem}.with-arrow[data-isopen=true] svg{transform:rotate(180deg)}.sidebar-section-children-container{border-radius:.5rem;overflow:hidden}.sidebar-section-children a{display:block;padding:.25rem 2rem;width:100%}.sidebar-section-children a{text-decoration:none}.with-arrow[data-isopen=false]+.sidebar-section-children-container{height:0;overflow:hidden}.with-arrow[data-isopen=true]+.sidebar-section-children-container{height:auto}.toc-container{bottom:0;position:fixed;right:4rem;top:0;width:16rem;z-index:10}.toc-content{display:flex;flex-direction:column;height:100%;padding-top:10rem}#eed4d2a0bfd64539bb9df78095dec881{flex:1;margin:2rem 0;overflow:auto}.toc-list{list-style:none;padding-left:1rem}.toc-link{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}.toc-link.is-active-link{font-family:heading}.has-anchor{position:relative}.link-anchor{padding:0 .5rem}.has-anchor .link-anchor{left:0;position:absolute;text-decoration:none;top:0;transform:translateX(-100%);visibility:hidden}.has-anchor:hover .link-anchor{visibility:visible}.navbar-container{display:flex;height:7rem;justify-content:center;left:25rem;padding-top:1rem;position:fixed;right:25rem;top:0;z-index:10}.navbar{display:flex;flex:1;max-width:var(--outer-wrapper-max-width);padding:1rem 4rem 1rem 2rem}.navbar-left-items{display:flex;flex:1}.navbar-right-items{display:flex}.icon-button svg{height:1rem;width:1rem}.icon-button{background:0 0;border:0;border-radius:50%;cursor:pointer;display:inline-flex;padding:.5rem;position:relative;transition:background .3s}.navbar-right-item{align-items:center;display:flex;justify-content:center;margin:0 .25rem}.navbar-item{border-radius:.5rem;overflow:hidden}.navbar-item a{display:inline-block;padding:1rem 2rem;text-decoration:none;transition:.3s}.font-size-tooltip{align-items:center;display:flex;margin:0-.5rem}.font-size-tooltip .icon-button.disabled{pointer-events:none}.main-content{align-items:center;display:flex;flex:1;flex-direction:column;overflow:auto;padding:7rem 25rem 0;position:relative}.main-wrapper{max-width:var(--outer-wrapper-max-width);padding:0 4rem 1rem;width:100%}.p-h-n{padding:.4rem 1rem}.footer{border-radius:1rem;display:flex;font-size:.875rem;justify-content:center;margin-top:5rem;width:100%}.source-page+.footer{margin-top:3rem}.footer .wrapper{flex:1;max-width:var(--outer-wrapper-max-width);padding:1rem 2rem}pre{position:relative}.hljs table td{background:0 0;border-radius:0;line-height:1.5;padding:0 .6125rem}.hljs .hljs-ln-numbers{padding-left:1.5rem;user-select:none;white-space:nowrap;width:2rem}.hljs-ln-line.hljs-ln-numbers::before{content:attr(data-line-number)}.pre-div{border-radius:1rem;margin:2rem 0;overflow:hidden;position:relative}.pre-top-bar-container{align-items:center;display:flex;justify-content:space-between;left:0;padding:.3125rem 1.5rem;position:absolute;right:0;top:0}.code-copy-icon-container{align-items:center;border-radius:50%;cursor:pointer;display:flex;height:1.875rem;justify-content:center;transition:.3s;width:1.875rem}.code-copy-icon-container>div{margin-top:.25rem;position:relative}.sm-icon{height:1rem;width:1rem}.code-lang-name{font-family:"body";font-size:.75rem}.tooltip{border-radius:.3125rem;opacity:0;padding:.1875rem .5rem;position:absolute;right:2rem;top:.3125rem;transform:scale(0);transition:.3s}.show-tooltip{opacity:1;transform:scale(1)}.allow-overflow{overflow:auto}.bold{font-family:heading}.search-container{align-items:flex-start;bottom:0;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:50}.search-container .wrapper{border-radius:1rem;margin:3rem 25rem;max-width:60rem;padding:4rem 2rem 2rem;position:relative;width:100%}.search-close-button{position:absolute;right:1rem;top:1rem}.search-result-c-text{display:flex;justify-content:center;user-select:none}.search-result-c{max-height:40rem;min-height:20rem;overflow:auto;padding:2rem 0}.search-box-c{align-items:center;display:flex;position:relative;width:100%}.search-box-c svg{height:1.5rem;left:1.5rem;position:absolute;width:1.5rem}.search-input{border:0;border-radius:1rem;flex:1;font-family:body;font-size:1.25rem;padding:1rem 2rem 1rem 4rem;width:100%}.search-result-item{border-radius:1rem;display:block;margin:1rem 0;padding:1rem;text-decoration:none}.search-result-item:hover{text-decoration:none}.search-result-item:active{text-decoration:none}.search-result-item-title{font-family:heading;font-size:1.5rem;margin:0}.search-result-item-p{font-size:.875rem;margin:0}.mobile-menu-icon-container{bottom:1.5rem;display:none;position:fixed;right:2rem;z-index:30}.mobile-menu-icon-container .icon-button svg{height:2rem;width:2rem}.mobile-sidebar-container{bottom:0;display:none;left:0;padding:1rem;position:fixed;right:0;top:0;z-index:25}.mobile-sidebar-container.show{display:block}.mobile-sidebar-wrapper{border-radius:1rem;display:flex;flex-direction:column;height:100%;padding-top:2rem;width:100%}.mobile-nav-links{display:flex;flex-wrap:wrap;padding-top:2rem}.mobile-sidebar-items-c{flex:1;overflow:auto}.mobile-navbar-actions{display:flex;padding:1rem}.rel{position:relative}.icon-button.codepen-button svg{height:1.5rem;width:1.5rem}.table-div{overflow:auto;width:100%}.tag-default{overflow:auto}@media screen and (max-width:100em){.toc-container{display:none}.main-content{padding:7rem 0 0 25rem}.search-container .wrapper{margin-right:1rem}.navbar-container{right:1rem}}@media screen and (min-width:65em){.mobile-sidebar-container.show{display:none}}@media screen and (max-width:65em){h1{font-size:3rem}h2{font-size:2rem}h3{font-size:1.875}h4,h5,h6{font-size:1rem}.main-wrapper{padding:0 1rem 1rem}.search-result-c{max-height:25rem}.mobile-menu-icon-container{display:block}.sidebar-container{display:none}.search-container .wrapper{margin-left:1rem}.main-content{padding-left:0;padding-top:1rem}.navbar-container{display:none}.source-page+.footer,.footer{margin-top:2rem}.has-anchor:hover .link-anchor{visibility:hidden}}.child-tutorial-container{display:flex;flex-direction:row;flex-wrap:wrap}.child-tutorial{border:1px solid;border-radius:10px;display:block;margin:5px;padding:10px 16px}.child-tutorial:hover{text-decoration:none}::selection{background:#ffce76;color:#222}body{background-color:#1a1a1a;color:#fff}a,a:active{color:#0bf}hr{color:#222}h1,h2,h3,h4,h5,h6{color:#fff}.sidebar{background-color:#222;color:#999}.sidebar-title{color:#999}.sidebar-section-title{color:#999}.sidebar-section-title:hover{background:#252525}.with-arrow{fill:#999}.sidebar-section-children-container{background:#292929}.sidebar-section-children.active{background:#444}.sidebar-section-children a:hover{background:#2c2c2c}.sidebar-section-children a{color:#fff}.navbar-container{background:#1a1a1a}.icon-button svg,.navbar-item a{color:#999;fill:#999}.font-size-tooltip .icon-button svg{fill:#fff}.font-size-tooltip .icon-button.disabled{background:#999}.icon-button:hover{background:#333}.icon-button:active{background:#444}.navbar-item a:active{background-color:#222;color:#aaa}.navbar-item:hover{background:#202020}.footer{background:#222;color:#999}.footer a{color:#999}.toc-link{color:#777;font-size:.875rem;transition:color .3s}.toc-link.is-active-link{color:#fff}.has-anchor .link-anchor{color:#555}.has-anchor .link-anchor:hover{color:#888}tt,code,kbd,samp{background:#333}.signature-attributes{color:#aaa}.ancestors{color:#999}.ancestors a{color:#999!important}.important{color:#c51313}.type-signature{color:#00918e}.name,.name a{color:#f7f7f7}.details{background:#222;color:#fff}.prettyprint{background:#222}.member-item-container strong,.method-member-container strong{color:#fff}.pre-top-bar-container{background:#292929}.prettyprint.source,.prettyprint code{background-color:#222;color:#c9d1d9}.pre-div{background-color:#222}.hljs .hljs-ln-numbers{color:#777}.hljs .selected{background:#444}.hljs .selected .hljs-ln-numbers{color:#eee}table .name,.params .name,.props .name,.name code{color:#fff}table td,.params td{background-color:#292929}table thead th,.params thead th,.props thead th{background-color:#222;color:#fff}table .params thead tr,.params .params thead tr,.props .props thead tr{background-color:#222;color:#fff}.disabled{color:#aaa}.code-lang-name{color:#ff8a00}.tooltip{background:#ffce76;color:#222}.hljs-comment{color:#8b949e}.hljs-doctag,.hljs-keyword,.hljs-template-tag,.hljs-variable.language_{color:#ff7b72}.hljs-template-variable,.hljs-type{color:#30ac7c}.hljs-meta,.hljs-string,.hljs-regexp{color:#a5d6ff}.hljs-title.class_,.hljs-title{color:#ffa657}.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}blockquote{background:#222;color:#fff}.search-container{background:rgba(255,255,255,.1)}.icon-button.search-close-button svg{fill:#a00}.search-container .wrapper{background:#222}.search-result-c{color:#666}.search-box-c{fill:#333}.search-input{background:#333;color:#fff}.search-box-c svg{fill:#fff}.search-result-item{background:#333}.search-result-item:hover{background:#444}.search-result-item:active{background:#555}.search-result-item-title{color:#fff}.search-result-item-p{color:#aaa}.mobile-menu-icon-container .icon-button{background:#333}.mobile-sidebar-container{background:#1a1a1a}.mobile-sidebar-wrapper{background:#222}.child-tutorial{border-color:#555;color:#f3f3f3}.child-tutorial:hover{background:#222}.light ::selection{background:#ffce76;color:#1d1919}body.light{background-color:#fff;color:#111}.light a,.light a:active{color:#007bff}.light hr{color:#f7f7f7}.light h1,.light h2,.light h3,.light h4,.light h5,.light h6{color:#111}.light .sidebar{background-color:#f7f7f7;color:#222}.light .sidebar-title{color:#222}.light .sidebar-section-title{color:#222}.light .sidebar-section-title:hover,.light .sidebar-section-title.active{background:#eee}.light .with-arrow{fill:#111}.light .sidebar-section-children-container{background:#eee}.light .sidebar-section-children.active{background:#ccc}.light .sidebar-section-children a:hover{background:#e0e0e0}.light .sidebar-section-children a{color:#111}.light .navbar-container{background:#fff}.light .icon-button svg,.light .navbar-item a{color:#222;fill:#222}.light .tippy-box{background:#eee;color:#111}.light .tippy-arrow{color:#f1f1f1}.light .font-size-tooltip .icon-button svg{fill:#111}.light .font-size-tooltip .icon-button.disabled svg{fill:#999}.light .icon-button:hover{background:#ddd}.light .icon-button:active{background:#ccc}.light .navbar-item a:active{background-color:#eee;color:#333}.light .navbar-item:hover{background:#f7f7f7}.light .footer{background:#f7f7f7;color:#111}.light .footer a{color:#111}.light .toc-link{color:#999;font-size:.875rem;transition:color .3s}.light .toc-link.is-active-link{color:#111}.light .has-anchor .link-anchor{color:#ddd}.light .has-anchor .link-anchor:hover{color:#ccc}.light .signature-attributes{color:#aaa}.light .ancestors{color:#999}.light .ancestors a{color:#999!important}.light .important{color:#ee1313}.light .type-signature{color:#00918e}.light .name,.light .name a{color:#293a80}.light .details{background:#f9f9f9;color:#101010}.light .member-item-container strong,.light .method-member-container strong{color:#000}.light .prettyprint{background:#f7f7f7}.light .pre-div{background:#f7f7f7}.light .hljs .hljs-ln-numbers{color:#aaa}.light .hljs .selected{background:#ccc}.light table.hljs-ln td{background:0 0}.light .hljs .selected .hljs-ln-numbers{color:#444}.light .pre-top-bar-container{background-color:#eee}.light .prettyprint code{background-color:#f7f7f7}.light table .name,.light .params .name,.light .props .name,.light .name code{color:#4d4e53}.light table td,.light .params td{background:#f7f7f7}.light table thead th,.light .params thead th,.light .props thead th{background-color:#eee;color:#111}.light table .params thead tr,.light .params .params thead tr,.light .props .props thead tr{background-color:#eee;color:#111}.light .disabled{color:#454545}.light .code-lang-name{color:red}.light .tooltip{background:#ffce76;color:#000}.light .hljs-comment,.light .hljs-quote{color:#a0a1a7}.light .hljs-doctag,.light .hljs-keyword,.light .hljs-formula{color:#a626a4}.light .hljs-section,.light .hljs-name,.light .hljs-selector-tag,.light .hljs-deletion,.light .hljs-subst{color:#e45649}.light .hljs-literal{color:#0184bb}.light .hljs-string,.light .hljs-regexp,.light .hljs-addition,.light .hljs-attribute,.light .hljs-meta .hljs-string{color:#50a14f}.light .hljs-attr,.light .hljs-variable,.light .hljs-template-variable,.light .hljs-type,.light .hljs-selector-class,.light .hljs-selector-attr,.light .hljs-selector-pseudo,.light .hljs-number{color:#986801}.light .hljs-symbol,.light .hljs-bullet,.light .hljs-link,.light .hljs-meta,.light .hljs-selector-id,.light .hljs-title{color:#4078f2}.light .hljs-built_in,.light .hljs-title.class_,.light .hljs-class .hljs-title{color:#c18401}.light .hljs-emphasis{font-style:italic}.light .hljs-strong{font-weight:700}.light .hljs-link{text-decoration:underline}.light blockquote{background:#eee;color:#111}.light code{background:#ddd;color:#000}.light .search-container{background:rgba(0,0,0,.1)}.light .search-close-button svg{fill:red}.light .search-container .wrapper{background:#eee}.light .search-result-c{color:#aaa}.light .search-box-c svg{fill:#333}.light .search-input{background:#f7f7f7;color:#111}.light .search-result-item{background:#f7f7f7}.light .search-result-item:hover{background:#e9e9e9}.light .search-result-item:active{background:#f7f7f7}.light .search-result-item-title{color:#111}.light .search-result-item-p{color:#aaa}.light .mobile-menu-icon-container .icon-button{background:#e5e5e5}.light .mobile-sidebar-container{background:#fff}.light .mobile-sidebar-wrapper{background:#f7f7f7}.light .child-tutorial{border-color:#aaa;color:#222}.light .child-tutorial:hover{background:#ccc} \ No newline at end of file diff --git a/sdk/docs/styles/clean-jsdoc-theme.min.css b/sdk/docs/styles/clean-jsdoc-theme.min.css index 188d27479..35a696a0f 100644 --- a/sdk/docs/styles/clean-jsdoc-theme.min.css +++ b/sdk/docs/styles/clean-jsdoc-theme.min.css @@ -1 +1 @@ -@font-face{font-family:"heading";src:url(../fonts/WorkSans-Bold.ttf)format("truetype");font-display:swap}@font-face{font-family:"body";src:url(../fonts/OpenSans-Regular.ttf)format("truetype");font-display:swap}@font-face{font-family:"code";src:url(../fonts/Inconsolata-Regular.ttf)format("truetype");font-display:swap}:root{--outer-wrapper-max-width:65rem}*{box-sizing:border-box;margin:0;padding:0}html,body{min-height:100%;width:100%;line-height:1.75}body{font-family:"body";overflow-x:hidden;position:relative}b{font-family:heading}h1,h2,h3,h4,h5,h6{font-family:"heading";font-weight:400;line-height:1.75}h1{font-size:3.5rem;margin:0}h2{font-size:2.25rem;margin:2rem 0 0}h3{font-size:1.5rem}h4{font-size:1.25rem}h5{font-size:1rem}h6{font-size:1rem}img{max-width:100%}a{text-decoration:none}a:hover{text-decoration:underline}a img{margin-right:.5rem}p{margin:1rem 0}article ul{list-style:none}article ul li,article ol li{padding:.5rem 0}article ol,article ul{padding-left:3rem}article ol p,article ul p{margin:0}.variation{display:none}.signature-attributes{font-style:italic;font-weight:lighter}.ancestors a{text-decoration:none}.important{font-weight:700}.signature{font-family:"code"}.name{font-family:"code";font-weight:700}blockquote{font-size:.875rem;padding:.0625rem 1.25rem;border-radius:1rem;margin:.5rem 0}.details{border-radius:1rem;margin:1rem 0}.details .details-item-container{display:flex;padding:1rem 2rem}dt{font-family:heading}.details dt{float:left;min-width:11rem}.details ul{margin:0;display:inline-flex;list-style-type:none}.details ul li{display:inline-flex;margin-right:.6125rem;padding:0;word-break:break-word}.details ul li p{margin:0}.details pre.prettyprint{margin:0}.details .object-value{padding-top:0}.description{margin-bottom:2rem}.method-member-container table{margin-top:1rem}.pre-div .hljs-ln{margin:0}.code-caption{font-size:.875rem}.prettyprint{font-size:.875rem;overflow:auto}pre.prettyprint{margin-top:3rem}.prettyprint.source{width:inherit}.prettyprint code{display:block;font-size:1rem;line-height:1.75;padding:0 0 1rem}.prettyprint .compact{padding:0}h4.name{margin-top:.5rem}.params,.props,table{border-collapse:separate;border-spacing:0 .5rem;border-radius:.5rem;font-size:.875rem;margin:0;width:100%}table td:first-child,.params td:first-child,table thead th:first-child,.params thead th:first-child,.props thead th:first-child{border-top-left-radius:1rem;border-bottom-left-radius:1rem}table td:last-child,.params td:last-child,table thead th:last-child,.params thead th:last-child,.props thead th:last-child{border-top-right-radius:1rem;border-bottom-right-radius:1rem}table th,.params th{position:sticky;top:0}.params .name,.props .name,.name code{font-family:"code";font-size:1rem}.params td,.params th,.props td,.props th,th,td{display:table-cell;margin:0;padding:1rem 2rem;text-align:left;vertical-align:top}.params thead tr,.props thead tr{font-weight:700}.params .params thead tr,.props .props thead tr{font-weight:700}.params td.description>p:first-child,.props td.description>p:first-child{margin-top:0;padding-top:0}.params td.description>p:last-child,.props td.description>p:last-child{margin-bottom:0;padding-bottom:0}dl.param-type{margin-bottom:1rem;padding-bottom:1rem}.param-type dt,.param-type dd{display:inline-block}.param-type dd{font-family:"code";font-size:1rem}code{border-radius:.3rem;font-family:"code";font-size:1rem;padding:.1rem .4rem}.mt-20{margin-top:1.5rem}.codepen-form{bottom:0;position:absolute;right:.6125rem}.body-wrapper{display:flex;flex-direction:column;height:100vh;position:relative}.sidebar-container{position:fixed;display:flex;padding:1rem;top:0;bottom:0;left:0;width:25rem;z-index:10}.sidebar{border-radius:1rem;flex:1;padding:1.5rem 0;overflow:hidden;display:flex;flex-direction:column}.sidebar-title{margin:0;padding:0 2rem;text-decoration:none;font-size:1.5rem;font-family:heading}.sidebar-title:hover{text-decoration:none}.sidebar-items-container{margin-top:5rem;overflow:auto;flex:1;position:relative}.sidebar-section-title{padding:.5rem 2rem;font-family:heading;font-size:1.25rem;border-radius:1rem}.with-arrow{align-items:center;cursor:pointer;display:flex}.with-arrow div{flex:1}.with-arrow svg{height:1rem;width:1rem;transition:transform .3s}.with-arrow[data-isopen=true] svg{transform:rotate(180deg)}.sidebar-section-children-container{border-radius:.5rem;overflow:hidden}.sidebar-section-children a{display:block;width:100%;padding:.25rem 2rem}.sidebar-section-children a{text-decoration:none}.with-arrow[data-isopen=false]+.sidebar-section-children-container{height:0;overflow:hidden}.with-arrow[data-isopen=true]+.sidebar-section-children-container{height:auto}.toc-container{position:fixed;top:0;right:4rem;bottom:0;width:16rem;z-index:10}.toc-content{padding-top:10rem;display:flex;flex-direction:column;height:100%}#eed4d2a0bfd64539bb9df78095dec881{margin:2rem 0;flex:1;overflow:auto}.toc-list{padding-left:1rem;list-style:none}.toc-link{display:block;white-space:nowrap;overflow:hidden;text-overflow:ellipsis;width:100%}.toc-link.is-active-link{font-family:heading}.has-anchor{position:relative}.link-anchor{padding:0 .5rem}.has-anchor .link-anchor{position:absolute;left:0;top:0;transform:translateX(-100%);text-decoration:none;visibility:hidden}.has-anchor:hover .link-anchor{visibility:visible}.navbar-container{position:fixed;z-index:10;top:0;left:25rem;right:25rem;height:7rem;padding-top:1rem;display:flex;justify-content:center}.navbar{display:flex;padding:1rem 4rem 1rem 2rem;flex:1;max-width:var(--outer-wrapper-max-width)}.navbar-left-items{display:flex;flex:1}.navbar-right-items{display:flex}.icon-button svg{height:1rem;width:1rem}.icon-button{background:0 0;position:relative;display:inline-flex;border:0;padding:.5rem;border-radius:50%;cursor:pointer;transition:background .3s}.navbar-right-item{display:flex;justify-content:center;align-items:center;margin:0 .25rem}.navbar-item{border-radius:.5rem;overflow:hidden}.navbar-item a{display:inline-block;padding:1rem 2rem;text-decoration:none;transition:.3s}.font-size-tooltip{display:flex;align-items:center;margin:0-.5rem}.font-size-tooltip .icon-button.disabled{pointer-events:none}.main-content{position:relative;flex:1;overflow:auto;display:flex;flex-direction:column;align-items:center;padding:7rem 25rem 0}.main-wrapper{width:100%;max-width:var(--outer-wrapper-max-width);padding:0 4rem 1rem}.p-h-n{padding:.4rem 1rem}.footer{width:100%;margin:5rem 0 0 0;border-radius:1rem;font-size:.875rem;display:flex;justify-content:center}.source-page+.footer{margin-top:3rem}.footer .wrapper{flex:1;padding:1rem 2rem;max-width:var(--outer-wrapper-max-width)}pre{position:relative}.hljs table td{background:0 0;padding:0 .6125rem;line-height:1.5;border-radius:0}.hljs .hljs-ln-numbers{width:2rem;white-space:nowrap;padding-left:1.5rem}.hljs-ln-line.hljs-ln-numbers::before{content:attr(data-line-number)}.pre-div{position:relative;border-radius:1rem;overflow:hidden;margin:2rem 0}.pre-top-bar-container{align-items:center;display:flex;justify-content:space-between;left:0;padding:.3125rem 1.5rem;position:absolute;right:0;top:0}.code-copy-icon-container{align-items:center;border-radius:50%;cursor:pointer;display:flex;height:1.875rem;justify-content:center;transition:.3s;width:1.875rem}.code-copy-icon-container>div{margin-top:.25rem;position:relative}.sm-icon{height:1rem;width:1rem}.code-lang-name{font-family:"body";font-size:.75rem}.tooltip{border-radius:.3125rem;opacity:0;padding:.1875rem .5rem;position:absolute;right:2rem;top:.3125rem;transform:scale(0);transition:.3s}.show-tooltip{opacity:1;transform:scale(1)}.allow-overflow{overflow:auto}.bold{font-family:heading}.search-container{position:fixed;top:0;bottom:0;right:0;left:0;justify-content:center;z-index:50;align-items:flex-start}.search-container .wrapper{width:100%;max-width:60rem;padding:4rem 2rem 2rem;border-radius:1rem;margin:3rem 25rem;position:relative}.search-close-button{position:absolute;top:1rem;right:1rem}.search-result-c-text{display:flex;justify-content:center;user-select:none}.search-result-c{min-height:20rem;max-height:40rem;overflow:auto;padding:2rem 0}.search-box-c{width:100%;position:relative;display:flex;align-items:center}.search-box-c svg{height:1.5rem;width:1.5rem;position:absolute;left:1.5rem}.search-input{border:0;border-radius:1rem;width:100%;flex:1;padding:1rem 2rem 1rem 4rem;font-family:body;font-size:1.25rem}.search-result-item{display:block;text-decoration:none;padding:1rem;border-radius:1rem;margin:1rem 0}.search-result-item:hover{text-decoration:none}.search-result-item:active{text-decoration:none}.search-result-item-title{font-family:heading;font-size:1.5rem;margin:0}.search-result-item-p{font-size:.875rem;margin:0}.mobile-menu-icon-container{display:none;position:fixed;bottom:1.5rem;right:2rem;z-index:30}.mobile-menu-icon-container .icon-button svg{height:2rem;width:2rem}.mobile-sidebar-container{position:fixed;top:0;right:0;left:0;bottom:0;padding:1rem;z-index:25;display:none}.mobile-sidebar-container.show{display:block}.mobile-sidebar-wrapper{border-radius:1rem;height:100%;width:100%;display:flex;flex-direction:column;padding-top:2rem}.mobile-nav-links{display:flex;flex-wrap:wrap;padding-top:2rem}.mobile-sidebar-items-c{flex:1;overflow:auto}.mobile-navbar-actions{display:flex;padding:1rem}.rel{position:relative}.icon-button.codepen-button svg{height:1.5rem;width:1.5rem}.table-div{width:100%;overflow:auto}.tag-default{overflow:auto}::-webkit-scrollbar{width:.3125rem;height:.3125rem}::-webkit-scrollbar-thumb,::-webkit-scrollbar-track{border-radius:1rem}@media screen and (max-width:100em){.toc-container{display:none}.main-content{padding:7rem 0 0 25rem}.search-container .wrapper{margin-right:1rem}.navbar-container{right:1rem}}@media screen and (min-width:65em){.mobile-sidebar-container.show{display:none}}@media screen and (max-width:65em){h1{font-size:3rem}h2{font-size:2rem}h3{font-size:1.875}h4,h5,h6{font-size:1rem}.main-wrapper{padding:0 1rem 1rem}.search-result-c{max-height:25rem}.mobile-menu-icon-container{display:block}.sidebar-container{display:none}.search-container .wrapper{margin-left:1rem}.main-content{padding-left:0;padding-top:1rem}.navbar-container{display:none}.source-page+.footer,.footer{margin-top:2rem}.has-anchor:hover .link-anchor{visibility:hidden}}::selection{background:#ffce76;color:#222}body{background-color:#1a1a1a;color:#fff}a,a:active{color:#0bf}hr{color:#222}h1,h2,h3,h4,h5,h6{color:#fff}.sidebar{background-color:#222;color:#999}.sidebar-title{color:#999}.sidebar-section-title{color:#999}.sidebar-section-title:hover{background:#252525}.with-arrow{fill:#999}.sidebar-section-children-container{background:#292929}.sidebar-section-children a:hover{background:#2c2c2c}.sidebar-section-children a{color:#fff}.navbar-container{background:#1a1a1a}.icon-button svg,.navbar-item a{color:#999;fill:#999}.font-size-tooltip .icon-button svg{fill:#fff}.font-size-tooltip .icon-button.disabled{background:#999}.icon-button:hover{background:#333}.icon-button:active{background:#444}.navbar-item a:active{color:#aaa;background-color:#222}.navbar-item:hover{background:#202020}.footer{background:#222;color:#999}.footer a{color:#999}.toc-link{color:#777;transition:color .3s;font-size:.875rem}.toc-link.is-active-link{color:#fff}.has-anchor .link-anchor{color:#555}.has-anchor .link-anchor:hover{color:#888}tt,code,kbd,samp{background:#333}.signature-attributes{color:#aaa}.ancestors{color:#999}.ancestors a{color:#999!important}.important{color:#c51313}.type-signature{color:#00918e}.name,.name a{color:#f7f7f7}.details{background:#222;color:#fff}.prettyprint{background:#222}.member-item-container strong,.method-member-container strong{color:#fff}.pre-top-bar-container{background:#292929}.prettyprint.source,.prettyprint code{background-color:#222;color:#c9d1d9}.pre-div{background-color:#222}.hljs .hljs-ln-numbers{color:#777}.hljs .selected{background:#444}.hljs .selected .hljs-ln-numbers{color:#eee}table .name,.params .name,.props .name,.name code{color:#fff}table td,.params td{background-color:#292929}table thead th,.params thead th,.props thead th{background-color:#222;color:#fff}table .params thead tr,.params .params thead tr,.props .props thead tr{background-color:#222;color:#fff}.disabled{color:#aaa}.code-lang-name{color:#ff8a00}.tooltip{background:#ffce76;color:#222}.hljs-comment{color:#8b949e}.hljs-doctag,.hljs-keyword,.hljs-template-tag,.hljs-variable.language_{color:#ff7b72}.hljs-template-variable,.hljs-type{color:#30ac7c}.hljs-meta,.hljs-string,.hljs-regexp{color:#a5d6ff}.hljs-title.class_,.hljs-title{color:#ffa657}.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}blockquote{background:#222;color:#fff}.search-container{background:rgba(255,255,255,.1)}.icon-button.search-close-button svg{fill:#a00}.search-container .wrapper{background:#222}.search-result-c{color:#666}.search-box-c{fill:#333}.search-input{background:#333;color:#fff}.search-box-c svg{fill:#fff}.search-result-item{background:#333}.search-result-item:hover{background:#444}.search-result-item:active{background:#555}.search-result-item-title{color:#fff}.search-result-item-p{color:#aaa}.mobile-menu-icon-container .icon-button{background:#333}.mobile-sidebar-container{background:#1a1a1a}.mobile-sidebar-wrapper{background:#222}::-webkit-scrollbar-track{background:#333}::-webkit-scrollbar-thumb{background:#555;outline:.06125rem solid #555}.light ::selection{background:#ffce76;color:#1d1919}body.light{background-color:#fff;color:#111}.light a,.light a:active{color:#007bff}.light hr{color:#f7f7f7}.light h1,.light h2,.light h3,.light h4,.light h5,.light h6{color:#111}.light .sidebar{background-color:#f7f7f7;color:#222}.light .sidebar-title{color:#222}.light .sidebar-section-title{color:#222}.light .sidebar-section-title:hover{background:#eee}.light .with-arrow{fill:#111}.light .sidebar-section-children-container{background:#eee}.light .sidebar-section-children a:hover{background:#e0e0e0}.light .sidebar-section-children a{color:#111}.light .navbar-container{background:#fff}.light .icon-button svg,.light .navbar-item a{color:#222;fill:#222}.light .tippy-box{background:#eee;color:#111}.light .tippy-arrow{color:#f1f1f1}.light .font-size-tooltip .icon-button svg{fill:#111}.light .font-size-tooltip .icon-button.disabled svg{fill:#999}.light .icon-button:hover{background:#ddd}.light .icon-button:active{background:#ccc}.light .navbar-item a:active{color:#333;background-color:#eee}.light .navbar-item:hover{background:#f7f7f7}.light .footer{background:#f7f7f7;color:#111}.light .footer a{color:#111}.light .toc-link{color:#999;transition:color .3s;font-size:.875rem}.light .toc-link.is-active-link{color:#111}.light .has-anchor .link-anchor{color:#ddd}.light .has-anchor .link-anchor:hover{color:#ccc}.light .signature-attributes{color:#aaa}.light .ancestors{color:#999}.light .ancestors a{color:#999!important}.light .important{color:#ee1313}.light .type-signature{color:#00918e}.light .name,.light .name a{color:#293a80}.light .details{background:#f9f9f9;color:#101010}.light .member-item-container strong,.light .method-member-container strong{color:#000}.light .prettyprint{background:#f7f7f7}.light .pre-div{background:#f7f7f7}.light .hljs .hljs-ln-numbers{color:#aaa}.light .hljs .selected{background:#ccc}.light table.hljs-ln td{background:0 0}.light .hljs .selected .hljs-ln-numbers{color:#444}.light .pre-top-bar-container{background-color:#eee}.light .prettyprint code{background-color:#f7f7f7}.light table .name,.light .params .name,.light .props .name,.light .name code{color:#4d4e53}.light table td,.light .params td{background:#f7f7f7}.light table thead th,.light .params thead th,.light .props thead th{background-color:#eee;color:#111}.light table .params thead tr,.light .params .params thead tr,.light .props .props thead tr{background-color:#eee;color:#111}.light .disabled{color:#454545}.light .code-lang-name{color:red}.light .tooltip{background:#ffce76;color:#000}.light .hljs-comment,.light .hljs-quote{color:#a0a1a7}.light .hljs-doctag,.light .hljs-keyword,.light .hljs-formula{color:#a626a4}.light .hljs-section,.light .hljs-name,.light .hljs-selector-tag,.light .hljs-deletion,.light .hljs-subst{color:#e45649}.light .hljs-literal{color:#0184bb}.light .hljs-string,.light .hljs-regexp,.light .hljs-addition,.light .hljs-attribute,.light .hljs-meta .hljs-string{color:#50a14f}.light .hljs-attr,.light .hljs-variable,.light .hljs-template-variable,.light .hljs-type,.light .hljs-selector-class,.light .hljs-selector-attr,.light .hljs-selector-pseudo,.light .hljs-number{color:#986801}.light .hljs-symbol,.light .hljs-bullet,.light .hljs-link,.light .hljs-meta,.light .hljs-selector-id,.light .hljs-title{color:#4078f2}.light .hljs-built_in,.light .hljs-title.class_,.light .hljs-class .hljs-title{color:#c18401}.light .hljs-emphasis{font-style:italic}.light .hljs-strong{font-weight:700}.light .hljs-link{text-decoration:underline}.light blockquote{background:#eee;color:#111}.light code{background:#ddd;color:#000}.light .search-container{background:rgba(0,0,0,.1)}.light .search-close-button svg{fill:red}.light .search-container .wrapper{background:#eee}.light .search-result-c{color:#aaa}.light .search-box-c svg{fill:#333}.light .search-input{background:#f7f7f7;color:#111}.light .search-result-item{background:#f7f7f7}.light .search-result-item:hover{background:#e9e9e9}.light .search-result-item:active{background:#f7f7f7}.light .search-result-item-title{color:#111}.light .search-result-item-p{color:#aaa}.light .mobile-menu-icon-container .icon-button{background:#e5e5e5}.light .mobile-sidebar-container{background:#fff}.light .mobile-sidebar-wrapper{background:#f7f7f7}.light ::-webkit-scrollbar-track{background:#ddd}.light ::-webkit-scrollbar-thumb{background:#aaa;outline:.06125rem solid #aaa} \ No newline at end of file +@font-face{font-display:swap;font-family:"heading";src:url(../fonts/WorkSans-Bold.ttf)format("truetype")}@font-face{font-display:swap;font-family:"body";src:url(../fonts/OpenSans-Regular.ttf)format("truetype")}@font-face{font-display:swap;font-family:"code";src:url(../fonts/Inconsolata-Regular.ttf)format("truetype")}:root{--outer-wrapper-max-width:65rem}*{box-sizing:border-box;margin:0;padding:0}html,body{line-height:1.75;min-height:100%;width:100%}body{font-family:"body";overflow-x:hidden;position:relative}b{font-family:heading}h1,h2,h3,h4,h5,h6{font-family:"heading";font-weight:400;line-height:1.75}h1{font-size:3.5rem;margin:0}h2{font-size:2.25rem;margin:2rem 0 0}h3{font-size:1.5rem}h4{font-size:1.25rem}h5{font-size:1rem}h6{font-size:1rem}img{max-width:100%}a{text-decoration:none}a:hover{text-decoration:underline}a img{margin-right:.5rem}p{margin:1rem 0}article ul{list-style:disc}article ul li,article ol li{padding:.5rem 0}article ol,article ul{padding-left:2rem}article ol p,article ul p{margin:0}.variation{display:none}.signature-attributes{font-style:italic;font-weight:lighter}.ancestors a{text-decoration:none}.important{font-weight:700}.signature{font-family:"code"}.name{font-family:"code";font-weight:700}blockquote{border-radius:1rem;font-size:.875rem;margin:.5rem 0;padding:.0625rem 1.25rem}.details{border-radius:1rem;margin:1rem 0}.details .details-item-container{display:flex;padding:1rem 2rem}dt{font-family:heading}.details dt{float:left;min-width:11rem}.details ul{display:inline-flex;list-style-type:none;margin:0}.details ul li{display:inline-flex;margin-right:.6125rem;padding:0;word-break:break-word}.details ul li p{margin:0}.details pre.prettyprint{margin:0}.details .object-value{padding-top:0}.description{margin-bottom:2rem}.method-member-container table{margin-top:1rem}.pre-div .hljs-ln{margin:0}.code-caption{font-size:.875rem}.prettyprint{font-size:.875rem;overflow:auto}pre.prettyprint{margin-top:3rem}.prettyprint.source{width:inherit}.prettyprint code{display:block;font-size:1rem;line-height:1.75;padding:0 0 1rem}.prettyprint .compact{padding:0}h4.name{margin-top:.5rem}.params,.props,table{border-collapse:separate;border-radius:.5rem;border-spacing:0 .5rem;font-size:.875rem;margin:0;width:100%}table td:first-child,.params td:first-child,table thead th:first-child,.params thead th:first-child,.props thead th:first-child{border-bottom-left-radius:1rem;border-top-left-radius:1rem}table td:last-child,.params td:last-child,table thead th:last-child,.params thead th:last-child,.props thead th:last-child{border-bottom-right-radius:1rem;border-top-right-radius:1rem}table th,.params th{position:sticky;top:0}.params .name,.props .name,.name code{font-family:"code";font-size:1rem}.params td,.params th,.props td,.props th,th,td{display:table-cell;margin:0;padding:1rem 2rem;text-align:left;vertical-align:top}.params thead tr,.props thead tr{font-weight:700}.params .params thead tr,.props .props thead tr{font-weight:700}.params td.description>p:first-child,.props td.description>p:first-child{margin-top:0;padding-top:0}.params td.description>p:last-child,.props td.description>p:last-child{margin-bottom:0;padding-bottom:0}dl.param-type{margin-bottom:1rem;padding-bottom:1rem}.param-type dt,.param-type dd{display:inline-block}.param-type dd{font-family:"code";font-size:1rem}code{border-radius:.3rem;font-family:"code";font-size:1rem;padding:.1rem .4rem}.mt-20{margin-top:1.5rem}.codepen-form{bottom:0;position:absolute;right:.6125rem}.body-wrapper{display:flex;flex-direction:column;height:100vh;position:relative}.sidebar-container{bottom:0;display:flex;left:0;padding:1rem;position:fixed;top:0;width:25rem;z-index:10}.sidebar{border-radius:1rem;display:flex;flex:1;flex-direction:column;overflow:hidden;padding:1.5rem 0}.sidebar-title{font-family:heading;font-size:1.5rem;margin:0 0 2rem;padding:0 2rem;text-decoration:none}.sidebar-title:hover{text-decoration:none}.sidebar-items-container{flex:1;overflow:auto;position:relative}.sidebar-section-title{border-radius:1rem;font-family:heading;font-size:1.25rem;padding:.5rem 2rem}.with-arrow{align-items:center;cursor:pointer;display:flex}.with-arrow div{flex:1}.with-arrow svg{height:1rem;transition:transform .3s;width:1rem}.with-arrow[data-isopen=true] svg{transform:rotate(180deg)}.sidebar-section-children-container{border-radius:.5rem;overflow:hidden}.sidebar-section-children a{display:block;padding:.25rem 2rem;width:100%}.sidebar-section-children a{text-decoration:none}.with-arrow[data-isopen=false]+.sidebar-section-children-container{height:0;overflow:hidden}.with-arrow[data-isopen=true]+.sidebar-section-children-container{height:auto}.toc-container{bottom:0;position:fixed;right:4rem;top:0;width:16rem;z-index:10}.toc-content{display:flex;flex-direction:column;height:100%;padding-top:10rem}#eed4d2a0bfd64539bb9df78095dec881{flex:1;margin:2rem 0;overflow:auto}.toc-list{list-style:none;padding-left:1rem}.toc-link{display:block;overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}.toc-link.is-active-link{font-family:heading}.has-anchor{position:relative}.link-anchor{padding:0 .5rem}.has-anchor .link-anchor{left:0;position:absolute;text-decoration:none;top:0;transform:translateX(-100%);visibility:hidden}.has-anchor:hover .link-anchor{visibility:visible}.navbar-container{display:flex;height:7rem;justify-content:center;left:25rem;padding-top:1rem;position:fixed;right:25rem;top:0;z-index:10}.navbar{display:flex;flex:1;max-width:var(--outer-wrapper-max-width);padding:1rem 4rem 1rem 2rem}.navbar-left-items{display:flex;flex:1}.navbar-right-items{display:flex}.icon-button svg{height:1rem;width:1rem}.icon-button{background:0 0;border:0;border-radius:50%;cursor:pointer;display:inline-flex;padding:.5rem;position:relative;transition:background .3s}.navbar-right-item{align-items:center;display:flex;justify-content:center;margin:0 .25rem}.navbar-item{border-radius:.5rem;overflow:hidden}.navbar-item a{display:inline-block;padding:1rem 2rem;text-decoration:none;transition:.3s}.font-size-tooltip{align-items:center;display:flex;margin:0-.5rem}.font-size-tooltip .icon-button.disabled{pointer-events:none}.main-content{align-items:center;display:flex;flex:1;flex-direction:column;overflow:auto;padding:7rem 25rem 0;position:relative}.main-wrapper{max-width:var(--outer-wrapper-max-width);padding:0 4rem 1rem;width:100%}.p-h-n{padding:.4rem 1rem}.footer{border-radius:1rem;display:flex;font-size:.875rem;justify-content:center;margin-top:5rem;width:100%}.source-page+.footer{margin-top:3rem}.footer .wrapper{flex:1;max-width:var(--outer-wrapper-max-width);padding:1rem 2rem}pre{position:relative}.hljs table td{background:0 0;border-radius:0;line-height:1.5;padding:0 .6125rem}.hljs .hljs-ln-numbers{padding-left:1.5rem;user-select:none;white-space:nowrap;width:2rem}.hljs-ln-line.hljs-ln-numbers::before{content:attr(data-line-number)}.pre-div{border-radius:1rem;margin:2rem 0;overflow:hidden;position:relative}.pre-top-bar-container{align-items:center;display:flex;justify-content:space-between;left:0;padding:.3125rem 1.5rem;position:absolute;right:0;top:0}.code-copy-icon-container{align-items:center;border-radius:50%;cursor:pointer;display:flex;height:1.875rem;justify-content:center;transition:.3s;width:1.875rem}.code-copy-icon-container>div{margin-top:.25rem;position:relative}.sm-icon{height:1rem;width:1rem}.code-lang-name{font-family:"body";font-size:.75rem}.tooltip{border-radius:.3125rem;opacity:0;padding:.1875rem .5rem;position:absolute;right:2rem;top:.3125rem;transform:scale(0);transition:.3s}.show-tooltip{opacity:1;transform:scale(1)}.allow-overflow{overflow:auto}.bold{font-family:heading}.search-container{align-items:flex-start;bottom:0;justify-content:center;left:0;position:fixed;right:0;top:0;z-index:50}.search-container .wrapper{border-radius:1rem;margin:3rem 25rem;max-width:60rem;padding:4rem 2rem 2rem;position:relative;width:100%}.search-close-button{position:absolute;right:1rem;top:1rem}.search-result-c-text{display:flex;justify-content:center;user-select:none}.search-result-c{max-height:40rem;min-height:20rem;overflow:auto;padding:2rem 0}.search-box-c{align-items:center;display:flex;position:relative;width:100%}.search-box-c svg{height:1.5rem;left:1.5rem;position:absolute;width:1.5rem}.search-input{border:0;border-radius:1rem;flex:1;font-family:body;font-size:1.25rem;padding:1rem 2rem 1rem 4rem;width:100%}.search-result-item{border-radius:1rem;display:block;margin:1rem 0;padding:1rem;text-decoration:none}.search-result-item:hover{text-decoration:none}.search-result-item:active{text-decoration:none}.search-result-item-title{font-family:heading;font-size:1.5rem;margin:0}.search-result-item-p{font-size:.875rem;margin:0}.mobile-menu-icon-container{bottom:1.5rem;display:none;position:fixed;right:2rem;z-index:30}.mobile-menu-icon-container .icon-button svg{height:2rem;width:2rem}.mobile-sidebar-container{bottom:0;display:none;left:0;padding:1rem;position:fixed;right:0;top:0;z-index:25}.mobile-sidebar-container.show{display:block}.mobile-sidebar-wrapper{border-radius:1rem;display:flex;flex-direction:column;height:100%;padding-top:2rem;width:100%}.mobile-nav-links{display:flex;flex-wrap:wrap;padding-top:2rem}.mobile-sidebar-items-c{flex:1;overflow:auto}.mobile-navbar-actions{display:flex;padding:1rem}.rel{position:relative}.icon-button.codepen-button svg{height:1.5rem;width:1.5rem}.table-div{overflow:auto;width:100%}.tag-default{overflow:auto}@media screen and (max-width:100em){.toc-container{display:none}.main-content{padding:7rem 0 0 25rem}.search-container .wrapper{margin-right:1rem}.navbar-container{right:1rem}}@media screen and (min-width:65em){.mobile-sidebar-container.show{display:none}}@media screen and (max-width:65em){h1{font-size:3rem}h2{font-size:2rem}h3{font-size:1.875}h4,h5,h6{font-size:1rem}.main-wrapper{padding:0 1rem 1rem}.search-result-c{max-height:25rem}.mobile-menu-icon-container{display:block}.sidebar-container{display:none}.search-container .wrapper{margin-left:1rem}.main-content{padding-left:0;padding-top:1rem}.navbar-container{display:none}.source-page+.footer,.footer{margin-top:2rem}.has-anchor:hover .link-anchor{visibility:hidden}}.child-tutorial-container{display:flex;flex-direction:row;flex-wrap:wrap}.child-tutorial{border:1px solid;border-radius:10px;display:block;margin:5px;padding:10px 16px}.child-tutorial:hover{text-decoration:none}::selection{background:#ffce76;color:#222}body{background-color:#1a1a1a;color:#fff}a,a:active{color:#0bf}hr{color:#222}h1,h2,h3,h4,h5,h6{color:#fff}.sidebar{background-color:#222;color:#999}.sidebar-title{color:#999}.sidebar-section-title{color:#999}.sidebar-section-title:hover{background:#252525}.with-arrow{fill:#999}.sidebar-section-children-container{background:#292929}.sidebar-section-children.active{background:#444}.sidebar-section-children a:hover{background:#2c2c2c}.sidebar-section-children a{color:#fff}.navbar-container{background:#1a1a1a}.icon-button svg,.navbar-item a{color:#999;fill:#999}.font-size-tooltip .icon-button svg{fill:#fff}.font-size-tooltip .icon-button.disabled{background:#999}.icon-button:hover{background:#333}.icon-button:active{background:#444}.navbar-item a:active{background-color:#222;color:#aaa}.navbar-item:hover{background:#202020}.footer{background:#222;color:#999}.footer a{color:#999}.toc-link{color:#777;font-size:.875rem;transition:color .3s}.toc-link.is-active-link{color:#fff}.has-anchor .link-anchor{color:#555}.has-anchor .link-anchor:hover{color:#888}tt,code,kbd,samp{background:#333}.signature-attributes{color:#aaa}.ancestors{color:#999}.ancestors a{color:#999!important}.important{color:#c51313}.type-signature{color:#00918e}.name,.name a{color:#f7f7f7}.details{background:#222;color:#fff}.prettyprint{background:#222}.member-item-container strong,.method-member-container strong{color:#fff}.pre-top-bar-container{background:#292929}.prettyprint.source,.prettyprint code{background-color:#222;color:#c9d1d9}.pre-div{background-color:#222}.hljs .hljs-ln-numbers{color:#777}.hljs .selected{background:#444}.hljs .selected .hljs-ln-numbers{color:#eee}table .name,.params .name,.props .name,.name code{color:#fff}table td,.params td{background-color:#292929}table thead th,.params thead th,.props thead th{background-color:#222;color:#fff}table .params thead tr,.params .params thead tr,.props .props thead tr{background-color:#222;color:#fff}.disabled{color:#aaa}.code-lang-name{color:#ff8a00}.tooltip{background:#ffce76;color:#222}.hljs-comment{color:#8b949e}.hljs-doctag,.hljs-keyword,.hljs-template-tag,.hljs-variable.language_{color:#ff7b72}.hljs-template-variable,.hljs-type{color:#30ac7c}.hljs-meta,.hljs-string,.hljs-regexp{color:#a5d6ff}.hljs-title.class_,.hljs-title{color:#ffa657}.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}blockquote{background:#222;color:#fff}.search-container{background:rgba(255,255,255,.1)}.icon-button.search-close-button svg{fill:#a00}.search-container .wrapper{background:#222}.search-result-c{color:#666}.search-box-c{fill:#333}.search-input{background:#333;color:#fff}.search-box-c svg{fill:#fff}.search-result-item{background:#333}.search-result-item:hover{background:#444}.search-result-item:active{background:#555}.search-result-item-title{color:#fff}.search-result-item-p{color:#aaa}.mobile-menu-icon-container .icon-button{background:#333}.mobile-sidebar-container{background:#1a1a1a}.mobile-sidebar-wrapper{background:#222}.child-tutorial{border-color:#555;color:#f3f3f3}.child-tutorial:hover{background:#222}.light ::selection{background:#ffce76;color:#1d1919}body.light{background-color:#fff;color:#111}.light a,.light a:active{color:#007bff}.light hr{color:#f7f7f7}.light h1,.light h2,.light h3,.light h4,.light h5,.light h6{color:#111}.light .sidebar{background-color:#f7f7f7;color:#222}.light .sidebar-title{color:#222}.light .sidebar-section-title{color:#222}.light .sidebar-section-title:hover,.light .sidebar-section-title.active{background:#eee}.light .with-arrow{fill:#111}.light .sidebar-section-children-container{background:#eee}.light .sidebar-section-children.active{background:#ccc}.light .sidebar-section-children a:hover{background:#e0e0e0}.light .sidebar-section-children a{color:#111}.light .navbar-container{background:#fff}.light .icon-button svg,.light .navbar-item a{color:#222;fill:#222}.light .tippy-box{background:#eee;color:#111}.light .tippy-arrow{color:#f1f1f1}.light .font-size-tooltip .icon-button svg{fill:#111}.light .font-size-tooltip .icon-button.disabled svg{fill:#999}.light .icon-button:hover{background:#ddd}.light .icon-button:active{background:#ccc}.light .navbar-item a:active{background-color:#eee;color:#333}.light .navbar-item:hover{background:#f7f7f7}.light .footer{background:#f7f7f7;color:#111}.light .footer a{color:#111}.light .toc-link{color:#999;font-size:.875rem;transition:color .3s}.light .toc-link.is-active-link{color:#111}.light .has-anchor .link-anchor{color:#ddd}.light .has-anchor .link-anchor:hover{color:#ccc}.light .signature-attributes{color:#aaa}.light .ancestors{color:#999}.light .ancestors a{color:#999!important}.light .important{color:#ee1313}.light .type-signature{color:#00918e}.light .name,.light .name a{color:#293a80}.light .details{background:#f9f9f9;color:#101010}.light .member-item-container strong,.light .method-member-container strong{color:#000}.light .prettyprint{background:#f7f7f7}.light .pre-div{background:#f7f7f7}.light .hljs .hljs-ln-numbers{color:#aaa}.light .hljs .selected{background:#ccc}.light table.hljs-ln td{background:0 0}.light .hljs .selected .hljs-ln-numbers{color:#444}.light .pre-top-bar-container{background-color:#eee}.light .prettyprint code{background-color:#f7f7f7}.light table .name,.light .params .name,.light .props .name,.light .name code{color:#4d4e53}.light table td,.light .params td{background:#f7f7f7}.light table thead th,.light .params thead th,.light .props thead th{background-color:#eee;color:#111}.light table .params thead tr,.light .params .params thead tr,.light .props .props thead tr{background-color:#eee;color:#111}.light .disabled{color:#454545}.light .code-lang-name{color:red}.light .tooltip{background:#ffce76;color:#000}.light .hljs-comment,.light .hljs-quote{color:#a0a1a7}.light .hljs-doctag,.light .hljs-keyword,.light .hljs-formula{color:#a626a4}.light .hljs-section,.light .hljs-name,.light .hljs-selector-tag,.light .hljs-deletion,.light .hljs-subst{color:#e45649}.light .hljs-literal{color:#0184bb}.light .hljs-string,.light .hljs-regexp,.light .hljs-addition,.light .hljs-attribute,.light .hljs-meta .hljs-string{color:#50a14f}.light .hljs-attr,.light .hljs-variable,.light .hljs-template-variable,.light .hljs-type,.light .hljs-selector-class,.light .hljs-selector-attr,.light .hljs-selector-pseudo,.light .hljs-number{color:#986801}.light .hljs-symbol,.light .hljs-bullet,.light .hljs-link,.light .hljs-meta,.light .hljs-selector-id,.light .hljs-title{color:#4078f2}.light .hljs-built_in,.light .hljs-title.class_,.light .hljs-class .hljs-title{color:#c18401}.light .hljs-emphasis{font-style:italic}.light .hljs-strong{font-weight:700}.light .hljs-link{text-decoration:underline}.light blockquote{background:#eee;color:#111}.light code{background:#ddd;color:#000}.light .search-container{background:rgba(0,0,0,.1)}.light .search-close-button svg{fill:red}.light .search-container .wrapper{background:#eee}.light .search-result-c{color:#aaa}.light .search-box-c svg{fill:#333}.light .search-input{background:#f7f7f7;color:#111}.light .search-result-item{background:#f7f7f7}.light .search-result-item:hover{background:#e9e9e9}.light .search-result-item:active{background:#f7f7f7}.light .search-result-item-title{color:#111}.light .search-result-item-p{color:#aaa}.light .mobile-menu-icon-container .icon-button{background:#e5e5e5}.light .mobile-sidebar-container{background:#fff}.light .mobile-sidebar-wrapper{background:#f7f7f7}.light .child-tutorial{border-color:#aaa;color:#222}.light .child-tutorial:hover{background:#ccc}::-webkit-scrollbar{height:.3125rem;width:.3125rem}::-webkit-scrollbar-thumb,::-webkit-scrollbar-track{border-radius:1rem}::-webkit-scrollbar-track{background:#333}::-webkit-scrollbar-thumb{background:#555;outline:.06125rem solid #555}.light ::-webkit-scrollbar-track{background:#ddd}.light ::-webkit-scrollbar-thumb{background:#aaa;outline:.06125rem solid #aaa} \ No newline at end of file diff --git a/sdk/jsdoc.json b/sdk/jsdoc.json index 6fc5ed67d..4edcdd4d9 100644 --- a/sdk/jsdoc.json +++ b/sdk/jsdoc.json @@ -1,6 +1,6 @@ { "source": { - "include": ["src/account.ts", "src/dev-server-client.ts", "src/key-provider.ts", "src/network-client.ts", "src/program-manager.ts", "src/record-provider.ts"], + "include": ["sdk/src/account.ts", "sdk/src/function-key-provider.ts", "sdk/src/network-client.ts", "sdk/src/offline-key-provider.ts", "sdk/src/program-manager.ts", "sdk/src/record-provider.ts"], "includePattern": ".+\\.ts?$" }, "tags": { @@ -10,14 +10,14 @@ "opts": { "encoding": "utf8", "readme": "./README.md", - "destination": "docs/", + "destination": "sdk/docs/", "recurse": true, "verbose": true, "template": "./node_modules/clean-jsdoc-theme", "theme_opts": { "default_theme": "dark", - "static_dir": ["./public"], - "homepageTitle": "Aleo SDK" + "static_dir": ["sdk/docs/public"], + "homepageTitle": "Provable SDK" } }, "markdown": { diff --git a/sdk/package.json b/sdk/package.json index 85d1c814a..6fdb45c1b 100644 --- a/sdk/package.json +++ b/sdk/package.json @@ -49,9 +49,9 @@ "dependencies": { "@provablehq/wasm": "^0.7.2", "comlink": "^4.4.1", + "core-js": "^3.38.1", "mime": "^3.0.0", - "sync-request": "^6.1.0", - "core-js": "^3.38.1" + "sync-request": "^6.1.0" }, "devDependencies": { "@rollup/plugin-replace": "^5.0.5", @@ -61,9 +61,9 @@ "@types/sinon": "^17.0.3", "@typescript-eslint/eslint-plugin": "^5.41.0", "@typescript-eslint/parser": "^5.41.0", - "better-docs": "^2.7.2", + "better-docs": "^2.7.3", "chai": "^5.1.1", - "clean-jsdoc-theme": "^4.1.8", + "clean-jsdoc-theme": "^4.3.0", "cpr": "^3.0.1", "eslint": "^8.26.0", "eslint-config-prettier": "^8.5.0", diff --git a/sdk/src/browser.ts b/sdk/src/browser.ts index a08d250ec..0f91580f2 100644 --- a/sdk/src/browser.ts +++ b/sdk/src/browser.ts @@ -2,7 +2,8 @@ import "./polyfill/shared"; import { Account } from "./account"; import { AleoNetworkClient, ProgramImports } from "./network-client"; -import { BlockJSON } from "./models/blockJSON"; +import { BlockJSON, Header, Metadata } from "./models/blockJSON"; +import { DeploymentMetadata } from "./models/deploy"; import { ExecutionJSON } from "./models/executionJSON"; import { FunctionObject } from "./models/functionObject"; import { InputJSON } from "./models/input/inputJSON"; @@ -11,9 +12,10 @@ import { OutputJSON } from "./models/output/outputJSON"; import { OutputObject } from "./models/output/outputObject"; import { PlaintextArray} from "./models/plaintext/array"; import { PlaintextLiteral} from "./models/plaintext/literal"; +import { PlaintextObject } from "./models/plaintext/plaintext"; import { PlaintextStruct} from "./models/plaintext/struct"; import { TransactionJSON } from "./models/transaction/transactionJSON"; -import { TransactionSummary } from "./models/transaction/transactionSummary"; +import { TransactionObject } from "./models/transaction/transactionObject"; import { TransitionJSON } from "./models/transition/transitionJSON"; import { TransitionObject } from "./models/transition/transitionObject"; import { @@ -97,24 +99,30 @@ export { BlockJSON, BlockHeightSearch, CachedKeyPair, + DeploymentMetadata, ExecutionJSON, FunctionObject, FunctionKeyPair, FunctionKeyProvider, + Header, InputJSON, InputObject, KeySearchParams, + Metadata, NetworkRecordProvider, ProgramImports, OfflineKeyProvider, OfflineSearchParams, PlaintextArray, PlaintextLiteral, + PlaintextObject, PlaintextStruct, OutputJSON, OutputObject, RecordProvider, RecordSearchParams, TransactionJSON, - TransactionSummary, + TransactionObject, + TransitionJSON, + TransitionObject, }; diff --git a/sdk/src/models/confirmed_transaction.ts b/sdk/src/models/confirmed_transaction.ts index a2546a775..9595947fa 100644 --- a/sdk/src/models/confirmed_transaction.ts +++ b/sdk/src/models/confirmed_transaction.ts @@ -1,6 +1,6 @@ import { TransactionJSON } from "./transaction/transactionJSON"; -export type ConfirmedTransaction = { +export interface ConfirmedTransaction { type: string; id: string; transaction: TransactionJSON; diff --git a/sdk/src/models/deploy.ts b/sdk/src/models/deploy.ts index 00229966e..57e8e89c6 100644 --- a/sdk/src/models/deploy.ts +++ b/sdk/src/models/deploy.ts @@ -1,6 +1,6 @@ import { FunctionObject } from "./functionObject"; -export type DeploymentMetadata = { +export interface DeploymentMetadata { "programId" : string, "functions" : FunctionObject[] } \ No newline at end of file diff --git a/sdk/src/models/executionJSON.ts b/sdk/src/models/executionJSON.ts index ce8f5bdf3..1088d0652 100644 --- a/sdk/src/models/executionJSON.ts +++ b/sdk/src/models/executionJSON.ts @@ -1,6 +1,6 @@ import { TransitionJSON } from "./transition/transitionJSON"; -export type ExecutionJSON = { +export interface ExecutionJSON { edition: number; transitions?: (TransitionJSON)[]; } diff --git a/sdk/src/models/functionObject.ts b/sdk/src/models/functionObject.ts index a6f0e232a..7ad9d68ff 100644 --- a/sdk/src/models/functionObject.ts +++ b/sdk/src/models/functionObject.ts @@ -1,6 +1,6 @@ -import { VerifyingKey } from "@provablehq/wasm"; +import { VerifyingKey } from "../wasm"; -export type FunctionObject = { +export interface FunctionObject { "name" : string, "constraints" : number, "variables" : number, diff --git a/sdk/src/models/input/inputJSON.ts b/sdk/src/models/input/inputJSON.ts index a98107ffa..d5b16f153 100644 --- a/sdk/src/models/input/inputJSON.ts +++ b/sdk/src/models/input/inputJSON.ts @@ -1,7 +1,7 @@ /** * Object representation of an Input as raw JSON returned from a SnarkOS node. */ -export type InputJSON = { +export interface InputJSON { type: string; id: string; tag?: string; diff --git a/sdk/src/models/input/inputObject.ts b/sdk/src/models/input/inputObject.ts index 8ad9c3080..4dc3a2ce3 100644 --- a/sdk/src/models/input/inputObject.ts +++ b/sdk/src/models/input/inputObject.ts @@ -1,14 +1,13 @@ /** * Aleo function Input represented as a typed typescript object. */ -import { Ciphertext, Field } from "@provablehq/wasm"; -import { Plaintext } from "@provablehq/wasm/mainnet.js"; +import { Ciphertext, Field, Plaintext } from "../../wasm"; import { PlaintextObject } from "../plaintext/plaintext"; /** * Object representation of an Input as raw JSON returned from a SnarkOS node. */ -export type InputObject = { +export interface InputObject { type: "string", id: "string" | Field, tag?: string | Field, diff --git a/sdk/src/models/output/outputJSON.ts b/sdk/src/models/output/outputJSON.ts index abf2acfed..45098f64b 100644 --- a/sdk/src/models/output/outputJSON.ts +++ b/sdk/src/models/output/outputJSON.ts @@ -1,4 +1,4 @@ -export type OutputJSON = { +export interface OutputJSON { type: string; id: string; checksum: string; diff --git a/sdk/src/models/output/outputObject.ts b/sdk/src/models/output/outputObject.ts index edded8da4..6c0e9fad7 100644 --- a/sdk/src/models/output/outputObject.ts +++ b/sdk/src/models/output/outputObject.ts @@ -1,13 +1,13 @@ /** * Aleo function Input represented as a typed typescript object. */ -import { Field, Ciphertext, Plaintext } from "@provablehq/wasm"; +import { Field, Ciphertext, Plaintext } from "../../wasm"; import { PlaintextObject } from "../plaintext/plaintext"; /** * Object representation of an Input as raw JSON returned from a SnarkOS node. */ -export type OutputObject = { +export interface OutputObject { type: string, id: string | Field, value?: Ciphertext | Plaintext | PlaintextObject, diff --git a/sdk/src/models/plaintext/plaintext.ts b/sdk/src/models/plaintext/plaintext.ts index 103382af3..13719543a 100644 --- a/sdk/src/models/plaintext/plaintext.ts +++ b/sdk/src/models/plaintext/plaintext.ts @@ -2,4 +2,4 @@ import { PlaintextArray } from "./array"; import { PlaintextLiteral } from "./literal"; import { PlaintextStruct } from "./struct"; -export type PlaintextObject = PlaintextArray| PlaintextLiteral | PlaintextStruct \ No newline at end of file +export type PlaintextObject = PlaintextArray| PlaintextLiteral | PlaintextStruct; \ No newline at end of file diff --git a/sdk/src/models/transaction/transactionJSON.ts b/sdk/src/models/transaction/transactionJSON.ts index 57f75df2a..58bcadc53 100644 --- a/sdk/src/models/transaction/transactionJSON.ts +++ b/sdk/src/models/transaction/transactionJSON.ts @@ -1,6 +1,6 @@ import { ExecutionJSON } from "../executionJSON"; -export type TransactionJSON = { +export interface TransactionJSON { type: string; id: string; execution: ExecutionJSON; diff --git a/sdk/src/models/transaction/transactionSummary.ts b/sdk/src/models/transaction/transactionObject.ts similarity index 88% rename from sdk/src/models/transaction/transactionSummary.ts rename to sdk/src/models/transaction/transactionObject.ts index 9aecbef56..f92627fdb 100644 --- a/sdk/src/models/transaction/transactionSummary.ts +++ b/sdk/src/models/transaction/transactionObject.ts @@ -1,7 +1,7 @@ import { TransitionObject } from "../transition/transitionObject"; import { DeploymentMetadata } from "../deploy"; -export type TransactionSummary = { +export interface TransactionObject { id : string; type : string; fee : bigint; diff --git a/sdk/src/models/transition/transitionJSON.ts b/sdk/src/models/transition/transitionJSON.ts index a279ddbd8..eca98b00f 100644 --- a/sdk/src/models/transition/transitionJSON.ts +++ b/sdk/src/models/transition/transitionJSON.ts @@ -1,7 +1,7 @@ import { InputJSON } from "../input/inputJSON"; import { OutputJSON } from "../output/outputJSON"; -export type TransitionJSON = { +export interface TransitionJSON { id: string; program: string; function: string; diff --git a/sdk/src/models/transition/transitionObject.ts b/sdk/src/models/transition/transitionObject.ts index 88b4061f0..582f366a3 100644 --- a/sdk/src/models/transition/transitionObject.ts +++ b/sdk/src/models/transition/transitionObject.ts @@ -1,8 +1,8 @@ import { InputObject } from "../input/inputObject"; import { OutputObject } from "../output/outputObject"; -import { Field, Group } from "@provablehq/wasm"; +import { Field, Group } from "../../wasm"; -export type TransitionObject = { +export interface TransitionObject { id: string; program: string; functionName: string; diff --git a/sdk/src/network-client.ts b/sdk/src/network-client.ts index f88cea543..f7aebb195 100644 --- a/sdk/src/network-client.ts +++ b/sdk/src/network-client.ts @@ -672,6 +672,7 @@ class AleoNetworkClient { * * @param {string} transactionId * @example + * const transaction = networkClient.getTransactionObject("at1handz9xjrqeynjrr0xay4pcsgtnczdksz3e584vfsgaz0dh0lyxq43a4wj"); */ async getTransactionObject(transactionId: string): Promise { try { @@ -708,11 +709,8 @@ class AleoNetworkClient { */ async getTransactionObjects(height: number): Promise> { try { - return (await this.fetchData>("/block/" + height.toString() + "/transactions")) - .reduce>((acc, transaction) => { - acc.push(Transaction.fromString(transaction)); - return acc; - }, []); + const transactionStrings = await this.fetchData>(`/block/${height}/transactions`); + return transactionStrings.map(transaction => Transaction.fromString(transaction)); } catch (error) { throw new Error("Error fetching transactions."); } @@ -740,11 +738,8 @@ class AleoNetworkClient { */ async getTransactionObjectsInMempool(): Promise> { try { - return (await this.fetchData>("/memoryPool/transactions")) - .reduce>((acc, transaction) => { - acc.push(Transaction.fromString(transaction)); - return acc; - }, []); + const transactionStrings = await this.fetchData>("/memoryPool/transactions"); + return transactionStrings.map(transaction => Transaction.fromString(transaction)); } catch (error) { throw new Error("Error fetching transactions from mempool."); } diff --git a/sdk/tests/key-provider.test.ts b/sdk/tests/key-provider.test.ts index ba329a237..50562abd5 100644 --- a/sdk/tests/key-provider.test.ts +++ b/sdk/tests/key-provider.test.ts @@ -11,134 +11,133 @@ describe('KeyProvider', () => { }); describe('getKeys', () => { - // it('should not fetch invalid transfer keys', async () => { - // try { - // const keys = await keyProvider.transferKeys("invalid"); - // // This should never be reached - // expect(true).equal(false); - // } catch (e) { - // expect(e).instanceof(Error); - // } - // }); - // - // it('Should use cache when set and not use it when not', async () => { - // // Ensure the cache properly downloads and stores keys - // keyProvider.useCache(true); - // - // const [provingKey, verifyingKey] = await keyProvider.feePublicKeys(); - // expect(keyProvider.cache.size).equal(1); - // expect(provingKey).instanceof(ProvingKey); - // expect(verifyingKey).instanceof(VerifyingKey); - // - // const transferCacheKey = keyProvider.cache.keys().next().value; - // const [cachedProvingKey, cachedVerifyingKey] = keyProvider.cache.get(transferCacheKey!); - // expect(cachedProvingKey).instanceof(Uint8Array); - // expect(cachedVerifyingKey).instanceof(Uint8Array); - // - // // Ensure the functionKeys method to get the keys and that the cache is used to do so - // const [fetchedProvingKey, fetchedVerifyingKey] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public) - // expect(keyProvider.cache.size).equal(1); - // expect(fetchedProvingKey).instanceof(ProvingKey); - // expect(fetchedVerifyingKey).instanceof(VerifyingKey); - // - // // Clear the cache and turn it off to ensure the keys are re-downloaded and the cache is not used - // keyProvider.clearCache(); - // keyProvider.useCache(false); - // const [redownloadedProvingKey, redownloadedVerifyingKey] = await keyProvider.feePublicKeys(); - // expect(keyProvider.cache.size).equal(0); - // expect(redownloadedProvingKey).instanceof(ProvingKey); - // expect(redownloadedVerifyingKey).instanceof(VerifyingKey); - // }); - // - // it.skip("Should not fetch offline keys that haven't already been stored", async () => { - // // Download the credits.aleo function keys - // const [bondPublicProver, bondPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_public); - // const [claimUnbondPublicProver, claimUnbondVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.claim_unbond_public); - // const [feePrivateProver, feePrivateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_private); - // const [feePublicProver, feePublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public); - // const [joinProver, joinVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.join); - // const [setValidatorStateProver, setValidatorStateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.set_validator_state); - // const [splitProver, splitVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.split); - // const [transferPrivateProver, transferPrivateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private); - // const [transferPrivateToPublicProver, transferPrivateToPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private_to_public); - // const [transferPublicProver, transferPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public); - // const [transferPublicToPrivateProver, transferPublicToPrivateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_to_private); - // const [unbondPublicProver, unbondPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.unbond_public); - // - // // Ensure the insertion methods work as expected without throwing an exception - // offlineKeyProvider.insertBondPublicKeys(bondPublicProver); - // offlineKeyProvider.insertClaimUnbondPublicKeys(claimUnbondPublicProver); - // offlineKeyProvider.insertFeePrivateKeys(feePrivateProver); - // offlineKeyProvider.insertFeePublicKeys(feePublicProver); - // offlineKeyProvider.insertJoinKeys(joinProver); - // offlineKeyProvider.insertSetValidatorStateKeys(setValidatorStateProver); - // offlineKeyProvider.insertSplitKeys(splitProver); - // offlineKeyProvider.insertTransferPrivateKeys(transferPrivateProver); - // offlineKeyProvider.insertTransferPrivateToPublicKeys(transferPrivateToPublicProver); - // offlineKeyProvider.insertTransferPublicKeys(transferPublicProver); - // offlineKeyProvider.insertTransferPublicToPrivateKeys(transferPublicToPrivateProver); - // offlineKeyProvider.insertUnbondPublicKeys(unbondPublicProver); - // - // // Ensure the offline key provider methods for credits.aleo return the correct keys - // const [bondPublicProverLocal, bondPublicVerifierLocal] = await offlineKeyProvider.bondPublicKeys(); - // const [claimUnbondPublicProverLocal, claimUnbondVerifierLocal] = await offlineKeyProvider.claimUnbondPublicKeys(); - // const [feePrivateProverLocal, feePrivateVerifierLocal] = await offlineKeyProvider.feePrivateKeys(); - // const [feePublicProverLocal, feePublicVerifierLocal] = await offlineKeyProvider.feePublicKeys(); - // const [joinProverLocal, joinVerifierLocal] = await offlineKeyProvider.joinKeys(); - // const [splitProverLocal, splitVerifierLocal] = await offlineKeyProvider.splitKeys(); - // const [transferPrivateProverLocal, transferPrivateVerifierLocal] = await offlineKeyProvider.transferKeys("private"); - // const [transferPrivateToPublicProverLocal, transferPrivateToPublicVerifierLocal] = await offlineKeyProvider.transferKeys("privateToPublic"); - // const [transferPublicProverLocal, transferPublicVerifierLocal] = await offlineKeyProvider.transferKeys("public"); - // const [transferPublicToPrivateProverLocal, transferPublicToPrivateVerifierLocal] = await offlineKeyProvider.transferKeys("publicToPrivate"); - // const [unbondPublicProverLocal, unbondPublicVerifierLocal] = await offlineKeyProvider.unBondPublicKeys(); - // - // // Ensure the checksum of the recovered keys match those of the original keys - // expect(bondPublicProver.checksum()).equal(bondPublicProverLocal.checksum()); - // expect(bondPublicVerifier.checksum()).equal(bondPublicVerifierLocal.checksum()); - // expect(claimUnbondPublicProver.checksum()).equal(claimUnbondPublicProverLocal.checksum()); - // expect(claimUnbondVerifier.checksum()).equal(claimUnbondVerifierLocal.checksum()); - // expect(feePrivateProver.checksum()).equal(feePrivateProverLocal.checksum()); - // expect(feePrivateVerifier.checksum()).equal(feePrivateVerifierLocal.checksum()); - // expect(feePublicProver.checksum()).equal(feePublicProverLocal.checksum()); - // expect(feePublicVerifier.checksum()).equal(feePublicVerifierLocal.checksum()); - // expect(joinProver.checksum()).equal(joinProverLocal.checksum()); - // expect(joinVerifier.checksum()).equal(joinVerifierLocal.checksum()); - // expect(splitProver.checksum()).equal(splitProverLocal.checksum()); - // expect(splitVerifier.checksum()).equal(splitVerifierLocal.checksum()); - // expect(transferPrivateProver.checksum()).equal(transferPrivateProverLocal.checksum()); - // expect(transferPrivateVerifier.checksum()).equal(transferPrivateVerifierLocal.checksum()); - // expect(transferPrivateToPublicProver.checksum()).equal(transferPrivateToPublicProverLocal.checksum()); - // expect(transferPrivateToPublicVerifier.checksum()).equal(transferPrivateToPublicVerifierLocal.checksum()); - // expect(transferPublicProver.checksum()).equal(transferPublicProverLocal.checksum()); - // expect(transferPublicVerifier.checksum()).equal(transferPublicVerifierLocal.checksum()); - // expect(transferPublicToPrivateProver.checksum()).equal(transferPublicToPrivateProverLocal.checksum()); - // expect(transferPublicToPrivateVerifier.checksum()).equal(transferPublicToPrivateVerifierLocal.checksum()); - // expect(unbondPublicProver.checksum()).equal(unbondPublicProverLocal.checksum()); - // expect(unbondPublicVerifier.checksum()).equal(unbondPublicVerifierLocal.checksum()); - // - // // Ensure the recovered keys are of the correct type - // expect(bondPublicProverLocal.isBondPublicProver()).equal(true); - // expect(bondPublicVerifierLocal.isBondPublicVerifier()).equal(true); - // expect(claimUnbondPublicProverLocal.isClaimUnbondPublicProver()).equal(true); - // expect(claimUnbondVerifierLocal.isClaimUnbondPublicVerifier()).equal(true); - // expect(feePrivateProverLocal.isFeePrivateProver()).equal(true); - // expect(feePrivateVerifierLocal.isFeePrivateVerifier()).equal(true); - // expect(feePublicProverLocal.isFeePublicProver()).equal(true); - // expect(feePublicVerifierLocal.isFeePublicVerifier()).equal(true); - // expect(joinProverLocal.isJoinProver()).equal(true); - // expect(joinVerifierLocal.isJoinVerifier()).equal(true); - // expect(splitProverLocal.isSplitProver()).equal(true); - // expect(splitVerifierLocal.isSplitVerifier()).equal(true); - // expect(transferPrivateProverLocal.isTransferPrivateProver()).equal(true); - // expect(transferPrivateVerifierLocal.isTransferPrivateVerifier()).equal(true); - // expect(transferPrivateToPublicProverLocal.isTransferPrivateToPublicProver()).equal(true); - // expect(transferPrivateToPublicVerifierLocal.isTransferPrivateToPublicVerifier()).equal(true); - // expect(transferPublicProverLocal.isTransferPublicProver()).equal(true); - // expect(transferPublicVerifierLocal.isTransferPublicVerifier()).equal(true); - // expect(transferPublicToPrivateProverLocal.isTransferPublicToPrivateProver()).equal(true); - // expect(transferPublicToPrivateVerifierLocal.isTransferPublicToPrivateVerifier()).equal(true); - // expect(unbondPublicProverLocal.isUnbondPublicProver()).equal(true); - // expect(unbondPublicVerifierLocal.isUnbondPublicVerifier()).equal(true); - // }); + it('should not fetch invalid transfer keys', async () => { + try { + const keys = await keyProvider.transferKeys("invalid"); + // This should never be reached + expect(true).equal(false); + } catch (e) { + expect(e).instanceof(Error); + } + }); + it('Should use cache when set and not use it when not', async () => { + // Ensure the cache properly downloads and stores keys + keyProvider.useCache(true); + + const [provingKey, verifyingKey] = await keyProvider.feePublicKeys(); + expect(keyProvider.cache.size).equal(1); + expect(provingKey).instanceof(ProvingKey); + expect(verifyingKey).instanceof(VerifyingKey); + + const transferCacheKey = keyProvider.cache.keys().next().value; + const [cachedProvingKey, cachedVerifyingKey] = keyProvider.cache.get(transferCacheKey!); + expect(cachedProvingKey).instanceof(Uint8Array); + expect(cachedVerifyingKey).instanceof(Uint8Array); + + // Ensure the functionKeys method to get the keys and that the cache is used to do so + const [fetchedProvingKey, fetchedVerifyingKey] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public) + expect(keyProvider.cache.size).equal(1); + expect(fetchedProvingKey).instanceof(ProvingKey); + expect(fetchedVerifyingKey).instanceof(VerifyingKey); + + // Clear the cache and turn it off to ensure the keys are re-downloaded and the cache is not used + keyProvider.clearCache(); + keyProvider.useCache(false); + const [redownloadedProvingKey, redownloadedVerifyingKey] = await keyProvider.feePublicKeys(); + expect(keyProvider.cache.size).equal(0); + expect(redownloadedProvingKey).instanceof(ProvingKey); + expect(redownloadedVerifyingKey).instanceof(VerifyingKey); + }); + + it.skip("Should not fetch offline keys that haven't already been stored", async () => { + // Download the credits.aleo function keys + const [bondPublicProver, bondPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.bond_public); + const [claimUnbondPublicProver, claimUnbondVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.claim_unbond_public); + const [feePrivateProver, feePrivateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_private); + const [feePublicProver, feePublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.fee_public); + const [joinProver, joinVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.join); + const [setValidatorStateProver, setValidatorStateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.set_validator_state); + const [splitProver, splitVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.split); + const [transferPrivateProver, transferPrivateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private); + const [transferPrivateToPublicProver, transferPrivateToPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_private_to_public); + const [transferPublicProver, transferPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public); + const [transferPublicToPrivateProver, transferPublicToPrivateVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.transfer_public_to_private); + const [unbondPublicProver, unbondPublicVerifier] = await keyProvider.fetchCreditsKeys(CREDITS_PROGRAM_KEYS.unbond_public); + + // Ensure the insertion methods work as expected without throwing an exception + offlineKeyProvider.insertBondPublicKeys(bondPublicProver); + offlineKeyProvider.insertClaimUnbondPublicKeys(claimUnbondPublicProver); + offlineKeyProvider.insertFeePrivateKeys(feePrivateProver); + offlineKeyProvider.insertFeePublicKeys(feePublicProver); + offlineKeyProvider.insertJoinKeys(joinProver); + offlineKeyProvider.insertSetValidatorStateKeys(setValidatorStateProver); + offlineKeyProvider.insertSplitKeys(splitProver); + offlineKeyProvider.insertTransferPrivateKeys(transferPrivateProver); + offlineKeyProvider.insertTransferPrivateToPublicKeys(transferPrivateToPublicProver); + offlineKeyProvider.insertTransferPublicKeys(transferPublicProver); + offlineKeyProvider.insertTransferPublicToPrivateKeys(transferPublicToPrivateProver); + offlineKeyProvider.insertUnbondPublicKeys(unbondPublicProver); + + // Ensure the offline key provider methods for credits.aleo return the correct keys + const [bondPublicProverLocal, bondPublicVerifierLocal] = await offlineKeyProvider.bondPublicKeys(); + const [claimUnbondPublicProverLocal, claimUnbondVerifierLocal] = await offlineKeyProvider.claimUnbondPublicKeys(); + const [feePrivateProverLocal, feePrivateVerifierLocal] = await offlineKeyProvider.feePrivateKeys(); + const [feePublicProverLocal, feePublicVerifierLocal] = await offlineKeyProvider.feePublicKeys(); + const [joinProverLocal, joinVerifierLocal] = await offlineKeyProvider.joinKeys(); + const [splitProverLocal, splitVerifierLocal] = await offlineKeyProvider.splitKeys(); + const [transferPrivateProverLocal, transferPrivateVerifierLocal] = await offlineKeyProvider.transferKeys("private"); + const [transferPrivateToPublicProverLocal, transferPrivateToPublicVerifierLocal] = await offlineKeyProvider.transferKeys("privateToPublic"); + const [transferPublicProverLocal, transferPublicVerifierLocal] = await offlineKeyProvider.transferKeys("public"); + const [transferPublicToPrivateProverLocal, transferPublicToPrivateVerifierLocal] = await offlineKeyProvider.transferKeys("publicToPrivate"); + const [unbondPublicProverLocal, unbondPublicVerifierLocal] = await offlineKeyProvider.unBondPublicKeys(); + + // Ensure the checksum of the recovered keys match those of the original keys + expect(bondPublicProver.checksum()).equal(bondPublicProverLocal.checksum()); + expect(bondPublicVerifier.checksum()).equal(bondPublicVerifierLocal.checksum()); + expect(claimUnbondPublicProver.checksum()).equal(claimUnbondPublicProverLocal.checksum()); + expect(claimUnbondVerifier.checksum()).equal(claimUnbondVerifierLocal.checksum()); + expect(feePrivateProver.checksum()).equal(feePrivateProverLocal.checksum()); + expect(feePrivateVerifier.checksum()).equal(feePrivateVerifierLocal.checksum()); + expect(feePublicProver.checksum()).equal(feePublicProverLocal.checksum()); + expect(feePublicVerifier.checksum()).equal(feePublicVerifierLocal.checksum()); + expect(joinProver.checksum()).equal(joinProverLocal.checksum()); + expect(joinVerifier.checksum()).equal(joinVerifierLocal.checksum()); + expect(splitProver.checksum()).equal(splitProverLocal.checksum()); + expect(splitVerifier.checksum()).equal(splitVerifierLocal.checksum()); + expect(transferPrivateProver.checksum()).equal(transferPrivateProverLocal.checksum()); + expect(transferPrivateVerifier.checksum()).equal(transferPrivateVerifierLocal.checksum()); + expect(transferPrivateToPublicProver.checksum()).equal(transferPrivateToPublicProverLocal.checksum()); + expect(transferPrivateToPublicVerifier.checksum()).equal(transferPrivateToPublicVerifierLocal.checksum()); + expect(transferPublicProver.checksum()).equal(transferPublicProverLocal.checksum()); + expect(transferPublicVerifier.checksum()).equal(transferPublicVerifierLocal.checksum()); + expect(transferPublicToPrivateProver.checksum()).equal(transferPublicToPrivateProverLocal.checksum()); + expect(transferPublicToPrivateVerifier.checksum()).equal(transferPublicToPrivateVerifierLocal.checksum()); + expect(unbondPublicProver.checksum()).equal(unbondPublicProverLocal.checksum()); + expect(unbondPublicVerifier.checksum()).equal(unbondPublicVerifierLocal.checksum()); + + // Ensure the recovered keys are of the correct type + expect(bondPublicProverLocal.isBondPublicProver()).equal(true); + expect(bondPublicVerifierLocal.isBondPublicVerifier()).equal(true); + expect(claimUnbondPublicProverLocal.isClaimUnbondPublicProver()).equal(true); + expect(claimUnbondVerifierLocal.isClaimUnbondPublicVerifier()).equal(true); + expect(feePrivateProverLocal.isFeePrivateProver()).equal(true); + expect(feePrivateVerifierLocal.isFeePrivateVerifier()).equal(true); + expect(feePublicProverLocal.isFeePublicProver()).equal(true); + expect(feePublicVerifierLocal.isFeePublicVerifier()).equal(true); + expect(joinProverLocal.isJoinProver()).equal(true); + expect(joinVerifierLocal.isJoinVerifier()).equal(true); + expect(splitProverLocal.isSplitProver()).equal(true); + expect(splitVerifierLocal.isSplitVerifier()).equal(true); + expect(transferPrivateProverLocal.isTransferPrivateProver()).equal(true); + expect(transferPrivateVerifierLocal.isTransferPrivateVerifier()).equal(true); + expect(transferPrivateToPublicProverLocal.isTransferPrivateToPublicProver()).equal(true); + expect(transferPrivateToPublicVerifierLocal.isTransferPrivateToPublicVerifier()).equal(true); + expect(transferPublicProverLocal.isTransferPublicProver()).equal(true); + expect(transferPublicVerifierLocal.isTransferPublicVerifier()).equal(true); + expect(transferPublicToPrivateProverLocal.isTransferPublicToPrivateProver()).equal(true); + expect(transferPublicToPrivateVerifierLocal.isTransferPublicToPrivateVerifier()).equal(true); + expect(unbondPublicProverLocal.isUnbondPublicProver()).equal(true); + expect(unbondPublicVerifierLocal.isUnbondPublicVerifier()).equal(true); + }); }); }); diff --git a/sdk/tests/network-client.test.ts b/sdk/tests/network-client.test.ts index a92d73ce3..0c3afe229 100644 --- a/sdk/tests/network-client.test.ts +++ b/sdk/tests/network-client.test.ts @@ -1,10 +1,8 @@ import sinon from "sinon"; import { expect } from "chai"; -import { Account, BlockJSON, AleoNetworkClient, TransactionSummary, InputObject, OutputObject } from "../src/node"; -import {beaconPrivateKeyString} from "./data/account-data"; -import { Plaintext, Transition } from "@provablehq/wasm"; -import { TransitionObject } from "../src/models/transition/transitionObject"; -import { PlaintextObject } from "../src/models/plaintext/plaintext"; +import { Account, BlockJSON, AleoNetworkClient, TransactionObject, InputObject, OutputObject } from "../src/node"; +import { beaconPrivateKeyString } from "./data/account-data"; +import { Plaintext, PlaintextObject, Transition, TransitionObject } from "../src/node"; async function catchError(f: () => Promise): Promise { try { @@ -254,7 +252,7 @@ describe('NodeConnection', () => { if (transactions.length > 1) { const transaction = transactions[0]; const transition = transaction.transitions()[0]; - const summary = transactions[0].summary(true); + const summary = transactions[0].summary(true); // Ensure the transaction metadata was correctly computed. expect(transactions.length).equal(3); diff --git a/yarn.lock b/yarn.lock index a5503cb42..954a134c5 100644 --- a/yarn.lock +++ b/yarn.lock @@ -3403,9 +3403,9 @@ batch@0.6.1: resolved "https://registry.npmjs.org/batch/-/batch-0.6.1.tgz" integrity sha512-x+VAiMRL6UPkx+kudNvxTl6hB2XNNCG2r+7wixVfIYwu/2HKRXimwQyaumLjMveWvT2Hkd/cAJw+QBMfJ/EKVw== -better-docs@^2.7.2: +better-docs@^2.7.3: version "2.7.3" - resolved "https://registry.npmjs.org/better-docs/-/better-docs-2.7.3.tgz" + resolved "https://registry.yarnpkg.com/better-docs/-/better-docs-2.7.3.tgz#bdeec1b24514bc22562af2a277c2cf527abbe726" integrity sha512-OEk9e7RQUQbo1DmVo0mdsALZ+mT0SwIen7/DGnN4xKNktXKgz1j7+KQ2pObNHHVSFGu8YMQW/Ig1v6eiTkdnbw== dependencies: brace "^0.11.1" @@ -3724,9 +3724,9 @@ clean-css@^5.2.2, clean-css@~5.3.2: dependencies: source-map "~0.6.0" -clean-jsdoc-theme@^4.1.8: +clean-jsdoc-theme@^4.3.0: version "4.3.0" - resolved "https://registry.npmjs.org/clean-jsdoc-theme/-/clean-jsdoc-theme-4.3.0.tgz" + resolved "https://registry.yarnpkg.com/clean-jsdoc-theme/-/clean-jsdoc-theme-4.3.0.tgz#6cd55ff7b25ff6d1719ae0ff9f1cdb5ef07bf640" integrity sha512-QMrBdZ2KdPt6V2Ytg7dIt0/q32U4COpxvR0UDhPjRRKRL0o0MvRCR5YpY37/4rPF1SI1AYEKAWyof7ndCb/dzA== dependencies: "@jsdoc/salty" "^0.2.4"