Join our webinar on Wednesday, June 26, at 1pm EDTHow Chia Mitigates Risk in the Crypto Industry.Register
Socket
Socket
Sign inDemoInstall

4irelabs-blackchain-smart-contract

Package Overview
Dependencies
75
Maintainers
1
Versions
53
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 0.0.45 to 0.0.46

10

dist/src/blackchainApi.d.ts

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

scoutDungeonWithoutSending(difficulty: Difficulty, character: PublicKey): Promise<[Buffer, PublicKey] | BCError>;
usePotion(character: PublicKey, potion: Potion): Promise<Buffer>;
setWeaponWithoutSending(character: PublicKey, weapon: PublicKey): Promise<TransactionInstruction>;

@@ -102,4 +103,13 @@ setArmorWithoutSending(character: PublicKey, armor: PublicKey): Promise<TransactionInstruction>;

unsetCharacterWithoutSending(character: PublicKey): Promise<Buffer | BCError>;
deleteMaterial(type: MaterialType, amount: number): Promise<Buffer | BCError>;
deleteConsumable(type: Potion, amount: number): Promise<Buffer | BCError>;
changeCharacterLot(character: PublicKey, newPrice: number): Promise<Buffer | BCError>;
changeWeaponLot(weapon: PublicKey, newPrice: number): Promise<Buffer | BCError>;
changeArmorLot(armor: PublicKey, newPrice: number): Promise<Buffer | BCError>;
changeShieldLot(shield: PublicKey, newPrice: number): Promise<Buffer | BCError>;
changeDungeonLot(dungeon: PublicKey, newPrice: number): Promise<Buffer | BCError>;
changeConsumableLot(lot: PublicKey, newPrice: number, newAmount: number): Promise<Buffer | BCError>;
changeMaterialLot(lot: PublicKey, newPrice: number, newAmount: number): Promise<Buffer | BCError>;
}
declare type del<T extends boolean> = T extends false ? TransactionInstruction : Buffer | BCError;
export {};

9

dist/src/types.d.ts

@@ -6,4 +6,5 @@ import * as Anchor from "@project-serum/anchor";

