feat: detailed error messages from deploy methods
This commit is contained in:
@@ -74,20 +74,23 @@ export class DefaultCreateContract implements CreateContract {
|
|||||||
|
|
||||||
await this.arweave.transactions.sign(contractTX, wallet);
|
await this.arweave.transactions.sign(contractTX, wallet);
|
||||||
|
|
||||||
let responseOk;
|
let responseOk: boolean;
|
||||||
|
let response: { status: number; statusText: string; data: any };
|
||||||
if (useBundler) {
|
if (useBundler) {
|
||||||
const result = await this.post(contractTX, srcTx);
|
const result = await this.post(contractTX, srcTx);
|
||||||
this.logger.debug(result);
|
this.logger.debug(result);
|
||||||
responseOk = true;
|
responseOk = true;
|
||||||
} else {
|
} else {
|
||||||
const response = await this.arweave.transactions.post(contractTX);
|
response = await this.arweave.transactions.post(contractTX);
|
||||||
responseOk = response.status === 200 || response.status === 208;
|
responseOk = response.status === 200 || response.status === 208;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseOk) {
|
if (responseOk) {
|
||||||
return { contractTxId: contractTX.id, srcTxId };
|
return { contractTxId: contractTX.id, srcTxId };
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unable to write Contract`);
|
throw new Error(
|
||||||
|
`Unable to write Contract. Arweave responded with status ${response.status}: ${response.statusText}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,7 +118,9 @@ export class DefaultCreateContract implements CreateContract {
|
|||||||
if (response.ok) {
|
if (response.ok) {
|
||||||
return response.json();
|
return response.json();
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Error while posting contract ${response.statusText}`);
|
throw new Error(
|
||||||
|
`Error while posting contract. Sequencer responded with status ${response.status} ${response.statusText}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -122,15 +122,18 @@ export class SourceImpl implements Source {
|
|||||||
// note: in case of useBundler = true, we're posting both
|
// note: in case of useBundler = true, we're posting both
|
||||||
// src tx and contract tx in one request.
|
// src tx and contract tx in one request.
|
||||||
let responseOk = true;
|
let responseOk = true;
|
||||||
|
let response: { status: number; statusText: string; data: any };
|
||||||
if (!useBundler) {
|
if (!useBundler) {
|
||||||
const response = await this.arweave.transactions.post(srcTx);
|
response = await this.arweave.transactions.post(srcTx);
|
||||||
responseOk = response.status === 200 || response.status === 208;
|
responseOk = response.status === 200 || response.status === 208;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (responseOk) {
|
if (responseOk) {
|
||||||
return srcTx;
|
return srcTx;
|
||||||
} else {
|
} else {
|
||||||
throw new Error(`Unable to write Contract Source`);
|
throw new Error(
|
||||||
|
`Unable to write Contract Source. Arweave responded with status ${response.status}: ${response.statusText}`
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user