Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Python/Node SDK Publish #516

Merged
merged 2 commits into from
May 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/cd-core.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
node-version: 18.15
- run: yarn --ignore-scripts
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- name: Change core version
uses: jossef/action-set-json-field@v2
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/cd-node-basemodels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ jobs:
node-version: 18.15
- run: yarn --ignore-scripts
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- name: Change Package version
uses: jossef/action-set-json-field@v2
Expand Down
7 changes: 5 additions & 2 deletions .github/workflows/cd-node-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,18 @@ jobs:
node-version: 18.15
- run: yarn --ignore-scripts
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- name: Change Node.js SDK version
uses: jossef/action-set-json-field@v2
with:
file: ./packages/sdk/typescript/human-protocol-sdk/package.json
field: version
value: ${{ github.event.release.tag_name }}
- run: yarn build
name: Build SDK package
working-directory: ./packages/sdk/typescript/human-protocol-sdk
- uses: JS-DevTools/npm-publish@v1
name: Publish
with:
Expand Down
2 changes: 0 additions & 2 deletions .github/workflows/cd-python-basemodels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node
run: yarn --ignore-scripts
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
10 changes: 8 additions & 2 deletions .github/workflows/cd-python-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,14 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Install Node
run: yarn --ignore-scripts
- uses: actions/setup-node@v3 #Temporal until this gets fixed https://github.com/NomicFoundation/hardhat/issues/3877
with:
node-version: 18.15
- run: yarn --ignore-scripts
name: Install dependencies
- run: yarn build
name: Build core package
working-directory: ./packages/core
- name: Set up Python
uses: actions/setup-python@v2
with:
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/cd-subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ jobs:
name: Deploy Subgraph
environment: deploy-subgraph
needs: contracts-check
runs-on: ubuntu-latest
runs-on: ubuntu-latest
strategy:
matrix:
network:
Expand Down Expand Up @@ -69,9 +69,9 @@ jobs:
- run: yarn --ignore-scripts
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Install dependencies
- run: yarn compile
- run: yarn build
if: ${{steps.continue_check.outputs.stop != 'true'}}
name: Compile smart contracts
name: Build core package
working-directory: ./packages/core
- run: yarn global add @graphprotocol/graph-cli
if: ${{steps.continue_check.outputs.stop != 'true'}}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn lint
name: Run lint
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-escrow-dashboard.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn escrow-dashboard:test
name: Run escrow-dashboard test
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-faucet-server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn faucet-server:test
name: Run faucet-server test
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-fortune.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn fortune:test
name: Run fortune test
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-meta-code-verify.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn meta-code-verify:test
name: Run meta-code-verify test
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-node-basemodels.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn --ignore-scripts
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn basemodels:test
name: Run Node.js Base Models Test
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-node-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn --ignore-scripts
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn sdk:test
name: Run Node.js SDK test
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-python-sdk.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- name: Install Node
run: yarn --ignore-scripts
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- name: Set up Python 3.10
uses: actions/setup-python@v1
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/ci-test-subgraph.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ jobs:
node-version: 18.15
- run: npm install --global yarn && yarn --ignore-scripts
name: Install dependencies
- run: yarn compile
name: Compile smart contracts
- run: yarn build
name: Build core package
working-directory: ./packages/core
- run: yarn subgraph:test
name: Run subgraph test
2 changes: 1 addition & 1 deletion packages/apps/faucet-server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"lint": "eslint src",
"test": "concurrently -k -s first --hide 0 \"hardhat node --port 8549\" \"jest\"",
"start": "NODE_ENV=development ts-node src/index.ts",
"vercel-build": "yarn workspace @human-protocol/core compile"
"vercel-build": "yarn workspace @human-protocol/core build"
},
"author": "",
"license": "ISC",
Expand Down
1 change: 1 addition & 0 deletions packages/core/.eslintignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ artifacts/
cache/
coverage/
typechain-types/
dist/
18 changes: 16 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
"abis/**/*.json",
"artifacts/@openzeppelin/**/[^.]*.json",
"artifacts/contracts/**/[^.]*.json",
"typechain-types/**/*.ts"
"typechain-types/**/*.ts",
"dist/typechain-types"
],
"scripts": {
"clean": "hardhat clean && rm -rf abis cache artifacts typechain-types",
Expand All @@ -25,7 +26,10 @@
"lint:fix": "eslint . --fix",
"format:contracts": "prettier --write '**/*.sol'",
"format:scripts": "prettier --write '**/*.ts'",
"format": "yarn format:contracts && yarn format:scripts"
"format": "yarn format:contracts && yarn format:scripts",
"build": "npm run compile && tsc",
"prebuild": "rm -rf dist",
"prepublish": "npm run build"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -78,5 +82,15 @@
"prettier --write",
"eslint --fix"
]
},
"exports": {
"./abis/*": "./abis/*",
"./artifacts/*": "./artifacts/*",
"./typechain-types": {
"default": "./dist/typechain-types/index.js",
"require": "./dist/typechain-types/index.js",
"import": "./typechain-types/index.ts",
"types": "./dist/typechain-types/index.d.ts"
}
}
}
9 changes: 8 additions & 1 deletion packages/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
{
"extends": "../../tsconfig.json",
"compilerOptions": {
"baseUrl": "."
"baseUrl": ".",
"target": "ES2020",
"module": "commonjs",
"lib": ["ES2017", "ES7", "ES6"],
"declaration": true,
"outDir": "./dist",
"declarationMap": true,
"esModuleInterop": true
},
"include": ["./scripts", "./test", "./typechain-types"],
"files": ["./hardhat.config.ts"]
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/fortune/launcher/server/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,6 @@
"start": "NODE_ENV=development ts-node ./src/index.ts",
"test": "concurrently -k -s first --hide 0 \"hardhat node --port 8546\" \"sleep 5 && RPC_PORT=8546 yarn workspace @human-protocol/core deploy:local && RPC_PORT=8546 vitest run -u\"",
"lint": "eslint '**/*.ts'",
"vercel-build": "yarn workspace @human-protocol/core compile"
"vercel-build": "yarn workspace @human-protocol/core build"
}
}
2 changes: 1 addition & 1 deletion packages/examples/fortune/recording-oracle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"start:prod": "ts-node build/src/index.js",
"start": "NODE_ENV=development ts-node ./src/index.ts",
"test": "concurrently -k -s first --hide 0 \"hardhat node --port 8547\" \"sleep 10 && RPC_PORT=8547 yarn workspace @human-protocol/core deploy:local && RPC_PORT=8547 vitest run -u\"",
"vercel-build": "yarn workspace @human-protocol/core compile"
"vercel-build": "yarn workspace @human-protocol/core build"
},
"repository": {
"type": "git",
Expand Down
2 changes: 1 addition & 1 deletion packages/examples/fortune/reputation-oracle/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,6 @@
"start": "ts-node src/index.ts",
"test": "concurrently -k -s first --hide 0 \"hardhat node --port 8548\" \"jest\"",
"lint": "eslint '**/*.ts'",
"vercel-build": "yarn workspace @human-protocol/core compile"
"vercel-build": "yarn workspace @human-protocol/core build"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -628,6 +628,48 @@ def get_escrows_filtered(self, filter: EscrowFilter):

return [launched_escrows[i]["id"] for i in range(len(launched_escrows))]

def get_recording_oracle_address(self, escrow_address: str):
"""Gets the recording oracle address of the escrow.

Args:
escrow_address (str): Address of the escrow

Returns:
str: Recording oracle address

Raises:
EscrowClientError: If an error occurs while checking the parameters
"""

if not Web3.isAddress(escrow_address):
raise EscrowClientError(f"Invalid escrow address: {escrow_address}")

return (
self._get_escrow_contract(escrow_address).functions.recordingOracle().call()
)

def get_reputation_oracle_address(self, escrow_address: str):
"""Gets the reputation oracle address of the escrow.

Args:
escrow_address (str): Address of the escrow

Returns:
str: Reputation oracle address

Raises:
EscrowClientError: If an error occurs while checking the parameters
"""

if not Web3.isAddress(escrow_address):
raise EscrowClientError(f"Invalid escrow address: {escrow_address}")

return (
self._get_escrow_contract(escrow_address)
.functions.reputationOracle()
.call()
)

def _get_escrow_contract(self, address: str):
"""Returns the escrow contract instance.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,13 +162,11 @@ def download_files(self, files: List[str], bucket: str) -> List:
result_files = []
for file in files:
try:
response = self.client.get_object(
bucket_name=bucket, object_name=file)
response = self.client.get_object(bucket_name=bucket, object_name=file)
result_files.append(response.read())
except Exception as e:
if hasattr(e, "code") and str(e.code) == "NoSuchKey":
raise StorageFileNotFoundError(
"No object found - returning empty")
raise StorageFileNotFoundError("No object found - returning empty")
LOG.warning(
f"Reading the key {file} with S3 failed" f" because of: {str(e)}"
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,4 @@
set -eux

rm -rf artifacts
yarn workspace @human-protocol/core compile
cp -r ../../../core/artifacts .
4 changes: 2 additions & 2 deletions packages/sdk/python/human-protocol-sdk/setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,14 @@
description="A python library to launch escrow contracts to the HUMAN network.",
url="https://github.com/humanprotocol/human-protocol/packages/sdk/python/human-protocol-sdk",
include_package_data=True,
exclude_package_data={"contracts": ["*.dbg.json"]},
exclude_package_data={"artifacts": ["*.dbg.json"]},
zip_safe=True,
classifiers=[
"Intended Audience :: Developers",
"Operating System :: OS Independent",
"Programming Language :: Python",
],
packages=setuptools.find_packages() + ["contracts"],
packages=setuptools.find_packages() + ["artifacts"],
install_requires=[
"boto3",
"cryptography",
Expand Down
Loading