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.10 to 0.0.11

9

dist/idl/blackchain_program.d.ts

@@ -106,2 +106,11 @@ export declare type BlackchainProgram = {

};
},
{
"name": "name";
"type": {
"array": [
"u8",
20
];
};
}

@@ -108,0 +117,0 @@ ];

@@ -109,2 +109,11 @@ "use strict";

}
},
{
"name": "name",
"type": {
"array": [
"u8",
20
]
}
}

@@ -111,0 +120,0 @@ ]

12

dist/src/blackchainApi.d.ts

@@ -16,9 +16,9 @@ /// <reference types="bn.js" />

addRoom(): Promise<void>;
hireCharacter(clas: Clas): Promise<Character>;
hireCharacter(name: string, clas: Clas): Promise<Character>;
hireCharacterRandom(index: Anchor.BN): Promise<void>;
getPlayerAccount(address?: PublicKey): Promise<PlayerAccount>;
getCharacter(address: PublicKey): Promise<Character>;
getCharactersList(address?: PublicKey): Promise<[PublicKey, Character][]>;
getRoomsCount(address?: PublicKey): Promise<BN>;
getGoldCount(address?: PublicKey): Promise<BN>;
getPlayerAccount(address?: PublicKey): Promise<PlayerAccount | null>;
getCharacter(address: PublicKey): Promise<Character | null>;
getCharactersList(address?: PublicKey): Promise<[PublicKey, Character][] | null>;
getRoomsCount(address?: PublicKey): Promise<BN | null>;
getGoldCount(address?: PublicKey): Promise<BN | null>;
}

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

}
hireCharacter(clas) {
hireCharacter(name, clas) {
return __awaiter(this, void 0, void 0, function* () {

@@ -116,3 +116,5 @@ if (!this.isMut)

const index = (yield this.program.account.playerAccount.fetch(playerPubkey)).characters.findIndex((key) => key.toString() == constants_1.DEFAULT_PUBLIC_KEY);
yield this.program.rpc.hireCharacter(new anchor_1.BN(index), clas, {
const nameToBytes = new Uint8Array(20);
nameToBytes.set(name.split("").map((ch) => ch.charCodeAt(0)));
yield this.program.rpc.hireCharacter(new anchor_1.BN(index), clas, nameToBytes, {
accounts: {

@@ -149,4 +151,9 @@ characterAccount: character.publicKey,

const playerPubkey = yield (0, utils_1.getPlayerAccountPublicKey)(address ? address : this.provider.wallet.publicKey, this.programId);
let playerAccount = yield this.program.account.playerAccount.fetch(playerPubkey);
return playerAccount;
try {
let playerAccount = yield this.program.account.playerAccount.fetch(playerPubkey);
return playerAccount;
}
catch (_a) {
return null;
}
});

@@ -156,4 +163,9 @@ }

return __awaiter(this, void 0, void 0, function* () {
let character = yield this.program.account.character.fetch(address);
return character;
try {
let character = yield this.program.account.character.fetch(address);
return character;
}
catch (_a) {
return null;
}
});

@@ -163,10 +175,11 @@ }

return __awaiter(this, void 0, void 0, function* () {
const playerPubkey = yield (0, utils_1.getPlayerAccountPublicKey)(address ? address : this.provider.wallet.publicKey, this.programId);
let player = yield this.program.account.playerAccount.fetch(playerPubkey);
return yield Promise.all(player.characters
.filter((key) => key.toString() != constants_1.DEFAULT_PUBLIC_KEY)
.map((key) => __awaiter(this, void 0, void 0, function* () {
let character = yield this.getCharacter(key);
return [key, character];
})));
let player = yield this.getPlayerAccount(address);
return player
? yield Promise.all(player.characters
.filter((key) => key.toString() != constants_1.DEFAULT_PUBLIC_KEY)
.map((key) => __awaiter(this, void 0, void 0, function* () {
let character = yield this.getCharacter(key);
return [key, character];
})))
: null;
});

@@ -176,3 +189,4 @@ }

return __awaiter(this, void 0, void 0, function* () {
return (yield this.getPlayerAccount(address)).numberOfRooms;
const playerAccount = yield this.getPlayerAccount(address);
return playerAccount ? playerAccount.numberOfRooms : null;
});

@@ -184,6 +198,12 @@ }

const goldMint = (yield (0, utils_1.getGoldMintPublicKey)(this.programId))[0];
const balance = new anchor_1.BN((yield this.provider.connection.getParsedTokenAccountsByOwner(owner, {
mint: goldMint,
})).value[0].account.data.parsed.info.tokenAmount.uiAmountString);
return balance;
try {
const associatedAccount = yield this.provider.connection.getParsedTokenAccountsByOwner(owner, {
mint: goldMint,
});
const balance = new anchor_1.BN(associatedAccount.value[0].account.data.parsed.info.tokenAmount.uiAmountString);
return balance;
}
catch (_a) {
return null;
}
});

@@ -190,0 +210,0 @@ }

export declare const DEFAULT_PUBLIC_KEY = "11111111111111111111111111111111";
export declare const PLAYER_ACCOUNT_SPACE = 16049;
export declare const enum Cluster {
localnet = "http://127.0.0.1:8899",
devnet = "https://api.devnet.solana.com",
testnet = "https://api.testnet.solana.com",
mainnet = "https://api.mainnet-beta.solana.com"
}
export declare const Cluster: {
localnet: string;
devnet: string;
testnet: string;
mainnet: string;
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.PLAYER_ACCOUNT_SPACE = exports.DEFAULT_PUBLIC_KEY = void 0;
exports.Cluster = exports.PLAYER_ACCOUNT_SPACE = exports.DEFAULT_PUBLIC_KEY = void 0;
exports.DEFAULT_PUBLIC_KEY = "11111111111111111111111111111111";
exports.PLAYER_ACCOUNT_SPACE = 16049;
exports.Cluster = {
localnet: "http://127.0.0.1:8899",
devnet: "https://api.devnet.solana.com",
testnet: "https://api.testnet.solana.com",
mainnet: "https://api.mainnet-beta.solana.com",
};
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BC = void 0;
exports.Cluster = exports.BC = void 0;
var blackchainApi_1 = require("./blackchainApi");
Object.defineProperty(exports, "BC", { enumerable: true, get: function () { return blackchainApi_1.BC; } });
var constants_1 = require("./constants");
Object.defineProperty(exports, "Cluster", { enumerable: true, get: function () { return constants_1.Cluster; } });
{
"name": "4irelabs-blackchain-smart-contract",
"version": "0.0.10",
"version": "0.0.11",
"description": "Integration with Solana API",

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

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