@zebec-network/zebec-stream-sdk 1.5.0 → 1.5.1

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.
@@ -1168,98 +1168,78 @@ export type ZebecStream = {
1168
1168
  },
1169
1169
  {
1170
1170
  code: 6006;
1171
- name: "unknownStreamFrequency";
1172
- msg: "Stream frequency not included in stream configuration";
1173
- },
1174
- {
1175
- code: 6007;
1176
- name: "durationNotExactlyDivisibleByFrequency";
1177
- msg: "Stream Duration is not exactly divisible by the frequency";
1178
- },
1179
- {
1180
- code: 6008;
1181
1171
  name: "insufficientSenderBalance";
1182
1172
  msg: "Sender does not have enough balance to create the stream";
1183
1173
  },
1184
1174
  {
1185
- code: 6009;
1175
+ code: 6007;
1186
1176
  name: "streamAlreadyCanceled";
1187
1177
  msg: "Stream Already Canceled";
1188
1178
  },
1189
1179
  {
1190
- code: 6010;
1180
+ code: 6008;
1191
1181
  name: "unauthorized";
1192
- msg: "Unauthorized: Only the allowed party can cancel the stream";
1182
+ msg: "unauthorized";
1193
1183
  },
1194
1184
  {
1195
- code: 6011;
1185
+ code: 6009;
1196
1186
  name: "notCancellable";
1197
1187
  msg: "Stream is not Cancellable";
1198
1188
  },
1199
1189
  {
1200
- code: 6012;
1190
+ code: 6010;
1201
1191
  name: "streamAlreadyWithdrawn";
1202
1192
  msg: "Stream has already been withdrawn";
1203
1193
  },
1204
1194
  {
1205
- code: 6013;
1195
+ code: 6011;
1206
1196
  name: "invalidReceiver";
1207
- msg: "UnAuthorized: Only the allowed party can transfer the stream";
1208
- },
1209
- {
1210
- code: 6014;
1211
- name: "streamAutoWithdrawable";
1212
- msg: "Stream is automatically withdrawable";
1197
+ msg: "Invalid receiver address";
1213
1198
  },
1214
1199
  {
1215
- code: 6015;
1200
+ code: 6012;
1216
1201
  name: "withdrawAmountExceeds";
1217
1202
  msg: "Withdraw amount exceeds the available amount in the stream";
1218
1203
  },
1219
1204
  {
1220
- code: 6016;
1205
+ code: 6013;
1221
1206
  name: "insufficientFundsToWithdraw";
1222
1207
  msg: "Insufficient funds in the stream vault for withdrawal";
1223
1208
  },
1224
1209
  {
1225
- code: 6017;
1210
+ code: 6014;
1226
1211
  name: "streamNotStarted";
1227
1212
  msg: "Stream has not started yet";
1228
1213
  },
1229
1214
  {
1230
- code: 6018;
1215
+ code: 6015;
1231
1216
  name: "noWithdrawableAmount";
1232
1217
  msg: "No withdrawable amount available at this time";
1233
1218
  },
1234
1219
  {
1235
- code: 6019;
1220
+ code: 6016;
1236
1221
  name: "invalidStreamToken";
1237
1222
  msg: "Invalid stream token";
1238
1223
  },
1239
1224
  {
1240
- code: 6020;
1225
+ code: 6017;
1241
1226
  name: "streamAlreadyEnded";
1242
1227
  msg: "Stream already ended";
1243
1228
  },
1244
1229
  {
1245
- code: 6021;
1230
+ code: 6018;
1246
1231
  name: "evergencyPauseActive";
1247
1232
  msg: "Emergency pause is active";
1248
1233
  },
1249
1234
  {
1250
- code: 6022;
1235
+ code: 6019;
1251
1236
  name: "invalidMint";
1252
1237
  msg: "Invalid mint address";
1253
1238
  },
1254
1239
  {
1255
- code: 6023;
1240
+ code: 6020;
1256
1241
  name: "invalidFeeVault";
1257
1242
  msg: "Invalid fee vault";
1258
- },
1259
- {
1260
- code: 6024;
1261
- name: "tokenNotAllowed";
1262
- msg: "Invalid Token";
1263
1243
  }
