diff --git a/.github/actions/build-anchor/action.yaml b/.github/actions/build-anchor/action.yaml index e806fcd07..c35f2f235 100644 --- a/.github/actions/build-anchor/action.yaml +++ b/.github/actions/build-anchor/action.yaml @@ -15,7 +15,6 @@ inputs: runs: using: "composite" steps: - - uses: actions/checkout@v2 - uses: ./.github/actions/setup/ - uses: ./.github/actions/setup-anchor/ with: diff --git a/.github/actions/setup-anchor/action.yaml b/.github/actions/setup-anchor/action.yaml index ce2c3f179..df94639a3 100644 --- a/.github/actions/setup-anchor/action.yaml +++ b/.github/actions/setup-anchor/action.yaml @@ -23,6 +23,6 @@ runs: path: | ~/.cargo/bin/toml key: toml-cli-${{ runner.os }}-v0002 - - run: cargo install toml-cli + - run: (cargo install toml-cli || true) if: steps.cache-toml-cli.outputs.cache-hit != 'true' shell: bash diff --git a/.github/workflows/develop-release-program.yaml b/.github/workflows/develop-release-program.yaml index 66079038e..b851675ae 100644 --- a/.github/workflows/develop-release-program.yaml +++ b/.github/workflows/develop-release-program.yaml @@ -54,7 +54,7 @@ jobs: ~/.cargo/bin/toml key: toml-cli-${{ runner.os }}-v0002 - - run: cargo install toml-cli + - run: (cargo install toml-cli || true) if: steps.cache-toml-cli.outputs.cache-hit != 'true' shell: bash diff --git a/.github/workflows/npm-canary-release.yaml b/.github/workflows/npm-canary-release.yaml index d196320b1..3aeea5a21 100644 --- a/.github/workflows/npm-canary-release.yaml +++ b/.github/workflows/npm-canary-release.yaml @@ -14,7 +14,7 @@ jobs: runs-on: ubuntu-latest if: | github.event_name == 'issue_comment' && - (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'CONTRIBUTOR') && + (github.event.comment.author_association == 'COLLABORATOR' || github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' || github.event.comment.author_association == 'CONTRIBUTOR') && startsWith(github.event.comment.body, '/canary-release') steps: - name: get pr information @@ -48,11 +48,23 @@ jobs: registry-url: 'https://registry.npmjs.org' - name: install run: yarn + - name: re create .npmrc file + run: | + cat << EOF > "$HOME/.npmrc" + //registry.npmjs.org/:_authToken=$NPM_TOKEN + EOF + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} + - uses: ./.github/actions/build-anchor/ + with: + testing: false + devnet: false + - uses: ./.github/actions/setup-ts/ - name: Publish run: yarn run release:canary env: GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} - NODE_AUTH_TOKEN: ${{ secrets.TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} - uses: actions/github-script@v4 with: github-token: ${{secrets.GITHUB_TOKEN}} diff --git a/.github/workflows/npm-publish.yaml b/.github/workflows/npm-publish.yaml index b68b7cacc..d27c8e9be 100644 --- a/.github/workflows/npm-publish.yaml +++ b/.github/workflows/npm-publish.yaml @@ -15,6 +15,13 @@ jobs: - uses: ./.github/actions/setup-anchor/ with: node-version: ${{ env.NODE_VERSION }} + - name: re create .npmrc file + run: | + cat << EOF > "$HOME/.npmrc" + //registry.npmjs.org/:_authToken=$NPM_TOKEN + EOF + env: + NPM_TOKEN: ${{ secrets.NPM_TOKEN }} - uses: ./.github/actions/build-anchor/ with: testing: false @@ -22,3 +29,6 @@ jobs: - uses: ./.github/actions/setup-ts/ - name: Lerna Publish run: yarn release + env: + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/release-program.yaml b/.github/workflows/release-program.yaml index 8b95d4dc5..9133321c1 100644 --- a/.github/workflows/release-program.yaml +++ b/.github/workflows/release-program.yaml @@ -20,7 +20,7 @@ jobs: path: | ~/.cargo/bin/toml key: toml-cli-${{ runner.os }}-v0002 - - run: cargo install toml-cli + - run: (cargo install toml-cli || true) if: steps.cache-toml-cli.outputs.cache-hit != 'true' shell: bash diff --git a/CHANGELOG.md b/CHANGELOG.md index bfe9a48be..ea0cb45f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -3,6 +3,45 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +### Breaking + + * `distributor-oracle` - `bulkFormTransactions` now takes batch functions for asset and proof fetching, instead of individual fetch functions. If you were passing custom functions, this code will need to change. + +### Features + +* **#373:** replace clockwork ([#388](https://github.com/helium/helium-program-library/issues/388)) ([55033c7](https://github.com/helium/helium-program-library/commit/55033c718df08f41eb2f77d726d59d916ebbd677)), closes [#373](https://github.com/helium/helium-program-library/issues/373) +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-library/issues/380)) ([a691257](https://github.com/helium/helium-program-library/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-library/issues/376) [#376](https://github.com/helium/helium-program-library/issues/376) +* **#379:** Automate npm publish and fix devnet conflicting sqds txns ([#386](https://github.com/helium/helium-program-library/issues/386)) ([a4a3780](https://github.com/helium/helium-program-library/commit/a4a37806fefe82ca9a38f04c311f600ad1f7c36c)) + + +### Reverts + +* Revert "Add back mobile genesis fix for devnet" ([93e9a2c](https://github.com/helium/helium-program-library/commit/93e9a2c370ba77a49b02efc2590ddf3039465ed6)) + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + + +### Features + +* **#373:** replace clockwork ([#388](https://github.com/helium/helium-program-library/issues/388)) ([55033c7](https://github.com/helium/helium-program-library/commit/55033c718df08f41eb2f77d726d59d916ebbd677)), closes [#373](https://github.com/helium/helium-program-library/issues/373) +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-library/issues/380)) ([a691257](https://github.com/helium/helium-program-library/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-library/issues/376) [#376](https://github.com/helium/helium-program-library/issues/376) +* **#379:** Automate npm publish and fix devnet conflicting sqds txns ([#386](https://github.com/helium/helium-program-library/issues/386)) ([a4a3780](https://github.com/helium/helium-program-library/commit/a4a37806fefe82ca9a38f04c311f600ad1f7c36c)) + + +### Reverts + +* Revert "Add back mobile genesis fix for devnet" ([93e9a2c](https://github.com/helium/helium-program-library/commit/93e9a2c370ba77a49b02efc2590ddf3039465ed6)) + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package helium-program-library diff --git a/Cargo.lock b/Cargo.lock index 4c472c519..7bf8baed4 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1779,7 +1779,6 @@ dependencies = [ "data-credits", "default-env", "helium-sub-daos", - "lazy-transactions", "mpl-token-metadata", "shared-utils", "solana-security-txt", diff --git a/Cargo.toml b/Cargo.toml index 47316cee1..472262921 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,3 +24,7 @@ account-compression-cpi = { rev = "9707a03eb7be0ccf4d96a18b662ffcd376365640", gi bubblegum-cpi = { rev = "9707a03eb7be0ccf4d96a18b662ffcd376365640", git = "https://github.com/helium/account-compression-anchor-gen.git", features = ["cpi"]} solana-security-txt = "1.1.1" default-env = "0.1.1" +shared-utils = { path = "./utils/shared-utils" } +circuit-breaker = { path = "./programs/circuit-breaker", features = ["cpi"] } +helium-sub-daos = { path = "./programs/helium-sub-daos", features = ["cpi"] } +helium-entity-manager = { path = "./programs/helium-entity-manager", features = ["cpi"] } \ No newline at end of file diff --git a/lerna.json b/lerna.json index 8fa2859b5..abb553f97 100644 --- a/lerna.json +++ b/lerna.json @@ -1,6 +1,8 @@ { "npmClient": "yarn", - "packages": ["packages/*"], + "packages": [ + "packages/*" + ], "useWorkspaces": true, - "version": "0.2.21" + "version": "0.3.0" } diff --git a/packages/account-fetch-cache-hooks/CHANGELOG.md b/packages/account-fetch-cache-hooks/CHANGELOG.md index f3a950602..8d6306de2 100644 --- a/packages/account-fetch-cache-hooks/CHANGELOG.md +++ b/packages/account-fetch-cache-hooks/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/account-fetch-cache-hooks + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/account-fetch-cache-hooks + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/account-fetch-cache-hooks diff --git a/packages/account-fetch-cache-hooks/package.json b/packages/account-fetch-cache-hooks/package.json index cd440f814..8a188e310 100644 --- a/packages/account-fetch-cache-hooks/package.json +++ b/packages/account-fetch-cache-hooks/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "React hooks and context for account-fetch-cache", "repository": { "type": "git", @@ -32,7 +32,7 @@ "prebuild": "npm run clean && npm run package" }, "dependencies": { - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@solana/web3.js": "^1.78.4", "react-async-hook": "^4.0.0" }, diff --git a/packages/account-fetch-cache/CHANGELOG.md b/packages/account-fetch-cache/CHANGELOG.md index c3db8ea34..660e87910 100644 --- a/packages/account-fetch-cache/CHANGELOG.md +++ b/packages/account-fetch-cache/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/account-fetch-cache + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/account-fetch-cache + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/account-fetch-cache diff --git a/packages/account-fetch-cache/package.json b/packages/account-fetch-cache/package.json index 02c3073bd..e96d263ef 100644 --- a/packages/account-fetch-cache/package.json +++ b/packages/account-fetch-cache/package.json @@ -1,6 +1,6 @@ { "name": "@helium/account-fetch-cache", - "version": "0.2.21", + "version": "0.3.0", "description": "Solana account fetch cache to eliminate reduntant fetching, and batch fetches", "publishConfig": { "access": "public", diff --git a/packages/account-fetch-cache/src/accountFetchCache.ts b/packages/account-fetch-cache/src/accountFetchCache.ts index 8eca1d99b..5b7323585 100644 --- a/packages/account-fetch-cache/src/accountFetchCache.ts +++ b/packages/account-fetch-cache/src/accountFetchCache.ts @@ -5,9 +5,10 @@ import { PublicKey, SendOptions, Transaction, - TransactionInstruction + TransactionInstruction, } from "@solana/web3.js"; import { EventEmitter } from "./eventEmitter"; +import { getMultipleAccounts } from "./getMultipleAccounts"; export const DEFAULT_CHUNK_SIZE = 99; export const DEFAULT_DELAY = 50; @@ -39,6 +40,25 @@ function getWriteableAccounts( let id = 0; +let singletons: Record = {}; +export function getSingleton(conn: Connection): AccountFetchCache { + const commitment = conn.commitment || "confirmed"; + const endp = conn.rpcEndpoint; + if (!singletons[endp + commitment]) { + singletons[endp + commitment] = new AccountFetchCache({ + connection: conn, + commitment, + }); + } + return singletons[endp + commitment]!; +} + +function setSingleton(conn: Connection, cache: AccountFetchCache) { + const commitment = conn.commitment || "confirmed"; + const endp = conn.rpcEndpoint; + singletons[endp + commitment] = cache; +} + export class AccountFetchCache { connection: Connection; chunkSize: number; @@ -64,9 +84,7 @@ export class AccountFetchCache { publicKey: PublicKey, com?: Commitment ) => Promise | null>; - oldSendTransaction: ( - ...args: any[] - ) => Promise; + oldSendTransaction: (...args: any[]) => Promise; oldSendRawTransaction: ( rawTransaction: Buffer | Uint8Array | Array, options?: SendOptions @@ -101,12 +119,14 @@ export class AccountFetchCache { ); this.oldSendTransaction = connection.sendTransaction.bind(connection); - this.oldSendRawTransaction = - connection.sendRawTransaction.bind(connection); + this.oldSendRawTransaction = connection.sendRawTransaction.bind(connection); const self = this; - if (extendConnection) { + // @ts-ignore + if (extendConnection && !connection._accountFetchWrapped) { + // @ts-ignore + connection._accountFetchWrapped = true; this.oldGetAccountinfo = connection.getAccountInfo.bind(connection); connection.getAccountInfo = async ( @@ -152,12 +172,14 @@ export class AccountFetchCache { return self.requeryMissing(instructions); }) .catch(console.error); - } catch(e: any) { + } catch (e: any) { // TODO: handle transaction v2 } return result; }; + + setSingleton(connection, this); } async requeryMissing(instructions: TransactionInstruction[]) { @@ -214,7 +236,11 @@ export class AccountFetchCache { this.currentBatch = new Set(); // Erase current batch from state, so we can fetch multiple at a time try { const keys = Array.from(currentBatch); - const array = await this.connection.getMultipleAccountsInfo(keys.map(b => new PublicKey(b)), this.commitment) + const { array } = await getMultipleAccounts( + this.connection, + keys, + this.commitment + ); keys.forEach((key, index) => { const callback = this.pendingCallbacks.get(key); callback && callback(array[index], null); @@ -230,6 +256,20 @@ export class AccountFetchCache { } } + addToBatchIgnoreResult(id: PublicKey): Promise | undefined { + const idStr = id.toBase58(); + + this.currentBatch.add(idStr); + + this.timeout != null && clearTimeout(this.timeout); + if (this.currentBatch.size > DEFAULT_CHUNK_SIZE) { + return this.fetchBatch().then(() => {}); + } else { + this.timeout = setTimeout(() => this.fetchBatch(), this.delay); + } + return undefined + } + async addToBatch(id: PublicKey): Promise> { const idStr = id.toBase58(); @@ -363,6 +403,52 @@ export class AccountFetchCache { return query; } + async searchMultiple( + pubKeys: PublicKey[], + parser?: AccountParser | undefined, + isStatic: Boolean = false, // optimization, set if the data will never change + forceRequery = false + ): Promise<(ParsedAccountBase | undefined)[]> { + for (const key of pubKeys) { + this.registerParser(key, parser); + const address = key.toBase58(); + if (isStatic) { + this.statics.add(address); + } else if (this.statics.has(address)) { + this.statics.delete(address); // If trying to use this as not static, need to rm it from the statics list. + } + + if (forceRequery || !this.genericCache.has(address)) { + await this.addToBatchIgnoreResult(key); + } + } + + const searched = new Set(pubKeys.map((p) => p.toBase58())); + // Force a batch fetch to resolve all accounts + const { keys, array } = await this.fetchBatch(); + // Cache these results if they aren't going to change + if (isStatic) { + keys.forEach((key, index) => { + if (searched.has(key)) { + const item = array[index]; + if (item) { + this.genericCache.set( + key, + this.getParsed(key, item, parser) || null + ); + } + } + }); + } + + return pubKeys.map( + (key) => + this.genericCache.get(key.toBase58()) as + | ParsedAccountBase + | undefined + ); + } + onAccountChange( key: PublicKey, parser: AccountParser | undefined, @@ -373,7 +459,7 @@ export class AccountFetchCache { const address = key.toBase58(); this.updateCache(address, parsed || null); } catch (e: any) { - console.error("accountFetchCache", "Failed to update account", e) + console.error("accountFetchCache", "Failed to update account", e); } } @@ -391,43 +477,43 @@ export class AccountFetchCache { // Only websocket watch accounts that exist // Don't recreate listeners // xNFT doesn't support onAccountChange, so we have to make a new usable connection. - if (!this.accountChangeListeners.has(address)) { - try { + if (!this.accountChangeListeners.has(address)) { + try { + this.accountChangeListeners.set( + address, + this.connection.onAccountChange( + id, + (account) => this.onAccountChange(id, undefined, account), + this.commitment + ) + ); + } catch (e: any) { + if (e.toString().includes("not implemented")) { + // @ts-ignore + this.usableConnection = + // @ts-ignore + this.usableConnection || + new Connection( + // @ts-ignore + this.connection._rpcEndpoint, + this.commitment + ); this.accountChangeListeners.set( address, - this.connection.onAccountChange( + // @ts-ignore + this.usableConnection.onAccountChange( id, + // @ts-ignore (account) => this.onAccountChange(id, undefined, account), this.commitment ) ); - } catch (e: any) { - if (e.toString().includes("not implemented")) { - // @ts-ignore - this.usableConnection = - // @ts-ignore - this.usableConnection || - new Connection( - // @ts-ignore - this.connection._rpcEndpoint, - this.commitment - ); - this.accountChangeListeners.set( - address, - // @ts-ignore - this.usableConnection.onAccountChange( - id, - // @ts-ignore - (account) => this.onAccountChange(id, undefined, account), - this.commitment - ) - ); - } else { - console.error(e) - throw e - } + } else { + console.error(e); + throw e; } } + } } else if (!exists) { // Poll accounts that don't exist this.missingAccounts.set( diff --git a/packages/account-postgres-sink-service/CHANGELOG.md b/packages/account-postgres-sink-service/CHANGELOG.md index dabfc9c31..41177b340 100644 --- a/packages/account-postgres-sink-service/CHANGELOG.md +++ b/packages/account-postgres-sink-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/account-postgres-sink-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/account-postgres-sink-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/account-postgres-sink-service diff --git a/packages/account-postgres-sink-service/package.json b/packages/account-postgres-sink-service/package.json index 6f9cac52f..460e85d5b 100644 --- a/packages/account-postgres-sink-service/package.json +++ b/packages/account-postgres-sink-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Sync account data to postgres", "repository": { "type": "git", @@ -34,7 +34,7 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/web3.js": "^1.78.4", "aws-sdk": "^2.1344.0", diff --git a/packages/active-device-oracle/CHANGELOG.md b/packages/active-device-oracle/CHANGELOG.md index ef753c393..92639f065 100644 --- a/packages/active-device-oracle/CHANGELOG.md +++ b/packages/active-device-oracle/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/active-device-oracle + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/active-device-oracle + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/active-device-oracle diff --git a/packages/active-device-oracle/package.json b/packages/active-device-oracle/package.json index 0cd7ff55f..09468419f 100644 --- a/packages/active-device-oracle/package.json +++ b/packages/active-device-oracle/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Oracle of helium active devices", "repository": { "type": "git", diff --git a/packages/anchor-resolvers/CHANGELOG.md b/packages/anchor-resolvers/CHANGELOG.md index ec83fc30a..42f31aad3 100644 --- a/packages/anchor-resolvers/CHANGELOG.md +++ b/packages/anchor-resolvers/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/anchor-resolvers + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/anchor-resolvers + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/anchor-resolvers diff --git a/packages/anchor-resolvers/package.json b/packages/anchor-resolvers/package.json index 2214f6c27..8d7839c23 100644 --- a/packages/anchor-resolvers/package.json +++ b/packages/anchor-resolvers/package.json @@ -1,6 +1,6 @@ { "name": "@helium/anchor-resolvers", - "version": "0.2.21", + "version": "0.3.0", "description": "Wrappers around anchor custom resolvers to make composition easier", "publishConfig": { "access": "public", diff --git a/packages/circuit-breaker-sdk/CHANGELOG.md b/packages/circuit-breaker-sdk/CHANGELOG.md index dd872a81b..c19f01da3 100644 --- a/packages/circuit-breaker-sdk/CHANGELOG.md +++ b/packages/circuit-breaker-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/circuit-breaker-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/circuit-breaker-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/circuit-breaker-sdk diff --git a/packages/circuit-breaker-sdk/package.json b/packages/circuit-breaker-sdk/package.json index 2d702bdea..8c498dd54 100644 --- a/packages/circuit-breaker-sdk/package.json +++ b/packages/circuit-breaker-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the circuit breaker smart contract", "repository": { "type": "git", @@ -32,8 +32,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/idls": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/idls": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/crons/CHANGELOG.md b/packages/crons/CHANGELOG.md new file mode 100644 index 000000000..9b1cbb006 --- /dev/null +++ b/packages/crons/CHANGELOG.md @@ -0,0 +1,22 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + + +### Features + +* **#373:** replace clockwork ([#388](https://github.com/helium/helium-program-library/issues/388)) ([55033c7](https://github.com/helium/helium-program-library/commit/55033c718df08f41eb2f77d726d59d916ebbd677)), closes [#373](https://github.com/helium/helium-program-library/issues/373) + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + + +### Features + +* **#373:** replace clockwork ([#388](https://github.com/helium/helium-program-library/issues/388)) ([55033c7](https://github.com/helium/helium-program-library/commit/55033c718df08f41eb2f77d726d59d916ebbd677)), closes [#373](https://github.com/helium/helium-program-library/issues/373) diff --git a/packages/crons/package.json b/packages/crons/package.json index 9e0220ff6..a54014482 100644 --- a/packages/crons/package.json +++ b/packages/crons/package.json @@ -1,6 +1,6 @@ { "name": "@helium/crons", - "version": "1.0.0", + "version": "0.3.0", "description": "scripts to run on a schedule", "private": true, "publishConfig": { @@ -32,16 +32,16 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/distributor-oracle": "^0.2.21", - "@helium/fanout-sdk": "^0.2.21", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/lazy-distributor-sdk": "^0.2.21", - "@helium/mobile-entity-manager-sdk": "^0.2.21", - "@helium/price-oracle-sdk": "^0.2.21", - "@helium/rewards-oracle-sdk": "^0.2.21", - "@helium/spl-utils": "^0.2.21", - "@helium/treasury-management-sdk": "^0.2.21", + "@helium/distributor-oracle": "^0.3.0", + "@helium/fanout-sdk": "^0.3.0", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/lazy-distributor-sdk": "^0.3.0", + "@helium/mobile-entity-manager-sdk": "^0.3.0", + "@helium/price-oracle-sdk": "^0.3.0", + "@helium/rewards-oracle-sdk": "^0.3.0", + "@helium/spl-utils": "^0.3.0", + "@helium/treasury-management-sdk": "^0.3.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.78.4", "axios": "^1.3.6", diff --git a/packages/currency-utils/CHANGELOG.md b/packages/currency-utils/CHANGELOG.md index 610c20396..a9aa82a50 100644 --- a/packages/currency-utils/CHANGELOG.md +++ b/packages/currency-utils/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/currency-utils + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/currency-utils + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/currency-utils diff --git a/packages/currency-utils/package.json b/packages/currency-utils/package.json index adf97762c..eda76000d 100644 --- a/packages/currency-utils/package.json +++ b/packages/currency-utils/package.json @@ -1,6 +1,6 @@ { "name": "@helium/currency-utils", - "version": "0.2.21", + "version": "0.3.0", "description": "Currency utilities", "homepage": "https://github.com/helium/helium-program-library#readme", "publishConfig": { diff --git a/packages/data-credits-sdk/CHANGELOG.md b/packages/data-credits-sdk/CHANGELOG.md index b02c15e29..16868aeb6 100644 --- a/packages/data-credits-sdk/CHANGELOG.md +++ b/packages/data-credits-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/data-credits-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/data-credits-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/data-credits-sdk diff --git a/packages/data-credits-sdk/package.json b/packages/data-credits-sdk/package.json index f1dc10671..b3d010a45 100644 --- a/packages/data-credits-sdk/package.json +++ b/packages/data-credits-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the data-credits smart contract", "repository": { "type": "git", @@ -32,10 +32,10 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/circuit-breaker-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/idls": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/circuit-breaker-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/idls": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1", "crypto-js": "^4.1.1" diff --git a/packages/distributor-oracle/CHANGELOG.md b/packages/distributor-oracle/CHANGELOG.md index f9819af5b..0207eaef9 100644 --- a/packages/distributor-oracle/CHANGELOG.md +++ b/packages/distributor-oracle/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/distributor-oracle + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/distributor-oracle + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/distributor-oracle diff --git a/packages/distributor-oracle/package.json b/packages/distributor-oracle/package.json index 5afbe40cd..53b28e0ab 100644 --- a/packages/distributor-oracle/package.json +++ b/packages/distributor-oracle/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Oracle server for the lazy distributor", "repository": { "type": "git", @@ -36,14 +36,14 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@helium/address": "^4.10.2", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/idls": "^0.2.21", - "@helium/lazy-distributor-sdk": "^0.2.21", - "@helium/rewards-oracle-sdk": "^0.2.21", - "@helium/spl-utils": "^0.2.21", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/idls": "^0.3.0", + "@helium/lazy-distributor-sdk": "^0.3.0", + "@helium/rewards-oracle-sdk": "^0.3.0", + "@helium/spl-utils": "^0.3.0", "@metaplex-foundation/mpl-bubblegum": "^0.7.0", "@solana/spl-token": "^0.3.8", "@types/sequelize": "^4.28.14", diff --git a/packages/distributor-oracle/src/client.ts b/packages/distributor-oracle/src/client.ts index 7c6abbafb..c60459f1b 100644 --- a/packages/distributor-oracle/src/client.ts +++ b/packages/distributor-oracle/src/client.ts @@ -1,4 +1,5 @@ -import { AnchorProvider, BN, Program } from '@coral-xyz/anchor'; +import { AnchorProvider, BN, IdlAccounts, Program } from '@coral-xyz/anchor'; +import { getSingleton } from '@helium/account-fetch-cache'; import { decodeEntityKey, init, @@ -7,7 +8,6 @@ import { keyToAssetForAsset, } from '@helium/helium-entity-manager-sdk'; import { daoKey } from '@helium/helium-sub-daos-sdk'; -import { HeliumEntityManager } from '@helium/idls/lib/types/helium_entity_manager'; import { LazyDistributor } from '@helium/idls/lib/types/lazy_distributor'; import { RewardsOracle } from '@helium/idls/lib/types/rewards_oracle'; import { @@ -22,6 +22,8 @@ import { HNT_MINT, getAsset, getAssetProof, + getAssetBatch, + getAssetProofBatch, truthy, } from '@helium/spl-utils'; import { getAssociatedTokenAddress } from '@solana/spl-token'; @@ -31,6 +33,7 @@ import { TransactionInstruction, } from '@solana/web3.js'; import axios from 'axios'; +import { HeliumEntityManager } from "@helium/idls/lib/types/helium_entity_manager"; const HNT = process.env.HNT_MINT ? new PublicKey(process.env.HNT_MINT) @@ -107,23 +110,47 @@ export async function getPendingRewards( ); const hemProgram = await init(program.provider as AnchorProvider); - const withRecipients = await Promise.all( - entityKeys.map(async (entityKey) => { - const keyToAssetK = keyToAssetKey(dao, entityKey, encoding)[0]; - const keyToAsset = await hemProgram.account.keyToAssetV0.fetch( - keyToAssetK - ); - const recipient = recipientKey(lazyDistributor, keyToAsset.asset)[0]; - const recipientAcc = await program.account.recipientV0.fetchNullable( - recipient - ); - - return { - entityKey, - recipientAcc, - }; + const cache = await getSingleton(hemProgram.provider.connection) + const keyToAssetKs = entityKeys.map((entityKey) => { + return keyToAssetKey(dao, entityKey, encoding)[0]; + }) + + const keyToAssets = await cache.searchMultiple( + keyToAssetKs, + (pubkey, account) => ({ + pubkey, + account, + info: hemProgram.coder.accounts.decode< + IdlAccounts["keyToAssetV0"] + >("KeyToAssetV0", account.data), + }), + true, + false + ); + keyToAssets.forEach((kta, index) => { + if (!kta?.info) { + throw new Error(`Key to asset account not found for entity key ${entityKeys[index]}`) + } + }) + const recipientKs = keyToAssets.map( + (keyToAsset) => recipientKey(lazyDistributor, keyToAsset!.info!.asset)[0] + ); + const recipients = await cache.searchMultiple( + recipientKs, + (pubkey, account) => ({ + pubkey, + account, + info: program.coder.accounts.decode< + IdlAccounts["recipientV0"] + >("RecipientV0", account.data), }) ); + const withRecipients = recipients.map((recipient, index) => { + return { + entityKey: entityKeys[index], + recipientAcc: recipient?.info, + } + }) return withRecipients.reduce((acc, { entityKey, recipientAcc }) => { const sortedOracleRewards = oracleRewards @@ -153,8 +180,8 @@ export async function formBulkTransactions({ wallet = (lazyDistributorProgram.provider as AnchorProvider).wallet.publicKey, skipOracleSign = false, assetEndpoint, - getAssetFn = getAsset, - getAssetProofFn = getAssetProof, + getAssetBatchFn = getAssetBatch, + getAssetProofBatchFn = getAssetProofBatch, }: { program: Program; rewardsOracleProgram?: Program; @@ -167,11 +194,11 @@ export async function formBulkTransactions({ wallet?: PublicKey; assetEndpoint?: string; skipOracleSign?: boolean; - getAssetFn?: (url: string, assetId: PublicKey) => Promise; - getAssetProofFn?: ( + getAssetBatchFn?: (url: string, assetIds: PublicKey[]) => Promise; + getAssetProofBatchFn?: ( url: string, - assetId: PublicKey - ) => Promise; + assetIds: PublicKey[] + ) => Promise | undefined>; }) { if (assets.length > 100) { throw new Error('Too many assets, max 100'); @@ -192,32 +219,34 @@ export async function formBulkTransactions({ } if (!compressionAssetAccs) { - compressionAssetAccs = await Promise.all( - assets.map(async (asset) => { - // @ts-ignore - const assetAcc = await getAssetFn( - assetEndpoint || provider.connection.rpcEndpoint, - asset - ); - if (!assetAcc) { - throw new Error('No asset with ID ' + asset.toBase58()); - } - return assetAcc; - }) - ); + compressionAssetAccs = await getAssetBatchFn( + assetEndpoint || provider.connection.rpcEndpoint, + assets + ) } - if (compressionAssetAccs.length != assets.length) { + if (compressionAssetAccs?.length != assets.length) { throw new Error('Assets not the same length as compressionAssetAccs'); } let recipientKeys = assets.map( (asset) => recipientKey(lazyDistributor, asset)[0] ); - let recipientAccs = - await lazyDistributorProgram.account.recipientV0.fetchMultiple( - recipientKeys - ); - + const cache = await getSingleton( + heliumEntityManagerProgram.provider.connection + ); + const recipientAccs = ( + await cache.searchMultiple(recipientKeys, (pubkey, account) => ({ + pubkey, + account, + info: lazyDistributorProgram.coder.accounts.decode< + IdlAccounts["recipientV0"] + >("RecipientV0", account.data), + })) + ).map((x) => x?.info); + const assetProofsById = await getAssetProofBatchFn( + assetEndpoint || provider.connection.rpcEndpoint, + assets + ) let ixsPerAsset = await Promise.all( recipientAccs.map(async (recipientAcc, idx) => { if (!recipientAcc) { @@ -232,7 +261,7 @@ export async function formBulkTransactions({ // Make the oracle pay for the recipient to avoid newly migrated users not having enough sol to claim rewards payer: lazyDistributorAcc.oracles[0].oracle, getAssetFn: () => Promise.resolve(compressionAssetAccs![idx]), // cache result so we don't hit again - getAssetProofFn, + getAssetProofFn: assetProofsById ? () => Promise.resolve(assetProofsById[compressionAssetAccs![idx].id.toBase58()]) : undefined, }) ).instruction(), ]; @@ -241,14 +270,29 @@ export async function formBulkTransactions({ }) ); + const keyToAssetKs = compressionAssetAccs.map((assetAcc, idx) => { + return keyToAssetForAsset(assetAcc) + }) + const keyToAssets = await cache.searchMultiple( + keyToAssetKs, + (pubkey, account) => ({ + pubkey, + account, + info: heliumEntityManagerProgram!.coder.accounts.decode< + IdlAccounts["keyToAssetV0"] + >("KeyToAssetV0", account.data), + }), + true, + false + ); // construct the set and distribute ixs let setAndDistributeIxs = await Promise.all( compressionAssetAccs.map(async (assetAcc, idx) => { - const keyToAssetK = keyToAssetForAsset(assetAcc); - const keyToAsset = - await heliumEntityManagerProgram!.account.keyToAssetV0.fetch( - keyToAssetK - ); + const keyToAssetK = keyToAssets[idx]?.pubkey; + const keyToAsset = keyToAssets[idx]?.info + if (!keyToAsset || !keyToAssetK) { + return [] + } const entityKey = decodeEntityKey( keyToAsset.entityKey, keyToAsset.keySerialization @@ -277,14 +321,19 @@ export async function formBulkTransactions({ if (setRewardIxs.length == 0) { return []; } - const distributeIx = await ( + const distributeIx = await( await distributeCompressionRewards({ program: lazyDistributorProgram, assetId: assets![idx], lazyDistributor, rewardsMint: lazyDistributorAcc.rewardsMint!, getAssetFn: () => Promise.resolve(assetAcc), // cache result so we don't hit again - getAssetProofFn, + getAssetProofFn: assetProofsById + ? () => + Promise.resolve( + assetProofsById[compressionAssetAccs![idx].id.toBase58()] + ) + : undefined, assetEndpoint, }) ).instruction(); diff --git a/packages/distributor-oracle/src/server.ts b/packages/distributor-oracle/src/server.ts index 168995b96..f270baa5c 100644 --- a/packages/distributor-oracle/src/server.ts +++ b/packages/distributor-oracle/src/server.ts @@ -69,10 +69,23 @@ export class PgDatabase implements Database { getActiveDevices(): Promise { return Reward.count({ where: { - lastReward: { - [Op.gte]: new Date(Date.now() - 1000 * 60 * 60 * 24 * 30), // Active within the last 30 days - }, - rewardType: 'mobile_gateway' + [Op.and]: [ + { + lastReward: { + [Op.gte]: new Date(Date.now() - 1000 * 60 * 60 * 24 * 30), // Active within the last 30 days + }, + }, + { + [Op.or]: [ + { + rewardType: "mobile_gateway", + }, + { + rewardType: "iot_gateway", + }, + ], + }, + ], }, }); } @@ -105,8 +118,13 @@ export class PgDatabase implements Database { return "0"; } const keyToAssetKey = keyToAssetForAsset(asset, DAO); - const keyToAsset = await this.issuanceProgram.account.keyToAssetV0.fetch(keyToAssetKey); - const entityKey = decodeEntityKey(keyToAsset.entityKey, keyToAsset.keySerialization)!; + const keyToAsset = await this.issuanceProgram.account.keyToAssetV0.fetch( + keyToAssetKey + ); + const entityKey = decodeEntityKey( + keyToAsset.entityKey, + keyToAsset.keySerialization + )!; // Verify the creator is our entity creator, otherwise they could just // pass in any NFT with this ecc compact to collect rewards if ( diff --git a/packages/fanout-metadata-service/CHANGELOG.md b/packages/fanout-metadata-service/CHANGELOG.md index f0ab6ff3a..ac15a440a 100644 --- a/packages/fanout-metadata-service/CHANGELOG.md +++ b/packages/fanout-metadata-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/fanout-metadata-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/fanout-metadata-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/fanout-metadata-service diff --git a/packages/fanout-metadata-service/package.json b/packages/fanout-metadata-service/package.json index 97f46b2b0..a6f0cc3ec 100644 --- a/packages/fanout-metadata-service/package.json +++ b/packages/fanout-metadata-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Mint metadata of fanout positions", "repository": { "type": "git", @@ -34,10 +34,10 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@helium/address": "^4.10.2", - "@helium/fanout-sdk": "^0.2.21", - "@helium/spl-utils": "^0.2.21", + "@helium/fanout-sdk": "^0.3.0", + "@helium/spl-utils": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/spl-account-compression": "^0.1.7", "@solana/spl-token": "^0.3.8", @@ -58,4 +58,4 @@ }, "keywords": [], "author": "" -} \ No newline at end of file +} diff --git a/packages/fanout-sdk/CHANGELOG.md b/packages/fanout-sdk/CHANGELOG.md index 98c914bf8..2d5734241 100644 --- a/packages/fanout-sdk/CHANGELOG.md +++ b/packages/fanout-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/fanout-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/fanout-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/fanout-sdk diff --git a/packages/fanout-sdk/package.json b/packages/fanout-sdk/package.json index 7091c86c1..3e8abf646 100644 --- a/packages/fanout-sdk/package.json +++ b/packages/fanout-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the fanout smart contract", "repository": { "type": "git", @@ -32,8 +32,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/idls": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/idls": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/faucet-service/CHANGELOG.md b/packages/faucet-service/CHANGELOG.md index d1c7ae985..92bf92ad7 100644 --- a/packages/faucet-service/CHANGELOG.md +++ b/packages/faucet-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/faucet-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/faucet-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/faucet-service diff --git a/packages/faucet-service/package.json b/packages/faucet-service/package.json index 81f19b7bf..6e9e2a664 100644 --- a/packages/faucet-service/package.json +++ b/packages/faucet-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Faucet for devnet Helium tokens", "repository": { "type": "git", @@ -35,8 +35,8 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/idls": "^0.2.21", - "@helium/spl-utils": "^0.2.21", + "@helium/idls": "^0.3.0", + "@helium/spl-utils": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/web3.js": "^1.78.4", "angry-purple-tiger": "^1.0.5", diff --git a/packages/helium-admin-cli/CHANGELOG.md b/packages/helium-admin-cli/CHANGELOG.md index 8ca782051..aca306af4 100644 --- a/packages/helium-admin-cli/CHANGELOG.md +++ b/packages/helium-admin-cli/CHANGELOG.md @@ -3,6 +3,38 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-libary/issues/380)) ([a691257](https://github.com/helium/helium-program-libary/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-libary/issues/376) [#376](https://github.com/helium/helium-program-libary/issues/376) + + +### Reverts + +* Revert "Add back mobile genesis fix for devnet" ([93e9a2c](https://github.com/helium/helium-program-libary/commit/93e9a2c370ba77a49b02efc2590ddf3039465ed6)) + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-libary/issues/380)) ([a691257](https://github.com/helium/helium-program-libary/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-libary/issues/376) [#376](https://github.com/helium/helium-program-libary/issues/376) + + +### Reverts + +* Revert "Add back mobile genesis fix for devnet" ([93e9a2c](https://github.com/helium/helium-program-libary/commit/93e9a2c370ba77a49b02efc2590ddf3039465ed6)) + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/helium-admin-cli diff --git a/packages/helium-admin-cli/package.json b/packages/helium-admin-cli/package.json index dc9085301..778813ce4 100644 --- a/packages/helium-admin-cli/package.json +++ b/packages/helium-admin-cli/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "CLI to bootstrap the network", "repository": { "type": "git", @@ -42,18 +42,18 @@ "@clockwork-xyz/sdk": "^0.3.0", "@coral-xyz/anchor": "^0.26.0", "@helium/address": "^4.10.2", - "@helium/circuit-breaker-sdk": "^0.2.21", + "@helium/circuit-breaker-sdk": "^0.3.0", "@helium/crypto": "^4.10.2", - "@helium/data-credits-sdk": "^0.2.21", - "@helium/distributor-oracle": "^0.2.21", - "@helium/fanout-sdk": "^0.2.21", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/lazy-distributor-sdk": "^0.2.21", - "@helium/mobile-entity-manager-sdk": "^0.2.21", - "@helium/price-oracle-sdk": "^0.2.21", - "@helium/spl-utils": "^0.2.21", - "@helium/treasury-management-sdk": "^0.2.21", + "@helium/data-credits-sdk": "^0.3.0", + "@helium/distributor-oracle": "^0.3.0", + "@helium/fanout-sdk": "^0.3.0", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/lazy-distributor-sdk": "^0.3.0", + "@helium/mobile-entity-manager-sdk": "^0.3.0", + "@helium/price-oracle-sdk": "^0.3.0", + "@helium/spl-utils": "^0.3.0", + "@helium/treasury-management-sdk": "^0.3.0", "@solana/spl-account-compression": "^0.1.7", "@solana/spl-governance": "^0.3.18", "@solana/spl-token": "^0.3.8", diff --git a/packages/helium-admin-cli/src/write-merkle-canopy-depths.ts b/packages/helium-admin-cli/src/write-merkle-canopy-depths.ts new file mode 100644 index 000000000..24160d5a2 --- /dev/null +++ b/packages/helium-admin-cli/src/write-merkle-canopy-depths.ts @@ -0,0 +1,43 @@ +import * as anchor from "@coral-xyz/anchor"; +import { init as initHem } from "@helium/helium-entity-manager-sdk"; +import os from "os"; +import yargs from "yargs/yargs"; +import fs from "fs"; +import { ConcurrentMerkleTreeAccount } from "@solana/spl-account-compression"; + +export async function run(args: any = process.argv) { + const yarg = yargs(args).options({ + wallet: { + alias: "k", + describe: "Anchor wallet keypair", + default: `${os.homedir()}/.config/solana/id.json`, + }, + url: { + alias: "u", + default: "http://127.0.0.1:8899", + describe: "The solana url", + }, + }); + const argv = await yarg.argv; + process.env.ANCHOR_WALLET = argv.wallet; + process.env.ANCHOR_PROVIDER_URL = argv.url; + anchor.setProvider(anchor.AnchorProvider.local(argv.url)); + const provider = anchor.getProvider() as anchor.AnchorProvider; + const hemProgram = await initHem(provider); + + const makers = await hemProgram.account.makerV0.all(); + const merkles = makers.map((m) => m.account.merkleTree); + let merkleDepths = {}; + for (const merkle of merkles) { + merkleDepths[merkle.toBase58()] = ( + await ConcurrentMerkleTreeAccount.fromAccountAddress( + hemProgram.provider.connection, + merkle + ) + ).getCanopyDepth(); + } + fs.writeFileSync( + "./merkles.json", + JSON.stringify(merkleDepths, null, 2) + ); +} diff --git a/packages/helium-entity-manager-sdk/CHANGELOG.md b/packages/helium-entity-manager-sdk/CHANGELOG.md index 5fda3b592..d63db37df 100644 --- a/packages/helium-entity-manager-sdk/CHANGELOG.md +++ b/packages/helium-entity-manager-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/helium-entity-manager-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/helium-entity-manager-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/helium-entity-manager-sdk diff --git a/packages/helium-entity-manager-sdk/package.json b/packages/helium-entity-manager-sdk/package.json index acf5d21b5..b59d0b149 100644 --- a/packages/helium-entity-manager-sdk/package.json +++ b/packages/helium-entity-manager-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the helium-entity-manager smart contract", "repository": { "type": "git", @@ -33,10 +33,10 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@helium/address": "^4.10.2", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/idls": "^0.2.21", - "@helium/spl-utils": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/idls": "^0.3.0", + "@helium/spl-utils": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1", "crypto-js": "^4.1.1", diff --git a/packages/helium-react-hooks/CHANGELOG.md b/packages/helium-react-hooks/CHANGELOG.md index 89740b323..5f30a74d5 100644 --- a/packages/helium-react-hooks/CHANGELOG.md +++ b/packages/helium-react-hooks/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/helium-react-hooks + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/helium-react-hooks + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/helium-react-hooks diff --git a/packages/helium-react-hooks/package.json b/packages/helium-react-hooks/package.json index 07ca1ef66..9969d3a79 100644 --- a/packages/helium-react-hooks/package.json +++ b/packages/helium-react-hooks/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "React hooks for helium", "repository": { "type": "git", @@ -33,8 +33,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/account-fetch-cache": "^0.2.21", - "@helium/account-fetch-cache-hooks": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", + "@helium/account-fetch-cache-hooks": "^0.3.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.78.4", "bs58": "^4.0.1", diff --git a/packages/helium-sub-daos-sdk/CHANGELOG.md b/packages/helium-sub-daos-sdk/CHANGELOG.md index e7daf5d0d..d12b2a72c 100644 --- a/packages/helium-sub-daos-sdk/CHANGELOG.md +++ b/packages/helium-sub-daos-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/helium-sub-daos-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/helium-sub-daos-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/helium-sub-daos-sdk diff --git a/packages/helium-sub-daos-sdk/package.json b/packages/helium-sub-daos-sdk/package.json index 5cbd6b871..b38552acd 100644 --- a/packages/helium-sub-daos-sdk/package.json +++ b/packages/helium-sub-daos-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the helium-sub-daos smart contract", "repository": { "type": "git", @@ -32,10 +32,10 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/circuit-breaker-sdk": "^0.2.21", - "@helium/treasury-management-sdk": "^0.2.21", - "@helium/voter-stake-registry-sdk": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/circuit-breaker-sdk": "^0.3.0", + "@helium/treasury-management-sdk": "^0.3.0", + "@helium/voter-stake-registry-sdk": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/hnt-to-rent-service/CHANGELOG.md b/packages/hnt-to-rent-service/CHANGELOG.md index 3378991d0..818207a69 100644 --- a/packages/hnt-to-rent-service/CHANGELOG.md +++ b/packages/hnt-to-rent-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/hnt-to-rent-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/hnt-to-rent-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/hnt-to-rent-service diff --git a/packages/hnt-to-rent-service/package.json b/packages/hnt-to-rent-service/package.json index a2d325798..fce2b0ac1 100644 --- a/packages/hnt-to-rent-service/package.json +++ b/packages/hnt-to-rent-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Service that gives flashloans of sol to allow orca swap of small amounts of hnt to sol for fees", "repository": { "type": "git", @@ -34,7 +34,7 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@helium/address": "^4.10.2", "@orca-so/whirlpools-sdk": "^0.8.2", "@solana/web3.js": "^1.78.4", diff --git a/packages/hotspot-utils/CHANGELOG.md b/packages/hotspot-utils/CHANGELOG.md index 8f9cb10a3..8d0a63bd4 100644 --- a/packages/hotspot-utils/CHANGELOG.md +++ b/packages/hotspot-utils/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/hotspot-utils + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/hotspot-utils + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/hotspot-utils diff --git a/packages/hotspot-utils/package.json b/packages/hotspot-utils/package.json index 2140c9d0d..7288321f4 100644 --- a/packages/hotspot-utils/package.json +++ b/packages/hotspot-utils/package.json @@ -1,6 +1,6 @@ { "name": "@helium/hotspot-utils", - "version": "0.2.21", + "version": "0.3.0", "description": "Utils for Hotspot interaction", "homepage": "https://github.com/helium/helium-program-library#readme", "publishConfig": { @@ -29,10 +29,10 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/idls": "^0.2.21", - "@helium/spl-utils": "^0.2.21", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/idls": "^0.3.0", + "@helium/spl-utils": "^0.3.0", "@solana/web3.js": "^1.78.4", "bs58": "^4.0.1" }, diff --git a/packages/idls/CHANGELOG.md b/packages/idls/CHANGELOG.md index 97878b0a6..254286c55 100644 --- a/packages/idls/CHANGELOG.md +++ b/packages/idls/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/idls + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/idls + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/idls diff --git a/packages/idls/package.json b/packages/idls/package.json index e7f727e5e..a8f95b0d6 100644 --- a/packages/idls/package.json +++ b/packages/idls/package.json @@ -1,6 +1,6 @@ { "name": "@helium/idls", - "version": "0.2.21", + "version": "0.3.0", "description": "Exported idls", "publishConfig": { "access": "public", diff --git a/packages/iot-premine-data-only-service/CHANGELOG.md b/packages/iot-premine-data-only-service/CHANGELOG.md new file mode 100644 index 000000000..72201b6c9 --- /dev/null +++ b/packages/iot-premine-data-only-service/CHANGELOG.md @@ -0,0 +1,16 @@ +# Change Log + +All notable changes to this project will be documented in this file. +See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. + +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/iot-premine-data-only-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/iot-premine-data-only-service diff --git a/packages/iot-premine-data-only-service/package.json b/packages/iot-premine-data-only-service/package.json index ffe87f60b..8e822b049 100644 --- a/packages/iot-premine-data-only-service/package.json +++ b/packages/iot-premine-data-only-service/package.json @@ -1,6 +1,6 @@ { "name": "@helium/iot-premine-data-only-service", - "version": "0.0.1", + "version": "0.3.0", "description": "iot premine data only service", "private": true, "publishConfig": { @@ -34,7 +34,7 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@helium/address": "^4.10.2", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.78.4", diff --git a/packages/lazy-distributor-sdk/CHANGELOG.md b/packages/lazy-distributor-sdk/CHANGELOG.md index d3af331e1..de8319db5 100644 --- a/packages/lazy-distributor-sdk/CHANGELOG.md +++ b/packages/lazy-distributor-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/lazy-distributor-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/lazy-distributor-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/lazy-distributor-sdk diff --git a/packages/lazy-distributor-sdk/package.json b/packages/lazy-distributor-sdk/package.json index 83dc47867..8f3e8bebe 100644 --- a/packages/lazy-distributor-sdk/package.json +++ b/packages/lazy-distributor-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the lazy-distributor smart contract", "repository": { "type": "git", @@ -32,8 +32,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/circuit-breaker-sdk": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/circuit-breaker-sdk": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/lazy-distributor-sdk/src/functions/distributeCompressionRewards.ts b/packages/lazy-distributor-sdk/src/functions/distributeCompressionRewards.ts index d302c5f8b..e3da9c2a0 100644 --- a/packages/lazy-distributor-sdk/src/functions/distributeCompressionRewards.ts +++ b/packages/lazy-distributor-sdk/src/functions/distributeCompressionRewards.ts @@ -1,17 +1,14 @@ -import { LazyDistributor } from "@helium/idls/lib/types/lazy_distributor"; -import { Asset, getAsset, getAssetProof, AssetProof } from "@helium/spl-utils"; import { Idl, Program } from "@coral-xyz/anchor"; +import { LazyDistributor } from "@helium/idls/lib/types/lazy_distributor"; +import { Asset, AssetProof, proofArgsAndAccounts } from "@helium/spl-utils"; import { PublicKey } from "@solana/web3.js"; -import { ConcurrentMerkleTreeAccount } from "@solana/spl-account-compression"; export async function distributeCompressionRewards({ program, assetId, lazyDistributor, - assetEndpoint, rewardsMint, - getAssetFn = getAsset, - getAssetProofFn = getAssetProof, + ...rest }: { program: Program; assetId: PublicKey; @@ -25,47 +22,30 @@ export async function distributeCompressionRewards({ assetId: PublicKey ) => Promise; }) { - // @ts-ignore - const endpoint = assetEndpoint || program.provider.connection._rpcEndpoint; - const asset = await getAssetFn(endpoint, assetId); - if (!asset) { - throw new Error("No asset with ID " + assetId.toBase58()); - } - const assetProof = await getAssetProofFn(endpoint, assetId); - if (!assetProof) { - throw new Error("No asset proof with ID " + assetId.toBase58()); - } - const { root, proof, leaf, treeId } = assetProof; const { - ownership: { owner }, - compression: { leafId }, - } = asset; - const canopy = await ( - await ConcurrentMerkleTreeAccount.fromAccountAddress(program.provider.connection, treeId) - ).getCanopyDepth(); + asset: { + ownership: { owner }, + }, + args, + accounts, + remainingAccounts, + } = await proofArgsAndAccounts({ + connection: program.provider.connection, + assetId, + ...rest, + }); return program.methods .distributeCompressionRewardsV0({ - dataHash: asset.compression.dataHash!.toJSON().data, - creatorHash: asset.compression.creatorHash!.toJSON().data, - root: root.toBuffer().toJSON().data, - index: leafId!, + ...args, }) .accounts({ + ...accounts, common: { lazyDistributor, rewardsMint, owner, }, - merkleTree: treeId, }) - .remainingAccounts( - proof.slice(0, proof.length - canopy).map((p) => { - return { - pubkey: p, - isWritable: false, - isSigner: false, - }; - }) - ); + .remainingAccounts(remainingAccounts); } diff --git a/packages/lazy-transactions-sdk/CHANGELOG.md b/packages/lazy-transactions-sdk/CHANGELOG.md index a7dec84d2..9612da6bd 100644 --- a/packages/lazy-transactions-sdk/CHANGELOG.md +++ b/packages/lazy-transactions-sdk/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-libary/issues/380)) ([a691257](https://github.com/helium/helium-program-libary/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-libary/issues/376) [#376](https://github.com/helium/helium-program-libary/issues/376) + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-libary/issues/380)) ([a691257](https://github.com/helium/helium-program-libary/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-libary/issues/376) [#376](https://github.com/helium/helium-program-libary/issues/376) + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/lazy-transactions-sdk diff --git a/packages/lazy-transactions-sdk/package.json b/packages/lazy-transactions-sdk/package.json index 4f1ac8662..2e48b7fd7 100644 --- a/packages/lazy-transactions-sdk/package.json +++ b/packages/lazy-transactions-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the lazy-transactions smart contract", "repository": { "type": "git", @@ -32,8 +32,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/idls": "^0.2.21", - "@helium/spl-utils": "^0.2.21", + "@helium/idls": "^0.3.0", + "@helium/spl-utils": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1", "js-sha3": "^0.8.0", diff --git a/packages/metadata-service/CHANGELOG.md b/packages/metadata-service/CHANGELOG.md index 7b23e34f1..c0a26b323 100644 --- a/packages/metadata-service/CHANGELOG.md +++ b/packages/metadata-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/metadata-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/metadata-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/metadata-service diff --git a/packages/metadata-service/package.json b/packages/metadata-service/package.json index 26e84876b..4bdfde253 100644 --- a/packages/metadata-service/package.json +++ b/packages/metadata-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Mint metadata of hotspots", "repository": { "type": "git", @@ -35,8 +35,8 @@ "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", "@helium/address": "^4.10.2", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/spl-token": "^0.3.8", "@solana/web3.js": "^1.78.4", diff --git a/packages/migration-service/CHANGELOG.md b/packages/migration-service/CHANGELOG.md index 152db6e81..8251f7998 100644 --- a/packages/migration-service/CHANGELOG.md +++ b/packages/migration-service/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-libary/issues/380)) ([a691257](https://github.com/helium/helium-program-libary/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-libary/issues/376) [#376](https://github.com/helium/helium-program-libary/issues/376) + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-libary/issues/380)) ([a691257](https://github.com/helium/helium-program-libary/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-libary/issues/376) [#376](https://github.com/helium/helium-program-libary/issues/376) + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/migration-service diff --git a/packages/migration-service/package.json b/packages/migration-service/package.json index 98182b1f2..863363901 100644 --- a/packages/migration-service/package.json +++ b/packages/migration-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Migration of state from helium", "repository": { "type": "git", @@ -35,18 +35,18 @@ "@clockwork-xyz/sdk": "^0.3.0", "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@helium/address": "^4.10.2", - "@helium/circuit-breaker-sdk": "^0.2.21", + "@helium/circuit-breaker-sdk": "^0.3.0", "@helium/crypto": "^4.10.2", - "@helium/data-credits-sdk": "^0.2.21", - "@helium/distributor-oracle": "^0.2.21", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/lazy-distributor-sdk": "^0.2.21", - "@helium/lazy-transactions-sdk": "^0.2.21", - "@helium/treasury-management-sdk": "^0.2.21", - "@helium/voter-stake-registry-sdk": "^0.2.21", + "@helium/data-credits-sdk": "^0.3.0", + "@helium/distributor-oracle": "^0.3.0", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/lazy-distributor-sdk": "^0.3.0", + "@helium/lazy-transactions-sdk": "^0.3.0", + "@helium/treasury-management-sdk": "^0.3.0", + "@helium/voter-stake-registry-sdk": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@project-serum/borsh": "^0.2.5", "@solana/buffer-layout": "^4.0.0", diff --git a/packages/mobile-entity-manager-sdk/CHANGELOG.md b/packages/mobile-entity-manager-sdk/CHANGELOG.md index 3bdaf11ce..916470e56 100644 --- a/packages/mobile-entity-manager-sdk/CHANGELOG.md +++ b/packages/mobile-entity-manager-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/mobile-entity-manager-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/mobile-entity-manager-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/mobile-entity-manager-sdk diff --git a/packages/mobile-entity-manager-sdk/package.json b/packages/mobile-entity-manager-sdk/package.json index 52502cf41..68e2f27cf 100644 --- a/packages/mobile-entity-manager-sdk/package.json +++ b/packages/mobile-entity-manager-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the mobile-entity-manager smart contract", "repository": { "type": "git", @@ -32,9 +32,9 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/idls": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/idls": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/monitor-service/CHANGELOG.md b/packages/monitor-service/CHANGELOG.md index 0f83a32dd..eafe60aef 100644 --- a/packages/monitor-service/CHANGELOG.md +++ b/packages/monitor-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/monitor-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/monitor-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/monitor-service diff --git a/packages/monitor-service/package.json b/packages/monitor-service/package.json index e7c647318..a11783a3e 100644 --- a/packages/monitor-service/package.json +++ b/packages/monitor-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Prometheus monitoring of important accounts on Solana", "repository": { "type": "git", @@ -33,13 +33,13 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/account-fetch-cache": "^0.2.21", - "@helium/circuit-breaker-sdk": "^0.2.21", - "@helium/data-credits-sdk": "^0.2.21", - "@helium/helium-entity-manager-sdk": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", - "@helium/idls": "^0.2.21", - "@helium/lazy-transactions-sdk": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", + "@helium/circuit-breaker-sdk": "^0.3.0", + "@helium/data-credits-sdk": "^0.3.0", + "@helium/helium-entity-manager-sdk": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", + "@helium/idls": "^0.3.0", + "@helium/lazy-transactions-sdk": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/spl-account-compression": "^0.1.7", "@solana/spl-token": "^0.3.8", diff --git a/packages/price-oracle-sdk/CHANGELOG.md b/packages/price-oracle-sdk/CHANGELOG.md index d1cf82367..6d20df337 100644 --- a/packages/price-oracle-sdk/CHANGELOG.md +++ b/packages/price-oracle-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/price-oracle-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/price-oracle-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/price-oracle-sdk diff --git a/packages/price-oracle-sdk/package.json b/packages/price-oracle-sdk/package.json index 797d28aba..a6ba7a97a 100644 --- a/packages/price-oracle-sdk/package.json +++ b/packages/price-oracle-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the price oracle smart contract", "repository": { "type": "git", @@ -32,7 +32,7 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/idls": "^0.2.21", + "@helium/idls": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/rewards-oracle-faucet-service/CHANGELOG.md b/packages/rewards-oracle-faucet-service/CHANGELOG.md index 9ad844bdb..90e06e6eb 100644 --- a/packages/rewards-oracle-faucet-service/CHANGELOG.md +++ b/packages/rewards-oracle-faucet-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/rewards-oracle-faucet-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/rewards-oracle-faucet-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/rewards-oracle-faucet-service diff --git a/packages/rewards-oracle-faucet-service/package.json b/packages/rewards-oracle-faucet-service/package.json index 433313a5b..0f4fc5f5d 100644 --- a/packages/rewards-oracle-faucet-service/package.json +++ b/packages/rewards-oracle-faucet-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Receives requests from Helius webhooks", "repository": { "type": "git", diff --git a/packages/rewards-oracle-sdk/CHANGELOG.md b/packages/rewards-oracle-sdk/CHANGELOG.md index ee84611eb..eb90ed47d 100644 --- a/packages/rewards-oracle-sdk/CHANGELOG.md +++ b/packages/rewards-oracle-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/rewards-oracle-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/rewards-oracle-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/rewards-oracle-sdk diff --git a/packages/rewards-oracle-sdk/package.json b/packages/rewards-oracle-sdk/package.json index 7c8f2c3af..13823b8e1 100644 --- a/packages/rewards-oracle-sdk/package.json +++ b/packages/rewards-oracle-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the rewards oracle smart contract", "repository": { "type": "git", @@ -32,8 +32,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/idls": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/idls": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/spl-utils/CHANGELOG.md b/packages/spl-utils/CHANGELOG.md index ff5897998..02a78657b 100644 --- a/packages/spl-utils/CHANGELOG.md +++ b/packages/spl-utils/CHANGELOG.md @@ -3,6 +3,28 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-library/issues/380)) ([a691257](https://github.com/helium/helium-program-library/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-library/issues/376) [#376](https://github.com/helium/helium-program-library/issues/376) + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + + +### Features + +* **#376:** Replace lazy transactions markers with a bitmap to reclaim rent ([#380](https://github.com/helium/helium-program-library/issues/380)) ([a691257](https://github.com/helium/helium-program-library/commit/a6912570d4e3d89869cd13c5cfc8ce8c4355148e)), closes [#376](https://github.com/helium/helium-program-library/issues/376) [#376](https://github.com/helium/helium-program-library/issues/376) + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/spl-utils diff --git a/packages/spl-utils/package.json b/packages/spl-utils/package.json index 391a2eda8..5a1213deb 100644 --- a/packages/spl-utils/package.json +++ b/packages/spl-utils/package.json @@ -1,6 +1,6 @@ { "name": "@helium/spl-utils", - "version": "0.2.21", + "version": "0.3.0", "description": "Utils shared across spl suite", "publishConfig": { "access": "public", @@ -32,9 +32,9 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@helium/address": "^4.10.2", - "@helium/anchor-resolvers": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/spl-account-compression": "^0.1.7", "@solana/spl-token": "^0.3.8", diff --git a/packages/spl-utils/src/index.ts b/packages/spl-utils/src/index.ts index 1344d844a..5d5905161 100644 --- a/packages/spl-utils/src/index.ts +++ b/packages/spl-utils/src/index.ts @@ -18,6 +18,8 @@ export { getAssetProof, getAssetsByOwner, searchAssets, + getAssetBatch, + getAssetProofBatch, } from './mplAssetAPI'; export { proofArgsAndAccounts } from './proofArgsAndAccounts'; diff --git a/packages/spl-utils/src/mplAssetAPI.ts b/packages/spl-utils/src/mplAssetAPI.ts index 26bcd9c2b..c119bd33d 100644 --- a/packages/spl-utils/src/mplAssetAPI.ts +++ b/packages/spl-utils/src/mplAssetAPI.ts @@ -1,8 +1,8 @@ -import { Creator, Uses } from '@metaplex-foundation/mpl-bubblegum'; -import { PublicKey } from '@solana/web3.js'; -import axios from 'axios'; +import { Creator, Uses } from "@metaplex-foundation/mpl-bubblegum"; +import { PublicKey } from "@solana/web3.js"; +import axios from "axios"; // @ts-ignore -import base58 from 'bs58'; +import base58 from "bs58"; export type AssetProof = { root: PublicKey; @@ -47,14 +47,14 @@ export async function getAsset( ): Promise { try { const response = await axios.post(url, { - jsonrpc: '2.0', - method: 'getAsset', - id: 'rpd-op-123', + jsonrpc: "2.0", + method: "getAsset", + id: "rpd-op-123", params: { id: assetId.toBase58() }, headers: { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0', + "Cache-Control": "no-cache", + Pragma: "no-cache", + Expires: "0", }, }); const result = response.data.result; @@ -67,6 +67,32 @@ export async function getAsset( } } +export async function getAssetBatch( + url: string, + assetIds: PublicKey[] +): Promise { + try { + const response = await axios.post(url, { + jsonrpc: "2.0", + method: "getAssetBatch", + id: "rpd-op-123", + params: { ids: assetIds.map((assetId) => assetId.toBase58()) }, + headers: { + "Cache-Control": "no-cache", + Pragma: "no-cache", + Expires: "0", + }, + }); + const result = response.data.result; + if (result) { + return result.map(toAsset); + } + } catch (error) { + console.error(error); + throw error; + } +} + export async function getAssets( url: string, assetIds: PublicKey[] @@ -79,9 +105,9 @@ export async function getAssets( } const batch = assetIds.map((assetId, i) => ({ - jsonrpc: '2.0', + jsonrpc: "2.0", id: `get-asset-${i}`, - method: 'getAsset', + method: "getAsset", params: { id: assetId.toBase58(), }, @@ -89,12 +115,12 @@ export async function getAssets( const response = await axios({ url, - method: 'POST', + method: "POST", headers: { - 'Content-Type': 'application/json', - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0', + "Content-Type": "application/json", + "Cache-Control": "no-cache", + Pragma: "no-cache", + Expires: "0", }, data: JSON.stringify(batch), }); @@ -153,14 +179,14 @@ export async function getAssetProof( ): Promise { try { const response = await axios.post(url, { - jsonrpc: '2.0', - method: 'getAssetProof', - id: 'rpd-op-123', + jsonrpc: "2.0", + method: "getAssetProof", + id: "rpd-op-123", params: { id: assetId.toBase58() }, headers: { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0', + "Cache-Control": "no-cache", + Pragma: "no-cache", + Expires: "0", }, }); const result = response.data.result; @@ -179,8 +205,46 @@ export async function getAssetProof( } } +export async function getAssetProofBatch( + url: string, + assetIds: PublicKey[] +): Promise | undefined> { + try { + const response = await axios.post(url, { + jsonrpc: "2.0", + method: "getAssetProofBatch", + id: "rpd-op-123", + params: { ids: assetIds.map((assetId) => assetId.toBase58()) }, + headers: { + "Cache-Control": "no-cache", + Pragma: "no-cache", + Expires: "0", + }, + }); + const result = response.data.result; + if (result) { + return Object.entries(result as Record).reduce( + (acc, [k, r]) => { + acc[k] = { + root: new PublicKey(r.root), + proof: r.proof.map((p: any) => new PublicKey(p)), + nodeIndex: r.node_index, + leaf: new PublicKey(r.leaf), + treeId: new PublicKey(r.tree_id), + } as AssetProof; + return acc; + }, + {} as Record + ); + } + } catch (error) { + console.error(error); + throw error; + } +} + export type AssetsByOwnerOpts = { - sortBy?: { sortBy: 'created'; sortDirection: 'asc' | 'desc' }; + sortBy?: { sortBy: "created"; sortDirection: "asc" | "desc" }; limit?: number; page?: number; before?: string; @@ -191,23 +255,23 @@ export async function getAssetsByOwner( url: string, wallet: string, { - sortBy = { sortBy: 'created', sortDirection: 'asc' }, + sortBy = { sortBy: "created", sortDirection: "asc" }, limit = 50, page = 1, - before = '', - after = '', + before = "", + after = "", }: AssetsByOwnerOpts = {} ): Promise { try { const response = await axios.post(url, { - jsonrpc: '2.0', - method: 'getAssetsByOwner', - id: 'rpd-op-123', + jsonrpc: "2.0", + method: "getAssetsByOwner", + id: "rpd-op-123", params: [wallet, sortBy, limit, page, before, after], headers: { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0', + "Cache-Control": "no-cache", + Pragma: "no-cache", + Expires: "0", }, }); @@ -219,7 +283,7 @@ export async function getAssetsByOwner( } export type SearchAssetsOpts = { - sortBy?: { sortBy: 'created'; sortDirection: 'asc' | 'desc' }; + sortBy?: { sortBy: "created"; sortDirection: "asc" | "desc" }; page?: number; collection?: string; ownerAddress: string; @@ -231,16 +295,16 @@ export async function searchAssets( url: string, { creatorVerified = true, - sortBy = { sortBy: 'created', sortDirection: 'asc' }, + sortBy = { sortBy: "created", sortDirection: "asc" }, page = 1, ...rest }: SearchAssetsOpts ): Promise { try { const response = await axios.post(url, { - jsonrpc: '2.0', - method: 'searchAssets', - id: 'get-assets-op-1', + jsonrpc: "2.0", + method: "searchAssets", + id: "get-assets-op-1", params: { page, creatorVerified, @@ -248,9 +312,9 @@ export async function searchAssets( ...rest, }, headers: { - 'Cache-Control': 'no-cache', - Pragma: 'no-cache', - Expires: '0', + "Cache-Control": "no-cache", + Pragma: "no-cache", + Expires: "0", }, }); diff --git a/packages/spl-utils/src/proofArgsAndAccounts.ts b/packages/spl-utils/src/proofArgsAndAccounts.ts index ff62a3001..2609637c0 100644 --- a/packages/spl-utils/src/proofArgsAndAccounts.ts +++ b/packages/spl-utils/src/proofArgsAndAccounts.ts @@ -1,5 +1,9 @@ import { Asset, AssetProof, getAsset, getAssetProof } from "./mplAssetAPI"; -import { ConcurrentMerkleTreeAccount } from "@solana/spl-account-compression"; +import { + concurrentMerkleTreeBeetFactory, + concurrentMerkleTreeHeaderBeet, + getCanopyDepth, +} from "@solana/spl-account-compression"; import { Connection, PublicKey, AccountMeta } from "@solana/web3.js"; export type ProofArgsAndAccountsArgs = { @@ -12,6 +16,11 @@ export type ProofArgsAndAccountsArgs = { assetId: PublicKey ) => Promise; }; + +const WELL_KNOWN_CANOPY_URL = + "https://shdw-drive.genesysgo.net/6tcnBSybPG7piEDShBcrVtYJDPSvGrDbVvXmXKpzBvWP/merkles.json"; +let wellKnownCanopyCache: Record; +const canopyCache: Record> = {}; export async function proofArgsAndAccounts({ connection, assetId, @@ -42,10 +51,45 @@ export async function proofArgsAndAccounts({ const { compression: { leafId }, } = asset; - const { root, proof, leaf, treeId } = assetProof; - const canopy = await ( - await ConcurrentMerkleTreeAccount.fromAccountAddress(connection, treeId) - ).getCanopyDepth(); + const { root, proof, treeId } = assetProof; + + const tree = treeId.toBase58(); + if (!canopyCache[tree] && !wellKnownCanopyCache?.[tree]) { + canopyCache[tree] = (async () => { + if (!wellKnownCanopyCache) { + wellKnownCanopyCache = await (await fetch(WELL_KNOWN_CANOPY_URL)).json() + } + if (wellKnownCanopyCache[tree]) { + return wellKnownCanopyCache[tree] + } + // IMPORTANT! Do not use `ConcurrentMerkleTreeAccount` class. It stupidly deserializes the whole merkle tree, + // including reading the entire canopy. For large trees this will freeze the wallet app. + let offset = 0; + // Construct a new connection to ensure there's no caching. Don't want to cache + // a giant account in AccountFetchCache accidentally. It also adds uneeded latency + const newConn = new Connection(connection.rpcEndpoint); + const buffer = (await newConn.getAccountInfo(treeId))!.data; + const [versionedHeader, offsetIncr] = + concurrentMerkleTreeHeaderBeet.deserialize(buffer); + offset = offsetIncr; + + // Only 1 version available + if (versionedHeader.header.__kind !== "V1") { + throw Error( + `Header has unsupported version: ${versionedHeader.header.__kind}` + ); + } + const header = versionedHeader.header.fields[0]; + const [_, offsetIncr2] = concurrentMerkleTreeBeetFactory( + header.maxDepth, + header.maxBufferSize + ).deserialize(buffer, offset); + offset = offsetIncr2; + + return getCanopyDepth(buffer.byteLength - offset); + })(); + } + const canopy = await (wellKnownCanopyCache?.[tree] || canopyCache[tree]); return { asset, diff --git a/packages/treasury-management-sdk/CHANGELOG.md b/packages/treasury-management-sdk/CHANGELOG.md index c93799ead..934b82c2b 100644 --- a/packages/treasury-management-sdk/CHANGELOG.md +++ b/packages/treasury-management-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/treasury-management-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/treasury-management-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/treasury-management-sdk diff --git a/packages/treasury-management-sdk/package.json b/packages/treasury-management-sdk/package.json index ef27b9410..ca27c9935 100644 --- a/packages/treasury-management-sdk/package.json +++ b/packages/treasury-management-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the treasury-management smart contract", "repository": { "type": "git", @@ -32,9 +32,9 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/circuit-breaker-sdk": "^0.2.21", - "@helium/idls": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/circuit-breaker-sdk": "^0.3.0", + "@helium/idls": "^0.3.0", "bn.js": "^5.2.0", "bs58": "^4.0.1" }, diff --git a/packages/voter-stake-registry-hooks/CHANGELOG.md b/packages/voter-stake-registry-hooks/CHANGELOG.md index cce46104b..2af67ebc0 100644 --- a/packages/voter-stake-registry-hooks/CHANGELOG.md +++ b/packages/voter-stake-registry-hooks/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/voter-stake-registry-hooks + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/voter-stake-registry-hooks + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/voter-stake-registry-hooks diff --git a/packages/voter-stake-registry-hooks/package.json b/packages/voter-stake-registry-hooks/package.json index 337fbc804..c1b5c9576 100644 --- a/packages/voter-stake-registry-hooks/package.json +++ b/packages/voter-stake-registry-hooks/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "React hooks for helium voter stake registry", "repository": { "type": "git", @@ -33,13 +33,13 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/account-fetch-cache": "^0.2.21", - "@helium/account-fetch-cache-hooks": "^0.2.21", - "@helium/helium-react-hooks": "^0.2.21", - "@helium/helium-sub-daos-sdk": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", + "@helium/account-fetch-cache-hooks": "^0.3.0", + "@helium/helium-react-hooks": "^0.3.0", + "@helium/helium-sub-daos-sdk": "^0.3.0", "@helium/modular-governance-hooks": "^0.0.2", - "@helium/spl-utils": "^0.2.21", - "@helium/voter-stake-registry-sdk": "^0.2.21", + "@helium/spl-utils": "^0.3.0", + "@helium/voter-stake-registry-sdk": "^0.3.0", "@metaplex-foundation/js": "^0.19.4", "@solana/wallet-adapter-base": "^0.9.22", "@solana/wallet-adapter-react": "^0.15.32", diff --git a/packages/voter-stake-registry-sdk/CHANGELOG.md b/packages/voter-stake-registry-sdk/CHANGELOG.md index 4ff35cb12..b93771d23 100644 --- a/packages/voter-stake-registry-sdk/CHANGELOG.md +++ b/packages/voter-stake-registry-sdk/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/voter-stake-registry-sdk + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/voter-stake-registry-sdk + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/voter-stake-registry-sdk diff --git a/packages/voter-stake-registry-sdk/package.json b/packages/voter-stake-registry-sdk/package.json index 089740872..c45e20afe 100644 --- a/packages/voter-stake-registry-sdk/package.json +++ b/packages/voter-stake-registry-sdk/package.json @@ -5,7 +5,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Interface to the voter-stake-registry smart contract", "repository": { "type": "git", @@ -32,8 +32,8 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/anchor-resolvers": "^0.2.21", - "@helium/idls": "^0.2.21", + "@helium/anchor-resolvers": "^0.3.0", + "@helium/idls": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/spl-token": "^0.3.8", "bn.js": "^5.2.0", diff --git a/packages/vsr-metadata-service/CHANGELOG.md b/packages/vsr-metadata-service/CHANGELOG.md index 88921e090..681e947c2 100644 --- a/packages/vsr-metadata-service/CHANGELOG.md +++ b/packages/vsr-metadata-service/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/vsr-metadata-service + + + + + +## [0.2.22](https://github.com/helium/helium-program-libary/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/vsr-metadata-service + + + + + ## [0.2.15](https://github.com/helium/helium-program-libary/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/vsr-metadata-service diff --git a/packages/vsr-metadata-service/package.json b/packages/vsr-metadata-service/package.json index 747cd86b9..8a115bb7f 100644 --- a/packages/vsr-metadata-service/package.json +++ b/packages/vsr-metadata-service/package.json @@ -6,7 +6,7 @@ "registry": "https://registry.npmjs.org/" }, "license": "Apache-2.0", - "version": "0.2.21", + "version": "0.3.0", "description": "Mint metadata of vsr positions", "repository": { "type": "git", @@ -34,10 +34,10 @@ "dependencies": { "@coral-xyz/anchor": "^0.26.0", "@fastify/cors": "^8.1.1", - "@helium/account-fetch-cache": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", "@helium/address": "^4.10.2", - "@helium/spl-utils": "^0.2.21", - "@helium/voter-stake-registry-sdk": "^0.2.21", + "@helium/spl-utils": "^0.3.0", + "@helium/voter-stake-registry-sdk": "^0.3.0", "@metaplex-foundation/mpl-token-metadata": "^2.10.0", "@solana/spl-account-compression": "^0.1.7", "@solana/spl-token": "^0.3.8", @@ -58,4 +58,4 @@ }, "keywords": [], "author": "" -} \ No newline at end of file +} diff --git a/packages/xnft-hotspot/CHANGELOG.md b/packages/xnft-hotspot/CHANGELOG.md index 307d83997..54fb573ef 100644 --- a/packages/xnft-hotspot/CHANGELOG.md +++ b/packages/xnft-hotspot/CHANGELOG.md @@ -3,6 +3,22 @@ All notable changes to this project will be documented in this file. See [Conventional Commits](https://conventionalcommits.org) for commit guidelines. +# [0.3.0](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.3.0) (2023-09-14) + +**Note:** Version bump only for package @helium/xnft-hotspot + + + + + +## [0.2.22](https://github.com/helium/helium-program-library/compare/v0.2.21...v0.2.22) (2023-09-13) + +**Note:** Version bump only for package @helium/xnft-hotspot + + + + + ## [0.2.15](https://github.com/helium/helium-program-library/compare/v0.2.14...v0.2.15) (2023-07-31) **Note:** Version bump only for package @helium/xnft-hotspot diff --git a/packages/xnft-hotspot/package.json b/packages/xnft-hotspot/package.json index b14ead970..f4578ae7e 100644 --- a/packages/xnft-hotspot/package.json +++ b/packages/xnft-hotspot/package.json @@ -1,6 +1,6 @@ { "name": "@helium/xnft-hotspot", - "version": "0.2.21", + "version": "0.3.0", "private": true, "description": "", "main": "index.js", @@ -18,11 +18,11 @@ }, "dependencies": { "@coral-xyz/anchor": "^0.26.0", - "@helium/account-fetch-cache": "^0.2.21", - "@helium/distributor-oracle": "^0.2.21", - "@helium/helium-react-hooks": "^0.2.21", - "@helium/idls": "^0.2.21", - "@helium/lazy-distributor-sdk": "^0.2.21", + "@helium/account-fetch-cache": "^0.3.0", + "@helium/distributor-oracle": "^0.3.0", + "@helium/helium-react-hooks": "^0.3.0", + "@helium/idls": "^0.3.0", + "@helium/lazy-distributor-sdk": "^0.3.0", "@solana/spl-token": "^0.3.8", "assert": "^2.0.0", "bn.js": "^5.2.0", diff --git a/programs/circuit-breaker/Cargo.toml b/programs/circuit-breaker/Cargo.toml index 3dfa505fd..9cc5b1069 100644 --- a/programs/circuit-breaker/Cargo.toml +++ b/programs/circuit-breaker/Cargo.toml @@ -25,6 +25,6 @@ overflow-checks = true [dependencies] anchor-lang = { workspace = true } anchor-spl = { workspace = true } -shared-utils = { path = "../../utils/shared-utils" } +shared-utils = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/data-credits/Cargo.toml b/programs/data-credits/Cargo.toml index 8869e843a..d1c49c514 100644 --- a/programs/data-credits/Cargo.toml +++ b/programs/data-credits/Cargo.toml @@ -25,8 +25,8 @@ overflow-checks = true [dependencies] anchor-lang = { version="0.26.0", features = ["init-if-needed"] } anchor-spl = { workspace = true } -helium-sub-daos = { path = "../helium-sub-daos", features = ["cpi"] } -circuit-breaker = { path = "../circuit-breaker", features = ["cpi"] } +helium-sub-daos = { workspace = true } +circuit-breaker = { workspace = true } pyth-sdk-solana = { version = "0.7.0" } lazy-transactions = { path = "../lazy-transactions", features = ["cpi"] } solana-security-txt = { workspace = true } diff --git a/programs/fanout/Cargo.toml b/programs/fanout/Cargo.toml index da357cca9..953913d28 100644 --- a/programs/fanout/Cargo.toml +++ b/programs/fanout/Cargo.toml @@ -25,7 +25,7 @@ overflow-checks = true [dependencies] anchor-lang = { workspace = true } anchor-spl = { workspace = true } -shared-utils = { path = "../../utils/shared-utils" } +shared-utils = { workspace = true } mpl-token-metadata = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/helium-entity-manager/Cargo.toml b/programs/helium-entity-manager/Cargo.toml index eb866c040..571d35979 100644 --- a/programs/helium-entity-manager/Cargo.toml +++ b/programs/helium-entity-manager/Cargo.toml @@ -31,9 +31,8 @@ angry-purple-tiger = "0.1.0" mpl-token-metadata = { workspace = true } bubblegum-cpi = { workspace = true } account-compression-cpi = { workspace = true } -shared-utils = { path = "../../utils/shared-utils" } +shared-utils = { workspace = true } data-credits = { path = "../data-credits", features = ["cpi"] } -helium-sub-daos = { path = "../helium-sub-daos", features = ["cpi"] } -lazy-transactions = { path = "../lazy-transactions", features = ["cpi"] } +helium-sub-daos = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/helium-sub-daos/Cargo.toml b/programs/helium-sub-daos/Cargo.toml index d844729d1..f10df3c4e 100644 --- a/programs/helium-sub-daos/Cargo.toml +++ b/programs/helium-sub-daos/Cargo.toml @@ -27,8 +27,8 @@ anchor-lang = { workspace = true } anchor-spl = { workspace = true } mpl-token-metadata = { workspace = true } voter-stake-registry = { path = "../voter-stake-registry", features = ["no-entrypoint", "cpi"] } -shared-utils = { path = "../../utils/shared-utils" } -circuit-breaker = { path = "../circuit-breaker", features = ["cpi"] } +shared-utils = { workspace = true } +circuit-breaker = { workspace = true } treasury-management = { path = "../treasury-management", features = ["cpi"] } clockwork-sdk = { git = "https://github.com/clockwork-xyz/clockwork", version="2.0.1", rev="781b42fd06f2926899597ce5ea1f19b8ecd3d2e4" } diff --git a/programs/lazy-distributor/Cargo.toml b/programs/lazy-distributor/Cargo.toml index 6b5c9afd2..8bbc558e6 100644 --- a/programs/lazy-distributor/Cargo.toml +++ b/programs/lazy-distributor/Cargo.toml @@ -27,8 +27,8 @@ anchor-lang = { workspace = true } anchor-spl = { workspace = true } mpl-token-metadata = { workspace = true } bubblegum-cpi = { workspace = true } -circuit-breaker = { path = "../circuit-breaker", features = ["cpi"] } -shared-utils = { path = "../../utils/shared-utils" } +circuit-breaker = { workspace = true } +shared-utils = { workspace = true } account-compression-cpi = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/lazy-transactions/Cargo.toml b/programs/lazy-transactions/Cargo.toml index d121be2a2..55aad77e9 100644 --- a/programs/lazy-transactions/Cargo.toml +++ b/programs/lazy-transactions/Cargo.toml @@ -27,6 +27,6 @@ anchor-lang = { workspace = true } anchor-spl = { workspace = true } spl-concurrent-merkle-tree = "0.1.2" bytemuck = "1.13.0" -shared-utils = { path = "../../utils/shared-utils" } +shared-utils = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/mobile-entity-manager/Cargo.toml b/programs/mobile-entity-manager/Cargo.toml index 1d7ae0b1a..085a968e9 100644 --- a/programs/mobile-entity-manager/Cargo.toml +++ b/programs/mobile-entity-manager/Cargo.toml @@ -31,8 +31,8 @@ angry-purple-tiger = "0.1.0" mpl-token-metadata = { workspace = true } bubblegum-cpi = { workspace = true } account-compression-cpi = { workspace = true } -shared-utils = { path = "../../utils/shared-utils" } -helium-entity-manager = { path = "../helium-entity-manager", features = ["cpi"] } -helium-sub-daos = { path = "../helium-sub-daos", features = ["cpi"] } +shared-utils = { workspace = true } +helium-entity-manager = { workspace = true } +helium-sub-daos = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/rewards-oracle/Cargo.toml b/programs/rewards-oracle/Cargo.toml index 06a1fe8ba..863f4a728 100644 --- a/programs/rewards-oracle/Cargo.toml +++ b/programs/rewards-oracle/Cargo.toml @@ -22,6 +22,6 @@ default = [] [dependencies] anchor-lang = "0.26.0" lazy-distributor = { path = "../lazy-distributor", features = ["cpi"] } -helium-entity-manager = { path = "../helium-entity-manager", features = ["cpi"] } +helium-entity-manager = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/treasury-management/Cargo.toml b/programs/treasury-management/Cargo.toml index b67023fa3..928425eac 100644 --- a/programs/treasury-management/Cargo.toml +++ b/programs/treasury-management/Cargo.toml @@ -24,8 +24,8 @@ overflow-checks = true [dependencies] anchor-lang = { workspace = true } -circuit-breaker = { path = "../circuit-breaker", features = ["cpi"] } +circuit-breaker = { workspace = true } anchor-spl = { workspace = true } -shared-utils = { path = "../../utils/shared-utils" } +shared-utils = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/programs/voter-stake-registry/Cargo.toml b/programs/voter-stake-registry/Cargo.toml index 6b7231067..c89680904 100644 --- a/programs/voter-stake-registry/Cargo.toml +++ b/programs/voter-stake-registry/Cargo.toml @@ -40,7 +40,7 @@ mpl-token-metadata = { workspace = true } itertools = "0.10.2" spl-governance-tools= "0.1.3" proposal = { path = "../../utils/proposal" } -shared-utils = { path = "../../utils/shared-utils" } +shared-utils = { workspace = true } solana-security-txt = { workspace = true } default-env = { workspace = true } diff --git a/tests/distributor-oracle.ts b/tests/distributor-oracle.ts index 74939e9e7..0b3028c69 100644 --- a/tests/distributor-oracle.ts +++ b/tests/distributor-oracle.ts @@ -6,12 +6,12 @@ import { ThresholdType } from "@helium/circuit-breaker-sdk"; import { Keypair as HeliumKeypair } from "@helium/crypto"; import { PROGRAM_ID as DC_PID, - init as initDataCredits + init as initDataCredits, } from "@helium/data-credits-sdk"; import { daoKey, PROGRAM_ID as HSD_PID, - init as initHeliumSubDaos + init as initHeliumSubDaos, } from "@helium/helium-sub-daos-sdk"; import { Asset, @@ -20,12 +20,15 @@ import { createMint, getAsset, sendAndConfirmWithRetry, - sendInstructions + sendInstructions, } from "@helium/spl-utils"; import { - ComputeBudgetProgram, Keypair, LAMPORTS_PER_SOL, PublicKey, + ComputeBudgetProgram, + Keypair, + LAMPORTS_PER_SOL, + PublicKey, SystemProgram, - Transaction + Transaction, } from "@solana/web3.js"; import chai, { assert, expect } from "chai"; import chaiHttp from "chai-http"; @@ -33,35 +36,31 @@ import fs from "fs"; import * as client from "../packages/distributor-oracle/src/client"; import { Database, - OracleServer + OracleServer, } from "../packages/distributor-oracle/src/server"; import { PROGRAM_ID as HEM_PID, init as initHeliumEntityManager, - keyToAssetKey + keyToAssetKey, } from "../packages/helium-entity-manager-sdk/src"; import { initializeCompressionRecipient, init as initLazy, - PROGRAM_ID as LD_PID + PROGRAM_ID as LD_PID, } from "../packages/lazy-distributor-sdk/src"; import { init as initRewards, oracleSignerKey, - PROGRAM_ID as REWARDS_PID + PROGRAM_ID as REWARDS_PID, } from "../packages/rewards-oracle-sdk/src"; import { PROGRAM_ID as VSR_PID, - init as vsrInit + init as vsrInit, } from "../packages/voter-stake-registry-sdk/src"; import { HeliumEntityManager } from "../target/types/helium_entity_manager"; import { LazyDistributor } from "../target/types/lazy_distributor"; import { RewardsOracle } from "../target/types/rewards_oracle"; -import { - ensureLDIdl, - ensureHEMIdl, - initWorld -} from "./utils/fixtures"; +import { ensureLDIdl, ensureHEMIdl, initWorld } from "./utils/fixtures"; import { initVsr } from "./utils/vsr"; import { createMockCompression } from "./utils/compression"; @@ -107,13 +106,16 @@ export class DatabaseMock implements Database { async getBulkRewards(entityKeys: string[]): Promise> { let _this = this; - const res: Record = entityKeys.reduce((acc: Record, key) => { - acc[key] = Math.floor( - (_this.inMemHash.byHotspot[key]?.lifetimeRewards || 0) * - Math.pow(10, 8) - ).toString(); - return acc; - }, {}); + const res: Record = entityKeys.reduce( + (acc: Record, key) => { + acc[key] = Math.floor( + (_this.inMemHash.byHotspot[key]?.lifetimeRewards || 0) * + Math.pow(10, 8) + ).toString(); + return acc; + }, + {} + ); return res; } @@ -258,7 +260,7 @@ describe("distributor-oracle", () => { thresholdType: ThresholdType.Absolute as never, threshold: new anchor.BN(1000000000), }, - approver: oracleSignerKey()[0] + approver: oracleSignerKey()[0], }) .accounts({ rewardsMint, @@ -341,7 +343,11 @@ describe("distributor-oracle", () => { .signers([makerKeypair, eccVerifier]) .rpc({ skipPreflight: true }); - ({getAssetFn, getAssetProofFn, hotspot: asset} = await createMockCompression({ + ({ + getAssetFn, + getAssetProofFn, + hotspot: asset, + } = await createMockCompression({ collection: collection, dao, merkle: merkle, @@ -424,12 +430,14 @@ describe("distributor-oracle", () => { ); }); - it("should bulk sign transactions", async() => { + it("should bulk sign transactions", async () => { const unsigned = await client.formBulkTransactions({ program: ldProgram, rewardsOracleProgram: rewardsProgram, - getAssetFn, - getAssetProofFn, + getAssetBatchFn: async () => [(await getAssetFn())!], + getAssetProofBatchFn: async () => ({ + [asset.toBase58()]: (await getAssetProofFn())!, + }), rewards: [ { oracleKey: oracle.publicKey, @@ -441,7 +449,6 @@ describe("distributor-oracle", () => { lazyDistributor, skipOracleSign: true, }); - console.log(unsigned); const tx = await provider.wallet.signTransaction(unsigned[0]); const serializedTx = tx.serialize({ requireAllSignatures: false, @@ -453,7 +460,7 @@ describe("distributor-oracle", () => { .post("/bulk-sign") .send({ transactions: [[...serializedTx]] }); - console.log(res.body) + console.log(res.body); assert.hasAllKeys(res.body, ["transactions", "success"]); const signedTx = Transaction.from(res.body.transactions[0].data); await sendAndConfirmWithRetry( @@ -470,7 +477,7 @@ describe("distributor-oracle", () => { recipientAcc.totalRewards.toNumber(), Number(await oracleServer.db.getCurrentRewards(asset)) ); - }) + }); it("should sign and execute properly formed transactions", async () => { const unsigned = await client.formTransaction({ diff --git a/tests/helium-entity-manager.ts b/tests/helium-entity-manager.ts index 56b5003ab..5383dbe09 100644 --- a/tests/helium-entity-manager.ts +++ b/tests/helium-entity-manager.ts @@ -509,7 +509,7 @@ describe("helium-entity-manager", () => { let tx = await hemProgram.methods .issueEntityV0({ - entityKey: Buffer.from(bs58.decode(eccKey)), + entityKey: Buffer.from(bs58.decode(eccKey!)), }) .preInstructions([ ComputeBudgetProgram.setComputeUnitLimit({ units: 350000 }), diff --git a/yarn.lock b/yarn.lock index ca55e0bd9..1fa08b06b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -724,6 +724,22 @@ dependencies: "@hapi/hoek" "^9.0.0" +"@helium/account-fetch-cache-hooks@^0.2.21", "@helium/account-fetch-cache-hooks@^0.2.5": + version "0.2.21" + resolved "https://registry.yarnpkg.com/@helium/account-fetch-cache-hooks/-/account-fetch-cache-hooks-0.2.21.tgz#c957838d0f5767db0e7425e968fa7facc512ac4c" + integrity sha512-oYzYCmdlo3b2GL8XM5Bs6NzBcCQGF9TJggNyxaCNNnHfe0Pobvexf8jBHTPzijebNyXTpyKcvzIzPXD7WUqlYg== + dependencies: + "@helium/account-fetch-cache" "^0.2.21" + "@solana/web3.js" "^1.66.2" + react-async-hook "^4.0.0" + +"@helium/account-fetch-cache@^0.2.21", "@helium/account-fetch-cache@^0.2.5": + version "0.2.21" + resolved "https://registry.yarnpkg.com/@helium/account-fetch-cache/-/account-fetch-cache-0.2.21.tgz#a7aab7d9e32de14ea6d55cc239c33ab5513b6a62" + integrity sha512-aOtM/BkTGOUKh608MsoqS41kpGBcdmklFOCrJR2D/3eFWoVAyjNoyEaMAg5AMVFvEvIZ7ulGSAd7SXQnVbxO4w== + dependencies: + "@solana/web3.js" "^1.43.4" + "@helium/address@^4.10.2": version "4.10.2" resolved "https://registry.yarnpkg.com/@helium/address/-/address-4.10.2.tgz#56960b118fceb6b6ddabe3e4ecec467d9ae50e26" @@ -733,6 +749,14 @@ js-sha256 "^0.9.0" multiformats "^9.6.4" +"@helium/anchor-resolvers@^0.2.5": + version "0.2.21" + resolved "https://registry.yarnpkg.com/@helium/anchor-resolvers/-/anchor-resolvers-0.2.21.tgz#8cd13bca3e7af83ffff3ab754dcf9f788d26e57e" + integrity sha512-rz3GJaULGmokjrq63v4sy683PMUkL31jrK5wVX01tzCYbI1woC9vISoPd3oSSuauZqQXdBhhQ49GKrpzi49JbA== + dependencies: + "@solana/spl-token" "^0.3.6" + "@solana/web3.js" "^1.43.4" + "@helium/crypto@^3.60.0": version "3.60.0" resolved "https://registry.yarnpkg.com/@helium/crypto/-/crypto-3.60.0.tgz#58be74745d0c7cc3198481dc69f5530393fc7287" @@ -751,6 +775,20 @@ create-hash "^1.2.0" libsodium-wrappers "^0.7.6" +"@helium/helium-react-hooks@^0.2.5": + version "0.2.21" + resolved "https://registry.yarnpkg.com/@helium/helium-react-hooks/-/helium-react-hooks-0.2.21.tgz#84b82b83602c20cae4a96c790786bb4b84e32530" + integrity sha512-c+U6TB+D+pww8awYvf7WtfY285FhbiUDGhE8KVEU8Y2RBHA39gE2F13Y0oSCj4RQfjGynv60ONCVc7PEkOqmsw== + dependencies: + "@coral-xyz/anchor" "^0.26.0" + "@helium/account-fetch-cache" "^0.2.21" + "@helium/account-fetch-cache-hooks" "^0.2.21" + "@solana/spl-token" "^0.3.6" + "@solana/web3.js" "^1.66.2" + bs58 "^5.0.0" + pako "^2.0.3" + react-async-hook "^4.0.0" + "@helium/modular-governance-hooks@^0.0.2": version "0.0.2" resolved "https://registry.yarnpkg.com/@helium/modular-governance-hooks/-/modular-governance-hooks-0.0.2.tgz#cbc51b2ae15c260614406cce092749883addd3a0" @@ -4353,22 +4391,6 @@ avvio@^8.2.1: debug "^4.0.0" fastq "^1.6.1" -aws-sdk@^2.1313.0: - version "2.1455.0" - resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1455.0.tgz#d4b98912e54ffdc06e868287d87c8bc6b4c3f00a" - integrity sha512-OCH3YcWZ1mqePNRcOxvnB4F270++X44K+/cKA7op2HYRKjTkIJjFVqJGVdMDPQAHlc0GTCKYD6CJOUEhR2pp7w== - dependencies: - buffer "4.9.2" - events "1.1.1" - ieee754 "1.1.13" - jmespath "0.16.0" - querystring "0.2.0" - sax "1.2.1" - url "0.10.3" - util "^0.12.4" - uuid "8.0.0" - xml2js "0.5.0" - aws-sdk@^2.1344.0: version "2.1448.0" resolved "https://registry.yarnpkg.com/aws-sdk/-/aws-sdk-2.1448.0.tgz#13d961afd7c4498d5b4af561118cd80eadee078d" @@ -6545,28 +6567,6 @@ fastify@^4.13.0: semver "^7.5.0" tiny-lru "^11.0.1" -fastify@^4.9.2: - version "4.23.0" - resolved "https://registry.yarnpkg.com/fastify/-/fastify-4.23.0.tgz#e49c4e90f0f6f9a2dd40b2443fce24b7bee86a2f" - integrity sha512-u4aQUjAqf+GQQI+IeIJtzOKCJHtdwPlGxzopq/Kv6QcEdJ7xuJFSQ5Bi7+uJ+F8990jWECLzRcAyZ4pVsloRpQ== - dependencies: - "@fastify/ajv-compiler" "^3.5.0" - "@fastify/error" "^3.2.0" - "@fastify/fast-json-stringify-compiler" "^4.3.0" - abstract-logging "^2.0.1" - avvio "^8.2.1" - fast-content-type-parse "^1.0.0" - fast-json-stringify "^5.7.0" - find-my-way "^7.6.0" - light-my-request "^5.9.1" - pino "^8.12.0" - process-warning "^2.2.0" - proxy-addr "^2.0.7" - rfdc "^1.3.0" - secure-json-parse "^2.5.0" - semver "^7.5.0" - toad-cache "^3.2.0" - fastq@^1.6.0, fastq@^1.6.1: version "1.15.0" resolved "https://registry.yarnpkg.com/fastq/-/fastq-1.15.0.tgz#d04d07c6a2a68fe4599fea8d2e103a937fae6b3a" @@ -11424,11 +11424,6 @@ to-regex-range@^5.0.1: dependencies: is-number "^7.0.0" -toad-cache@^3.2.0: - version "3.2.0" - resolved "https://registry.yarnpkg.com/toad-cache/-/toad-cache-3.2.0.tgz#8221a1906ce7bd18cd56b22f5603bcf9e38b54f9" - integrity sha512-Hj5zSqBS6OHbZoQk9IU8VqIr+0JUpwzunnwSlFJhG8aJSInYUMEuzItl3kJsGteTPd1qtflafdRHlRtUazYeqg== - toidentifier@1.0.1: version "1.0.1" resolved "https://registry.yarnpkg.com/toidentifier/-/toidentifier-1.0.1.tgz#3be34321a88a820ed1bd80dfaa33e479fbb8dd35"