Skip to content

Commit 4919412

Browse files
committed
refactor: regenerate declarations with @icp-sdk/bindgen
Regenerate canister declaration files using @icp-sdk/bindgen@0.3.0, replacing the old dfx-generated index.js/index.d.ts boilerplate. - Replace createActor wrappers with direct Actor.createActor calls - Add new typed .ts declaration files generated by bindgen - Remove old .did, index.js, and index.d.ts files - Update import paths to use .did.js extensions and import type - Refine ByteBuf.inner type from Uint8Array | number[] to Uint8Array - Add null guards for canister IDs in tests - Update test host ports to 8000 - Reformat tsconfig.json, vite.config.ts, eslint.config.mjs
1 parent 714735c commit 4919412

25 files changed

+831
-354
lines changed

frontend/ic_vetkeys/CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,21 @@
1212

1313
### Changed
1414

15+
- **BREAKING** `DefaultEncryptedMapsClient` and `DefaultKeyManagerClient`
16+
constructors now accept an `HttpAgent` (from `@icp-sdk/core/agent`) instead of
17+
`HttpAgentOptions`. Since `HttpAgent.create()` is async, the agent must be
18+
created by the caller before being passed in — this avoids the deprecated
19+
`new HttpAgent(options)` constructor and allows full configuration upfront,
20+
including providing the network's root key for local development:
21+
22+
```ts
23+
const agent = await HttpAgent.create({
24+
host,
25+
identity,
26+
...(rootKey ? { rootKey } : {}), // rootKey from ic_env cookie in local dev
27+
});
28+
new DefaultEncryptedMapsClient(agent, canisterId);
29+
```
1530

1631
- Make `DerivedKeyMaterial.deriveAesGcmCryptoKey` `@internal`.
1732

@@ -27,7 +42,7 @@
2742

2843
### Changed
2944

30-
- Bump `@dfinity` agent-related packages to major version `3`.
45+
- Bump `@dfinity` agent-related packages to major version `3`.
3146

3247
## [0.3.0] - 2025-06-30
3348

@@ -44,9 +59,11 @@
4459
## [0.2.0] - 2025-06-08
4560

4661
### Fixed
62+
4763
- Links in code docs.
4864

4965
### Changed
66+
5067
- The code docs now live on github.io.
5168
- Replaces some instances of `window` with `globalThis` in a few places for better node compatibility.
5269

frontend/ic_vetkeys/eslint.config.mjs

Lines changed: 25 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import eslint from "@eslint/js";
44
import tseslint from "typescript-eslint";
55
import eslintPluginPrettierRecommended from "eslint-plugin-prettier/recommended";
6-
import { fileURLToPath } from 'url';
7-
import path from 'path';
6+
import { fileURLToPath } from "url";
7+
import path from "path";
88

99
const __dirname = path.dirname(fileURLToPath(import.meta.url));
1010

