From cd3b3dd172bbac0877ee9ce82cfd398ee4134bb5 Mon Sep 17 00:00:00 2001 From: Nick Zhelezkov Date: Wed, 23 Mar 2022 00:22:02 +0400 Subject: [PATCH 01/10] update readme to prevent some issues for newbies --- README.md | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index f4fdfe7..e0323ca 100644 --- a/README.md +++ b/README.md @@ -83,7 +83,7 @@ Note: If you just need a local running instance of the Dialect program, it is ea Dialect is built with Solana and Anchor. Install both dependencies first following their respective documentation - [Solana](https://docs.solana.com/cli/install-solana-cli-tools) -- [Anchor](https://book.anchor-lang.com) +- [Anchor](https://book.anchor-lang.com) v0.18.0 Be sure you are targeting a Solana `localnet` instance: @@ -103,7 +103,12 @@ Build the Dialect Solana program: anchor build ``` -If you haven't deployed before, the output of `anchor build` will give you a program keypair, stored in `target/deploy/dialect-keypair.json`. Add this keypair in the following additional places: +If you haven't deployed before, the output of `anchor build` will give you a program keypair, stored in `target/deploy/dialect-keypair.json`.\ +Note: if it doesn't print a keypair, fetch it with the following command: +`solana address -k target/deploy/dialect-keypair.json` + + +Add this keypair in the following additional places: 1. In the `dialect = ""` in `Anchor.toml` 2. In the `declare_id!("")` in `programs/dialect/lib.rs` From 460b5270fd0a3da822d8009991fce05a99c52a8b Mon Sep 17 00:00:00 2001 From: GK <73589321+gklawcode@users.noreply.github.com> Date: Tue, 29 Mar 2022 07:41:27 -1000 Subject: [PATCH 02/10] updating program-id location for build/deploy --- README.md | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f4fdfe7..b4bd6a2 100644 --- a/README.md +++ b/README.md @@ -103,7 +103,15 @@ Build the Dialect Solana program: anchor build ``` -If you haven't deployed before, the output of `anchor build` will give you a program keypair, stored in `target/deploy/dialect-keypair.json`. Add this keypair in the following additional places: +If you haven't deployed this program to localnet before, `anchor build` produces a program-id stored in `target/idl/dialect.json`. The program-id is the address field of the "metadata" element (usually at bottom of file, note your address may differ locally): + +``` + "metadata": { + "address": "2YFyZAg8rBtuvzFFiGvXwPHFAQJ2FXZoS7bYCKticpjk" + } +``` + +Add this program-id in the following additional places before proceeding: 1. In the `dialect = ""` in `Anchor.toml` 2. In the `declare_id!("")` in `programs/dialect/lib.rs` From 2c555111499c220c277ecd4c276efde5a77370cd Mon Sep 17 00:00:00 2001 From: GK <73589321+gklawcode@users.noreply.github.com> Date: Tue, 29 Mar 2022 08:16:09 -1000 Subject: [PATCH 03/10] Adding a toc for readme ease-of-use --- README.md | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index b4bd6a2..7c0ed27 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # Protocol & web3 +## Summary + Dialect is a smart messaging protocol for dapp notifications and wallet-to-wallet messaging on the Solana Blockchain. Dialect works by decorating on-chain resources, or sets of resources, with publish-subscribe (pub-sub) messaging capabilities. This is accomplished by creating a PDA whose seeds are the (lexically sorted) resources' public keys. Each pub-sub messaging PDA is called a _dialect_. @@ -10,6 +12,15 @@ This repository contains both the Dialect rust programs (protocol), in Anchor, a Currently, the dialect account rent cost is `~0.059 SOL`. +## Table of Contents +1. Installation +2. Usage +3. Local Development +4. Docker +5. Anchor Tests +6. Examples +7. Message Encryption + ## Installation **npm:** @@ -76,7 +87,7 @@ Run the example above ts-node examples/hello-world.ts ``` -## Local development +## Local Development Note: If you just need a local running instance of the Dialect program, it is easiest to simply run Dialect in a docker container. See the [Docker](###docker) section below. @@ -141,7 +152,7 @@ docker build -f docker/Dockerfile . -t dialect/protocol:latest docker run -i --rm -p 8899:8899 -p 8900:8900 -p 9900:9900 --name protocol dialect/protocol:latest ``` -## Tests +## Anchor Tests First ensure you have ts-mocha install globally: @@ -155,7 +166,7 @@ Run the tests with: anchor test ``` -## examples +## Examples Run the example with: @@ -165,7 +176,7 @@ DIALECT_PUBLIC_KEY= ts-node examples/index.ts It is fine to omit the `DIALECT_PUBLIC_KEY` environment variable, the example will generate one on the fly. However, if you're using this example as an integration test with other services, such as the monitoring, you'll need to set it to the public key corresponding to the private key in the notification service. -## Message encryption +## Message Encryption A note about the encryption nonce. From 0d09d341e4b458b9870b1583b997deee3ac23ff5 Mon Sep 17 00:00:00 2001 From: cbosborn Date: Sat, 2 Apr 2022 12:26:10 -0400 Subject: [PATCH 04/10] Odds & ends. --- .github/workflows/formatters.yml | 30 +++++++++++++++--------------- examples/hello-world.ts | 2 +- index.ts | 2 -- package.json | 6 +++--- src/utils/programs.json | 2 +- tsconfig.json | 1 + 6 files changed, 21 insertions(+), 22 deletions(-) delete mode 100644 index.ts diff --git a/.github/workflows/formatters.yml b/.github/workflows/formatters.yml index 98f4c35..529dad6 100644 --- a/.github/workflows/formatters.yml +++ b/.github/workflows/formatters.yml @@ -32,18 +32,18 @@ jobs: with: command: fmt args: --all -- --check - - clippy: - name: Clippy - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - - uses: actions-rs/toolchain@v1 - with: - toolchain: 1.57.0 - override: true - components: clippy - - uses: actions-rs/clippy-check@v1 - with: - token: ${{ secrets.GITHUB_TOKEN }} - args: -- -D warnings + # TODO: Address failing issue + # clippy: + # name: Clippy + # runs-on: ubuntu-latest + # steps: + # - uses: actions/checkout@v2 + # - uses: actions-rs/toolchain@v1 + # with: + # toolchain: 1.57.0 + # override: true + # components: clippy + # - uses: actions-rs/clippy-check@v1 + # with: + # token: ${{ secrets.GITHUB_TOKEN }} + # args: -- -D warnings diff --git a/examples/hello-world.ts b/examples/hello-world.ts index 9bb1143..bee43c8 100644 --- a/examples/hello-world.ts +++ b/examples/hello-world.ts @@ -10,7 +10,7 @@ import { programs, sendMessage, Wallet_, -} from '..'; +} from '../src'; const NETWORK_NAME = 'localnet'; const local = new web3.Connection( diff --git a/index.ts b/index.ts deleted file mode 100644 index 294b265..0000000 --- a/index.ts +++ /dev/null @@ -1,2 +0,0 @@ -export * from './src/api'; -export * from './src/utils'; diff --git a/package.json b/package.json index 01fdcfc..99fb2ad 100644 --- a/package.json +++ b/package.json @@ -1,14 +1,14 @@ { "name": "@dialectlabs/web3", "description": "A smart messaging protocol for dapp notifications and wallet-to-wallet messaging on the Solana Blockchain.", - "version": "0.1.6", + "version": "0.1.12", "module": "./lib/es/index.js", "repository": { "type": "git", "url": "https://github.com/dialectlabs/protocol" }, "main": "./lib/es/index.js", - "types": "./lib/es/types.d.ts", + "types": "./lib/es/index.d.ts", "scripts": { "publish": "npm run build && npm publish && rm -rf lib", "build": "rm -rf lib && tsc", @@ -48,7 +48,7 @@ "typescript": "^4.3.5" }, "engines": { - "node": ">=15.10", + "node": ">=14.18", "npm": ">=8" }, "engineStrict": true, diff --git a/src/utils/programs.json b/src/utils/programs.json index 15bf417..667c5a6 100644 --- a/src/utils/programs.json +++ b/src/utils/programs.json @@ -1,7 +1,7 @@ { "localnet": { "clusterAddress": "http://127.0.0.1:8899", - "programAddress": "CeNUxGUsSeb5RuAGvaMLNx3tEZrpBwQqA7Gs99vMPCAb" + "programAddress": "2YFyZAg8rBtuvzFFiGvXwPHFAQJ2FXZoS7bYCKticpjk" }, "devnet": { "clusterAddress": "https://api.devnet.solana.com", diff --git a/tsconfig.json b/tsconfig.json index f60521c..75b2c01 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -16,6 +16,7 @@ "noEmit": false, "declaration": true }, + "rootDir": "./src", "include": ["next-env.d.ts", "**/*.ts"], "exclude": ["node_modules"], "type": "module" From eec6fc607f644fec77095d706cb153528dc5a071 Mon Sep 17 00:00:00 2001 From: cbosborn Date: Sat, 2 Apr 2022 12:26:56 -0400 Subject: [PATCH 05/10] Add src/index.ts --- src/index.ts | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 src/index.ts diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..ea066c6 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,2 @@ +export * from './api'; +export * from './utils'; From 33d0337e49828c238461c906b886da753e6b64c9 Mon Sep 17 00:00:00 2001 From: cbosborn Date: Sat, 2 Apr 2022 12:36:09 -0400 Subject: [PATCH 06/10] Update package-lock.json --- package-lock.json | 262 ++++++++++++++++++++++++++++++++++------------ 1 file changed, 196 insertions(+), 66 deletions(-) diff --git a/package-lock.json b/package-lock.json index 97f1221..a46fd15 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,15 +1,15 @@ { "name": "@dialectlabs/web3", - "version": "0.1.6", + "version": "0.1.12", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@dialectlabs/web3", - "version": "0.1.6", + "version": "0.1.12", "license": "Apache-2.0", "dependencies": { - "@project-serum/anchor": "0.18.2", + "@project-serum/anchor": "0.23.0", "@solana/spl-token": "^0.1.8", "@solana/web3.js": "^1.22.0", "bytebuffer": "^5.0.1", @@ -36,7 +36,7 @@ "typescript": "^4.3.5" }, "engines": { - "node": ">=15.10", + "node": ">=14.18", "npm": ">=8" } }, @@ -181,6 +181,59 @@ "node": "^10.12.0 || >=12.0.0" } }, + "node_modules/@ethersproject/bytes": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.6.1.tgz", + "integrity": "sha512-NwQt7cKn5+ZE4uDn+X5RAXLp46E1chXoaMmrxAyA0rblpxz8t58lVkrHXoRIn0lz1joQElQ8410GqhTqMOwc6g==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/logger": "^5.6.0" + } + }, + "node_modules/@ethersproject/logger": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.6.0.tgz", + "integrity": "sha512-BiBWllUROH9w+P21RzoxJKzqoqpkyM1pRnEKG69bulE9TSQD8SAIvTQqIMZmmCO8pUNkgLP1wndX1gKghSpBmg==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ] + }, + "node_modules/@ethersproject/sha2": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.6.0.tgz", + "integrity": "sha512-1tNWCPFLu1n3JM9t4/kytz35DkuF9MxqkGGEHNauEbaARdm2fafnOyw1s0tIQDPKF/7bkP1u3dbrmjpn5CelyA==", + "funding": [ + { + "type": "individual", + "url": "https://gitcoin.co/grants/13/ethersjs-complete-simple-and-tiny-2" + }, + { + "type": "individual", + "url": "https://www.buymeacoffee.com/ricmoo" + } + ], + "dependencies": { + "@ethersproject/bytes": "^5.6.0", + "@ethersproject/logger": "^5.6.0", + "hash.js": "1.1.7" + } + }, "node_modules/@humanwhocodes/config-array": { "version": "0.5.0", "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", @@ -232,17 +285,18 @@ } }, "node_modules/@project-serum/anchor": { - "version": "0.18.2", - "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.18.2.tgz", - "integrity": "sha512-uyjiN/3Ipp+4hrZRm/hG18HzGLZyvP790LXrCsGO3IWxSl28YRhiGEpKnZycfMW94R7nxdUoE3wY67V+ZHSQBQ==", + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.23.0.tgz", + "integrity": "sha512-LV2/ifZOJVFTZ4GbEloXln3iVfCvO1YM8i7BBCrUm4tehP7irMx4nr4/IabHWOzrQcQElsxSP/lb1tBp+2ff8A==", "dependencies": { - "@project-serum/borsh": "^0.2.2", - "@solana/web3.js": "^1.17.0", + "@project-serum/borsh": "^0.2.5", + "@solana/web3.js": "^1.36.0", "base64-js": "^1.5.1", "bn.js": "^5.1.2", "bs58": "^4.0.1", - "buffer-layout": "^1.2.0", + "buffer-layout": "^1.2.2", "camelcase": "^5.3.1", + "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "find": "^0.3.0", @@ -256,8 +310,9 @@ } }, "node_modules/@project-serum/borsh": { - "version": "0.2.2", - "integrity": "sha512-Ms+aWmGVW6bWd3b0+MWwoaYig2QD0F90h0uhr7AzY3dpCb5e2S6RsRW02vFTfa085pY2VLB7nTZNbFECQ1liTg==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@project-serum/borsh/-/borsh-0.2.5.tgz", + "integrity": "sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==", "dependencies": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" @@ -270,8 +325,9 @@ } }, "node_modules/@solana/buffer-layout": { - "version": "3.0.0", - "integrity": "sha512-MVdgAKKL39tEs0l8je0hKaXLQFb7Rdfb0Xg2LjFZd8Lfdazkg6xiS98uAZrEKvaoF3i4M95ei9RydkGIDMeo3w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.0.tgz", + "integrity": "sha512-lR0EMP2HC3+Mxwd4YcnZb0smnaDw7Bl2IQWZiTevRH5ZZBZn6VRWn3/92E3qdU4SSImJkA6IDHawOHAnx/qUvQ==", "dependencies": { "buffer": "~6.0.3" }, @@ -281,6 +337,7 @@ }, "node_modules/@solana/buffer-layout/node_modules/buffer": { "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", "funding": [ { @@ -341,17 +398,18 @@ } }, "node_modules/@solana/web3.js": { - "version": "1.26.0", - "integrity": "sha512-XXrE8srfA3ilMvpOs6WdGOIuY8epc0sF9Tl4M6BHNnfS5pbSQ+jJJdEhwi6AzURgXWWu//242Tq347iLSQhRqQ==", + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.37.0.tgz", + "integrity": "sha512-O2iCcgkGdi2FXwVLztPIZHcBuZXdhbVLavMsG+RdEyFGzFD0tQN1rOJ+Xb5eaexjqtgcqRN+Fyg3wAhLcHJbiA==", "dependencies": { "@babel/runtime": "^7.12.5", - "@solana/buffer-layout": "^3.0.0", + "@ethersproject/sha2": "^5.5.0", + "@solana/buffer-layout": "^4.0.0", "bn.js": "^5.0.0", - "borsh": "^0.4.0", + "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.1", "cross-fetch": "^3.1.4", - "crypto-hash": "^1.2.2", "jayson": "^3.4.4", "js-sha3": "^0.8.0", "rpc-websockets": "^7.4.2", @@ -383,13 +441,6 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, - "node_modules/@types/bn.js": { - "version": "4.11.6", - "integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", - "dependencies": { - "@types/node": "*" - } - }, "node_modules/@types/bs58": { "version": "4.0.1", "integrity": "sha512-yfAgiWgVLjFCmRv8zAcOIHywYATEwiTVccTLnRp6UxTNavT55M9d/uhK3T03St/+8/z/wW+CRjGKUNmEqoHHCA==", @@ -806,11 +857,11 @@ "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" }, "node_modules/borsh": { - "version": "0.4.0", - "integrity": "sha512-aX6qtLya3K0AkT66CmYWCCDr77qsE9arV05OmdFpmat9qu8Pg9J5tBUPDztAW5fNh/d/MyVG/OYziP52Ndzx1g==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", + "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", "dependencies": { - "@types/bn.js": "^4.11.5", - "bn.js": "^5.0.0", + "bn.js": "^5.2.0", "bs58": "^4.0.0", "text-encoding-utf-8": "^1.0.2" } @@ -1043,10 +1094,11 @@ "dev": true }, "node_modules/cross-fetch": { - "version": "3.1.4", - "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", + "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", "dependencies": { - "node-fetch": "2.6.1" + "node-fetch": "2.6.7" } }, "node_modules/cross-spawn": { @@ -2243,10 +2295,22 @@ "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, "node_modules/node-fetch": { - "version": "2.6.1", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==", + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "dependencies": { + "whatwg-url": "^5.0.0" + }, "engines": { "node": "4.x || >=6.0.0" + }, + "peerDependencies": { + "encoding": "^0.1.0" + }, + "peerDependenciesMeta": { + "encoding": { + "optional": true + } } }, "node_modules/node-gyp-build": { @@ -2766,6 +2830,7 @@ }, "node_modules/text-encoding-utf-8": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" }, "node_modules/text-table": { @@ -2796,6 +2861,11 @@ "version": "3.0.0", "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, + "node_modules/tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + }, "node_modules/traverse-chain": { "version": "0.1.0", "integrity": "sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE=" @@ -3052,6 +3122,20 @@ "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, + "node_modules/webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + }, + "node_modules/whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "dependencies": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "node_modules/which": { "version": "2.0.2", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", @@ -3360,6 +3444,29 @@ "strip-json-comments": "^3.1.1" } }, + "@ethersproject/bytes": { + "version": "5.6.1", + "resolved": "https://registry.npmjs.org/@ethersproject/bytes/-/bytes-5.6.1.tgz", + "integrity": "sha512-NwQt7cKn5+ZE4uDn+X5RAXLp46E1chXoaMmrxAyA0rblpxz8t58lVkrHXoRIn0lz1joQElQ8410GqhTqMOwc6g==", + "requires": { + "@ethersproject/logger": "^5.6.0" + } + }, + "@ethersproject/logger": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@ethersproject/logger/-/logger-5.6.0.tgz", + "integrity": "sha512-BiBWllUROH9w+P21RzoxJKzqoqpkyM1pRnEKG69bulE9TSQD8SAIvTQqIMZmmCO8pUNkgLP1wndX1gKghSpBmg==" + }, + "@ethersproject/sha2": { + "version": "5.6.0", + "resolved": "https://registry.npmjs.org/@ethersproject/sha2/-/sha2-5.6.0.tgz", + "integrity": "sha512-1tNWCPFLu1n3JM9t4/kytz35DkuF9MxqkGGEHNauEbaARdm2fafnOyw1s0tIQDPKF/7bkP1u3dbrmjpn5CelyA==", + "requires": { + "@ethersproject/bytes": "^5.6.0", + "@ethersproject/logger": "^5.6.0", + "hash.js": "1.1.7" + } + }, "@humanwhocodes/config-array": { "version": "0.5.0", "integrity": "sha512-FagtKFz74XrTl7y6HCzQpwDfXP0yhxe9lHLD1UZxjvZIcbyRz8zTFF/yYNfSfzU414eDwZ1SrO0Qvtyf+wFMQg==", @@ -3399,17 +3506,18 @@ } }, "@project-serum/anchor": { - "version": "0.18.2", - "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.18.2.tgz", - "integrity": "sha512-uyjiN/3Ipp+4hrZRm/hG18HzGLZyvP790LXrCsGO3IWxSl28YRhiGEpKnZycfMW94R7nxdUoE3wY67V+ZHSQBQ==", + "version": "0.23.0", + "resolved": "https://registry.npmjs.org/@project-serum/anchor/-/anchor-0.23.0.tgz", + "integrity": "sha512-LV2/ifZOJVFTZ4GbEloXln3iVfCvO1YM8i7BBCrUm4tehP7irMx4nr4/IabHWOzrQcQElsxSP/lb1tBp+2ff8A==", "requires": { - "@project-serum/borsh": "^0.2.2", - "@solana/web3.js": "^1.17.0", + "@project-serum/borsh": "^0.2.5", + "@solana/web3.js": "^1.36.0", "base64-js": "^1.5.1", "bn.js": "^5.1.2", "bs58": "^4.0.1", - "buffer-layout": "^1.2.0", + "buffer-layout": "^1.2.2", "camelcase": "^5.3.1", + "cross-fetch": "^3.1.5", "crypto-hash": "^1.3.0", "eventemitter3": "^4.0.7", "find": "^0.3.0", @@ -3420,22 +3528,25 @@ } }, "@project-serum/borsh": { - "version": "0.2.2", - "integrity": "sha512-Ms+aWmGVW6bWd3b0+MWwoaYig2QD0F90h0uhr7AzY3dpCb5e2S6RsRW02vFTfa085pY2VLB7nTZNbFECQ1liTg==", + "version": "0.2.5", + "resolved": "https://registry.npmjs.org/@project-serum/borsh/-/borsh-0.2.5.tgz", + "integrity": "sha512-UmeUkUoKdQ7rhx6Leve1SssMR/Ghv8qrEiyywyxSWg7ooV7StdpPBhciiy5eB3T0qU1BXvdRNC8TdrkxK7WC5Q==", "requires": { "bn.js": "^5.1.2", "buffer-layout": "^1.2.0" } }, "@solana/buffer-layout": { - "version": "3.0.0", - "integrity": "sha512-MVdgAKKL39tEs0l8je0hKaXLQFb7Rdfb0Xg2LjFZd8Lfdazkg6xiS98uAZrEKvaoF3i4M95ei9RydkGIDMeo3w==", + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.0.tgz", + "integrity": "sha512-lR0EMP2HC3+Mxwd4YcnZb0smnaDw7Bl2IQWZiTevRH5ZZBZn6VRWn3/92E3qdU4SSImJkA6IDHawOHAnx/qUvQ==", "requires": { "buffer": "~6.0.3" }, "dependencies": { "buffer": { "version": "6.0.3", + "resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz", "integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==", "requires": { "base64-js": "^1.3.1", @@ -3469,17 +3580,18 @@ } }, "@solana/web3.js": { - "version": "1.26.0", - "integrity": "sha512-XXrE8srfA3ilMvpOs6WdGOIuY8epc0sF9Tl4M6BHNnfS5pbSQ+jJJdEhwi6AzURgXWWu//242Tq347iLSQhRqQ==", + "version": "1.37.0", + "resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.37.0.tgz", + "integrity": "sha512-O2iCcgkGdi2FXwVLztPIZHcBuZXdhbVLavMsG+RdEyFGzFD0tQN1rOJ+Xb5eaexjqtgcqRN+Fyg3wAhLcHJbiA==", "requires": { "@babel/runtime": "^7.12.5", - "@solana/buffer-layout": "^3.0.0", + "@ethersproject/sha2": "^5.5.0", + "@solana/buffer-layout": "^4.0.0", "bn.js": "^5.0.0", - "borsh": "^0.4.0", + "borsh": "^0.7.0", "bs58": "^4.0.1", "buffer": "6.0.1", "cross-fetch": "^3.1.4", - "crypto-hash": "^1.2.2", "jayson": "^3.4.4", "js-sha3": "^0.8.0", "rpc-websockets": "^7.4.2", @@ -3508,13 +3620,6 @@ "integrity": "sha512-eZxlbI8GZscaGS7kkc/trHTT5xgrjH3/1n2JDwusC9iahPKWMRvRjJSAN5mCXviuTGQ/lHnhvv8Q1YTpnfz9gA==", "dev": true }, - "@types/bn.js": { - "version": "4.11.6", - "integrity": "sha512-pqr857jrp2kPuO9uRjZ3PwnJTjoQy+fcdxvBTvHm6dkmEL9q+hDD/2j/0ELOBPtPnS8LjCX0gI9nbl8lVkadpg==", - "requires": { - "@types/node": "*" - } - }, "@types/bs58": { "version": "4.0.1", "integrity": "sha512-yfAgiWgVLjFCmRv8zAcOIHywYATEwiTVccTLnRp6UxTNavT55M9d/uhK3T03St/+8/z/wW+CRjGKUNmEqoHHCA==", @@ -3801,11 +3906,11 @@ "integrity": "sha512-D7iWRBvnZE8ecXiLj/9wbxH7Tk79fAh8IHaTNq1RWRixsS02W+5qS+iE9yq6RYl0asXx5tw0bLhmT5pIfbSquw==" }, "borsh": { - "version": "0.4.0", - "integrity": "sha512-aX6qtLya3K0AkT66CmYWCCDr77qsE9arV05OmdFpmat9qu8Pg9J5tBUPDztAW5fNh/d/MyVG/OYziP52Ndzx1g==", + "version": "0.7.0", + "resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz", + "integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==", "requires": { - "@types/bn.js": "^4.11.5", - "bn.js": "^5.0.0", + "bn.js": "^5.2.0", "bs58": "^4.0.0", "text-encoding-utf-8": "^1.0.2" } @@ -3984,10 +4089,11 @@ "dev": true }, "cross-fetch": { - "version": "3.1.4", - "integrity": "sha512-1eAtFWdIubi6T4XPy6ei9iUFoKpUkIF971QLN8lIvvvwueI65+Nw5haMNKUwfJxabqlIIDODJKGrQ66gxC0PbQ==", + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/cross-fetch/-/cross-fetch-3.1.5.tgz", + "integrity": "sha512-lvb1SBsI0Z7GDwmuid+mU3kWVBwTVUbe7S0H52yaaAdQOXq2YktTCZdlAcNKFzE6QtRz0snpw9bNiPeOIkkQvw==", "requires": { - "node-fetch": "2.6.1" + "node-fetch": "2.6.7" } }, "cross-spawn": { @@ -4866,8 +4972,12 @@ "integrity": "sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==" }, "node-fetch": { - "version": "2.6.1", - "integrity": "sha512-V4aYg89jEoVRxRb2fJdAg8FHvI7cEyYdVAh94HH0UIK8oJxUfkjlDQN9RbMx+bEjP7+ggMiFRprSti032Oipxw==" + "version": "2.6.7", + "resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.7.tgz", + "integrity": "sha512-ZjMPFEfVx5j+y2yF35Kzx5sF7kDzxuDj6ziH4FFbOp87zKDZNx8yExJIb05OGF4Nlt9IHFIMBkRl41VdvcNdbQ==", + "requires": { + "whatwg-url": "^5.0.0" + } }, "node-gyp-build": { "version": "4.2.3", @@ -5212,6 +5322,7 @@ }, "text-encoding-utf-8": { "version": "1.0.2", + "resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz", "integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==" }, "text-table": { @@ -5239,6 +5350,11 @@ "version": "3.0.0", "integrity": "sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==" }, + "tr46": { + "version": "0.0.3", + "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz", + "integrity": "sha1-gYT9NH2snNwYWZLzpmIuFLnZq2o=" + }, "traverse-chain": { "version": "0.1.0", "integrity": "sha1-YdvC1Ttp/2CRoSoWj9fUMxB+QPE=" @@ -5411,6 +5527,20 @@ "integrity": "sha512-l8lCEmLcLYZh4nbunNZvQCJc5pv7+RCwa8q/LdUx8u7lsWvPDKmpodJAJNwkAhJC//dFY48KuIEmjtd4RViDrA==", "dev": true }, + "webidl-conversions": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz", + "integrity": "sha1-JFNCdeKnvGvnvIZhHMFq4KVlSHE=" + }, + "whatwg-url": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz", + "integrity": "sha1-lmRU6HZUYuN2RNNib2dCzotwll0=", + "requires": { + "tr46": "~0.0.3", + "webidl-conversions": "^3.0.0" + } + }, "which": { "version": "2.0.2", "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", From 149e1f6a15baf607b7005f78c8b56ce4779d6990 Mon Sep 17 00:00:00 2001 From: cbosborn Date: Sat, 2 Apr 2022 12:38:08 -0400 Subject: [PATCH 07/10] Add src/ prefix in tsconfig.json --- tsconfig.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tsconfig.json b/tsconfig.json index 75b2c01..372a048 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -17,7 +17,7 @@ "declaration": true }, "rootDir": "./src", - "include": ["next-env.d.ts", "**/*.ts"], + "include": ["next-env.d.ts", "src/**/*.ts"], "exclude": ["node_modules"], "type": "module" } From bae1ba96a5bbf7a36401cc5e623a5aeacaa7794a Mon Sep 17 00:00:00 2001 From: cbosborn Date: Sat, 2 Apr 2022 12:39:34 -0400 Subject: [PATCH 08/10] rm root index.ts from prettier args. --- .github/workflows/formatters.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/formatters.yml b/.github/workflows/formatters.yml index 529dad6..d04bd83 100644 --- a/.github/workflows/formatters.yml +++ b/.github/workflows/formatters.yml @@ -16,7 +16,7 @@ jobs: - uses: actionsx/prettier@v2 with: # prettier CLI arguments. - args: --check index.ts examples/ src/ tests/ + args: --check examples/ src/ tests/ fmt: name: Rustfmt From 27ad8e318dc6b837a6f9aa417910bc2899486080 Mon Sep 17 00:00:00 2001 From: cbosborn Date: Sat, 2 Apr 2022 12:52:37 -0400 Subject: [PATCH 09/10] CHANGELOG. --- CHANGELOG.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index b4ca4f8..5127618 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,11 @@ # CHANGELOG +## [0.1.12] - 2022-04-02 + +* Upgrade anchor to 0.23.0. +* Move index.ts to src/index.ts. +* Enforce that dialect owner must be a member with admin privileges. + ## [0.1.6] - 2022-02-28 * Update program ids for mainnet. From 0d4a56e9533bdedbfc42011745316aebf3c95834 Mon Sep 17 00:00:00 2001 From: cbosborn Date: Sun, 3 Apr 2022 22:34:53 -0400 Subject: [PATCH 10/10] Minor tweaks --- README.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index ab1f153..ea58e37 100644 --- a/README.md +++ b/README.md @@ -180,7 +180,7 @@ docker build -f docker/Dockerfile . -t dialect/protocol:latest docker run -i --rm -p 8899:8899 -p 8900:8900 -p 9900:9900 --name protocol dialect/protocol:latest ``` -## Anchor Tests +## Tests First ensure you have ts-mocha install globally: @@ -199,10 +199,10 @@ anchor test Run the example with: ```bash -DIALECT_PUBLIC_KEY= ts-node examples/index.ts +DIALECT_PUBLIC_KEY= ts-node examples/hello-world.ts ``` -It is fine to omit the `DIALECT_PUBLIC_KEY` environment variable, the example will generate one on the fly. However, if you're using this example as an integration test with other services, such as the monitoring, you'll need to set it to the public key corresponding to the private key in the notification service. +It is fine to omit the `DIALECT_PUBLIC_KEY` environment variable, the example will generate one on the fly. However, if you're using this example as an integration test with other services, such as the monitoring service, you'll need to set it to the public key corresponding to the private key in the monitoring service. ## Message Encryption