@cardano-sdk/e2e 0.45.0 → 0.45.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.
@@ -53,6 +53,53 @@ getAddressBalance() {
53
53
  echo ${total_balance}
54
54
  }
55
55
 
56
+ getBlockHeight() {
57
+ cardano-cli query tip --testnet-magic $NETWORK_MAGIC | jq -r '.block'
58
+ }
59
+
60
+ submitTransactionWithRetry() {
61
+ local txFile=$1
62
+ local retryCount=${2:-0}
63
+ local numberOfConfirmations=5
64
+
65
+ if [ "$retryCount" -ge 5 ]; then
66
+ echo "Transaction failed after $retryCount retries"
67
+ return 1
68
+ fi
69
+
70
+ cardano-cli latest transaction submit --testnet-magic $NETWORK_MAGIC --tx-file "$txFile"
71
+
72
+ local txId=$(cardano-cli latest transaction txid --tx-file "$txFile")
73
+
74
+ local mempoolTx="true"
75
+ while [ "$mempoolTx" == "true" ]; do
76
+ echo "Transaction is still in the mempool, waiting ${txId}"
77
+ sleep 1
78
+ mempoolTx=$(cardano-cli latest query tx-mempool --testnet-magic $NETWORK_MAGIC tx-exists ${txId} --out-file /dev/stdout | jq -r '.exists')
79
+ done
80
+
81
+ local initialTip=$(getBlockHeight)
82
+ local currentTip=$initialTip
83
+ local utxo="null"
84
+ while [ $(($currentTip - $initialTip)) -lt $numberOfConfirmations ]; do
85
+ sleep 1
86
+ utxo=$(cardano-cli query utxo --tx-in "${txId}#0" --testnet-magic $NETWORK_MAGIC --out-file /dev/stdout | jq -r 'keys[0]')
87
+ if [ "$utxo" == "null" ]; then
88
+ # Transaction was rolled back
89
+ break;
90
+ fi
91
+ currentTip=$(getBlockHeight)
92
+ done
93
+
94
+ if [ "$utxo" == "null" ]; then
95
+ echo "Transaction rolled back, retrying ${retryCount} ..."
96
+ submitTransactionWithRetry "$txFile" $((retryCount + 1))
97
+ return $?
98
+ fi
99
+
100
+ echo "Transaction successful ${txId}"
101
+ }
102
+
56
103
  NETWORK_MAGIC=888
57
104
  UTXO_DIR=network-files/utxo-keys
58
105
  TRANSACTIONS_DIR=network-files/transactions
@@ -68,7 +115,7 @@ mkdir -p "$DELEGATORS_DIR"
68
115
  # GENERATE NEW PAYMENT KEYS
69
116
 
70
117
  for NODE_ID in ${SP_NODES_ID}; do
71
- cardano-cli conway address key-gen \
118
+ cardano-cli latest address key-gen \
72
119
  --verification-key-file "${DELEGATORS_DIR}/payment${NODE_ID}.vkey" \
73
120
  --signing-key-file "${DELEGATORS_DIR}/payment${NODE_ID}.skey"
74
121
  done
@@ -76,7 +123,7 @@ done
76
123
  # GENERATE NEW STAKE
77
124
 
78
125
  for NODE_ID in ${SP_NODES_ID}; do
79
- cardano-cli conway stake-address key-gen \
126
+ cardano-cli latest stake-address key-gen \
80
127
  --verification-key-file "${DELEGATORS_DIR}/staking${NODE_ID}.vkey" \
81
128
  --signing-key-file "${DELEGATORS_DIR}/staking${NODE_ID}.skey"
82
129
  done
@@ -84,7 +131,7 @@ done
84
131
  # BUILD ADDRESSES FOR OUR NEW KEYS
85
132
 
86
133
  for NODE_ID in ${SP_NODES_ID}; do
87
- cardano-cli conway address build \
134
+ cardano-cli latest address build \
88
135
  --testnet-magic $NETWORK_MAGIC \
89
136
  --payment-verification-key-file "${DELEGATORS_DIR}/payment${NODE_ID}.vkey" \
