SPL Account Compression JS Package (#3609)

* AC: fix tsconfig json files for publishing js package

* AC: fix package.json module exporting, move mpl to peerDeps

* AC: rename program ids and addresses to match crate
This commit is contained in:
Noah Gundotra 2022-09-16 15:56:31 -04:00 committed by GitHub
parent feeda6a61e
commit 8528f92f07
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
9 changed files with 105 additions and 45 deletions

View File

@ -1,26 +1,33 @@
{ {
"name": "@solana/spl-account-compression", "name": "@solana/spl-account-compression",
"version": "0.1.0",
"description": "SPL Account Compression Program JS API", "description": "SPL Account Compression Program JS API",
"version": "0.1.0",
"author": "Solana Maintainers <maintainers@solana.foundation>", "author": "Solana Maintainers <maintainers@solana.foundation>",
"repository": { "repository": {
"url": "https://github.com/solana-labs/solana-program-library", "url": "https://github.com/solana-labs/solana-program-library",
"type": "git" "type": "git"
}, },
"license": "Apache-2.0",
"sideEffects": false, "sideEffects": false,
"engines": { "engines": {
"node": ">=16" "node": ">=16"
}, },
"license": "Apache-2.0", "files": [
"dist",
"src",
"idl",
"README.md"
],
"publishConfig": {
"access": "public"
},
"main": "./dist/cjs/index.js", "main": "./dist/cjs/index.js",
"module": "./dist/esm/index.js", "module": "./dist/esm/index.js",
"types": "./dist/cjs/index.d.ts", "types": "./dist/types/index.d.ts",
"exports": { "exports": {
".": { "require": "./dist/cjs/index.js",
"require": "./dist/cjs/index.js", "import": "./dist/esm/index.js",
"import": "./dist/esm/index.js", "types": "./dist/types/index.d.ts"
"types": "./dist/cjs/index.d.ts"
}
}, },
"scripts": { "scripts": {
"build": "rm -rf dist/ && tsc && tsc -p tsconfig.cjs.json", "build": "rm -rf dist/ && tsc && tsc -p tsconfig.cjs.json",
@ -29,13 +36,14 @@
"test": "start-server-and-test start-validator http://localhost:8899/health run-tests" "test": "start-server-and-test start-validator http://localhost:8899/health run-tests"
}, },
"dependencies": { "dependencies": {
"@metaplex-foundation/beet": "^0.6.1",
"@types/bn.js": "^5.1.1", "@types/bn.js": "^5.1.1",
"bn.js": "^5.2.1", "bn.js": "^5.2.1",
"borsh": "^0.7.0" "borsh": "^0.7.0"
}, },
"peerDependencies": { "peerDependencies": {
"@solana/web3.js": "^1.50.1" "@solana/web3.js": "^1.50.1",
"@metaplex-foundation/beet": "^0.6.1",
"@metaplex-foundation/beet-solana": "^0.6.1"
}, },
"devDependencies": { "devDependencies": {
"@metaplex-foundation/rustbin": "^0.3.1", "@metaplex-foundation/rustbin": "^0.3.1",
@ -43,6 +51,7 @@
"@project-serum/anchor": "^0.25.0", "@project-serum/anchor": "^0.25.0",
"@types/chai": "^4.3.0", "@types/chai": "^4.3.0",
"@types/jest": "^29.0.0", "@types/jest": "^29.0.0",
"@types/node-fetch": "^2.6.2",
"chai": "^4.3.4", "chai": "^4.3.4",
"jest": "^29.0.1", "jest": "^29.0.1",
"jest-config": "^29.0.1", "jest-config": "^29.0.1",
@ -53,8 +62,5 @@
"ts-node": "^10.9.1", "ts-node": "^10.9.1",
"typescript": "=4.7.4", "typescript": "=4.7.4",
"typescript-collections": "^1.3.3" "typescript-collections": "^1.3.3"
}, }
"files": [
"dist"
]
} }

View File

@ -1,5 +1,9 @@
export * from './generated'; export * from './generated';
export {
PROGRAM_ADDRESS as SPL_ACCOUNT_COMPRESSION_ADDRESS,
PROGRAM_ID as SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
} from './generated';
export * from './instructions'; export * from './instructions';
export * from './accounts'; export * from './accounts';
export { PathNode } from './accounts'; export type { PathNode } from './accounts';
export * from './utils'; export * from './utils';

View File

@ -1,5 +1,5 @@
import { Connection, Keypair, PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js'; import { Connection, Keypair, PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
import { LOG_WRAPPER_PROGRAM_ID } from "../utils"; import { SPL_NOOP_PROGRAM_ID } from "../utils";
import { getConcurrentMerkleTreeAccountSize } from '../accounts'; import { getConcurrentMerkleTreeAccountSize } from '../accounts';
import { import {
createReplaceLeafInstruction, createReplaceLeafInstruction,
@ -41,7 +41,7 @@ export function createReplaceIx(
{ {
merkleTree, merkleTree,
authority: authority.publicKey, authority: authority.publicKey,
logWrapper: LOG_WRAPPER_PROGRAM_ID, logWrapper: SPL_NOOP_PROGRAM_ID,
}, },
{ {
root: Array.from(treeRoot), root: Array.from(treeRoot),
@ -61,7 +61,7 @@ export function createAppendIx(
{ {
merkleTree, merkleTree,
authority: authority.publicKey, authority: authority.publicKey,
logWrapper: LOG_WRAPPER_PROGRAM_ID, logWrapper: SPL_NOOP_PROGRAM_ID,
}, },
{ {
leaf: Array.from(newLeaf), leaf: Array.from(newLeaf),

View File

@ -3,7 +3,8 @@ import {
} from "@solana/web3.js"; } from "@solana/web3.js";
import * as borsh from "borsh"; import * as borsh from "borsh";
export const LOG_WRAPPER_PROGRAM_ID = new PublicKey("WRAPYChf58WFCnyjXKJHtrPgzKXgHp6MD9aVDqJBbGh"); export const SPL_NOOP_ADDRESS = "WRAPYChf58WFCnyjXKJHtrPgzKXgHp6MD9aVDqJBbGh";
export const SPL_NOOP_PROGRAM_ID = new PublicKey("WRAPYChf58WFCnyjXKJHtrPgzKXgHp6MD9aVDqJBbGh");
/// Read in a public key from a BinaryReader /// Read in a public key from a BinaryReader
export function readPublicKey(reader: borsh.BinaryReader): PublicKey { export function readPublicKey(reader: borsh.BinaryReader): PublicKey {

View File

@ -30,7 +30,7 @@ import {
createVerifyLeafIx, createVerifyLeafIx,
createAllocTreeIx, createAllocTreeIx,
createInitEmptyMerkleTreeInstruction, createInitEmptyMerkleTreeInstruction,
LOG_WRAPPER_PROGRAM_ID, SPL_NOOP_PROGRAM_ID,
} from "../src"; } from "../src";
import { import {
getCMTMaxBufferSize, getCMTMaxBufferSize,
@ -160,7 +160,7 @@ describe("Account Compression", () => {
{ {
merkleTree: cmtKeypair.publicKey, merkleTree: cmtKeypair.publicKey,
authority: payer.publicKey, authority: payer.publicKey,
logWrapper: LOG_WRAPPER_PROGRAM_ID, logWrapper: SPL_NOOP_PROGRAM_ID,
}, },
{ {
maxDepth, maxDepth,
@ -676,7 +676,7 @@ describe("Account Compression", () => {
let leafList = Array.from(leaves.entries()); let leafList = Array.from(leaves.entries());
leafList.sort(() => Math.random() - 0.5); leafList.sort(() => Math.random() - 0.5);
let replaces = 0; let replaces = 0;
let newLeaves = {}; let newLeaves: Record<number, Buffer> = {};
for (const [i, leaf] of leafList) { for (const [i, leaf] of leafList) {
const newLeaf = crypto.randomBytes(32); const newLeaf = crypto.randomBytes(32);
newLeaves[i] = newLeaf; newLeaves[i] = newLeaf;

View File

@ -1,24 +1,17 @@
{ {
"include": [ "include": [],
"./src/**/*",
],
"compilerOptions": { "compilerOptions": {
"sourceMap": true, "target": "ESNext",
"declaration": true, "module": "ESNext",
"declarationMap": true, "moduleResolution": "Node",
"allowSyntheticDefaultImports": true,
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"noImplicitAny": false,
"strictNullChecks": true,
"esModuleInterop": true, "esModuleInterop": true,
"isolatedModules": true,
"noEmitOnError": true,
"resolveJsonModule": true, "resolveJsonModule": true,
"composite": true, "strict": true,
"downlevelIteration": true, "stripInternal": true,
"baseUrl": ".",
"typeRoots": [ "typeRoots": [
"src/types",
"node_modules/@types" "node_modules/@types"
], ]
} }
} }

View File

@ -1,8 +1,12 @@
{ {
"extends": "./tsconfig.base.json", "extends": "./tsconfig.base.json",
"include": [
"src"
],
"compilerOptions": { "compilerOptions": {
"module": "commonjs",
"target": "es2019",
"outDir": "dist/cjs/", "outDir": "dist/cjs/",
"target": "ES2016",
"module": "CommonJS",
"sourceMap": true,
} }
} }

View File

@ -1,9 +1,15 @@
{ {
"extends": "./tsconfig.base.json", "extends": "./tsconfig.base.json",
"include": [
"src"
],
"compilerOptions": { "compilerOptions": {
"moduleResolution": "node",
"module": "es2022",
"target": "es2019",
"outDir": "dist/esm/", "outDir": "dist/esm/",
"declarationDir": "dist/types",
"module": "es2020",
"target": "es2020",
"sourceMap": true,
"declaration": true,
"declarationMap": true
} }
} }

View File

@ -620,7 +620,7 @@
bs58 "^5.0.0" bs58 "^5.0.0"
debug "^4.3.4" debug "^4.3.4"
"@metaplex-foundation/beet@>=0.1.0", "@metaplex-foundation/beet@^0.6.1": "@metaplex-foundation/beet@>=0.1.0":
version "0.6.1" version "0.6.1"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.6.1.tgz#6331bdde0648bf2cae6f9e482f8e3552db05d69f" resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.6.1.tgz#6331bdde0648bf2cae6f9e482f8e3552db05d69f"
integrity sha512-OYgnijLFzw0cdUlRKH5POp0unQECPOW9muJ2X3QIVyak5G6I6l/rKo72sICgPLIFKdmsi2jmnkuLY7wp14iXdw== integrity sha512-OYgnijLFzw0cdUlRKH5POp0unQECPOW9muJ2X3QIVyak5G6I6l/rKo72sICgPLIFKdmsi2jmnkuLY7wp14iXdw==
@ -878,6 +878,14 @@
expect "^29.0.0" expect "^29.0.0"
pretty-format "^29.0.0" pretty-format "^29.0.0"
"@types/node-fetch@^2.6.2":
version "2.6.2"
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da"
integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==
dependencies:
"@types/node" "*"
form-data "^3.0.0"
"@types/node@*": "@types/node@*":
version "18.7.16" version "18.7.16"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.16.tgz#0eb3cce1e37c79619943d2fd903919fc30850601" resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.16.tgz#0eb3cce1e37c79619943d2fd903919fc30850601"
@ -1003,6 +1011,11 @@ assertion-error@^1.1.0:
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b" resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw== integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
axios@^0.21.1: axios@^0.21.1:
version "0.21.4" version "0.21.4"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575" resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
@ -1329,6 +1342,13 @@ color-name@~1.1.4:
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2" resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA== integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"
commander@^2.20.3: commander@^2.20.3:
version "2.20.3" version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33" resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
@ -1408,6 +1428,11 @@ delay@^5.0.0:
resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d" resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d"
integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw== integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==
delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
detect-newline@^3.0.0: detect-newline@^3.0.0:
version "3.1.0" version "3.1.0"
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651" resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
@ -1586,6 +1611,15 @@ follow-redirects@^1.14.0:
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5" resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5"
integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA== integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==
form-data@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f"
integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"
from@~0: from@~0:
version "0.1.7" version "0.1.7"
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe" resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
@ -2426,6 +2460,18 @@ micromatch@^4.0.4:
braces "^3.0.2" braces "^3.0.2"
picomatch "^2.3.1" picomatch "^2.3.1"
mime-db@1.52.0:
version "1.52.0"
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
mime-types@^2.1.12:
version "2.1.35"
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
dependencies:
mime-db "1.52.0"
mimic-fn@^2.1.0: mimic-fn@^2.1.0:
version "2.1.0" version "2.1.0"
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b" resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"