@@ -13,30 +13,30 @@ export default tseslint.config(
1313
tseslint.configs.recommendedTypeChecked,
1414
eslintPluginPrettierRecommended,
1515
{
16-
languageOptions: {
17-
parserOptions: {
18-
project: path.resolve(__dirname, "tsconfig.tests.json"),
19-
tsconfigRootDir: __dirname,
16+
languageOptions: {
17+
parserOptions: {
18+
project: path.resolve(__dirname, "tsconfig.tests.json"),
19+
tsconfigRootDir: __dirname,
20+
},
21+
},
22+
rules: {
23+
"@typescript-eslint/naming-convention": [
24+
"error",
25+
{
26+
selector: "variableLike",
27+
format: ["camelCase"],
28+
},
29+
{
30+
selector: "variable",
31+
modifiers: ["const"],
32+
format: ["camelCase", "UPPER_CASE"],
33+
},
34+
{
35+
selector: "typeLike",
36+
format: ["PascalCase"],
37+
},
38+
],
2039
},
21-
},
22-
rules: {
23-
'@typescript-eslint/naming-convention': [
24-
'error',
25-
{
26-
selector: 'variableLike',
27-
format: ['camelCase'],
28-
},
29-
{
30-
selector: 'variable',
31-
modifiers: ['const'],
32-
format: ['camelCase', 'UPPER_CASE'],
33-
},
34-
{
35-
selector: 'typeLike',
36-
format: ['PascalCase'],
37-
},
38-
],
39-
},
4040
},
4141
{
4242
ignores: [

frontend/ic_vetkeys/package.json

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
"module": "dist/lib/index.es.js",
5858
"typings": "dist/types/index.d.ts",
5959
"dependencies": {
60-
"@icp-sdk/core": "^5.0.0",
60+
"@icp-sdk/core": "^5.2.1",
6161
"idb-keyval": "^6.2.1"
6262
},
6363
"devDependencies": {
@@ -80,16 +80,16 @@
8080
},
8181
"scripts": {
8282
"build": "tsc && vite build",
83-
"prepare": "test -d dist || npm run build",
84-
"coverage": "npm run test:deploy_all && export $(cat .test1.env .test2.env | xargs) && vitest run --coverage",
83+
"prepare": "npm run build",
84+
"coverage": "npm run test:deploy_all && CANISTER_ID_IC_VETKEYS_MANAGER_CANISTER=$(cd $(git rev-parse --show-toplevel)/backend/rs/canisters && icp canister status ic_vetkeys_manager_canister -e local --id-only) CANISTER_ID_IC_VETKEYS_ENCRYPTED_MAPS_CANISTER=$(cd $(git rev-parse --show-toplevel)/backend/rs/canisters && icp canister status ic_vetkeys_encrypted_maps_canister -e local --id-only) vitest run --coverage",
8585
"lint": "eslint",
8686
"make:docs": "mkdir -p $(git rev-parse --show-toplevel)/docs/key_manager && mkdir -p $(git rev-parse --show-toplevel)/docs/encrypted_maps && typedoc --out $(git rev-parse --show-toplevel)/docs",
8787
"prettier": "prettier --write .",
8888
"prettier-check": "prettier --check .",
8989
"test_utils": "vitest utils",
90-
"test": "npm run test:deploy_all && export $(cat .test1.env .test2.env | xargs) && vitest --sequence.concurrent",
91-
"test:deploy_all": "npm run test:deploy_key_manager_canister && npm run test:deploy_encrypted_maps_canister",
92-
"test:deploy_key_manager_canister": "cd $(git rev-parse --show-toplevel)/backend/rs/canisters/ic_vetkeys_manager_canister && dfx start --clean --background; dfx deploy --argument '(\"dfx_test_key\")' ic_vetkeys_manager_canister && grep CANISTER_ID .env > $(git rev-parse --show-toplevel)/frontend/ic_vetkeys/.test1.env",
93-
"test:deploy_encrypted_maps_canister": "cd $(git rev-parse --show-toplevel)/backend/rs/canisters/ic_vetkeys_encrypted_maps_canister && dfx start --clean --background; dfx deploy --argument '(\"dfx_test_key\")' ic_vetkeys_encrypted_maps_canister && grep CANISTER_ID .env > $(git rev-parse --show-toplevel)/frontend/ic_vetkeys/.test2.env"
90+
"test": "npm run test:deploy_all && CANISTER_ID_IC_VETKEYS_MANAGER_CANISTER=$(cd $(git rev-parse --show-toplevel)/backend/rs/canisters && icp canister status ic_vetkeys_manager_canister -e local --id-only) CANISTER_ID_IC_VETKEYS_ENCRYPTED_MAPS_CANISTER=$(cd $(git rev-parse --show-toplevel)/backend/rs/canisters && icp canister status ic_vetkeys_encrypted_maps_canister -e local --id-only) vitest run --sequence.concurrent",
91+
"test:deploy_all": "cd $(git rev-parse --show-toplevel)/backend/rs/canisters && (icp network stop || true) && icp network start -d && icp deploy ic_vetkeys_manager_canister -e local && icp deploy ic_vetkeys_encrypted_maps_canister -e local",
92+
"test:deploy_key_manager_canister": "cd $(git rev-parse --show-toplevel)/backend/rs/canisters && (icp network stop || true) && icp network start -d && icp deploy ic_vetkeys_manager_canister -e local",
93+
"test:deploy_encrypted_maps_canister": "cd $(git rev-parse --show-toplevel)/backend/rs/canisters && (icp network stop || true) && icp network start -d && icp deploy ic_vetkeys_encrypted_maps_canister -e local"
9494
}
9595
}

frontend/ic_vetkeys/src/declarations/ic_vetkeys_encrypted_maps_canister/ic_vetkeys_encrypted_maps_canister.did

Lines changed: 0 additions & 41 deletions
This file was deleted.

frontend/ic_vetkeys/src/declarations/ic_vetkeys_encrypted_maps_canister/ic_vetkeys_encrypted_maps_canister.did.d.ts

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,19 @@
1-
import type { Principal } from '@icp-sdk/core/principal';
1+
/* eslint-disable */
2+
3+
// @ts-nocheck
4+
5+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
6+
// You should NOT make any changes in this file as it will be overwritten.
7+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
8+
29
import type { ActorMethod } from '@icp-sdk/core/agent';
310
import type { IDL } from '@icp-sdk/core/candid';
11+
import type { Principal } from '@icp-sdk/core/principal';
412

513
export type AccessRights = { 'Read' : null } |
614
{ 'ReadWrite' : null } |
715
{ 'ReadWriteManage' : null };
8-
export interface ByteBuf { 'inner' : Uint8Array | number[] }
16+
export interface ByteBuf { 'inner' : Uint8Array }
917
export interface EncryptedMapData {
1018
'access_control' : Array<[Principal, AccessRights]>,
1119
'keyvals' : Array<[ByteBuf, ByteBuf]>,
@@ -60,4 +68,4 @@ export interface _SERVICE {
6068
>,
6169
}
6270
export declare const idlFactory: IDL.InterfaceFactory;
63-
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];
71+
export declare const init: (args: { IDL: typeof IDL }) => IDL.Type[];

frontend/ic_vetkeys/src/declarations/ic_vetkeys_encrypted_maps_canister/ic_vetkeys_encrypted_maps_canister.did.js

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
/* eslint-disable */
2+
3+
// @ts-nocheck
4+
5+
// This file was automatically generated by @icp-sdk/bindgen@0.3.0.
6+
// You should NOT make any changes in this file as it will be overwritten.
7+
// Additionally, you should also exclude this file from your linter and/or formatter to prevent it from being checked or modified.
8+
9+
import { IDL } from '@icp-sdk/core/candid';
10+
111
export const idlFactory = ({ IDL }) => {
212
const ByteBuf = IDL.Record({ 'inner' : IDL.Vec(IDL.Nat8) });
313
const AccessRights = IDL.Variant({
@@ -26,6 +36,7 @@ export const idlFactory = ({ IDL }) => {
2636
'Err' : IDL.Text,
2737
});
2838
const Result_5 = IDL.Variant({ 'Ok' : IDL.Vec(ByteBuf), 'Err' : IDL.Text });
39+
2940
return IDL.Service({
3041
'get_accessible_shared_map_names' : IDL.Func(
3142
[],
@@ -103,4 +114,5 @@ export const idlFactory = ({ IDL }) => {
103114
),
104115
});
105116
};
106-
export const init = ({ IDL }) => { return []; };
117+
118+
export const init = ({ IDL }) => { return [IDL.Text]; };

0 commit comments

Comments
 (0)