From 015edae98d5ccd3b9e160412bd8c2d1ae0f86b0f Mon Sep 17 00:00:00 2001 From: NoahMaizels Date: Wed, 3 Sep 2025 21:54:02 +0700 Subject: [PATCH] feat: update to use buyStorage to purchase postage --- src/templates/app.tsx.ts | 4 ++-- src/templates/index.ts.ts | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/templates/app.tsx.ts b/src/templates/app.tsx.ts index 6e53239..c357ec0 100644 --- a/src/templates/app.tsx.ts +++ b/src/templates/app.tsx.ts @@ -1,5 +1,5 @@ export function getAppTsxTemplate(beeInit: string) { - return `import { BatchId, Bee } from '@ethersphere/bee-js' + return `import { BatchId, Bee, Size, Duration } from '@ethersphere/bee-js' import { useState } from 'react' import { BEE_HOST } from './config' @@ -18,7 +18,7 @@ export function App() { if (usable) { setBatchId(usable.batchID) } else { - setBatchId(await bee.createPostageBatch('500000000', 20)) + setBatchId(await bee.buyStorage(Size.fromGigabytes(1), Duration.fromDays(1))) } } diff --git a/src/templates/index.ts.ts b/src/templates/index.ts.ts index 8d953b0..dff577b 100644 --- a/src/templates/index.ts.ts +++ b/src/templates/index.ts.ts @@ -2,7 +2,7 @@ import { makeImport } from '../importer' import { CodeType } from '../types' export function getIndexTsTemplate(beeInit: string, codeType: CodeType) { - return `${makeImport(codeType, ['Bee'], '@ethersphere/bee-js')} + return `${makeImport(codeType, ['Bee', 'Size', 'Duration'], '@ethersphere/bee-js')} ${makeImport(codeType, ['BEE_HOST'], './config')} main() @@ -25,7 +25,7 @@ async function getOrCreatePostageBatch(${codeType === 'typescript' ? 'bee: Bee' if (usable) { return usable.batchID } else { - return bee.createPostageBatch('500000000', 20) + return bee.buyStorage(Size.fromGigabytes(1), Duration.fromDays(1)) } } `