From 2897983af182cff00ea541b00884edb3832b5a17 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Wed, 13 Mar 2024 11:31:07 +0300 Subject: [PATCH 01/24] Use host machine chain --- README.md | 5 +++-- docker-compose.yml | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index fa43b51..8ec272d 100644 --- a/README.md +++ b/README.md @@ -28,6 +28,7 @@ The IDOS extension requires two configuration variables: `ETH_RPC_URL` and `NEAR export ETH_RPC_URL=xxx export NEAR_RPC_URL=xxx ``` +By default ETH_RPC_URL is `http://127.0.0.1:8545/`. If you want to connect th chain run in your host machine, i.e. hardhat running locally in development environment, you should use `http://host.docker.internal:8545/` instead to access host machine port from the container. ### Initialization @@ -50,7 +51,7 @@ action get_credential ($id) public { $can_access = grants_eth.has_grants(@caller, $id); SELECT CASE WHEN $can_access != 1 THEN ERROR('caller does not have access') END; - + SELECT content FROM credentials WHERE id = $id; @@ -69,7 +70,7 @@ interface IKwilWhitelist { string dataId; uint256 lockedUntil; } - + function grants_for(address grantee, string dataId) public view returns(Grant[] memory) diff --git a/docker-compose.yml b/docker-compose.yml index 3958991..1791ce3 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -6,7 +6,7 @@ services: ports: - 50055:50055 environment: - - ETH_RPC_URL= + - ETH_RPC_URL=http://host.docker.internal:8545/ - NEAR_RPC_URL= - PORT=50055 restart: on-failure From 55c6aaf7e01c6cb39e6b3167520aa45947a3c2f7 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Wed, 13 Mar 2024 11:32:07 +0300 Subject: [PATCH 02/24] Add hex_to_base58 function --- go/extension/extension.go | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/go/extension/extension.go b/go/extension/extension.go index 4a4ad85..7ab28b8 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -2,6 +2,7 @@ package extension import ( "context" + "encoding/hex" "errors" "fmt" "log" @@ -10,6 +11,8 @@ import ( "github.com/kwilteam/kwil-extensions/server" "github.com/kwilteam/kwil-extensions/types" + + "github.com/mr-tron/base58" ) const ( @@ -63,6 +66,7 @@ func (e *FractalExt) BuildServer(logger *log.Logger) (*server.ExtensionServer, e map[string]server.MethodFunc{ "get_block_height": server.WithOutputsCheck(e.BlockHeight, 1), "has_grants": server.WithInputsCheck(server.WithOutputsCheck(e.GrantsFor, 1), 2), + "hex_to_base58": server.WithInputsCheck(server.WithOutputsCheck(e.HexToBase58, 1), 1), }). Build() } @@ -141,6 +145,20 @@ func (e *FractalExt) GrantsFor(ctx *types.ExecutionContext, values ...*types.Sca return encodeScalarValues(exist) } +func (e *FractalExt) HexToBase58(ctx *types.ExecutionContext, values ...*types.ScalarValue) ([]*types.ScalarValue, error) { + inputHex, err := values[0].String() + if err != nil { + return nil, fmt.Errorf("convert value to string failed: %w", err) + } + fmt.Println(inputHex) + binaryString, _ := hex.DecodeString(inputHex) + base58 := base58.Encode(binaryString) + public_key := fmt.Sprintf("ed25519:%s", base58) + fmt.Println(public_key) + + return encodeScalarValues(public_key) +} + // initialize checks that the meta data includes all required fields and applies // any default values. func initialize(ctx context.Context, metadata map[string]string) (map[string]string, error) { From b7f494a36e7500e3fd9eea328a0c548fcba4afa8 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Wed, 13 Mar 2024 11:58:02 +0300 Subject: [PATCH 03/24] Push idos-extension image to ecr --- .github/workflows/deploy.yml | 120 ++++++++++++++++++++++++ .github/workflows/review_and_deploy.yml | 82 ++++++++++++++++ 2 files changed, 202 insertions(+) create mode 100644 .github/workflows/deploy.yml create mode 100644 .github/workflows/review_and_deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml new file mode 100644 index 0000000..2b6d148 --- /dev/null +++ b/.github/workflows/deploy.yml @@ -0,0 +1,120 @@ +name: "Deploy" + +on: + workflow_call: + inputs: + AWS_REGION: + required: true + type: string + ENVIRONMENT: + required: true + type: string + PRODUCT: + required: true + type: string + PROJECT: + required: true + type: string + secrets: + AWS_ACCESS_KEY_ID: + required: true + AWS_SECRET_ACCESS_KEY: + required: true + SLACK_BOT_TOKEN: + required: true + DOCKER_HUB_USERNAME: + required: true + DOCKER_HUB_PASSWORD: + required: true + +jobs: + deploy: + name: "Publish image" + runs-on: ubuntu-latest + timeout-minutes: 15 + steps: + - uses: actions/checkout@v4 + + - name: Notify slack deployment start + uses: trustfractal/github-action-slack-notify-build@v1.5.1 + id: slack + env: + SLACK_BOT_TOKEN: "${{secrets.SLACK_BOT_TOKEN}}" + with: + channel: id-deployments + status: STARTING + color: warning + custom_attachments: | + [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] + + - name: Configure AWS Credentials + uses: aws-actions/configure-aws-credentials@v1 + with: + mask-aws-account-id: false + aws-region: ${{inputs.AWS_REGION}} + aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}} + aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} + + - name: Log in to Docker Hub + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKER_HUB_USERNAME }} + password: ${{ secrets.DOCKER_HUB_PASSWORD }} + + - name: Login to Amazon ECR + id: login-ecr + uses: aws-actions/amazon-ecr-login@v1 + + - name: Build, tag, and push image to Amazon ECR + env: + ECR_REGISTRY: ${{steps.login-ecr.outputs.registry}} + ECR_REPOSITORY: "${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}}-${{inputs.PROJECT}}-idos-extension" + IMAGE_TAG: "${{steps.login-ecr.outputs.registry}}/${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}}-${{inputs.PROJECT}}-idos-extension:${{github.sha}}" + + run: | + docker build ./go \ + --file ./go/Dockerfile + --tag ${{env.IMAGE_TAG}} \ + --platform linux/amd64 + + docker tag "${{env.IMAGE_TAG}}" "${{env.ECR_REGISTRY}}/${{env.ECR_REPOSITORY}}:latest" + docker push "${{env.IMAGE_TAG}}" + docker push "${{env.ECR_REGISTRY}}/${{env.ECR_REPOSITORY}}:latest" + echo "::set-output name=image_tag::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" + + - name: Force new deployment + uses: trustfractal/aws-ecs-force-deployment@v1.0 + with: + cluster: ${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}} + tag_filters: | + { "Environment": ["${{inputs.ENVIRONMENT}}"], "Project": ["${{inputs.PROJECT}}"], "Product": ["${{inputs.PRODUCT}}"] } + + - name: Move deployment branch + run: | + git push -f origin HEAD:${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}}-${{inputs.PROJECT}}-latest + + - name: Notify slack success + if: success() + uses: trustfractal/github-action-slack-notify-build@v1.5.1 + env: + SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} + with: + message_id: ${{steps.slack.outputs.message_id}} + channel: id-deployments + status: SUCCESS + color: good + custom_attachments: | + [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] + + - name: Notify slack fail + if: failure() + uses: trustfractal/github-action-slack-notify-build@v1.5.1 + env: + SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} + with: + message_id: ${{steps.slack.outputs.message_id}} + channel: id-deployments + status: FAILED + color: danger + custom_attachments: | + [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] diff --git a/.github/workflows/review_and_deploy.yml b/.github/workflows/review_and_deploy.yml new file mode 100644 index 0000000..cd5b5b5 --- /dev/null +++ b/.github/workflows/review_and_deploy.yml @@ -0,0 +1,82 @@ +name: "Review and deploy" + +on: + pull_request: + push: + branches: + - master + - deploy_to_staging + - deploy_to_clients + - deploy_to_production + +concurrency: + group: ${{ github.head_ref || github.ref }} + cancel-in-progress: false + +jobs: + target_name: + runs-on: ubuntu-latest + + outputs: + name: ${{steps.branch_name.outputs.current_branch}} + + steps: + - uses: actions/checkout@v4 + + - name: Get branch name + id: branch_name + uses: tj-actions/branch-names@v7.0.7 + + staging: + uses: ./.github/workflows/deploy.yml + needs: + - target_name + if: ${{needs.target_name.outputs.name == 'master' || needs.target_name.outputs.name == 'deploy_to_staging'}} + with: + AWS_REGION: eu-west-1 + ENVIRONMENT: "staging" + PRODUCT: "idos" + PROJECT: "kwil" + + secrets: + AWS_ACCESS_KEY_ID: ${{secrets.STAGING_AWS_ACCESS_KEY_ID}} + AWS_SECRET_ACCESS_KEY: ${{secrets.STAGING_AWS_SECRET_ACCESS_KEY}} + SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} + DOCKER_HUB_USERNAME: ${{secrets.DOCKER_HUB_USERNAME}} + DOCKER_HUB_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} + + clients: + uses: ./.github/workflows/deploy.yml + needs: + - target_name + if: ${{false}} # Temporarily disabled + with: + AWS_REGION: eu-west-1 + ENVIRONMENT: "clients" + PRODUCT: "idos" + PROJECT: "kwil" + + secrets: + AWS_ACCESS_KEY_ID: ${{secrets.STAGING_AWS_ACCESS_KEY_ID}} + AWS_SECRET_ACCESS_KEY: ${{secrets.STAGING_AWS_SECRET_ACCESS_KEY}} + SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} + DOCKER_HUB_USERNAME: ${{secrets.DOCKER_HUB_USERNAME}} + DOCKER_HUB_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} + + production: + uses: ./.github/workflows/deploy.yml + needs: + - target_name + if: ${{false}} # Temporarily disabled + with: + AWS_REGION: eu-west-1 + ENVIRONMENT: "production" + PRODUCT: "idos" + PROJECT: "kwil" + + secrets: + AWS_ACCESS_KEY_ID: ${{secrets.PRODUCTION_AWS_ACCESS_KEY_ID}} + AWS_SECRET_ACCESS_KEY: ${{secrets.PRODUCTION_AWS_SECRET_ACCESS_KEY}} + SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} + DOCKER_HUB_USERNAME: ${{secrets.DOCKER_HUB_USERNAME}} + DOCKER_HUB_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} From 75f778038766edcd33e7dd79431d64314d23b091 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Wed, 13 Mar 2024 16:01:54 +0300 Subject: [PATCH 04/24] Disable import unexist module --- go/extension/chains/near/near_online_test.go | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/go/extension/chains/near/near_online_test.go b/go/extension/chains/near/near_online_test.go index 441d6db..11d46ce 100644 --- a/go/extension/chains/near/near_online_test.go +++ b/go/extension/chains/near/near_online_test.go @@ -8,8 +8,7 @@ import ( "context" "testing" "time" - - "github.com/kwilteam/extension-fractal-demo/extension/chains/near" + // "github.com/kwilteam/extension-fractal-demo/extension/chains/near" ) func TestBackend_Online(t *testing.T) { From 89dc53ac3bebafd6f01b768b36dd8b8b08bd11b0 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Wed, 13 Mar 2024 16:02:35 +0300 Subject: [PATCH 05/24] Update mod because of security vulnerability --- go/go.mod | 4 ++-- go/go.sum | 62 +++++++++++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 60 insertions(+), 6 deletions(-) diff --git a/go/go.mod b/go/go.mod index 029c8a8..d38413a 100644 --- a/go/go.mod +++ b/go/go.mod @@ -7,6 +7,7 @@ require ( github.com/eteu-technologies/near-api-go v0.0.2-0.20221130095932-ef78f2789388 github.com/ethereum/go-ethereum v1.12.0 github.com/kwilteam/kwil-extensions v0.0.0-20230727040522-1cfd930226b7 + github.com/mr-tron/base58 v1.2.0 ) require ( @@ -25,7 +26,6 @@ require ( github.com/gorilla/websocket v1.4.2 // indirect github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.5 // indirect github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c // indirect - github.com/mr-tron/base58 v1.2.0 // indirect github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/tklauser/go-sysconf v0.3.5 // indirect @@ -36,7 +36,7 @@ require ( golang.org/x/sys v0.10.0 // indirect golang.org/x/text v0.11.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230710151506-e685fd7b542b // indirect - google.golang.org/grpc v1.56.2 // indirect + google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.31.0 // indirect gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect ) diff --git a/go/go.sum b/go/go.sum index cfb8d6d..0f5274b 100644 --- a/go/go.sum +++ b/go/go.sum @@ -1,26 +1,39 @@ github.com/DataDog/zstd v1.5.2 h1:vUG4lAyuPCXO0TLbXvPv7EB7cNK1QV/luu55UHLrrn8= +github.com/DataDog/zstd v1.5.2/go.mod h1:g4AWEaM3yOg3HYfnJ3YIawPnVdXJh9QME85blwSAmyw= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6 h1:fLjPD/aNc3UIOA6tDi6QXUemppXK3P9BI7mr2hd6gx8= github.com/StackExchange/wmi v0.0.0-20180116203802-5d049714c4a6/go.mod h1:3eOhrUMpNV+6aFIbp5/iudMxNCF27Vw2OZgy4xEx0Fg= github.com/VictoriaMetrics/fastcache v1.6.0 h1:C/3Oi3EiBCqufydp1neRZkqcwmEiuRT9c3fqvvgKm5o= +github.com/VictoriaMetrics/fastcache v1.6.0/go.mod h1:0qHz5QP0GMX4pfmMA/zt5RgfNuXJrTP0zS7DqpHGGTw= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/btcsuite/btcd/btcec/v2 v2.2.0 h1:fzn1qaOt32TuLjFlkzYSsBC35Q3KUjT1SwPxiMSCF5k= github.com/btcsuite/btcd/btcec/v2 v2.2.0/go.mod h1:U7MHm051Al6XmscBQ0BoNydpOTsFAn707034b5nY8zU= github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1 h1:q0rUy8C/TYNBQS1+CGKw68tLOFYSNEs0TFnxxnS9+4U= +github.com/btcsuite/btcd/chaincfg/chainhash v1.0.1/go.mod h1:7SFka0XMvUgj3hfZtydOrQY2mwhPclbT2snogU7SQQc= github.com/caarlos0/env/v8 v8.0.0 h1:POhxHhSpuxrLMIdvTGARuZqR4Jjm8AYmoi/JKlcScs0= github.com/caarlos0/env/v8 v8.0.0/go.mod h1:7K4wMY9bH0esiXSSHlfHLX5xKGQMnkH5Fk4TDSSSzfo= github.com/cespare/cp v0.1.0 h1:SE+dxFebS7Iik5LK0tsi1k9ZCxEaFX4AjQmoyA+1dJk= +github.com/cespare/cp v0.1.0/go.mod h1:SOGHArjBr4JWaSDEVpWpo/hNg6RoKrls6Oh40hiwW+s= github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= +github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cockroachdb/errors v1.9.1 h1:yFVvsI0VxmRShfawbt/laCIDy/mtTqqnvoNgiy5bEV8= +github.com/cockroachdb/errors v1.9.1/go.mod h1:2sxOtL2WIc096WSZqZ5h8fa17rdDq9HZOZLBCor4mBk= github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b h1:r6VH0faHjZeQy818SGhaone5OnYfxFR/+AzdY3sf5aE= +github.com/cockroachdb/logtags v0.0.0-20230118201751-21c54148d20b/go.mod h1:Vz9DsVWQQhf3vs21MhPMZpMGSht7O/2vFW2xusFUVOs= github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811 h1:ytcWPaNPhNoGMWEhDvS3zToKcDpRsLuRolQJBVGdozk= +github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lgvnQ2+oGlE/EyZy4+2/CxRh9KfvCXnag1vtpxVM= github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= +github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/cpuguy83/go-md2man/v2 v2.0.2 h1:p1EgwI/C7NhT0JmVkwCD2ZBK8j4aeHQX2pMHHBfMQ6w= +github.com/cpuguy83/go-md2man/v2 v2.0.2/go.mod h1:tgQtvFlXSQOSOSIRvRPT7W67SCa46tRHOmNcaadrF8o= github.com/cstockton/go-conv v1.0.0 h1:zj/q/0MpQ/97XfiC9glWiohO8lhgR4TTnHYZifLTv6I= github.com/cstockton/go-conv v1.0.0/go.mod h1:HuiHkkRgOA0IoBNPC7ysG7kNpjDYlgM7Kj62yQPxjy4= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/deckarep/golang-set/v2 v2.1.0 h1:g47V4Or+DUdzbs8FxCCmgb6VYd+ptPAngjM6dtGktsI= github.com/deckarep/golang-set/v2 v2.1.0/go.mod h1:VAky9rY/yGXJOLEDv3OMci+7wtDpOF4IN+y82NBOac4= github.com/decred/dcrd/crypto/blake256 v1.0.0 h1:/8DMNYp9SGi5f0w7uCm6d6M4OU2rGFK09Y2A4Xv7EE0= +github.com/decred/dcrd/crypto/blake256 v1.0.0/go.mod h1:sQl2p6Y26YV+ZOcSTP6thNdn47hh8kt6rqSlvmrXFAc= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 h1:HbphB4TFFXpv7MNrT52FGrrgVXF1owhMVTHFZIlnvd4= github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0/go.mod h1:DZGJHZMqrU4JJqFAWUS2UO1+lbSKsdiOoYi9Zzey7Fc= github.com/eteu-technologies/borsh-go v0.3.2 h1:2c4H5yNtgzvgiYOZbN/DKE+iFjS6hK0QibEvw/5ELsI= @@ -33,24 +46,33 @@ github.com/eteu-technologies/near-api-go v0.0.2-0.20221130095932-ef78f2789388/go github.com/ethereum/go-ethereum v1.12.0 h1:bdnhLPtqETd4m3mS8BGMNvBTf36bO5bx/hxE2zljOa0= github.com/ethereum/go-ethereum v1.12.0/go.mod h1:/oo2X/dZLJjf2mJ6YT9wcWxa4nNJDBKDBU6sFIpx1Gs= github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5 h1:FtmdgXiUlNeRsoNMFlKLDt+S+6hbjVMEW6RGQ7aUf7c= +github.com/fjl/memsize v0.0.0-20190710130421-bcb5799ab5e5/go.mod h1:VvhXpOYNQvB+uIk2RvXzuaQtkQJzzIx6lSBe1xv7hi0= github.com/fsnotify/fsnotify v1.6.0 h1:n+5WquG0fcWoWp6xPWfHdbskMCQaFnG6PfBrh1Ky4HY= github.com/fsnotify/fsnotify v1.6.0/go.mod h1:sl3t1tCWJFWoRz9R8WJCbQihKKwmorjAbSClcnxKAGw= github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff h1:tY80oXqGNY4FhTFhk+o9oFHGINQ/+vhlm8HFzi6znCI= +github.com/gballet/go-libpcsclite v0.0.0-20190607065134-2772fd86a8ff/go.mod h1:x7DCsMOv1taUwEWCzT4cmDeAkigA5/QCwUodaVOe8Ww= github.com/getsentry/sentry-go v0.18.0 h1:MtBW5H9QgdcJabtZcuJG80BMOwaBpkRDZkxRkNC1sN0= +github.com/getsentry/sentry-go v0.18.0/go.mod h1:Kgon4Mby+FJ7ZWHFUAZgVaIa8sxHtnRJRLTXZr51aKQ= github.com/go-ole/go-ole v1.2.1 h1:2lOsA72HgjxAuMlKpFiCbHTvu44PIVkZ5hqm3RSdI/E= github.com/go-ole/go-ole v1.2.1/go.mod h1:7FAglXiTm7HKlQRDeOQ6ZNUHidzCWXuZWq/1dTyBNF8= github.com/go-stack/stack v1.8.1 h1:ntEHSVwIt7PNXNpgPmVfMrNhLtgjlmnZha2kOpuRiDw= github.com/go-stack/stack v1.8.1/go.mod h1:dcoOX6HbPZSZptuspn9bctJ+N/CnF5gGygcUP3XYfe4= github.com/gofrs/flock v0.8.1 h1:+gYjHKf32LDeiEEFhQaotPbLuUXjY5ZqxKgXy7n59aw= +github.com/gofrs/flock v0.8.1/go.mod h1:F1TvTiK9OcQqauNUHlbJvyl9Qa1QvF/gOUDKA14jxHU= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= +github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v4 v4.3.0 h1:kHL1vqdqWNfATmA0FNMdmZNMyZI1U6O31X4rlIPoBog= +github.com/golang-jwt/jwt/v4 v4.3.0/go.mod h1:/xlHOz8bRuivTWchD4jCa+NbatV+wEUSzwAxVc6locg= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb h1:PBC98N2aIaM3XXiurYmW7fx4GZkL8feAMVq7nEjURHk= +github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.2.0 h1:xRy4A+RhZaiKjJ1bPfwQ8sedCA+YS2YcCHW6ec7JMi0= +github.com/google/gofuzz v1.2.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/uuid v1.3.0 h1:t6JiXgmwXMjEs8VusXIJk2BXHsn+wx8BZdTaoZ5fu7I= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.4.2 h1:+/TMaTYc4QFitKJxsQ7Yye35DkWvkdLcvGKqM+x0Ufc= @@ -58,54 +80,83 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.5 h1:3IZOAnD058zZllQTZNBioTlrzrBG/IjpiZ133IEtusM= github.com/grpc-ecosystem/go-grpc-middleware/v2 v2.0.0-rc.5/go.mod h1:xbKERva94Pw2cPen0s79J3uXmGzbbpDYFBFDlZ4mV/w= github.com/hashicorp/go-bexpr v0.1.10 h1:9kuI5PFotCboP3dkDYFr/wi0gg0QVbSNz5oFRpxn4uE= +github.com/hashicorp/go-bexpr v0.1.10/go.mod h1:oxlubA2vC/gFVfX1A6JGp7ls7uCDlfJn732ehYYg+g0= github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao= +github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c h1:DZfsyhDK1hnSS5lH8l+JggqzEleHteTYfutAiVlSUM8= github.com/holiman/uint256 v1.2.2-0.20230321075855-87b91420868c/go.mod h1:SC8Ryt4n+UBbPbIBKaG9zbbDlp4jOru9xFZmPzLUTxw= github.com/huin/goupnp v1.0.3 h1:N8No57ls+MnjlB+JPiCVSOyy/ot7MJTqlo7rn+NYSqQ= +github.com/huin/goupnp v1.0.3/go.mod h1:ZxNlw5WqJj6wSsRK5+YfflQGXYfccj5VgQsMNixHM7Y= github.com/jackpal/go-nat-pmp v1.0.2 h1:KzKSgb7qkJvOUTqYl9/Hg/me3pWgBmERKrTGD7BdWus= +github.com/jackpal/go-nat-pmp v1.0.2/go.mod h1:QPH045xvCAeXUZOxsnwmrtiCoxIr9eob+4orBN1SBKc= github.com/klauspost/compress v1.15.15 h1:EF27CXIuDsYJ6mmvtBRlEuB2UVOqHG1tAXgZ7yIO+lw= +github.com/klauspost/compress v1.15.15/go.mod h1:ZcK2JAFqKOpnBlxcLsJzYfrS9X1akm9fHZNnD9+Vo/4= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= -github.com/kwilteam/kwil-extensions v0.0.0-20230710183301-88ce82f2d3af h1:hz5aDXiyBcux1rfNhBrdkIU5mBgsBBClDq/Apo35qxQ= -github.com/kwilteam/kwil-extensions v0.0.0-20230710183301-88ce82f2d3af/go.mod h1:+BrFrV+3qcdYIfptqjwatE5gT19azuRHJzw77wMPY8c= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kwilteam/kwil-extensions v0.0.0-20230727040522-1cfd930226b7 h1:YiPBu0pOeYOtOVfwKQqdWB07SUef9LvngF4bVFD+x34= github.com/kwilteam/kwil-extensions v0.0.0-20230727040522-1cfd930226b7/go.mod h1:+BrFrV+3qcdYIfptqjwatE5gT19azuRHJzw77wMPY8c= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-runewidth v0.0.9 h1:Lm995f3rfxdpd6TSmuVCHVb/QhupuXlYr8sCI/QdE+0= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/matttproud/golang_protobuf_extensions v1.0.4 h1:mmDVorXM7PCGKw94cs5zkfA9PSy5pEvNWRP0ET0TIVo= +github.com/matttproud/golang_protobuf_extensions v1.0.4/go.mod h1:BSXmuO+STAnVfrANrmjBb36TMTDstsz7MSK+HVaYKv4= github.com/mitchellh/mapstructure v1.4.1 h1:CpVNEelQCZBooIPDn+AR3NpivK/TIKU8bDxdASFVQag= +github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= github.com/mitchellh/pointerstructure v1.2.0 h1:O+i9nHnXS3l/9Wu7r4NrEdwA2VFTicjUEN1uBnDo34A= +github.com/mitchellh/pointerstructure v1.2.0/go.mod h1:BRAsLI5zgXmw97Lf6s25bs8ohIXc3tViBH44KcwB2g4= github.com/mr-tron/base58 v1.2.0 h1:T/HDJBh4ZCPbU39/+c3rRvE0uKBQlU27+QI8LJ4t64o= github.com/mr-tron/base58 v1.2.0/go.mod h1:BinMc/sQntlIE1frQmRFPUoPA1Zkr8VRgBdjWI2mNwc= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.14.0 h1:nJdhIvne2eSX/XRAFV9PcvFFRbrjbcTUj0VP62TMhnw= +github.com/prometheus/client_golang v1.14.0/go.mod h1:8vpkKitgIVNcqrRBWh1C4TIUQgYNtG/XQE4E/Zae36Y= github.com/prometheus/client_model v0.3.0 h1:UBgGFHqYdG/TPFD1B1ogZywDqEkwp3fBMvqdiQ7Xew4= +github.com/prometheus/client_model v0.3.0/go.mod h1:LDGWKZIo7rky3hgvBe+caln+Dr3dPggB5dvjtD7w9+w= github.com/prometheus/common v0.39.0 h1:oOyhkDq05hPZKItWVBkJ6g6AtGxi+fy7F4JvUV8uhsI= +github.com/prometheus/common v0.39.0/go.mod h1:6XBZ7lYdLCbkAVhwRsWTZn+IN5AB9F/NXd5w0BbEX0Y= github.com/prometheus/procfs v0.9.0 h1:wzCHvIvM5SxWqYvwgVL7yJY8Lz3PKn49KQtpgMYJfhI= +github.com/prometheus/procfs v0.9.0/go.mod h1:+pB4zwohETzFnmlpe6yd2lSc+0/46IYZRB/chUwxUZY= github.com/rogpeppe/go-internal v1.9.0 h1:73kH8U+JUqXU8lRuOHeVHaa/SZPifC7BkcraZVejAe8= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= github.com/rs/cors v1.7.0 h1:+88SsELBHx5r+hZ8TCkggzSstaWNbDvThkVK8H6f9ik= +github.com/rs/cors v1.7.0/go.mod h1:gFx+x8UowdsKA9AchylcLynDq+nNFfI8FkUZdN/jGCU= github.com/russross/blackfriday/v2 v2.1.0 h1:JIOH55/0cWyOuilr9/qlrm0BSXldqnqwMsf35Ld67mk= +github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible h1:Bn1aCHHRnjv4Bl16T8rcaFjYSrGrIZvpiGO6P3Q4GpU= github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shopspring/decimal v1.3.1 h1:2Usl1nmF/WZucqkFZhnfFYxxxu8LG21F6nPQBE5gKV8= github.com/shopspring/decimal v1.3.1/go.mod h1:DKyhrW/HYNuLGql+MJL6WCR6knT2jwCFRcu2hWCYk4o= github.com/status-im/keycard-go v0.2.0 h1:QDLFswOQu1r5jsycloeQh3bVU8n/NatHHaZobtDnDzA= +github.com/status-im/keycard-go v0.2.0/go.mod h1:wlp8ZLbsmrF6g6WjugPAx+IzoLrkdf9+mHxBEeo3Hbg= github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY= +github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo= github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7 h1:epCh84lMvA70Z7CTTCmYQn2CKbY8j86K7/FAIr141uY= +github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7/go.mod h1:q4W45IWZaF22tdD+VEXcAWRA037jwmWEB5VWYORlTpc= github.com/tklauser/go-sysconf v0.3.5 h1:uu3Xl4nkLzQfXNsWn15rPc/HQCJKObbt1dKJeWp3vU4= github.com/tklauser/go-sysconf v0.3.5/go.mod h1:MkWzOF4RMCshBAMXuhXJs64Rte09mITnppBXY/rYEFI= github.com/tklauser/numcpus v0.2.2 h1:oyhllyrScuYI6g+h/zUvNXNp1wy7x8qQy3t/piefldA= github.com/tklauser/numcpus v0.2.2/go.mod h1:x3qojaO3uyYt0i56EW/VUYs7uBvdl2fkfZFu0T9wgjM= github.com/tyler-smith/go-bip39 v1.1.0 h1:5eUemwrMargf3BSLRRCalXT93Ns6pQJIjYQN2nyfOP8= +github.com/tyler-smith/go-bip39 v1.1.0/go.mod h1:gUYDtqQw1JS3ZJ8UWVcGTGqqr6YIN3CWg+kkNaLt55U= github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bCzK15ozrqo2sZxkh0FHynJZOTVoV6Q= +github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= +github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg= +golang.org/x/exp v0.0.0-20230206171751-46f607a40771/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= golang.org/x/net v0.12.0/go.mod h1:zEVYFnQC7m/vmpQFELhcD1EWkZlX69l4oqgmer6hfKA= golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= @@ -117,16 +168,19 @@ golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= +golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/genproto/googleapis/rpc v0.0.0-20230710151506-e685fd7b542b h1:BC7Q0uXfp6VFXnNWp5RqATIN/viqCGkqBO8+HxzH/jY= google.golang.org/genproto/googleapis/rpc v0.0.0-20230710151506-e685fd7b542b/go.mod h1:TUfxEVdsvPg18p6AslUXFoLdpED4oBnGwyqk3dV1XzM= -google.golang.org/grpc v1.56.2 h1:fVRFRnXvU+x6C4IlHZewvJOVHoOv1TUuQyoRsYnB4bI= -google.golang.org/grpc v1.56.2/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= +google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.31.0 h1:g0LDEJHgrBl9N9r17Ru3sqWhkIx2NB67okBHPwC7hs8= google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= +gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce h1:+JknDZhAj8YMt7GC73Ei8pv4MzjDUNPHgQWJdtMAaDU= gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce/go.mod h1:5AcXVHNjg+BDxry382+8OKon8SEWiKktQR07RKPsv1c= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From 341ddd661bfc6cd2b3659b4640a7f0aef27e2bbd Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Wed, 13 Mar 2024 16:04:21 +0300 Subject: [PATCH 06/24] Update golang.org/x/crypto mod --- go/go.mod | 6 +++--- go/go.sum | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/go/go.mod b/go/go.mod index d38413a..d953272 100644 --- a/go/go.mod +++ b/go/go.mod @@ -30,11 +30,11 @@ require ( github.com/shopspring/decimal v1.3.1 // indirect github.com/tklauser/go-sysconf v0.3.5 // indirect github.com/tklauser/numcpus v0.2.2 // indirect - golang.org/x/crypto v0.11.0 // indirect + golang.org/x/crypto v0.17.0 // indirect golang.org/x/net v0.12.0 // indirect golang.org/x/sync v0.2.0 // indirect - golang.org/x/sys v0.10.0 // indirect - golang.org/x/text v0.11.0 // indirect + golang.org/x/sys v0.15.0 // indirect + golang.org/x/text v0.14.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230710151506-e685fd7b542b // indirect google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.31.0 // indirect diff --git a/go/go.sum b/go/go.sum index 0f5274b..29651e7 100644 --- a/go/go.sum +++ b/go/go.sum @@ -153,8 +153,8 @@ github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa h1:5SqCsI/2Qya2bC github.com/urfave/cli/v2 v2.17.2-0.20221006022127-8f469abc00aa/go.mod h1:1CNUng3PtjQMtRzJO4FMXBQvkGtuYRxxiR9xMa7jMwI= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673 h1:bAn7/zixMGCfxrRTfdpNzjtPYqr8smhKouy9mxVdGPU= github.com/xrash/smetrics v0.0.0-20201216005158-039620a65673/go.mod h1:N3UwUGtsrSj3ccvlPHLoLsHnpR27oXr4ZE984MbSER8= -golang.org/x/crypto v0.11.0 h1:6Ewdq3tDic1mg5xRO4milcWCfMVQhI4NkqWWvqejpuA= -golang.org/x/crypto v0.11.0/go.mod h1:xgJhtzW8F9jGdVFWZESrid1U1bjeNy4zgy5cRr/CIio= +golang.org/x/crypto v0.17.0 h1:r8bRNjWL3GshPW3gkd+RpvzWrZAwPS49OmTGZ/uhM4k= +golang.org/x/crypto v0.17.0/go.mod h1:gCAAfMLgwOJRpTjQ2zCCt2OcSfYMTeZVSRtQlPC7Nq4= golang.org/x/exp v0.0.0-20230206171751-46f607a40771 h1:xP7rWLUr1e1n2xkK5YB4LI0hPEy3LJC6Wk+D4pGlOJg= golang.org/x/exp v0.0.0-20230206171751-46f607a40771/go.mod h1:CxIveKay+FTh1D0yPZemJVgC/95VzuuOLq5Qi4xnoYc= golang.org/x/net v0.12.0 h1:cfawfvKITfUsFCeJIHJrbSxpeu/E81khclypR0GVT50= @@ -163,10 +163,10 @@ golang.org/x/sync v0.2.0 h1:PUR+T4wwASmuSTYdKjYHI5TD22Wy5ogLU5qZCOLxBrI= golang.org/x/sync v0.2.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20210316164454-77fc1eacc6aa/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220908164124-27713097b956/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.10.0 h1:SqMFp9UcQJZa+pmYuAKjd9xq1f0j5rLcDIk0mj4qAsA= -golang.org/x/sys v0.10.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/text v0.11.0 h1:LAntKIrcmeSKERyiOh0XMV39LXS8IE9UL2yP7+f5ij4= -golang.org/x/text v0.11.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= +golang.org/x/sys v0.15.0 h1:h48lPFYpsTvQJZF4EKyI4aLHaev3CxivZmv7yZig9pc= +golang.org/x/sys v0.15.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.14.0 h1:ScX5w1eTa3QqT8oi6+ziP7dTV1S2+ALU0bI+0zXKWiQ= +golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af h1:Yx9k8YCG3dvF87UAn2tu2HQLf2dt/eR1bXxpLMWeH+Y= golang.org/x/time v0.0.0-20220922220347-f3bd1da661af/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 1c188da5a1301e59d6ae7ff97deaf7a08541bec6 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Wed, 13 Mar 2024 18:16:14 +0300 Subject: [PATCH 07/24] Do not deploy to staging when merge to master --- .github/workflows/review_and_deploy.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/review_and_deploy.yml b/.github/workflows/review_and_deploy.yml index cd5b5b5..966e586 100644 --- a/.github/workflows/review_and_deploy.yml +++ b/.github/workflows/review_and_deploy.yml @@ -31,7 +31,7 @@ jobs: uses: ./.github/workflows/deploy.yml needs: - target_name - if: ${{needs.target_name.outputs.name == 'master' || needs.target_name.outputs.name == 'deploy_to_staging'}} + if: ${{needs.target_name.outputs.name == 'deploy_to_staging'}} with: AWS_REGION: eu-west-1 ENVIRONMENT: "staging" From ec83ba78501dcb8d57670f9b40bce62b91544323 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Thu, 14 Mar 2024 11:32:23 +0300 Subject: [PATCH 08/24] Temporary disable slack GH actions --- .github/workflows/deploy.yml | 70 ++++++++++++++++++------------------ 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 2b6d148..939fc12 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -35,17 +35,17 @@ jobs: steps: - uses: actions/checkout@v4 - - name: Notify slack deployment start - uses: trustfractal/github-action-slack-notify-build@v1.5.1 - id: slack - env: - SLACK_BOT_TOKEN: "${{secrets.SLACK_BOT_TOKEN}}" - with: - channel: id-deployments - status: STARTING - color: warning - custom_attachments: | - [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] + # - name: Notify slack deployment start + # uses: trustfractal/github-action-slack-notify-build@v1.5.1 + # id: slack + # env: + # SLACK_BOT_TOKEN: "${{secrets.SLACK_BOT_TOKEN}}" + # with: + # channel: id-deployments + # status: STARTING + # color: warning + # custom_attachments: | + # [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] - name: Configure AWS Credentials uses: aws-actions/configure-aws-credentials@v1 @@ -93,28 +93,28 @@ jobs: run: | git push -f origin HEAD:${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}}-${{inputs.PROJECT}}-latest - - name: Notify slack success - if: success() - uses: trustfractal/github-action-slack-notify-build@v1.5.1 - env: - SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} - with: - message_id: ${{steps.slack.outputs.message_id}} - channel: id-deployments - status: SUCCESS - color: good - custom_attachments: | - [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] + # - name: Notify slack success + # if: success() + # uses: trustfractal/github-action-slack-notify-build@v1.5.1 + # env: + # SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} + # with: + # message_id: ${{steps.slack.outputs.message_id}} + # channel: id-deployments + # status: SUCCESS + # color: good + # custom_attachments: | + # [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] - - name: Notify slack fail - if: failure() - uses: trustfractal/github-action-slack-notify-build@v1.5.1 - env: - SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} - with: - message_id: ${{steps.slack.outputs.message_id}} - channel: id-deployments - status: FAILED - color: danger - custom_attachments: | - [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] + # - name: Notify slack fail + # if: failure() + # uses: trustfractal/github-action-slack-notify-build@v1.5.1 + # env: + # SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} + # with: + # message_id: ${{steps.slack.outputs.message_id}} + # channel: id-deployments + # status: FAILED + # color: danger + # custom_attachments: | + # [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] From 6228bd5789ff85b386fe1acfe708410776c18c38 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Tue, 26 Mar 2024 17:26:18 +0300 Subject: [PATCH 09/24] Add determine_wallet_type method --- go/extension/extension.go | 37 +++++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 7ab28b8..5d947e5 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -6,6 +6,7 @@ import ( "errors" "fmt" "log" + "regexp" "github.com/idos-network/idos-extensions/extension/chains" @@ -64,9 +65,10 @@ func (e *FractalExt) BuildServer(logger *log.Logger) (*server.ExtensionServer, e }). WithMethods( map[string]server.MethodFunc{ - "get_block_height": server.WithOutputsCheck(e.BlockHeight, 1), - "has_grants": server.WithInputsCheck(server.WithOutputsCheck(e.GrantsFor, 1), 2), - "hex_to_base58": server.WithInputsCheck(server.WithOutputsCheck(e.HexToBase58, 1), 1), + "get_block_height": server.WithOutputsCheck(e.BlockHeight, 1), + "has_grants": server.WithInputsCheck(server.WithOutputsCheck(e.GrantsFor, 1), 2), + "hex_to_base58": server.WithInputsCheck(server.WithOutputsCheck(e.HexToBase58, 1), 1), + "determine_wallet_type": server.WithInputsCheck(server.WithOutputsCheck(e.DetermineWalletType, 1), 1), }). Build() } @@ -150,15 +152,38 @@ func (e *FractalExt) HexToBase58(ctx *types.ExecutionContext, values ...*types.S if err != nil { return nil, fmt.Errorf("convert value to string failed: %w", err) } - fmt.Println(inputHex) binaryString, _ := hex.DecodeString(inputHex) base58 := base58.Encode(binaryString) - public_key := fmt.Sprintf("ed25519:%s", base58) - fmt.Println(public_key) + var public_key string + if base58 == "" { + public_key = "" + } else { + public_key = fmt.Sprintf("ed25519:%s", base58) + } return encodeScalarValues(public_key) } +// This has very dumb logic: eth address returns EVM type, and NEAR returns otherwise. +// TODO: make the logic more detailed and return error is the address is neither EVM no NEAR. +func (e *FractalExt) DetermineWalletType(ctx *types.ExecutionContext, values ...*types.ScalarValue) ([]*types.ScalarValue, error) { + address, err := values[0].String() + if err != nil { + return nil, fmt.Errorf("convert value to string failed: %w", err) + } + re := regexp.MustCompile("^0x[0-9a-fA-F]{40}$") + var wallet_type string + if re.MatchString(address) { + wallet_type = "EVM" + } else { + wallet_type = "NEAR" + } + fmt.Println(address) + fmt.Println(wallet_type) + + return encodeScalarValues(wallet_type) +} + // initialize checks that the meta data includes all required fields and applies // any default values. func initialize(ctx context.Context, metadata map[string]string) (map[string]string, error) { From dbd84597e7af3159b6dee58f917e5bede7877437 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Thu, 28 Mar 2024 17:13:06 +0300 Subject: [PATCH 10/24] Remove GH Actions --- .github/workflows/deploy.yml | 120 ------------------------ .github/workflows/review_and_deploy.yml | 82 ---------------- 2 files changed, 202 deletions(-) delete mode 100644 .github/workflows/deploy.yml delete mode 100644 .github/workflows/review_and_deploy.yml diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml deleted file mode 100644 index 939fc12..0000000 --- a/.github/workflows/deploy.yml +++ /dev/null @@ -1,120 +0,0 @@ -name: "Deploy" - -on: - workflow_call: - inputs: - AWS_REGION: - required: true - type: string - ENVIRONMENT: - required: true - type: string - PRODUCT: - required: true - type: string - PROJECT: - required: true - type: string - secrets: - AWS_ACCESS_KEY_ID: - required: true - AWS_SECRET_ACCESS_KEY: - required: true - SLACK_BOT_TOKEN: - required: true - DOCKER_HUB_USERNAME: - required: true - DOCKER_HUB_PASSWORD: - required: true - -jobs: - deploy: - name: "Publish image" - runs-on: ubuntu-latest - timeout-minutes: 15 - steps: - - uses: actions/checkout@v4 - - # - name: Notify slack deployment start - # uses: trustfractal/github-action-slack-notify-build@v1.5.1 - # id: slack - # env: - # SLACK_BOT_TOKEN: "${{secrets.SLACK_BOT_TOKEN}}" - # with: - # channel: id-deployments - # status: STARTING - # color: warning - # custom_attachments: | - # [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] - - - name: Configure AWS Credentials - uses: aws-actions/configure-aws-credentials@v1 - with: - mask-aws-account-id: false - aws-region: ${{inputs.AWS_REGION}} - aws-access-key-id: ${{secrets.AWS_ACCESS_KEY_ID}} - aws-secret-access-key: ${{secrets.AWS_SECRET_ACCESS_KEY}} - - - name: Log in to Docker Hub - uses: docker/login-action@v3 - with: - username: ${{ secrets.DOCKER_HUB_USERNAME }} - password: ${{ secrets.DOCKER_HUB_PASSWORD }} - - - name: Login to Amazon ECR - id: login-ecr - uses: aws-actions/amazon-ecr-login@v1 - - - name: Build, tag, and push image to Amazon ECR - env: - ECR_REGISTRY: ${{steps.login-ecr.outputs.registry}} - ECR_REPOSITORY: "${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}}-${{inputs.PROJECT}}-idos-extension" - IMAGE_TAG: "${{steps.login-ecr.outputs.registry}}/${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}}-${{inputs.PROJECT}}-idos-extension:${{github.sha}}" - - run: | - docker build ./go \ - --file ./go/Dockerfile - --tag ${{env.IMAGE_TAG}} \ - --platform linux/amd64 - - docker tag "${{env.IMAGE_TAG}}" "${{env.ECR_REGISTRY}}/${{env.ECR_REPOSITORY}}:latest" - docker push "${{env.IMAGE_TAG}}" - docker push "${{env.ECR_REGISTRY}}/${{env.ECR_REPOSITORY}}:latest" - echo "::set-output name=image_tag::$ECR_REGISTRY/$ECR_REPOSITORY:$IMAGE_TAG" - - - name: Force new deployment - uses: trustfractal/aws-ecs-force-deployment@v1.0 - with: - cluster: ${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}} - tag_filters: | - { "Environment": ["${{inputs.ENVIRONMENT}}"], "Project": ["${{inputs.PROJECT}}"], "Product": ["${{inputs.PRODUCT}}"] } - - - name: Move deployment branch - run: | - git push -f origin HEAD:${{inputs.ENVIRONMENT}}-${{inputs.PRODUCT}}-${{inputs.PROJECT}}-latest - - # - name: Notify slack success - # if: success() - # uses: trustfractal/github-action-slack-notify-build@v1.5.1 - # env: - # SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} - # with: - # message_id: ${{steps.slack.outputs.message_id}} - # channel: id-deployments - # status: SUCCESS - # color: good - # custom_attachments: | - # [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] - - # - name: Notify slack fail - # if: failure() - # uses: trustfractal/github-action-slack-notify-build@v1.5.1 - # env: - # SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} - # with: - # message_id: ${{steps.slack.outputs.message_id}} - # channel: id-deployments - # status: FAILED - # color: danger - # custom_attachments: | - # [{ "title": "Environment", "value": "${{inputs.ENVIRONMENT}}", "short": true }] diff --git a/.github/workflows/review_and_deploy.yml b/.github/workflows/review_and_deploy.yml deleted file mode 100644 index 966e586..0000000 --- a/.github/workflows/review_and_deploy.yml +++ /dev/null @@ -1,82 +0,0 @@ -name: "Review and deploy" - -on: - pull_request: - push: - branches: - - master - - deploy_to_staging - - deploy_to_clients - - deploy_to_production - -concurrency: - group: ${{ github.head_ref || github.ref }} - cancel-in-progress: false - -jobs: - target_name: - runs-on: ubuntu-latest - - outputs: - name: ${{steps.branch_name.outputs.current_branch}} - - steps: - - uses: actions/checkout@v4 - - - name: Get branch name - id: branch_name - uses: tj-actions/branch-names@v7.0.7 - - staging: - uses: ./.github/workflows/deploy.yml - needs: - - target_name - if: ${{needs.target_name.outputs.name == 'deploy_to_staging'}} - with: - AWS_REGION: eu-west-1 - ENVIRONMENT: "staging" - PRODUCT: "idos" - PROJECT: "kwil" - - secrets: - AWS_ACCESS_KEY_ID: ${{secrets.STAGING_AWS_ACCESS_KEY_ID}} - AWS_SECRET_ACCESS_KEY: ${{secrets.STAGING_AWS_SECRET_ACCESS_KEY}} - SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} - DOCKER_HUB_USERNAME: ${{secrets.DOCKER_HUB_USERNAME}} - DOCKER_HUB_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} - - clients: - uses: ./.github/workflows/deploy.yml - needs: - - target_name - if: ${{false}} # Temporarily disabled - with: - AWS_REGION: eu-west-1 - ENVIRONMENT: "clients" - PRODUCT: "idos" - PROJECT: "kwil" - - secrets: - AWS_ACCESS_KEY_ID: ${{secrets.STAGING_AWS_ACCESS_KEY_ID}} - AWS_SECRET_ACCESS_KEY: ${{secrets.STAGING_AWS_SECRET_ACCESS_KEY}} - SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} - DOCKER_HUB_USERNAME: ${{secrets.DOCKER_HUB_USERNAME}} - DOCKER_HUB_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} - - production: - uses: ./.github/workflows/deploy.yml - needs: - - target_name - if: ${{false}} # Temporarily disabled - with: - AWS_REGION: eu-west-1 - ENVIRONMENT: "production" - PRODUCT: "idos" - PROJECT: "kwil" - - secrets: - AWS_ACCESS_KEY_ID: ${{secrets.PRODUCTION_AWS_ACCESS_KEY_ID}} - AWS_SECRET_ACCESS_KEY: ${{secrets.PRODUCTION_AWS_SECRET_ACCESS_KEY}} - SLACK_BOT_TOKEN: ${{secrets.SLACK_BOT_TOKEN}} - DOCKER_HUB_USERNAME: ${{secrets.DOCKER_HUB_USERNAME}} - DOCKER_HUB_PASSWORD: ${{secrets.DOCKER_HUB_PASSWORD}} From dbee3379824452be51a3cd7d1dcf53b4b87f55cf Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Thu, 28 Mar 2024 17:13:22 +0300 Subject: [PATCH 11/24] Clean extension code from debug --- go/extension/extension.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 5d947e5..25e1c4a 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -178,8 +178,6 @@ func (e *FractalExt) DetermineWalletType(ctx *types.ExecutionContext, values ... } else { wallet_type = "NEAR" } - fmt.Println(address) - fmt.Println(wallet_type) return encodeScalarValues(wallet_type) } From d1c4aa435e532627476c6e96b034e47bb4d0a25f Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Thu, 28 Mar 2024 17:17:20 +0300 Subject: [PATCH 12/24] Removed because no more repo the file uses --- go/extension/chains/near/near_online_test.go | 49 -------------------- 1 file changed, 49 deletions(-) delete mode 100644 go/extension/chains/near/near_online_test.go diff --git a/go/extension/chains/near/near_online_test.go b/go/extension/chains/near/near_online_test.go deleted file mode 100644 index 11d46ce..0000000 --- a/go/extension/chains/near/near_online_test.go +++ /dev/null @@ -1,49 +0,0 @@ -//go:build online - -package near_test - -// NOTE: go test -v -tags online - -import ( - "context" - "testing" - "time" - // "github.com/kwilteam/extension-fractal-demo/extension/chains/near" -) - -func TestBackend_Online(t *testing.T) { - be, err := near.New("https://rpc.testnet.near.org") - if err != nil { - t.Fatal(err) - } - - ctx, cancel := context.WithTimeout(context.Background(), 20*time.Second) - defer cancel() - - height, err := be.Height(ctx) - if err != nil { - t.Fatal(err) - } - t.Logf("Height: %d", height) - - // jsonArgs := `{"account_id": "linear-protocol.near"}` - // argsB64 := base64.StdEncoding.EncodeToString([]byte(jsonArgs)) - // callRes, err := be.cl.ContractViewCallFunction(ctx, "nodeasy.poolv1.near", - // "get_account_staked_balance", argsB64, block.FinalityFinal()) - - // Check the deployed (fake) registry contract at - // https://explorer.testnet.near.org/accounts/grants.jchappelow.testnet - // - // NOTE that this deployment always returns the same response from - // grants_from because I could not figure out how to ensure it was a - // read-only (view) method. Despite no `&mut self`, read-only RPC's always - // errored claiming "storage_write" was being used. Regardless, the method - // has the correct inputs/outputs so we can test an actual testnet RPC. - grants, err := be.GrantsFor(ctx, "grants.jchappelow.testnet", - "dummy.testnet", "whatever_data") - if err != nil { - t.Fatal(err) - } - t.Log("grants to \"dummy.testnet\" for data_id \"whaterver_data\" "+ - "on \"grants.jchappelow.testnet\"? ", len(grants) > 0) -} From 55dfb1d46bb0393d3dddfbd1cc2a686cfc1d77d7 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Thu, 28 Mar 2024 19:02:12 +0300 Subject: [PATCH 13/24] Update README.md Co-authored-by: Paulo Koch --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 8ec272d..8d8e122 100644 --- a/README.md +++ b/README.md @@ -28,7 +28,7 @@ The IDOS extension requires two configuration variables: `ETH_RPC_URL` and `NEAR export ETH_RPC_URL=xxx export NEAR_RPC_URL=xxx ``` -By default ETH_RPC_URL is `http://127.0.0.1:8545/`. If you want to connect th chain run in your host machine, i.e. hardhat running locally in development environment, you should use `http://host.docker.internal:8545/` instead to access host machine port from the container. +By default, `ETH_RPC_URL` is `http://127.0.0.1:8545/`. If you're using macOS and want to connect the chain running in your host machine (i.e. hardhat running locally in development environment), you should use `http://host.docker.internal:8545/` instead to access host machine port from the container. ### Initialization From 39f029dbc65bc0767fc6a13a4879a2ef8efac72e Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Fri, 29 Mar 2024 12:32:58 +0300 Subject: [PATCH 14/24] Update go/extension/extension.go Co-authored-by: Paulo Koch --- go/extension/extension.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 25e1c4a..82bb1a5 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -67,7 +67,7 @@ func (e *FractalExt) BuildServer(logger *log.Logger) (*server.ExtensionServer, e map[string]server.MethodFunc{ "get_block_height": server.WithOutputsCheck(e.BlockHeight, 1), "has_grants": server.WithInputsCheck(server.WithOutputsCheck(e.GrantsFor, 1), 2), - "hex_to_base58": server.WithInputsCheck(server.WithOutputsCheck(e.HexToBase58, 1), 1), + "implicit_address_to_public_key": server.WithInputsCheck(server.WithOutputsCheck(e.ImplicitAddressToPublicKey, 1), 1), "determine_wallet_type": server.WithInputsCheck(server.WithOutputsCheck(e.DetermineWalletType, 1), 1), }). Build() From 67dc7dd1651a58e788970d273d8b1eca6b0dccb0 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Fri, 29 Mar 2024 12:33:08 +0300 Subject: [PATCH 15/24] Update go/extension/extension.go Co-authored-by: Paulo Koch --- go/extension/extension.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 82bb1a5..3bf2e09 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -147,7 +147,7 @@ func (e *FractalExt) GrantsFor(ctx *types.ExecutionContext, values ...*types.Sca return encodeScalarValues(exist) } -func (e *FractalExt) HexToBase58(ctx *types.ExecutionContext, values ...*types.ScalarValue) ([]*types.ScalarValue, error) { +func (e *FractalExt) ImplicitAddressToPublicKey(ctx *types.ExecutionContext, values ...*types.ScalarValue) ([]*types.ScalarValue, error) { inputHex, err := values[0].String() if err != nil { return nil, fmt.Errorf("convert value to string failed: %w", err) From 65a92441452b9ca81317536656d83082a924cfef Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Mon, 1 Apr 2024 14:09:27 +0300 Subject: [PATCH 16/24] Align code --- go/extension/extension.go | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 3bf2e09..0ab40f3 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -65,10 +65,10 @@ func (e *FractalExt) BuildServer(logger *log.Logger) (*server.ExtensionServer, e }). WithMethods( map[string]server.MethodFunc{ - "get_block_height": server.WithOutputsCheck(e.BlockHeight, 1), - "has_grants": server.WithInputsCheck(server.WithOutputsCheck(e.GrantsFor, 1), 2), - "implicit_address_to_public_key": server.WithInputsCheck(server.WithOutputsCheck(e.ImplicitAddressToPublicKey, 1), 1), - "determine_wallet_type": server.WithInputsCheck(server.WithOutputsCheck(e.DetermineWalletType, 1), 1), + "get_block_height": server.WithOutputsCheck(e.BlockHeight, 1), + "has_grants": server.WithInputsCheck(server.WithOutputsCheck(e.GrantsFor, 1), 2), + "implicit_address_to_public_key": server.WithInputsCheck(server.WithOutputsCheck(e.ImplicitAddressToPublicKey, 1), 1), + "determine_wallet_type": server.WithInputsCheck(server.WithOutputsCheck(e.DetermineWalletType, 1), 1), }). Build() } From c69307211b64e42ac908dfcc9cdd551b3f115a52 Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Mon, 1 Apr 2024 16:04:25 +0100 Subject: [PATCH 17/24] Require the right length for NEAR implicit addresses --- go/extension/extension.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 0ab40f3..9fb3591 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -155,7 +155,7 @@ func (e *FractalExt) ImplicitAddressToPublicKey(ctx *types.ExecutionContext, val binaryString, _ := hex.DecodeString(inputHex) base58 := base58.Encode(binaryString) var public_key string - if base58 == "" { + if len(base58) != 64 || base58 == "" { public_key = "" } else { public_key = fmt.Sprintf("ed25519:%s", base58) From 0abf544d48d6c1d8c64561028d4c317f64a0ce02 Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Mon, 1 Apr 2024 16:07:30 +0100 Subject: [PATCH 18/24] Update go/extension/extension.go --- go/extension/extension.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 9fb3591..3542ca9 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -152,7 +152,10 @@ func (e *FractalExt) ImplicitAddressToPublicKey(ctx *types.ExecutionContext, val if err != nil { return nil, fmt.Errorf("convert value to string failed: %w", err) } - binaryString, _ := hex.DecodeString(inputHex) + binaryString, err := hex.DecodeString(inputHex) + if err != nil { + return nil, fmt.Errorf("can't hex-decode string: %w", err) + } base58 := base58.Encode(binaryString) var public_key string if len(base58) != 64 || base58 == "" { From a2138231192fd65b72765aa001bdf1b26cfb2914 Mon Sep 17 00:00:00 2001 From: Alexandr Kovalenko Date: Tue, 2 Apr 2024 14:28:12 +0300 Subject: [PATCH 19/24] Do not fail when hex convertion failes (for eth addresses). Check length of hex instead of base58. --- go/extension/extension.go | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index 3542ca9..d528c9d 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -152,13 +152,10 @@ func (e *FractalExt) ImplicitAddressToPublicKey(ctx *types.ExecutionContext, val if err != nil { return nil, fmt.Errorf("convert value to string failed: %w", err) } - binaryString, err := hex.DecodeString(inputHex) - if err != nil { - return nil, fmt.Errorf("can't hex-decode string: %w", err) - } + binaryString, _ := hex.DecodeString(inputHex) base58 := base58.Encode(binaryString) var public_key string - if len(base58) != 64 || base58 == "" { + if len(inputHex) != 64 || base58 == "" { public_key = "" } else { public_key = fmt.Sprintf("ed25519:%s", base58) From f7b1ec5a05196c1de4cfc336c16806cec2268dcc Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Mon, 8 Apr 2024 17:00:30 +0100 Subject: [PATCH 20/24] Add IsValidPublicKey --- go/extension/chains/ethereum/ethereum.go | 12 ++++++ go/extension/chains/ethereum/ethereum_test.go | 41 +++++++++++++++++++ go/extension/chains/interface.go | 1 + go/extension/chains/near/near.go | 22 ++++++++++ go/extension/chains/near/near_test.go | 35 ++++++++++++++++ go/extension/extension.go | 15 +++++++ 6 files changed, 126 insertions(+) create mode 100644 go/extension/chains/ethereum/ethereum_test.go diff --git a/go/extension/chains/ethereum/ethereum.go b/go/extension/chains/ethereum/ethereum.go index 4deebcd..f662aff 100644 --- a/go/extension/chains/ethereum/ethereum.go +++ b/go/extension/chains/ethereum/ethereum.go @@ -3,6 +3,7 @@ package ethereum import ( "context" "fmt" + "regexp" "github.com/idos-network/idos-extensions/extension/chains" "github.com/idos-network/idos-extensions/extension/chains/ethereum/registry" @@ -64,6 +65,17 @@ func (b *Backend) GrantsFor(ctx context.Context, contract, addr, resource string return grants, nil } +var publicKeyRegex = regexp.MustCompile("^(:?0x)?[0-9a-fA-F]{130}$") + +// Extracted this to be able to test without having to create an RPC connection. +func isValidPublicKey(publicKey string) bool { + return publicKeyRegex.MatchString(publicKey) +} + +func (b *Backend) IsValidPublicKey(publicKey string) bool { + return isValidPublicKey(publicKey) +} + type driver struct{} func (d *driver) New(url string) (chains.ChainBackend, error) { diff --git a/go/extension/chains/ethereum/ethereum_test.go b/go/extension/chains/ethereum/ethereum_test.go new file mode 100644 index 0000000..5538dd9 --- /dev/null +++ b/go/extension/chains/ethereum/ethereum_test.go @@ -0,0 +1,41 @@ +package ethereum + +import ( + "testing" +) + +func Test_isValidPublicKey(t *testing.T) { + tests := []struct { + publicKey string + want bool + }{ + { + "", + false, + }, + { + "some random string", + false, + }, + { + // Address; not a public key + "0x9E660ba85118b722147BBaf04ED697C95549dF03", + false, + }, + { + "0408cf359417716c8c4dd03ab0c3b243b383599cb05c1b276b326c92a8f4b2b4acdcbdd98e9443f8bfc370b40e80f677142dab8cffd348a22fdf4b68ab61c7d78f", + true, + }, + { + "0x0408cf359417716c8c4dd03ab0c3b243b383599cb05c1b276b326c92a8f4b2b4acdcbdd98e9443f8bfc370b40e80f677142dab8cffd348a22fdf4b68ab61c7d78f", + true, + }, + } + for _, tt := range tests { + t.Run(tt.publicKey, func(t *testing.T) { + if got := isValidPublicKey(tt.publicKey); got != tt.want { + t.Errorf("isValidPublicKey() = %v, want %v", got, tt.want) + } + }) + } +} diff --git a/go/extension/chains/interface.go b/go/extension/chains/interface.go index b65159b..34ef549 100644 --- a/go/extension/chains/interface.go +++ b/go/extension/chains/interface.go @@ -25,6 +25,7 @@ type GrantChecker interface { type ChainBackend interface { GrantChecker Height(context.Context) (uint64, error) + IsValidPublicKey(public_key string) bool // TODO: Close(), for ws connections } diff --git a/go/extension/chains/near/near.go b/go/extension/chains/near/near.go index 5561be5..b1d79ec 100644 --- a/go/extension/chains/near/near.go +++ b/go/extension/chains/near/near.go @@ -11,6 +11,7 @@ import ( "github.com/eteu-technologies/near-api-go/pkg/client" "github.com/eteu-technologies/near-api-go/pkg/client/block" "github.com/idos-network/idos-extensions/extension/chains" + "github.com/mr-tron/base58" ) // isNearAcct checks if the string is a valid near account name. This is either @@ -124,6 +125,27 @@ func (nb *Backend) GrantsFor(ctx context.Context, registry, acct, resource strin return grants, nil } +func isValidPublicKey(publicKey string) (bool, error) { + pieces := strings.SplitN(publicKey, ":", 2) + if len(pieces) != 2 { + return false, fmt.Errorf("unrecognized format for NEAR public key: %s", publicKey) + } + if pieces[0] != "ed25519" { + return false, fmt.Errorf("unsupported NEAR public key type: %s", pieces[0]) + } + + if _, err := base58.Decode(pieces[1]); err != nil { + return false, fmt.Errorf("unable to decode %s: %w", pieces[1], err) + } + + return true, nil +} + +func (b *Backend) IsValidPublicKey(publicKey string) bool { + result, _ := isValidPublicKey(publicKey) + return result +} + type driver struct{} func (d *driver) New(url string) (chains.ChainBackend, error) { diff --git a/go/extension/chains/near/near_test.go b/go/extension/chains/near/near_test.go index f501f20..7a4c18c 100644 --- a/go/extension/chains/near/near_test.go +++ b/go/extension/chains/near/near_test.go @@ -145,3 +145,38 @@ func Test_isNearAcct(t *testing.T) { }) } } + +func Test_isValidPublicKey(t *testing.T) { + tests := []struct { + publicKey string + want bool + }{ + { + "", + false, + }, + { + "blah.near", + false, + }, + { + "derp:herp", + false, + }, + { + "ed25519:INVALID", + false, + }, + { + "ed25519:7dLLbzqc6kgGAC6smmJUUh9xqxH9habnLhptauAymmUJ", + true, + }, + } + for _, tt := range tests { + t.Run(tt.publicKey, func(t *testing.T) { + if res, _ := isValidPublicKey(tt.publicKey); res != tt.want { + t.Errorf("isNearAcct() = %v, want %v", res, tt.want) + } + }) + } +} diff --git a/go/extension/extension.go b/go/extension/extension.go index d528c9d..cb64fd0 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -69,6 +69,7 @@ func (e *FractalExt) BuildServer(logger *log.Logger) (*server.ExtensionServer, e "has_grants": server.WithInputsCheck(server.WithOutputsCheck(e.GrantsFor, 1), 2), "implicit_address_to_public_key": server.WithInputsCheck(server.WithOutputsCheck(e.ImplicitAddressToPublicKey, 1), 1), "determine_wallet_type": server.WithInputsCheck(server.WithOutputsCheck(e.DetermineWalletType, 1), 1), + "is_valid_public_key": server.WithInputsCheck(server.WithOutputsCheck(e.IsValidPublicKey, 1), 1), }). Build() } @@ -164,6 +165,20 @@ func (e *FractalExt) ImplicitAddressToPublicKey(ctx *types.ExecutionContext, val return encodeScalarValues(public_key) } +func (e *FractalExt) IsValidPublicKey(ctx *types.ExecutionContext, values ...*types.ScalarValue) ([]*types.ScalarValue, error) { + be, _, err := e.chainBackend(ctx) + if err != nil { + return nil, err + } + + public_key, err := values[0].String() + if err != nil { + return nil, fmt.Errorf("convert value to string failed: %w", err) + } + + return encodeScalarValues(be.IsValidPublicKey(public_key)) +} + // This has very dumb logic: eth address returns EVM type, and NEAR returns otherwise. // TODO: make the logic more detailed and return error is the address is neither EVM no NEAR. func (e *FractalExt) DetermineWalletType(ctx *types.ExecutionContext, values ...*types.ScalarValue) ([]*types.ScalarValue, error) { From 20f22970cbc9d702847dd7505d6afb7e6ed30056 Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Mon, 8 Apr 2024 17:00:44 +0100 Subject: [PATCH 21/24] Ignore built binary --- .gitignore | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 46c444f..1ff8b74 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,5 @@ +go/idos-extensions + **/vue/node_modules **/vue/dist **/release/ @@ -41,4 +43,4 @@ dist/* .run # go -vendor/ \ No newline at end of file +vendor/ From d2682e232289a31b8b6c3f667ede8996b6bf4d7f Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Mon, 8 Apr 2024 20:51:06 +0100 Subject: [PATCH 22/24] Use a supported scalar value --- go/extension/extension.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/go/extension/extension.go b/go/extension/extension.go index cb64fd0..a6f408a 100644 --- a/go/extension/extension.go +++ b/go/extension/extension.go @@ -176,7 +176,13 @@ func (e *FractalExt) IsValidPublicKey(ctx *types.ExecutionContext, values ...*ty return nil, fmt.Errorf("convert value to string failed: %w", err) } - return encodeScalarValues(be.IsValidPublicKey(public_key)) + var result uint + if be.IsValidPublicKey(public_key) { + result = 1 + } else { + result = 0 + } + return encodeScalarValues(result) } // This has very dumb logic: eth address returns EVM type, and NEAR returns otherwise. From 1a1c8e11371ab05baf7d8a84c1899837c1f82a4c Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Mon, 8 Apr 2024 21:07:37 +0100 Subject: [PATCH 23/24] Check for payload size --- go/extension/chains/near/near.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/go/extension/chains/near/near.go b/go/extension/chains/near/near.go index b1d79ec..0f32022 100644 --- a/go/extension/chains/near/near.go +++ b/go/extension/chains/near/near.go @@ -125,6 +125,8 @@ func (nb *Backend) GrantsFor(ctx context.Context, registry, acct, resource strin return grants, nil } +const NEAR_KEY_LENGTH = 32 + func isValidPublicKey(publicKey string) (bool, error) { pieces := strings.SplitN(publicKey, ":", 2) if len(pieces) != 2 { @@ -134,10 +136,16 @@ func isValidPublicKey(publicKey string) (bool, error) { return false, fmt.Errorf("unsupported NEAR public key type: %s", pieces[0]) } - if _, err := base58.Decode(pieces[1]); err != nil { + binaryPayload, err := base58.Decode(pieces[1]) + if err != nil { return false, fmt.Errorf("unable to decode %s: %w", pieces[1], err) } + binaryPayloadLen := len(binaryPayload) + if binaryPayloadLen != NEAR_KEY_LENGTH { + return false, fmt.Errorf("wrong binary length: was expecting %d, got %d", NEAR_KEY_LENGTH, binaryPayloadLen) + } + return true, nil } From b3d61c3a688d71c7f69a85871683c2995a4cdbad Mon Sep 17 00:00:00 2001 From: Paulo Koch Date: Mon, 8 Apr 2024 21:59:22 +0100 Subject: [PATCH 24/24] Add test --- go/extension/chains/near/near_test.go | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/go/extension/chains/near/near_test.go b/go/extension/chains/near/near_test.go index 7a4c18c..ee58828 100644 --- a/go/extension/chains/near/near_test.go +++ b/go/extension/chains/near/near_test.go @@ -167,6 +167,10 @@ func Test_isValidPublicKey(t *testing.T) { "ed25519:INVALID", false, }, + { + "ed25519:7dLLbzqc6kgGAC6smmJUUh9xqxH9habnLhptauA", + false, + }, { "ed25519:7dLLbzqc6kgGAC6smmJUUh9xqxH9habnLhptauAymmUJ", true,