Save contract source through Bundlr
This release adds an option to save contract source through Bundlr using Warp Gateway and introduces some significant API changes.
- 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 usingcreateSourceTx
method; by default source transaction is sent to Warp Gateway where it is uploaded to Bundlr, if in local environment or bundle is disabled usingdisableBundling
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.
- API changes
createContract
field inWarp
instance is now deprecated and will be changed into private field soon. AllCreateContract
methods are now accessible directly fromWarp
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
- feat: save source through bundlr by @asiaziola in #283
Full Changelog: 1.2.31...v1.2.32