All files / test/data-mocks tx.ts

100% Statements 38/38
100% Branches 0/0
100% Functions 0/0
100% Lines 38/38

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 2957x 7x   7x   7x       7x             7x       7x         7x   7x   7x           7x                                                   7x         7x                     7x                 7x       7x                 7x                 7x               7x             7x                   7x             7x             7x                             7x             7x   7x               7x                 7x   7x           7x                   7x                   7x       7x         7x                 7x                   7x             7x                                     7x                                                
import { Cardano } from '@cardano-sdk/core';
import { Hash28ByteBase16, Hash32ByteBase16 } from '@cardano-sdk/crypto';
 
import merge from 'lodash/merge.js';
 
export const valueWithCoinOnly: Cardano.Value = {
  coins: 7_420_514n
};
 
export const valueWithAssets: Cardano.Value = {
  ...valueWithCoinOnly,
  assets: new Map([
    [Cardano.AssetId('57fca08abbaddee36da742a839f7d83a7e1d2419f1507fcbf3916522534245525259'), 10_000_000n]
  ])
};
 
export const txOutBase: Omit<Cardano.TxOut, 'value' | 'datum'> = {
  address: Cardano.PaymentAddress('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t')
};
 
export const txOutBaseWithDatum: Omit<Cardano.TxOut, 'value'> = {
  ...txOutBase,
  datumHash: Hash32ByteBase16('c5dfa8c3cbd5a959829618a7b46e163078cb3f1b39f152514d0c3686d553529a')
};
 
export const txOutWithCoinOnly: Cardano.TxOut = { ...txOutBase, value: valueWithCoinOnly };
 
export const txOutWithAssets: Cardano.TxOut = { ...txOutBase, value: valueWithAssets };
 
export const txIn: Cardano.HydratedTxIn = {
  address: Cardano.PaymentAddress('addr_test1wrsexavz37208qda7mwwu4k7hcpg26cz0ce86f5e9kul3hqzlh22t'),
  index: 0,
  txId: Cardano.TransactionId('cefd2fcf657e5e5d6c35975f4e052f427819391b153ebb16ad8aa107ba5a3819')
};
 
export const base = {
  auxiliaryData: {
    blob: new Map()
  },
  blockHeader: {
    blockNo: Cardano.BlockNo(3_157_934),
    hash: Cardano.BlockId('f03084089ec7e74a79e69a5929b2d3c0836d6f12279bd103d0875847c740ae27'),
    slot: Cardano.Slot(45_286_016)
  } as Cardano.HydratedTx['blockHeader'],
  body: {
    fee: 191_109n,
    inputs: [txIn],
    outputs: [txOutWithCoinOnly],
    validityInterval: {
      invalidBefore: undefined,
      invalidHereafter: undefined
    }
  } as Omit<Cardano.HydratedTx['body'], 'outputs'>,
  id: Cardano.TransactionId('cefd2fcf657e5e5d6c35975f4e052f427819391b153ebb16ad8aa107ba5a3819'),
  index: 30,
  txSize: 711,
  witness: {
    signatures: new Map()
  }
};
 
export const withCoinOnly: Cardano.HydratedTx = merge(base, {
  body: { outputs: [txOutWithCoinOnly] },
  inputSource: Cardano.InputSource.inputs
});
 
export const withAssets: Cardano.HydratedTx = merge(base, {
  body: {
    ...base.body,
    outputs: [txOutWithAssets]
  },
  inputSource: Cardano.InputSource.inputs,
  witness: {
    signatures: new Map()
  }
});
 
export const withMint: Cardano.HydratedTx = merge(withAssets, {
  body: {
    mint: new Map([
      [Cardano.AssetId('57fca08abbaddee36da742a839f7d83a7e1d2419f1507fcbf3916522534245525259'), 10_000_000n]
    ])
  },
  inputSource: Cardano.InputSource.inputs
});
 
export const mint: Cardano.TokenMap = new Map([
  [Cardano.AssetId('57fca08abbaddee36da742a839f7d83a7e1d2419f1507fcbf3916522534245525259'), 10_000_000n]
]);
 
export const withAuxiliaryData: Cardano.HydratedTx = merge(withAssets, {
  auxiliaryData: {
    body: {
      blob: new Map([[1, 'abc']])
    }
  },
  inputSource: Cardano.InputSource.inputs
});
 
export const delegationCertificate: Cardano.StakeDelegationCertificate = {
  __typename: Cardano.CertificateType.StakeDelegation,
  poolId: Cardano.PoolId('pool1cjm567pd9eqj7wlpuq2mnsasw2upewq0tchg4n8gktq5k7eepvr'),
  stakeCredential: {
    hash: Hash28ByteBase16('f15db05f56035465bf8900a09bdaa16c3d8b8244fea686524408dd80'),
    type: Cardano.CredentialType.KeyHash
  }
};
 
export const collateralInputs = [
  {
    address: 'addr_test1vryustw2u58ln2jhnp85mqzqntmtf076ywuvf8r03g2pw5q3xw00t',
    index: 0,
    txId: '4801e599cf8acc51364c7288d39f4b66ac8c480bbeac375d7138c485d0566197'
  }
];
 
export const collateralReturn: Cardano.TxOut = {
  address: Cardano.PaymentAddress('addr_test1wqnp362vmvr8jtc946d3a3utqgclfdl5y9d3kn849e359hst7hkqk'),
  value: {
    coins: 3_681_817_479_100_950n
  }
};
 
export const withValidityInterval: Cardano.HydratedTx = merge(withAssets, {
  body: {
    validityInterval: {
      invalidBefore: 1,
      invalidHereafter: 2
    }
  },
  inputSource: Cardano.InputSource.inputs
});
 
export const withdrawals = [
  {
    quantity: 1_834_170_201n,
    stakeAddress: 'stake_test1uzfef3dmd0ykz9wfm3zx35pq4xdtla929hk6sx6tcen9h6s3vf52j'
  }
];
 
export const withWithdrawals: Cardano.HydratedTx = merge(withAssets, {
  body: {
    withdrawals
  },
  inputSource: Cardano.InputSource.inputs
});
 
export const witnessRedeemers = {
  redeemers: [
    {
      data: {},
      executionUnits: {
        memory: 1700,
        steps: 476_468
      },
      index: 0,
      purpose: 'spend'
    }
  ],
  signatures: {}
};
 
export const input = {
  address:
    'addr_test1qpcncempf4svkpw0salztrsxzrfpr5ll323q5whw7lv94vyw0kz5rxvdaq6u6tslwfrrgz6l4n4lpcpnawn87yl9k6dsu4hhg2',
  index: 0,
  txId: '5293c1165896ab6bed6f7e969792fe4ac2202ddac5a5186d941ae2c9310b7056'
};
 
export const inputs = [input];
 
export const output = {
  address:
    'addr_test1qpcncempf4svkpw0salztrsxzrfpr5ll323q5whw7lv94vyw0kz5rxvdaq6u6tslwfrrgz6l4n4lpcpnawn87yl9k6dsu4hhg2',
  value: {
    coins: 13_499_999_999_819_540n
  }
};
 
export const outputWithInlineDatum = {
  address:
    'addr_test1qpcncempf4svkpw0salztrsxzrfpr5ll323q5whw7lv94vyw0kz5rxvdaq6u6tslwfrrgz6l4n4lpcpnawn87yl9k6dsu4hhg2',
  datum: 42n,
  value: {
    coins: 13_499_999_999_819_540n
  }
};
 
export const outputs = [output];
 
export const blockHeader: Cardano.HydratedTx['blockHeader'] = {
  blockNo: Cardano.BlockNo(3_157_934),
  hash: Cardano.BlockId('f03084089ec7e74a79e69a5929b2d3c0836d6f12279bd103d0875847c740ae27'),
  slot: Cardano.Slot(45_286_016)
};
 
export const txInput = {
  address:
    // eslint-disable-next-line max-len
    'addr_test1qpv5muwgjmmtqh2ta0kq9pmz0nurg9kmw7dryueqt57mncynjnzmk67fvy2unhzydrgzp2v6hl625t0d4qd5h3nxt04qu0ww7k',
  id: '0',
  index: 0,
  txInputId: '0000000000000000000000000000000000000000000000000000000000000000',
  txSourceId: '0000000000000000000000000000000000000000000000000000000000000000'
};
 
export const txOut = {
  address:
    // eslint-disable-next-line max-len
    'addr_test1qpv5muwgjmmtqh2ta0kq9pmz0nurg9kmw7dryueqt57mncynjnzmk67fvy2unhzydrgzp2v6hl625t0d4qd5h3nxt04qu0ww7k',
  // datumHash: undefined,
  index: 0,
  txId: '59f3ea1bb67b39447aad523f35daa1950c833472bf9232b6c0abac968f45bad9',
  value: { /* assets: undefined,*/ coins: 3_061_089_499_500n }
};
 
export const txTokenMap = new Map<string, bigint>([
  ['ea53552348385c7421003f315b43271aee7e65ad900c195ce57fa0903030303030', 10n]
]);
 
export const withdrawal = {
  quantity: 1_834_170_201n,
  stakeAddress: 'stake_test1uzfef3dmd0ykz9wfm3zx35pq4xdtla929hk6sx6tcen9h6s3vf52j'
};
 
export const certificate = {
  __typename: 'StakeDelegationCertificate',
  poolId: 'pool19yv4rswp06fdnwg5zq0uk876gttewt86kytqrlt3ermnq3reky0',
  stakeCredential: {
    hash: '9394c5bb6bc96115c9dc4468d020a99abff4aa2deda81b4bc6665bea',
    type: 0
  }
};
 
export const redeemer = {
  data: {},
  executionUnits: {
    memory: 0,
    steps: 0
  },
  index: 0,
  purpose: 'spend'
};
 
export const infoAction = {
  anchor: { dataHash: '3e33018e8293d319ef5b3ac72366dd28006bd315b715f7e7cfcbd3004129b80d', url: 'https://testing.this' },
  deposit: 1_000_000_000n,
  governanceAction: { __typename: 'info_action' },
  rewardAccount: 'stake_test1urc4mvzl2cp4gedl3yq2px7659krmzuzgnl2dpjjgsydmqqxgamj7'
};
 
export const vote = {
  voter: {
    __typename: 'dRepKeyHash',
    credential: { hash: '4615beb10ff7b5d247dd0f8cb28ba447e8db9e7b4782b5d6eec7f1ed', type: 0 }
  },
  votes: [
    {
      actionId: { actionIndex: 0, id: 'c8686bd84d979285513a27e1c8dd4f6306c332df1b888ca5f2bb652945d78d64' },
      votingProcedure: {
        anchor: {
          dataHash: '3e33018e8293d319ef5b3ac72366dd28006bd315b715f7e7cfcbd3004129b80d',
          url: 'https://testing.this'
        },
        vote: 2
      }
    }
  ]
};
 
export const tx = [
  base,
  certificate,
  withAssets,
  withAuxiliaryData,
  delegationCertificate,
  withCoinOnly,
  collateralInputs,
  withMint,
  witnessRedeemers,
  withValidityInterval,
  withWithdrawals,
  withdrawal,
  inputs,
  outputs,
  blockHeader,
  txInput,
  txOut,
  txTokenMap,
  redeemer,
  input,
  withdrawals,
  outputWithInlineDatum
];