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

Upgrade NPM dependencies #222

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
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 .yarn/sdks/eslint/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "eslint",
"version": "8.15.0-sdk",
"version": "8.17.0-sdk",
"main": "./lib/api.js",
"type": "commonjs"
}
39 changes: 33 additions & 6 deletions .yarn/sdks/typescript/lib/tsserver.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,30 @@ const moduleWrapper = tsserver => {
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
// Update Oct 8 2021: VSCode changed their format in 1.61.
// 2021-10-08: VSCode changed the format in 1.61.
// Before | ^zip:/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
// 2022-04-06: VSCode changed the format in 1.66.
// Before | ^/zip//c:/foo/bar.zip/package.json
// After | ^/zip/c:/foo/bar.zip/package.json
//
// 2022-05-06: VSCode changed the format in 1.68
// Before | ^/zip/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
case `vscode <1.61`: {
str = `^zip:${str}`;
} break;

case `vscode <1.66`: {
str = `^/zip/${str}`;
} break;

case `vscode <1.68`: {
str = `^/zip${str}`;
} break;

case `vscode`: {
str = `^/zip/${str}`;
} break;
Expand Down Expand Up @@ -119,9 +135,7 @@ const moduleWrapper = tsserver => {

case `vscode`:
default: {
return process.platform === `win32`
? str.replace(/^\^?(zip:|\/zip)\/+/, ``)
: str.replace(/^\^?(zip:|\/zip)\/+/, `/`);
return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
} break;
}
}
Expand Down Expand Up @@ -160,8 +174,21 @@ const moduleWrapper = tsserver => {
typeof parsedMessage.arguments.hostInfo === `string`
) {
hostInfo = parsedMessage.arguments.hostInfo;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.([1-5][0-9]|60)\./)) {
hostInfo += ` <1.61`;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
// The RegExp from https://semver.org/ but without the caret at the start
/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
) ?? []).map(Number)

if (major === 1) {
if (minor < 61) {
hostInfo += ` <1.61`;
} else if (minor < 66) {
hostInfo += ` <1.66`;
} else if (minor < 68) {
hostInfo += ` <1.68`;
}
}
}
}

Expand Down
39 changes: 33 additions & 6 deletions .yarn/sdks/typescript/lib/tsserverlibrary.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,14 +61,30 @@ const moduleWrapper = tsserver => {
//
// Ref: https://github.com/microsoft/vscode/issues/105014#issuecomment-686760910
//
// Update Oct 8 2021: VSCode changed their format in 1.61.
// 2021-10-08: VSCode changed the format in 1.61.
// Before | ^zip:/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
// 2022-04-06: VSCode changed the format in 1.66.
// Before | ^/zip//c:/foo/bar.zip/package.json
// After | ^/zip/c:/foo/bar.zip/package.json
//
// 2022-05-06: VSCode changed the format in 1.68
// Before | ^/zip/c:/foo/bar.zip/package.json
// After | ^/zip//c:/foo/bar.zip/package.json
//
case `vscode <1.61`: {
str = `^zip:${str}`;
} break;

case `vscode <1.66`: {
str = `^/zip/${str}`;
} break;

case `vscode <1.68`: {
str = `^/zip${str}`;
} break;

case `vscode`: {
str = `^/zip/${str}`;
} break;
Expand Down Expand Up @@ -119,9 +135,7 @@ const moduleWrapper = tsserver => {

case `vscode`:
default: {
return process.platform === `win32`
? str.replace(/^\^?(zip:|\/zip)\/+/, ``)
: str.replace(/^\^?(zip:|\/zip)\/+/, `/`);
return str.replace(/^\^?(zip:|\/zip(\/ts-nul-authority)?)\/+/, process.platform === `win32` ? `` : `/`)
} break;
}
}
Expand Down Expand Up @@ -160,8 +174,21 @@ const moduleWrapper = tsserver => {
typeof parsedMessage.arguments.hostInfo === `string`
) {
hostInfo = parsedMessage.arguments.hostInfo;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK && process.env.VSCODE_IPC_HOOK.match(/Code\/1\.([1-5][0-9]|60)\./)) {
hostInfo += ` <1.61`;
if (hostInfo === `vscode` && process.env.VSCODE_IPC_HOOK) {
const [, major, minor] = (process.env.VSCODE_IPC_HOOK.match(
// The RegExp from https://semver.org/ but without the caret at the start
/(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-((?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*)(?:\.(?:0|[1-9]\d*|\d*[a-zA-Z-][0-9a-zA-Z-]*))*))?(?:\+([0-9a-zA-Z-]+(?:\.[0-9a-zA-Z-]+)*))?$/
) ?? []).map(Number)

if (major === 1) {
if (minor < 61) {
hostInfo += ` <1.61`;
} else if (minor < 66) {
hostInfo += ` <1.66`;
} else if (minor < 68) {
hostInfo += ` <1.68`;
}
}
}
}

