Skip to content

Commit

Permalink
Merge pull request #124 from ardriveapp/build-and-docs
Browse files Browse the repository at this point in the history
fix(build): update build outputs for web and README
  • Loading branch information
dtfiedler authored Aug 7, 2024
2 parents e37949b + 74cce09 commit 0282d71
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 18 deletions.
56 changes: 45 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,31 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac

## Table of Contents

<!-- toc -->

- [Table of Contents](#table-of-contents)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Usage](#usage)
- [Web](#web)
- [Bundlers (Webpack, Rollup, ESbuild, etc.)](#bundlers-webpack-rollup-esbuild-etc)
- [Browser](#browser)
- [NodeJS](#nodejs)
- [CommonJS](#commonjs)
- [ESM](#esm)
- [Typescript](#typescript)
- [Examples](#examples)
- [APIs](#apis)
- [TurboFactory](#turbofactory)
- [`unauthenticated()`](#unauthenticated)
- [`authenticated()`](#authenticated)
- [Arweave JWK](#arweave-jwk)
- [ArweaveSigner](#arweavesigner)
- [ArconnectSigner](#arconnectsigner)
- [EthereumSigner](#ethereumsigner)
- [Ethereum Private Key](#ethereum-private-key)
- [HexSolanaSigner](#hexsolanasigner)
- [Solana Secret Key](#solana-secret-key)
- [TurboUnauthenticatedClient](#turbounauthenticatedclient)
- [`getSupportedCurrencies()`](#getsupportedcurrencies)
- [`getSupportedCountries()`](#getsupportedcountries)
Expand All @@ -26,14 +40,26 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
- [`getUploadCosts({ bytes })`](#getuploadcosts-bytes-)
- [`uploadSignedDataItem({ dataItemStreamFactory, dataItemSizeFactory, signal })`](#uploadsigneddataitem-dataitemstreamfactory-dataitemsizefactory-signal-)
- [`createCheckoutSession({ amount, owner })`](#createcheckoutsession-amount-owner-)
- [Arweave (AR)](#arweave-ar)
- [Ethereum (ETH)](#ethereum-eth)
- [Solana (SOL)](#solana-sol)
- [`submitFundTransaction({ txId })`](#submitfundtransaction-txid-)
- [TurboAuthenticatedClient](#turboauthenticatedclient)
- [`getBalance()`](#getbalance)
- [`getWincForFiat({ amount, promoCodes })`](#getwincforfiat-amount-promocodes-)
- [`createCheckoutSession({ amount, owner, promoCodes })`](#createcheckoutsession-amount-owner-promocodes-)
- [`uploadFile({ fileStreamFactory, fileSizeFactory, signal, dataItemOpts })`](#uploadfile-filestreamfactory-filesizefactory-signal-dataitemopts-)
- [`topUpWithTokens({ tokenAmount, feeMultiplier })`](#topupwithtokens-tokenamount-feemultiplier-)
- [Ethereum (ETH)](#ethereum-eth-1)
- [Solana (SOL)](#solana-sol-1)
- [Developers](#developers)
- [Requirements](#requirements)
- [Setup & Build](#setup--build)
- [Testing](#testing)
- [Linting & Formatting](#linting--formatting)
- [Architecture](#architecture)

<!-- tocstop -->

## Installation

Expand Down Expand Up @@ -119,6 +145,9 @@ const turbo = TurboFactory.unauthenticated();
const rates = await turbo.getFiatRates();
```

> [!WARNING]
> Polyfills are not provided by default for bundled web projects (Vite, ESBuild, Webpack, Rollup, etc.) . Depending on your apps bundler configuration and plugins, you will need to provide polyfills for various imports including `crypto`, `process`, `fs` and `buffer`. Refer to your bundler's documentation for how to provide the necessary polyfills.
ESM:

```javascript
Expand Down Expand Up @@ -183,35 +212,35 @@ const turbo = TurboFactory.unauthenticated();

Creates an instance of a client that accesses Turbo's authenticated and unauthenticated services. Requires either a signer, or private key to be provided.

##### Construct Turbo with an Arweave JWK
##### Arweave JWK

```typescript
const jwk = await arweave.crypto.generateJWK();
const turbo = TurboFactory.authenticated({ privateKey: jwk });
```

##### Construct Turbo with an Arweave signer
##### ArweaveSigner

```typescript
const signer = new ArweaveSigner(jwk);
const turbo = TurboFactory.authenticated({ signer });
```

##### Construct Turbo with an Arconnect signer
##### ArconnectSigner

```typescript
const signer = new ArconnectSigner(window.arweaveWallet);
const turbo = TurboFactory.authenticated({ signer });
```

##### Construct Turbo with an ETH signer
##### EthereumSigner

```typescript
const signer = new EthereumSigner(privateKey);
const turbo = TurboFactory.authenticated({ signer });
```

##### Construct Turbo with an ETH private key
##### Ethereum Private Key

```typescript
const turbo = TurboFactory.authenticated({
Expand All @@ -220,14 +249,14 @@ const turbo = TurboFactory.authenticated({
});
```

##### Construct Turbo with a SOL signer
##### HexSolanaSigner

```typescript
const signer = new HexSolanaSigner(bs58.encode(secretKey));
const turbo = TurboFactory.authenticated({ signer });
```

##### Construct Turbo with a SOL secret key
##### Solana Secret Key

```typescript
const turbo = TurboFactory.authenticated({
Expand Down Expand Up @@ -309,6 +338,8 @@ const uploadResponse = await turbo.uploadSignedDataItem({

Creates a Stripe checkout session for a Turbo Top Up with the provided amount, currency, owner. The returned URL can be opened in the browser, all payments are processed by Stripe. To leverage promo codes, see [TurboAuthenticatedClient].

##### Arweave (AR)

```typescript
const { url, winc, paymentAmount, quotedPaymentAmount, adjustments } =
await turbo.createCheckoutSession({
Expand All @@ -330,7 +361,7 @@ if (process.platform === 'darwin') {
}
```

##### Top up to ETH or SOL wallets
##### Ethereum (ETH)

```ts
const turbo = TurboFactory.unauthenticated({ token: 'ethereum' });
Expand All @@ -341,6 +372,8 @@ const { url, winc, paymentAmount } = await turbo.createCheckoutSession({
});
```

##### Solana (SOL)

```ts
const turbo = TurboFactory.unauthenticated({ token: 'solana' });

Expand All @@ -354,7 +387,8 @@ const { url, winc, paymentAmount } = await turbo.createCheckoutSession({

Submits the transaction ID of a funding transaction to Turbo Payment Service for top up processing. The `txId` is the transaction ID of the transaction to be submitted.

- Note: Use this API if you've already executed your token transfer to the Turbo wallet. Otherwise, consider using `topUpWithTokens` to execute a new token transfer to the Turbo wallet and submit its resulting transaction ID for top up processing all in one go
> [!NOTE]
> Use this API if you've already executed your token transfer to the Turbo wallet. Otherwise, consider using `topUpWithTokens` to execute a new token transfer to the Turbo wallet and submit its resulting transaction ID for top up processing all in one go
```typescript
const turbo = TurboFactory.unauthenticated(); // defaults to arweave token type
Expand Down Expand Up @@ -453,7 +487,7 @@ const { winc, status, id, ...fundResult } = await turbo.topUpWithTokens({
});
```

##### Top up ETH tokens to ETH wallet
##### Ethereum (ETH)

```ts
const turbo = TurboFactory.authenticated({ signer, token: 'ethereum' });
Expand All @@ -463,7 +497,7 @@ const { winc, status, id, ...fundResult } = await turbo.topUpWithTokens({
});
```

##### Top up SOL tokens to SOL wallet
##### Solana (SOL)

```ts
const turbo = TurboFactory.authenticated({ signer, token: 'solana' });
Expand Down
8 changes: 5 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@
"types": "./lib/types/node/index.d.ts"
},
"./web": {
"import": "./bundles/web.bundle.min.js",
"require": "./bundles/web.bundle.min.js",
"import": "./lib/esm/web/index.js",
"require": "./lib/cjs/web/index.js",
"types": "./lib/types/web/index.d.ts",
"browser": "./bundles/web.bundle.min.js"
}
Expand Down Expand Up @@ -67,7 +67,8 @@
"example:ts:esm": "cd examples/typescript/esm && yarn && yarn test",
"example:ts:cjs": "cd examples/typescript/cjs && yarn && yarn test",
"docker:up": "docker compose up --quiet-pull --pull always -d",
"docker:down": "docker compose down -v"
"docker:down": "docker compose down -v",
"docs": "markdown-toc-gen insert README.md"
},
"dependencies": {
"@irys/arweave": "0.0.3",
Expand Down Expand Up @@ -111,6 +112,7 @@
"eslint-plugin-promise": "^6.1.1",
"http-server": "^14.1.1",
"husky": "^8.0.3",
"markdown-toc-gen": "^1.0.1",
"mocha": "^10.2.0",
"prettier": "^3.0.2",
"rimraf": "^5.0.1",
Expand Down
92 changes: 88 additions & 4 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1868,6 +1868,11 @@ ansi-styles@^4.0.0, ansi-styles@^4.1.0, ansi-styles@^4.3.0:
dependencies:
color-convert "^2.0.1"

ansi-styles@^5.0.0:
version "5.2.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-5.2.0.tgz#07449690ad45777d1924ac2abb2fc8895dba836b"
integrity sha512-Cxwpt2SfTzTtXcfOlzGEee8O+c+MmUgGrNiBcXnuWxuFJHe6a5Hz7qwhwe5OgaSYI0IJvkLqWX1ASG+cJOkEiA==

ansi-styles@^6.1.0:
version "6.2.1"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-6.2.1.tgz#0e62320cf99c21afff3b3012192546aacbfb05c5"
Expand Down Expand Up @@ -2875,6 +2880,11 @@ deprecation@^2.0.0:
resolved "https://registry.yarnpkg.com/deprecation/-/deprecation-2.3.1.tgz#6368cbdb40abf3373b525ac87e4a260c3a700919"
integrity sha512-xmHIy4F3scKVwMsQ4WnVaS8bHOx0DmVwRywosKhaILI0ywMDWPtBSku2HNxRvF7jtwDRsoEwYQSfbxj8b7RlJQ==

diff-sequences@^27.5.1:
version "27.5.1"
resolved "https://registry.yarnpkg.com/diff-sequences/-/diff-sequences-27.5.1.tgz#eaecc0d327fd68c8d9672a1e64ab8dccb2ef5327"
integrity sha512-k1gCAXAsNgLwEL+Y8Wvl+M6oEFj5bgazfZULpS5CneoPPXRaCCW7dm+q21Ky2VEE5X+VeRDBVg1Pcvvsr4TtNQ==

diff@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
Expand Down Expand Up @@ -4267,6 +4277,11 @@ into-stream@^7.0.0:
from2 "^2.3.0"
p-is-promise "^3.0.0"

inversify@^5.0.5:
version "5.1.1"
resolved "https://registry.yarnpkg.com/inversify/-/inversify-5.1.1.tgz#6fbd668c591337404e005a1946bfe0d802c08730"
integrity sha512-j8grHGDzv1v+8T1sAQ+3boTCntFPfvxLCkNcxB1J8qA0lUN+fAlSyYd+RXKvaPRL4AGyPxViutBEJHNXOyUdFQ==

ip-regex@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ip-regex/-/ip-regex-4.3.0.tgz#687275ab0f57fa76978ff8f4dddc8a23d5990db5"
Expand Down Expand Up @@ -4624,6 +4639,21 @@ jayson@^4.1.0:
uuid "^8.3.2"
ws "^7.4.5"

jest-diff@^27.0.2:
version "27.5.1"
resolved "https://registry.yarnpkg.com/jest-diff/-/jest-diff-27.5.1.tgz#a07f5011ac9e6643cf8a95a462b7b1ecf6680def"
integrity sha512-m0NvkX55LDt9T4mctTEgnZk3fmEg3NRYutvMPWM/0iPnkFj2wIeF45O1718cMSOFO1vINkqmxqD8vE37uTEbqw==
dependencies:
chalk "^4.0.0"
diff-sequences "^27.5.1"
jest-get-type "^27.5.1"
pretty-format "^27.5.1"

jest-get-type@^27.5.1:
version "27.5.1"
resolved "https://registry.yarnpkg.com/jest-get-type/-/jest-get-type-27.5.1.tgz#3cd613c507b0f7ace013df407a1c1cd578bcb4f1"
integrity sha512-2KY95ksYSaK7DMBWQn6dQz3kqAf3BB64y2udeG+hv4KfSOb9qwcYQstTJc1KCbsix+wLZWZYN8t7nwX3GOBLRw==

js-sha256@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966"
Expand Down Expand Up @@ -5124,6 +5154,16 @@ map-obj@^4.0.0:
resolved "https://registry.yarnpkg.com/map-obj/-/map-obj-4.3.0.tgz#9304f906e93faae70880da102a9f1df0ea8bb05a"
integrity sha512-hdN1wVrZbb29eBGiGjJbeP8JbKjq1urkHJ/LIP/NY48MZ1QVXUsQBV1G1zvYFHn1XE06cwjBsOI2K3Ulnj1YXQ==

markdown-toc-gen@^1.0.1:
version "1.0.1"
resolved "https://registry.yarnpkg.com/markdown-toc-gen/-/markdown-toc-gen-1.0.1.tgz#838c875d987445e84c86ded1cf04f6ee83a9df1a"
integrity sha512-vBa1eD9TOmru18LBiWq/s2unihvfbR4Tj5ZImwgB30/hHI1kQxYXri0vttNI8rDGm0Bl/LBkMAEX4PizO46JHg==
dependencies:
inversify "^5.0.5"
jest-diff "^27.0.2"
reflect-metadata "^0.1.13"
yargs "^16.2.0"

marked-terminal@^5.1.1:
version "5.2.0"
resolved "https://registry.yarnpkg.com/marked-terminal/-/marked-terminal-5.2.0.tgz#c5370ec2bae24fb2b34e147b731c94fa933559d3"
Expand Down Expand Up @@ -6134,6 +6174,15 @@ prettier@^3.0.2:
resolved "https://registry.yarnpkg.com/prettier/-/prettier-3.0.2.tgz#78fcecd6d870551aa5547437cdae39d4701dca5b"
integrity sha512-o2YR9qtniXvwEZlOKbveKfDQVyqxbEIWn48Z8m3ZJjBjcCmUy3xZGIv+7AkaeuaTr6yPXJjwv07ZWlsWbEy1rQ==

pretty-format@^27.5.1:
version "27.5.1"
resolved "https://registry.yarnpkg.com/pretty-format/-/pretty-format-27.5.1.tgz#2181879fdea51a7a5851fb39d920faa63f01d88e"
integrity sha512-Qb1gy5OrP5+zDf2Bvnzdl3jsTf1qXVMazbvCoKhtKqVs4/YK4ozX4gKQJJVyNe+cajNPn0KoC0MC3FUmaHWEmQ==
dependencies:
ansi-regex "^5.0.1"
ansi-styles "^5.0.0"
react-is "^17.0.1"

proc-log@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/proc-log/-/proc-log-3.0.0.tgz#fb05ef83ccd64fd7b20bbe9c8c1070fc08338dd8"
Expand Down Expand Up @@ -6238,6 +6287,11 @@ rc@^1.2.8:
minimist "^1.2.0"
strip-json-comments "~2.0.1"

react-is@^17.0.1:
version "17.0.2"
resolved "https://registry.yarnpkg.com/react-is/-/react-is-17.0.2.tgz#e691d4a8e9c789365655539ab372762b0efb54f0"
integrity sha512-w2GsyukL62IJnlaff/nRegPQR94C/XXamvMWmSHRJ4y7Ts/4ocGRmTHvOs8PSE6pB3dWOrD/nueuU5sduBsQ4w==

read-cmd-shim@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/read-cmd-shim/-/read-cmd-shim-4.0.0.tgz#640a08b473a49043e394ae0c7a34dd822c73b9bb"
Expand Down Expand Up @@ -6361,6 +6415,11 @@ redeyed@~2.1.0:
dependencies:
esprima "~4.0.0"

reflect-metadata@^0.1.13:
version "0.1.14"
resolved "https://registry.yarnpkg.com/reflect-metadata/-/reflect-metadata-0.1.14.tgz#24cf721fe60677146bb77eeb0e1f9dece3d65859"
integrity sha512-ZhYeb6nRaXCfhnndflDK8qI6ZQ/YcWZCISRAWICW9XYqMUwjZM9Z0DveWX/ABN01oxSHwVxKQmxeYZSsm0jh5A==

regenerator-runtime@^0.14.0:
version "0.14.0"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.14.0.tgz#5e19d68eb12d486f797e15a3c6a918f7cec5eb45"
Expand Down Expand Up @@ -6829,7 +6888,16 @@ stream-combiner2@~1.1.1:
duplexer2 "~0.1.0"
readable-stream "^2.0.2"

"string-width-cjs@npm:string-width@^4.2.0", "string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
"string-width-cjs@npm:string-width@^4.2.0":
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"

"string-width@^1.0.2 || 2 || 3 || 4", string-width@^4.1.0, string-width@^4.2.0, string-width@^4.2.3:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
Expand Down Expand Up @@ -6888,7 +6956,14 @@ string_decoder@~1.1.1:
dependencies:
safe-buffer "~5.1.0"

"strip-ansi-cjs@npm:strip-ansi@^6.0.1", strip-ansi@^6.0.0, strip-ansi@^6.0.1:
"strip-ansi-cjs@npm:strip-ansi@^6.0.1":
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"

strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
Expand Down Expand Up @@ -7547,7 +7622,16 @@ workerpool@6.2.1:
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==

"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0", wrap-ansi@^7.0.0:
"wrap-ansi-cjs@npm:wrap-ansi@^7.0.0":
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"

wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
Expand Down Expand Up @@ -7638,7 +7722,7 @@ yargs-unparser@2.0.0:
flat "^5.0.2"
is-plain-obj "^2.1.0"

yargs@16.2.0:
yargs@16.2.0, yargs@^16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
Expand Down

0 comments on commit 0282d71

Please sign in to comment.