fix: trying to fix arlocal issues with loading wasm binaries..

This commit is contained in:
ppedziwiatr
2022-03-23 21:35:28 +01:00
parent fb310845d7
commit e9c0f09010
2 changed files with 15 additions and 6 deletions

View File

@@ -121,8 +121,6 @@ describe('Testing the Go WASM Profit Sharing Token', () => {
it('should properly deploy contract', async () => {
const contractTx = await arweave.transactions.get(contractTxId);
console.log(contractTx.id);
expect(contractTx).not.toBeNull();
expect(getTag(contractTx, SmartWeaveTags.CONTRACT_TYPE)).toEqual('wasm');
expect(getTag(contractTx, SmartWeaveTags.WASM_LANG)).toEqual('go');

View File

@@ -90,10 +90,21 @@ export class ArweaveWrapper {
async txData(id: string): Promise<Buffer> {
// https://github.com/textury/arlocal/issues/83
const txData = (await this.arweave.transactions.getData(id, {
decode: true
})) as Uint8Array;
return isomorphicBuffer.from(txData);
try {
const txData = (await this.arweave.transactions.getData(id, {
decode: true
})) as Uint8Array;
return isomorphicBuffer.from(txData);
} catch (e) {
const response = await fetch(`${this.baseUrl}/${id}`);
if (!response.ok) {
this.logger.error(e);
this.logger.error(response.statusText);
throw new Error('Unable to load tx data');
}
const buffer = await response.arrayBuffer();
return isomorphicBuffer.from(buffer);
}
// note: this is using arweave.net cache -
// not very safe and clever, but fast...