feat: merge api (#658)

This commit is contained in:
Cafe137
2024-06-03 15:07:01 -07:00
committed by GitHub
parent b3f521ca20
commit 8cbd812a2c
43 changed files with 218 additions and 717 deletions
-2
View File
@@ -6,8 +6,6 @@ import { getJson, postJson } from './net'
export interface BeeConfig {
'api-addr': string
'debug-api-addr': string
'debug-api-enable': boolean
password: string
'swap-enable': boolean
'swap-initial-deposit': bigint
+2 -2
View File
@@ -114,8 +114,8 @@ export function packageFile(file: FilePath, pathOverwrite?: string): FilePath {
size: file.size,
type: file.type,
stream: file.stream,
slice: file.slice,
slice: (start: number, end: number) => file.slice(start, end),
text: file.text,
arrayBuffer: async () => await file.arrayBuffer(), // This is needed for successful upload and can not simply be { arrayBuffer: file.arrayBuffer }
arrayBuffer: async () => await file.arrayBuffer(),
}
}
+2 -5
View File
@@ -1,4 +1,4 @@
import { BatchId, Bee, BeeDebug, Reference } from '@ethersphere/bee-js'
import { BatchId, Bee, Reference } from '@ethersphere/bee-js'
import { Wallet } from 'ethers'
import { uuidV4, waitUntilStampUsable } from '.'
import { Identity, IdentityType } from '../providers/Feeds'
@@ -79,7 +79,6 @@ async function getWallet(type: IdentityType, data: string, password?: string): P
export async function updateFeed(
beeApi: Bee,
beeDebugApi: BeeDebug | null,
identity: Identity,
hash: string,
stamp: string,
@@ -93,8 +92,6 @@ export async function updateFeed(
const writer = beeApi.makeFeedWriter('sequence', '00'.repeat(32), wallet.privateKey)
if (beeDebugApi) {
await waitUntilStampUsable(stamp as BatchId, beeDebugApi)
}
await waitUntilStampUsable(stamp as BatchId, beeApi)
await writer.upload(stamp, hash as Reference)
}
+7 -7
View File
@@ -1,4 +1,4 @@
import { BatchId, BeeDebug, PostageBatch } from '@ethersphere/bee-js'
import { BatchId, Bee, PostageBatch } from '@ethersphere/bee-js'
import { decodeCid } from '@ethersphere/swarm-cid'
import { BigNumber } from 'bignumber.js'
import { BZZ_LINK_DOMAIN } from '../constants'
@@ -232,17 +232,17 @@ interface Options {
timeout?: number
}
export function waitUntilStampUsable(batchId: BatchId, beeDebug: BeeDebug, options?: Options): Promise<PostageBatch> {
return waitForStamp(batchId, beeDebug, 'usable', options)
export function waitUntilStampUsable(batchId: BatchId, bee: Bee, options?: Options): Promise<PostageBatch> {
return waitForStamp(batchId, bee, 'usable', options)
}
export function waitUntilStampExists(batchId: BatchId, beeDebug: BeeDebug, options?: Options): Promise<PostageBatch> {
return waitForStamp(batchId, beeDebug, 'exists', options)
export function waitUntilStampExists(batchId: BatchId, bee: Bee, options?: Options): Promise<PostageBatch> {
return waitForStamp(batchId, bee, 'exists', options)
}
async function waitForStamp(
batchId: BatchId,
beeDebug: BeeDebug,
bee: Bee,
field: 'exists' | 'usable',
options?: Options,
): Promise<PostageBatch> {
@@ -251,7 +251,7 @@ async function waitForStamp(
for (let i = 0; i < timeout; i += pollingFrequency) {
try {
const stamp = await beeDebug.getPostageBatch(batchId)
const stamp = await bee.getPostageBatch(batchId)
if (stamp[field]) return stamp
} catch {
+1 -1
View File
@@ -1,5 +1,5 @@
import { Bee, Utils } from '@ethersphere/bee-js'
import { loadAllNodes, MantarayNode, MetadataMapping, Reference } from 'mantaray-js'
import { MantarayNode, MetadataMapping, Reference, loadAllNodes } from 'mantaray-js'
interface ValueNode extends MantarayNode {
getEntry: Reference