Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

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.14 to 0.0.15

36

dist/src/blackchainApi.d.ts

@@ -0,3 +1,4 @@

/// <reference types="node" />
/// <reference types="bn.js" />
import { Character, PlayerAccount, Clas, Weapon, Armor, BCResult, Dungeon, Difficulty } from "./types";
import { Character, PlayerAccount, Clas, Weapon, Armor, BCResult, Dungeon, Difficulty, Shield } from "./types";
import * as Anchor from "@project-serum/anchor";

@@ -18,17 +19,18 @@ import { BlackchainProgram } from "../idl/blackchain_program";

scoutDungeon(difficulty: Difficulty, character: PublicKey): Promise<Dungeon | BCResult>;
lockCharacter(character: PublicKey): Promise<BCResult>;
lockWeapon(weapon: PublicKey): Promise<BCResult>;
lockArmor(armor: PublicKey): Promise<BCResult>;
lockShield(shield: PublicKey): Promise<BCResult>;
lockDungeon(dungeon: PublicKey): Promise<BCResult>;
unlockCharacter(character: PublicKey): Promise<BCResult>;
unlockWeapon(weapon: PublicKey): Promise<BCResult>;
unlockArmor(armor: PublicKey): Promise<BCResult>;
unlockShield(shield: PublicKey): Promise<BCResult>;
unlockDungeon(dungeon: PublicKey): Promise<BCResult>;
transferCharacter(character: PublicKey, receiver: PublicKey): Promise<BCResult>;
transferWeapon(weapon: PublicKey, receiver: PublicKey): Promise<BCResult>;
transferArmor(armor: PublicKey, receiver: PublicKey): Promise<BCResult>;
transferShield(shield: PublicKey, receiver: PublicKey): Promise<BCResult>;
transferDungeon(dungeon: PublicKey, receiver: PublicKey): Promise<BCResult>;
sendTransaction(buffer: Buffer): Promise<BCResult>;
lockCharacter(character: PublicKey): Promise<Buffer | BCResult>;
lockWeapon(weapon: PublicKey): Promise<Buffer | BCResult>;
lockArmor(armor: PublicKey): Promise<Buffer | BCResult>;
lockShield(shield: PublicKey): Promise<Buffer | BCResult>;
lockDungeon(dungeon: PublicKey): Promise<Buffer | BCResult>;
unlockCharacter(character: PublicKey): Promise<Buffer | BCResult>;
unlockWeapon(weapon: PublicKey): Promise<Buffer | BCResult>;
unlockArmor(armor: PublicKey): Promise<Buffer | BCResult>;
unlockShield(shield: PublicKey): Promise<Buffer | BCResult>;
unlockDungeon(dungeon: PublicKey): Promise<Buffer | BCResult>;
transferCharacter(character: PublicKey, receiver: PublicKey): Promise<Buffer | BCResult>;
transferWeapon(weapon: PublicKey, receiver: PublicKey): Promise<Buffer | BCResult>;
transferArmor(armor: PublicKey, receiver: PublicKey): Promise<Buffer | BCResult>;
transferShield(shield: PublicKey, receiver: PublicKey): Promise<Buffer | BCResult>;
transferDungeon(dungeon: PublicKey, receiver: PublicKey): Promise<Buffer | BCResult>;
getPlayerAccountPublicKey(address?: PublicKey): Promise<PublicKey>;

@@ -42,2 +44,4 @@ getPlayerAccount(address?: PublicKey): Promise<PlayerAccount | null>;

getArmorsList(address?: PublicKey): Promise<[PublicKey, Armor][] | null>;
getShield(address: PublicKey): Promise<Shield | null>;
getShieldList(address?: PublicKey): Promise<[PublicKey, Shield][] | null>;
getDungeon(address: PublicKey): Promise<Dungeon | null>;

@@ -44,0 +48,0 @@ getDungeonList(address?: PublicKey): Promise<[PublicKey, Dungeon][] | null>;

@@ -153,3 +153,2 @@ "use strict";

.filter((key) => key[0].toString() == constants_1.DEFAULT_PUBLIC_KEY);
console.log(freeIndexes[0][1], freeIndexes[1][1], freeIndexes[2][1]);
const nameToBytes = new Uint8Array(20);

