Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(root): upgrade solana lib #4447

Merged
merged 1 commit into from
Apr 17, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion modules/account-lib/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@
"bs58": "^4.0.1"
},
"devDependencies": {
"@solana/web3.js": "1.56.0",
"@solana/web3.js": "1.91.6",
"@types/bs58": "^4.0.1",
"keccak": "3.0.3",
"paillier-bigint": "3.3.0",
Expand Down
2 changes: 1 addition & 1 deletion modules/sdk-coin-sol/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
"@bitgo/sdk-lib-mpc": "^9.2.0",
"@bitgo/statics": "^48.6.0",
"@solana/spl-token": "0.3.1",
"@solana/web3.js": "1.78.0",
"@solana/web3.js": "1.91.6",
"bignumber.js": "^9.0.0",
"bs58": "^4.0.1",
"lodash": "^4.17.14",
Expand Down
1 change: 1 addition & 0 deletions modules/sdk-coin-sol/src/lib/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ export const MEMO_PROGRAM_PK = 'MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr';
export const SEED_LENGTH = 32;

export const MAX_MEMO_LENGTH = 100;
export const STAKE_ACCOUNT_RENT_EXEMPT_AMOUNT = 2282880;

export const UNAVAILABLE_TEXT = 'UNAVAILABLE';

Expand Down
15 changes: 9 additions & 6 deletions modules/sdk-coin-sol/src/lib/solInstructionFactory.ts
Original file line number Diff line number Diff line change
Expand Up @@ -241,12 +241,15 @@ function stakingDeactivateInstruction(data: StakingDeactivate): TransactionInstr
});
tx.add(assignAccount);

const splitStake = StakeProgram.split({
stakePubkey: new PublicKey(stakingAddress),
authorizedPubkey: new PublicKey(fromAddress),
splitStakePubkey: unstakingAddress,
lamports: new BigNumber(data.params.amount).toNumber(),
});
const splitStake = StakeProgram.split(
{
stakePubkey: new PublicKey(stakingAddress),
authorizedPubkey: new PublicKey(fromAddress),
splitStakePubkey: unstakingAddress,
lamports: new BigNumber(data.params.amount).toNumber(),
},
0
);
tx.add(splitStake.instructions[1]);

const deactivateStaking = StakeProgram.deactivate({
Expand Down
5 changes: 2 additions & 3 deletions modules/sdk-coin-sol/src/lib/stakingDeactivateBuilder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { BaseCoin as CoinConfig } from '@bitgo/statics';
import assert from 'assert';

import { BuildTransactionError, TransactionType } from '@bitgo/sdk-core';
import { InstructionBuilderTypes } from './constants';
import { InstructionBuilderTypes, STAKE_ACCOUNT_RENT_EXEMPT_AMOUNT } from './constants';
import { StakingDeactivate, Transfer } from './iface';
import { Transaction } from './transaction';
import { TransactionBuilder } from './transactionBuilder';
Expand All @@ -12,7 +12,6 @@ export class StakingDeactivateBuilder extends TransactionBuilder {
protected _stakingAddress: string;
protected _stakingAddresses: string[];
protected _amount?: string;
protected _fundUnstakeAddress = 2282880;
protected _unstakingAddress: string;

constructor(_coinConfig: Readonly<CoinConfig>) {
Expand Down Expand Up @@ -146,7 +145,7 @@ export class StakingDeactivateBuilder extends TransactionBuilder {
type: InstructionBuilderTypes.Transfer,
params: {
fromAddress: this._sender,
amount: this._fundUnstakeAddress.toString(),
amount: STAKE_ACCOUNT_RENT_EXEMPT_AMOUNT.toString(),
toAddress: this._unstakingAddress,
},
};
Expand Down
139 changes: 83 additions & 56 deletions modules/sdk-coin-sol/test/unit/instructionParamsFactory.staking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import * as testData from '../resources/sol';
import { instructionParamsFactory } from '../../src/lib/instructionParamsFactory';
import { TransactionType } from '@bitgo/sdk-core';
import { InstructionParams, Nonce, StakingActivate, StakingDeactivate, StakingWithdraw } from '../../src/lib/iface';
import { InstructionBuilderTypes, MEMO_PROGRAM_PK } from '../../src/lib/constants';
import { InstructionBuilderTypes, MEMO_PROGRAM_PK, STAKE_ACCOUNT_RENT_EXEMPT_AMOUNT } from '../../src/lib/constants';
import {
Keypair as SolKeypair,
Lockup,
Expand Down Expand Up @@ -484,12 +484,15 @@ describe('Instruction Parser Staking Tests: ', function () {
programId: StakeProgram.programId,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down Expand Up @@ -532,12 +535,15 @@ describe('Instruction Parser Staking Tests: ', function () {
space: StakeProgram.space,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down Expand Up @@ -624,12 +630,15 @@ describe('Instruction Parser Staking Tests: ', function () {
space: StakeProgram.space,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
},
0
).instructions;

const assignInstruction = SystemProgram.assign({
accountPubkey: splitStakeAccount,
Expand Down Expand Up @@ -683,12 +692,15 @@ describe('Instruction Parser Staking Tests: ', function () {
programId: StakeProgram.programId,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down Expand Up @@ -738,12 +750,15 @@ describe('Instruction Parser Staking Tests: ', function () {
programId: StakeProgram.programId,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down Expand Up @@ -793,12 +808,15 @@ describe('Instruction Parser Staking Tests: ', function () {
programId: SystemProgram.programId,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down Expand Up @@ -848,12 +866,15 @@ describe('Instruction Parser Staking Tests: ', function () {
programId: StakeProgram.programId,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: stakingAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: stakingAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down Expand Up @@ -902,12 +923,15 @@ describe('Instruction Parser Staking Tests: ', function () {
programId: StakeProgram.programId,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: stakingAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: stakingAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down Expand Up @@ -951,7 +975,7 @@ describe('Instruction Parser Staking Tests: ', function () {
const transferInstruction = SystemProgram.transfer({
fromPubkey: new PublicKey(fromAccount),
toPubkey: new PublicKey(splitStakeAccount),
lamports: parseInt((2282880).toString(), 10),
lamports: parseInt(STAKE_ACCOUNT_RENT_EXEMPT_AMOUNT.toString(), 10),
});

const allocateInstruction = SystemProgram.allocate({
Expand All @@ -964,12 +988,15 @@ describe('Instruction Parser Staking Tests: ', function () {
programId: StakeProgram.programId,
});

const splitInstructions = StakeProgram.split({
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
}).instructions;
const splitInstructions = StakeProgram.split(
{
stakePubkey: stakingAccount,
authorizedPubkey: fromAccount,
splitStakePubkey: splitStakeAccount,
lamports: 100000,
},
0
).instructions;

const stakingDeactivateInstructions = StakeProgram.deactivate({
authorizedPubkey: fromAccount,
Expand Down
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@
"@polkadot/x-global": "12.3.2",
"@polkadot/x-randomvalues": "12.3.2",
"@polkadot/x-ws": "12.3.2",
"@solana/web3.js": "1.91.6",
"@substrate/txwrapper-core": "7.0.1",
"@substrate/txwrapper-polkadot": "7.0.1",
"buffer": "^6.0.3",
Expand Down
Loading
Loading