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

nft-staking

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

nft-staking - npm Package Compare versions

Comparing version 1.6.1 to 1.6.2

dist/src/generated/instructions/claimRewardV2.d.ts

1

dist/src/generated/instructions/index.d.ts

@@ -9,2 +9,3 @@ /**

export * from './claimReward';
export * from './claimRewardV2';
export * from './closeConfig';

@@ -11,0 +12,0 @@ export * from './initConfig';

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

__exportStar(require("./claimReward"), exports);
__exportStar(require("./claimRewardV2"), exports);
__exportStar(require("./closeConfig"), exports);

@@ -27,0 +28,0 @@ __exportStar(require("./initConfig"), exports);

@@ -5,1 +5,2 @@ import { KeypairSigner, PublicKey, Signer, Umi } from "@metaplex-foundation/umi";

export declare function createClaimRewardIx(umi: Umi, user: Signer, mint: PublicKey, nftMint: PublicKey, rewardVaultAuthority: KeypairSigner): Promise<import("@metaplex-foundation/umi").TransactionBuilder>;
export declare function createClaimRewardV2Ix(umi: Umi, user: Signer, mint: PublicKey, nftMint: PublicKey, rewardVaultAuthority: KeypairSigner, rewardAmount: number): Promise<import("@metaplex-foundation/umi").TransactionBuilder>;

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

Object.defineProperty(exports, "__esModule", { value: true });
exports.createClaimRewardIx = exports.createUnstakeIx = exports.createStakeIx = void 0;
exports.createClaimRewardV2Ix = exports.createClaimRewardIx = exports.createUnstakeIx = exports.createStakeIx = void 0;
var mpl_token_metadata_1 = require("@metaplex-foundation/mpl-token-metadata");

@@ -162,1 +162,37 @@ var mpl_toolbox_1 = require("@metaplex-foundation/mpl-toolbox");

exports.createClaimRewardIx = createClaimRewardIx;
function createClaimRewardV2Ix(umi, user, mint, nftMint, rewardVaultAuthority, rewardAmount) {
return __awaiter(this, void 0, void 0, function () {
var nftStake, config, rewardVaultToken, userToken, createUserTokenIx, claimRewardIx;
return __generator(this, function (_a) {
nftStake = umi.eddsa.findPda(src_1.NFT_STAKING_PROGRAM_ID, [
(0, serializers_1.string)({ size: "variable" }).serialize(constants_1.SEED_NFT_STAKE),
(0, serializers_1.publicKey)().serialize(nftMint),
(0, serializers_1.publicKey)().serialize(user.publicKey),
]);
config = umi.eddsa.findPda(src_1.NFT_STAKING_PROGRAM_ID, [
(0, serializers_1.string)({ size: "variable" }).serialize(constants_1.SEED_CONFIG),
])[0];
rewardVaultToken = (0, umi_1.publicKey)("Lx5d3g5tt2s5rw7GBQYwqhTRdWKnbh85PYBfKzZ4j5r");
userToken = (0, mpl_toolbox_1.findAssociatedTokenPda)(umi, {
mint: mint,
owner: user.publicKey,
})[0];
createUserTokenIx = (0, mpl_toolbox_1.createTokenIfMissing)(umi, {
mint: mint,
owner: user.publicKey,
});
claimRewardIx = (0, src_1.claimRewardV2)(umi, {
user: user,
config: config,
vaultAuthority: rewardVaultAuthority,
nftStake: nftStake,
mint: mint,
userToken: userToken,
vaultToken: rewardVaultToken,
rewardAmount: rewardAmount,
});
return [2 /*return*/, (0, umi_1.transactionBuilder)().add(createUserTokenIx).add(claimRewardIx)];
});
});
}
exports.createClaimRewardV2Ix = createClaimRewardV2Ix;