Expand Down
2 changes: 1 addition & 1 deletion .yarn/sdks/typescript/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "typescript",
"version": "4.6.4-sdk",
"version": "4.7.3-sdk",
"main": "./lib/typescript.js",
"type": "commonjs"
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@
"@types/bn.js": "^5"
},
"peerDependencies": {
"@project-serum/anchor": "^0.24.2",
"@saberhq/anchor-contrib": "^1.13",
"@saberhq/solana-contrib": "^1.13",
"@saberhq/stableswap-sdk": "^1.13",
Expand Down
18 changes: 18 additions & 0 deletions src/redeemer/pda.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { utils } from "@project-serum/anchor";
import { getProgramAddress } from "@saberhq/solana-contrib";
import { PublicKey } from "@solana/web3.js";

import { SABER_ADDRESSES } from "../constants";
Expand All @@ -19,3 +20,20 @@ export const findRedeemerKey = async ({
SABER_ADDRESSES.Redeemer
);
};

export const getRedeemerKey = ({
iouMint,
redemptionMint,
}: {
iouMint: PublicKey;
redemptionMint: PublicKey;
}): PublicKey => {
return getProgramAddress(
[
utils.bytes.utf8.encode("Redeemer"),
iouMint.toBytes(),
redemptionMint.toBytes(),
],
SABER_ADDRESSES.Redeemer
);
};
21 changes: 10 additions & 11 deletions src/wrappers/lockup.ts
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
import type * as anchor from "@project-serum/anchor";
import type { TransactionEnvelope } from "@saberhq/solana-contrib";
import type { u64 } from "@saberhq/token-utils";
import { getOrCreateATA, TOKEN_PROGRAM_ID } from "@saberhq/token-utils";
import type { PublicKey } from "@solana/web3.js";
import type { PublicKey, TransactionInstruction } from "@solana/web3.js";
import {
SystemProgram,
SYSVAR_CLOCK_PUBKEY,
SYSVAR_RENT_PUBKEY,
} from "@solana/web3.js";
import { BN } from "bn.js";
import BN from "bn.js";

import type { LockupProgram, ReleaseData } from "../programs/lockup";
import type { Saber } from "../sdk";

const ZERO = new BN(0);

export interface PendingRelease {
release: anchor.web3.PublicKey;
release: PublicKey;
tx: TransactionEnvelope;
}

Expand Down Expand Up @@ -55,9 +54,9 @@ export class LockupWrapper {
minterInfo,
mint,
}: {
amount: anchor.BN;
startTs: anchor.BN;
endTs: anchor.BN;
amount: BN;
startTs: BN;
endTs: BN;
beneficiary: PublicKey;
release: PublicKey;
minterInfo: PublicKey;
Expand Down Expand Up @@ -107,9 +106,9 @@ export class LockupWrapper {
endTs,
beneficiary,
}: {
amount: anchor.BN;
startTs: anchor.BN;
endTs: anchor.BN;
amount: BN;
startTs: BN;
endTs: BN;
beneficiary: PublicKey;
}): Promise<PendingRelease> {
const release = await this.releaseAddress(beneficiary);
Expand Down Expand Up @@ -139,7 +138,7 @@ export class LockupWrapper {
const mintProxyStateAddress = this.saber.mintProxy.program.state.address();
const mintProxyState = await this.saber.mintProxy.program.state.fetch();

const instructions: anchor.web3.TransactionInstruction[] = [];
const instructions: TransactionInstruction[] = [];
const { address, instruction } = await getOrCreateATA({
provider: this.saber.provider,
mint: mintProxyState.tokenMint,
Expand Down
35 changes: 21 additions & 14 deletions src/wrappers/mint-proxy/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { Address } from "@project-serum/anchor";
import { translateAddress, utils } from "@project-serum/anchor";
import { utils } from "@project-serum/anchor";
import type { TransactionEnvelope } from "@saberhq/solana-contrib";
import { getProgramAddress } from "@saberhq/solana-contrib";
import type { u64 } from "@saberhq/token-utils";
import {
ChainId,
Expand All @@ -22,30 +22,37 @@ import type { MinterInfo, MintProxyProgram } from "../../programs";
import type { Saber } from "../../sdk";
import type { PendingMintAndProxy, PendingMintProxy } from "./types";

async function associated(
programId: Address,
...args: Array<Address | Buffer>
): Promise<PublicKey> {
const associated = (
programId: PublicKey,
...args: Array<PublicKey | Buffer>
): PublicKey => {
const seeds = [Buffer.from([97, 110, 99, 104, 111, 114])]; // b"anchor".
args.forEach((arg) => {
seeds.push(arg instanceof Buffer ? arg : translateAddress(arg).toBuffer());
seeds.push(arg instanceof Buffer ? arg : arg.toBuffer());
});
const [assoc] = await PublicKey.findProgramAddress(
seeds,
translateAddress(programId)
);
return assoc;
}
return getProgramAddress(seeds, programId);
};

/**
* Finds the address of a minter.
* @param minter
*
* @deprecated use {@link getMinterInfoAddress}
* @returns
*/
export const findMinterInfoAddress = async (
minter: PublicKey
): Promise<PublicKey> => {
return await associated(SABER_ADDRESSES.MintProxy, minter);
return Promise.resolve(getMinterInfoAddress(minter));
};

/**
* Finds the address of a minter.
* @param minter
* @returns
*/
export const getMinterInfoAddress = (minter: PublicKey): PublicKey => {
return associated(SABER_ADDRESSES.MintProxy, minter);
};

export class MintProxyWrapper {
Expand Down
1 change: 1 addition & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -451,6 +451,7 @@ __metadata:
typedoc: ^0.22.17
typescript: ^4.7.3
peerDependencies:
"@project-serum/anchor": ^0.24.2
"@saberhq/anchor-contrib": ^1.13
"@saberhq/solana-contrib": ^1.13
"@saberhq/stableswap-sdk": ^1.13
Expand Down