Skip to content
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
1 change: 1 addition & 0 deletions docs/generated/changelog.html
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ <h1>Agent-JS Changelog</h1>
<section>
<h2>Version x.x.x</h2>
<ul>
<li>feat: new CustomPath class, better docs, and deprecating metadata path type for CanisterStatus</li>
<li>chore: adding new controller to snapshot for e2e canister status</li>
</ul>
<h2>Version 0.21.4</h2>
Expand Down
32 changes: 23 additions & 9 deletions packages/agent/src/canisterStatus/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,18 +52,31 @@ export type Status =
| null;

/**
* Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using {@link TextEncoder}
* Interface to define a custom path. Nested paths will be represented as individual buffers, and can be created from text using TextEncoder.
* @param {string} key the key to use to access the returned value in the canisterStatus map
* @param {ArrayBuffer[]} path the path to the desired value, represented as an array of buffers
* @param {string} decodeStrategy the strategy to use to decode the returned value
*/
export interface CustomPath {
key: string;
path: ArrayBuffer[] | string;
decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
export class CustomPath implements CustomPath {
public key: string;
public path: ArrayBuffer[] | string;
public decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw';
constructor(
key: string,
path: ArrayBuffer[] | string,
decodeStrategy: 'cbor' | 'hex' | 'leb128' | 'utf-8' | 'raw',
) {
this.key = key;
this.path = path;
this.decodeStrategy = decodeStrategy;
}
}

/**
* Interface to request metadata from the icp:public or icp:private sections.
* Similar to {@link CustomPath}, but accepts a simple string argument.
* Private metadata will require the ${@link Identity} used by the ${@link HttpAgent} will need to be requested using an identity that controlls the canister.
* @deprecated Use {@link CustomPath} instead
* @param {string} key the key to use to access the returned value in the canisterStatus map
* @param {string} path the path to the desired value, represented as a string
* @param {string} decodeStrategy the strategy to use to decode the returned value
*/
export interface MetaData {
kind: 'metadata';
Expand Down Expand Up @@ -94,7 +107,8 @@ export type CanisterStatusOptions = {
};

/**
*
* Request information in the request_status state tree for a given canister.
* Can be used to request information about the canister's controllers, time, module hash, candid interface, and more.
* @param {CanisterStatusOptions} options {@link CanisterStatusOptions}
* @param {CanisterStatusOptions['canisterId']} options.canisterId {@link Principal}
* @param {CanisterStatusOptions['agent']} options.agent {@link HttpAgent} optional authenticated agent to use to make the canister request. Useful for accessing private metadata under icp:private
Expand Down
4 changes: 1 addition & 3 deletions packages/agent/src/certificate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ export function hashTreeToString(tree: HashTree): string {
}
}

interface Delegation extends Record<string, any> {
interface Delegation extends Record<string, unknown> {
subnet_id: ArrayBuffer;
certificate: ArrayBuffer;
}
Expand Down Expand Up @@ -153,8 +153,6 @@ export interface CreateCertificateOptions {
maxAgeInMinutes?: number;
}

type MetricsResult = number | bigint | Map<number, number | bigint> | undefined;

export class Certificate {
private readonly cert: Cert;

Expand Down