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);
|
||||
|
||||
let responseOk;
|
||||
let responseOk: boolean;
|
||||
let response: { status: number; statusText: string; data: any };
|
||||
if (useBundler) {
|
||||
const result = await this.post(contractTX, srcTx);
|
||||
this.logger.debug(result);
|
||||
responseOk = true;
|
||||
} else {
|
||||
const response = await this.arweave.transactions.post(contractTX);
|
||||
response = await this.arweave.transactions.post(contractTX);
|
||||
responseOk = response.status === 200 || response.status === 208;
|
||||
}
|
||||
|
||||
if (responseOk) {
|
||||
return { contractTxId: contractTX.id, srcTxId };
|
||||
} 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) {
|
||||
return response.json();
|
||||
} 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
|
||||
// src tx and contract tx in one request.
|
||||
let responseOk = true;
|
||||
let response: { status: number; statusText: string; data: any };
|
||||
if (!useBundler) {
|
||||
const response = await this.arweave.transactions.post(srcTx);
|
||||
response = await this.arweave.transactions.post(srcTx);
|
||||
responseOk = response.status === 200 || response.status === 208;
|
||||
}
|
||||
|
||||
if (responseOk) {
|
||||
return srcTx;
|
||||
} 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