Skip to content

Commit

Permalink
feat: upgrade node-api, authenticator for parachain.
Browse files Browse the repository at this point in the history
  • Loading branch information
benoitdevos committed Apr 5, 2024
1 parent 50a5d48 commit c0c4f38
Show file tree
Hide file tree
Showing 6 changed files with 32 additions and 24 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@logion/rest-api-core",
"version": "0.4.7",
"version": "0.4.8-1",
"repository": {
"type": "git",
"url": "git+https://github.com/logion-network/logion-rest-api-core.git"
Expand All @@ -26,7 +26,7 @@
"coverage": "nyc yarn run test"
},
"dependencies": {
"@logion/authenticator": "^0.5.5",
"@logion/authenticator": "^0.5.6-1",
"dinoloop": "^2.4.0",
"express": "^4.18.2",
"express-fileupload": "^1.4.0",
Expand All @@ -39,7 +39,7 @@
},
"devDependencies": {
"@istanbuljs/nyc-config-typescript": "^1.0.2",
"@logion/node-api": "^0.28.4-1",
"@logion/node-api": "^0.29.0-1",
"@tsconfig/node16": "^16.1.1",
"@types/express": "^4.17.14",
"@types/express-fileupload": "^1.4.1",
Expand Down
1 change: 0 additions & 1 deletion src/TestApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ import { buildBaseExpress } from "./Express.js";

export const ALICE = "5GrwvaEF5zXb26Fz9rcQpDWS57CtERHpNehXCPcNoHGKutQY";
export const BOB = "5FHneW46xGXgs5mUiveU4sbTyGBzmstUspZC92UhjJM694ty";
export const CHARLY = "5FLSigC9HGRKVhB9FiEo4Y3koPsNmBmLJbpXg2mp1hXcS59Y";

export * from "./TestUtil.js";

Expand Down
11 changes: 10 additions & 1 deletion src/TestUtil.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,24 @@
import { ValidAccountId, LogionNodeApiClass } from "@logion/node-api";
import { ApiPromise } from "@polkadot/api";

export const SS58_PREFIX = 2021;

export function mockLogionNodeApi(): LogionNodeApiClass {
const api = {
createType() {
return;
},
runtimeVersion: {
specName: { toString: () => "logion" },
specVersion: { toBigInt: () => 164n },
specVersion: { toBigInt: () => 3000n },
},
consts: {
system: {
ss58Prefix: {
toNumber: () => SS58_PREFIX
}
}
}
} as unknown as ApiPromise;
return new LogionNodeApiClass(api);
}
Expand Down
16 changes: 8 additions & 8 deletions test/AuthenticationController.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,13 @@ function mockDependenciesForAuth(container: Container, verifies: boolean, sessio
if(verifies) {
const signatures: SessionSignature[] = [
{
address: ALICE,
address: validAccountId(ALICE).address,
signature: "SIG_ALICE",
signedOn: requireDefined(DateTime.now().toISO()),
type: "POLKADOT",
},
{
address: BOB,
address: validAccountId(BOB).address,
signature: "SIG_BOB",
signedOn: requireDefined(DateTime.now().toISO()),
type: "POLKADOT",
Expand All @@ -256,13 +256,13 @@ function mockDependenciesForAuth(container: Container, verifies: boolean, sessio
const tokens: Token[] = [
{
type: "Polkadot",
address: ALICE,
address: validAccountId(ALICE).address,
value: TOKEN_ALICE,
expiredOn: DateTime.now(),
},
{
type: "Polkadot",
address: BOB,
address: validAccountId(BOB).address,
value: TOKEN_BOB,
expiredOn: DateTime.now(),
}
Expand All @@ -278,23 +278,23 @@ function mockDependenciesForAuth(container: Container, verifies: boolean, sessio
const sessionRepository = new Mock<SessionRepository>();
if (sessionExists) {
sessionRepository.setup(instance => instance.find(
It.Is<ValidAccountId>(accountId => accountId.address === ALICE && accountId.type === "Polkadot"),
It.Is<ValidAccountId>(accountId => accountId.address === validAccountId(ALICE).address && accountId.type === "Polkadot"),
SESSION_ID)
)
.returns(Promise.resolve(sessionAlice.object()))
sessionRepository.setup(instance => instance.find(
It.Is<ValidAccountId>(accountId => accountId.address === BOB && accountId.type === "Polkadot"),
It.Is<ValidAccountId>(accountId => accountId.address === validAccountId(BOB).address && accountId.type === "Polkadot"),
SESSION_ID)
)
.returns(Promise.resolve(sessionAlice.object()))
} else {
sessionRepository.setup(instance => instance.find(
It.Is<ValidAccountId>(accountId => accountId.address === ALICE && accountId.type === "Polkadot"),
It.Is<ValidAccountId>(accountId => accountId.address === validAccountId(ALICE).address && accountId.type === "Polkadot"),
SESSION_ID)
)
.returns(Promise.resolve(null))
sessionRepository.setup(instance => instance.find(
It.Is<ValidAccountId>(accountId => accountId.address === BOB && accountId.type === "Polkadot"),
It.Is<ValidAccountId>(accountId => accountId.address === validAccountId(BOB).address && accountId.type === "Polkadot"),
SESSION_ID)
)
.returns(Promise.resolve(null))
Expand Down
2 changes: 1 addition & 1 deletion test/TestUtil.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { validAccountId } from "../src/TestUtil.js";
describe("TestUtil", () => {

it("provides valid account ID", () => {
const address = "some-address";
const address = "vQwvFMsZRPEZDaMAZpApQMTgB6qvPSJhEJ2PHjSiwAa16ZsBk";
const account = validAccountId(address);
expect(account.address).toBe(address);
expect(account.type).toBe("Polkadot");
Expand Down
20 changes: 10 additions & 10 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -564,9 +564,9 @@ __metadata:
languageName: node
linkType: hard

"@logion/authenticator@npm:^0.5.5":
version: 0.5.5
resolution: "@logion/authenticator@npm:0.5.5"
"@logion/authenticator@npm:^0.5.6-1":
version: 0.5.6-1
resolution: "@logion/authenticator@npm:0.5.6-1"
dependencies:
"@ethersproject/transactions": ^5.7.0
"@multiversx/sdk-core": ^12.19.1
Expand All @@ -578,21 +578,21 @@ __metadata:
web3-utils: ^4.2.1
peerDependencies:
"@logion/node-api": 0.x
checksum: 13783c7d56a319eb7dba070f499c5eb9fc86d3db8c130412c98a2ed988196e59d9a1f86464c61fb68f86fa0108563c88e2f34c2c3dfcc251f6050e8ecfb5bf7d
checksum: 277d25608c976ac3e42710dc977f344739181d7ae271621a4c16bce5842ed13684a273a364b26df16a2b337f22a23628b9c773260bbac98a1077b14c83434298
languageName: node
linkType: hard

"@logion/node-api@npm:^0.28.4-1":
version: 0.28.4-1
resolution: "@logion/node-api@npm:0.28.4-1"
"@logion/node-api@npm:^0.29.0-1":
version: 0.29.0-1
resolution: "@logion/node-api@npm:0.29.0-1"
dependencies:
"@polkadot/api": ^10.12.2
"@polkadot/util": ^12.6.2
"@polkadot/util-crypto": ^12.6.2
"@types/uuid": ^9.0.2
fast-sha256: ^1.3.0
uuid: ^9.0.0
checksum: c790f99a0f85bdd8aa3d7f40e2b37b6f4a228b5e0753ce3565a9674a681ad4409f6aa53b735bb220890543d0287b3ef2fcee02feb3e997ce44a27824b6d33512
checksum: 6cc936d1866fef7cf05029ef9ebf097c836c9754587b5e528269d737007aefff577419c2f24f474f4ae40f283b7d2308907596649ca40bb022afeb3cca26051c
languageName: node
linkType: hard

Expand All @@ -601,8 +601,8 @@ __metadata:
resolution: "@logion/rest-api-core@workspace:."
dependencies:
"@istanbuljs/nyc-config-typescript": ^1.0.2
"@logion/authenticator": ^0.5.5
"@logion/node-api": ^0.28.4-1
"@logion/authenticator": ^0.5.6-1
"@logion/node-api": ^0.29.0-1
"@tsconfig/node16": ^16.1.1
"@types/express": ^4.17.14
"@types/express-fileupload": ^1.4.1
Expand Down

0 comments on commit c0c4f38

Please sign in to comment.