-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[v0.2.0] ERC20 / ERC721 Support (#18)
* v0.1.1 Release Signed-off-by: hfuss <[email protected]> * latest DX Signed-off-by: hfuss <[email protected]> * latest token connector images Signed-off-by: hfuss <[email protected]> * debugging test failure, downgrading to 0.11.5 temporarily Signed-off-by: hfuss <[email protected]> * downgrading postgres chart Signed-off-by: hfuss <[email protected]> * started on migrating to erc20-erc721 support Signed-off-by: hfuss <[email protected]> * ethconnect contract registration refactored and more idempotent; ethconnect catchupmode support; migrating to new erc20-erc-721 connector Signed-off-by: hfuss <[email protected]> * ready for testing Signed-off-by: hfuss <[email protected]> * updated firefly.core Signed-off-by: hfuss <[email protected]> * fixing erc20-erc721 labels helper Signed-off-by: hfuss <[email protected]> * fixing erc20-erc721 image ref; ensuring erc20-erc721 templating is tested Signed-off-by: hfuss <[email protected]> * im not a js developer can you tell ;) Signed-off-by: hfuss <[email protected]> * shoulda used bash 😬 Signed-off-by: hfuss <[email protected]> * or not bitwise or; other fixes Signed-off-by: hfuss <[email protected]> * debugging script Signed-off-by: hfuss <[email protected]> * Fixing deploy-contracts job Signed-off-by: hfuss <[email protected]> * latest ethconnect Signed-off-by: hfuss <[email protected]> * catchupModeBlockGap Signed-off-by: hfuss <[email protected]> * debugging deploy contracts Signed-off-by: hfuss <[email protected]> * fixing contracts lookup in erc20-erc721 job; latest erc20-erc721; docs update Signed-off-by: hfuss <[email protected]> * fix lint Signed-off-by: hfuss <[email protected]> * renaming erc20erc721 values Signed-off-by: hfuss <[email protected]> * updating makefile Signed-off-by: hfuss <[email protected]> * debugging script Signed-off-by: hfuss <[email protected]> * script fixed with longer sleep Signed-off-by: hfuss <[email protected]>
- Loading branch information
1 parent
f1e9239
commit c534110
Showing
22 changed files
with
540 additions
and
183 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,7 +9,7 @@ clean: | |
kind delete cluster | ||
|
||
lint: | ||
helm template charts/firefly --set "erc20.enabled=true" --set "erc1155.enabled=true" --set "ethconnect.enabled=true" | ||
helm template charts/firefly --set "erc20erc721.enabled=true" --set "erc1155.enabled=true" --set "ethconnect.enabled=true" | ||
ct lint \ | ||
--target-branch=main \ | ||
--exclude-deprecated \ | ||
|
@@ -26,7 +26,7 @@ deps: | |
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts || true | ||
helm upgrade --install --set kubeStateMetrics.enabled=false --set nodeExporter.enabled=false --set grafana.enabled=false kube-prometheus prometheus-community/kube-prometheus-stack | ||
helm repo add bitnami https://charts.bitnami.com/bitnami || true | ||
helm upgrade --install --set postgresqlPassword=firef1y --set extraEnv[0].name=POSTGRES_DATABASE --set extraEnv[0].value=firefly postgresql bitnami/postgresql | ||
helm upgrade --install --set postgresqlPassword=firef1y --set extraEnv[0].name=POSTGRES_DATABASE --set extraEnv[0].value=firefly postgresql bitnami/postgresql --version 10.16.2 | ||
kubectl create secret generic custom-psql-config --dry-run --from-literal="url=postgres://postgres:[email protected]:5432/postgres?sslmode=disable" -o json | kubectl apply -f - | ||
|
||
starter: charts/firefly/local-values.yaml | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
129 changes: 129 additions & 0 deletions
129
charts/firefly/scripts/ff-deploy-erc20-erc721-contracts/index.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
'use strict'; | ||
|
||
// Copyright © 2022 Kaleido, Inc. | ||
// | ||
// SPDX-License-Identifier: Apache-2.0 | ||
// | ||
// Licensed under the Apache License, Version 2.0 (the "License"); | ||
// you may not use this file except in compliance with the License. | ||
// You may obtain a copy of the License at | ||
// | ||
// http://swww.apache.org/licenses/LICENSE-2.0 | ||
// | ||
// Unless required by applicable law or agreed to in writing, software | ||
// distributed under the License is distributed on an "AS IS" BASIS, | ||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
// See the License for the specific language governing permissions and | ||
// limitations under the License. | ||
|
||
const axios = require('axios'); | ||
|
||
const erc20ContractJson = require('/root/solidity/build/contracts/ERC20WithData.json'); | ||
const erc721ContractJson = require('/root/solidity/build/contracts/ERC721WithData.json'); | ||
|
||
const deployContracts = async () => { | ||
let FormData = require("form-data"); | ||
const ETHCONNECT_BASE_URL = process.env.ETHCONNECT_URL; | ||
const ETHCONNECT_PREFIX = process.env.ETHCONNECT_PREFIX || "firefly"; | ||
const ABIS_URI = process.env.ABIS_URI || "/abis"; | ||
const CONTRACTS_URI = process.env.CONTRACTS_URI || "/contracts"; | ||
|
||
// does not currently support using an address resolver to look up the wallet address i.e. must be in hex format | ||
const TOKENS_OWNER_KEY = process.env.TOKENS_OWNER_KEY; | ||
|
||
const ERC20_ENABLED = process.env.ERC20_ENABLED === "true"; | ||
const ERC20_TOKEN_NAME = process.env.ERC20_TOKEN_NAME; | ||
|
||
const ERC721_ENABLED = process.env.ERC721_ENABLED === "true"; | ||
const ERC721_TOKEN_NAME = process.env.ERC721_TOKEN_NAME; | ||
|
||
async function deployTokenContract(jsonLink, tokenName) { | ||
const abi = jsonLink.abi; | ||
const byteCode = jsonLink.bytecode; | ||
|
||
// POST /abis | ||
const bodyFormData = new FormData(); | ||
bodyFormData.append("abi", JSON.stringify(abi)); | ||
bodyFormData.append("bytecode", byteCode); | ||
console.log(`POST ${ETHCONNECT_BASE_URL}${ABIS_URI} with abi/bytecode form data`); | ||
const abiRes = await axios | ||
.post(`${ETHCONNECT_BASE_URL}${ABIS_URI}`, bodyFormData, { | ||
headers: bodyFormData.getHeaders(), | ||
}) | ||
.catch((err) => { | ||
throw `Error in POST ${ETHCONNECT_BASE_URL}${ABIS_URI} with form data. ${err}`; | ||
}); | ||
|
||
console.log("Sleeping 10s for sync..."); | ||
await new Promise((f) => setTimeout(f, 10000)); | ||
|
||
// POST /abis/<id> | ||
console.log(`POST ${ETHCONNECT_BASE_URL}${ABIS_URI}/${abiRes.data.id}`); | ||
const contractRes = await axios | ||
.post( | ||
`${ETHCONNECT_BASE_URL}${ABIS_URI}/${abiRes.data.id}`, | ||
JSON.stringify({ | ||
name: tokenName, | ||
symbol: tokenName, | ||
}), | ||
{ | ||
headers: { | ||
accept: "application/json", | ||
"Content-Type": "application/json", | ||
[`x-${ETHCONNECT_PREFIX}-from`]: TOKENS_OWNER_KEY, | ||
}, | ||
} | ||
) | ||
.catch((err) => { | ||
throw `Error in POST ${ETHCONNECT_BASE_URL}${ABIS_URI}/${abiRes.data.id}. ${err}`; | ||
}); | ||
|
||
console.log("Sleeping 10s for sync..."); | ||
await new Promise((f) => setTimeout(f, 10000)); | ||
|
||
console.log(`GET ${ETHCONNECT_BASE_URL}${CONTRACTS_URI}`); | ||
const contracts = await axios | ||
.get(`${ETHCONNECT_BASE_URL}${CONTRACTS_URI}`, { | ||
headers: { | ||
accept: "application/json", | ||
"Content-Type": "application/json", | ||
}, | ||
}) | ||
.catch((err) => { | ||
console.log(`Error in GET ${ETHCONNECT_BASE_URL}${CONTRACTS_URI}. ${err}`); | ||
}); | ||
|
||
const contract = contracts.data.filter(contract => contract.abi === abiRes.data.id)[0]; | ||
|
||
return { | ||
address: `0x${contract.address}`, | ||
abiId: abiRes.data.id | ||
}; | ||
} | ||
|
||
|
||
console.log("\n\n"); | ||
|
||
if (ERC20_ENABLED) { | ||
const erc20Contract = await deployTokenContract(erc20ContractJson, ERC20_TOKEN_NAME); | ||
console.log("ERC20"); | ||
console.log(`\tAddress: ${erc20Contract.address}`); | ||
console.log(`\tABI ID: ${erc20Contract.abiId}\n`); | ||
} | ||
|
||
if (ERC721_ENABLED) { | ||
const erc721Contract = await deployTokenContract(erc721ContractJson, ERC721_TOKEN_NAME); | ||
console.log("ERC721"); | ||
console.log(`\tAddress: ${erc721Contract.address}`); | ||
console.log(`\tABI ID: ${erc721Contract.abiId}\n`); | ||
} | ||
}; | ||
|
||
(async () => { | ||
try { | ||
await deployContracts(); | ||
} catch (e) { | ||
console.error(`Failed to deploy contracts due to: ${e}`); | ||
process.exit(1); | ||
} | ||
})(); |
16 changes: 16 additions & 0 deletions
16
charts/firefly/scripts/ff-deploy-erc20-erc721-contracts/package.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "ff-deploy-erc20-erc721-contracts", | ||
"version": "0.1.0", | ||
"description": "", | ||
"main": "index.js", | ||
"scripts": { | ||
"test": "echo \"Error: no test specified\" && exit 1" | ||
}, | ||
"private": true, | ||
"author": "", | ||
"license": "Apache-2.0", | ||
"dependencies": { | ||
"axios": "^0.25.0", | ||
"form-data": "^4.0.0" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
charts/firefly/templates/erc20erc721/configmap-deploy-scripts.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
{{/* | ||
Copyright © 2022 Kaleido, Inc. | ||
|
||
SPDX-License-Identifier: Apache-2.0 | ||
|
||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
|
||
http://swww.apache.org/licenses/LICENSE-2.0 | ||
|
||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/}} | ||
|
||
{{- if and .Values.erc20erc721.enabled .Values.erc20erc721.job.deployContracts.enabled }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "firefly.fullname" . }}-erc20-erc721-deploy-scripts | ||
labels: | ||
{{- include "firefly.erc20erc721Labels" . | nindent 4 }} | ||
data: | ||
{{ (.Files.Glob "scripts/ff-deploy-erc20-erc721-contracts/*").AsConfig | indent 2 }} | ||
{{- end }} |
Oops, something went wrong.