From a8f7854fb68bab4f8eb578d6ea67a84afafa3071 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 20 Mar 2024 12:41:11 +0545 Subject: [PATCH 1/8] refactor: Replace Warp with AO --- package.json | 5 +- pnpm-lock.yaml | 441 ++++--------------------- src/index.ts | 6 +- src/lib/{warpHelper.ts => aoHelper.ts} | 134 +++++--- src/lib/common.ts | 4 +- 5 files changed, 152 insertions(+), 438 deletions(-) rename src/lib/{warpHelper.ts => aoHelper.ts} (52%) diff --git a/package.json b/package.json index e117285..b3d3a3a 100644 --- a/package.json +++ b/package.json @@ -25,7 +25,6 @@ }, "files": [ "dist/", - "src/", "package.json", "README.md" ], @@ -36,14 +35,14 @@ "homepage": "https://github.com/labscommunity/protocol-land-sync#readme", "dependencies": { "@amplitude/analytics-node": "^1.3.4", + "@permaweb/aoconnect": "^0.0.48", "arbundles": "^0.9.11", "arseeding-js": "^0.0.30", "arweave": "^1.14.4", "dotenv": "^16.4.1", "everpay": "^1.2.2", "jszip": "^3.10.1", - "uuid": "^9.0.1", - "warp-contracts": "^1.4.33" + "uuid": "^9.0.1" }, "devDependencies": { "@changesets/cli": "^2.26.2", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 43fcf35..a15b043 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -11,6 +11,9 @@ 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.9.11 version: 0.9.11 @@ -32,9 +35,6 @@ dependencies: uuid: specifier: ^9.0.1 version: 9.0.1 - warp-contracts: - specifier: ^1.4.33 - version: 1.4.33 devDependencies: '@changesets/cli': @@ -814,8 +814,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 @@ -910,6 +910,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 @@ -1167,19 +1191,6 @@ packages: through: 2.3.8 dev: false - /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 - /acorn-walk@8.3.2: resolution: {integrity: sha512-cjkyv4OtNCIeqhHrfS81QWXoCBPExR/J62oyEqepVw8WaQeSqpW2uhuLPh1m9eWhDuOo/jUXVTlifvesOWp/4A==} engines: {node: '>=0.4.0'} @@ -1291,51 +1302,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: @@ -1489,16 +1455,6 @@ packages: - debug dev: false - /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.2 - dev: false - /arweave@1.14.4: resolution: {integrity: sha512-tmqU9fug8XAmFETYwgUhLaD3WKav5DaM4p1vgJpEj/Px2ORPPMikwnSySlFymmL2qgRh2ZBcZsg11+RXPPGLsA==} engines: {node: '>=16.15.0'} @@ -1518,16 +1474,6 @@ 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@3.2.5: - resolution: {integrity: sha512-baNZyqaaLhyLVKm/DlvdW051MSgO6b8eVfIezl9E5PqWxFgzLm/wQntEW4zOytVburDEr0JlALEpdOFwvErLsg==} - dev: false - /asynckit@0.4.0: resolution: {integrity: sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==} dev: false @@ -1590,10 +1536,6 @@ packages: bindings: 1.5.0 dev: false - /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 @@ -1609,14 +1551,6 @@ packages: file-uri-to-path: 1.0.0 dev: false - /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 @@ -1639,12 +1573,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'} @@ -1662,15 +1590,6 @@ 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 - /browserify-aes@1.2.0: resolution: {integrity: sha512-+7CHXqGuspUn/Sl5aO7Ea0xWGAtETPXNSAjHo48JfLdPWcMng33Xe4znFvQweqc/uzk5zSOI3H52CYnjCfb5hA==} dependencies: @@ -1727,33 +1646,10 @@ packages: 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-xor@1.0.3: resolution: {integrity: sha512-571s0T7nZWK6vB67HI5dyUF7wXiNcfaPPPTl6zYCNApANjIvYJTg7hlud/+cJpdAhS7dVzqMLmfhfHR3rAcOjQ==} 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: @@ -1805,11 +1701,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'} @@ -1858,18 +1749,6 @@ packages: safe-buffer: 5.2.1 dev: false - /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: @@ -1929,16 +1808,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==} @@ -1946,20 +1815,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 - /create-ecdh@4.0.4: resolution: {integrity: sha512-mf+TCx8wWc9VpuxfP2ht0iSISLZnt0JgWlrOKZiNqyUZWnjIaCIVNQArMHnCZKfEYRg6IM7A+NeJoN8gf/Ws0A==} dependencies: @@ -2070,7 +1925,6 @@ packages: optional: true dependencies: ms: 2.1.2 - dev: true /decamelize-keys@1.1.1: resolution: {integrity: sha512-WiPxgEirIV0/eIOMcnFBA3/IJZAZqKnwAwWyvvdi4lsr1WCN22nhdf/3db3DoZcUjTV2SqfzIwNyp6y2xs3nmg==} @@ -2176,12 +2030,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'} @@ -2363,11 +2211,6 @@ packages: resolution: {integrity: sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==} dev: false - /events@3.3.0: - resolution: {integrity: sha512-mQw+2fkQbALzQ7V0MY0IqdnXNOeTtP4r0lN9z7AAawCXgqea7bDii20AYrIBrFd/Hx0M2Ocz6S111CaFkUcb0Q==} - engines: {node: '>=0.8.x'} - dev: false - /everpay@0.6.7: resolution: {integrity: sha512-MC2/zDs/BAUYCvXQ5X2QVkUh1NsoOhXxgYpUUtLxffhrzkpeKZcwYHJ79YaSOdEME4RfB806fqNjnD76HKko5A==} dependencies: @@ -2451,10 +2294,6 @@ packages: engines: {node: '> 0.1.90'} dev: false - /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'} @@ -2539,10 +2378,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'} @@ -2585,10 +2420,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 @@ -2639,6 +2470,7 @@ packages: /glob@7.2.3: resolution: {integrity: sha512-nFR0zLpU2YCaRxwoCJvL6UvCH2JFyFVIvwTLsIf21AuHlMskA1hhTdk+LlYJtOlYt9v6dvszD2BGRqBL+iQK9Q==} + requiresBuild: true dependencies: fs.realpath: 1.0.0 inflight: 1.0.6 @@ -2674,6 +2506,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==} @@ -2771,6 +2604,10 @@ packages: ms: 2.1.3 dev: false + /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'} @@ -2855,11 +2692,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'} @@ -3115,41 +2947,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: @@ -3194,22 +2991,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 @@ -3218,14 +2999,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: @@ -3262,15 +3044,6 @@ packages: safe-buffer: 5.2.1 dev: false - /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'} @@ -3348,13 +3121,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'} @@ -3369,14 +3135,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 /ms@2.1.3: resolution: {integrity: sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==} @@ -3398,10 +3164,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 @@ -3446,6 +3208,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==} @@ -3478,6 +3241,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: @@ -3697,12 +3464,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 + /randombytes@2.1.0: resolution: {integrity: sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==} dependencies: @@ -3766,12 +3538,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'} @@ -3879,12 +3645,6 @@ packages: utf-8-validate: 5.0.10 dev: false - /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: @@ -3917,11 +3677,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==} @@ -4095,11 +3850,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: @@ -4218,17 +3968,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'} @@ -4472,11 +4211,11 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - /undici@5.27.2: - resolution: {integrity: sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==} + /undici@5.28.3: + resolution: {integrity: sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==} engines: {node: '>=14.0'} dependencies: - '@fastify/busboy': 2.1.0 + '@fastify/busboy': 2.1.1 dev: false /universalify@0.1.2: @@ -4484,13 +4223,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 - /utf-8-validate@5.0.10: resolution: {integrity: sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==} engines: {node: '>=6.14.2'} @@ -4523,10 +4255,6 @@ packages: hasBin: true dev: false - /uzip-module@1.0.3: - resolution: {integrity: sha512-AMqwWZaknLM77G+VPYNZLEruMGWGzyigPK3/Whg99B3S6vGHuqsyl5ZrOv1UUF3paGK1U6PM0cnayioaryg/fA==} - dev: false - /v8-compile-cache-lib@3.0.1: resolution: {integrity: sha512-wa7YjyUGfNZngI/vtK0UHAN+lgDCxBPCylVXGp0zu59Fz5aiGtNXaq3DhIov063MorB+VfufLh3JlF2KdTK3xg==} dev: false @@ -4552,56 +4280,12 @@ packages: warp-isomorphic: 1.0.7 dev: false - /warp-contracts@1.4.33: - resolution: {integrity: sha512-MYmjhfgvzYSD8OCxt2ZGyHfn90aHBzdjB3JmtkThYpzs0OFhIO+CAFue67v+gbIAP9TPBrMu4S8l9lL0dRXl2g==} - 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'} dependencies: buffer: 6.0.3 - 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 + undici: 5.28.3 dev: false /wcwidth@1.0.1: @@ -4820,13 +4504,8 @@ 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 github.com/Irys-xyz/avsc/a730cc8018b79e114b6a3381bbb57760a24c6cef: diff --git a/src/index.ts b/src/index.ts index 377970a..c3da55c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -1,10 +1,10 @@ #!/usr/bin/env node +import { v4 as uuidv4 } from 'uuid'; import { zipRepoJsZip } from './lib/zipHelper'; import { uploadRepo } from './lib/arweaveHelper'; -import { getRepos, postRepoToWarp } from './lib/warpHelper'; +import { getRepos, postRepo } from './lib/aoHelper'; import { exitWithError, getTags, getTitle } from './lib/common'; -import { v4 as uuidv4 } from 'uuid'; import { encryptRepo } from './lib/privateRepo'; // Set up constants @@ -56,7 +56,7 @@ async function main() { const dataTxId = await uploadRepo(zipBuffer, tags); - if (dataTxId) await postRepoToWarp(dataTxId, repoId, repoInfo); + if (dataTxId) await postRepo(dataTxId, repoId, repoInfo); } catch (error) { exitWithError(error as string); } diff --git a/src/lib/warpHelper.ts b/src/lib/aoHelper.ts similarity index 52% rename from src/lib/warpHelper.ts rename to src/lib/aoHelper.ts index 153aee0..2912e61 100644 --- a/src/lib/warpHelper.ts +++ b/src/lib/aoHelper.ts @@ -1,41 +1,85 @@ -import { WarpFactory, defaultCacheOptions } from 'warp-contracts'; import { + AOS_PROCESS_ID, getDescription, getTitle, getWallet, - getWarpContractTxId, waitFor, } from './common'; +import { + createDataItemSigner, + dryrun, + message, + result, +} from '@permaweb/aoconnect'; +import type { Tag } from 'arweave/node/lib/transaction'; import { getAddress } from './arweaveHelper'; import { trackAmplitudeAnalyticsEvent } from './analytics'; -const jwk = getWallet(); -const contractTxId = getWarpContractTxId(); const title = getTitle(); const description = getDescription(); -const getWarp = () => - WarpFactory.forMainnet({ - ...defaultCacheOptions, - inMemory: true, +type SendMessageArgs = { + data?: string; + tags: { + name: string; + value: string; + }[]; + anchor?: string; +}; + +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) { + const regex = /:\s*([^:!]+)!/; + const match = text.match(regex); + 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, }); -const contract = getWarp().contract(contractTxId).connect(jwk); + + if (Output?.data?.output) { + throw new Error(extractMessage(Output?.data?.output)); + } + + return messageId; +} export async function getRepos() { const address = await getAddress(); - await contract - .syncState('https://pl-cache.saikranthi.dev/contract') - .catch(() => {}); - - // let warp throw error if it can't retrieve the repositories - const response = await contract.viewState({ - function: 'getRepositoriesByOwner', - payload: { - owner: address, - }, + const { Messages } = await dryrun({ + process: AOS_PROCESS_ID, + tags: getTags({ + Action: 'Get-Repositories-By-Owner', + 'Owner-Address': address, + }), }); - return response.result as { + + if (Messages.length === 0) return []; + + return JSON.parse(Messages[0].Data)?.result as { id: string; name: string; private: boolean; @@ -43,7 +87,7 @@ export async function getRepos() { }[]; } -export async function postRepoToWarp( +export async function postRepo( dataTxId: string, repoId: string, repoInfo?: { id: string } | undefined @@ -101,54 +145,48 @@ export async function postRepoToWarp( } async function newRepo(repoId: string, dataTxId: string) { - if (!title || !dataTxId) throw '[ warp ] No title or dataTx for new repo'; - - // const contract = getWarp().contract(contractTxId).connect(jwk); + if (!title || !dataTxId) throw '[ AO ] No title or dataTx for new repo'; const uploadStrategy = process.env.STRATEGY === 'ARSEEDING' ? 'ARSEEDING' : 'DEFAULT'; - const payload = { - id: repoId, - name: title, - description, - dataTxId, - uploadStrategy, - }; - await waitFor(500); - // let warp throw error if it can't perform the writeInteraction - await contract.writeInteraction({ - function: 'initialize', - payload, + await sendMessage({ + tags: getTags({ + Action: 'Initialize-Repository', + id: repoId, + name: title, + description, + dataTxId, + uploadStrategy, + }), }); - console.log(`[ warp ] Repo '${title}' initialized with id '${repoId}'`); + console.log(`[ AO ] Repo '${title}' initialized with id '${repoId}'`); return { id: repoId }; } async function updateRepo(id: string, dataTxId: string) { if (!id || !title || !dataTxId) - throw '[ warp ] No id, title or dataTxId to update repo '; - - // const contract = getWarp().contract(contractTxId).connect(jwk); + throw '[ AO ] No id, title or dataTxId to update repo '; const uploadStrategy = process.env.STRATEGY === 'ARSEEDING' ? 'ARSEEDING' : 'DEFAULT'; - const payload = { id, name: title, description, dataTxId, uploadStrategy }; - await waitFor(500); - // let warp throw error if it can't perform the writeInteraction - await contract.writeInteraction({ - function: 'updateRepositoryTxId', - payload, + await sendMessage({ + tags: getTags({ + Action: 'Update-Repository-TxId', + id, + dataTxId, + uploadStrategy, + }), }); - console.log(`[ warp ] Repo '${title}' with id '${payload.id}' updated`); + console.log(`[ AO ] Repo '${title}' with id '${id}' updated`); - return { id: payload.id }; + return { id }; } diff --git a/src/lib/common.ts b/src/lib/common.ts index 41faced..c7ea951 100644 --- a/src/lib/common.ts +++ b/src/lib/common.ts @@ -7,6 +7,7 @@ import { config } from 'dotenv'; config(); const DESCRIPTION_PLACEHOLDER = 'Decentralized repo description'; +export const AOS_PROCESS_ID = 'Mj6eddWvVjxROVUvUoz-ysr0lrcb36b9hNgF5NKLoLw'; const isJwk = (obj: any): boolean => { if (typeof obj !== 'object') return false; @@ -26,9 +27,6 @@ export const getWallet = () => { throw new Error('Arweave wallet key not found or invalid'); }; -export const getWarpContractTxId = () => - 'w5ZU15Y2cLzZlu3jewauIlnzbKw-OAxbN9G5TbuuiDQ'; - export const getTitle = () => process.env.REPO_TITLE as string; export const getDescription = () => From 3208d34e8568f20ae74727ed17b4e6ab5a3d44d1 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 20 Mar 2024 15:27:54 +0545 Subject: [PATCH 2/8] refactor: Get repo by name and address --- src/index.ts | 11 +++-------- src/lib/aoHelper.ts | 17 ++++++++++++----- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/src/index.ts b/src/index.ts index c3da55c..59d34ba 100644 --- a/src/index.ts +++ b/src/index.ts @@ -3,7 +3,7 @@ import { v4 as uuidv4 } from 'uuid'; import { zipRepoJsZip } from './lib/zipHelper'; import { uploadRepo } from './lib/arweaveHelper'; -import { getRepos, postRepo } from './lib/aoHelper'; +import { getRepo, postRepo } from './lib/aoHelper'; import { exitWithError, getTags, getTitle } from './lib/common'; import { encryptRepo } from './lib/privateRepo'; @@ -25,13 +25,8 @@ async function main() { console.log(`[ PL Sync ] Starting sync for repo '${title}'`); - // get existing repos for this wallet - const repos = await getRepos(); - - // check if repo already exists - let repoInfo = repos.find( - (r) => r.name.toLowerCase() === title.toLowerCase() - ); + // get existing repo for this title & wallet + const repoInfo = await getRepo(title); const repoId = repoInfo?.id || uuidv4(); diff --git a/src/lib/aoHelper.ts b/src/lib/aoHelper.ts index 2912e61..5161f7f 100644 --- a/src/lib/aoHelper.ts +++ b/src/lib/aoHelper.ts @@ -66,25 +66,32 @@ async function sendMessage({ tags, data }: SendMessageArgs) { return messageId; } -export async function getRepos() { +export async function getRepo(name: string) { const address = await getAddress(); const { Messages } = await dryrun({ process: AOS_PROCESS_ID, tags: getTags({ - Action: 'Get-Repositories-By-Owner', - 'Owner-Address': address, + Action: 'Get-Repository-By-Name-Owner', + RepoName: name, + OwnerAddress: address, + Fields: JSON.stringify([ + 'id', + 'name', + 'private', + 'privateStateTxId', + ]), }), }); - if (Messages.length === 0) return []; + if (Messages.length === 0) return undefined; return JSON.parse(Messages[0].Data)?.result as { id: string; name: string; private: boolean; privateStateTxId: string; - }[]; + }; } export async function postRepo( From f43197149f4ef72d816b51c786e183b7dc14a667 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 20 Mar 2024 18:41:31 +0545 Subject: [PATCH 3/8] 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 5161f7f..4cec333 100644 --- a/src/lib/aoHelper.ts +++ b/src/lib/aoHelper.ts @@ -72,7 +72,7 @@ export async function getRepo(name: string) { const { Messages } = await dryrun({ process: AOS_PROCESS_ID, tags: getTags({ - Action: 'Get-Repository-By-Name-Owner', + Action: 'Get-Repo-By-Name-Owner', RepoName: name, OwnerAddress: address, Fields: JSON.stringify([ @@ -161,7 +161,7 @@ async function newRepo(repoId: string, dataTxId: string) { await sendMessage({ tags: getTags({ - Action: 'Initialize-Repository', + Action: 'Initialize-Repo', id: repoId, name: title, description, @@ -186,7 +186,7 @@ async function updateRepo(id: string, dataTxId: string) { await sendMessage({ tags: getTags({ - Action: 'Update-Repository-TxId', + Action: 'Update-Repo-TxId', id, dataTxId, uploadStrategy, From d4707e6346f77f92b2a18ee0e1418c54e06ad377 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 24 Apr 2024 16:17:00 +0545 Subject: [PATCH 4/8] refactor: Update tags --- src/lib/aoHelper.ts | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/lib/aoHelper.ts b/src/lib/aoHelper.ts index 4cec333..30956b4 100644 --- a/src/lib/aoHelper.ts +++ b/src/lib/aoHelper.ts @@ -73,8 +73,8 @@ export async function getRepo(name: string) { process: AOS_PROCESS_ID, tags: getTags({ Action: 'Get-Repo-By-Name-Owner', - RepoName: name, - OwnerAddress: address, + "Repo-Name": name, + "Owner-Address": address, Fields: JSON.stringify([ 'id', 'name', @@ -162,11 +162,11 @@ async function newRepo(repoId: string, dataTxId: string) { await sendMessage({ tags: getTags({ Action: 'Initialize-Repo', - id: repoId, - name: title, - description, - dataTxId, - uploadStrategy, + Id: repoId, + Name: title, + Description: description, + "Data-TxId": dataTxId, + "Upload-Strategy": uploadStrategy, }), }); @@ -187,9 +187,9 @@ async function updateRepo(id: string, dataTxId: string) { await sendMessage({ tags: getTags({ Action: 'Update-Repo-TxId', - id, - dataTxId, - uploadStrategy, + Id: id, + "Data-TxId": dataTxId, + "Upload-Strategy": uploadStrategy, }), }); From f4acf554708681cbcd19a8689186f6bb6a30982b Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 24 Apr 2024 16:39:53 +0545 Subject: [PATCH 5/8] fix: instanceof error --- package.json | 2 +- pnpm-lock.yaml | 27 ++++++++++++++------------- src/lib/privateRepo.ts | 2 +- 3 files changed, 16 insertions(+), 15 deletions(-) diff --git a/package.json b/package.json index b3d3a3a..c516199 100644 --- a/package.json +++ b/package.json @@ -35,7 +35,7 @@ "homepage": "https://github.com/labscommunity/protocol-land-sync#readme", "dependencies": { "@amplitude/analytics-node": "^1.3.4", - "@permaweb/aoconnect": "^0.0.48", + "@permaweb/aoconnect": "^0.0.52", "arbundles": "^0.9.11", "arseeding-js": "^0.0.30", "arweave": "^1.14.4", diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index a15b043..1bc3c9f 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -12,8 +12,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.9.11 version: 0.9.11 @@ -910,26 +910,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 @@ -4211,8 +4212,8 @@ packages: /undici-types@5.26.5: resolution: {integrity: sha512-JlCMO+ehdEIKqlFxk6IfVoAUVmgz7cU7zD/h9XZ0qzeosSHmUJVOzSQvvYSYWXkFXC+IfLKSIffhv0sVZup6pA==} - /undici@5.28.3: - resolution: {integrity: sha512-3ItfzbrhDlINjaP0duwnNsKpDQk3acHI3gVJ1z4fmwMK31k5G9OVIAMLSIaP6w4FaGkaAkN6zaQO9LUvZ1t7VA==} + /undici@5.28.4: + resolution: {integrity: sha512-72RFADWFqKmUb2hmmvNODKL3p9hcB6Gt2DOQMis1SEBaV6a4MH8soBvzg+95CYhCKPFedut2JY9bMfrDl9D23g==} engines: {node: '>=14.0'} dependencies: '@fastify/busboy': 2.1.1 @@ -4285,7 +4286,7 @@ packages: engines: {node: '>=16.8.0'} dependencies: buffer: 6.0.3 - undici: 5.28.3 + undici: 5.28.4 dev: false /wcwidth@1.0.1: @@ -4504,8 +4505,8 @@ 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 github.com/Irys-xyz/avsc/a730cc8018b79e114b6a3381bbb57760a24c6cef: diff --git a/src/lib/privateRepo.ts b/src/lib/privateRepo.ts index 7342f41..a59d3c0 100644 --- a/src/lib/privateRepo.ts +++ b/src/lib/privateRepo.ts @@ -25,7 +25,7 @@ async function encryptDataWithExistingKey( ) { let key = aesKey; - if (!(aesKey instanceof crypto.webcrypto.CryptoKey)) { + if (!(aesKey instanceof CryptoKey)) { key = await crypto.subtle.importKey( 'raw', aesKey, From 9721f2d275663bf9dab68c8ca35c9dd817152f67 Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 24 Apr 2024 17:59:59 +0545 Subject: [PATCH 6/8] 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 a59d3c0..4bd1330 100644 --- a/src/lib/privateRepo.ts +++ b/src/lib/privateRepo.ts @@ -1,6 +1,7 @@ import crypto from 'crypto'; import { getActivePublicKey } from './arweaveHelper'; import { getWallet, initArweave } from './common'; +import { isCryptoKey } from 'util/types'; type PrivateState = { iv: string; @@ -25,7 +26,7 @@ async function encryptDataWithExistingKey( ) { let key = aesKey; - if (!(aesKey instanceof CryptoKey)) { + if (!isCryptoKey(aesKey)) { key = await crypto.subtle.importKey( 'raw', aesKey, From 34d32345aa7df236e9fca111014fa6fd19de11ba Mon Sep 17 00:00:00 2001 From: Pawan Paudel Date: Wed, 24 Apr 2024 21:51:29 +0545 Subject: [PATCH 7/8] refactor: Add isCryptoKey function to check crypto key --- src/lib/privateRepo.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/lib/privateRepo.ts b/src/lib/privateRepo.ts index 4bd1330..0253911 100644 --- a/src/lib/privateRepo.ts +++ b/src/lib/privateRepo.ts @@ -1,7 +1,6 @@ import crypto from 'crypto'; import { getActivePublicKey } from './arweaveHelper'; import { getWallet, initArweave } from './common'; -import { isCryptoKey } from 'util/types'; type PrivateState = { iv: string; @@ -12,6 +11,14 @@ type PrivateState = { const arweave = initArweave(); +function isCryptoKey(obj: any) { + try { + 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 5e34d53d2067e9dd19bde73480923b2195873877 Mon Sep 17 00:00:00 2001 From: Sai Kranthi Date: Thu, 25 Jul 2024 18:35:39 +0530 Subject: [PATCH 8/8] refactor: remove support for private repos and update ao process id --- src/index.ts | 3 +-- src/lib/common.ts | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/index.ts b/src/index.ts index 59d34ba..6fb6d85 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,7 +5,6 @@ import { zipRepoJsZip } from './lib/zipHelper'; import { uploadRepo } from './lib/arweaveHelper'; import { getRepo, postRepo } from './lib/aoHelper'; import { exitWithError, getTags, getTitle } from './lib/common'; -import { encryptRepo } from './lib/privateRepo'; // Set up constants const PATH = '.'; @@ -46,7 +45,7 @@ async function main() { const privateStateTxId = repoInfo?.privateStateTxId; if (isPrivate && privateStateTxId) { - zipBuffer = await encryptRepo(zipBuffer, privateStateTxId); + throw new Error('Private repos are not supported.'); } const dataTxId = await uploadRepo(zipBuffer, tags); diff --git a/src/lib/common.ts b/src/lib/common.ts index c7ea951..1e91e81 100644 --- a/src/lib/common.ts +++ b/src/lib/common.ts @@ -7,7 +7,7 @@ import { config } from 'dotenv'; config(); const DESCRIPTION_PLACEHOLDER = 'Decentralized repo description'; -export const AOS_PROCESS_ID = 'Mj6eddWvVjxROVUvUoz-ysr0lrcb36b9hNgF5NKLoLw'; +export const AOS_PROCESS_ID = 'yJZ3_Yrc-qYRt1zHmY7YeNvpmQwuqyK3dT0-gxWftew'; const isJwk = (obj: any): boolean => { if (typeof obj !== 'object') return false;