@streamflow/stream 6.5.0 → 7.0.0-alpha.10
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/README.md +17 -22
- package/dist/cjs/__tests__/aptos/streamClient.spec.js +111 -0
- package/dist/cjs/__tests__/common/GenericStreamClient.spec.js +45 -0
- package/dist/cjs/aptos/StreamClient.js +226 -0
- package/dist/cjs/aptos/constants.js +27 -0
- package/dist/{aptos → cjs/aptos}/index.js +6 -6
- package/dist/cjs/aptos/types.js +69 -0
- package/dist/{aptos → cjs/aptos}/utils.js +4 -4
- package/dist/cjs/aptos/wallet.js +34 -0
- package/dist/cjs/common/BaseStreamClient.js +23 -0
- package/dist/cjs/common/GenericStreamClient.js +102 -0
- package/dist/{common → cjs/common}/constants.js +2 -2
- package/dist/{common → cjs/common}/contractUtils.js +19 -20
- package/dist/cjs/common/utils.js +66 -0
- package/dist/cjs/evm/StreamClient.js +238 -0
- package/dist/cjs/evm/constants.js +38 -0
- package/dist/{evm → cjs/evm}/index.js +8 -8
- package/dist/{evm → cjs/evm}/types.js +26 -35
- package/dist/{evm → cjs/evm}/utils.js +2 -2
- package/dist/{index.js → cjs/index.js} +10 -10
- package/dist/cjs/solana/StreamClient.js +737 -0
- package/dist/{solana → cjs/solana}/constants.js +33 -33
- package/dist/cjs/solana/index.js +39 -0
- package/dist/{solana → cjs/solana}/instructions.js +83 -83
- package/dist/{solana → cjs/solana}/layout.js +8 -9
- package/dist/{solana → cjs/solana}/types.js +16 -26
- package/dist/cjs/solana/utils.js +134 -0
- package/dist/cjs/sui/StreamClient.js +402 -0
- package/dist/cjs/sui/constants.js +42 -0
- package/dist/{sui → cjs/sui}/index.js +5 -5
- package/dist/cjs/sui/types.js +68 -0
- package/dist/{sui → cjs/sui}/utils.js +7 -7
- package/dist/cjs/sui/wallet.js +40 -0
- package/dist/esm/__tests__/aptos/streamClient.spec.js +106 -0
- package/dist/esm/__tests__/common/GenericStreamClient.spec.js +40 -0
- package/dist/{aptos → esm/aptos}/StreamClient.d.ts +3 -3
- package/dist/esm/aptos/StreamClient.js +226 -0
- package/dist/{aptos → esm/aptos}/constants.d.ts +1 -1
- package/dist/esm/aptos/constants.js +24 -0
- package/dist/esm/aptos/index.d.ts +4 -0
- package/dist/esm/aptos/index.js +4 -0
- package/dist/{aptos → esm/aptos}/types.d.ts +13 -13
- package/dist/esm/aptos/types.js +105 -0
- package/dist/esm/aptos/utils.js +30 -0
- package/dist/esm/aptos/wallet.js +33 -0
- package/dist/{common → esm/common}/BaseStreamClient.d.ts +1 -1
- package/dist/esm/common/BaseStreamClient.js +19 -0
- package/dist/{common → esm/common}/GenericStreamClient.d.ts +6 -6
- package/dist/esm/common/GenericStreamClient.js +101 -0
- package/dist/esm/common/constants.d.ts +3 -0
- package/dist/esm/common/constants.js +3 -0
- package/dist/{common → esm/common}/contractUtils.d.ts +15 -15
- package/dist/esm/common/contractUtils.js +42 -0
- package/dist/{common → esm/common}/types.d.ts +19 -19
- package/dist/esm/common/types.js +106 -0
- package/dist/{common → esm/common}/utils.d.ts +11 -12
- package/dist/esm/common/utils.js +56 -0
- package/dist/{evm → esm/evm}/StreamClient.d.ts +4 -4
- package/dist/esm/evm/StreamClient.js +237 -0
- package/dist/esm/evm/abi.js +1255 -0
- package/dist/{evm → esm/evm}/constants.d.ts +1 -1
- package/dist/esm/evm/constants.js +35 -0
- package/dist/esm/evm/ercAbi.js +222 -0
- package/dist/esm/evm/index.d.ts +5 -0
- package/dist/esm/evm/index.js +5 -0
- package/dist/{evm → esm/evm}/types.d.ts +38 -38
- package/dist/esm/evm/types.js +102 -0
- package/dist/esm/evm/utils.js +8 -0
- package/dist/esm/index.d.ts +9 -0
- package/dist/esm/index.js +9 -0
- package/dist/{solana → esm/solana}/StreamClient.d.ts +4 -4
- package/dist/esm/solana/StreamClient.js +711 -0
- package/dist/{solana → esm/solana}/constants.d.ts +3 -1
- package/dist/esm/solana/constants.js +62 -0
- package/dist/esm/solana/index.d.ts +6 -0
- package/dist/esm/solana/index.js +6 -0
- package/dist/esm/solana/instructionTypes.js +1 -0
- package/dist/{solana → esm/solana}/instructions.d.ts +18 -18
- package/dist/esm/solana/instructions.js +257 -0
- package/dist/{solana → esm/solana}/layout.d.ts +2 -1
- package/dist/esm/solana/layout.js +155 -0
- package/dist/esm/solana/timelockIDL.js +420 -0
- package/dist/{solana → esm/solana}/types.d.ts +38 -37
- package/dist/esm/solana/types.js +101 -0
- package/dist/{solana → esm/solana}/utils.d.ts +4 -1
- package/dist/esm/solana/utils.js +123 -0
- package/dist/{sui → esm/sui}/StreamClient.d.ts +3 -3
- package/dist/esm/sui/StreamClient.js +403 -0
- package/dist/{sui → esm/sui}/constants.d.ts +1 -1
- package/dist/esm/sui/constants.js +39 -0
- package/dist/esm/sui/index.d.ts +4 -0
- package/dist/esm/sui/index.js +4 -0
- package/dist/{sui → esm/sui}/types.d.ts +13 -13
- package/dist/esm/sui/types.js +104 -0
- package/dist/{sui → esm/sui}/utils.d.ts +1 -1
- package/dist/esm/sui/utils.js +23 -0
- package/dist/{sui → esm/sui}/wallet.d.ts +1 -1
- package/dist/esm/sui/wallet.js +38 -0
- package/package.json +37 -35
- package/dist/__tests__/aptos/streamClient.spec.js +0 -161
- package/dist/__tests__/common/GenericStreamClient.spec.js +0 -44
- package/dist/aptos/StreamClient.js +0 -431
- package/dist/aptos/constants.js +0 -28
- package/dist/aptos/index.d.ts +0 -4
- package/dist/aptos/types.js +0 -77
- package/dist/aptos/wallet.js +0 -89
- package/dist/common/BaseStreamClient.js +0 -71
- package/dist/common/GenericStreamClient.js +0 -128
- package/dist/common/constants.d.ts +0 -3
- package/dist/common/utils.js +0 -118
- package/dist/evm/StreamClient.js +0 -496
- package/dist/evm/constants.js +0 -39
- package/dist/evm/index.d.ts +0 -5
- package/dist/index.d.ts +0 -9
- package/dist/solana/StreamClient.js +0 -1253
- package/dist/solana/index.d.ts +0 -7
- package/dist/solana/index.js +0 -43
- package/dist/solana/utils.js +0 -211
- package/dist/sui/StreamClient.js +0 -648
- package/dist/sui/constants.js +0 -43
- package/dist/sui/index.d.ts +0 -4
- package/dist/sui/types.js +0 -102
- package/dist/sui/wallet.js +0 -90
- /package/dist/{common → cjs/common}/types.js +0 -0
- /package/dist/{evm → cjs/evm}/abi.js +0 -0
- /package/dist/{evm → cjs/evm}/ercAbi.js +0 -0
- /package/dist/{solana → cjs/solana}/instructionTypes.js +0 -0
- /package/dist/{solana → cjs/solana}/timelockIDL.js +0 -0
- /package/dist/{__tests__ → esm/__tests__}/aptos/streamClient.spec.d.ts +0 -0
- /package/dist/{__tests__ → esm/__tests__}/common/GenericStreamClient.spec.d.ts +0 -0
- /package/dist/{aptos → esm/aptos}/utils.d.ts +0 -0
- /package/dist/{aptos → esm/aptos}/wallet.d.ts +0 -0
- /package/dist/{evm → esm/evm}/abi.d.ts +0 -0
- /package/dist/{evm → esm/evm}/ercAbi.d.ts +0 -0
- /package/dist/{evm → esm/evm}/utils.d.ts +0 -0
- /package/dist/{solana → esm/solana}/instructionTypes.d.ts +0 -0
- /package/dist/{solana → esm/solana}/timelockIDL.d.ts +0 -0
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import BigNumber from "bignumber.js";
|
|
2
|
+
import { buildStreamType, calculateUnlockedAmount } from "../common/contractUtils.js";
|
|
3
|
+
import { getNumberFromBigNumber } from "../common/utils.js";
|
|
4
|
+
export class Contract {
|
|
5
|
+
magic;
|
|
6
|
+
version;
|
|
7
|
+
createdAt;
|
|
8
|
+
withdrawnAmount;
|
|
9
|
+
canceledAt;
|
|
10
|
+
end;
|
|
11
|
+
lastWithdrawnAt;
|
|
12
|
+
sender;
|
|
13
|
+
senderTokens;
|
|
14
|
+
recipient;
|
|
15
|
+
recipientTokens;
|
|
16
|
+
mint;
|
|
17
|
+
escrowTokens;
|
|
18
|
+
streamflowTreasury;
|
|
19
|
+
streamflowTreasuryTokens;
|
|
20
|
+
streamflowFeeTotal;
|
|
21
|
+
streamflowFeeWithdrawn;
|
|
22
|
+
streamflowFeePercent;
|
|
23
|
+
partnerFeeTotal;
|
|
24
|
+
partnerFeeWithdrawn;
|
|
25
|
+
partnerFeePercent;
|
|
26
|
+
partner;
|
|
27
|
+
partnerTokens;
|
|
28
|
+
start;
|
|
29
|
+
depositedAmount;
|
|
30
|
+
period;
|
|
31
|
+
amountPerPeriod;
|
|
32
|
+
cliff;
|
|
33
|
+
cliffAmount;
|
|
34
|
+
cancelableBySender;
|
|
35
|
+
cancelableByRecipient;
|
|
36
|
+
automaticWithdrawal;
|
|
37
|
+
transferableBySender;
|
|
38
|
+
transferableByRecipient;
|
|
39
|
+
canTopup;
|
|
40
|
+
name;
|
|
41
|
+
withdrawalFrequency;
|
|
42
|
+
closed;
|
|
43
|
+
currentPauseStart;
|
|
44
|
+
pauseCumulative;
|
|
45
|
+
lastRateChangeTime;
|
|
46
|
+
fundsUnlockedAtLastRateChange;
|
|
47
|
+
type;
|
|
48
|
+
constructor(stream, tokenId) {
|
|
49
|
+
const meta = stream.meta.fields;
|
|
50
|
+
const fees = stream.fees.fields;
|
|
51
|
+
this.magic = 0;
|
|
52
|
+
this.version = parseInt(stream.version);
|
|
53
|
+
this.createdAt = parseInt(stream.created);
|
|
54
|
+
this.withdrawnAmount = BigNumber(stream.withdrawn);
|
|
55
|
+
this.canceledAt = parseInt(stream.canceled_at);
|
|
56
|
+
this.end = parseInt(stream.end);
|
|
57
|
+
this.lastWithdrawnAt = parseInt(stream.last_withdrawn_at);
|
|
58
|
+
this.sender = stream.sender;
|
|
59
|
+
this.senderTokens = stream.sender;
|
|
60
|
+
this.recipient = stream.recipient;
|
|
61
|
+
this.recipientTokens = stream.recipient;
|
|
62
|
+
this.mint = tokenId;
|
|
63
|
+
this.escrowTokens = "";
|
|
64
|
+
this.streamflowTreasury = "";
|
|
65
|
+
this.streamflowTreasuryTokens = "";
|
|
66
|
+
this.streamflowFeeTotal = BigNumber(0);
|
|
67
|
+
this.streamflowFeeWithdrawn = BigNumber(0);
|
|
68
|
+
this.streamflowFeePercent = parseInt(fees.streamflow_fee_percentage) / 10000;
|
|
69
|
+
this.partnerFeeTotal = BigNumber(0);
|
|
70
|
+
this.partnerFeeWithdrawn = BigNumber(0);
|
|
71
|
+
this.partnerFeePercent = parseInt(fees.partner_fee_percentage) / 10000;
|
|
72
|
+
this.partner = stream.partner;
|
|
73
|
+
this.partnerTokens = "";
|
|
74
|
+
this.start = parseInt(stream.start);
|
|
75
|
+
this.depositedAmount = BigNumber(stream.amount);
|
|
76
|
+
this.period = parseInt(stream.period);
|
|
77
|
+
this.amountPerPeriod = BigNumber(stream.amount_per_period);
|
|
78
|
+
this.cliff = parseInt(stream.start);
|
|
79
|
+
this.cliffAmount = BigNumber(stream.cliff_amount);
|
|
80
|
+
this.cancelableBySender = meta.cancelable_by_sender;
|
|
81
|
+
this.cancelableByRecipient = meta.cancelable_by_recipient;
|
|
82
|
+
this.automaticWithdrawal = meta.automatic_withdrawal;
|
|
83
|
+
this.transferableBySender = meta.transferable_by_sender;
|
|
84
|
+
this.transferableByRecipient = meta.transferable_by_recipient;
|
|
85
|
+
this.canTopup = meta.can_topup;
|
|
86
|
+
this.name = String.fromCharCode(...meta.contract_name);
|
|
87
|
+
this.withdrawalFrequency = parseInt(meta.withdrawal_frequency);
|
|
88
|
+
this.closed = stream.closed;
|
|
89
|
+
this.currentPauseStart = parseInt(stream.current_pause_start);
|
|
90
|
+
this.pauseCumulative = BigNumber(stream.pause_cumulative);
|
|
91
|
+
this.lastRateChangeTime = parseInt(stream.last_rate_change_time);
|
|
92
|
+
this.fundsUnlockedAtLastRateChange = BigNumber(stream.funds_unlocked_at_last_rate_change);
|
|
93
|
+
this.type = buildStreamType(this);
|
|
94
|
+
}
|
|
95
|
+
unlocked(currentTimestamp) {
|
|
96
|
+
return calculateUnlockedAmount({
|
|
97
|
+
...this,
|
|
98
|
+
currentTimestamp,
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
remaining(decimals) {
|
|
102
|
+
return getNumberFromBigNumber(this.depositedAmount.minus(this.withdrawnAmount), decimals);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { SuiErrorInfo } from "./types";
|
|
1
|
+
import { SuiErrorInfo } from "./types.js";
|
|
2
2
|
export declare function extractSuiErrorInfo(errorText: string): SuiErrorInfo;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { SUI_ERROR_MATCH_REGEX, SUI_MODULE_ERROR_MAP } from "./constants.js";
|
|
2
|
+
export function extractSuiErrorInfo(errorText) {
|
|
3
|
+
const error = { text: errorText };
|
|
4
|
+
const match = SUI_ERROR_MATCH_REGEX.exec(errorText);
|
|
5
|
+
if (!match) {
|
|
6
|
+
return error;
|
|
7
|
+
}
|
|
8
|
+
const moduleName = match[2];
|
|
9
|
+
const errorCode = Number(match[4]);
|
|
10
|
+
const errorName = SUI_MODULE_ERROR_MAP[moduleName] ? SUI_MODULE_ERROR_MAP[moduleName][errorCode] : undefined;
|
|
11
|
+
const index = Number(match[5]);
|
|
12
|
+
if (index) {
|
|
13
|
+
error.index = index;
|
|
14
|
+
}
|
|
15
|
+
if (errorName) {
|
|
16
|
+
error.parsed = {
|
|
17
|
+
module: moduleName,
|
|
18
|
+
code: errorCode,
|
|
19
|
+
name: errorName,
|
|
20
|
+
};
|
|
21
|
+
}
|
|
22
|
+
return error;
|
|
23
|
+
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Keypair } from "@mysten/sui.js/cryptography";
|
|
2
2
|
import { WalletContextState } from "@suiet/wallet-kit";
|
|
3
3
|
import { SuiClient, SuiTransactionBlockResponse } from "@mysten/sui.js/client";
|
|
4
|
-
import { SuiSignAndExecuteTransactionBlockInput } from "./types";
|
|
4
|
+
import { SuiSignAndExecuteTransactionBlockInput } from "./types.js";
|
|
5
5
|
/**
|
|
6
6
|
* Utility function to check if the transaction initiator is a Wallet object
|
|
7
7
|
* @param {Keypair | WalletContextState} walletOrKeypair - Wallet or Keypair in question
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import { Keypair } from "@mysten/sui.js/cryptography";
|
|
2
|
+
/**
|
|
3
|
+
* Utility function to check if the transaction initiator is a Wallet object
|
|
4
|
+
* @param {Keypair | WalletContextState} walletOrKeypair - Wallet or Keypair in question
|
|
5
|
+
* @return {boolean} - Returns true if parameter is a Wallet.
|
|
6
|
+
*/
|
|
7
|
+
export function isSignerKeypair(walletOrKeypair) {
|
|
8
|
+
return (walletOrKeypair instanceof Keypair ||
|
|
9
|
+
walletOrKeypair.constructor === Keypair ||
|
|
10
|
+
walletOrKeypair.constructor.name === Keypair.prototype.constructor.name ||
|
|
11
|
+
"export" in walletOrKeypair);
|
|
12
|
+
}
|
|
13
|
+
export class SuiWalletWrapper {
|
|
14
|
+
wallet;
|
|
15
|
+
address;
|
|
16
|
+
client;
|
|
17
|
+
constructor(wallet, client) {
|
|
18
|
+
this.client = client;
|
|
19
|
+
this.wallet = wallet;
|
|
20
|
+
if (isSignerKeypair(wallet)) {
|
|
21
|
+
this.address = wallet.toSuiAddress();
|
|
22
|
+
}
|
|
23
|
+
else {
|
|
24
|
+
this.address = wallet.address;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
async signAndExecuteTransactionBlock(input) {
|
|
28
|
+
if (isSignerKeypair(this.wallet)) {
|
|
29
|
+
return this.client.signAndExecuteTransactionBlock({
|
|
30
|
+
...input,
|
|
31
|
+
// @ts-ignore
|
|
32
|
+
signer: this.wallet,
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
// @ts-ignore
|
|
36
|
+
return this.wallet.signAndExecuteTransactionBlock(input);
|
|
37
|
+
}
|
|
38
|
+
}
|
package/package.json
CHANGED
|
@@ -1,49 +1,52 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@streamflow/stream",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "7.0.0-alpha.10",
|
|
4
4
|
"description": "JavaScript SDK to interact with Streamflow protocol.",
|
|
5
5
|
"homepage": "https://github.com/streamflow-finance/js-sdk/",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/esm/index.js",
|
|
7
|
+
"types": "./dist/esm/index.d.ts",
|
|
8
|
+
"type": "module",
|
|
8
9
|
"exports": {
|
|
9
|
-
".":
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
"
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
"
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
"
|
|
27
|
-
|
|
28
|
-
|
|
10
|
+
".": {
|
|
11
|
+
"import": "./dist/esm/index.js",
|
|
12
|
+
"require": "./dist/cjs/index.js",
|
|
13
|
+
"types": "./dist/esm/index.d.ts"
|
|
14
|
+
},
|
|
15
|
+
"./aptos": {
|
|
16
|
+
"import": "./dist/esm/aptos/index.js",
|
|
17
|
+
"require": "./dist/cjs/aptos/index.js",
|
|
18
|
+
"types": "./dist/esm/aptos/index.d.ts"
|
|
19
|
+
},
|
|
20
|
+
"./evm": {
|
|
21
|
+
"import": "./dist/esm/evm/index.js",
|
|
22
|
+
"require": "./dist/cjs/evm/index.js",
|
|
23
|
+
"types": "./dist/esm/evm/index.d.ts"
|
|
24
|
+
},
|
|
25
|
+
"./solana": {
|
|
26
|
+
"import": "./dist/esm/solana/index.js",
|
|
27
|
+
"require": "./dist/cjs/solana/index.js",
|
|
28
|
+
"types": "./dist/esm/solana/index.d.ts"
|
|
29
|
+
},
|
|
30
|
+
"./sui": {
|
|
31
|
+
"import": "./dist/esm/sui/index.js",
|
|
32
|
+
"require": "./dist/cjs/sui/index.js",
|
|
33
|
+
"types": "./dist/esm/sui/index.d.ts"
|
|
29
34
|
}
|
|
30
35
|
},
|
|
31
36
|
"scripts": {
|
|
32
|
-
"build": "rm -rf dist; tsc -p tsconfig.json",
|
|
37
|
+
"build:cjs": "rm -rf dist/cjs; tsc -p tsconfig.cjs.json",
|
|
38
|
+
"build:esm": "rm -rf dist/esm; tsc -p tsconfig.esm.json",
|
|
39
|
+
"build": "rm -rf dist; pnpm run build:esm && pnpm run build:cjs",
|
|
33
40
|
"pack": "pnpm build && pnpm pack",
|
|
34
|
-
"test": "
|
|
41
|
+
"test": "vitest",
|
|
35
42
|
"lint": "eslint --fix .",
|
|
36
43
|
"prepublishOnly": "npm run lint && npm test && npm run build"
|
|
37
44
|
},
|
|
38
|
-
"gitHead": "
|
|
45
|
+
"gitHead": "263638b9fd29395dcb64c33dfc2197df47f526af",
|
|
39
46
|
"devDependencies": {
|
|
40
|
-
"@streamflow/eslint-config": "
|
|
41
|
-
"@types/bn.js": "5.1.1",
|
|
47
|
+
"@streamflow/eslint-config": "7.0.0-alpha.10",
|
|
42
48
|
"@types/ethereum-checksum-address": "^0.0.0",
|
|
43
|
-
"@types/jest": "29.2.4",
|
|
44
49
|
"date-fns": "2.28.0",
|
|
45
|
-
"jest": "29.3.1",
|
|
46
|
-
"ts-jest": "29.0.3",
|
|
47
50
|
"typescript": "^5.3.3"
|
|
48
51
|
},
|
|
49
52
|
"dependencies": {
|
|
@@ -54,15 +57,14 @@
|
|
|
54
57
|
"@solana/spl-token": "0.3.6",
|
|
55
58
|
"@solana/wallet-adapter-base": "0.9.19",
|
|
56
59
|
"@solana/web3.js": "1.90.2",
|
|
57
|
-
"@streamflow/common": "
|
|
60
|
+
"@streamflow/common": "7.0.0-alpha.10",
|
|
58
61
|
"@suiet/wallet-kit": "0.2.22",
|
|
59
62
|
"aptos": "1.21.0",
|
|
60
|
-
"
|
|
63
|
+
"bignumber.js": "^9.1.2",
|
|
61
64
|
"borsh": "^2.0.0",
|
|
62
65
|
"bs58": "5.0.0",
|
|
63
66
|
"ethereum-checksum-address": "0.0.8",
|
|
64
67
|
"ethers": "5.7.2",
|
|
65
|
-
"
|
|
66
|
-
"p-queue": "^6.6.2"
|
|
68
|
+
"p-queue": "^8.0.1"
|
|
67
69
|
}
|
|
68
70
|
}
|
|
@@ -1,161 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
-
function step(op) {
|
|
27
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
29
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
30
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
-
switch (op[0]) {
|
|
32
|
-
case 0: case 1: t = op; break;
|
|
33
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
-
default:
|
|
37
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
-
if (t[2]) _.ops.pop();
|
|
42
|
-
_.trys.pop(); continue;
|
|
43
|
-
}
|
|
44
|
-
op = body.call(thisArg, _);
|
|
45
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
-
}
|
|
48
|
-
};
|
|
49
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
50
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
51
|
-
};
|
|
52
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
53
|
-
var bn_js_1 = require("bn.js");
|
|
54
|
-
var StreamClient_1 = __importDefault(require("../../aptos/StreamClient"));
|
|
55
|
-
var types_1 = require("../../common/types");
|
|
56
|
-
describe("AptosStreamClient", function () {
|
|
57
|
-
describe("init", function () {
|
|
58
|
-
it("should successfully create AptosStreamInstance", function () {
|
|
59
|
-
var instance = new StreamClient_1.default(types_1.ICluster.Devnet);
|
|
60
|
-
expect(instance).toBeInstanceOf(StreamClient_1.default);
|
|
61
|
-
});
|
|
62
|
-
it("should correctly set passed params", function () {
|
|
63
|
-
var pid = "PID";
|
|
64
|
-
var gas = "30";
|
|
65
|
-
var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
|
|
66
|
-
expect(instance.getMaxGas()).toEqual({ max_gas_amount: gas });
|
|
67
|
-
expect(instance.getProgramId()).toBe(pid);
|
|
68
|
-
});
|
|
69
|
-
});
|
|
70
|
-
describe("create", function () {
|
|
71
|
-
var pid = "PID";
|
|
72
|
-
var gas = "30";
|
|
73
|
-
var instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
|
|
74
|
-
beforeEach(function () {
|
|
75
|
-
instance = new StreamClient_1.default("https://cluster", types_1.ICluster.Devnet, gas, pid);
|
|
76
|
-
});
|
|
77
|
-
test("should create a stream with passed parameters", function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
78
|
-
var mockSigner, mockWallet, mockRecipient, mockData, mockReturn, result, callParam, args;
|
|
79
|
-
return __generator(this, function (_a) {
|
|
80
|
-
switch (_a.label) {
|
|
81
|
-
case 0:
|
|
82
|
-
mockSigner = jest.fn();
|
|
83
|
-
mockWallet = {
|
|
84
|
-
signAndSubmitTransaction: mockSigner,
|
|
85
|
-
account: { address: "" },
|
|
86
|
-
};
|
|
87
|
-
mockRecipient = {
|
|
88
|
-
recipient: "0xtest",
|
|
89
|
-
amount: new bn_js_1.BN(1000),
|
|
90
|
-
name: "test name",
|
|
91
|
-
cliffAmount: new bn_js_1.BN(1),
|
|
92
|
-
amountPerPeriod: new bn_js_1.BN(1),
|
|
93
|
-
};
|
|
94
|
-
mockData = {
|
|
95
|
-
period: 100,
|
|
96
|
-
start: 10,
|
|
97
|
-
cliff: 12,
|
|
98
|
-
cancelableBySender: true,
|
|
99
|
-
cancelableByRecipient: false,
|
|
100
|
-
transferableBySender: false,
|
|
101
|
-
transferableByRecipient: true,
|
|
102
|
-
canTopup: true,
|
|
103
|
-
automaticWithdrawal: false,
|
|
104
|
-
withdrawalFrequency: 10,
|
|
105
|
-
tokenId: "0xtest::token::Token",
|
|
106
|
-
canPause: false,
|
|
107
|
-
canUpdateRate: false,
|
|
108
|
-
};
|
|
109
|
-
mockReturn = "hash";
|
|
110
|
-
mockSigner.mockResolvedValue({ hash: mockReturn });
|
|
111
|
-
return [4 /*yield*/, instance.create(__assign(__assign({}, mockData), mockRecipient), { senderWallet: mockWallet })];
|
|
112
|
-
case 1:
|
|
113
|
-
result = _a.sent();
|
|
114
|
-
// Assert
|
|
115
|
-
expect(mockSigner).toHaveBeenCalledTimes(1);
|
|
116
|
-
callParam = mockSigner.mock.calls[0][0];
|
|
117
|
-
args = callParam.arguments;
|
|
118
|
-
delete callParam.arguments;
|
|
119
|
-
args.shift();
|
|
120
|
-
expect(args).toEqual([
|
|
121
|
-
mockRecipient.amount.toString(),
|
|
122
|
-
100,
|
|
123
|
-
mockRecipient.amountPerPeriod.toString(),
|
|
124
|
-
10,
|
|
125
|
-
mockRecipient.cliffAmount.toString(),
|
|
126
|
-
true,
|
|
127
|
-
false,
|
|
128
|
-
false,
|
|
129
|
-
true,
|
|
130
|
-
true,
|
|
131
|
-
false,
|
|
132
|
-
false,
|
|
133
|
-
false,
|
|
134
|
-
10,
|
|
135
|
-
"test name",
|
|
136
|
-
"0xtest",
|
|
137
|
-
]);
|
|
138
|
-
expect(callParam).toEqual({
|
|
139
|
-
function: "PID::protocol::create",
|
|
140
|
-
type: "create",
|
|
141
|
-
type_arguments: ["0xtest::token::Token"],
|
|
142
|
-
});
|
|
143
|
-
expect(result.txId).toEqual(mockReturn);
|
|
144
|
-
return [2 /*return*/];
|
|
145
|
-
}
|
|
146
|
-
});
|
|
147
|
-
}); });
|
|
148
|
-
});
|
|
149
|
-
// describe("createMultiple", () => {
|
|
150
|
-
// });
|
|
151
|
-
// describe("withdraw", () => {
|
|
152
|
-
// });
|
|
153
|
-
// describe("cancel", () => {
|
|
154
|
-
// });
|
|
155
|
-
// describe("transfer", () => {
|
|
156
|
-
// });
|
|
157
|
-
// describe("topup", () => {
|
|
158
|
-
// });
|
|
159
|
-
// describe("getOne", () => {
|
|
160
|
-
// });
|
|
161
|
-
});
|
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
var ethers_1 = require("ethers");
|
|
7
|
-
var index_1 = require("../../index");
|
|
8
|
-
var GenericStreamClient_1 = __importDefault(require("../../common/GenericStreamClient"));
|
|
9
|
-
var types_1 = require("../../common/types");
|
|
10
|
-
describe("GenericStreamClient", function () {
|
|
11
|
-
describe.each([
|
|
12
|
-
{
|
|
13
|
-
chain: types_1.IChain.Aptos,
|
|
14
|
-
cluster: types_1.ICluster.Devnet,
|
|
15
|
-
clusterUrl: "https://cluster",
|
|
16
|
-
expected: index_1.StreamflowAptos.AptosStreamClient,
|
|
17
|
-
},
|
|
18
|
-
{
|
|
19
|
-
chain: types_1.IChain.Solana,
|
|
20
|
-
cluster: types_1.ICluster.Devnet,
|
|
21
|
-
clusterUrl: "https://cluster",
|
|
22
|
-
expected: index_1.StreamflowSolana.SolanaStreamClient,
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
chain: types_1.IChain.Ethereum,
|
|
26
|
-
cluster: types_1.ICluster.Devnet,
|
|
27
|
-
clusterUrl: "https://cluster",
|
|
28
|
-
signer: ethers_1.Wallet.createRandom(),
|
|
29
|
-
expected: index_1.StreamflowEVM.EvmStreamClient,
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
chain: types_1.IChain.Sui,
|
|
33
|
-
cluster: types_1.ICluster.Devnet,
|
|
34
|
-
clusterUrl: "https://cluster",
|
|
35
|
-
expected: index_1.StreamflowSui.SuiStreamClient,
|
|
36
|
-
},
|
|
37
|
-
])(".init($chain)", function (config) {
|
|
38
|
-
it("should successfully create GenericStreamClient instance", function () {
|
|
39
|
-
var instance = new GenericStreamClient_1.default(config);
|
|
40
|
-
expect(instance).toBeInstanceOf(GenericStreamClient_1.default);
|
|
41
|
-
expect(instance.nativeStreamClient).toBeInstanceOf(config.expected);
|
|
42
|
-
});
|
|
43
|
-
});
|
|
44
|
-
});
|