Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: agent-js v2.0.0 #679

Merged
merged 8 commits into from
Aug 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@
- Provide a new utility to convert Candid `Nat` to `BigInt`. This utility is useful for interpreting the fees provided by the SNS Aggregator.
- Support conversion of `InstallCode`, `StopOrStartCanister` and `UpdateCanisterSettings` actions, `SetVisibility` neuron operation, and `Neuron::visibility` attribute.

## Build

- Upgrade `agent-js` dependencies to `v2.0.0`.

# 2024.07.22-0645Z

## Overview
Expand Down
96 changes: 48 additions & 48 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions packages/ckbtc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
],
"homepage": "https://github.com/dfinity/ic-js#readme",
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/cketh/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
],
"homepage": "https://github.com/dfinity/ic-js#readme",
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/cmc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@
],
"homepage": "https://github.com/dfinity/ic-js#readme",
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/ic-management/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@
],
"homepage": "https://github.com/dfinity/ic-js#readme",
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/ledger-icp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
],
"homepage": "https://github.com/dfinity/ic-js#readme",
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/ledger-icrc/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@
],
"homepage": "https://github.com/dfinity/ic-js#readme",
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/nns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@
"network-nervous-system"
],
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/ledger-icp": "^2.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
}
}
6 changes: 3 additions & 3 deletions packages/sns/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@
"sns"
],
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/ledger-icrc": "^2.4.0",
"@dfinity/principal": "^1.4.0",
"@dfinity/principal": "^2.0.0",
"@dfinity/utils": "^2.4.0"
},
"dependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/utils/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@
"service-nervous-system"
],
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/principal": "^1.4.0"
"@dfinity/agent": "^2.0.0",
"@dfinity/candid": "^2.0.0",
"@dfinity/principal": "^2.0.0"
}
}
11 changes: 3 additions & 8 deletions packages/utils/src/utils/agent.utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { nonNullish } from "./nullish.utils";
* @returns The default agent to use
*/
export const defaultAgent = (): Agent =>
new HttpAgent({
HttpAgent.createSync({
host: "https://icp-api.io",
identity: new AnonymousIdentity(),
});
Expand All @@ -34,16 +34,11 @@ export const createAgent = async ({
verifyQuerySignatures?: boolean;
retryTimes?: number;
}): Promise<HttpAgent> => {
const agent: HttpAgent = new HttpAgent({
return await HttpAgent.create({
mstrasinskis marked this conversation as resolved.
Show resolved Hide resolved
identity,
...(nonNullish(host) && { host }),
verifyQuerySignatures,
...(nonNullish(retryTimes) && { retryTimes }),
shouldFetchRootKey: fetchRootKey,
});

if (fetchRootKey) {
await agent.fetchRootKey();
}

return agent;
};
8 changes: 3 additions & 5 deletions scripts/refreshNeuron.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@ import fetch from "node-fetch";
import pkg from "../packages/nns/dist/index.cjs.js";
const { GovernanceCanister } = pkg;

const refreshNeuron = async (neuronId, fetchRotkey) => {
const refreshNeuron = async (neuronId, shouldFetchRootKey) => {
try {
const agent = new HttpAgent({
const agent = await HttpAgent.create({
fetch,
host: "https://ic0.app",
// host: "https://nnsdapp.dfinity.network",
shouldFetchRootKey,
});
if (fetchRotkey) {
await agent.fetchRootKey();
}
const canister = GovernanceCanister.create({
agent,
canisterId: Principal.fromText("rrkah-fqaaa-aaaaa-aaaaq-cai"),
Expand Down
2 changes: 1 addition & 1 deletion scripts/test-vectors/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import { MAINNET_GOVERNANCE_CANISTER_ID } from "../../packages/nns/src/constants
* - Change `sender` in the `createCallRequest` to the one commented.
*
* In the hardware-wallet-cli
* - `disableNonce: true` in `getAgent` when creating the `new HttpAgent(...)`.
* - `disableNonce: true` in `getAgent` when creating the `HttpAgent.create(...)`.
* - `console.log(Buffer.from(blob).toString("hex"));` inside the `sign` method in LedgerIdentity
*
* Go to cbor.me and decode both blobs.
Expand Down
Loading