Skip to content

Commit 33372a0

Browse files
committed
add --update-animation-url flag to update-metadata command
1 parent c500d97 commit 33372a0

File tree

9 files changed

+68
-19
lines changed

9 files changed

+68
-19
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,11 @@ All notable changes starting with v0.1.34 to this project will be documented in
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
# v0.1.54 (2022-01-18)
9+
- **added:** added `--update-animation-url` flag to `update-metadata`.
10+
- **added:** added [instructions](docs/multiple_asset_files.md) for uploading with multiple asset files.
11+
- **changed:** validate `<FILE_PATHS>` for `update-metadata` command as json and fix docs to specify json instead of assets.
12+
813
# v0.1.53 (2022-01-12)
914
- **fixed:** Include files as objects with `uri` and `type` keys in the `files` key of the `properties` key when updating metadata files.
1015
- **changed:** File objects are now appended to the `files` key with the `update-metadata` command and in order to update the `image` key, you have to pass the `--update-image` flag. This was done to make it possible to have multiple asset files and associated links for each NFT, in which case you can run `update-metadata` multiple times without the `--update-image` flag to append multiple links to the `files` key.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
name = "arloader"
33
authors = ["calebeverett <[email protected]>"]
44
description = "Command line application and library for uploading files to Arweave."
5-
version = "0.1.53"
5+
version = "0.1.54"
66
edition = "2021"
77
license = "Apache-2.0"
88
repository = "https://github.com/CalebEverett/arloader"

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ Upload gigabytes of files with one command. Files are read and posted to [arweav
2020
* [Pricing Comparison](#pricing-comparison)
2121
* [Roadmap](#roadmap)
2222
* [Transactions Prior to v0.1.51](#potential-issue-with-transactions-uploaded-prior-to-version-0.1.51)
23+
* [Showing Love](#showing-love)
2324

2425
## Installation
2526

@@ -436,3 +437,6 @@ file size | num files | arweave | bundlr | arweave total | bundlr total | arweav
436437

437438
## Potential Issue with Transactions Uploaded Prior to Version 0.1.51
438439
The way arloader was formatting transactions for upload was not entirely compatible with the Arweave protocol prior to version 1.51. For transactions bigger than 256 KB it is possible that even though your transactions are visible and are showing more than 25 confirmations that they were not written to the Arweave blockchain. If you would like assistance determining whether your transactions were impacted, please open an issue and I will be happy to help, including paying for any necessary re-uploading.
440+
441+
## Showing Love
442+
If arloader was useful and the spirit moves you, I'd love to have one of your NFTs in my collection: `F4B7659xdVcTqQEHShLsxp7w8wckMyBmT9GM8bGDqTUW`.

docs/multiple_asset_files.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22

33
There isn't a single command you can run if you have multiple media files per NFT, i.e., an mp4 and a png file. But you can run separate commands for each to get all of your files uploaded with your metadata files updated to include links to all of your media files.
44

5-
Here is an example from a an upload of a series of glb and png files
5+
Here is an example from a an upload of a series of glb and png files.
66

77
1. `arloader upload *.glb --sol-keypair-path ~/.config/solana/wallet.json --with-sol --ar-default-keypair --bundle-size 100 --reward-multiplier 2`
88
2. `arloader upload-manifest arloader_EsBWe5NTZ8E --sol-keypair-path ~/.config/solana/wallet.json --with-sol --ar-default-keypair --reward-multiplier 2`
9-
3. `arloader update-metadata *.glb --manifest-path arloader_EsBWe5NTZ8E/manifest_2LpuzxUYEmKl5huvPChgoZ3YcAKNnpUoh-Jyq1EoB-9.json`
9+
3. `arloader update-metadata *.glb --manifest-path arloader_EsBWe5NTZ8E/manifest_2LpuzxUYEmKl5huvPChgoZ3YcAKNnpUoh-Jyq1EoB-9.json --update-animation-url`
1010
4. `arloader upload *.png --sol-keypair-path ~/.config/solana/wallet.json --with-sol --ar-default-keypair --reward-multiplier 2`
1111
5. `arloader upload-manifest arloader_l00ydMAOy7E --sol-keypair-path ~/.config/solana/wallet.json --with-sol --ar-default-keypair --reward-multiplier 2`
1212
6. `arloader update-metadata *.png --manifest-path arloader_l00ydMAOy7E/manifest_rJiNPRYtu-tsMYP5wyDU4L-4Qu8HFaL2QMHn7Oq1BGn.json --update-image`

docs/upload_nfts_steps.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ If your metadata files have the same stem as your asset files and an extension o
9898
arloader update-metadata --manifest-path <MANIFEST_PATH>
9999
```
100100

101-
This will append the links from the manifest file to the `files` key in the metadata file. If you want to update the `image` key as well, pass the `--update-image` flag. Arloader defaults to using the id link (`https://arweave.net/<BUNDLE_ITEM_ID>`) for the `image` key, but you can pass the `--link-file` flag to use the file path based link. If you pass `--link-file`, the `files` key will get both the id based and file path based links appended.
101+
This will append the links from the manifest file to the `files` key in the metadata file.Arloader defaults to using the id link (`https://arweave.net/<BUNDLE_ITEM_ID>`) for the `image` key, but you can pass the `--link-file` flag to use the file path based link. If you pass `--link-file`, the `files` key will get both the id based and file path based links appended.
102+
103+
If you want to update the `image` key as well, pass the `--update-image` flag. If you want to update the `animation_url` key as well, pass the `--update-animation-url` flag.
102104

103105
### Upload Metadata
104106

examples/check_peers.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use reqwest;
33

44
#[tokio::main]
55
async fn main() {
6-
let txid = "4Mh_VQSTvL_jD-PrP7aUzrOkJ2zmXbYJhvfxnn-ojk0";
6+
let txid = "8kEv0wGeAuk5-lateTOwFiWGffZomRS3sYZgwiDiY74";
77

88
let peers = reqwest::get("https://arweave.net/peers")
99
.await

src/commands.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,7 @@ pub async fn command_update_metadata<IP>(
285285
manifest_path: PathBuf,
286286
link_file: bool,
287287
update_image: bool,
288+
update_animation_url: bool,
288289
) -> CommandResult
289290
where
290291
IP: Iterator<Item = PathBuf> + Send + Sync,
@@ -298,6 +299,7 @@ where
298299
manifest_path,
299300
link_file,
300301
update_image,
302+
update_animation_url,
301303
)
302304
.await?;
303305

@@ -807,6 +809,7 @@ where
807809
asset_manifest_path,
808810
link_file,
809811
true,
812+
false,
810813
)
811814
.await?;
812815

src/lib.rs

Lines changed: 36 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1572,6 +1572,7 @@ impl Arweave {
15721572
file_path: PathBuf,
15731573
mut files_array: Vec<Value>,
15741574
image_link: Option<String>,
1575+
animation_url_link: Option<String>,
15751576
) -> Result<(), Error> {
15761577
let data = fs::read_to_string(file_path.clone()).await?;
15771578
let mut metadata: Value = serde_json::from_str(&data)?;
@@ -1581,6 +1582,13 @@ impl Arweave {
15811582
metadata.insert("image".to_string(), Value::String(image_link));
15821583
}
15831584

1585+
if let Some(animation_url_link) = animation_url_link {
1586+
metadata.insert(
1587+
"animation_url".to_string(),
1588+
Value::String(animation_url_link),
1589+
);
1590+
}
1591+
15841592
let properties = if let Some(properties) = metadata.get_mut("properties") {
15851593
properties.as_object_mut().unwrap()
15861594
} else {
@@ -1604,6 +1612,7 @@ impl Arweave {
16041612
manifest_path: PathBuf,
16051613
image_link_file: bool,
16061614
update_image_link: bool,
1615+
update_animation_url_link: bool,
16071616
) -> Result<(), Error>
16081617
where
16091618
IP: Iterator<Item = PathBuf> + Send,
@@ -1621,23 +1630,32 @@ impl Arweave {
16211630

16221631
try_join_all(paths_iter.map(|p| {
16231632
let path_object = manifest.get(&p.display().to_string()).unwrap();
1633+
1634+
let link = if image_link_file {
1635+
format!(
1636+
"https://arweave.net/{}/{}",
1637+
manifest_id,
1638+
&p.display().to_string()
1639+
)
1640+
} else {
1641+
format!(
1642+
"https://arweave.net/{}",
1643+
path_object["id"].as_str().unwrap()
1644+
)
1645+
};
1646+
16241647
let image_link = if update_image_link {
1625-
let link = if image_link_file {
1626-
format!(
1627-
"https://arweave.net/{}/{}",
1628-
manifest_id,
1629-
&p.display().to_string()
1630-
)
1631-
} else {
1632-
format!(
1633-
"https://arweave.net/{}",
1634-
path_object["id"].as_str().unwrap()
1635-
)
1636-
};
1648+
Some(link.clone())
1649+
} else {
1650+
None
1651+
};
1652+
1653+
let animation_url_link = if update_animation_url_link {
16371654
Some(link)
16381655
} else {
16391656
None
16401657
};
1658+
16411659
let files_array = if image_link_file {
16421660
path_object["files"].as_array().unwrap().clone()
16431661
} else {
@@ -1648,7 +1666,12 @@ impl Arweave {
16481666
.unwrap()
16491667
.clone()]
16501668
};
1651-
self.update_metadata_file(p.with_extension("json"), files_array, image_link)
1669+
self.update_metadata_file(
1670+
p.with_extension("json"),
1671+
files_array,
1672+
image_link,
1673+
animation_url_link,
1674+
)
16521675
}))
16531676
.await?;
16541677
Ok(())

src/main.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,12 +202,14 @@ async fn main() -> CommandResult {
202202
.unwrap();
203203
let link_file = sub_arg_matches.is_present("link_file");
204204
let update_image = sub_arg_matches.is_present("update_image");
205+
let update_animation_url = sub_arg_matches.is_present("update_animation_url");
205206
command_update_metadata(
206207
&Arweave::default(),
207208
paths_iter,
208209
manifest_path,
209210
link_file,
210211
update_image,
212+
update_animation_url,
211213
)
212214
.await
213215
}
@@ -555,7 +557,8 @@ fn get_app() -> App<'static, 'static> {
555557
.arg(file_paths_arg())
556558
.arg(manifest_path_arg())
557559
.arg(link_file_arg())
558-
.arg(update_image_arg()),
560+
.arg(update_image_arg())
561+
.arg(update_animation_url_arg())
559562
)
560563
.subcommand(
561564
SubCommand::with_name("update-status")
@@ -810,6 +813,15 @@ fn tags_arg<'a, 'b>() -> Arg<'a, 'b> {
810813
)
811814
}
812815

816+
fn update_animation_url_arg<'a, 'b>() -> Arg<'a, 'b> {
817+
Arg::with_name("update_animation_url")
818+
.long("update-animation-url")
819+
.value_name("UPDATE_ANIMATION_URL")
820+
.required(false)
821+
.takes_value(false)
822+
.help("Update animation_url key in metadata file with link from manifest file.")
823+
}
824+
813825
fn update_image_arg<'a, 'b>() -> Arg<'a, 'b> {
814826
Arg::with_name("update_image")
815827
.long("update-image")

0 commit comments

Comments
 (0)