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

STREAM-1123: distributor client #131

Merged
merged 28 commits into from
Mar 5, 2024

Conversation

Yolley
Copy link
Collaborator

@Yolley Yolley commented Feb 13, 2024

  • add distributor package with create/claim/clawback methods for now
  • separate check or create ATAs into an util
  • remove docs from repo, move to CI
  • add common package with common utilities
  • add more exports for all modules
  • move to pnpm as it works better with workspaces

Comment on lines 343 to 350
for (let i = 0; i < response.length; i++) {
if (!response[i]) {
ixs.push(
createAssociatedTokenAccountInstruction(invoker.publicKey!, atas[i], owners[i], mint)
);
}
}
return ixs;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno, is it an optimization or not, but as an option again 😄

Suggested change
for (let i = 0; i < response.length; i++) {
if (!response[i]) {
ixs.push(
createAssociatedTokenAccountInstruction(invoker.publicKey!, atas[i], owners[i], mint)
);
}
}
return ixs;
return response.reduce((result, responseItem) => {
if (!responseItem) {
result.push(createAssociatedTokenAccountInstruction(invoker.publicKey!, atas[i], owners[i], mint));
return result;
}
return result;
}, [];

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I dunno, is it an optimization or not, but as an option again 😄

It's harder to read. 🌚

packages/stream/solana/index.ts Outdated Show resolved Hide resolved
Comment on lines 65 to 66
clusterUrl,
cluster = ICluster.Mainnet,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

When I touched our js-sdk api for the first time I had an issue with this setup.
As clusterUrl and cluster are separated, it wasn't obvious for me that I have to pass them both when I switch to ``devnet` for instance. Probably we should combine them to an one parameter?

like

type ClusterConnectionInput = {
  clusterUrl: string,
  cluster: <some predefined union type>
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, the idea is that you can't really extra cluster from URL, so that's why you send them both. And I mean they are part of the constuctors, what's the problem? We can rename it to clusterType if it makes it more obvious. I am opposed to adding extra types, especially in costructors.

Comment on lines 86 to 89
const mintAccount = await getMint(this.connection, mint);
const distributorPublicKey = getDistributorPda(this.programId, mint, data.version);
const tokenVault = await ata(mint, distributorPublicKey);
const senderTokens = await ata(mint, sender.publicKey);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we somehow make these requests in parallel?
All this RPC calls can be slow as we see always 😄

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we somehow make these requests in parallel? All this RPC calls can be slow as we see always 😄

Seems like it requires refactoring through the whole sdk then as we do all these calls in our core client also.

@Yolley Yolley force-pushed the oleg/feature/STREAM-1123_distributor_integration branch from 488a82f to b37a381 Compare February 21, 2024 06:44
.github/workflows/docs.yml Show resolved Hide resolved
packages/distributor/.eslintrc Show resolved Hide resolved
@@ -25,12 +49,13 @@
"jest": "29.3.1",
"prettier": "2.8.1",
"ts-jest": "29.0.3",
"typescript": "4.6.4"
"typescript": "^4.9.5"
},
"dependencies": {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thinking about one package.json per repo. Will it be easier to manage cross-package dependencies sync in this case? 3rd parties like @solana/x, bn.js etc should be the same across all packages?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand, lerna promotes each package having their dependencies listed individually within its own package.json. By looking at other monorepoes like https://github.com/suiet/wallet-kit or https://github.com/aptos-labs/aptos-wallet-adapter/tree/main I see that they also for every package list its own dependencies, even if they are shared across multiple packages.

@@ -1,6 +1,6 @@
import { Wallet } from "ethers";

import { StreamflowAptos, StreamflowEVM, StreamflowSolana, StreamflowSui } from "../../";
import { StreamflowAptos, StreamflowEVM, StreamflowSolana, StreamflowSui } from "../../index";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🤔 auto-refactoring feature replaced it? btw shouldn't be required

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There was a problem with running tests locally when dist was built, so I decided just to import from index here.

return this.client.signAndExecuteTransactionBlock({
...input,
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what error do you have here?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are several sui.js library versions provided from different libraries and that makes it error out here. Basically we need to get rid of manahipppo/aptos-wallet-adapter to get rid of older versions, but it's a huge refactoring, not part of this feature.

signer: this.wallet,
});
}
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

and here

packages/common/.npmignore Show resolved Hide resolved
@Yolley Yolley force-pushed the oleg/feature/STREAM-1123_distributor_integration branch from 3a4612c to b3264d5 Compare February 23, 2024 06:53
@Yolley Yolley merged commit 5b1627a into master Mar 5, 2024
2 checks passed
@Yolley Yolley deleted the oleg/feature/STREAM-1123_distributor_integration branch March 5, 2024 17:17
Copy link

github-actions bot commented Mar 6, 2024

1 similar comment
Copy link

github-actions bot commented Mar 6, 2024

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants