UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

43 lines (42 loc) 1.85 kB
import { fromBase64, fromHex } from '@btc-vision/bitcoin'; import { Address } from '@btc-vision/transaction'; import { TransactionBase } from '../Transaction.js'; export class DeploymentTransaction extends TransactionBase { contractAddress; contractPublicKey; bytecode; wasCompressed; deployerPubKey; deployerHashedPublicKey; deployerAddress; contractSeed; contractSaltHash; from; constructor(transaction, network) { super(transaction, network); if (!transaction.deployerAddress && (transaction.revert === null || transaction.revert === undefined)) { throw new Error('Deployer address is missing'); } try { this.from = new Address(fromBase64(transaction.from), fromBase64(transaction.fromLegacy)); this.contractAddress = transaction.contractAddress; this.contractPublicKey = new Address(fromBase64(transaction.contractPublicKey)); this.bytecode = fromBase64(transaction.bytecode); this.wasCompressed = transaction.wasCompressed; if (transaction.deployerPubKey) { this.deployerPubKey = fromBase64(transaction.deployerPubKey); } if (transaction.deployerAddress) { const deployerAddr = transaction.deployerAddress; this.deployerHashedPublicKey = fromHex(deployerAddr.startsWith('0x') ? deployerAddr.slice(2) : deployerAddr); } if (this.deployerHashedPublicKey && this.deployerPubKey) { this.deployerAddress = new Address(this.deployerHashedPublicKey, this.deployerPubKey); } this.contractSeed = fromBase64(transaction.contractSeed); this.contractSaltHash = fromBase64(transaction.contractSaltHash); } catch { } } }