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

Introduce AssetUploader module and integrate Irys as an asset uploader provider #318

Merged
merged 5 commits into from
Mar 7, 2024

Conversation

0xmaayan
Copy link
Collaborator

@0xmaayan 0xmaayan commented Mar 1, 2024

Description

This PR introduces a generic AssetUploader module and Irys asset uploader provider as an optional dependency.

We integrate irys package as a peer (optional) dependency to not add too much noise and maintenance for SDK users by forcing them to have a core dependency for a functionality they might not need.

For users who want to use the SDK asset uploader, and more specifically Irys, they should install the @irys/sdk package manually.

The SDK knows how to resolve whether the host package has the Irys package or not. If it doesnt and it tries to use Irys, the SDK would let the user know they should install the Irys package.

If the host package has Irys dependency with a lower version than what the SDK expects, it would warn the user that they have an unmet peer dependency

└─┬ @aptos-labs/ts-sdk 1.9.1-plugin.7
  └── ✕ unmet peer @irys/sdk@>=0.1.15: found 0.1.12

Test Plan

  • Tests are passing.
  • Added an example to demonstrate/show the Irys module usage and flow
  • Tested when host package does not have Irys dependency installed
Error: To use the Irys service, please install the `@irys/sdk` package
  • Tested when host package does have Irys dependency installed