90
137
  --stake-verification-key-file "${DELEGATORS_DIR}/staking${NODE_ID}.vkey" \
@@ -94,7 +141,7 @@ done
94
141
  # BUILD ADDRESSES FOR THE EXISTING KEYS, WE WILL NEED THEM FOR OUR FUTURE TRANSACTIONS
95
142
 
96
143
  for NODE_ID in ${SP_NODES_ID}; do
97
- cardano-cli conway address build \
144
+ cardano-cli latest address build \
98
145
  --testnet-magic $NETWORK_MAGIC \
99
146
  --payment-verification-key-file "${UTXO_DIR}/utxo${NODE_ID}.vkey" \
100
147
  --out-file "${UTXO_DIR}/utxo${NODE_ID}.addr"
@@ -102,72 +149,90 @@ done
102
149
 
103
150
  # FUND OUR NEWLY CREATED ADDRESSES
104
151
 
105
- stakeAddr="$(cat "${UTXO_DIR}/utxo1.addr")"
106
- currentBalance=$(getAddressBalance "$stakeAddr")
107
- echo "Funding stake addresses with ${AMOUNT_PER_DELEGATOR}"
108
-
109
152
  for NODE_ID in ${SP_NODES_ID}; do
110
- cardano-cli conway transaction build \
153
+ sourceAddr="$(cat "${UTXO_DIR}/utxo${NODE_ID}.addr")"
154
+ destAddr="$(cat ${DELEGATORS_DIR}/payment${NODE_ID}.addr)"
155
+ echo "Funding ${destAddr} with ${AMOUNT_PER_DELEGATOR}"
156
+
157
+ cardano-cli latest transaction build \
111
158
  --testnet-magic $NETWORK_MAGIC \
112
- --tx-in "$(cardano-cli query utxo --address "$(cat "${UTXO_DIR}/utxo${NODE_ID}.addr")" --testnet-magic $NETWORK_MAGIC --out-file /dev/stdout | jq -r 'keys[0]')" \
113
- --tx-out "$(cat ${DELEGATORS_DIR}/payment${NODE_ID}.addr)+${AMOUNT_PER_DELEGATOR}" \
114
- --change-address "$(cat ${UTXO_DIR}/utxo${NODE_ID}.addr)" \
159
+ --tx-in "$(cardano-cli query utxo --address "$sourceAddr" --testnet-magic $NETWORK_MAGIC --out-file /dev/stdout | jq -r 'keys[0]')" \
160
+ --tx-out "${destAddr}+${AMOUNT_PER_DELEGATOR}" \
161
+ --change-address "$sourceAddr" \
115
162
  --out-file "${TRANSACTIONS_DIR}/tx${NODE_ID}.raw"
116
163
 
117
- cardano-cli conway transaction sign --testnet-magic $NETWORK_MAGIC \
118
- --tx-body-file "${TRANSACTIONS_DIR}/tx${NODE_ID}.raw" \
119
- --signing-key-file "${UTXO_DIR}/utxo${NODE_ID}.skey" \
120
- --out-file "${TRANSACTIONS_DIR}/tx${NODE_ID}.signed"
164
+ cardano-cli latest transaction sign --testnet-magic $NETWORK_MAGIC \
165
+ --tx-body-file "${TRANSACTIONS_DIR}/tx${NODE_ID}.raw" \
166
+ --signing-key-file "${UTXO_DIR}/utxo${NODE_ID}.skey" \
167
+ --out-file "${TRANSACTIONS_DIR}/tx${NODE_ID}.signed"
121
168
 
122
- cardano-cli conway transaction submit \
123
- --testnet-magic $NETWORK_MAGIC \
124
- --tx-file "${TRANSACTIONS_DIR}/tx${NODE_ID}.signed"
169
+ if [ "$NODE_ID" -eq 1 ]; then
170
+ # This is the first transaction after startin the network.
171
+ # It usually takes a long time to be included in a block and often rolled back, so use submit with retry.
172
+ # Do not use submit with retry for regular transactions because it waits for 5 block confirmations before it returns
173
+ submitTransactionWithRetry "${TRANSACTIONS_DIR}/tx${NODE_ID}.signed"
174
+ else
175
+ cardano-cli latest transaction submit --testnet-magic $NETWORK_MAGIC --tx-file "${TRANSACTIONS_DIR}/tx${NODE_ID}.signed"
176
+ fi
125
177
  done