1264
1244
  ];
1265
1245
  types: [
@@ -862,98 +862,78 @@
862
862
  },
863
863
  {
864
864
  "code": 6006,
865
- "name": "UnknownStreamFrequency",
866
- "msg": "Stream frequency not included in stream configuration"
867
- },
868
- {
869
- "code": 6007,
870
- "name": "DurationNotExactlyDivisibleByFrequency",
871
- "msg": "Stream Duration is not exactly divisible by the frequency"
872
- },
873
- {
874
- "code": 6008,
875
865
  "name": "InsufficientSenderBalance",
876
866
  "msg": "Sender does not have enough balance to create the stream"
877
867
  },
878
868
  {
879
- "code": 6009,
869
+ "code": 6007,
880
870
  "name": "StreamAlreadyCanceled",
881
871
  "msg": "Stream Already Canceled"
882
872
  },
883
873
  {
884
- "code": 6010,
874
+ "code": 6008,
885
875
  "name": "Unauthorized",
886
- "msg": "Unauthorized: Only the allowed party can cancel the stream"
876
+ "msg": "Unauthorized"
887
877
  },
888
878
  {
889
- "code": 6011,
879
+ "code": 6009,
890
880
  "name": "NotCancellable",
891
881
  "msg": "Stream is not Cancellable"
892
882
  },
893
883
  {
894
- "code": 6012,
884
+ "code": 6010,
895
885
  "name": "StreamAlreadyWithdrawn",
896
886
  "msg": "Stream has already been withdrawn"
897
887
  },
898
888
  {
899
- "code": 6013,
889
+ "code": 6011,
900
890
  "name": "InvalidReceiver",
901
- "msg": "UnAuthorized: Only the allowed party can transfer the stream"
902
- },
903
- {
904
- "code": 6014,
905
- "name": "StreamAutoWithdrawable",
906
- "msg": "Stream is automatically withdrawable"
891
+ "msg": "Invalid receiver address"
907
892
  },
908
893
  {
909
- "code": 6015,
894
+ "code": 6012,
910
895
  "name": "WithdrawAmountExceeds",
911
896
  "msg": "Withdraw amount exceeds the available amount in the stream"
912
897
  },
913
898
  {
914
- "code": 6016,
899
+ "code": 6013,
915
900
  "name": "InsufficientFundsToWithdraw",
916
901
  "msg": "Insufficient funds in the stream vault for withdrawal"
917
902
  },
918
903
  {
919
- "code": 6017,
904
+ "code": 6014,
920
905
  "name": "StreamNotStarted",
921
906
  "msg": "Stream has not started yet"
922
907
  },
923
908
  {
924
- "code": 6018,
909
+ "code": 6015,
925
910
  "name": "NoWithdrawableAmount",
926
911
  "msg": "No withdrawable amount available at this time"
927
912
  },
928
913
  {
929
- "code": 6019,
914
+ "code": 6016,
930
915
  "name": "InvalidStreamToken",
931
916
  "msg": "Invalid stream token"
932
917
  },
933
918
  {
934
- "code": 6020,
919
+ "code": 6017,
935
920
  "name": "StreamAlreadyEnded",
936
921
  "msg": "Stream already ended"
937
922
  },
938
923
  {
939
- "code": 6021,
924
+ "code": 6018,
940
925
  "name": "EvergencyPauseActive",
941
926
  "msg": "Emergency pause is active"
942
927
  },
943
928
  {
944
- "code": 6022,
929
+ "code": 6019,
945
930
  "name": "InvalidMint",
946
931
  "msg": "Invalid mint address"
947
932
  },
948
933
  {
949
- "code": 6023,
934
+ "code": 6020,
950
935
  "name": "InvalidFeeVault",
951
936
  "msg": "Invalid fee vault"
952
- },
953
- {
954
- "code": 6024,
955
- "name": "TokenNotAllowed",
956
- "msg": "Invalid Token"
957
937
  }
