Skip to content

Commit e095923

Browse files
committed
working build
1 parent 75ac5aa commit e095923

File tree

13 files changed

+3075
-90
lines changed

13 files changed

+3075
-90
lines changed

packages/agent/src/actor.ts

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ import { pollForResponse, PollStrategyFactory, strategy } from './polling';
1414
import { Principal } from '@dfinity/principal';
1515
import { RequestId } from './request_id';
1616
import { toHex } from './utils/buffer';
17-
import { CreateCertificateOptions } from './certificate';
1817
import managementCanisterIdl from './canisters/management_idl';
1918
import _SERVICE from './canisters/management_service';
2019

@@ -130,11 +129,6 @@ export interface ActorConfig extends CallConfig {
130129
args: unknown[],
131130
callConfig: CallConfig,
132131
): Partial<CallConfig> | void;
133-
134-
/**
135-
* Polyfill for BLS Certificate verification in case wasm is not supported
136-
*/
137-
blsVerify?: CreateCertificateOptions['blsVerify'];
138132
}
139133

140134
// TODO: move this to proper typing when Candid support TypeScript.
@@ -308,7 +302,7 @@ export class Actor {
308302
func.annotations.push(ACTOR_METHOD_WITH_HTTP_DETAILS);
309303
}
310304

311-
this[methodName] = _createActorMethod(this, methodName, func, config.blsVerify);
305+
this[methodName] = _createActorMethod(this, methodName, func);
312306
}
313307
}
314308
}
@@ -369,12 +363,7 @@ export type ActorConstructor = new (config: ActorConfig) => ActorSubclass;
369363

370364
export const ACTOR_METHOD_WITH_HTTP_DETAILS = 'http-details';
371365

372-
function _createActorMethod(
373-
actor: Actor,
374-
methodName: string,
375-
func: IDL.FuncClass,
376-
blsVerify?: CreateCertificateOptions['blsVerify'],
377-
): ActorMethod {
366+
function _createActorMethod(actor: Actor, methodName: string, func: IDL.FuncClass): ActorMethod {
378367
let caller: (options: CallConfig, ...args: unknown[]) => Promise<unknown>;
379368
if (func.annotations.includes('query') || func.annotations.includes('composite_query')) {
380369
caller = async (options, ...args) => {
@@ -437,7 +426,7 @@ function _createActorMethod(
437426
}
438427

439428
const pollStrategy = pollingStrategyFactory();
440-
const responseBytes = await pollForResponse(agent, ecid, requestId, pollStrategy, blsVerify);
429+
const responseBytes = await pollForResponse(agent, ecid, requestId, pollStrategy);
441430
const shouldIncludeHttpDetails = func.annotations.includes(ACTOR_METHOD_WITH_HTTP_DETAILS);
442431

443432
if (responseBytes !== undefined) {

packages/agent/src/canisterStatus/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,6 @@ export type CanisterStatusOptions = {
9090
canisterId: Principal;
9191
agent: HttpAgent;
9292
paths?: Path[] | Set<Path>;
93-
blsVerify?: CreateCertificateOptions['blsVerify'];
9493
};
9594

9695
/**

packages/agent/src/certificate.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { AgentError } from './errors';
33
import { hash } from './request_id';
44
import { concat, fromHex, toHex } from './utils/buffer';
55
import { Principal } from '@dfinity/principal';
6-
import * as bls from './utils/bls';
6+
import { blsVerify } from '@dfinity/bls-verify';
77
import { decodeTime } from './utils/leb';
88

99
/**
@@ -170,15 +170,10 @@ export class Certificate {
170170
* @throws {CertificateVerificationError}
171171
*/
172172
public static async create(options: CreateCertificateOptions): Promise<Certificate> {
173-
let blsVerify = options.blsVerify;
174-
if (!blsVerify) {
175-
blsVerify = bls.blsVerify;
176-
}
177173
const cert = new Certificate(
178174
options.certificate,
179175
options.rootKey,
180176
options.canisterId,
181-
blsVerify,
182177
options.maxAgeInMinutes,
183178
);
184179

@@ -190,8 +185,6 @@ export class Certificate {
190185
certificate: ArrayBuffer,
191186
private _rootKey: ArrayBuffer,
192187
private _canisterId: Principal,
193-
private _blsVerify: VerifyFunc,
194-
// Default to 5 minutes
195188
private _maxAgeInMinutes: number = 5,
196189
) {
197190
this.cert = cbor.decode(new Uint8Array(certificate));
@@ -245,7 +238,7 @@ export class Certificate {
245238
}
246239

247240
try {
248-
sigVer = await this._blsVerify(new Uint8Array(key), new Uint8Array(sig), new Uint8Array(msg));
241+
sigVer = await blsVerify(new Uint8Array(key), new Uint8Array(sig), new Uint8Array(msg));
249242
} catch (err) {
250243
sigVer = false;
251244
}
@@ -263,7 +256,6 @@ export class Certificate {
263256
certificate: d.certificate,
264257
rootKey: this._rootKey,
265258
canisterId: this._canisterId,
266-
blsVerify: this._blsVerify,
267259
// Do not check max age for delegation certificates
268260
maxAgeInMinutes: Infinity,
269261
});

packages/agent/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export * from './der';
1111
export * from './fetch_candid';
1212
export * from './public_key';
1313
export * from './request_id';
14-
export * from './utils/bls';
1514
export * from './utils/buffer';
1615
export * from './utils/random';
1716
export * as polling from './polling';

packages/agent/src/polling/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,6 @@ export async function pollForResponse(
2929
strategy: PollStrategy,
3030
// eslint-disable-next-line
3131
request?: any,
32-
blsVerify?: CreateCertificateOptions['blsVerify'],
3332
): Promise<ArrayBuffer> {
3433
const path = [new TextEncoder().encode('request_status'), requestId];
3534
const currentRequest = request ?? (await agent.createReadStateRequest?.({ paths: [path] }));
@@ -39,7 +38,6 @@ export async function pollForResponse(
3938
certificate: state.certificate,
4039
rootKey: agent.rootKey,
4140
canisterId: canisterId,
42-
blsVerify,
4341
});
4442
const maybeBuf = cert.lookup([...path, new TextEncoder().encode('status')]);
4543
let status;

packages/agent/src/utils/bls.test.ts

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

packages/agent/src/utils/bls.ts

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

packages/bls-verify/README.md

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,4 @@ npm i --save @dfinity/bls-verify
2020

2121
```ts
2222
import { blsVerify } from '@dfinity/bls-verify';
23-
import { createActor, canisterId } from '../declarations/example';
24-
25-
const exampleActor = createActor(canisterId, {
26-
actorOptions: {
27-
blsVerify,
28-
},
29-
});
3023
```

packages/bls-verify/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
"bugs": {
1414
"url": "https://github.com/dfinity/agent-js/issues"
1515
},
16-
"type": "module",
1716
"keywords": [
1817
"internet computer",
1918
"ic",

packages/bls-verify/src/index.test.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ test('delegation works for canisters within the subnet range', async () => {
3333
certificate: fromHex(SAMPLE_CERT),
3434
rootKey: fromHex(IC_ROOT_KEY),
3535
canisterId: canisterId,
36-
blsVerify,
3736
}),
3837
).resolves.not.toThrow();
3938
}

0 commit comments

Comments
 (0)