126
178
 
127
- updatedBalance=$(getAddressBalance "$stakeAddr")
128
-
129
- while [ "$currentBalance" -eq "$updatedBalance" ]; do
130
- updatedBalance=$(getAddressBalance "$stakeAddr")
131
- sleep 1
179
+ # Wait for funds to reach destAddr
180
+ for NODE_ID in ${SP_NODES_ID}; do
181
+ destAddr="$(cat ${DELEGATORS_DIR}/payment${NODE_ID}.addr)"
182
+
183
+ currentBalance=$(getAddressBalance "$destAddr")
184
+ while [ "$currentBalance" -lt "$AMOUNT_PER_DELEGATOR" ]; do
185
+ echo "Waiting for funds to reach ${destAddr} ${currentBalance} < ${AMOUNT_PER_DELEGATOR}"
186
+ currentBalance=$(getAddressBalance "$destAddr")
187
+ sleep 1
188
+ done
132
189
  done
133
190
 
134
191
  sleep 10
135
192
 
136
193
  # SHOW THE UTXO DISTRIBUTION
137
194
 
138
- cardano-cli conway query utxo --whole-utxo --testnet-magic $NETWORK_MAGIC
195
+ cardano-cli query utxo --whole-utxo --testnet-magic $NETWORK_MAGIC
139
196
 
140
197
  # REGISTER STAKE ADDRESSES
141
198
 
142
- echo "Registering $(cat "${DELEGATORS_DIR}/payment${NODE_ID}.addr")"
143
-
144
199
  keyDeposit=2000000
145
200
  stakeAddr="$(cat "${DELEGATORS_DIR}/payment1.addr")"
146
201
  currentBalance=$(getAddressBalance "$stakeAddr")
147
202
 
148
203
  for NODE_ID in ${SP_NODES_ID}; do
149
- cardano-cli conway stake-address registration-certificate \
204
+ stakeAddr=$(cat "${DELEGATORS_DIR}/payment${NODE_ID}.addr")
205
+ echo "Registering $stakeAddr"
206
+
207
+ cardano-cli latest stake-address registration-certificate \
150
208
  --stake-verification-key-file "${DELEGATORS_DIR}/staking${NODE_ID}.vkey" \
151
209
  --key-reg-deposit-amt ${keyDeposit} \
152
210
  --out-file "${TRANSACTIONS_DIR}/staking${NODE_ID}reg.cert"
153
211
 
154
- cardano-cli conway transaction build \
212
+ # Wait for utxo to become available
213
+ txIn="null";
214
+ while [ "$txIn" == "null" ]; do
215
+ echo "Waiting for ${stakeAddr} UTxO..."
216
+ txInJson="$(cardano-cli latest query utxo --address "$stakeAddr" --testnet-magic $NETWORK_MAGIC --out-file /dev/stdout)";
217
+ txIn=$(jq -r 'keys[0]' <<< "$txInJson");
218
+ sleep 0.1
219
+ done
220
+
221
+ cardano-cli latest transaction build \
155
222
  --testnet-magic $NETWORK_MAGIC \
156
- --tx-in "$(cardano-cli query utxo --address "$(cat "${DELEGATORS_DIR}/payment${NODE_ID}.addr")" --testnet-magic $NETWORK_MAGIC --out-file /dev/stdout | jq -r 'keys[0]')" \
223
+ --tx-in "$txIn" \
157
224
  --change-address "$(cat ${DELEGATORS_DIR}/payment${NODE_ID}.addr)" \
158
225
  --certificate-file "${TRANSACTIONS_DIR}/staking${NODE_ID}reg.cert" \
