saber-hq / saber-common Goto Github PK
View Code? Open in Web Editor NEW๐ก Saber common utilities and libraries
Home Page: https://saber-hq.github.io/saber-common/
License: Apache License 2.0
๐ก Saber common utilities and libraries
Home Page: https://saber-hq.github.io/saber-common/
License: Apache License 2.0
hi, any idea about this error?
program is a AnchorTypes from @saberhq/anchor-contrib.
this.program.instruction.update(new anchor.BN(timestampNow), null, {
accounts: {
activityMaster: activityMasterKey,
authority: authority.publicKey,
},
}),
Argument of type '[any, null, { accounts: { activityMaster: PublicKey; authority: PublicKey; }; }]' is not assignable to parameter of type '[...any[], Context<[{ name: "activityMaster"; isMut: true; isSigner: false; }, { name: "authority"; isMut: false; isSigner: true; }]>]'.
Type at position 2 in source is not compatible with type at position 1 in target.
Type '{ accounts: { activityMaster: PublicKey; authority: PublicKey; }; }' is not assignable to type 'Context<[{ name: "activityMaster"; isMut: true; isSigner: false; }, { name: "authority"; isMut: false; isSigner: true; }]>'.
Type '{ accounts: { activityMaster: PublicKey; authority: PublicKey; }; }' is not assignable to type '{ accounts: ContextAccounts<[{ name: "activityMaster"; isMut: true; isSigner: false; }, { name: "authority"; isMut: false; isSigner: true; }]>; }'.
The types of 'accounts.authority' are incompatible between these types.
Type 'PublicKey' is not assignable to type 'ContextAccounts<any>'.
the idl is:
{
name: "update",
accounts: [
{
name: "activityMaster",
isMut: true,
isSigner: false
},
{
name: "authority",
isMut: false,
isSigner: true
}
],
args: [
{
name: "openRewardTimestamp",
type: "i64"
},
{
name: "url",
type: {
option: "string"
}
}
]
},
I'm getting the error below while trying to build a project that has anchor-contrib as a dependency. Any ideas?
node_modules/@saberhq/solana-contrib/dist/cjs/transaction/PendingTransaction.d.ts:7:49 - error TS2312: An interface can only extend an object type or intersection of object types with statically known members.
7 export interface TransactionWaitOptions extends OperationOptions {
~~~~~~~~~~~~~~~~
Found 1 error in node_modules/@saberhq/solana-contrib/dist/cjs/transaction/PendingTransaction.d.ts:7
Add support for the Trust Wallet adapter.
The Provider should know the network it is on, so explorer utils can properly compute the URLs
Would be nice to have this as a type in my project!
Hi Ian, do you know if it's possible to get walletconnect support? It seems like adapter was set up a month ago. I would be happy to create a PR but it seems that because it the adapter accepts nonstandard options such as a projectId
field, it's slightly nontrivial to integrate (happy to take a stab). The use case I have is for fireblocks support.
The AnchorTypes method
works as expected for instructions. However, for methods it looks for a method field which is not present in the idl. Could consider using anchors way of generating the methods type from the idl.
I didn't try to root cause this one. But here's a way to reproduce:
Try to get the SOL balance for an account.
useAccountData()
will give the proper lamports after a sail refetch
but
useParsedAccountData()
will have the stale lamports
Add support for the Torus Solana wallet adapter.
Transactions should be sent multiple times in the event that the cluster does not propagate them
Try quoting an 8 decimal token by a 6 decimal token. The result will be greater by 2 orders of magnitude than actual
I'm getting an issue using the stableswap-sdk.
import { loadExchangeInfoFromSwapAccount, SWAP_PROGRAM_ID } from "@saberhq/stableswap-sdk";
Simply importing anything that imports stableswap-sdk/src/instructions/layouts.ts
fails with this error:
/Users/andrew/w/x/node_modules/@solana/buffer-layout/lib/Layout.js:999
throw new TypeError('fields must be array of Layout instances');
^
TypeError: fields must be array of Layout instances
at new Structure (/Users/andrew/w/x/node_modules/@solana/buffer-layout/lib/Layout.js:999:19)
at Object.exports.struct (/Users/andrew/w/x/node_modules/@solana/buffer-layout/lib/Layout.js:2373:57)
at Object.<anonymous> (/Users/andrew/w/x/node_modules/@saberhq/stableswap-sdk/dist/cjs/state/layout.js:10:35)
at Module._compile (node:internal/modules/cjs/loader:1097:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1149:10)
at Module.load (node:internal/modules/cjs/loader:975:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/andrew/w/x/node_modules/@saberhq/stableswap-sdk/dist/cjs/instructions/layouts.js:7:18)
solana-labs/solana-program-library#2683 suggests it's a package version issue.
I have
"@saberhq/stableswap-sdk": "^1.12.44",
"@solana/buffer-layout": "^4.0.0",
"@solana/spl-token": "^0.1.8",
"@solana/web3.js": "^1.34.0"
in my package.json.
Any idea what the issue is?
How do I fix Invalid Chai property: eventually
when running tests using chai-solana? Anyone experienced this before?
I noticed that token-utils
have es6 module
export in the package.json but not stableswap-sdk. Can we add it in? Seems to be a quick win for bundling.
@saber-hq/use-solana
often tries to connect to a wallet too early, before it's ready, and ends up giving a WalletNotReadyError
.
We may want to change this code to use retries instead of just waiting for 1 second, particularly if a WalletNotReadyError
is thrown:
saber-common/packages/use-solana/src/utils/useWalletInternal.ts
Lines 128 to 132 in 05bf414
TypeError: Blob.encode[amount] requires (length 8) Buffer as src
at Blob.encode (node_modules/buffer-layout/lib/Layout.js:2321:13)
at Structure.encode (node_modules/buffer-layout/lib/Layout.js:1263:26)
at Function.createMintToInstruction (node_modules/@solana/spl-token/client/token.js:1745:16)
getRecentBlockhash should use a proper hash to reduce rejections by the cluster
The stableswap-sdk code describes the swapAccount
parameter as "The public key identifying this instance of the Stable Swap."
Where can I find a mapping of pool pairs to swapAccount public keys? (i.e. how do I find what swapAccount
to pass into methods like loadExchangeInfoFromSwapAccount
?)
should I just call getProgramAccounts
passing in the SWAP_PROGRAM_ID
? e.g.
curl https://api.mainnet-beta.solana.com -X POST -H "Content-Type: application/json" -d '
{
"jsonrpc": "2.0",
"id": 1,
"method": "getProgramAccounts",
"params": [
"SSwpkEEcbUqx4vtoEByFjSkhKdCT862DNVb52nZg1UZ",
{
"encoding": "base64"
}
]
}
'
Hi
solana-contrib is now just providing solana explorer link.
Can we add solscan link?
generateSolanaExplorerLink(cluster: Cluster = "mainnet-beta"): string {
return `https://explorer.solana.com/tx/${this.signature}?cluster=${cluster}`;
}
Hi, Saber Team,
I really like your work.
I am wondering whether saber exchange API is available. I want to use exchange API to pull some public data, such as available pools, TVL, etc. Also, I want to deposit / withdraw from the liquidity pools via API. Is this possible at the current stage?
looking forward to your response!
Thank you in advance!
export const parseAmountFromString = <Tk extends Token<Tk>>(
token: Tk,
uiAmount: string
): JSBI => {
const parts = uiAmount.split(".");
if (parts.length === 0) {
throw new Error("empty number");
}
invariant(parts[0]);
const whole = JSBI.BigInt(parts[0]);
I believe this is in the @ubeswap/token-math package. Instead of using split
, it may make sense to to just do a simple indexOf
on the .
Add support for the Ledger Solana wallet adapter.
node_modules/@saberhq/anchor-contrib/dist/cjs/utils/coder.d.ts:4:41 - error TS2307: Cannot find module '@project-serum/anchor/dist/cjs/coder/instruction' or its corresponding type declarations.
4 import type { InstructionDisplay } from "@project-serum/anchor/dist/cjs/coder/instruction";
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Found 1 error.
This is with anchor v0.21.0
and v1.12.43
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.