Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

estimate and set CU budget and priortiy fee #44

Merged
merged 11 commits into from
Apr 1, 2024
1 change: 1 addition & 0 deletions backend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
"@cosmjs/crypto": "^0.32.3",
"@cosmjs/encoding": "^0.32.3",
"@influxdata/influxdb-client": "^1.33.2",
"@solana/spl-token": "^0.4.3",
"@solana/web3.js": "^1.91.1",
"bs58": "^5.0.0",
"hi-base32": "^0.5.1",
Expand Down
6 changes: 4 additions & 2 deletions backend/src/utils/fund-transactions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import {
TransactionInstruction,
VersionedTransaction
} from '@solana/web3.js'
import * as splToken from '@solana/spl-token'
import { coder } from '../token-dispenser'

import config from '../config'
Expand Down Expand Up @@ -58,7 +59,8 @@ async function loadWhitelistedProgramIds(): Promise<PublicKey[]> {
tokenDispenserPublicKey,
Secp256k1Program.programId,
Ed25519Program.programId,
ComputeBudgetProgram.programId
ComputeBudgetProgram.programId,
splToken.ASSOCIATED_TOKEN_PROGRAM_ID
]
}

Expand Down Expand Up @@ -140,7 +142,7 @@ export function checkSetComputeBudgetInstructionsAreSetComputeUnitPrice(
const priorityFee = ComputeBudgetInstruction.decodeSetComputeUnitPrice(
legacTransactionInstruction
)
if (priorityFee.microLamports >= MAX_COMPUTE_UNIT_PRICE) {
if (priorityFee.microLamports > MAX_COMPUTE_UNIT_PRICE) {
console.error('Priority fee set is too high')
return false
}
Expand Down
184 changes: 182 additions & 2 deletions backend/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1679,13 +1679,178 @@
"@smithy/util-buffer-from" "^2.2.0"
tslib "^2.6.2"

"@solana/buffer-layout@^4.0.1":
"@solana/buffer-layout-utils@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca"
integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==
dependencies:
"@solana/buffer-layout" "^4.0.0"
"@solana/web3.js" "^1.32.0"
bigint-buffer "^1.1.5"
bignumber.js "^9.0.1"

"@solana/buffer-layout@^4.0.0", "@solana/buffer-layout@^4.0.1":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15"
integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==
dependencies:
buffer "~6.0.3"

"@solana/codecs-core@2.0.0-experimental.8618508":
version "2.0.0-experimental.8618508"
resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.0.0-experimental.8618508.tgz#4f6709dd50e671267f3bea7d09209bc6471b7ad0"
integrity sha512-JCz7mKjVKtfZxkuDtwMAUgA7YvJcA2BwpZaA1NOLcted4OMC4Prwa3DUe3f3181ixPYaRyptbF0Ikq2MbDkYEA==

"@solana/codecs-core@2.0.0-preview.2":
version "2.0.0-preview.2"
resolved "https://registry.yarnpkg.com/@solana/codecs-core/-/codecs-core-2.0.0-preview.2.tgz#689784d032fbc1fedbde40bb25d76cdcecf6553b"
integrity sha512-gLhCJXieSCrAU7acUJjbXl+IbGnqovvxQLlimztPoGgfLQ1wFYu+XJswrEVQqknZYK1pgxpxH3rZ+OKFs0ndQg==
dependencies:
"@solana/errors" "2.0.0-preview.2"

"@solana/codecs-data-structures@2.0.0-experimental.8618508":
version "2.0.0-experimental.8618508"
resolved "https://registry.yarnpkg.com/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-experimental.8618508.tgz#c16a704ac0f743a2e0bf73ada42d830b3402d848"
integrity sha512-sLpjL9sqzaDdkloBPV61Rht1tgaKq98BCtIKRuyscIrmVPu3wu0Bavk2n/QekmUzaTsj7K1pVSniM0YqCdnEBw==
dependencies:
"@solana/codecs-core" "2.0.0-experimental.8618508"
"@solana/codecs-numbers" "2.0.0-experimental.8618508"

"@solana/codecs-data-structures@2.0.0-preview.2":
version "2.0.0-preview.2"
resolved "https://registry.yarnpkg.com/@solana/codecs-data-structures/-/codecs-data-structures-2.0.0-preview.2.tgz#e82cb1b6d154fa636cd5c8953ff3f32959cc0370"
integrity sha512-Xf5vIfromOZo94Q8HbR04TbgTwzigqrKII0GjYr21K7rb3nba4hUW2ir8kguY7HWFBcjHGlU5x3MevKBOLp3Zg==
dependencies:
"@solana/codecs-core" "2.0.0-preview.2"
"@solana/codecs-numbers" "2.0.0-preview.2"
"@solana/errors" "2.0.0-preview.2"

"@solana/codecs-numbers@2.0.0-experimental.8618508":
version "2.0.0-experimental.8618508"
resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.0.0-experimental.8618508.tgz#d84f9ed0521b22e19125eefc7d51e217fcaeb3e4"
integrity sha512-EXQKfzFr3CkKKNzKSZPOOOzchXsFe90TVONWsSnVkonO9z+nGKALE0/L9uBmIFGgdzhhU9QQVFvxBMclIDJo2Q==
dependencies:
"@solana/codecs-core" "2.0.0-experimental.8618508"

"@solana/codecs-numbers@2.0.0-preview.2":
version "2.0.0-preview.2"
resolved "https://registry.yarnpkg.com/@solana/codecs-numbers/-/codecs-numbers-2.0.0-preview.2.tgz#56995c27396cd8ee3bae8bd055363891b630bbd0"
integrity sha512-aLZnDTf43z4qOnpTcDsUVy1Ci9im1Md8thWipSWbE+WM9ojZAx528oAql+Cv8M8N+6ALKwgVRhPZkto6E59ARw==
dependencies:
"@solana/codecs-core" "2.0.0-preview.2"
"@solana/errors" "2.0.0-preview.2"

"@solana/codecs-strings@2.0.0-experimental.8618508":
version "2.0.0-experimental.8618508"
resolved "https://registry.yarnpkg.com/@solana/codecs-strings/-/codecs-strings-2.0.0-experimental.8618508.tgz#72457b884d9be80b59b263bcce73892b081e9402"
integrity sha512-b2yhinr1+oe+JDmnnsV0641KQqqDG8AQ16Z/x7GVWO+AWHMpRlHWVXOq8U1yhPMA4VXxl7i+D+C6ql0VGFp0GA==
dependencies:
"@solana/codecs-core" "2.0.0-experimental.8618508"
"@solana/codecs-numbers" "2.0.0-experimental.8618508"

"@solana/codecs-strings@2.0.0-preview.2":
version "2.0.0-preview.2"
resolved "https://registry.yarnpkg.com/@solana/codecs-strings/-/codecs-strings-2.0.0-preview.2.tgz#8bd01a4e48614d5289d72d743c3e81305d445c46"
integrity sha512-EgBwY+lIaHHgMJIqVOGHfIfpdmmUDNoNO/GAUGeFPf+q0dF+DtwhJPEMShhzh64X2MeCZcmSO6Kinx0Bvmmz2g==
dependencies:
"@solana/codecs-core" "2.0.0-preview.2"
"@solana/codecs-numbers" "2.0.0-preview.2"
"@solana/errors" "2.0.0-preview.2"

"@solana/codecs@2.0.0-preview.2":
version "2.0.0-preview.2"
resolved "https://registry.yarnpkg.com/@solana/codecs/-/codecs-2.0.0-preview.2.tgz#d6615fec98f423166fb89409f9a4ad5b74c10935"
integrity sha512-4HHzCD5+pOSmSB71X6w9ptweV48Zj1Vqhe732+pcAQ2cMNnN0gMPMdDq7j3YwaZDZ7yrILVV/3+HTnfT77t2yA==
dependencies:
"@solana/codecs-core" "2.0.0-preview.2"
"@solana/codecs-data-structures" "2.0.0-preview.2"
"@solana/codecs-numbers" "2.0.0-preview.2"
"@solana/codecs-strings" "2.0.0-preview.2"
"@solana/options" "2.0.0-preview.2"

"@solana/errors@2.0.0-preview.2":
version "2.0.0-preview.2"
resolved "https://registry.yarnpkg.com/@solana/errors/-/errors-2.0.0-preview.2.tgz#e0ea8b008c5c02528d5855bc1903e5e9bbec322e"
integrity sha512-H2DZ1l3iYF5Rp5pPbJpmmtCauWeQXRJapkDg8epQ8BJ7cA2Ut/QEtC3CMmw/iMTcuS6uemFNLcWvlOfoQhvQuA==
dependencies:
chalk "^5.3.0"
commander "^12.0.0"

"@solana/options@2.0.0-experimental.8618508":
version "2.0.0-experimental.8618508"
resolved "https://registry.yarnpkg.com/@solana/options/-/options-2.0.0-experimental.8618508.tgz#95385340e85f9e8a81b2bfba089404a61c8e9520"
integrity sha512-fy/nIRAMC3QHvnKi63KEd86Xr/zFBVxNW4nEpVEU2OT0gCEKwHY4Z55YHf7XujhyuM3PNpiBKg/YYw5QlRU4vg==
dependencies:
"@solana/codecs-core" "2.0.0-experimental.8618508"
"@solana/codecs-numbers" "2.0.0-experimental.8618508"

"@solana/options@2.0.0-preview.2":
version "2.0.0-preview.2"
resolved "https://registry.yarnpkg.com/@solana/options/-/options-2.0.0-preview.2.tgz#13ff008bf43a5056ef9a091dc7bb3f39321e867e"
integrity sha512-FAHqEeH0cVsUOTzjl5OfUBw2cyT8d5Oekx4xcn5hn+NyPAfQJgM3CEThzgRD6Q/4mM5pVUnND3oK/Mt1RzSE/w==
dependencies:
"@solana/codecs-core" "2.0.0-preview.2"
"@solana/codecs-numbers" "2.0.0-preview.2"

"@solana/spl-token-group@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@solana/spl-token-group/-/spl-token-group-0.0.2.tgz#23f754fd535a4df5e2b80293a03aabd58bd99167"
integrity sha512-vLePrFvT9+PfK2KZaddPebTWtRykXUR+060gqomFUcBk/2UPpZtsJGW+xshI9z9Ryrx7FieprZEUCApw34BwrQ==
dependencies:
"@solana/codecs" "2.0.0-preview.2"
"@solana/spl-type-length-value" "0.1.0"

"@solana/spl-token-metadata@^0.1.2":
version "0.1.2"
resolved "https://registry.yarnpkg.com/@solana/spl-token-metadata/-/spl-token-metadata-0.1.2.tgz#876e13432bd2960bd3cac16b9b0af63e69e37719"
integrity sha512-hJYnAJNkDrtkE2Q41YZhCpeOGU/0JgRFXbtrtOuGGeKc3pkEUHB9DDoxZAxx+XRno13GozUleyBi0qypz4c3bw==
dependencies:
"@solana/codecs-core" "2.0.0-experimental.8618508"
"@solana/codecs-data-structures" "2.0.0-experimental.8618508"
"@solana/codecs-numbers" "2.0.0-experimental.8618508"
"@solana/codecs-strings" "2.0.0-experimental.8618508"
"@solana/options" "2.0.0-experimental.8618508"
"@solana/spl-type-length-value" "0.1.0"

"@solana/spl-token@^0.4.3":
version "0.4.3"
resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.4.3.tgz#cb923184fcba3f875f5914a440a68d7f537d0bac"
integrity sha512-mRjJJE9CIBejsg9WAmDp369pWeObm42K2fwsZ4dkJAMCt1KBPb5Eb1vzM5+AYfV/BUTy3QP2oFx8kV+8Doa1xQ==
dependencies:
"@solana/buffer-layout" "^4.0.0"
"@solana/buffer-layout-utils" "^0.2.0"
"@solana/spl-token-group" "^0.0.2"
"@solana/spl-token-metadata" "^0.1.2"
buffer "^6.0.3"

"@solana/spl-type-length-value@0.1.0":
version "0.1.0"
resolved "https://registry.yarnpkg.com/@solana/spl-type-length-value/-/spl-type-length-value-0.1.0.tgz#b5930cf6c6d8f50c7ff2a70463728a4637a2f26b"
integrity sha512-JBMGB0oR4lPttOZ5XiUGyvylwLQjt1CPJa6qQ5oM+MBCndfjz2TKKkw0eATlLLcYmq1jBVsNlJ2cD6ns2GR7lA==
dependencies:
buffer "^6.0.3"

"@solana/web3.js@^1.32.0":
version "1.91.3"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.91.3.tgz#25b8b9dfd88bfa6441c0c02bbdb67abd32bfa0f4"
integrity sha512-Z6FZyW8SWm7RXW5ZSyr1kmpR+eH/F4DhgxV4WPaq5AbAAMnCiiGm36Jb7ACHFXtWzq1a24hBkJ1wnVANjsmdPA==
dependencies:
"@babel/runtime" "^7.23.4"
"@noble/curves" "^1.2.0"
"@noble/hashes" "^1.3.3"
"@solana/buffer-layout" "^4.0.1"
agentkeepalive "^4.5.0"
bigint-buffer "^1.1.5"
bn.js "^5.2.1"
borsh "^0.7.0"
bs58 "^4.0.1"
buffer "6.0.3"
fast-stable-stringify "^1.0.0"
jayson "^4.1.0"
node-fetch "^2.7.0"
rpc-websockets "^7.5.1"
superstruct "^0.14.2"

"@solana/web3.js@^1.68.0", "@solana/web3.js@^1.91.1":
version "1.91.1"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.91.1.tgz#d49d2f982b52070be3b987fd8d892fcbddd064b5"
Expand Down Expand Up @@ -2549,6 +2714,11 @@ bigint-buffer@^1.1.5:
dependencies:
bindings "^1.3.0"

bignumber.js@^9.0.1:
version "9.1.2"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.2.tgz#b7c4242259c008903b13707983b5f4bbd31eda0c"
integrity sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==

bin-check@^4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/bin-check/-/bin-check-4.1.0.tgz#fc495970bdc88bb1d5a35fc17e65c4a149fc4a49"
Expand Down Expand Up @@ -2705,7 +2875,7 @@ buffer-layout@^1.2.0, buffer-layout@^1.2.2:
resolved "https://registry.yarnpkg.com/buffer-layout/-/buffer-layout-1.2.2.tgz#b9814e7c7235783085f9ca4966a0cfff112259d5"
integrity sha512-kWSuLN694+KTk8SrYvCqwP2WcgQjoRCiF5b4QDvkkz8EmgD+aWAIceGFKMIAdmF/pH+vpgNV3d3kAKorcdAmWA==

buffer@6.0.3, buffer@~6.0.3:
buffer@6.0.3, buffer@^6.0.3, buffer@~6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
Expand Down Expand Up @@ -2809,6 +2979,11 @@ chalk@^4.0.0, chalk@^4.1.2:
ansi-styles "^4.1.0"
supports-color "^7.1.0"

chalk@^5.3.0:
version "5.3.0"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-5.3.0.tgz#67c20a7ebef70e7f3970a01f90fa210cb6860385"
integrity sha512-dLitG79d+GV1Nb/VYcCDFivJeK1hiukt9QjRNVOsUtTy1rR1YJsmpGGTZ3qJos+uw7WmWF4wUwBd9jxjocFC2w==

char-regex@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/char-regex/-/char-regex-1.0.2.tgz#d744358226217f981ed58f479b1d6bcc29545dcf"
Expand Down Expand Up @@ -2894,6 +3069,11 @@ colorette@^2.0.20:
resolved "https://registry.yarnpkg.com/colorette/-/colorette-2.0.20.tgz#9eb793e6833067f7235902fcd3b09917a000a95a"
integrity sha512-IfEDxwoWIjkeXL1eXcDiow4UbKjhLdq6/EuSVR9GMN7KVH3r9gQ83e73hsz1Nd1T3ijd5xv1wcWRYO+D6kCI2w==

commander@^12.0.0:
version "12.0.0"
resolved "https://registry.yarnpkg.com/commander/-/commander-12.0.0.tgz#b929db6df8546080adfd004ab215ed48cf6f2592"
integrity sha512-MwVNWlYjDTtOjX5PiD7o5pK0UrFU/OYgcJfjjK4RaHZETNtjJqrZa9Y9ds88+A+f+d5lv+561eZ+yCKoS3gbAA==

commander@^2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
Expand Down
41 changes: 16 additions & 25 deletions frontend/claim_sdk/claim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,7 @@ import { ethers } from 'ethers'
import { base32decode, removeLeading0x } from './index'

// Must be kept in line with the database types and the on-chain program
export type Ecosystem =
| 'discord'
| 'solana'
| 'evm'
| 'sui'
| 'algorand'
| 'aptos'
| 'terra'
| 'osmosis'
| 'injective'
export const Ecosystems: Ecosystem[] = [
export const Ecosystems = [
'discord',
'solana',
'evm',
Expand All @@ -25,7 +15,8 @@ export const Ecosystems: Ecosystem[] = [
'terra',
'osmosis',
'injective',
]
] as const
export type Ecosystem = typeof Ecosystems[number]

export class ClaimInfo {
constructor(
Expand Down Expand Up @@ -56,16 +47,11 @@ export class ClaimInfo {
}
break
}
case 'osmosis':
case 'terra': {
identityStruct = {
cosmwasm: { address: this.identity },
}
break
}
case 'injective': {
case 'sui': {
identityStruct = {
injective: { address: this.identity },
sui: {
address: Buffer.from(removeLeading0x(this.identity), 'hex'),
},
}
break
}
Expand All @@ -77,11 +63,16 @@ export class ClaimInfo {
}
break
}
case 'sui': {
case 'terra':
case 'osmosis': {
identityStruct = {
sui: {
address: Buffer.from(removeLeading0x(this.identity), 'hex'),
},
cosmwasm: { address: this.identity },
}
break
}
case 'injective': {
identityStruct = {
injective: { address: this.identity },
}
break
}
Expand Down
Loading
Loading