UNPKG

opnet

Version:

The perfect library for building Bitcoin-based applications.

40 lines (39 loc) 1.73 kB
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) { throw new Error('Deployer address is missing'); } try { this.from = new Address(Buffer.from(transaction.from, 'base64'), Buffer.from(transaction.fromLegacy, 'base64')); this.contractAddress = transaction.contractAddress; this.contractPublicKey = new Address(Buffer.from(transaction.contractPublicKey, 'base64')); this.bytecode = Buffer.from(transaction.bytecode, 'base64'); this.wasCompressed = transaction.wasCompressed; if (transaction.deployerPubKey) { this.deployerPubKey = Buffer.from(transaction.deployerPubKey, 'base64'); } if (transaction.deployerAddress) { this.deployerHashedPublicKey = Buffer.from(transaction.deployerAddress.replace('0x', ''), 'hex'); } if (this.deployerHashedPublicKey && this.deployerPubKey) { this.deployerAddress = new Address(this.deployerHashedPublicKey, this.deployerPubKey); } this.contractSeed = Buffer.from(transaction.contractSeed, 'base64'); this.contractSaltHash = Buffer.from(transaction.contractSaltHash, 'base64'); } catch { } } }