Skip to content

Commit 7c3304b

Browse files
committed
refactor: utxo to core
1 parent c172805 commit 7c3304b

File tree

4 files changed

+316
-160
lines changed

4 files changed

+316
-160
lines changed

packages/evolution-devnet/test/Client.Devnet.test.ts

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,17 @@ import { describe, expect, it } from "@effect/vitest"
22
import * as Cluster from "@evolution-sdk/devnet/Cluster"
33
import * as Config from "@evolution-sdk/devnet/Config"
44
import * as Genesis from "@evolution-sdk/devnet/Genesis"
5-
import * as Address from "@evolution-sdk/evolution/core/AddressEras"
5+
import { Core } from "@evolution-sdk/evolution"
6+
import * as CoreAddress from "@evolution-sdk/evolution/core/Address"
67
import * as Assets from "@evolution-sdk/evolution/sdk/Assets"
78
import { createClient } from "@evolution-sdk/evolution/sdk/client/ClientImpl"
89
import type { ProtocolParameters } from "@evolution-sdk/evolution/sdk/ProtocolParameters"
910
import type { UTxO } from "@evolution-sdk/evolution/sdk/UTxO"
1011
import { afterAll, beforeAll } from "vitest"
12+
import { createCoreTestUtxo } from "./utils/utxo-helpers"
13+
14+
// Alias for Core.Assets
15+
const CoreAssets = Core.Assets
1116

1217
/**
1318
* Client integration tests with local Devnet
@@ -41,8 +46,8 @@ describe("Client with Devnet", () => {
4146
wallet: { type: "seed", mnemonic: TEST_MNEMONIC, accountIndex: 0 }
4247
})
4348

44-
const testAddressBech32 = await testClient.address()
45-
const testAddressHex = Address.toHex(Address.fromBech32(testAddressBech32))
49+
const testAddress = await testClient.address()
50+
const testAddressHex = CoreAddress.toHex(testAddress)
4651

4752
genesisConfig = {
4853
...Config.DEFAULT_SHELLEY_GENESIS,
@@ -92,7 +97,8 @@ describe("Client with Devnet", () => {
9297

9398
const address = await client.address()
9499
expect(address).toBeDefined()
95-
expect(address).toMatch(/^addr_test/)
100+
const addressBech32 = CoreAddress.toBech32(address)
101+
expect(addressBech32).toMatch(/^addr_test/)
96102
})
97103

98104
it("should query wallet UTxOs", { timeout: 30_000 }, async () => {
@@ -123,18 +129,27 @@ describe("Client with Devnet", () => {
123129

124130
const client = createTestClient()
125131
const genesisAddress = await client.address()
126-
const genesisUtxo = genesisUtxos.find((u) => u.address === genesisAddress)
132+
const genesisAddressBech32 = CoreAddress.toBech32(genesisAddress)
133+
const genesisUtxoSdk = genesisUtxos.find((u) => u.address === genesisAddressBech32)
127134

128-
if (!genesisUtxo) {
135+
if (!genesisUtxoSdk) {
129136
throw new Error("Genesis UTxO not found")
130137
}
131138

139+
// Convert SDK UTxO to Core UTxO
140+
const genesisUtxo = createCoreTestUtxo({
141+
address: genesisUtxoSdk.address,
142+
transactionId: genesisUtxoSdk.txHash,
143+
index: genesisUtxoSdk.outputIndex,
144+
lovelace: Assets.getAsset(genesisUtxoSdk.assets, "lovelace")
145+
})
146+
132147
const receiverAddress =
133148
"addr_test1qz2fxv2umyhttkxyxp8x0dlpdt3k6cwng5pxj3jhsydzer3n0d3vllmyqwsx5wktcd8cc3sq835lu7drv2xwl2wywfgs68faae"
134149

135150
const signBuilder = await client
136151
.newTx()
137-
.payToAddress({ address: receiverAddress, assets: Assets.fromLovelace(5_000_000n) })
152+
.payToAddress({ address: CoreAddress.fromBech32(receiverAddress), assets: CoreAssets.fromLovelace(5_000_000n) })
138153
.build({ availableUtxos: [genesisUtxo] })
139154

140155
const tx = await signBuilder.toTransaction()

0 commit comments

Comments
 (0)