@cardano-sdk/e2e 0.49.8 → 0.51.0
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/.env.example +2 -0
- package/CHANGELOG.md +33 -0
- package/dist/cjs/environment.d.ts +4 -2
- package/dist/cjs/environment.d.ts.map +1 -1
- package/dist/cjs/environment.js +4 -0
- package/dist/cjs/environment.js.map +1 -1
- package/dist/cjs/factories.d.ts +4 -2
- package/dist/cjs/factories.d.ts.map +1 -1
- package/dist/cjs/factories.js +18 -3
- package/dist/cjs/factories.js.map +1 -1
- package/dist/cjs/scripts/mnemonic.js +1 -1
- package/dist/cjs/scripts/mnemonic.js.map +1 -1
- package/dist/cjs/tools/multi-delegation-data-gen/index.js +3 -2
- package/dist/cjs/tools/multi-delegation-data-gen/index.js.map +1 -1
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.d.ts +18 -3
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.d.ts.map +1 -1
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.js +6 -7
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.js.map +1 -1
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/util/createMockKeyAgent.d.ts +1 -1
- package/dist/cjs/util/createMockKeyAgent.d.ts.map +1 -1
- package/dist/cjs/util/createMockKeyAgent.js +2 -2
- package/dist/cjs/util/createMockKeyAgent.js.map +1 -1
- package/dist/esm/environment.d.ts +4 -2
- package/dist/esm/environment.d.ts.map +1 -1
- package/dist/esm/environment.js +4 -0
- package/dist/esm/environment.js.map +1 -1
- package/dist/esm/factories.d.ts +4 -2
- package/dist/esm/factories.d.ts.map +1 -1
- package/dist/esm/factories.js +18 -3
- package/dist/esm/factories.js.map +1 -1
- package/dist/esm/scripts/mnemonic.js +1 -1
- package/dist/esm/scripts/mnemonic.js.map +1 -1
- package/dist/esm/tools/multi-delegation-data-gen/index.js +3 -2
- package/dist/esm/tools/multi-delegation-data-gen/index.js.map +1 -1
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.d.ts +18 -3
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.d.ts.map +1 -1
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.js +6 -7
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.js.map +1 -1
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/util/createMockKeyAgent.d.ts +1 -1
- package/dist/esm/util/createMockKeyAgent.d.ts.map +1 -1
- package/dist/esm/util/createMockKeyAgent.js +2 -2
- package/dist/esm/util/createMockKeyAgent.js.map +1 -1
- package/package.json +19 -19
- package/src/environment.ts +4 -0
- package/src/factories.ts +44 -6
- package/src/scripts/mnemonic.ts +1 -1
- package/src/tools/multi-delegation-data-gen/index.ts +8 -2
- package/src/tools/multi-delegation-data-gen/utils/utils.ts +10 -9
- package/src/util/createMockKeyAgent.ts +4 -2
- package/test/artillery/wallet-restoration/WalletRestoration.ts +1 -1
- package/test/load-test-custom/wallet-init/wallet-init.test.ts +6 -0
- package/test/load-test-custom/wallet-restoration/wallet-restoration.test.ts +1 -1
- package/test/local-network/register-pool.test.ts +2 -2
- package/test/long-running/multisig-wallet/MultiSigWallet.ts +2 -2
- package/test/long-running/multisig-wallet/multisig-delegation-rewards.test.ts +6 -2
- package/test/wallet_epoch_3/PersonalWallet/conwayTransactions.test.ts +13 -6
- package/test/wallet_epoch_3/PersonalWallet/delegation.test.ts +26 -13
- package/test/wallet_epoch_3/PersonalWallet/delegationDistribution.test.ts +18 -9
- package/test/wallet_epoch_3/PersonalWallet/drepRetirement.test.ts +20 -9
- package/test/wallet_epoch_3/SharedWallet/delegation.test.ts +25 -13
- package/test/web-extension/extension/ui.ts +43 -37
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
import * as Crypto from '@cardano-sdk/crypto';
|
|
4
4
|
import { BaseWallet } from '@cardano-sdk/wallet';
|
|
5
|
-
import { Cardano, setInConwayEra } from '@cardano-sdk/core';
|
|
5
|
+
import { Cardano, StakePoolProvider, setInConwayEra } from '@cardano-sdk/core';
|
|
6
6
|
import { logger } from '@cardano-sdk/util-dev';
|
|
7
7
|
|
|
8
8
|
import { filter, firstValueFrom, map } from 'rxjs';
|
|
@@ -48,17 +48,18 @@ const anchor = {
|
|
|
48
48
|
};
|
|
49
49
|
|
|
50
50
|
const getTestWallet = async (idx: number, name: string, minCoinBalance?: bigint) => {
|
|
51
|
-
const
|
|
51
|
+
const testWallet = await getWallet({ env, idx, logger, name, polling: { interval: 50 } });
|
|
52
52
|
|
|
53
|
-
await walletReady(wallet, minCoinBalance);
|
|
53
|
+
await walletReady(testWallet.wallet, minCoinBalance);
|
|
54
54
|
|
|
55
|
-
return
|
|
55
|
+
return testWallet;
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
describe('PersonalWallet/drepRetirement', () => {
|
|
59
59
|
let dRepWallet1: BaseWallet;
|
|
60
60
|
let dRepWallet2: BaseWallet;
|
|
61
61
|
let delegatingWallet: BaseWallet;
|
|
62
|
+
let stakePoolProvider: StakePoolProvider;
|
|
62
63
|
|
|
63
64
|
let dRepCredential1: Cardano.Credential & { type: Cardano.CredentialType.KeyHash };
|
|
64
65
|
let drepId1: Cardano.DRepID;
|
|
@@ -91,7 +92,7 @@ describe('PersonalWallet/drepRetirement', () => {
|
|
|
91
92
|
};
|
|
92
93
|
|
|
93
94
|
const getPoolIds = async () => {
|
|
94
|
-
const activePools = await
|
|
95
|
+
const activePools = await stakePoolProvider.queryStakePools({
|
|
95
96
|
filters: { status: [StakePoolStatus.Active] },
|
|
96
97
|
pagination: { limit: 2, startAt: 0 }
|
|
97
98
|
});
|
|
@@ -105,7 +106,7 @@ describe('PersonalWallet/drepRetirement', () => {
|
|
|
105
106
|
);
|
|
106
107
|
|
|
107
108
|
return rewardAccounts.map((rewardAccount) => ({
|
|
108
|
-
hash:
|
|
109
|
+
hash: RewardAccount.toHash(rewardAccount),
|
|
109
110
|
type: CredentialType.KeyHash
|
|
110
111
|
}));
|
|
111
112
|
};
|
|
@@ -156,7 +157,14 @@ describe('PersonalWallet/drepRetirement', () => {
|
|
|
156
157
|
// TODO: remove once mainnet hardforks to conway-era, and this becomes "the norm"
|
|
157
158
|
setInConwayEra(true);
|
|
158
159
|
|
|
159
|
-
[
|
|
160
|
+
[
|
|
161
|
+
{
|
|
162
|
+
wallet: delegatingWallet,
|
|
163
|
+
providers: { stakePoolProvider }
|
|
164
|
+
},
|
|
165
|
+
{ wallet: dRepWallet1 },
|
|
166
|
+
{ wallet: dRepWallet2 }
|
|
167
|
+
] = await Promise.all([
|
|
160
168
|
getTestWallet(0, 'wallet-delegating', 100_000_000n),
|
|
161
169
|
getTestWallet(1, 'wallet-DRep1', 0n),
|
|
162
170
|
getTestWallet(2, 'wallet-DRep2', 0n)
|
|
@@ -254,13 +262,16 @@ describe('PersonalWallet/drepRetirement', () => {
|
|
|
254
262
|
]);
|
|
255
263
|
});
|
|
256
264
|
|
|
257
|
-
|
|
265
|
+
// TODO: this was broken when refactoring to partial tx history
|
|
266
|
+
// tx history vote delegation change only triggers refetch of *that* reward account delegations.
|
|
267
|
+
// behavior asserted in this test is not a strict requirement - we could accept current behavior.
|
|
268
|
+
it.skip('tx history vote delegation change triggers refresh of all delegations', async () => {
|
|
258
269
|
// Retire DRep2
|
|
259
270
|
await sendDRepRegCert(dRepWallet2, false);
|
|
260
271
|
|
|
261
272
|
// Create a clone of the delegatingWallet and change drep delegation.
|
|
262
273
|
// The delegatingWallet tx history will update, which will trigger a refetch of all dreps, including DRep2 which was retired.
|
|
263
|
-
const delegatingWalletClone = await getTestWallet(0, 'wallet-delegating-clone', 0n);
|
|
274
|
+
const delegatingWalletClone = (await getTestWallet(0, 'wallet-delegating-clone', 0n)).wallet;
|
|
264
275
|
const signedTx = await delegatingWalletClone
|
|
265
276
|
.createTxBuilder()
|
|
266
277
|
.customize(({ txBody }) => ({
|
|
@@ -32,7 +32,10 @@ const getWalletStateSnapshot = async (wallet: ObservableWallet) => {
|
|
|
32
32
|
return {
|
|
33
33
|
balance: { available: balanceAvailable, deposit, total: balanceTotal },
|
|
34
34
|
epoch: epoch.epochNo,
|
|
35
|
-
isStakeCredentialRegistered:
|
|
35
|
+
isStakeCredentialRegistered: [
|
|
36
|
+
Cardano.StakeCredentialStatus.Registered,
|
|
37
|
+
Cardano.StakeCredentialStatus.Registering
|
|
38
|
+
].includes(rewardAccount.credentialStatus),
|
|
36
39
|
publicStakeKey,
|
|
37
40
|
rewardAccount,
|
|
38
41
|
rewardsBalance,
|
|
@@ -217,21 +220,30 @@ describe('SharedWallet/delegation', () => {
|
|
|
217
220
|
// Updates total and available balance after tx is on-chain
|
|
218
221
|
expect(tx1ConfirmedState.balance.total.coins).toBe(expectedCoinsAfterTx1);
|
|
219
222
|
expect(tx1ConfirmedState.balance.total).toEqual(tx1ConfirmedState.balance.available);
|
|
220
|
-
expect(
|
|
223
|
+
expect(tx1ConfirmedState.balance.deposit).toEqual(stakeKeyDeposit);
|
|
221
224
|
|
|
222
225
|
// If less than two epochs have elapsed, delegatee will still delegate to former pool during current epoch
|
|
223
226
|
// if more than two epochs has elapsed, delegatee will delegate to new pool.
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
initialState
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
227
|
+
const numEpochsPassed = tx1ConfirmedState.epoch - initialState.epoch;
|
|
228
|
+
expect(tx1ConfirmedState.rewardAccount.delegatee?.currentEpoch?.id).toEqual(
|
|
229
|
+
numEpochsPassed === 0
|
|
230
|
+
? initialState?.rewardAccount.delegatee?.currentEpoch?.id
|
|
231
|
+
: numEpochsPassed === 1
|
|
232
|
+
? !initialState.isStakeCredentialRegistered
|
|
233
|
+
? initialState?.rewardAccount.delegatee?.nextEpoch?.id
|
|
234
|
+
: poolId
|
|
235
|
+
: poolId
|
|
236
|
+
);
|
|
237
|
+
expect(tx1ConfirmedState.rewardAccount.delegatee?.nextEpoch?.id).toEqual(
|
|
238
|
+
initialState.isStakeCredentialRegistered
|
|
239
|
+
? poolId
|
|
240
|
+
: numEpochsPassed === 0
|
|
241
|
+
? initialState?.rewardAccount.delegatee?.nextEpoch?.id
|
|
242
|
+
: numEpochsPassed === 1
|
|
243
|
+
? initialState?.rewardAccount.delegatee?.nextNextEpoch?.id
|
|
244
|
+
: poolId
|
|
245
|
+
);
|
|
246
|
+
expect(tx1ConfirmedState.rewardAccount.delegatee?.nextNextEpoch?.id).toEqual(poolId);
|
|
235
247
|
|
|
236
248
|
expect(tx1ConfirmedState.rewardAccount.credentialStatus).toBe(Cardano.StakeCredentialStatus.Registered);
|
|
237
249
|
|
|
@@ -193,47 +193,53 @@ const cleanupMultidelegationInfo = (multiDelegationDiv: Element) => {
|
|
|
193
193
|
}
|
|
194
194
|
};
|
|
195
195
|
|
|
196
|
-
const signingCoordinator = new SigningCoordinator(
|
|
197
|
-
{
|
|
198
|
-
hwOptions: {
|
|
199
|
-
communicationType: CommunicationType.Web,
|
|
200
|
-
manifest: {
|
|
201
|
-
appUrl: 'https://web-extension.app',
|
|
202
|
-
email: 'e2e@web-extension.app'
|
|
203
|
-
}
|
|
204
|
-
}
|
|
205
|
-
},
|
|
206
|
-
{
|
|
207
|
-
keyAgentFactory: createKeyAgentFactory({
|
|
208
|
-
bip32Ed25519: new Crypto.SodiumBip32Ed25519(),
|
|
209
|
-
logger
|
|
210
|
-
}),
|
|
211
|
-
logger
|
|
212
|
-
}
|
|
213
|
-
);
|
|
214
|
-
|
|
215
196
|
const passphraseByteArray = Uint8Array.from(
|
|
216
197
|
env.KEY_MANAGEMENT_PARAMS.passphrase.split('').map((letter) => letter.charCodeAt(0))
|
|
217
198
|
);
|
|
218
|
-
merge(signingCoordinator.signDataRequest$, signingCoordinator.transactionWitnessRequest$).subscribe((req) => {
|
|
219
|
-
logger.info('Sign request', req);
|
|
220
|
-
if (req.walletType === WalletType.InMemory) {
|
|
221
|
-
void req.sign(new Uint8Array(passphraseByteArray));
|
|
222
|
-
} else {
|
|
223
|
-
void req.sign();
|
|
224
|
-
}
|
|
225
|
-
logger.info('Signed', req);
|
|
226
|
-
});
|
|
227
199
|
|
|
228
|
-
|
|
200
|
+
const initSigningCoordinator = async () => {
|
|
201
|
+
const bip32Ed25519 = await Crypto.SodiumBip32Ed25519.create();
|
|
229
202
|
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
203
|
+
const signingCoordinator = new SigningCoordinator(
|
|
204
|
+
{
|
|
205
|
+
hwOptions: {
|
|
206
|
+
communicationType: CommunicationType.Web,
|
|
207
|
+
manifest: {
|
|
208
|
+
appUrl: 'https://web-extension.app',
|
|
209
|
+
email: 'e2e@web-extension.app'
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
keyAgentFactory: createKeyAgentFactory({
|
|
215
|
+
bip32Ed25519,
|
|
216
|
+
logger
|
|
217
|
+
}),
|
|
218
|
+
logger
|
|
219
|
+
}
|
|
220
|
+
);
|
|
221
|
+
|
|
222
|
+
merge(signingCoordinator.signDataRequest$, signingCoordinator.transactionWitnessRequest$).subscribe((req) => {
|
|
223
|
+
logger.info('Sign request', req);
|
|
224
|
+
if (req.walletType === WalletType.InMemory) {
|
|
225
|
+
void req.sign(new Uint8Array(passphraseByteArray));
|
|
226
|
+
} else {
|
|
227
|
+
void req.sign();
|
|
228
|
+
}
|
|
229
|
+
logger.info('Signed', req);
|
|
230
|
+
});
|
|
231
|
+
|
|
232
|
+
exposeSigningCoordinatorApi(
|
|
233
|
+
{
|
|
234
|
+
signingCoordinator
|
|
235
|
+
},
|
|
236
|
+
{ logger, runtime }
|
|
237
|
+
);
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
initSigningCoordinator().catch((error) => {
|
|
241
|
+
logger.error('Error initializing Signing Coordinator:', error);
|
|
242
|
+
});
|
|
237
243
|
|
|
238
244
|
// Consume remote objects.
|
|
239
245
|
const walletManager = consumeRemoteApi(
|
|
@@ -278,7 +284,7 @@ const createWalletIfNotExistsAndActivate = async (accountIndex: number) => {
|
|
|
278
284
|
if (!walletId) {
|
|
279
285
|
logger.log('creating wallet');
|
|
280
286
|
clearWalletValues();
|
|
281
|
-
const bip32Ed25519 =
|
|
287
|
+
const bip32Ed25519 = await SodiumBip32Ed25519.create();
|
|
282
288
|
const mnemonicWords = env.KEY_MANAGEMENT_PARAMS.mnemonic.split(' ');
|
|
283
289
|
const encryptedMnemonic = await emip3encrypt(Buffer.from(env.KEY_MANAGEMENT_PARAMS.mnemonic), passphraseByteArray);
|
|
284
290
|
const passphrase = new Uint8Array(passphraseByteArray);
|