958
938
  ],
959
939
  "types": [
@@ -225,8 +225,8 @@ class ZebecStreamService {
225
225
  const streamTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, streamToken);
226
226
  const amount = new anchor_1.BN((0, bignumber_js_1.BigNumber)(params.amount).times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals)).toFixed(0));
227
227
  const cliffPercentage = new anchor_1.BN((0, core_utils_1.percentToBps)(params.cliffPercentage));
228
- const streamNameBuffer = Buffer.alloc(constants_1.STREAM_NAME_BUFFER_SIZE);
229
- streamNameBuffer.fill(anchor_1.utils.bytes.utf8.encode(params.streamName), 0);
228
+ const streamName = new Uint8Array(constants_1.STREAM_NAME_BUFFER_SIZE);
229
+ streamName.set(anchor_1.utils.bytes.utf8.encode(params.streamName));
230
230
  const ix = await this.getCreateStreamInstruction(feePayer, receiver, senderAta, streamToken, withdrawer, sender, streamMetadataKeypair.publicKey, {
231
231
  amount,
232
232
  automaticWithdrawal: params.automaticWithdrawal,
@@ -241,7 +241,7 @@ class ZebecStreamService {
241
241
  startNow: params.startNow,
242
242
  startTime: new anchor_1.BN(params.startTime),
243
243
  autoWithdrawFrequency: new anchor_1.BN(params.autoWithdrawFrequency),
244
- streamName: streamNameBuffer,
244
+ streamName,
245
245
  transferableByRecipient: params.transferableByRecipient,
246
246
  transferableBySender: params.transferableBySender,
247
247
  });
@@ -307,7 +307,6 @@ class ZebecStreamService {
307
307
  }
308
308
  async getStreamConfigInfo(commitment) {
309
309
  const [config] = (0, pda_1.deriveStreamConfigPda)(this.programId);
310
- console.log("config:", config.toString());
311
310
  const configInfo = await this.program.account.streamConfig.fetch(config, commitment ?? this.connection.commitment);
312
311
  return {
313
312
  address: config,
@@ -1,5 +1,5 @@
1
1
  import * as anchor from "@coral-xyz/anchor";
2
- import { Connection, Keypair, PublicKey } from "@solana/web3.js";
2
+ import { Commitment, Connection, Keypair, PublicKey } from "@solana/web3.js";
3
3
  import { TransactionPayload } from "@zebec-network/solana-common";
4
4
  import { ZebecStreamIdl as ZTokenIdl } from "../artifacts";
5
5
  import { Numeric } from "../types";
@@ -55,7 +55,7 @@ export declare class ZTokenService {
55
55
  emergencyPause(params: {
56
56
  admin: anchor.Address;
57
57
  }): Promise<TransactionPayload>;
58
- getZTokenConfigInfo(): Promise<{
58
+ getZTokenConfigInfo(commitment?: Commitment): Promise<{
59
59
  fee: number;
60
60
  admin: anchor.web3.PublicKey;
61
61
  emergencyPause: boolean;
@@ -273,9 +273,9 @@ class ZTokenService {
273
273
  const ix = await this.getEmergencyPauseInstruction(admin);
274
274
  return this._createPayload(admin, [ix]);
275
275
  }
276
- async getZTokenConfigInfo() {
276
+ async getZTokenConfigInfo(commitment) {
277
277
  const [config] = (0, pda_1.deriveZTokenConfigPda)(this.programId);
278
- const configAccount = await this.program.account.ztoken.fetch(config);
278
+ const configAccount = await this.program.account.ztoken.fetch(config, commitment ?? this.connection.commitment);
279
279
  return {
280
280
  fee: Number((0, core_utils_1.bpsToPercent)(configAccount.fee)),
281
281
  admin: configAccount.admin,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zebec-network/zebec-stream-sdk",
3
- "version": "1.5.0",
3
+ "version": "1.5.1",
4
4
  "description": "This is an SDK for interacting with ZEBEC Stream Program in solana",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",