declare type CharacterAccount = TypeDef<BlackchainProgram["accounts"]["1"], Anchor.IdlTypes<BlackchainProgram>>;
export declare type Character = Omit<CharacterAccount, "status"> & {
export declare type Character = Omit<CharacterAccount, "status" | "potions"> & {
status: Status;
potions: (PotionsEffect | null)[];
};

@@ -41,2 +42,6 @@ export declare type PlayerAccount = TypeDef<BlackchainProgram["accounts"]["7"], Anchor.IdlTypes<BlackchainProgram>>;

declare type ConsumablesAccount = TypeDef<BlackchainProgram["accounts"]["2"], Anchor.IdlTypes<BlackchainProgram>>;
declare type PotionsEffect = {
effect: Potion;
effectEnd: Anchor.BN;
};
export declare type Consumables = Omit<ConsumablesAccount, "consumables"> & {

@@ -1198,3 +1203,3 @@ consumables: {

export declare type Potion = typeof PotionEnum[keyof typeof PotionEnum];
export declare type UpgradeCharacter = TypeDef<BlackchainProgram["types"]["3"], Anchor.IdlTypes<BlackchainProgram>>;
export declare type UpgradeCharacter = TypeDef<BlackchainProgram["types"]["4"], Anchor.IdlTypes<BlackchainProgram>>;
export declare type UpgradeStats = {

@@ -1201,0 +1206,0 @@ [k in keyof UpgradeCharacter]+?: UpgradeCharacter[keyof UpgradeCharacter];

@@ -1,2 +0,2 @@

export declare const KEY = "5mFLtdYokuVKeo25McVdNyCmWZ68pystcAeBSZCCEdpb";
export declare const KEY = "DfUYMPUztLXR7fZTVYMr46xrMyyyBHw4LP4Koogzyho3";
export declare const cluster: string;

@@ -5,3 +5,3 @@ "use strict";

const constants_1 = require("../src/constants");
exports.KEY = "5mFLtdYokuVKeo25McVdNyCmWZ68pystcAeBSZCCEdpb";
exports.KEY = "DfUYMPUztLXR7fZTVYMr46xrMyyyBHw4LP4Koogzyho3";
exports.cluster = constants_1.Cluster.localnet;

@@ -23,4 +23,3 @@ "use strict";

let bc;
jest.setTimeout(1000 * 1000);
//describe("Tests:", () => {
jest.setTimeout(1000000 * 1000);
beforeAll(() => {

@@ -43,2 +42,4 @@ let keypair = new web3_js_1.Keypair();

test("Create player account", () => __awaiter(void 0, void 0, void 0, function* () {
console.log(yield bc.getPlayerAccount(new web3_js_1.PublicKey("BgfXjkCaTB9cfg7SfQGBpdnJBGnQPMoDTF6Skd9w9PEy")));
console.log(yield bc.getPlayerAccount(new web3_js_1.PublicKey("2vw8Hia8E9DEurAzMhySZbj9nZfJtaEnTiT8AJjS8GiM")));
yield bc.createPlayerAccount();

@@ -107,32 +108,70 @@ const player = yield bc.getPlayerAccount();

expect((0, types_1.enumEq)(character.status, types_1.StatusEnum.Close)).toBe(true);
expect(character.potions).toEqual([null, null, null, null, null]);
}));
test("Blind raid", () => __awaiter(void 0, void 0, void 0, function* () {
for (let i = 0; i < 10; i++) {
const player = (yield bc.getPlayerAccount());
const characterBefore = (yield bc.getCharacter(player.characters[0]));
let tx = yield bc.blindRaid(types_1.DifficultyEnum.Hard, player.characters[0], [
types_1.PotionEnum.ArtisansPotion,
]);
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;
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());
// for (let i = 0; i < 10; i++) {
const player = (yield bc.getPlayerAccount());
const characterBefore = (yield bc.getCharacter(player.characters[0]));
let tx = yield bc.blindRaid(types_1.DifficultyEnum.Hard, 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;
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());
// // console.log(
// // await Promise.all(
// // battleLog.items
// // .filter((x) => enumEq(x.artifactType, ArtifactTypeEnum.Weapon))
// // .map(async (x) => (await bc.getWeapon(x.key))?.weaponTyp)
// // )
// // );
// // console.log(
// // await Promise.all(
// // battleLog.items
// // .filter((x) => enumEq(x.artifactType, ArtifactTypeEnum.Armor))
// // .map(async (x) => (await bc.getArmor(x.key))?.armorTyp)
// // )
// // );
// // console.log(
// // await Promise.all(
// // battleLog.items
// // .filter((x) => enumEq(x.artifactType, ArtifactTypeEnum.Shield))
// // .map(async (x) => (await bc.getShield(x.key))?.typ)
// // )
// // );
// console.log(initDungeon.branches.map((x) => x.enemy?.typ));
// }
}));
test("Set weapon with bonus", () => __awaiter(void 0, void 0, void 0, function* () {
let weapons = (yield bc.getWeaponsList());
let character = (yield bc.getCharactersList())[0];
for (let w of weapons) {
if ((0, types_1.enumEq)(w[1].rank, types_1.RankEnum.Rare) ||
(0, types_1.enumEq)(w[1].rank, types_1.RankEnum.Epic) ||
(0, types_1.enumEq)(w[1].rank, types_1.RankEnum.Legendary) ||
(0, types_1.enumEq)(w[1].rank, types_1.RankEnum.Mythic)) {
let tx = yield bc.unsetWeaponWithoutSending(character[0], character[1].rightHand);
yield bc.sendTransaction(yield bc.instructionsToBuffer([tx]));
let tx1 = yield bc.setWeaponWithoutSending(character[0], w[0]);
yield bc.sendTransaction(yield bc.instructionsToBuffer([tx1]));
console.log(w[1].bonuses);
console.log(yield bc.getCharacter(character[0]));
break;
}
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());
console.log(battleLog.items);
}

@@ -143,4 +182,4 @@ }));

// for (let m of materials.materials) {
// if (m.amount.gtn(0)) {
// let tx = await bc.lockMaterial(0.01, 1, m.typ);
// if (m.amount.gtn(1)) {
// let tx = await bc.lockMaterial(0.001, 2, m.typ);
// expect(typeof tx).not.toBe("number");

@@ -151,2 +190,12 @@ // await bc.sendTransaction(tx[0] as Buffer);

// lot = lot as MaterialLot;
// expect(lot.amount.toNumber()).toBe(2);
// expect(enumEq(lot.typ, m.typ)).toBe(true);
// expect(lot.price.toNumber()).toBe(0.001 * 10 ** 9);
// expect(lot.isInitialized).toBe(true);
// let tx1 = await bc.changeMaterialLot(tx[1], 0.01, 1);
// expect(typeof tx).not.toBe("number");
// await bc.sendTransaction(tx1 as Buffer);
// lot = await bc.getMaterialLot(tx[1]);
// expect(lot).not.toBeNull();
// lot = lot as MaterialLot;
// expect(lot.amount.toNumber()).toBe(1);

@@ -183,2 +232,12 @@ // expect(enumEq(lot.typ, m.typ)).toBe(true);

// );
// tx1 = await bcBuyer.deleteMaterial(m.typ, 1);
// await bcBuyer.sendTransaction(tx1 as Buffer);
// buyMaterial = await bcBuyer.getMaterials();
// expect(buyMaterial).not.toBeNull();
// buyMaterial = buyMaterial as [PublicKey, Materials];
// expect(
// buyMaterial[1].materials[
// materialTypeMap.get(JSON.stringify(lot.typ))
// ].amount.toString()
// ).toBe("0");
// break;

@@ -188,45 +247,72 @@ // }

// });
// test("Scouting & raid", async () => {
// const player = (await bc.getPlayerAccount()) as PlayerAccount;
// const characterBefore = (await bc.getCharacter(
// player.characters[0]
// )) as Character;
// let tx1 = await bc.scoutDungeonWithoutSending(
// DifficultyEnum.Hard,
// player.characters[0]
// );
// expect(typeof tx1).not.toBe("number");
// await bc.sendTransaction(tx1[0] as Buffer);
// let initDungeon = await bc.getDungeon(tx1[1]);
// expect(initDungeon).not.toBeNull();
// initDungeon = initDungeon as Dungeon;
// let tx = await bc.raid(tx1[1], player.characters[0], [
// PotionEnum.ArtisansPotion,
// ]);
// expect(typeof tx).not.toBe("number");
// let sign = await bc.sendTransaction(tx 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;
// if (battleLog.complete != 100) {
// let dungeon = await bc.getDungeon(tx1[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 potions", () => __awaiter(void 0, void 0, void 0, function* () {
var _a, _b;
let consumables = (yield bc.getConsumables())[1];
for (let m of consumables.consumables) {
if ((0, types_1.enumEq)(m.typ, types_1.PotionEnum.PotionOfClearMind) && m.amount.gtn(0)) {
let characterBefore = (yield bc.getCharactersList())[0];
let tx = yield bc.usePotion(characterBefore[0], m.typ);
expect(typeof tx).not.toBe("number");
yield bc.sendTransaction(tx);
let characterAfter = (yield bc.getCharactersList())[0];
expect((0, types_1.enumEq)((_a = characterAfter[1].potions[0]) === null || _a === void 0 ? void 0 : _a.effect, types_1.PotionEnum.PotionOfClearMind)).toBe(true);
expect((0, types_1.enumEq)((_b = characterAfter[1].potions[0]) === null || _b === void 0 ? void 0 : _b.effect, types_1.PotionEnum.PotionOfClearMind)).toBe(true);
let consumables = (yield bc.getConsumables())[1];
expect(consumables[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(types_1.PotionEnum.PotionOfClearMind))].amount.toString()).toBe(m.amount.subn(1).toString());
console.log("use");
break;
}
}
}));
test("Scouting & raid", () => __awaiter(void 0, void 0, void 0, function* () {
// for (let i = 0; i < 100; i++) {
const player = (yield bc.getPlayerAccount());
const characterBefore = (yield bc.getCharacter(player.characters[0]));
let tx1 = yield bc.scoutDungeonWithoutSending(types_1.DifficultyEnum.Hard, player.characters[0]);
expect(typeof tx1).not.toBe("number");
yield bc.sendTransaction(tx1[0]);
let initDungeon = yield bc.getDungeon(tx1[1]);
expect(initDungeon).not.toBeNull();
initDungeon = initDungeon;
let consumables = (yield bc.getConsumables())[1];
let potion = [];
let p = new anchor_1.BN();
for (let m of consumables.consumables) {
if (m.amount.gtn(0) && (0, types_1.enumEq)(m.typ, types_1.PotionEnum.LesserHealingPotion)) {
console.log(m.typ);
potion.push(m.typ);
p = m.amount;
break;
}
}
let tx = yield bc.raid(tx1[1], player.characters[0], potion);
expect(typeof tx).not.toBe("number");
let sign = yield bc.sendTransaction(tx);
expect(typeof sign).toBe("string");
sign = sign;
let battleLog = yield bc.getBattleLog(sign);
expect(typeof battleLog).not.toBe("number");
battleLog = battleLog;
console.log(battleLog.battleLog);
if (battleLog.complete != 100) {
let dungeon = yield bc.getDungeon(tx1[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());
if (potion[0] !== undefined) {
let con = yield bc.getConsumables();
expect(con).not.toBeNull();
console.log(potion[0]);
console.log(types_1.consumablesTypeMap.get(JSON.stringify(potion[0])));
con = con;
expect(con[1].consumables[types_1.consumablesTypeMap.get(JSON.stringify(potion[0]))].amount.toString()).toBe(p.subn(1).toString());
}
//}
}));
// test("Lock consumable", async () => {

@@ -248,2 +334,7 @@ // let consumables = (

// expect(lot.isInitialized).toBe(true);
// let tx1 = await bc.unlockConsumable(tx[1]);
// expect(typeof tx).not.toBe("number");
// await bc.sendTransaction(tx1 as Buffer);
// lot = await bc.getConsumableLot(tx[1]);
// expect(lot).toBeNull();
// break;

@@ -257,3 +348,3 @@ // }

// if (enumEq(w[1].status, StatusEnum.Free)) {
// let tx = await bc.lockWeapon(w[0], 0.5);
// let tx = await bc.lockWeapon(w[0], 0.4);
// await bc.sendTransaction(tx as Buffer);

@@ -263,2 +354,8 @@ // let weapon = await bc.getWeapon(w[0]);

// weapon = weapon as Weapon;
// expect(weapon.price.toNumber()).toBe(0.4 * 10 ** 9);
// tx = await bc.changeWeaponLot(w[0], 0.5);
// await bc.sendTransaction(tx as Buffer);
// weapon = await bc.getWeapon(w[0]);
// expect(weapon).not.toBeNull();
// weapon = weapon as Weapon;
// expect(weapon.price.toNumber()).toBe(0.5 * 10 ** 9);

@@ -298,2 +395,1 @@ // let keypair = new Keypair();

// });
// //});
{
"name": "4irelabs-blackchain-smart-contract",
"version": "0.0.45",
"version": "0.0.46",
"description": "Integration with Solana API",

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

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

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

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

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc