Skip to content

Commit cab36be

Browse files
committed
Helpers for encoding and decoding offchain messages
1 parent ac72d8d commit cab36be

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+3767
-0
lines changed

.changeset/calm-jokes-run.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
---
2+
'@solana/offchain-messages': minor
3+
'@solana/errors': minor
4+
'@solana/kit': minor
5+
---
6+
7+
Added codecs for encoding and decoding Solana Offchain Messages (see https://github.com/solana-foundation/SRFCs/discussions/3)

packages/kit/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@
8484
"@solana/instructions": "workspace:*",
8585
"@solana/instruction-plans": "workspace:*",
8686
"@solana/keys": "workspace:*",
87+
"@solana/offchain-messages": "workspace:*",
8788
"@solana/programs": "workspace:*",
8889
"@solana/rpc": "workspace:*",
8990
"@solana/rpc-parsed-types": "workspace:*",

packages/kit/src/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ export * from '@solana/functional';
1414
export * from '@solana/instructions';
1515
export * from '@solana/instruction-plans';
1616
export * from '@solana/keys';
17+
export * from '@solana/offchain-messages';
1718
export * from '@solana/programs';
1819
export * from '@solana/rpc';
1920
export * from '@solana/rpc-parsed-types';
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
.docs/
2+
dist/

packages/offchain-messages/.npmrc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
engine-strict=true
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Changelogs are autogenerated, so leave them alone
2+
CHANGELOG.md
3+
4+
dist/
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# @solana/offchain-messages

packages/offchain-messages/LICENSE

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
Copyright (c) 2023 Solana Labs, Inc
2+
3+
Permission is hereby granted, free of charge, to any person obtaining
4+
a copy of this software and associated documentation files (the
5+
"Software"), to deal in the Software without restriction, including
6+
without limitation the rights to use, copy, modify, merge, publish,
7+
distribute, sublicense, and/or sell copies of the Software, and to
8+
permit persons to whom the Software is furnished to do so, subject to
9+
the following conditions:
10+
11+
The above copyright notice and this permission notice shall be
12+
included in all copies or substantial portions of the Software.
13+
14+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
[![npm][npm-image]][npm-url]
2+
[![npm-downloads][npm-downloads-image]][npm-url]
3+
<br />
4+
[![code-style-prettier][code-style-prettier-image]][code-style-prettier-url]
5+
6+
[code-style-prettier-image]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square
7+
[code-style-prettier-url]: https://github.com/prettier/prettier
8+
[npm-downloads-image]: https://img.shields.io/npm/dm/@solana/offchain-messages?style=flat
9+
[npm-image]: https://img.shields.io/npm/v/@solana/offchain-messages?style=flat
10+
[npm-url]: https://www.npmjs.com/package/@solana/offchain-messages
11+
12+
# @solana/offchain-messages
13+
14+
This package contains utilities for encoding and decoding messages according to the offchain message [specification](https://github.com/solana-foundation/SRFCs/discussions/3). It can be used standalone, but it is also exported as part of Kit [`@solana/kit`](https://github.com/anza-xyz/kit/tree/main/packages/kit).
Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
{
2+
"name": "@solana/offchain-messages",
3+
"version": "5.0.0",
4+
"description": "Helpers for encoding and decoding messages according to the offchain message specification",
5+
"homepage": "https://www.solanakit.com/api#solanaoffchain-messages",
6+
"exports": {
7+
"edge-light": {
8+
"import": "./dist/index.node.mjs",
9+
"require": "./dist/index.node.cjs"
10+
},
11+
"workerd": {
12+
"import": "./dist/index.node.mjs",
13+
"require": "./dist/index.node.cjs"
14+
},
15+
"browser": {
16+
"import": "./dist/index.browser.mjs",
17+
"require": "./dist/index.browser.cjs"
18+
},
19+
"node": {
20+
"import": "./dist/index.node.mjs",
21+
"require": "./dist/index.node.cjs"
22+
},
23+
"react-native": "./dist/index.native.mjs",
24+
"types": "./dist/types/index.d.ts"
25+
},
26+
"browser": {
27+
"./dist/index.node.cjs": "./dist/index.browser.cjs",
28+
"./dist/index.node.mjs": "./dist/index.browser.mjs"
29+
},
30+
"main": "./dist/index.node.cjs",
31+
"module": "./dist/index.node.mjs",
32+
"react-native": "./dist/index.native.mjs",
33+
"types": "./dist/types/index.d.ts",
34+
"type": "commonjs",
35+
"files": [
36+
"./dist/"
37+
],
38+
"sideEffects": false,
39+
"keywords": [
40+
"blockchain",
41+
"solana",
42+
"web3"
43+
],
44+
"scripts": {
45+
"compile:docs": "typedoc",
46+
"compile:js": "tsup --config build-scripts/tsup.config.package.ts",
47+
"compile:typedefs": "tsc -p ./tsconfig.declarations.json",
48+
"dev": "NODE_OPTIONS=\"--localstorage-file=/tmp/node-localstorage-$(head /dev/urandom | tr -dc a-zA-Z0-9 | head -c 8)\" jest -c ../../node_modules/@solana/test-config/jest-dev.config.ts --rootDir . --watch",
49+
"prepublishOnly": "pnpm pkg delete devDependencies",
50+
"publish-impl": "npm view $npm_package_name@$npm_package_version > /dev/null 2>&1 || (pnpm publish --tag ${PUBLISH_TAG:-canary} --access public --no-git-checks && (([ -n \"${GITHUB_OUTPUT:-}\" ] && echo 'published=true' >> \"$GITHUB_OUTPUT\") || true) && (([ \"$PUBLISH_TAG\" != \"canary\" ] && ../build-scripts/maybe-tag-latest.ts $npm_package_name@$npm_package_version) || true))",
51+
"publish-packages": "pnpm prepublishOnly && pnpm publish-impl",
52+
"style:fix": "pnpm eslint --fix src && pnpm prettier --log-level warn --ignore-unknown --write ./*",
53+
"test:lint": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-lint.config.ts --rootDir . --silent",
54+
"test:prettier": "TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-prettier.config.ts --rootDir . --silent",
55+
"test:treeshakability:browser": "agadoo dist/index.browser.mjs",
56+
"test:treeshakability:native": "agadoo dist/index.native.mjs",
57+
"test:treeshakability:node": "agadoo dist/index.node.mjs",
58+
"test:typecheck": "tsc --noEmit",
59+
"test:unit:browser": "NODE_OPTIONS=\"--localstorage-file=/tmp/node-localstorage-$(head /dev/urandom | tr -dc a-zA-Z0-9 | head -c 8)\" TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.browser.ts --rootDir . --silent",
60+
"test:unit:node": "NODE_OPTIONS=\"--localstorage-file=/tmp/node-localstorage-$(head /dev/urandom | tr -dc a-zA-Z0-9 | head -c 8)\" TERM_OVERRIDE=\"${TURBO_HASH:+dumb}\" TERM=${TERM_OVERRIDE:-$TERM} jest -c ../../node_modules/@solana/test-config/jest-unit.config.node.ts --rootDir . --silent"
61+
},
62+
"author": "Solana Labs Maintainers <maintainers@solanalabs.com>",
63+
"license": "MIT",
64+
"repository": {
65+
"type": "git",
66+
"url": "https://github.com/anza-xyz/kit"
67+
},
68+
"bugs": {
69+
"url": "https://github.com/anza-xyz/kit/issues"
70+
},
71+
"browserslist": [
72+
"supports bigint and not dead",
73+
"maintained node versions"
74+
],
75+
"dependencies": {
76+
"@solana/addresses": "workspace:*",
77+
"@solana/codecs-core": "workspace:*",
78+
"@solana/codecs-data-structures": "workspace:*",
79+
"@solana/codecs-numbers": "workspace:*",
80+
"@solana/codecs-strings": "workspace:*",
81+
"@solana/errors": "workspace:*",
82+
"@solana/keys": "workspace:*",
83+
"@solana/nominal-types": "workspace:*"
84+
},
85+
"peerDependencies": {
86+
"typescript": ">=5.3.3"
87+
},
88+
"engines": {
89+
"node": ">=20.18.0"
90+
}
91+
}

0 commit comments

Comments
 (0)