Skip to content

Commit

Permalink
Merge pull request #915 from Pauan/feat/error-refactor
Browse files Browse the repository at this point in the history
Refactoring error handling
  • Loading branch information
jaketarnow authored Sep 19, 2024
2 parents 5b4f27d + 97442a9 commit 4f4dc8c
Show file tree
Hide file tree
Showing 31 changed files with 966 additions and 747 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/staging-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2024-05-14
toolchain: nightly-2024-08-12
override: true
components: rustfmt, rust-src

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test-website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2024-05-14
toolchain: nightly-2024-08-12
override: true
components: rustfmt, rust-src

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/website.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly-2024-05-14
toolchain: nightly-2024-08-12
override: true
components: rustfmt, rust-src

Expand Down
11 changes: 5 additions & 6 deletions create-leo-app/template-node-ts/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,14 @@ async function localProgramExecution(program, programName, aleoFunction, inputs)
programManager.setKeyProvider(keyProvider);

// Pre-synthesize the program keys and then cache them in memory using key provider
const keyPair = await programManager.synthesizeKeys(hello_hello_program, aleoFunction, inputs);
try {
const keyPair = await programManager.synthesizeKeys(hello_hello_program, aleoFunction, inputs);

if (keyPair instanceof Error) {
throw new Error(`Failed to synthesize keys: ${keyPair.message}`);
} else {
programManager.keyProvider.cacheKeys(`${programName}:${aleoFunction}`, keyPair);
}

programManager.keyProvider.cacheKeys(`${programName}:${aleoFunction}`, keyPair);
} catch (e) {
throw new Error(`Failed to synthesize keys: ${e.message}`);
}

// Specify parameters for the key provider to use search for program keys. In particular specify the cache key
// that was used to cache the keys in the previous step.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getLocalKey, preDownloadBondingKeys, preDownloadTransferKeys } from "./
await initThreadPool();

/// Build transfer public transaction without connection to the internet
async function buildTransferPublicTxOffline(recipientAddress: Address, amount: number, latestStateRoot: string, keyPaths: {}): Promise<Error | Transaction> {
async function buildTransferPublicTxOffline(recipientAddress: Address, amount: number, latestStateRoot: string, keyPaths: {}): Promise<Transaction> {
// Create an offline program manager
const programManager = new ProgramManager();

Expand Down Expand Up @@ -47,7 +47,7 @@ async function buildTransferPublicTxOffline(recipientAddress: Address, amount: n
}

/// Build bonding and unbonding transactions without connection to the internet
async function buildBondingTxOffline(stakerAddress: Address, validatorAddress: Address, withdrawalAddress: Address, amount: number, latestStateRoot: string, keyPaths: {}): Promise<Error | Transaction[]> {
async function buildBondingTxOffline(stakerAddress: Address, validatorAddress: Address, withdrawalAddress: Address, amount: number, latestStateRoot: string, keyPaths: {}): Promise<Transaction[]> {
// Create an offline program manager
const programManager = new ProgramManager();

Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[toolchain]
channel = "nightly-2024-05-14"
channel = "nightly-2024-08-12"
components = [ "rust-std", "rust-src" ]
targets = [ "wasm32-unknown-unknown" ]
2 changes: 1 addition & 1 deletion sdk/src/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ export class Account {
* Attempts to create an account from a private key ciphertext
* @param {PrivateKeyCiphertext | string} ciphertext
* @param {string} password
* @returns {PrivateKey | Error}
* @returns {PrivateKey}
*
* @example
* const ciphertext = PrivateKey.newEncrypted("password");
Expand Down
Loading

0 comments on commit 4f4dc8c

Please sign in to comment.