Skip to content

Commit

Permalink
ts: remove deprecated commitment settings (#1128)
Browse files Browse the repository at this point in the history
  • Loading branch information
Necmttn committed Dec 20, 2021
1 parent d353ed1 commit 483999e
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 14 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Expand Up @@ -11,8 +11,9 @@ incremented for features.

## [Unreleased]

### Fixes

### Fixes
* ts: Change commitment message `recent` to `processed` and `max` to `finalized` ([#1128](https://github.com/project-serum/anchor/pull/1128))
* ts: fix `translateAddress` which currently leads to failing browser code. Now uses `PublicKey` constructor instead of prototype chain constructor name checking which doesn't work in the presence of code minifying/mangling([1138](https://github.com/project-serum/anchor/pull/1138))

### Features
Expand Down
2 changes: 1 addition & 1 deletion tests/cfo/scripts/fees.js
Expand Up @@ -19,7 +19,7 @@ async function main() {
let marketClient = await Market.load(
provider.connection,
market,
{ commitment: "recent" },
{ commitment: "processed" },
DEX_PID
);
console.log("Fees: ", marketClient._decoded.quoteFeesAccrued.toString());
Expand Down
4 changes: 2 additions & 2 deletions tests/cfo/tests/cfo.js
Expand Up @@ -102,13 +102,13 @@ describe("cfo", () => {
marketAClient = await Market.load(
program.provider.connection,
ORDERBOOK_ENV.marketA.address,
{ commitment: "recent" },
{ commitment: "processed" },
DEX_PID
);
marketBClient = await Market.load(
program.provider.connection,
ORDERBOOK_ENV.marketB.address,
{ commitment: "recent" },
{ commitment: "processed" },
DEX_PID
);
assert.ok(marketAClient._decoded.quoteFeesAccrued.toString() === FEES);
Expand Down
9 changes: 5 additions & 4 deletions tests/cfo/tests/utils/index.js
Expand Up @@ -201,7 +201,7 @@ async function setupMarket({
const MARKET_A_USDC = await Market.load(
provider.connection,
marketAPublicKey,
{ commitment: "recent" },
{ commitment: "processed" },
DEX_PID
);
for (let k = 0; k < asks.length; k += 1) {
Expand Down Expand Up @@ -382,7 +382,8 @@ async function signTransactions({
wallet,
connection,
}) {
const blockhash = (await connection.getRecentBlockhash("max")).blockhash;
const blockhash = (await connection.getRecentBlockhash("finalized"))
.blockhash;
transactionsAndSigners.forEach(({ transaction, signers = [] }) => {
transaction.recentBlockhash = blockhash;
transaction.setSigners(
Expand All @@ -401,7 +402,7 @@ async function signTransactions({
async function sendAndConfirmRawTransaction(
connection,
raw,
commitment = "recent"
commitment = "processed"
) {
let tx = await connection.sendRawTransaction(raw, {
skipPreflight: true,
Expand Down Expand Up @@ -429,7 +430,7 @@ async function runTradeBot(market, provider, iterations = undefined) {
let marketClient = await Market.load(
provider.connection,
market,
{ commitment: "recent" },
{ commitment: "processed" },
DEX_PID
);
const baseTokenUser1 = (
Expand Down
7 changes: 4 additions & 3 deletions tests/swap/tests/utils/index.js
Expand Up @@ -272,7 +272,7 @@ async function setupMarket({
const MARKET_A_USDC = await Market.load(
provider.connection,
marketAPublicKey,
{ commitment: "recent" },
{ commitment: "processed" },
DEX_PID
);
for (let k = 0; k < asks.length; k += 1) {
Expand Down Expand Up @@ -453,7 +453,8 @@ async function signTransactions({
wallet,
connection,
}) {
const blockhash = (await connection.getRecentBlockhash("max")).blockhash;
const blockhash = (await connection.getRecentBlockhash("finalized"))
.blockhash;
transactionsAndSigners.forEach(({ transaction, signers = [] }) => {
transaction.recentBlockhash = blockhash;
transaction.setSigners(
Expand All @@ -472,7 +473,7 @@ async function signTransactions({
async function sendAndConfirmRawTransaction(
connection,
raw,
commitment = "recent"
commitment = "processed"
) {
let tx = await connection.sendRawTransaction(raw, {
skipPreflight: true,
Expand Down
6 changes: 3 additions & 3 deletions ts/src/provider.ts
Expand Up @@ -30,8 +30,8 @@ export default class Provider {

static defaultOptions(): ConfirmOptions {
return {
preflightCommitment: "recent",
commitment: "recent",
preflightCommitment: "processed",
commitment: "processed",
};
}

Expand Down Expand Up @@ -207,7 +207,7 @@ export default class Provider {
return await simulateTransaction(
this.connection,
tx,
opts.commitment ?? this.opts.commitment ?? "recent"
opts.commitment ?? this.opts.commitment ?? "processed"
);
}
}
Expand Down

0 comments on commit 483999e

Please sign in to comment.