From fb0883c347494bcebabe35a015d2bc56ff3d2ee4 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Tue, 19 Mar 2024 23:46:42 +0545 Subject: [PATCH 1/7] refactor: Replace Warp with AO --- README.md | 8 - package.json | 5 +- pnpm-lock.yaml | 439 +++++------------------------------- src/lib/aoHelper.ts | 113 ++++++++++ src/lib/common.ts | 4 +- src/lib/protocolLandSync.ts | 14 +- src/lib/warpHelper.ts | 113 ---------- src/types.ts | 11 +- 8 files changed, 190 insertions(+), 517 deletions(-) create mode 100644 src/lib/aoHelper.ts delete mode 100644 src/lib/warpHelper.ts diff --git a/README.md b/README.md index e1840db..c930a7a 100644 --- a/README.md +++ b/README.md @@ -110,11 +110,3 @@ git remote add origin proland://YOUR_PROTOCOL_LAND_REPO_ID ``` Replace `YOUR_PROTOCOL_LAND_REPO_ID` with the specific ID of the Protocol Land repository you wish to associate with your project. This establishes a connection to the remote repository, allowing you to fetch, pull, and push changes seamlessly. - -## Fix Remote Helper Issues - -If you're facing problems with the remote helper that is related to corrupted warp cache, try deleting the Warp cache directory shown while running Git commands. After deleting it, run your Git commands again to check if the issues are resolved. - -For example, this is the directory where the warp cache is stored. It varies for every user. - -![image](https://github.com/labscommunity/protocol-land-remote-helper/assets/11836100/640669bf-f196-4302-a5c2-3d1a95387b90) diff --git a/package.json b/package.json index 4297a8e..7dfedbe 100644 --- a/package.json +++ b/package.json @@ -44,13 +44,12 @@ }, "dependencies": { "@amplitude/analytics-node": "^1.3.4", + "@permaweb/aoconnect": "^0.0.48", "arbundles": "^0.10.0", "arweave": "^1.14.4", - "env-paths": "^3.0.0", "jszip": "^3.10.1", "node-machine-id": "^1.1.12", "redstone-api": "^0.4.11", - "uuid": "^9.0.1", - "warp-contracts": "^1.4.25" + "uuid": "^9.0.1" } } diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 10a763c..a8c0dfe 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,15 +8,15 @@ dependencies: '@amplitude/analytics-node': specifier: ^1.3.4 version: 1.3.4 + '@permaweb/aoconnect': + specifier: ^0.0.48 + version: 0.0.48 arbundles: specifier: ^0.10.0 version: 0.10.0(arweave@1.14.4) arweave: specifier: ^1.14.4 version: 1.14.4 - env-paths: - specifier: ^3.0.0 - version: 3.0.0 jszip: specifier: ^3.10.1 version: 3.10.1 @@ -29,9 +29,6 @@ dependencies: uuid: specifier: ^9.0.1 version: 9.0.1 - warp-contracts: - specifier: ^1.4.25 - version: 1.4.25 devDependencies: '@changesets/cli': @@ -841,6 +838,30 @@ packages: fastq: 1.15.0 dev: true + /@permaweb/ao-scheduler-utils@0.0.15: + resolution: {integrity: sha512-Ef3IGP08E6KgcwX/AUq3k9gj7W/5GylEZRwXbXwC1JYl5FoHegdGAy0gDJYKHO1Nf4NVNFicb1xBaDeU0Ic7og==} + engines: {node: '>=18'} + dependencies: + lru-cache: 10.2.0 + ramda: 0.29.1 + dev: false + + /@permaweb/aoconnect@0.0.48: + resolution: {integrity: sha512-CldwoE+6STKrfvknnmozRDBlo5gSHXLhmfAtAqHZvbMRprZ3yk+N3OIAt8La5axQ8Rwte5KKRcltvrNyxZpsVA==} + engines: {node: '>=18'} + dependencies: + '@permaweb/ao-scheduler-utils': 0.0.15 + buffer: 6.0.3 + debug: 4.3.4 + hyper-async: 1.1.2 + mnemonist: 0.39.8 + ramda: 0.29.1 + warp-arbundles: 1.0.4 + zod: 3.22.4 + transitivePeerDependencies: + - supports-color + dev: false + /@randlabs/communication-bridge@1.0.1: resolution: {integrity: sha512-CzS0U8IFfXNK7QaJFE4pjbxDGfPjbXBEsEaCn9FN15F+ouSAEUQkva3Gl66hrkBZOGexKFEWMwUHIDKpZ2hfVg==} requiresBuild: true @@ -983,19 +1004,6 @@ packages: resolution: {integrity: sha512-WUtIVRUZ9i5dYXefDEAI7sh9/O7jGvHg7Df/5O/gtH3Yabe5odI3UWopVR1qbPXQtvOxWu3mM4XxlYeZtMWF4g==} dev: true - /abstract-level@1.0.3: - resolution: {integrity: sha512-t6jv+xHy+VYwc4xqZMn2Pa9DjcdzvzZmQGRjTFc8spIbRGHgBrEKbPq+rYXc7CCo0lxgYvSgKVg9qZAhpVQSjA==} - engines: {node: '>=12'} - dependencies: - buffer: 6.0.3 - catering: 2.1.1 - is-buffer: 2.0.5 - level-supports: 4.0.1 - level-transcoder: 1.0.1 - module-error: 1.0.2 - queue-microtask: 1.2.3 - dev: false - /aes-js@3.0.0: resolution: {integrity: sha512-H7wUZRn8WpTq9jocdxQ2c8x2sKo9ZVmzfRE13GiNJXfp7NcKYEdvl3vspKjXox6RIG2VtaRe4JFvxG4rqp2Zuw==} dev: false @@ -1100,51 +1108,6 @@ packages: - utf-8-validate dev: false - /archiver-utils@2.1.0: - resolution: {integrity: sha512-bEL/yUb/fNNiNTuUz979Z0Yg5L+LzLxGJz8x79lYmR54fmTIb6ob/hNQgkQnIUDWIFjZVQwl9Xs356I6BAMHfw==} - engines: {node: '>= 6'} - dependencies: - glob: 7.2.3 - graceful-fs: 4.2.11 - lazystream: 1.0.1 - lodash.defaults: 4.2.0 - lodash.difference: 4.5.0 - lodash.flatten: 4.4.0 - lodash.isplainobject: 4.0.6 - lodash.union: 4.6.0 - normalize-path: 3.0.0 - readable-stream: 2.3.8 - dev: false - - /archiver-utils@3.0.4: - resolution: {integrity: sha512-KVgf4XQVrTjhyWmx6cte4RxonPLR9onExufI1jhvw/MQ4BB6IsZD5gT8Lq+u/+pRkWna/6JoHpiQioaqFP5Rzw==} - engines: {node: '>= 10'} - dependencies: - glob: 7.2.3 - graceful-fs: 4.2.11 - lazystream: 1.0.1 - lodash.defaults: 4.2.0 - lodash.difference: 4.5.0 - lodash.flatten: 4.4.0 - lodash.isplainobject: 4.0.6 - lodash.union: 4.6.0 - normalize-path: 3.0.0 - readable-stream: 3.6.2 - dev: false - - /archiver@5.3.2: - resolution: {integrity: sha512-+25nxyyznAXF7Nef3y0EbBeqmGZgeN/BxHX29Rs39djAfaFalmQ89SE6CWyDCHzGL0yt/ycBtNOmGTW0FyGWNw==} - engines: {node: '>= 10'} - dependencies: - archiver-utils: 2.1.0 - async: 3.2.5 - buffer-crc32: 0.2.13 - readable-stream: 3.6.2 - readdir-glob: 1.1.3 - tar-stream: 2.2.0 - zip-stream: 4.1.1 - dev: false - /arconnect@0.4.2: resolution: {integrity: sha512-Jkpd4QL3TVqnd3U683gzXmZUVqBUy17DdJDuL/3D9rkysLgX6ymJ2e+sR+xyZF5Rh42CBqDXWNMmCjBXeP7Gbw==} dependencies: @@ -1217,16 +1180,6 @@ packages: dev: false optional: true - /arweave@1.13.7: - resolution: {integrity: sha512-Hv+x2bSI6UyBHpuVbUDMMpMje1ETfpJWj52kKfz44O0IqDRi/LukOkkDUptup1p6OT6KP1/DdpnUnsNHoskFeA==} - engines: {node: '>=16.15.0'} - dependencies: - arconnect: 0.4.2 - asn1.js: 5.4.1 - base64-js: 1.5.1 - bignumber.js: 9.1.1 - dev: false - /arweave@1.14.4: resolution: {integrity: sha512-tmqU9fug8XAmFETYwgUhLaD3WKav5DaM4p1vgJpEj/Px2ORPPMikwnSySlFymmL2qgRh2ZBcZsg11+RXPPGLsA==} engines: {node: '>=16.15.0'} @@ -1246,22 +1199,12 @@ packages: safer-buffer: 2.1.2 dev: false - /async-mutex@0.4.0: - resolution: {integrity: sha512-eJFZ1YhRR8UN8eBLoNzcDPcy/jqjsg6I1AP+KvWQX80BqOSW1oJPJXDylPUEeMr2ZQvHgnQ//Lp6f3RQ1zI7HA==} - dependencies: - tslib: 2.6.2 - dev: false - /async-retry@1.3.3: resolution: {integrity: sha512-wfr/jstw9xNi/0teMHrRW7dsz3Lt5ARhYNZ2ewpadnhaIp5mbALhOAP+EAdsC7t4Z6wqsDVv9+W6gm1Dk9mEyw==} dependencies: retry: 0.13.1 dev: false - /async@3.2.5: - resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} - dev: false - /asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} dev: false @@ -1318,10 +1261,6 @@ packages: is-windows: 1.0.2 dev: true - /bignumber.js@9.1.1: - resolution: {integrity: sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==} - dev: false - /bignumber.js@9.1.2: resolution: {integrity: sha512-2/mKyZH9K85bzOEfhXDBFZTGd1CTs+5IHpeFQo9luiBG7hghdC851Pj2WAhb6E3R6b9tZj/XKhbg4fum+Kepug==} dev: false @@ -1331,14 +1270,6 @@ packages: engines: {node: '>=8'} dev: true - /bl@4.1.0: - resolution: {integrity: sha512-1W07cM9gS6DcLperZfFSj+bWLtaPGSOHWhPiGzXmvVJbRLdG82sH/Kn8EtW1VqWVA54AKf2h5k5BbnIbwF3h6w==} - dependencies: - buffer: 5.7.1 - inherits: 2.0.4 - readable-stream: 3.6.2 - dev: false - /bn.js@4.12.0: resolution: {integrity: sha512-c98Bf3tPniI+scsdk237ku1Dc3ujXQTSgyiPUDEOe7tRkhrqridvh8klBv0HCEso1OLOYcHuCv/cS6DNxKH+ZA==} dev: false @@ -1353,12 +1284,6 @@ packages: balanced-match: 1.0.2 concat-map: 0.0.1 - /brace-expansion@2.0.1: - resolution: {integrity: sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==} - dependencies: - balanced-match: 1.0.2 - dev: false - /braces@3.0.2: resolution: {integrity: sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==} engines: {node: '>=8'} @@ -1376,44 +1301,12 @@ packages: resolution: {integrity: sha512-cKV8tMCEpQs4hK/ik71d6LrPOnpkpGBR0wzxqr68g2m/LB2GxVYQroAjMJZRVM1Y4BCjCKc3vAamxSzOY2RP+w==} dev: false - /browser-level@1.0.1: - resolution: {integrity: sha512-XECYKJ+Dbzw0lbydyQuJzwNXtOpbMSq737qxJN11sIRTErOMShvDpbzTlgju7orJKvx4epULolZAuJGLzCmWRQ==} - dependencies: - abstract-level: 1.0.3 - catering: 2.1.1 - module-error: 1.0.2 - run-parallel-limit: 1.1.0 - dev: false - /bs58@4.0.1: resolution: {integrity: sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==} dependencies: base-x: 3.0.9 dev: false - /buffer-crc32@0.2.13: - resolution: {integrity: sha512-VO9Ht/+p3SN7SKWqcrgEzjGbRSJYTx+Q1pTQC0wrWqHx0vpJraQ6GtHx8tvcg1rlK1byhU5gccxgOgj7B0TDkQ==} - dev: false - - /buffer-pipe@0.0.0: - resolution: {integrity: sha512-PvKbsvQOH4dcUyUEvQQSs3CIkkuPcOHt3gKnXwf4HsPKFDxSN7bkmICVIWgOmW/jx/fAEGGn4mIayIJPLs7G8g==} - dependencies: - safe-buffer: 5.2.1 - dev: false - - /buffer-pipe@0.0.3: - resolution: {integrity: sha512-GlxfuD/NrKvCNs0Ut+7b1IHjylfdegMBxQIlZHj7bObKVQBxB5S84gtm2yu1mQ8/sSggceWBDPY0cPXgvX2MuA==} - dependencies: - safe-buffer: 5.2.1 - dev: false - - /buffer@5.7.1: - resolution: {integrity: sha512-EHcyIPBQ4BSGlvjB16k5KgAJ27CIsHY/2JBmCRReo48y9rQ3MaUzWX3KVlBa4U7MyX02HdVj0K7C3WaB3ju7FQ==} - dependencies: - base64-js: 1.5.1 - ieee754: 1.2.1 - dev: false - /buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} dependencies: @@ -1458,11 +1351,6 @@ packages: engines: {node: '>=6'} dev: true - /catering@2.1.1: - resolution: {integrity: sha512-K7Qy8O9p76sL3/3m7/zLKbRkyOlSZAgzEaLhyj2mXS8PsCud2Eo4hAb8aLtZqHh0QGqLcb9dlJSu6lHRVENm1w==} - engines: {node: '>=6'} - dev: false - /chalk@2.4.2: resolution: {integrity: sha512-Mti+f9lpJNcwF4tWV8/OrTTtF1gZi+f8FqlyAdouralcFWFQWF2+NgCHShjkCb+IFBLq9buZwE1xckQU4peSuQ==} engines: {node: '>=4'} @@ -1504,18 +1392,6 @@ packages: engines: {node: '>=8'} dev: true - /classic-level@1.3.0: - resolution: {integrity: sha512-iwFAJQYtqRTRM0F6L8h4JCt00ZSGdOyqh7yVrhhjrOpFhmBjNlRUey64MCiyo6UmQHMJ+No3c81nujPv+n9yrg==} - engines: {node: '>=12'} - requiresBuild: true - dependencies: - abstract-level: 1.0.3 - catering: 2.1.1 - module-error: 1.0.2 - napi-macros: 2.2.2 - node-gyp-build: 4.7.0 - dev: false - /cliui@6.0.0: resolution: {integrity: sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==} dependencies: @@ -1571,16 +1447,6 @@ packages: engines: {node: '>= 6'} dev: true - /compress-commons@4.1.2: - resolution: {integrity: sha512-D3uMHtGc/fcO1Gt1/L7i1e33VOvD4A9hfQLP+6ewd+BvG/gQ84Yh4oftEhAdjSMgBgwGL+jsppT7JYNpo6MHHg==} - engines: {node: '>= 10'} - dependencies: - buffer-crc32: 0.2.13 - crc32-stream: 4.0.3 - normalize-path: 3.0.0 - readable-stream: 3.6.2 - dev: false - /concat-map@0.0.1: resolution: {integrity: sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==} @@ -1588,20 +1454,6 @@ packages: resolution: {integrity: sha512-ZQBvi1DcpJ4GDqanjucZ2Hj3wEO5pZDS89BWbkcrvdxksJorwUDDZamX9ldFkp9aw2lmBDLgkObEA4DWNJ9FYQ==} dev: false - /crc-32@1.2.2: - resolution: {integrity: sha512-ROmzCKrTnOwybPcJApAA6WBWij23HVfGVNKqqrZpuyZOHqK2CwHSvpGuyt/UNNvaIjEd8X5IFGp4Mh+Ie1IHJQ==} - engines: {node: '>=0.8'} - hasBin: true - dev: false - - /crc32-stream@4.0.3: - resolution: {integrity: sha512-NT7w2JVU7DFroFdYkeq8cywxrgjPHWkdX1wjpRQXPX5Asews3tA+Ght6lddQO5Mkumffp3X7GEqku3epj2toIw==} - engines: {node: '>= 10'} - dependencies: - crc-32: 1.2.2 - readable-stream: 3.6.2 - dev: false - /cross-fetch@3.1.8: resolution: {integrity: sha512-cvA+JwZoU0Xq+h6WkMvAUqPEYy92Obet6UdKLfW60qn99ftItKjB5T+BkyWOFWe2pUyfQ+IJHmpOTznqk1M6Kg==} requiresBuild: true @@ -1661,7 +1513,6 @@ packages: optional: true dependencies: ms: 2.1.2 - dev: true /decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} @@ -1739,12 +1590,6 @@ packages: resolution: {integrity: sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==} dev: true - /end-of-stream@1.4.4: - resolution: {integrity: sha512-+uw1inIHVPQoaVuHzRyXd21icM+cnt4CzD5rW+NC1wjOUSTOs+Te7FOv7AhN7vS9x/oIyhLP5PR1H+phQAHu5Q==} - dependencies: - once: 1.4.0 - dev: false - /enquirer@2.4.1: resolution: {integrity: sha512-rRqJg/6gd538VHvR3PSrdRBb/1Vy2YfzHqzvbhGIQpDRKIa4FgV/54b5Q1xYSxOOwKvjXweS26E0Q+nAMwp2pQ==} engines: {node: '>=8.6'} @@ -1753,11 +1598,6 @@ packages: strip-ansi: 6.0.1 dev: true - /env-paths@3.0.0: - resolution: {integrity: sha512-dtJUTepzMW3Lm/NPxRf3wP4642UWhjL2sQxc+ym2YMj1m/H2zDNQOlezafzkHwn6sMstjHTwG6iQQsctDW/b1A==} - engines: {node: ^12.20.0 || ^14.13.1 || >=16.0.0} - dev: false - /error-ex@1.3.2: resolution: {integrity: sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==} dependencies: @@ -1879,11 +1719,6 @@ packages: hasBin: true dev: true - /events@3.3.0: - resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} - engines: {node: '>=0.8.x'} - dev: false - /execa@5.1.1: resolution: {integrity: sha512-8uSpZZocAZRBAPIEINJj3Lo9HyGitllczc27Eh5YYojjMFMn8yHMDMaUHE2Jqfq05D/wucwI4JGURyXt1vchyg==} engines: {node: '>=10'} @@ -1918,10 +1753,6 @@ packages: tmp: 0.0.33 dev: true - /fast-copy@3.0.1: - resolution: {integrity: sha512-Knr7NOtK3HWRYGtHoJrjkaWepqT8thIVGAwt0p0aUs1zqkAzXZV4vo9fFNwyb5fcqK1GKYFYxldQdIDVKhUAfA==} - dev: false - /fast-glob@3.3.2: resolution: {integrity: sha512-oX2ruAFQwf/Orj8m737Y5adxDQO0LAB7/S5MnxCdTNDd4p6BsyIVsv9JQsATbTSq8KHRpLwIHbVlUNatxd+1Ow==} engines: {node: '>=8.6.0'} @@ -1994,10 +1825,6 @@ packages: mime-types: 2.1.35 dev: false - /fs-constants@1.0.0: - resolution: {integrity: sha512-y6OAwoSIf7FyjMIv94u+b5rdheZEjzR63GTyZJm5qh4Bi+2YgwLCcI/fPFZkL5PSixOt6ZNKm+w+Hfp/Bciwow==} - dev: false - /fs-extra@7.0.1: resolution: {integrity: sha512-YJDaCJZEnBmcbw13fvdAM9AwNOJwOzrE4pqMqBq5nFiEqXUqHwlK4B+3pUw6JNvfSPtX05xFHtYy/1ni01eGCw==} engines: {node: '>=6 <7 || >=8'} @@ -2041,10 +1868,6 @@ packages: functions-have-names: 1.2.3 dev: true - /functional-red-black-tree@1.0.1: - resolution: {integrity: sha512-dsKNQNdj6xA3T+QlADDA7mOSlX0qiMINjn0cgr+eGHGsbSHzTabcIogz2+p/iqP1Xs6EP/sS2SbqH+brGTbq0g==} - dev: false - /functions-have-names@1.2.3: resolution: {integrity: sha512-xckBUXyTIqT97tq2x2AMb+g163b5JFysYk0x4qxNFwbfQkmNZoiRHb6sPzI9/QV33WeuvVYBUIiD4NzNIyqaRQ==} dev: true @@ -2096,6 +1919,7 @@ packages: /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + requiresBuild: true dependencies: fs.realpath: 1.0.0 inflight: 1.0.6 @@ -2104,6 +1928,7 @@ packages: once: 1.4.0 path-is-absolute: 1.0.1 dev: false + optional: true /globalthis@1.0.3: resolution: {integrity: sha512-sFdI5LyBiNTHjRd7cGPWapiHWMOXKyuBNX/cWJ3NfzrZQVa8GI/8cofCl74AOVqq9W5kNmguTIzJ/1s2gyI9wA==} @@ -2132,6 +1957,7 @@ packages: /graceful-fs@4.2.11: resolution: {integrity: sha512-RbJ5/jmFcNNCcDV5o9eTnBLJ/HszWV0P73bc+Ff4nS/rJj+YaS6IGyiOL0VoBYX+l1Wrl3k63h/KrH+nhJ0XvQ==} + dev: true /grapheme-splitter@1.0.4: resolution: {integrity: sha512-bzh50DW9kTPM00T8y4o8vQg89Di9oLJVLW/KaOGIXJWP/iqCN6WKYkbNOF04vFLJhwcpYUh9ydh/+5vpOqV4YQ==} @@ -2220,6 +2046,10 @@ packages: engines: {node: '>=10.17.0'} dev: true + /hyper-async@1.1.2: + resolution: {integrity: sha512-cnpOgKa+5FZOaccTtjduac1FrZuSc38/ftCp3vYJdUMt+7c+uvGDKLDK4MTNK8D3aFjIeveVrPcSgUPvzZLopg==} + dev: false + /iconv-lite@0.4.24: resolution: {integrity: sha512-v3MXnZAcvnywkTUEZomIActle7RXXeedOR31wwl7VlyoXO4Qi9arvSenNQWne1TcRwhCL1HwLI21bEqdpj8/rA==} engines: {node: '>=0.10.0'} @@ -2296,11 +2126,6 @@ packages: has-tostringtag: 1.0.0 dev: true - /is-buffer@2.0.5: - resolution: {integrity: sha512-i2R6zNFDwgEHJyQUtJEk0XFi1i0dPFn/oqjK3/vPCcDeJvW5NQ83V8QbicfF1SupOaB0h8ntgBC2YiE7dfyctQ==} - engines: {node: '>=4'} - dev: false - /is-callable@1.2.7: resolution: {integrity: sha512-1BC0BVFhS/p0qtw6enp8e+8OD0UrK0oFLztSjNzhcKA3WDuJxxAPXzPuPtKkjEY9UUoEWlX/8fgKeu2S8i9JTA==} engines: {node: '>= 0.4'} @@ -2527,41 +2352,6 @@ packages: engines: {node: '>=6'} dev: true - /lazystream@1.0.1: - resolution: {integrity: sha512-b94GiNHQNy6JNTrt5w6zNyffMrNkXZb3KTkCZJb2V1xaEGCk093vkZ2jk3tpaeP33/OiXC+WvK9AxUebnf5nbw==} - engines: {node: '>= 0.6.3'} - dependencies: - readable-stream: 2.3.8 - dev: false - - /leb128@0.0.4: - resolution: {integrity: sha512-2zejk0fCIgY8RVcc/KzvyfpDio5Oo8HgPZmkrOmdwmbk0KpKpgD+JKwikxKk8cZYkANIhwHK50SNukkCm3XkCQ==} - dependencies: - bn.js: 4.12.0 - buffer-pipe: 0.0.0 - dev: false - - /level-supports@4.0.1: - resolution: {integrity: sha512-PbXpve8rKeNcZ9C1mUicC9auIYFyGpkV9/i6g76tLgANwWhtG2v7I4xNBUlkn3lE2/dZF3Pi0ygYGtLc4RXXdA==} - engines: {node: '>=12'} - dev: false - - /level-transcoder@1.0.1: - resolution: {integrity: sha512-t7bFwFtsQeD8cl8NIoQ2iwxA0CL/9IFw7/9gAjOonH0PWTTiRfY7Hq+Ejbsxh86tXobDQ6IOiddjNYIfOBs06w==} - engines: {node: '>=12'} - dependencies: - buffer: 6.0.3 - module-error: 1.0.2 - dev: false - - /level@8.0.0: - resolution: {integrity: sha512-ypf0jjAk2BWI33yzEaaotpq7fkOPALKAgDBxggO6Q9HGX2MRXn0wbP1Jn/tJv1gtL867+YOjOB49WaUF3UoJNQ==} - engines: {node: '>=12'} - dependencies: - browser-level: 1.0.1 - classic-level: 1.3.0 - dev: false - /lie@3.3.0: resolution: {integrity: sha512-UaiMJzeWRlEujzAuw5LokY1L5ecNQYZKfmyZ9L7wDHb/p5etKaxXhohBcrw0EYby+G/NA52vRSN4N39dxHAIwQ==} dependencies: @@ -2606,22 +2396,6 @@ packages: p-locate: 5.0.0 dev: true - /lodash.defaults@4.2.0: - resolution: {integrity: sha512-qjxPLHd3r5DnsdGacqOMU6pb/avJzdh9tFX2ymgoZE27BmjXrNy/y4LoaiTeAb+O3gL8AfpJGtqfX/ae2leYYQ==} - dev: false - - /lodash.difference@4.5.0: - resolution: {integrity: sha512-dS2j+W26TQ7taQBGN8Lbbq04ssV3emRw4NY58WErlTO29pIqS0HmoT5aJ9+TUQ1N3G+JOZSji4eugsWwGp9yPA==} - dev: false - - /lodash.flatten@4.4.0: - resolution: {integrity: sha512-C5N2Z3DgnnKr0LOpv/hKCgKdb7ZZwafIrsesve6lmzvZIRZRGaZ/l6Q8+2W7NaT+ZwO3fFlSCzCzrDCFdJfZ4g==} - dev: false - - /lodash.isplainobject@4.0.6: - resolution: {integrity: sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==} - dev: false - /lodash.sortby@4.7.0: resolution: {integrity: sha512-HDWXG8isMntAyRF5vZ7xKuEvOhT4AhlRt/3czTSjvGUxjYCBVRQY48ViDHyfYz9VIoBkW4TMGQNapx+l3RUwdA==} dev: true @@ -2630,14 +2404,15 @@ packages: resolution: {integrity: sha512-+WKqsK294HMSc2jEbNgpHpd0JfIBhp7rEV4aqXWqFr6AlXov+SlcgB1Fv01y2kGe3Gc8nMW7VA0SrGuSkRfIEg==} dev: true - /lodash.union@4.6.0: - resolution: {integrity: sha512-c4pB2CdGrGdjMKYLA+XiRDO7Y0PRQbm/Gzg8qMj+QH+pFVAoTp5sBpO0odL3FjoPCGjK96p6qsP+yQoiLoOBcw==} - dev: false - /lodash@4.17.21: resolution: {integrity: sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==} dev: false + /lru-cache@10.2.0: + resolution: {integrity: sha512-2bIM8x+VAf6JT4bKAljS1qUWgMsqZRPGJS6FSahIMPVvctcNhyVp7AJu7quxOW9jwkryBReKZY5tY5JYv2n/7Q==} + engines: {node: 14 || >=16.14} + dev: false + /lru-cache@4.1.5: resolution: {integrity: sha512-sWZlbEP2OsHNkXrMl5GYk/jKk70MBng6UU4YI/qGDYbgf6YbP4EvmqISbXCoJiRKs+1bSpFHVgQxvJ17F2li5g==} dependencies: @@ -2662,15 +2437,6 @@ packages: engines: {node: '>=8'} dev: true - /memory-level@1.0.0: - resolution: {integrity: sha512-UXzwewuWeHBz5krr7EvehKcmLFNoXxGcvuYhC41tRnkrTbJohtS7kVn9akmgirtRygg+f7Yjsfi8Uu5SGSQ4Og==} - engines: {node: '>=12'} - dependencies: - abstract-level: 1.0.3 - functional-red-black-tree: 1.0.1 - module-error: 1.0.2 - dev: false - /meow@6.1.1: resolution: {integrity: sha512-3YffViIt2QWgTy6Pale5QpopX/IvU3LPL03jOTqp6pGj3VjesdO/U8CuHMKpnQr4shCNCM5fd5XFFvIIl6JBHg==} engines: {node: '>=8'} @@ -2740,13 +2506,6 @@ packages: dependencies: brace-expansion: 1.1.11 - /minimatch@5.1.6: - resolution: {integrity: sha512-lKwV/1brpG6mBUFHtb7NUmtABCb2WZZmm2wNiOA5hAb8VdCS4B3dtMWyvcoViccwAW/COERjXLt0zP1zXUN26g==} - engines: {node: '>=10'} - dependencies: - brace-expansion: 2.0.1 - dev: false - /minimist-options@4.1.0: resolution: {integrity: sha512-Q4r8ghd80yhO/0j1O3B2BjweX3fiHg9cdOwjJd2J76Q135c+NDxGCqdYKQ1SKBuFfgWbAUzBfvYjPUEeNgqN1A==} engines: {node: '>= 6'} @@ -2761,14 +2520,14 @@ packages: engines: {node: '>= 8.0.0'} dev: true - /module-error@1.0.2: - resolution: {integrity: sha512-0yuvsqSCv8LbaOKhnsQ/T5JhyFlCYLPXK3U2sgV10zoKQwzs/MyfuQUOZQ1V/6OCOJsK/TRgNVrPuPDqtdMFtA==} - engines: {node: '>=10'} + /mnemonist@0.39.8: + resolution: {integrity: sha512-vyWo2K3fjrUw8YeeZ1zF0fy6Mu59RHokURlld8ymdUPjMlD9EC9ov1/YPqTgqRvUN9nTr3Gqfz29LYAmu0PHPQ==} + dependencies: + obliterator: 2.0.4 dev: false /ms@2.1.2: resolution: {integrity: sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==} - dev: true /multistream@4.1.0: resolution: {integrity: sha512-J1XDiAmmNpRCBfIWJv+n0ymC4ABcf/Pl+5YvC5B/D2f/2+8PtHvCNxMPKiQcZyi922Hq69J2YOpb1pTywfifyw==} @@ -2787,10 +2546,6 @@ packages: thenify-all: 1.6.0 dev: true - /napi-macros@2.2.2: - resolution: {integrity: sha512-hmEVtAGYzVQpCKdbQea4skABsdXW4RUh5t5mJ2zzqowJS2OyXZTU1KhDVFhx+NlWZ4ap9mqR9TcDO3LTTttd+g==} - dev: false - /node-addon-api@2.0.2: resolution: {integrity: sha512-Ntyt4AIXyaLIuMHF6IOoTakB3K+RWxwtsHNRxllEoA6vPwP9o4866g6YWDLUdnucilZhmkxiHwHr11gAENw+QA==} dev: false @@ -2834,6 +2589,7 @@ packages: /normalize-path@3.0.0: resolution: {integrity: sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==} engines: {node: '>=0.10.0'} + dev: true /npm-run-path@4.0.1: resolution: {integrity: sha512-S48WzZW777zhNIrn7gxOlISNAqi9ZC/uQFnRdbeIHhZhCA6UqpkOT8T1G7BvfdgP4Er8gF4sUbaS0i7QvIfCWw==} @@ -2866,6 +2622,10 @@ packages: object-keys: 1.1.1 dev: true + /obliterator@2.0.4: + resolution: {integrity: sha512-lgHwxlxV1qIg1Eap7LgIeoBWIMFibOjbrYPIPJZcI1mmGAI2m3lNYpK12Y+GBdPQ0U1hRwSord7GIaawz962qQ==} + dev: false + /once@1.4.0: resolution: {integrity: sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==} dependencies: @@ -3046,12 +2806,17 @@ packages: /queue-microtask@1.2.3: resolution: {integrity: sha512-NuaNSa6flKT5JaSYQzJok04JzTL1CA6aGhv5rfLW3PgqA+M2ChpZQnAC8h8i4ZFkBS8X5RqkDBHA7r4hej3K9A==} + dev: true /quick-lru@4.0.1: resolution: {integrity: sha512-ARhCpm70fzdcvNQfPoy49IaanKkTlRWF2JMzqhcJbhSFRZv7nPTvZJdcY7301IPmvW+/p0RgIWnQDLJxifsQ7g==} engines: {node: '>=8'} dev: true + /ramda@0.29.1: + resolution: {integrity: sha512-OfxIeWzd4xdUNxlWhgFazxsA/nl3mS4/jGZI5n00uWOoSSFRhC1b6gl6xvmzUamgmqELraWp0J/qqVlXYPDPyA==} + dev: false + /read-pkg-up@7.0.1: resolution: {integrity: sha512-zK0TB7Xd6JpCLmlLmufqykGE+/TlOePD6qKClNW7hHDKFh/J7/7gCWGR7joEQEW1bKq3a3yUZSObOoWLFQ4ohg==} engines: {node: '>=8'} @@ -3102,12 +2867,6 @@ packages: util-deprecate: 1.0.2 dev: false - /readdir-glob@1.1.3: - resolution: {integrity: sha512-v05I2k7xN8zXvPD9N+z/uhXPaj0sUFCe2rcWZIpBsqxfP7xXFQ0tipAd/wjj1YxWyWtUS5IDJpOG82JKt2EAVA==} - dependencies: - minimatch: 5.1.6 - dev: false - /readdirp@3.6.0: resolution: {integrity: sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==} engines: {node: '>=8.10.0'} @@ -3212,12 +2971,6 @@ packages: fsevents: 2.3.3 dev: true - /run-parallel-limit@1.1.0: - resolution: {integrity: sha512-jJA7irRNM91jaKc3Hcl1npHsFLOXOoTkPCUL1JEa1R82O2miplXXRaGdjW/KM/98YQWDhJLiSs793CnXfblJUw==} - dependencies: - queue-microtask: 1.2.3 - dev: false - /run-parallel@1.2.0: resolution: {integrity: sha512-5l4VyZR86LZ/lDxZTR6jqL8AFE2S0IFLMP26AbjsLVADxHdhB/c0GUsH+y39UfCi3dzz8OlQuPmnaJOMoDHQBA==} dependencies: @@ -3250,11 +3003,6 @@ packages: is-regex: 1.1.4 dev: true - /safe-stable-stringify@2.4.1: - resolution: {integrity: sha512-dVHE6bMtS/bnL2mwualjc6IxEv1F+OCUpA46pKUj6F8uDbUM0jCCulPqRNPSnWwGNKx5etqMjZYdXtrm5KJZGA==} - engines: {node: '>=10'} - dev: false - /safer-buffer@2.1.2: resolution: {integrity: sha512-YZo3K82SD7Riyi0E1EQPojLz7kpepnSQI9IyPbHHg1XXXevb5dJI7tpyN2ADxGcQbHG7vcyRHk0cbwqcQriUtg==} @@ -3406,11 +3154,6 @@ packages: resolution: {integrity: sha512-D9cPgkvLlV3t3IzL0D0YLvGA9Ahk4PcvVwUbN0dSGr1aP0Nrt4AEnTUbuGvquEC0mA64Gqt1fzirlRs5ibXx8g==} dev: true - /stream-buffers@3.0.2: - resolution: {integrity: sha512-DQi1h8VEBA/lURbSwFtEHnSTb9s2/pwLEaFuNhXwy1Dx3Sa0lOuYT2yNUr4/j2fs8oCAMANtrZ5OrPZtyVs3MQ==} - engines: {node: '>= 0.10.0'} - dev: false - /stream-transform@2.1.3: resolution: {integrity: sha512-9GHUiM5hMiCi6Y03jD2ARC1ettBXkQBoQAe7nJsPknnI0ow10aXjTnew8QtYQmLjzn974BnmWEAJgCY6ZP1DeQ==} dependencies: @@ -3459,6 +3202,7 @@ packages: /string_decoder@1.3.0: resolution: {integrity: sha512-hkRX8U1WjJFd8LsDJ2yQ/wWWxaopEsABU1XfkM8A+j0+85JAGppt16cr1Whg6KIbb4okU6Mql6BOj+uup/wKeA==} + requiresBuild: true dependencies: safe-buffer: 5.2.1 dev: false @@ -3520,17 +3264,6 @@ packages: engines: {node: '>= 0.4'} dev: true - /tar-stream@2.2.0: - resolution: {integrity: sha512-ujeqbceABgwMZxEJnk2HDY2DlnUZ+9oEcb1KzTVfYHio0UE6dG71n60d8D2I4qNvleWrrXpmjpt7vZeF1LnMZQ==} - engines: {node: '>=6'} - dependencies: - bl: 4.1.0 - end-of-stream: 1.4.4 - fs-constants: 1.0.0 - inherits: 2.0.4 - readable-stream: 3.6.2 - dev: false - /term-size@2.2.1: resolution: {integrity: sha512-wK0Ri4fOGjv/XPy8SBHZChl8CM7uMc5VML7SqiQ0zG7+J5Vr+RMQDoHa2CNT6KHUnTGIXH34UDMkPzAUyapBZg==} engines: {node: '>=8'} @@ -3753,13 +3486,6 @@ packages: engines: {node: '>= 4.0.0'} dev: true - /unzipit@1.4.3: - resolution: {integrity: sha512-gsq2PdJIWWGhx5kcdWStvNWit9FVdTewm4SEG7gFskWs+XCVaULt9+BwuoBtJiRE8eo3L1IPAOrbByNLtLtIlg==} - engines: {node: '>=12'} - dependencies: - uzip-module: 1.0.3 - dev: false - /util-deprecate@1.0.2: resolution: {integrity: sha512-EPD5q1uXyFxJpCrLnCc1nHnq3gOa6DZBocAIiI2TaSCA7VCJ1UJDMagCzIkXNsUYfD1daK//LTEQ8xiIbrHtcw==} dev: false @@ -3769,10 +3495,6 @@ packages: hasBin: true dev: false - /uzip-module@1.0.3: - resolution: {integrity: sha512-AMqwWZaknLM77G+VPYNZLEruMGWGzyigPK3/Whg99B3S6vGHuqsyl5ZrOv1UUF3paGK1U6PM0cnayioaryg/fA==} - dev: false - /validate-npm-package-license@3.0.4: resolution: {integrity: sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==} dependencies: @@ -3795,33 +3517,6 @@ packages: warp-isomorphic: 1.0.7 dev: false - /warp-contracts@1.4.25: - resolution: {integrity: sha512-hJ05UbQxD3fW4ZI/6qztXW509tIyT/oRE8y4r7WzKfVu19u0dDjcPEsJC2U2yflke8P1+oi+BrSulT+o7yoPKA==} - engines: {node: '>=16.8'} - dependencies: - archiver: 5.3.2 - arweave: 1.13.7 - async-mutex: 0.4.0 - bignumber.js: 9.1.1 - events: 3.3.0 - fast-copy: 3.0.1 - level: 8.0.0 - memory-level: 1.0.0 - safe-stable-stringify: 2.4.1 - stream-buffers: 3.0.2 - unzipit: 1.4.3 - warp-arbundles: 1.0.4 - warp-isomorphic: 1.0.7 - warp-wasm-metering: 1.0.1 - dev: false - - /warp-isomorphic@1.0.0: - resolution: {integrity: sha512-E+9+brlrnZoNpNvpz8foIZiCk9fIVukRBZYEy/yefM+oAG+zNgDPb/xNaZyUJWC8rSZxE1DqrhRl0JxjtLVltA==} - dependencies: - buffer: 6.0.3 - undici: 5.27.2 - dev: false - /warp-isomorphic@1.0.7: resolution: {integrity: sha512-fXHbUXwdYqPm9fRPz8mjv5ndPco09aMQuTe4kXfymzOq8V6F3DLsg9cIafxvjms9/mc6eijzkLBJ63yjEENEjA==} engines: {node: '>=16.8.0'} @@ -3830,23 +3525,6 @@ packages: undici: 5.27.2 dev: false - /warp-wasm-json-toolkit@1.0.2: - resolution: {integrity: sha512-T6pKJz9mO0ZFYiu4jB2v8j8t8Cw21n/+uFh0QKbc/7cJSssGd3I26sV/VXjoDbGuG7bGzK9BewlFd+ukvxABOA==} - hasBin: true - dependencies: - buffer-pipe: 0.0.3 - leb128: 0.0.4 - warp-isomorphic: 1.0.0 - dev: false - - /warp-wasm-metering@1.0.1: - resolution: {integrity: sha512-s2NtOPTGIDPWeDKyrY5UiUUf3oOjbjwGF9sgmRR3nqXzjxdgppvuf+6VYquzYM3xRMXIOq+AWMK2H/D/Yv+4tg==} - hasBin: true - dependencies: - leb128: 0.0.4 - warp-wasm-json-toolkit: 1.0.2 - dev: false - /wcwidth@1.0.1: resolution: {integrity: sha512-XHPEwS0q6TaxcvG85+8EYkbiCux2XtWG2mkc47Ng2A77BQu9+DqIOJldST4HgPkuea7dvKSj5VgX3P1d4rW8Tg==} dependencies: @@ -4032,11 +3710,6 @@ packages: engines: {node: '>=10'} dev: true - /zip-stream@4.1.1: - resolution: {integrity: sha512-9qv4rlDiopXg4E69k+vMHjNN63YFMe9sZMrdlvKnCjlCRWeCBswPPMPUfx+ipsAWq1LXHe70RcbaHdJJpS6hyQ==} - engines: {node: '>= 10'} - dependencies: - archiver-utils: 3.0.4 - compress-commons: 4.1.2 - readable-stream: 3.6.2 + /zod@3.22.4: + resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} dev: false diff --git a/src/lib/aoHelper.ts b/src/lib/aoHelper.ts new file mode 100644 index 0000000..9b04f87 --- /dev/null +++ b/src/lib/aoHelper.ts @@ -0,0 +1,113 @@ +import type { Tag } from 'arweave/node/lib/transaction'; +import { AOS_PROCESS_ID, getWallet, isValidUuid, waitFor } from './common'; +import type { Repo, SendMessageArgs } from '../types'; +import { + createDataItemSigner, + dryrun, + message, + result, +} from '@permaweb/aoconnect'; + +function capitalizeFirstLetter(str: string) { + return str.charAt(0).toUpperCase() + str.slice(1); +} + +function getTags(payload: { [key: string]: string }): Tag[] { + return Object.entries(payload).map( + ([key, value]) => ({ name: capitalizeFirstLetter(key), value } as Tag) + ); +} + +export function extractMessage(text: string) { + // This regex looks for a pattern that starts with a colon (escaping it since it's a special character in regex), + // followed by any character (.) zero or more times (*) in a non-greedy way (?), + // until it hits an exclamation mark. We're capturing the content between the colon and the exclamation mark. + const regex = /:\s*([^:!]+)!/; + const match = text.match(regex); + + // If a match is found, return the captured group, which is the message. + // Else, return an empty string or null to indicate no match was found. + return match ? match[1]!.trim() : text; +} + +async function sendMessage({ tags, data }: SendMessageArgs) { + const args = { + process: AOS_PROCESS_ID, + tags, + signer: createDataItemSigner(getWallet()), + } as any; + + if (data) args.data = data; + + const messageId = await message(args); + + const { Output } = await result({ + message: messageId, + process: AOS_PROCESS_ID, + }); + + if (Output?.data?.output) { + throw new Error(extractMessage(Output?.data?.output)); + } + + return messageId; +} + +export async function getRepo(id: string) { + let Messages = []; + const fields = JSON.stringify([ + 'id', + 'name', + 'description', + 'owner', + 'fork', + 'parent', + 'dataTxId', + 'contributors', + 'githubSync', + ]); + if (isValidUuid(id)) { + ({ Messages } = await dryrun({ + process: AOS_PROCESS_ID, + tags: getTags({ + Action: 'Get-Repository', + Id: id, + Fields: fields, + }), + })); + } else { + const [username, repoName] = id.split('/'); + if (!username || !repoName) return; + + ({ Messages } = await dryrun({ + process: AOS_PROCESS_ID, + tags: getTags({ + Action: 'Get-Repository-By-Name-Username', + RepoName: repoName, + Username: username, + Fields: fields, + }), + })); + } + + if (Messages.length === 0) return undefined; + + return JSON.parse(Messages[0].Data)?.result as Repo; +} + +export async function updateRepo(repo: Repo, newDataTxId: string) { + if (!repo.id || !repo.name || !newDataTxId) + throw '[ AO ] No id, title or dataTxId to update repo '; + + await waitFor(500); + + await sendMessage({ + tags: getTags({ + Action: 'Update-Repository-TxId', + Id: repo.id, + DataTxId: newDataTxId, + }), + }); + + return { id: repo.id }; +} diff --git a/src/lib/common.ts b/src/lib/common.ts index 205475d..9df8bc8 100644 --- a/src/lib/common.ts +++ b/src/lib/common.ts @@ -15,8 +15,8 @@ const DIRTY_EXT = '.tmp'; export const PL_TMP_PATH = '.protocol.land'; export const GIT_CONFIG_KEYFILE = 'protocol.land.keyfile'; export const GIT_CONFIG_THRESHOLD_COST = 'protocol.land.thresholdCost'; -export const getWarpContractTxId = () => - 'w5ZU15Y2cLzZlu3jewauIlnzbKw-OAxbN9G5TbuuiDQ'; +export const AOS_PROCESS_ID = 'Mj6eddWvVjxROVUvUoz-ysr0lrcb36b9hNgF5NKLoLw'; + // get gitdir (usually '.git') export const gitdir = process.env.GIT_DIR as string; diff --git a/src/lib/protocolLandSync.ts b/src/lib/protocolLandSync.ts index e144ce7..94dffa2 100644 --- a/src/lib/protocolLandSync.ts +++ b/src/lib/protocolLandSync.ts @@ -1,4 +1,4 @@ -import { getRepo, updateWarpRepo } from './warpHelper'; +import { getRepo, updateRepo } from './aoHelper'; import { spawn } from 'child_process'; import { arweaveDownload, uploadRepo } from './arweaveHelper'; import { unpackGitRepo, zipRepoJsZip } from './zipHelper'; @@ -22,7 +22,7 @@ export const downloadProtocolLandRepo = async ( ) => { log(`Getting latest repo from Protocol.Land into '${destPath}' ...`); - // find repo in Protocol Land's warp contract + // find repo in Protocol Land's AO contract let repo: Repo | undefined; try { repo = await getRepo(repoId); @@ -117,7 +117,7 @@ export const downloadProtocolLandRepo = async ( process.exit(0); } - // rm -rf everything but the bare repo and warp cache (discard stdout) + // rm -rf everything but the bare repo and AO cache (discard stdout) try { clearCache(destPath, { keepFolders: [repo.dataTxId] }); } catch {} @@ -174,11 +174,11 @@ export const uploadProtocolLandRepo = async ( } if (!dataTxId) return { success: false, pushCancelled }; - // update repo info in warp - log('Updating in warp ...'); - const updated = await updateWarpRepo(repo, dataTxId); + // update repo info in AO + log('Updating in AO ...'); + const updated = await updateRepo(repo, dataTxId); - // check for warp update success + // check for AO update success return { success: updated.id === repo.id, pushCancelled }; }; diff --git a/src/lib/warpHelper.ts b/src/lib/warpHelper.ts deleted file mode 100644 index 24c9a25..0000000 --- a/src/lib/warpHelper.ts +++ /dev/null @@ -1,113 +0,0 @@ -import { - LoggerFactory, - WarpFactory, - defaultCacheOptions, - type LogLevel, -} from 'warp-contracts/mjs'; -import { - PL_TMP_PATH, - getWallet, - getWarpContractTxId, - isValidUuid, - log, - waitFor, -} from './common'; -import type { Repo, User } from '../types'; -import envPaths from 'env-paths'; -import path from 'path'; -import fs from 'fs'; - -async function getWarpContract(signer?: any) { - const contractTxId = getWarpContractTxId(); - const cacheDirectory = envPaths(PL_TMP_PATH, { suffix: '' }).cache; - const cacheDirectoryExists = fs.existsSync(cacheDirectory); - - log(`Warp cache stored at: ${cacheDirectory}`); - - const warp = getWarp(cacheDirectory); - const contract = warp.contract(contractTxId); - - if (!cacheDirectoryExists) { - fs.mkdirSync(cacheDirectory, { recursive: true }); - await contract - .syncState('https://pl-cache.saikranthi.dev/contract', { - validity: true, - }) - .catch(() => {}); - } - - return signer ? contract.connect(signer) : contract; -} - -export const getWarpCacheOptions = (cachePath: string) => { - return { - ...defaultCacheOptions, - dbLocation: path.join(cachePath, defaultCacheOptions.dbLocation), - }; -}; - -const getWarp = (destPath?: string, logLevel?: LogLevel) => { - // set warp log level to none - LoggerFactory.INST.logLevel(logLevel ? logLevel : 'none'); - const options = destPath - ? getWarpCacheOptions(destPath) - : { ...defaultCacheOptions, inMemory: true }; - return WarpFactory.forMainnet({ ...options }); -}; - -export async function getRepo(id: string, destpath?: string) { - let pl = await getWarpContract(); - if (isValidUuid(id)) { - // let warp throw error if it can't retrieve the repository - const response = await pl.viewState({ - function: 'getRepository', - payload: { - id, - }, - }); - return response.result as Repo; - } else { - const [username, repoName] = id.split('/'); - if (!username || !repoName) return; - - const state = (await pl.readState()).cachedValue.state as { - users: { [key: string]: User }; - }; - const userAddress = Object.entries(state.users).find( - ([_, user]) => user.username === username - )?.[0]; - if (!userAddress) return; - - const ownerReposResponse = await pl.viewState({ - function: 'getRepositoriesByOwner', - payload: { owner: userAddress }, - }); - - const repos = ownerReposResponse?.result as Repo[]; - const repo = repos.find((repo) => repo.name === repoName); - return repo; - } -} - -export async function updateWarpRepo(repo: Repo, newDataTxId: string) { - if (!repo.id || !repo.name || !newDataTxId) - throw '[ warp ] No id, title or dataTxId to update repo '; - - const payload = { - id: repo.id, - name: repo.name, - description: repo.description, - dataTxId: newDataTxId, - }; - - await waitFor(500); - - // let warp throw error if it can't perform the writeInteraction - const contract = getWarp().contract(getWarpContractTxId()); - await contract.connect(getWallet()).writeInteraction({ - function: 'updateRepositoryTxId', - payload, - }); - - return { id: payload.id }; -} diff --git a/src/types.ts b/src/types.ts index 23dbbf7..ffb4109 100644 --- a/src/types.ts +++ b/src/types.ts @@ -50,7 +50,16 @@ export type Tag = { export type SubsidizedUploadJsonResponse = { success: boolean; - bundled:boolean; + bundled: boolean; data: { repoTxId: string }; error?: string; }; + +export type SendMessageArgs = { + data?: string; + tags: { + name: string; + value: string; + }[]; + anchor?: string; +}; From 1c022587b592046d9cbb652ebf38a8743bb0596d Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 20 Mar 2024 10:09:53 +0545 Subject: [PATCH 2/7] fix: Add missing private repo fields --- src/lib/aoHelper.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/aoHelper.ts b/src/lib/aoHelper.ts index 9b04f87..f628841 100644 --- a/src/lib/aoHelper.ts +++ b/src/lib/aoHelper.ts @@ -65,6 +65,8 @@ export async function getRepo(id: string) { 'dataTxId', 'contributors', 'githubSync', + 'private', + 'privateStateTxId', ]); if (isValidUuid(id)) { ({ Messages } = await dryrun({ From 83a4970dc9e127e8ba120cfce4758805689c5b16 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 20 Mar 2024 18:40:32 +0545 Subject: [PATCH 3/7] refactor: Update actions name --- src/lib/aoHelper.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/aoHelper.ts b/src/lib/aoHelper.ts index f628841..e87bc93 100644 --- a/src/lib/aoHelper.ts +++ b/src/lib/aoHelper.ts @@ -72,7 +72,7 @@ export async function getRepo(id: string) { ({ Messages } = await dryrun({ process: AOS_PROCESS_ID, tags: getTags({ - Action: 'Get-Repository', + Action: 'Get-Repo', Id: id, Fields: fields, }), @@ -84,7 +84,7 @@ export async function getRepo(id: string) { ({ Messages } = await dryrun({ process: AOS_PROCESS_ID, tags: getTags({ - Action: 'Get-Repository-By-Name-Username', + Action: 'Get-Repo-By-Name-Username', RepoName: repoName, Username: username, Fields: fields, @@ -105,7 +105,7 @@ export async function updateRepo(repo: Repo, newDataTxId: string) { await sendMessage({ tags: getTags({ - Action: 'Update-Repository-TxId', + Action: 'Update-Repo-TxId', Id: repo.id, DataTxId: newDataTxId, }), From b41b4c281e26b8e29e73d033f72cc16fd6f4cf2c Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 24 Apr 2024 16:40:31 +0545 Subject: [PATCH 4/7] refactor: Update tags --- package.json | 2 +- pnpm-lock.yaml | 35 +++++++++++++++++++---------------- src/lib/aoHelper.ts | 4 ++-- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/package.json b/package.json index 7dfedbe..d09d0a2 100644 --- a/package.json +++ b/package.json @@ -44,7 +44,7 @@ }, "dependencies": { "@amplitude/analytics-node": "^1.3.4", - "@permaweb/aoconnect": "^0.0.48", + "@permaweb/aoconnect": "^0.0.52", "arbundles": "^0.10.0", "arweave": "^1.14.4", "jszip": "^3.10.1", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a8c0dfe..91b8239 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -9,8 +9,8 @@ dependencies: specifier: ^1.3.4 version: 1.3.4 '@permaweb/aoconnect': - specifier: ^0.0.48 - version: 0.0.48 + specifier: ^0.0.52 + version: 0.0.52 arbundles: specifier: ^0.10.0 version: 0.10.0(arweave@1.14.4) @@ -746,8 +746,8 @@ packages: '@ethersproject/strings': 5.7.0 dev: false - /@fastify/busboy@2.1.0: - resolution: {integrity: sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==} + /@fastify/busboy@2.1.1: + resolution: {integrity: sha512-vBZP4NlzfOlerQTnba4aqZoMhE/a9HY7HRqoOPaETQcSQuWEIyZMHGfVu6w9wGtGK5fED5qRs2DteVCjOH60sA==} engines: {node: '>=14'} dev: false @@ -838,26 +838,27 @@ packages: fastq: 1.15.0 dev: true - /@permaweb/ao-scheduler-utils@0.0.15: - resolution: {integrity: sha512-Ef3IGP08E6KgcwX/AUq3k9gj7W/5GylEZRwXbXwC1JYl5FoHegdGAy0gDJYKHO1Nf4NVNFicb1xBaDeU0Ic7og==} + /@permaweb/ao-scheduler-utils@0.0.18: + resolution: {integrity: sha512-hN5Iu1jV9xMYUwUsmU9ZpSktHqaKQ3zMXqrXwEjfwNiGEZXmuOLz5grY7PKY/cwlkIZN83cTOM/mtgPPJ33E/A==} engines: {node: '>=18'} dependencies: lru-cache: 10.2.0 ramda: 0.29.1 + zod: 3.23.4 dev: false - /@permaweb/aoconnect@0.0.48: - resolution: {integrity: sha512-CldwoE+6STKrfvknnmozRDBlo5gSHXLhmfAtAqHZvbMRprZ3yk+N3OIAt8La5axQ8Rwte5KKRcltvrNyxZpsVA==} + /@permaweb/aoconnect@0.0.52: + resolution: {integrity: sha512-0NEohkDAzJwqa12+7d2u/RrseW8swPdjQYupf/yqLYUQw5xXkViRUb2FaU7R7aQaZrzb5R3q90OCr5lMyk/7UA==} engines: {node: '>=18'} dependencies: - '@permaweb/ao-scheduler-utils': 0.0.15 + '@permaweb/ao-scheduler-utils': 0.0.18 buffer: 6.0.3 debug: 4.3.4 hyper-async: 1.1.2 mnemonist: 0.39.8 ramda: 0.29.1 warp-arbundles: 1.0.4 - zod: 3.22.4 + zod: 3.23.4 transitivePeerDependencies: - supports-color dev: false @@ -1309,6 +1310,7 @@ packages: /buffer@6.0.3: resolution: {integrity: sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==} + requiresBuild: true dependencies: base64-js: 1.5.1 ieee754: 1.2.1 @@ -2059,6 +2061,7 @@ packages: /ieee754@1.2.1: resolution: {integrity: sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==} + requiresBuild: true dev: false /ignore@5.3.0: @@ -3474,11 +3477,11 @@ packages: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} dev: true - /undici@5.27.2: - resolution: {integrity: sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==} + /undici@5.28.4: + resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} engines: {node: '>=14.0'} dependencies: - '@fastify/busboy': 2.1.0 + '@fastify/busboy': 2.1.1 dev: false /universalify@0.1.2: @@ -3522,7 +3525,7 @@ packages: engines: {node: '>=16.8.0'} dependencies: buffer: 6.0.3 - undici: 5.27.2 + undici: 5.28.4 dev: false /wcwidth@1.0.1: @@ -3710,6 +3713,6 @@ packages: engines: {node: '>=10'} dev: true - /zod@3.22.4: - resolution: {integrity: sha512-iC+8Io04lddc+mVqQ9AZ7OQ2MrUKGN+oIQyq1vemgt46jwCwLfhq7/pwnBnNXXXZb8VTVLKwp9EDkx+ryxIWmg==} + /zod@3.23.4: + resolution: {integrity: sha512-/AtWOKbBgjzEYYQRNfoGKHObgfAZag6qUJX1VbHo2PRBgS+wfWagEY2mizjfyAPcGesrJOcx/wcl0L9WnVrHFw==} dev: false diff --git a/src/lib/aoHelper.ts b/src/lib/aoHelper.ts index e87bc93..0e25ad8 100644 --- a/src/lib/aoHelper.ts +++ b/src/lib/aoHelper.ts @@ -85,7 +85,7 @@ export async function getRepo(id: string) { process: AOS_PROCESS_ID, tags: getTags({ Action: 'Get-Repo-By-Name-Username', - RepoName: repoName, + "Repo-Name": repoName, Username: username, Fields: fields, }), @@ -107,7 +107,7 @@ export async function updateRepo(repo: Repo, newDataTxId: string) { tags: getTags({ Action: 'Update-Repo-TxId', Id: repo.id, - DataTxId: newDataTxId, + "Data-TxId": newDataTxId, }), }); From b4d20cdc782e057aae79e470ba1b820945c78273 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 24 Apr 2024 18:01:54 +0545 Subject: [PATCH 5/7] fix: Use isCryptoKey util for checking cryptokey --- src/lib/privateRepo.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/lib/privateRepo.ts b/src/lib/privateRepo.ts index 9a33d36..206a550 100644 --- a/src/lib/privateRepo.ts +++ b/src/lib/privateRepo.ts @@ -2,6 +2,7 @@ import crypto from 'crypto'; import type { PrivateState } from '../types'; import { getActivePublicKey } from './arweaveHelper'; import { getWallet, initArweave } from './common'; +import { isCryptoKey } from 'util/types'; const arweave = initArweave(); @@ -19,7 +20,7 @@ async function encryptDataWithExistingKey( ) { let key = aesKey; - if (!(aesKey instanceof crypto.webcrypto.CryptoKey)) { + if (!isCryptoKey(aesKey)) { key = await crypto.subtle.importKey( 'raw', aesKey, From dfd99ca0ab164c650a902a807c8224c01edc0586 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 24 Apr 2024 21:53:00 +0545 Subject: [PATCH 6/7] refactor: Add isCryptoKey function to check crypto key --- src/lib/privateRepo.ts | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/lib/privateRepo.ts b/src/lib/privateRepo.ts index 206a550..b9705de 100644 --- a/src/lib/privateRepo.ts +++ b/src/lib/privateRepo.ts @@ -2,10 +2,18 @@ import crypto from 'crypto'; import type { PrivateState } from '../types'; import { getActivePublicKey } from './arweaveHelper'; import { getWallet, initArweave } from './common'; -import { isCryptoKey } from 'util/types'; const arweave = initArweave(); +function isCryptoKey(obj: any) { + try { + // @ts-ignore + return obj instanceof CryptoKey; + } catch (e) { + return obj instanceof crypto.webcrypto.CryptoKey; + } +} + async function deriveAddress(publicKey: string) { const pubKeyBuf = arweave.utils.b64UrlToBuffer(publicKey); const sha512DigestBuf = await crypto.subtle.digest('SHA-512', pubKeyBuf); From 2947b865971ed9f4285efa9cfe365fd05511ee07 Mon Sep 17 00:00:00 2001 From: Sai Kranthi Date: Thu, 25 Jul 2024 18:39:45 +0530 Subject: [PATCH 7/7] refactor: disable private repos and update ao pid --- src/lib/common.ts | 2 +- src/lib/protocolLandSync.ts | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/lib/common.ts b/src/lib/common.ts index 9df8bc8..54eff48 100644 --- a/src/lib/common.ts +++ b/src/lib/common.ts @@ -15,7 +15,7 @@ const DIRTY_EXT = '.tmp'; export const PL_TMP_PATH = '.protocol.land'; export const GIT_CONFIG_KEYFILE = 'protocol.land.keyfile'; export const GIT_CONFIG_THRESHOLD_COST = 'protocol.land.thresholdCost'; -export const AOS_PROCESS_ID = 'Mj6eddWvVjxROVUvUoz-ysr0lrcb36b9hNgF5NKLoLw'; +export const AOS_PROCESS_ID = 'yJZ3_Yrc-qYRt1zHmY7YeNvpmQwuqyK3dT0-gxWftew'; // get gitdir (usually '.git') export const gitdir = process.env.GIT_DIR as string; diff --git a/src/lib/protocolLandSync.ts b/src/lib/protocolLandSync.ts index 94dffa2..0d548dd 100644 --- a/src/lib/protocolLandSync.ts +++ b/src/lib/protocolLandSync.ts @@ -13,7 +13,7 @@ import { isCacheDirty, log, } from './common'; -import { decryptRepo, encryptRepo } from './privateRepo'; +import { decryptRepo } from './privateRepo'; import { calculateEstimate } from './prices'; export const downloadProtocolLandRepo = async ( @@ -143,7 +143,7 @@ export const uploadProtocolLandRepo = async ( const privateStateTxId = repo?.privateStateTxId; if (isPrivate && privateStateTxId) { - buffer = await encryptRepo(buffer, privateStateTxId); + throw new Error('Private repos are no longer supported.'); } const bufferSize = Buffer.byteLength(buffer);