bmcgames-sdk-dev
v1.0.5
Published
Typescript SDK to interact with BMCgames program.
Downloads
69
Maintainers
Readme
bmc-games-dev-sdk
Installation
yarn add bmc-games-dev-sdk
BackOffice
Load SDK wrappers
import { BmcGamesSDK, AdminWrapper } from "bmc-games-dev-sdk";
import { SolanaProvider } from "@saberhq/solana-contrib";
const wallet = useWallet();
const { connection } = useConnection();
const provider = SolanaProvider.init({
connection,
wallet: wallet as any,
opts: {
preflightCommitment: "finalized",
commitment: "finalized",
},
});
const bmcGamesSDK = BmcGamesSDK.load({ provider });
const adminWrapper = new AdminWrapper(bmcGamesSDK, wallet.publickKey.toString()); // wallet.publickKey should be String
Add game partner - Admin Wallet
const tx = await adminWrapper.addGamePartner({
partnerWalletStr,
partnerWithdrawalTokenMintAddressStr,
});
Change voter wallets - Admin Wallet
const tx = await adminWrapper.changeVoterWithdrawalWallets({
wallet1Str,
wallet2Str,
wallet3Str,
wallet4Str,
wallet5Str,
approvalChin, // number
});
Decrease liquidity - Withdrawal Wallet
token and amount depends on pool which is going to decrease
const tx = await adminWrapper.decreaseLiquidity({
withdrawAmount, // token amount; ex: 3.412
withdrawalTokenMintAddress, // Pubkey. not string
});
Increase liquidity - Withdrawal Wallet
token and amount depends on pool which is going to increase
const tx = await adminWrapper.increaseLiquidity({
depositAmount, // token amount; ex: 3.412
depositTokenMintAddress, // Pubkey. not string
});
Update By Admin - Admin Wallet
const tx = await adminWrapper.updateByAdmin({
botWalletStr, // String
isEnabledVoting, // boolean
isEmergencyStatus, // boolean
});
Set deposit token - Admin Wallet
const tx = await adminWrapper.setDepositToken({
newDepositTokenMintAddress // Pubkey
});
Set game partner status - Admin Wallet
const tx = await adminWrapper.setGamePartnerStatus({
partnerWalletStr, // String
isEnabled // boolean
});
Set game partner token - Admin Wallet
const tx = await adminWrapper.setGamePartnerToken({
partnerWalletStr, // String
newPartnerWithdrawalTokenMintAddress // Pubkey
});
Set platform withdrawal token - Admin Wallet
:warning: Warning ~~setPlatformWithdrawalToken();~~ This function is deprecated.
// const tx = await adminWrapper.setPlatformWithdrawalToken({
// newPlatformWithdrawalTokenMintAddress // Pubkey
// });
Set reward token - Admin Wallet
const tx = await adminWrapper.setRewardToken({
newRewardWithdrawalTokenMintAddress // Pubkey
});
Set user status - Admin Wallet
const tx = await adminWrapper.setUserStatus({
userWalletStr, // String
isUnblocked, // boolean
});
Start voting withdrawal wallet - Admin Wallet
const tx = await adminWrapper.startVotingWithdrawalWallet({
newWithdrawalWalletStr, // String
});
Withdraw platform fund - Withdrawal Wallet
const tx = await adminWrapper.withdrawPlatformFund({
withdrawAmount, // token amount; ex: 3.412
});
Get global states - admin wrapper
let info = await adminWrapper.getGlobalInfo();
Get fund status - admin wrapper
let info = await adminWrapper.calcInsufficientWithdrawalTokenAmount();
Bmc
import { BmcGamesSDK, BmcWrapper } from "bmc-games-dev-sdk";
import { SolanaProvider } from "@saberhq/solana-contrib";
const wallet = useWallet();
const { connection } = useConnection();
const provider = SolanaProvider.init({
connection,
wallet: wallet as any,
opts: {
preflightCommitment: "finalized",
commitment: "finalized",
},
});
const bmcGamesSDK = BmcGamesSDK.load({ provider });
const bmcWrapper = new BmcWrapper(bmcGamesSDK, wallet.publickKey.toString()); // wallet.publickKey should be String
Vote withdrawal wallet - voter Wallet
const tx = await bmcWrapper.voteWithdrawalWallet();
Get voting status - bmc wrapper
let info = await bmcWrapper.getVoteWalletInfo();
Bot
import { BmcGamesSDK, BotWrapper } from "bmc-games-dev-sdk";
import { SolanaProvider } from "@saberhq/solana-contrib";
const wallet = useWallet();
const { connection } = useConnection();
const provider = SolanaProvider.init({
connection,
wallet: wallet as any,
opts: {
preflightCommitment: "finalized",
commitment: "finalized",
},
});
const bmcGamesSDK = BmcGamesSDK.load({ provider });
const botWrapper = new BotWrapper(bmcGamesSDK, wallet.publickKey.toString()); // wallet.publickKey should be String
Add user - bot Wallet
const tx = await botWrapper.addUser({
userWalletStr // String
});
End season (unlock partner funds) - bot Wallet
token and amount depends on depositToken
const tx = await botWrapper.endSeasonGamePartner({
partnerWalletStr, // String
unlockedAmount, // token amount; ex: 3.412
});
End season (unlock platform funds) - bot Wallet
token and amount depends on depositToken
const tx = await botWrapper.endSeasonPlatform({
unlockedAmount, // token amount; ex: 3.412
});
End season (unlock user reward ticket) - bot Wallet
token and amount depends on depositToken
const tx = await botWrapper.endSeasonUser({
userWalletStr, // String
unlockedAmount, // token amount; ex: 3.412 - based on beamo depositToken
});
Purchase game item (deposit from Beamo) - beamo & bot Wallet
token and amount depends on depositToken
const tx = await botWrapper.purchaseGameItem({
gamePartnerWalletStr, // String
depositAmount, // token amount; ex: 3.412 - based on beamo depositToken
gameStudioPercentage, // 100% = 10000
rewardPercentage, // 100% = 10000, if isSeasonGame == true then 0%
isSeasonGame, // boolean
});
Partner
import { BmcGamesSDK, PartnerWrapper } from "bmc-games-dev-sdk";
import { SolanaProvider } from "@saberhq/solana-contrib";
const wallet = useWallet();
const { connection } = useConnection();
const provider = SolanaProvider.init({
connection,
wallet: wallet as any,
opts: {
preflightCommitment: "finalized",
commitment: "finalized",
},
});
const bmcGamesSDK = BmcGamesSDK.load({ provider });
const partnerWrapper = new PartnerWrapper(bmcGamesSDK, wallet.publickKey.toString()); // wallet.publickKey should be String
Claim game partner fund - partner Wallet
Amount depends on depositToken. Partner will receive with partnerWithdrawalToken. Signers will be partner-wallet and bot-wallet. If smartContract returns InsufficientTokenAmount error, insufficient_withdrawal_pool = true and then send message to admin via slack bot channel. Check diagram.xlsx [checklist] No.4
const tx = await partnerWrapper.claimGamePartnerFund({
rewardAmount // token amount; ex: 3.412
});
Get partners list - partner wrapper
let partners = await partnerWrapper.getPartnersInfo();
Get a partner info - partner wrapper
The unit of token amount in returned array is same with depositToken
let partner = await partnerWrapper.getPartnerInfo(
partnerWalletStr // String
);
User
import { BmcGamesSDK, UserWrapper } from "bmc-games-dev-sdk";
import { SolanaProvider } from "@saberhq/solana-contrib";
const wallet = useWallet();
const { connection } = useConnection();
const provider = SolanaProvider.init({
connection,
wallet: wallet as any,
opts: {
preflightCommitment: "finalized",
commitment: "finalized",
},
});
const bmcGamesSDK = BmcGamesSDK.load({ provider });
const userWrapper = new UserWrapper(bmcGamesSDK, wallet.publickKey.toString()); // wallet.publickKey should be String
Claim user reward ticket - user Wallet
Amount depends on depositToken. User will receive with rewardToken. Signers will be user-wallet and bot-wallet. If smartContract returns InsufficientTokenAmount error, insufficient_withdrawal_pool = true and then send message to admin via slack bot channel. Check diagram.xlsx [checklist] No.4
const tx = await userWrapper.claimUserReward({
rewardAmount // token amount; ex: 3.412
});
Get users list - user wrapper
let users = await userWrapper.getUsersInfo();
Get a user info - user wrapper
The unit of token amount in returned array is same with depositToken
let user = await userWrapper.getUserInfo(
userWalletStr // String
);