diff --git a/package.json b/package.json index ce25b6993..1998a6ee8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@interlay/polkabtc", - "version": "0.14.2", + "version": "0.14.3", "description": "JavaScript library to interact with PolkaBTC", "main": "build/index.js", "typings": "build/index.d.ts", @@ -47,13 +47,10 @@ "regtest-client": "^0.2.0", "sinon": "^9.0.3", "ts-mock-imports": "^1.3.0", - "@polkadot/api": "3.11.1", - "@polkadot/typegen": "3.11.1", + "@polkadot/api": "4.8.1", + "@polkadot/typegen": "4.8.1", "bitcoin-core": "^3.0.0" }, - "peerDependencies": { - "@polkadot/api": "3.11.1" - }, "devDependencies": { "@types/chai": "^4.2.12", "@types/chai-as-promised": "^7.1.3", diff --git a/src/polkabtc-api.ts b/src/polkabtc-api.ts index 873423a62..bc00827ea 100644 --- a/src/polkabtc-api.ts +++ b/src/polkabtc-api.ts @@ -21,7 +21,7 @@ import { Network, networks } from "bitcoinjs-lib"; export * from "./factory"; export * from "./parachain/transaction"; -function getBitcoinNetwork(network: string = "mainnet"): Network { +export function getBitcoinNetwork(network: string = "mainnet"): Network { switch (network) { case "mainnet": return networks.bitcoin; diff --git a/src/utils/bitcoin-core-client.ts b/src/utils/bitcoin-core-client.ts index d5980f8cb..268ec7165 100644 --- a/src/utils/bitcoin-core-client.ts +++ b/src/utils/bitcoin-core-client.ts @@ -66,8 +66,6 @@ export class BitcoinCoreClient { throw new Error("Client needs to be initialized before usage"); } - const paidOutput: { [key: string]: string } = {}; - paidOutput[recipient] = amount.toString(); const raw = await this.client.command( "createrawtransaction", [], diff --git a/src/utils/issue.ts b/src/utils/issue.ts index 54959c459..5af62a2fc 100644 --- a/src/utils/issue.ts +++ b/src/utils/issue.ts @@ -1,9 +1,8 @@ import { ApiPromise } from "@polkadot/api"; import { KeyringPair } from "@polkadot/keyring/types"; -import * as bitcoinjs from "bitcoinjs-lib"; import Big from "big.js"; -import { btcToSat, satToBTC, IssueRequestExt } from ".."; +import { btcToSat, satToBTC, IssueRequestExt, getBitcoinNetwork } from ".."; import { ElectrsAPI } from "../external/electrs"; import { DefaultCollateralAPI } from "../parachain/collateral"; import { IssueRequestResult, DefaultIssueAPI } from "../parachain/issue"; @@ -26,10 +25,12 @@ export async function issue( amount: Big, vaultAddress?: string, autoExecute = true, - triggerRefund = false + triggerRefund = false, + network = "regtest", ): Promise { const treasuryAPI = new DefaultTreasuryAPI(api); - const issueAPI = new DefaultIssueAPI(api, bitcoinjs.networks.regtest, electrsAPI); + const bitcoinjsNetwork = getBitcoinNetwork(network); + const issueAPI = new DefaultIssueAPI(api, bitcoinjsNetwork, electrsAPI); const collateralAPI = new DefaultCollateralAPI(api); issueAPI.setAccount(issuingAccount); diff --git a/test/integration/parachain/release/redeem.test.ts b/test/integration/parachain/release/redeem.test.ts index 36326e2ac..bd7d274b8 100644 --- a/test/integration/parachain/release/redeem.test.ts +++ b/test/integration/parachain/release/redeem.test.ts @@ -21,12 +21,10 @@ describe("redeem", () => { let keyring: Keyring; // alice is the root account let alice: KeyringPair; - let ferdie: KeyringPair; before(async () => { api = await createPolkadotAPI(defaultParachainEndpoint); keyring = new Keyring({ type: "sr25519" }); - ferdie = keyring.addFromUri("//Ferdie"); alice = keyring.addFromUri("//Alice"); electrsAPI = new DefaultElectrsAPI("http://0.0.0.0:3002"); }); @@ -50,7 +48,7 @@ describe("redeem", () => { "rpcuser", "rpcpassword", "18443", - vaultToLiquidate.address + "Bob" ); // Steal some bitcoin (spend from the vault's account) @@ -61,7 +59,7 @@ describe("redeem", () => { await DefaultTransactionAPI.waitForEvent(api, api.events.stakedRelayers.VaultTheft, 17 * 60000); // Burn PolkaBTC for a premium, to restore peg - redeemAPI.setAccount(ferdie); + redeemAPI.setAccount(alice); await redeemAPI.burn(amount); // it takes about 15 mins for the theft to be reported