159
226
  --witness-override 2 \
160
227
  --out-file "${TRANSACTIONS_DIR}/reg-stake-tx${NODE_ID}.raw"
161
228
 
162
- cardano-cli conway transaction sign --testnet-magic $NETWORK_MAGIC \
229
+ cardano-cli latest transaction sign --testnet-magic $NETWORK_MAGIC \
163
230
  --tx-body-file "${TRANSACTIONS_DIR}/reg-stake-tx${NODE_ID}.raw" \
164
231
  --signing-key-file "${DELEGATORS_DIR}/payment${NODE_ID}.skey" \
165
232
  --signing-key-file "${DELEGATORS_DIR}/staking${NODE_ID}.skey" \
166
233
  --out-file "${TRANSACTIONS_DIR}/reg-stake-tx${NODE_ID}.signed"
167
234
 
168
- cardano-cli conway transaction submit \
169
- --testnet-magic $NETWORK_MAGIC \
170
- --tx-file "${TRANSACTIONS_DIR}/reg-stake-tx${NODE_ID}.signed"
235
+ cardano-cli latest transaction submit --testnet-magic $NETWORK_MAGIC --tx-file "${TRANSACTIONS_DIR}/reg-stake-tx${NODE_ID}.signed"
171
236
  done
172
237
 
173
238
  updatedBalance=$(getAddressBalance "$stakeAddr")
@@ -37,7 +37,7 @@ walletAddr5="addr_test1qr0c3frkem9cqn5f73dnvqpena27k2fgqew6wct9eaka03agfwkvzr0zy
37
37
  # Spend the first UTxO
38
38
  utxo=$(cardano-cli query utxo --address "$genesisAddr" --testnet-magic 888 | awk 'NR == 3 {printf("%s#%s", $1, $2)}')
39
39
 
40
- cardano-cli conway transaction build \
40
+ cardano-cli latest transaction build \
41
41
  --change-address "$genesisAddr" \
42
42
  --tx-in "$utxo" \
43
43
  --tx-out "$walletAddr1"+"$AMOUNT_PER_WALLET" \
@@ -48,11 +48,11 @@ cardano-cli conway transaction build \
48
48
  --testnet-magic 888 \
49
49
  --out-file wallets-tx.raw
50
50
 
51
- cardano-cli transaction sign \
51
+ cardano-cli latest transaction sign \
52
52
  --tx-body-file wallets-tx.raw \
53
53
  --signing-key-file network-files/utxo-keys/utxo3.skey \
54
54
  --testnet-magic 888 \
55
55
  --out-file wallets-tx.signed
56
56
 
57
- cardano-cli transaction submit --testnet-magic 888 --tx-file wallets-tx.signed
57
+ cardano-cli latest transaction submit --testnet-magic 888 --tx-file wallets-tx.signed
58
58
  wait_tx_complete $utxo
@@ -43,7 +43,6 @@ while [ `cardano-cli query tip --testnet-magic 888 | jq .block` == null ] ; do
43
43
  sleep 1
44
44
  done
45
45
 
46
- healthy &
47
46
 
48
47
  ./scripts/setup-new-delegator-keys.sh
49
48
  ./scripts/update-stake-pools.sh.sh "$SP_NODES_ID"
@@ -56,4 +55,6 @@ healthy &
56
55
 
57
56
  touch ./network-files/run/done
58
57
 
58
+ healthy &
59
+
59
60
  wait
@@ -113,6 +113,10 @@
113
113
  }
114
114
  ],
115
115
  "insert_options": {
116
- "tx_cbor": "enable"
116
+ "tx_cbor": "enable",
117
+ "tx_out": {
118
+ "value": "consumed",
119
+ "force_tx_in": true
120
+ }
117
121
  }
118
122
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cardano-sdk/e2e",
3
- "version": "0.45.0",
3
+ "version": "0.45.1",
4
4
  "description": "End to end tests for the cardano-js-sdk packages.",
5
5
  "repository": "https://github.com/input-output-hk/cardano-js-sdk",
6
6
  "license": "Apache-2.0",
