fix: workaround for slow arweave.createTransaction for bundled interactions
This commit is contained in:
@@ -251,7 +251,14 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
...options
|
||||
};
|
||||
|
||||
const interactionTx = await this.createInteraction(input, options.tags, emptyTransfer, options.strict, options.vrf);
|
||||
const interactionTx = await this.createInteraction(
|
||||
input,
|
||||
options.tags,
|
||||
emptyTransfer,
|
||||
options.strict,
|
||||
true,
|
||||
options.vrf
|
||||
);
|
||||
|
||||
const response = await fetch(`${this._evaluationOptions.bundlerUrl}gateway/sequencer/register`, {
|
||||
method: 'POST',
|
||||
@@ -280,7 +287,14 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
};
|
||||
}
|
||||
|
||||
private async createInteraction<Input>(input: Input, tags: Tags, transfer: ArTransfer, strict: boolean, vrf = false) {
|
||||
private async createInteraction<Input>(
|
||||
input: Input,
|
||||
tags: Tags,
|
||||
transfer: ArTransfer,
|
||||
strict: boolean,
|
||||
bundle = false,
|
||||
vrf = false
|
||||
) {
|
||||
if (this._evaluationOptions.internalWrites) {
|
||||
// Call contract and verify if there are any internal writes:
|
||||
// 1. Evaluate current contract state
|
||||
@@ -328,7 +342,8 @@ export class HandlerBasedContract<State> implements Contract<State> {
|
||||
input,
|
||||
tags,
|
||||
transfer.target,
|
||||
transfer.winstonQty
|
||||
transfer.winstonQty,
|
||||
bundle
|
||||
);
|
||||
return interactionTx;
|
||||
}
|
||||
|
||||
@@ -11,7 +11,8 @@ export async function createTx(
|
||||
input: any,
|
||||
tags: { name: string; value: string }[],
|
||||
target = '',
|
||||
winstonQty = '0'
|
||||
winstonQty = '0',
|
||||
bundle = false
|
||||
): Promise<Transaction> {
|
||||
const options: Partial<CreateTransactionInterface> = {
|
||||
data: Math.random().toString().slice(-4)
|
||||
@@ -24,6 +25,15 @@ export async function createTx(
|
||||
}
|
||||
}
|
||||
|
||||
// both reward and last_tx are irrelevant in case of interactions
|
||||
// that are bundled. So to speed up the procees (and prevent the arweave-js
|
||||
// from calling /tx_anchor and /price endpoints) - we're presetting theses
|
||||
// values here
|
||||
if (bundle) {
|
||||
options.reward = '72600854';
|
||||
options.last_tx = 'p7vc1iSP6bvH_fCeUFa9LqoV5qiyW-jdEKouAT0XMoSwrNraB9mgpi29Q10waEpO';
|
||||
}
|
||||
|
||||
const interactionTx = await arweave.createTransaction(options);
|
||||
|
||||
if (!input) {
|
||||
|
||||
Reference in New Issue
Block a user