fund response {
  reward: '{"gasUnitPrice":100,"maxGasAmount":12}',
  target: '0xfa3e389d045e057145e29f544f9809c28399f8167e0e45fd157084858dda8a0f',
  quantity: '1000',
  id: '0x2f58562b969d357ef2d9ef505791cde47101f39716fc1a02da9ea4b4b52a7bef'
}
upload response {
  id: 'aXFHH3CExmof64hStNw8JkubWFTFur7tjsNg8j-PuPc',
  timestamp: 1709323853932,
  version: '1.0.0',
  public: 'x2dVQryQrutE8B-8aGBBu4LHoLide9c5dOEC09-4KjPnieORbvB6_pWPTqtKXPowBcy3BmRkuUiQiDXSB80cd5_TRpC6EUl_WJXUAcVwJb8BnDiOf88_P0lSZmU4_zK1F2O4FPQp_eNvyNVThFGTuF6v6L1sNEneFawHBA2PSTI8KEYuF8kmS0CW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fKAhZH-hOGdEjO67aL5OGIFJ06KGQkkulSe9hlF8W1BResOh5RJqUk5uLvsnHNIbUg-IwwGtJdBDSQhSMxqEV3_aTSQfRHFOeihpU9SHoqo0zNTc',
  deadlineHeight: 1378797,
  block: 1378797,
  validatorSignatures: [],
  verify: [Function (anonymous)]
}
uploadFileResponse {
  id: 'y8Etqpn7XbWuxXtK0Rp14zEuZ3Ytcps2aHKeh7h-sLc',
  timestamp: 1709323854836,
  version: '1.0.0',
  public: 'x2dVQryQrutE8B-8aGBBu4LHoLide9c5dOEC09-4KjPnieORbvB6_pWPTqtKXPowBcy3BmRkuUiQiDXSB80cd5_TRpC6EUl_WJXUAcVwJb8BnDiOf88_P0lSZmU4_zK1F2O4FPQp_eNvyNVThFGTuF6v6L1sNEneFawHBA2PSTI8KEYuF8kmS0CWcJ-yotX7cgPeyOFWKlghY1qUb5pKmNGhipQE2bUYhgFJdOKcfRJsyqJwDGsjA3XqGbmK5BXUFRRckSha1U4UHAKHlI6UXO4wHXqf8dLoCe_XVz6T9dbj1mwG56QnzB_brzI6z5aPhQq6oMeblOi27pxk8xR--8RZoqm6fwDs_cROleLKKlBRXPQepjF7xZzzS7Z_51KJEwysbExwq9wqh5O-EuTKxJNggIHGS5JsSYx5rlwKeE5H525sxrOALGe4XiK4uO-AffI-ysmVDKKFBfJFlRLS7S0cvZE698rd_TH0pbdianH6yOjTxlM26AJFWR1UmimA3ZAWIWejcN2aoglaTU1W2wKeFGcBUFnz1Z3JA0jOjHNsNEle55XG3tpBBpLLQN7TBWcyZXPCcJbfcZKJlT5RlgwauIseMKder6c-75tlaXzNNKwOMDxcLPqlrM5huzt7MwkBUTz-ftcPnD-CWZWs0MyaFEPCPjEgLloCaIEH_bc',
  signature: 'uSGzmKqTZvxbJ5s1dyC8-kTkU7khlwBYUcc6fgN2xNGNRpecos0_bJklGpwurN4am3Fyk6GDF4URuL4xJlIdqvfAA6wlWifKUHAnCfWk2khJaAQNMZPCjL9ytHRVltkRNpLTN6CJSXQ1l_gfn1FN1XdwxO8vUYF7UcsKZtAYy68I86scfqyoogI_MnD1ZhhAS5-Ws0qXJoRrdrVYC6BCQw1cZL_MXbuD5Z423nFli9FzbMlK4iuoWR1HlWCsPz3i0Olx8qJsJPERmJI5G9c7HRk1A_sUP1UDps9pMktF-s1G-6nqFpYIl9X6bBlEnDXabO5j-JVnc-u8CdvxkrROO-HI7aNKVjPGoM8UnZfx0xBlQdpWHsVFm_nX1dOKbFMzL_Hmyzw4uzvkKRG93dehU-HXkOkyK__UaV-gCw0T9aSm6GDXtf1hwT3Pw5Ynao30OKG6ciVO5Vj-Xv1j89EPNgtxNwU5q816s_Vx4td_NXwZb8PhRkzbd6yk0ByfDpiJagQiRSB0yz9hxojg-4A5bRLJf7LeJwwGY62oVC_xtOcw1sVbgj6KoVkwoEkB3U0yZ5dkQjQJYWbAa8w4vL6HqGX4iUEvI0CJD5_BpKLCCNjgha6WcbZcfB17WYhbMzysmHy7XcT3dUDX-XHaQDyRubNTIIf6pt1La0oxqkQutTo',
  deadlineHeight: 1378797,
  block: 1378797,
  validatorSignatures: [],
  verify: [Function: bound verifyReceipt]
}
uploadFolderResponse {
  id: 'kNMXy2QjaAAtj1ZB7U53yxCnm_qFRObSSbFNFH3tm-A',
  timestamp: 1709216981122,
  version: '1.0.0',
  public: 'x2dVQryQrutE8B-8aGBBu4LHoLide9c5dOEC09-4KjPnieORbvB6_pWPTqtKXPowBcy3BmRkuUiQiDXSB80cd5_TRpC6EUl_WJXUAcVwJb8BnDiOf88_P0lSZmU4_zK1F2O4FPQp_eNvyNVThFGTuF6v6L1sNEneFawHBA2PSTI8KEYuF8kmS0CWcJ-yotX7cgPeyOFWKlghY1qUb5pKmNGhipQE2bUYhgFJdOKcfRJsyqJwDGsjA3XqGbmK5BXUFRRckSha1U4UHAKHlI6UXO4wHXqf8dLoCe_XVz6T9dbj1mwG56QnzB_brzI6z5aPhQq6oMeblOi27pxk8xR--8RZoqm6fwDs_cROleLKKlBRXPQepjF7xZzzS7Z_51KJEwysbExwq9wqh5O-EuTKxJNggIHGS5JsSYx5rlwKeE5H525sxrOALGe4XiK4uO-AffI-ysmVDKKFBfJFlRLS7S0cvZE698rd_TH0pbdianH6yOjTxlM26AJFWR1UmimA3ZAWIWejcN2aoglaTU1W2wKeFGcBUFnz1Z3JA0jOjHNsNEle55XG3tpBBpLLQN7TBWcyZXPCcJbfcZKJlT5RlgwauIseMKder6c-75tlaXzNNKwOMDxcLPqlrM5huzt7MwkBUTz-ftcPnD-CWZWs0MyaFEPCPjEgLloCaIEH_bc',
  signature: 'RQQj7o7RCo58f0HE-SlAn-hNEMiuoakmFeUFHi5rteqatKFrhCcfUT3HukxX4VGsIYO7SC3BcIS5aIKxKz8sd3KQeF3lDcRzEzlN4pdx61f76m0PZ_x7bCFBNUvuDrf1dBCbdeOGmXBYh6eeBxDbjYO_HSQg1xeHKYd-sgAaKraLajYvFuV-hUMUsvoGLAsFzgJrdSkFXGx_yATupdJdRQQhXiOzXyabcnTC3dMWOXKiqk9yzSZBAeOfH85KflO68OiH4gGYl6pe5rNmv6ALyMaHtygmYPV0WhF1WT7LAHSjzcgMsQ9WzHUnOuDYLb3SylSvpeppJMwLbcvtKarScXq3wGrJvphmXtcETJlzg6ZRPJ2q9HPzUBGLxqNzd09qpY9byQBvy_yn5gjdKUcrkU72gwli5URt2qUaFO4KZ8lSm3xISQkAgo-WOzwj2b8mVk7H9uXy9iiMjQC0sCGua7DYvWWUWkHN5z0VYJbgsqnzD9JWCx4Wziyz1VXIQD1HQYF0ZO3udOIbxkTI7IKJcHhDYbS1K7BSaDRMFhtklxDueL9ESCzbFu5W05oklCZs-jUsEcKrsYVdnercgBDlKDTM9AWG5Dmb_gdo6bSc2W0ZyDKSQGs2cc_Tgv9xDlibJCkk7ptoqFZ0KP2DfUYoO08yLU6HgGyM_iVqX2q7heg',
  deadlineHeight: 1377959,
  block: 1377959,
  validatorSignatures: []
}

