Skip to content

Commit

Permalink
feat: update dependencies
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanosdev committed Nov 28, 2024
1 parent aaa02dd commit 52a3581
Show file tree
Hide file tree
Showing 10 changed files with 641 additions and 728 deletions.
2 changes: 1 addition & 1 deletion .bun-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
1.1.29
1.1.37
2 changes: 1 addition & 1 deletion .node-version
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v20.18.0
v22.11.0
Binary file modified bun.lockb
Binary file not shown.
41 changes: 31 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "pic-js",
"private": true,
"packageManager": "pnpm@9.12.1+sha256.91452fdfa46234ae447d46d5c4fc4e7e0a7058f90495c4b6f77f8beebbb154e3",
"packageManager": "pnpm@9.14.2+sha512.6e2baf77d06b9362294152c851c4f278ede37ab1eba3a55fda317a4a17b209f4dbb973fb250a77abc463a341fcb1f17f17cfa24091c4eb319cda0d9b84278387",
"workspaces": [
"packages/pic",
"examples/counter/tests",
Expand Down Expand Up @@ -30,19 +30,40 @@
"postinstall": "tar -xvf examples/nns_proxy/tests/state/nns_state.tar.gz -C examples/nns_proxy/tests/state"
},
"devDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/identity": "^1.4.0",
"@dfinity/principal": "^1.4.0",
"@types/jest": "^29.5.13",
"@types/node": "^20.16.10",
"@dfinity/agent": "^2.1.3",
"@dfinity/candid": "^2.1.3",
"@dfinity/identity": "^2.1.3",
"@dfinity/principal": "^2.1.3",
"@tsconfig/node22": "^22.0.0",
"@types/jest": "^29.5.14",
"@types/node": "^22.10.0",
"bip39": "^3.1.0",
"jest": "^29.7.0",
"npm-run-all": "^4.1.5",
"prettier": "3.1.0",
"prettier": "3.4.1",
"ts-jest": "^29.2.5",
"ts-node": "^10.9.2",
"typescript": "^5.6.2",
"vitest": "^1.6.0"
"typescript": "^5.7.2",
"vitest": "^2.1.6"
},
"overrides": {
"webpack-dev-middleware@<=5.3.3": ">=5.3.4",
"express@<4.19.2": ">=4.19.2",
"follow-redirects@<=1.15.5": ">=1.15.6",
"braces@<3.0.3": ">=3.0.3",
"ws@>=8.0.0 <8.17.1": ">=8.17.1",
"ws@>=7.0.0 <7.5.10": ">=7.5.10",
"webpack@>=5.0.0-alpha.0 <5.94.0": ">=5.94.0",
"body-parser@<1.20.3": ">=1.20.3",
"path-to-regexp@>=2.0.0 <3.3.0": ">=3.3.0",
"path-to-regexp@>=0.2.0 <1.9.0": ">=1.9.0",
"path-to-regexp@<0.1.10": ">=0.1.10",
"cookie@<0.7.0": ">=0.7.0",
"http-proxy-middleware@<2.0.7": ">=2.0.7",
"send@<0.19.0": ">=0.19.0",
"serve-static@<1.16.0": ">=1.16.0",
"express@<4.20.0": ">=4.20.0",
"cross-spawn@<6.0.6": ">=6.0.6",
"cross-spawn@>=7.0.0 <7.0.5": ">=7.0.5"
}
}
8 changes: 4 additions & 4 deletions packages/pic/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@
"bip39": "^3.1.0"
},
"peerDependencies": {
"@dfinity/agent": "^1.4.0",
"@dfinity/candid": "^1.4.0",
"@dfinity/identity": "^1.4.0",
"@dfinity/principal": "^1.4.0"
"@dfinity/agent": "^2.1.3",
"@dfinity/candid": "^2.1.3",
"@dfinity/identity": "^2.1.3",
"@dfinity/principal": "^2.1.3"
}
}
13 changes: 10 additions & 3 deletions packages/pic/src/management-canister.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { IDL } from '@dfinity/candid';
import { Principal } from '@dfinity/principal';
import { decodeCandid, isNil } from './util';

export const MANAGEMENT_CANISTER_ID = Principal.fromText('aaaaa-aa');

Expand Down Expand Up @@ -48,10 +49,16 @@ export interface CreateCanisterResponse {
export function decodeCreateCanisterResponse(
arg: Uint8Array,
): CreateCanisterResponse {
const [payload] = IDL.decode([CreateCanisterResponse], arg);
const payload = decodeCandid<CreateCanisterResponse>(
[CreateCanisterResponse],
arg,
);

// [TODO] - type check?
return payload as unknown as CreateCanisterResponse;
if (isNil(payload)) {
throw new Error('Failed to decode CreateCanisterResponse');
}

return payload;
}

const StartCanisterRequest = IDL.Record({
Expand Down
10 changes: 5 additions & 5 deletions packages/pic/src/util/candid.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
import { IDL, JsonValue } from '@dfinity/candid';
import { IDL } from '@dfinity/candid';
import { isNil } from './is-nil';

export function optional<T>(value: T | undefined | null): [] | [T] {
return isNil(value) ? [] : [value];
}

export function decodeCandid(
export function decodeCandid<T>(
types: IDL.Type[],
data: ArrayBufferLike,
): JsonValue | null {
): T | null {
const returnValues = IDL.decode(types, data);

switch (returnValues.length) {
case 0:
return null;
case 1:
return returnValues[0];
return returnValues[0] as T;
default:
return returnValues;
return returnValues as T;
}
}
6 changes: 2 additions & 4 deletions packages/pic/src/util/fs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,8 @@ export function tmpFile(filePath: string) {
return resolve(tmpdir(), filePath);
}

export async function readFileAsBytes(filePath: string): Promise<Uint8Array> {
const buffer = await readFile(filePath);

return Uint8Array.from(buffer);
export async function readFileAsBytes(filePath: string): Promise<Buffer> {
return await readFile(filePath);
}

export async function readFileAsString(filePath: string): Promise<string> {
Expand Down
Loading

0 comments on commit 52a3581

Please sign in to comment.