diff --git a/docs/pages/guides/creating_ship.mdx b/docs/pages/guides/creating_ship.mdx index d212263..9e1fe0e 100644 --- a/docs/pages/guides/creating_ship.mdx +++ b/docs/pages/guides/creating_ship.mdx @@ -8,12 +8,19 @@ Creates a `ShipState` UTxO locking min ada and a `ShipToken` (minted in this tx) ## Lucid Example ```ts +import { Kupmios } from "@blaze-cardano/sdk"; import { createShip } from "../src"; import { GameIdentifier, OutRef } from "../src/types"; +import { Unwrapped } from "@blaze-cardano/ogmios"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; + + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); const spacetime_script_reference: OutRef = { tx_hash: @@ -43,6 +50,7 @@ async function main() { }; const tx = await createShip( + provider, address, gameIdentifier, pos_x, diff --git a/docs/pages/guides/gathering_fuel.mdx b/docs/pages/guides/gathering_fuel.mdx index 3a31fb7..30fc3c0 100644 --- a/docs/pages/guides/gathering_fuel.mdx +++ b/docs/pages/guides/gathering_fuel.mdx @@ -1,11 +1,17 @@ -import { max } from "rxjs"; import { GameIdentifier, OutRef } from "../src/types"; import { gatherFuel } from "../src"; +import { Unwrapped } from "@blaze-cardano/ogmios"; +import { Kupmios } from "@blaze-cardano/sdk"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); + const ship_utxo: OutRef = { tx_hash: "3e04a7a3e4a1015705c44822feaf5f2da1e9609eebd68310c87b7eba7923739a", @@ -38,6 +44,7 @@ async function main() { }; const tx = await gatherFuel( + provider, address, gather_fuel_identifier, ); diff --git a/docs/pages/guides/mining_asteria.mdx b/docs/pages/guides/mining_asteria.mdx index de536f2..91df221 100644 --- a/docs/pages/guides/mining_asteria.mdx +++ b/docs/pages/guides/mining_asteria.mdx @@ -1,3 +1,5 @@ +import { Unwrapped } from "@blaze-cardano/ogmios"; +import { Kupmios } from "@blaze-cardano/sdk"; import { mineAsteria } from "../src"; import { GameIdentifier, OutRef } from "../src/types"; @@ -5,6 +7,11 @@ async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); + const spacetime_script_reference: OutRef = { tx_hash: "41e5881cd3bdc3f08bcf341796347e9027e3bcd8d58608b4fcfca5c16cbf5921", @@ -38,6 +45,7 @@ async function main() { }; const tx = await mineAsteria( + provider, address, gameIdentifier, ); diff --git a/docs/pages/guides/moving_ship.mdx b/docs/pages/guides/moving_ship.mdx index d01234b..c04be39 100644 --- a/docs/pages/guides/moving_ship.mdx +++ b/docs/pages/guides/moving_ship.mdx @@ -1,9 +1,16 @@ -import { createShip, moveShip } from "../src"; +import { Unwrapped } from "@blaze-cardano/ogmios"; +import { Kupmios } from "@blaze-cardano/sdk"; +import { moveShip } from "../src"; import { OutRef, GameIdentifier } from "../src/types"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; + + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); const ship_utxo: OutRef = { tx_hash: @@ -33,6 +40,7 @@ async function main() { }; const tx = await moveShip( + provider, address, move_ship_identifier, delta_x, diff --git a/sdk/blaze/examples/create-ship.ts b/sdk/blaze/examples/create-ship.ts index 6e3e4b2..6e52b30 100644 --- a/sdk/blaze/examples/create-ship.ts +++ b/sdk/blaze/examples/create-ship.ts @@ -1,10 +1,17 @@ +import { Kupmios } from "@blaze-cardano/sdk"; import { createShip } from "../src"; import { GameIdentifier, OutRef } from "../src/types"; +import { Unwrapped } from "@blaze-cardano/ogmios"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); + const spacetime_script_reference: OutRef = { tx_hash: "41e5881cd3bdc3f08bcf341796347e9027e3bcd8d58608b4fcfca5c16cbf5921", @@ -33,6 +40,7 @@ async function main() { }; const tx = await createShip( + provider, address, gameIdentifier, pos_x, diff --git a/sdk/blaze/examples/gather-fuel.ts b/sdk/blaze/examples/gather-fuel.ts index e4720ea..4bb66ed 100644 --- a/sdk/blaze/examples/gather-fuel.ts +++ b/sdk/blaze/examples/gather-fuel.ts @@ -1,11 +1,18 @@ -import { max } from "rxjs"; import { GameIdentifier, OutRef } from "../src/types"; import { gatherFuel } from "../src"; +import { Unwrapped } from "@blaze-cardano/ogmios"; +import { Kupmios } from "@blaze-cardano/sdk"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; - + + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); + + const ship_utxo: OutRef = { tx_hash: "3e04a7a3e4a1015705c44822feaf5f2da1e9609eebd68310c87b7eba7923739a", @@ -38,6 +45,7 @@ async function main() { }; const tx = await gatherFuel( + provider, address, gather_fuel_identifier, ); diff --git a/sdk/blaze/examples/mine-asteria.ts b/sdk/blaze/examples/mine-asteria.ts index 3a96907..161f1ff 100644 --- a/sdk/blaze/examples/mine-asteria.ts +++ b/sdk/blaze/examples/mine-asteria.ts @@ -1,10 +1,18 @@ +import { Unwrapped } from "@blaze-cardano/ogmios"; +import { Kupmios } from "@blaze-cardano/sdk"; import { mineAsteria } from "../src"; import { GameIdentifier, OutRef } from "../src/types"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; - + + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); + + const spacetime_script_reference: OutRef = { tx_hash: "41e5881cd3bdc3f08bcf341796347e9027e3bcd8d58608b4fcfca5c16cbf5921", @@ -38,6 +46,7 @@ async function main() { }; const tx = await mineAsteria( + provider, address, gameIdentifier, ); diff --git a/sdk/blaze/examples/move-ship.ts b/sdk/blaze/examples/move-ship.ts index d01234b..bf9e3ed 100644 --- a/sdk/blaze/examples/move-ship.ts +++ b/sdk/blaze/examples/move-ship.ts @@ -1,10 +1,18 @@ -import { createShip, moveShip } from "../src"; +import { Unwrapped } from "@blaze-cardano/ogmios"; +import { Kupmios } from "@blaze-cardano/sdk"; +import { moveShip } from "../src"; import { OutRef, GameIdentifier } from "../src/types"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); + + const ship_utxo: OutRef = { tx_hash: "41f2a593e131a3c5db878bbe7753b89c8c6de555b7127e812c0f488d1a898368", @@ -33,6 +41,7 @@ async function main() { }; const tx = await moveShip( + provider, address, move_ship_identifier, delta_x, diff --git a/sdk/blaze/examples/quit.ts b/sdk/blaze/examples/quit.ts index db92fee..be9bc13 100644 --- a/sdk/blaze/examples/quit.ts +++ b/sdk/blaze/examples/quit.ts @@ -1,10 +1,18 @@ -import { createShip, moveShip, quit } from "../src"; +import { Unwrapped } from "@blaze-cardano/ogmios"; +import { Kupmios } from "@blaze-cardano/sdk"; +import { quit } from "../src"; import { OutRef, GameIdentifier } from "../src/types"; async function main() { const address = "addr_test1qzjpgxkhe06gxzstfhywg02ggy5ltuwne6mfr406dlf0mpwp9a07r34cwsnkpn44tllxuydw4wp0xvstw5jqv5q9lszsk2qynn"; + const provider = new Kupmios( + process.env.KUPO_URL!, + await Unwrapped.Ogmios.new(process.env.OGMIOS_URL!) + ); + + const ship_utxo: OutRef = { tx_hash: "870b37da4cc82a16eb47db293713d81fe9abfe183055341174405e94768264c5", @@ -23,8 +31,6 @@ async function main() { tx_index: 0n, }; - - const quit_game_identifier: GameIdentifier = { ship_utxo, spacetime_script_reference, @@ -32,6 +38,7 @@ async function main() { }; const tx = await quit( + provider, address, quit_game_identifier, ); diff --git a/sdk/blaze/src/asteria.ts b/sdk/blaze/src/asteria.ts index 5b8b7a5..a00b06a 100644 --- a/sdk/blaze/src/asteria.ts +++ b/sdk/blaze/src/asteria.ts @@ -12,6 +12,7 @@ import { Constr, Core, Data, + Kupmios, makeValue, Static, } from "@blaze-cardano/sdk"; @@ -35,12 +36,13 @@ import { import { max } from "rxjs"; async function createShip( + provider: Kupmios, address: string, game_identifier: GameIdentifier, pos_x: bigint, pos_y: bigint, ): Promise { - const blaze = await blazeInit(address); + const blaze = await blazeInit(address, provider); const spacetime_ref_input = outRefToTransactionInput( game_identifier.spacetime_script_reference!, @@ -177,12 +179,13 @@ async function createShip( } async function moveShip( + provider: Kupmios, address: string, game_identifier: GameIdentifier, delta_x: bigint, delta_y: bigint, ): Promise { - const blaze = await blazeInit(address); + const blaze = await blazeInit(address, provider); const ship_input = outRefToTransactionInput(game_identifier.ship_utxo!); const spacetime_ref_input = outRefToTransactionInput( @@ -314,10 +317,11 @@ async function moveShip( } async function gatherFuel( + provider: Kupmios, address: string, game_identifier: GameIdentifier, ): Promise { - const blaze = await blazeInit(address); + const blaze = await blazeInit(address, provider); const ship_input = outRefToTransactionInput( game_identifier.ship_utxo!, @@ -482,10 +486,11 @@ async function gatherFuel( } async function mineAsteria( + provider: Kupmios, address: string, game_identifier: GameIdentifier, ): Promise { - const blaze = await blazeInit(address); + const blaze = await blazeInit(address, provider); const asteria_ref_input = outRefToTransactionInput( game_identifier.asteria_script_reference!, @@ -603,10 +608,11 @@ async function mineAsteria( } async function quit( + provider: Kupmios, address: string, game_identifier: GameIdentifier, ): Promise { - const blaze = await blazeInit(address); + const blaze = await blazeInit(address, provider); const ship_input = outRefToTransactionInput( game_identifier.ship_utxo!, diff --git a/sdk/blaze/src/types.ts b/sdk/blaze/src/types.ts index 684154e..0ea0dfc 100644 --- a/sdk/blaze/src/types.ts +++ b/sdk/blaze/src/types.ts @@ -95,5 +95,6 @@ export { PelletDatum, ShipDatum, SpaceTimeScriptDatum, - PelletScriptDatum + PelletScriptDatum, }; + diff --git a/sdk/blaze/src/utils.ts b/sdk/blaze/src/utils.ts index 123af42..a5cd6e4 100644 --- a/sdk/blaze/src/utils.ts +++ b/sdk/blaze/src/utils.ts @@ -1,16 +1,9 @@ import { Address, AssetId, NetworkId, TransactionId, TransactionInput } from "@blaze-cardano/core"; -import { Unwrapped } from "@blaze-cardano/ogmios"; import { Blaze, ColdWallet, Core, Kupmios } from "@blaze-cardano/sdk"; -import { GameIdentifier, OutRef } from "./types"; +import { OutRef } from "./types"; -async function blazeInit(address: string): Promise> { +async function blazeInit(address: string, provider: Kupmios): Promise> { const blaze_address = Core.Address.fromBech32(address); - const provider = new Kupmios( - "https://kupo1dce45wncnj6zgxxext7.preview-v2.kupo-m1.demeter.run", - await Unwrapped.Ogmios.new( - "https://ogmios13lw5mnhwypg5shrt9eh.preview-v5.ogmios-m1.demeter.run", - ), - ); const wallet = new ColdWallet(blaze_address, NetworkId.Testnet, provider); return Blaze.from(provider, wallet);