From 8cd9fd21a15703885f56b2223eded181a007aaf0 Mon Sep 17 00:00:00 2001 From: Chad Ostrowski <221614+chadoh@users.noreply.github.com> Date: Thu, 20 Jul 2023 14:40:51 -0400 Subject: [PATCH] build: directly generate js libs to node_modules Roll back https://github.com/stellar/soroban-example-dapp/pull/122, but keep `crowdfund-contract` and `abundance-token` in `optionalDependencies`. As I worked with the old version in earnest, iterating on a local copy of the CLI and generating new JS libs over and over, the two-step generate-to-.soroban, then install-to-node_modules wasn't working very well. Probably because the new library wasn't being added until the `postinstall` step, and the dependencies are optional. Generating directly to `node_modules` feels dirty, but it works consistently. At least in this version, you can still see the dependencies listed in the `optionalDependencies` section, so they're not quite as surprising/mysterious. --- .gitattributes | 1 + package-lock.json | 270 +++++++++++++++++++++++++++++++++++++++++----- package.json | 12 ++- 3 files changed, 253 insertions(+), 30 deletions(-) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 00000000..f3c54b5f --- /dev/null +++ b/.gitattributes @@ -0,0 +1 @@ +package-lock.json linguist-generated=true -diff diff --git a/package-lock.json b/package-lock.json index 7a80e2a9..c658686d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -11,16 +11,14 @@ "dependencies": { "@radix-ui/react-dialog": "1.0.2", "@stellar/freighter-api": "^1.5.1", - "abundance-token": "file:.soroban/abundance-token", "axios": "^0.27.2", "bigint-conversion": "^2.4.1", - "crowdfund-contract": "file:.soroban/crowdfund-contract", "humanize-duration": "^3.27.3", "moment": "^2.29.4", "next": "^13.4.4", "react": "^18.2.0", "react-dom": "^18.2.0", - "soroban-client": "0.9.2" + "soroban-client": "0.9.1" }, "devDependencies": { "@types/humanize-duration": "^3.27.1", @@ -34,10 +32,12 @@ "engines": { "node": ">=17", "npm": ">=8" + }, + "optionalDependencies": { + "abundance-token": "file:node_modules/abundance-token", + "crowdfund-contract": "file:node_modules/crowdfund-contract" } }, - ".soroban/abundance-token": {}, - ".soroban/crowdfund-contract": {}, "node_modules/@aashutoshrathi/word-wrap": { "version": "1.2.6", "resolved": "https://registry.npmjs.org/@aashutoshrathi/word-wrap/-/word-wrap-1.2.6.tgz", @@ -736,8 +736,63 @@ } }, "node_modules/abundance-token": { - "resolved": ".soroban/abundance-token", - "link": true + "version": "0.0.0", + "resolved": "file:node_modules/abundance-token", + "optional": true, + "dependencies": { + "@stellar/freighter-api": "1.5.1", + "buffer": "6.0.3", + "soroban-client": "0.9.2" + } + }, + "node_modules/abundance-token/node_modules/axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "optional": true, + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/abundance-token/node_modules/soroban-client": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.2.tgz", + "integrity": "sha512-PPQLvAQTF/y56ev9V9wdMze/K49u1Cj6F9rkiUlRy++wCpSAVjiRYG+duolYvjkzUFPon56xlgAc7tuP4EolWA==", + "optional": true, + "dependencies": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", + "es6-promise": "^4.2.4", + "eventsource": "^2.0.2", + "lodash": "^4.17.21", + "randombytes": "^2.1.0", + "stellar-base": "10.0.0-soroban.4", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "node_modules/abundance-token/node_modules/stellar-base": { + "version": "10.0.0-soroban.4", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.4.tgz", + "integrity": "sha512-Afl2Mlh+aXokIHhy2x67Df5ofbss83oAOHV7pHLI0fsPlxAgs7YtbClzkNxvpnXyxQI77PMIWFJbT17Y3dR/+A==", + "optional": true, + "dependencies": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "crc": "^4.3.2", + "crypto-browserify": "^3.12.0", + "js-xdr": "^3.0.0", + "sha.js": "^2.3.6", + "tweetnacl": "^1.0.3" + }, + "optionalDependencies": { + "sodium-native": "^4.0.1" + } }, "node_modules/acorn": { "version": "8.10.0", @@ -1393,8 +1448,63 @@ } }, "node_modules/crowdfund-contract": { - "resolved": ".soroban/crowdfund-contract", - "link": true + "version": "0.0.0", + "resolved": "file:node_modules/crowdfund-contract", + "optional": true, + "dependencies": { + "@stellar/freighter-api": "1.5.1", + "buffer": "6.0.3", + "soroban-client": "0.9.2" + } + }, + "node_modules/crowdfund-contract/node_modules/axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "optional": true, + "dependencies": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "node_modules/crowdfund-contract/node_modules/soroban-client": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.2.tgz", + "integrity": "sha512-PPQLvAQTF/y56ev9V9wdMze/K49u1Cj6F9rkiUlRy++wCpSAVjiRYG+duolYvjkzUFPon56xlgAc7tuP4EolWA==", + "optional": true, + "dependencies": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", + "es6-promise": "^4.2.4", + "eventsource": "^2.0.2", + "lodash": "^4.17.21", + "randombytes": "^2.1.0", + "stellar-base": "10.0.0-soroban.4", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "node_modules/crowdfund-contract/node_modules/stellar-base": { + "version": "10.0.0-soroban.4", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.4.tgz", + "integrity": "sha512-Afl2Mlh+aXokIHhy2x67Df5ofbss83oAOHV7pHLI0fsPlxAgs7YtbClzkNxvpnXyxQI77PMIWFJbT17Y3dR/+A==", + "optional": true, + "dependencies": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "crc": "^4.3.2", + "crypto-browserify": "^3.12.0", + "js-xdr": "^3.0.0", + "sha.js": "^2.3.6", + "tweetnacl": "^1.0.3" + }, + "optionalDependencies": { + "sodium-native": "^4.0.1" + } }, "node_modules/crypto-browserify": { "version": "3.12.0", @@ -4388,9 +4498,9 @@ } }, "node_modules/soroban-client": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.2.tgz", - "integrity": "sha512-PPQLvAQTF/y56ev9V9wdMze/K49u1Cj6F9rkiUlRy++wCpSAVjiRYG+duolYvjkzUFPon56xlgAc7tuP4EolWA==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.1.tgz", + "integrity": "sha512-wAxu8Z15vBirjizdGG5BnUtZDtf/+ul37q84xHqUUHS7t7sL8CBeTdM6bFYmlEVLjpfFtAhdB/yJBQU7Bo4kBQ==", "dependencies": { "axios": "^1.4.0", "bignumber.js": "^9.1.1", @@ -4400,7 +4510,7 @@ "eventsource": "^2.0.2", "lodash": "^4.17.21", "randombytes": "^2.1.0", - "stellar-base": "10.0.0-soroban.4", + "stellar-base": "10.0.0-soroban.3", "toml": "^3.0.0", "urijs": "^1.19.1" } @@ -4424,9 +4534,9 @@ } }, "node_modules/stellar-base": { - "version": "10.0.0-soroban.4", - "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.4.tgz", - "integrity": "sha512-Afl2Mlh+aXokIHhy2x67Df5ofbss83oAOHV7pHLI0fsPlxAgs7YtbClzkNxvpnXyxQI77PMIWFJbT17Y3dR/+A==", + "version": "10.0.0-soroban.3", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.3.tgz", + "integrity": "sha512-XixwHHggxuWHQYY2CiVIzXLCGwaphS6pKF1GFyTC4QNIouR7IRWn/fzbXkYmzIbJTq6gM4mORO3kaLwl4bd7yA==", "dependencies": { "base32.js": "^0.1.0", "bignumber.js": "^9.1.1", @@ -5466,7 +5576,62 @@ } }, "abundance-token": { - "version": "file:.soroban/abundance-token" + "version": "0.0.0", + "optional": true, + "requires": { + "@stellar/freighter-api": "1.5.1", + "buffer": "6.0.3", + "soroban-client": "0.9.2" + }, + "dependencies": { + "axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "optional": true, + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "soroban-client": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.2.tgz", + "integrity": "sha512-PPQLvAQTF/y56ev9V9wdMze/K49u1Cj6F9rkiUlRy++wCpSAVjiRYG+duolYvjkzUFPon56xlgAc7tuP4EolWA==", + "optional": true, + "requires": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", + "es6-promise": "^4.2.4", + "eventsource": "^2.0.2", + "lodash": "^4.17.21", + "randombytes": "^2.1.0", + "stellar-base": "10.0.0-soroban.4", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "stellar-base": { + "version": "10.0.0-soroban.4", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.4.tgz", + "integrity": "sha512-Afl2Mlh+aXokIHhy2x67Df5ofbss83oAOHV7pHLI0fsPlxAgs7YtbClzkNxvpnXyxQI77PMIWFJbT17Y3dR/+A==", + "optional": true, + "requires": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "crc": "^4.3.2", + "crypto-browserify": "^3.12.0", + "js-xdr": "^3.0.0", + "sha.js": "^2.3.6", + "sodium-native": "^4.0.1", + "tweetnacl": "^1.0.3" + } + } + } }, "acorn": { "version": "8.10.0", @@ -5966,7 +6131,62 @@ } }, "crowdfund-contract": { - "version": "file:.soroban/crowdfund-contract" + "version": "0.0.0", + "optional": true, + "requires": { + "@stellar/freighter-api": "1.5.1", + "buffer": "6.0.3", + "soroban-client": "0.9.2" + }, + "dependencies": { + "axios": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.4.0.tgz", + "integrity": "sha512-S4XCWMEmzvo64T9GfvQDOXgYRDJ/wsSZc7Jvdgx5u1sd0JwsuPLqb3SYmusag+edF6ziyMensPVqLTSc1PiSEA==", + "optional": true, + "requires": { + "follow-redirects": "^1.15.0", + "form-data": "^4.0.0", + "proxy-from-env": "^1.1.0" + } + }, + "soroban-client": { + "version": "0.9.2", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.2.tgz", + "integrity": "sha512-PPQLvAQTF/y56ev9V9wdMze/K49u1Cj6F9rkiUlRy++wCpSAVjiRYG+duolYvjkzUFPon56xlgAc7tuP4EolWA==", + "optional": true, + "requires": { + "axios": "^1.4.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "detect-node": "^2.0.4", + "es6-promise": "^4.2.4", + "eventsource": "^2.0.2", + "lodash": "^4.17.21", + "randombytes": "^2.1.0", + "stellar-base": "10.0.0-soroban.4", + "toml": "^3.0.0", + "urijs": "^1.19.1" + } + }, + "stellar-base": { + "version": "10.0.0-soroban.4", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.4.tgz", + "integrity": "sha512-Afl2Mlh+aXokIHhy2x67Df5ofbss83oAOHV7pHLI0fsPlxAgs7YtbClzkNxvpnXyxQI77PMIWFJbT17Y3dR/+A==", + "optional": true, + "requires": { + "base32.js": "^0.1.0", + "bignumber.js": "^9.1.1", + "buffer": "^6.0.3", + "crc": "^4.3.2", + "crypto-browserify": "^3.12.0", + "js-xdr": "^3.0.0", + "sha.js": "^2.3.6", + "sodium-native": "^4.0.1", + "tweetnacl": "^1.0.3" + } + } + } }, "crypto-browserify": { "version": "3.12.0", @@ -8112,9 +8332,9 @@ } }, "soroban-client": { - "version": "0.9.2", - "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.2.tgz", - "integrity": "sha512-PPQLvAQTF/y56ev9V9wdMze/K49u1Cj6F9rkiUlRy++wCpSAVjiRYG+duolYvjkzUFPon56xlgAc7tuP4EolWA==", + "version": "0.9.1", + "resolved": "https://registry.npmjs.org/soroban-client/-/soroban-client-0.9.1.tgz", + "integrity": "sha512-wAxu8Z15vBirjizdGG5BnUtZDtf/+ul37q84xHqUUHS7t7sL8CBeTdM6bFYmlEVLjpfFtAhdB/yJBQU7Bo4kBQ==", "requires": { "axios": "^1.4.0", "bignumber.js": "^9.1.1", @@ -8124,7 +8344,7 @@ "eventsource": "^2.0.2", "lodash": "^4.17.21", "randombytes": "^2.1.0", - "stellar-base": "10.0.0-soroban.4", + "stellar-base": "10.0.0-soroban.3", "toml": "^3.0.0", "urijs": "^1.19.1" }, @@ -8147,9 +8367,9 @@ "integrity": "sha512-R0XvVJ9WusLiqTCEiGCmICCMplcCkIwwR11mOSD9CR5u+IXYdiseeEuXCVAjS54zqwkLcPNnmU4OeJ6tUrWhDw==" }, "stellar-base": { - "version": "10.0.0-soroban.4", - "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.4.tgz", - "integrity": "sha512-Afl2Mlh+aXokIHhy2x67Df5ofbss83oAOHV7pHLI0fsPlxAgs7YtbClzkNxvpnXyxQI77PMIWFJbT17Y3dR/+A==", + "version": "10.0.0-soroban.3", + "resolved": "https://registry.npmjs.org/stellar-base/-/stellar-base-10.0.0-soroban.3.tgz", + "integrity": "sha512-XixwHHggxuWHQYY2CiVIzXLCGwaphS6pKF1GFyTC4QNIouR7IRWn/fzbXkYmzIbJTq6gM4mORO3kaLwl4bd7yA==", "requires": { "base32.js": "^0.1.0", "bignumber.js": "^9.1.1", diff --git a/package.json b/package.json index 735a2931..e4ed5102 100644 --- a/package.json +++ b/package.json @@ -8,9 +8,9 @@ "start": "next start", "lint": "next lint", "setup": "./initialize.sh ${NETWORK:-futurenet} && npm install", - "clean": "rm -rf .next .soroban .soroban-example-dapp node_modules", + "clean": "rm -rf .next .soroban .soroban-example-dapp", "reset": "npm run clean && npm run setup", - "postinstall": "rm -rf ./.soroban/crowdfund-contract && rm -rf ./.soroban/abundance-token && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --rpc-url $(cat ./.soroban-example-dapp/rpc-url) --network-passphrase \"$(cat ./.soroban-example-dapp/passphrase)\" --output-dir ./.soroban/crowdfund-contract --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --rpc-url $(cat ./.soroban-example-dapp/rpc-url) --network-passphrase \"$(cat ./.soroban-example-dapp/passphrase)\" --output-dir ./.soroban/abundance-token --contract-name abundance-token" + "postinstall": "cargo build --target wasm32-unknown-unknown --release && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/soroban_crowdfund_contract.wasm --id $(cat ./.soroban-example-dapp/crowdfund_id) --output-dir ./node_modules/crowdfund-contract --network $(cat ./.soroban-example-dapp/network) --contract-name crowdfund-contract && ./target/bin/soroban contract bindings typescript --wasm ./target/wasm32-unknown-unknown/release/abundance_token.wasm --id $(cat ./.soroban-example-dapp/abundance_token_id) --output-dir ./node_modules/abundance-token --network $(cat ./.soroban-example-dapp/network) --contract-name abundance-token" }, "dependencies": { "@radix-ui/react-dialog": "1.0.2", @@ -22,9 +22,7 @@ "next": "^13.4.4", "react": "^18.2.0", "react-dom": "^18.2.0", - "soroban-client": "0.9.2", - "crowdfund-contract": "file:.soroban/crowdfund-contract", - "abundance-token": "file:.soroban/abundance-token" + "soroban-client": "0.9.1" }, "devDependencies": { "@types/humanize-duration": "^3.27.1", @@ -35,6 +33,10 @@ "eslint-config-next": "^13.3.1", "typescript": "5.1.3" }, + "optionalDependencies": { + "crowdfund-contract": "file:node_modules/crowdfund-contract", + "abundance-token": "file:node_modules/abundance-token" + }, "engines": { "node": ">=17", "npm": ">=8"