feat: merge api (#658)
This commit is contained in:
@@ -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
@@ -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(),
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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
@@ -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,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
|
||||
|
||||
Reference in New Issue
Block a user