Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions scenarios/synapse-e2e/account.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,14 @@ async function waitForTransaction(synapse: ScenarioSynapse, hash: Hash, label: s
throw new Error(`${label} transaction ${hash} was not confirmed${details}`)
}

export async function prepareAccount(synapse: ScenarioSynapse, dataSize: bigint): Promise<AccountState> {
export async function prepareAccount(synapse: ScenarioSynapse, pieceSize: bigint): Promise<AccountState> {
const before = await readAccountState(synapse)
const { costs, transaction } = await synapse.storage.prepare({ dataSize })
const options = {
// TODO: Remove dataSize after dropping Synapse SDK 1.2 compatibility.
dataSize: pieceSize,
pieceSizes: [pieceSize],
}
Comment thread
Kubuxu marked this conversation as resolved.
const { costs, transaction } = await synapse.storage.prepare(options)
assert.equal(transaction == null, costs.ready, 'Account readiness and preparation transaction disagree')
console.log(
`Account preparation: ready=${costs.ready} deposit=${costs.depositNeeded} approval=${costs.needsFwssMaxApproval}`
Expand All @@ -79,7 +84,7 @@ export async function prepareAccount(synapse: ScenarioSynapse, dataSize: bigint)
console.log(`Account funding confirmed: ${result.hash}`)
}

const ready = await synapse.storage.prepare({ dataSize })
const ready = await synapse.storage.prepare(options)
assert.equal(ready.costs.ready, true, 'Payment account remains unprepared')
assert.equal(ready.transaction, null, 'Prepared payment account still requires a transaction')
const after = await readAccountState(synapse)
Expand All @@ -93,10 +98,16 @@ export async function prepareAccount(synapse: ScenarioSynapse, dataSize: bigint)

export async function prepareAccountWithPlainErc20(
synapse: ScenarioSynapse,
dataSize: bigint,
pieceSize: bigint,
context: StorageContext
): Promise<AccountState> {
const { costs, transaction } = await synapse.storage.prepare({ context, dataSize })
const options = {
context,
// TODO: Remove dataSize after dropping Synapse SDK 1.2 compatibility.
dataSize: pieceSize,
pieceSizes: [pieceSize],
}
const { costs, transaction } = await synapse.storage.prepare(options)
assert.equal(transaction == null, costs.ready, 'Account readiness and preparation transaction disagree')
console.log(
`Plain ERC20 preparation: ready=${costs.ready} deposit=${costs.depositNeeded} approval=${costs.needsFwssMaxApproval}`
Expand All @@ -122,7 +133,7 @@ export async function prepareAccountWithPlainErc20(
await waitForTransaction(synapse, approvalHash, 'FWSS approval')
}

const ready = await synapse.storage.prepare({ context, dataSize })
const ready = await synapse.storage.prepare(options)
assert.equal(ready.costs.ready, true, 'Plain ERC20 payment account remains unprepared')
assert.equal(ready.transaction, null, 'Prepared plain ERC20 account still requires a transaction')
const account = await readAccountState(synapse)
Expand Down