Skip to content

Save contract source through Bundlr

Compare
Choose a tag to compare
@asiaziola asiaziola released this 02 Dec 15:54
· 302 commits to main since this release

This release adds an option to save contract source through Bundlr using Warp Gateway and introduces some significant API changes.

  1. Saving source through Bundlr
    This release splits contract source saving process to two parts - creating source and saving source.
  • createSourceTx - creates and signs contract source transaction, returns signed contract source transaction
createSourceTx(sourceData: SourceData, wallet: ArWallet | SignatureType): Promise<Transaction>;

usage:

const srcTx = await warp.createSourceTx({ src: contractSrc }, wallet);
  • saveSourceTx - saves source transaction created using createSourceTx method; by default source transaction is sent to Warp Gateway where it is uploaded to Bundlr, if in local environment or bundle is disabled using disableBundling method - source transaction is sent directly to Arweave, returns source transaction id
saveSourceTx(sourceTx: Transaction, disableBundling?: boolean): Promise<string>;

usage:

const srcTxId = await warp.saveSourceTx(srcTx);

Above methods are useful particularly when one contract needs to evolve its current contract source:

const srcTx = await warp.createSourceTx({ src: newJsContractSrc }, wallet);
const newSrcTxId = await warp.saveSourceTx(srcTx);
await contract.evolve(newSrcTxId);

...it is also useful when one contract source should be later used by multiple contracts.

  1. API changes
  • createContract field in Warp instance is now deprecated and will be changed into private field soon. All CreateContract methods are now accessible directly from Warp instance, they can be used like so:
const { contractTxId } = await warp.deploy({
  wallet,
  initState: JSON.stringify(initialState),
  src: contractSrc
});

List of CreateContract methods now available from Warp instance:

async deploy(contractData: ContractData, disableBundling?: boolean): Promise<ContractDeploy>;
async deployFromSourceTx(contractData: FromSrcTxContractData, disableBundling?: boolean): Promise<ContractDeploy>;
async deployBundled(rawDataItem: Buffer): Promise<ContractDeploy>;
async createSourceTx(sourceData: SourceData, wallet: ArWallet | SignatureType): Promise<Transaction> 
async saveSourceTx(srcTx: Transaction, disableBundling?: boolean): Promise<string>

What's Changed

Full Changelog: 1.2.31...v1.2.32