@@ -75,21 +75,21 @@
75
75
  },
76
76
  "dependencies": {
77
77
  "@cardano-foundation/ledgerjs-hw-app-cardano": "^7.1.4",
78
- "@cardano-ogmios/client": "6.5.0",
79
- "@cardano-sdk/cardano-services": "~0.32.0",
80
- "@cardano-sdk/cardano-services-client": "~0.22.0",
81
- "@cardano-sdk/core": "~0.41.2",
82
- "@cardano-sdk/crypto": "~0.1.30",
83
- "@cardano-sdk/hardware-ledger": "~0.12.10",
84
- "@cardano-sdk/hardware-trezor": "~0.6.9",
85
- "@cardano-sdk/input-selection": "~0.13.25",
86
- "@cardano-sdk/key-management": "~0.24.8",
87
- "@cardano-sdk/ogmios": "~0.18.10",
88
- "@cardano-sdk/tx-construction": "~0.21.10",
78
+ "@cardano-ogmios/client": "6.9.0",
79
+ "@cardano-sdk/cardano-services": "~0.32.1",
80
+ "@cardano-sdk/cardano-services-client": "~0.22.1",
81
+ "@cardano-sdk/core": "~0.41.3",
82
+ "@cardano-sdk/crypto": "~0.1.31",
83
+ "@cardano-sdk/hardware-ledger": "~0.12.11",
84
+ "@cardano-sdk/hardware-trezor": "~0.6.10",
85
+ "@cardano-sdk/input-selection": "~0.13.26",
86
+ "@cardano-sdk/key-management": "~0.24.9",
87
+ "@cardano-sdk/ogmios": "~0.18.11",
88
+ "@cardano-sdk/tx-construction": "~0.21.11",
89
89
  "@cardano-sdk/util": "~0.15.5",
90
- "@cardano-sdk/util-dev": "~0.23.10",
91
- "@cardano-sdk/util-rxjs": "~0.7.38",
92
- "@cardano-sdk/wallet": "~0.44.18",
90
+ "@cardano-sdk/util-dev": "~0.23.11",
91
+ "@cardano-sdk/util-rxjs": "~0.7.39",
92
+ "@cardano-sdk/wallet": "~0.44.19",
93
93
  "@dcspark/cardano-multiplatform-lib-nodejs": "^3.1.1",
94
94
  "@shiroyasha9/axios-fetch-adapter": "1.0.3",
95
95
  "axios": "^1.7.4",
@@ -119,10 +119,10 @@
119
119
  "@babel/core": "^7.18.2",
120
120
  "@babel/preset-env": "^7.18.2",
121
121
  "@babel/preset-typescript": "^7.17.12",
122
- "@cardano-sdk/dapp-connector": "~0.12.42",
123
- "@cardano-sdk/projection": "~0.12.10",
124
- "@cardano-sdk/projection-typeorm": "~0.9.10",
125
- "@cardano-sdk/web-extension": "~0.34.17",
122
+ "@cardano-sdk/dapp-connector": "~0.12.43",
123
+ "@cardano-sdk/projection": "~0.12.11",
124
+ "@cardano-sdk/projection-typeorm": "~0.9.11",
125
+ "@cardano-sdk/web-extension": "~0.34.18",
126
126
  "@dcspark/cardano-multiplatform-lib-browser": "^3.1.1",
127
127
  "@emurgo/cardano-message-signing-asmjs": "^1.0.1",
128
128
  "@types/bunyan": "^1.8.8",
@@ -182,5 +182,5 @@
182
182
  "publishConfig": {
183
183
  "access": "public"
184
184
  },
185
- "gitHead": "786381908d2d3ec916d64c37201d43c52ebd5b26"
185
+ "gitHead": "d1544fc9d1fb3997eb7c5b94a233789bb9e5cd9f"
186
186
  }
package/src/factories.ts CHANGED
@@ -36,6 +36,8 @@ import {
36
36
  util
37
37
  } from '@cardano-sdk/key-management';
