@towns-protocol/sdk 0.0.218 → 0.0.220
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.
|
@@ -6,28 +6,37 @@ import { makeUserStreamId } from '../../id';
|
|
|
6
6
|
import { getNftRuleData, linkWallets, unlinkWallet, setupChannelWithCustomRole, expectUserCanJoinChannel, waitFor, } from '../testUtils';
|
|
7
7
|
import { dlog } from '@towns-protocol/dlog';
|
|
8
8
|
import { TestERC721 } from '@towns-protocol/web3';
|
|
9
|
+
import { ethers } from 'ethers';
|
|
9
10
|
const log = dlog('csb:test:channelsWithEntitlements');
|
|
10
11
|
describe('channelScrubbing', () => {
|
|
11
12
|
test('User who loses entitlements is bounced after a channel scrub is triggered', async () => {
|
|
12
13
|
const TestNftName = 'TestNFT';
|
|
13
14
|
const TestNftAddress = await TestERC721.getContractAddress(TestNftName);
|
|
14
|
-
const { alice,
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
15
|
+
const { alice, aliceSpaceDapp, aliceProvider, carol, carolSpaceDapp, carolProvider, spaceId, channelId, } = await setupChannelWithCustomRole([], getNftRuleData(TestNftAddress));
|
|
16
|
+
const aliceLinkedWallet = ethers.Wallet.createRandom();
|
|
17
|
+
const carolLinkedWallet = ethers.Wallet.createRandom();
|
|
18
|
+
// link wallets
|
|
19
|
+
await Promise.all([
|
|
20
|
+
linkWallets(aliceSpaceDapp, aliceProvider.wallet, aliceLinkedWallet),
|
|
21
|
+
linkWallets(carolSpaceDapp, carolProvider.wallet, carolLinkedWallet),
|
|
22
|
+
]);
|
|
23
|
+
// Mint the needed asset to Alice and Carol's linked wallets
|
|
18
24
|
log('Minting an NFT to alices linked wallet');
|
|
19
|
-
await
|
|
25
|
+
await Promise.all([
|
|
26
|
+
TestERC721.publicMint(TestNftName, aliceLinkedWallet.address),
|
|
27
|
+
TestERC721.publicMint(TestNftName, carolLinkedWallet.address),
|
|
28
|
+
]);
|
|
20
29
|
// Join alice to the channel based on her linked wallet credentials
|
|
21
30
|
await expectUserCanJoinChannel(alice, aliceSpaceDapp, spaceId, channelId);
|
|
22
|
-
await unlinkWallet(aliceSpaceDapp, aliceProvider.wallet,
|
|
31
|
+
await unlinkWallet(aliceSpaceDapp, aliceProvider.wallet, aliceLinkedWallet);
|
|
23
32
|
// Wait 5 seconds so the channel stream will become eligible for scrubbing
|
|
24
33
|
await new Promise((f) => setTimeout(f, 5000));
|
|
25
|
-
// When
|
|
34
|
+
// When carol's join event is added to the stream, it should trigger a scrub, and Alice
|
|
26
35
|
// should be booted from the stream since she unlinked her entitled wallet.
|
|
27
|
-
await
|
|
36
|
+
await expectUserCanJoinChannel(carol, carolSpaceDapp, spaceId, channelId);
|
|
28
37
|
const userStreamView = (await alice.waitForStream(makeUserStreamId(alice.userId))).view;
|
|
29
38
|
// Wait for alice's user stream to have the leave event
|
|
30
|
-
await waitFor(() => userStreamView.userContent.isMember(channelId, MembershipOp.SO_LEAVE));
|
|
39
|
+
await waitFor(() => expect(userStreamView.userContent.isMember(channelId, MembershipOp.SO_LEAVE)).toBe(true));
|
|
31
40
|
});
|
|
32
41
|
});
|
|
33
42
|
//# sourceMappingURL=channelScrubbing.test.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"channelScrubbing.test.js","sourceRoot":"","sources":["../../../src/tests/multi/channelScrubbing.test.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAA;AACpD,OAAO,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AAC3C,OAAO,EACH,cAAc,EACd,WAAW,EACX,YAAY,EACZ,0BAA0B,EAC1B,wBAAwB,EACxB,OAAO,GACV,MAAM,cAAc,CAAA;AACrB,OAAO,EAAE,IAAI,EAAE,MAAM,sBAAsB,CAAA;AAC3C,OAAO,EAAW,UAAU,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"channelScrubbing.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dist/index.js",
|
|
@@ -30,11 +30,11 @@
|
|
|
30
30
|
"@connectrpc/connect-node": "^2.0.0",
|
|
31
31
|
"@connectrpc/connect-web": "^2.0.0",
|
|
32
32
|
"@ethereumjs/util": "^8.0.1",
|
|
33
|
-
"@towns-protocol/dlog": "^0.0.
|
|
34
|
-
"@towns-protocol/encryption": "^0.0.
|
|
35
|
-
"@towns-protocol/generated": "^0.0.
|
|
36
|
-
"@towns-protocol/proto": "^0.0.
|
|
37
|
-
"@towns-protocol/web3": "^0.0.
|
|
33
|
+
"@towns-protocol/dlog": "^0.0.220",
|
|
34
|
+
"@towns-protocol/encryption": "^0.0.220",
|
|
35
|
+
"@towns-protocol/generated": "^0.0.220",
|
|
36
|
+
"@towns-protocol/proto": "^0.0.220",
|
|
37
|
+
"@towns-protocol/web3": "^0.0.220",
|
|
38
38
|
"browser-or-node": "^3.0.0",
|
|
39
39
|
"debug": "^4.3.4",
|
|
40
40
|
"dexie": "^4.0.7",
|
|
@@ -69,5 +69,5 @@
|
|
|
69
69
|
"files": [
|
|
70
70
|
"/dist"
|
|
71
71
|
],
|
|
72
|
-
"gitHead": "
|
|
72
|
+
"gitHead": "b821a1085b1c7ec45cf6012ebfdd96e16605ac39"
|
|
73
73
|
}
|