Related Links

@0xmaayan 0xmaayan requested a review from a team as a code owner March 1, 2024 21:02
@0xmaayan 0xmaayan requested review from davidiw and jillxuu March 1, 2024 21:02
@0xmaayan 0xmaayan force-pushed the irys_asset_uploader branch 3 times, most recently from c5f6782 to 7aab4c4 Compare March 1, 2024 21:17
Copy link

@jillxuu jillxuu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

overall lgtm! one question i have:
RE if clients manually installed irys sdk is lower than what we expected, in this case, it should break instead of warning? cuz older irys version might not support sdk v2 at all

/**
* Asset uploader provider, default to "irys"
*/
readonly assetUploaderProvider = "irys";
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lets make this a enum?

src/plugins/assetUploader/index.ts Outdated Show resolved Hide resolved
src/plugins/assetUploader/irys.ts Outdated Show resolved Hide resolved
src/plugins/assetUploader/irys.ts Outdated Show resolved Hide resolved
@0xmaayan
Copy link
Collaborator Author

0xmaayan commented Mar 5, 2024

overall lgtm! one question i have: RE if clients manually installed irys sdk is lower than what we expected, in this case, it should break instead of warning? cuz older irys version might not support sdk v2 at all

This a default npm process, if a package declares a peer dependency at version X and the host package has a lower version than X, npm would show this warning.

I am not sure if/how we can detect the host package dependency version. Also, Irys released a patch version with the new Aptos SDK support so it should be pretty automatically for users to have the new version.

A section on the SDK documentation page will be added for the AssetUploader option, I will make sure to mention it there.

@0xmaayan 0xmaayan force-pushed the irys_asset_uploader branch from 7aab4c4 to 41f59db Compare March 5, 2024 16:09
Comment on lines +6 to +8
const aptosConfig = new AptosConfig({
network: Network.TESTNET,
});
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm guessing it only supports testnet?


static async init(config: AptosConfig) {
switch (config.assetUploaderProvider) {
case "irys": {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Enum? :)

Comment on lines 33 to 43
case Network.DEVNET:
// Irys does not support Aptos' devnet
throw new Error("Irys does not support Aptos' devnet");
case Network.TESTNET:
return { irysNode: "devnet", providerUrl: Network.TESTNET };
case Network.MAINNET:
// Irys supports node1 and node2, there is no major difference between
// those and it is recommended to simply use node1
return { irysNode: "node1", providerUrl: Network.MAINNET };
default:
throw new Error("Unsupported network");
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could also just say Irys does not support ${network} including devnet, but this owrks as well.

@0xmaayan 0xmaayan force-pushed the irys_asset_uploader branch 2 times, most recently from fbc5fff to 950e622 Compare March 7, 2024 15:28
@0xmaayan 0xmaayan force-pushed the irys_asset_uploader branch from 950e622 to ff953db Compare March 7, 2024 15:28
@0xmaayan 0xmaayan changed the base branch from main to tmp March 7, 2024 15:29
@0xmaayan 0xmaayan force-pushed the irys_asset_uploader branch from ff953db to 598513e Compare March 7, 2024 15:45
@0xmaayan 0xmaayan merged commit 0d3367e into tmp Mar 7, 2024
4 of 5 checks passed
@0xmaayan 0xmaayan deleted the irys_asset_uploader branch March 7, 2024 20:56
0xmaayan added a commit that referenced this pull request Mar 7, 2024
…oader provider (#318)

* integrate irys as an asset uploader service

* address comments

* upgrade irys package version

* add known limitations of irys comments

* run check version only on prs with main as branch target
jillxuu pushed a commit that referenced this pull request Jul 15, 2024
…oader provider (#318)

* integrate irys as an asset uploader service

* address comments

* upgrade irys package version

* add known limitations of irys comments

* run check version only on prs with main as branch target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants