Skip to content

Commit

Permalink
Merge pull request #204 from ardriveapp/main
Browse files Browse the repository at this point in the history
chore: main back to alpha
  • Loading branch information
fedellen authored Nov 4, 2024
2 parents 2b764c4 + f94fe10 commit df8d87c
Show file tree
Hide file tree
Showing 9 changed files with 112 additions and 63 deletions.
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,25 @@
# [1.20.0](https://github.com/ardriveapp/turbo-sdk/compare/v1.19.2...v1.20.0) (2024-11-04)


### Bug Fixes

* **arweave:** modify import of Arweave in `ArweaveToken` ([b934677](https://github.com/ardriveapp/turbo-sdk/commit/b934677e00b95283d30bca0bf719d919312aabe2))
* supply starknet dependency for resolving kyve-js -> keplr-wallet import error ([cf5ab39](https://github.com/ardriveapp/turbo-sdk/commit/cf5ab39a3a08afebbb9d4f7b535ddd40fd57798c))


### Features

* add cli helper for --local development endpoints PE-6754 ([79fe7a0](https://github.com/ardriveapp/turbo-sdk/commit/79fe7a0b81daeec18a9ca4aa68fe300d71bee009))
* **delegated payments:** add list-approvals command rather than overloaded balance command PE-6754 ([ee44ef6](https://github.com/ardriveapp/turbo-sdk/commit/ee44ef6c1176734a72e5e4b310dcd9468028c779))
* **delegated payments:** add paid-by headers for uploads when applicable PE-6754 ([953648e](https://github.com/ardriveapp/turbo-sdk/commit/953648e67719cc3c663ac75a702fd653e33b7c8f))
* **delegated payments:** add revoke approvals to SDK and CLI PE-6754 ([f2d26da](https://github.com/ardriveapp/turbo-sdk/commit/f2d26daa5ee12008dc8173a0ee44bfc2828028ba))
* **delegated payments:** display approvals if they exist on `balance` command PE-6754 ([669dfca](https://github.com/ardriveapp/turbo-sdk/commit/669dfca76332756e93accf1b0a01cfa8538f9e84))
* **delegated payments:** extend turbo.getBalance method to include approval details PE-6754 ([baec107](https://github.com/ardriveapp/turbo-sdk/commit/baec1072b7750cc08bb1588dc5ff2a870f47b3e5))
* **delegated payments:** init logic for create-approval PE-6754 ([1047762](https://github.com/ardriveapp/turbo-sdk/commit/10477621bad131ec85203814ce3846040cba15ea))
* **delegated payments:** push created/revoked approvals into upload response if they exist PE-6754 ([33da73d](https://github.com/ardriveapp/turbo-sdk/commit/33da73d29b6db6f706f1debd1e83aa5acb5f9ee5))
* **delegated payments:** use any approvals first by default on CLI PE-6754 ([96d4a32](https://github.com/ardriveapp/turbo-sdk/commit/96d4a32fe3d2e84a6dd3742a2d1c981acc786596))
* update credit sharing command and method names ([c3e9bd9](https://github.com/ardriveapp/turbo-sdk/commit/c3e9bd95dc1585e80cdce1b237cab02889976d41))

## [1.19.2](https://github.com/ardriveapp/turbo-sdk/compare/v1.19.1...v1.19.2) (2024-10-21)


Expand Down
9 changes: 9 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ Welcome to the `@ardrive/turbo-sdk`! This SDK provides functionality for interac
- [ESM](#esm)
- [Typescript](#typescript)
- [Examples](#examples)
- [Logging](#logging)
- [APIs](#apis)
- [TurboFactory](#turbofactory)
- [`unauthenticated()`](#unauthenticated)
Expand Down Expand Up @@ -227,6 +228,14 @@ Examples are available in the [examples] directory. To run examples:
- `yarn example:cjs` - runs example CJS node script
- `yarn example:esm` - runs example ESM node script

## Logging

The SDK uses winston for logging. You can set the log level using the `setLogLevel` method.

```typescript
TurboFactory.setLogLevel('debug');
```

## APIs

### TurboFactory
Expand Down
2 changes: 1 addition & 1 deletion examples/vite/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ yarn start

## Polyfills

The `@ar.io/sdk` uses some modern browser features that may not be available in all browsers. To ensure compatibility, you may need to include some polyfills. This example uses the [vite-plugin-node-polyfills] plugin to include the necessary polyfills.
The `@ardrive/turbo-sdk` uses some modern browser features that may not be available in all browsers. To ensure compatibility, you may need to include some polyfills. This example uses the [vite-plugin-node-polyfills] plugin to include the necessary polyfills.

The [tsconfig.json](./tsconfig.json) includes the following compiler options:

Expand Down
2 changes: 1 addition & 1 deletion examples/vite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.1.0",
"private": true,
"dependencies": {
"@ardrive/turbo-sdk": "^1.19.2",
"@ardrive/turbo-sdk": "^1.20.0",
"arweave": "^1.15.5",
"react": "^18.3.1",
"react-dom": "^18.3.1"
Expand Down
Binary file added examples/vite/public/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
97 changes: 71 additions & 26 deletions examples/vite/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -10,24 +10,15 @@ import { ReadableStream } from 'web-streams-polyfill';

import './App.css';

// enable debug logs
TurboFactory.setLogLevel('debug');

const arweave = new Arweave({
host: 'arweave.net',
port: 443,
protocol: 'https',
});

const fileToReadableStream = (file: File): ReadableStream => {
const fileReader = new FileReader();
const stream = new ReadableStream({
start(controller) {
fileReader.addEventListener('load', () =>
controller.enqueue(fileReader.result as ArrayBuffer),
);
},
});
return stream;
};

function App() {
const [wallet, setWallet] = useState<JWKInterface | null>(null);
const [selectedFile, setSelectedFile] = useState<File | null>(null);
Expand All @@ -53,6 +44,8 @@ function App() {
return;
}

console.log('Uploading selected file...');

if (!wallet) {
setUploadStatus('Please generate a wallet first');
return;
Expand All @@ -65,12 +58,17 @@ function App() {

try {
setUploadStatus('Uploading...');
console.log(selectedFile);
const buffer = await selectedFile.arrayBuffer();
const upload = await turbo.uploadFile({
fileStreamFactory: () => fileToReadableStream(selectedFile),
fileStreamFactory: () =>
new ReadableStream({
start(controller) {
controller.enqueue(buffer);
controller.close();
},
}),
fileSizeFactory: () => selectedFile.size,
});
console.log(upload);
setUploadStatus(`Upload successful! ${JSON.stringify(upload, null, 2)}`);
} catch (error) {
setUploadStatus(
Expand All @@ -90,7 +88,11 @@ function App() {
setAddress(address);
setShowJwkInput(false);
} catch (error) {
console.error('Error generating JWK:', error);
setUploadStatus(
`Error generating JWK: ${
error instanceof Error ? error.message : 'Unknown error'
}`,
);
}
};

Expand All @@ -103,7 +105,6 @@ function App() {
setWallet(JSON.parse(jwk));
setTurbo(
TurboFactory.authenticated({
...developmentTurboConfiguration,
privateKey: JSON.parse(jwk),
}),
);
Expand All @@ -112,47 +113,91 @@ function App() {

return (
<div
className="App flex flex-col items-center"
className="App flex flex-col items-center justify-center"
style={{ padding: '50px', height: '100vh' }}
>
<div
className="flex flex-col items-center"
className="flex flex-col items-center justify-center"
style={{
marginBottom: '20px',
height: '100%',
}}
>
<h2>File Upload with Turbo SDK</h2>

<h3>Provide a JWK</h3>

{showJwkInput ? (
<div style={{ marginBottom: '20px' }}>
<div
style={{
marginBottom: '20px',
display: 'flex',
justifyContent: 'center',
}}
>
<textarea
placeholder="Paste your JWK here..."
value={jwk}
onChange={handleJwkChange}
style={{ width: '300px', height: '100px', marginRight: '10px' }}
/>
<button onClick={generateRandomJwk}>Generate Random JWK</button>
or
<button
onClick={generateRandomJwk}
style={{ marginLeft: '10px', height: '20px' }}
>
Generate Random JWK
</button>
</div>
) : (
<div style={{ marginBottom: '10px' }}>
<div
style={{
marginBottom: '10px',
display: 'flex',
flexDirection: 'column',
alignItems: 'center',
}}
>
<p>Using generated JWK - {address}</p>
<button onClick={() => setShowJwkInput(true)}>
Use Different JWK
</button>
</div>
)}

<form onSubmit={handleUpload}>
<h3>Select a file to upload</h3>

<form
onSubmit={handleUpload}
style={{
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
flexDirection: 'column',
width: '300px',
margin: 'auto',
gap: '20px',
}}
>
<input
type="file"
onChange={handleFileSelect}
style={{ marginRight: '10px' }}
style={{ display: 'block', marginTop: '10px' }}
/>
<button type="submit">Upload File</button>
</form>

{uploadStatus && <p style={{ marginTop: '10px' }}>{uploadStatus}</p>}
{uploadStatus && (
<p
style={{
width: '500px',
wordWrap: 'break-word',
textAlign: 'center',
margin: 'auto',
}}
>
{uploadStatus}
</p>
)}
</div>
</div>
);
Expand Down
39 changes: 6 additions & 33 deletions examples/vite/yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@
"@jridgewell/gen-mapping" "^0.3.5"
"@jridgewell/trace-mapping" "^0.3.24"

"@ardrive/turbo-sdk@^1.19.2":
version "1.19.2"
resolved "https://registry.yarnpkg.com/@ardrive/turbo-sdk/-/turbo-sdk-1.19.2.tgz#6e1cb8f956fd1c5100d344378b556557ff94e582"
integrity sha512-6ZncZhBPbP72oFqRMhXpREQ9djvQyqUVfEndcbGNdeRTm0vexZv/T8sTXQqxzQPRtjRnA05SvEAjYchZHkqm/g==
"@ardrive/turbo-sdk@^1.20.0":
version "1.20.0"
resolved "https://registry.yarnpkg.com/@ardrive/turbo-sdk/-/turbo-sdk-1.20.0.tgz#059a414a45335b9714819f21b9a3d55af6cb3fea"
integrity sha512-Mc7T+1PCBxVOPOMBLzCGj7vNicvcEo043oJyfSOQHk9Tt/cBd9uJ3kcaYwAsisgIv1psbFozCqi6KjsAlcpmEw==
dependencies:
"@cosmjs/amino" "^0.32.4"
"@cosmjs/crypto" "^0.32.4"
Expand All @@ -43,6 +43,7 @@
mime-types "^2.1.35"
plimit-lit "^3.0.1"
prompts "^2.4.2"
starknet "^6.11.0"
tweetnacl "^1.0.3"
winston "^3.14.1"

Expand Down Expand Up @@ -2757,14 +2758,6 @@ filelist@^1.0.4:
dependencies:
minimatch "^5.0.1"

filereader-stream@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/filereader-stream/-/filereader-stream-2.0.0.tgz#b30d5a5bf6d14c638d7eb55e193abb986f8048a1"
integrity sha512-U1OzPNA5quv2/ejRikN/G8llfdtHpblOuKNgxooVjbr/i9uEJ/QIQ7eslx/RqHRJVuTqwr6v5/XG87935t/daA==
dependencies:
from2 "^2.1.0"
typedarray-to-buffer "^3.0.4"

fill-range@^7.1.1:
version "7.1.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.1.1.tgz#44265d3cac07e3ea7dc247516380643754a05292"
Expand Down Expand Up @@ -2811,14 +2804,6 @@ form-data@^4.0.0:
combined-stream "^1.0.8"
mime-types "^2.1.12"

from2@^2.1.0:
version "2.3.0"
resolved "https://registry.yarnpkg.com/from2/-/from2-2.3.0.tgz#8bfb5502bde4a4d36cfdeea007fcca21d7e382af"
integrity sha512-OMcX/4IC/uqEPVgGeyfN22LJk6AZrMkRZHxcHBMBvHScDGgwTm2GT2Wkgtocyd3JfZffjj2kYUDXXII0Fk9W0g==
dependencies:
inherits "^2.0.1"
readable-stream "^2.0.0"

fs-extra@^10.0.0, fs-extra@^10.0.1:
version "10.1.0"
resolved "https://registry.yarnpkg.com/fs-extra/-/fs-extra-10.1.0.tgz#02873cfbc4084dde127eaa5f9905eef2325d1abf"
Expand Down Expand Up @@ -3202,11 +3187,6 @@ is-typed-array@^1.1.3:
dependencies:
which-typed-array "^1.1.14"

is-typedarray@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/is-typedarray/-/is-typedarray-1.0.0.tgz#e479c80858df0c1b11ddda6940f96011fcda4a9a"
integrity sha512-cyA56iCMHAh5CdzjJIa4aohJyeO1YbwLi3Jc35MmRU6poroFjIGZzUzupGiRPOjgHg9TLu43xbpwXk523fMxKA==

is-weakmap@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/is-weakmap/-/is-weakmap-2.0.2.tgz#bf72615d649dfe5f699079c54b83e47d1ae19cfd"
Expand Down Expand Up @@ -4023,7 +4003,7 @@ react@^18.3.1:
dependencies:
loose-envify "^1.1.0"

readable-stream@^2.0.0, readable-stream@^2.3.8:
readable-stream@^2.3.8:
version "2.3.8"
resolved "https://registry.yarnpkg.com/readable-stream/-/readable-stream-2.3.8.tgz#91125e8042bba1b9887f49345f6277027ce8be9b"
integrity sha512-8p0AUk4XODgIewSi0l8Epjs+EVnWiK7NoDIEGU0HhE7+ZyY8D1IMY7odu5lRrFXGg71L15KG8QrPmum45RTtdA==
Expand Down Expand Up @@ -4546,13 +4526,6 @@ tweetnacl@^1.0.3:
resolved "https://registry.yarnpkg.com/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596"
integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==

typedarray-to-buffer@^3.0.4:
version "3.1.5"
resolved "https://registry.yarnpkg.com/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz#a97ee7a9ff42691b9f783ff1bc5112fe3fca9080"
integrity sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==
dependencies:
is-typedarray "^1.0.0"

typeforce@^1.11.5:
version "1.18.0"
resolved "https://registry.yarnpkg.com/typeforce/-/typeforce-1.18.0.tgz#d7416a2c5845e085034d70fcc5b6cc4a90edbfdc"
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@ardrive/turbo-sdk",
"version": "1.20.0-alpha.4",
"version": "1.20.0",
"main": "./lib/cjs/node/index.js",
"types": "./lib/types/node/index.d.ts",
"module": "./lib/esm/node/index.js",
Expand Down
2 changes: 1 addition & 1 deletion src/version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@
*/

// AUTOMATICALLY GENERATED FILE - DO NOT TOUCH
export const version = '1.20.0-alpha.4';
export const version = '1.20.0';

0 comments on commit df8d87c

Please sign in to comment.