Skip to content
This repository was archived by the owner on Mar 11, 2025. It is now read-only.

Commit 8528f92

Browse files
authored
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
1 parent feeda6a commit 8528f92

File tree

9 files changed

+105
-45
lines changed

9 files changed

+105
-45
lines changed

account-compression/sdk/package.json

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,33 @@
11
{
22
"name": "@solana/spl-account-compression",
3-
"version": "0.1.0",
43
"description": "SPL Account Compression Program JS API",
4+
"version": "0.1.0",
55
"author": "Solana Maintainers <[email protected]>",
66
"repository": {
77
"url": "https://github.com/solana-labs/solana-program-library",
88
"type": "git"
99
},
10+
"license": "Apache-2.0",
1011
"sideEffects": false,
1112
"engines": {
1213
"node": ">=16"
1314
},
14-
"license": "Apache-2.0",
15+
"files": [
16+
"dist",
17+
"src",
18+
"idl",
19+
"README.md"
20+
],
21+
"publishConfig": {
22+
"access": "public"
23+
},
1524
"main": "./dist/cjs/index.js",
1625
"module": "./dist/esm/index.js",
17-
"types": "./dist/cjs/index.d.ts",
26+
"types": "./dist/types/index.d.ts",
1827
"exports": {
19-
".": {
20-
"require": "./dist/cjs/index.js",
21-
"import": "./dist/esm/index.js",
22-
"types": "./dist/cjs/index.d.ts"
23-
}
28+
"require": "./dist/cjs/index.js",
29+
"import": "./dist/esm/index.js",
30+
"types": "./dist/types/index.d.ts"
2431
},
2532
"scripts": {
2633
"build": "rm -rf dist/ && tsc && tsc -p tsconfig.cjs.json",
@@ -29,20 +36,22 @@
2936
"test": "start-server-and-test start-validator http://localhost:8899/health run-tests"
3037
},
3138
"dependencies": {
32-
"@metaplex-foundation/beet": "^0.6.1",
3339
"@types/bn.js": "^5.1.1",
3440
"bn.js": "^5.2.1",
3541
"borsh": "^0.7.0"
3642
},
3743
"peerDependencies": {
38-
"@solana/web3.js": "^1.50.1"
44+
"@solana/web3.js": "^1.50.1",
45+
"@metaplex-foundation/beet": "^0.6.1",
46+
"@metaplex-foundation/beet-solana": "^0.6.1"
3947
},
4048
"devDependencies": {
4149
"@metaplex-foundation/rustbin": "^0.3.1",
4250
"@metaplex-foundation/solita": "^0.12.2",
4351
"@project-serum/anchor": "^0.25.0",
4452
"@types/chai": "^4.3.0",
4553
"@types/jest": "^29.0.0",
54+
"@types/node-fetch": "^2.6.2",
4655
"chai": "^4.3.4",
4756
"jest": "^29.0.1",
4857
"jest-config": "^29.0.1",
@@ -53,8 +62,5 @@
5362
"ts-node": "^10.9.1",
5463
"typescript": "=4.7.4",
5564
"typescript-collections": "^1.3.3"
56-
},
57-
"files": [
58-
"dist"
59-
]
60-
}
65+
}
66+
}

account-compression/sdk/src/index.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
export * from './generated';
2+
export {
3+
PROGRAM_ADDRESS as SPL_ACCOUNT_COMPRESSION_ADDRESS,
4+
PROGRAM_ID as SPL_ACCOUNT_COMPRESSION_PROGRAM_ID,
5+
} from './generated';
26
export * from './instructions';
37
export * from './accounts';
4-
export { PathNode } from './accounts';
8+
export type { PathNode } from './accounts';
59
export * from './utils';

account-compression/sdk/src/instructions/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Connection, Keypair, PublicKey, SystemProgram, TransactionInstruction } from '@solana/web3.js';
2-
import { LOG_WRAPPER_PROGRAM_ID } from "../utils";
2+
import { SPL_NOOP_PROGRAM_ID } from "../utils";
33
import { getConcurrentMerkleTreeAccountSize } from '../accounts';
44
import {
55
createReplaceLeafInstruction,
@@ -41,7 +41,7 @@ export function createReplaceIx(
4141
{
4242
merkleTree,
4343
authority: authority.publicKey,
44-
logWrapper: LOG_WRAPPER_PROGRAM_ID,
44+
logWrapper: SPL_NOOP_PROGRAM_ID,
4545
},
4646
{
4747
root: Array.from(treeRoot),
@@ -61,7 +61,7 @@ export function createAppendIx(
6161
{
6262
merkleTree,
6363
authority: authority.publicKey,
64-
logWrapper: LOG_WRAPPER_PROGRAM_ID,
64+
logWrapper: SPL_NOOP_PROGRAM_ID,
6565
},
6666
{
6767
leaf: Array.from(newLeaf),

account-compression/sdk/src/utils/index.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {
33
} from "@solana/web3.js";
44
import * as borsh from "borsh";
55

6-
export const LOG_WRAPPER_PROGRAM_ID = new PublicKey("WRAPYChf58WFCnyjXKJHtrPgzKXgHp6MD9aVDqJBbGh");
6+
export const SPL_NOOP_ADDRESS = "WRAPYChf58WFCnyjXKJHtrPgzKXgHp6MD9aVDqJBbGh";
7+
export const SPL_NOOP_PROGRAM_ID = new PublicKey("WRAPYChf58WFCnyjXKJHtrPgzKXgHp6MD9aVDqJBbGh");
78

89
/// Read in a public key from a BinaryReader
910
export function readPublicKey(reader: borsh.BinaryReader): PublicKey {

account-compression/sdk/tests/accountCompression.test.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ import {
3030
createVerifyLeafIx,
3131
createAllocTreeIx,
3232
createInitEmptyMerkleTreeInstruction,
33-
LOG_WRAPPER_PROGRAM_ID,
33+
SPL_NOOP_PROGRAM_ID,
3434
} from "../src";
3535
import {
3636
getCMTMaxBufferSize,
@@ -160,7 +160,7 @@ describe("Account Compression", () => {
160160
{
161161
merkleTree: cmtKeypair.publicKey,
162162
authority: payer.publicKey,
163-
logWrapper: LOG_WRAPPER_PROGRAM_ID,
163+
logWrapper: SPL_NOOP_PROGRAM_ID,
164164
},
165165
{
166166
maxDepth,
@@ -676,7 +676,7 @@ describe("Account Compression", () => {
676676
let leafList = Array.from(leaves.entries());
677677
leafList.sort(() => Math.random() - 0.5);
678678
let replaces = 0;
679-
let newLeaves = {};
679+
let newLeaves: Record<number, Buffer> = {};
680680
for (const [i, leaf] of leafList) {
681681
const newLeaf = crypto.randomBytes(32);
682682
newLeaves[i] = newLeaf;
Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,17 @@
11
{
2-
"include": [
3-
"./src/**/*",
4-
],
2+
"include": [],
53
"compilerOptions": {
6-
"sourceMap": true,
7-
"declaration": true,
8-
"declarationMap": true,
9-
"allowSyntheticDefaultImports": true,
10-
"experimentalDecorators": true,
11-
"emitDecoratorMetadata": true,
12-
"noImplicitAny": false,
13-
"strictNullChecks": true,
4+
"target": "ESNext",
5+
"module": "ESNext",
6+
"moduleResolution": "Node",
147
"esModuleInterop": true,
8+
"isolatedModules": true,
9+
"noEmitOnError": true,
1510
"resolveJsonModule": true,
16-
"composite": true,
17-
"downlevelIteration": true,
18-
"baseUrl": ".",
11+
"strict": true,
12+
"stripInternal": true,
1913
"typeRoots": [
20-
"src/types",
2114
"node_modules/@types"
22-
],
15+
]
2316
}
2417
}
Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,12 @@
11
{
22
"extends": "./tsconfig.base.json",
3+
"include": [
4+
"src"
5+
],
36
"compilerOptions": {
4-
"module": "commonjs",
5-
"target": "es2019",
67
"outDir": "dist/cjs/",
8+
"target": "ES2016",
9+
"module": "CommonJS",
10+
"sourceMap": true,
711
}
812
}

account-compression/sdk/tsconfig.json

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
{
22
"extends": "./tsconfig.base.json",
3+
"include": [
4+
"src"
5+
],
36
"compilerOptions": {
4-
"moduleResolution": "node",
5-
"module": "es2022",
6-
"target": "es2019",
77
"outDir": "dist/esm/",
8+
"declarationDir": "dist/types",
9+
"module": "es2020",
10+
"target": "es2020",
11+
"sourceMap": true,
12+
"declaration": true,
13+
"declarationMap": true
814
}
915
}

account-compression/sdk/yarn.lock

Lines changed: 47 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -620,7 +620,7 @@
620620
bs58 "^5.0.0"
621621
debug "^4.3.4"
622622

623-
"@metaplex-foundation/beet@>=0.1.0", "@metaplex-foundation/beet@^0.6.1":
623+
"@metaplex-foundation/beet@>=0.1.0":
624624
version "0.6.1"
625625
resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.6.1.tgz#6331bdde0648bf2cae6f9e482f8e3552db05d69f"
626626
integrity sha512-OYgnijLFzw0cdUlRKH5POp0unQECPOW9muJ2X3QIVyak5G6I6l/rKo72sICgPLIFKdmsi2jmnkuLY7wp14iXdw==
@@ -878,6 +878,14 @@
878878
expect "^29.0.0"
879879
pretty-format "^29.0.0"
880880

881+
"@types/node-fetch@^2.6.2":
882+
version "2.6.2"
883+
resolved "https://registry.yarnpkg.com/@types/node-fetch/-/node-fetch-2.6.2.tgz#d1a9c5fd049d9415dce61571557104dec3ec81da"
884+
integrity sha512-DHqhlq5jeESLy19TYhLakJ07kNumXWjcDdxXsLUMJZ6ue8VZJj4kLPQVE/2mdHh3xZziNF1xppu5lwmS53HR+A==
885+
dependencies:
886+
"@types/node" "*"
887+
form-data "^3.0.0"
888+
881889
"@types/node@*":
882890
version "18.7.16"
883891
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.7.16.tgz#0eb3cce1e37c79619943d2fd903919fc30850601"
@@ -1003,6 +1011,11 @@ assertion-error@^1.1.0:
10031011
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
10041012
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
10051013

1014+
asynckit@^0.4.0:
1015+
version "0.4.0"
1016+
resolved "https://registry.yarnpkg.com/asynckit/-/asynckit-0.4.0.tgz#c79ed97f7f34cb8f2ba1bc9790bcc366474b4b79"
1017+
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
1018+
10061019
axios@^0.21.1:
10071020
version "0.21.4"
10081021
resolved "https://registry.yarnpkg.com/axios/-/axios-0.21.4.tgz#c67b90dc0568e5c1cf2b0b858c43ba28e2eda575"
@@ -1329,6 +1342,13 @@ color-name@~1.1.4:
13291342
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
13301343
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
13311344

1345+
combined-stream@^1.0.8:
1346+
version "1.0.8"
1347+
resolved "https://registry.yarnpkg.com/combined-stream/-/combined-stream-1.0.8.tgz#c3d45a8b34fd730631a110a8a2520682b31d5a7f"
1348+
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
1349+
dependencies:
1350+
delayed-stream "~1.0.0"
1351+
13321352
commander@^2.20.3:
13331353
version "2.20.3"
13341354
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
@@ -1408,6 +1428,11 @@ delay@^5.0.0:
14081428
resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d"
14091429
integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==
14101430

1431+
delayed-stream@~1.0.0:
1432+
version "1.0.0"
1433+
resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"
1434+
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
1435+
14111436
detect-newline@^3.0.0:
14121437
version "3.1.0"
14131438
resolved "https://registry.yarnpkg.com/detect-newline/-/detect-newline-3.1.0.tgz#576f5dfc63ae1a192ff192d8ad3af6308991b651"
@@ -1586,6 +1611,15 @@ follow-redirects@^1.14.0:
15861611
resolved "https://registry.yarnpkg.com/follow-redirects/-/follow-redirects-1.15.1.tgz#0ca6a452306c9b276e4d3127483e29575e207ad5"
15871612
integrity sha512-yLAMQs+k0b2m7cVxpS1VKJVvoz7SS9Td1zss3XRwXj+ZDH00RJgnuLx7E44wx02kQLrdM3aOOy+FpzS7+8OizA==
15881613

1614+
form-data@^3.0.0:
1615+
version "3.0.1"
1616+
resolved "https://registry.yarnpkg.com/form-data/-/form-data-3.0.1.tgz#ebd53791b78356a99af9a300d4282c4d5eb9755f"
1617+
integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==
1618+
dependencies:
1619+
asynckit "^0.4.0"
1620+
combined-stream "^1.0.8"
1621+
mime-types "^2.1.12"
1622+
15891623
from@~0:
15901624
version "0.1.7"
15911625
resolved "https://registry.yarnpkg.com/from/-/from-0.1.7.tgz#83c60afc58b9c56997007ed1a768b3ab303a44fe"
@@ -2426,6 +2460,18 @@ micromatch@^4.0.4:
24262460
braces "^3.0.2"
24272461
picomatch "^2.3.1"
24282462

2463+
2464+
version "1.52.0"
2465+
resolved "https://registry.yarnpkg.com/mime-db/-/mime-db-1.52.0.tgz#bbabcdc02859f4987301c856e3387ce5ec43bf70"
2466+
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
2467+
2468+
mime-types@^2.1.12:
2469+
version "2.1.35"
2470+
resolved "https://registry.yarnpkg.com/mime-types/-/mime-types-2.1.35.tgz#381a871b62a734450660ae3deee44813f70d959a"
2471+
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
2472+
dependencies:
2473+
mime-db "1.52.0"
2474+
24292475
mimic-fn@^2.1.0:
24302476
version "2.1.0"
24312477
resolved "https://registry.yarnpkg.com/mimic-fn/-/mimic-fn-2.1.0.tgz#7ed2c2ccccaf84d3ffcb7a69b57711fc2083401b"

0 commit comments

Comments
 (0)