Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add gateway constant #962

Merged
merged 1 commit into from
Oct 24, 2024
Merged
Show file tree
Hide file tree
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
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,20 @@ Loading this module through a script tag will make the `BeeJs` object available

## Usage

### Upload via Swarm Gateway

```js
import { Bee, NULL_STAMP, SWARM_GATEWAY_URL } from '@ethersphere/bee-js'

main()

async function main() {
const bee = new Bee(SWARM_GATEWAY_URL)
const { reference } = await bee.uploadData(NULL_STAMP, 'Hello, World!')
console.log(reference)
}
```

### Create or select an existing postage batch

Swarm incentivizes nodes in the network to store content, therefor all uploads require a paid
Expand Down
1 change: 1 addition & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { Bee } from './bee'

export { SUPPORTED_BEE_VERSION, SUPPORTED_BEE_VERSION_EXACT } from './modules/debug/status'
export * from './types'
export * from './utils/constants'
export * from './utils/error'
export * as Utils from './utils/expose'
export { Bee }
Expand Down
5 changes: 5 additions & 0 deletions src/utils/constants.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { BatchId, Topic } from '..'

export const SWARM_GATEWAY_URL = 'https://api.gateway.ethswarm.org'
export const NULL_STAMP: BatchId = '0000000000000000000000000000000000000000000000000000000000000000' as BatchId
export const NULL_TOPIC: Topic = '0000000000000000000000000000000000000000000000000000000000000000' as Topic
5 changes: 0 additions & 5 deletions src/utils/expose.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import { BatchId, Topic } from '..'

export { getCollectionSize } from './collection'
export { getFolderSize } from './collection.node'

Expand Down Expand Up @@ -54,6 +52,3 @@ export {
} from './stamps'

export { approximateOverheadForRedundancyLevel, getRedundancyStat, getRedundancyStats } from './redundancy'

export const NULL_STAMP: BatchId = '0000000000000000000000000000000000000000000000000000000000000000' as BatchId
export const NULL_TOPIC: Topic = '0000000000000000000000000000000000000000000000000000000000000000' as Topic
2 changes: 1 addition & 1 deletion test/integration/feed/index.spec.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { NULL_TOPIC } from '../../../src'
import { makeContentAddressedChunk } from '../../../src/chunk/cac'
import { makePrivateKeySigner } from '../../../src/chunk/signer'
import { downloadFeedUpdate, FeedUploadOptions, findNextIndex, updateFeed } from '../../../src/feed'
import * as chunkAPI from '../../../src/modules/chunk'
import { fetchLatestFeedUpdate } from '../../../src/modules/feed'
import type { BeeRequestOptions, BytesReference, PrivateKeyBytes, Signer, Topic } from '../../../src/types'
import { assertBytes, Bytes } from '../../../src/utils/bytes'
import { NULL_TOPIC } from '../../../src/utils/expose'
import { hexToBytes, makeHexString } from '../../../src/utils/hex'
import { beeKyOptions, getPostageBatch, testIdentity } from '../../utils'

Expand Down
2 changes: 1 addition & 1 deletion test/integration/modules/feed.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { NULL_TOPIC } from '../../../src'
import { createFeedManifest, fetchLatestFeedUpdate } from '../../../src/modules/feed'
import { upload as uploadSOC } from '../../../src/modules/soc'
import type { Topic } from '../../../src/types'
import { NULL_TOPIC } from '../../../src/utils/expose'
import { HexString, hexToBytes, makeHexString } from '../../../src/utils/hex'
import { beeKyOptions, commonMatchers, getPostageBatch, testIdentity } from '../../utils'

Expand Down
Loading