@cardano-sdk/e2e 0.14.0 → 0.14.2
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/CHANGELOG.md +16 -0
- package/dist/cjs/factories.d.ts +3 -2
- package/dist/cjs/factories.d.ts.map +1 -1
- package/dist/cjs/factories.js +0 -1
- package/dist/cjs/factories.js.map +1 -1
- package/dist/cjs/scripts/mnemonic.js +2 -2
- package/dist/cjs/scripts/mnemonic.js.map +1 -1
- package/dist/cjs/tools/multi-delegation-data-gen/index.d.ts +2 -0
- package/dist/cjs/tools/multi-delegation-data-gen/index.d.ts.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/index.js +64 -0
- package/dist/cjs/tools/multi-delegation-data-gen/index.js.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/config.d.ts +40 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/config.d.ts.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/config.js +110 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/config.js.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/files.d.ts +12 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/files.d.ts.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/files.js +66 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/files.js.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/index.d.ts +5 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/index.d.ts.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/index.js +21 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/index.js.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts +19 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js +107 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.d.ts +46 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.d.ts.map +1 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.js +172 -0
- package/dist/cjs/tools/multi-delegation-data-gen/utils/utils.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/cjs/util/index.d.ts +1 -0
- package/dist/cjs/util/index.d.ts.map +1 -1
- package/dist/cjs/util/index.js +1 -0
- package/dist/cjs/util/index.js.map +1 -1
- package/dist/cjs/util/util.d.ts +40 -0
- package/dist/cjs/util/util.d.ts.map +1 -0
- package/dist/cjs/util/util.js +171 -0
- package/dist/cjs/util/util.js.map +1 -0
- package/dist/esm/factories.d.ts +3 -2
- package/dist/esm/factories.d.ts.map +1 -1
- package/dist/esm/factories.js +0 -1
- 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.d.ts +2 -0
- package/dist/esm/tools/multi-delegation-data-gen/index.d.ts.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/index.js +59 -0
- package/dist/esm/tools/multi-delegation-data-gen/index.js.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/config.d.ts +40 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/config.d.ts.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/config.js +104 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/config.js.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/files.d.ts +12 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/files.d.ts.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/files.js +37 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/files.js.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/index.d.ts +5 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/index.d.ts.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/index.js +5 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/index.js.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts +19 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.d.ts.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js +100 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.js.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.d.ts +46 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.d.ts.map +1 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.js +153 -0
- package/dist/esm/tools/multi-delegation-data-gen/utils/utils.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/util/index.d.ts +1 -0
- package/dist/esm/util/index.d.ts.map +1 -1
- package/dist/esm/util/index.js +1 -0
- package/dist/esm/util/index.js.map +1 -1
- package/dist/esm/util/util.d.ts +40 -0
- package/dist/esm/util/util.d.ts.map +1 -0
- package/dist/esm/util/util.js +127 -0
- package/dist/esm/util/util.js.map +1 -0
- package/docker-compose.yml +3 -0
- package/local-network/README.md +1 -1
- package/local-network/scripts/make-babbage.sh +3 -1
- package/local-network/scripts/mint-handles.sh +52 -0
- package/local-network/scripts/mint-tokens.sh +1 -1
- package/local-network/scripts/start.sh +2 -0
- package/package.json +27 -18
- package/src/factories.ts +2 -3
- package/src/scripts/mnemonic.ts +1 -1
- package/src/tools/multi-delegation-data-gen/example.json +31 -0
- package/src/tools/multi-delegation-data-gen/index.ts +110 -0
- package/src/tools/multi-delegation-data-gen/utils/config.ts +112 -0
- package/src/tools/multi-delegation-data-gen/utils/files.ts +73 -0
- package/src/tools/multi-delegation-data-gen/utils/index.ts +4 -0
- package/src/tools/multi-delegation-data-gen/utils/terminal-progress-monitor.ts +147 -0
- package/src/tools/multi-delegation-data-gen/utils/utils.ts +416 -0
- package/src/util/index.ts +1 -0
- package/{test → src/util}/util.ts +4 -20
- package/test/artillery/wallet-restoration/WalletRestoration.ts +11 -3
- package/test/load-test-custom/wallet-init/wallet-init.test.ts +1 -1
- package/test/load-test-custom/wallet-restoration/wallet-restoration.test.ts +3 -3
- package/test/load-testing/tx-submit-load.test.ts +1 -2
- package/test/local-network/register-pool.test.ts +10 -2
- package/test/long-running/cache-invalidation.test.ts +7 -3
- package/test/long-running/delegation-rewards.test.ts +7 -4
- package/test/util.test.ts +1 -1
- package/test/wallet/PersonalWallet/byron.test.ts +1 -2
- package/test/wallet/PersonalWallet/delegation.test.ts +10 -2
- package/test/wallet/PersonalWallet/delegationDistribution.test.ts +3 -15
- package/test/wallet/PersonalWallet/handle.test.ts +10 -2
- package/test/wallet/PersonalWallet/metadata.test.ts +1 -2
- package/test/wallet/PersonalWallet/mint.test.ts +9 -2
- package/test/wallet/PersonalWallet/multiAddress.test.ts +16 -2
- package/test/wallet/PersonalWallet/multisignature.test.ts +9 -2
- package/test/wallet/PersonalWallet/nft.test.ts +10 -2
- package/test/wallet/PersonalWallet/phase2validation.test.ts +1 -2
- package/test/wallet/PersonalWallet/pouchDbWalletStores.test.ts +1 -2
- package/test/wallet/PersonalWallet/txChainHistory.test.ts +1 -2
- package/test/wallet/PersonalWallet/txChaining.test.ts +1 -2
- package/test/wallet/PersonalWallet/unspendableUtxos.test.ts +1 -2
package/dist/esm/util/index.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC"}
|
package/dist/esm/util/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,uBAAuB,CAAC;AACtC,cAAc,QAAQ,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import * as Crypto from '@cardano-sdk/crypto';
|
|
2
|
+
import { Cardano } from '@cardano-sdk/core';
|
|
3
|
+
import { Observable } from 'rxjs';
|
|
4
|
+
import { ObservableWallet, PersonalWallet } from '@cardano-sdk/wallet';
|
|
5
|
+
import { InMemoryKeyAgent, TransactionSigner } from '@cardano-sdk/key-management';
|
|
6
|
+
import { TestWallet } from '../factories';
|
|
7
|
+
export declare const firstValueFromTimed: <T>(observable$: Observable<T>, timeoutMessage?: string, timeoutAfter?: number) => Promise<T>;
|
|
8
|
+
export declare const waitForWalletStateSettle: (wallet: ObservableWallet, syncTimeout?: number) => Promise<boolean>;
|
|
9
|
+
export declare const insufficientFundsMessage: (address: Cardano.PaymentAddress, min: bigint, actual: bigint) => string;
|
|
10
|
+
export declare const walletReady: (wallet: ObservableWallet, minCoinBalance?: bigint, syncTimeout?: number) => Promise<[boolean, Cardano.Value]>;
|
|
11
|
+
export declare const normalizeTxBody: (body: Cardano.HydratedTxBody | Cardano.TxBody) => Cardano.TxBody | Cardano.HydratedTxBody;
|
|
12
|
+
export declare const txConfirmed: ({ tip$, transactions: { history$, outgoing: { failed$ } } }: ObservableWallet, { id }: Pick<Cardano.Tx, 'id'>, numConfirmations?: number) => Promise<Cardano.HydratedTx>;
|
|
13
|
+
export declare const submitAndConfirm: (wallet: ObservableWallet, tx: Cardano.Tx) => Promise<[string & {
|
|
14
|
+
__opaqueString: "TransactionId";
|
|
15
|
+
}, Cardano.HydratedTx]>;
|
|
16
|
+
export declare type RequestCoinsProps = {
|
|
17
|
+
wallet: ObservableWallet;
|
|
18
|
+
coins: Cardano.Lovelace;
|
|
19
|
+
};
|
|
20
|
+
export declare const requestCoins: ({ coins, wallet }: RequestCoinsProps) => Promise<void>;
|
|
21
|
+
export declare type TransferCoinsProps = {
|
|
22
|
+
fromWallet: ObservableWallet;
|
|
23
|
+
toWallet: ObservableWallet;
|
|
24
|
+
coins: Cardano.Lovelace;
|
|
25
|
+
};
|
|
26
|
+
export declare const transferCoins: ({ fromWallet, toWallet, coins }: TransferCoinsProps) => Promise<void>;
|
|
27
|
+
export declare const waitForEpoch: (wallet: Pick<ObservableWallet, 'currentEpoch$'>, waitForEpochNo: number) => Promise<number & {
|
|
28
|
+
__opaqueNumber: "EpochNo";
|
|
29
|
+
}>;
|
|
30
|
+
export declare const runningAgainstLocalNetwork: () => Promise<boolean>;
|
|
31
|
+
export declare const getTxConfirmationEpoch: (wallet: PersonalWallet, tx: Cardano.Tx<Cardano.TxBody>) => Promise<Cardano.EpochNo>;
|
|
32
|
+
export declare const submitCertificate: (certificate: Cardano.Certificate, wallet: TestWallet) => Promise<Cardano.Tx<Cardano.TxBody>>;
|
|
33
|
+
export declare const createStandaloneKeyAgent: (mnemonics: string[], genesis: Cardano.CompactGenesis, bip32Ed25519: Crypto.Bip32Ed25519) => Promise<InMemoryKeyAgent>;
|
|
34
|
+
export declare const burnTokens: ({ wallet, tokens, scripts, policySigners: extraSigners }: {
|
|
35
|
+
wallet: PersonalWallet;
|
|
36
|
+
tokens?: Cardano.TokenMap | undefined;
|
|
37
|
+
scripts: Cardano.Script[];
|
|
38
|
+
policySigners: TransactionSigner[];
|
|
39
|
+
}) => Promise<void>;
|
|
40
|
+
//# sourceMappingURL=util.d.ts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Q,EAAE,gBAAgB,CAAC;IAC3B,KAAK,EAAE,OAAO,CAAC,QAAQ,CAAC;CACzB,CAAC;AAEF,eAAO,MAAM,aAAa,oCAA2C,kBAAkB,kBActF,CAAC;AAEF,eAAO,MAAM,YAAY,WAAY,KAAK,gBAAgB,EAAE,eAAe,CAAC,kBAAkB,MAAM;;EAUnG,CAAC;AAEF,eAAO,MAAM,0BAA0B,wBAetC,CAAC;AASF,eAAO,MAAM,sBAAsB,WAAkB,cAAc,MAAM,QAAQ,EAAE,CAAC,QAAQ,MAAM,CAAC,6BAMlG,CAAC;AAQF,eAAO,MAAM,iBAAiB,gBAAuB,QAAQ,WAAW,UAAU,UAAU,wCAa3F,CAAC;AAWF,eAAO,MAAM,wBAAwB,cACxB,MAAM,EAAE,WACV,QAAQ,cAAc,gBACjB,OAAO,YAAY,8BAShC,CAAC;AAQJ,eAAO,MAAM,UAAU;YAMb,cAAc;;aAEb,QAAQ,MAAM,EAAE;mBACV,iBAAiB,EAAE;mBA0BnC,CAAC"}
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
import * as envalid from 'envalid';
|
|
2
|
+
import { Cardano, createSlotEpochCalc } from '@cardano-sdk/core';
|
|
3
|
+
import { EMPTY, catchError, combineLatest, distinctUntilChanged, filter, firstValueFrom, map, merge, mergeMap, switchMap, tap, throwError, timeout } from 'rxjs';
|
|
4
|
+
import { FAST_OPERATION_TIMEOUT_DEFAULT, SYNC_TIMEOUT_DEFAULT } from '../defaults';
|
|
5
|
+
import { InMemoryKeyAgent } from '@cardano-sdk/key-management';
|
|
6
|
+
import { faucetProviderFactory, networkInfoProviderFactory } from '../factories';
|
|
7
|
+
import { getEnv, walletVariables } from '../environment';
|
|
8
|
+
import { logger } from '@cardano-sdk/util-dev';
|
|
9
|
+
import sortBy from 'lodash/sortBy';
|
|
10
|
+
const env = getEnv(walletVariables);
|
|
11
|
+
export const firstValueFromTimed = (observable$, timeoutMessage = 'Timed out', timeoutAfter = FAST_OPERATION_TIMEOUT_DEFAULT) => firstValueFrom(observable$.pipe(timeout(timeoutAfter), catchError(() => throwError(() => new Error(timeoutMessage)))));
|
|
12
|
+
export const waitForWalletStateSettle = (wallet, syncTimeout = SYNC_TIMEOUT_DEFAULT) => firstValueFromTimed(wallet.syncStatus.isSettled$.pipe(filter((isSettled) => isSettled)), 'Took too long to settle', syncTimeout);
|
|
13
|
+
export const insufficientFundsMessage = (address, min, actual) => `Insufficient funds at ${address}. Expected ${min}, found ${actual} lovelace.
|
|
14
|
+
Please use a faucet to fund the address or another address with sufficient funds`;
|
|
15
|
+
export const walletReady = async (wallet, minCoinBalance = 1n, syncTimeout = SYNC_TIMEOUT_DEFAULT) => {
|
|
16
|
+
const [isSettled, balance, address] = await firstValueFromTimed(combineLatest([
|
|
17
|
+
wallet.syncStatus.isSettled$,
|
|
18
|
+
wallet.balance.utxo.total$,
|
|
19
|
+
wallet.addresses$.pipe(map((addresses) => addresses[0].address))
|
|
20
|
+
]).pipe(filter(([settled]) => settled)), 'Took too long to be ready', syncTimeout);
|
|
21
|
+
if (balance.coins < minCoinBalance) {
|
|
22
|
+
throw new Error(insufficientFundsMessage(address, minCoinBalance, balance.coins));
|
|
23
|
+
}
|
|
24
|
+
return [isSettled, balance];
|
|
25
|
+
};
|
|
26
|
+
const sortTxIn = (txInCollection) => sortBy(txInCollection, ['txId', 'index']);
|
|
27
|
+
export const normalizeTxBody = (body) => {
|
|
28
|
+
body.inputs = sortTxIn(body.inputs);
|
|
29
|
+
body.collaterals = sortTxIn(body.collaterals);
|
|
30
|
+
body.referenceInputs = sortTxIn(body.referenceInputs);
|
|
31
|
+
return body;
|
|
32
|
+
};
|
|
33
|
+
export const txConfirmed = ({ tip$, transactions: { history$, outgoing: { failed$ } } }, { id }, numConfirmations = 3) => firstValueFromTimed(merge(history$.pipe(switchMap((txs) => {
|
|
34
|
+
const tx = txs.find((historyTx) => historyTx.id === id);
|
|
35
|
+
if (!tx)
|
|
36
|
+
return EMPTY;
|
|
37
|
+
return tip$.pipe(filter(({ blockNo }) => blockNo >= Cardano.BlockNo(tx.blockHeader.blockNo + numConfirmations)), map(() => tx));
|
|
38
|
+
})), failed$.pipe(mergeMap((outgoingTx) => outgoingTx.id === id
|
|
39
|
+
? throwError(() => outgoingTx.error || new Error(`Tx failed due to '${outgoingTx.reason}': ${outgoingTx.id}`))
|
|
40
|
+
: EMPTY))), `Tx confirmation timeout: ${id}`, SYNC_TIMEOUT_DEFAULT / 5);
|
|
41
|
+
const submit = (wallet, tx) => wallet.submitTx(tx);
|
|
42
|
+
const confirm = (wallet, tx) => txConfirmed(wallet, tx);
|
|
43
|
+
export const submitAndConfirm = (wallet, tx) => Promise.all([submit(wallet, tx), confirm(wallet, tx)]);
|
|
44
|
+
export const requestCoins = async ({ coins, wallet }) => {
|
|
45
|
+
const [{ address }] = await firstValueFrom(wallet.addresses$);
|
|
46
|
+
logger.info(`Address ${address} will be funded with ${coins} tLovelace.`);
|
|
47
|
+
const { FAUCET_PROVIDER, FAUCET_PROVIDER_PARAMS } = envalid.cleanEnv(process.env, {
|
|
48
|
+
FAUCET_PROVIDER: envalid.str(),
|
|
49
|
+
FAUCET_PROVIDER_PARAMS: envalid.json({ default: {} })
|
|
50
|
+
});
|
|
51
|
+
const faucetProvider = await faucetProviderFactory.create(FAUCET_PROVIDER, FAUCET_PROVIDER_PARAMS, logger);
|
|
52
|
+
await faucetProvider.start();
|
|
53
|
+
const healthCheck = await faucetProvider.healthCheck();
|
|
54
|
+
if (!healthCheck.ok)
|
|
55
|
+
throw new Error('Faucet provider could not be started.');
|
|
56
|
+
const requestResult = await faucetProvider.request(address, Number.parseInt(coins.toString()), 3, 30000);
|
|
57
|
+
await txConfirmed(wallet, requestResult);
|
|
58
|
+
await faucetProvider.close();
|
|
59
|
+
};
|
|
60
|
+
export const transferCoins = async ({ fromWallet, toWallet, coins }) => {
|
|
61
|
+
const [{ address: sendingAddress }] = await firstValueFrom(fromWallet.addresses$);
|
|
62
|
+
const [{ address: receivingAddress }] = await firstValueFrom(toWallet.addresses$);
|
|
63
|
+
logger.info(`Address ${sendingAddress} will send ${coins} lovelace to address ${receivingAddress}.`);
|
|
64
|
+
const txBuilder = fromWallet.createTxBuilder();
|
|
65
|
+
const txOut = await txBuilder.buildOutput().address(receivingAddress).coin(coins).build();
|
|
66
|
+
const { tx: signedTx } = await txBuilder.addOutput(txOut).build().sign();
|
|
67
|
+
await Promise.all([fromWallet.submitTx(signedTx), txConfirmed(toWallet, signedTx)]);
|
|
68
|
+
};
|
|
69
|
+
export const waitForEpoch = (wallet, waitForEpochNo) => {
|
|
70
|
+
logger.info(`Waiting for epoch #${waitForEpochNo}`);
|
|
71
|
+
return firstValueFrom(wallet.currentEpoch$.pipe(map(({ epochNo }) => epochNo), distinctUntilChanged(), tap((epochNo) => logger.info(`Currently at epoch #${epochNo}`)), filter((currentEpochNo) => currentEpochNo >= waitForEpochNo)));
|
|
72
|
+
};
|
|
73
|
+
export const runningAgainstLocalNetwork = async () => {
|
|
74
|
+
const networkInfoProvider = await networkInfoProviderFactory.create(env.NETWORK_INFO_PROVIDER, env.NETWORK_INFO_PROVIDER_PARAMS, logger);
|
|
75
|
+
const { epochLength, slotLength } = await networkInfoProvider.genesisParameters();
|
|
76
|
+
const estimatedTestDurationInEpochs = 4;
|
|
77
|
+
const localNetworkEpochDuration = 1000 * 0.2;
|
|
78
|
+
const estimatedTestDuration = epochLength * slotLength * estimatedTestDurationInEpochs;
|
|
79
|
+
if (estimatedTestDuration > localNetworkEpochDuration * estimatedTestDurationInEpochs) {
|
|
80
|
+
return false;
|
|
81
|
+
}
|
|
82
|
+
return true;
|
|
83
|
+
};
|
|
84
|
+
export const getTxConfirmationEpoch = async (wallet, tx) => {
|
|
85
|
+
const txs = await firstValueFrom(wallet.transactions.history$.pipe(filter((_) => _.some(({ id }) => id === tx.id))));
|
|
86
|
+
const observedTx = txs.find(({ id }) => id === tx.id);
|
|
87
|
+
const slotEpochCalc = createSlotEpochCalc(await firstValueFrom(wallet.eraSummaries$));
|
|
88
|
+
return slotEpochCalc(observedTx.blockHeader.slot);
|
|
89
|
+
};
|
|
90
|
+
export const submitCertificate = async (certificate, wallet) => {
|
|
91
|
+
const walletAddress = (await firstValueFrom(wallet.wallet.addresses$))[0].address;
|
|
92
|
+
const txProps = {
|
|
93
|
+
certificates: [certificate],
|
|
94
|
+
outputs: new Set([{ address: walletAddress, value: { coins: 3000000n } }])
|
|
95
|
+
};
|
|
96
|
+
const unsignedTx = await wallet.wallet.initializeTx(txProps);
|
|
97
|
+
const signedTx = await wallet.wallet.finalizeTx({ tx: unsignedTx });
|
|
98
|
+
await submitAndConfirm(wallet.wallet, signedTx);
|
|
99
|
+
return signedTx;
|
|
100
|
+
};
|
|
101
|
+
export const createStandaloneKeyAgent = async (mnemonics, genesis, bip32Ed25519) => await InMemoryKeyAgent.fromBip39MnemonicWords({
|
|
102
|
+
chainId: genesis,
|
|
103
|
+
getPassphrase: async () => Buffer.from(''),
|
|
104
|
+
mnemonicWords: mnemonics
|
|
105
|
+
}, { bip32Ed25519, inputResolver: { resolveInput: async () => null }, logger });
|
|
106
|
+
export const burnTokens = async ({ wallet, tokens, scripts, policySigners: extraSigners }) => {
|
|
107
|
+
if (!tokens) {
|
|
108
|
+
tokens = (await firstValueFrom(wallet.balance.utxo.available$)).assets;
|
|
109
|
+
}
|
|
110
|
+
if (!tokens?.size) {
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
const negativeTokens = new Map([...tokens].map(([assetId, value]) => [assetId, -value]));
|
|
114
|
+
const txProps = {
|
|
115
|
+
mint: negativeTokens,
|
|
116
|
+
witness: { extraSigners, scripts }
|
|
117
|
+
};
|
|
118
|
+
const unsignedTx = await wallet.initializeTx(txProps);
|
|
119
|
+
const finalizeProps = {
|
|
120
|
+
tx: unsignedTx,
|
|
121
|
+
witness: { extraSigners, scripts }
|
|
122
|
+
};
|
|
123
|
+
const signedTx = await wallet.finalizeTx(finalizeProps);
|
|
124
|
+
await submitAndConfirm(wallet, signedTx);
|
|
125
|
+
await txConfirmed(wallet, signedTx);
|
|
126
|
+
};
|
|
127
|
+
//# sourceMappingURL=util.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"util.js","sourceRoot":"","sources":["../../../src/util/util.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,OAAO,MAAM,SAAS,CAAC;AACnC,OAAO,EAAE,OAAO,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AACjE,OAAO,EACL,KAAK,EAEL,UAAU,EACV,aAAa,EACb,oBAAoB,EACpB,MAAM,EACN,cAAc,EACd,GAAG,EACH,KAAK,EACL,QAAQ,EACR,SAAS,EACT,GAAG,EACH,UAAU,EACV,OAAO,EACR,MAAM,MAAM,CAAC;AACd,OAAO,EAAE,8BAA8B,EAAE,oBAAoB,EAAE,MAAM,aAAa,CAAC;AAEnF,OAAO,EAAE,gBAAgB,EAAqB,MAAM,6BAA6B,CAAC;AAElF,OAAO,EAAc,qBAAqB,EAAE,0BAA0B,EAAE,MAAM,cAAc,CAAC;AAC7F,OAAO,EAAE,MAAM,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AACzD,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,MAAM,MAAM,eAAe,CAAC;AAEnC,MAAM,GAAG,GAAG,MAAM,CAAC,eAAe,CAAC,CAAC;AAEpC,MAAM,CAAC,MAAM,mBAAmB,GAAG,CACjC,WAA0B,EAC1B,cAAc,GAAG,WAAW,EAC5B,YAAY,GAAG,8BAA8B,EAC7C,EAAE,CACF,cAAc,CACZ,WAAW,CAAC,IAAI,CACd,OAAO,CAAC,YAAY,CAAC,EACrB,UAAU,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,GAAG,EAAE,CAAC,IAAI,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC,CAC9D,CACF,CAAC;AAEJ,MAAM,CAAC,MAAM,wBAAwB,GAAG,CAAC,MAAwB,EA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EtD,MAAM,aAAa,GAAoB;QACrC,EAAE,EAAE,UAAU;QACd,OAAO,EAAE,EAAE,YAAY,EAAE,OAAO,EAAE;KACnC,CAAC;IAEF,MAAM,QAAQ,GAAG,MAAM,MAAM,CAAC,UAAU,CAAC,aAAa,CAAC,CAAC;IACxD,MAAM,gBAAgB,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACzC,MAAM,WAAW,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;AACtC,CAAC,CAAC"}
|
package/docker-compose.yml
CHANGED
package/local-network/README.md
CHANGED
|
@@ -21,7 +21,7 @@ Supported OS:
|
|
|
21
21
|
1. Run `./scripts/install.sh` to install necessary binaries.
|
|
22
22
|
2. Run `./scripts/make-babbage.sh` to create all the keys, certificates and genesis files.
|
|
23
23
|
3. Run `./scrips/start.sh` to start the nodes.
|
|
24
|
-
4. Run `export CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-
|
|
24
|
+
4. Run `export CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-sp1/node.sock` for `cardano-cli` to work.
|
|
25
25
|
5. (Optional) Run `export PATH=$PATH:$PWD/bin` so you can use `cardano-cli` instead of `./bin/cardano-cli`.
|
|
26
26
|
6. Check the network: `./bin/cardano-cli query tip --testnet-magic 888`
|
|
27
27
|
|
|
@@ -113,7 +113,9 @@ $SED -i "${ROOT}/configuration.yaml" \
|
|
|
113
113
|
-e '/ByronGenesisFile/ aAlonzoGenesisFile: genesis/shelley/genesis.alonzo.json' \
|
|
114
114
|
-e 's/RequiresNoMagic/RequiresMagic/' \
|
|
115
115
|
-e 's/LastKnownBlockVersion-Major: 0/LastKnownBlockVersion-Major: 6/' \
|
|
116
|
-
-e 's/LastKnownBlockVersion-Minor: 2/LastKnownBlockVersion-Minor: 0/'
|
|
116
|
+
-e 's/LastKnownBlockVersion-Minor: 2/LastKnownBlockVersion-Minor: 0/' \
|
|
117
|
+
-e "s/minSeverity: Info/minSeverity: ${CARDANO_NODE_LOG_LEVEL}/" \
|
|
118
|
+
-e "s/cardano.node.ChainDB: Notice/cardano.node.ChainDB: ${CARDANO_NODE_CHAINDB_LOG_LEVEL}/"
|
|
117
119
|
|
|
118
120
|
echo "" >> "${ROOT}/configuration.yaml"
|
|
119
121
|
echo "PBftSignatureThreshold: 0.6" >> "${ROOT}/configuration.yaml"
|
|
@@ -0,0 +1,52 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
|
|
3
|
+
handleNames=("HelloHandle" "TestHandle" "DoubleHandle")
|
|
4
|
+
handleHexes=("48656c6c6f48616e646c65" "5465737448616e646c65" "446f75626c6548616e646c65")
|
|
5
|
+
|
|
6
|
+
cat >network-files/utxo-keys/minting-policy.json <<EOL
|
|
7
|
+
{
|
|
8
|
+
"keyHash": "$(cardano-cli address key-hash --payment-verification-key-file network-files/utxo-keys/utxo1.vkey)",
|
|
9
|
+
"type": "sig"
|
|
10
|
+
}
|
|
11
|
+
EOL
|
|
12
|
+
|
|
13
|
+
# Generate the policy ID from the script file and save it
|
|
14
|
+
policyid=$(cardano-cli transaction policyid --script-file network-files/utxo-keys/minting-policy.json)
|
|
15
|
+
|
|
16
|
+
cat >network-files/utxo-keys/handles-metadata.json <<EOL
|
|
17
|
+
{ "721":
|
|
18
|
+
{"${policyid}":
|
|
19
|
+
{
|
|
20
|
+
"${handleNames[0]}": {"core": {"og": 0, "prefix": "$", "version": 0, "termsofuse": "https://cardanofoundation.org/en/terms-and-conditions/", "handleEncoding": "utf-8"}, "name": "${handleNames[0]}", "image": "ipfs://some-hash", "website": "https://cardano.org/", "description": "The Handle Standard", "augmentations": []},
|
|
21
|
+
"${handleNames[1]}": {"core": {"og": 0, "prefix": "$", "version": 0, "termsofuse": "https://cardanofoundation.org/en/terms-and-conditions/", "handleEncoding": "utf-8"}, "name": "${handleNames[1]}", "image": "ipfs://some-hash", "website": "https://cardano.org/", "description": "The Handle Standard", "augmentations": []},
|
|
22
|
+
"${handleNames[2]}": {"core": {"og": 0, "prefix": "$", "version": 0, "termsofuse": "https://cardanofoundation.org/en/terms-and-conditions/", "handleEncoding": "utf-8"}, "name": "${handleNames[2]}", "image": "ipfs://some-hash", "website": "https://cardano.org/", "description": "The Handle Standard", "augmentations": []},
|
|
23
|
+
"${handleNames[3]}": {"core": {"og": 0, "prefix": "$", "version": 0, "termsofuse": "https://cardanofoundation.org/en/terms-and-conditions/", "handleEncoding": "utf-8"}, "name": "${handleNames[3]}", "image": "ipfs://some-hash", "website": "https://cardano.org/", "description": "The Handle Standard", "augmentations": []}
|
|
24
|
+
}
|
|
25
|
+
}}
|
|
26
|
+
EOL
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
addr=$(cardano-cli address build --payment-verification-key-file network-files/utxo-keys/utxo1.vkey --testnet-magic 888)
|
|
30
|
+
faucetAddr="addr_test1qqen0wpmhg7fhkus45lyv4wju26cecgu6avplrnm6dgvuk6qel5hu3u3q0fht53ly97yx95hkt56j37ch07pesf6s4pqh5gd4e"
|
|
31
|
+
utxo=$(cardano-cli query utxo --address "$addr" --testnet-magic 888 | awk 'NR == 3 {printf("%s#%s", $1, $2)}')
|
|
32
|
+
|
|
33
|
+
tokenList="1 ${policyid}.${handleHexes[0]}+1 ${policyid}.${handleHexes[1]}+2 ${policyid}.${handleHexes[2]}"
|
|
34
|
+
|
|
35
|
+
cardano-cli transaction build \
|
|
36
|
+
--babbage-era \
|
|
37
|
+
--change-address "$addr" \
|
|
38
|
+
--tx-in "$utxo" \
|
|
39
|
+
--tx-out "$faucetAddr"+10000000+"$tokenList" \
|
|
40
|
+
--mint "$tokenList" \
|
|
41
|
+
--mint-script-file network-files/utxo-keys/minting-policy.json \
|
|
42
|
+
--metadata-json-file network-files/utxo-keys/handles-metadata.json \
|
|
43
|
+
--testnet-magic 888 \
|
|
44
|
+
--out-file handle-tx.raw
|
|
45
|
+
|
|
46
|
+
cardano-cli transaction sign \
|
|
47
|
+
--tx-body-file handle-tx.raw \
|
|
48
|
+
--signing-key-file network-files/utxo-keys/utxo1.skey \
|
|
49
|
+
--testnet-magic 888 \
|
|
50
|
+
--out-file handle-tx.signed
|
|
51
|
+
|
|
52
|
+
cardano-cli transaction submit --testnet-magic 888 --tx-file handle-tx.signed
|
|
@@ -32,6 +32,8 @@ done
|
|
|
32
32
|
CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-sp1/node.sock ./scripts/plutus-transaction.sh
|
|
33
33
|
CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-sp1/node.sock ./scripts/reference-input-transaction.sh
|
|
34
34
|
CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-sp1/node.sock ./scripts/mint-tokens.sh
|
|
35
|
+
sleep 10
|
|
36
|
+
CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-sp1/node.sock ./scripts/mint-handles.sh
|
|
35
37
|
CARDANO_NODE_SOCKET_PATH=$PWD/network-files/node-sp1/node.sock ./scripts/setup-wallets.sh
|
|
36
38
|
|
|
37
39
|
wait
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cardano-sdk/e2e",
|
|
3
|
-
"version": "0.14.
|
|
3
|
+
"version": "0.14.2",
|
|
4
4
|
"description": "End to end tests for the cardano-js-sdk packages.",
|
|
5
5
|
"engines": {
|
|
6
6
|
"node": ">=16.0"
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"test:web-extension:watch:run": "yarn test:web-extension:run --watch",
|
|
46
46
|
"test:web-extension:watch": "run-s test:web-extension:build test:web-extension:watch:bg",
|
|
47
47
|
"test:web-extension:watch:bg": "run-p test:web-extension:watch:build test:web-extension:watch:run",
|
|
48
|
-
"local-network:common": "USE_BLOCKFROST=false docker compose -p local-network-e2e -f docker-compose.yml -f ../../compose/common.yml $FILES up",
|
|
48
|
+
"local-network:common": "DISABLE_DB_CACHE=${DISABLE_DB_CACHE:-true} USE_BLOCKFROST=false docker compose -p local-network-e2e -f docker-compose.yml -f ../../compose/common.yml $FILES up",
|
|
49
49
|
"local-network:up": "FILES='' yarn local-network:common",
|
|
50
50
|
"local-network:dev": "FILES='-f ../../compose/dev.yml' yarn local-network:common",
|
|
51
51
|
"local-network:profile:up": "FILES='-f ../../compose/pg-agent.yml' yarn local-network:common",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"test:build:verify": "run-p test:web-extension:build test:build:verify:tsc",
|
|
71
71
|
"test:debug": "DEBUG=true yarn test",
|
|
72
72
|
"generate-mnemonics": "ts-node src/scripts/mnemonic.ts",
|
|
73
|
+
"multi-delegation-data-gen": "ts-node src/tools/multi-delegation-data-gen/index.ts",
|
|
73
74
|
"wait-for-network": "ts-node src/scripts/is-local-network-ready.ts"
|
|
74
75
|
},
|
|
75
76
|
"repository": "https://github.com/input-output-hk/cardano-js-sdk",
|
|
@@ -80,22 +81,26 @@
|
|
|
80
81
|
"dependencies": {
|
|
81
82
|
"@cardano-foundation/ledgerjs-hw-app-cardano": "^6.0.0",
|
|
82
83
|
"@cardano-ogmios/client": "5.6.0",
|
|
83
|
-
"@cardano-sdk/cardano-services": "~0.13.
|
|
84
|
-
"@cardano-sdk/cardano-services-client": "~0.9.
|
|
85
|
-
"@cardano-sdk/core": "~0.14.
|
|
84
|
+
"@cardano-sdk/cardano-services": "~0.13.2",
|
|
85
|
+
"@cardano-sdk/cardano-services-client": "~0.9.8",
|
|
86
|
+
"@cardano-sdk/core": "~0.14.1",
|
|
86
87
|
"@cardano-sdk/crypto": "~0.1.6",
|
|
87
|
-
"@cardano-sdk/hardware-ledger": "~0.2.
|
|
88
|
-
"@cardano-sdk/key-management": "~0.7.
|
|
89
|
-
"@cardano-sdk/ogmios": "~0.12.
|
|
90
|
-
"@cardano-sdk/tx-construction": "~0.7.
|
|
88
|
+
"@cardano-sdk/hardware-ledger": "~0.2.7",
|
|
89
|
+
"@cardano-sdk/key-management": "~0.7.6",
|
|
90
|
+
"@cardano-sdk/ogmios": "~0.12.4",
|
|
91
|
+
"@cardano-sdk/tx-construction": "~0.7.2",
|
|
91
92
|
"@cardano-sdk/util": "~0.11.0",
|
|
92
|
-
"@cardano-sdk/util-dev": "~0.13.
|
|
93
|
-
"@cardano-sdk/util-rxjs": "~0.4.
|
|
94
|
-
"@cardano-sdk/wallet": "~0.16.
|
|
93
|
+
"@cardano-sdk/util-dev": "~0.13.2",
|
|
94
|
+
"@cardano-sdk/util-rxjs": "~0.4.15",
|
|
95
|
+
"@cardano-sdk/wallet": "~0.16.2",
|
|
95
96
|
"@vespaiach/axios-fetch-adapter": "^0.3.0",
|
|
96
97
|
"axios": "^0.27.2",
|
|
97
98
|
"bunyan": "^1.8.15",
|
|
98
99
|
"cardano-wallet-js": "^1.4.0",
|
|
100
|
+
"chalk": "4.1.2",
|
|
101
|
+
"cli-spinners": "^2.9.0",
|
|
102
|
+
"convict": "^6.2.4",
|
|
103
|
+
"delay": "5.0.0",
|
|
99
104
|
"dotenv": "^16.0.1",
|
|
100
105
|
"envalid": "^7.3.1",
|
|
101
106
|
"get-port-please": "^2.5.0",
|
|
@@ -103,6 +108,7 @@
|
|
|
103
108
|
"k6": "^0.0.0",
|
|
104
109
|
"lodash": "^4.17.21",
|
|
105
110
|
"optionator": "^0.9.1",
|
|
111
|
+
"ora": "^3.2.0",
|
|
106
112
|
"pg": "^8.7.3",
|
|
107
113
|
"rxjs": "^7.4.0",
|
|
108
114
|
"ts-log": "^2.2.4",
|
|
@@ -116,15 +122,19 @@
|
|
|
116
122
|
"@babel/core": "^7.18.2",
|
|
117
123
|
"@babel/preset-env": "^7.18.2",
|
|
118
124
|
"@babel/preset-typescript": "^7.17.12",
|
|
119
|
-
"@cardano-sdk/dapp-connector": "~0.9.
|
|
120
|
-
"@cardano-sdk/projection": "~0.6.
|
|
121
|
-
"@cardano-sdk/projection-typeorm": "~0.3.
|
|
122
|
-
"@cardano-sdk/web-extension": "~0.12.
|
|
125
|
+
"@cardano-sdk/dapp-connector": "~0.9.6",
|
|
126
|
+
"@cardano-sdk/projection": "~0.6.8",
|
|
127
|
+
"@cardano-sdk/projection-typeorm": "~0.3.4",
|
|
128
|
+
"@cardano-sdk/web-extension": "~0.12.4",
|
|
123
129
|
"@dcspark/cardano-multiplatform-lib-browser": "^3.1.1",
|
|
124
130
|
"@emurgo/cardano-message-signing-asmjs": "^1.0.1",
|
|
125
131
|
"@types/bunyan": "^1.8.8",
|
|
132
|
+
"@types/chalk": "^2.2.0",
|
|
133
|
+
"@types/convict": "^6.1.2",
|
|
134
|
+
"@types/delay": "^3.1.0",
|
|
126
135
|
"@types/jest": "^28.1.2",
|
|
127
136
|
"@types/lodash": "^4.14.182",
|
|
137
|
+
"@types/ora": "^3.2.0",
|
|
128
138
|
"@types/uuid": "^8.3.4",
|
|
129
139
|
"@types/webextension-polyfill": "^0.8.0",
|
|
130
140
|
"@wdio/cli": "^7.19.5",
|
|
@@ -138,7 +148,6 @@
|
|
|
138
148
|
"buffer": "^6.0.3",
|
|
139
149
|
"chromedriver": "^112.0.0",
|
|
140
150
|
"copy-webpack-plugin": "^10.2.4",
|
|
141
|
-
"delay": "^5.0.0",
|
|
142
151
|
"eslint": "^7.32.0",
|
|
143
152
|
"events": "^3.3.0",
|
|
144
153
|
"expect-webdriverio": "^3.2.1",
|
|
@@ -164,5 +173,5 @@
|
|
|
164
173
|
"webpack-cli": "^4.9.2",
|
|
165
174
|
"webpack-merge": "^5.8.0"
|
|
166
175
|
},
|
|
167
|
-
"gitHead": "
|
|
176
|
+
"gitHead": "badfa920af582c12079ce55bf74ba7337d9cc3cb"
|
|
168
177
|
}
|
package/src/factories.ts
CHANGED
|
@@ -76,7 +76,7 @@ export const utxoProviderFactory = new ProviderFactory<UtxoProvider>();
|
|
|
76
76
|
export const stakePoolProviderFactory = new ProviderFactory<StakePoolProvider>();
|
|
77
77
|
export const bip32Ed25519Factory = new ProviderFactory<Crypto.Bip32Ed25519>();
|
|
78
78
|
export const addressDiscoveryFactory = new ProviderFactory<AddressDiscovery>();
|
|
79
|
-
export const handleProviderFactory = new ProviderFactory<HandleProvider>();
|
|
79
|
+
export const handleProviderFactory = new ProviderFactory<HandleProvider | KoraLabsHandleProvider>();
|
|
80
80
|
|
|
81
81
|
// Address Discovery strategies
|
|
82
82
|
|
|
@@ -164,12 +164,11 @@ utxoProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logger):
|
|
|
164
164
|
});
|
|
165
165
|
});
|
|
166
166
|
|
|
167
|
-
handleProviderFactory.register(HANDLE_PROVIDER, async (params: any): Promise<
|
|
167
|
+
handleProviderFactory.register(HANDLE_PROVIDER, async (params: any): Promise<KoraLabsHandleProvider> => {
|
|
168
168
|
if (params.serverUrl === undefined) throw new Error(`${KoraLabsHandleProvider.name}: ${MISSING_URL_PARAM}`);
|
|
169
169
|
|
|
170
170
|
return new KoraLabsHandleProvider({
|
|
171
171
|
adapter: customHttpFetchAdapter,
|
|
172
|
-
networkInfoProvider: params.networkInfoProvider,
|
|
173
172
|
policyId: params.policyId,
|
|
174
173
|
serverUrl: params.serverUrl
|
|
175
174
|
});
|
package/src/scripts/mnemonic.ts
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
import * as Crypto from '@cardano-sdk/crypto';
|
|
4
4
|
import { AddressType, InMemoryKeyAgent, util } from '@cardano-sdk/key-management';
|
|
5
5
|
import { CML } from '@cardano-sdk/core';
|
|
6
|
-
import { localNetworkChainId } from '../util';
|
|
6
|
+
import { localNetworkChainId } from '../util/localNetworkChainId';
|
|
7
7
|
|
|
8
8
|
/**
|
|
9
9
|
* Generates a new set of Mnemonic words and prints them to the console.
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"startingFunds": 1000000000000,
|
|
3
|
+
"stakeDistribution": [
|
|
4
|
+
0.2,
|
|
5
|
+
0.2,
|
|
6
|
+
0.6
|
|
7
|
+
],
|
|
8
|
+
"utxoOut": {
|
|
9
|
+
"amount": {
|
|
10
|
+
"min": 1000000000,
|
|
11
|
+
"max": 1000000000
|
|
12
|
+
},
|
|
13
|
+
"count": {
|
|
14
|
+
"min": 1,
|
|
15
|
+
"max": 1
|
|
16
|
+
},
|
|
17
|
+
"period": 1
|
|
18
|
+
},
|
|
19
|
+
"utxoIn": {
|
|
20
|
+
"amount": {
|
|
21
|
+
"min": 1000000,
|
|
22
|
+
"max": 1000000
|
|
23
|
+
},
|
|
24
|
+
"count": {
|
|
25
|
+
"min": 1,
|
|
26
|
+
"max": 1
|
|
27
|
+
},
|
|
28
|
+
"period": 0
|
|
29
|
+
},
|
|
30
|
+
"iterations": 100
|
|
31
|
+
}
|
|
@@ -0,0 +1,110 @@
|
|
|
1
|
+
/* eslint-disable no-console, max-statements, @typescript-eslint/no-floating-promises, unicorn/no-process-exit */
|
|
2
|
+
import {
|
|
3
|
+
Files,
|
|
4
|
+
Paths,
|
|
5
|
+
TaskResult,
|
|
6
|
+
TerminalProgressMonitor,
|
|
7
|
+
createDelegationWallet,
|
|
8
|
+
delegateToMultiplePools,
|
|
9
|
+
distributeStake,
|
|
10
|
+
generateStakeAddresses,
|
|
11
|
+
getOutputPathName,
|
|
12
|
+
loadConfiguration,
|
|
13
|
+
logState,
|
|
14
|
+
rewardAccountStatuses,
|
|
15
|
+
sendTransactions,
|
|
16
|
+
transferStartingFunds,
|
|
17
|
+
waitForFundingWallet
|
|
18
|
+
} from './utils';
|
|
19
|
+
|
|
20
|
+
import { Cardano } from '@cardano-sdk/core';
|
|
21
|
+
import { PersonalWallet } from '@cardano-sdk/wallet';
|
|
22
|
+
import { walletReady } from '../../';
|
|
23
|
+
import chalk from 'chalk';
|
|
24
|
+
|
|
25
|
+
const monitor = new TerminalProgressMonitor();
|
|
26
|
+
|
|
27
|
+
/**
|
|
28
|
+
* This script creates a new wallet, delegate to multiple pools, and execute transactions
|
|
29
|
+
* over a period of time. The state of the wallet (UTXO set) and the stake distribution at each
|
|
30
|
+
* iteration is stored.
|
|
31
|
+
*/
|
|
32
|
+
(async () => {
|
|
33
|
+
if (process.argv.length < 3) {
|
|
34
|
+
console.log(
|
|
35
|
+
'USAGE: yarn workspace @cardano-sdk/e2e multi-delegation-data-gen [JSON_CONFIG_FILE_PATH] [SCRIPT_WORKING_DIRECTORY]'
|
|
36
|
+
);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
let exitCode = 0;
|
|
41
|
+
let fundingWallet: PersonalWallet | undefined;
|
|
42
|
+
|
|
43
|
+
try {
|
|
44
|
+
const config = await loadConfiguration(monitor);
|
|
45
|
+
|
|
46
|
+
if (process.argv.length > 3) process.chdir(process.argv[3]);
|
|
47
|
+
|
|
48
|
+
const outputPath = getOutputPathName();
|
|
49
|
+
|
|
50
|
+
// Initialize the CSV file with its header.
|
|
51
|
+
const stakeKeysToUse = config.stakeDistribution.map((_, index) => `Stake ${index}`);
|
|
52
|
+
Files.writeFile(
|
|
53
|
+
Files.combine([outputPath, Paths.StakeDistribution]),
|
|
54
|
+
`Iteration, Total, ${stakeKeysToUse.join(',')}\n`,
|
|
55
|
+
true
|
|
56
|
+
);
|
|
57
|
+
|
|
58
|
+
monitor.logInfo(`Output directory: ${chalk.green!(Files.combine([process.cwd(), outputPath]))}`);
|
|
59
|
+
|
|
60
|
+
fundingWallet = await waitForFundingWallet(monitor);
|
|
61
|
+
|
|
62
|
+
const delegationWallet = await createDelegationWallet(monitor);
|
|
63
|
+
|
|
64
|
+
await transferStartingFunds(fundingWallet, delegationWallet, config.startingFunds, monitor);
|
|
65
|
+
|
|
66
|
+
monitor.startTask('Waiting for delegation wallet to be ready.');
|
|
67
|
+
|
|
68
|
+
await walletReady(delegationWallet);
|
|
69
|
+
|
|
70
|
+
monitor.endTask('Delegation wallet ready.', TaskResult.Success);
|
|
71
|
+
|
|
72
|
+
const stakeAddresses = await generateStakeAddresses(delegationWallet, config.stakeDistribution.length, monitor);
|
|
73
|
+
|
|
74
|
+
await delegateToMultiplePools(delegationWallet, stakeAddresses, monitor);
|
|
75
|
+
|
|
76
|
+
await distributeStake(delegationWallet, config.startingFunds, config.stakeDistribution, stakeAddresses, monitor);
|
|
77
|
+
|
|
78
|
+
monitor.startTask('Waiting for delegation to be updated on the wallet.');
|
|
79
|
+
await rewardAccountStatuses(delegationWallet.delegation.rewardAccounts$, [
|
|
80
|
+
Cardano.StakeKeyStatus.Registering,
|
|
81
|
+
Cardano.StakeKeyStatus.Registered
|
|
82
|
+
]);
|
|
83
|
+
monitor.endTask('Delegation updated.', TaskResult.Success);
|
|
84
|
+
|
|
85
|
+
monitor.logInfo('Setup phase ended. Starting interactions...');
|
|
86
|
+
|
|
87
|
+
// Initial setup done, log starting state.
|
|
88
|
+
await logState(delegationWallet, 0, outputPath, monitor);
|
|
89
|
+
|
|
90
|
+
// Runs indefinitely if iterations is set to 0.
|
|
91
|
+
for (let i = 1; config.iterations === 0 || i < config.iterations; ++i) {
|
|
92
|
+
await sendTransactions(fundingWallet, delegationWallet, config.utxoIn, config.utxoOut, i, monitor);
|
|
93
|
+
await logState(delegationWallet, i, outputPath, monitor);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
monitor.logSuccess('Data generation complete.');
|
|
97
|
+
} catch (error) {
|
|
98
|
+
exitCode = -1;
|
|
99
|
+
const message = error instanceof Error ? error.message : JSON.stringify(error);
|
|
100
|
+
|
|
101
|
+
if (monitor.isTrackingTask()) {
|
|
102
|
+
monitor.endTask(message, TaskResult.Fail);
|
|
103
|
+
} else {
|
|
104
|
+
monitor.logFailure(message);
|
|
105
|
+
}
|
|
106
|
+
} finally {
|
|
107
|
+
fundingWallet?.shutdown();
|
|
108
|
+
process.exit(exitCode);
|
|
109
|
+
}
|
|
110
|
+
})();
|