38
38
  import {
39
+ BlockfrostAssetProvider,
40
+ BlockfrostClient,
39
41
  CardanoWsClient,
40
42
  assetInfoHttpProvider,
41
43
  chainHistoryHttpProvider,
@@ -66,6 +68,7 @@ const HTTP_PROVIDER = 'http';
66
68
  const OGMIOS_PROVIDER = 'ogmios';
67
69
  const STUB_PROVIDER = 'stub';
68
70
  const WS_PROVIDER = 'ws';
71
+ const BLOCKFROST_PROVIDER = 'blockfrost';
69
72
 
70
73
  const MISSING_URL_PARAM = 'Missing URL';
71
74
 
@@ -130,6 +133,19 @@ assetProviderFactory.register(HTTP_PROVIDER, async (params: any, logger: Logger)
130
133
  });
131
134
  });
132
135
 
136
+ assetProviderFactory.register(BLOCKFROST_PROVIDER, async (params: any, logger): Promise<AssetProvider> => {
137
+ if (params.baseUrl === undefined) throw new Error(`${BlockfrostAssetProvider.name}: ${MISSING_URL_PARAM}`);
138
+
139
+ return new Promise<AssetProvider>(async (resolve) => {
140
+ resolve(
141
+ new BlockfrostAssetProvider(
142
+ new BlockfrostClient({ baseUrl: params.baseUrl }, { rateLimiter: { schedule: (task) => task() } }),
143
+ logger
144
+ )
145
+ );
146
+ });
147
+ });
148
+
133
149
  chainHistoryProviderFactory.register(
134
150
  HTTP_PROVIDER,
135
151
  async (params: any, logger: Logger): Promise<ChainHistoryProvider> => {
@@ -1,11 +1,21 @@
1
- import { BlockfrostAssetProvider } from '@cardano-sdk/cardano-services-client';
2
1
  import { Cardano } from '@cardano-sdk/core';
2
+ import { assetProviderFactory, getEnv, walletVariables } from '../../src';
3
3
  import { logger } from '@cardano-sdk/util-dev';
4
- import { util } from '@cardano-sdk/cardano-services';
4
+
5
+ const env = getEnv(walletVariables);
5
6
 
6
7
  describe('BlockfrostAssetProvider', () => {
8
+ beforeAll(() => {
9
+ if (env.TEST_CLIENT_ASSET_PROVIDER !== 'blockfrost')
10
+ throw new Error('TEST_CLIENT_ASSET_PROVIDER must be "blockfrost" to run these tests');
11
+ });
12
+
7
13
  test('getAsset', async () => {
8
- const assetProvider = new BlockfrostAssetProvider(util.getBlockfrostClient(), logger);
14
+ const assetProvider = await assetProviderFactory.create(
15
+ 'blockfrost',
16
+ env.TEST_CLIENT_ASSET_PROVIDER_PARAMS,
17
+ logger
18
+ );
9
19
  const asset = await assetProvider.getAsset({
10
20
  assetId: Cardano.AssetId(
11
21
  'b27160f0c50a9cf168bf945dcbfcabbfbee5c7a801e7b467093b41534d6574616c4d6f6e7374657230303036'
@@ -5,7 +5,7 @@ import { logger } from '@cardano-sdk/util-dev';
5
5
  import { networkInfoHttpProvider } from '@cardano-sdk/cardano-services-client';
6
6
  import { toSerializableObject } from '@cardano-sdk/util';
7
7
 
8
- // LW-11697 to enable this
8
+ // LW-11858 to enable this
9
9
  describe.skip('Web Socket', () => {
10
10
  const legacyProvider = networkInfoHttpProvider({ baseUrl: 'http://localhost:4000/', logger });
11
11
  const provider = networkInfoHttpProvider({ baseUrl: 'http://localhost:4001/', logger });
@@ -46,7 +46,6 @@ describe('PersonalWallet.assets/nft', () => {
46
46
  let policyId: Cardano.PolicyId;
47
47
  let policyScript: Cardano.NativeScript;
48
48
  let assetIds: Cardano.AssetId[];
49
- let fingerprints: Cardano.AssetFingerprint[];
50
49
  const assetNames = ['4e46542d66696c6573', '4e46542d303031', '4e46542d303032'];
51
50
  let walletAddress: Cardano.PaymentAddress;
52
51
  const coins = 10_000_000n; // number of coins to use in each transaction
@@ -101,12 +100,6 @@ describe('PersonalWallet.assets/nft', () => {
101
100
  [assetIds[TOKEN_BURN_INDEX], 1n]
102
101
  ]);
103
102
 
104
- fingerprints = [
105
- Cardano.AssetFingerprint.fromParts(policyId, Cardano.AssetName(assetNames[TOKEN_METADATA_1_INDEX])),
106
- Cardano.AssetFingerprint.fromParts(policyId, Cardano.AssetName(assetNames[TOKEN_METADATA_2_INDEX])),
107
- Cardano.AssetFingerprint.fromParts(policyId, Cardano.AssetName(assetNames[TOKEN_BURN_INDEX]))
108
- ];
109
-
110
103
  walletAddress = (await firstValueFrom(wallet.addresses$))[0].address;
111
104
 
112
105
  const txMetadatum = metadatum.jsonToMetadatum({
@@ -199,23 +192,13 @@ describe('PersonalWallet.assets/nft', () => {
199
192
  // Check balance here because asset info will not be re-fetched when balance changes due to minting and burning
200
193
  expect(walletAssetBalance?.get(assetIds[TOKEN_METADATA_2_INDEX])).toBe(1n);
201
194
 
202
- expect(nfts.find((nft) => nft.assetId === assetIds[TOKEN_METADATA_2_INDEX])).toMatchObject({
203
- assetId: assetIds[TOKEN_METADATA_2_INDEX],
204
- fingerprint: fingerprints[TOKEN_METADATA_2_INDEX],
205
- name: assetNames[TOKEN_METADATA_2_INDEX],
206
- nftMetadata: {
207
- image: 'ipfs://some_hash1',
208
- name: 'One',
209
- otherProperties: new Map([['version', '1.0']]),
210
- version: '1.0'
211
- },
212
- policyId,
213
- // in case of repeated tests on the same network, total asset supply is not updated due to
214
- // the limitation that asset info is not refreshed on wallet balance changes
215
- quantity: expect.anything(),
216
- supply: expect.anything(),
217
- tokenMetadata: null
195
+ const secondTokenMetadata = nfts.find((nft) => nft.assetId === assetIds[TOKEN_METADATA_2_INDEX])?.nftMetadata;
196
+ expect(secondTokenMetadata).toMatchObject({
197
+ image: 'ipfs://some_hash1',
198
+ name: 'One',
199
+ version: '1.0'
218
200
  });
201
+
219
202
  expect(nfts.find((nft) => nft.assetId === assetIds[TOKEN_METADATA_1_INDEX])).toBeDefined();
220
203
  });
221
204
 
@@ -225,37 +208,20 @@ describe('PersonalWallet.assets/nft', () => {
225
208
  // Check balance here because asset info will not be re-fetched when balance changes due to minting and burning
226
209
  expect(walletAssetBalance?.get(assetIds[TOKEN_METADATA_1_INDEX])).toBe(1n);
227
210
 
228
- expect(nfts.find((nft) => nft.assetId === assetIds[TOKEN_METADATA_1_INDEX])).toMatchObject({
229
- assetId: assetIds[TOKEN_METADATA_1_INDEX],
230
- fingerprint: fingerprints[TOKEN_METADATA_1_INDEX],
231
- name: assetNames[TOKEN_METADATA_1_INDEX],
232
- nftMetadata: {
233
- description: 'NFT with different types of files',
234
- files: [
235
- {
236
- mediaType: 'video/mp4',
237
- name: 'some name',
238
- src: 'ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2N5'
239
- },
240
- {
241
- mediaType: 'audio/mpeg',
242
- name: 'some name',
243
- src: 'ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2Ny'
244
- }
245
- ],
246
- image: 'ipfs://somehash',
247
- mediaType: 'image/png',
248
- name: 'NFT with files',
249
- otherProperties: new Map([
250
- ['id', '1'],
251
- ['version', '1.0']
252
- ]),
253
- version: '1.0'
254
- } as Asset.NftMetadata,
255
- policyId,
256
- supply: expect.anything(),
257
- tokenMetadata: null
258
- });
211
+ const nftMetadata = nfts.find((nft) => nft.assetId === assetIds[TOKEN_METADATA_1_INDEX])?.nftMetadata;
212
+ expect(nftMetadata?.otherProperties?.get('id')).toBe('1');
213
+ expect(nftMetadata?.files).toEqual([
214
+ expect.objectContaining({
215
+ mediaType: 'video/mp4',
216
+ name: 'some name',
217
+ src: 'ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2N5'
218
+ }),
219
+ expect.objectContaining({
220
+ mediaType: 'audio/mpeg',
221
+ name: 'some name',
222
+ src: 'ipfs://Qmb78QQ4RXxKQrteRn4X3WaMXXfmi2BU2dLjfWxuJoF2Ny'
223
+ })
224
+ ]);
259
225
  });
260
226
 
261
227
  it('supports burning tokens', async () => {
@@ -313,7 +279,6 @@ describe('PersonalWallet.assets/nft', () => {
313
279
 
314
280
  const assetNameHex = Buffer.from(assetName).toString('hex');
315
281
  const assetId = Cardano.AssetId(`${policyId}${assetNameHex}`);
316
- const fingerprint = Cardano.AssetFingerprint.fromParts(policyId, Cardano.AssetName(assetNameHex));
317
282
  const tokens = new Map([[assetId, 1n]]);
318
283
 
319
284
  const txDataMetadatum = new Map([
@@ -325,7 +290,7 @@ describe('PersonalWallet.assets/nft', () => {
325
290
  metadatum.jsonToMetadatum({
326
291
  image: ['ipfs://some_hash1'],
327
292
  name: assetName,
328
- version: '1.0'
293
+ version
329
294
  })
330
295
  ]
331
296
  ])
@@ -369,26 +334,18 @@ describe('PersonalWallet.assets/nft', () => {
369
334
 
370
335
  // try remove the asset.nftMetadata filter
371
336
  const [, nfts] = await firstValueFromTimed(walletBalanceAssetsAndNfts(wallet));
337
+ const nftMetadata = nfts.find((nft) => nft.assetId === assetId)?.nftMetadata;
372
338
 
373
- expect(nfts.find((nft) => nft.assetId === assetId)).toMatchObject({
374
- assetId,
375
- fingerprint,
376
- name: assetNameHex,
377
- nftMetadata: {
378
- image: 'ipfs://some_hash1',
379
- name: assetName,
380
- otherProperties: new Map([['version', '1.0']]),
381
- version: '1.0'
382
- },
383
- policyId,
384
- quantity: expect.anything(),
385
- supply: expect.anything(),
386
- tokenMetadata: null
387
- });
339
+ expect(nftMetadata?.image).toBe('ipfs://some_hash1');
340
+ expect(nftMetadata?.name).toBe(assetName);
388
341
  });
389
342
 
390
343
  CIP0025Test('supports CIP-25 v1, assetName hex encoded', 'CIP-0025-v1-hex', 1, 'hex');
391
344
  CIP0025Test('supports CIP-25 v1, assetName utf8 encoded', 'CIP-0025-v1-utf8', 1, 'utf8');
392
- CIP0025Test('supports CIP-25 v2', 'CIP-0025-v2', 2);
345
+
346
+ // https://input-output-rnd.slack.com/archives/C06J663L2A2/p1731505470694659
347
+ env.TEST_CLIENT_ASSET_PROVIDER !== 'blockfrost'
348
+ ? CIP0025Test('supports CIP-25 v2', 'CIP-0025-v2', 2)
349
+ : test.todo('"supports CIP-25 v2" test is disabled when running with Blockfrost asset provider');
393
350
  });
394
351
  });