@@ -211,2 +211,31 @@ "use strict";

}); });
ava_1.default.serial("claim reward v2 amount", function (t) { return __awaiter(void 0, void 0, void 0, function () {
var _a, umi, user, nftStake, nftMint, mint, vaultAuthority, claimRewardIx, stakeAccount;
return __generator(this, function (_b) {
switch (_b.label) {
case 0:
_a = t.context, umi = _a.umi, user = _a.user, nftStake = _a.nftStake, nftMint = _a.nftMint, mint = _a.rewardMint;
vaultAuthority = (0, umi_1.generateSigner)(umi);
return [4 /*yield*/, (0, mpl_toolbox_1.createMintWithAssociatedToken)(umi, {
mint: mint,
owner: vaultAuthority.publicKey,
decimals: 6,
amount: 100,
}).sendAndConfirm(umi)];
case 1:
_b.sent();
return [4 /*yield*/, (0, src_1.createClaimRewardV2Ix)(umi, user, mint.publicKey, nftMint.publicKey, vaultAuthority, 10000)];
case 2:
claimRewardIx = _b.sent();
return [4 /*yield*/, claimRewardIx.sendAndConfirm(umi)];
case 3:
_b.sent();
return [4 /*yield*/, (0, src_1.fetchNftStake)(umi, nftStake.publicKey)];
case 4:
stakeAccount = _b.sent();
t.true(stakeAccount.lastClaimed >= stakeAccount.stakedOn);
return [2 /*return*/];
}
});
}); });
ava_1.default.serial("unstake nft", function (t) { return __awaiter(void 0, void 0, void 0, function () {

@@ -213,0 +242,0 @@ var _a, umi, user, nftMint, unstakeIx, _b, _c;

2

package.json
{
"name": "nft-staking",
"version": "1.6.1",
"version": "1.6.2",
"description": "Stake nfts on whitestache",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

@@ -10,2 +10,3 @@ /**

export * from './claimReward';
export * from './claimRewardV2';
export * from './closeConfig';

@@ -12,0 +13,0 @@ export * from './initConfig';

@@ -19,4 +19,10 @@ import {

import { publicKey as pk, string } from "@metaplex-foundation/umi/serializers";
import { NFT_STAKING_PROGRAM_ID, claimReward, stake, unstake } from "../src";
import {
NFT_STAKING_PROGRAM_ID,
claimReward,
claimRewardV2,
stake,
unstake,
} from "../src";
import {
METAPLEX_STANDARD_RULESET,

@@ -163,1 +169,47 @@ SEED_CONFIG,

}
export async function createClaimRewardV2Ix(
umi: Umi,
user: Signer,
mint: PublicKey,
nftMint: PublicKey,
rewardVaultAuthority: KeypairSigner,
rewardAmount: number
) {
const nftStake = umi.eddsa.findPda(NFT_STAKING_PROGRAM_ID, [
string({ size: "variable" }).serialize(SEED_NFT_STAKE),
pk().serialize(nftMint),
pk().serialize(user.publicKey),
]);
const [config] = umi.eddsa.findPda(NFT_STAKING_PROGRAM_ID, [
string({ size: "variable" }).serialize(SEED_CONFIG),
]);
const rewardVaultToken = publicKey(
"Lx5d3g5tt2s5rw7GBQYwqhTRdWKnbh85PYBfKzZ4j5r"
);
const [userToken] = findAssociatedTokenPda(umi, {
mint: mint,
owner: user.publicKey,
});
const createUserTokenIx = createTokenIfMissing(umi, {
mint: mint,
owner: user.publicKey,
});
const claimRewardIx = claimRewardV2(umi, {
user,
config,
vaultAuthority: rewardVaultAuthority,
nftStake: nftStake,
mint,
userToken,
vaultToken: rewardVaultToken,
rewardAmount,
});
return transactionBuilder().add(createUserTokenIx).add(claimRewardIx);
}

@@ -36,2 +36,3 @@ import {

createClaimRewardIx,
createClaimRewardV2Ix,
createStakeIx,

@@ -208,2 +209,34 @@ createUnstakeIx,

test.serial("claim reward v2 amount", async (t) => {
const {
umi,
user,
nftStake,
nftMint,
rewardMint: mint,
} = t.context as TestContext;
const vaultAuthority = generateSigner(umi);
await createMintWithAssociatedToken(umi, {
mint,
owner: vaultAuthority.publicKey,
decimals: 6,
amount: 100,
}).sendAndConfirm(umi);
const claimRewardIx = await createClaimRewardV2Ix(
umi,
user,
mint.publicKey,
nftMint.publicKey,
vaultAuthority,
10000
);
await claimRewardIx.sendAndConfirm(umi);
const stakeAccount = await fetchNftStake(umi, nftStake.publicKey);
t.true(stakeAccount.lastClaimed >= stakeAccount.stakedOn);
});
test.serial("unstake nft", async (t) => {

@@ -210,0 +243,0 @@ const { umi, user, nftMint } = t.context as TestContext;

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