Socket
Socket
Sign inDemoInstall

4irelabs-blackchain-smart-contract

Package Overview
Dependencies
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

4irelabs-blackchain-smart-contract - npm Package Compare versions

Comparing version 0.0.51 to 0.0.52

2

dist/src/blackchainApi.d.ts

@@ -73,3 +73,3 @@ /// <reference types="node" />

getMaterialsByKey(address?: PublicKey): Promise<Materials | null>;
getConsumablesByKey(address?: PublicKey): Promise<Consumables | null>;
getConsumablesByKey(address: PublicKey): Promise<Consumables | null>;
getMaterials(address?: PublicKey): Promise<[PublicKey, Materials] | null>;

@@ -76,0 +76,0 @@ getConsumables(address?: PublicKey): Promise<[PublicKey, Consumables] | null>;

@@ -6,2 +6,2 @@ "use strict";

exports.KEY = "DfUYMPUztLXR7fZTVYMr46xrMyyyBHw4LP4Koogzyho3";
exports.cluster = constants_1.Cluster.testnet;
exports.cluster = constants_1.Cluster.localnet;

@@ -109,98 +109,109 @@ "use strict";

}));
// test("Hire character", async () => {
// //await bc.addRoom();
// let tx = await bc.hireCharacterWithoutSending("Dragon", ClassEnum.Templar);
test("Hire character", () => __awaiter(void 0, void 0, void 0, function* () {
//await bc.addRoom();
let tx = yield bc.hireCharacterWithoutSending("Dragon", types_1.ClassEnum.Templar);
expect(typeof tx).not.toBe("number");
yield bc.sendTransaction(tx[0]);
let character = yield bc.getCharacter(tx[1]);
expect(character).not.toBeNull();
character = character;
expect(character.name
.filter((ch) => ch !== 0)
.reduce((acc, ch) => acc + String.fromCharCode(ch), "")).toBe("Dragon");
expect(character.potions.map((x) => [
x.effectEnd.toString(),
(0, types_1.enumEq)(x.effect, types_1.PotionEnum.NoPotion),
])).toEqual([
["0", true],
["0", true],
["0", true],
["0", true],
["0", true],
]);
}));
test("Set character in tavern", () => __awaiter(void 0, void 0, void 0, function* () {
const player = (yield bc.getPlayerAccount());
let tx1 = yield bc.setCharacterWithoutSending(new web3_js_1.PublicKey(player.characters[0]));
expect(typeof tx1).not.toBe("number");
yield bc.sendTransaction(tx1);
let character = yield bc.getCharacter(player.characters[0]);
expect(character).not.toBeNull();
character = character;
console.log(character);
expect((0, types_1.enumEq)(character.status, types_1.StatusEnum.Close)).toBe(true);
}));
test("Blind raid", () => __awaiter(void 0, void 0, void 0, function* () {
for (let i = 0; i < 1; i++) {
const player = (yield bc.getPlayerAccount());
const characterBefore = (yield bc.getCharacter(player.characters[0]));
let tx = yield bc.blindRaid(types_1.DifficultyEnum.Easy, player.characters[0]);
expect(typeof tx).not.toBe("number");
let sign = yield bc.sendTransaction(tx[0]);
expect(typeof sign).toBe("string");
sign = sign;
let battleLog = yield bc.getBattleLog(sign);
expect(typeof battleLog).not.toBe("number");
battleLog = battleLog;
console.log(battleLog);
let initDungeon = yield bc.getInitialDungeon(sign);
expect(typeof initDungeon).not.toBe("number");
initDungeon = initDungeon;
if (battleLog.complete != 100) {
let dungeon = yield bc.getDungeon(tx[1]);
expect(dungeon).not.toBeNull();
dungeon = dungeon;
expect(battleLog.receivedExp.toString()).toBe(initDungeon.exp.sub(dungeon.exp).toString());
}
else {
expect(battleLog.receivedExp.toString()).toBe(initDungeon.exp.subn(0).toString());
}
const characterAfter = (yield bc.getCharacter(player.characters[0]));
expect(battleLog.receivedExp.toString()).toBe(characterAfter.experience.sub(characterBefore.experience).toString());
}
}));
// test("Use golds", async () => {
// let consumablesBefore = (await bc.getConsumables()) as [
// PublicKey,
// Consumables
// ];
// let gold = await bc.getGoldCount();
// expect(gold).not.toBeNull();
// gold = gold as BN;
// let tx = await bc.buyConsumableForGold(PotionEnum.RejuvenationHoneydew, 1);
// expect(typeof tx).not.toBe("number");
// await bc.sendTransaction(tx[0] as Buffer);
// let character = await bc.getCharacter(tx[1] as PublicKey);
// expect(character).not.toBeNull();
// character = character as Character;
// await bc.sendTransaction(tx as Buffer);
// expect(gold.subn(100).toString()).toBe((await bc.getGoldCount()).toString());
// let consumablesAfter = (await bc.getConsumables()) as [
// PublicKey,
// Consumables
// ];
// expect(
// character.name
// .filter((ch) => ch !== 0)
// .reduce((acc, ch) => acc + String.fromCharCode(ch), "")
// ).toBe("Dragon");
// consumablesBefore[1].consumables[
// consumablesTypeMap.get(JSON.stringify(PotionEnum.RejuvenationHoneydew))
// ].amount.toString()
// ).toBe("0");
// expect(
// character.potions.map((x) => [
// x.effectEnd.toString(),
// enumEq(x.effect, PotionEnum.NoPotion),
// ])
// ).toEqual([
// ["0", true],
// ["0", true],
// ["0", true],
// ["0", true],
// ["0", true],
// ]);
// });
// test("Set character in tavern", async () => {
// const player = (await bc.getPlayerAccount()) as PlayerAccount;
// let tx1 = await bc.setCharacterWithoutSending(
// new PublicKey(player.characters[0])
// consumablesBefore[1].consumables[
// consumablesTypeMap.get(JSON.stringify(PotionEnum.RejuvenationHoneydew))
// ].amount
// .addn(1)
// .toString()
// ).toBe(
// consumablesAfter[1].consumables[
// consumablesTypeMap.get(JSON.stringify(PotionEnum.RejuvenationHoneydew))
// ].amount.toString()
// );
// expect(typeof tx1).not.toBe("number");
// let tx1 = await bc.deleteConsumable(PotionEnum.RejuvenationHoneydew, 1);
// await bc.sendTransaction(tx1 as Buffer);
// let character = await bc.getCharacter(player.characters[0]);
// expect(character).not.toBeNull();
// character = character as Character;
// console.log(character);
// expect(enumEq(character.status, StatusEnum.Close)).toBe(true);
// consumablesAfter = (await bc.getConsumables()) as [PublicKey, Consumables];
// expect(
// consumablesBefore[1].consumables[
// consumablesTypeMap.get(JSON.stringify(PotionEnum.RejuvenationHoneydew))
// ].amount.toString()
// ).toBe(
// consumablesAfter[1].consumables[
// consumablesTypeMap.get(JSON.stringify(PotionEnum.RejuvenationHoneydew))
// ].amount.toString()
// );
// });
// test("Blind raid", async () => {
// for (let i = 0; i < 1; i++) {
// const player = (await bc.getPlayerAccount()) as PlayerAccount;
// const characterBefore = (await bc.getCharacter(
// player.characters[0]
// )) as Character;
// let tx = await bc.blindRaid(DifficultyEnum.Easy, player.characters[0]);
// expect(typeof tx).not.toBe("number");
// let sign = await bc.sendTransaction(tx[0] as Buffer);
// expect(typeof sign).toBe("string");
// sign = sign as string;
// let battleLog = await bc.getBattleLog(sign);
// expect(typeof battleLog).not.toBe("number");
// battleLog = battleLog as BattleLog;
// console.log(battleLog);
// let initDungeon = await bc.getInitialDungeon(sign);
// expect(typeof initDungeon).not.toBe("number");
// initDungeon = initDungeon as Dungeon;
// if (battleLog.complete != 100) {
// let dungeon = await bc.getDungeon(tx[1]);
// expect(dungeon).not.toBeNull();
// dungeon = dungeon as Dungeon;
// expect(battleLog.receivedExp.toString()).toBe(
// initDungeon.exp.sub(dungeon.exp).toString()
// );
// } else {
// expect(battleLog.receivedExp.toString()).toBe(
// initDungeon.exp.subn(0).toString()
// );
// }
// const characterAfter = (await bc.getCharacter(
// player.characters[0]
// )) as Character;
// expect(battleLog.receivedExp.toString()).toBe(
// characterAfter.experience.sub(characterBefore.experience).toString()
// );
// }
// });
test("Use golds", () => __awaiter(void 0, void 0, void 0, function* () {
let consumablesBefore = (yield bc.getConsumables());
let gold = yield bc.getGoldCount();
expect(gold).not.toBeNull();
gold = gold;
let tx = yield bc.buyConsumableForGold(types_1.PotionEnum.RejuvenationHoneydew, 1);
expect(typeof tx).not.toBe("number");
yield bc.sendTransaction(tx);
expect(gold.subn(100).toString()).toBe((yield bc.getGoldCount()).toString());
let consumablesAfter = (yield bc.getConsumables());
expect(consumablesBefore[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(types_1.PotionEnum.RejuvenationHoneydew))].amount.toString()).toBe("0");
expect(consumablesBefore[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(types_1.PotionEnum.RejuvenationHoneydew))].amount
.addn(1)
.toString()).toBe(consumablesAfter[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(types_1.PotionEnum.RejuvenationHoneydew))].amount.toString());
let tx1 = yield bc.deleteConsumable(types_1.PotionEnum.RejuvenationHoneydew, 1);
yield bc.sendTransaction(tx1);
consumablesAfter = (yield bc.getConsumables());
expect(consumablesBefore[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(types_1.PotionEnum.RejuvenationHoneydew))].amount.toString()).toBe(consumablesAfter[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(types_1.PotionEnum.RejuvenationHoneydew))].amount.toString());
}));
// test("Set weapon with bonus", async () => {

@@ -207,0 +218,0 @@ // let weapons = (await bc.getWeaponsList()) as [PublicKey, Weapon][];

{
"name": "4irelabs-blackchain-smart-contract",
"version": "0.0.51",
"version": "0.0.52",
"description": "Integration with Solana API",

@@ -5,0 +5,0 @@ "author": "",

Sorry, the diff of this file is too big to display

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc