Skip to content

Commit

Permalink
add author_getFingerprint
Browse files Browse the repository at this point in the history
  • Loading branch information
clangenb committed Oct 9, 2024
1 parent 7b10058 commit 0693290
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 7 deletions.
3 changes: 2 additions & 1 deletion packages/types/src/interfaces/augment-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import type { AnnouncementSigner, Bip340, CidDigest, CidName, CommunityCeremony,
import type { EncointerBalanceTransferArgs, EncointerGetter, EncointerGetterArgs, EncointerPublicGetter, EncointerTrustedCall, EncointerTrustedCallSigned, EncointerTrustedGetter, EncointerTrustedGetterSigned, GrantReputationArgs, RegisterAttestationsArgs, RegisterParticipantArgs } from '@encointer/types/interfaces/encointerWorker';
import type { BalanceSetBalanceArgs, BalanceShieldArgs, BalanceTransferArgs, BalanceUnshieldArgs, IntegriteeGetter, IntegriteePublicGetter, IntegriteeTrustedCall, IntegriteeTrustedCallSigned, IntegriteeTrustedGetter, IntegriteeTrustedGetterSigned, IntegriteeTrustedOperation, TimestampSetArgs } from '@encointer/types/interfaces/integriteeWorker';
import type { SchedulerState, SystemNumber } from '@encointer/types/interfaces/scheduler';
import type { DirectRequestStatus, Enclave, GetterArgs, ParentchainId, Request, RpcReturnValue, ShardIdentifier, TrustedOperationStatus, Vault, WorkerEncoded } from '@encointer/types/interfaces/worker';
import type { DirectRequestStatus, Enclave, EnclaveFingerprint, GetterArgs, ParentchainId, Request, RpcReturnValue, ShardIdentifier, TrustedOperationStatus, Vault, WorkerEncoded } from '@encointer/types/interfaces/worker';
import type { Data, StorageKey } from '@polkadot/types';
import type { BitVec, Bool, Bytes, F32, F64, I128, I16, I256, I32, I64, I8, ISize, Json, Null, OptionBool, Raw, Text, Type, U128, U16, U256, U32, U64, U8, USize, bool, f32, f64, i128, i16, i256, i32, i64, i8, isize, u128, u16, u256, u32, u64, u8, usize } from '@polkadot/types-codec';
import type { TAssetConversion } from '@polkadot/types/interfaces/assetConversion';
Expand Down Expand Up @@ -426,6 +426,7 @@ declare module '@polkadot/types/types/registry' {
ElectionSize: ElectionSize;
ElectionStatus: ElectionStatus;
Enclave: Enclave;
EnclaveFingerprint: EnclaveFingerprint;
EncodedFinalityProofs: EncodedFinalityProofs;
EncodedJustification: EncodedJustification;
EncointerBalanceTransferArgs: EncointerBalanceTransferArgs;
Expand Down
1 change: 1 addition & 0 deletions packages/types/src/interfaces/worker/definitions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ export default {
rpc: {},
types: {
ShardIdentifier: 'Hash',
EnclaveFingerprint: 'H256',
GetterArgs: '(AccountId, CommunityIdentifier)',
Enclave: {
pubkey: 'AccountId',
Expand Down
5 changes: 4 additions & 1 deletion packages/types/src/interfaces/worker/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import type { CommunityIdentifier } from '@encointer/types/interfaces/community';
import type { Bytes, Enum, Struct, Text, bool, u64 } from '@polkadot/types-codec';
import type { ITuple } from '@polkadot/types-codec/types';
import type { AccountId, Hash } from '@polkadot/types/interfaces/runtime';
import type { AccountId, H256, Hash } from '@polkadot/types/interfaces/runtime';

/** @name DirectRequestStatus */
export interface DirectRequestStatus extends Enum {
Expand All @@ -23,6 +23,9 @@ export interface Enclave extends Struct {
readonly url: Text;
}

/** @name EnclaveFingerprint */
export interface EnclaveFingerprint extends H256 {}

/** @name GetterArgs */
export interface GetterArgs extends ITuple<[AccountId, CommunityIdentifier]> {}

Expand Down
4 changes: 2 additions & 2 deletions packages/worker-api/src/testUtils/networks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ export const localDockerNetwork = () => {
chain: 'ws://127.0.0.1:9944',
worker: 'wss://127.0.0.1:2000',
genesisHash: '0x388c446a804e24e77ae89f5bb099edb60cacc2ac7c898ce175bdaa08629c1439',
mrenclave: '9jm9Wm4DwGxsUUPA1cvcWWxyTuynpJ2YeEcNGnm8nztk',
chosenCid: '9jm9Wm4DwGxsUUPA1cvcWWxyTuynpJ2YeEcNGnm8nztk',
mrenclave: 'FtNhy2ZvHHDPZxHZY5atVav2VVkoipR3BE6zAbcveUcT',
chosenCid: 'FtNhy2ZvHHDPZxHZY5atVav2VVkoipR3BE6zAbcveUcT',
customTypes: {},
palletOverrides: {}
};
Expand Down
12 changes: 10 additions & 2 deletions packages/worker-api/src/worker.spec.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import { Keyring } from '@polkadot/api';
import { cryptoWaitReady } from '@polkadot/util-crypto';
import { paseoNetwork } from './testUtils/networks.js';
import {localDockerNetwork} from './testUtils/networks.js';
import { Worker } from './worker.js';
import WS from 'websocket';

const {w3cwebsocket: WebSocket} = WS;

describe('worker', () => {
const network = paseoNetwork();
const network = localDockerNetwork();
let keyring: Keyring;
let worker: Worker;
beforeAll(async () => {
Expand Down Expand Up @@ -51,5 +51,13 @@ describe('worker', () => {
expect(result).toBeDefined();
});
});

describe('getFingerprint', () => {
it('should return value', async () => {
const result = await worker.getFingerprint();
console.log('Fingerprint', result.toHuman());
expect(result).toBeDefined();
});
});
});
});
6 changes: 5 additions & 1 deletion packages/worker-api/src/worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import WebSocketAsPromised from 'websocket-as-promised';
import {options as encointerOptions} from '@encointer/node-api';
import {parseI64F64} from '@encointer/util';

import type {Vault} from '@encointer/types';
import type {Vault, EnclaveFingerprint} from '@encointer/types';

import {type RequestOptions, type IWorker, Request, type WorkerOptions} from './interface.js';
import {parseBalance} from './parsers.js';
Expand Down Expand Up @@ -162,4 +162,8 @@ export class Worker extends WebSocketAsPromised implements IWorker {
public async getShardVault(options: RequestOptions = {} as RequestOptions): Promise<Vault> {
return await callGetter<Vault>(this, [Request.Worker, 'author_getShardVault', 'Vault'], {}, options)
}

public async getFingerprint(options: RequestOptions = {} as RequestOptions): Promise<EnclaveFingerprint> {
return await callGetter<EnclaveFingerprint>(this, [Request.Worker, 'author_getFingerprint', 'EnclaveFingerprint'], {}, options)
}
}

0 comments on commit 0693290

Please sign in to comment.