@@ -259,2 +258,9 @@ nameToBytes.set(name.split("").map((ch) => ch.charCodeAt(0)));

}
sendTransaction(buffer) {
return __awaiter(this, void 0, void 0, function* () {
const sign = yield this.provider.connection.sendRawTransaction(buffer);
yield this.provider.connection.confirmTransaction(sign);
return { status: true, error: null };
});
}
lockCharacter(character) {

@@ -264,3 +270,3 @@ return __awaiter(this, void 0, void 0, function* () {

try {
yield this.program.rpc.lockCharacter({
const tx = yield this.program.transaction.lockCharacter({
accounts: {

@@ -273,3 +279,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -293,3 +302,3 @@ catch (e) {

try {
yield this.program.rpc.lockWeapon({
const tx = yield this.program.transaction.lockWeapon({
accounts: {

@@ -302,3 +311,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -322,3 +334,3 @@ catch (e) {

try {
yield this.program.rpc.lockArmor({
const tx = yield this.program.transaction.lockArmor({
accounts: {

@@ -331,3 +343,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -351,3 +366,3 @@ catch (e) {

try {
yield this.program.rpc.lockShield({
const tx = yield this.program.transaction.lockShield({
accounts: {

@@ -360,3 +375,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -380,3 +398,3 @@ catch (e) {

try {
yield this.program.rpc.lockDungeon({
const tx = yield this.program.transaction.lockDungeon({
accounts: {

@@ -389,3 +407,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -409,3 +430,3 @@ catch (e) {

try {
yield this.program.rpc.unlockCharacter({
const tx = yield this.program.transaction.unlockCharacter({
accounts: {

@@ -418,3 +439,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -438,3 +462,3 @@ catch (e) {

try {
yield this.program.rpc.unlockWeapon({
const tx = yield this.program.transaction.unlockWeapon({
accounts: {

@@ -447,3 +471,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -467,3 +494,3 @@ catch (e) {

try {
yield this.program.rpc.unlockArmor({
const tx = yield this.program.transaction.unlockArmor({
accounts: {

@@ -476,3 +503,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -496,3 +526,3 @@ catch (e) {

try {
yield this.program.rpc.unlockShield({
const tx = yield this.program.transaction.unlockShield({
accounts: {

@@ -505,3 +535,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -525,3 +558,3 @@ catch (e) {

try {
yield this.program.rpc.unlockDungeon({
const tx = yield this.program.transaction.unlockDungeon({
accounts: {

@@ -534,3 +567,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -557,3 +593,3 @@ catch (e) {

try {
yield this.program.rpc.transferCharacter(new anchor_1.BN(characterIndex), new anchor_1.BN(freeIndex), {
const tx = yield this.program.transaction.transferCharacter(new anchor_1.BN(characterIndex), new anchor_1.BN(freeIndex), {
accounts: {

@@ -567,3 +603,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -590,3 +629,3 @@ catch (e) {

try {
yield this.program.rpc.transferWeapon(new anchor_1.BN(weaponIndex), new anchor_1.BN(freeIndex), {
const tx = yield this.program.transaction.transferWeapon(new anchor_1.BN(weaponIndex), new anchor_1.BN(freeIndex), {
accounts: {

@@ -600,3 +639,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -623,3 +665,3 @@ catch (e) {

try {
yield this.program.rpc.transferArmor(new anchor_1.BN(armorIndex), new anchor_1.BN(freeIndex), {
const tx = yield this.program.transaction.transferArmor(new anchor_1.BN(armorIndex), new anchor_1.BN(freeIndex), {
accounts: {

@@ -633,3 +675,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -656,3 +701,3 @@ catch (e) {

try {
yield this.program.rpc.transferShield(new anchor_1.BN(shieldIndex), new anchor_1.BN(freeIndex), {
const tx = yield this.program.transaction.transferShield(new anchor_1.BN(shieldIndex), new anchor_1.BN(freeIndex), {
accounts: {

@@ -666,3 +711,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -689,3 +737,3 @@ catch (e) {

try {
yield this.program.rpc.transferDungeon(new anchor_1.BN(dungeonIndex), new anchor_1.BN(freeIndex), {
const tx = yield this.program.transaction.transferDungeon(new anchor_1.BN(dungeonIndex), new anchor_1.BN(freeIndex), {
accounts: {

@@ -699,3 +747,6 @@ playerAccount: playerPubkey,

});
return { status: true, error: null };
tx.recentBlockhash = (yield this.provider.connection.getRecentBlockhash()).blockhash;
tx.feePayer = this.provider.wallet.publicKey;
const signedTx = yield this.provider.wallet.signTransaction(tx);
return signedTx.serialize();
}

@@ -805,2 +856,26 @@ catch (e) {

}
getShield(address) {
return __awaiter(this, void 0, void 0, function* () {
try {
let shield = yield this.program.account.shield.fetch(address);
return shield;
}
catch (_a) {
return null;
}
});
}
getShieldList(address) {
return __awaiter(this, void 0, void 0, function* () {
let player = yield this.getPlayerAccount(address);
return player
? yield Promise.all(player.shields
.filter((key) => key.toString() != constants_1.DEFAULT_PUBLIC_KEY)
.map((key) => __awaiter(this, void 0, void 0, function* () {
let shield = yield this.getShield(key);
return [key, shield];
})))
: null;
});
}
getDungeon(address) {

@@ -807,0 +882,0 @@ return __awaiter(this, void 0, void 0, function* () {

@@ -796,2 +796,38 @@ /// <reference types="bn.js" />

export declare type Shields = typeof ShieldsEnum[keyof typeof ShieldsEnum];
export declare type Branch = {
id: number;
next: Turn[];
exit: boolean;
trap: Trap | null;
enemy: Enemy;
chest: Difficulty;
};
export declare type Enemy = {
name: number[];
hp: number;
dmg: {
min: number;
max: number;
critChance: Anchor.BN;
critMult: Anchor.BN;
attackType: DamageType;
};
race: EnemyRace;
typ: EnemyType;
};
export declare type Branches = Branch[];
export declare type Turn = [{
id: number;
turn: TurnWay;
}];
export declare type Trap = {
difficult: Difficulty;
typ: DamageType;
damage: number;
effect: TrapEffect;
};
export declare type TrapEffect = {
chance: Anchor.BN;
state: TrapType;
};
export declare const EnemyRaceEnum: {

@@ -798,0 +834,0 @@ Undead: {

{
"name": "4irelabs-blackchain-smart-contract",
"version": "0.0.14",
"version": "0.0.15",
"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

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