@zebec-network/zebec-stream-sdk 1.4.1 → 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.
- package/dist/artifacts/zebec_stream.d.ts +21 -36
- package/dist/artifacts/zebec_stream.json +21 -36
- package/dist/services/streamService.d.ts +2 -1
- package/dist/services/streamService.js +7 -6
- package/dist/services/zTokenService.d.ts +2 -2
- package/dist/services/zTokenService.js +2 -2
- package/package.json +1 -1
|
@@ -943,6 +943,11 @@ export type ZebecStream = {
|
|
|
943
943
|
writable: true;
|
|
944
944
|
signer: true;
|
|
945
945
|
},
|
|
946
|
+
{
|
|
947
|
+
name: "feePayer";
|
|
948
|
+
writable: true;
|
|
949
|
+
signer: true;
|
|
950
|
+
},
|
|
946
951
|
{
|
|
947
952
|
name: "receiver";
|
|
948
953
|
},
|
|
@@ -1163,98 +1168,78 @@ export type ZebecStream = {
|
|
|
1163
1168
|
},
|
|
1164
1169
|
{
|
|
1165
1170
|
code: 6006;
|
|
1166
|
-
name: "unknownStreamFrequency";
|
|
1167
|
-
msg: "Stream frequency not included in stream configuration";
|
|
1168
|
-
},
|
|
1169
|
-
{
|
|
1170
|
-
code: 6007;
|
|
1171
|
-
name: "durationNotExactlyDivisibleByFrequency";
|
|
1172
|
-
msg: "Stream Duration is not exactly divisible by the frequency";
|
|
1173
|
-
},
|
|
1174
|
-
{
|
|
1175
|
-
code: 6008;
|
|
1176
1171
|
name: "insufficientSenderBalance";
|
|
1177
1172
|
msg: "Sender does not have enough balance to create the stream";
|
|
1178
1173
|
},
|
|
1179
1174
|
{
|
|
1180
|
-
code:
|
|
1175
|
+
code: 6007;
|
|
1181
1176
|
name: "streamAlreadyCanceled";
|
|
1182
1177
|
msg: "Stream Already Canceled";
|
|
1183
1178
|
},
|
|
1184
1179
|
{
|
|
1185
|
-
code:
|
|
1180
|
+
code: 6008;
|
|
1186
1181
|
name: "unauthorized";
|
|
1187
|
-
msg: "
|
|
1182
|
+
msg: "unauthorized";
|
|
1188
1183
|
},
|
|
1189
1184
|
{
|
|
1190
|
-
code:
|
|
1185
|
+
code: 6009;
|
|
1191
1186
|
name: "notCancellable";
|
|
1192
1187
|
msg: "Stream is not Cancellable";
|
|
1193
1188
|
},
|
|
1194
1189
|
{
|
|
1195
|
-
code:
|
|
1190
|
+
code: 6010;
|
|
1196
1191
|
name: "streamAlreadyWithdrawn";
|
|
1197
1192
|
msg: "Stream has already been withdrawn";
|
|
1198
1193
|
},
|
|
1199
1194
|
{
|
|
1200
|
-
code:
|
|
1195
|
+
code: 6011;
|
|
1201
1196
|
name: "invalidReceiver";
|
|
1202
|
-
msg: "
|
|
1197
|
+
msg: "Invalid receiver address";
|
|
1203
1198
|
},
|
|
1204
1199
|
{
|
|
1205
|
-
code:
|
|
1206
|
-
name: "streamAutoWithdrawable";
|
|
1207
|
-
msg: "Stream is automatically withdrawable";
|
|
1208
|
-
},
|
|
1209
|
-
{
|
|
1210
|
-
code: 6015;
|
|
1200
|
+
code: 6012;
|
|
1211
1201
|
name: "withdrawAmountExceeds";
|
|
1212
1202
|
msg: "Withdraw amount exceeds the available amount in the stream";
|
|
1213
1203
|
},
|
|
1214
1204
|
{
|
|
1215
|
-
code:
|
|
1205
|
+
code: 6013;
|
|
1216
1206
|
name: "insufficientFundsToWithdraw";
|
|
1217
1207
|
msg: "Insufficient funds in the stream vault for withdrawal";
|
|
1218
1208
|
},
|
|
1219
1209
|
{
|
|
1220
|
-
code:
|
|
1210
|
+
code: 6014;
|
|
1221
1211
|
name: "streamNotStarted";
|
|
1222
1212
|
msg: "Stream has not started yet";
|
|
1223
1213
|
},
|
|
1224
1214
|
{
|
|
1225
|
-
code:
|
|
1215
|
+
code: 6015;
|
|
1226
1216
|
name: "noWithdrawableAmount";
|
|
1227
1217
|
msg: "No withdrawable amount available at this time";
|
|
1228
1218
|
},
|
|
1229
1219
|
{
|
|
1230
|
-
code:
|
|
1220
|
+
code: 6016;
|
|
1231
1221
|
name: "invalidStreamToken";
|
|
1232
1222
|
msg: "Invalid stream token";
|
|
1233
1223
|
},
|
|
1234
1224
|
{
|
|
1235
|
-
code:
|
|
1225
|
+
code: 6017;
|
|
1236
1226
|
name: "streamAlreadyEnded";
|
|
1237
1227
|
msg: "Stream already ended";
|
|
1238
1228
|
},
|
|
1239
1229
|
{
|
|
1240
|
-
code:
|
|
1230
|
+
code: 6018;
|
|
1241
1231
|
name: "evergencyPauseActive";
|
|
1242
1232
|
msg: "Emergency pause is active";
|
|
1243
1233
|
},
|
|
1244
1234
|
{
|
|
1245
|
-
code:
|
|
1235
|
+
code: 6019;
|
|
1246
1236
|
name: "invalidMint";
|
|
1247
1237
|
msg: "Invalid mint address";
|
|
1248
1238
|
},
|
|
1249
1239
|
{
|
|
1250
|
-
code:
|
|
1240
|
+
code: 6020;
|
|
1251
1241
|
name: "invalidFeeVault";
|
|
1252
1242
|
msg: "Invalid fee vault";
|
|
1253
|
-
},
|
|
1254
|
-
{
|
|
1255
|
-
code: 6024;
|
|
1256
|
-
name: "tokenNotAllowed";
|
|
1257
|
-
msg: "Invalid Token";
|
|
1258
1243
|
}
|
|
1259
1244
|
];
|
|
1260
1245
|
types: [
|
|
@@ -697,6 +697,11 @@
|
|
|
697
697
|
"writable": true,
|
|
698
698
|
"signer": true
|
|
699
699
|
},
|
|
700
|
+
{
|
|
701
|
+
"name": "fee_payer",
|
|
702
|
+
"writable": true,
|
|
703
|
+
"signer": true
|
|
704
|
+
},
|
|
700
705
|
{
|
|
701
706
|
"name": "receiver"
|
|
702
707
|
},
|
|
@@ -857,98 +862,78 @@
|
|
|
857
862
|
},
|
|
858
863
|
{
|
|
859
864
|
"code": 6006,
|
|
860
|
-
"name": "UnknownStreamFrequency",
|
|
861
|
-
"msg": "Stream frequency not included in stream configuration"
|
|
862
|
-
},
|
|
863
|
-
{
|
|
864
|
-
"code": 6007,
|
|
865
|
-
"name": "DurationNotExactlyDivisibleByFrequency",
|
|
866
|
-
"msg": "Stream Duration is not exactly divisible by the frequency"
|
|
867
|
-
},
|
|
868
|
-
{
|
|
869
|
-
"code": 6008,
|
|
870
865
|
"name": "InsufficientSenderBalance",
|
|
871
866
|
"msg": "Sender does not have enough balance to create the stream"
|
|
872
867
|
},
|
|
873
868
|
{
|
|
874
|
-
"code":
|
|
869
|
+
"code": 6007,
|
|
875
870
|
"name": "StreamAlreadyCanceled",
|
|
876
871
|
"msg": "Stream Already Canceled"
|
|
877
872
|
},
|
|
878
873
|
{
|
|
879
|
-
"code":
|
|
874
|
+
"code": 6008,
|
|
880
875
|
"name": "Unauthorized",
|
|
881
|
-
"msg": "Unauthorized
|
|
876
|
+
"msg": "Unauthorized"
|
|
882
877
|
},
|
|
883
878
|
{
|
|
884
|
-
"code":
|
|
879
|
+
"code": 6009,
|
|
885
880
|
"name": "NotCancellable",
|
|
886
881
|
"msg": "Stream is not Cancellable"
|
|
887
882
|
},
|
|
888
883
|
{
|
|
889
|
-
"code":
|
|
884
|
+
"code": 6010,
|
|
890
885
|
"name": "StreamAlreadyWithdrawn",
|
|
891
886
|
"msg": "Stream has already been withdrawn"
|
|
892
887
|
},
|
|
893
888
|
{
|
|
894
|
-
"code":
|
|
889
|
+
"code": 6011,
|
|
895
890
|
"name": "InvalidReceiver",
|
|
896
|
-
"msg": "
|
|
891
|
+
"msg": "Invalid receiver address"
|
|
897
892
|
},
|
|
898
893
|
{
|
|
899
|
-
"code":
|
|
900
|
-
"name": "StreamAutoWithdrawable",
|
|
901
|
-
"msg": "Stream is automatically withdrawable"
|
|
902
|
-
},
|
|
903
|
-
{
|
|
904
|
-
"code": 6015,
|
|
894
|
+
"code": 6012,
|
|
905
895
|
"name": "WithdrawAmountExceeds",
|
|
906
896
|
"msg": "Withdraw amount exceeds the available amount in the stream"
|
|
907
897
|
},
|
|
908
898
|
{
|
|
909
|
-
"code":
|
|
899
|
+
"code": 6013,
|
|
910
900
|
"name": "InsufficientFundsToWithdraw",
|
|
911
901
|
"msg": "Insufficient funds in the stream vault for withdrawal"
|
|
912
902
|
},
|
|
913
903
|
{
|
|
914
|
-
"code":
|
|
904
|
+
"code": 6014,
|
|
915
905
|
"name": "StreamNotStarted",
|
|
916
906
|
"msg": "Stream has not started yet"
|
|
917
907
|
},
|
|
918
908
|
{
|
|
919
|
-
"code":
|
|
909
|
+
"code": 6015,
|
|
920
910
|
"name": "NoWithdrawableAmount",
|
|
921
911
|
"msg": "No withdrawable amount available at this time"
|
|
922
912
|
},
|
|
923
913
|
{
|
|
924
|
-
"code":
|
|
914
|
+
"code": 6016,
|
|
925
915
|
"name": "InvalidStreamToken",
|
|
926
916
|
"msg": "Invalid stream token"
|
|
927
917
|
},
|
|
928
918
|
{
|
|
929
|
-
"code":
|
|
919
|
+
"code": 6017,
|
|
930
920
|
"name": "StreamAlreadyEnded",
|
|
931
921
|
"msg": "Stream already ended"
|
|
932
922
|
},
|
|
933
923
|
{
|
|
934
|
-
"code":
|
|
924
|
+
"code": 6018,
|
|
935
925
|
"name": "EvergencyPauseActive",
|
|
936
926
|
"msg": "Emergency pause is active"
|
|
937
927
|
},
|
|
938
928
|
{
|
|
939
|
-
"code":
|
|
929
|
+
"code": 6019,
|
|
940
930
|
"name": "InvalidMint",
|
|
941
931
|
"msg": "Invalid mint address"
|
|
942
932
|
},
|
|
943
933
|
{
|
|
944
|
-
"code":
|
|
934
|
+
"code": 6020,
|
|
945
935
|
"name": "InvalidFeeVault",
|
|
946
936
|
"msg": "Invalid fee vault"
|
|
947
|
-
},
|
|
948
|
-
{
|
|
949
|
-
"code": 6024,
|
|
950
|
-
"name": "TokenNotAllowed",
|
|
951
|
-
"msg": "Invalid Token"
|
|
952
937
|
}
|
|
953
938
|
],
|
|
954
939
|
"types": [
|
|
@@ -44,7 +44,7 @@ export declare class ZebecStreamService {
|
|
|
44
44
|
}): Promise<TransactionInstruction>;
|
|
45
45
|
getPauseResumeStreamInstruction(streamMetadata: PublicKey, user: PublicKey): Promise<TransactionInstruction>;
|
|
46
46
|
getCancelStreamInstruction(feePayer: PublicKey, otherParty: PublicKey, otherPartyAta: PublicKey, signer: PublicKey, signerAta: PublicKey, streamMetadata: PublicKey, streamToken: PublicKey, streamVault: PublicKey, streamVaultAta: PublicKey): Promise<TransactionInstruction>;
|
|
47
|
-
getWithdrawStreamInstruction(receiver: PublicKey, receiverAta: PublicKey, streamMetadata: PublicKey, streamToken: PublicKey, streamVault: PublicKey, streamVaultAta: PublicKey, withdrawer: PublicKey): Promise<TransactionInstruction>;
|
|
47
|
+
getWithdrawStreamInstruction(receiver: PublicKey, receiverAta: PublicKey, streamMetadata: PublicKey, streamToken: PublicKey, streamVault: PublicKey, streamVaultAta: PublicKey, withdrawer: PublicKey, feePayer: PublicKey): Promise<TransactionInstruction>;
|
|
48
48
|
getWhitelistTokensInstruction(admin: PublicKey, tokens: PublicKey[]): Promise<TransactionInstruction>;
|
|
49
49
|
getChangeStreamReceiverInstruction(streamMetadata: PublicKey, newRecipient: PublicKey, signer: PublicKey): Promise<TransactionInstruction>;
|
|
50
50
|
initializeStreamConfig(params: InitializeStreamConfigParams): Promise<TransactionPayload>;
|
|
@@ -111,6 +111,7 @@ export type PauseResumeStreamParams = {
|
|
|
111
111
|
export type WithdrawStreamParams = {
|
|
112
112
|
streamMetadata: Address;
|
|
113
113
|
withdrawer?: Address;
|
|
114
|
+
feePayer?: Address;
|
|
114
115
|
receiver: Address;
|
|
115
116
|
};
|
|
116
117
|
export type WhiteListTokensParams = {
|
|
@@ -139,7 +139,7 @@ class ZebecStreamService {
|
|
|
139
139
|
})
|
|
140
140
|
.instruction();
|
|
141
141
|
}
|
|
142
|
-
getWithdrawStreamInstruction(receiver, receiverAta, streamMetadata, streamToken, streamVault, streamVaultAta, withdrawer) {
|
|
142
|
+
getWithdrawStreamInstruction(receiver, receiverAta, streamMetadata, streamToken, streamVault, streamVaultAta, withdrawer, feePayer) {
|
|
143
143
|
return this.program.methods
|
|
144
144
|
.withdrawStream()
|
|
145
145
|
.accountsPartial({
|
|
@@ -150,6 +150,7 @@ class ZebecStreamService {
|
|
|
150
150
|
receiver,
|
|
151
151
|
receiverAta,
|
|
152
152
|
withdrawer,
|
|
153
|
+
feePayer,
|
|
153
154
|
})
|
|
154
155
|
.instruction();
|
|
155
156
|
}
|
|
@@ -224,8 +225,8 @@ class ZebecStreamService {
|
|
|
224
225
|
const streamTokenDecimals = await (0, solana_common_1.getMintDecimals)(this.connection, streamToken);
|
|
225
226
|
const amount = new anchor_1.BN((0, bignumber_js_1.BigNumber)(params.amount).times(solana_common_1.TEN_BIGNUM.pow(streamTokenDecimals)).toFixed(0));
|
|
226
227
|
const cliffPercentage = new anchor_1.BN((0, core_utils_1.percentToBps)(params.cliffPercentage));
|
|
227
|
-
const
|
|
228
|
-
|
|
228
|
+
const streamName = new Uint8Array(constants_1.STREAM_NAME_BUFFER_SIZE);
|
|
229
|
+
streamName.set(anchor_1.utils.bytes.utf8.encode(params.streamName));
|
|
229
230
|
const ix = await this.getCreateStreamInstruction(feePayer, receiver, senderAta, streamToken, withdrawer, sender, streamMetadataKeypair.publicKey, {
|
|
230
231
|
amount,
|
|
231
232
|
automaticWithdrawal: params.automaticWithdrawal,
|
|
@@ -240,7 +241,7 @@ class ZebecStreamService {
|
|
|
240
241
|
startNow: params.startNow,
|
|
241
242
|
startTime: new anchor_1.BN(params.startTime),
|
|
242
243
|
autoWithdrawFrequency: new anchor_1.BN(params.autoWithdrawFrequency),
|
|
243
|
-
streamName
|
|
244
|
+
streamName,
|
|
244
245
|
transferableByRecipient: params.transferableByRecipient,
|
|
245
246
|
transferableBySender: params.transferableBySender,
|
|
246
247
|
});
|
|
@@ -281,13 +282,14 @@ class ZebecStreamService {
|
|
|
281
282
|
async withdrawStream(params) {
|
|
282
283
|
const receiver = (0, anchor_1.translateAddress)(params.receiver);
|
|
283
284
|
const withdrawer = params.withdrawer ? (0, anchor_1.translateAddress)(params.withdrawer) : receiver;
|
|
285
|
+
const feePayer = params.feePayer ? (0, anchor_1.translateAddress)(params.feePayer) : params.withdrawer ? withdrawer : receiver;
|
|
284
286
|
const streamMetadata = (0, anchor_1.translateAddress)(params.streamMetadata);
|
|
285
287
|
const streamMetadataAccount = await this.program.account.paymentStream.fetch(streamMetadata);
|
|
286
288
|
const streamToken = streamMetadataAccount.financials.streamToken;
|
|
287
289
|
const receiverAta = (0, solana_common_1.getAssociatedTokenAddressSync)(streamToken, receiver, true);
|
|
288
290
|
const [streamVault] = (0, pda_1.deriveStreamVaultPda)(streamMetadata, this.programId);
|
|
289
291
|
const streamVaultAta = (0, solana_common_1.getAssociatedTokenAddressSync)(streamToken, streamVault, true);
|
|
290
|
-
const ix = await this.getWithdrawStreamInstruction(receiver, receiverAta, streamMetadata, streamToken, streamVault, streamVaultAta, withdrawer);
|
|
292
|
+
const ix = await this.getWithdrawStreamInstruction(receiver, receiverAta, streamMetadata, streamToken, streamVault, streamVaultAta, withdrawer, feePayer);
|
|
291
293
|
return this._createPayload(withdrawer, [ix]);
|
|
292
294
|
}
|
|
293
295
|
async whiteListTokens(params) {
|
|
@@ -305,7 +307,6 @@ class ZebecStreamService {
|
|
|
305
307
|
}
|
|
306
308
|
async getStreamConfigInfo(commitment) {
|
|
307
309
|
const [config] = (0, pda_1.deriveStreamConfigPda)(this.programId);
|
|
308
|
-
console.log("config:", config.toString());
|
|
309
310
|
const configInfo = await this.program.account.streamConfig.fetch(config, commitment ?? this.connection.commitment);
|
|
310
311
|
return {
|
|
311
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,
|