-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
189 additions
and
31 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 |
---|---|---|
@@ -0,0 +1,96 @@ | ||
#!/bin/bash | ||
|
||
# This script is used to download infinity wasm files from github | ||
# and generate the multisig store wasm message for deployment on mainnet. | ||
|
||
# Download royalty registry | ||
|
||
VERSION=v0.3.0 | ||
CONTRACT=stargaze_royalty_registry | ||
|
||
CORE_CONTRACTS=( | ||
"stargaze_royalty_registry" | ||
) | ||
|
||
for contract in "${CORE_CONTRACTS[@]}"; do | ||
contract_tmp=$(echo $contract | tr '_' '-') | ||
|
||
# If file exists then skip | ||
if [ -f "./artifacts/${contract}.wasm" ]; then | ||
echo "Skipping ${contract}.wasm" | ||
continue | ||
fi | ||
|
||
version=${VERSION} | ||
url=https://github.com/public-awesome/core/releases/download/${contract_tmp}/${version}/${contract}.wasm | ||
|
||
if [ -z "$version" ]; then | ||
echo "Version not found for $contract" | ||
exit 1 | ||
fi | ||
|
||
echo "Downloading $url" | ||
curl -L --output "./artifacts/${contract}.wasm" "${url}" | ||
done | ||
|
||
|
||
Download infinity contracts | ||
|
||
VERSION=v0.1.5 | ||
INFINITY_CONTRACTS=( | ||
"infinity_builder" | ||
"infinity_factory" | ||
"infinity_global" | ||
"infinity_index" | ||
"infinity_pair" | ||
"infinity_router" | ||
) | ||
|
||
for contract in "${INFINITY_CONTRACTS[@]}"; do | ||
contract_tmp=$(echo $contract | tr '_' '-') | ||
|
||
# If file exists then skip | ||
if [ -f "./artifacts/${contract}.wasm" ]; then | ||
echo "Skipping ${contract}.wasm" | ||
continue | ||
fi | ||
|
||
url=https://github.com/tasiov/infinity-swap/releases/download/${VERSION}/${contract}.wasm | ||
echo "Downloading $url" | ||
response_code=$(curl -L --output "./artifacts/${contract}.wasm" --write-out "%{http_code}" "${url}") | ||
|
||
# Check if the download was successful | ||
if [ "$response_code" -ne 200 ]; then | ||
echo "Error downloading ${contract}.wasm. HTTP status code: ${response_code}" | ||
rm "./artifacts/${contract}.wasm" | ||
exit 1 | ||
fi | ||
done | ||
|
||
echo "Generating wasm store messages for mainnet..." | ||
|
||
FROM="stars1jwgchjqltama8z0v0smpagmnpjkc8sw8r03xzq" | ||
CHAIN_ID="stargaze-1" | ||
NODE="https://rpc.stargaze-apis.com:443" | ||
|
||
for contract in "${CORE_CONTRACTS[@]}"; do | ||
starsd tx wasm store artifacts/${contract}.wasm \ | ||
--from $FROM \ | ||
--chain-id "$CHAIN_ID" \ | ||
--node "$NODE" \ | ||
--keyring-backend os \ | ||
--gas-prices 1ustars \ | ||
--generate-only \ | ||
> ./tmp/unsigned_store_${contract}.json 2>&1 | ||
done | ||
|
||
for contract in "${INFINITY_CONTRACTS[@]}"; do | ||
starsd tx wasm store artifacts/${contract}.wasm \ | ||
--from $FROM \ | ||
--chain-id "$CHAIN_ID" \ | ||
--node "$NODE" \ | ||
--keyring-backend os \ | ||
--gas-prices 1ustars \ | ||
--generate-only \ | ||
> ./tmp/unsigned_store_${contract}.json 2>&1 | ||
done |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
import fs from 'fs' | ||
import readline from 'readline' | ||
|
||
export const readChecksumFile = async (checksumFilePath: string, target: string): Promise<string> => { | ||
return new Promise((resolve, reject) => { | ||
const readInterface = readline.createInterface(fs.createReadStream(checksumFilePath)) | ||
|
||
readInterface.on('line', function (line) { | ||
const [checksum, fileName] = line.split(/\s+/) // Split by whitespace | ||
if (fileName === target) { | ||
readInterface.close() // Close the stream if the checksum is found | ||
resolve(checksum) | ||
} | ||
}) | ||
|
||
readInterface.on('close', function () { | ||
reject(`Checksum for ${target} not found.`) | ||
}) | ||
}) | ||
} |
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,10 @@ | ||
export const hexStringToUint8Array = (hexString: string) => { | ||
const length = hexString.length | ||
const uint8Array = new Uint8Array(length / 2) | ||
|
||
for (let i = 0; i < length; i += 2) { | ||
uint8Array[i / 2] = parseInt(hexString.substring(i, i + 2), 16) | ||
} | ||
|
||
return uint8Array | ||
} |