Rename toB58String to getPeerId (#178)

This commit is contained in:
Pavel 2022-09-05 19:27:19 +03:00 committed by GitHub
parent 1ca867b802
commit 7408b07ed8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 18 additions and 18 deletions

View File

@ -32,4 +32,4 @@ service Sig("sig"):
verify(signature: []u8, data: []u8) -> bool
-- Gets service's public key.
get_pub_key() -> string
get_peer_id() -> string

View File

@ -1,6 +1,6 @@
{
"name": "@fluencelabs/fluence",
"version": "0.23.8",
"version": "0.24.0",
"description": "TypeScript implementation of Fluence Peer",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
@ -28,7 +28,7 @@
"@fluencelabs/avm": "0.27.0",
"@fluencelabs/connection": "workspace:0.2.0",
"@fluencelabs/interfaces": "workspace:0.1.0",
"@fluencelabs/keypair": "workspace:0.1.0",
"@fluencelabs/keypair": "workspace:0.2.0",
"@fluencelabs/marine-js": "0.3.9",
"async": "3.2.3",
"base64-js": "^1.5.1",

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.7.0-287
* Aqua version: 0.7.2-314
*
*/
import { Fluence, FluencePeer } from '../../index';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.7.0-285
* Aqua version: 0.7.2-314
*
*/
import { Fluence, FluencePeer } from '../../index';

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.7.0-285
* Aqua version: 0.7.2-314
*
*/
import { Fluence, FluencePeer } from '../../index';
@ -49,7 +49,7 @@ export function registerDataProvider(...args: any) {
}
export interface SigDef {
get_pub_key: (callParams: CallParams<null>) => string | Promise<string>;
get_peer_id: (callParams: CallParams<null>) => string | Promise<string>;
sign: (
data: number[],
callParams: CallParams<'data'>,
@ -73,7 +73,7 @@ export function registerSig(...args: any) {
functions: {
tag: 'labeledProduct',
fields: {
get_pub_key: {
get_peer_id: {
tag: 'arrow',
domain: {
tag: 'nil',

View File

@ -283,7 +283,7 @@ describe('Sig service tests', () => {
const res = await sig.sign(
testData,
makeTetraplet((await KeyPair.randomEd25519()).toB58String(), 'registry', 'get_key_bytes'),
makeTetraplet((await KeyPair.randomEd25519()).getPeerId(), 'registry', 'get_key_bytes'),
);
await expect(res.success).toBe(false);

View File

@ -3,7 +3,7 @@
* This file is auto-generated. Do not edit manually: changes may be erased.
* Generated by Aqua compiler: https://github.com/fluencelabs/aqua/.
* If you find any bugs, please write an issue on GitHub: https://github.com/fluencelabs/aqua/issues
* Aqua version: 0.7.0-285
* Aqua version: 0.7.2-314
*
*/
import { Fluence, FluencePeer } from '../../index';
@ -12,7 +12,7 @@ import { CallParams, callFunction, registerService } from '../../internal/compil
// Services
export interface SigDef {
get_pub_key: (callParams: CallParams<null>) => string | Promise<string>;
get_peer_id: (callParams: CallParams<null>) => string | Promise<string>;
sign: (
data: number[],
callParams: CallParams<'data'>,
@ -36,7 +36,7 @@ export function registerSig(...args: any) {
functions: {
tag: 'labeledProduct',
fields: {
get_pub_key: {
get_peer_id: {
tag: 'arrow',
domain: {
tag: 'nil',

View File

@ -91,8 +91,8 @@ export class Sig implements SigDef {
/**
* Gets the public key of KeyPair. Required by aqua
*/
get_pub_key() {
return this._keyPair.toB58String();
get_peer_id() {
return this._keyPair.getPeerId();
}
/**

View File

@ -126,7 +126,7 @@ export class EphemeralNetwork {
this._send(peer.getStatus().peerId!, nextPeerIds, particle);
};
const kp = await keyPairFromBase64Sk(x.sk);
if (kp.toB58String() !== x.peerId) {
if (kp.getPeerId() !== x.peerId) {
throw new Error(`Invalid config: peer id ${x.peerId} does not match the secret key ${x.sk}`);
}

View File

@ -1,6 +1,6 @@
{
"name": "@fluencelabs/keypair",
"version": "0.1.0",
"version": "0.2.0",
"description": "Keypair implementation for Fluence JS Peer",
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",

View File

@ -49,7 +49,7 @@ export class KeyPair {
return new KeyPair(lib2p2Pid);
}
toB58String(): string {
getPeerId(): string {
return this.Libp2pPeerId.toB58String();
}

2
pnpm-lock.yaml generated
View File

@ -62,7 +62,7 @@ importers:
'@fluencelabs/connection': workspace:0.2.0
'@fluencelabs/fluence-network-environment': ^1.0.13
'@fluencelabs/interfaces': workspace:0.1.0
'@fluencelabs/keypair': workspace:0.1.0
'@fluencelabs/keypair': workspace:0.2.0
'@fluencelabs/marine-js': 0.3.9
'@types/bs58': ^4.0.1
'@types/jest': ^27.5.1