Skip to content

Commit

Permalink
add: dynamic routing info (#4111)
Browse files Browse the repository at this point in the history
* add dynamic routing info

* fix sub conflict

* fix sub conflict

* fix sub conflict
  • Loading branch information
jessiemongeon1 authored Jan 28, 2025
1 parent bc7d283 commit b506c07
Show file tree
Hide file tree
Showing 6 changed files with 26 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,15 @@ import { MarkdownChipRow } from "/src/components/Chip/MarkdownChipRow";

<MarkdownChipRow labels={["Intermediate", "Agents" ]} />



The [ICP Rust agent](https://docs.rs/ic-agent/latest/ic_agent/) by DFINITY is a simple library that enables you to build applications and interact with ICP, serving as a low-level Rust backend for the IC SDK.

The agent is designed to be compatible with multiple versions of the replica API, exposing both low-level APIs for communicating with components like the replica and higher-level APIs for communicating with software applications deployed as canisters.

One example of a project that uses the [ICP Rust agent](https://docs.rs/ic-agent/latest/ic_agent/) is [dfx](https://github.com/dfinity/sdk).
One example of a project that uses the ICP Rust agent is [dfx](https://github.com/dfinity/sdk).

## Adding the agent as a dependency

To add the [ICP Rust agent](https://docs.rs/ic-agent/latest/ic_agent/) crate as a dependency in your project, use the command:
To add the ICP Rust agent crate as a dependency in your project, use the command:

```
cargo add ic-agent
Expand All @@ -41,6 +39,25 @@ pub async fn create_agent(url: &str, is_mainnet: bool) -> Result<Agent> {
}
```

### Using dynamic routing

The ICP Rust agent provides built-in dynamic routing functionality, allowing an application to communicate seamlessly via decentralized API boundary nodes for optimal performance. To enable dynamic routing, the agent needs to be initialized with a bootstrap URL. Using this initial URL, the agent will:

- Fetch the list of available API boundary nodes.
- Continuously monitor the health of these nodes.
- Automatically route requests to the closest healthy node.

Here’s an example of how to set up your agent with dynamic routing:

```rust
let agent = Agent::builder()
.with_url(URL)
.with_background_dynamic_routing()
.await
.build()
.expect("failed to build ic-agent");
```


## Authentication

Expand Down
2 changes: 1 addition & 1 deletion submodules/internetidentity
Submodule internetidentity updated 48 files
+1 −1 rust-toolchain.toml
+4 −2 src/frontend/generated/internet_identity_idl.js
+2 −1 src/frontend/generated/internet_identity_types.d.ts
+8 −2 src/frontend/src/components/alias/index.ts
+2 −1 src/frontend/src/components/promptUserNumber.ts
+2 −0 src/frontend/src/constants.ts
+7 −3 src/frontend/src/flows/addDevice/manage/addCurrentDevice.ts
+10 −2 src/frontend/src/flows/addDevice/manage/addDevice.ts
+3 −2 src/frontend/src/flows/addDevice/manage/pollForTentativeDevice.ts
+1 −1 src/frontend/src/flows/addDevice/registerCurrentDeviceCurrentOrigin.json
+16 −6 src/frontend/src/flows/addDevice/registerCurrentDeviceCurrentOrigin.ts
+2 −2 src/frontend/src/flows/authorize/index.ts
+18 −2 src/frontend/src/flows/manage/authenticatorsSection.ts
+8 −3 src/frontend/src/flows/manage/deviceSettings.ts
+108 −0 src/frontend/src/flows/manage/devicesFromDevicesWithUsage.test.ts
+64 −13 src/frontend/src/flows/manage/index.ts
+62 −56 src/frontend/src/flows/manage/migration.test.ts
+3 −0 src/frontend/src/flows/manage/types.ts
+10 −2 src/frontend/src/flows/recovery/recoverWith/device.ts
+56 −46 src/frontend/src/flows/recovery/recoveryWizard.test.ts
+21 −7 src/frontend/src/flows/recovery/recoveryWizard.ts
+18 −28 src/frontend/src/flows/recovery/setupRecovery.ts
+29 −8 src/frontend/src/flows/recovery/useRecovery.ts
+126 −0 src/frontend/src/storage/index.test.ts
+132 −0 src/frontend/src/storage/index.ts
+33 −4 src/frontend/src/test-e2e/flows.ts
+54 −1 src/frontend/src/test-e2e/recovery/index.test.ts
+3 −3 src/frontend/src/test-e2e/recovery/protected/reset.test.ts
+49 −5 src/frontend/src/test-e2e/views.ts
+7 −11 src/frontend/src/utils/authnMethodData.ts
+101 −0 src/frontend/src/utils/credential-devices.test.ts
+42 −0 src/frontend/src/utils/credential-devices.ts
+5 −6 src/frontend/src/utils/findWebAuthnRpId.ts
+384 −3 src/frontend/src/utils/iiConnection.test.ts
+47 −31 src/frontend/src/utils/iiConnection.ts
+4 −5 src/frontend/src/utils/webAuthn.ts
+11 −2 src/internet_identity/internet_identity.did
+1 −1 src/internet_identity/src/archive.rs
+15 −14 src/internet_identity/src/main.rs
+5 −3 src/internet_identity/src/openid.rs
+18 −7 src/internet_identity/src/openid/google.rs
+3 −3 src/internet_identity/src/state.rs
+6 −6 src/internet_identity/src/storage/storable_persistent_state.rs
+15 −10 src/internet_identity/tests/integration/config.rs
+4 −4 src/internet_identity/tests/integration/http.rs
+13 −1 src/internet_identity_interface/src/internet_identity/types.rs
+3 −3 src/showcase/src/pages/registerCurrentDeviceCurrentOrigin.astro
+4 −0 src/sig-verifier-js/Cargo.toml
2 changes: 1 addition & 1 deletion submodules/motoko
Submodule motoko updated 52 files
+25 −5 Changelog.md
+3 −2 doc/md/base/Debug.md
+10 −0 doc/md/base/ExperimentalInternetComputer.md
+1 −1 doc/md/base/OrderedMap.md
+1 −1 doc/md/base/OrderedSet.md
+1 −1 doc/md/base/RBTree.md
+58 −0 doc/md/base/Text.md
+26 −0 doc/md/canister-maintenance/memory.md
+5 −5 doc/md/getting-started/dev-env.md
+2 −13 nix/drun.nix
+10 −10 nix/sources.json
+58 −27 rts/motoko-rts/src/idl.rs
+21 −0 src/codegen/compile_classical.ml
+21 −0 src/codegen/compile_enhanced.ml
+2 −1 src/ir_def/arrange_ir.ml
+8 −2 src/ir_def/check_ir.ml
+7 −0 src/ir_def/construct.ml
+1 −0 src/ir_def/construct.mli
+2 −1 src/ir_def/freevars.ml
+1 −0 src/ir_def/ir.ml
+4 −2 src/ir_def/rename.ml
+4 −2 src/ir_passes/async.ml
+17 −5 src/ir_passes/await.ml
+4 −2 src/ir_passes/const.ml
+6 −2 src/ir_passes/eq.ml
+4 −2 src/ir_passes/erase_typ_field.ml
+6 −2 src/ir_passes/show.ml
+11 −4 src/lowering/desugar.ml
+3 −10 src/mo_frontend/typing.ml
+0 −2 src/mo_frontend/typing.mli
+19 −3 src/mo_types/type.ml
+5 −1 src/mo_types/type.mli
+27 −8 src/prelude/internals.mo
+1 −1 test/bench/ok/region-mem.drun-run.ok
+1 −1 test/bench/ok/region0-mem.drun-run.ok
+1 −1 test/bench/ok/stable-mem.drun-run.ok
+1 −1 test/fail/ok/M0129.tc.ok
+5 −5 test/fail/ok/illegal-await.tc.ok
+2 −2 test/run-drun/actor-class-mgmt-enhanced.mo
+23 −12 test/run-drun/call-raw.mo
+61 −0 test/run-drun/low-memory.mo
+27 −0 test/run-drun/low-memory/low-memory-actor.mo
+2 −2 test/run-drun/map-mixed-upgrades/map0.mo
+2 −2 test/run-drun/map-mixed-upgrades/map1.mo
+2 −2 test/run-drun/migration-paths/new-installer.mo
+2 −2 test/run-drun/migration-paths/old-installer.mo
+2 −2 test/run-drun/ok/call-raw.tc.ok
+6 −0 test/run-drun/ok/low-memory.drun-run.ok
+3 −0 test/run-drun/ok/tmp_upgrade.drun.ok
+3 −0 test/run-drun/tmp_upgrade.drun
+6 −0 test/run-drun/tmp_upgrade/version0.mo
+6 −0 test/run-drun/tmp_upgrade/version1.mo
2 changes: 1 addition & 1 deletion submodules/response-verfication
Submodule response-verfication updated 30 files
+0 −1 .cz.yaml
+0 −13 .github/actions/setup-dfx/action.yml
+0 −35 .github/actions/setup-pnpm/action.yml
+12 −10 .github/workflows/build-and-test.yml
+0 −29 .github/workflows/check-commit-messages.yml
+15 −0 .github/workflows/commitizen.yml
+25 −29 .github/workflows/create-release-pr.yml
+6 −7 .github/workflows/e2e-tests.yml
+14 −0 .github/workflows/generate-changelog.yml
+13 −8 .github/workflows/release.yml
+0 −42 .github/workflows/update-changelog.yml
+476 −403 Cargo.lock
+1 −0 Cargo.toml
+22 −1 README.md
+2 −0 packages/ic-asset-certification/Cargo.toml
+14 −9 packages/ic-asset-certification/src/asset_router.rs
+58 −0 packages/ic-asset-certification/tests/common/mod.rs
+193 −0 packages/ic-asset-certification/tests/large_assets.rs
+1 −0 packages/ic-http-certification-tests/Cargo.toml
+49 −49 packages/ic-http-certification-tests/tests/v1_response_verification.rs
+34 −25 packages/ic-http-certification-tests/tests/v2_response_verification_certification_scenarios.rs
+9 −8 packages/ic-http-certification-tests/tests/v2_response_verification_happy_path.rs
+54 −21 packages/ic-http-certification-tests/tests/v2_response_verification_sad_path.rs
+20 −0 packages/ic-http-certification/src/http/http_request.rs
+1 −0 packages/ic-response-verification/Cargo.toml
+91 −75 packages/ic-response-verification/src/error.rs
+30 −13 packages/ic-response-verification/src/validation/common_validation.rs
+82 −33 packages/ic-response-verification/src/validation/v2_validation.rs
+6 −6 packages/ic-response-verification/src/verification/certificate_header.rs
+27 −38 packages/ic-response-verification/src/verification/verify_request_response_pair.rs
2 changes: 1 addition & 1 deletion submodules/sdk
Submodule sdk updated 40 files
+24 −1 .github/workflows/e2e.yml
+49 −6 CHANGELOG.md
+23 −22 Cargo.lock
+3 −3 Cargo.toml
+3 −0 e2e/assets/hyphenated-project/Cargo.toml
+15 −0 e2e/assets/hyphenated-project/dfx.json
+8 −0 e2e/assets/hyphenated-project/hyphenated-bin/Cargo.toml
+6 −0 e2e/assets/hyphenated-project/hyphenated-bin/src/main.rs
+11 −0 e2e/assets/hyphenated-project/hyphenated-lib/Cargo.toml
+4 −0 e2e/assets/hyphenated-project/hyphenated-lib/src/lib.rs
+3 −0 e2e/assets/hyphenated-project/name.did
+43 −0 e2e/playwright/tests/react.spec.ts
+43 −0 e2e/playwright/tests/vanilla.spec.ts
+43 −0 e2e/playwright/tests/vue.spec.ts
+2 −1 e2e/tests-dfx/basic-project.bash
+14 −0 e2e/tests-dfx/build.bash
+2 −2 e2e/tests-dfx/call.bash
+11 −0 e2e/tests-dfx/deploy.bash
+5 −0 e2e/tests-dfx/new.bash
+16 −0 e2e/tests-dfx/wallet.bash
+75 −75 nix/sources.json
+9 −0 src/dfx-core/CHANGELOG.md
+1 −1 src/dfx-core/Cargo.toml
+1 −1 src/dfx/Cargo.toml
+53 −53 src/dfx/assets/dfx-asset-sources.toml
+1 −1 src/dfx/assets/project_templates/svelte/src/__frontend_name__/package.json
+6 −2 src/dfx/src/commands/canister/call.rs
+7 −7 src/dfx/src/commands/canister/status.rs
+2 −2 src/dfx/src/commands/canister/update_settings.rs
+60 −52 src/dfx/src/commands/new.rs
+5 −1 src/dfx/src/config/cache.rs
+5 −1 src/dfx/src/lib/canister_info/rust.rs
+33 −52 src/dfx/src/lib/diagnosis.rs
+0 −1 src/dfx/src/lib/manifest.rs
+1 −0 src/dfx/src/lib/models/canister.rs
+4 −4 src/dfx/src/lib/operations/canister/motoko_playground.rs
+1 −1 src/dfx/src/lib/operations/ledger.rs
+1 −1 src/dfx/src/lib/progress_bar.rs
+2 −1 src/dfx/src/lib/project/templates.rs
+35 −29 src/dfx/src/main.rs

0 comments on commit b506c07

Please sign in to comment.