solana.js: fix lease withdraw timing

This commit is contained in:
Conner Gallagher 2023-03-08 10:57:15 -07:00
parent b8fdd2c171
commit 39a5dc692c
5 changed files with 40 additions and 30 deletions

View File

@ -1,6 +1,6 @@
{
"name": "@switchboard-xyz/solana.js",
"version": "2.0.134",
"version": "2.0.135-beta.0",
"author": "",
"license": "MIT",
"description": "API wrapper for integrating with the Switchboard V2 program on Solana",
@ -15,7 +15,11 @@
"import": "./lib/esm/index.js",
"require": "./lib/cjs/index.js"
},
"./package.json": "./package.json"
"./package.json": "./package.json",
"./test": {
"import": "./lib/esm/test/index.js",
"require": "./lib/cjs/test/index.js"
}
},
"main": "lib/cjs/index.js",
"module": "lib/esm/index.js",

View File

@ -502,7 +502,7 @@ export class LeaseAccount extends Account<types.LeaseAccountData> {
oracleRequestBatchSize: number,
queueReward: BN
): BN {
return queueReward.mul(new BN(oracleRequestBatchSize + 1));
return queueReward.mul(new BN(oracleRequestBatchSize + 1)).mul(new BN(2));
}
/**

View File

@ -9,6 +9,5 @@ export * from './SwitchboardError';
export * from './SwitchboardEvents';
export * from './SwitchboardNetwork';
export * from './SwitchboardProgram';
export * from './test';
export * from './TransactionObject';
export * from './utils';

View File

@ -352,29 +352,34 @@ export class NativeMint extends Mint {
owner,
Mint.native
),
spl.createAssociatedTokenAccountInstruction(
payer,
ephemeralWallet,
ephemeralAccount.publicKey,
spl.NATIVE_MINT
),
SystemProgram.transfer({
fromPubkey: owner,
toPubkey: ephemeralWallet,
lamports: wrapAmountLamports,
}),
spl.createSyncNativeInstruction(ephemeralWallet),
spl.createTransferInstruction(
ephemeralWallet,
associatedAddress,
ephemeralAccount.publicKey,
wrapAmountLamports
),
spl.createCloseAccountInstruction(
ephemeralWallet,
owner,
ephemeralAccount.publicKey
),
// only wrap funds if needed
...(amount > 0
? [
spl.createAssociatedTokenAccountInstruction(
payer,
ephemeralWallet,
ephemeralAccount.publicKey,
spl.NATIVE_MINT
),
SystemProgram.transfer({
fromPubkey: owner,
toPubkey: ephemeralWallet,
lamports: wrapAmountLamports,
}),
spl.createSyncNativeInstruction(ephemeralWallet),
spl.createTransferInstruction(
ephemeralWallet,
associatedAddress,
ephemeralAccount.publicKey,
wrapAmountLamports
),
spl.createCloseAccountInstruction(
ephemeralWallet,
owner,
ephemeralAccount.publicKey
),
]
: []),
],
user ? [user, ephemeralAccount] : [ephemeralAccount]
),

View File

@ -42,14 +42,15 @@
},
"../../javascript/solana.js": {
"name": "@switchboard-xyz/solana.js",
"version": "2.0.119",
"version": "2.0.133",
"license": "MIT",
"dependencies": {
"@coral-xyz/anchor": "^0.26.0",
"@coral-xyz/borsh": "^0.26.0",
"@solana/spl-token": "^0.3.6",
"@solana/web3.js": "^1.73.0",
"@switchboard-xyz/common": "^2.1.29",
"@switchboard-xyz/common": "^2.1.33",
"@switchboard-xyz/oracle": "^2.1.11",
"dotenv": "^16.0.3",
"lodash": "^4.17.21"
},
@ -4920,7 +4921,8 @@
"@coral-xyz/borsh": "^0.26.0",
"@solana/spl-token": "^0.3.6",
"@solana/web3.js": "^1.73.0",
"@switchboard-xyz/common": "^2.1.29",
"@switchboard-xyz/common": "^2.1.33",
"@switchboard-xyz/oracle": "^2.1.11",
"@types/chai": "^4.3.4",
"@types/expect": "^24.3.0",
"@types/lodash": "^4.14.191",