@streamflow/stream 3.0.3 → 3.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -9,8 +9,9 @@ export default class StreamClient {
9
9
  /**
10
10
  * Create Stream instance
11
11
  */
12
- constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig);
12
+ constructor(clusterUrl: string, cluster?: ClusterExtended, commitment?: Commitment | ConnectionConfig, programId?: string);
13
13
  getConnection(): web3.Connection;
14
+ getProgramId(): string;
14
15
  /**
15
16
  * Creates a new stream/vesting contract.
16
17
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -101,17 +101,24 @@ var StreamClient = /** @class */ (function () {
101
101
  /**
102
102
  * Create Stream instance
103
103
  */
104
- function StreamClient(clusterUrl, cluster, commitment) {
104
+ function StreamClient(clusterUrl, cluster, commitment, programId) {
105
105
  if (cluster === void 0) { cluster = types_1.Cluster.Mainnet; }
106
106
  if (commitment === void 0) { commitment = "confirmed"; }
107
+ if (programId === void 0) { programId = ""; }
107
108
  this.commitment = commitment;
108
109
  this.cluster = cluster;
109
110
  this.connection = new web3_js_1.Connection(clusterUrl, this.commitment);
110
111
  this.programId = new web3_js_1.PublicKey(constants_1.PROGRAM_ID[cluster]);
112
+ if (programId != "") {
113
+ this.programId = new web3_js_1.PublicKey(programId);
114
+ }
111
115
  }
112
116
  StreamClient.prototype.getConnection = function () {
113
117
  return this.connection;
114
118
  };
119
+ StreamClient.prototype.getProgramId = function () {
120
+ return this.programId.toBase58();
121
+ };
115
122
  /**
116
123
  * Creates a new stream/vesting contract.
117
124
  * All fees are paid by sender (escrow metadata account rent, escrow token account rent, recipient's associated token account rent, Streamflow's service fee).
@@ -618,10 +625,10 @@ var StreamClient = /** @class */ (function () {
618
625
  case 0:
619
626
  accounts = [];
620
627
  if (!(direction === "all")) return [3 /*break*/, 3];
621
- return [4 /*yield*/, getProgramAccounts(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_SENDER, this.cluster)];
628
+ return [4 /*yield*/, getProgramAccounts(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_SENDER, this.programId)];
622
629
  case 1:
623
630
  outgoingAccounts = _d.sent();
624
- return [4 /*yield*/, getProgramAccounts(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_RECIPIENT, this.cluster)];
631
+ return [4 /*yield*/, getProgramAccounts(this.connection, wallet, constants_1.STREAM_STRUCT_OFFSET_RECIPIENT, this.programId)];
625
632
  case 2:
626
633
  incomingAccounts = _d.sent();
627
634
  accounts = __spreadArray(__spreadArray([], __read(outgoingAccounts), false), __read(incomingAccounts), false);
@@ -630,7 +637,7 @@ var StreamClient = /** @class */ (function () {
630
637
  offset = direction === "outgoing"
631
638
  ? constants_1.STREAM_STRUCT_OFFSET_SENDER
632
639
  : constants_1.STREAM_STRUCT_OFFSET_RECIPIENT;
633
- return [4 /*yield*/, getProgramAccounts(this.connection, wallet, offset, this.cluster)];
640
+ return [4 /*yield*/, getProgramAccounts(this.connection, wallet, offset, this.programId)];
634
641
  case 4:
635
642
  accounts = _d.sent();
636
643
  _d.label = 5;
@@ -769,11 +776,10 @@ var StreamClient = /** @class */ (function () {
769
776
  return StreamClient;
770
777
  }());
771
778
  exports.default = StreamClient;
772
- function getProgramAccounts(connection, wallet, offset, cluster) {
773
- if (cluster === void 0) { cluster = types_1.Cluster.Mainnet; }
779
+ function getProgramAccounts(connection, wallet, offset, programId) {
774
780
  return __awaiter(this, void 0, void 0, function () {
775
781
  return __generator(this, function (_a) {
776
- return [2 /*return*/, connection === null || connection === void 0 ? void 0 : connection.getProgramAccounts(new web3_js_1.PublicKey(constants_1.PROGRAM_ID[cluster]), {
782
+ return [2 /*return*/, connection === null || connection === void 0 ? void 0 : connection.getProgramAccounts(programId, {
777
783
  filters: [
778
784
  {
779
785
  memcmp: {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@streamflow/stream",
3
- "version": "3.0.3",
3
+ "version": "3.0.6",
4
4
  "description": "JavaScript SDK to interact with Streamflow protocol.",
5
5
  "main": "dist/index.js",
6
6
  "homepage": "https://github.com/streamflow-finance/js-sdk/",